public function copyPoll($tid, $newTid)
 {
     list($poll, $pollOption, $pollVoter) = $this->initInfo($tid);
     if (!$poll) {
         return;
     }
     Wind::import('SRV:poll.dm.PwPollDm');
     $pollDm = new PwPollDm();
     /* @var $pollDm PwPollDm */
     $pollDm->setVoterNum($poll['voter_num']);
     $pollDm->setIsViewResult($poll['isafter_view']);
     $pollDm->setIsIncludeImg($poll['isinclude_img']);
     $pollDm->setOptionLimit($poll['option_limit']);
     $pollDm->setRegtimeLimit($poll['regtime_limit']);
     $pollDm->setCreatedUserid($poll['created_userid']);
     $pollDm->setAppType($poll['app_type']);
     $pollDm->setExpiredTime($poll['expired_time']);
     $newPollid = $this->_getPollDS()->addPoll($pollDm);
     $optionVoter = array();
     foreach ($pollVoter as $value) {
         $optionVoter[$value['option_id']][] = $value['uid'];
     }
     Wind::import('SRV:poll.dm.PwPollOptionDm');
     foreach ($pollOption as $key => $value) {
         $pollOptionDm = new PwPollOptionDm();
         $pollOptionDm->setPollid($newPollid);
         $pollOptionDm->setVotedNum($value['voted_num']);
         $pollOptionDm->setContent($value['content']);
         $pollOptionDm->setImage($value['image']);
         $newOptionid = $this->_getPollOptionDs()->add($pollOptionDm);
         if (isset($optionVoter[$key]) && is_array($optionVoter[$key])) {
             $this->copyVoter($optionVoter[$key], $newPollid, $newOptionid);
         }
     }
     Wind::import('SRV:poll.dm.PwThreadPollDm');
     $threadPollDm = new PwThreadPollDm();
     $threadPollDm->setTid($newTid);
     $threadPollDm->setPollid($newPollid);
     $threadPollDm->setCreatedUserid($poll['created_userid']);
     $this->_getThreadPollDs()->addPoll($threadPollDm);
     return true;
 }
Exemplo n.º 2
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;
 }