Example #1
0
 public static function FormatEvent($arFields, $arParams, $bMail = false)
 {
     global $APPLICATION, $CACHE_MANAGER;
     $arResult = array("EVENT" => $arFields);
     if (defined("BX_COMP_MANAGED_CACHE")) {
         $CACHE_MANAGER->RegisterTag("CALENDAR_EVENT_" . intval($arFields["SOURCE_ID"]));
         $CACHE_MANAGER->RegisterTag("CALENDAR_EVENT_LIST");
     }
     $eventViewResult = $APPLICATION->IncludeComponent('bitrix:calendar.livefeed.view', '', array("EVENT_ID" => $arFields["SOURCE_ID"], "USER_ID" => $arFields["USER_ID"], "PATH_TO_USER" => $arParams["PATH_TO_USER"], "MOBILE" => $arParams["MOBILE"]), null, array('HIDE_ICONS' => 'Y'));
     $arResult["EVENT_FORMATTED"] = array("TITLE" => GetMessage("EC_EDEV_EVENT"), "TITLE_24" => GetMessage("EC_EDEV_EVENT"), "URL" => "javascript:BX.StartSlider(" . $arFields["USER_ID"] . "," . $arFields["SOURCE_ID"] . ");", "MESSAGE" => $eventViewResult['MESSAGE'], "FOOTER_MESSAGE" => $eventViewResult['FOOTER_MESSAGE'], "IS_IMPORTANT" => false, "STYLE" => "calendar-confirm");
     $eventId = $arFields["SOURCE_ID"];
     if (!$eventId) {
         $eventId = 0;
     }
     $editUrl = CCalendar::GetPath('user', $arFields["USER_ID"]);
     $editUrl = $editUrl . (strpos($editUrl, "?") === false ? '?' : '&') . 'EVENT_ID=EDIT' . $eventId;
     $arRights = array();
     $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
     while ($arRight = $dbRight->Fetch()) {
         $arRights[] = $arRight["GROUP_CODE"];
     }
     $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])));
     if (isset($eventViewResult['CACHED_JS_PATH'])) {
         $arResult['CACHED_JS_PATH'] = $eventViewResult['CACHED_JS_PATH'];
     }
     $arResult['ENTITY']['FORMATTED']["NAME"] = "ENTITY FORMATTED NAME";
     $arResult['ENTITY']['FORMATTED']["URL"] = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php");
     $arResult['AVATAR_SRC'] = CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams, 'CREATED_BY');
     $arFieldsTooltip = array('ID' => $arFields['USER_ID'], 'NAME' => $arFields['~CREATED_BY_NAME'], 'LAST_NAME' => $arFields['~CREATED_BY_LAST_NAME'], 'SECOND_NAME' => $arFields['~CREATED_BY_SECOND_NAME'], 'LOGIN' => $arFields['~CREATED_BY_LOGIN']);
     $arResult['CREATED_BY']['TOOLTIP_FIELDS'] = CSocNetLog::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
     return $arResult;
 }
Example #2
0
 function FormatEvent_Data($arFields, $arParams, $bMail = false)
 {
     $arResult = array("EVENT" => $arFields, "URL" => "");
     if (!CModule::IncludeModule("socialnetwork")) {
         return $arResult;
     }
     if (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) {
         $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arFields, $arParams, $bMail);
         $rsRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
         $arRights = array();
         while ($arRight = $rsRight->Fetch()) {
             $arRights[] = $arRight["GROUP_CODE"];
         }
         $arDestination = CSocNetLogTools::FormatDestinationFromRights($arRights, $arParams, $iMoreCount);
     }
     $title = "";
     $arEventParams = unserialize(strlen($arFields["~PARAMS"]) > 0 ? $arFields["~PARAMS"] : $arFields["PARAMS"]);
     if (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER)) && is_array($arEventParams) && count($arEventParams) > 0 && array_key_exists("ENTITY_NAME", $arEventParams) && strlen($arEventParams["ENTITY_NAME"]) > 0) {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arEventParams["ENTITY_NAME"] . '</a>';
         } else {
             $title_tmp = $arEventParams["ENTITY_NAME"];
         }
     } else {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arFields["TITLE"] . '</a>';
         } else {
             $title_tmp = $arFields["TITLE"];
         }
     }
     $title = str_replace(array("#TITLE#", "#ENTITY#"), array($title_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $bMail ? GetMessage("LFP_SOCNET_LOG_DATA_" . $arFields["ENTITY_TYPE"] . "_TITLE_MAIL") : GetMessage("LFP_SOCNET_LOG_DATA_TITLE"));
     $url = false;
     if (strlen($arFields["URL"]) > 0) {
         $url = $arFields["URL"];
     }
     if (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) {
         if (!$bMail) {
             $message = $arFields["MESSAGE"];
         } else {
             $message = $arFields["TITLE"] . "#BR##BR#" . $arFields["MESSAGE"];
         }
     } else {
         $message = $arFields["MESSAGE"];
     }
     $arFieldsTooltip = array('ID' => $arFields['USER_ID'], 'NAME' => $arFields['~CREATED_BY_NAME'], 'LAST_NAME' => $arFields['~CREATED_BY_LAST_NAME'], 'SECOND_NAME' => $arFields['~CREATED_BY_SECOND_NAME'], 'LOGIN' => $arFields['~CREATED_BY_LOGIN']);
     $arResult['CREATED_BY']['TOOLTIP_FIELDS'] = CSocNetLog::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
     $twitInfo = unserialize($arFields['~PARAMS']);
     $arResult["EVENT_FORMATTED"] = array("TITLE" => $arFields["TITLE"], "TITLE_24" => "", "MESSAGE" => "<a  target=\"_blank\" style=\"text-decoration: none; color: #5C6470; font-weight: bold; font-size: 12px\" href=\"https://twitter.com/" . $twitInfo['SCREEN_NAME'] . "/status/" . $twitInfo['TWIT_ID'] . "\">" . $arFields["TITLE"] . "</a><p>" . ($bMail ? CSocNetTextParser::killAllTags($message) : $message), "IS_IMPORTANT" => false, "STYLE" => "", "DESTINATION" => $arDestination);
     if (intval($iMoreCount) > 0) {
         $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
     }
     if (is_array($arEventParams) && array_key_exists("SOURCE_TIMESTAMP", $arEventParams)) {
         $arResult["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] = ConvertTimeStamp($arEventParams["SOURCE_TIMESTAMP"], "FULL");
     }
     if (strlen($url) > 0) {
         $arResult["EVENT_FORMATTED"]["URL"] = $url;
     }
     if (!$bMail) {
         if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) {
             $arGroup = array("IMAGE_ID" => $arFields["GROUP_IMAGE_ID"]);
             $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatarGroup($arGroup, $arParams);
         } elseif ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_USER) {
             $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatar($arFields, $arParams, "USER_");
         } elseif ($arFields["ENTITY_TYPE"] == "N") {
             $arResult["EVENT_FORMATTED"]["AVATAR_STYLE"] = "avatar-info";
         }
         $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
         $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "MULTIPLE_BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N");
         $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback(str_replace("#CUT#", "", $arResult["EVENT_FORMATTED"]["MESSAGE"])), array(), $arAllow), 500);
         $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "MULTIPLE_BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N");
         $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
         if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") {
             $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
         }
     }
     return $arResult;
 }
Example #3
0
				$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,
				"CHECK_PERMISSIONS_DEST" => "N"
			);

			if ($created_by_id > 0)
				$arParams["CREATED_BY"] = $created_by_id;

			$arDestinations = CSocNetLogTools::FormatDestinationFromRights($arRights, $arParams, $iMoreCount);
			if (is_array($arDestinations))
			{
				$iDestinationsHidden = 0;
				$arGroupID = array();

				// get tagged cached available groups and intersect
				$cache = new CPHPCache;	
				$cache_id = $GLOBALS["USER"]->GetID();
				$cache_path = "/sonet/groups_available/".$GLOBALS["USER"]->GetID()."/";

				if ($cache->InitCache($cache_time, $cache_id, $cache_path))
				{
					$arCacheVars = $cache->GetVars();
					$arGroupID = $arCacheVars["arGroupID"];
				}
Example #4
0
 public static function GetFormatedDestination($codes = array())
 {
     $ac = CSocNetLogTools::FormatDestinationFromRights($codes, array("CHECK_PERMISSIONS_DEST" => "Y", "DESTINATION_LIMIT" => 100000, "NAME_TEMPLATE" => "#NAME# #LAST_NAME#", "PATH_TO_USER" => "/company/personal/user/#user_id#/"));
     return $ac;
 }
Example #5
0
 function FormatEvent_News($arFields, $arParams, $bMail = false)
 {
     $GLOBALS["APPLICATION"]->SetAdditionalCSS("/bitrix/themes/.default/intranet_sonet_log.css");
     $arResult = array("EVENT" => $arFields, "ENTITY" => CIntranetEventHandlers::GetEntity_News($arFields, $bMail), "URL" => "", "CACHED_CSS_PATH" => "/bitrix/themes/.default/intranet_sonet_log.css");
     if (!CModule::IncludeModule("socialnetwork")) {
         return $arResult;
     }
     $title = "";
     if (strlen($arFields["TITLE_TEMPLATE"]) > 0) {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arFields["TITLE"] . '</a>';
         } else {
             $title_tmp = $arFields["TITLE"];
         }
         $title = str_replace(array("#TITLE#", "#ENTITY#"), array($title_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $bMail ? GetMessage("INTR_SOCNET_LOG_NEWS_TITLE_MAIL") : GetMessage("INTR_SOCNET_LOG_NEWS_TITLE"));
     } else {
         $title_tmp = "";
     }
     $url = false;
     if (strlen($arFields["URL"]) > 0 && strlen($arFields["SITE_ID"]) > 0) {
         if (substr($arFields["URL"], 0, 1) === "/") {
             $rsSites = CSite::GetByID($arFields["SITE_ID"]);
             $arSite = $rsSites->Fetch();
             if (strlen($arSite["SERVER_NAME"]) > 0) {
                 $server_name = $arSite["SERVER_NAME"];
             } else {
                 $server_name = COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]);
             }
             $protocol = CMain::IsHTTPS() ? "https" : "http";
             $url = $protocol . "://" . $server_name . $arFields["URL"];
         } else {
             $url = $arFields["URL"];
         }
     }
     $arResult["EVENT_FORMATTED"] = array("TITLE" => $title, "MESSAGE" => $bMail ? CSocNetTextParser::killAllTags($arFields["MESSAGE"]) : $arFields["MESSAGE"], "IS_IMPORTANT" => true, "TITLE_24" => GetMessage("INTR_SONET_LOG_DATA_TITLE_IMPORTANT_24"), "TITLE_24_2" => $arFields["TITLE"], "STYLE" => "imp-post");
     if ($arParams["MOBILE"] == "Y") {
         $arResult["EVENT_FORMATTED"]["STYLE"] = "item-top-text-important";
         $arResult["EVENT_FORMATTED"]["AVATAR_STYLE"] = "avatar-info";
     } else {
         $arResult["EVENT_FORMATTED"]["STYLE"] = "info";
     }
     if (strlen($url) > 0) {
         $arResult["EVENT_FORMATTED"]["URL"] = $url;
     }
     if (!$bMail) {
         if (intval($arFields["SOURCE_ID"]) > 0 && CModule::IncludeModule("iblock")) {
             $rsIBlockElement = CIBlockElement::GetList(array(), array("ID" => $arFields["SOURCE_ID"]), false, false, array("ID", "DETAIL_TEXT"));
             if ($arIBlockElement = $rsIBlockElement->GetNext()) {
                 $arResult["EVENT_FORMATTED"]["MESSAGE"] = $arIBlockElement["DETAIL_TEXT"];
             }
         }
         if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") {
             $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
             $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N");
             $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback(str_replace("#CUT#", "", $arResult["EVENT_FORMATTED"]["MESSAGE"])), array(), $arAllow), 1000);
             $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
         }
         if ($arParams["MOBILE"] != "Y") {
             $rsRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
             $arRights = array();
             while ($arRight = $rsRight->Fetch()) {
                 $arRights[] = $arRight["GROUP_CODE"];
             }
             $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, $arParams);
         }
     }
     $arResult["HAS_COMMENTS"] = intval($arFields["SOURCE_ID"]) > 0 ? "Y" : "N";
     return $arResult;
 }
Example #6
0
 public static function FormatEvent($arFields, $arParams, $bMail = false)
 {
     ob_start();
     if ($arFields['ENTITY_TYPE'] == CCrmLiveFeedEntity::Activity) {
         if ($arActivity = CCrmActivity::GetByID($arFields["ENTITY_ID"], false)) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_ACTIVITY_" . $arFields["ENTITY_ID"]);
                 if ($arActivity["TYPE_ID"] == CCrmActivityType::Call) {
                     $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_CALLTO_SETTINGS");
                 }
             }
             $arActivity["COMMUNICATIONS"] = CCrmActivity::GetCommunications($arActivity["ID"]);
             $arComponentReturn = $GLOBALS['APPLICATION']->IncludeComponent('bitrix:crm.livefeed.activity', '', array('FIELDS' => $arFields, 'ACTIVITY' => $arActivity, 'PARAMS' => $arParams), null, array('HIDE_ICONS' => 'Y'));
         }
     } elseif ($arFields['ENTITY_TYPE'] == CCrmLiveFeedEntity::Invoice) {
         if ($arInvoice = CCrmInvoice::GetByID($arFields["ENTITY_ID"])) {
             if (!array_key_exists("URL", $arInvoice)) {
                 $arInvoice["URL"] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Invoice, $arFields["ENTITY_ID"]);
             }
             $arComponentReturn = $GLOBALS['APPLICATION']->IncludeComponent('bitrix:crm.livefeed.invoice', '', array('FIELDS' => $arFields, 'INVOICE' => $arInvoice, 'PARAMS' => $arParams), null, array('HIDE_ICONS' => 'Y'));
         }
     } else {
         $arComponentReturn = $GLOBALS['APPLICATION']->IncludeComponent('bitrix:crm.livefeed', '', array('FIELDS' => $arFields, 'PARAMS' => $arParams), null, array('HIDE_ICONS' => 'Y'));
     }
     $html_message = ob_get_contents();
     ob_end_clean();
     $arRights = array();
     $arEventFields = array("LOG_ID" => $arFields["ID"], "EVENT_ID" => $arFields["EVENT_ID"]);
     if ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Activity) {
         $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
         while ($arRight = $dbRight->Fetch()) {
             if (preg_match('/^SG(\\d+)$/', $arRight["GROUP_CODE"], $matches)) {
                 $arRights[] = $arRight["GROUP_CODE"];
             }
         }
     }
     if ($arParams["MOBILE"] == "Y") {
         self::OnBeforeSocNetLogEntryGetRights($arEventFields, $arRights);
         $arDestination = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"], "USE_ALL_DESTINATION" => true)), $iMoreCount);
         if ($arFields['ENTITY_TYPE'] == CCrmLiveFeedEntity::Activity && $arActivity && $arActivity["TYPE_ID"] == CCrmActivityType::Task) {
             $title_24 = '';
         } else {
             $title_24 = GetMessage('CRM_LF_MESSAGE_TITLE_24');
         }
         $arResult = array('EVENT' => $arFields, 'EVENT_FORMATTED' => array('TITLE_24' => $title_24, "MESSAGE" => htmlspecialcharsbx($html_message), "IS_IMPORTANT" => false, "DESTINATION" => $arDestination), "AVATAR_SRC" => CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams, 'CREATED_BY'));
     } else {
         if ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Activity) {
             $arEventFields["ACTIVITY"] = $arActivity;
         } elseif ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Invoice) {
             $arEventFields["ACTIVITY"] = $arInvoice;
         }
         self::OnBeforeSocNetLogEntryGetRights($arEventFields, $arRights);
         if ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Activity && $arActivity) {
             if ($arActivity["TYPE_ID"] == CCrmActivityType::Call) {
                 if ($arActivity["DIRECTION"] == CCrmActivityDirection::Incoming) {
                     $title24_2 = GetMessage("CRM_LF_ACTIVITY_CALL_INCOMING_TITLE");
                 } elseif ($arActivity["DIRECTION"] == CCrmActivityDirection::Outgoing) {
                     $title24_2 = GetMessage("CRM_LF_ACTIVITY_CALL_OUTGOING_TITLE");
                 }
                 $title24_2 = str_replace("#COMPLETED#", "<i>" . GetMessage($arActivity["COMPLETED"] == "Y" ? "CRM_LF_ACTIVITY_CALL_COMPLETED" : "") . "</i>", $title24_2);
             } elseif ($arActivity["TYPE_ID"] == CCrmActivityType::Email) {
                 if ($arActivity["DIRECTION"] == CCrmActivityDirection::Incoming) {
                     $title24_2 = GetMessage("CRM_LF_ACTIVITY_EMAIL_INCOMING_TITLE");
                 } elseif ($arActivity["DIRECTION"] == CCrmActivityDirection::Outgoing) {
                     $title24_2 = GetMessage("CRM_LF_ACTIVITY_EMAIL_OUTGOING_TITLE");
                 }
             } elseif ($arActivity["TYPE_ID"] == CCrmActivityType::Meeting) {
                 $title24_2 = GetMessage("CRM_LF_ACTIVITY_MEETING_TITLE");
                 $title24_2 = str_replace("#COMPLETED#", "<i>" . GetMessage($arActivity["COMPLETED"] == "Y" ? "CRM_LF_ACTIVITY_MEETING_COMPLETED" : "CRM_LF_ACTIVITY_MEETING_NOT_COMPLETED") . "</i>", $title24_2);
             }
             $title24_2_style = "crm-feed-activity-status";
         }
         $arDestination = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"], "USE_ALL_DESTINATION" => true)), $iMoreCount);
         $arResult = array('EVENT' => $arFields, 'EVENT_FORMATTED' => array('URL' => "", "MESSAGE" => htmlspecialcharsbx($html_message), "IS_IMPORTANT" => false, "DESTINATION" => $arDestination));
         if ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Activity && $arActivity["TYPE_ID"] == CCrmActivityType::Email && $arActivity["DIRECTION"] == CCrmActivityDirection::Incoming) {
             switch ($arActivity['OWNER_TYPE_ID']) {
                 case CCrmOwnerType::Company:
                     $rsCrmCompany = CCrmCompany::GetListEx(array(), array('ID' => $arActivity['OWNER_ID'], 'CHECK_PERMISSIONS' => 'N'), false, false, array('LOGO'));
                     if ($arCrmCompany = $rsCrmCompany->Fetch()) {
                         $fileID = $arCrmCompany['LOGO'];
                     }
                     break;
                 case CCrmOwnerType::Contact:
                     $rsCrmContact = CCrmContact::GetListEx(array(), array('ID' => $arActivity['OWNER_ID'], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO'));
                     if ($arCrmContact = $rsCrmContact->Fetch()) {
                         $fileID = $arCrmContact['PHOTO'];
                     }
                     break;
                 default:
                     $fileID = false;
             }
             $arResult["AVATAR_SRC"] = CSocNetLog::FormatEvent_CreateAvatar(array('PERSONAL_PHOTO' => $fileID), $arParams, '');
         } else {
             $arResult["AVATAR_SRC"] = CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams, 'CREATED_BY');
         }
         if (isset($title24_2)) {
             $arResult["EVENT_FORMATTED"]["TITLE_24_2"] = $title24_2;
             if (isset($title24_2_style)) {
                 $arResult["EVENT_FORMATTED"]["TITLE_24_2_STYLE"] = $title24_2_style;
             }
         }
         $arResult["CACHED_CSS_PATH"] = array("/bitrix/themes/.default/crm-entity-show.css");
         $arResult["CACHED_JS_PATH"] = array("/bitrix/js/crm/progress_control.js", "/bitrix/js/crm/activity.js", "/bitrix/js/crm/common.js");
         if (IsModuleInstalled("tasks")) {
             $arResult["CACHED_CSS_PATH"][] = "/bitrix/js/tasks/css/tasks.css";
         }
         if (is_array($arComponentReturn) && !empty($arComponentReturn["CACHED_CSS_PATH"])) {
             $arResult["CACHED_CSS_PATH"][] = $arComponentReturn["CACHED_CSS_PATH"];
         }
         if (is_array($arComponentReturn) && !empty($arComponentReturn["CACHED_JS_PATH"])) {
             $arResult["CACHED_JS_PATH"][] = $arComponentReturn["CACHED_JS_PATH"];
         }
         if (intval($iDestinationsMore) > 0) {
             $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iDestinationsMore;
         }
     }
     if ($arFields["ENTITY_TYPE"] == CCrmLiveFeedEntity::Activity && $arActivity["TYPE_ID"] == CCrmActivityType::Email && $arActivity["DIRECTION"] == CCrmActivityDirection::Incoming) {
         $arResult['CREATED_BY']['FORMATTED'] = CCrmOwnerType::GetCaption($arActivity['OWNER_TYPE_ID'], $arActivity['OWNER_ID'], false);
     } else {
         $arFieldsTooltip = array('ID' => $arFields['USER_ID'], 'NAME' => $arFields['~CREATED_BY_NAME'], 'LAST_NAME' => $arFields['~CREATED_BY_LAST_NAME'], 'SECOND_NAME' => $arFields['~CREATED_BY_SECOND_NAME'], 'LOGIN' => $arFields['~CREATED_BY_LOGIN']);
         $arResult['CREATED_BY']['TOOLTIP_FIELDS'] = CSocNetLog::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
     }
     if ($arFields['ENTITY_TYPE'] == CCrmLiveFeedEntity::Activity && $arActivity && $arActivity["TYPE_ID"] == CCrmActivityType::Task) {
         $arResult["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => "TK", "ENTITY_XML_ID" => "TASK_" . $arActivity["ASSOCIATED_ENTITY_ID"], "NOTIFY_TAGS" => "FORUM|COMMENT");
     }
     return $arResult;
 }
Example #7
0
 function FormatEvent_Files($arFields, $arParams, $bMail = false)
 {
     if ($bMail && strlen($arFields["MAIL_LANGUAGE_ID"]) > 0) {
         IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
     }
     $arResult = array("EVENT" => $arFields, "CREATED_BY" => CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail), "ENTITY" => CSocNetLogTools::FormatEvent_GetEntity($arFields, $arParams, $bMail), "EVENT_FORMATTED" => array());
     if (!$bMail) {
         $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatar($arFields, $arParams);
     }
     if (!$bMail && array_key_exists("URL", $arFields) && strlen($arFields["URL"]) > 0) {
         if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && (IsModuleInstalled("extranet") || strpos($arFields["URL"], "#GROUPS_PATH#") !== false)) {
             $arFields["URL"] = str_replace("#GROUPS_PATH#", COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID), $arFields["URL"]);
             $arResult["EVENT"]["URL"] = $arFields["URL"];
         }
         $file_tmp = '<a href="' . $arFields["URL"] . '">' . $arFields["TITLE"] . '</a>';
     } else {
         $file_tmp = $arFields["TITLE"];
     }
     if ($bMail) {
         $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_" . ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_FILE_MAIL");
     } else {
         $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_FILE");
         switch ($arFields["CREATED_BY_PERSONAL_GENDER"]) {
             case "M":
                 $suffix = "_M";
                 break;
             case "F":
                 $suffix = "_F";
                 break;
             default:
                 $suffix = "";
         }
         $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_FILE_24" . $suffix);
     }
     $title = str_replace(array("#TITLE#", "#ENTITY#", "#CREATED_BY#"), array($file_tmp, $arResult["ENTITY"]["FORMATTED"], $bMail ? $arResult["CREATED_BY"]["FORMATTED"] : ""), $title_tmp);
     if ($arParams["MOBILE"] == "Y") {
         $arResult["EVENT_FORMATTED"] = array("TITLE_24" => GetMessage("SONET_GL_EVENT_TITLE_FILE_24_MOBILE"), "MESSAGE" => $arFields["MESSAGE"]);
     } else {
         $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail ? $title : "", "MESSAGE_TITLE_24" => $title_tmp_24, "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]);
     }
     if (!$bMail) {
         $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = true;
     }
     $arResult["HAS_COMMENTS"] = "N";
     if (intval($arFields["SOURCE_ID"]) > 0 && array_key_exists("PARAMS", $arFields) && strlen($arFields["PARAMS"]) > 0) {
         $arFieldsParams = explode("&", $arFields["PARAMS"]);
         if (is_array($arFieldsParams) && count($arFieldsParams) > 0) {
             foreach ($arFieldsParams as $tmp) {
                 list($key, $value) = explode("=", $tmp);
                 if ($key == "forum_id") {
                     $arResult["HAS_COMMENTS"] = "Y";
                     break;
                 }
             }
         }
     }
     if ($bMail) {
         $url = CSocNetLogTools::FormatEvent_GetURL($arFields);
         if (strlen($url) > 0) {
             $arResult["EVENT_FORMATTED"]["URL"] = $url;
         }
     }
     if (!$bMail) {
         $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
         while ($arRight = $dbRight->Fetch()) {
             $arRights[] = $arRight["GROUP_CODE"];
         }
         $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])), $iMoreCount);
         if (intval($iMoreCount) > 0) {
             $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
         }
     }
     if ($bMail && strlen($arFields["MAIL_LANGUAGE_ID"]) > 0) {
         IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
     }
     return $arResult;
 }
 static function FormatEvent_Files($arFields, $arParams, $bMail = false)
 {
     if (!CModule::IncludeModule("socialnetwork")) {
         return null;
     }
     $arResult = array("EVENT" => $arFields, "CREATED_BY" => CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail), "ENTITY" => self::GetEntity_Files($arFields, $bMail), "URL" => "");
     if (!$bMail) {
         $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatar($arFields, $arParams);
         switch ($arFields["CREATED_BY_PERSONAL_GENDER"]) {
             case "M":
                 $suffix = "_M";
                 break;
             case "F":
                 $suffix = "_F";
                 break;
             default:
                 $suffix = "";
         }
         $title_tmp_24 = GetMessage("WEBDAV_SONET_EVENT_TITLE_FILE_24" . $suffix);
     }
     $title = "";
     if (strlen($arFields["TITLE"]) > 0) {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arFields["TITLE"] . '</a>';
         } else {
             $title_tmp = $arFields["TITLE"];
         }
         $title = str_replace(array("#TITLE#", "#ENTITY#"), array($title_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $bMail ? GetMessage("WEBDAV_SOCNET_LOG_FILES_TITLE_MAIL") : GetMessage("WEBDAV_SOCNET_LOG_FILES_TITLE"));
     } else {
         $title_tmp = "";
     }
     $url = false;
     if (strlen($arFields["URL"]) > 0 && strlen($arFields["SITE_ID"]) > 0) {
         $rsSites = CSite::GetByID($arFields["SITE_ID"]);
         $arSite = $rsSites->Fetch();
         if (strlen($arSite["SERVER_NAME"]) > 0) {
             $server_name = $arSite["SERVER_NAME"];
         } else {
             $server_name = COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]);
         }
         $protocol = CMain::IsHTTPS() ? "https" : "http";
         $url = $protocol . "://" . $server_name . $arFields["URL"];
     }
     if ($arParams["MOBILE"] == "Y") {
         $arResult["EVENT_FORMATTED"] = array("TITLE_24" => GetMessage("WEBDAV_SONET_EVENT_TITLE_FILE_24_MOBILE"), "MESSAGE" => $arFields["MESSAGE"]);
     } else {
         $arResult["EVENT_FORMATTED"] = array("TITLE" => $title, "MESSAGE_TITLE_24" => $title_tmp_24, "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]);
     }
     if (!$bMail) {
         $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = true;
     }
     if (strlen($url) > 0) {
         $arResult["EVENT_FORMATTED"]["URL"] = $url;
     }
     $arResult["HAS_COMMENTS"] = "N";
     if (intval($arFields["SOURCE_ID"]) > 0 && array_key_exists("PARAMS", $arFields) && strlen($arFields["PARAMS"]) > 0) {
         $arFieldsParams = explode("&", $arFields["PARAMS"]);
         if (is_array($arFieldsParams) && count($arFieldsParams) > 0) {
             foreach ($arFieldsParams as $tmp) {
                 list($key, $value) = explode("=", $tmp);
                 if ($key == "forum_id") {
                     $arResult["HAS_COMMENTS"] = "Y";
                     break;
                 }
             }
         }
     }
     if (!$bMail) {
         $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
         while ($arRight = $dbRight->Fetch()) {
             $arRights[] = $arRight["GROUP_CODE"];
         }
         $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])), $iMoreCount);
         if (intval($iMoreCount) > 0) {
             $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
         }
     }
     return $arResult;
 }
Example #9
0
         }
     }
 } elseif ($action == "get_blog_post_data") {
     $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $post_id), false, false, array("ID"));
     if ($arLog = $rsLog->Fetch()) {
         $arResult["log_id"] = $arLog["ID"];
         $arResult["post_user_id"] = $arBlogPost["AUTHOR_ID"];
         $arResult["PostPerm"] = CBlogPost::GetSocNetPostPerms($post_id, true, $GLOBALS["USER"]->GetID(), $arBlogPost["AUTHOR_ID"]);
         if ($arResult["PostPerm"] >= BLOG_PERMS_FULL) {
             $arRights = array();
             $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arLog["ID"]));
             while ($arRight = $dbRight->Fetch()) {
                 $arRights[] = $arRight["GROUP_CODE"];
             }
             $arDestinationAll = CSocNetLogTools::FormatDestinationFromRights($arRights, array("CHECK_PERMISSIONS_DEST" => "N", "DESTINATION_LIMIT" => 100, "CREATED_BY" => $arBlogPost["AUTHOR_ID"], "NAME_TEMPLATE" => $_REQUEST["nt"], "SHOW_LOGIN" => $_REQUEST["sl"]));
             $arDestinationAvailable = CSocNetLogTools::FormatDestinationFromRights($arRights, array("CHECK_PERMISSIONS_DEST" => "Y", "DESTINATION_LIMIT" => 100, "CREATED_BY" => $arBlogPost["AUTHOR_ID"], "NAME_TEMPLATE" => $_REQUEST["nt"], "SHOW_LOGIN" => $_REQUEST["sl"]));
             $arCodeAvailable = array();
             foreach ($arDestinationAvailable as $key => $arDest) {
                 if (!empty($arDest["TYPE"]) && !empty($arDest["ID"])) {
                     $arCodeAvailable[] = $arDest["TYPE"] . $arDest["ID"];
                 }
             }
             $arResult["PostDestination"] = array();
             $arResult["PostDestinationHidden"] = array();
             foreach ($arDestinationAll as $key => $arDest) {
                 if (!empty($arDest["TYPE"]) && !empty($arDest["ID"])) {
                     $destCode = $arDest["TYPE"] . $arDest["ID"];
                     if (in_array($destCode, $arCodeAvailable)) {
                         $arResult["PostDestination"][] = $arDest;
                     } else {
                         $arResult["PostDestinationHidden"][] = array('TYPE' => $arDest['TYPE'], 'ID' => $arDest['ID']);
Example #10
0
 function FormatEvent_Data($arFields, $arParams, $bMail = false)
 {
     $arResult = array("EVENT" => $arFields, "URL" => "");
     if (!CModule::IncludeModule("socialnetwork")) {
         return $arResult;
     }
     if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER) {
         $arResult["ENTITY"] = CXDILFEventHandlers::GetEntity_Data($arFields, $bMail);
         $rsRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
         $arRights = array();
         while ($arRight = $rsRight->Fetch()) {
             $arRights[] = $arRight["GROUP_CODE"];
         }
         $arDestination = CSocNetLogTools::FormatDestinationFromRights($arRights, $arParams, $iMoreCount);
     } elseif (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) {
         $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arFields, $arParams, $bMail);
         if ($entity_type == SONET_SUBSCRIBE_ENTITY_GROUP) {
             $arDestination = array(array("STYLE" => "sonetgroups", "TITLE" => $arResult["ENTITY"]["FORMATTED"]["NAME"], "URL" => $arResult["ENTITY"]["FORMATTED"]["URL"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetGroupID"]) && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetGroupID"])));
         } else {
         }
     }
     $title = "";
     $arEventParams = unserialize(strlen($arFields["~PARAMS"]) > 0 ? $arFields["~PARAMS"] : $arFields["PARAMS"]);
     if (is_array($arEventParams) && array_key_exists("SCHEME_ID", $arEventParams)) {
         $rs = CXDILFScheme::GetByID($arEventParams["SCHEME_ID"]);
         if ($arScheme = $rs->Fetch()) {
             $arParams["IS_HTML"] = $arScheme["IS_HTML"];
         }
     }
     if (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER)) && is_array($arEventParams) && count($arEventParams) > 0 && array_key_exists("ENTITY_NAME", $arEventParams) && strlen($arEventParams["ENTITY_NAME"]) > 0) {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arEventParams["ENTITY_NAME"] . '</a>';
         } else {
             $title_tmp = $arEventParams["ENTITY_NAME"];
         }
     } else {
         if (!$bMail && strlen($arFields["URL"]) > 0) {
             $title_tmp = '<a href="' . $arFields["URL"] . '">' . $arFields["TITLE"] . '</a>';
         } else {
             $title_tmp = $arFields["TITLE"];
         }
     }
     $title = str_replace(array("#TITLE#", "#ENTITY#"), array($title_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $bMail ? GetMessage("LFP_SOCNET_LOG_DATA_" . $arFields["ENTITY_TYPE"] . "_TITLE_MAIL") : GetMessage("LFP_SOCNET_LOG_DATA_TITLE"));
     $url = false;
     if (strlen($arFields["URL"]) > 0) {
         $url = $arFields["URL"];
     }
     if (in_array($arFields["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) {
         if (!$bMail) {
             $message = "<b><a href='" . $arFields["URL"] . "'>" . $arFields["TITLE"] . "</a></b><br />" . $arFields["MESSAGE"];
         } else {
             $message = $arFields["TITLE"] . "#BR##BR#" . $arFields["MESSAGE"];
         }
     } else {
         $message = $arFields["MESSAGE"];
     }
     $arResult["EVENT_FORMATTED"] = array("TITLE" => $title, "TITLE_24" => $arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER ? $arParams["MOBILE"] == "Y" ? GetMessage("LFP_SOCNET_LOG_DATA_TITLE_24") : GetMessage("LFP_SOCNET_LOG_DATA_TITLE_IMPORTANT_24") : GetMessage("LFP_SOCNET_LOG_DATA_TITLE_24"), "MESSAGE" => $bMail ? CSocNetTextParser::killAllTags($message) : $message, "IS_IMPORTANT" => $arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER ? true : false, "STYLE" => $arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER ? "imp-post feed-external-massage" : "", "DESTINATION" => $arDestination);
     if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER) {
         $arResult["EVENT_FORMATTED"]["TITLE_24_2"] = $arFields["TITLE"];
     }
     if (intval($iMoreCount) > 0) {
         $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
     }
     if (is_array($arEventParams) && array_key_exists("SOURCE_TIMESTAMP", $arEventParams)) {
         $arResult["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] = ConvertTimeStamp($arEventParams["SOURCE_TIMESTAMP"], "FULL");
     }
     if (strlen($url) > 0) {
         $arResult["EVENT_FORMATTED"]["URL"] = $url;
     }
     if (!$bMail) {
         if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER) {
             $arResult["EVENT_FORMATTED"]["AVATAR_STYLE"] = "avatar-rss";
         } elseif ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) {
             $arGroup = array("IMAGE_ID" => $arFields["GROUP_IMAGE_ID"]);
             $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatarGroup($arGroup, $arParams);
         } elseif ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_USER) {
             $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatar($arFields, $arParams, "USER_");
         } elseif ($arFields["ENTITY_TYPE"] == "N") {
             $arResult["EVENT_FORMATTED"]["AVATAR_STYLE"] = "avatar-info";
         }
         $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
         $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "LOG_NL2BR" => $arParams["IS_HTML"] == "Y" ? "N" : "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N");
         $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
         if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") {
             $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback(str_replace("#CUT#", "", $arResult["EVENT_FORMATTED"]["MESSAGE"])), array(), $arAllow), 500);
             $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
         }
     }
     return $arResult;
 }