2002-07-26 12:26:22 +00:00
|
|
|
checkIfLoggedIn(this.href(req.action));
|
|
|
|
|
2002-09-11 14:40:46 +00:00
|
|
|
var denied = this.isDenied(session.user);
|
|
|
|
if (denied) {
|
|
|
|
res.message = denied;
|
2002-07-26 12:26:22 +00:00
|
|
|
res.redirect(path.site.href());
|
|
|
|
}
|
|
|
|
|
2002-09-11 14:40:46 +00:00
|
|
|
if (this._parent.isEditDenied(session.user)) {
|
|
|
|
res.data.title = path.site.title + " - Shortcuts";
|
|
|
|
res.data.body = this.renderSkinAsString("main");
|
|
|
|
path.site.renderSkin("page");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-07-26 12:26:22 +00:00
|
|
|
// check if the shortcut list was submitted
|
|
|
|
if (req.data.submit || req.data.submit == "submit") {
|
|
|
|
for (var i=this.size()-1; i>=0; i--) {
|
|
|
|
var sc = this.get(i);
|
|
|
|
var content = req.data["content" + i];
|
|
|
|
// delete a shortcut if it's content is empty
|
|
|
|
if (!content) {
|
|
|
|
this.remove(sc);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sc.title = req.data["title" + i];
|
|
|
|
sc.content = content;
|
|
|
|
sc.modifytime = new Date();
|
|
|
|
}
|
2002-09-11 14:40:46 +00:00
|
|
|
// add a shortcut if the corresponding fields are not empty
|
2002-07-26 12:26:22 +00:00
|
|
|
if (req.data.newtitle && req.data.newcontent) {
|
|
|
|
// check if there is not already a shortcut with that name
|
|
|
|
if (!this.get(req.data.newtitle)) {
|
|
|
|
var sc = new shortcut();
|
|
|
|
sc.title = req.data.newtitle;
|
|
|
|
sc.content = req.data.newcontent;
|
|
|
|
sc.creator = session.user;
|
|
|
|
sc.site = path.site;
|
|
|
|
sc.createtime = new Date();
|
|
|
|
sc.modifytime = sc.createtime;
|
|
|
|
this.add(sc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res.message = "This shortcut already exists.";
|
|
|
|
}
|
|
|
|
res.redirect(this.href());
|
|
|
|
}
|
|
|
|
|
2002-07-26 15:52:24 +00:00
|
|
|
res.data.action = this.href();
|
2002-07-26 12:26:22 +00:00
|
|
|
res.data.title = path.site.title + " - Shortcuts";
|
2002-09-11 14:40:46 +00:00
|
|
|
res.data.body = this.renderSkinAsString("edit");
|
2002-07-26 12:26:22 +00:00
|
|
|
path.site.renderSkin("page");
|