Пример #1
0
 public static function Set($user_id, $page_last_date, $page_size, $page_num = 1, $site_id = SITE_ID, $group_code = '**', $traffic_avg = false, $traffic_cnt = false)
 {
     global $DB;
     $user_id = intval($user_id);
     $page_size = intval($page_size);
     $page_num = intval($page_num);
     $traffic_avg = intval($traffic_avg);
     $traffic_cnt = intval($traffic_cnt);
     if ($user_id <= 0 || $page_size <= 0 || strlen($page_last_date) <= 0) {
         return false;
     }
     $page_last_date = new \Bitrix\Main\Type\DateTime($page_last_date);
     $connection = \Bitrix\Main\Application::getConnection();
     $helper = $connection->getSqlHelper();
     $arInsertFields = array("USER_ID" => $user_id, "SITE_ID" => $DB->ForSQL($site_id), "GROUP_CODE" => $DB->ForSQL($group_code), "PAGE_SIZE" => $page_size, "PAGE_NUM" => $page_num, "PAGE_LAST_DATE" => $page_last_date);
     $arUpdateFields = array("PAGE_LAST_DATE" => $page_last_date);
     if ($traffic_cnt) {
         $arInsertFields["TRAFFIC_AVG"] = $arUpdateFields["TRAFFIC_AVG"] = $traffic_avg;
         $arInsertFields["TRAFFIC_CNT"] = $arUpdateFields["TRAFFIC_CNT"] = $traffic_cnt;
         $arInsertFields["TRAFFIC_LAST_DATE"] = $arUpdateFields["TRAFFIC_LAST_DATE"] = new \Bitrix\Main\DB\SqlExpression($helper->getCurrentDateTimeFunction());
     }
     $merge = $helper->prepareMerge("b_sonet_log_page", array("USER_ID", "SITE_ID", "GROUP_CODE", "PAGE_SIZE", "PAGE_NUM"), $arInsertFields, $arUpdateFields);
     if ($merge[0] != "") {
         $connection->query($merge[0]);
         if ($traffic_cnt) {
             CSocNetLogFollow::checkAutoUnfollow($traffic_cnt, $traffic_avg, $user_id);
         }
     }
 }
Пример #2
0
 function Add($LOG_ID, $GROUP_CODE)
 {
     global $DB;
     if (is_array($GROUP_CODE)) {
         foreach ($GROUP_CODE as $GROUP_CODE_TMP) {
             CSocNetLogRights::Add($LOG_ID, $GROUP_CODE_TMP);
         }
         return false;
     } else {
         $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogRightsAdd");
         while ($arEvent = $db_events->Fetch()) {
             if (ExecuteModuleEventEx($arEvent, array($LOG_ID, &$GROUP_CODE)) === false) {
                 return false;
             }
         }
         $NEW_RIGHT_ID = $DB->Add("b_sonet_log_right", array("LOG_ID" => $LOG_ID, "GROUP_CODE" => $GROUP_CODE));
         if (preg_match('/^U(\\d+)$/', $GROUP_CODE, $matches)) {
             CSocNetLogFollow::Set($matches[1], "L" . $LOG_ID, "Y");
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_" . intval($LOG_ID));
         }
         return $NEW_RIGHT_ID;
     }
 }
Пример #3
0
 public static function Add($LOG_ID, $GROUP_CODE, $bShare = false, $followSet = true)
 {
     global $DB;
     if (is_array($GROUP_CODE)) {
         foreach ($GROUP_CODE as $GROUP_CODE_TMP) {
             CSocNetLogRights::Add($LOG_ID, $GROUP_CODE_TMP, $bShare, $followSet);
         }
         return false;
     } else {
         $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogRightsAdd");
         while ($arEvent = $db_events->Fetch()) {
             if (ExecuteModuleEventEx($arEvent, array($LOG_ID, $GROUP_CODE)) === false) {
                 return false;
             }
         }
         $NEW_RIGHT_ID = $DB->Add("b_sonet_log_right", array("LOG_ID" => $LOG_ID, "GROUP_CODE" => $GROUP_CODE), array(), "", true);
         if ($NEW_RIGHT_ID) {
             if (preg_match('/^U(\\d+)$/', $GROUP_CODE, $matches)) {
                 if ($followSet) {
                     CSocNetLogFollow::Set($matches[1], "L" . $LOG_ID, "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
                 }
             } elseif ($bShare && preg_match('/^SG(\\d+)$/', $GROUP_CODE, $matches)) {
                 // get all members who unfollow and set'em unfollow from the date
                 $arUserIDToCheck = array();
                 $rsGroupMembers = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $matches[1], "USER_ACTIVE" => "Y", "<=ROLE" => SONET_ROLES_USER), false, false, array("USER_ID"));
                 while ($arGroupMembers = $rsGroupMembers->Fetch()) {
                     $arUserIDToCheck[] = $arGroupMembers["USER_ID"];
                 }
                 if (!empty($arUserIDToCheck)) {
                     $arUserIDFollowDefault = array("Y" => array(), "N" => array());
                     $arUserIDAlreadySaved = array();
                     $default_follow_type = COption::GetOptionString("socialnetwork", "follow_default_type", "Y");
                     $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arUserIDToCheck, "CODE" => "**"), array("USER_ID", "TYPE"));
                     while ($arFollow = $rsFollow->Fetch()) {
                         $arUserIDFollowDefault[$arFollow["TYPE"]][] = $arFollow["USER_ID"];
                     }
                     $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arUserIDToCheck, "CODE" => "L" . $LOG_ID), array("USER_ID"));
                     while ($arFollow = $rsFollow->Fetch()) {
                         $arUserIDAlreadySaved[] = $arFollow["USER_ID"];
                     }
                     foreach ($arUserIDToCheck as $iUserID) {
                         // for them who not followed by default and not already saved follow/unfollow for the log entry
                         if (!in_array($iUserID, $arUserIDAlreadySaved) && ($default_follow_type == "N" && !in_array($iUserID, $arUserIDFollowDefault["Y"]) || $default_follow_type == "Y" && in_array($iUserID, $arUserIDFollowDefault["N"]))) {
                             CSocNetLogFollow::Add($iUserID, "L" . $LOG_ID, "N", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
                         }
                     }
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_" . intval($LOG_ID));
         }
         return $NEW_RIGHT_ID;
     }
 }
Пример #4
0
                }
                $arResult["SUCCESS"] = "Y";
            } else {
                $arResult["SUCCESS"] = "N";
            }
        } else {
            $arResult["SUCCESS"] = "N";
        }
    } elseif ($action == "change_follow") {
        $log_id = intval($_REQUEST["log_id"]);
        if ($log_id > 0 && ($strRes = CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L" . $log_id, $_REQUEST["follow"] == "Y" ? "Y" : "N"))) {
            $arResult["SUCCESS"] = "Y";
        } else {
            $arResult["SUCCESS"] = "N";
        }
    } elseif ($action == "change_follow_default") {
        $arResult["SUCCESS"] = CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "**", $_POST["value"] == "Y" ? "Y" : "N") ? "Y" : "N";
    } elseif ($action == "log_error") {
        $message = trim($_REQUEST["message"]);
        $url = trim($_REQUEST["url"]);
        $linenumber = intval($_REQUEST["linenumber"]);
        if (!IsModuleInstalled("bitrix24")) {
            AddMessage2Log("Mobile Livefeed javascript error:\nMessage: " . $message . "\nURL: " . $url . "\nLine number: " . $linenumber . "\nUser ID: " . $GLOBALS["USER"]->GetID());
        }
    }
    header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
    echo CUtil::PhpToJSObject($arResult);
}
define('PUBLIC_AJAX_MODE', true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
die;
Пример #5
0
                             }
                         }
                     }
                     if (count($socnetPermsAdd) > 0) {
                         $socnetPerms = array_merge($socnetPerms, $socnetPermsAdd);
                     }
                 }
                 CSocNetLogRights::DeleteByLogID($arRes["ID"]);
                 CSocNetLogRights::Add($arRes["ID"], $socnetPerms, true);
                 if (count(array_diff($arLogSitesNew, $arLogSites)) > 0) {
                     CSocNetLog::Update($arRes["ID"], array("ENTITY_TYPE" => $arRes["ENTITY_TYPE"], "SITE_ID" => $arLogSitesNew, "=LOG_UPDATE" => $DB->CurrentTimeFunction()));
                 } else {
                     CSocNetLog::Update($arRes["ID"], array("=LOG_UPDATE" => $DB->CurrentTimeFunction()));
                 }
                 /* subscribe share author */
                 CSocNetLogFollow::Set($user_id, "L" . $arRes["ID"], "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"));
             }
             /* update socnet groupd activity*/
             foreach ($arNewRights as $v) {
                 if (substr($v, 0, 2) == "SG") {
                     $group_id_tmp = substr($v, 2);
                     if (IntVal($group_id_tmp) > 0) {
                         CSocNetGroup::SetLastActivity(IntVal($group_id_tmp));
                     }
                 }
             }
             \Bitrix\Main\FinderDestTable::merge(array("CONTEXT" => "blog_post", "CODE" => \Bitrix\Main\FinderDestTable::convertRights($arNewRights)));
         }
     }
     die;
 }
Пример #6
0
 public static function NotifyGroup($arFields)
 {
     if (!CModule::IncludeModule("im")) {
         return;
     }
     if (!is_array($arFields["GROUP_ID"])) {
         $arFields["GROUP_ID"] = array($arFields["GROUP_ID"]);
     }
     if (empty($arFields["GROUP_ID"])) {
         return;
     }
     if (empty($arFields["EXCLUDE_USERS"])) {
         $arFields["EXCLUDE_USERS"] = array();
     }
     if (intval($arFields["LOG_ID"]) > 0) {
         $rsUnFollower = CSocNetLogFollow::GetList(array("CODE" => "L" . intval($arFields["LOG_ID"]), "TYPE" => "N"), array("USER_ID"));
         while ($arUnFollower = $rsUnFollower->Fetch()) {
             $arFields["EXCLUDE_USERS"][] = $arUnFollower["USER_ID"];
         }
         $arFields["EXCLUDE_USERS"] = array_unique($arFields["EXCLUDE_USERS"]);
     }
     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "socialnetwork", "NOTIFY_EVENT" => "sonet_group_event", "NOTIFY_TAG" => "SONET|EVENT|" . (intval($arFields["LOG_ID"]) > 0 ? $arFields["LOG_ID"] : rand()));
     if (intval($arFields["FROM_USER_ID"]) > 0) {
         $arMessageFields["FROM_USER_ID"] = $arFields["FROM_USER_ID"];
     }
     $arUserToSend = array();
     $arUserIDToSend = array();
     $arGroupID = array();
     $arCodes = array();
     foreach ($arFields["GROUP_ID"] as $group_id) {
         $arCodes[] = "SG" . $group_id;
     }
     $rsSubscriber = CSocNetSubscription::GetList(array(), array("CODE" => $arCodes), false, false, array("USER_ID", "CODE"));
     while ($arSubscriber = $rsSubscriber->Fetch()) {
         if (!in_array($arSubscriber["USER_ID"], $arFields["EXCLUDE_USERS"]) && !in_array($arSubscriber["USER_ID"], $arUserIDToSend)) {
             if (preg_match('/^SG(\\d+)$/', $arSubscriber["CODE"], $matches)) {
                 $arUserToSend[] = array("USER_ID" => $arSubscriber["USER_ID"], "GROUP_ID" => $matches[1]);
                 $arUserIDToSend[] = $arSubscriber["USER_ID"];
                 $arGroupID[] = $matches[1];
             }
         }
     }
     $rsGroup = CSocNetGroup::GetList(array(), array("ID" => $arGroupID), false, false, array("ID", "NAME", "OWNER_ID"));
     while ($arGroup = $rsGroup->GetNext()) {
         $arGroups[$arGroup["ID"]] = $arGroup;
     }
     $workgroupsPage = COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID);
     $groupUrlTemplate = COption::GetOptionString("socialnetwork", "group_path_template", "/workgroups/group/#group_id#/", SITE_ID);
     $groupUrlTemplate = "#GROUPS_PATH#" . substr($groupUrlTemplate, strlen($workgroupsPage), strlen($groupUrlTemplate) - strlen($workgroupsPage));
     foreach ($arUserToSend as $arUser) {
         $arMessageFields["TO_USER_ID"] = $arUser["USER_ID"];
         $arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arFields["URL"], "GROUP_URL" => str_replace(array("#group_id#", "#GROUP_ID#"), $arUser["GROUP_ID"], $groupUrlTemplate)), $arUser["USER_ID"]);
         $url = $arTmp["URLS"]["URL"];
         if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) {
             $serverName = "";
         } else {
             $serverName = $arTmp["SERVER_NAME"];
         }
         $groupUrl = $serverName . $arTmp["URLS"]["GROUP_URL"];
         $group_name = array_key_exists($arUser["GROUP_ID"], $arGroups) ? $arGroups[$arUser["GROUP_ID"]]["NAME"] : "";
         $arMessageFields["NOTIFY_MESSAGE"] = str_replace(array("#URL#", "#url#", "#group_name#", "#GROUP_ID#", "#group_id#"), array($url, $url, "<a href=\"" . $groupUrl . "\" class=\"bx-notifier-item-action\">" . $group_name . "</a>", $arUser["GROUP_ID"], $arUser["GROUP_ID"]), $arFields["MESSAGE"]);
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = str_replace(array("#URL#", "#url#", "#group_name#"), array($serverName . $url, $serverName . $url, $group_name), $arFields["MESSAGE_OUT"]);
         $arMessageFields2Send = $arMessageFields;
         if (!is_set($arMessageFields2Send["FROM_USER_ID"]) || intval($arMessageFields2Send["FROM_USER_ID"]) <= 0) {
             $arMessageFields2Send["NOTIFY_TYPE"] = IM_NOTIFY_SYSTEM;
             $arMessageFields2Send["FROM_USER_ID"] = 0;
         }
         CIMNotify::Add($arMessageFields2Send);
     }
 }
Пример #7
0
 public static function AddCommentToIM($arFields)
 {
     if (CModule::IncludeModule("im") && intval($arFields["USER_ID"]) > 0) {
         $date_text = "";
         $dbReport = CTimeManReportFull::GetByID($arFields["REPORT_ID"]);
         if ($arReport = $dbReport->Fetch()) {
             $date_from = FormatDate("j F", MakeTimeStamp($arReport["DATE_FROM"], CSite::GetDateFormat("FULL", SITE_ID)));
             $date_to = FormatDate("j F", MakeTimeStamp($arReport["DATE_TO"], CSite::GetDateFormat("FULL", SITE_ID)));
             if ($date_from == $date_to) {
                 $date_text = $date_to;
             } else {
                 $date_text = $date_from . " - " . $date_to;
             }
             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $arFields["USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "timeman", "NOTIFY_EVENT" => "report_comment", "NOTIFY_TAG" => "TIMEMAN|REPORT|" . $arFields["REPORT_ID"]);
             $arUserIDToSend = array($arReport["USER_ID"]);
             $gender_suffix = "";
             $dbUser = CUser::GetByID($arFields["USER_ID"]);
             if ($arUser = $dbUser->Fetch()) {
                 switch ($arUser["PERSONAL_GENDER"]) {
                     case "M":
                         $gender_suffix = "_M";
                         break;
                     case "F":
                         $gender_suffix = "_F";
                         break;
                     default:
                         $gender_suffix = "";
                 }
             }
             $arManagers = CTimeMan::GetUserManagers($arReport["USER_ID"]);
             if (is_array($arManagers)) {
                 $arUserIDToSend = array_merge($arUserIDToSend, $arManagers);
             }
             $reports_page = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php");
             $arUnFollowers = array();
             $rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arUserIDToSend, "CODE" => "L" . $arFields["LOG_ID"], "TYPE" => "N"), array("USER_ID"));
             while ($arUnFollower = $rsUnFollower->Fetch()) {
                 $arUnFollowers[] = $arUnFollower["USER_ID"];
             }
             $arUserIDToSend = array_diff($arUserIDToSend, $arUnFollowers);
             foreach ($arUserIDToSend as $user_id) {
                 if ($arFields["USER_ID"] == $user_id) {
                     continue;
                 }
                 $arMessageFields["TO_USER_ID"] = $user_id;
                 $arTmp = CSocNetLogTools::ProcessPath(array("REPORTS_PAGE" => $reports_page), $user_id);
                 $sender_type = $arReport["USER_ID"] == $user_id ? "1" : ($arReport["USER_ID"] == $arFields["USER_ID"] ? "2" : "3");
                 $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("REPORT_FULL_IM_COMMENT_" . $sender_type . $gender_suffix, array("#period#" => "<a href=\"" . $arTmp["URLS"]["REPORTS_PAGE"] . "#user_id=" . $arReport["USER_ID"] . "&report=" . $arReport["ID"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($date_text) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("REPORT_FULL_IM_COMMENT_" . $sender_type . $gender_suffix, array("#period#" => htmlspecialcharsbx($date_text))) . " ( " . $arTmp["SERVER_NAME"] . $arTmp["URLS"]["REPORTS_PAGE"] . "#user_id=" . $arReport["USER_ID"] . "&report=" . $arReport["ID"] . " )#BR##BR#" . $arFields["MESSAGE"];
                 CIMNotify::Add($arMessageFields);
             }
         }
     }
 }
Пример #8
0
							"ENTITY_TYPE_ID" => $rating_entity_type,
							"OWNER_ID" => $arResult["arComments"][$key]["EVENT"]["USER_ID"]
						)
					);
			}
		}
	}
	elseif ($action == "change_favorites" && $GLOBALS["USER"]->IsAuthorized())
	{
		$log_id = intval($_REQUEST["log_id"]);
		if ($arLog = CSocNetLog::GetByID($log_id))
		{
			if ($strRes = CSocNetLogFavorites::Change($GLOBALS["USER"]->GetID(), $log_id))
			{
				if ($strRes == "Y")
					CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L".$log_id, "Y");
				$arResult["bResult"] = $strRes;
			}
			else
			{
				if($e = $GLOBALS["APPLICATION"]->GetException())
					$arResult["strMessage"] = $e->GetString();
				else
					$arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_CANNOT_CHANGE");
				$arResult["bResult"] = "E";
			}
		}
		else
		{
			$arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_INCORRECT_LOG_ID");
			$arResult["bResult"] = "E";
Пример #9
0
	function Add($arFields, $bSetSource = false, $bSendEvent = true, $bSetLogUpDate = true)
	{
		global $DB;

		$arFields1 = array();
		foreach ($arFields as $key => $value)
		{
			if (substr($key, 0, 1) == "=")
			{
				$arFields1[substr($key, 1)] = $value;
				unset($arFields[$key]);
			}
		}

		if (
			$bSetSource 
			&& strlen($arFields["EVENT_ID"]) > 0)
		{
			$arCommentEvent = CSocNetLogTools::FindLogCommentEventByID($arFields["EVENT_ID"]);
			if (
				!$arCommentEvent
				|| !array_key_exists("ADD_CALLBACK", $arCommentEvent)
				|| !is_callable($arCommentEvent["ADD_CALLBACK"])
			)
			{
				$bSetSource = false;
			}
		}

		$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogCommentAdd");
		while ($arEvent = $db_events->Fetch())
		{
			if (ExecuteModuleEventEx($arEvent, array(&$arFields))===false)
			{
				return false;
			}
		}

		if ($bSetSource)
		{
			$arSource = CSocNetLogComments::SetSource($arFields);
			if (
				$arSource["NO_SOURCE"] == "Y"
				|| intval($arSource["SOURCE_ID"]) > 0
			)
			{
				if ($arSource["NO_SOURCE"] == "Y")
					$bSetSource = false;
				else
					$arFields["SOURCE_ID"] = $arSource["SOURCE_ID"];

				if (
					array_key_exists("RATING_ENTITY_ID", $arSource)
					&& array_key_exists("RATING_TYPE_ID", $arSource)
					&& intval($arSource["RATING_ENTITY_ID"]) > 0
					&& strlen($arSource["RATING_TYPE_ID"]) > 0
				)
				{
					$arFields["RATING_TYPE_ID"] = $arSource["RATING_TYPE_ID"];
					$arFields["RATING_ENTITY_ID"] = $arSource["RATING_ENTITY_ID"];
				}

				if (isset($arSource["MESSAGE"]) && strlen($arSource["MESSAGE"]) > 0)
					$arFields["MESSAGE"] = $arSource["MESSAGE"];

				if (isset($arSource["TEXT_MESSAGE"]) && strlen($arSource["TEXT_MESSAGE"]) > 0)
					$arFields["TEXT_MESSAGE"] = $arSource["TEXT_MESSAGE"];

				if (isset($arSource["URL"]) && strlen($arSource["URL"]) > 0)
					$arFields["URL"] = $arSource["URL"];

				if (
					isset($arSource["UF"]) 
					&& isset($arSource["UF"]["FILE"])
				)
				{
					if (!is_array($arSource["UF"]["FILE"]))
						$arSource["UF"]["FILE"] = array($arSource["UF"]["FILE"]);

					$arFields["UF_SONET_COM_FILE"] = $arSource["UF"]["FILE"];
				}

				if (
					isset($arSource["UF"]) 
					&& isset($arSource["UF"]["DOC"])
				)
				{
					if (!is_array($arSource["UF"]["DOC"]))
						$arSource["UF"]["DOC"] = array($arSource["UF"]["DOC"]);

					$arFields["UF_SONET_COM_DOC"] = $arSource["UF"]["DOC"];
				}
			}
			else
			{
				$strMessage =
				(
					array_key_exists("ERROR", $arSource) && strlen($arSource["ERROR"]) > 0
						? $arSource["ERROR"] :
						(
							array_key_exists("NOTES", $arSource)  && strlen($arSource["NOTES"]) > 0
								? $arSource["NOTES"]
								: ""
						)
				);
			}
		}

		if (!CSocNetLogComments::CheckFields("ADD", $arFields))
		{
			if ($e = $GLOBALS["APPLICATION"]->GetException())
			{
				$errorMessage = $e->GetString();
			}
			if (strlen($errorMessage) <= 0)
			{
				$errorMessage = GetMessage("SONET_GLC_ERROR_CHECKFIELDS_FAILED");
			}

			return array(
				"ID" => false,
				"MESSAGE" => $errorMessage
			);

			return false;
		}

		if (
			!$bSetSource 
			|| (
				is_array($arSource) 
				&& array_key_exists("SOURCE_ID", $arFields) 
				&& intval($arFields["SOURCE_ID"]) > 0
			)
		)
		{
			$arInsert = $DB->PrepareInsert("b_sonet_log_comment", $arFields);

			foreach ($arFields1 as $key => $value)
			{
				if (strlen($arInsert[0]) > 0)
					$arInsert[0] .= ", ";
				$arInsert[0] .= $key;
				if (strlen($arInsert[1]) > 0)
					$arInsert[1] .= ", ";
				$arInsert[1] .= $value;
			}

			$ID = false;
			if (strlen($arInsert[0]) > 0)
			{
				$strSql =
					"INSERT INTO b_sonet_log_comment(".$arInsert[0].") ".
					"VALUES(".$arInsert[1].")";
				$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);

				$ID = IntVal($DB->LastID());

				if ($ID > 0)
				{
					if (
						!array_key_exists("RATING_TYPE_ID", $arFields)
						|| empty($arFields["RATING_TYPE_ID"])
					)
						CSocNetLogComments::Update($ID, array(
							"RATING_TYPE_ID" => "LOG_COMMENT",
							"RATING_ENTITY_ID" => $ID
						));

					CSocNetLogFollow::Set(
						$arFields["USER_ID"], 
						"L".$arFields["LOG_ID"], 
						"Y", 
						ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL")
					);

					$rsLog = CSocNetLog::GetList(
						array(),
						array("ID" => $arFields["LOG_ID"]),
						false,
						false,
						array("ID", "USER_ID")
					);
					if (
						($arLog = $rsLog->Fetch())
						&& (intval($arLog["USER_ID"]) > 0)
					)
					{
						$default_follow = CSocNetLogFollow::GetDefaultValue($arLog["USER_ID"]);
						if ($default_follow != "Y")
						{
							$rsLogFollow = CSocNetLogFollow::GetList(
								array(
									"USER_ID" => $arLog["USER_ID"],
									"CODE" => "L".$arFields["LOG_ID"]
								), 
								array("TYPE")
							);

							$arLogFollow = $rsLogFollow->Fetch();
							if (!$arLogFollow)
								CSocNetLogFollow::Set($arLog["USER_ID"], "L".$arFields["LOG_ID"], "Y");
						}
					}

					if ($bSendEvent)
					{
						CSocNetLogComments::SendEvent($ID, "SONET_NEW_EVENT");
					}

					CSocNetLogComments::UpdateLogData($arFields["LOG_ID"], $bSetLogUpDate);

					$db_events = GetModuleEvents("socialnetwork", "OnAfterSocNetLogCommentAdd");
					while ($arEvent = $db_events->Fetch())
					{
						ExecuteModuleEventEx($arEvent, array($ID, $arFields));
					}

					$GLOBALS["USER_FIELD_MANAGER"]->Update("SONET_COMMENT", $ID, $arFields);

					if(defined("BX_COMP_MANAGED_CACHE"))
					{
						$GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_".$arFields["LOG_ID"]);
					}
					else
					{
						$cache = new CPHPCache;
						$cache->CleanDir("/sonet/log/".$arFields["LOG_ID"]."/comments/");
					}

					CSocNetLogComments::SendMentionNotification(array_merge($arFields, array("ID" => $ID)));
				}
			}

			CSocNetLogTools::SetCacheLastLogID("comment", $ID);
			return $ID;
		}
		elseif ($bSetSource && strlen($strMessage) > 0)
			return array(
				"ID" => false,
				"MESSAGE" => $strMessage
			);
		else
			return false;
	}
Пример #10
0
             }
         } else {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                 $arResult["strMessage"] = $e->GetString();
             } else {
                 $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_CANNOT_CHANGE");
             }
             $arResult["bResult"] = "E";
         }
     } else {
         $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_INCORRECT_LOG_ID");
         $arResult["bResult"] = "E";
     }
 } elseif ($action == "change_follow") {
     $log_id = intval($_REQUEST["log_id"]);
     if ($log_id > 0 && ($strRes = CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L" . $log_id, $_REQUEST["follow"] == "Y" ? "Y" : "N"))) {
         $arResult["SUCCESS"] = "Y";
     } else {
         $arResult["SUCCESS"] = "N";
     }
 } elseif ($action == "get_more_destination") {
     $arResult["arDestinations"] = false;
     $log_id = intval($_REQUEST["log_id"]);
     $author_id = intval($_REQUEST["author_id"]);
     $iDestinationLimit = intval($_REQUEST["dlim"]);
     if ($log_id > 0) {
         $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $log_id));
         while ($arRight = $dbRight->Fetch()) {
             $arRights[] = $arRight["GROUP_CODE"];
         }
         $arParams = array("PATH_TO_USER" => $_REQUEST["p_user"], "PATH_TO_GROUP" => $_REQUEST["p_group"], "PATH_TO_CONPANY_DEPARTMENT" => $_REQUEST["p_dep"], "NAME_TEMPLATE" => $_REQUEST["nt"], "SHOW_LOGIN" => $_REQUEST["sl"], "DESTINATION_LIMIT" => 100);
Пример #11
0
	public static function OnAddRatingVote($id, $arParams)
	{
		if (CModule::IncludeModule("socialnetwork"))
		{
			$followValue = CSocNetLogFollow::GetExactValueByRating(
				intval($arParams["OWNER_ID"]),
				trim($arParams["ENTITY_TYPE_ID"]),
				intval($arParams["ENTITY_ID"])
			);
			if ($followValue === "N")
				return false;
		}
		if ($arParams['ENTITY_TYPE_ID'] == 'LOG_COMMENT')
		{
			if ($arComment = CSocNetLogComments::GetByID($arParams['ENTITY_ID']))
			{
				if ($arComment['USER_ID'] == $arParams['USER_ID'])
					return false;

				$arEventTmp = CSocNetLogTools::FindLogCommentEventByID($arComment["EVENT_ID"]);
				if (
					$arEventTmp
					&& array_key_exists("CLASS_FORMAT", $arEventTmp)
					&& array_key_exists("METHOD_FORMAT", $arEventTmp)
				)
				{
					$arFIELDS_FORMATTED = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arComment, array());

					$CCTP = new CTextParser();
					$CCTP->MaxStringLen = 200;
					$CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
					$arComment["MESSAGE"] = $CCTP->convertText($arFIELDS_FORMATTED["EVENT_FORMATTED"]["MESSAGE"]);
				}

				$arParams["ENTITY_TITLE"] = strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" "," ", " ", " "), $arComment["MESSAGE"]));

				$arMessageFields = array(
					"MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
					"TO_USER_ID" => intval($arComment['USER_ID']),
					"FROM_USER_ID" => intval($arParams['USER_ID']),
					"NOTIFY_TYPE" => IM_NOTIFY_FROM,
					"NOTIFY_MODULE" => "main",
					"NOTIFY_EVENT" => "rating_vote",
					"NOTIFY_TAG" => "RATING|".($arParams['VALUE'] >= 0?"":"DL|").$arParams['ENTITY_TYPE_ID']."|".$arParams['ENTITY_ID'],
					"NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams),
					"NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true)
				);
				CIMNotify::Add($arMessageFields);
			}
		}
		else
		{
			if ($arParams['OWNER_ID'] == $arParams['USER_ID'])
				return false;

			if (!CModule::IncludeModule("search") || BX_SEARCH_VERSION <= 1)
				return false;

			$CSI = new CSearchItem;
			$res = $CSI->GetList(Array(), Array('=ENTITY_TYPE_ID' => $arParams['ENTITY_TYPE_ID'], '=ENTITY_ID' => $arParams['ENTITY_ID']), Array('URL', 'TITLE', 'BODY', 'PARAM1'));
			if ($arItem = $res->GetNext(true, false))
			{
				$arParams["ENTITY_LINK"] = $arItem['URL'];
				$arParams["ENTITY_PARAM"] = $arItem['PARAM1'];
				$arParams["ENTITY_TITLE"] = trim(strip_tags(str_replace(array("\r\n","\n","\r"), ' ', htmlspecialcharsback($arItem['TITLE']))));
				$arParams["ENTITY_MESSAGE"] = trim(strip_tags(str_replace(array("\r\n","\n","\r"), ' ', htmlspecialcharsback($arItem['BODY']))));

				if ((strlen($arParams["ENTITY_TITLE"]) > 0 || strlen($arParams["ENTITY_MESSAGE"]) > 0 ) && strlen($arParams["ENTITY_LINK"]) > 0)
				{
					if (CModule::IncludeModule("extranet"))
					{
						$arSites = array();
						$extranet_site_id = CExtranet::GetExtranetSiteID();
						$intranet_site_id = CSite::GetDefSite();
						$dbSite = CSite::GetList($by="sort", $order="desc", array("ACTIVE" => "Y"));
						while($arSite = $dbSite->Fetch())
						{
							$arSites[$arSite["ID"]] = array(
								"DIR" => (strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/"),
								"SERVER_NAME" => (strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]))
							);
						}

						$bExtranetUser = false;
						if ($arSites[$extranet_site_id])
						{
							$bExtranetUser = true;
							$rsUser = CUser::GetByID(intval($arParams['OWNER_ID']));
							if ($arUser = $rsUser->Fetch())
								if (intval($arUser["UF_DEPARTMENT"][0]) > 0)
									$bExtranetUser = false;
						}

						if ($bExtranetUser)
						{
							$link = $arParams['ENTITY_LINK'];
							if (substr($link, 0, strlen($arSites[$extranet_site_id]['DIR'])) == $arSites[$extranet_site_id]['DIR'])
								$link = substr($link, strlen($arSites[$extranet_site_id]['DIR']));

							$SiteServerName = $arSites[$extranet_site_id]['SERVER_NAME'].$arSites[$extranet_site_id]['DIR'].ltrim($link, "/");
						}
						else
						{
							$link = $arParams['ENTITY_LINK'];
							if (substr($link, 0, strlen($arSites[$intranet_site_id]['DIR'])) == $arSites[$intranet_site_id]['DIR'])
								$link = substr($link, strlen($arSites[$intranet_site_id]['DIR']));

							$SiteServerName = $arSites[$intranet_site_id]['SERVER_NAME'].$arSites[$intranet_site_id]['DIR'].ltrim($link, "/");
						}

						$arParams['ENTITY_LINK'] = (CMain::IsHTTPS() ? "https" : "http")."://".$SiteServerName;
					}
					else
					{
						if (defined('SITE_SERVER_NAME') && strlen(SITE_SERVER_NAME) > 0)
							$SiteServerName = SITE_SERVER_NAME;
						else
							$SiteServerName = COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]);

						if (strlen($SiteServerName) > 0)
							$arParams['ENTITY_LINK'] = (CMain::IsHTTPS() ? "https" : "http")."://".$SiteServerName.$arParams['ENTITY_LINK'];
					}

					$arMessageFields = array(
						"MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
						"TO_USER_ID" => intval($arParams['OWNER_ID']),
						"FROM_USER_ID" => intval($arParams['USER_ID']),
						"NOTIFY_TYPE" => IM_NOTIFY_FROM,
						"NOTIFY_MODULE" => "main",
						"NOTIFY_EVENT" => "rating_vote",
						"NOTIFY_TAG" => "RATING|".($arParams['VALUE'] >= 0?"":"DL|").$arParams['ENTITY_TYPE_ID']."|".$arParams['ENTITY_ID'],
						"NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams),
						"NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true)
					);
					CIMNotify::Add($arMessageFields);
				}
			}
		}
	}
Пример #12
0
}
$arResult["FOLLOW_TYPE"] = "";
if ($GLOBALS["USER"]->IsAuthorized()) {
    $arParams["SHOW_SMART_FILTER_MYGROUPS"] = $arParams["USE_SMART_FILTER"];
    if (array_key_exists("set_follow_type", $_GET)) {
        CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "**", $_GET["set_follow_type"] == "Y" ? "Y" : "N", false);
        if ($_GET["set_follow_type"] != "Y") {
            $_SESSION["SL_SHOW_FOLLOW_HINT"] = "Y";
        }
        LocalRedirect("");
    } elseif ($arParams["USE_SMART_FILTER"] == "Y" && array_key_exists("set_smart_filter_mygroups", $_GET)) {
        CSocNetLogSmartFilter::Set($GLOBALS["USER"]->GetID(), $_GET["set_smart_filter_mygroups"] == "Y" ? "Y" : "N");
        CSocNetLogPages::DeleteEx($GLOBALS["USER"]->GetID(), SITE_ID);
        LocalRedirect("");
    }
    $arResult["FOLLOW_TYPE"] = CSocNetLogFollow::GetDefaultValue($GLOBALS["USER"]->GetID());
}
$arResult["flt_created_by_string"] = "";
if (strlen($_REQUEST["flt_created_by_string"]) > 0) {
    $arResult["flt_created_by_string"] = $_REQUEST["flt_created_by_string"];
} else {
    if (is_array($_REQUEST["flt_created_by_id"]) && intval($_REQUEST["flt_created_by_id"][0]) > 0) {
        $user_id_tmp = $_REQUEST["flt_created_by_id"][0];
    } elseif (intval($_REQUEST["flt_created_by_id"]) > 0) {
        $user_id_tmp = $_REQUEST["flt_created_by_id"];
    }
    if (intval($user_id_tmp) > 0) {
        $rsUser = CUser::GetByID($user_id_tmp);
        if ($arUser = $rsUser->GetNext()) {
            $arResult["flt_created_by_string"] = CUser::FormatName($arParams["NAME_TEMPLATE"] . " <#EMAIL#> [#ID#]", $arUser, $arParams["SHOW_LOGIN"] != "N", false);
        }
Пример #13
0
 protected static function setSocnetFollow($users, $logId, $type)
 {
     if ($type == 'Y') {
         foreach ($users as $userId) {
             CSocNetLogFollow::delete($userId, 'L' . $logId, false);
             CSocNetLogFollow::set($userId, 'L' . $logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
             //$logFollowObject = CSocNetLogFollow::getList(array('USER_ID' => $userId, 'REF_ID' => $logId), array('BY_WF'));
             //$logFollow = $logFollowObject->fetch();
             //if(!empty($logFollow) && $logFollow['BY_WF'] == 'Y')
             //{
             //	CSocNetLogFollow::delete($userId, 'L'.$logId, false);
             //	CSocNetLogFollow::set($userId, 'L'.$logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID), true);
             //}
             //elseif(empty($logFollow))
             //{
             //	CSocNetLogFollow::delete($userId, 'L'.$logId, false);
             //	CSocNetLogFollow::set($userId, 'L'.$logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID), true);
             //}
         }
     } else {
         foreach ($users as $userId) {
             CSocNetLogFollow::set($userId, 'L' . $logId, $type, false, SITE_ID);
             //$logFollowObject = CSocNetLogFollow::getList(array('USER_ID' => $userId, 'REF_ID' => $logId), array('BY_WF'));
             //$logFollow = $logFollowObject->fetch();
             //if(!empty($logFollow) && $logFollow['BY_WF'] == 'Y')
             //{
             //	CSocNetLogFollow::set($userId, 'L'.$logId, $type, false, SITE_ID, true);
             //}
             //elseif(empty($logFollow))
             //{
             //	CSocNetLogFollow::set($userId, 'L'.$logId, $type, false, SITE_ID, true);
             //}
         }
     }
 }
Пример #14
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");
         }
     }
 }
Пример #15
0
         }
     }
     preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/is" . BX_UTF_PCRE_MODIFIER, $_POST['comment'], $arMention);
     $arFieldsIM = array("TYPE" => "COMMENT", "TITLE" => htmlspecialcharsBack($arPost["TITLE"]), "URL" => $commentUrl, "ID" => $arPost["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => array($arPost["AUTHOR_ID"]), "TO_SOCNET_RIGHTS" => $arUsrS, "TO_SOCNET_RIGHTS_OLD" => array("U" => array(), "SG" => array()), "AUTHOR_ID" => $arPost["AUTHOR_ID"], "BODY" => $text4mail);
     if (!empty($arMention)) {
         $arFieldsIM["MENTION_ID"] = $arMention[1];
         if ($_POST["act"] != "edit" && is_array($arMention[1]) && !empty($arMention[1])) {
             $arMentionedDestCode = array();
             foreach ($arMention[1] as $val) {
                 $arMentionedDestCode[] = "U" . $val;
             }
             \Bitrix\Main\FinderDestTable::merge(array("CONTEXT" => "mention", "CODE" => array_unique($arMentionedDestCode)));
         }
     }
     $arFieldsIM["EXCLUDE_USERS"] = array();
     $rsUnFollower = CSocNetLogFollow::GetList(array("CODE" => "L" . $log_id, "TYPE" => "N"), array("USER_ID"));
     while ($arUnFollower = $rsUnFollower->Fetch()) {
         $arFieldsIM["EXCLUDE_USERS"][$arUnFollower["USER_ID"]] = $arUnFollower["USER_ID"];
     }
     CBlogPost::NotifyIm($arFieldsIM);
 }
 $res = CBlogImage::GetList(array(), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y", "COMMENT_ID" => false, "<=TIMESTAMP_X" => ConvertTimeStamp(AddToTimeStamp(array("HH" => -3)), "FULL")));
 while ($aImg = $res->Fetch()) {
     CBlogImage::Delete($aImg["ID"]);
 }
 if (strlen($arFields["PUBLISH_STATUS"]) > 0 && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
     $arResult["MESSAGE"] = GetMessage("B_B_PC_MES_HIDDEN_ADDED");
 }
 $arResult["ajax_comment"] = $commentId;
 $bHasImg = false;
 $bHasProps = false;
Пример #16
0
 function OnBeforeConfirmNotify($module, $tag, $value, $arParams)
 {
     if ($module == "socialnetwork") {
         $arTag = explode("|", $tag);
         if (count($arTag) == 3 && $arTag[1] == 'UNFOLLOW') {
             if ($value == 'Y') {
                 CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "**", "N");
             }
             return true;
         }
     }
 }
Пример #17
0
 protected static function setSocnetFollow($users = array(), $logId, $type, $manualMode = false, $addingComment = false)
 {
     if ($manualMode) {
         foreach ($users as $userId) {
             $logFollowObject = CSocNetLogFollow::getList(array('USER_ID' => $userId, 'REF_ID' => $logId), array('BY_WF', 'TYPE'));
             $logFollow = $logFollowObject->fetch();
             if (!empty($logFollow) && $logFollow['TYPE'] == 'Y' && !$logFollow['BY_WF']) {
                 CSocNetLogFollow::delete($userId, 'L' . $logId, false);
                 CSocNetLogFollow::set($userId, 'L' . $logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID), true);
             }
         }
     } else {
         if ($type == 'Y') {
             foreach ($users as $userId) {
                 $logFollowObject = CSocNetLogFollow::getList(array('USER_ID' => $userId, 'REF_ID' => $logId), array('BY_WF'));
                 $logFollow = $logFollowObject->fetch();
                 if (!empty($logFollow) && ($logFollow['BY_WF'] == 'Y' || $addingComment)) {
                     CSocNetLogFollow::delete($userId, 'L' . $logId, false);
                     CSocNetLogFollow::set($userId, 'L' . $logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID), true);
                 } elseif (empty($logFollow)) {
                     CSocNetLogFollow::delete($userId, 'L' . $logId, false);
                     CSocNetLogFollow::set($userId, 'L' . $logId, $type, ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID), true);
                 }
             }
         } else {
             foreach ($users as $userId) {
                 $logFollowObject = CSocNetLogFollow::getList(array('USER_ID' => $userId, 'REF_ID' => $logId), array('BY_WF'));
                 $logFollow = $logFollowObject->fetch();
                 if (!empty($logFollow) && $logFollow['BY_WF'] == 'Y') {
                     CSocNetLogFollow::set($userId, 'L' . $logId, $type, false, SITE_ID, true);
                 } elseif (empty($logFollow)) {
                     CSocNetLogFollow::set($userId, 'L' . $logId, $type, false, SITE_ID, true);
                 }
             }
         }
     }
 }
Пример #18
0
</script><?php 
                $t = ob_get_clean();
                $records[$commentId] = array("ID" => $commentId, "NEW" => $lastLogTs > 0 && $arComment["LOG_DATE_TS"] > $lastLogTs && $USER->IsAuthorized() && $arEvent["EVENT"]["FOLLOW"] != "N" && $arComment["EVENT"]["USER_ID"] != $USER->GetID() && ($arResult["COUNTER_TYPE"] == "**" || $arResult["COUNTER_TYPE"] == "CRM_**" || $arResult["COUNTER_TYPE"] == "blog_post") ? "Y" : "N", "APPROVED" => "Y", "POST_TIMESTAMP" => $arComment["LOG_DATE_TS"], "AUTHOR_ID" => array("ID" => $arComment["CREATED_BY"]["TOOLTIP_FIELDS"]["ID"], "NAME" => $arComment["CREATED_BY"]["TOOLTIP_FIELDS"]["NAME"], "LAST_NAME" => $arComment["CREATED_BY"]["TOOLTIP_FIELDS"]["LAST_NAME"], "SECOND_NAME" => $arComment["CREATED_BY"]["TOOLTIP_FIELDS"]["SECOND_NAME"], "AVATAR" => $arComment["AVATAR_SRC"]), "FILES" => false, "UF" => $arComment["UF"], "~POST_MESSAGE_TEXT" => $arComment["EVENT_FORMATTED"]["MESSAGE"], "POST_MESSAGE_TEXT" => $arComment["EVENT_FORMATTED"]["FULL_MESSAGE_CUT"], "CLASSNAME" => $t ? "" : "", "BEFORE_HEADER" => "", "BEFORE_ACTIONS" => "", "AFTER_ACTIONS" => "", "AFTER_HEADER" => "", "BEFORE" => "", "AFTER" => $t, "BEFORE_RECORD" => "", "AFTER_RECORD" => "");
            }
            $eventHandlerID = AddEventHandler("main", "system.field.view.file", array("CSocNetLogTools", "logUFfileShow"));
            $rights = CSocNetLogComponent::getCommentRights(array("EVENT_ID" => $arLog["EVENT_ID"], "SOURCE_ID" => $arLog["SOURCE_ID"]));
            $res = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => '', "RATING_TYPE_ID" => $rating_entity_type, "ENTITY_XML_ID" => $entity_xml_id, "RECORDS" => array_reverse($records, true), "NAV_STRING" => $db_res->GetPageNavStringEx($navComponentObject, ""), "NAV_RESULT" => $db_res, "PREORDER" => "N", "RIGHTS" => array("MODERATE" => "N", "EDIT" => $rights["COMMENT_RIGHTS_EDIT"], "DELETE" => $rights["COMMENT_RIGHTS_DELETE"]), "ERROR_MESSAGE" => "", "OK_MESSAGE" => "", "VIEW_URL" => isset($arComment["EVENT"]["URL"]) && strlen($arComment["EVENT"]["URL"]) > 0 ? $arComment["EVENT"]["URL"] : (isset($arParams["PATH_TO_LOG_ENTRY"]) && strlen($arParams["PATH_TO_LOG_ENTRY"]) > 0 ? CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_LOG_ENTRY"], array("log_id" => $arLog["ID"])) . "?commentId=#ID#" : ""), "EDIT_URL" => "__logEditComment('" . $entity_xml_id . "', '#ID#', '" . $log_tmp_id . "');", "MODERATE_URL" => "", "DELETE_URL" => '/bitrix/components/bitrix/socialnetwork.log.entry/ajax.php?lang=' . LANGUAGE_ID . '&action=delete_comment&delete_comment_id=#ID#&post_id=' . $arLog["ID"] . '&site=' . SITE_ID, "AUTHOR_URL" => $arParams["PATH_TO_USER"], "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT"], "LAZYLOAD" => "Y", "NOTIFY_TAG" => "", "NOTIFY_TEXT" => "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => "", "IMAGE_SIZE" => "", "mfi" => ""), array(), null);
            RemoveEventHandler('main', 'system.field.view.file', $eventHandlerID);
        }
    } elseif ($action == "change_favorites" && $GLOBALS["USER"]->IsAuthorized()) {
        $log_id = intval($_REQUEST["log_id"]);
        if ($arLog = CSocNetLog::GetByID($log_id)) {
            $strRes = CSocNetLogFavorites::Change($GLOBALS["USER"]->GetID(), $log_id);
            if ($strRes) {
                if ($strRes == "Y") {
                    CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L" . $log_id, "Y", $arLog["LOG_UPDATE"]);
                }
                $arResult["bResult"] = $strRes;
            } else {
                if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                    $arResult["strMessage"] = $e->GetString();
                } else {
                    $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_CANNOT_CHANGE");
                }
                $arResult["bResult"] = "E";
            }
        } else {
            $arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_INCORRECT_LOG_ID");
            $arResult["bResult"] = "E";
        }
    } elseif ($action == "delete" && CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)) {
Пример #19
0
 static function AddComment_Wiki($arFields)
 {
     if (!CModule::IncludeModule('iblock')) {
         return false;
     }
     if (!CModule::IncludeModule('socialnetwork')) {
         return false;
     }
     $ufFileID = array();
     $ufDocID = array();
     $dbResult = CSocNetLog::GetList(array('ID' => 'DESC'), array('TMP_ID' => $arFields['LOG_ID']), false, false, array('ID', 'SOURCE_ID', 'PARAMS', 'URL'));
     $bFound = false;
     if ($arLog = $dbResult->Fetch()) {
         if (strlen($arLog['PARAMS']) > 0) {
             $arFieldsParams = explode('&', $arLog['PARAMS']);
             if (is_array($arFieldsParams) && count($arFieldsParams) > 0) {
                 foreach ($arFieldsParams as $tmp) {
                     list($key, $value) = explode('=', $tmp);
                     if ($key == 'forum_id') {
                         $FORUM_ID = intval($value);
                         break;
                     }
                 }
             }
         }
         if ($FORUM_ID > 0 && intval($arLog['SOURCE_ID']) > 0) {
             $bFound = true;
         }
     }
     if ($bFound) {
         $arElement = false;
         $arFilter = array('ID' => $arLog['SOURCE_ID']);
         $arSelectedFields = array('IBLOCK_ID', 'ID', 'NAME', 'TAGS', 'CODE', 'IBLOCK_SECTION_ID', 'DETAIL_PAGE_URL', 'CREATED_BY', 'PREVIEW_PICTURE', 'PREVIEW_TEXT', 'PROPERTY_FORUM_TOPIC_ID', 'PROPERTY_FORUM_MESSAGE_CNT');
         $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
         if ($db_res && ($res = $db_res->GetNext())) {
             $arElement = $res;
         }
         if ($arElement) {
             // check iblock properties
             CSocNetLogTools::AddComment_Review_CheckIBlock($arElement);
             $dbMessage = CForumMessage::GetList(array(), array('PARAM2' => $arElement['ID']));
             if (!($arMessage = $dbMessage->Fetch())) {
                 // Add Topic and Root Message
                 $TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot($arElement, $FORUM_ID, false);
                 $bNewTopic = true;
             } else {
                 $TOPIC_ID = $arMessage['TOPIC_ID'];
             }
             if (intval($TOPIC_ID) > 0) {
                 // Add comment
                 $messageID = false;
                 $arFieldsMessage = array('POST_MESSAGE' => $arFields['TEXT_MESSAGE'], 'USE_SMILES' => 'Y', 'PARAM2' => $arElement['ID'], 'APPROVED' => 'Y');
                 $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
                 if (is_array($arTmp)) {
                     if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
                         $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
                     } elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
                         $arFieldsMessage["FILES"] = array();
                         foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
                             $arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
                         }
                     }
                 }
                 $messageID = ForumAddMessage('REPLY', $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
                 if (!$messageID) {
                     $strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
                 } else {
                     $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
                     while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
                         $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
                     }
                     $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
                     CSocNetLogTools::AddComment_Review_UpdateElement($arElement, $TOPIC_ID, $bNewTopic);
                     $userID = $GLOBALS["USER"]->GetID();
                     if (CModule::IncludeModule("im") && intval($arElement["CREATED_BY"]) > 0 && $arElement["CREATED_BY"] != $userID) {
                         $rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arElement["CREATED_BY"], "CODE" => "L" . $arLog["ID"], "TYPE" => "N"), array("USER_ID"));
                         $arUnFollower = $rsUnFollower->Fetch();
                         if (!$arUnFollower) {
                             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arElement["CREATED_BY"], "FROM_USER_ID" => $userID, "LOG_ID" => $arLog["ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "wiki", "NOTIFY_EVENT" => "comment");
                             $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arElement["NAME"]);
                             $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
                             $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
                             $arTmp = CSocNetLogTools::ProcessPath(array("ELEMENT_URL" => $arLog["URL"]), $arElement["CREATED_BY"]);
                             $serverName = $arTmp["SERVER_NAME"];
                             $url = $arTmp["URLS"]["ELEMENT_URL"];
                             $arMessageFields["NOTIFY_TAG"] = "WIKI|COMMENT|" . $arElement['ID'];
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => strlen($url) > 0 ? "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>" : htmlspecialcharsbx($arParams["TITLE"])));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => htmlspecialcharsbx($arParams["TITLE"]))) . (strlen($url) > 0 ? " (" . $serverName . $url . ")" : "") . "#BR##BR#" . $arFields["TEXT_MESSAGE"];
                             CIMNotify::Add($arMessageFields);
                         }
                     }
                 }
             } else {
                 $strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
             }
         } else {
             $strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
         }
     } else {
         $strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
     }
     return array('SOURCE_ID' => $messageID, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => $messageID, 'ERROR' => $strError, 'NOTES' => '', "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
 }
Пример #20
0
 function AddComment_Tasks($arFields)
 {
     global $DB;
     if (!CModule::IncludeModule("forum")) {
         return false;
     }
     if (!CModule::IncludeModule("tasks")) {
         return false;
     }
     $ufFileID = array();
     $ufDocID = array();
     $dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID"));
     if ($arLog = $dbResult->Fetch()) {
         $rsTask = CTasks::GetById($arLog["SOURCE_ID"]);
         if ($arTask = $rsTask->Fetch()) {
             // read shared cross-site FORUM_ID
             $forumID = COption::GetOptionString("tasks", "task_forum_id", 0, $siteId = '');
             if ($forumID) {
                 if (!$arTask["FORUM_TOPIC_ID"]) {
                     $arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
                     if ($arUserStart["ID"] > 0) {
                         $res = array();
                         $db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
                         if ($db_res && ($res = $db_res->Fetch())) {
                             $res["FORUM_USER_ID"] = intVal($res["ID"]);
                             $res["ID"] = $res["USER_ID"];
                         } else {
                             $db_res = CUser::GetByID($arTask["CREATED_BY"]);
                             if ($db_res && ($res = $db_res->Fetch())) {
                                 $res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
                                 $res["USER_PROFILE"] = "N";
                             }
                         }
                         if (!empty($res)) {
                             $arUserStart = $res;
                             $sName = $res["SHOW_NAME"] == "Y" ? trim($res["NAME"] . " " . $res["LAST_NAME"]) : "";
                             $arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
                         }
                     }
                     $arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
                     $DB->StartTransaction();
                     $arTopicFields = array("TITLE" => $arTask["TITLE"], "FORUM_ID" => $forumID, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E', "APPROVED" => "Y", 'XML_ID' => 'TASK_' . $arTask['ID']);
                     $TID = CForumTopic::Add($arTopicFields);
                     if (intVal($TID) > 0) {
                         $arFieldsFirstMessage = array("POST_MESSAGE" => $arTopicFields['XML_ID'], "AUTHOR_ID" => $arTopicFields["USER_START_ID"], "AUTHOR_NAME" => $arTopicFields["USER_START_NAME"], "FORUM_ID" => $arTopicFields["FORUM_ID"], "TOPIC_ID" => $TID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => 'TK', "PARAM2" => $arTask['ID'], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E');
                         CForumMessage::Add($arFieldsFirstMessage, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
                         $arTask["FORUM_TOPIC_ID"] = $TID;
                         $arTaskFields = array("FORUM_TOPIC_ID" => $TID);
                         $task = new CTasks();
                         $task->Update($arTask["ID"], $arTaskFields);
                     }
                     if (!$arTask["FORUM_TOPIC_ID"]) {
                         $DB->Rollback();
                     } else {
                         $DB->Commit();
                     }
                 } else {
                     // override forumId by fact forum, attached to the task
                     if ($arTopic = CForumTopic::getByID($arTask['FORUM_TOPIC_ID'])) {
                         $forumID = $arTopic['FORUM_ID'];
                     }
                 }
                 if ($forumID && $arTask["FORUM_TOPIC_ID"]) {
                     $userID = $GLOBALS["USER"]->GetID();
                     $arLogSites = array();
                     $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
                     while ($arLogSite = $rsLogSite->Fetch()) {
                         $arLogSites[] = $arLogSite["LID"];
                     }
                     $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
                     if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
                         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
                             $strPermission = "I";
                         }
                     } else {
                         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
                             $strPermission = "I";
                         }
                     }
                     $arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "PERMISSION_EXTERNAL" => "Q", "PERMISSION" => $strPermission, "APPROVED" => "Y");
                     $MESSAGE_TYPE = 'REPLY';
                     $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
                     if (is_array($arTmp)) {
                         if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
                             $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
                         } elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
                             $arFieldsMessage["FILES"] = array();
                             foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
                                 $arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
                             }
                         }
                     }
                     $messageID = ForumAddMessage($MESSAGE_TYPE, $forumID, $arTask["FORUM_TOPIC_ID"], 0, $arFieldsMessage, $sError, $sNote);
                     // get UF DOC value and FILE_ID there
                     if ($messageID > 0) {
                         $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
                         while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
                             $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
                         }
                         $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
                     }
                     if ($messageID && ($arMessage = CForumMessage::GetByID($messageID))) {
                         $arLogFields = array("TASK_ID" => $arTask["ID"], "USER_ID" => $userID, "CREATED_DATE" => $arMessage["POST_DATE"], "FIELD" => "COMMENT", "TO_VALUE" => $messageID);
                         $log = new CTaskLog();
                         $log->Add($arLogFields);
                         // notification to IM
                         $arRecipientsIDs = CTaskNotifications::GetRecipientsIDs($arTask);
                         $arUnFollowers = array();
                         $rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arRecipientsIDs, "CODE" => "L" . $arFields["LOG_ID"], "TYPE" => "N"), array("USER_ID"));
                         while ($arUnFollower = $rsUnFollower->Fetch()) {
                             $arUnFollowers[] = $arUnFollower["USER_ID"];
                         }
                         $arRecipientsIDs = array_diff($arRecipientsIDs, $arUnFollowers);
                         if (IsModuleInstalled("im") && CModule::IncludeModule("im") && sizeof($arRecipientsIDs)) {
                             $extranetSiteId = false;
                             if (CModule::IncludeModule('extranet') && method_exists('CExtranet', 'GetExtranetSiteID')) {
                                 $extranetSiteId = CExtranet::GetExtranetSiteID();
                             }
                             foreach ($arRecipientsIDs as $recipientUserID) {
                                 $arFilter = array("UF_DEPARTMENT" => false, "ID" => $recipientUserID);
                                 $rsUser = CUser::GetList($by = "last_name", $order = "asc", $arFilter, array("SELECT" => array("UF_DEPARTMENT")));
                                 $isExtranetUser = false;
                                 if ($arUser = $rsUser->Fetch()) {
                                     $isExtranetUser = true;
                                 }
                                 if ($isExtranetUser && $extranetSiteId !== false) {
                                     if ($arTask["GROUP_ID"]) {
                                         $pathTemplate = str_replace("#group_id#", $arTask["GROUP_ID"], COption::GetOptionString("tasks", "paths_task_group_entry", "/extranet/workgroups/group/#group_id#/tasks/task/view/#task_id#/", $extranetSiteId));
                                         $pathTemplate = str_replace("#GROUP_ID#", $arTask["GROUP_ID"], $pathTemplate);
                                     } else {
                                         $pathTemplate = COption::GetOptionString("tasks", "paths_task_user_entry", "/extranet/contacts/personal/user/#user_id#/tasks/task/view/#task_id#/", $extranetSiteId);
                                     }
                                 } else {
                                     if ($arTask["GROUP_ID"]) {
                                         $pathTemplate = str_replace("#group_id#", $arTask["GROUP_ID"], COption::GetOptionString("tasks", "paths_task_group_entry", "/workgroups/group/#group_id#/tasks/task/view/#task_id#/", $arLog["SITE_ID"]));
                                         $pathTemplate = str_replace("#GROUP_ID#", $arTask["GROUP_ID"], $pathTemplate);
                                     } else {
                                         $pathTemplate = COption::GetOptionString("tasks", "paths_task_user_entry", "/company/personal/user/#user_id#/tasks/task/view/#task_id#/", $arLog["SITE_ID"]);
                                     }
                                 }
                                 $messageUrl = CComponentEngine::MakePathFromTemplate($pathTemplate, array("user_id" => $recipientUserID, "task_id" => $arTask["ID"], "action" => "view"));
                                 if (strpos($messageUrl, "?") === false) {
                                     $messageUrl .= "?";
                                 } else {
                                     $messageUrl .= "&";
                                 }
                                 $messageUrl .= "MID=" . $messageID;
                                 $MESSAGE_SITE = preg_replace(array('|\\[\\/USER\\]|', '|\\[USER=\\d+\\]|', '|\\[DISK\\sFILE\\sID=[n]*\\d+\\]|', '|\\[DOCUMENT\\sID=\\d+\\]|'), '', $arFields['TEXT_MESSAGE']);
                                 if (strlen($MESSAGE_SITE) >= 100) {
                                     $dot = '...';
                                     $MESSAGE_SITE = substr($MESSAGE_SITE, 0, 99);
                                     if (substr($MESSAGE_SITE, -1) === '[') {
                                         $MESSAGE_SITE = substr($MESSAGE_SITE, 0, 98);
                                     }
                                     if (($lastLinkPosition = strrpos($MESSAGE_SITE, '[u')) !== false || ($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;
                                 }
                                 $rsUser = CUser::GetList($by = 'id', $order = 'asc', array('ID_EQUAL_EXACT' => (int) $userID), array('FIELDS' => array('PERSONAL_GENDER')));
                                 $strMsgAddComment = GetMessage("SONET_GL_EVENT_TITLE_TASK_COMMENT_MESSAGE_ADD");
                                 $strMsgEditComment = GetMessage("SONET_GL_EVENT_TITLE_TASK_COMMENT_MESSAGE_EDIT");
                                 if ($arUser = $rsUser->fetch()) {
                                     switch ($arUser['PERSONAL_GENDER']) {
                                         case "F":
                                         case "M":
                                             $strMsgAddComment = GetMessage("SONET_GL_EVENT_TITLE_TASK_COMMENT_MESSAGE_ADD" . '_' . $arUser['PERSONAL_GENDER']);
                                             $strMsgEditComment = GetMessage("SONET_GL_EVENT_TITLE_TASK_COMMENT_MESSAGE_EDIT" . '_' . $arUser['PERSONAL_GENDER']);
                                             break;
                                         default:
                                             break;
                                     }
                                 }
                                 $arMessageFields = array("TO_USER_ID" => $recipientUserID, "FROM_USER_ID" => $userID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "tasks", "NOTIFY_EVENT" => "comment", "NOTIFY_MESSAGE" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array('[URL=' . tasksServerName() . $messageUrl . "#message" . $messageID . ']' . htmlspecialcharsbx($arTask["TITLE"]) . '[/URL]', '[COLOR=#000000]' . $MESSAGE_SITE . '[/COLOR]'), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment), "NOTIFY_MESSAGE_OUT" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array(htmlspecialcharsbx($arTask["TITLE"]), $MESSAGE_SITE . ' #BR# ' . tasksServerName() . $messageUrl . "#message" . $messageID . ' '), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment) . "#BR##BR#" . $arFields["TEXT_MESSAGE"], "NOTIFY_TAG" => "TASKS|COMMENT|" . intval($arTask["ID"]) . "|" . intval($recipientUserID));
                                 CIMNotify::Add($arMessageFields);
                             }
                         }
                         CSocNetLog::Update($arFields["LOG_ID"], array('PARAMS' => serialize(array('TYPE' => 'comment'))));
                         $arFilesIds = array_merge($ufFileID, is_array($ufDocID) ? $ufDocID : array());
                         CTaskComments::fireOnAfterCommentAddEvent($messageID, $arTask['ID'], $arFields["TEXT_MESSAGE"], $arFilesIds);
                     }
                 }
             }
         }
     }
     if (!$messageID) {
         $sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
     }
     return array("SOURCE_ID" => $messageID, "MESSAGE" => $arFieldsMessage ? $arFieldsMessage["POST_MESSAGE"] : false, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $messageID, "ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID), "URL" => $messageUrl);
 }
Пример #21
0
 public static function SendMentionNotification($arCommentFields)
 {
     if (!CModule::IncludeModule("im")) {
         return false;
     }
     switch ($arCommentFields["EVENT_ID"]) {
         case "forum":
             $arTitleRes = self::OnSendMentionGetEntityFields_Forum($arCommentFields);
             break;
         default:
             $db_events = GetModuleEvents("socialnetwork", "OnSendMentionGetEntityFields");
             while ($arEvent = $db_events->Fetch()) {
                 $arTitleRes = ExecuteModuleEventEx($arEvent, array($arCommentFields));
                 if ($arTitleRes) {
                     break;
                 }
             }
     }
     if ($arTitleRes && is_array($arTitleRes) && !empty($arTitleRes["NOTIFY_MESSAGE"])) {
         $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $arCommentFields["USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => !empty($arTitleRes["NOTIFY_MODULE"]) ? $arTitleRes["NOTIFY_MODULE"] : "socialnetwork", "NOTIFY_EVENT" => "mention", "NOTIFY_TAG" => !empty($arTitleRes["NOTIFY_TAG"]) ? $arTitleRes["NOTIFY_TAG"] : "LOG_COMMENT|COMMENT_MENTION|" . $arCommentFields["ID"]);
         preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/ies" . BX_UTF_PCRE_MODIFIER, $arCommentFields["MESSAGE"], $arMention);
         if (!empty($arMention)) {
             $arMention = $arMention[1];
             $arExcludeUsers = array();
             if (!empty($arCommentFields["LOG_ID"])) {
                 $rsUnFollower = CSocNetLogFollow::GetList(array("CODE" => "L" . $arCommentFields["LOG_ID"], "TYPE" => "N"), array("USER_ID"));
                 while ($arUnFollower = $rsUnFollower->Fetch()) {
                     $arExcludeUsers[] = $arUnFollower["USER_ID"];
                 }
             }
             $arSourceURL = array("URL" => $arTitleRes["URL"]);
             if (!empty($arTitleRes["CRM_URL"])) {
                 $arSourceURL["CRM_URL"] = $arTitleRes["CRM_URL"];
             }
             foreach ($arMention as $mentionUserID) {
                 $bHaveRights = CSocNetLogRights::CheckForUserOnly($arCommentFields["LOG_ID"], $mentionUserID);
                 if (!$bHaveRights && $arTitleRes["IS_CRM"] == "Y") {
                     $dbLog = CSocNetLog::GetList(array(), array("ID" => $arCommentFields["LOG_ID"], "ENTITY_TYPE" => $arCommentFields["ENTITY_TYPE"]), false, false, array("ID"), array("IS_CRM" => "Y", "CHECK_CRM_RIGHTS" => "Y", "USER_ID" => $mentionUserID, "USE_SUBSCRIBE" => "N"));
                     if ($arLog = $dbLog->Fetch()) {
                         $bHaveCrmRights = true;
                     }
                 }
                 if (in_array($mentionUserID, $arExcludeUsers) || !$bHaveRights && !$bHaveCrmRights) {
                     continue;
                 }
                 $url = false;
                 if (!empty($arSourceURL["URL"]) || !empty($arSourceURL["CRM_URL"])) {
                     $arTmp = CSocNetLogTools::ProcessPath($arSourceURL, $mentionUserID);
                     if ($arTitleRes["IS_CRM"] == "Y" && !$bHaveRights && !empty($arTmp["URLS"]["CRM_URL"])) {
                         $url = $arTmp["URLS"]["CRM_URL"];
                     } else {
                         $url = $arTmp["URLS"]["URL"];
                     }
                     $serverName = strpos($url, "http://") === 0 || strpos($url, "https://") === 0 ? "" : $arTmp["SERVER_NAME"];
                 }
                 $arMessageFields["TO_USER_ID"] = $mentionUserID;
                 $arMessageFields["NOTIFY_MESSAGE"] = str_replace(array("#url#", "#server_name#"), array($url, $serverName), $arTitleRes["NOTIFY_MESSAGE"]);
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = !empty($arTitleRes["NOTIFY_MESSAGE_OUT"]) ? str_replace(array("#url#", "#server_name#"), array($url, $serverName), $arTitleRes["NOTIFY_MESSAGE_OUT"]) : "";
                 CIMNotify::Add($arMessageFields);
             }
             $arMentionedDestCode = array();
             foreach ($arMention as $val) {
                 $arMentionedDestCode[] = "U" . $val;
             }
             \Bitrix\Main\FinderDestTable::merge(array("CONTEXT" => "mention", "CODE" => array_unique($arMentionedDestCode)));
         }
     }
 }
Пример #22
0
        }
    }
    if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y" && (intval($arResult["LOG_COUNTER"]) > 0 || $bEmptyCounter)) {
        CUserCounter::ClearByUser($GLOBALS["USER"]->GetID(), array(SITE_ID, "**"), $arResult["COUNTER_TYPE"]);
    }
    if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y" && $dateLastPage && (!$dateLastPageStart || $dateLastPageStart != $dateLastPage || $bNeedSetLogPage)) {
        CSocNetLogPages::Set($GLOBALS["USER"]->GetID(), $dateLastPage, $arParams["PAGE_SIZE"], $arResult["PAGE_NUMBER"], SITE_ID, strlen($arResult["COUNTER_TYPE"]) > 0 ? $arResult["COUNTER_TYPE"] : "**");
    }
} else {
    $rsCurrentUser = CUser::GetByID($GLOBALS["USER"]->GetID());
    if ($arCurrentUser = $rsCurrentUser->Fetch()) {
        $arResult["EmptyComment"] = array("AVATAR_SRC" => CSocNetLogTools::FormatEvent_CreateAvatar($arCurrentUser, $arParams, ""), "AUTHOR_NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arCurrentUser, $bUseLogin));
    }
}
if ($GLOBALS["USER"]->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") {
    $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $GLOBALS["USER"]->GetID(), "CODE" => "**"), array("TYPE"));
    if ($arFollow = $rsFollow->Fetch()) {
        $arResult["FOLLOW_DEFAULT"] = $arFollow["TYPE"];
    } else {
        $arResult["FOLLOW_DEFAULT"] = COption::GetOptionString("socialnetwork", "follow_default_type", "Y");
    }
}
$bAllowToAll = COption::GetOptionString("socialnetwork", "allow_livefeed_toall", "Y") == "Y";
if ($bAllowToAll) {
    $arToAllRights = unserialize(COption::GetOptionString("socialnetwork", "livefeed_toall_rights", 'a:1:{i:0;s:2:"AU";}'));
    if (!$arToAllRights) {
        $arToAllRights = array("AU");
    }
    $arUserGroupCode = array_merge(array("AU"), CAccess::GetUserCodesArray($GLOBALS["USER"]->GetID()));
    if (count(array_intersect($arToAllRights, $arUserGroupCode)) <= 0) {
        $bAllowToAll = false;
Пример #23
0
                        $arFields["EVENT_ID"] = $event_id;
                        $dbResultTmp = CSocNetLogEvents::GetList(array(), $arFields, false, false, array("ID", "TRANSPORT"));
                        $arFieldsSet = array_merge($arFields, $arFieldsVal);
                        if ($arResultTmp = $dbResultTmp->Fetch()) {
                            if ($arFieldsVal["TRANSPORT"] == "I") {
                                CSocNetLogEvents::Delete($arResultTmp["ID"]);
                            } else {
                                $idTmp = CSocNetLogEvents::Update($arResultTmp["ID"], $arFieldsSet);
                            }
                        } elseif ($arFieldsVal["TRANSPORT"] != "I") {
                            if (!array_key_exists("TRANSPORT", $arFieldsSet)) {
                                $arFieldsSet["TRANSPORT"] = "I";
                            }
                            $idTmp = CSocNetLogEvents::Add($arFieldsSet);
                        }
                    }
                }
            }
        }
    } elseif ($action == "change_follow" && $GLOBALS["USER"]->IsAuthorized()) {
        if ($strRes = CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L" . intval($_REQUEST["log_id"]), $_REQUEST["follow"] == "Y" ? "Y" : "N")) {
            $arResult["SUCCESS"] = "Y";
        } else {
            $arResult["SUCCESS"] = "N";
        }
    }
    header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
    echo CUtil::PhpToJSObject($arResult);
}
define('PUBLIC_AJAX_MODE', true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Пример #24
0
 function Add($arFields, $bSetSource = false, $bSendEvent = true, $bSetLogUpDate = true)
 {
     global $DB;
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSocNetLogComments::CheckFields("ADD", $arFields)) {
         return false;
     }
     $arCommentEvent = CSocNetLogTools::FindLogCommentEventByID($arFields["EVENT_ID"]);
     if (!$arCommentEvent || !array_key_exists("ADD_CALLBACK", $arCommentEvent) || !is_callable($arCommentEvent["ADD_CALLBACK"])) {
         $bSetSource = false;
     }
     $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogCommentAdd");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
             return false;
         }
     }
     if ($bSetSource) {
         $arSource = CSocNetLogComments::SetSource($arFields);
         if (intval($arSource["SOURCE_ID"]) > 0) {
             $arFields["SOURCE_ID"] = $arSource["SOURCE_ID"];
             if (array_key_exists("RATING_ENTITY_ID", $arSource) && array_key_exists("RATING_TYPE_ID", $arSource) && intval($arSource["RATING_ENTITY_ID"]) > 0 && strlen($arSource["RATING_TYPE_ID"]) > 0) {
                 $arFields["RATING_TYPE_ID"] = $arSource["RATING_TYPE_ID"];
                 $arFields["RATING_ENTITY_ID"] = $arSource["RATING_ENTITY_ID"];
             }
             if (isset($arSource["MESSAGE"]) && strlen($arSource["MESSAGE"]) > 0) {
                 $arFields["MESSAGE"] = $arSource["MESSAGE"];
             }
             if (isset($arSource["TEXT_MESSAGE"]) && strlen($arSource["TEXT_MESSAGE"]) > 0) {
                 $arFields["TEXT_MESSAGE"] = $arSource["TEXT_MESSAGE"];
             }
         } else {
             $strMessage = array_key_exists("ERROR", $arSource) && strlen($arSource["ERROR"]) > 0 ? $arSource["ERROR"] : (array_key_exists("NOTES", $arSource) && strlen($arSource["NOTES"]) > 0 ? $arSource["NOTES"] : "");
         }
     }
     if (!$bSetSource || is_array($arSource) && array_key_exists("SOURCE_ID", $arFields) && intval($arFields["SOURCE_ID"]) > 0) {
         $arInsert = $DB->PrepareInsert("b_sonet_log_comment", $arFields);
         foreach ($arFields1 as $key => $value) {
             if (strlen($arInsert[0]) > 0) {
                 $arInsert[0] .= ", ";
             }
             $arInsert[0] .= $key;
             if (strlen($arInsert[1]) > 0) {
                 $arInsert[1] .= ", ";
             }
             $arInsert[1] .= $value;
         }
         $ID = false;
         if (strlen($arInsert[0]) > 0) {
             $strSql = "INSERT INTO b_sonet_log_comment(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
             $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $ID = IntVal($DB->LastID());
             if ($ID > 0) {
                 if (!array_key_exists("RATING_TYPE_ID", $arFields) || empty($arFields["RATING_TYPE_ID"])) {
                     CSocNetLogComments::Update($ID, array("RATING_TYPE_ID" => "LOG_COMMENT", "RATING_ENTITY_ID" => $ID));
                 }
                 CSocNetLogFollow::Set($arFields["USER_ID"], "L" . $arFields["LOG_ID"], "Y");
                 $rsLog = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "USER_ID"));
                 if (($arLog = $rsLog->Fetch()) && intval($arLog["USER_ID"]) > 0) {
                     $default_follow = CSocNetLogFollow::GetDefaultValue($arLog["USER_ID"]);
                     if ($default_follow != "Y") {
                         $rsLogFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arLog["USER_ID"], "CODE" => "L" . $arFields["LOG_ID"]), array("TYPE"));
                         $arLogFoillow = $rsLogFollow->Fetch();
                         if (!$arLogFoillow) {
                             CSocNetLogFollow::Set($arLog["USER_ID"], "L" . $arFields["LOG_ID"], "Y");
                         }
                     }
                 }
                 if ($bSendEvent) {
                     CSocNetLogComments::SendEvent($ID, "SONET_NEW_EVENT");
                 }
                 CSocNetLogComments::UpdateLogData($arFields["LOG_ID"], $bSetLogUpDate);
                 $db_events = GetModuleEvents("socialnetwork", "OnAfterSocNetLogCommentAdd");
                 while ($arEvent = $db_events->Fetch()) {
                     ExecuteModuleEventEx($arEvent, array($ID, $arFields));
                 }
                 if (defined("BX_COMP_MANAGED_CACHE")) {
                     $GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_" . $arFields["LOG_ID"]);
                 }
             }
         }
         CSocNetLogTools::SetCacheLastLogID("comment", $ID);
         return $ID;
     } elseif ($bSetSource && strlen($strMessage) > 0) {
         return array("ID" => false, "MESSAGE" => $strMessage);
     } else {
         return false;
     }
 }
Пример #25
0
 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arParams = array())
 {
     global $DB, $arSocNetAllowedEntityTypes, $USER, $USER_FIELD_MANAGER;
     $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("SONET_LOG", "L.ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "RATING_TOTAL_VALUE", "RATING_TOTAL_VOTES", "RATING_TOTAL_POSITIVE_VOTES", "RATING_TOTAL_NEGATIVE_VOTES", "RATING_USER_VOTE_VALUE", "SOURCE_TYPE");
         if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") {
             $arSelectFields[] = "FAVORITES_USER_ID";
         }
     }
     static $arFields1 = array("ID" => array("FIELD" => "L.ID", "TYPE" => "int"), "TMP_ID" => array("FIELD" => "L.TMP_ID", "TYPE" => "int"), "SOURCE_ID" => array("FIELD" => "L.SOURCE_ID", "TYPE" => "int"), "ENTITY_TYPE" => array("FIELD" => "L.ENTITY_TYPE", "TYPE" => "string"), "ENTITY_ID" => array("FIELD" => "L.ENTITY_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "L.USER_ID", "TYPE" => "int"), "EVENT_ID" => array("FIELD" => "L.EVENT_ID", "TYPE" => "string"), "LOG_DATE" => array("FIELD" => "L.LOG_DATE", "TYPE" => "datetime"), "LOG_DATE_TS" => array("FIELD" => "UNIX_TIMESTAMP(L.LOG_DATE)", "TYPE" => "int"), "LOG_UPDATE" => array("FIELD" => "L.LOG_UPDATE", "TYPE" => "datetime"), "TITLE_TEMPLATE" => array("FIELD" => "L.TITLE_TEMPLATE", "TYPE" => "string"), "TITLE" => array("FIELD" => "L.TITLE", "TYPE" => "string"), "MESSAGE" => array("FIELD" => "L.MESSAGE", "TYPE" => "string"), "TEXT_MESSAGE" => array("FIELD" => "L.TEXT_MESSAGE", "TYPE" => "string"), "URL" => array("FIELD" => "L.URL", "TYPE" => "string"), "MODULE_ID" => array("FIELD" => "L.MODULE_ID", "TYPE" => "string"), "CALLBACK_FUNC" => array("FIELD" => "L.CALLBACK_FUNC", "TYPE" => "string"), "EXTERNAL_ID" => array("FIELD" => "L.EXTERNAL_ID", "TYPE" => "string"), "PARAMS" => array("FIELD" => "L.PARAMS", "TYPE" => "string"), "COMMENTS_COUNT" => array("FIELD" => "L.COMMENTS_COUNT", "TYPE" => "int"), "ENABLE_COMMENTS" => array("FIELD" => "L.ENABLE_COMMENTS", "TYPE" => "string"), "SOURCE_TYPE" => array("FIELD" => "L.SOURCE_TYPE", "TYPE" => "string"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OWNER_ID" => array("FIELD" => "G.OWNER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_INITIATE_PERMS" => array("FIELD" => "G.INITIATE_PERMS", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_VISIBLE" => array("FIELD" => "G.VISIBLE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OPENED" => array("FIELD" => "G.OPENED", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_IMAGE_ID" => array("FIELD" => "G.IMAGE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_GENDER" => array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "CREATED_BY_NAME" => array("FIELD" => "U1.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LAST_NAME" => array("FIELD" => "U1.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_SECOND_NAME" => array("FIELD" => "U1.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LOGIN" => array("FIELD" => "U1.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_PHOTO" => array("FIELD" => "U1.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_GENDER" => array("FIELD" => "U1.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "USER_ID|COMMENT_USER_ID" => array("FIELD" => "L.USER_ID|LC.USER_ID", "WHERE" => array("CSocNetLog", "GetSimpleOrQuery"), "FROM" => "LEFT JOIN b_sonet_log_comment LC ON LC.LOG_ID = L.ID"));
     $arFields = array("RATING_TYPE_ID" => array("FIELD" => "L.RATING_TYPE_ID", "TYPE" => "string"), "RATING_ENTITY_ID" => array("FIELD" => "L.RATING_ENTITY_ID", "TYPE" => "int"), "RATING_TOTAL_VALUE" => array("FIELD" => $DB->IsNull('RG.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_VOTES', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_POSITIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_NEGATIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"));
     if (isset($USER) && is_object($USER)) {
         $arFields["RATING_USER_VOTE_VALUE"] = array("FIELD" => $DB->IsNull('RV.VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RV ON L.RATING_TYPE_ID = RV.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RV.ENTITY_ID AND RV.USER_ID = " . intval($USER->GetID()));
         if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") {
             $join_type = "LEFT";
             $field_value = $DB->IsNull("SLF.USER_ID", "0");
             foreach ($arFilter as $key => $value) {
                 if (strpos($key, "FAVORITES_USER_ID") !== false) {
                     $join_type = "INNER";
                     $field_value = "SLF.USER_ID";
                     break;
                 }
             }
             $arFields["FAVORITES_USER_ID"] = array("FIELD" => $field_value, "TYPE" => "double", "FROM" => $join_type . " JOIN b_sonet_log_favorites SLF ON L.ID = SLF.LOG_ID AND SLF.USER_ID = " . intval($USER->GetID()));
         }
     }
     if (isset($USER) && is_object($USER) && $USER->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") {
         $default_follow = CSocNetLogFollow::GetDefaultValue($USER->GetID());
         $default_field = $default_follow == "Y" ? "LOG_UPDATE" : "LOG_DATE";
         $arFields["DATE_FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN L." . $default_field . "\n\t\t\t\t\tWHEN LFW.FOLLOW_DATE IS NOT NULL\n\t\t\t\t\t\tTHEN LFW.FOLLOW_DATE\n\t\t\t\t\tWHEN LFW.TYPE = 'Y'\n\t\t\t\t\t\tTHEN L.LOG_UPDATE\n\t\t\t\t\tELSE L.LOG_DATE\n\t\t\t\tEND", "TYPE" => "datetime", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID"));
         $arFields["FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN '" . $default_follow . "'\n\t\t\t\t\tELSE LFW.TYPE\n\t\t\t\tEND", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID"));
         if (!in_array("FOLLOW", $arSelectFields)) {
             $arSelectFields[] = "FOLLOW";
         }
     }
     if (array_key_exists("SITE_ID", $arFilter)) {
         $arFields["SITE_ID"] = array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_site SLS ON L.ID = SLS.LOG_ID");
         if (is_array($arFilter["SITE_ID"])) {
             $site_cnt = 0;
             foreach ($arFilter["SITE_ID"] as $site_id_tmp) {
                 if ($site_id_tmp) {
                     $site_cnt++;
                 }
             }
             $strDistinct = $site_cnt > 1 ? " DISTINCT " : " ";
         } else {
             $strDistinct = " ";
         }
         foreach ($arSelectFields as $i => $strFieldTmp) {
             if ($strFieldTmp == "SITE_ID") {
                 unset($arSelectFields[$i]);
             }
         }
         foreach ($arOrder as $by => $order) {
             if (!in_array($by, $arSelectFields)) {
                 $arSelectFields[] = $by;
             }
         }
     } else {
         $arFields["SITE_ID"] = array("FIELD" => "L.SITE_ID", "TYPE" => "string");
         $strDistinct = " ";
     }
     if (array_key_exists("USER_ID", $arFilter) && !array_key_exists("ENTITY_TYPE", $arFilter)) {
         $arCBFilterEntityType = array();
         foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) {
             if (array_key_exists("USE_CB_FILTER", $arEntityTypeTmp) && $arEntityTypeTmp["USE_CB_FILTER"] == "Y") {
                 $arCBFilterEntityType[] = $entity_type_tmp;
             }
         }
         if (is_array($arCBFilterEntityType) && count($arCBFilterEntityType) > 0) {
             $arFilter["ENTITY_TYPE"] = $arCBFilterEntityType;
         }
     }
     if (array_key_exists("LOG_RIGHTS", $arFilter)) {
         $Rights = array();
         if (is_array($arFilter["LOG_RIGHTS"])) {
             foreach ($arFilter["LOG_RIGHTS"] as $str) {
                 if (trim($str)) {
                     $Rights[] = trim($str);
                 }
             }
         } elseif (trim($arFilter["LOG_RIGHTS"])) {
             $Rights = trim($arFilter["LOG_RIGHTS"]);
         }
         unset($arFilter["LOG_RIGHTS"]);
         if (is_array($Rights) && !empty($Rights) || !is_array($Rights)) {
             $arFilter["LOG_RIGHTS"] = $Rights;
             $arFields["LOG_RIGHTS"] = array("FIELD" => "SLR0.GROUP_CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log_right SLR0 ON L.ID = SLR0.LOG_ID");
         }
         if (is_array($Rights) && count($Rights) > 1) {
             $strDistinct = " DISTINCT ";
         }
     }
     if (array_key_exists("USER_ID|COMMENT_USER_ID", $arFilter)) {
         $strDistinct = " DISTINCT ";
     }
     if ($arParams["IS_CRM"] == "Y") {
         $events = GetModuleEvents("socialnetwork", "OnFillSocNetLogFields");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array(&$arFields));
         }
     }
     $arFields = array_merge($arFields1, $arFields);
     $arSqls = CSocNetGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
     $listEvents = GetModuleEvents("socialnetwork", "OnBuildSocNetLogSql");
     while ($arEvent = $listEvents->Fetch()) {
         ExecuteModuleEventEx($arEvent, array(&$arFields, &$arOrder, &$arFilter, &$arGroupBy, &$arSelectFields, &$arSqls));
     }
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlUFFilter = " (" . $r . ") ";
     }
     $arSqls["RIGHTS"] = "";
     $arSqls["CRM_RIGHTS"] = "";
     if (!empty($arParams) && (array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" || array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y") && !array_key_exists("USER_ID", $arParams) && is_object($USER)) {
         $arParams["USER_ID"] = $USER->GetID();
     }
     if (!empty($arParams) && array_key_exists("USER_ID", $arParams) && $arParams["CHECK_CRM_RIGHTS"] != "Y") {
         $arParams["CHECK_RIGHTS"] = "Y";
     }
     if (!empty($arParams) && ($arParams["USE_SUBSCRIBE"] == "Y" || $arParams["USE_FOLLOW"] == "Y")) {
         if (!array_key_exists("SUBSCRIBE_USER_ID", $arParams)) {
             if (array_key_exists("USER_ID", $arParams) && intval($arParams["USER_ID"]) > 0) {
                 $arParams["SUBSCRIBE_USER_ID"] = $arParams["USER_ID"];
             } elseif (is_object($USER)) {
                 $arParams["SUBSCRIBE_USER_ID"] = $USER->GetID();
             }
         }
         if ($arParams["USE_SUBSCRIBE"] == "Y" && !array_key_exists("MY_ENTITIES", $arParams)) {
             foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) {
                 if (array_key_exists("HAS_MY", $arEntityTypeTmp) && $arEntityTypeTmp["HAS_MY"] == "Y" && array_key_exists("CLASS_MY", $arEntityTypeTmp) && array_key_exists("METHOD_MY", $arEntityTypeTmp) && strlen($arEntityTypeTmp["CLASS_MY"]) > 0 && strlen($arEntityTypeTmp["METHOD_MY"]) > 0 && method_exists($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])) {
                     $arMyEntities[$entity_type_tmp] = call_user_func(array($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"]));
                 }
             }
             $arParams["MY_ENTITIES"] = $arMyEntities;
         }
     }
     if (!empty($arParams) && array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) {
         $acc = new CAccess();
         $acc->UpdateCodes();
         $arSqls["RIGHTS"] = "EXISTS ( SELECT SLR.ID FROM b_sonet_log_right SLR\n\t\t\t\tLEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . (is_object($USER) ? intval($USER->GetID()) : 0) . ")\n\t\t\t\tWHERE L.ID = SLR.LOG_ID " . (is_object($USER) && $USER->IsAuthorized() && $arParams["MY_GROUPS_ONLY"] == "Y" ? " AND (\n\t\t\t\t\t\t\t\t(SLR.GROUP_CODE LIKE 'SG%' AND (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")) \n\t\t\t\t\t\t\t\tOR SLR.GROUP_CODE = 'U" . intval($USER->GetID()) . "'\n\t\t\t\t\t\t\t)" : " AND (\n\t\t\t\t\t\t\t\t0=1 " . (is_object($USER) && CSocNetUser::IsCurrentUserModuleAdmin() ? " OR SLR.GROUP_CODE = 'SA'" : "") . (is_object($USER) && $USER->IsAuthorized() ? " OR (SLR.GROUP_CODE = 'AU')" : "") . " OR (SLR.GROUP_CODE = 'G2')" . (is_object($USER) && $USER->IsAuthorized() ? " OR (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")" : "") . "\n\t\t\t\t\t\t\t)") . ")";
     }
     if (!empty($arParams) && array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) {
         $permParams = array('ALIAS_PREFIX' => 'L', 'PERM_TYPE' => 'READ', 'FILTER_PARAMS' => isset($arParams['CUSTOM_FILTER_PARAMS']) ? $arParams['CUSTOM_FILTER_PARAMS'] : array(), 'OPTIONS' => array('ENTITY_TYPE_COLUMN' => 'ENTITY_TYPE', 'IDENTITY_COLUMN' => 'ENTITY_ID'));
         $altPerms = array();
         $events = GetModuleEvents("socialnetwork", "OnBuildSocNetLogPerms");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array(&$altPerms, $permParams));
         }
         if (!empty($altPerms)) {
             foreach ($altPerms as $permSql) {
                 if ($permSql === false) {
                     //Access denied
                     $dbRes = new CDBResult();
                     $dbRes->InitFromArray(array());
                     return $dbRes;
                 }
                 if (is_string($permSql) && $permSql !== '') {
                     if ($arSqls['CRM_RIGHTS'] !== '') {
                         $arSqls['CRM_RIGHTS'] .= ' AND ';
                     }
                     $arSqls['CRM_RIGHTS'] = $permSql;
                 }
             }
         }
     }
     if ($arParams["USE_SUBSCRIBE"] == "Y" && intval($arParams["SUBSCRIBE_USER_ID"]) > 0) {
         $arSqls["SUBSCRIBE"] = CSocNetLogEvents::GetSQL($arParams["SUBSCRIBE_USER_ID"], is_array($arParams["MY_ENTITIES"]) ? $arParams["MY_ENTITIES"] : array(), $arParams["TRANSPORT"], $arParams["VISIBLE"]);
         $arParams["MIN_ID_JOIN"] = true;
     }
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", $strDistinct, $arSqls["SELECT"]);
     $strMinIDJoin = "";
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " ";
         $bWhereStarted = false;
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
             $bWhereStarted = true;
         }
         if (strlen($strSqlUFFilter) > 0) {
             $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " ";
             $bWhereStarted = true;
         }
         if (strlen($arSqls["RIGHTS"]) > 0) {
             $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " ";
             $bWhereStarted = true;
         }
         if (strlen($arSqls["CRM_RIGHTS"]) > 0) {
             $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " ";
             $bWhereStarted = true;
         }
         if (strlen($arSqls["SUBSCRIBE"]) > 0) {
             $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") ";
             $bWhereStarted = true;
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " ";
     $bWhereStarted = false;
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($strSqlUFFilter) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["RIGHTS"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["CRM_RIGHTS"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["SUBSCRIBE"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         if (isset($arNavStartParams["nRecordCount"]) && intval($arNavStartParams["nRecordCount"]) > 0) {
             $cnt = intval($arNavStartParams["nRecordCount"]);
         } else {
             $strSql_tmp = "SELECT COUNT('x') as CNT " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " ";
             $bWhereStarted = false;
             if (strlen($arSqls["WHERE"]) > 0) {
                 $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($strSqlUFFilter) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["RIGHTS"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["CRM_RIGHTS"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["SUBSCRIBE"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["GROUPBY"]) > 0) {
                 $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
             }
             //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
             $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $cnt = 0;
             if (strlen($arSqls["GROUPBY"]) <= 0) {
                 if ($arRes = $dbRes->Fetch()) {
                     $cnt = $arRes["CNT"];
                 }
             } else {
                 // рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
                 $cnt = $dbRes->SelectedRowsCount();
             }
             // for empty 2nd page show
             if ($arNavStartParams["bSkipPageReset"] && $arNavStartParams["nPageSize"] >= $cnt) {
                 $cnt = $arNavStartParams["nPageSize"] + $cnt;
             }
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG"));
     }
     return $dbRes;
 }
Пример #26
0
 public static function OnAddRatingVote($id, $arParams)
 {
     $bSocialnetworkInstalled = CModule::IncludeModule("socialnetwork");
     if ($arParams['ENTITY_TYPE_ID'] == 'LISTS_NEW_ELEMENT' && CModule::IncludeModule("socialnetwork")) {
         $rsLog = CSocNetLog::GetList(array(), array("RATING_TYPE_ID" => $arParams['ENTITY_TYPE_ID'], "RATING_ENTITY_ID" => $arParams['ENTITY_ID']), false, false, array("ID", "USER_ID", "TITLE_TEMPLATE", "TITLE"));
         if ($arLog = $rsLog->Fetch()) {
             if ($arLog['USER_ID'] != $arParams['USER_ID']) {
                 $url = COption::GetOptionString("socialnetwork", "log_entry_page", $arSites[$user_site_id]["DIR"] . "company/personal/log/#log_id#/", SITE_ID);
                 $url = str_replace("#log_id#", $arLog["ID"], $url);
                 $arParams['ENTITY_LINK'] = $url;
                 $arParams['ENTITY_TITLE'] = htmlspecialcharsback($arLog["TITLE"]);
                 $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => intval($arLog['USER_ID']), "FROM_USER_ID" => intval($arParams['USER_ID']), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|" . ($arParams['VALUE'] >= 0 ? "" : "DL|") . $arParams['ENTITY_TYPE_ID'] . "|" . $arParams['ENTITY_ID'], "NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams), "NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true));
                 CIMNotify::Add($arMessageFields);
             }
         }
     } elseif ($arParams['ENTITY_TYPE_ID'] == 'LOG_COMMENT') {
         if ($arComment = CSocNetLogComments::GetByID($arParams['ENTITY_ID'])) {
             preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/ies" . BX_UTF_PCRE_MODIFIER, $arComment["TEXT_MESSAGE"], $arMention);
             if (!empty($arMention)) {
                 $arMentionedUserID = $arMention[1];
             }
             if ($arComment['USER_ID'] == $arParams['USER_ID'] && empty($arMentionedUserID)) {
                 return false;
             }
             $arEventTmp = CSocNetLogTools::FindLogCommentEventByID($arComment["EVENT_ID"]);
             if ($arEventTmp && array_key_exists("CLASS_FORMAT", $arEventTmp) && array_key_exists("METHOD_FORMAT", $arEventTmp)) {
                 $arComment["MESSAGE"] = preg_replace(array('|\\[DISK\\sFILE\\sID=[n]*\\d+\\]|', '|\\[DOCUMENT\\sID=[n]*\\d+\\]|'), '', $arComment["MESSAGE"]);
                 $arComment["MESSAGE"] = preg_replace('|\\[QUOTE\\](.+?)\\[\\/QUOTE\\]|is' . BX_UTF_PCRE_MODIFIER, '&quot;\\1&quot;', $arComment["MESSAGE"]);
                 $arFIELDS_FORMATTED = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arComment, array("IM" => "Y"));
                 $CCTP = new CTextParser();
                 $CCTP->MaxStringLen = 200;
                 $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
                 $arComment["MESSAGE"] = $CCTP->convertText($arFIELDS_FORMATTED["EVENT_FORMATTED"]["MESSAGE"]);
             }
             $arComment["MESSAGE"] = preg_replace(array('|\\[DISK\\sFILE\\sID=[n]*\\d+\\]|', '|\\[DOCUMENT\\sID=[n]*\\d+\\]|'), '', $arComment["MESSAGE"]);
             $arParams["ENTITY_TITLE"] = strip_tags(str_replace(array("<br>", "<br/>", "<br />", "#BR#"), array(" ", " ", " ", " "), htmlspecialcharsback($arComment["MESSAGE"])));
             $bExtranetInstalled = CModule::IncludeModule("extranet");
             if ($bExtranetInstalled) {
                 $arSites = array();
                 $extranet_site_id = CExtranet::GetExtranetSiteID();
                 $intranet_site_id = CSite::GetDefSite();
                 $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
                 while ($arSite = $dbSite->Fetch()) {
                     $arSites[$arSite["ID"]] = array("DIR" => strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/", "SERVER_NAME" => strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]));
                 }
             }
             if ($arComment['USER_ID'] != $arParams['USER_ID']) {
                 $followValue = "Y";
                 if ($bSocialnetworkInstalled) {
                     $followValue = CSocNetLogFollow::GetExactValueByRating($arComment['USER_ID'], trim($arParams["ENTITY_TYPE_ID"]), intval($arParams["ENTITY_ID"]));
                 }
                 if ($followValue != "N") {
                     $arParams['ENTITY_LINK'] = self::GetMessageRatingLogCommentURL($arComment, intval($arComment['USER_ID']), $arSites, $intranet_site_id, $extranet_site_id);
                     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => intval($arComment['USER_ID']), "FROM_USER_ID" => intval($arParams['USER_ID']), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|" . ($arParams['VALUE'] >= 0 ? "" : "DL|") . $arParams['ENTITY_TYPE_ID'] . "|" . $arParams['ENTITY_ID'], "NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams), "NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true));
                     CIMNotify::Add($arMessageFields);
                 }
             }
             if (!empty($arMentionedUserID) && is_array($arMentionedUserID)) {
                 $arParams["MENTION"] = true;
                 // for self::GetMessageRatingVote()
                 foreach ($arMentionedUserID as $mentioned_user_id) {
                     if ($mentioned_user_id != $arParams['USER_ID'] && CSocNetLogRights::CheckForUserOnly($arComment["LOG_ID"], $mentioned_user_id)) {
                         $followValue = "Y";
                         if ($bSocialnetworkInstalled) {
                             $followValue = CSocNetLogFollow::GetExactValueByRating(intval($mentioned_user_id), trim($arParams["ENTITY_TYPE_ID"]), intval($arParams["ENTITY_ID"]));
                         }
                         if ($followValue != "N") {
                             $arParams['ENTITY_LINK'] = self::GetMessageRatingLogCommentURL($arComment, intval($mentioned_user_id), $arSites, $intranet_site_id, $extranet_site_id);
                             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => intval($mentioned_user_id), "FROM_USER_ID" => intval($arParams['USER_ID']), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote_mentioned", "NOTIFY_TAG" => "RATING_MENTION|" . ($arParams['VALUE'] >= 0 ? "" : "DL|") . $arParams['ENTITY_TYPE_ID'] . "|" . $arParams['ENTITY_ID'], "NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams), "NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true));
                             CIMNotify::Add($arMessageFields);
                         }
                     }
                 }
             }
         }
     } else {
         if (!CModule::IncludeModule("search") || BX_SEARCH_VERSION <= 1) {
             return false;
         }
         $CSI = new CSearchItem();
         $arFSearch = array('=ENTITY_TYPE_ID' => $arParams['ENTITY_TYPE_ID'], '=ENTITY_ID' => $arParams['ENTITY_ID']);
         if (defined("SITE_ID") && strlen(SITE_ID) > 0) {
             $arFSearch["=SITE_ID"] = SITE_ID;
         }
         $res = $CSI->GetList(array(), $arFSearch, array('ID', 'URL', 'TITLE', 'BODY', 'PARAM1'));
         if ($arItem = $res->GetNext(true, false)) {
             // notify mentioned users
             $arSearchItemParams = CSearch::GetContentItemParams($arItem['ID'], 'mentioned_user_id');
             if (is_array($arSearchItemParams) && array_key_exists('mentioned_user_id', $arSearchItemParams) && is_array($arSearchItemParams['mentioned_user_id'])) {
                 $arMentionedUserID = $arSearchItemParams['mentioned_user_id'];
             }
             // send to author
             if ($arParams['OWNER_ID'] != $arParams['USER_ID'] || $arMentionedUserID) {
                 $arParams["ENTITY_LINK"] = $arItem['URL'];
                 $arParams["ENTITY_PARAM"] = $arItem['PARAM1'];
                 $arParams["ENTITY_TITLE"] = trim(strip_tags(str_replace(array("\r\n", "\n", "\r"), ' ', htmlspecialcharsback($arItem['TITLE']))));
                 $arParams["ENTITY_MESSAGE"] = trim(strip_tags(str_replace(array("\r\n", "\n", "\r"), ' ', htmlspecialcharsback($arItem['BODY']))));
                 if ((strlen($arParams["ENTITY_TITLE"]) > 0 || strlen($arParams["ENTITY_MESSAGE"]) > 0) && strlen($arParams["ENTITY_LINK"]) > 0) {
                     $originalLink = $arParams["ENTITY_LINK"];
                     $bExtranetInstalled = CModule::IncludeModule("extranet");
                     if ($bExtranetInstalled) {
                         $arSites = array();
                         $extranet_site_id = CExtranet::GetExtranetSiteID();
                         $intranet_site_id = CSite::GetDefSite();
                         $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
                         while ($arSite = $dbSite->Fetch()) {
                             $arSites[$arSite["ID"]] = array("DIR" => strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/", "SERVER_NAME" => strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]));
                         }
                     }
                     if ($arParams['OWNER_ID'] != $arParams['USER_ID']) {
                         $followValue = "Y";
                         if ($bSocialnetworkInstalled) {
                             $followValue = CSocNetLogFollow::GetExactValueByRating(intval($arParams['OWNER_ID']), trim($arParams["ENTITY_TYPE_ID"]), intval($arParams["ENTITY_ID"]));
                         }
                         if ($followValue != "N") {
                             $arParams['ENTITY_LINK'] = self::GetMessageRatingEntityURL($originalLink, intval($arParams['OWNER_ID']), $arSites, $intranet_site_id, $extranet_site_id);
                             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => intval($arParams['OWNER_ID']), "FROM_USER_ID" => intval($arParams['USER_ID']), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|" . ($arParams['VALUE'] >= 0 ? "" : "DL|") . $arParams['ENTITY_TYPE_ID'] . "|" . $arParams['ENTITY_ID'], "NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams), "NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true));
                             CIMNotify::Add($arMessageFields);
                         }
                     }
                     if (is_array($arMentionedUserID) && $bSocialnetworkInstalled) {
                         if (in_array($arParams['ENTITY_TYPE_ID'], array("BLOG_COMMENT", "FORUM_POST"))) {
                             $rsLogComment = CSocNetLogComments::GetList(array(), array("RATING_TYPE_ID" => $arParams['ENTITY_TYPE_ID'], "RATING_ENTITY_ID" => $arParams['ENTITY_ID']), false, false, array("LOG_ID"));
                             if ($arLogComment = $rsLogComment->Fetch()) {
                                 $log_id = $arLogComment["LOG_ID"];
                             }
                         } elseif (in_array($arParams['ENTITY_TYPE_ID'], array("BLOG_POST"))) {
                             $rsLog = CSocNetLog::GetList(array(), array("RATING_TYPE_ID" => $arParams['ENTITY_TYPE_ID'], "RATING_ENTITY_ID" => $arParams['ENTITY_ID']), false, false, array("ID"));
                             if ($arLog = $rsLog->Fetch()) {
                                 $log_id = $arLog["ID"];
                             }
                         }
                         if (intval($log_id) > 0) {
                             $arParams["MENTION"] = true;
                             // for self::GetMessageRatingVote()
                             foreach ($arMentionedUserID as $mentioned_user_id) {
                                 if ($mentioned_user_id != $arParams['USER_ID'] && CSocNetLogRights::CheckForUserOnly($log_id, $mentioned_user_id)) {
                                     $followValue = "Y";
                                     if ($bSocialnetworkInstalled) {
                                         $followValue = CSocNetLogFollow::GetExactValueByRating(intval($mentioned_user_id), trim($arParams["ENTITY_TYPE_ID"]), intval($arParams["ENTITY_ID"]));
                                     }
                                     if ($followValue != "N") {
                                         $arParams['ENTITY_LINK'] = self::GetMessageRatingEntityURL($originalLink, intval($mentioned_user_id), $arSites, $intranet_site_id, $extranet_site_id);
                                         $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => intval($mentioned_user_id), "FROM_USER_ID" => intval($arParams['USER_ID']), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote_mentioned", "NOTIFY_TAG" => "RATING_MENTION|" . ($arParams['VALUE'] >= 0 ? "" : "DL|") . $arParams['ENTITY_TYPE_ID'] . "|" . $arParams['ENTITY_ID'], "NOTIFY_MESSAGE" => self::GetMessageRatingVote($arParams), "NOTIFY_MESSAGE_OUT" => self::GetMessageRatingVote($arParams, true));
                                         CIMNotify::Add($arMessageFields);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #27
0
 function UpdateLogData($log_id, $bSetDate = true, $bSetDateByLastComment = false)
 {
     $dbResult = CSocNetLogComments::GetList(array(), array("LOG_ID" => $log_id), array());
     $comments_count = $dbResult;
     $dbResult = CSocNetLog::GetList(array(), array("ID" => $log_id), false, false, array("ID", "COMMENTS_COUNT", "LOG_DATE"));
     while ($arResult = $dbResult->Fetch()) {
         $arFields = array("COMMENTS_COUNT" => $comments_count);
         if ($bSetDateByLastComment) {
             $dbComment = CSocNetLogComments::GetList(array("LOG_DATE" => "DESC"), array("LOG_ID" => $log_id), false, false, array("ID", "LOG_DATE"));
             if ($arComment = $dbComment->Fetch()) {
                 $arFields["LOG_UPDATE"] = $arComment["LOG_DATE"];
             } else {
                 $arFields["LOG_UPDATE"] = $arResult["LOG_DATE"];
             }
         } elseif ($bSetDate) {
             $arFields["=LOG_UPDATE"] = $GLOBALS["DB"]->CurrentTimeFunction();
         }
         CSocNetLog::Update($arResult["ID"], $arFields);
         CSocNetLogFollow::DeleteByLogID($log_id, "Y", true);
     }
 }
Пример #28
0
 public static function NotifyIm($arParams)
 {
     if (!CModule::IncludeModule("im") || intval($arParams["PHOTO_AUTHOR_ID"]) <= 0 || $arParams["PHOTO_AUTHOR_ID"] == intval($arParams["COMMENT_AUTHOR_ID"])) {
         return;
     }
     if (!array_key_exists("SECTION_NAME", $arParams)) {
         $arParams["SECTION_NAME"] = "";
     }
     if (!array_key_exists("SECTION_URL", $arParams)) {
         $arParams["SECTION_URL"] = 0;
     }
     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arParams["PHOTO_AUTHOR_ID"], "FROM_USER_ID" => $arParams["COMMENT_AUTHOR_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "photogallery", "NOTIFY_EVENT" => "comment");
     $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("photo_photo"), "SOURCE_ID" => $arParams["ID"]), false, false, array("ID"));
     if ($arLog = $rsLog->Fetch()) {
         $rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arParams["PHOTO_AUTHOR_ID"], "CODE" => "L" . $arLog["ID"], "TYPE" => "N"), array("USER_ID"));
         if ($arUnFollower = $rsUnFollower->Fetch()) {
             return;
         }
         $arMessageFields["LOG_ID"] = $arLog["ID"];
     }
     $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]);
     $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
     $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
     $arTmp = CSocNetLogTools::ProcessPath(array("PHOTO_URL" => $arParams["URL"], "SECTION_URL" => $arParams["SECTION_URL"]), $arParams["PHOTO_AUTHOR_ID"]);
     $serverName = $arTmp["SERVER_NAME"];
     $arParams["URL"] = $arTmp["URLS"]["PHOTO_URL"];
     $arParams["SECTION_URL"] = $arTmp["URLS"]["SECTION_URL"];
     $arMessageFields["NOTIFY_TAG"] = "PHOTO|COMMENT|" . $arParams["ID"];
     $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("SONET_PHOTO_IM_COMMENT", array("#photo_title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>", "#album_title#" => "<a href=\"" . $arParams["SECTION_URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["SECTION_NAME"]) . "</a>"));
     $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("SONET_PHOTO_IM_COMMENT", array("#photo_title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]), "#album_title#" => htmlspecialcharsbx($arParams["SECTION_NAME"]))) . " (" . $serverName . $arParams["URL"] . ")#BR##BR#" . $arParams["MESSAGE"];
     $ID = CIMNotify::Add($arMessageFields);
     if (!empty($arParams["COMMENT_MENTION_ID"])) {
         //
     }
 }
Пример #29
0
	public static function OnBlogPostMentionNotifyIm($ID, $arMessageFields)
	{
		if (
			is_array($arMessageFields)
			&& intval($arMessageFields["TO_USER_ID"]) > 0
			&& intval($arMessageFields["LOG_ID"]) > 0
		)
			$res = CSocNetLogFollow::Set(intval($arMessageFields["TO_USER_ID"]), "L".intval($arMessageFields["LOG_ID"]), "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));

		return $res;
	}
Пример #30
0
	function GetList($arOrder = Array("ID" => "DESC"), $arFilter = Array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arParams = array())
	{
		global $DB, $arSocNetAllowedEntityTypes, $USER;

		if (count($arSelectFields) <= 0)
			$arSelectFields = array(
				"ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS",
				"COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID",
				"GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID",
				"USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER",
				"CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER",
				"RATING_TYPE_ID", "RATING_ENTITY_ID", "RATING_TOTAL_VALUE", "RATING_TOTAL_VOTES", "RATING_TOTAL_POSITIVE_VOTES", "RATING_TOTAL_NEGATIVE_VOTES", "RATING_USER_VOTE_VALUE",
				"FAVORITES_USER_ID", "SOURCE_TYPE"
			);

		static $arFields1 = array(
			"ID" => Array("FIELD" => "L.ID", "TYPE" => "int"),
			"TMP_ID" => Array("FIELD" => "L.TMP_ID", "TYPE" => "int"),
			"SOURCE_ID" => Array("FIELD" => "L.SOURCE_ID", "TYPE" => "int"),
			"ENTITY_TYPE" => Array("FIELD" => "L.ENTITY_TYPE", "TYPE" => "string"),
			"ENTITY_ID" => Array("FIELD" => "L.ENTITY_ID", "TYPE" => "int"),
			"USER_ID" => Array("FIELD" => "L.USER_ID", "TYPE" => "int"),
			"EVENT_ID" => Array("FIELD" => "L.EVENT_ID", "TYPE" => "string"),
			"LOG_DATE" => Array("FIELD" => "L.LOG_DATE", "TYPE" => "datetime"),
			"LOG_DATE_TS" => Array("FIELD" => "UNIX_TIMESTAMP(L.LOG_DATE)", "TYPE" => "int"),
			"LOG_UPDATE" => Array("FIELD" => "L.LOG_UPDATE", "TYPE" => "datetime"),
			"TITLE_TEMPLATE" => Array("FIELD" => "L.TITLE_TEMPLATE", "TYPE" => "string"),
			"TITLE" => Array("FIELD" => "L.TITLE", "TYPE" => "string"),
			"MESSAGE" => Array("FIELD" => "L.MESSAGE", "TYPE" => "string"),
			"TEXT_MESSAGE" => Array("FIELD" => "L.TEXT_MESSAGE", "TYPE" => "string"),
			"URL" => Array("FIELD" => "L.URL", "TYPE" => "string"),
			"MODULE_ID" => Array("FIELD" => "L.MODULE_ID", "TYPE" => "string"),
			"CALLBACK_FUNC" => Array("FIELD" => "L.CALLBACK_FUNC", "TYPE" => "string"),
			"EXTERNAL_ID" => Array("FIELD" => "L.EXTERNAL_ID", "TYPE" => "string"),
			"PARAMS" => Array("FIELD" => "L.PARAMS", "TYPE" => "string"),
			"COMMENTS_COUNT" => Array("FIELD" => "L.COMMENTS_COUNT", "TYPE" => "int"),
			"ENABLE_COMMENTS" => Array("FIELD" => "L.ENABLE_COMMENTS", "TYPE" => "string"),
			"SOURCE_TYPE" => Array("FIELD" => "L.SOURCE_TYPE", "TYPE" => "string"),
			"GROUP_NAME" => Array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"GROUP_OWNER_ID" => Array("FIELD" => "G.OWNER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"GROUP_INITIATE_PERMS" => Array("FIELD" => "G.INITIATE_PERMS", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"GROUP_VISIBLE" => Array("FIELD" => "G.VISIBLE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"GROUP_OPENED" => Array("FIELD" => "G.OPENED", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"GROUP_IMAGE_ID" => Array("FIELD" => "G.IMAGE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"),
			"USER_NAME" => Array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"USER_LAST_NAME" => Array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"USER_SECOND_NAME" => Array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"USER_LOGIN" => Array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"USER_PERSONAL_PHOTO" => Array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"USER_PERSONAL_GENDER" => Array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"),
			"CREATED_BY_NAME" => Array("FIELD" => "U1.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"CREATED_BY_LAST_NAME" => Array("FIELD" => "U1.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"CREATED_BY_SECOND_NAME" => Array("FIELD" => "U1.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"CREATED_BY_LOGIN" => Array("FIELD" => "U1.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"CREATED_BY_PERSONAL_PHOTO" => Array("FIELD" => "U1.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"CREATED_BY_PERSONAL_GENDER" => Array("FIELD" => "U1.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"),
			"USER_ID|COMMENT_USER_ID" => Array("FIELD" => "L.USER_ID|LC.USER_ID", "WHERE" => array("CSocNetLog", "GetSimpleOrQuery"), "FROM" => "LEFT JOIN b_sonet_log_comment LC ON LC.LOG_ID = L.ID"),
		);

		$arFields = array(
			"RATING_TYPE_ID" => Array("FIELD" => "L.RATING_TYPE_ID", "TYPE" => "string"),
			"RATING_ENTITY_ID" => Array("FIELD" => "L.RATING_ENTITY_ID", "TYPE" => "int"),
			"RATING_TOTAL_VALUE" => Array("FIELD" => $DB->IsNull('RG.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"),
			"RATING_TOTAL_VOTES" => Array("FIELD" => $DB->IsNull('RG.TOTAL_VOTES', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"),
			"RATING_TOTAL_POSITIVE_VOTES" => Array("FIELD" => $DB->IsNull('RG.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"),
			"RATING_TOTAL_NEGATIVE_VOTES" => Array("FIELD" => $DB->IsNull('RG.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"),
		);

		if (isset($USER) && is_object($USER))
		{
			$arFields["RATING_USER_VOTE_VALUE"] = Array("FIELD" => $DB->IsNull('RV.VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RV ON L.RATING_TYPE_ID = RV.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RV.ENTITY_ID AND RV.USER_ID = ".intval($USER->GetID()));
			$arFields["FAVORITES_USER_ID"] = Array("FIELD" => $DB->IsNull('SLF.USER_ID', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_sonet_log_favorites SLF ON L.ID = SLF.LOG_ID AND SLF.USER_ID = ".intval($USER->GetID()));
		}

		if (
			isset($USER) 
			&& is_object($USER) 
			&& $USER->IsAuthorized() 
			&& $arParams["USE_FOLLOW"] == "Y"
		)
		{
			$default_follow = CSocNetLogFollow::GetDefaultValue($USER->GetID());
			$default_field = ($default_follow == "Y" ? "LOG_UPDATE" : "LOG_DATE");

			$arFields["DATE_FOLLOW"] = Array("FIELD" => "CASE 
				WHEN LFW.USER_ID IS NULL 
					THEN L.".$default_field." 
				WHEN LFW.FOLLOW_DATE IS NOT NULL 
					THEN LFW.FOLLOW_DATE 
				WHEN LFW.TYPE = 'Y' 
					THEN L.LOG_UPDATE 
				ELSE L.LOG_DATE 
				END", "TYPE" => "datetime", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = ".$USER->GetID()." AND LFW.CODE = ".$DB->Concat("'L'", "L.ID"));

			$arFields["FOLLOW"] = Array("FIELD" => "case when LFW.USER_ID IS NULL then '".$default_follow."' else LFW.TYPE end", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = ".$USER->GetID()." AND LFW.CODE = ".$DB->Concat("'L'", "L.ID"));

			if (!in_array("FOLLOW", $arSelectFields))
				$arSelectFields[] = "FOLLOW";
		}

		if (array_key_exists("SITE_ID", $arFilter))
		{
			$arFields["SITE_ID"] = Array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_site SLS ON L.ID = SLS.LOG_ID");

			if (is_array($arFilter["SITE_ID"]))
			{
				$site_cnt = 0;
				foreach ($arFilter["SITE_ID"] as $site_id_tmp)
					if ($site_id_tmp)
						$site_cnt++;

				$strDistinct = ($site_cnt > 1 ? " DISTINCT " : " ");
			}
			else
				$strDistinct = " ";

			foreach ($arSelectFields as $i => $strFieldTmp)
				if ($strFieldTmp == "SITE_ID")
					unset($arSelectFields[$i]);

			foreach ($arOrder as $by => $order)
				if (!in_array($by, $arSelectFields))
					$arSelectFields[] = $by;
		}
		else
		{
			$arFields["SITE_ID"] = Array("FIELD" => "L.SITE_ID", "TYPE" => "string");
			$strDistinct = " ";
		}

		if (
			array_key_exists("USER_ID", $arFilter)
			&& !array_key_exists("ENTITY_TYPE", $arFilter)
		)
		{
			$arCBFilterEntityType = array();
			foreach($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"] as $entity_type_tmp => $arEntityTypeTmp)
				if (
					array_key_exists("USE_CB_FILTER", $arEntityTypeTmp)
					&& $arEntityTypeTmp["USE_CB_FILTER"] == "Y"
				)
					$arCBFilterEntityType[] = $entity_type_tmp;

			if (is_array($arCBFilterEntityType) && count($arCBFilterEntityType) > 0)
				$arFilter["ENTITY_TYPE"] = $arCBFilterEntityType;
		}

		if (array_key_exists("LOG_RIGHTS", $arFilter))
		{
			$Rights = array();
			if(is_array($arFilter["LOG_RIGHTS"]))
			{
				foreach($arFilter["LOG_RIGHTS"] as $str)
					if(trim($str))
						$Rights[] = trim($str);
			}
			elseif(trim($arFilter["LOG_RIGHTS"]))
				$Rights = trim($arFilter["LOG_RIGHTS"]);

			unset($arFilter["LOG_RIGHTS"]);
			if((is_array($Rights) && !empty($Rights)) || !is_array($Rights))
			{
				$arFilter["LOG_RIGHTS"] = $Rights;
				$arFields["LOG_RIGHTS"] = Array("FIELD" => "SLR0.GROUP_CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log_right SLR0 ON L.ID = SLR0.LOG_ID");
			}

			if(is_array($Rights) && count($Rights) > 1)
				$strDistinct = " DISTINCT ";
		}

		if (array_key_exists("USER_ID|COMMENT_USER_ID", $arFilter))
			$strDistinct = " DISTINCT ";		

		$arFields = array_merge($arFields1, $arFields);

		$arSqls = CSocNetGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);

		$arSqls["RIGHTS"] = "";

		if (
			!empty($arParams)
			&& array_key_exists("CHECK_RIGHTS", $arParams)
			&& $arParams["CHECK_RIGHTS"] == "Y"
			&& !array_key_exists("USER_ID", $arParams)
			&& is_object($USER)
		)
			$arParams["USER_ID"] = $USER->GetID();

		if (
			!empty($arParams)
			&& array_key_exists("USER_ID", $arParams)
		)
			$arParams["CHECK_RIGHTS"] = "Y";

		if (
			!empty($arParams)
			&& (
				$arParams["USE_SUBSCRIBE"] == "Y"
				|| $arParams["USE_FOLLOW"] == "Y"
			)
		)
		{
			if (!array_key_exists("SUBSCRIBE_USER_ID", $arParams))
			{
				if (
					array_key_exists("USER_ID", $arParams)
					&& intval($arParams["USER_ID"]) > 0
				)
					$arParams["SUBSCRIBE_USER_ID"] = $arParams["USER_ID"];
				elseif (is_object($USER))
					$arParams["SUBSCRIBE_USER_ID"] = $USER->GetID();
			}

			if (
				$arParams["USE_SUBSCRIBE"] == "Y"
				&& !array_key_exists("MY_ENTITIES", $arParams)
			)
			{
				foreach($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"] as $entity_type_tmp => $arEntityTypeTmp)
					if (
						array_key_exists("HAS_MY", $arEntityTypeTmp)
						&& $arEntityTypeTmp["HAS_MY"] == "Y"
						&& array_key_exists("CLASS_MY", $arEntityTypeTmp)
						&& array_key_exists("METHOD_MY", $arEntityTypeTmp)
						&& strlen($arEntityTypeTmp["CLASS_MY"]) > 0
						&& strlen($arEntityTypeTmp["METHOD_MY"]) > 0
						&& method_exists($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])
					)
						$arMyEntities[$entity_type_tmp] = call_user_func(array($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"]));

				$arParams["MY_ENTITIES"] = $arMyEntities;
			}
		}

		if (
			!empty($arParams)
			&& array_key_exists("CHECK_RIGHTS", $arParams)
			&& $arParams["CHECK_RIGHTS"] == "Y"
			&& array_key_exists("USER_ID", $arParams)
		)
		{
			$acc = new CAccess;
			$acc->UpdateCodes();

			$arSqls["RIGHTS"] = "EXISTS ( SELECT SLR.ID FROM b_sonet_log_right SLR
				LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = ".(is_object($USER) ? intval($USER->GetID()) : 0).")
				WHERE L.ID = SLR.LOG_ID ".
					(
						is_object($USER) && $USER->IsAuthorized() && $arParams["MY_GROUPS_ONLY"] == "Y" 
						? 
							" AND (
								(SLR.GROUP_CODE LIKE 'SG%' AND (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = ".intval($USER->GetID()).")) 
								OR SLR.GROUP_CODE = 'U".intval($USER->GetID())."'
							)"
						:
							" AND (
								0=1 ".
								(is_object($USER) && CSocNetUser::IsCurrentUserModuleAdmin() ? " OR SLR.GROUP_CODE = 'SA'" : "").
								(is_object($USER) && $USER->IsAuthorized() ? " OR (SLR.GROUP_CODE = 'AU')" : "").
								" OR (SLR.GROUP_CODE = 'G2')".
								(is_object($USER) && $USER->IsAuthorized() ? " OR (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = ".intval($USER->GetID()).")" : "")."
							)"
					).")";
		}

		if (
			$arParams["USE_SUBSCRIBE"] == "Y"
			&& intval($arParams["SUBSCRIBE_USER_ID"]) > 0
		)
		{
			$arSqls["SUBSCRIBE"] = CSocNetLogEvents::GetSQL(
				$arParams["SUBSCRIBE_USER_ID"],
				(is_array($arParams["MY_ENTITIES"]) ? $arParams["MY_ENTITIES"] : array()),
				$arParams["TRANSPORT"],
				$arParams["VISIBLE"]
			);
			$arParams["MIN_ID_JOIN"] = true;
		}

		$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", $strDistinct, $arSqls["SELECT"]);
		$strMinIDJoin = "";

		if (is_array($arGroupBy) && count($arGroupBy)==0)
		{
			$strSql =
				"SELECT ".$arSqls["SELECT"]." ".
				"FROM b_sonet_log L ".
				$strMinIDJoin.
				"	".$arSqls["FROM"]." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$strSql .= "WHERE ".$arSqls["WHERE"]." ";
			if (strlen($arSqls["RIGHTS"]) > 0)
			{
				if (strlen($arSqls["WHERE"]) > 0)
					$strSql .= " AND ";
				else
					$strSql .= " WHERE ";
				$strSql .= $arSqls["RIGHTS"]." ";
			}
			if (strlen($arSqls["SUBSCRIBE"]) > 0)
			{
				if (
					strlen($arSqls["WHERE"]) > 0
					|| strlen($arSqls["RIGHTS"]) > 0
				)
					$strSql .= " AND ";
				else
					$strSql .= " WHERE ";
				$strSql .= "(".$arSqls["SUBSCRIBE"].") ";
			}
			if (strlen($arSqls["GROUPBY"]) > 0)
				$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			if ($arRes = $dbRes->Fetch())
				return $arRes["CNT"];
			else
				return False;
		}

		$strSql =
			"SELECT ".$arSqls["SELECT"]." ".
			"FROM b_sonet_log L ".
			$strMinIDJoin.
			"       ".$arSqls["FROM"]." ";
		if (strlen($arSqls["WHERE"]) > 0)
			$strSql .= "WHERE ".$arSqls["WHERE"]." ";
		if (strlen($arSqls["RIGHTS"]) > 0)
		{
			if (strlen($arSqls["WHERE"]) > 0)
				$strSql .= " AND ";
			else
				$strSql .= " WHERE ";
			$strSql .= $arSqls["RIGHTS"]." ";
		}
		if (strlen($arSqls["SUBSCRIBE"]) > 0)
		{
			if (
				strlen($arSqls["WHERE"]) > 0
				|| strlen($arSqls["RIGHTS"]) > 0
			)
				$strSql .= " AND ";
			else
				$strSql .= " WHERE ";
			$strSql .= "(".$arSqls["SUBSCRIBE"].") ";
		}
		if (strlen($arSqls["GROUPBY"]) > 0)
			$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
		if (strlen($arSqls["ORDERBY"]) > 0)
			$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";

		if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0)
		{
			$strSql_tmp =
				"SELECT COUNT('x') as CNT ".
				"FROM b_sonet_log L ".
				$strMinIDJoin.
				"	".$arSqls["FROM"]." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ";
			if (strlen($arSqls["RIGHTS"]) > 0)
			{
				if (strlen($arSqls["WHERE"]) > 0)
					$strSql_tmp .= " AND ";
				else
					$strSql_tmp .= " WHERE ";
				$strSql_tmp .= $arSqls["RIGHTS"]." ";
			}
			if (strlen($arSqls["SUBSCRIBE"]) > 0)
			{
				if (
					strlen($arSqls["WHERE"]) > 0
					|| strlen($arSqls["RIGHTS"]) > 0
				)
					$strSql_tmp .= " AND ";
				else
					$strSql_tmp .= " WHERE ";
				$strSql_tmp .= "(".$arSqls["SUBSCRIBE"].") ";
			}
			if (strlen($arSqls["GROUPBY"]) > 0)
				$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";

			$dbRes = $DB->Query($strSql_tmp, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$cnt = 0;
			if (strlen($arSqls["GROUPBY"]) <= 0)
			{
				if ($arRes = $dbRes->Fetch())
					$cnt = $arRes["CNT"];
			}
			else
			{
				// рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
				$cnt = $dbRes->SelectedRowsCount();
			}

			// for empty 2nd page show
			if ($arNavStartParams["bSkipPageReset"] && $arNavStartParams["nPageSize"] >= $cnt)
				$cnt = $arNavStartParams["nPageSize"] + $cnt;

			$dbRes = new CDBResult();

			//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
		}
		else
		{
			if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
				$strSql .= "LIMIT ".intval($arNavStartParams["nTopCount"]);

			//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}

		return $dbRes;
	}