本文整理汇总了PHP中CSocNetLogRights::GetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetLogRights::GetList方法的具体用法?PHP CSocNetLogRights::GetList怎么用?PHP CSocNetLogRights::GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetLogRights
的用法示例。
在下文中一共展示了CSocNetLogRights::GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetForSonet
function SetForSonet($logID, $entity_type, $entity_id, $feature, $operation, $bNew = false)
{
$bFlag = true;
if (!$bNew) {
$rsRights = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID));
if ($arRights = $rsRights->Fetch()) {
$bFlag = false;
}
}
if ($bFlag) {
$bExtranet = false;
$perm = CSocNetFeaturesPerms::GetOperationPerm($entity_type, $entity_id, $feature, $operation);
if ($perm) {
if (CModule::IncludeModule("extranet") && ($extranet_site_id = CExtranet::GetExtranetSiteID())) {
$arLogSites = array();
$rsLogSite = CSocNetLog::GetSite($logID);
while ($arLogSite = $rsLogSite->Fetch()) {
$arLogSites[] = $arLogSite["LID"];
}
if (in_array($extranet_site_id, $arLogSites)) {
$bExtranet = true;
}
}
if ($bExtranet) {
if ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_OWNER) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER));
} elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_MODERATOR) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR));
} elseif ($entity_type == SONET_ENTITY_GROUP && in_array($perm, array(SONET_ROLES_USER, SONET_ROLES_AUTHORIZED, SONET_ROLES_ALL))) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
} elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_NONE) {
CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id));
} elseif ($entity_type == SONET_ENTITY_USER && in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS, SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_AUTHORIZED, SONET_RELATIONS_TYPE_ALL))) {
$arCode = array("SA");
$arLog = CSocNetLog::GetByID($logID);
if ($arLog) {
$dbUsersInGroup = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arLog["USER_ID"], "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => $extranet_site_id, "GROUP_ACTIVE" => "Y"), false, false, array("ID", "GROUP_ID"));
while ($arUsersInGroup = $dbUsersInGroup->Fetch()) {
if (!in_array("S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_USER, $arCode)) {
$arCode = array_merge($arCode, array("S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $arUsersInGroup["GROUP_ID"] . "_" . SONET_ROLES_USER));
}
}
CSocNetLogRights::Add($logID, $arCode);
}
}
} else {
if ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_OWNER) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER));
} elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_MODERATOR) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR));
} elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_USER) {
CSocNetLogRights::Add($logID, array("SA", "S" . SONET_ENTITY_GROUP . $entity_id, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
} elseif ($entity_type == SONET_ENTITY_USER && in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS, SONET_RELATIONS_TYPE_FRIENDS2))) {
$arCodes = array("SA", "U" . $entity_id, "S" . $entity_type . $entity_id . "_" . SONET_RELATIONS_TYPE_FRIENDS);
if ($perm == SONET_RELATIONS_TYPE_FRIENDS2) {
$arCodes[] = "S" . $entity_type . $entity_id . "_" . SONET_RELATIONS_TYPE_FRIENDS2;
}
CSocNetLogRights::Add($logID, $arCodes);
} elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_NONE) {
CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id));
} elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_AUTHORIZED) {
CSocNetLogRights::Add($logID, array("SA", "S" . $entity_type . $entity_id, "AU"));
} elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
CSocNetLogRights::Add($logID, array("SA", "AU"));
} elseif ($entity_type == SONET_ENTITY_GROUP && $perm == SONET_ROLES_ALL) {
CSocNetLogRights::Add($logID, array("SA", "S" . $entity_type . $entity_id, "G2"));
} elseif ($entity_type == SONET_ENTITY_USER && $perm == SONET_RELATIONS_TYPE_ALL) {
CSocNetLogRights::Add($logID, array("SA", "G2"));
}
}
}
}
}
示例2: 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;
}
示例3: CopyCommentRights
function CopyCommentRights($ID, $arFields)
{
if (empty($arFields['LOG_ID'])) {
return false;
}
if (empty(self::$storedFileIdsByComment[$arFields['SOURCE_ID']])) {
return false;
}
$arRights0 = array();
$rConst = 0;
$rs = CTask::GetList(array("LETTER" => "asc"), array("MODULE_ID" => "iblock", "LETTER" => "R"));
if ($ar = $rs->Fetch()) {
$rConst = $ar["ID"];
} else {
return false;
}
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["LOG_ID"]));
$i = 1;
while ($arRight = $dbRight->Fetch()) {
/*$arRights0["n" .$i] = Array(
"GROUP_CODE" => $arRight["GROUP_CODE"],
"TASK_ID" => $rConst,
);*/
$gc = $arRight["GROUP_CODE"];
if (array_key_exists($gc, $arRights0) && $arRights0[$gc]["TASK_ID"] >= $rConst) {
continue;
}
$arRights0[$gc] = array("KEY" => "n" . $i, "GROUP_CODE" => $gc, "TASK_ID" => $rConst);
$i++;
}
$arFilesID = self::$storedFileIdsByComment[$arFields['SOURCE_ID']];
$arFiles = array();
foreach ($arFilesID as $id) {
$id = intval($id);
if (intval($id) > 0) {
$arFiles[] = $id;
}
}
if (!$arFiles) {
return;
}
$ibe = new CIBlockElement();
$dbWDFile = $ibe->GetList(array(), array('ID' => $arFiles, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
while ($dbWDFile && ($arWDFile = $dbWDFile->Fetch())) {
$arRights1 = $arRights0;
$ob = new CIBlockElementRights($arWDFile['IBLOCK_ID'], $arWDFile['ID']);
$ar = $ob->GetRights();
foreach ($ar as $k => $v) {
$gc = $v["GROUP_CODE"];
if (array_key_exists($gc, $arRights1) && $arRights1[$gc]["TASK_ID"] >= $v["TASK_ID"]) {
continue;
}
$arRights1[$gc] = array("KEY" => $k, "GROUP_CODE" => $gc, "TASK_ID" => $v["TASK_ID"]);
}
$arRights2 = array();
foreach ($arRights1 as $v) {
$arRights2[$v["KEY"]] = array("GROUP_CODE" => $v["GROUP_CODE"], "TASK_ID" => $v["TASK_ID"]);
}
$ob->SetRights($arRights2);
}
}
示例4: 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);
}
}
}
}
}
示例5: FormatEvent_News
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;
}
示例6: GetMessage
else
{
$arResult["strMessage"] = GetMessage("SONET_LOG_FAVORITES_INCORRECT_LOG_ID");
$arResult["bResult"] = "E";
}
}
elseif ($action == "get_more_destination")
{
$arResult["arDestinations"] = false;
$log_id = intval($_REQUEST["log_id"]);
$created_by_id = intval($_REQUEST["created_by_id"]);
$iDestinationLimit = intval($_REQUEST["dlim"]);
if ($log_id > 0)
{
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $log_id));
while ($arRight = $dbRight->Fetch())
$arRights[] = $arRight["GROUP_CODE"];
$arParams = array(
"PATH_TO_USER" => $_REQUEST["p_user"],
"PATH_TO_GROUP" => $_REQUEST["p_group"],
"PATH_TO_CONPANY_DEPARTMENT" => $_REQUEST["p_dep"],
"NAME_TEMPLATE" => $_REQUEST["nt"],
"SHOW_LOGIN" => $_REQUEST["sl"],
"DESTINATION_LIMIT" => 100,
"CHECK_PERMISSIONS_DEST" => "N"
);
if ($created_by_id > 0)
$arParams["CREATED_BY"] = $created_by_id;
示例7: OnAfterPhotoUpload
public static function OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult)
{
static $arSiteWorkgroupsPage;
if (!CModule::IncludeModule("iblock")) {
return;
}
if (!array_key_exists("IS_SOCNET", $arComponentParams) || $arComponentParams["IS_SOCNET"] != "Y") {
return;
}
$bPassword = false;
$arComponentResult["SECTION"]["PATH"] = array();
$rsSectionAlbum = CIBlockSection::GetList(array(), array("ID" => intval($arFields["IBLOCK_SECTION"])), false, array("ID", "LEFT_MARGIN", "RIGHT_MARGIN", "DEPTH_LEVEL"));
if ($arSectionAlbum = $rsSectionAlbum->Fetch()) {
$dbSection = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arComponentParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSectionAlbum["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSectionAlbum["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSectionAlbum["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD"));
while ($arPath = $dbSection->Fetch()) {
$arComponentResult["SECTION"]["PATH"][] = $arPath;
}
}
foreach ($arComponentResult["SECTION"]["PATH"] as $arPathSection) {
if (strlen(trim($arPathSection["UF_PASSWORD"])) > 0) {
$bPassword = true;
break;
}
}
if (array_key_exists("USER_ALIAS", $arComponentParams) && strlen($arComponentParams["USER_ALIAS"]) > 0) {
$arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
if (is_array($arTmp) && count($arTmp) == 2) {
$entity_type = $arTmp[0];
$entity_id = $arTmp[1];
if ($entity_type == "group") {
$entity_type = SONET_ENTITY_GROUP;
} elseif ($entity_type == "user") {
$entity_type = SONET_ENTITY_USER;
}
}
if ((!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER)) || intval($entity_id) <= 0) && count($arComponentResult["SECTION"]["PATH"]) > 0) {
$entity_type = SONET_ENTITY_USER;
$entity_id = $arComponentResult["SECTION"]["PATH"][0]["CREATED_BY"];
}
}
if (!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER)) || intval($entity_id) <= 0) {
return;
}
if (!$arSiteWorkgroupsPage && IsModuleInstalled("extranet") && $entity_type == SONET_ENTITY_GROUP) {
$rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
while ($arSite = $rsSite->Fetch()) {
$arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]);
}
}
if (is_set($arComponentParams["DETAIL_URL"]) && is_array($arSiteWorkgroupsPage) && $entity_type == SONET_ENTITY_GROUP) {
foreach ($arSiteWorkgroupsPage as $groups_page) {
if (strpos($arComponentParams["DETAIL_URL"], $groups_page) === 0) {
$arComponentParams["DETAIL_URL"] = "#GROUPS_PATH#" . substr($arComponentParams["DETAIL_URL"], strlen($groups_page), strlen($arComponentParams["DETAIL_URL"]) - strlen($groups_page));
}
}
}
$db_res = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo", "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"] . "_" . $arFields["MODIFIED_BY"], ">=LOG_UPDATE" => ConvertTimeStamp(AddToTimeStamp(array("MI" => -5)) + CTimeZone::GetOffset(), "FULL")));
if (array_key_exists("SECTION", $arComponentResult) && array_key_exists("NAME", $arComponentResult["SECTION"])) {
$strSectionName = $arComponentResult["SECTION"]["NAME"];
} else {
$strSectionName = $arComponentResult["SECTION"]["PATH"][count($arComponentResult["SECTION"]["PATH"]) - 1]["NAME"];
}
if (array_key_exists("URL", $arComponentResult) && array_key_exists("SECTION_EMPTY", $arComponentResult["URL"])) {
$strSectionUrl = $arComponentResult["URL"]["SECTION_EMPTY"];
} else {
$strSectionUrl = $arComponentResult["SECTION_URL"];
}
$strSectionUrl = str_replace(array("#SECTION_ID#", "#section_id#"), $arFields["IBLOCK_SECTION"], $strSectionUrl);
if ($db_res && ($res = $db_res->Fetch())) {
if (strlen($res["PARAMS"]) > 0) {
$arResParams = unserialize($res["PARAMS"]);
array_push($arResParams["arItems"], $arFields["ID"]);
} else {
return;
}
$arLogParams = array("COUNT" => $arResParams["COUNT"] + 1, "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"], "ALIAS" => $arComponentParams["USER_ALIAS"], "DETAIL_URL" => $arResParams["DETAIL_URL"], "arItems" => $arResParams["arItems"]);
$arSonetFields = array("=LOG_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "PARAMS" => serialize($arLogParams));
CSocNetLog::Update($res["ID"], $arSonetFields);
if (!$bPassword) {
CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view");
}
$logID = $res["ID"];
} else {
$arLogParams = array("COUNT" => 1, "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"], "DETAIL_URL" => $arComponentParams["DETAIL_URL"], "ALIAS" => $arComponentParams["USER_ALIAS"], "arItems" => array($arFields["ID"]));
$sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
$sAuthorUrl = "";
if ($GLOBALS["USER"]->IsAuthorized()) {
$sAuthorName = trim($GLOBALS["USER"]->GetFullName());
$sAuthorName = empty($sAuthorName) ? $GLOBALS["USER"]->GetLogin() : $sAuthorName;
}
$arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTO_LOG_1")), "TITLE" => str_replace("#COUNT#", "1", GetMessage("SONET_PHOTO_LOG_2")), "MESSAGE" => "", "URL" => $strSectionUrl, "MODULE_ID" => false, "CALLBACK_FUNC" => false, "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"] . "_" . $arFields["MODIFIED_BY"], "PARAMS" => serialize($arLogParams), "SOURCE_ID" => $arFields["IBLOCK_SECTION"]);
$serverName = defined("SITE_SERVER_NAME") && strLen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name");
$arSonetFields["TEXT_MESSAGE"] = str_replace(array("#TITLE#"), array($strSectionName), GetMessage("SONET_PHOTO_LOG_MAIL_TEXT"));
if ($GLOBALS["USER"]->IsAuthorized()) {
$arSonetFields["USER_ID"] = $GLOBALS["USER"]->GetID();
}
$logID = CSocNetLog::Add($arSonetFields, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID, "RATING_TYPE_ID" => "IBLOCK_SECTION", "RATING_ENTITY_ID" => $arFields["IBLOCK_SECTION"]));
if ($bPassword) {
//.........这里部分代码省略.........
示例8: GetSubSelect
private static function GetSubSelect($arLogFields, $bDecrement = false)
{
global $DB;
$author_id = CCrmSecurityHelper::GetCurrentUserID();
if ($author_id <= 0 && isset($arLogFields["USER_ID"])) {
$author_id = intval($arLogFields["USER_ID"]);
}
if ($author_id <= 0) {
return "";
}
$entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($arLogFields["ENTITY_TYPE"]);
$entityID = $arLogFields["ENTITY_ID"];
$arEntities = array();
if ($entityTypeID == CCrmOwnerType::Activity) {
if ($arActivity = CCrmActivity::GetByID($entityID)) {
$entityTypeID = $arActivity["OWNER_TYPE_ID"];
$entityID = $arActivity["OWNER_ID"];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
$arCommunications = CCrmActivity::GetCommunications($arActivity["ID"]);
foreach ($arCommunications as $arActivityCommunication) {
$entityTypeID = $arActivityCommunication["ENTITY_TYPE_ID"];
$entityID = $arActivityCommunication["ENTITY_ID"];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
}
} elseif ($entityTypeID == CCrmOwnerType::Invoice) {
if ($arInvoice = CCrmInvoice::GetByID($entityID)) {
$arBindings = array(CCrmOwnerType::Contact => $arInvoice["UF_CONTACT_ID"], CCrmOwnerType::Company => $arInvoice["UF_COMPANY_ID"], CCrmOwnerType::Deal => $arInvoice["UF_DEAL_ID"]);
foreach ($arBindings as $entityTypeID => $entityID) {
if (intval($entityID) > 0) {
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if ($entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
}
}
} else {
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
if (intval($arLogFields["LOG_ID"]) > 0 && in_array($arLogFields["EVENT_ID"], array("crm_lead_message", "crm_deal_message", "crm_contact_message", "crm_company_message"))) {
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arLogFields["LOG_ID"]));
while ($arRight = $dbRight->Fetch()) {
if (preg_match('/^(' . CCrmLiveFeedEntity::Contact . '|' . CCrmLiveFeedEntity::Lead . '|' . CCrmLiveFeedEntity::Company . '|' . CCrmLiveFeedEntity::Deal . ')(\\d+)$/', $arRight["GROUP_CODE"], $matches)) {
$entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($matches[1]);
$entityID = $matches[2];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0 && !array_key_exists($entityTypeID . "_" . $entityID, $arEntities[$entityName])) {
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => CCrmOwnerType::isOpened($entityTypeID, $entityID, false), "RESPONSIBLE_ID" => $responsible_id);
}
}
}
}
$arUserID = array();
foreach ($arEntities as $entityName => $arTmp) {
$sSql = "SELECT RL.RELATION, RP.ATTR \n\t\t\t\tFROM b_crm_role_relation RL \n\t\t\t\tINNER JOIN b_crm_role_perms RP ON RL.ROLE_ID = RP.ROLE_ID AND RP.ENTITY = '" . $entityName . "' AND RP.PERM_TYPE = 'READ'\n\t\t\t";
$res = $DB->Query($sSql, false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
while ($row = $res->Fetch()) {
$user_id = false;
switch ($row["ATTR"]) {
case BX_CRM_PERM_SELF:
foreach ($arTmp as $arEntity) {
$strSQL = "SELECT UA.USER_ID \n\t\t\t\t\t\t\tFROM b_user_access UA \n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tUA.USER_ID = " . intval($arEntity["RESPONSIBLE_ID"]) . "\n\t\t\t\t\t\t\t\tAND UA.ACCESS_CODE = '" . $DB->ForSQL($row["RELATION"]) . "'";
$rsUser = $DB->Query($strSQL, false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (($arUser = $rsUser->Fetch()) && !in_array($arUser["USER_ID"], $arUserID) && $arUser["USER_ID"] != $author_id) {
$arUserID[] = $arUser["USER_ID"];
}
//.........这里部分代码省略.........
示例9: FormatEvent_Files
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;
}
示例10: SetCommentFileRights
public static function SetCommentFileRights($arData, $logID)
{
if (intval($logID) <= 0) {
return;
}
$arAccessCodes = array();
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID));
while ($arRight = $dbRight->Fetch()) {
$arAccessCodes[] = $arRight["GROUP_CODE"];
}
$arFilesIds = $arData["PARAMS"]["UF_FORUM_MESSAGE_DOC"];
$UF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("FORUM_MESSAGE", $arData["MESSAGE_ID"], LANGUAGE_ID);
CCalendar::UpdateUFRights($arFilesIds, $arAccessCodes, $UF["UF_FORUM_MESSAGE_DOC"]);
}
示例11: SendMessageToSocNet
protected static function SendMessageToSocNet($arFields, $bSpawnedByAgent, $arChanges = null, $arTask = null, array $parameters = array())
{
global $USER, $DB;
$effectiveUserId = self::getEffectiveUserId($arFields, array(), $bSpawnedByAgent, $parameters);
if (!CModule::IncludeModule('socialnetwork')) {
return null;
}
$bCrmTask = isset($arTask) && isset($arTask["UF_CRM_TASK"]) && (is_array($arTask["UF_CRM_TASK"]) && (isset($arTask["UF_CRM_TASK"][0]) && strlen($arTask["UF_CRM_TASK"][0]) > 0) || !is_array($arTask["UF_CRM_TASK"]) && strlen($arTask["UF_CRM_TASK"]) > 0);
$arLogFilter = false;
if (!$bCrmTask) {
$arLogFilter = array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]);
} elseif (CModule::IncludeModule("crm")) {
$dbCrmActivity = CCrmActivity::GetList(array(), array('TYPE_ID' => CCrmActivityType::Task, 'ASSOCIATED_ENTITY_ID' => $arTask["ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
if ($arCrmActivity = $dbCrmActivity->Fetch()) {
$arLogFilter = array("EVENT_ID" => "crm_activity_add", "ENTITY_ID" => $arCrmActivity["ID"]);
}
}
if (!$arLogFilter) {
return null;
}
static $arCheckedUsers = array();
// users that checked for their existing
static $cachedSiteTimeFormat = -1;
// select "real" author
$occurAsUserId = CTasksTools::getOccurAsUserId();
if (!$occurAsUserId) {
$occurAsUserId = $effectiveUserId;
}
if ($cachedSiteTimeFormat === -1) {
$cachedSiteTimeFormat = CSite::GetDateFormat('FULL', SITE_ID);
}
static $cachedAllSitesIds = -1;
if ($cachedAllSitesIds === -1) {
$cachedAllSitesIds = array();
$dbSite = CSite::GetList($by = 'sort', $order = 'desc', array('ACTIVE' => 'Y'));
while ($arSite = $dbSite->Fetch()) {
$cachedAllSitesIds[] = $arSite['ID'];
}
}
// Check that user exists
if (!in_array((int) $arFields["CREATED_BY"], $arCheckedUsers, true)) {
$rsUser = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => $arFields["CREATED_BY"]), array('FIELDS' => array('ID')));
if (!($arUser = $rsUser->Fetch())) {
return false;
}
$arCheckedUsers[] = (int) $arFields["CREATED_BY"];
}
if (is_array($arChanges)) {
if (count($arChanges) == 0) {
$rsSocNetLogItems = CSocNetLog::GetList(array("ID" => "DESC"), $arLogFilter, false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
while ($arRes = $rsSocNetLogItems->Fetch()) {
$authorUserId = false;
if (isset($arFields['CREATED_BY'])) {
$authorUserId = (int) $arFields['CREATED_BY'];
} elseif (isset($arTask['CREATED_BY'])) {
$authorUserId = (int) $arTask['CREATED_BY'];
}
// Add author to list of users that view log about task in livefeed
// But only when some other person change task
// or if added FORUM_TOPIC_ID
if ($authorUserId !== $effectiveUserId || $arTask['FORUM_TOPIC_ID'] == 0 && isset($arFields['FORUM_TOPIC_ID']) && $arFields['FORUM_TOPIC_ID'] > 0) {
$authorGroupCode = 'U' . $authorUserId;
$rsRights = CSocNetLogRights::GetList(array(), array('LOG_ID' => $arRes['ID'], 'GROUP_CODE' => $authorGroupCode));
// If task's author hasn't rights yet, give them
if (!($arRights = $rsRights->fetch())) {
CSocNetLogRights::Add($arRes["ID"], array($authorGroupCode));
}
}
}
return null;
} elseif (count($arChanges) == 1 && isset($arChanges['STATUS'])) {
return null;
// if only status changes - don't send message, because it will be sent by SendStatusMessage()
}
}
if ($bSpawnedByAgent === 'Y') {
$bSpawnedByAgent = true;
} elseif ($bSpawnedByAgent === 'N') {
$bSpawnedByAgent = false;
}
if (!is_bool($bSpawnedByAgent)) {
return false;
}
$taskId = false;
if (is_array($arFields) && isset($arFields['ID']) && $arFields['ID'] > 0) {
$taskId = $arFields['ID'];
} elseif (is_array($arTask) && isset($arTask['ID']) && $arTask['ID'] > 0) {
$taskId = $arTask['ID'];
}
// We will mark this to false, if we send update message and log item already exists
$bSocNetAddNewItem = true;
$logDate = $DB->CurrentTimeFunction();
$curTimeTimestamp = time() + CTimeZone::GetOffset();
if (!$bCrmTask) {
$arSoFields = array('EVENT_ID' => 'tasks', 'TITLE' => $arFields['TITLE'], 'MESSAGE' => '', 'MODULE_ID' => 'tasks');
} else {
$arSoFields = array();
}
// If changes and task data given => we are prepare "update" message,
// or "add" message otherwise
//.........这里部分代码省略.........
示例12: FormatEvent_Files
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;
}
示例13: BXClearCache
BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/");
BXClearCache(true, "/blog/socnet_post/" . $post_id . "/");
BXClearCache(true, "/blog/socnet_post/gen/" . $post_id . "/");
} else {
$strError = GetMessage("BLOG_MOBILE_DELETE_ERROR");
}
}
} 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"])) {
示例14: SendStatusMessage
function SendStatusMessage($arTask, $status, $arFields = array())
{
global $USER, $DB;
$status = intval($status);
if ($status > 0 && $status < 8) {
$arRecipientsIDs = CTaskNotifications::GetRecipientsIDs(array_merge($arTask, $arFields));
if (sizeof($arRecipientsIDs) && (is_object($USER) && $USER->GetID() || $arTask["CREATED_BY"])) {
// If task was redoed
if (($status == CTasks::STATE_NEW || $status == CTasks::STATE_PENDING) && $arTask['REAL_STATUS'] == CTasks::STATE_SUPPOSEDLY_COMPLETED) {
$message = str_replace("#TASK_TITLE#", self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID'], true), GetMessage("TASKS_TASK_STATUS_MESSAGE_REDOED"));
$message_email = str_replace("#TASK_TITLE#", self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID']), GetMessage("TASKS_TASK_STATUS_MESSAGE_REDOED") . "\r\n" . GetMessage('TASKS_MESSAGE_LINK') . ': #PATH_TO_TASK#');
} else {
$message = str_replace("#TASK_TITLE#", self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID'], true), GetMessage("TASKS_TASK_STATUS_MESSAGE_" . $status));
$message_email = str_replace("#TASK_TITLE#", self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID']), GetMessage("TASKS_TASK_STATUS_MESSAGE_" . $status) . "\r\n" . GetMessage('TASKS_MESSAGE_LINK') . ': #PATH_TO_TASK#');
if ($status == CTasks::STATE_DECLINED) {
$message = str_replace("#TASK_DECLINE_REASON#", $arTask["DECLINE_REASON"], $message);
$message_email = str_replace("#TASK_DECLINE_REASON#", $arTask["DECLINE_REASON"], $message_email);
}
}
$occurAsUserId = CTasksTools::getOccurAsUserId();
if (!$occurAsUserId) {
$occurAsUserId = is_object($USER) && $USER->GetID() ? $USER->GetID() : $arTask["CREATED_BY"];
}
CTaskNotifications::SendMessage($occurAsUserId, $arRecipientsIDs, $message, $arTask["ID"], $message_email, array('ACTION' => 'TASK_STATUS_CHANGED_MESSAGE', 'arTask' => $arTask, 'arFields' => $arFields));
}
}
// sonet log
if (CModule::IncludeModule("socialnetwork")) {
if ($status == CTasks::STATE_PENDING) {
$message = GetMessage("TASKS_SONET_TASK_STATUS_MESSAGE_" . CTasks::STATE_NEW);
} else {
$message = GetMessage("TASKS_SONET_TASK_STATUS_MESSAGE_" . $status);
}
if ($status == CTasks::STATE_DECLINED) {
$message = str_replace("#TASK_DECLINE_REASON#", $arTask["DECLINE_REASON"], $message);
}
$arSoFields = array("TITLE" => $arTask["TITLE"], "=LOG_UPDATE" => strlen($arTask["CHANGED_DATE"]) > 0 ? MakeTimeStamp($arTask["CHANGED_DATE"], CSite::GetDateFormat("FULL", SITE_ID)) > time() + CTimeZone::GetOffset() ? $DB->CharToDateFunction($arTask["CHANGED_DATE"], "FULL", SITE_ID) : $DB->CurrentTimeFunction() : $DB->CurrentTimeFunction(), "MESSAGE" => "", "TEXT_MESSAGE" => $message, "PARAMS" => serialize(array("TYPE" => "status", 'CHANGED_BY' => $arFields['CHANGED_BY'], 'PREV_REAL_STATUS' => isset($arTask['REAL_STATUS']) ? $arTask['REAL_STATUS'] : false)));
$arSoFields['=LOG_DATE'] = $arSoFields['=LOG_UPDATE'];
// All tasks posts in live feed should be from director
if (isset($arFields['CREATED_BY'])) {
$arSoFields["USER_ID"] = $arFields['CREATED_BY'];
}
$loggedInUserId = false;
if (is_object($USER) && method_exists($USER, 'getId')) {
$loggedInUserId = (int) $USER->getId();
}
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
while ($arRes = $dbRes->Fetch()) {
CSocNetLog::Update($arRes['ID'], $arSoFields);
$authorUserId = (int) $arTask['CREATED_BY'];
// Add author to list of users that view log about task in livefeed
// But only when some other person change task
if ($authorUserId !== $loggedInUserId) {
$authorGroupCode = 'U' . $authorUserId;
$rsRights = CSocNetLogRights::GetList(array(), array('LOG_ID' => $arRes['ID'], 'GROUP_CODE' => $authorGroupCode));
// If task's author hasn't rights yet, give them
if (!($arRights = $rsRights->fetch())) {
CSocNetLogRights::Add($arRes["ID"], array($authorGroupCode));
}
}
}
}
}
示例15: FormatEvent_Data
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;
}