/** * 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. */ function camp_comment_first_post($p_article, $p_forumId) { // Check if the first post already exists. $articleNumber = $p_article->getArticleNumber(); $languageId = $p_article->getLanguageId(); $firstPostId = ArticleComment::GetCommentThreadId($articleNumber, $languageId); if ($firstPostId) { $firstPost = new Phorum_message($firstPostId); if ($firstPost->exists()) { return $firstPost; } // Unlink the message from the current article. ArticleComment::Unlink($articleNumber, $languageId, $firstPostId); } // 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 false; } } 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 false; } } // fn camp_comment_first_post
/** * This function should be called whenever an article is deleted. * * @param int $p_articleNumber * @param int $p_languageId * @return void */ public static function OnArticleDelete($p_articleNumber, $p_languageId) { if (!is_numeric($p_articleNumber) || !is_numeric($p_languageId)) { return; } $threadId = ArticleComment::GetCommentThreadId($p_articleNumber, $p_languageId); // Delete all comments for this article $threadHead = new Phorum_message($threadId); $threadHead->delete(PHORUM_DELETE_TREE); // Delete all links to this article. ArticleComment::Unlink($p_articleNumber, $p_languageId); } // fn OnArticleDelete
$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"); ?>
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 base message. if ($comment->getMessageId() != $comment->getThreadId()) { $comment->delete(); ArticleComment::Unlink($articleObj->getArticleNumber(), $articleObj->getLanguageId(), $messageId); } break; case "approve": $comment->setStatus(PHORUM_STATUS_APPROVED); break; } } } if (!empty($_REQUEST['isAjax'])) { echo json_encode(true); exit; }