/** * Adds a topic to a user's list of email subscriptions and then does a * redirect to the previous page. * this function is called from teh * @param \tx_mmforum_base $forumObj The plugin object * @return string An error message in case the redirect attempt to * the previous page fails. */ static function set(tx_mmforum_base $forumObj) { tx_mmforum_havealook::addSubscription($forumObj, $forumObj->piVars['tid'], $GLOBALS['TSFE']->fe_user->user['uid']); // Redirecting visitor back to previous page $forumObj->redirectToReferrer(); return $forumObj->pi_getLL('subscr.addSuccess') . '<br/>' . $forumObj->pi_getLL('redirect.error') . '<br />'; }
/** * * Creates a new post. * This function creates a new post. Also automatically updates all database counters. * * @author Martin Helmich * @version 2007-07-23 * @param int $topicId The UID of the topic the new post is to be created in * @param int $author The UID of the fe_user creating this post * @param string $text The post's text * @param int $date The date of post creation as unix timestamp * @param string $ip The post author's IP address * @param array $attachments An array of attachments that are to be attached * to this post. * @param boolean $noUpdate Set to TRUE in order to prevent the database counters from * being updated directly after creating this post. 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 $subscribe * @return int/boolean If post creation was successfull, the post's UID is returned, * otherwise FALSE. */ function create_post($topicId, $author, $text, $date, $ip, $attachments = array(), $noUpdate = false, $subscribe = FALSE) { $author = intval($author); // Retrieve forum uid $forumId = $this->getForumUIDByTopic($topicId); if ($forumId === false) { return false; } // Generate post record $insertArray = array('pid' => $this->getFirstPid(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'topic_id' => $topicId, 'forum_id' => $forumId, 'poster_id' => $author, 'post_time' => $date, 'poster_ip' => $ip, 'attachment' => is_array($attachments) ? implode(',', $attachments) : ''); // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertPost'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertPost'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $insertArray = $_procObj->processPostInsertArray($insertArray, $this); } } // Insert post record if (!$this->databaseHandle->exec_INSERTquery('tx_mmforum_posts', $insertArray)) { return false; } // Retrieve post uid $postId = $this->databaseHandle->sql_insert_id(); // Update attachment record if (is_array($attachments) && count($attachments)) { $this->databaseHandle->exec_UPDATEquery('tx_mmforum_attachments', 'uid IN (' . implode(',', $attachments) . ')', array('post_id' => $postId)); } // Generate post text record $insertArray = array('pid' => $this->getFirstPid(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'post_id' => $postId, 'post_text' => $text, 'cache_text' => $text); // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertPostText'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['postfactory']['insertPostText'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $insertArray = $_procObj->processPostTextInsertArray($insertArray, $this); } } // Insert post text record if (!$this->databaseHandle->exec_INSERTquery('tx_mmforum_posts_text', $insertArray)) { $this->databaseHandle->exec_DELETEquery('tx_mmforum_posts', 'uid = ' . $postId); return false; } // Clear topic for indexing if (class_exists('tx_mmforum_indexing')) { tx_mmforum_indexing::delete_topic_ind_date($topicId); } // Send notification email to users who have subscribed this topic if ($this->parent != null) { // Subscribe to the topic if ($subscribe) { $this->tx_mmforum_havealook->addSubscription($this->parent, $topicId, $author); } $this->tx_mmforum_havealook->notifyTopicSubscribers($topicId, $this->parent); } // Set topic for all users to "not read" $this->databaseHandle->exec_DELETEquery('tx_mmforum_postsread', 'topic_id = ' . $topicId); // Update topic and forum post counters if (!$noUpdate) { $this->updateTopicPostCount($topicId); $this->updateForumPostCount($forumId); $this->updateUserPostCount($author); } else { $this->updateQueue_addTopic($topicId); $this->updateQueue_addForum($forumId); $this->updateQueue_addUser($author); } return $postId; }
/** * 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); }