예제 #1
0
파일: EditPoll.php 프로젝트: sinfocol/gwf3
 public function onEdit(GWF_VoteMulti $poll, GWF_User $user)
 {
     $form = $this->getForm($poll, $user);
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors;
     }
     $global = isset($_POST['public']);
     if ($global && !Module_Votes::mayAddGlobalPoll($user)) {
         return $this->module->error('err_global_poll');
     }
     $options = 0;
     $options |= $global ? 0 : GWF_VoteMulti::INTERNAL_VOTE;
     $options |= isset($_POST['enabled']) ? GWF_VoteMulti::ENABLED : 0;
     $options |= isset($_POST['guest']) ? GWF_VoteMulti::GUEST_VOTES : 0;
     $options |= isset($_POST['multi']) ? GWF_VoteMulti::MULTIPLE_CHOICE : 0;
     $options |= $form->getVar('view');
     if (false === $poll->saveVars(array('vm_title' => $form->getVar('title'), 'vm_gid' => $form->getVar('gid'), 'vm_level' => $form->getVar('level'), 'vm_options' => $options))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_poll_edit');
 }
예제 #2
0
파일: Polls.php 프로젝트: sinfocol/gwf3
 private function templatePolls()
 {
     $ipp = 25;
     $t = GDO::table('GWF_VoteMulti');
     $user = GWF_Session::getUser();
     $conditions = GWF_VoteMulti::permqueryRead($user);
     $nItems = $t->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(intval(Common::getGet('page')), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $by = Common::getGet('by', 'vm_date');
     $dir = Common::getGet('dir', 'DESC');
     $orderby = $t->getMultiOrderby($by, $dir);
     $polls = $t->selectObjects('*', $conditions, $orderby, $ipp, $from);
     foreach ($polls as $poll) {
         $poll instanceof GWF_VoteMulti;
         $poll->loadVoteOptions();
     }
     $tVars = array('page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'poll_overview/by/' . urlencode($by) . '/' . urlencode($dir) . '/page-%PAGE%'), 'polls' => $polls, 'sort_url' => GWF_WEB_ROOT . 'poll_overview/by/%BY%/%DIR%/page-1', 'may_add_poll' => Module_Votes::mayAddPoll($user), 'href_add_poll' => GWF_WEB_ROOT . 'poll/add');
     return $this->module->templatePHP('polls.php', $tVars);
 }
예제 #3
0
 /**
  * Get a select for result viewmode.
  * @param Module_Votes $module
  * @param string $name
  * @return string html select
  */
 public static function getViewSelect(Module_Votes $module, $name = 'view', $selected = self::SHOW_RESULT_VOTED)
 {
     $data = array(array(self::SHOW_RESULT_NEVER, $module->lang('vmview_never')), array(self::SHOW_RESULT_VOTED, $module->lang('vmview_voted')), array(self::SHOW_RESULT_ALWAYS, $module->lang('vmview_allways')));
     return GWF_Select::display($name, $data, $selected);
 }
예제 #4
0
 /**
  * Create voting table.
  * @param Module_Download $module
  * @return boolean
  */
 public function createVotes(Module_Download $module)
 {
     if (false === ($votes = Module_Votes::installVoteScoreTable('dl_' . $this->getVar('dl_id'), $module->cfgMinVote(), $module->cfgMaxVote(), $module->cfgGuestVote()))) {
         return false;
     }
     if (false === $this->saveVar('dl_voteid', $votes->getID())) {
         return false;
     }
     $this->setVar('dl_voteid', $votes);
     return true;
 }
예제 #5
0
파일: GWF_Links.php 프로젝트: sinfocol/gwf3
 public function installVotes(Module_Links $module)
 {
     $link_id = $this->getID();
     $minvote = $module->cfgVoteMin();
     $maxvote = $module->cfgVoteMax();
     $guestvotes = $module->cfgGuestVotes();
     if (false === ($vs = Module_Votes::installVoteScoreTable('link_' . $link_id, $minvote, $maxvote, $guestvotes))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $this->saveVar('link_voteid', $vs->getID())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $this->setVar('link_voteid', $vs);
     return false;
 }
예제 #6
0
파일: AddPoll.php 프로젝트: sinfocol/gwf3
 private function onAddPoll()
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateAddPoll();
     }
     $opts = Common::getPostArray('opt', array());
     if (count($opts) === 0) {
         return $this->module->error('err_no_options') . $this->templateAddPoll();
     }
     $user = GWF_Session::getUser();
     $name = GWF_VoteMulti::createPollName(GWF_Session::getUser());
     $title = $form->getVar('title');
     $gid = $form->getVar('gid');
     $level = $form->getVar('level');
     $reverse = isset($_POST['reverse']);
     $is_multi = isset($_POST['multi']);
     $guest_votes = isset($_POST['guests']);
     $is_public = isset($_POST['public']);
     $result = (int) $form->getVar('view');
     if ($is_public && !$this->module->mayAddGlobalPoll($user)) {
         return $this->module->error('err_global_poll') . $this->templateAddPoll();
     }
     GWF_Session::remove(self::SESS_OPTIONS);
     return Module_Votes::installPollTable($user, $name, $title, $opts, $gid, $level, $is_multi, $guest_votes, $is_public, $result, $reverse);
 }
예제 #7
0
파일: AddPoll.php 프로젝트: sinfocol/gwf3
 private function template()
 {
     $form = $this->getForm();
     $tVars = array('may_add_poll' => Module_Votes::mayAddPoll($this->user), 'href_add' => Module_Votes::hrefAddPoll(), 'form' => $form->templateY($this->module->lang('ft_add_poll')));
     return $this->module->templatePHP('add_poll.php', $tVars);
 }
예제 #8
0
파일: WC_Site.php 프로젝트: sinfocol/gwf3
 public function onCreateVotes()
 {
     $sid = $this->getID();
     if (false === ($votes = Module_Votes::installVoteScoreTable('site_dif_' . $sid, 1, 5, false, false, GWF_VoteScore::SHOW_RESULT_ALWAYS))) {
         return false;
     } else {
         $this->saveVar('site_vote_dif', $votes->getID());
         $this->setVar('site_vote_dif', $votes);
     }
     if (false === ($votes = Module_Votes::installVoteScoreTable('site_fun_' . $sid, 1, 5, false, false, GWF_VoteScore::SHOW_RESULT_ALWAYS))) {
         return false;
     } else {
         $this->saveVar('site_vote_fun', $votes->getID());
         $this->setVar('site_vote_fun', $votes);
     }
     return true;
 }