コード例 #1
0
 /**
  * Returns a poll object for a news entry.
  * 
  * @return	\wcf\data\poll\Poll
  */
 public function getPoll()
 {
     if ($this->pollID && !$this->poll) {
         // new poll object
         $this->poll = new Poll($this->pollID);
         if ($this->poll->pollID) {
             $this->poll->setRelatedObject($this);
         } else {
             $this->poll = null;
         }
     }
     return $this->poll;
 }
コード例 #2
0
ファイル: PollAction.class.php プロジェクト: nick-strohm/WCF
 /**
  * Adds a user vote.
  * 
  * @param	array<mixed>	$returnValues
  */
 protected function vote(array &$returnValues)
 {
     $pollAction = new \wcf\data\poll\PollAction(array($this->poll), 'vote', array('optionIDs' => $this->optionIDs));
     $pollAction->executeAction();
     // update poll object
     $polls = PollManager::getInstance()->getPolls(array($this->pollID));
     $this->poll = $polls[$this->pollID];
     if ($this->relatedObject !== null) {
         $this->poll->setRelatedObject($this->relatedObject);
     }
     // render result template
     $this->getResult($returnValues);
     // render vote template if votes are changeable
     if ($this->poll->isChangeable) {
         $this->getVote($returnValues);
     }
     $returnValues['canVote'] = $this->poll->isChangeable ? 1 : 0;
 }