本文整理汇总了PHP中CSocNetLogRights类的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetLogRights类的具体用法?PHP CSocNetLogRights怎么用?PHP CSocNetLogRights使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSocNetLogRights类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NewUserMessage
public static function NewUserMessage($USER_ID)
{
global $DB, $APPLICATION;
if (!CModule::IncludeModule('socialnetwork')) {
return false;
}
$USER_ID = intval($USER_ID);
if ($USER_ID <= 0) {
return false;
}
$arRights = self::GetRights($USER_ID);
if (!$arRights) {
return false;
}
$dbRes = CUser::GetByID($USER_ID);
if ($arUser = $dbRes->Fetch()) {
$arSoFields = array("ENTITY_TYPE" => SONET_INTRANET_NEW_USER_ENTITY, "EVENT_ID" => SONET_INTRANET_NEW_USER_EVENT_ID, "ENTITY_ID" => $USER_ID, "SOURCE_ID" => $USER_ID, "USER_ID" => $USER_ID, "=LOG_DATE" => $DB->CurrentTimeFunction(), "MODULE_ID" => "intranet", "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => GetMessage('I_NEW_USER_TITLE'), "MESSAGE" => '', "TEXT_MESSAGE" => '', "CALLBACK_FUNC" => false, "SITE_ID" => SITE_ID, "ENABLE_COMMENTS" => "Y", "RATING_TYPE_ID" => "INTRANET_NEW_USER", "RATING_ENTITY_ID" => $USER_ID);
// check that there wasn't message for this user
$dbRes = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => $arSoFields['ENTITY_TYPE'], 'ENTITY_ID' => $arSoFields['ENTITY_ID'], 'EVENT_ID' => $arSoFields['EVENT_ID'], 'SOURCE_ID' => $arSoFields['SOURCE_ID']));
if (!$dbRes->Fetch()) {
$logID = CSocNetLog::Add($arSoFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
CSocNetLogRights::Add($logID, $arRights);
}
}
if (intval($logID) > 0) {
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
}
}
}
示例2: canRead
public function canRead($userId)
{
if ($this->canRead !== null) {
return $this->canRead;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
if (\CSocNetUser::isCurrentUserModuleAdmin()) {
$this->canRead = true;
return $this->canRead;
}
if ($comment = $this->loadLogCommentData()) {
if (strpos($comment["EVENT_ID"], "crm_") === 0) {
$queryLog = \CSocNetLog::getList(array(), array("ID" => intval($comment["LOG_ID"])), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
if (($log = $queryLog->fetch()) && Loader::includeModule("crm")) {
$userPermissions = \CCrmPerms::getUserPermissions($userId);
if ($log["ENTITY_TYPE"] == "CRMACTIVITY") {
$bindings = \CCRMActivity::getBindings($log["ENTITY_ID"]);
foreach ($bindings as $binding) {
if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmOwnerType::resolveName($binding["OWNER_TYPE_ID"]), $binding["OWNER_ID"], $userPermissions)) {
$this->canRead = true;
return $this->canRead;
}
}
} else {
if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmLiveFeedEntity::resolveEntityTypeID($log["ENTITY_TYPE"]), $log["ENTITY_ID"], $userPermissions)) {
$this->canRead = true;
return $this->canRead;
} elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) {
$this->canRead = true;
return $this->canRead;
}
}
}
} elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) {
$this->canRead = true;
return $this->canRead;
}
}
$this->canRead = false;
return $this->canRead;
}
示例3: SetPerm
function SetPerm($featureID, $operation, $perm)
{
$arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
$featureID = IntVal($featureID);
$operation = Trim($operation);
$perm = Trim($perm);
$dbResult = CSocNetFeaturesPerms::GetList(array(), array("FEATURE_ID" => $featureID, "OPERATION_ID" => $operation), false, false, array("ID", "FEATURE_ENTITY_TYPE", "FEATURE_ENTITY_ID", "FEATURE_FEATURE", "OPERATION_ID", "ROLE"));
if ($arResult = $dbResult->Fetch()) {
$r = CSocNetFeaturesPerms::Update($arResult["ID"], array("ROLE" => $perm));
} else {
$r = CSocNetFeaturesPerms::Add(array("FEATURE_ID" => $featureID, "OPERATION_ID" => $operation, "ROLE" => $perm));
}
if (!$r) {
$errorMessage = "";
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$errorMessage = $e->GetString();
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_GF_ERROR_SET") . ".";
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_SET_RECORD");
return false;
} else {
if (!$arResult) {
$arFeature = CSocNetFeatures::GetByID($featureID);
$entity_type = $arFeature["ENTITY_TYPE"];
$entity_id = $arFeature["ENTITY_ID"];
$feature = $arFeature["FEATURE"];
} else {
$entity_type = $arResult["FEATURE_ENTITY_TYPE"];
$entity_id = $arResult["FEATURE_ENTITY_ID"];
$feature = $arResult["FEATURE_FEATURE"];
}
if (empty($arResult) || $arResult["ROLE"] != $perm) {
if ($arResult && $arResult["ROLE"] != $perm) {
CSocNetSearch::SetFeaturePermissions($entity_type, $entity_id, $feature, $arResult["OPERATION_ID"], $perm);
} else {
CSocNetSearch::SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $perm);
}
}
if (!in_array($feature, array("tasks", "files", "blog")) && is_array($arSocNetFeaturesSettings[$feature]["subscribe_events"])) {
$arEventsTmp = array_keys($arSocNetFeaturesSettings[$feature]["subscribe_events"]);
$rsLog = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => $arEventsTmp), false, false, array("ID", "EVENT_ID"));
while ($arLog = $rsLog->Fetch()) {
CSocNetLogRights::DeleteByLogID($arLog["ID"]);
CSocNetLogRights::SetForSonet($arLog["ID"], $entity_type, $entity_id, $feature, $arSocNetFeaturesSettings[$feature]["subscribe_events"][$arLog["EVENT_ID"]]["OPERATION"]);
}
}
}
return $r;
}
示例4: __SLEGetLogRecord
//.........这里部分代码省略.........
$arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_UPDATE"]), "SHORT");
$arEvent["FIELDS_FORMATTED"]["COMMENTS_COUNT"] = $arEvent["COMMENTS_COUNT"];
$arEvent["FIELDS_FORMATTED"]["TMP_ID"] = $arEvent["TMP_ID"];
$arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated;
$arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["EVENT_ID"]);
if (!array_key_exists("HAS_COMMENTS", $arEvent["FIELDS_FORMATTED"]) || $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] != "N") {
$arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] = $arCommentEvent && (!array_key_exists("ENABLE_COMMENTS", $arEvent) || $arEvent["ENABLE_COMMENTS"] != "N") ? "Y" : "N";
}
}
}
if (is_object($cache)) {
$arCacheData = array("FIELDS_FORMATTED" => $arEvent["FIELDS_FORMATTED"]);
$cache->EndDataCache($arCacheData);
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->EndTagCache();
}
}
}
if ($bEmpty) {
return false;
}
$feature = CSocNetLogTools::FindFeatureByEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
if ($feature && (!array_key_exists($feature, $arSocNetFeaturesSettings) || array_key_exists("allowed", $arSocNetFeaturesSettings[$feature]) && is_array($arSocNetFeaturesSettings[$feature]["allowed"]) && !in_array($arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arSocNetFeaturesSettings[$feature]["allowed"]))) {
return false;
}
if (!array_key_exists("COMMENTS_PARAMS", $arEvent["FIELDS_FORMATTED"])) {
$arForumMetaData = CSocNetLogTools::GetForumCommentMetaData($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
if ($arForumMetaData && $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"] > 0) {
$arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => $arForumMetaData[1], "ENTITY_XML_ID" => $arForumMetaData[0] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"], "NOTIFY_TAGS" => $arForumMetaData[2]);
} else {
$arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => substr(strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], 0, 2), "ENTITY_XML_ID" => strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], "NOTIFY_TAGS" => "");
}
}
foreach (GetModuleEvents("socialnetwork", "OnSonetLogEntryMenuCreate", true) as $arModuleEvent) {
if (!array_key_exists("FIELDS_FORMATTED", $arEvent)) {
$arEvent["FIELDS_FORMATTED"] = array();
}
if (!array_key_exists("MENU", $arEvent["FIELDS_FORMATTED"])) {
$arEvent["FIELDS_FORMATTED"]["MENU"] = array();
}
$arMenuItems = ExecuteModuleEventEx($arModuleEvent, array($arEvent));
if (!empty($arMenuItems)) {
$arEvent["FIELDS_FORMATTED"]["MENU"] = array_merge($arEvent["FIELDS_FORMATTED"]["MENU"], $arMenuItems);
}
}
if (is_array($arCurrentUserSubscribe)) {
$arEvent["FIELDS_FORMATTED"]["TRANSPORT"] = __SLEGetTransport($arEvent, $arCurrentUserSubscribe);
}
$arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
if (!$GLOBALS["USER"]->IsAuthorized()) {
$arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = "N";
} elseif ($arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && $arCommentEvent["OPERATION_ADD"] == "log_rights") {
$arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = CSocNetLogRights::CheckForUser($arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], $GLOBALS["USER"]->GetID()) ? "Y" : "N";
} else {
$array_key = $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"];
if (array_key_exists($array_key, $GLOBALS["CurUserCanAddComments"])) {
$arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N";
} else {
if ($feature && $arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) {
$GLOBALS["CurUserCanAddComments"][$array_key] = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"], $feature == "microblog" ? "blog" : $feature, $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin) ? "Y" : "N";
} else {
$GLOBALS["CurUserCanAddComments"][$array_key] = "Y";
}
$arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N";
}
}
$arEvent["FIELDS_FORMATTED"]["FAVORITES"] = $arParams["EVENT"]["FAVORITES"];
if ($arParams["USE_FOLLOW"] == "Y") {
$arEvent["FIELDS_FORMATTED"]["EVENT"]["FOLLOW"] = $arParams["EVENT"]["FOLLOW"];
$arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW_X1"] = $arParams["EVENT"]["DATE_FOLLOW_X1"];
$arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW"] = $arParams["EVENT"]["DATE_FOLLOW"];
}
if ($arParams["CHECK_PERMISSIONS_DEST"] == "N" && !$bCurrentUserIsAdmin && is_object($GLOBALS["USER"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) || array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"]))) {
$arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"] = 0;
$arGroupID = CSocNetLogTools::GetAvailableGroups();
if (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"])) {
foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] as $key => $arDestination) {
if (array_key_exists("TYPE", $arDestination) && array_key_exists("ID", $arDestination) && ($arDestination["TYPE"] == "SG" && !in_array(intval($arDestination["ID"]), $arGroupID) || in_array($arDestination["TYPE"], array("CRMCOMPANY", "CRMLEAD", "CRMCONTACT", "CRMDEAL")) && CModule::IncludeModule("crm") && !CCrmAuthorizationHelper::CheckReadPermission(CCrmLiveFeedEntity::ResolveEntityTypeID($arDestination["TYPE"]), $arDestination["ID"]) || in_array($arDestination["TYPE"], array("DR", "D")) && $isExtranetUser == "Y" || $arDestination["TYPE"] == "U" && isset($arUserIdVisible) && is_array($arUserIdVisible) && !in_array(intval($arDestination["ID"]), $arUserIdVisible) || $arDestination["TYPE"] == "U" && isset($arDestination["IS_EXTRANET"]) && $arDestination["IS_EXTRANET"] == "Y" && isset($arAvailableExtranetUserID) && is_array($arAvailableExtranetUserID) && !in_array(intval($arDestination["ID"]), $arAvailableExtranetUserID))) {
unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"][$key]);
$arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++;
}
}
if (intval($arParams["DESTINATION_LIMIT_SHOW"]) > 0 && count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) > $arParams["DESTINATION_LIMIT_SHOW"]) {
$arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_MORE"] = count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) - $arParams["DESTINATION_LIMIT_SHOW"];
$arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] = array_slice($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"], 0, $arParams["DESTINATION_LIMIT_SHOW"]);
}
} elseif (array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"])) {
foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"] as $key => $right_tmp) {
if (preg_match('/^SG(\\d+)$/', $right_tmp, $matches) && !in_array(intval($matches[1]), $arGroupID)) {
unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"][$key]);
$arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++;
}
}
}
}
if ($arParams["SHOW_RATING"] == "Y" && strlen($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"]) > 0 && intval($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]) > 0) {
$arEvent["FIELDS_FORMATTED"]["RATING"] = CRatings::GetRatingVoteResult($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]);
}
return $arEvent["FIELDS_FORMATTED"];
}
示例5: NotifyError
private function NotifyError()
{
if ($this->arExternalSale == null) {
$this->arExternalSale = CCrmExternalSale::GetDefaultSettings($this->externalSaleId);
}
if (intval($this->arExternalSale["GROUP_ID"]) <= 0) {
return true;
}
static $isSNIncluded = null;
if ($isSNIncluded === null) {
$isSNIncluded = CModule::IncludeModule("socialnetwork");
}
if (!$isSNIncluded) {
return;
}
$ar = array("#NAME#" => $this->arExternalSale["NAME"], "#URL#" => "/crm/configs/external_sale/", "#DATE#" => date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), time()));
$message = GetMessage("CRM_GCES_NOTIFY_ERROR_MESSAGE", $ar);
$arFields = array("EVENT_ID" => "crm_10_errors", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => "SYSTEM MESSAGE", "TITLE" => GetMessage("CRM_GCES_NOTIFY_ERROR_TITLE", array("#NAME#" => $this->arExternalSale["NAME"])), "MESSAGE" => $message, "TEXT_MESSAGE" => HTMLToTxt($message), "MODULE_ID" => "crm", "CALLBACK_FUNC" => false, "SOURCE_ID" => false, "ENABLE_COMMENTS" => "Y", "ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $this->arExternalSale["GROUP_ID"], "URL" => "");
$logId = CSocNetLog::Add($arFields, false);
if (intval($logId) > 0) {
$arPerms = array("SG" . $this->arExternalSale["GROUP_ID"], "SG" . $this->arExternalSale["GROUP_ID"] . "_A", "SG" . $this->arExternalSale["GROUP_ID"] . "_E", "SG" . $this->arExternalSale["GROUP_ID"] . "_K");
CSocNetLog::Update($logId, array("TMP_ID" => $logId));
CSocNetLogRights::Add($logId, $arPerms);
CSocNetLog::SendEvent($logId, "SONET_NEW_EVENT", $logId);
return $logId;
}
if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
$this->AddError($ex->GetID(), $ex->GetString());
} else {
$this->AddError("CDA", "Notify error");
}
return false;
}
示例6: FormatEvent_Data
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;
}
示例7: SendEvent
function SendEvent($ID, $mailTemplate = "SONET_NEW_EVENT")
{
$ID = IntVal($ID);
if ($ID <= 0) {
return false;
}
$arFilter = array("ID" => $ID);
$dbLogComments = CSocNetLogComments::GetList(array(), $arFilter, false, false, array("ID", "LOG_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "EVENT_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "GROUP_NAME", "CREATED_BY_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_LOGIN", "LOG_SITE_ID", "SOURCE_ID", "LOG_SOURCE_ID"));
$arLogComment = $dbLogComments->Fetch();
if (!$arLogComment) {
return false;
}
$arLog = array();
if (intval($arLogComment["LOG_ID"]) > 0) {
$dbLog = CSocNetLog::GetList(array(), array("ID" => $arLogComment["LOG_ID"]));
$arLog = $dbLog->Fetch();
if (!$arLog) {
$arLog = array();
}
}
$arEvent = CSocNetLogTools::FindLogCommentEventByID($arLogComment["EVENT_ID"]);
if ($arEvent && array_key_exists("CLASS_FORMAT", $arEvent) && array_key_exists("METHOD_FORMAT", $arEvent) && strlen($arEvent["CLASS_FORMAT"]) > 0 && strlen($arEvent["METHOD_FORMAT"]) > 0) {
$dbSiteCurrent = CSite::GetByID(SITE_ID);
if ($arSiteCurrent = $dbSiteCurrent->Fetch()) {
if ($arSiteCurrent["LANGUAGE_ID"] != LANGUAGE_ID) {
$arLogComment["MAIL_LANGUAGE_ID"] = $arSiteCurrent["LANGUAGE_ID"];
}
}
$arLogComment["FIELDS_FORMATTED"] = call_user_func(array($arEvent["CLASS_FORMAT"], $arEvent["METHOD_FORMAT"]), $arLogComment, array(), true, $arLog);
}
if (array_key_exists($arLogComment["ENTITY_TYPE"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"]) && array_key_exists("HAS_MY", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["HAS_MY"] == "Y" && array_key_exists("CLASS_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && array_key_exists("METHOD_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"]) > 0 && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]) > 0 && method_exists($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"])) {
$arOfEntities = call_user_func(array($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]), $arLogComment["ENTITY_ID"]);
}
$arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => array("M", "X"));
$arLogSites = array();
$rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
while ($arLogSite = $rsLogSite->Fetch()) {
$arLogSites[] = $arLogSite["LID"];
}
if (CModule::IncludeModule("extranet")) {
if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
$arSites = array();
$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"]));
}
$intranet_site_id = CSite::GetDefSite();
}
$arIntranetUsers = CExtranet::GetIntranetUsers();
$extranet_site_id = CExtranet::GetExtranetSiteID();
}
$dbSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_LID", "USER_EMAIL", "TRANSPORT"), $arListParams);
$arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => "N");
$dbUnSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "TRANSPORT", "EVENT_ID"), $arListParams);
$arUnSubscribers = array();
while ($arUnSubscriber = $dbUnSubscribers->Fetch()) {
$arUnSubscribers[] = $arUnSubscriber["USER_ID"] . "_" . $arUnSubscriber["ENTITY_TYPE"] . "_" . $arUnSubscriber["ENTITY_ID"] . "_" . $arUnSubscriber["ENTITY_MY"] . "_" . $arUnSubscriber["ENTITY_CB"] . "_" . $arUnSubscriber["EVENT_ID"];
}
$bHasAccessAll = CSocNetLogRights::CheckForUserAll($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"]);
$arSentUserID = array("M" => array(), "X" => array());
while ($arSubscriber = $dbSubscribers->Fetch()) {
if (is_array($arIntranetUsers) && !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && !in_array($extranet_site_id, $arLogSites)) {
continue;
}
if (array_key_exists($arSubscriber["TRANSPORT"], $arSentUserID) && in_array($arSubscriber["USER_ID"], $arSentUserID[$arSubscriber["TRANSPORT"]])) {
continue;
}
if (intval($arSubscriber["ENTITY_ID"]) != 0 && $arSubscriber["EVENT_ID"] == "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_N_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_Y_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) {
continue;
} elseif (intval($arSubscriber["ENTITY_ID"]) == 0 && $arSubscriber["ENTITY_CB"] == "N" && $arSubscriber["EVENT_ID"] != "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) {
continue;
}
$arSentUserID[$arSubscriber["TRANSPORT"]][] = $arSubscriber["USER_ID"];
if (!$bHasAccessAll) {
$bHasAccess = CSocNetLogRights::CheckForUserOnly($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"], $arSubscriber["USER_ID"]);
if (!$bHasAccess) {
continue;
}
}
if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP && is_array($arIntranetUsers) && CModule::IncludeModule("extranet")) {
$server_name = $arSites[!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id]["SERVER_NAME"];
$arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = str_replace(array("#SERVER_NAME#", "#GROUPS_PATH#"), array($server_name, COption::GetOptionString("socialnetwork", "workgroups_page", false, !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id)), $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]);
} else {
$arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
}
switch ($arSubscriber["TRANSPORT"]) {
case "X":
if (array_key_exists("URL_TO_SEND", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && strlen($arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0) {
$link = GetMessage("SONET_GLC_SEND_EVENT_LINK") . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
} else {
$link = "";
}
$arMessageFields = array("FROM_USER_ID" => intval($arLogComment["USER_ID"]) > 0 ? $arLogComment["USER_ID"] : 1, "TO_USER_ID" => $arSubscriber["USER_ID"], "MESSAGE" => $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"] . " #BR# " . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] . (strlen($link) > 0 ? "#BR# " . $link : ""), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "IS_LOG" => "Y");
CSocNetMessages::Add($arMessageFields);
break;
case "M":
$arFields["SUBSCRIBER_ID"] = $arSubscriber["USER_ID"];
$arFields["SUBSCRIBER_NAME"] = $arSubscriber["USER_NAME"];
$arFields["SUBSCRIBER_LAST_NAME"] = $arSubscriber["USER_LAST_NAME"];
$arFields["SUBSCRIBER_LOGIN"] = $arSubscriber["USER_LOGIN"];
//.........这里部分代码省略.........
示例8: OnAfterUserUpdate
public static function OnAfterUserUpdate($arFields)
{
if (array_key_exists("UF_DEPARTMENT", $arFields)) {
$arDept = $arFields["UF_DEPARTMENT"];
if (!is_array($arDept)) {
$arDept = array($arDept);
}
foreach ($arDept as $key => $val) {
if (intval($val) <= 0) {
unset($arDept[$key]);
}
}
if (!empty($arDept) && CModule::IncludeModule("socialnetwork")) {
$arNewRights = CReportNotifications::GetRights($arFields["ID"]);
$rsLog = CSocNetLog::GetList(array(), array('ENTITY_TYPE' => SONET_WORK_REPORT_ENTITY, 'ENTITY_ID' => $arFields["ID"], 'EVENT_ID' => "report"), false, false, array("ID"));
while ($arLog = $rsLog->Fetch()) {
$arOldRights = array();
$rsLogRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arLog["ID"]));
while ($arLogRight = $rsLogRight->Fetch()) {
$arOldRights[] = $arLogRight["GROUP_CODE"];
}
$diff1 = array_diff($arNewRights, $arOldRights);
$diff2 = array_diff($arOldRights, $arNewRights);
if (!empty($diff1) || !empty($diff2)) {
CSocNetLogRights::DeleteByLogID($arLog["ID"]);
CSocNetLogRights::Add($arLog["ID"], $arNewRights);
}
}
}
}
}
示例9: formatListsElement
public static function formatListsElement($fields, $params, $mail = false)
{
$element = array('EVENT' => $fields, 'CREATED_BY' => array(), 'ENTITY' => array(), 'EVENT_FORMATTED' => array());
$userObject = CUser::getByID($fields['ENTITY_ID']);
$user = $userObject->fetch();
if ($user) {
if (!$mail) {
global $APPLICATION;
$rights = array();
$rightsQuery = CSocNetLogRights::getList(array(), array('LOG_ID' => $fields['ID']));
while ($right = $rightsQuery->fetch()) {
$rights[] = $right['GROUP_CODE'];
}
if (defined('BX_COMP_MANAGED_CACHE')) {
$GLOBALS['CACHE_MANAGER']->registerTag('LISTS_ELEMENT_LIVE_FEED');
}
$componentResult = $APPLICATION->includeComponent('bitrix:bizproc.workflow.livefeed', '', array('WORKFLOW_ID' => $fields['MESSAGE']), null, array('HIDE_ICONS' => 'Y'));
$siteDir = rtrim(SITE_DIR, '/');
$url = CSocNetLogTools::formatEvent_GetURL($fields, true);
$url = str_replace('#SITE_DIR#', $siteDir, $url);
$url .= '' . $fields['ID'] . '/';
$element = array('EVENT' => $fields, 'EVENT_FORMATTED' => array('TITLE_24' => '<a href="' . $fields['TITLE_TEMPLATE'] . '" class="bx-lists-live-feed-title-link">' . $fields['TITLE'] . '</a>', 'MESSAGE' => $fields['TEXT_MESSAGE'] . $componentResult['MESSAGE'], 'IS_IMPORTANT' => false, 'STYLE' => 'new-employee', 'AVATAR_STYLE' => 'avatar-info', 'DESTINATION' => CSocNetLogTools::formatDestinationFromRights($rights, array_merge($params, array('CREATED_BY' => $fields['USER_ID']))), 'URL' => $url), 'CREATED_BY' => CSocNetLogTools::formatEvent_GetCreatedBy($fields, $params, $mail), 'AVATAR_SRC' => CSocNetLog::formatEvent_CreateAvatar($fields, $params), 'CACHED_JS_PATH' => $componentResult['CACHED_JS_PATH'], 'CACHED_CSS_PATH' => $componentResult['CACHED_CSS_PATH']);
if ($params['MOBILE'] == 'Y') {
$element['EVENT_FORMATTED']['TITLE_24'] = Loc::getMessage('LISTS_LF_MOBILE_DESTINATION');
$element['EVENT_FORMATTED']['TITLE_24_2'] = $fields['TITLE'];
}
if (CModule::IncludeModule('bizproc')) {
$workflowId = \CBPStateService::getWorkflowByIntegerId($element['EVENT']['SOURCE_ID']);
}
if ($workflowId) {
$element['EVENT']['SOURCE_ID'] = $workflowId;
}
}
return $element;
}
}
示例10: AddMessage
private function AddMessage()
{
global $DB;
$arNotification = $this->Notify->getNotification();
$arNotify = Array(
"EVENT_ID" => "idea",
"=LOG_DATE" => $DB->CurrentTimeFunction(),
"URL" => $arNotification["PATH"],
"TITLE" => $arNotification["TITLE"],
"TITLE_24" => $arNotification["TITLE_24"],
"MESSAGE" => $arNotification["DETAIL_TEXT"],
"CALLBACK_FUNC" => false,
"SOURCE_ID" => $arNotification["ID"],
"SITE_ID" => SITE_ID,
"ENABLE_COMMENTS" => "Y",
"ENTITY_TYPE" => SONET_ENTITY_USER,
"ENTITY_ID" => $arNotification["AUTHOR_ID"],
"USER_ID" => $arNotification["AUTHOR_ID"],
"MODULE_ID" => 'idea',
);
//Use rating
if($arNotification["SHOW_RATING"] == "Y")
{
$arNotify["RATING_ENTITY_ID"] = $arNotification["ID"];
$arNotify["RATING_TYPE_ID"] = "BLOG_POST";
}
if($arNotification["ACTION"] == "ADD")
{
$LogID = CSocNetLog::Add($arNotify, false);
if (intval($LogID) > 0)
{
CSocNetLog::Update($LogID, array("TMP_ID" => $LogID));
CSocNetLogRights::Add($LogID, array("G2")); //G2 - everyone
}
}
elseif($arNotification["ACTION"] == "UPDATE")
{
$arLog = CSocNetLog::GetList(
array("ID" => "DESC"),
array("SOURCE_ID" => $arNotification["ID"]),
false,
false,
array("ID")
)->Fetch();
if($arLog)
{
$LogID = $arLog["ID"];
CSocNetLog::Update($LogID, $arNotify);
}
}
return $LogID>0;
}
示例11: array
}
$arImages = array();
$res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y", "COMMENT_ID" => $commentId));
while ($arImage = $res->Fetch()) {
$arImages[$arImage["ID"]] = $arImage["FILE_ID"];
}
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
$text4mail = $parserBlog->convert4mail($_POST['comment'], $arImages);
if (intval($log_id) > 0) {
$text4message = $parserBlog->convert($_POST['comment'], false, $arImages, $arAllow, array("isSonetLog" => true));
$arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $arBlog["OWNER_ID"], "EVENT_ID" => "blog_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "URL" => $commentUrl, "MODULE_ID" => false, "SOURCE_ID" => $commentId, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($commentId));
if (intval($user_id) > 0) {
$arFieldsForSocnet["USER_ID"] = $user_id;
}
$log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC", CSocNetLogRights::CheckForUserAll($log_id));
}
$arPSR = CBlogPost::GetSocnetPerms($arPost["ID"]);
$arUsrS = array();
if (!empty($arPSR["U"])) {
foreach ($arPSR["U"] as $k => $v) {
$arUsrS[] = "U" . $k;
}
}
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) {
示例12: OnAfterPhotoCommentAddBlog
public function OnAfterPhotoCommentAddBlog($ID, $arFields)
{
if (!CModule::IncludeModule('iblock')) {
return;
}
if (!$this->IsSocnet) {
return;
}
if (intval($this->PhotoElementID) > 0) {
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "photo_photo", "SOURCE_ID" => $this->PhotoElementID), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "TITLE", "URL", "USER_ID", "PARAMS"));
$bSocNetLogRecordExists = false;
if ($arRes = $dbRes->Fetch()) {
$log_id = $arRes["ID"];
$entity_type = $arRes["ENTITY_TYPE"];
$entity_id = $arRes["ENTITY_ID"];
$log_title = $arRes["TITLE"];
$log_url = $arRes["URL"];
$log_user_id = $arRes["USER_ID"];
$bSocNetLogRecordExists = true;
if (strlen($arRes["PARAMS"]) > 0) {
$arTmp = unserialize($arRes["PARAMS"]);
if ($arTmp) {
if (array_key_exists("SECTION_NAME", $arTmp) && strlen($arTmp["SECTION_NAME"]) > 0) {
$log_section_name = $arTmp["SECTION_NAME"];
}
if (array_key_exists("SECTION_URL", $arTmp) && strlen($arTmp["SECTION_URL"]) > 0) {
$log_section_url = $arTmp["SECTION_URL"];
}
}
}
} else {
$rsElement = CIBlockElement::GetByID($this->PhotoElementID);
if ($arElement = $rsElement->Fetch()) {
$url = $this->arPath["DETAIL_URL"];
$sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
if (intval($arElement["CREATED_BY"]) > 0) {
$rsUser = CUser::GetByID($arElement["CREATED_BY"]);
if ($arUser = $rsUser->Fetch()) {
$sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
}
}
if (in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0) {
$entity_type = $this->entity_type;
$entity_id = $this->entity_id;
$alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user") . "_" . $this->entity_id;
}
$arLogParams = array("BLOG_ID" => intval($this->BlogID));
$rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]);
if ($arIBlock = $rsIBlock->Fetch()) {
$arLogParams["IBLOCK_ID"] = $arIBlock["ID"];
$arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"];
}
$rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]);
if ($arSection = $rsSection->Fetch()) {
$arLogParams["SECTION_ID"] = $arSection["ID"];
$arLogParams["SECTION_NAME"] = $arSection["NAME"];
$arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]);
$arSectionPath = array();
$bPassword = false;
$dbSectionPath = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD"));
while ($arPath = $dbSectionPath->Fetch()) {
$arSectionPath[] = $arPath;
if (strlen(trim($arPath["UF_PASSWORD"])) > 0) {
$bPassword = true;
break;
}
}
if (!$alias) {
$entity_type = SONET_ENTITY_USER;
$entity_id = $arSectionPath[0]["CREATED_BY"];
$alias = $arSectionPath[0]["CODE"];
}
}
$arLogParams["ALIAS"] = $alias;
$arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array("ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"])), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID" => $arElement["ID"]);
if (intval($arElement["CREATED_BY"]) > 0) {
$arSonetFields["USER_ID"] = $arElement["CREATED_BY"];
}
$log_id = CSocNetLog::Add($arSonetFields, false);
if (intval($log_id) > 0) {
$log_title = $arSonetFields["TITLE"];
$log_url = $arSonetFields["URL"];
$log_section_name = $arLogParams["SECTION_NAME"];
$log_section_url = $arLogParams["SECTION_URL"];
$log_user_id = $arSonetFields["USER_ID"];
CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
if ($bPassword) {
CSocNetLogRights::DeleteByLogID($log_id);
CSocNetLogRights::Add($log_id, array("U" . $GLOBALS["USER"]->GetID(), "SA"));
} else {
CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true);
}
}
}
}
if (intval($log_id) > 0) {
$parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]);
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
if ($bSocNetLogRecordExists) {
$text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow);
//.........这里部分代码省略.........
示例13: __deprecated_Add
//.........这里部分代码省略.........
if (isset($arTask['GROUP_ID'])) {
$groupId = (int) $arTask['GROUP_ID'];
}
$messageUrl = $urlPrefixForUser . CComponentEngine::MakePathFromTemplate($pathTemplate, array("user_id" => $userID, "task_id" => $arTask["ID"], "action" => "view", "USER_ID" => $userID, "TASK_ID" => $arTask["ID"], "ACTION" => "view", 'GROUP_ID' => $groupId, 'group_id' => $groupId));
if ($pageNumber > 1) {
$messageUrl .= (strpos($messageUrl, "?") === false ? "?" : "&") . "MID=" . $MID;
}
$NOTIFY_MESSAGE_TITLE_TEMPLATE = '[URL=' . $messageUrl . "#message" . $MID . ']' . $arTask["~TITLE"] . '[/URL]';
} else {
$NOTIFY_MESSAGE_TITLE_TEMPLATE = $arTask["~TITLE"];
}
$MESSAGE_SITE = trim(htmlspecialcharsbx(strip_tags(str_replace(array("\r\n", "\n", "\r"), ' ', htmlspecialcharsback($message_notify)))));
$MESSAGE_EMAIL = $MESSAGE_SITE;
// full message to email
if (strlen($MESSAGE_SITE) >= 100) {
$dot = '...';
$MESSAGE_SITE = substr($MESSAGE_SITE, 0, 99);
if (($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;
}
$arMessageFields = array("TO_USER_ID" => $userID, "FROM_USER_ID" => $givenUserId, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "tasks", "NOTIFY_EVENT" => "comment", "NOTIFY_MESSAGE" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($NOTIFY_MESSAGE_TITLE_TEMPLATE, '[COLOR=#000000]' . $MESSAGE_SITE . '[/COLOR]'), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment), "NOTIFY_MESSAGE_OUT" => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($arTask["~TITLE"], $MESSAGE_EMAIL . ' #BR# ' . $messageUrl . "#message" . $MID . ' '), $MESSAGE_TYPE != "EDIT" ? $strMsgAddComment : $strMsgEditComment));
CIMNotify::Add($arMessageFields);
}
}
$strURL = !empty($backPage) ? $backPage : $GLOBALS['APPLICATION']->GetCurPageParam("", array("IFRAME", "MID", "SEF_APPLICATION_CUR_PAGE_URL", BX_AJAX_PARAM_ID, "result"));
$strURL = ForumAddPageParams($strURL, array("MID" => $MID, "result" => $arForum["MODERATION"] != "Y" || CForumNew::CanUserModerateForum($forumId, $arUserGroupArray) ? "reply" : "not_approved"), false, false);
$outStrUrl = $strURL;
// sonet log
if (CModule::IncludeModule("socialnetwork")) {
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID"));
if ($arRes = $dbRes->Fetch()) {
$log_id = $arRes["TMP_ID"];
$entity_type = $arRes["ENTITY_TYPE"];
$entity_id = $arRes["ENTITY_ID"];
} else {
$entity_type = $arTask["GROUP_ID"] ? SONET_ENTITY_GROUP : SONET_ENTITY_USER;
$entity_id = $arTask["GROUP_ID"] ? $arTask["GROUP_ID"] : $arTask["CREATED_BY"];
$rsUser = CUser::GetByID($arTask["CREATED_BY"]);
if ($arUser = $rsUser->Fetch()) {
$arSoFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks", "LOG_DATE" => $arTask["CREATED_DATE"], "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => htmlspecialcharsBack($arTask["~TITLE"]), "MESSAGE" => "", "TEXT_MESSAGE" => $strMsgNewTask, "MODULE_ID" => "tasks", "CALLBACK_FUNC" => false, "SOURCE_ID" => $arTask["ID"], "ENABLE_COMMENTS" => "Y", "USER_ID" => $arTask["CREATED_BY"], "URL" => CTaskNotifications::GetNotificationPath($arUser, $arTask["ID"]), "PARAMS" => serialize(array("TYPE" => "create")));
$log_id = CSocNetLog::Add($arSoFields, false);
if (intval($log_id) > 0) {
CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
$arRights = CTaskNotifications::__UserIDs2Rights(CTaskNotifications::GetRecipientsIDs($arTask, false));
if ($arTask["GROUP_ID"]) {
$arRights[] = "S" . SONET_ENTITY_GROUP . $arTask["GROUP_ID"];
}
CSocNetLogRights::Add($log_id, $arRights);
}
}
}
if (intval($log_id) > 0) {
$sText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"];
CSocNetLog::Update($log_id, array('PARAMS' => serialize(array('TYPE' => 'comment'))));
$arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks_comment", "MESSAGE" => $sText, "TEXT_MESSAGE" => $parser->convert4mail($sText), "URL" => str_replace("?IFRAME=Y", "", str_replace("&IFRAME=Y", "", str_replace("IFRAME=Y&", "", $strURL))), "MODULE_ID" => "tasks", "SOURCE_ID" => $MID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $MID);
if ($MESSAGE_TYPE == "EDIT") {
$dbRes = CSocNetLogComments::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("tasks_comment"), "SOURCE_ID" => $MID), false, false, array("ID"));
while ($arRes = $dbRes->Fetch()) {
CSocNetLogComments::Update($arRes["ID"], $arFieldsForSocnet);
}
} else {
$arFieldsForSocnet['USER_ID'] = $givenUserId;
$arFieldsForSocnet['=LOG_DATE'] = $GLOBALS['DB']->CurrentTimeFunction();
$ufFileID = array();
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $MID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
if (count($ufFileID) > 0) {
$arFieldsForSocnet["UF_SONET_COM_FILE"] = $ufFileID;
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $MID, LANGUAGE_ID);
if ($ufDocID) {
$arFieldsForSocnet["UF_SONET_COM_DOC"] = $ufDocID;
}
$ufDocVer = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_VER", $MID, LANGUAGE_ID);
if ($ufDocVer) {
$arFieldsForSocnet["UF_SONET_COM_VER"] = $ufDocVer;
}
$comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
}
}
}
$occurAsUserId = CTasksTools::getOccurAsUserId();
if (!$occurAsUserId) {
$occurAsUserId = $arMessage["AUTHOR_ID"] ? $arMessage["AUTHOR_ID"] : 1;
}
// Tasks log
$arLogFields = array("TASK_ID" => $arTask["ID"], "USER_ID" => $occurAsUserId, "CREATED_DATE" => $arMessage["EDIT_DATE"] ? ConvertTimeStamp(MakeTimeStamp($arMessage["EDIT_DATE"], CSite::GetDateFormat()), "FULL") : $arMessage["POST_DATE"], "FIELD" => "COMMENT", "TO_VALUE" => $MID);
$log = new CTaskLog();
$log->Add($arLogFields);
}
return $MID;
// Message id
}
示例14: OnAddRatingVote
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, '"\\1"', $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");
//.........这里部分代码省略.........
示例15: RegisterLiveFeedEvent
private static function RegisterLiveFeedEvent(&$arFields)
{
$ID = isset($arFields['ID']) ? intval($arFields['ID']) : 0;
if ($ID <= 0) {
$arFields['ERROR'] = 'Could not find activity ID.';
return false;
}
$ownerTypeID = isset($arFields['OWNER_TYPE_ID']) ? intval($arFields['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
if (!CCrmOwnerType::IsDefined($ownerTypeID)) {
$arFields['ERROR'] = 'Could not find owner type ID.';
return false;
}
$ownerID = isset($arFields['OWNER_ID']) ? intval($arFields['OWNER_ID']) : 0;
if ($ownerID <= 0) {
$arFields['ERROR'] = 'Could not find owner ID.';
return false;
}
$arOwners = array(array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID));
$authorID = isset($arFields['AUTHOR_ID']) ? intval($arFields['AUTHOR_ID']) : 0;
$editorID = isset($arFields['EDITOR_ID']) ? intval($arFields['EDITOR_ID']) : 0;
$userID = $authorID > 0 ? $authorID : $editorID;
if ($userID <= 0) {
$userID = CCrmSecurityHelper::GetCurrentUserID();
}
// Params are not assigned - we will use current activity only.
$liveFeedFields = array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $ID, 'USER_ID' => $userID, 'MESSAGE' => '', 'TITLE' => '');
$bindings = isset($arFields['BINDINGS']) && is_array($arFields['BINDINGS']) ? $arFields['BINDINGS'] : array();
if (!empty($bindings)) {
$liveFeedFields['PARENTS'] = $bindings;
$liveFeedFields['PARENT_OPTIONS'] = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID');
$ownerInfoOptions = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID', 'ADDITIONAL_DATA' => array('LEVEL' => 2));
$additionalParents = array();
foreach ($bindings as &$binding) {
$ownerTypeID = isset($binding['OWNER_TYPE_ID']) ? intval($binding['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
$ownerID = isset($binding['OWNER_ID']) ? intval($binding['OWNER_ID']) : 0;
if ($ownerTypeID != CCrmOwnerType::Undefined && $ownerID > 0) {
$arOwners[] = array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID);
}
if ($ownerTypeID === CCrmOwnerType::Contact && $ownerID > 0) {
$owners = array();
if (CCrmOwnerType::TryGetOwnerInfos(CCrmOwnerType::Contact, $ownerID, $owners, $ownerInfoOptions)) {
$additionalParents = array_merge($additionalParents, $owners);
}
}
}
unset($binding);
if (!empty($additionalParents)) {
$liveFeedFields['PARENTS'] = array_merge($bindings, $additionalParents);
}
$arOwners = array_unique($arOwners);
}
self::PrepareStorageElementIDs($arFields);
$arStorageElementID = $arFields["STORAGE_ELEMENT_IDS"];
if (!empty($arStorageElementID)) {
if ($arFields["STORAGE_TYPE_ID"] == StorageType::WebDav) {
$liveFeedFields["UF_SONET_LOG_DOC"] = $arStorageElementID;
} else {
if ($arFields["STORAGE_TYPE_ID"] == StorageType::Disk) {
$liveFeedFields["UF_SONET_LOG_DOC"] = array();
//We have to add prefix Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX to file ID
foreach ($arStorageElementID as $elementID) {
$liveFeedFields["UF_SONET_LOG_DOC"][] = "n{$elementID}";
}
} else {
$liveFeedFields["UF_SONET_LOG_FILE"] = $arStorageElementID;
}
}
}
if ($arFields['TYPE_ID'] == CCrmActivityType::Task && isset($arFields["ASSOCIATED_ENTITY_ID"]) && intval($arFields["ASSOCIATED_ENTITY_ID"]) > 0 && CModule::IncludeModule("tasks")) {
$dbTask = CTasks::GetByID($arFields["ASSOCIATED_ENTITY_ID"], false);
if ($arTask = $dbTask->Fetch()) {
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("TASKS_TASK", "UF_TASK_WEBDAV_FILES", $arTask["ID"], LANGUAGE_ID);
if ($ufDocID) {
$liveFeedFields["UF_SONET_LOG_DOC"] = $ufDocID;
}
}
}
$bConvert = false;
if ($arTask) {
$rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), array("ID"));
if ($arLog = $rsLog->Fetch()) {
$eventID = CCrmLiveFeed::ConvertTasksLogEvent(array("LOG_ID" => $arLog["ID"], "ACTIVITY_ID" => $ID));
$bConvert = true;
}
}
if (!$bConvert) {
$eventID = CCrmLiveFeed::CreateLogEvent($liveFeedFields, CCrmLiveFeedEvent::Add);
}
if (!(is_int($eventID) && $eventID > 0) && isset($liveFeedFields['ERROR'])) {
$arFields['ERROR'] = $liveFeedFields['ERROR'];
} else {
if ($arTask) {
$arTaskParticipant = CTaskNotifications::GetRecipientsIDs($arTask, false);
$arSocnetRights = CTaskNotifications::__UserIDs2Rights($arTaskParticipant);
if (isset($arTask['GROUP_ID']) && intval($arTask['GROUP_ID']) > 0) {
$perm = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arTask['GROUP_ID'], "tasks", "view");
$arSocnetRights = array_merge($arSocnetRights, array('SG' . $arTask['GROUP_ID'], 'SG' . $arTask['GROUP_ID'] . '_' . $perm));
}
CSocNetLogRights::DeleteByLogID($eventID);
CSocNetLogRights::Add($eventID, $arSocnetRights);
//.........这里部分代码省略.........