コード例 #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())));
 }
コード例 #2
0
ファイル: EditPoll.php プロジェクト: sinfocol/gwf3
 private function getForm(GWF_VoteMulti $poll, GWF_User $user)
 {
     $data = array();
     $data['title'] = array(GWF_Form::STRING, $poll->getVar('vm_title'), $this->module->lang('th_title'));
     $data['guest'] = array(GWF_Form::CHECKBOX, $poll->isGuestVoteAllowed(), $this->module->lang('th_guests'));
     $data['multi'] = array(GWF_Form::CHECKBOX, $poll->isMultipleChoice(), $this->module->lang('th_multi'));
     $data['enabled'] = array(GWF_Form::CHECKBOX, $poll->isEnabled(), $this->module->lang('th_enabled'));
     if (Module_Votes::mayAddGlobalPoll(GWF_Session::getUser())) {
         $data['public'] = array(GWF_Form::CHECKBOX, $poll->isGlobal(), $this->module->lang('th_vm_public'));
     }
     $data['view'] = array(GWF_Form::SELECT, GWF_VoteMulti::getViewSelect($this->module, 'view', $poll->getViewFlag()), $this->module->lang('th_mvview'));
     $data['gid'] = array(GWF_Form::SELECT, GWF_GroupSelect::single('gid', $poll->getGroupID(), true, true), $this->module->lang('th_vm_gid'));
     $data['level'] = array(GWF_Form::INT, $poll->getLevel(), $this->module->lang('th_vm_level'));
     $data['edit'] = array(GWF_Form::SUBMIT, $this->module->lang('btn_edit'));
     return new GWF_Form($this, $data);
 }