Exemplo n.º 1
0
<?php

//TODO later: allow anonymous polls? then allow 1 vote from each IP
namespace cd;

switch ($this->owner) {
    case 'active':
        echo '<h1>Active polls</h1>';
        $list = PollItem::getActivePolls(SITE);
        //    d($list);
        foreach ($list as $p) {
            echo ahref('u/polls/show/' . $p->id, $p->text) . '<br/>';
        }
        break;
    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) {