/** * 投票帖子的接收投票接口 * @access public * @return string <pre> /index.php?m=native&c=vote&_json=1 post: apptype=0&typeid=帖子id&optionid[]=投票值 response: {err:"",data:""} </pre> */ public function run() { // var_dump($_POST);exit; if (!$this->loginUser->getPermission('allow_participate_vote')) { $this->showError('VOTE:group.not.allow.participate'); } list($appType, $typeid, $optionid) = $this->getInput(array('apptype', 'typeid', 'optionid')); if (empty($optionid) || !is_array($optionid)) { $this->showError('VOTE:not.select.option'); } $poll = $this->_serviceFactory($appType, $typeid); if (($result = $poll->check()) !== true) { $this->showError($result->getError()); } if (!$poll->isInit()) { $this->showError('VOTE:thread.not.exist'); } if ($poll->isExpired()) { $this->showError('VOTE:vote.activity.end'); } $regtimeLimit = $poll->getRegtimeLimit(); if ($regtimeLimit && $this->loginUser->info['regdate'] > $regtimeLimit) { $this->showError(array('VOTE:vote.regtime.limit', array('{regtimelimit}' => pw::time2str($regtimeLimit, 'Y-m-d')))); } if (($result = $this->_getPollService()->doVote($this->loginUser->uid, $poll->info['poll_id'], $optionid)) !== true) { $this->showError($result->getError()); } $this->showMessage('VOTE:vote.success'); }
/** * (non-PHPdoc) * @see PwTagAction::getContents() */ public function getContents($ids) { $threads = $this->_getThreadDs()->fetchThread($ids, PwThread::FETCH_ALL); $array = array(); if ($threads) { $fids = array(); foreach ($threads as $v) { $fids[] = $v['fid']; } $user = Wekit::getLoginUser(); $forums = $this->_getForumDs()->fetchForum($fids); $forbidFids = $this->getForbidVisitForum($user, $forums); $lang = Wind::getComponent('i18n'); foreach ($threads as $k => $v) { if ($v['disabled'] > 0) { $content = $lang->getMessage('BBS:forum.thread.disabled'); $v['subject'] = $content; $v['content'] = $content; } elseif (in_array($v['fid'], $forbidFids)) { $content = $lang->getMessage('BBS:forum.thread.right.error'); $v['subject'] = $content; $v['content'] = $content; } $v['forum_name'] = $forums[$v['fid']]['name']; $v['created_time_auto'] = pw::time2str($v['created_time'], 'auto'); $v['type_id'] = $forums[$v['fid']]['name']; $array[$k] = $v; } } return $array; }