/** * Create the first message for an article, which is a blank message * with the title of the article as the subject. * * @param Article $p_article * @param int $p_forumId * @return mixed * The comment created (or the one that already exists) on success, * or false on error. */ private function CreateFirstComment($p_article, $p_forumId) { // Check if the first post already exists. $articleNumber = $p_article->getArticleNumber(); $languageId = $p_article->getLanguageId(); $firstPost = ArticleComment::GetCommentThreadId($articleNumber, $languageId); if ($firstPost) { return new Phorum_message($firstPost); } // Get article creator $user = new User($p_article->getCreatorId()); if ($user->exists()) { $userId = $user->getUserId(); $userEmail = $user->getEmail(); $userPasswd = $user->getPassword(); $userName = $user->getUserName(); $userRealName = $user->getRealName(); // Create phorum user if necessary $phorumUser = Phorum_user::GetByUserName($userName); if (!is_object($phorumUser)) { $phorumUser = new Phorum_user(); } if (!$phorumUser->CampUserExists($userId) && !$phorumUser->create($userName, $userPasswd, $userEmail, $userId)) { return null; } } else { $userId = null; $userEmail = ''; $userRealName = ''; } // Create the comment. $title = $p_article->getTitle(); $commentObj = new Phorum_message(); if ($commentObj->create($p_forumId, $title, '', 0, 0, $userRealName, $userEmail, is_null($userId) ? 0 : $userId)) { // Link the message to the current article. ArticleComment::Link($articleNumber, $languageId, $commentObj->getMessageId(), true); return $commentObj; } else { return null; } } // method CreateFirstComment
function testUpdateThreadInfo() { // Create thread start. $message = new Phorum_message(); $message->create(1, 'delete me'); $messageId = $message->getMessageId(); // add message to the thread. $message2 = new Phorum_message(); $message2->create(1, "delete me", "wow", $messageId, $messageId); $message->fetch(); $threadCount = $message->getNumMessagesInThread(); $message2->delete(); $message->fetch(); $threadCount2 = $message->getNumMessagesInThread(); if ($threadCount != ($threadCount2 + 1)) { $this->fail("Thread stats not updated correctly."); } }
$parts = explode("_", $name); $messageId = $parts[2]; $comment = new Phorum_message($messageId); if (!$comment->exists()) { continue; } switch ($value) { case "inbox": $comment->setStatus(PHORUM_STATUS_HOLD); break; case "hide": $comment->setStatus(PHORUM_STATUS_HIDDEN); break; case "delete": // Not allowed to delete first post. if ($comment->getMessageId() != $comment->getThreadId()) { $comment->delete(); ArticleComment::Unlink(null, null, $messageId); } break; case "approve": $comment->setStatus(PHORUM_STATUS_APPROVED); break; } $subjectStr = Input::Get('f_subject_'.$messageId, 'string', '', true); $comment->setSubject($subjectStr); $commentStr = Input::Get('f_comment_'.$messageId, 'string', '', true); $comment->setBody($commentStr); } } camp_html_goto_page("/$ADMIN/comments/index.php");