"bDescPageNumbering" => false, "nPageSize" => $arParams["MESSAGES_PER_PAGE"], "bShowAll" => false, "sNameTemplate" => $arParams["NAME_TEMPLATE"]); $MID = intVal($_REQUEST["MID"]); unset($_GET["MID"]); unset($GLOBALS["MID"]); if (isset($arResult['RESULT']) && intval($arResult['RESULT']) > 0) $MID = $arResult['RESULT']; if (intVal($MID) > 0) { $page_number = CForumMessage::GetMessagePage( $MID, $arParams["MESSAGES_PER_PAGE"], $USER->GetUserGroupArray(), $arResult["FORUM_TOPIC_ID"], array( "ORDER_DIRECTION" => ($arParams["PREORDER"] == "N" ? "DESC" : "ASC"), "PERMISSION_EXTERNAL" => $arResult["USER"]["PERMISSION"], "FILTER" => array("!PARAM1" => "IB") ) ); if ($page_number > 0) $arFields["iNumPage"] = intVal($page_number); } $arFilter = array("FORUM_ID"=>$arParams["FORUM_ID"], "TOPIC_ID"=>$arResult["FORUM_TOPIC_ID"], "!PARAM1" => "IB"); if ($arResult["USER"]["RIGHTS"]["MODERATE"] != "Y") $arFilter["APPROVED"] = "Y"; $db_res = CForumMessage::GetListEx($arOrder, $arFilter, false, 0, $arFields); $db_res->NavStart($arParams["MESSAGES_PER_PAGE"], false, ($arFields["iNumPage"] > 0 ? $arFields["iNumPage"] : false)); $arResult["NAV_RESULT"] = $db_res;
if (isset($arNote['title'])) { $arResult['OK_MESSAGE'] = $arNote['title']; } else { $e = new CAdminException($arNote); $arResult["OK_MESSAGE"] = $e->GetString(); } } /******************************************************************** Data ********************************************************************/ /************** Message list ***************************************/ $arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = $arResult["TOPIC"]["ABS_LAST_MESSAGE_ID"]; // Number current page $iNumPage = 0; if ($arParams["MID"] > 0) { $iNumPage = CForumMessage::GetMessagePage($arParams["MID"], $arParams["MESSAGES_PER_PAGE"], $USER->GetUserGroupArray(), $arParams["TID"], array("PERMISSION_EXTERNAL" => $arParams["PERMISSION"])); } $arFilter = array("TOPIC_ID" => $arParams["TID"]); if ($arParams["MODE"] != "GROUP") { $arFilter["FORUM_ID"] = $arParams["FID"]; } if ($arResult["USER"]["RIGHTS"]["MODERATE"] != "Y") { $arFilter["APPROVED"] = "Y"; } if ($USER->IsAuthorized()) { $arFilter["POINTS_TO_AUTHOR_ID"] = $USER->GetID(); } // Pagen CPageOption::SetOptionString("main", "nav_page_in_session", "N"); $db_res = CForumMessage::GetListEx(array("ID" => "ASC"), $arFilter, false, false, array("bDescPageNumbering" => false, "nPageSize" => $arParams["MESSAGES_PER_PAGE"], "bShowAll" => $arParams["PAGE_NAVIGATION_SHOW_ALL"] == "Y", "iNumPage" => $iNumPage > 0 ? $iNumPage : false, "sNameTemplate" => $arParams["NAME_TEMPLATE"])); $db_res->NavStart($arParams["MESSAGES_PER_PAGE"], false, $iNumPage > 0 ? $iNumPage : false);
$pager_number = $GLOBALS["NavNum"] + 1; $arResult["UNREAD_MID"] = intVal(ForumGetFirstUnreadMessage($arParams["FORUM_ID"], $arResult["FORUM_TOPIC_ID"])); $MID = intVal($_REQUEST["MID"]); unset($_GET["MID"]); unset($GLOBALS["MID"]); if (isset($arResult['RESULT']) && intval($arResult['RESULT']) > 0) { $MID = $arResult['RESULT']; if ($arResult["UNREAD_MID"] == $MID) { $arResult["UNREAD_MID"]++; } } elseif ($arResult["UNREAD_MID"] > 0 && ($MID > 0 && $MID > $arResult["UNREAD_MID"] || $MID <= 0)) { $MID = $arResult["UNREAD_MID"]; } ForumSetReadTopic($arParams["FORUM_ID"], $arResult["FORUM_TOPIC_ID"]); if (intVal($MID) > 0) { $pageNo = CForumMessage::GetMessagePage($MID, $arParams["MESSAGES_PER_PAGE"], $GLOBALS["USER"]->GetUserGroupArray(), $arResult["FORUM_TOPIC_ID"], array("ORDER_DIRECTION" => $arParams["PREORDER"] == "N" ? "DESC" : "ASC", "PERMISSION_EXTERNAL" => $arResult["USER"]["PERMISSION"], "FILTER" => array("!PARAM1" => $arParams['ENTITY_TYPE']))); $bShowAll = $pageNo > 1; $arResult['MID'] = $MID; } else { $pageNo = $_GET["PAGEN_" . $pager_number]; if (isset($arResult['RESULT']) && intval($arResult['RESULT']) > 0) { $pageNo = $arResult['RESULT']; } } if ($pageNo > 200) { $pageNo = 0; } } $ar_cache_id = array($arParams["FORUM_ID"], $arParams["ENTITY_XML_ID"], $arResult["FORUM_TOPIC_ID"], $arResult["USER"]["RIGHTS"], $arResult["USER"]["PERMISSION"], $arResult["PANELS"], $arParams['SHOW_RATING'], $arParams["MESSAGES_PER_PAGE"], $arParams["DATE_TIME_FORMAT"], $arParams["PREORDER"], $pageNo); $cache_id = "forum_comment_" . serialize($ar_cache_id); ob_start();
/** * 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; $MESSAGE_TYPE = $TOPIC_ID > 0 ? "REPLY" : "NEW"; if (COption::GetOptionString("tasks", "task_comment_allow_edit") && ($MESSAGE_ID = intval($commentId))) { $MESSAGE_TYPE = "EDIT"; } $strErrorMessage = ''; $strOKMessage = ''; $MID = ForumAddMessage($MESSAGE_TYPE, $forumId, $TOPIC_ID, $MESSAGE_ID, $arFieldsG, $strErrorMessage, $strOKMessage, false, $_POST["captcha_word"], 0, $_POST["captcha_code"], $nameTemplate); if ($MID <= 0 || !empty($strErrorMessage)) { $arErrorCodes[] = array('code' => 'message is not added 2', 'title' => empty($strErrorMessage) ? NULL : $strErrorMessage); } else { $arMessage = CForumMessage::GetByID($MID); if ($forumTopicId <= 0) { $forumTopicId = $TID = intVal($arMessage["TOPIC_ID"]); } $outForumTopicId = intVal($forumTopicId); if ($componentName !== null) { ForumClearComponentCache($componentName); } // NOTIFICATION $arTask["ACCOMPLICES"] = $arTask["AUDITORS"] = array(); $rsMembers = CTaskMembers::GetList(array(), array("TASK_ID" => $arTask["ID"])); while ($arMember = $rsMembers->Fetch()) { if ($arMember["TYPE"] == "A") { $arTask["ACCOMPLICES"][] = $arMember["USER_ID"]; } elseif ($arMember["TYPE"] == "U") { $arTask["AUDITORS"][] = $arMember["USER_ID"]; } } $arEmailUserIDs = array($arTask["RESPONSIBLE_ID"], $arTask["CREATED_BY"]); $arEmailUserIDs = array_unique(array_merge($arEmailUserIDs, $arTask["ACCOMPLICES"], $arTask["AUDITORS"])); $currentUserPos = array_search($givenUserId, $arEmailUserIDs); if ($currentUserPos !== false) { unset($arEmailUserIDs[$currentUserPos]); } $parser = new CTextParser(); $parser->imageWidth = $imageWidth; $parser->imageHeight = $imageHeight; $parser->smiles = $arSmiles; $parser->allow = array("HTML" => $arForum["ALLOW_HTML"], "ANCHOR" => $arForum["ALLOW_ANCHOR"], "BIU" => $arForum["ALLOW_BIU"], "IMG" => "N", "VIDEO" => "N", "LIST" => $arForum["ALLOW_LIST"], "QUOTE" => $arForum["ALLOW_QUOTE"], "CODE" => $arForum["ALLOW_CODE"], "FONT" => $arForum["ALLOW_FONT"], "SMILES" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => $arForum["ALLOW_NL2BR"], "TABLE" => "Y"); $arAllow = NULL; $MESSAGE = HTMLToTxt($parser->convertText($commentText, $arAllow)); // remove [ url] for socialnetwork log $MESSAGE = preg_replace("/(\\s\\[\\s(http:\\/\\/|https:\\/\\/|ftp:\\/\\/))(.*?)(\\s\\])/is", "", $MESSAGE); $parser->allow = array("HTML" => 'Y', "ANCHOR" => 'Y', "BIU" => 'Y', "IMG" => "Y", "VIDEO" => "Y", "LIST" => 'N', "QUOTE" => 'Y', "CODE" => 'Y', "FONT" => 'Y', "SMILES" => "N", "UPLOAD" => 'N', "NL2BR" => 'N', "TABLE" => "Y"); $message_notify = $parser->convertText($commentText); $arRecipientsIDs = CTaskNotifications::GetRecipientsIDs($arTask); // Instant Messages if (IsModuleInstalled("im") && CModule::IncludeModule("im") && sizeof($arRecipientsIDs)) { $pageNumber = CForumMessage::GetMessagePage($MID, $messagesPerPage, $arUserGroupArray); // There are different links for extranet users $isExtranetEnabled = false; if (CModule::IncludeModule("extranet")) { $isExtranetEnabled = true; } if ($isExtranetEnabled) { $arSites = array(); $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($arSite = $dbSite->Fetch()) { if (strlen(trim($arSite["DIR"])) > 0) { $arSites[$arSite['ID']]['DIR'] = $arSite['DIR']; } else { $arSites[$arSite['ID']]['DIR'] = '/'; } if (strlen(trim($arSite["SERVER_NAME"])) > 0) { $arSites[$arSite['ID']]['SERVER_NAME'] = $arSite["SERVER_NAME"]; } else { $arSites[$arSite['ID']]['SERVER_NAME'] = COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]); } $arSites[$arSite['ID']]['urlPrefix'] = $arSites[$arSite['ID']]['SERVER_NAME'] . $arSites[$arSite['ID']]['DIR']; // remove last '/' if (strlen($arSites[$arSite['ID']]['urlPrefix']) > 0 && substr($arSites[$arSite['ID']]['urlPrefix'], -1) === '/') { $arSites[$arSite['ID']]['urlPrefix'] = substr($arSites[$arSite['ID']]['urlPrefix'], 0, -1); } } $extranet_site_id = CExtranet::GetExtranetSiteID(); $intranet_site_id = CSite::GetDefSite(); $arIntranetUsers = CExtranet::GetIntranetUsers(); } else { if ($arTask["GROUP_ID"]) { $pathTemplateWoExtranet = str_replace("#group_id#", $arTask["GROUP_ID"], COption::GetOptionString("tasks", "paths_task_group_entry", "/workgroups/group/#group_id#/tasks/task/view/#task_id#/", $arFields["SITE_ID"])); } else { $pathTemplateWoExtranet = COption::GetOptionString("tasks", "paths_task_user_entry", "/company/personal/user/#user_id#/tasks/task/view/#task_id#/", $arFields["SITE_ID"]); } } foreach ($arRecipientsIDs as $userID) { $urlPrefixForUser = tasksServerName(); if ($isExtranetEnabled) { if (!in_array($userID, $arIntranetUsers) && $extranet_site_id) { $userSiteId = $extranet_site_id; } else { $userSiteId = $intranet_site_id; } if (isset($arSites[$userSiteId]['SERVER_NAME'])) { $urlPrefixForUser = tasksServerName($arSites[$userSiteId]['SERVER_NAME']); } if ($arTask["GROUP_ID"]) { $pathTemplate = str_replace('#group_id#', $arTask['GROUP_ID'], CTasksTools::GetOptionPathTaskGroupEntry($userSiteId, '')); } else { $pathTemplate = CTasksTools::GetOptionPathTaskUserEntry($userSiteId, ''); } } else { $pathTemplate = $pathTemplateWoExtranet; } $NOTIFY_MESSAGE_TITLE_TEMPLATE = ''; $messageUrl = ''; if (strlen($pathTemplate) > 0) { $groupId = 0; if (isset($arTask['GROUP_ID'])) { $groupId = (int) $arTask['GROUP_ID']; } $messageUrl = $urlPrefixForUser . CComponentEngine::MakePathFromTemplate($pathTemplate, array("user_id" => $userID, "task_id" => $arTask["ID"], "action" => "view", "USER_ID" => $userID, "TASK_ID" => $arTask["ID"], "ACTION" => "view", 'GROUP_ID' => $groupId, 'group_id' => $groupId)); if ($pageNumber > 1) { $messageUrl .= (strpos($messageUrl, "?") === false ? "?" : "&") . "MID=" . $MID; } $NOTIFY_MESSAGE_TITLE_TEMPLATE = '[URL=' . $messageUrl . "#message" . $MID . ']' . $arTask["~TITLE"] . '[/URL]'; } else { $NOTIFY_MESSAGE_TITLE_TEMPLATE = $arTask["~TITLE"]; } $MESSAGE_SITE = trim(htmlspecialcharsbx(strip_tags(str_replace(array("\r\n", "\n", "\r"), ' ', htmlspecialcharsback($message_notify))))); $MESSAGE_EMAIL = $MESSAGE_SITE; // full message to email if (strlen($MESSAGE_SITE) >= 100) { $dot = '...'; $MESSAGE_SITE = substr($MESSAGE_SITE, 0, 99); if (($lastLinkPosition = strrpos($MESSAGE_SITE, 'http://')) !== false || ($lastLinkPosition = strrpos($MESSAGE_SITE, 'https://')) !== false || ($lastLinkPosition = strrpos($MESSAGE_SITE, 'ftp://')) !== false || ($lastLinkPosition = strrpos($MESSAGE_SITE, 'ftps://')) !== false) { if (strpos($MESSAGE_SITE, ' ', $lastLinkPosition) === false) { $MESSAGE_SITE = substr($MESSAGE_SITE, 0, $lastLinkPosition); } } $MESSAGE_SITE .= $dot; } $arMessageFields = array("TO_USER_ID" => $userID, "FROM_USER_ID" => $givenUserId, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "tasks", "NOTIFY_EVENT" => "comment", "NOTIFY_MESSAGE" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($NOTIFY_MESSAGE_TITLE_TEMPLATE, '[COLOR=#000000]' . $MESSAGE_SITE . '[/COLOR]'), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment), "NOTIFY_MESSAGE_OUT" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($arTask["~TITLE"], $MESSAGE_EMAIL . ' #BR# ' . $messageUrl . "#message" . $MID . ' '), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment)); CIMNotify::Add($arMessageFields); } } $strURL = !empty($backPage) ? $backPage : $GLOBALS['APPLICATION']->GetCurPageParam("", array("IFRAME", "MID", "SEF_APPLICATION_CUR_PAGE_URL", BX_AJAX_PARAM_ID, "result")); $strURL = ForumAddPageParams($strURL, array("MID" => $MID, "result" => $arForum["MODERATION"] != "Y" || CForumNew::CanUserModerateForum($forumId, $arUserGroupArray) ? "reply" : "not_approved"), false, false); $outStrUrl = $strURL; // sonet log if (CModule::IncludeModule("socialnetwork")) { $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID")); if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["TMP_ID"]; $entity_type = $arRes["ENTITY_TYPE"]; $entity_id = $arRes["ENTITY_ID"]; } else { $entity_type = $arTask["GROUP_ID"] ? SONET_ENTITY_GROUP : SONET_ENTITY_USER; $entity_id = $arTask["GROUP_ID"] ? $arTask["GROUP_ID"] : $arTask["CREATED_BY"]; $rsUser = CUser::GetByID($arTask["CREATED_BY"]); if ($arUser = $rsUser->Fetch()) { $arSoFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks", "LOG_DATE" => $arTask["CREATED_DATE"], "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => htmlspecialcharsBack($arTask["~TITLE"]), "MESSAGE" => "", "TEXT_MESSAGE" => $strMsgNewTask, "MODULE_ID" => "tasks", "CALLBACK_FUNC" => false, "SOURCE_ID" => $arTask["ID"], "ENABLE_COMMENTS" => "Y", "USER_ID" => $arTask["CREATED_BY"], "URL" => CTaskNotifications::GetNotificationPath($arUser, $arTask["ID"]), "PARAMS" => serialize(array("TYPE" => "create"))); $log_id = CSocNetLog::Add($arSoFields, false); if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); $arRights = CTaskNotifications::__UserIDs2Rights(CTaskNotifications::GetRecipientsIDs($arTask, false)); if ($arTask["GROUP_ID"]) { $arRights[] = "S" . SONET_ENTITY_GROUP . $arTask["GROUP_ID"]; } CSocNetLogRights::Add($log_id, $arRights); } } } if (intval($log_id) > 0) { $sText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"]; CSocNetLog::Update($log_id, array('PARAMS' => serialize(array('TYPE' => 'comment')))); $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks_comment", "MESSAGE" => $sText, "TEXT_MESSAGE" => $parser->convert4mail($sText), "URL" => str_replace("?IFRAME=Y", "", str_replace("&IFRAME=Y", "", str_replace("IFRAME=Y&", "", $strURL))), "MODULE_ID" => "tasks", "SOURCE_ID" => $MID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $MID); if ($MESSAGE_TYPE == "EDIT") { $dbRes = CSocNetLogComments::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("tasks_comment"), "SOURCE_ID" => $MID), false, false, array("ID")); while ($arRes = $dbRes->Fetch()) { CSocNetLogComments::Update($arRes["ID"], $arFieldsForSocnet); } } else { $arFieldsForSocnet['USER_ID'] = $givenUserId; $arFieldsForSocnet['=LOG_DATE'] = $GLOBALS['DB']->CurrentTimeFunction(); $ufFileID = array(); $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $MID)); while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) { $ufFileID[] = $arAddedMessageFiles["FILE_ID"]; } if (count($ufFileID) > 0) { $arFieldsForSocnet["UF_SONET_COM_FILE"] = $ufFileID; } $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $MID, LANGUAGE_ID); if ($ufDocID) { $arFieldsForSocnet["UF_SONET_COM_DOC"] = $ufDocID; } $ufDocVer = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_VER", $MID, LANGUAGE_ID); if ($ufDocVer) { $arFieldsForSocnet["UF_SONET_COM_VER"] = $ufDocVer; } $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false); CSocNetLog::CounterIncrement($comment_id, false, false, "LC"); } } } $occurAsUserId = CTasksTools::getOccurAsUserId(); if (!$occurAsUserId) { $occurAsUserId = $arMessage["AUTHOR_ID"] ? $arMessage["AUTHOR_ID"] : 1; } // Tasks log $arLogFields = array("TASK_ID" => $arTask["ID"], "USER_ID" => $occurAsUserId, "CREATED_DATE" => $arMessage["EDIT_DATE"] ? ConvertTimeStamp(MakeTimeStamp($arMessage["EDIT_DATE"], CSite::GetDateFormat()), "FULL") : $arMessage["POST_DATE"], "FIELD" => "COMMENT", "TO_VALUE" => $MID); $log = new CTaskLog(); $log->Add($arLogFields); } return $MID; // Message id }
// LAST MESSAGE $arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = 0; if ($arResult["USER"]["RIGHTS"]["EDIT"] != "Y" && $USER->IsAuthorized() && COption::GetOptionString("forum", "USER_EDIT_OWN_POST", "N") != "Y"): if ($arResult["FORUM"]["MODERATION"] == "Y"): $db_res = CForumMessage::GetList(array("ID" => "DESC"), array("TOPIC_ID" => $arParams["TID"], "APPROVED" => "N", ">ID" => $arResult["TOPIC"]["LAST_MESSAGE_ID"]), false, 1); if ($db_res && $res = $db_res->Fetch()): $arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = intVal($res["ID"]); endif; endif; if ($arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] <= 0): $arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = $arResult["TOPIC"]["LAST_MESSAGE_ID"]; endif; endif; // NUMBER CURRENT PAGE $iNumPage = ($arParams["MID"] > 0 ? CForumMessage::GetMessagePage($arParams["MID"], $arParams["MESSAGES_PER_PAGE"], $arUserGroups, $arParams["TID"]) : 0); // Create filter and additional fields for message select $arFilter = array("TOPIC_ID" => $arParams["TID"]); if ($arResult["USER"]["RIGHTS"]["MODERATE"] != "Y") {$arFilter["APPROVED"] = "Y";} if ($USER->IsAuthorized()) {$arFilter["POINTS_TO_AUTHOR_ID"] = $USER->GetID();} /*******************************************************************/ CPageOption::SetOptionString("main", "nav_page_in_session", "N"); $db_res = CForumMessage::GetListEx(array("ID"=>"ASC"), $arFilter, false, false, array( "bDescPageNumbering" => false, "nPageSize" => $arParams["MESSAGES_PER_PAGE"], "bShowAll" => ($arParams["PAGE_NAVIGATION_SHOW_ALL"] == "Y"), "iNumPage" => ($iNumPage > 0 ? $iNumPage : false), "sNameTemplate" => $arParams["NAME_TEMPLATE"])); $db_res->NavStart($arParams["MESSAGES_PER_PAGE"], false, ($iNumPage > 0 ? $iNumPage : false)); $db_res->nPageWindow = $arParams["PAGE_NAVIGATION_WINDOW"];
$arTopic["iLAST_TOPIC_MESSAGE"] = $tmp; $arFilter = array("TOPIC_ID" => $TID); if ($PermissionUser < "Q") { $arFilter["APPROVED"] = "Y"; } if ($USER->IsAuthorized()) { $arFilter["POINTS_TO_AUTHOR_ID"] = $USER->GetID(); } $db_Message = CForumMessage::GetListEx(array("ID" => "ASC"), $arFilter); global $HTTP_GET_VARS; unset($_GET["MID"]); unset($HTTP_GET_VARS["MID"]); unset($_GET["ACTION"]); unset($HTTP_GET_VARS["ACTION"]); if ($MID > 0) { $db_Message->NavStart($GLOBALS["FORUM_MESSAGES_PER_PAGE"], false, CForumMessage::GetMessagePage($MID, $GLOBALS["FORUM_MESSAGES_PER_PAGE"], $USER->GetUserGroupArray())); } else { $db_Message->NavStart($GLOBALS["FORUM_MESSAGES_PER_PAGE"], false); } $UserInfo = array(); $arCurrUser = array(); $arCurrUser["Rank"] = CForumUser::GetUserRank(IntVal($USER->GetParam("USER_ID"))); $arCurrUser["bCanUserDeleteMessages"] = CForumTopic::CanUserDeleteTopicMessage($TID, $USER->GetUserGroupArray(), $USER->GetID()); $arCurrUser["Perms"] = ForumCurrUserPermissions($FID); $parser = new textParser(LANGUAGE_ID); $arAllow = array("HTML" => $arForum["ALLOW_HTML"], "ANCHOR" => $arForum["ALLOW_ANCHOR"], "BIU" => $arForum["ALLOW_BIU"], "IMG" => $arForum["ALLOW_IMG"], "LIST" => $arForum["ALLOW_LIST"], "QUOTE" => $arForum["ALLOW_QUOTE"], "CODE" => $arForum["ALLOW_CODE"], "FONT" => $arForum["ALLOW_FONT"], "SMILES" => $arForum["ALLOW_SMILES"], "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => $arForum["ALLOW_NL2BR"]); ?> <table width="100%" border="0"> <tr> <td align="left"><?php echo $db_Message->NavPrint(GetMessage("FR_MESS"));
$ORDER_DIRECTION = strtoupper($arResult['FORUM']['ORDER_DIRECTION']); } elseif ($arParams['PREORDER'] === 'N') { $ORDER_DIRECTION = 'DESC'; } if (!in_array($ORDER_DIRECTION, array('ASC', 'DESC'), true)) { $ORDER_DIRECTION = 'ASC'; } $arResult['ORDER_DIRECTION'] = $ORDER_DIRECTION; $pageNo = 0; if ($arResult["FORUM_TOPIC_ID"] > 0) { $page_number = $GLOBALS["NavNum"] + 1; $MID = intVal($_REQUEST["MID"]); unset($_GET["MID"]); unset($GLOBALS["MID"]); if (intVal($MID) > 0) { $pageNo = CForumMessage::GetMessagePage($MID, $arParams["MESSAGES_PER_PAGE"], $GLOBALS["USER"]->GetUserGroupArray(), $arResult["FORUM_TOPIC_ID"], array("ORDER_DIRECTION" => $ORDER_DIRECTION, "PERMISSION_EXTERNAL" => $arResult["USER"]["PERMISSION"], "FILTER" => array("!PARAM1" => "IB"))); } else { $pageNo = $_GET["PAGEN_" . $page_number]; if (isset($arResult['RESULT']) && intval($arResult['RESULT']) > 0) { $pageNo = $arResult['RESULT']; } } if ($pageNo > 200) { $pageNo = 0; } $arMessages = array(); $ar_cache_id = array($arParams["FORUM_ID"], $arParams["TASK_ID"], $arResult["FORUM_TOPIC_ID"], $arParams["MESSAGES_PER_PAGE"], $arParams["DATE_TIME_FORMAT"], $ORDER_DIRECTION, $pageNo, $arResult['FORUM']['LAST_POST_DATE'] . $arResult['FORUM']['ABS_LAST_POST_DATE'], $arResult['TASK']['COMMENTS_COUNT']); if ($_GET["IFRAME"] == "Y") { $ar_cache_id[] = "IFRAME"; } $cache_id = "forum_message_" . sha1(serialize($ar_cache_id));