コード例 #1
0
 /**
  * Preforms a single voting process.
  * This function preforms a single voting process (i.e. when a user
  * selects an answer possibility in the post listing view and hits "Vote!").
  * The fact that this user voted on this poll is stored into the database.
  *
  * @version 2008-04-07
  * @return  void
  */
 function objVote()
 {
     $answer_id = $this->piVars['poll']['answer'];
     $poll_id = $this->data['uid'];
     $user_id = $GLOBALS['TSFE']->fe_user->user['uid'];
     if (!$this->getMayVote()) {
         return;
     }
     $answer_id = intval($answer_id);
     $poll_id = intval($poll_id);
     if (!$answer_id) {
         return;
     }
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_polls', 'uid=' . $poll_id . ' AND deleted=0', array('votes' => 'votes + 1'));
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_polls_answers', 'uid=' . $answer_id . ' AND deleted=0', array('votes' => 'votes + 1'));
     $insertArray = array('pid' => $this->p->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'poll_id' => $poll_id, 'answer_id' => $answer_id, 'user_id' => $user_id);
     $this->databaseHandle->exec_INSERTquery('tx_mmforum_polls_votes', $insertArray);
     $this->data['votes']++;
 }
コード例 #2
0
 /**
  *
  * Saves changes made to either an existing or a newly created forum to the
  * datbase.
  *
  * @access private
  * @return Array An array that contains a status code and validation errors, if
  *               some occured.
  */
 function saveEditAction()
 {
     $forum = $this->v['forum'];
     $forumUid = intval($this->v['editForum']);
     $validationResult = $this->forumValidator->validateEditObject($forumUid, $forum);
     if (!$this->checkActionAllowance($forum['parent'] == 0 ? 'category' : 'forum', $forumUid == -1 ? 'create' : 'edit')) {
         return $this->displayNoAccessError();
     }
     if ($validationResult['error']) {
         return array('success' => FALSE, 'errors' => $validationResult['errors'], 'overrideValues' => $forum);
     }
     $saveArray = array('tstamp' => $GLOBALS['EXEC_TIME'], 'forum_name' => $forum['name'], 'forum_desc' => $forum['description'], 'parentID' => $forum['parent'], 'hidden' => $forum['hidden'] ? 1 : 0);
     if ($forumUid == -1) {
         $saveArray['pid'] = $this->p->getStoragePID();
         $saveArray['crdate'] = $GLOBALS['EXEC_TIME'];
         $saveArray['sorting'] = $this->getSortingForNewForum($forum['parent']);
         $this->databaseHandle->exec_INSERTquery('tx_mmforum_forums', $saveArray);
     } else {
         $this->databaseHandle->exec_UPDATEquery('tx_mmforum_forums', 'uid=' . intval($forumUid), $saveArray);
     }
     return array('success' => TRUE);
 }
コード例 #3
0
 /**
  * Adds a topic to a (logged in) user's list of email subscriptions.
  *
  * @param  \tx_mmforum_base $forumObj The plugin object
  * @param  string $topicId The topic identifier
  * @param $feUserId
  * @return bool             Whether it worked or not
  */
 function addSubscription(\tx_mmforum_base $forumObj, $topicId, $feUserId)
 {
     $feUserId = intval($feUserId);
     $topicId = intval($topicId);
     if ($feUserId && $topicId) {
         // Executing database operations
         $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . $topicId . $forumObj->getStoragePIDQuery());
         if ($this->databaseHandle->sql_num_rows($res) < 1) {
             $insertData = array('pid' => $forumObj->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'topic_id' => $topicId, 'user_id' => $feUserId);
             return $this->databaseHandle->exec_INSERTquery('tx_mmforum_topicmail', $insertData);
         } else {
             // it's already added, so "it worked"
             return true;
         }
     }
     // invalid parameters
     return false;
 }