/**
  *
  * Creates a new topic.
  * This function creates a new topic. Also automatically creates the first posts
  * of this topic and updates all database counters.
  *
  * @author  Martin Helmich
  * @version 2009-02-05
  * @param   int     $forumId     The UID of the forum the new topic is to be created in
  * @param   int     $author      The UID of the fe_user creating this topic
  * @param   string  $subject     The topic's subject
  * @param   string  $text        The topic's first post's text
  * @param   int     $date        The date of topic creation as unix timestamp
  * @param   string  $ip          The topic author's IP address
  * @param   array   $attachments An array of attachments that are to be attached
  *                               to the topic's first post.
  * @param   int     $poll        The UID of the poll that is to be attached to the topic.
  *                               Set 0 for no poll.
  * @param   boolean $subscribe
  * @param   boolean $noUpdate    Set to TRUE in order to prevent the database counters from
  *                               being updated directly after creating this topic. Instead,
  *                               the elements to be updated will be stored in an "update queue"
  *                               and will be updated after all posts/topics have been created.
  *                               This minimizes database load.
  * @param   boolean $notifyForumSubscribers
  * @return  int/boolean          If topic creation was successfull, the topic's UID is returned,
  *                               otherwise FALSE.
  */
 function create_topic($forumId, $author, $subject, $text, $date, $ip, $attachments = array(), $poll = 0, $subscribe = false, $noUpdate = false, $notifyForumSubscribers = true)
 {
     // Generate topic record
     $insertArray = array('pid' => $this->getFirstPid(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'topic_title' => $subject, 'topic_poster' => $author, 'topic_time' => $date, 'forum_id' => $forumId, 'poll_id' => $poll);
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertTopic'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertTopic'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $insertArray = $_procObj->processTopicInsertArray($insertArray, $this);
         }
     }
     // Insert topic record
     if (!$this->databaseHandle->exec_INSERTquery('tx_mmforum_topics', $insertArray)) {
         return false;
     }
     // Retrieve topic uid
     $topicId = $this->databaseHandle->sql_insert_id();
     // Generate post record
     $postId = $this->create_post($topicId, $author, $text, $date, $ip, $attachments, $noUpdate);
     if ($postId === false) {
         $this->databaseHandle->exec_DELETEquery('tx_mmforum_topics', 'uid = ' . $topicId);
         return false;
     }
     // Update first post record
     $updateData = array('topic_first_post_id' => $postId);
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'uid = ' . $topicId, $updateData);
     // Subscribe the author to the topic
     if ($subscribe) {
         $this->tx_mmforum_havealook->addSubscription($this->parent, $topicId, $author);
     }
     //added by Cyrill Helg
     // Send notification email to users who have subscribed the forum where this topic is created
     if ($notifyForumSubscribers) {
         $this->tx_mmforum_havealook->notifyForumSubscribers($topicId, $forumId, $this->parent);
     }
     return $topicId;
 }
예제 #2
0
 /**
  * Sends an e-mail to users who have subscribed to certain forumcategory
  * @param  string $content The plugin content
  * @param  array  $conf    The configuration vars
  * @param  int    $topic_id   The UID of the new topic that was created
  * @param  int    $forum_id   The UID of the forum about which the users are
  *                        to be alerted.
  * @return void
  * @author Cyrill Helg
  * @deprecated since 0.1.8, please use the direct call to the static function
  */
 function send_newpost_mail_forum($content, $conf, $topicId, $forumId)
 {
     GeneralUtility::logDeprecatedFunction();
     tx_mmforum_havealook::notifyForumSubscribers($topicId, $forumId, $this);
 }