/** * this function allows to add a choice to a give poll * @post all parameters from argpost * returns true if choice was added with success **/ function UpdateChoice($post) { $words = new MOD_words(); $IdPoll = $post['IdPoll']; $IdPollChoice = $post['IdPollChoice']; $rPoll = $this->singleLookup("select * from polls where id=" . $IdPoll . " /* UpdatedChoice */"); if (empty($rPoll->id) or $rPoll->Status == 'Open') { $sLog = "it is not possible to change The possible choices for poll #" . $rPoll->id . " because it is an Open one or there is no such a poll"; MOD_log::get()->write($sLog, "polls"); } if (!(isset($_SESSION["IdMember"]) and $rPoll->IdCreator == $_SESSION["IdMember"] and $rPoll->Status == "Projet" or MOD_right::get()->HasRight("Poll", "update"))) { MOD_log::get()->write("Forbidden to update poll choice for poll #" . $IdPoll, "polls"); die("Sorry forbidden for you"); } $rPollChoice = $this->singleLookup("select * from polls_choices where id=" . $IdPollChoice . " /* UpdatedChoice*/"); $ss = $this->dao->escape($post['ChoiceText']); $words->ReplaceInFTrad($ss, "polls_choices.IdChoiceText", $rPollChoice->id, $rPollChoice->IdChoiceText); MOD_log::get()->write("pollchoice : update to <b>" . $post["ChoiceText"] . "</b> IdPollChoice=#" . $IdPollChoice . " for poll #" . $IdPoll, "polls"); return true; }