本文整理汇总了PHP中CForumTopic::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumTopic::Add方法的具体用法?PHP CForumTopic::Add怎么用?PHP CForumTopic::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumTopic
的用法示例。
在下文中一共展示了CForumTopic::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
public function Execute()
{
if (!CModule::IncludeModule("forum")) {
return CBPActivityExecutionStatus::Closed;
}
if (!CModule::IncludeModule("iblock")) {
return CBPActivityExecutionStatus::Closed;
}
$forumId = intval($this->ForumId);
if ($forumId <= 0) {
return CBPActivityExecutionStatus::Closed;
}
$rootActivity = $this->GetRootActivity();
$documentId = $rootActivity->GetDocumentId();
$iblockId = $this->IBlockId;
$dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID"));
$arResult = $dbResult->Fetch();
if (!$arResult) {
$obProperty = new CIBlockProperty();
$obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum topic", "CODE" => "FORUM_TOPIC_ID"));
$obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum message count", "CODE" => "FORUM_MESSAGE_CNT"));
$dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID"));
$arResult = $dbResult->Fetch();
}
$forumTopicId = intval($arResult["VALUE"]);
$arForumUserTmp = $this->ForumUser;
$arForumUser = CBPHelper::ExtractUsers($arForumUserTmp, $documentId, true);
$forumUserId = 1;
$forumUserName = "Admin";
if ($arForumUser != null) {
$forumUserId = $arForumUser;
$dbResult = CUser::GetByID($forumUserId);
if ($arResult = $dbResult->Fetch()) {
$forumUserName = CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), $arResult, true);
}
}
$newTopic = "N";
if ($forumTopicId <= 0) {
$documentService = $this->workflow->GetService("DocumentService");
$document = $documentService->GetDocument($documentId);
$newTopic = "Y";
$arFields = array("TITLE" => $document["NAME"], "FORUM_ID" => $forumId, "USER_START_ID" => $forumUserId, "USER_START_NAME" => $forumUserName, "LAST_POSTER_NAME" => $forumUserName, "APPROVED" => "Y");
$forumTopicId = CForumTopic::Add($arFields);
CIBlockElement::SetPropertyValues($documentId[2], $iblockId, $forumTopicId, "FORUM_TOPIC_ID");
}
$arFields = array("POST_MESSAGE" => $this->ForumPostMessage, "AUTHOR_ID" => $forumUserId, "AUTHOR_NAME" => $forumUserName, "FORUM_ID" => $forumId, "TOPIC_ID" => $forumTopicId, "APPROVED" => "Y", "NEW_TOPIC" => $newTopic, "PARAM2" => $documentId[2]);
$forumMessageId = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
return CBPActivityExecutionStatus::Closed;
}
示例2: array
} else {
$authorName = "admin";
}
$arForums = array(array("XML_ID" => "NEWS_COMMENTS", "NAME" => GetMessage("NEWS_COMMENTS_FORUM_NAME"), "DESCRIPTION" => GetMessage("NEWS_COMMENTS_FORUM_DESCRIPTION"), "SORT" => 2, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "DEDUPLICATION" => "N", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["COMMENTS"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "M", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y")), array("XML_ID" => "PHOTOGALLERY_COMMENTS", "NAME" => GetMessage("PHOTOGALLERY_COMMENTS_FORUM_NAME"), "DESCRIPTION" => GetMessage("PHOTOGALLERY_COMMENTS_FORUM_DESCRIPTION"), "SORT" => 3, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "DEDUPLICATION" => "N", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "M", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y")), array("XML_ID" => "USERS_AND_GROUPS", "NAME" => GetMessage("USERS_AND_GROUPS_FORUM_NAME"), "DESCRIPTION" => GetMessage("USERS_AND_GROUPS_FORUM_DESCRIPTION"), "SORT" => 4, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "A", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "DEDUPLICATION" => "N", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array(WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y")), array("XML_ID" => "DOCS_SHARED_COMMENTS", "NAME" => GetMessage("DOCS_SHARED_COMMENTS_NAME"), "DESCRIPTION" => GetMessage("DOCS_SHARED_COMMENTS_DECRIPTION"), "SORT" => 5, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "DEDUPLICATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "M", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y")), array("XML_ID" => "DOCS_SALES_COMMENTS", "NAME" => GetMessage("DOCS_SALES_COMMENTS_NAME"), "DESCRIPTION" => GetMessage("DOCS_SALES_COMMENTS_DECRIPTION"), "SORT" => 6, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "DEDUPLICATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "A", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y", WIZARD_EMPLOYEES_GROUP => "M", WIZARD_MARKETING_AND_SALES_GROUP => "M")), array("XML_ID" => "DOCS_DIRECTORS_COMMENTS", "NAME" => GetMessage("DOCS_DIRECTORS_COMMENTS_NAME"), "DESCRIPTION" => GetMessage("DOCS_DIRECTORS_COMMENTS_DECRIPTION"), "SORT" => 6, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "DEDUPLICATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "A", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y", WIZARD_DIRECTION_GROUP => "M")), array("XML_ID" => "GROUPS_AND_USERS_FILES_COMMENTS", "NAME" => GetMessage("GROUPS_AND_USERS_COMMENTS_NAME"), "DESCRIPTION" => GetMessage("GROUPS_AND_USERS_COMMENTS_DESCRIPTION"), "SORT" => 6, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "Y", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "DEDUPLICATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroupID["HIDDEN"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "N", "SITES" => array(WIZARD_SITE_ID => WIZARD_SITE_DIR . "community/forum/messages/forum#FORUM_ID#/topic#TOPIC_ID#/message#MESSAGE_ID#/#message#MESSAGE_ID#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "M", WIZARD_PORTAL_ADMINISTRATION_GROUP => "Y")));
foreach ($arForums as $arForum) {
$dbForum = CForumNew::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID, "XML_ID" => $arForum["XML_ID"]));
if ($dbForum->Fetch()) {
continue;
}
$forumID = CForumNew::Add($arForum);
if ($forumID < 1 || !isset($arForum["TOPICS"]) || !is_array($arForum["TOPICS"])) {
continue;
}
foreach ($arForum["TOPICS"] as $arTopic) {
$arTopic["FORUM_ID"] = $forumID;
$topicID = CForumTopic::Add($arTopic);
if ($topicID < 1 || !isset($arTopic["MESSAGES"]) || !is_array($arTopic["MESSAGES"])) {
continue;
}
foreach ($arTopic["MESSAGES"] as $arMessage) {
$arMessage["FORUM_ID"] = $forumID;
$arMessage["TOPIC_ID"] = $topicID;
$messageID = CForumMessage::Add($arMessage, false);
if ($messageID < 1) {
CForumTopic::Delete($topicID);
continue 2;
}
}
CForumTopic::SetStat($topicID);
}
}
示例3: AddComment_Report_Forum
public static function AddComment_Report_Forum($arFields, $FORUM_ID, $arLog)
{
global $USER, $DB;
$mess_id = false;
$dbReport = CTimeManReportFull::GetByID($arLog["SOURCE_ID"]);
$arReport = $dbReport->Fetch();
if (CModule::IncludeModule("forum") && $arReport) {
$ufFileID = array();
$ufDocID = array();
if (!($userName = trim($USER->GetFormattedName(false)))) {
$userName = $USER->GetLogin();
}
if (!$arReport["FORUM_TOPIC_ID"]) {
$arTopicFields = array("TITLE" => $arReport["DATE_FROM"] . "-" . $arReport["DATE_TO"], "USER_START_ID" => $arFields["USER_ID"], "STATE" => "Y", "FORUM_ID" => $FORUM_ID, "USER_START_NAME" => $userName, "START_DATE" => ConvertTimeStamp(time(), "FULL"), "POSTS" => 0, "VIEWS" => 0, "APPROVED" => "Y", "LAST_POSTER_NAME" => $userName, "LAST_POST_DATE" => ConvertTimeStamp(time(), "FULL"), "LAST_MESSAGE_ID" => 0, "XML_ID" => "TIMEMAN_REPORT_" . $arLog["SOURCE_ID"]);
$TOPIC_ID = CForumTopic::Add($arTopicFields);
if ($TOPIC_ID) {
CTimeManReportFull::Update($arLog["SOURCE_ID"], array("FORUM_TOPIC_ID" => $TOPIC_ID));
}
} else {
$TOPIC_ID = $arReport["FORUM_TOPIC_ID"];
}
if ($TOPIC_ID) {
$arFieldsP = array("AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $userName, "POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "PARAM2" => $arLog["SOURCE_ID"]);
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsP["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsP["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $arFieldsP);
$mess_id = CForumMessage::Add($arFieldsP);
// get UF DOC value and FILE_ID there
if ($mess_id > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $mess_id));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $mess_id, LANGUAGE_ID);
}
}
}
return array("SOURCE_ID" => $mess_id, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
示例4: SocnetEMailMessageAdd
function SocnetEMailMessageAdd($arMessageFields, $ACTION_VARS)
{
if (!is_array($arMessageFields["FORUM_EMAIL_FILTER"])) {
return false;
}
if (!CModule::IncludeModule("socialnetwork")) {
return false;
}
$arParams = $arMessageFields["FORUM_EMAIL_FILTER"];
if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum")) {
return false;
}
// Найдем кто отправитель
$message_email = strlen($arMessageFields["FIELD_REPLY_TO"]) > 0 ? $arMessageFields["FIELD_REPLY_TO"] : $arMessageFields["FIELD_FROM"];
$message_email_addr = strtolower(CMailUtil::ExtractMailAddress($message_email));
$o = "LAST_LOGIN";
$b = "DESC";
$res = CUser::GetList($o, $b, array("ACTIVE" => "Y", "EMAIL" => $message_email_addr));
if (($arUser = $res->Fetch()) && strtolower(CMailUtil::ExtractMailAddress($arUser["EMAIL"])) == $message_email_addr) {
$AUTHOR_USER_ID = $arUser["ID"];
} elseif ($arParams["NOT_MEMBER_POST"] == "Y") {
$AUTHOR_USER_ID = false;
} else {
CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR1") . ": " . $message_email_addr));
return false;
}
if ($arParams["NOT_MEMBER_POST"] != "Y") {
// Проверим права доступа
if (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "full")) {
$PERMISSION = "Y";
} elseif (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "newtopic")) {
$PERMISSION = "M";
} elseif (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "answer")) {
$PERMISSION = "I";
} else {
CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR2") . " " . $arUser["LOGIN"] . " [" . $AUTHOR_USER_ID . "] (" . $message_email_addr . ")"));
return false;
}
}
$body = $arMessageFields["BODY"];
//$body = preg_replace("/(\r\n)+/", "\r\n", $body);
$p = strpos($body, "\r\nFrom:");
if ($p > 0) {
$body = substr($body, 0, $p) . "\r\n[CUT]" . substr($body, $p) . "[/CUT]";
}
$subject = $arMessageFields["SUBJECT"];
// обрежем все RE и FW
$subject = trim(preg_replace('#^\\s*((RE[0-9\\[\\]]*:\\s*)|(FW:\\s*))+(.*)$#i', '\\4', $subject));
if ($subject == '') {
$subject = GetMessage("FORUM_MAIL_EMPTY_TOPIC_TITLE") . " " . rand();
}
// Найдем какая тема
$arFields = array();
$FORUM_ID = IntVal($arParams["FORUM_ID"]);
$SOCNET_GROUP_ID = IntVal($arParams["SOCNET_GROUP_ID"]);
$TOPIC_ID = 0;
global $DB;
if ($arMessageFields["IN_REPLY_TO"] != '') {
$dbTopic = $DB->Query("SELECT FT.ID FROM b_forum_topic FT INNER JOIN b_forum_message FM ON FM.TOPIC_ID=FT.ID WHERE FM.XML_ID='" . $DB->ForSQL($arMessageFields["IN_REPLY_TO"], 255) . "' AND FT.FORUM_ID=" . $FORUM_ID . " AND FT.SOCNET_GROUP_ID=" . $SOCNET_GROUP_ID);
if ($arTopic = $dbTopic->Fetch()) {
$TOPIC_ID = $arTopic["ID"];
}
}
if ($arParams["USE_SUBJECT"] == "Y" && $TOPIC_ID <= 0) {
$dbTopic = $DB->Query("SELECT ID FROM b_forum_topic WHERE TITLE='" . $DB->ForSQL($subject, 255) . "' AND FORUM_ID=" . $FORUM_ID . " AND SOCNET_GROUP_ID=" . $SOCNET_GROUP_ID);
// ограничить по старости?
if ($arTopic = $dbTopic->Fetch()) {
$TOPIC_ID = $arTopic["ID"];
}
}
if ($AUTHOR_USER_ID > 0) {
if ($TOPIC_ID < 0 && $PERMISSION <= "I") {
CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR3") . " " . $arUser["LOGIN"] . " [" . $AUTHOR_USER_ID . "] (" . $message_email_addr . ")"));
return false;
}
$bSHOW_NAME = true;
$res = CForumUser::GetByUSER_ID($AUTHOR_USER_ID);
if ($res) {
$bSHOW_NAME = $res["SHOW_NAME"] == "Y";
}
if ($bSHOW_NAME) {
$AUTHOR_NAME = $arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"];
}
if (strlen(Trim($AUTHOR_NAME)) <= 0) {
$AUTHOR_NAME = $arUser["LOGIN"];
}
} else {
$AUTHOR_NAME = $arMessageFields["FIELD_FROM"];
$arFields["AUTHOR_EMAIL"] = $arMessageFields["FIELD_FROM"];
}
$arFields["NEW_TOPIC"] = "N";
if ($PERMISSION >= "Q") {
$arFields["APPROVED"] = "Y";
} else {
$arFields["APPROVED"] = $arParams["MODERATION"] == "Y" ? "N" : "Y";
}
// Добавим новую тему
if ($TOPIC_ID <= 0) {
$arTopicFields = array("TITLE" => $subject, "FORUM_ID" => $FORUM_ID, "USER_START_ID" => $AUTHOR_USER_ID, "OWNER_ID" => $AUTHOR_USER_ID, "SOCNET_GROUP_ID" => $SOCNET_GROUP_ID);
$arTopicFields["XML_ID"] = $arMessageFields["MSG_ID"];
//.........这里部分代码省略.........
示例5: __deprecated_Add
/**
* WARNING! This method is transitional and can be changed without
* any notifications! Don't use it.
*
* @deprecated
*/
public static function __deprecated_Add($commentText, $forumTopicId, $forumId, $nameTemplate, $arTask, $permissions, $commentId, $givenUserId, $imageWidth, $imageHeight, $arSmiles, $arForum, $messagesPerPage, $arUserGroupArray, $backPage, $strMsgAddComment, $strMsgEditComment, $strMsgNewTask, $componentName, &$outForumTopicId, &$arErrorCodes, &$outStrUrl, $arFieldsAdditional = array())
{
global $DB;
if (is_array($arTask)) {
if (!array_key_exists('~TITLE', $arTask)) {
$arTmpTask = $arTask;
foreach ($arTmpTask as $key => $value) {
if (substr($key, 0, 1) !== '~') {
$arTask['~' . $key] = $arTmpTask[$key];
}
}
}
}
$MID = 0;
$TID = 0;
if ($forumTopicId > 0 && CForumTopic::GetByID($forumTopicId) === false) {
$forumTopicId = false;
}
if ($forumTopicId <= 0) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim(CUser::FormatName($nameTemplate, $res)) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arFields = array("TITLE" => $arTask["~TITLE"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions, "NAME_TEMPLATE" => $nameTemplate, 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arFields);
if (intVal($TID) <= 0) {
$arErrorCodes[] = array('code' => 'topic is not created');
} else {
$arFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arFields);
}
if (!empty($arErrorCodes)) {
$DB->Rollback();
return false;
} else {
$DB->Commit();
}
}
$arFieldsG = array("POST_MESSAGE" => $commentText, "AUTHOR_NAME" => '', "AUTHOR_EMAIL" => $GLOBALS['USER']->GetEmail(), "USE_SMILES" => NULL, "PARAM2" => $arTask['ID'], "TITLE" => $arTask["~TITLE"], "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions);
// UF_* forwarding
if (is_array($arFieldsAdditional)) {
foreach ($arFieldsAdditional as $field => $value) {
if (strlen($field) && substr($field, 0, 3) == 'UF_') {
$arFieldsG[$field] = $value;
$GLOBALS[$field] = $value;
// strange behaviour required for ForumMessageAdd() to handle UF_* properly
}
}
}
if (!empty($_FILES["REVIEW_ATTACH_IMG"])) {
$arFieldsG["ATTACH_IMG"] = $_FILES["REVIEW_ATTACH_IMG"];
} else {
$arFiles = array();
if (!empty($_REQUEST["FILES"])) {
foreach ($_REQUEST["FILES"] as $key) {
$arFiles[$key] = array("FILE_ID" => $key);
if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$key]["del"] = "Y";
}
}
}
if (!empty($_FILES)) {
$res = array();
foreach ($_FILES as $key => $val) {
if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
$arFiles[] = $_FILES[$key];
}
}
}
if (!empty($arFiles)) {
$arFieldsG["FILES"] = $arFiles;
}
}
$TOPIC_ID = $forumTopicId > 0 ? $forumTopicId : $TID;
$MESSAGE_ID = 0;
//.........这里部分代码省略.........
示例6: AddCrmActivityComment
public static function AddCrmActivityComment($arFields)
{
if (!CModule::IncludeModule("forum")) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$messageID = false;
$dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array('ID', 'ENTITY_ID', 'SOURCE_ID', 'SITE_ID', 'TITLE', 'PARAMS'));
if ($arLog = $dbResult->Fetch()) {
$dbCrmActivity = CCrmActivity::GetList(array(), array('ID' => $arLog['ENTITY_ID'], 'CHECK_PERMISSIONS' => 'N'));
if ($arCrmActivity = $dbCrmActivity->Fetch()) {
if ($arCrmActivity['TYPE_ID'] == CCrmActivityType::Task && CModule::IncludeModule('tasks')) {
$userID = $GLOBALS["USER"]->GetID();
$dbTask = CTasks::GetByID($arCrmActivity["ASSOCIATED_ENTITY_ID"], false);
if ($arTaskFields = $dbTask->Fetch()) {
if (!($userName = trim($GLOBALS["USER"]->GetFormattedName(false)))) {
$userName = $GLOBALS["USER"]->GetLogin();
}
$FORUM_ID = CTasksTools::GetForumIdForIntranet();
if (!$arTaskFields["FORUM_TOPIC_ID"]) {
$arTopicFields = array("TITLE" => $arTaskFields["TITLE"], "USER_START_ID" => $arFields["USER_ID"], "STATE" => "Y", "FORUM_ID" => $FORUM_ID, "USER_START_NAME" => $userName, "START_DATE" => ConvertTimeStamp(time(), "FULL"), "POSTS" => 0, "VIEWS" => 0, "APPROVED" => "Y", "LAST_POSTER_NAME" => $userName, "LAST_POST_DATE" => ConvertTimeStamp(time(), "FULL"), "LAST_MESSAGE_ID" => 0, "XML_ID" => 'TASK_' . $arTaskFields['ID']);
$TOPIC_ID = CForumTopic::Add($arTopicFields);
if ($TOPIC_ID) {
$arFieldsFirstMessage = array("POST_MESSAGE" => $arTopicFields["XML_ID"], "AUTHOR_ID" => $arTopicFields["USER_START_ID"], "AUTHOR_NAME" => $arTopicFields["USER_START_NAME"], "FORUM_ID" => $arTopicFields["FORUM_ID"], "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => 'TK', "PARAM2" => $arTaskFields['ID'], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E');
CForumMessage::Add($arFieldsFirstMessage, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
$oTask = new CTasks();
$oTask->Update($arTaskFields["ID"], array("FORUM_TOPIC_ID" => $TOPIC_ID));
}
} else {
$TOPIC_ID = $arTaskFields["FORUM_TOPIC_ID"];
}
if ($TOPIC_ID) {
$arFieldsP = array("AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $userName, "POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y");
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsP["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsP["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $arFieldsP);
$messageID = CForumMessage::Add($arFieldsP);
// get UF DOC value and FILE_ID there
if ($messageID > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
}
}
}
} else {
return array("NO_SOURCE" => "Y");
}
} else {
$sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
}
} else {
$sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
}
return array("SOURCE_ID" => $messageID, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $messageID, "ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
示例7: addCommentLists
public static function addCommentLists($fields)
{
if (!CModule::IncludeModule('forum') || !CModule::IncludeModule('bizproc')) {
return false;
}
$ufFileId = array();
$ufDocId = array();
$fieldsMessage = array();
$messageId = array();
$error = array();
$note = array();
$sonetLogQuery = CSocNetLog::GetList(array(), array('ID' => $fields['LOG_ID']), false, false, array('ID', 'SOURCE_ID', 'SITE_ID', 'MESSAGE', 'USER_ID'));
if ($sonetLog = $sonetLogQuery->fetch()) {
$users = CBPTaskService::getWorkflowParticipants($sonetLog['MESSAGE'], CBPTaskUserStatus::Waiting);
if (preg_match_all("/(?<=\\[USER=)(?P<id>[0-9]+)(?=\\])/", $fields['TEXT_MESSAGE'], $matches)) {
$users = array_unique(array_merge($users, $matches['id']));
}
$users[] = $sonetLog['USER_ID'];
self::setSocnetFollow($users, $sonetLog['ID'], 'Y', false, true);
$forumId = CBPHelper::getForumId();
if ($forumId) {
$topicQuery = CForumTopic::GetList(array(), array('FORUM_ID' => $forumId, 'XML_ID' => 'WF_' . $sonetLog['MESSAGE']));
if ($topicQuery && ($topic = $topicQuery->fetch())) {
$topicId = $topic['ID'];
} else {
$arTopic = array('AUTHOR_ID' => 0, 'TITLE' => 'WF_' . $sonetLog['MESSAGE'], 'TAGS' => '', 'MESSAGE' => 'WF_' . $sonetLog['MESSAGE'], 'XML_ID' => 'WF_' . $sonetLog['MESSAGE']);
$arUserStart = array("ID" => $arTopic["AUTHOR_ID"], "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
$GLOBALS["DB"]->StartTransaction();
$arTopicFields = array("TITLE" => $arTopic["TITLE"], "TAGS" => $arTopic["TAGS"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "XML_ID" => $arTopic["XML_ID"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => 'Q', "PERMISSION" => 'Y');
$topicId = CForumTopic::Add($arTopicFields);
if (intval($topicId) > 0) {
$arTopic['MESSAGE'] = strip_tags($arTopic['MESSAGE']);
$arFields = array("POST_MESSAGE" => $arTopic['MESSAGE'], "AUTHOR_ID" => $arUserStart["ID"], "AUTHOR_NAME" => $arUserStart["NAME"], "FORUM_ID" => $forumId, "TOPIC_ID" => $topicId, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "WF", "PARAM2" => 0, "PERMISSION_EXTERNAL" => 'Q', "PERMISSION" => 'Y');
$startMessageId = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
if (intVal($startMessageId) <= 0) {
CForumTopic::Delete($topicId);
$topicId = 0;
}
}
if (intval($topicId) <= 0) {
$GLOBALS["DB"]->Rollback();
} else {
$GLOBALS["DB"]->Commit();
}
}
if ($topicId) {
$fieldsMessage = array('POST_MESSAGE' => $fields['TEXT_MESSAGE'], 'USE_SMILES' => 'Y', 'PERMISSION_EXTERNAL' => 'Q', 'PERMISSION' => 'Y', 'APPROVED' => 'Y');
$tmp = false;
$GLOBALS['USER_FIELD_MANAGER']->editFormAddFields('SONET_COMMENT', $tmp);
if (is_array($tmp)) {
if (array_key_exists('UF_SONET_COM_DOC', $tmp)) {
$GLOBALS['UF_FORUM_MESSAGE_DOC'] = $tmp['UF_SONET_COM_DOC'];
} elseif (array_key_exists('UF_SONET_COM_FILE', $tmp)) {
$fieldsMessage['FILES'] = array();
foreach ($tmp['UF_SONET_COM_FILE'] as $fileId) {
$fieldsMessage['FILES'][] = array('FILE_ID' => $fileId);
}
}
if (array_key_exists("UF_SONET_COM_URL_PRV", $tmp)) {
$GLOBALS["UF_FORUM_MES_URL_PRV"] = $tmp["UF_SONET_COM_URL_PRV"];
}
}
$messageId = ForumAddMessage("REPLY", $forumId, $topicId, 0, $fieldsMessage, $error, $note);
if ($messageId > 0) {
$addedMessageFilesQuery = CForumFiles::getList(array('ID' => 'ASC'), array('MESSAGE_ID' => $messageId));
while ($addedMessageFiles = $addedMessageFilesQuery->fetch()) {
$ufFileId[] = $addedMessageFiles['FILE_ID'];
}
$ufDocId = $GLOBALS['USER_FIELD_MANAGER']->getUserFieldValue('FORUM_MESSAGE', 'UF_FORUM_MESSAGE_DOC', $messageId, LANGUAGE_ID);
$ufUrlPreview = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MES_URL_PRV", $messageID, LANGUAGE_ID);
}
}
}
}
if (!$messageId) {
$error = Loc::getMessage('LISTS_LF_ADD_COMMENT_SOURCE_ERROR');
}
return array('SOURCE_ID' => $messageId, 'MESSAGE' => $fieldsMessage ? $fieldsMessage['POST_MESSAGE'] : false, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => $messageId, 'ERROR' => $error, 'NOTES' => $note, 'UF' => array('FILE' => $ufFileId, 'DOC' => $ufDocId, 'URL_PREVIEW' => $ufUrlPreview));
}
示例8: GetMessage
if (strlen($_POST["comment_body"]) <= 0) {
$strErrorMessage .= GetMessage("TFC_NO_BODY") . ". ";
}
$sTransStarted = False;
if (strlen($strErrorMessage) <= 0) {
$strDescription = $_POST["comment_body"] . "\n";
if (strlen($_POST["comment_phone"]) > 0) {
$strDescription .= "\n" . GetMessage("COMM_PHONE") . " " . $_POST["comment_phone"];
}
if (strlen($_POST["comment_email"]) > 0) {
$strDescription .= "\n" . GetMessage("COMM_EMAIL") . " " . $_POST["comment_email"];
}
$DB->StartTransaction();
$sTransStarted = True;
$arFields = array("TITLE" => TruncateText($strDescription, 40), "FORUM_ID" => $INQUERY_FORUM_ID, "USER_START_NAME" => $_POST["comment_author"], "LAST_POSTER_NAME" => $_POST["comment_author"]);
$TID1 = CForumTopic::Add($arFields);
if (IntVal($TID1) <= 0) {
$strErrorMessage .= GetMessage("ADDMESS_ERROR_ADD_TOPIC") . ". \n";
}
}
if (strlen($strErrorMessage) <= 0) {
$AUTHOR_IP = ForumGetRealIP();
$AUTHOR_IP_tmp = $AUTHOR_IP;
$AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR'];
$AUTHOR_IP = @gethostbyaddr($AUTHOR_IP);
if ($AUTHOR_IP_tmp == $AUTHOR_REAL_IP) {
$AUTHOR_REAL_IP = $AUTHOR_IP;
} else {
$AUTHOR_REAL_IP = @gethostbyaddr($AUTHOR_REAL_IP);
}
$arFields = array("POST_MESSAGE" => $strDescription, "AUTHOR_NAME" => $_POST["comment_author"], "AUTHOR_EMAIL" => $_POST["comment_email"], "FORUM_ID" => $INQUERY_FORUM_ID, "TOPIC_ID" => $TID1, "AUTHOR_IP" => $AUTHOR_IP !== False ? $AUTHOR_IP : "<no address>", "AUTHOR_REAL_IP" => $AUTHOR_REAL_IP !== False ? $AUTHOR_REAL_IP : "<no address>", "NEW_TOPIC" => "Y", "GUEST_ID" => $_SESSION["SESS_GUEST_ID"]);
示例9: __deprecated_Add
/**
* WARNING! This method is transitional and can be changed without
* any notifications! Don't use it.
*
* @deprecated
*/
public static function __deprecated_Add($commentText, $forumTopicId, $forumId, $nameTemplate, $arTask, $permissions, $commentId, $givenUserId, $imageWidth, $imageHeight, $arSmiles, $arForum, $messagesPerPage, $arUserGroupArray, $backPage, $strMsgAddComment, $strMsgEditComment, $strMsgNewTask, $componentName, &$outForumTopicId, &$arErrorCodes, &$outStrUrl, $arFieldsAdditional)
{
global $DB;
if (is_array($arTask)) {
if (!array_key_exists('~TITLE', $arTask)) {
$arTmpTask = $arTask;
foreach ($arTmpTask as $key => $value) {
if (substr($key, 0, 1) !== '~') {
$arTask['~' . $key] = $arTmpTask[$key];
}
}
}
}
$MID = 0;
$TID = 0;
if ($forumTopicId > 0 && CForumTopic::GetByID($forumTopicId) === false) {
$forumTopicId = false;
}
if ($forumTopicId <= 0) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim(CUser::FormatName($nameTemplate, $res)) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arFields = array("TITLE" => $arTask["~TITLE"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions, "NAME_TEMPLATE" => $nameTemplate, 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arFields);
if (intVal($TID) <= 0) {
$arErrorCodes[] = array('code' => 'topic is not created');
} else {
$arFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arFields);
}
if (!empty($arErrorCodes)) {
$DB->Rollback();
return false;
} else {
$DB->Commit();
}
}
$arFieldsG = array("POST_MESSAGE" => $commentText, "AUTHOR_NAME" => '', "AUTHOR_EMAIL" => $GLOBALS['USER']->GetEmail(), "USE_SMILES" => NULL, "PARAM2" => $arTask['ID'], "TITLE" => $arTask["~TITLE"], "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions);
// UF_* forwarding
if (is_array($arFieldsAdditional)) {
foreach ($arFieldsAdditional as $field => $value) {
if (strlen($field) && substr($field, 0, 3) == 'UF_') {
$arFieldsG[$field] = $value;
$GLOBALS[$field] = $value;
// strange behaviour required for ForumMessageAdd() to handle UF_* properly
}
}
}
if (!empty($_FILES["REVIEW_ATTACH_IMG"])) {
$arFieldsG["ATTACH_IMG"] = $_FILES["REVIEW_ATTACH_IMG"];
} else {
$arFiles = array();
if (!empty($_REQUEST["FILES"])) {
foreach ($_REQUEST["FILES"] as $key) {
$arFiles[$key] = array("FILE_ID" => $key);
if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$key]["del"] = "Y";
}
}
}
if (!empty($_FILES)) {
$res = array();
foreach ($_FILES as $key => $val) {
if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
$arFiles[] = $_FILES[$key];
}
}
}
if (!empty($arFiles)) {
$arFieldsG["FILES"] = $arFiles;
}
}
$TOPIC_ID = $forumTopicId > 0 ? $forumTopicId : $TID;
$MESSAGE_ID = 0;
//.........这里部分代码省略.........
示例10: MoveTopic2Forum
function MoveTopic2Forum($TID, $FID, $leaveLink = "N")
{
global $DB;
$FID = intVal($FID);
$arForum = CForumNew::GetByID($FID);
$arTopics = is_array($TID) ? $TID : (intVal($TID) > 0 ? array($TID) : array());
$leaveLink = strToUpper($leaveLink) == "Y" ? "Y" : "N";
$arMsg = array();
$arForums = array();
if (empty($arForum)) {
$arMsg[] = array("id" => "FORUM_NOT_EXIST", "text" => GetMessage("F_ERR_FORUM_NOT_EXIST", array("#FORUM_ID#" => $FID)));
}
if (empty($arTopics)) {
$arMsg[] = array("id" => "TOPIC_EMPTY", "text" => GetMessage("F_ERR_EMPTY_TO_MOVE"));
}
if (!empty($arMsg)) {
$e = new CAdminException($arMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
$arTopicsCopy = $arTopics;
$arTopics = array();
foreach ($arTopicsCopy as $res) {
$arTopics[intVal($res)] = array("ID" => intVal($res));
}
$db_res = CForumTopic::GetList(array(), array("@ID" => implode(", ", array_keys($arTopics))));
if ($db_res && ($res = $db_res->Fetch())) {
do {
if (intVal($res["FORUM_ID"]) == $FID) {
$arMsg[] = array("id" => "FORUM_ID_IDENTICAL", "text" => GetMessage("F_ERR_THIS_TOPIC_IS_NOT_MOVE", array("#TITLE#" => $res["TITLE"], "#ID#" => $res["ID"])));
continue;
}
// $DB->StartTransaction();
if ($leaveLink != "N") {
CForumTopic::Add(array("TITLE" => $res["TITLE"], "DESCRIPTION" => $res["DESCRIPTION"], "STATE" => "L", "USER_START_NAME" => $res["USER_START_NAME"], "START_DATE" => $res["START_DATE"], "ICON_ID" => $res["ICON_ID"], "POSTS" => "0", "VIEWS" => "0", "FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["ID"], "APPROVED" => $res["APPROVED"], "SORT" => $res["SORT"], "LAST_POSTER_NAME" => $res["LAST_POSTER_NAME"], "LAST_POST_DATE" => $res["LAST_POST_DATE"], "HTML" => $res["HTML"], "USER_START_ID" => $res["USER_START_ID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"]));
}
CForumTopic::Update($res["ID"], array("FORUM_ID" => $FID), true);
// move message
$strSql = "UPDATE b_forum_message SET FORUM_ID=" . $FID . ", POST_MESSAGE_HTML='' WHERE TOPIC_ID=" . $res["ID"];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
// move subscribe
$strSql = "UPDATE b_forum_subscribe SET FORUM_ID=" . intVal($FID) . " WHERE TOPIC_ID=" . $res["ID"];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$arForums[$res["FORUM_ID"]] = $res["FORUM_ID"];
unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$res["ID"]]);
unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$res["ID"]]);
$arTopics[intVal($res["ID"])] = $res;
// $DB->Commit();
CForumCacheManager::ClearTag("F", $res["ID"]);
$res_log["DESCRIPTION"] = str_replace(array("#TOPIC_TITLE#", "#TOPIC_ID#", "#FORUM_TITLE#", "#FORUM_ID#"), array($res["TITLE"], $res["ID"], $arForum["NAME"], $arForum["ID"]), $leaveLink != "N" ? GetMessage("F_LOGS_MOVE_TOPIC_WITH_LINK") : GetMessage("F_LOGS_MOVE_TOPIC"));
$res_log["FORUM_ID"] = $arForum["ID"];
$res_log["TOPIC_ID"] = $res["ID"];
$res_log["TITLE"] = $res["TITLE"];
$res_log["FORUM_TITLE"] = $arForum["NAME"];
CForumEventLog::Log("topic", "move", $res["ID"], serialize($res_log));
} while ($res = $db_res->Fetch());
}
/***************** Cleaning cache **********************************/
unset($GLOBALS["FORUM_CACHE"]["FORUM"][$FID]);
if (CACHED_b_forum !== false) {
$GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum");
}
/***************** Cleaning cache/**********************************/
CForumNew::SetStat($FID);
foreach ($arForums as $key) {
CForumNew::SetStat($key);
}
if (!empty($arMsg)) {
$e = new CAdminException($arMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
} else {
CForumCacheManager::ClearTag("F", $FID);
if ($leaveLink != "Y") {
foreach ($arTopics as $key => $res) {
CForumCacheManager::ClearTag("F", $res["FORUM_ID"]);
}
}
}
return true;
}
示例11: foreach
}
}
// Forum № 3
if (in_array(GetMessage("F_FORUM_3_NAME"), $arForums)) {
foreach ($arForums as $key => $val) {
if ($val == GetMessage("F_FORUM_3_NAME")) {
$arReplaceForums[] = $key;
}
}
} else {
$arFields = array("NAME" => GetMessage("F_FORUM_3_NAME"), "DESCRIPTION" => GetMessage("F_FORUM_3_DECRIPTION"), "SORT" => 200, "ACTIVE" => "Y", "ALLOW_HTML" => "N", "ALLOW_ANCHOR" => "Y", "ALLOW_BIU" => "Y", "ALLOW_IMG" => "Y", "ALLOW_LIST" => "Y", "ALLOW_QUOTE" => "Y", "ALLOW_CODE" => "Y", "ALLOW_FONT" => "Y", "ALLOW_SMILES" => "Y", "ALLOW_UPLOAD" => "N", "ALLOW_NL2BR" => "N", "MODERATION" => "N", "ALLOW_MOVE_TOPIC" => "Y", "ORDER_BY" => "P", "ORDER_DIRECTION" => "DESC", "LID" => LANGUAGE_ID, "PATH2FORUM_MESSAGE" => "", "ALLOW_UPLOAD_EXT" => "", "FORUM_GROUP_ID" => $arGroup["PARTNER"], "ASK_GUEST_EMAIL" => "N", "USE_CAPTCHA" => "Y", "SITES" => array($SITE_ID => "/communication/forum/messages/forum#FID#/message#MID#/#TITLE_SEO#"), "EVENT1" => "forum", "EVENT2" => "message", "EVENT3" => "", "GROUP_ID" => array("2" => "M", "4" => "A", "5" => "A", "11" => "A", "15" => "A", "16" => "A", "17" => "A", "18" => "A", "19" => "Q", "20" => "A"));
$FID = CForumNew::Add($arFields);
if ($FID > 0) {
$arReplaceForums[] = $FID;
$arFields = array("FORUM_ID" => $FID, "TITLE" => GetMessage("F_FORUM_3_TOPIC_1_TITLE"), "DESCRIPTION" => GetMessage("F_FORUM_3_TOPIC_1_DESCRIPTION"), "ICON_ID" => 0, "TAGS" => GetMessage("F_FORUM_3_TOPIC_1_TAGS"), "USER_START_ID" => 1, "USER_START_NAME" => GetMessage("F_FORUM_3_TOPIC_1_AUTHOR"), "LAST_POSTER_NAME" => GetMessage("F_FORUM_3_TOPIC_1_AUTHOR"), "APPROVED" => "Y");
$TID = intVal(CForumTopic::Add($arFields));
if ($TID > 0) {
$arFields = array("POST_MESSAGE" => GetMessage("F_FORUM_3_TOPIC_1_MESSAGE_1_POSTMESS"), "USE_SMILES" => "Y", "APPROVED" => "Y", "AUTHOR_NAME" => GetMessage("F_FORUM_3_TOPIC_1_AUTHOR"), "AUTHOR_EMAIL" => "", "AUTHOR_ID" => "1", "FORUM_ID" => $FID, "TOPIC_ID" => $TID, "AUTHOR_IP" => "SWAMP", "AUTHOR_REAL_IP" => "SWAMP", "NEW_TOPIC" => "Y", "GUEST_ID" => 58);
$MID = CForumMessage::Add($arFields, false);
if (IntVal($MID) <= 0) {
CForumTopic::Delete($TID);
}
}
}
}
//Copy public files with "on the fly" translation
$source = "/public/forum/";
$target = "/communication/forum/";
$source_base = dirname(__FILE__);
$source_abs = $source_base . $source;
$source_abs = str_replace(array("\\", "//"), "/", $source_base . $source . "/");
示例12: AddCommentMessage
public static function AddCommentMessage($arFields, $FORUM_ID, $arLog)
{
global $USER, $DB;
$dbRes = CTimeManEntry::GetList(array(), array('ID' => $arLog['SOURCE_ID']));
$arEntry = $dbRes->Fetch();
if ($arEntry && CModule::IncludeModule("forum")) {
$ufFileID = array();
$ufDocID = array();
if (!($userName = trim($USER->GetFormattedName(false)))) {
$userName = $USER->GetLogin();
}
if ($arEntry["FORUM_TOPIC_ID"] <= 0) {
$t = ConvertTimeStamp(time(), "FULL");
$arTopicFields = array("TITLE" => $arEntry["DATE_START"], "USER_START_ID" => $arFields["USER_ID"], "STATE" => "Y", "FORUM_ID" => $FORUM_ID, "USER_START_NAME" => $userName, "START_DATE" => $t, "POSTS" => 0, "VIEWS" => 0, "APPROVED" => "Y", "LAST_POSTER_NAME" => $userName, "LAST_POST_DATE" => $t, "LAST_MESSAGE_ID" => 0, "XML_ID" => "TIMEMAN_ENTRY_" . $arLog["SOURCE_ID"]);
$TOPIC_ID = CForumTopic::Add($arTopicFields);
if ($TOPIC_ID > 0) {
CTimeManEntry::Update($arLog['SOURCE_ID'], array("FORUM_TOPIC_ID" => $TOPIC_ID));
}
} else {
$TOPIC_ID = $arEntry["FORUM_TOPIC_ID"];
}
if ($TOPIC_ID) {
$arFieldsP = array("AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $userName, "POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "POST_DATE" => date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), time() - 1), "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "PARAM2" => $arLog["SOURCE_ID"]);
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsP["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsP["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $arFieldsP);
$mess_id = CForumMessage::Add($arFieldsP);
// get UF DOC value and FILE_ID there
if ($mess_id > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $mess_id));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $mess_id, LANGUAGE_ID);
}
if (IsModuleInstalled("im")) {
CTimeManNotify::AddCommentToIM(array("USER_ID" => $arFieldsP["AUTHOR_ID"], "ENTRY_ID" => $arEntry["ID"], "LOG_ID" => $arLog["ID"], "MESSAGE" => $arFields["TEXT_MESSAGE"]));
}
}
return array("SOURCE_ID" => $mess_id, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
return false;
}
示例13: AddComment_Tasks
function AddComment_Tasks($arFields)
{
global $DB;
if (!CModule::IncludeModule("forum")) {
return false;
}
if (!CModule::IncludeModule("tasks")) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID"));
if ($arLog = $dbResult->Fetch()) {
$rsTask = CTasks::GetById($arLog["SOURCE_ID"]);
if ($arTask = $rsTask->Fetch()) {
// read shared cross-site FORUM_ID
$forumID = COption::GetOptionString("tasks", "task_forum_id", 0, $siteId = '');
if ($forumID) {
if (!$arTask["FORUM_TOPIC_ID"]) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim($res["NAME"] . " " . $res["LAST_NAME"]) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arTopicFields = array("TITLE" => $arTask["TITLE"], "FORUM_ID" => $forumID, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E', "APPROVED" => "Y", 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arTopicFields);
if (intVal($TID) > 0) {
$arFieldsFirstMessage = array("POST_MESSAGE" => $arTopicFields['XML_ID'], "AUTHOR_ID" => $arTopicFields["USER_START_ID"], "AUTHOR_NAME" => $arTopicFields["USER_START_NAME"], "FORUM_ID" => $arTopicFields["FORUM_ID"], "TOPIC_ID" => $TID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => 'TK', "PARAM2" => $arTask['ID'], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E');
CForumMessage::Add($arFieldsFirstMessage, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
$arTask["FORUM_TOPIC_ID"] = $TID;
$arTaskFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arTaskFields);
}
if (!$arTask["FORUM_TOPIC_ID"]) {
$DB->Rollback();
} else {
$DB->Commit();
}
} else {
// override forumId by fact forum, attached to the task
if ($arTopic = CForumTopic::getByID($arTask['FORUM_TOPIC_ID'])) {
$forumID = $arTopic['FORUM_ID'];
}
}
if ($forumID && $arTask["FORUM_TOPIC_ID"]) {
$userID = $GLOBALS["USER"]->GetID();
$arLogSites = array();
$rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
while ($arLogSite = $rsLogSite->Fetch()) {
$arLogSites[] = $arLogSite["LID"];
}
$bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
$strPermission = "I";
}
} else {
if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
$strPermission = "I";
}
}
$arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "PERMISSION_EXTERNAL" => "Q", "PERMISSION" => $strPermission, "APPROVED" => "Y");
$MESSAGE_TYPE = 'REPLY';
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$messageID = ForumAddMessage($MESSAGE_TYPE, $forumID, $arTask["FORUM_TOPIC_ID"], 0, $arFieldsMessage, $sError, $sNote);
// get UF DOC value and FILE_ID there
if ($messageID > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
//.........这里部分代码省略.........
示例14: ForumMoveMessage
function ForumMoveMessage($FID, $TID, $Message, $NewTID = 0, $arFields, &$strErrorMessage, &$strOKMessage, $iFileSize = false)
{
global $USER, $DB;
$arError = array();
$arOK = array();
$NewFID = 0;
$arForum = array();
$arTopic = array();
$arNewForum = array();
$arNewTopic = array();
$arCurrUser = array();
$SendSubscribe = false;
//************************* Input params **************************************************************************
$TID = IntVal($TID);
$FID = IntVal($FID);
$NewTID = IntVal($NewTID);
$Message = ForumDataToArray($Message);
if (empty($Message)) {
$arError[] = GetMessage("FMM_NO_MESSAGE");
}
if ($TID <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_SOURCE0");
} else {
$arTopic = CForumTopic::GetByID($TID);
if ($arTopic) {
$FID = IntVal($arTopic["FORUM_ID"]);
$arForum = CForumNew::GetByID($FID);
} else {
$arError[] = GetMessage("FMM_NO_TOPIC_SOURCE1");
}
}
if ($NewTID <= 0 && strLen(trim($arFields["TITLE"])) <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_RECIPIENT0");
} elseif ($NewTID > 0) {
if ($NewTID == $TID) {
$arError[] = GetMessage("FMM_NO_TOPIC_EQUAL");
}
$arNewTopic = CForumTopic::GetByID($NewTID);
if (!$arNewTopic) {
$arError[] = GetMessage("FMM_NO_TOPIC_RECIPIENT1");
} elseif ($arNewTopic["STATE"] == "L") {
$arError[] = GetMessage("FMM_TOPIC_IS_LINK");
} else {
$NewFID = $arNewTopic["FORUM_ID"];
$arNewForum = CForumNew::GetByID($NewFID);
}
}
//*************************/Input params **************************************************************************
//*************************!Proverka prav pol'zovatelya na forume-istochnike i forume-poluchatele*********************
// Tak kak realizovan mehanizm peremeweniya tem s forumov, gde tekuwij pol'zovatel' yavlyaetsya moderatorom na forumy,
// gde on moderatorov ne yavlyaetsya, to v dannom sluchae budet ispol'zovan tot zhe samyj shablon dejstvij. Isklyucheniem
// yavlyaetsya to, chto esli pol'zovatel' na forume-poluchatele ne obladaet pravami moderirovaniya, tema budet neaktivna.
//*************************!Proverka prav pol'zovatelya*************************************************************
$arCurrUser["Perms"]["FID"] = ForumCurrUserPermissions($FID);
$arCurrUser["Perms"]["NewFID"] = ForumCurrUserPermissions($NewFID);
if ($arCurrUser["Perms"]["FID"] < "Q") {
$arError[] = GetMessage("FMM_NO_MODERATE");
}
//************************* Actions *******************************************************************************
$DB->StartTransaction();
if (count($arError) <= 0) {
// Create topic
if ($NewTID <= 0) {
$arFields["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
$arFields["APPROVED"] = "Y";
}
$arRes = array("NAME" => GetMessage("FR_GUEST"));
$ShowName = GetMessage("FR_GUEST");
$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
if ($db_res && ($res = $db_res->Fetch())) {
$arRes["NAME"] = $res["AUTHOR_NAME"];
$arRes["ID"] = $res["AUTHOR_ID"];
}
$arFieldsTopic = array("TITLE" => $arFields["TITLE"], "TITLE_SEO" => $arFields["TITLE_SEO"], "DESCRIPTION" => $arFields["DESCRIPTION"], "ICON" => $arFields["ICON"], "TAGS" => $arFields["TAGS"], "FORUM_ID" => $FID, "USER_START_ID" => $arRes["ID"], "USER_START_NAME" => $arRes["NAME"], "LAST_POSTER_NAME" => $arRes["NAME"], "LAST_POSTER_ID" => $arRes["ID"], "APPROVED" => $arFields["APPROVED"]);
$NewTID = CForumTopic::Add($arFieldsTopic);
if (IntVal($NewTID) <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
} else {
$arNewTopic = CForumTopic::GetByID($NewTID);
if ($arNewTopic) {
$NewFID = $FID;
$arNewForum = $arForum;
$SendSubscribe = true;
} else {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
}
}
}
}
if (count($arError) <= 0) {
// Move message
$db_res = CForumMessage::GetList(array(), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
// echo "NewFID: ".$NewFID." -- FID:".$FID."<br/>";
$arMessage = array();
if ($NewFID != $FID) {
$arMessage["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
//.........这里部分代码省略.........
示例15: AddForumLog
function AddForumLog($taskId, $taskName, $arFields, &$arError)
{
$arError = array();
$iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
if ($iblockId <= 0) {
return;
}
$taskId = intval($taskId);
if ($taskId <= 0) {
return;
}
$db = CIBlockElement::GetProperty($iblockId, $taskId, "", "", array("CODE" => "FORUM_TOPIC_ID"));
$ar = $db->Fetch();
$forumTopicId = intval($ar["VALUE"]);
if ($forumTopicId <= 0) {
$arFields = array("TITLE" => $taskName, "FORUM_ID" => $arFields["FORUM_ID"], "USER_START_ID" => $arFields["USER_ID"], "USER_START_NAME" => $arFields["USER_NAME"], "LAST_POSTER_NAME" => $arFields["USER_NAME"], "APPROVED" => "Y");
$forumTopicId = CForumTopic::Add($arFields);
CIBlockElement::SetPropertyValues($taskId, $iblockId, $forumTopicId, "FORUM_TOPIC_ID");
}
$arFields = array("POST_MESSAGE" => $arFields["POST_MESSAGE"], "AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $arFields["USER_NAME"], "FORUM_ID" => $arFields["FORUM_ID"], "TOPIC_ID" => $forumTopicId, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "IB", "PARAM2" => $taskId);
CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
}