• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::SocNetLog
function SocNetLog($arParams)
{
	$ownerType = isset($arParams['ownerType']) ? $arParams['ownerType'] : $this->ownerType;
	$ownerId = isset($arParams['ownerId']) ? $arParams['ownerId'] : $this->ownerId;
	$iblockId = isset($arParams['iblockId']) ? $arParams['iblockId'] : $this->iblockId;
	$pathToUserCalendar = isset($arParams['pathToUserCalendar']) ? $arParams['pathToUserCalendar'] : $this->pathToUserCalendar;
	$pathToGroupCalendar = isset($arParams['pathToGroupCalendar']) ? $arParams['pathToGroupCalendar'] : $this->pathToGroupCalendar;

	if (!class_exists('CSocNetLog') || !$ownerType || !$ownerId)
		return;

	$target = $arParams['target'];
	$id = $arParams['id'];
	$name = htmlspecialcharsex($arParams['name']);
	$from = htmlspecialcharsex($arParams['from']);
	$to = htmlspecialcharsex($arParams['to']);
	$desc = htmlspecialcharsex($arParams['desc']);
	$accessibility = htmlspecialcharsex($arParams['accessibility']);
	$importance = htmlspecialcharsex($arParams['importance']);
	$calendarId = $arParams['calendarId'];

	if ($ownerType == 'USER')
	{
		// Get user name
		$dbUser = CUser::GetByID($ownerId);
		if (!$arUser = $dbUser->Fetch())
			return;
		$owner_mess = GetMessage('EC_LOG_EV_USER', array('#USER_NAME#' => $arUser["NAME"]." ".$arUser["LAST_NAME"]));
		$url = preg_replace('/#user_id#/i', $ownerId, $pathToUserCalendar);
		$privateStatus = CECCalendar::GetPrivateStatus($iblockId, $calendarId, $ownerType);

		if (!$accessibility)
			$accessibility = 'busy';
		$accessibilityMess = GetMessage('EC_ACCESSIBILITY_'.mb_strtoupper($accessibility));

		if ($privateStatus == 'private')
			return;
		elseif ($privateStatus == 'time' || $privateStatus == 'title')
		{
			if ($privateStatus == 'time')
			{
				$name = $accessibilityMess;
				$accessibility = '';
			}
			$desc = '';
		}
	}
	else
	{
		// Get group name
		if (!$arGroup = CSocNetGroup::GetByID($ownerId))
			return;
		$owner_mess = GetMessage('EC_LOG_EV_GROUP', array('#GROUP_NAME#' => $arGroup["NAME"]));
		$url = preg_replace('/#group_id#/i', $ownerId, $pathToGroupCalendar);
		$accessibility = '';
	}

	if ($calendarId <= 0)
		return;

	$rsData = CIBlockSection::GetByID($calendarId);
	if (!$arCalendar = $rsData->Fetch())
		return;

	$accessibility_mess = $accessibility <> ''? '
'.GetMessage('EC_LOG_EV_ACCESS', array('#EV_ACCESS#' => $accessibilityMess)) : ''; $importance_mess = $importance <> ''? '
'.GetMessage('EC_LOG_EV_IMP', array('#EV_IMP#' => GetMessage('EC_IMPORTANCE_'.mb_strtoupper($importance)))) : ''; $desc_mess = $desc <> ''? '
'.GetMessage('EC_LOG_EV_DESC', array('#EV_DESC#' => $desc)) : ''; $calendarTitle = htmlspecialcharsex($arCalendar['NAME']); if ($target == 'add_event') { $title_template = GetMessage('EC_LOG_NEW_EV_TITLE'); $mess = GetMessage('EC_LOG_NEW_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)).' '.$owner_mess.' '.$desc_mess.$accessibility_mess.$importance_mess; $url .= '?EVENT_ID='.$id; } elseif ($target == 'edit_event') { $title_template = GetMessage('EC_LOG_EDIT_EV_TITLE'); $mess = GetMessage('EC_LOG_EDIT_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)).' '.$owner_mess.' '.$desc_mess.$accessibility_mess.$importance_mess; $url .= '?EVENT_ID='.$id; } elseif ($target == 'delete_event') { $title_template = GetMessage('EC_LOG_DEL_EV_TITLE'); $mess = GetMessage('EC_LOG_DEL_EV_MESS', array('#EV_TITLE#' => $name, '#CAL_TITLE#' => $calendarTitle, '#EV_FROM#' => $from, '#EV_TO#' => $to)).' '.$owner_mess.' '.$desc_mess; } $USER_ID = false; if ($GLOBALS["USER"]->IsAuthorized()) $USER_ID = $GLOBALS["USER"]->GetID(); $res = CSocNetLog::Add( array( "ENTITY_TYPE" => $ownerType == 'GROUP' ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, "ENTITY_ID" => $ownerId, "EVENT_ID" => "calendar", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $title_template, "TITLE" => $name, "MESSAGE" => $mess, "TEXT_MESSAGE" => preg_replace(array("/<(/)?b>/i", "/
/i"), array('', " n"), $mess), "URL" => $url, "MODULE_ID" => false, "CALLBACK_FUNC" => false, "USER_ID" => $USER_ID ) ); if (intval($res) > 0) CSocNetLog::Update($res, array("TMP_ID" => $res)); }