コード例 #1
0
ファイル: VotePoll.php プロジェクト: sinfocol/gwf3
 private function onVote(GWF_VoteMulti $poll, $user)
 {
     $opts = Common::getPostArray('opt', array());
     $taken = array();
     $max = $poll->getNumChoices();
     foreach ($opts as $i => $stub) {
         $i = (int) $i;
         if ($i < 1 || $i > $max) {
             continue;
         }
         if (!in_array($i, $taken, true)) {
             $taken[] = $i;
         }
     }
     $count = count($taken);
     //		if ($count === 0) {
     //			return $this->module->error('err_no_options');
     //		}
     if (!$poll->isMultipleChoice() && $count !== 1) {
         return $this->module->error('err_no_multi');
     }
     if (false === $poll->onVote($user, $taken)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_voted', array(htmlspecialchars(GWF_Session::getLastURL())));
 }