Beispiel #1
0
 public function handler_ajax_vote($page)
 {
     $json = json_decode(Env::v('json'));
     $vote = intval($json->{'vote'});
     $qdj = QDJ::last(0);
     $already_voted = $qdj->hasVoted(S::user()->id());
     if (!$already_voted) {
         $qdj->vote($vote);
     } else {
         $page->jsonAssign('error', 'Tu as déjà voté');
     }
     $page->jsonAssign('success', !$already_voted);
     return PL_JSON;
 }
Beispiel #2
0
 public function run()
 {
     $qdj = QDJ::last();
     $this->assign('qdj', $qdj);
     $this->assign('votes', $qdj->last_votes());
 }