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; }
public static function FormatEvent($arFields, $arParams, $bMail = false) { $user_url = strlen($arParams["PATH_TO_USER"]) > 0 ? $arParams["PATH_TO_USER"] : COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $arFields["SITE_ID"]); $dbReport = CTimeManReportFull::GetByID($arFields["SOURCE_ID"]); $arReport = $dbReport->Fetch(); if (!$arReport) { return false; } $arManagers = CTimeMan::GetUserManagers($arReport["USER_ID"]); $arManagers[] = $arReport["USER_ID"]; $arManagers = array_unique($arManagers); $dbManagers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', $arManagers))); $arCurrentUserManagers = array(); while ($manager = $dbManagers->GetNext()) { $tmpUser = array('ID' => $manager['ID'], 'LOGIN' => $manager['LOGIN'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $manager, true, false), 'URL' => str_replace(array('#ID#', '#USER_ID#', '#id#', '#user_id#'), $manager['ID'], $user_url), 'WORK_POSITION' => $manager['WORK_POSITION'], 'PERSONAL_PHOTO' => $manager['PERSONAL_PHOTO'], 'SEX' => $manager["PERSONAL_GENDER"]); if ($manager['ID'] == $arReport["USER_ID"]) { $arUser = $tmpUser; } if ($manager['ID'] != $arReport["USER_ID"] || count($arManagers) == 1) { $arCurrentUserManagers[] = $tmpUser; } } $arResult["EVENT"] = $arFields; if (!$bMail) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arUser["ID"])); $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arCurrentUserManagers[0]["ID"])); } ob_start(); $GLOBALS['APPLICATION']->IncludeComponent('bitrix:timeman.livefeed.workreport', $arParams["MOBILE"] == "Y" ? 'mobile' : '', array("USER" => $arUser, "MANAGER" => $arCurrentUserManagers[0], "MARK" => $arReport["MARK"], "REPORT_ID" => $arReport["ID"], "PARAMS" => $arParams), null, array('HIDE_ICONS' => 'Y')); $html_message = ob_get_contents(); ob_end_clean(); $arResult["EVENT"] = $arFields; if ($arParams["MOBILE"] == "Y") { $arResult["EVENT_FORMATTED"] = array("TITLE_24" => ($arFields["USER_ID"] == $arFields["ENTITY_ID"] ? GetMessage("REPORT_ADD_24" . ($arUser["SEX"] == "M" ? "_M" : ($arUser["SEX"] == "F" ? "_F" : ""))) : GetMessage("REPORT_CHANGE_24" . ($arCurrentUserManagers[0]["SEX"] == "M" ? "_M" : ($arCurrentUserManagers[0]["SEX"] == "F" ? "_F" : "")))) . " " . $arFields["TITLE"], "MESSAGE" => htmlspecialcharsbx($html_message), "IS_IMPORTANT" => false, "DESCRIPTION" => in_array($arReport["MARK"], array("G", "B")) ? array(GetMessage("REPORT_FULL_COMMENT_CONFIRM_MOBILE"), GetMessage("REPORT_FULL_COMMENT_CONFIRM_MOBILE_VALUE_" . $arReport["MARK"])) : ($arReport["MARK"] == "N" ? GetMessage("REPORT_FULL_COMMENT_CONFIRM_WO_MARK") : ""), "DESCRIPTION_STYLE" => in_array($arReport["MARK"], array("G", "B")) ? $arReport["MARK"] == "G" ? "green" : "red" : false); } else { $arResult["EVENT_FORMATTED"] = array("TITLE" => ($arFields["USER_ID"] == $arFields["ENTITY_ID"] ? $arUser["SEX"] == "F" ? GetMessage("REPORT_ADD_W") : GetMessage("REPORT_ADD") : ($arCurrentUserManagers[0]["SEX"] == "F" ? GetMessage("REPORT_CHANGE_W") : GetMessage("REPORT_CHANGE"))) . " <a href='javascript:BX.StartSlider(" . $arReport["USER_ID"] . "," . $arFields["SOURCE_ID"] . ");'>" . $arFields["TITLE"] . "</a>", "TITLE_24" => ($arFields["USER_ID"] == $arFields["ENTITY_ID"] ? GetMessage("REPORT_ADD_24" . ($arUser["SEX"] == "M" ? "_M" : ($arUser["SEX"] == "F" ? "_F" : ""))) : GetMessage("REPORT_CHANGE_24" . ($arCurrentUserManagers[0]["SEX"] == "M" ? "_M" : ($arCurrentUserManagers[0]["SEX"] == "F" ? "_F" : "")))) . " <a href='javascript:BX.StartSlider(" . $arReport["USER_ID"] . "," . $arFields["SOURCE_ID"] . ");'>" . $arFields["TITLE"] . "</a>", "URL" => "javascript:BX.StartSlider(" . $arReport["USER_ID"] . "," . $arFields["SOURCE_ID"] . ");", "MESSAGE" => $html_message, "SHORT_MESSAGE" => $html_message, "IS_IMPORTANT" => false, "STYLE" => $arReport["MARK"] == "G" ? "workday-confirm" : ($arReport["MARK"] == "B" ? "workday-rejected" : "workday-edit")); if ($arParams["NEW_TEMPLATE"] != "Y") { $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLog::FormatEvent_IsMessageShort($arFields['MESSAGE']); } $arResult['ENTITY']['FORMATTED']["NAME"] = GetMessage('REPORT_TITLE'); $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); } else { $reportURL = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php"); if (strlen($reportURL) == 0) { $reportURL = "/company/work_report.php"; } $reportURL = CSocNetLogTools::FormatEvent_GetURL(array("URL" => $reportURL, "SITE_ID" => $arFields["SITE_ID"])); $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("REPORT_TITLE_FOR_MAIL"); $arResult['EVENT_FORMATTED'] = array("TITLE" => $arUser["NAME"] . " " . ($arUser["SEX"] == "F" ? GetMessage("REPORT_ADD_W") : GetMessage("REPORT_ADD")) . " " . GetMessage("REPORT_WORK_REPORT"), "URL" => $reportURL . "#user_id=" . $arReport["USER_ID"] . "&report=" . $arFields["SOURCE_ID"], "MESSAGE" => $arFields["TITLE"], "IS_IMPORTANT" => false); } return $arResult; }
static function FormatEvent_Wiki($arFields, $arParams, $bMail = false) { $GLOBALS['APPLICATION']->SetAdditionalCSS('/bitrix/themes/.default/wiki_sonet_log.css'); $arResult = array('EVENT' => $arFields, 'CREATED_BY' => array(), 'ENTITY' => array(), 'EVENT_FORMATTED' => array(), "CACHED_CSS_PATH" => array("/bitrix/themes/.default/wiki_sonet_log.css")); $arResult['CREATED_BY'] = CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail); if (!$bMail) { $arResult['AVATAR_SRC'] = CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams); } if ($arFields['ENTITY_TYPE'] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arFields['ENTITY_ID']) > 0) { if ($bMail) { $arResult['ENTITY']['FORMATTED'] = $arFields['GROUP_NAME']; $arResult['ENTITY']['TYPE_MAIL'] = GetMessage('WIKI_SOCNET_LOG_ENTITY_G'); } else { $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc(); $url = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_GROUP'], array('group_id' => $arFields['ENTITY_ID'])); $arResult['ENTITY']['FORMATTED']['TYPE_NAME'] = $arSocNetAllowedSubscribeEntityTypesDesc[SONET_SUBSCRIBE_ENTITY_GROUP]['TITLE_ENTITY']; $arResult['ENTITY']['FORMATTED']['URL'] = $url; $arResult['ENTITY']['FORMATTED']['NAME'] = $arFields['GROUP_NAME']; } } if (!$bMail && array_key_exists('URL', $arFields) && strlen($arFields['URL']) > 0) { $wiki_tmp = '<a href="' . $arFields['URL'] . '">' . $arFields['TITLE'] . '</a>'; } else { $wiki_tmp = $arFields['TITLE']; } if ($arFields['EVENT_ID'] == 'wiki') { $title_tmp = $bMail ? GetMessage('WIKI_SOCNET_LOG_TITLE_MAIL') : GetMessage('WIKI_SOCNET_LOG_TITLE'); $title_tmp_24 = GetMessage("WIKI_SOCNET_LOG_TITLE_24"); } elseif ($arFields['EVENT_ID'] == 'wiki_del') { $title_tmp = $bMail ? GetMessage('WIKI_DEL_SOCNET_LOG_TITLE_MAIL') : GetMessage('WIKI_DEL_SOCNET_LOG_TITLE'); $title_tmp_24 = GetMessage("WIKI_DEL_SOCNET_LOG_TITLE_24"); } $title = str_replace(array('#TITLE#', '#ENTITY#', '#CREATED_BY#'), array($wiki_tmp, $arResult['ENTITY']['FORMATTED'], $bMail ? $arResult['CREATED_BY']['FORMATTED'] : ''), $title_tmp); $arResult['EVENT_FORMATTED'] = array("TITLE" => $title, "TITLE_24" => $title_tmp_24, "TITLE_24_2" => $arFields["TITLE"], "MESSAGE" => $arFields['MESSAGE']); $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; } $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" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "Y", "TABLE" => "Y"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = $arFields["TEXT_MESSAGE"] ? $arFields["TEXT_MESSAGE"] : HTMLToTxt($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } else { $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" => "Y", "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") { $GLOBALS['APPLICATION']->SetAdditionalCSS('/bitrix/components/bitrix/wiki.show/templates/.default/style.css'); $arResult["CACHED_CSS_PATH"][] = "/bitrix/components/bitrix/wiki.show/templates/.default/style.css"; if ($arParams["NEW_TEMPLATE"] != "Y") { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($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 ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) { $arResult["EVENT_FORMATTED"]["DESTINATION"] = 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"]))); } } return $arResult; }
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; }
public static function FormatEvent($arFields, $arParams, $bMail = false) { $arResult = array("EVENT" => $arFields); $user_url = str_replace('#user_id#', $arFields['ENTITY_ID'], $arParams['PATH_TO_USER']); $dbRes = CUser::GetByID($arFields['ENTITY_ID']); $arUser = $dbRes->Fetch(); if ($arUser) { if (!$bMail) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arUser["ID"])); } ob_start(); $GLOBALS['APPLICATION']->IncludeComponent('bitrix:intranet.livefeed.newuser', '', array('USER' => $arUser, 'PARAMS' => $arParams, 'AVATAR_SRC' => CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams, 'CREATED_BY'), 'USER_URL' => $user_url), null, array('HIDE_ICONS' => 'Y')); $html_message = ob_get_contents(); ob_end_clean(); $arResult = array('EVENT' => $arFields, 'EVENT_FORMATTED' => array('TITLE' => GetMessage('I_NEW_USER_TITLE'), 'TITLE_24' => GetMessage('I_NEW_USER_TITLE'), "MESSAGE" => $html_message, "SHORT_MESSAGE" => $html_message, 'IS_IMPORTANT' => true, 'STYLE' => 'new-employee', 'AVATAR_STYLE' => 'avatar-info')); $arResult['CREATED_BY']['FORMATTED'] = ''; if (is_array($arUser['UF_DEPARTMENT']) && count($arUser['UF_DEPARTMENT']) > 0) { if ($arParams["MOBILE"] == "Y") { $url = ""; } else { $url = $arParams['PATH_TO_CONPANY_DEPARTMENT']; if (strlen($url) <= 0) { $url = $arParams['PATH_TO_COMPANY_DEPARTMENT']; } } $dbRes = CIBlockSection::GetList(array('ID' => 'ASC'), array('ID' => $arUser['UF_DEPARTMENT'])); if ($arSection = $dbRes->GetNext()) { if (strlen($url) > 0) { $arResult['CREATED_BY']['FORMATTED'] = '<a href="' . str_replace('#ID#', $arSection['ID'], $url) . '">' . $arSection['NAME'] . '</a>'; } else { $arResult['CREATED_BY']['FORMATTED'] = $arSection['NAME']; } } } if (!$arResult['CREATED_BY']['FORMATTED']) { $arResult['CREATED_BY']['FORMATTED'] = self::GetSiteName(); } $arResult['ENTITY']['FORMATTED']["NAME"] = GetMessage('I_NEW_USER_TITLE'); $arResult['ENTITY']['FORMATTED']["URL"] = $user_url; if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { $arResult['EVENT_FORMATTED']['IS_MESSAGE_SHORT'] = CSocNetLog::FormatEvent_IsMessageShort($arFields['MESSAGE']); } } return $arResult; } }
public static function FormatEvent($arFields, $arParams, $bMail = false) { $arResult = array(); $user_url = strlen($arParams["PATH_TO_USER"]) > 0 ? $arParams["PATH_TO_USER"] : COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $arFields["SITE_ID"]); $arManagers = CTimeMan::GetUserManagers($arFields["ENTITY_ID"]); $arManagers[] = $arFields["ENTITY_ID"]; $arManagers[] = $arFields["USER_ID"]; $arManagers = array_unique($arManagers); $dbEntry = CTimeManEntry::GetList(array(), array('ID' => $arFields["SOURCE_ID"]), false, false, array('DATE_START', 'INACTIVE_OR_ACTIVATED', 'ACTIVE')); $arEntry = $dbEntry->Fetch(); $dbManagers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', $arManagers))); $arCurrentUserManagers = array(); $arUser = array(); $arChanger = array(); while ($manager = $dbManagers->GetNext()) { $info = array('ID' => $manager['ID'], 'LOGIN' => $manager['LOGIN'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $manager, true, false), 'URL' => str_replace(array('#ID#', '#USER_ID#', '#id#', '#user_id#'), $manager['ID'], $user_url), 'WORK_POSITION' => $manager['WORK_POSITION'], 'PERSONAL_PHOTO' => $manager['PERSONAL_PHOTO'], 'PERSONAL_GENDER' => $manager['PERSONAL_GENDER']); if ($manager['ID'] == $arFields["ENTITY_ID"]) { $arUser = $info; } if ($manager['ID'] == $arFields["USER_ID"]) { $arChanger = $info; } if ($manager['ID'] != $arFields["ENTITY_ID"] || count($arManagers) == 1) { $arCurrentUserManagers[] = $info; } } $arResult["EVENT"] = $arFields; $gender = trim($arChanger['PERSONAL_GENDER']); if (strlen($gender) <= 0) { $gender = 'N'; } if (!$bMail) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arUser["ID"])); $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arCurrentUserManagers[0]["ID"])); } ob_start(); $GLOBALS['APPLICATION']->IncludeComponent('bitrix:timeman.livefeed.workday', $arParams["MOBILE"] == "Y" ? 'mobile' : '', array('USER' => $arUser, 'MANAGER' => $arCurrentUserManagers[0], 'ENTRY' => $arEntry, 'PARAMS' => $arParams), null, array('HIDE_ICONS' => 'Y')); $html_message = ob_get_contents(); ob_end_clean(); if ($arParams["MOBILE"] == "Y") { $arResult = array('EVENT' => $arFields, 'EVENT_FORMATTED' => array('TITLE_24' => GetMessage('TIMEMAN_ENTRY_LF_TITLE' . ($arEntry['INACTIVE_OR_ACTIVATED'] == 'N' ? '_COMMENT' : ($arFields['ENTITY_ID'] == $arFields['USER_ID'] ? '' : '2')) . $gender . "_24_MOBILE", array('#DATE#' => FormatDate('j F', MakeTimeStamp($arEntry['DATE_START'])))), "MESSAGE" => htmlspecialcharsbx($html_message), "IS_IMPORTANT" => false, "DESCRIPTION" => $arEntry['INACTIVE_OR_ACTIVATED'] == 'N' ? '' : ($arFields['ENTITY_ID'] == $arFields['USER_ID'] ? GetMessage("TIMEMAN_ENTRY_LF_DESCRIPTION_24_MOBILE") : array(GetMessage("TIMEMAN_ENTRY_LF_DESCRIPTION2_24_MOBILE"), GetMessage("TIMEMAN_ENTRY_LF_DESCRIPTION2_24_MOBILE_VALUE"))), "DESCRIPTION_STYLE" => $arEntry["INACTIVE_OR_ACTIVATED"] == "Y" && $arEntry["ACTIVE"] == "N" ? false : "green")); } else { $href = "javascript:BX.StartNotifySlider('" . $arFields["ENTITY_ID"] . "', '" . $arFields["SOURCE_ID"] . "', 1);"; $arResult = array('EVENT' => $arFields, 'EVENT_FORMATTED' => array('TITLE' => GetMessage('TIMEMAN_ENTRY_LF_TITLE' . ($arEntry['INACTIVE_OR_ACTIVATED'] == 'N' ? '_COMMENT' : ($arFields['ENTITY_ID'] == $arFields['USER_ID'] ? '' : '2')) . $gender, array('#URL#' => $href, '#DATE#' => FormatDate('j F', MakeTimeStamp($arEntry['DATE_START'])))), 'TITLE_24' => GetMessage('TIMEMAN_ENTRY_LF_TITLE' . ($arEntry['INACTIVE_OR_ACTIVATED'] == 'N' ? '_COMMENT' : ($arFields['ENTITY_ID'] == $arFields['USER_ID'] ? '' : '2')) . $gender . "_24", array('#URL#' => $href, '#DATE#' => FormatDate('j F', MakeTimeStamp($arEntry['DATE_START'])))), 'URL' => $href, "MESSAGE" => $html_message, "SHORT_MESSAGE" => $html_message, "IS_IMPORTANT" => false, "STYLE" => $arEntry["INACTIVE_OR_ACTIVATED"] == "Y" && $arEntry["ACTIVE"] == "N" ? "workday-edit" : "workday-confirm")); $arResult["ENTITY"]["FORMATTED"]["NAME"] = GetMessage("TIMEMAN_NOTIFY_TITLE"); $arResult["ENTITY"]["FORMATTED"]["URL"] = COption::GetOptionString("timeman", "TIMEMAN_REPORT_PATH", "/company/timeman.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); if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { $arResult['EVENT_FORMATTED']['IS_MESSAGE_SHORT'] = CSocNetLog::FormatEvent_IsMessageShort($arFields['MESSAGE']); } } else { $URL = COption::GetOptionString("timeman", "TIMEMAN_REPORT_PATH", "/company/timeman.php"); $URL = CSocNetLogTools::FormatEvent_GetURL(array("URL" => $URL, "SITE_ID" => $arFields["SITE_ID"])); $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("TIMEMAN_TITLE_FOR_MAIL"); $arResult['EVENT_FORMATTED'] = array("TITLE" => $arChanger["NAME"] . " " . GetMessage('TIMEMAN_ENTRY_LF_TITLE' . ($arEntry['INACTIVE_OR_ACTIVATED'] == 'N' ? '_COMMENT' : ($arFields['ENTITY_ID'] == $arFields['USER_ID'] ? '' : '2')) . '_MAIL' . $gender, array('#DATE#' => FormatDate('j F', MakeTimeStamp($arEntry['DATE_START'])))), "URL" => $URL, "MESSAGE" => $arFields["TITLE"], "IS_IMPORTANT" => false); } return $arResult; }