/** * 添加 * * @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); }
public function addPoll($tid) { if (($attachInfo = $this->uploadOptionImage()) instanceof PwError) { return $attachInfo; } $pollData = $this->poll['poll']; $optionData = $this->poll['option']; Wind::import('SRV:poll.dm.PwPollDm'); $pollDm = new PwPollDm(); /* @var $pwPollDm PwPollDm */ $pollDm->setIsViewResult($pollData['isviewresult']); $pollDm->setOptionLimit($pollData['optionlimit']); $pollDm->setCreatedUserid($this->user->uid); $pollData['regtimelimit'] && $pollDm->setRegtimeLimit(pw::str2time($pollData['regtimelimit'])); $expiredTime = $pollData['expiredday'] ? intval($pollData['expiredday']) * 86400 + pw::getTime() : 0; $pollDm->setExpiredTime($expiredTime); $optinNum = $pollData['ismultiple'] ? count($optionData) : 0; $pollDm->setOptionLimit(min($optinNum, $pollData['optionlimit'])); $attachInfo && $pollDm->setIsIncludeImg(1); $newPollid = $this->_getPollDS()->addPoll($pollDm); Wind::import('SRV:poll.dm.PwPollOptionDm'); foreach ($optionData as $key => $value) { if (!$value) { continue; } $dm = new PwPollOptionDm(); /* @var $pwPollDm PwPollDm */ $image = isset($attachInfo['optionpic'][$key]) ? $attachInfo['optionpic'][$key]['path'] : ''; $dm->setContent($value)->setPollid($newPollid)->setImage($image); $this->_getPollOptionDS()->add($dm); } Wind::import('SRV:poll.dm.PwThreadPollDm'); $threadPollDm = new PwThreadPollDm(); /* @var $threadPollDm PwThreadPollDm */ $threadPollDm->setTid($tid)->setPollid($newPollid)->setCreatedUserid($this->user->uid); $this->_getThreadPollDS()->addPoll($threadPollDm); $this->_afterUpdate($newPollid); return true; }
/** * * 获取热门话题 * @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); }