Exemplo n.º 1
0
 case 'vote':
     // child = vote id
     // child2 = option id
     if (!$session->id || !is_numeric($this->child) || !is_numeric($this->child2)) {
         throw new \Exception('XXX');
     }
     Rating::addVote(POLL, $this->child, $this->child2);
     $page->disableDesign();
     echo '1';
     break;
 case 'show':
     //child = poll id
     if (!$this->child) {
         throw new \Exception('no id set');
     }
     $poll = PollItem::get($this->child);
     if (!$poll) {
         die('meh');
     }
     $header = XhtmlHeader::getInstance();
     $header->embedCss('.poll_item{' . 'background-color:#eee;' . 'padding:5px;' . 'cursor:pointer;' . '}');
     $header->includeJs('http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js');
     $header->embedJs('function submit_poll(id,opt)' . '{' . 'YUI().use("io-base", function(Y) {' . 'var uri = "' . relurl('') . 'u/polls/vote/" + id + "/" + opt;' . 'Y.on("io:complete", function(id,o){' . 'var id = id;' . 'var data = o.responseText;' . 'if (data==1) return;' . 'alert("Voting error " + data);' . '});' . 'var request = Y.io(uri);' . '});' . 'hide_el("poll"+id);' . 'show_el("poll_voted"+id);' . '}');
     $active = false;
     if (time() >= ts($poll->time_start) && time() <= ts($poll->time_end)) {
         $active = true;
     }
     if (!$poll->time_start) {
         $active = true;
     }
     echo '<div class="item">';