- rewrote evalNewPoll()

This commit is contained in:
Robert Gaggl 2003-08-02 11:37:03 +00:00
parent b8c677ae50
commit 698c19f9e7

View file

@ -8,43 +8,14 @@
* - url (String): the URL string of the poll * - url (String): the URL string of the poll
* - id (Number): the internal Hop ID of the poll * - id (Number): the internal Hop ID of the poll
*/ */
function evalNewPoll(question, choices, creator) {
function evalNewPoll(param, creator) { if (!question || !choices || choices.length < 2)
var result; throw new Exception("pollMissing");
var choiceInput = param.choice; var newPoll = new poll(question, creator);
if (param.choice_array) {
var choiceCnt = 0;
for (var i=0; i<param.choice_array.length; i++) {
if (param.choice_array[i])
choiceCnt++;
}
}
if (param.question && creator && choiceCnt > 1) {
var newPoll = new poll();
newPoll.site = this._parent;
newPoll.question = param.question;
newPoll.closed = 0;
newPoll.creator = creator;
newPoll.createtime = new Date();
newPoll.modifytime = new Date();
this.add(newPoll); this.add(newPoll);
for (var i=0; i<param.choice_array.length; i++) { for (var i=0; i<choices.length; i++)
var title = param.choice_array[i]; newPoll.add(choices[i]);
if (!title) return new Message("pollCreate");
continue;
var newChoice = new choice();
newChoice.poll = newPoll;
newChoice.title = title;
newChoice.createtime = new Date();
newChoice.modifytime = new Date();
newPoll.add(newChoice);
}
result = getConfirm("pollCreate");
result.error = false;
} else
result = getError("pollMissing");
return(result);
} }
@ -55,23 +26,11 @@ function evalNewPoll(param, creator) {
* - error (boolean): true if error occured, false otherwise * - error (boolean): true if error occured, false otherwise
* - message (String): an error or a confirmation message * - message (String): an error or a confirmation message
*/ */
function deletePoll(currPoll) { function deletePoll(currPoll) {
var result; currPoll.deleteAll();
for (var i=currPoll.size(); i>0; i--) { if (!this.remove(currPoll))
var ch = currPoll.get(i-1); throw new Exception("pollDelete");
for (var n=ch.size(); n>0; n--) { return new Message("pollDelete");
var vt = ch.get(n-1);
ch.remove(vt);
}
currPoll.remove(ch);
}
currPoll.setParent(this._parent);
if (this._parent.remove(currPoll))
result = getConfirm("pollDelete");
else
result = getError("pollDelete");
return (result);
} }
@ -84,8 +43,6 @@ function deletePoll(currPoll) {
*/ */
function closePoll(currPoll) { function closePoll(currPoll) {
var result;
currPoll.closed = 1; currPoll.closed = 1;
result = getConfirm("pollClose"); return new Message("pollClose");
return(result);
} }