Example #1
0
 public function onVoteGuest($ip, array $chosen)
 {
     $pid = $this->getID();
     $eip = self::escape($ip);
     $choices = implode(':', $chosen);
     if (false !== ($row = GWF_VoteMultiRow::getVoteRowGuest($pid, $ip))) {
         if (false === $this->onRevert($row)) {
             return false;
         }
         if (false === GDO::table('GWF_VoteMultiRow')->update("vmr_choices='{$choices}'", "vmr_vmid={$pid} AND vmr_ip='{$eip}'")) {
             return false;
         }
         if (false === $this->onApply($chosen)) {
             return false;
         }
     } else {
         $row = new GWF_VoteMultiRow(array('vmr_vmid' => $pid, 'vmr_uid' => 0, 'vmr_ip' => $ip, 'vmr_time' => time(), 'vmr_choices' => $choices));
         if (false === $row->insert()) {
             return false;
         }
         if (false === $this->onApply($chosen)) {
             return false;
         }
     }
     return true;
 }
Example #2
0
<?php

$p = $tVars['poll'];
$p instanceof GWF_VoteMulti;
$pid = $p->getVar('vm_id');
$o = $p->getChoices();
$total = $p->getVotecount();
$user = GWF_Session::getUser();
$has_voted = $p->hasVoted($user);
$may_vote = $p->mayVote($user);
$may_edit = $p->mayEdit($user);
$reveal = $p->canSeeOutcome($user);
$voterow = $user === false ? GWF_VoteMultiRow::getVoteRowGuest($pid, GWF_IP6::getIP(GWF_IP_QUICK)) : GWF_VoteMultiRow::getVoteRowUser($pid, $user->getID());
?>
<form method="post" action="<?php 
echo htmlspecialchars($tVars['form_action']);
?>
">
<table>
<thead><tr><th colspan="4"><?php 
echo $p->display('vm_title');
?>
</th></tr></thead>
<tr><td colspan="4"><span id="vm_<?php 
echo $pid;
?>
"><?php 
echo $reveal ? $total : '????';
?>
</span>&nbsp;<?php 
echo $tLang->lang('votes');