Ejemplo n.º 1
0
 function onAfterForumMessageAdd($ID, $arForumMessage, $arTopicInfo, $arForumInfo, $arFields)
 {
     // add log comment
     if (array_key_exists("ADD_TO_LOG", $arFields) && $arFields["ADD_TO_LOG"] == "N") {
         return;
     }
     if (array_key_exists("NEW_TOPIC", $arFields) && $arFields["NEW_TOPIC"] == "Y") {
         return;
     }
     if (!array_key_exists("TOPIC_INFO", $arForumMessage) || !is_array($arForumMessage["TOPIC_INFO"]) || !array_key_exists("XML_ID", $arForumMessage["TOPIC_INFO"]) || empty($arForumMessage["TOPIC_INFO"]["XML_ID"]) || strpos($arForumMessage["TOPIC_INFO"]["XML_ID"], "IBLOCK_") !== 0) {
         return;
     }
     $val = COption::GetOptionString("intranet", "sonet_log_news_iblock_forum");
     $arIBlockForum = strlen($val) > 0 ? unserialize($val) : array();
     if (CModule::IncludeModule("socialnetwork") && in_array($arFields["FORUM_ID"], $arIBlockForum) && array_key_exists("PARAM2", $arFields) && intval($arFields["PARAM2"]) > 0) {
         CSocNetAllowed::GetAllowedEntityTypes();
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "news", "SOURCE_ID" => $arFields["PARAM2"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID"));
         if ($arRes = $dbRes->Fetch()) {
             $log_id = $arRes["ID"];
             $entity_id = $arRes["ENTITY_ID"];
             $arForum = CForumNew::GetByID($arFields["FORUM_ID"]);
             $parser = new textParser(LANGUAGE_ID);
             // second parameter - path to smile!
             $parser->image_params["width"] = false;
             $parser->image_params["height"] = false;
             $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "VIDEO" => "N", "SMILES" => "N");
             $arMessage = CForumMessage::GetByIDEx($ID);
             $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arMessage["FORUM_ID"], "TID" => $arMessage["TOPIC_ID"], "MID" => $ID));
             $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_SUBSCRIBE_ENTITY_NEWS, "ENTITY_ID" => $entity_id, "EVENT_ID" => "news_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert($arFields["POST_MESSAGE"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($arFields["POST_MESSAGE"]), "URL" => $url, "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $ID);
             if (intVal($arMessage["AUTHOR_ID"]) > 0) {
                 $arFieldsForSocnet["USER_ID"] = $arMessage["AUTHOR_ID"];
             }
             $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
             CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
         }
     }
 }
Ejemplo n.º 2
0
 function OnReindex($NS = array(), $oCallback = NULL, $callback_method = "")
 {
     global $DB;
     $arResultAll = array();
     $arParams = array("PERMISSION" => array(), "SITE" => array(), "DEFAULT_URL" => array());
     $search_message_count = intVal(COption::GetOptionInt("forum", "search_message_count", 0));
     $strNSJoin = "";
     $strFilter = "";
     if ($NS["MODULE"] == "forum" && intVal($NS["ID"]) > 0 && intVal($NS["CNT"]) > 0) {
         $strFilter = " AND (FM.ID>" . intVal($NS["ID"]) . ") ";
     } elseif ($NS["MODULE"] == "forum" && intVal($NS["ID"]) > 0) {
         // out of date
         $strFilter = " AND (FM.ID>=" . intVal($NS["ID"]) . ") ";
     }
     if ($NS["SITE_ID"] != "") {
         $strNSJoin .= " INNER JOIN b_forum2site FS ON (FS.FORUM_ID=F.ID) ";
         $strFilter .= " AND FS.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "' ";
     }
     $strSql = "SELECT STRAIGHT_JOIN FT.ID as TID, FM.ID as MID, FM.ID as ID, FT.FORUM_ID, FT.TITLE, " . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . ",\n\t\t\t\tFT.DESCRIPTION, FT.TAGS, FT.HTML as FT_HTML,\n\t\t\t\tFM.PARAM1, FM.PARAM2, FM.POST_MESSAGE, FM.POST_MESSAGE_FILTER, FM.POST_MESSAGE_HTML, FM.AUTHOR_NAME, FM.AUTHOR_ID, FM.NEW_TOPIC,\n\t\t\t\t" . $DB->DateToCharFunction("FM.POST_DATE") . " as POST_DATE, " . $DB->DateToCharFunction("FM.EDIT_DATE") . " as EDIT_DATE, FT.SOCNET_GROUP_ID, FT.OWNER_ID\n\t\t\tFROM b_forum_message FM use index (PRIMARY), b_forum_topic FT, b_forum F\n\t\t\t" . $strNSJoin . "\n\t\t\tWHERE (FM.TOPIC_ID = FT.ID) AND (F.ID = FT.FORUM_ID) AND (F.INDEXATION = 'Y') AND (FM.APPROVED = 'Y')\n\t\t\t" . $strFilter . "\n\t\t\tORDER BY FM.ID";
     if ($search_message_count > 0) {
         $strSql .= " LIMIT 0, " . $search_message_count;
     }
     $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($db_res && COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
         $db_res = new _CMessageDBResult($db_res);
     }
     $rownum = 0;
     while ($res = $db_res->Fetch()) {
         $rownum++;
         if (empty($arParams["PERMISSION"][$res["FORUM_ID"]])) {
             $arGroups = CForumNew::GetAccessPermissions($res["FORUM_ID"]);
             $arParams["PERMISSION"][$res["FORUM_ID"]] = array();
             for ($i = 0; $i < count($arGroups); $i++) {
                 if ($arGroups[$i][1] >= "E") {
                     $arParams["PERMISSION"][$res["FORUM_ID"]][] = $arGroups[$i][0];
                     if ($arGroups[$i][0] == 2) {
                         break;
                     }
                 }
             }
         }
         if (empty($arParams["SITE"][$res["FORUM_ID"]])) {
             $arParams["SITE"][$res["FORUM_ID"]] = CForumNew::GetSites($res["FORUM_ID"]);
         }
         $arResult = array("ID" => $res["MID"], "LID" => array(), "LAST_MODIFIED" => !empty($res["EDIT_DATE"]) ? $res["EDIT_DATE"] : $res["POST_DATE"], "PARAM1" => $res["FORUM_ID"], "PARAM2" => $res["TID"], "USER_ID" => $res["AUTHOR_ID"], "ENTITY_TYPE_ID" => $res["NEW_TOPIC"] == "Y" ? "FORUM_TOPIC" : "FORUM_POST", "ENTITY_ID" => $res["NEW_TOPIC"] == "Y" ? $res["TID"] : $res["MID"], "PERMISSIONS" => $arParams["PERMISSION"][$res["FORUM_ID"]], "TITLE" => $res["TITLE"] . ($res["NEW_TOPIC"] == "Y" && !empty($res["DESCRIPTION"]) ? ", " . $res["DESCRIPTION"] : ""), "TAGS" => $res["NEW_TOPIC"] == "Y" ? $res["TAGS"] : "", "BODY" => GetMessage("AVTOR_PREF") . " " . $res["AUTHOR_NAME"] . ". " . textParser::killAllTags(COption::GetOptionString("forum", "FILTER", "Y") != "Y" ? $res["POST_MESSAGE"] : $res["POST_MESSAGE_FILTER"]), "URL" => "", "INDEX_TITLE" => $res["NEW_TOPIC"] == "Y");
         foreach ($arParams["SITE"][$res["FORUM_ID"]] as $key => $val) {
             $arResult["LID"][$key] = CForumNew::PreparePath2Message($val, array("FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["TID"], "MESSAGE_ID" => $res["MID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"], "PARAM1" => $res["PARAM1"], "PARAM2" => $res["PARAM2"]));
             if (empty($arResult["URL"]) && !empty($arResult["LID"][$key])) {
                 $arResult["URL"] = $arResult["LID"][$key];
             }
         }
         if (empty($arResult["URL"])) {
             if (empty($arParams["DEFAULT_URL"][$res["FORUM_ID"]])) {
                 $arParams["DEFAULT_URL"][$res["FORUM_ID"]] = "/";
                 foreach ($arParams["SITE"][$res["FORUM_ID"]] as $key => $val) {
                     $db_lang = CLang::GetByID($key);
                     if ($db_lang && ($ar_lang = $db_lang->Fetch())) {
                         $arParams["DEFAULT_URL"][$res["FORUM_ID"]] = $ar_lang["DIR"];
                         break;
                     }
                 }
                 $arParams["DEFAULT_URL"][$res["FORUM_ID"]] .= COption::GetOptionString("forum", "REL_FPATH", "") . "forum/read.php?FID=#FID#&TID=#TID#&MID=#MID##message#MID#";
             }
             $arResult["URL"] = CForumNew::PreparePath2Message($arParams["DEFAULT_URL"][$res["FORUM_ID"]], array("FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["TID"], "MESSAGE_ID" => $res["MID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"], "PARAM1" => $res["PARAM1"], "PARAM2" => $res["PARAM2"]));
         }
         if ($oCallback) {
             $resCall = call_user_func(array($oCallback, $callback_method), $arResult);
             if (!$resCall) {
                 return $arResult["ID"];
             }
         } else {
             $arResultAll[] = $arResult;
         }
     }
     if ($oCallback && $search_message_count > 0 && $rownum >= $search_message_count - 1) {
         return $arResult["ID"];
     }
     if ($oCallback) {
         return false;
     }
     return $arResultAll;
 }
Ejemplo n.º 3
0
 public function OnAfterPhotoCommentAddForum($ID, $arFields)
 {
     static $arSiteWorkgroupsPage;
     if (!CModule::IncludeModule('iblock')) {
         return;
     }
     if (!$this->IsSocnet) {
         return;
     }
     if ((!array_key_exists("PARAM1", $arFields) || $arFields["PARAM1"] != "IB") && array_key_exists("PARAM2", $arFields) && intval($arFields["PARAM2"]) > 0) {
         $bSocNetLogRecordExists = false;
         $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "photo_photo", "SOURCE_ID" => $arFields["PARAM2"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "USER_ID", "TITLE", "URL", "PARAMS"));
         if ($arRes = $dbRes->Fetch()) {
             $log_id = $arRes["ID"];
             $entity_type = $arRes["ENTITY_TYPE"];
             $entity_id = $arRes["ENTITY_ID"];
             $log_title = $arRes["TITLE"];
             $log_url = $arRes["URL"];
             $log_user_id = $arRes["USER_ID"];
             if (strlen($arRes["PARAMS"]) > 0) {
                 $arTmp = unserialize($arRes["PARAMS"]);
                 if ($arTmp) {
                     if (array_key_exists("SECTION_NAME", $arTmp) && strlen($arTmp["SECTION_NAME"]) > 0) {
                         $log_section_name = $arTmp["SECTION_NAME"];
                     }
                     if (array_key_exists("SECTION_URL", $arTmp) && strlen($arTmp["SECTION_URL"]) > 0) {
                         $log_section_url = $arTmp["SECTION_URL"];
                     }
                 }
             }
             $bSocNetLogRecordExists = true;
         } else {
             $rsElement = CIBlockElement::GetByID($arFields["PARAM2"]);
             if ($arElement = $rsElement->Fetch()) {
                 $url = $this->arPath["DETAIL_URL"];
                 $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
                 if (intval($arElement["CREATED_BY"]) > 0) {
                     $rsUser = CUser::GetByID($arElement["CREATED_BY"]);
                     if ($arUser = $rsUser->Fetch()) {
                         $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
                     }
                 }
                 if (in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0) {
                     $entity_type = $this->entity_type;
                     $entity_id = $this->entity_id;
                     $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user") . "_" . $this->entity_id;
                 }
                 $arLogParams = array("FORUM_ID" => intval($this->ForumID));
                 $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]);
                 if ($arIBlock = $rsIBlock->Fetch()) {
                     $arLogParams["IBLOCK_ID"] = $arIBlock["ID"];
                     $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"];
                 }
                 $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]);
                 if ($arSection = $rsSection->Fetch()) {
                     $arLogParams["SECTION_ID"] = $arSection["ID"];
                     $arLogParams["SECTION_NAME"] = $arSection["NAME"];
                     $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]);
                     $arSectionPath = array();
                     $bPassword = false;
                     $dbSection = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CODE", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD"));
                     while ($arPath = $dbSection->Fetch()) {
                         $arSectionPath[] = $arPath;
                         if (strlen(trim($arPath["UF_PASSWORD"])) > 0) {
                             $bPassword = true;
                             break;
                         }
                     }
                     if (!$alias) {
                         $entity_type = SONET_ENTITY_USER;
                         $entity_id = $arSectionPath[0]["CREATED_BY"];
                         $alias = $arSectionPath[0]["CODE"];
                     }
                     if (!$arSiteWorkgroupsPage && IsModuleInstalled("extranet") && $entity_type == SONET_ENTITY_GROUP) {
                         $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
                         while ($arSite = $rsSite->Fetch()) {
                             $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]);
                         }
                     }
                     if (is_set($arLogParams["SECTION_URL"]) && is_array($arSiteWorkgroupsPage) && $entity_type == SONET_ENTITY_GROUP) {
                         foreach ($arSiteWorkgroupsPage as $groups_page) {
                             if (strpos($arLogParams["SECTION_URL"], $groups_page) === 0) {
                                 $arLogParams["SECTION_URL"] = "#GROUPS_PATH#" . substr($arLogParams["SECTION_URL"], strlen($groups_page), strlen($arLogParams["SECTION_URL"]) - strlen($groups_page));
                             }
                         }
                     }
                 }
                 $arLogParams["ALIAS"] = $alias;
                 $arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array("ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"])), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID" => $arElement["ID"]);
                 if (intval($arElement["CREATED_BY"]) > 0) {
                     $arSonetFields["USER_ID"] = $arElement["CREATED_BY"];
                 }
                 $log_id = CSocNetLog::Add($arSonetFields, false);
                 if (intval($log_id) > 0) {
                     $log_title = $arSonetFields["TITLE"];
                     $log_url = $arSonetFields["URL"];
                     $log_section_name = $arLogParams["SECTION_NAME"];
                     $log_section_url = $arLogParams["SECTION_URL"];
                     $log_user_id = $arSonetFields["USER_ID"];
                     CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
                     if ($bPassword) {
                         CSocNetLogRights::DeleteByLogID($log_id);
                         CSocNetLogRights::Add($log_id, array("U" . $GLOBALS["USER"]->GetID(), "SA"));
                     } else {
                         CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view");
                     }
                 }
             }
         }
         if (intval($log_id) > 0) {
             $arForum = CForumNew::GetByID($this->ForumID);
             $parser = new textParser(LANGUAGE_ID, $this->arPath["PATH_TO_SMILE"]);
             $parser->image_params["width"] = false;
             $parser->image_params["height"] = false;
             $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "SMILES" => "N", "VIDEO" => "N");
             $url = $this->arPath["DETAIL_URL"];
             if ($bSocNetLogRecordExists) {
                 $arMessage = CForumMessage::GetByIDEx($ID);
                 $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arMessage["FORUM_ID"], "TID" => $arMessage["TOPIC_ID"], "MID" => $ID));
                 $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert(empty($arFields["POST_MESSAGE_FILTER"]) ? $arFields["POST_MESSAGE"] : $arFields["POST_MESSAGE_FILTER"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail(empty($arFields["POST_MESSAGE_FILTER"]) ? $arFields["POST_MESSAGE"] : $arFields["POST_MESSAGE_FILTER"]), "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $ID);
                 if (intVal($arMessage["AUTHOR_ID"]) > 0) {
                     $arFieldsForSocnet["USER_ID"] = $arMessage["AUTHOR_ID"];
                 }
                 $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                 if ($comment_id) {
                     CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
                     $arFieldsIM = array("TYPE" => "COMMENT", "TITLE" => $log_title, "MESSAGE" => $arFieldsForSocnet["MESSAGE"], "URL" => $log_url, "SECTION_NAME" => $log_section_name, "SECTION_URL" => $log_section_url, "ID" => $arFields["PARAM2"], "PHOTO_AUTHOR_ID" => $log_user_id, "COMMENT_AUTHOR_ID" => $arMessage["AUTHOR_ID"]);
                     CSocNetPhotoCommentEvent::NotifyIm($arFieldsIM);
                 }
             } else {
                 $dbComments = CForumMessage::GetListEx(array(), array('TOPIC_ID' => $arFields["TOPIC_ID"], "NEW_TOPIC" => "N"));
                 while ($arComment = $dbComments->GetNext()) {
                     $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arComment["FORUM_ID"], "TID" => $arComment["TOPIC_ID"], "MID" => $arComment["ID"]));
                     $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CharToDateFunction($arComment["POST_DATE"], "FULL", SITE_ID), "MESSAGE" => $parser->convert(empty($arComment["POST_MESSAGE_FILTER"]) ? $arComment["POST_MESSAGE"] : $arComment["POST_MESSAGE_FILTER"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail(empty($arComment["POST_MESSAGE_FILTER"]) ? $arComment["POST_MESSAGE"] : $arComment["POST_MESSAGE_FILTER"]), "MODULE_ID" => false, "SOURCE_ID" => $arComment["ID"], "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $arComment["ID"]);
                     if (intVal($arComment["AUTHOR_ID"]) > 0) {
                         $arFieldsForSocnet["USER_ID"] = $arComment["AUTHOR_ID"];
                     }
                     $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                     if ($comment_id) {
                         CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
                         $arFieldsIM = array("TYPE" => "COMMENT", "TITLE" => $log_title, "MESSAGE" => $arFieldsForSocnet["MESSAGE"], "URL" => $log_url, "SECTION_NAME" => $log_section_name, "SECTION_URL" => $log_section_url, "ID" => $arFields["PARAM2"], "PHOTO_AUTHOR_ID" => $log_user_id, "COMMENT_AUTHOR_ID" => $arComment["AUTHOR_ID"]);
                         CSocNetPhotoCommentEvent::NotifyIm($arFieldsIM);
                     }
                 }
                 if ($arElement) {
                     self::InheriteAlbumFollow($arElement["IBLOCK_SECTION_ID"], $log_id, intVal($arElement["CREATED_BY"]) > 0 ? $arElement["CREATED_BY"] : false);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
	function Add($arFields, $strUploadDir = false, $arParams = array())
	{
		global $DB;

		$strUploadDir = ($strUploadDir === false ? "forum/upload" : $strUploadDir);

		if (!CForumMessage::CheckFields("ADD", $arFields))
			return false;

		$arForum = CForumNew::GetByID($arFields["FORUM_ID"]);
		$arParams["SKIP_STATISTIC"] = ($arParams["SKIP_STATISTIC"] == "Y" ? "Y" : "N");
		$arParams["SKIP_INDEXING"] = ($arParams["SKIP_INDEXING"] == "Y" || $arForum["INDEXATION"] != "Y" ? "Y" : "N");

		$POST_MESSAGE = $arFields["POST_MESSAGE"];
		$parser = new forumTextParser(LANGUAGE_ID);
		$allow = forumTextParser::GetFeatures($arForum);
		$allow['SMILES'] = (($arFields["USE_SMILES"] != "Y") ? 'N' : $allow['SMILES']);
		if (COption::GetOptionString("forum", "FILTER", "Y") == "Y")
		{
			$POST_MESSAGE = CFilterUnquotableWords::Filter($POST_MESSAGE);
			$arFields["POST_MESSAGE_FILTER"] = (empty($POST_MESSAGE) ? "*" : $POST_MESSAGE);
		}
/***************** Attach ******************************************/
		$arFiles = array();
		if (is_array($arFields["ATTACH_IMG"]))
			$arFields["FILES"] = array($arFields["ATTACH_IMG"]);
		unset($arFields["ATTACH_IMG"]);
		if (is_array($arFields["FILES"]) && !empty($arFields["FILES"]))
		{
			$res = array("FORUM_ID" => $arFields["FORUM_ID"], "USER_ID" => $arFields["AUTHOR_ID"], "upload_dir" => $strUploadDir);
			$arFiles = CForumFiles::Save($arFields["FILES"], $res, false);
			if (!empty($arFiles))
			{
				$arFiles = array_keys($arFiles);
				sort($arFiles);
				$arFields["ATTACH_IMG"] = $arFiles[0];
				$arFields["ATTACHED_FILES"] = $arFiles;
			}
			unset($arFields["FILES"]);
		}
/***************** Attach/******************************************/
		if (COption::GetOptionString("forum", "MESSAGE_HTML", "N") == "Y")
			$POST_MESSAGE = $parser->convert($POST_MESSAGE, $allow, "html", $arFiles);
		$arFields["POST_MESSAGE_HTML"] = $POST_MESSAGE;
/***************** Event onBeforeMessageAdd ************************/
		foreach(GetModuleEvents("forum", "onBeforeMessageAdd", true) as $arEvent)
		{
			if (ExecuteModuleEventEx($arEvent, array(&$arFields, &$strUploadDir)) === false)
				return false;
		}
/***************** /Event ******************************************/
		if (empty($arFields))
			return false;
		$arInsert = $DB->PrepareInsert("b_forum_message", $arFields, $strUploadDir);

		$strDatePostField = "";
		$strDatePostValue = "";
		if (!is_set($arFields, "POST_DATE"))
		{
			$strDatePostField = ", POST_DATE";
			$strDatePostValue = ", ".$DB->GetNowFunction()."";
		}

		$strSql = "INSERT INTO b_forum_message(".$arInsert[0].$strDatePostField.") VALUES(".$arInsert[1].$strDatePostValue.")";
		$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		$ID = intVal($DB->LastID());
/***************** Attach ******************************************/
		if (!empty($arFiles))
			CForumFiles::UpdateByID($arFiles, array("FORUM_ID" => $arFields["FORUM_ID"],
				"TOPIC_ID" => $arFields["TOPIC_ID"], "MESSAGE_ID" => $ID));
/***************** Attach/******************************************/
/***************** Quota *******************************************/
		$_SESSION["SESS_RECOUNT_DB"] = "Y";

		$GLOBALS["USER_FIELD_MANAGER"]->Update("FORUM_MESSAGE", $ID, $arFields);
		if ($arParams["SKIP_STATISTIC"] == "Y" && $arParams["SKIP_INDEXING"] == "Y")
			return $ID;
		$arMessage = CForumMessage::GetByIDEx($ID, array("GET_FORUM_INFO" => "N", "GET_TOPIC_INFO" => "Y", "FILTER" => "Y"));

		if ($arParams["SKIP_STATISTIC"] != "Y")
		{
			if (intVal($arMessage["AUTHOR_ID"]) > 0)
			{
				CForumUser::SetStat($arMessage["AUTHOR_ID"], array("MESSAGE" => $arMessage));
			}
			CForumTopic::SetStat($arMessage["TOPIC_ID"],  array("MESSAGE" => $arMessage));
			CForumNew::SetStat($arMessage["FORUM_ID"],  array("MESSAGE" => $arMessage));
		}
/***************** Events onAfterMessageAdd ************************/
		foreach(GetModuleEvents("forum", "onAfterMessageAdd", true) as $arEvent)
			ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage, $arMessage["TOPIC_INFO"], $arMessage["FORUM_INFO"], $arFields));
/***************** /Events *****************************************/
		if ($arMessage["APPROVED"] == "Y")
		{
			if ($arParams["SKIP_INDEXING"] != "Y" && CModule::IncludeModule("search"))
			{
				$arMessage["POST_MESSAGE"] = (COption::GetOptionString("forum", "FILTER", "Y") == "Y" ?
					$arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"]);
				$arParams = array(
					"PERMISSION" => array(),
					"SITE" => CForumNew::GetSites($arMessage["FORUM_ID"]),
					"DEFAULT_URL" => "/");

				$arGroups = CForumNew::GetAccessPermissions($arMessage["FORUM_ID"]);
				foreach($arGroups as $arGroup)
				{
					if ($arGroup[1] >= "E")
					{
						$arParams["PERMISSION"][] = $arGroup[0];
						if ($arGroup[0] == 2)
							break;
					}
				}

				$arSearchInd = array(
					"LID" => array(),
					"LAST_MODIFIED" => $arMessage["POST_DATE"],
					"PARAM1" => $arMessage["FORUM_ID"],
					"PARAM2" => $arMessage["TOPIC_ID"],
					"ENTITY_TYPE_ID"  => ($arMessage["NEW_TOPIC"] == "Y"? "FORUM_TOPIC": "FORUM_POST"),
					"ENTITY_ID" => ($arMessage["NEW_TOPIC"] == "Y"? $arMessage["TOPIC_ID"]: $ID),
					"USER_ID" => $arMessage["AUTHOR_ID"],
					"PERMISSIONS" => $arParams["PERMISSION"],
					"TITLE" => $arMessage["TOPIC_INFO"]["TITLE"].($arMessage["NEW_TOPIC"] == "Y" && !empty($arMessage["TOPIC_INFO"]["DESCRIPTION"]) ?
						", ".$arMessage["TOPIC_INFO"]["DESCRIPTION"] : ""),
					"TAGS" => ($arMessage["NEW_TOPIC"] == "Y" ? $arMessage["TOPIC_INFO"]["TAGS"] : ""),
					"BODY" => GetMessage("AVTOR_PREF")." ".$arMessage["AUTHOR_NAME"].". ".(textParser::killAllTags($arMessage["POST_MESSAGE"])),
					"URL" => "",
					"INDEX_TITLE" => $arMessage["NEW_TOPIC"] == "Y",
				);

				// get mentions
				$arMentionedUserID = CForumMessage::GetMentionedUserID($arMessage["POST_MESSAGE"]);
				if (!empty($arMentionedUserID))
				{
					$arSearchInd["PARAMS"] = array(
						"mentioned_user_id" => $arMentionedUserID
					);
				}

				$urlPatterns = array(
					"FORUM_ID" => $arMessage["FORUM_ID"],
					"TOPIC_ID" => $arMessage["TOPIC_ID"],
					"TITLE_SEO" => $arMessage["TOPIC_INFO"]["TITLE_SEO"],
					"MESSAGE_ID" => $arMessage["ID"],
					"SOCNET_GROUP_ID" => $arMessage["TOPIC_INFO"]["SOCNET_GROUP_ID"],
					"OWNER_ID" => $arMessage["TOPIC_INFO"]["OWNER_ID"],
					"PARAM1" => $arMessage["PARAM1"],
					"PARAM2" => $arMessage["PARAM2"]);
				foreach ($arParams["SITE"] as $key => $val)
				{
					$arSearchInd["LID"][$key] = CForumNew::PreparePath2Message($val, $urlPatterns);
					if (empty($arSearchInd["URL"]) && !empty($arSearchInd["LID"][$key]))
						$arSearchInd["URL"] = $arSearchInd["LID"][$key];
				}

				if (empty($arSearchInd["URL"]))
				{
					foreach ($arParams["SITE"] as $key => $val):
						$db_lang = CLang::GetByID($key);
						if ($db_lang && $ar_lang = $db_lang->Fetch()):
							$arParams["DEFAULT_URL"] = $ar_lang["DIR"];
							break;
						endif;
					endforeach;
					$arParams["DEFAULT_URL"] .= COption::GetOptionString("forum", "REL_FPATH", "").
						"forum/read.php?FID=#FID#&TID=#TID#&MID=#MID##message#MID#";

					$arSearchInd["URL"] = CForumNew::PreparePath2Message($arParams["DEFAULT_URL"], $urlPatterns);
				}
				CSearch::Index("forum", $ID, $arSearchInd);
			}
		}
		return $ID;
	}
Ejemplo n.º 5
0
 function convert4mail($text, $arFiles = false)
 {
     $text = textParser::convert4mail($text);
     if ($arFiles !== false) {
         $this->arFiles = is_array($arFiles) ? $arFiles : array($arFiles);
     }
     $this->arFilesIDParsed = array();
     if (!empty($this->arFiles)) {
         $this->ParserFile($text, $this, "mail");
     }
     return $text;
 }
Ejemplo n.º 6
0
    echo ShowMessage(array("MESSAGE" => $strOKMessage, "TYPE" => "OK"));
    ?>
	
	<?php 
    $arFormParams = compact("arForum", "FID", "TID", "MID", "bVarsFromForm", "MESSAGE_TYPE", "strErrorMessage", "strOKMessage");
    if ($bVarsFromForm) {
        $arFormParams["AUTHOR_NAME"] = $_POST["AUTHOR_NAME"];
        $arFormParams["AUTHOR_EMAIL"] = $_POST["AUTHOR_EMAIL"];
        $arFormParams["POST_MESSAGE"] = $_POST["POST_MESSAGE"];
        $arFormParams["USE_SMILES"] = $_POST["USE_SMILES"];
        $arFormParams["TITLE"] = $_POST["TITLE"];
        $arFormParams["DESCRIPTION"] = $_POST["DESCRIPTION"];
        $arFormParams["ICON_ID"] = $_POST["ICON_ID"];
    }
    if ($View) {
        $parser = new textParser(LANGUAGE_ID);
        ?>
<font style="font-size:4px;">&nbsp;<br></font>
		<table width="100%" border="0" cellspacing="0" cellpadding="5">
			<tr class="forumpostsep"><td colspan="2"><a name="postform"></a></td></tr>
			<tr>
				<td valign="top" class="forumbody forumbrd forumbrd1" width="10%"><b><font class="forumtitletext"><?php 
        echo GetMessage("FNT_VIEW");
        ?>
:</font></b></td>
				<td valign="bottom" class="forumbody forumbrd forumbrd1" style="border-left : none;">
					<font style="font-size:5px;">&nbsp;<br></font>
					<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="forumhr"><img src="/bitrix/images/1.gif" width="1" height="1" alt=""></td></tr></table>
					<font style="font-size:8px;">&nbsp;<br></font>
					<font class="forumbodytext"><?php 
        echo $parser->convert($_POST["POST_MESSAGE"], $arAllow);
Ejemplo n.º 7
0
        function PrintMessages($mass, $arUser)
        {
            global $USER;
            $parser = new textParser(LANGUAGE_ID);
            ?>
<table width="100%" border="0" cellspacing="0" cellpadding="5"><?php 
            if (count($mass) <= 0) {
                ?>
<tr><td class="forumtitle" colspan="2">
				<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="top">
					<td width="99%" class="forumtitletext"><b><?php 
                echo GetMessage("LU_NONE_MESSAGE");
                ?>
</b></td>
				</tr></table></td></tr><?php 
            } else {
                foreach ($mass as $arForum) {
                    $strPerms = ForumCurrUserPermissions($arForum["ID"]);
                    if ($strPerms < "E" || $arForum["ACTIVE"] != "Y") {
                        continue;
                    }
                    ?>
<tr><td colspan="2"><font style="font-size:4px;">&nbsp;<br></font></td></tr><?php 
                    ?>
<tr><td class="forumtitle" colspan="2">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="top">
							<td width="99%" class="forumtitletext"><?php 
                    echo GetMessage("FL_FORUM");
                    ?>
 <a href="list.php?FID=<?php 
                    echo $arForum["ID"];
                    ?>
"><b><?php 
                    echo $arForum["NAME"];
                    ?>
</b></a></td>
							<td nowrap width="1%" align="right" class="forumtitletext"><?php 
                    echo GetMessage("LU_USER_POSTS_ON_FORUM");
                    ?>
: <?php 
                    echo $arForum["NUM_POSTS_ALL"];
                    ?>
</td>
						</tr></table></td></tr><?php 
                    ?>
<tr><td colspan="2"><font style="font-size:4px;">&nbsp;<br></font></td></tr><?php 
                    foreach ($arForum["TOPIC"] as $arTopic) {
                        if ($strPerms < "Q" && $arTopic["APPROVED"] != "Y") {
                            continue;
                        }
                        ?>
<tr><td class="forumtitle" colspan="2">
							<table width="100%" border="0" cellspacing="0" cellpadding="0" background="red">
								<tr valign="top">
									<?php 
                        if (strlen($arTopic["IMAGE"]) > 0) {
                            ?>
										<td width="0%"><img src="/bitrix/images/forum/icon/<?php 
                            echo $arTopic["IMAGE"];
                            ?>
" alt="<?php 
                            echo $arTopic["IMAGE_DESCR"];
                            ?>
" border="0" width="15" height="15" vspace="0"><br></td>
										<td class="forumtitletext" width="0%">&nbsp;</td>
									<?php 
                        }
                        ?>
		
									<td class="forumtitletext" width="99%"><font class="forumtitletext">
										<?php 
                        echo GetMessage("FR_TOPIC");
                        ?>
 &laquo;<a href="read.php?FID=<?php 
                        echo $arForum["ID"];
                        ?>
&TID=<?php 
                        echo $arTopic["ID"];
                        ?>
&UID=<?php 
                        echo $arUser["USER_ID"];
                        ?>
"><b><?php 
                        echo htmlspecialcharsEx($arTopic["TITLE"]);
                        ?>
</b><?php 
                        if (strlen($arTopic["DESCRIPTION"]) > 0) {
                            echo ", " . htmlspecialcharsEx($arTopic["DESCRIPTION"]);
                        }
                        ?>
</a >&raquo;  
										<?php 
                        echo GetMessage("FR_ON_FORUM");
                        ?>
 <a href="list.php?FID=<?php 
                        echo $arForum["ID"];
                        ?>
"><b><?php 
                        echo $arForum["NAME"];
                        ?>
</b></a></font></td>
									<td nowrap width="1%" align="right" valign="middle" class="forumtitletext"><?php 
                        echo GetMessage("FR_ON_VIEWS");
                        ?>
 <?php 
                        echo $arTopic["VIEWS"];
                        ?>
<br>
									<?php 
                        echo GetMessage("LU_USER_POSTS_ON_TOPIC");
                        ?>
: <?php 
                        echo $arTopic["COUNT_MESSAGE"];
                        ?>
</td>
								</tr>
							</table>
						</td></tr><?php 
                        ?>
<tr><td colspan="2"><font style="font-size:4px;">&nbsp;<br></font></td></tr><?php 
                        foreach ($arTopic["MESSAGE"] as $arMessage) {
                            if ($strPerms < "Q" && $arMessage["APPROVED"] != "Y") {
                                continue;
                            }
                            ?>
<tr valign="top" class="forumbody">
						<td align="left" rowspan="2" width="140" class="forumbrd" style="border-right:none;">
							<a name="message<?php 
                            echo $arMessage["ID"];
                            ?>
"></a>
							<font class="forumbodytext"><b><?php 
                            echo htmlspecialcharsEx($arMessage["AUTHOR_NAME"]);
                            ?>
</b>
							<br><font class=\"forumheadcolor\"><?php 
                            echo htmlSpecialCharsEx($arForum["USER_PERM_STR"]);
                            ?>
</font>
							<br>
							<?php 
                            if (strlen($arUser["AVATAR"]) > 0) {
                                ?>
								<a href="view_profile.php?UID=<?php 
                                echo $arUser["USER_ID"];
                                ?>
&FID=<?php 
                                echo $arForum["ID"];
                                ?>
&TID=<?php 
                                echo $arTopic["ID"];
                                ?>
&MID=<?php 
                                echo $arMessage["ID"];
                                ?>
" title="<?php 
                                echo GetMessage("FR_AUTHOR_PROFILE");
                                ?>
"><?php 
                                echo CFile::ShowImage($arUser["AVATAR"], 90, 90, "border=0 vspace=5", "", true);
                                ?>
</a><br>
							<?php 
                            }
                            ?>
							<?php 
                            if (strlen($arUser["DESCRIPTION"]) > 0) {
                                ?>
								<i><?php 
                                echo htmlspecialcharsEx($arUser["DESCRIPTION"]);
                                ?>
</i><br>
							<?php 
                            }
                            ?>
							<font style="font-size:8px;">&nbsp;<br></font>
							<?php 
                            if (IntVal($arUser["NUM_POSTS"]) > 0) {
                                ?>
								<font class="forumheadcolor"><?php 
                                echo GetMessage("FR_NUM_MESS");
                                ?>
</font> <?php 
                                echo $arUser["NUM_POSTS"];
                                ?>
<br>
							<?php 
                            }
                            ?>
							<?php 
                            if (strlen($arUser["DATE_REG"]) > 0) {
                                ?>
								<font class="forumheadcolor"><?php 
                                echo GetMessage("FR_DATE_REGISTER");
                                ?>
</font> <?php 
                                echo $arUser["DATE_REG"];
                                ?>
<br>
							<?php 
                            }
                            ?>
							</font>
						</td>
						<td class="forumbrd forumbrd1" style="border-bottom:none;">
							<table border="0" cellspacing="0" cellpadding="0" width="100%">
								<tr><td width="100%"><font class="forumbodytext"><font class="forumheadcolor"><?php 
                            echo GetMessage("FR_DATE_CREATE");
                            ?>
</font><nobr><?php 
                            echo $arMessage["POST_DATE"];
                            ?>
</nobr><br></font></td></tr></table>
							<font style="font-size:5px;">&nbsp;<br></font>
							<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="forumhr"><img src="/bitrix/images/1.gif" width="1" height="1" alt=""></td></tr></table>
							<font style="font-size:8px;">&nbsp;<br></font>
							<font class="forumbodytext">
							<?php 
                            $arForum["ALLOW"]["SMILES"] = $arForum["ALLOW_SMILES"];
                            if ($arMessage["USE_SMILES"] != "Y") {
                                $arForum["ALLOW"]["SMILES"] = "N";
                            }
                            if (COption::GetOptionString("forum", "FILTER", "Y") == "Y" || COption::GetOptionString("forum", "MESSAGE_HTML", "Y") == "Y") {
                                $message = $arMessage["POST_MESSAGE_HTML"];
                            } else {
                                $message = $arMessage["POST_MESSAGE"];
                            }
                            if (COption::GetOptionString("forum", "MESSAGE_HTML", "Y") == "N") {
                                $message = $parser->convert($message, $arAllow);
                            }
                            echo $message;
                            if (IntVal($arMessage["ATTACH_IMG"]) > 0) {
                                echo "<br><br>";
                                if ($arForum["ALLOW_UPLOAD"] == "Y" || $arForum["ALLOW_UPLOAD"] == "F" || $arForum["ALLOW_UPLOAD"] == "A") {
                                    echo CFile::ShowFile($arMessage["ATTACH_IMG"], 0, 300, 300, true, "border=0", false);
                                }
                            }
                            if (strlen($arUser["SIGNATURE"]) > 0) {
                                echo "<br><br><font class=\"forumsigntext\">";
                                $arForum["ALLOW"]["SMILES"] = "N";
                                echo $parser->convert($arUser["SIGNATURE"], $arForum["ALLOW"]);
                                echo "</font>";
                            }
                            ?>
							</font>
						</td>
					</tr>
					<tr>
						<td valign="bottom" class="forumbody forumbrd forumbrd1" style="border-top:none;">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr><td class="forumhr"><img src="/bitrix/images/1.gif" width="1" height="1" alt=""></td></tr></table>
							<font style="font-size:5px;">&nbsp;<br></font>
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr valign="top">
									<td>
										<table border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td nowrap class="forummessbutton"><a href="view_profile.php?UID=<?php 
                            echo $arMessage["AUTHOR_ID"];
                            ?>
&FID=<?php 
                            echo $arForum["ID"];
                            ?>
&TID=<?php 
                            echo $arTopic["ID"];
                            ?>
&MID=<?php 
                            echo $arMessage["ID"];
                            ?>
" title="<?php 
                            echo GetMessage("FR_AUTHOR_PROFILE");
                            ?>
" class="forummessbuttontext"><?php 
                            echo GetMessage("FR_PROFILE");
                            ?>
</a></td>
												<td><div class="forummessbuttonsep"></div></td>
												<?php 
                            if (strlen($arUser["EMAIL"]) > 0) {
                                ?>
													<td nowrap class="forummessbutton"><a href="send_message.php?TYPE=MAIL&UID=<?php 
                                echo $arMessage["AUTHOR_ID"];
                                ?>
" title="<?php 
                                echo GetMessage("FR_EMAIL_AUTHOR");
                                ?>
" class="forummessbuttontext">E-Mail</a></td>
													<td><div class="forummessbuttonsep"></div></td>
												<?php 
                            }
                            ?>
												<?php 
                            if (strLen($arUser["PERSONAL_ICQ"]) > 0 && COption::GetOptionString("forum", "SHOW_ICQ_CONTACT", "N") == "Y") {
                                ?>
													<td nowrap class="forummessbutton"><a href="send_message.php?TYPE=ICQ&UID=<?php 
                                echo $arMessage["AUTHOR_ID"];
                                ?>
" title="<?php 
                                echo GetMessage("FR_ICQ_AUTHOR");
                                ?>
" class="forummessbuttontext">ICQ</a></td>
													<td><div class="forummessbuttonsep"></div></td>
												<?php 
                            }
                            ?>
												<?php 
                            if ($USER->IsAuthorized()) {
                                ?>
													<td nowrap class="forummessbutton"><a href="pm_message.php?mode=new&USER_ID=<?php 
                                echo $arMessage["AUTHOR_ID"];
                                ?>
" title="<?php 
                                echo GetMessage("FR_PRIVATE_MESSAGE");
                                ?>
"  class="forummessbuttontext">P-Mess</a></td>
													<td><div class="forummessbuttonsep"></div></td>
												<?php 
                            }
                            ?>
												<?php 
                            ?>
</tr>
										</table>
										<?php 
                            if (ForumCurrUserPermissions($arForum["ID"]) >= "Q" || $arTopic["LAST_TOPIC_MESSAGE"] == IntVal($arMessage["ID"]) && $USER->IsAuthorized() && IntVal($ar_Message["AUTHOR_ID"]) == IntVal($USER->GetParam("USER_ID")) || $arTopic["USER_PERM_DELETE"]) {
                                ?>
											<font style="font-size:4px;">&nbsp;<br></font>
											<table border="0" cellspacing="0" cellpadding="0">
												<tr>
													<?php 
                                if ($arMessage["APPROVED"] == "Y" && ForumCurrUserPermissions($arForum["ID"]) >= "Q") {
                                    ?>
														<td nowrap class="forummessbutton"><a href="read.php?FID=<?php 
                                    echo $arForum["ID"];
                                    ?>
&TID=<?php 
                                    echo $arTopic["ID"];
                                    ?>
&MID=<?php 
                                    echo $arMessage["ID"];
                                    ?>
&ACTION=HIDE&<?php 
                                    echo bitrix_sessid_get();
                                    ?>
" title="<?php 
                                    echo GetMessage("FR_HIDE_MESS");
                                    ?>
" class="forummessbuttontext"><?php 
                                    echo GetMessage("FR_HIDE");
                                    ?>
</a></td>
														<td><div class="forummessbuttonsep"></div></td>
													<?php 
                                } elseif (ForumCurrUserPermissions($arForum["ID"]) >= "Q") {
                                    ?>
														<td nowrap class="forummessbutton"><a href="read.php?FID=<?php 
                                    echo $arForum["ID"];
                                    ?>
&TID=<?php 
                                    echo $arTopic["ID"];
                                    ?>
&MID=<?php 
                                    echo $arMessage["ID"];
                                    ?>
&ACTION=SHOW&<?php 
                                    echo bitrix_sessid_get();
                                    ?>
" title="<?php 
                                    echo GetMessage("FR_SHOW_MESS");
                                    ?>
" class="forummessbuttontext"><i><b><?php 
                                    echo GetMessage("FR_SHOW");
                                    ?>
</b></i></a></td>
														<td><div class="forummessbuttonsep"></div></td>
													<?php 
                                }
                                ?>
													<?php 
                                if (ForumCurrUserPermissions($arForum["ID"]) >= "U" || $arTopic["LAST_TOPIC_MESSAGE"] == IntVal($arMessage["ID"]) && $USER->IsAuthorized() && IntVal($arMessage["AUTHOR_ID"]) == IntVal($USER->GetParam("USER_ID"))) {
                                    ?>
														<td nowrap class="forummessbutton"><a href="new_topic.php?FID=<?php 
                                    echo $arForum["ID"];
                                    ?>
&TID=<?php 
                                    echo $arTopic["ID"];
                                    ?>
&MID=<?php 
                                    echo $arMessage["ID"];
                                    ?>
&MESSAGE_TYPE=EDIT" title="<?php 
                                    echo GetMessage("FR_EDIT_MESS");
                                    ?>
" class="forummessbuttontext"><?php 
                                    echo GetMessage("FR_EDIT");
                                    ?>
</a></td>
														<td><div class="forummessbuttonsep"></div></td>
													<?php 
                                }
                                ?>
													<?php 
                                if ($arTopic["USER_PERM_DELETE"]) {
                                    ?>
														<td nowrap class="forummessbutton"><a href="read.php?FID=<?php 
                                    echo $arForum["ID"];
                                    ?>
&TID=<?php 
                                    echo $arTopic["ID"];
                                    ?>
&MID=<?php 
                                    echo $arMessage["ID"];
                                    ?>
&ACTION=DEL&<?php 
                                    echo bitrix_sessid_get();
                                    ?>
" title="<?php 
                                    echo GetMessage("FR_DELETE_MESS");
                                    ?>
" class="forummessbuttontext"><?php 
                                    echo GetMessage("FR_DELETE");
                                    ?>
</a></td>
														<td><div class="forummessbuttonsep"></div></td>
														<?php 
                                    if (IntVal($arMessage["AUTHOR_ID"]) > 0 && CModule::IncludeModule("support")) {
                                        ?>
															<td nowrap class="forummessbutton"><a href="read.php?FID=<?php 
                                        echo $arForum["ID"];
                                        ?>
&TID=<?php 
                                        echo $arTopic["ID"];
                                        ?>
&MID=<?php 
                                        echo $arMessage["ID"];
                                        ?>
&ACTION=FORUM_MESSAGE2SUPPORT&<?php 
                                        echo bitrix_sessid_get();
                                        ?>
" title="<?php 
                                        echo GetMessage("FR_MOVE2SUPPORT");
                                        ?>
" class="forummessbuttontext"><?php 
                                        echo GetMessage("FR_2SUPPORT");
                                        ?>
</a></td>
															<td><div class="forummessbuttonsep"></div></td>
														<?php 
                                    }
                                    ?>
													<?php 
                                }
                                ?>
													</font>
												</tr>
											</table>
										<?php 
                            }
                            ?>
									</td>
									<td align="right">
										<table border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td nowrap class="forummessbutton" style="padding-left:2px; padding-right:2px;"><a href="javascript:scroll(0,0);" title="<?php 
                            echo GetMessage("FR_2TOP");
                            ?>
" class="forummessbuttontext"><?php 
                            echo GetMessage("FR_TOP");
                            ?>
</a></td>
										  </tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr><?php 
                            ?>
<tr><td colspan="2"><font style="font-size:4px;">&nbsp;<br></font></td></tr><?php 
                        }
                    }
                }
            }
            ?>
</table><?php 
        }
Ejemplo n.º 8
0
	public static function Reindex($ID, &$arMessage)
	{
		if (!CModule::IncludeModule("search")) return;
		if (!is_set($arMessage, "FORUM_INFO") || !is_set($arMessage, "TOPIC_INFO"))
			$arMessage = CForumMessage::GetByIDEx($arMessage['ID'], array("GET_TOPIC_INFO" => "Y", "GET_FORUM_INFO" => "Y", "FILTER" => "Y"));

		$arForum = $arMessage["FORUM_INFO"];
		$arTopic = $arMessage["TOPIC_INFO"];
		$arMessage["POST_MESSAGE"] = (COption::GetOptionString("forum", "FILTER", "Y") == "Y" ?
			$arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"]);

		$arParams = array(
			"PERMISSION" => array(),
			"SITE" => CForumNew::GetSites($arMessage["FORUM_ID"]),
			"DEFAULT_URL" => "/");

		$arGroups = CForumNew::GetAccessPermissions($arMessage["FORUM_ID"]);
		for ($i = 0; $i < count($arGroups); $i++)
		{
			if ($arGroups[$i][1] >= "E")
			{
				$arParams["PERMISSION"][] = $arGroups[$i][0];
				if ($arGroups[$i][0] == 2)
					break;
			}
		}

		$arSearchInd = array(
			"LID" => array(),
			"LAST_MODIFIED" => $arMessage["POST_DATE"],
			"PARAM1" => $arMessage["FORUM_ID"],
			"PARAM2" => $arMessage["TOPIC_ID"],
			"PERMISSIONS" => $arParams["PERMISSION"],
			"TITLE" => $arMessage["TOPIC_INFO"]["TITLE"],
			"TAGS" => (($arMessage["NEW_TOPIC"] == "Y") ? $arMessage["TOPIC_INFO"]["TAGS"] : ""),
			"BODY" => GetMessage("AVTOR_PREF")." ".$arMessage["AUTHOR_NAME"].". ".(textParser::killAllTags($arMessage["POST_MESSAGE"])),
			"ENTITY_TYPE_ID"  => $arMessage["NEW_TOPIC"] == "Y"? "FORUM_TOPIC": "FORUM_POST",
			"ENTITY_ID"  => $arMessage["NEW_TOPIC"] == "Y"? $arMessage["TOPIC_ID"]: $arMessage["ID"],
			"USER_ID" => $arMessage["AUTHOR_ID"],
			"URL" => "",
			"INDEX_TITLE" => $arMessage["NEW_TOPIC"] == "Y",
		);

		foreach ($arParams["SITE"] as $key => $val)
		{
			$arSearchInd["LID"][$key] =
				CForumNew::PreparePath2Message(
					$val,
					array(
						"FORUM_ID" => $arMessage["FORUM_ID"],
						"TOPIC_ID" => $arMessage["TOPIC_ID"],
						"MESSAGE_ID" => $arMessage["ID"],
						"SOCNET_GROUP_ID" => $arMessage["TOPIC_INFO"]["SOCNET_GROUP_ID"],
						"OWNER_ID" => $arMessage["TOPIC_INFO"]["OWNER_ID"],
						"PARAM1" => $arMessage["PARAM1"],
						"PARAM2" => $arMessage["PARAM2"]));
			if (empty($arSearchInd["URL"]) && !empty($arSearchInd["LID"][$key]))
				$arSearchInd["URL"] = $arSearchInd["LID"][$key];
		}

		if (empty($arSearchInd["URL"]))
		{
			foreach ($arParams["SITE"] as $key => $val) {
				$db_lang = CLang::GetByID($key);
				if ($db_lang && $ar_lang = $db_lang->Fetch()){
					$arParams["DEFAULT_URL"] = $ar_lang["DIR"];
					break;
				}
			}
			$arParams["DEFAULT_URL"] .= COption::GetOptionString("forum", "REL_FPATH", "").
				"forum/read.php?FID=#FID#&TID=#TID#&MID=#MID##message#MID#";

			$arSearchInd["URL"] = CForumNew::PreparePath2Message($arParams["DEFAULT_URL"],
				array("FORUM_ID" => $arMessage["FORUM_ID"], "TOPIC_ID" => $arMessage["TOPIC_ID"], "MESSAGE_ID" => $arMessage["ID"],
				"SOCNET_GROUP_ID" => $arMessage["TOPIC_INFO"]["SOCNET_GROUP_ID"], "OWNER_ID" => $arMessage["TOPIC_INFO"]["OWNER_ID"],
				"PARAM1" => $arMessage["PARAM1"], "PARAM2" => $arMessage["PARAM2"]));
		}
		CSearch::DeleteIndex("forum", $ID);
		CSearch::Index("forum", $ID, $arSearchInd, true);
	}
Ejemplo n.º 9
0
 function onAfterMessageAdd($ID, $arFields)
 {
     $bSocNetLogRecordExists = false;
     // add log comment
     if ((!array_key_exists('PARAM1', $arFields) || $arFields['PARAM1'] != 'IB') && array_key_exists('PARAM2', $arFields) && intval($arFields['PARAM2']) > 0) {
         $dbRes = CSocNetLog::GetList(array('ID' => 'DESC'), array("EVENT_ID" => "wiki", "SOURCE_ID" => $arFields["PARAM2"]), false, false, array('ID', 'ENTITY_TYPE', 'ENTITY_ID', 'TMP_ID', 'URL'));
         if ($arRes = $dbRes->Fetch()) {
             $log_id = $arRes['TMP_ID'];
             $url = $arRes['URL'];
             $bSocNetLogRecordExists = true;
         } else {
             $rsElement = CIBlockElement::GetByID($arFields['PARAM2']);
             if ($arElement = $rsElement->Fetch()) {
                 $arWikiElement = CWiki::GetElementById($arElement['ID'], array('IBLOCK_ID' => $arElement['IBLOCK_ID']));
                 $CWikiParser = new CWikiParser();
                 $parserLog = new logTextParser();
                 $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "N");
                 $text4message = $CWikiParser->Parse($arElement['DETAIL_TEXT'], $arElement['DETAIL_TEXT_TYPE'], $arWikiElement['IMAGES']);
                 $text4message = preg_replace("#<br[\\s]*\\/>#is", "#BR#", $text4message);
                 $text4message = htmlspecialcharsback($parserLog->convert($text4message, array(), $arAllow));
                 $text4message = preg_replace("#\\#BR\\##is", "\n", $text4message);
                 $text4message = $CWikiParser->Clear($text4message);
                 $url = str_replace(array('#group_id#', '#wiki_name#'), array(intval($this->SonetGroupID), urlencode($arElement['NAME'])), $this->arPath['PATH_TO_POST']);
                 $arSoFields = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'IS_CUSTOM_ET' => 'N', 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki', 'USER_ID' => $arElement['CREATED_BY'], 'LOG_DATE' => $arElement['DATE_CREATE'], 'LOG_UPDATE' => $arElement['DATE_CREATE'], 'TITLE_TEMPLATE' => GetMessage('WIKI_SONET_LOG_TITLE_TEMPLATE'), 'TITLE' => $arElement['NAME'], 'MESSAGE' => $text4message, 'TEXT_MESSAGE' => '', 'MODULE_ID' => 'wiki', 'URL' => $url, 'CALLBACK_FUNC' => false, 'SOURCE_ID' => $arFields['PARAM2'], 'PARAMS' => 'forum_id=' . $this->ForumID, 'RATING_TYPE_ID' => 'IBLOCK_ELEMENT', 'RATING_ENTITY_ID' => intval($arFields['PARAM2']));
                 $log_id = CSocNetLog::Add($arSoFields, false);
                 if (intval($log_id) > 0) {
                     CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
                     CSocNetLogRights::SetForSonet($log_id, SONET_SUBSCRIBE_ENTITY_GROUP, intval($this->SonetGroupID), "wiki", "view", true);
                 }
             }
         }
         if (intval($log_id) > 0) {
             $arForum = CForumNew::GetByID($this->ForumID);
             $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']);
             $parser->image_params['width'] = false;
             $parser->image_params['height'] = false;
             $arAllow = array('HTML' => "N", 'ANCHOR' => "N", 'BIU' => "N", 'IMG' => "N", 'LIST' => "N", 'QUOTE' => "N", 'CODE' => "N", 'FONT' => "N", 'UPLOAD' => $arForum['ALLOW_UPLOAD'], 'NL2BR' => "N", 'SMILES' => "N");
             $sAuthorForMail = str_replace('#TITLE#', $arMessage['AUTHOR_NAME'], GetMessage('SONET_FORUM_LOG_TEMPLATE_GUEST'));
             if ($bSocNetLogRecordExists) {
                 $arMessage = CForumMessage::GetByIDEx($ID);
                 $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']);
                 $parser->image_params['width'] = false;
                 $parser->image_params['height'] = false;
                 if (intVal($arMessage['AUTHOR_ID']) > 0) {
                     $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR'));
                 }
                 $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CurrentTimeFunction(), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $url, 'MODULE_ID' => false, 'SOURCE_ID' => $ID, 'LOG_ID' => $log_id, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID']));
                 if (intVal($arMessage['AUTHOR_ID']) > 0) {
                     $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID'];
                 }
                 CSocNetLogComments::Add($arFieldsForSocnet);
             } else {
                 $dbMessage = CForumMessage::GetListEx(array(), array('TOPIC_ID' => $arFields["TOPIC_ID"], "NEW_TOPIC" => "N"));
                 while ($arMessage = $dbMessage->GetNext()) {
                     if (intVal($arMessage['AUTHOR_ID']) > 0) {
                         $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR'));
                     }
                     $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CharToDateFunction($arMessage['POST_DATE'], "FULL", SITE_ID), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $url, 'MODULE_ID' => false, 'SOURCE_ID' => $ID, 'LOG_ID' => $log_id, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID']));
                     if (intVal($arMessage['AUTHOR_ID']) > 0) {
                         $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID'];
                     }
                     CSocNetLogComments::Add($arFieldsForSocnet);
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
    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"));
    ?>
</td>
			<?php 
    if (CForumTopic::CanUserAddTopic($FID, $USER->GetUserGroupArray(), $USER->GetID())) {
        ?>
				<form action='new_topic.php' method='GET'><td align='right'>
				<input type='hidden' name='FID' value='<?php 
        echo $FID;
        ?>
Ejemplo n.º 11
0
    $APPLICATION->SetTitle("Форум &laquo;" . $arForum["NAME"] . "&raquo;");
    $APPLICATION->SetTemplateCSS("forum/forum_tmpl_2/forum.css");
    $arMenuParams = compact("arTopic", "FID", "TID");
    $APPLICATION->IncludeFile("forum/forum_tmpl_2/menu.php", $arMenuParams);
    ?>

<?php 
    echo ShowMessage(array("MESSAGE" => $strErrorMessage, "TYPE" => "ERROR"));
    echo ShowMessage(array("MESSAGE" => $strOKMessage, "TYPE" => "OK"));
    ?>

<?php 
    if ($GLOBALS["SHOW_FORUM_DEBUG_INFO"]) {
        $prexectime = getmicrotime();
    }
    $parser = new textParser(LANGUAGE_ID);
    $bCanUserDeleteMessages = CForumTopic::CanUserDeleteTopicMessage($TID, $USER->GetUserGroupArray(), $USER->GetID());
    $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"]);
    $iLAST_TOPIC_MESSAGE = 0;
    $db_res = CForumMessage::GetList(array("ID" => "DESC"), array("TOPIC_ID" => $TID), false, 1);
    if ($ar_res = $db_res->Fetch()) {
        $iLAST_TOPIC_MESSAGE = IntVal($ar_res["ID"]);
    }
    $arFilter = array("TOPIC_ID" => $TID);
    if (ForumCurrUserPermissions($FID) < "Q") {
        $arFilter["APPROVED"] = "Y";
    }
    $db_Message = CForumMessage::GetListEx(array("ID" => "ASC"), $arFilter);
    if ($MID > 0) {
        $db_Message->NavStart($GLOBALS["FORUM_MESSAGES_PER_PAGE"], true, CForumMessage::GetMessagePage($MID, $GLOBALS["FORUM_MESSAGES_PER_PAGE"], $USER->GetUserGroupArray()));
    } else {
Ejemplo n.º 12
0
 private function createLogComment($messageID, $bSocNetLogRecordExists, $iblockElementID, $topicID, $arLogParams)
 {
     $dbComment = CSocNetLogComments::GetList(array(), array('EVENT_ID' => 'wiki_comment', 'SOURCE_ID' => $messageID), false, false, array('ID'));
     if (($arComment = $dbComment->Fetch()) && intval($arComment['ID']) > 0) {
         return false;
     }
     $arForum = CForumNew::GetByID($this->ForumID);
     $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']);
     $parser->image_params['width'] = false;
     $parser->image_params['height'] = false;
     $arAllow = array('HTML' => "N", 'ANCHOR' => "N", 'BIU' => "N", 'IMG' => "N", 'LIST' => "N", 'QUOTE' => "N", 'CODE' => "N", 'FONT' => "N", 'UPLOAD' => $arForum['ALLOW_UPLOAD'], 'NL2BR' => "N", 'SMILES' => "N");
     if ($bSocNetLogRecordExists) {
         $arMessage = CForumMessage::GetByIDEx($messageID);
         $sAuthorForMail = str_replace('#TITLE#', $arMessage['AUTHOR_NAME'], GetMessage('SONET_FORUM_LOG_TEMPLATE_GUEST'));
         $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']);
         $parser->image_params['width'] = false;
         $parser->image_params['height'] = false;
         if (intVal($arMessage['AUTHOR_ID']) > 0) {
             $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR'));
         }
         $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CharToDateFunction($arMessage['POST_DATE'], "FULL", SITE_ID), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $arLogParams["URL"], 'MODULE_ID' => false, 'SOURCE_ID' => $messageID, 'LOG_ID' => $arLogParams["LOG_ID"], 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID']));
         if (intVal($arMessage['AUTHOR_ID']) > 0) {
             $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID'];
         }
         $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
         if ($log_comment_id) {
             CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC");
             if (CModule::IncludeModule("im") && intval($arMessage["AUTHOR_ID"]) > 0 && $arMessage["AUTHOR_ID"] != $arLogParams["LOG_USER_ID"]) {
                 $rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arLogParams["LOG_USER_ID"], "CODE" => "L" . $arLogParams["LOG_ID"], "TYPE" => "N"), array("USER_ID"));
                 $arUnFollower = $rsUnFollower->Fetch();
                 if (!$arUnFollower) {
                     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arLogParams["LOG_USER_ID"], "FROM_USER_ID" => $arMessage["AUTHOR_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "wiki", "NOTIFY_EVENT" => "comment");
                     $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arLogParams["LOG_TITLE"]);
                     $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
                     $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
                     $arTmp = CSocNetLogTools::ProcessPath(array("ELEMENT_URL" => $arLogParams["URL"]), $arLogParams["LOG_USER_ID"]);
                     $serverName = $arTmp["SERVER_NAME"];
                     $url = $arTmp["URLS"]["ELEMENT_URL"];
                     $arMessageFields["NOTIFY_TAG"] = "WIKI|COMMENT|" . $iblockElementID;
                     $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("WIKI_SONET_IM_COMMENT", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                     $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("WIKI_SONET_IM_COMMENT", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $url . ")#BR##BR#" . $arFieldsForSocnet["MESSAGE"];
                     CIMNotify::Add($arMessageFields);
                 }
             }
         }
     } else {
         $dbMessage = CForumMessage::GetListEx(array(), array("TOPIC_ID" => $topicID, "NEW_TOPIC" => "N"));
         while ($arMessage = $dbMessage->GetNext()) {
             if (intVal($arMessage['AUTHOR_ID']) > 0) {
                 $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR'));
             }
             $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CharToDateFunction($arMessage['POST_DATE'], "FULL", SITE_ID), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $arLogParams["URL"], 'MODULE_ID' => false, 'SOURCE_ID' => $arMessage['ID'], 'LOG_ID' => $arLogParams["LOG_ID"], 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID']));
             if (intVal($arMessage['AUTHOR_ID']) > 0) {
                 $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID'];
             }
             $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
             CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC");
         }
     }
 }
Ejemplo n.º 13
0
 public function SocnetLogMessageAdd($ID, $arFields, $bUpdate = false)
 {
     $arForum = CForumNew::GetByID($this->forumID);
     $arMessage = CForumMessage::GetByIDEx($ID);
     if ($arMessage["TOPIC_ID"]) {
         $arTopic = CForumTopic::GetByID($arMessage["TOPIC_ID"]);
     }
     $arRes = $this->_getSocnetLogEntityByComment($arMessage);
     if ($arRes && intval($arRes["TMP_ID"]) > 0) {
         $parser = new textParser(LANGUAGE_ID, $this->arPath["PATH_TO_SMILE"]);
         $parser->image_params["width"] = false;
         $parser->image_params["height"] = false;
         $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "SMILES" => "N");
         if (intval($arRes["COMMENTS_COUNT"]) == intval($arTopic["POSTS"])) {
             $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arMessage["FORUM_ID"], "TID" => $arMessage["TOPIC_ID"], "MID" => $ID));
             $arFieldsForSocnet = array("ENTITY_TYPE" => $arRes["ENTITY_TYPE"], "ENTITY_ID" => $arRes["ENTITY_ID"], "EVENT_ID" => $this->event_comments_id, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert($arMessage["POST_MESSAGE"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($arMessage["POST_MESSAGE"]), "URL" => $url, "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $arRes["TMP_ID"], "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => intval($ID));
             if (intVal($arMessage["AUTHOR_ID"]) > 0) {
                 $arFieldsForSocnet["USER_ID"] = $arMessage["AUTHOR_ID"];
             }
             if ($bUpdate) {
                 $commentID = $this->_getSocnetLogCommentByForumComment($ID, $arRes);
                 if ($arMessage['APPROVED'] == 'Y') {
                     if ($commentID) {
                         CSocNetLogComments::Update($commentID, $arFieldsForSocnet);
                     } else {
                         $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                         //, true
                         CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC");
                     }
                 } else {
                     if ($commentID) {
                         CSocNetLogComments::Delete($commentID);
                     }
                 }
             } else {
                 $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                 //, true
                 CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC");
             }
         } else {
             $dbComments = CForumMessage::GetListEx(array(), array('TOPIC_ID' => $arMessage["TOPIC_ID"], "NEW_TOPIC" => "N"));
             while ($arComment = $dbComments->GetNext()) {
                 $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arComment["FORUM_ID"], "TID" => $arComment["TOPIC_ID"], "MID" => $arComment["ID"]));
                 $arFieldsForSocnet = array("ENTITY_TYPE" => $arRes["ENTITY_TYPE"], "ENTITY_ID" => $arRes["ENTITY_ID"], "EVENT_ID" => $this->event_comments_id, "=LOG_DATE" => $GLOBALS["DB"]->CharToDateFunction($arComment['POST_DATE'], "FULL", SITE_ID), "MESSAGE" => $parser->convert($arComment["POST_MESSAGE"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($arComment["POST_MESSAGE"]), "URL" => $url, "MODULE_ID" => false, "SOURCE_ID" => $arComment["ID"], "LOG_ID" => $arRes["TMP_ID"], "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => intval($arComment["ID"]));
                 if (intVal($arComment["AUTHOR_ID"]) > 0) {
                     $arFieldsForSocnet["USER_ID"] = $arComment["AUTHOR_ID"];
                 }
                 $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                 //, true
                 CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC");
             }
         }
     }
 }