Пример #1
0
 public function onVoteUser(GWF_User $user, array $chosen)
 {
     $pid = $this->getID();
     $uid = $user->getID();
     $choices = implode(':', $chosen);
     if (false !== ($row = GWF_VoteMultiRow::getVoteRowUser($pid, $uid))) {
         if (false === $this->onRevert($row)) {
             return false;
         }
         if (false === GDO::table('GWF_VoteMultiRow')->update("vmr_choices='{$choices}'", "vmr_vmid={$pid} AND vmr_uid={$uid}")) {
             return false;
         }
         if (count($chosen) > 0) {
             if (false === $this->onApply($chosen)) {
                 return false;
             }
         }
     } elseif (count($chosen) > 0) {
         $row = new GWF_VoteMultiRow(array('vmr_vmid' => $pid, 'vmr_uid' => $uid, 'vmr_ip' => 'NULL', 'vmr_time' => time(), 'vmr_choices' => $choices));
         if (false === $row->insert()) {
             return false;
         }
         if (false === $this->onApply($chosen)) {
             return false;
         }
     }
     return true;
 }
Пример #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');