function update_action($range_id) { $vote_id = self::ensureMD5(Request::option('vote_id')); $choice = self::ensureMD5(Request::option('choice')); $q = \Cliqr\Question::find($vote_id); # no such active question in this range_id if (!$q->isActiveIn($range_id)) { throw new Trails_Exception(400); } $status = $q->recordAnswer($choice); if (Request::isXhr()) { if ($status) { $this->response->set_status(204, "No Content"); return $this->render_nothing(); } else { throw new Trails_Exception(500, "Could not record"); } } else { if ($status) { $this->response->set_status(204, "No Content"); } else { $this->response->set_status(500, "Could not record"); } # TODO $this->render_nothing(); } }
public function before_filter(&$action, &$args) { parent::before_filter($action, $args); $this->cid = self::requireContext(); self::requireAuthorisation($this->cid); // TODO: anders sicherstellen, dass sich #state und #start/stopdate nicht widersprechen Question::consolidateState($this->cid); # find and set question # URL: /cliqr/questions/(show|update|destroy|start|stop)/:question_id if (in_array($action, words("show update destroy start stop"))) { $question_id = self::ensureMD5($args[0]); $this->question = Question::find($question_id); } # else: index create }