64 lines
No EOL
1.5 KiB
Text
64 lines
No EOL
1.5 KiB
Text
checkIfLoggedIn(this.href(req.action));
|
|
|
|
var deny = this.isEditDenied(session.user);
|
|
if (deny) {
|
|
res.message = deny;
|
|
res.redirect(session.data.referrer ? path.site.members.href("login") : this.href());
|
|
}
|
|
|
|
// storing referer in session in case user clicks cancel later
|
|
if (!session.data.referrer && req.data.http_referer)
|
|
session.data.referrer = req.data.http_referer;
|
|
|
|
if (req.data.submit == "cancel" || req.data.cancel) {
|
|
var url = session.data.referrer ? session.data.referrer : this.href();
|
|
session.data.referrer = null;
|
|
res.redirect(url);
|
|
} else if (req.data.submit == "save" || req.data.save) {
|
|
var result = this.evalPoll(req.data, session.user);
|
|
res.message = result.message;
|
|
session.data.referrer = null;
|
|
if (!result.error)
|
|
res.redirect(result.url);
|
|
}
|
|
|
|
var len = 0
|
|
var max = 2;
|
|
var choices = new Array();
|
|
if (!req.data.choice_array) {
|
|
if (req.data.choice) {
|
|
choices[0] = req.data.choice;
|
|
}
|
|
else {
|
|
len = this.size();
|
|
max = len;
|
|
for (var i=0; i<len; i++) {
|
|
choices[i] = this.get(i).title;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
choices = req.data.choice_array;
|
|
len = choices.length;
|
|
max = len;
|
|
}
|
|
|
|
if (req.data.submit == "add choice")
|
|
max++;
|
|
|
|
var c = new choice();
|
|
res.data.choices = "";
|
|
for (var i=0; i<max; i++) {
|
|
var param = new Object();
|
|
param.value = (i < len) ? choices[i] : "";
|
|
param.count = i+1;
|
|
res.data.choices += c.renderSkinAsString("edit", param);
|
|
}
|
|
|
|
res.data.action = this.href(req.action);
|
|
|
|
res.data.command = "Edit";
|
|
res.data.title = path.site.title;
|
|
res.data.body = this.renderSkinAsString("edit");
|
|
|
|
path.site.renderSkin("page"); |