示例#1
0
 /**
 * 投票帖子的接收投票接口
 * @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');
 }
示例#2
0
 /**
  * (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;
 }
示例#3
0
 /**
  * 添加
  *
  * @param int $userid
  * @param int $pollid
  * @param int $optionid
  * @return int
  */
 public function add($userid, $pollid, $optionid)
 {
     $userid = intval($userid);
     $pollid = intval($pollid);
     $optionid = intval($optionid);
     if (!$userid || !$pollid || !$optionid) {
         return false;
     }
     $fieldData = array('uid' => $userid, 'poll_id' => $pollid, 'option_id' => $optionid, 'created_time' => pw::getTime());
     return $this->_getPollVoterDao()->add($fieldData);
 }
示例#4
0
 /**
  * 
  * 获取热门话题
  * @param ing $categoryId
  * @param ing $num
  */
 public function getHotTagsNoCache($categoryId = 0, $num = 100)
 {
     // 删除过期数据
     $updateTime = pw::getTime() - 86400 * $this->expireDay;
     $this->_getTagDs()->deleteExpireHotTag($updateTime);
     $tags = $this->_getTagDs()->getCountHotTag($categoryId, $num);
     $tagIds = array_keys($tags);
     if (!$tagIds) {
         return array();
     }
     return $this->_getTagDs()->fetchTag($tagIds);
 }
示例#5
0
 public function doimportAction()
 {
     Wind::import('SRV:upload.action.PwWordUpload');
     Wind::import('LIB:upload.PwUpload');
     $bhv = new PwWordUpload();
     $upload = new PwUpload($bhv);
     if (($result = $upload->check()) === true) {
         $result = $upload->execute();
     }
     if ($result !== true) {
         $error = $result->getError();
         if (is_array($error)) {
             list($error, ) = $error;
             if ($error == 'upload.ext.error') {
                 $this->showError('WORD:ext.error');
             }
         }
         $this->showError($result->getError());
     }
     $source = $bhv->getAbsoluteFile();
     if (!WindFile::isFile($source)) {
         $this->showError('operate.fail');
     }
     $content = WindFile::read($source);
     pw::deleteAttach($bhv->dir . $bhv->filename, 0, $bhv->isLocal);
     $content = explode("\n", $content);
     if (!$content) {
         $this->showError('WORD:import.data.empty');
     }
     $wordService = $this->_getWordService();
     $typeMap = $this->_getWordDS()->getTypeMap();
     Wind::import('SRV:word.dm.PwWordDm');
     foreach ($content as $value) {
         list($word, $type, $replace) = $this->_parseTextUseInImport($value, $typeMap);
         if (!$word || !$type || $wordService->isExistWord($word)) {
             continue;
         }
         $dm = new PwWordDm();
         /* @var $dm PwWordDm */
         $dm->setWord($word)->setWordType($type);
         $replace = $this->_getWordDS()->isReplaceWord($type) ? $replace ? $replace : '****' : '';
         $dm->setWordReplace($replace);
         $this->_getWordDS()->add($dm);
     }
     $this->_getWordFilter()->updateCache();
     $this->showMessage('success');
 }
示例#6
0
 public function updatePoll($tid)
 {
     $this->info = $this->getThreadPollBo()->info;
     if ($this->info['poll']['voter_num']) {
         return true;
     }
     if (($attachInfo = $this->uploadOptionImage()) instanceof PwError) {
         return $attachInfo;
     }
     $pollData = $this->poll['poll'];
     Wind::import('SRV:poll.dm.PwPollDm');
     $pollDm = new PwPollDm($this->info['poll_id']);
     /* @var $pwPollDm PwPollDm */
     $pollDm->setIsViewResult($pollData['isviewresult']);
     $pollDm->setOptionLimit($pollData['optionlimit']);
     $pollDm->setRegtimeLimit($pollData['regtimelimit'] ? pw::str2time($pollData['regtimelimit']) : 0);
     $expiredTime = $pollData['expiredday'] ? intval($pollData['expiredday']) * 86400 + $this->info['poll']['created_time'] : 0;
     $pollDm->setExpiredTime($expiredTime);
     $optinNum = $pollData['ismultiple'] ? $this->info['poll']['optionnum'] + count($this->poll['newoption']) : 0;
     $pollDm->setOptionLimit(min($optinNum, $pollData['optionlimit']));
     $attachInfo && $pollDm->setIsIncludeImg(1);
     $this->_getPollDS()->updatePoll($pollDm);
     $this->_updatePollOption($attachInfo);
     return true;
 }