function _FormatUser(&$arUser, $arPath) { global $USER, $CACHE_ABSENCE; if ($arUser['PERSONAL_PHOTO']) { $arImage = CIntranetUtils::InitImage($arUser['PERSONAL_PHOTO'], 30); $arUser['PERSONAL_PHOTO'] = $arImage['IMG']; } if ($arPath['DETAIL_URL']) { $arUser['DETAIL_URL'] = str_replace('#ID#', $arUser['ID'], $arPath['DETAIL_URL']); } $arUser["canViewProfile"] = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $arUser['ID'], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin()); $arUser["canMessage"] = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $arUser['ID'], "message", CSocNetUser::IsCurrentUserModuleAdmin()); if ($arPath['MESSAGES_CHAT_URL']) { $arUser['MESSAGES_CHAT_URL'] = str_replace('#ID#', $arUser['ID'], $arPath['MESSAGES_CHAT_URL']); } $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']); $arUser['IS_ONLINE'] = CSocNetUser::IsOnLine($arUser['ID']); if ($arUser['IS_ABSENT']) { $maxAbsence = 0; foreach ($CACHE_ABSENCE[$arUser["ID"]] as $arAbsence) { if (MakeTimeStamp($arAbsence["DATE_TO"]) > $maxAbsence) { $arUser['ABSENT_TILL'] = $arAbsence["DATE_TO"]; } } } $arFilter = array("TO_USER_ID" => $arUser['ID'], "MESSAGE_TYPE" => SONET_MESSAGE_PRIVATE, "FROM_USER_ID" => $USER->GetID()); $dbMessages = CSocNetMessages::GetList(array("DATE_CREATE" => "DESC"), $arFilter, false, array("nTopCount" => 1), array("ID", "DATE_CREATE")); if ($arMessages = $dbMessages->GetNext()) { $arUser['LAST_CHAT'] = $arMessages["DATE_CREATE"]; } return true; }
public function onPrepareComponentParams($params) { $this->arIBlock = CIBlock::GetArrayByID($params["IBLOCK_ID"]); $this->arResult["IBLOCK"] = htmlspecialcharsex($this->arIBlock); $this->arResult["IBLOCK_ID"] = $this->arIBlock["ID"]; $this->arResult["GRID_ID"] = "lists_list_elements_" . $this->arResult["IBLOCK_ID"]; $this->arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0; $this->arResult["SECTIONS"] = array(); $this->arResult["SECTION_ID"] = false; $this->arResult["LIST_SECTIONS"] = array(); if (isset($_GET["list_section_id"])) { $sectionId = intval($_GET["list_section_id"]); } else { $sectionId = intval($params["SECTION_ID"]); } $rsSections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $this->arIBlock["ID"], "GLOBAL_ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y")); while ($arSection = $rsSections->GetNext()) { $this->arResult["SECTIONS"][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => $arSection["NAME"]); if ($arSection["ID"] == $sectionId) { $this->arResult["SECTION"] = $arSection; $this->arResult["SECTION_ID"] = $arSection["ID"]; } $this->arResult["LIST_SECTIONS"][$arSection["ID"]] = str_repeat(" . ", $arSection["DEPTH_LEVEL"]) . $arSection["NAME"]; } $this->arResult["IS_SOCNET_GROUP_CLOSED"] = false; if (intval($params["~SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork")) { $arSonetGroup = CSocNetGroup::GetByID(intval($params["~SOCNET_GROUP_ID"])); if (is_array($arSonetGroup) && $arSonetGroup["CLOSED"] == "Y" && !CSocNetUser::IsCurrentUserModuleAdmin() && ($arSonetGroup["OWNER_ID"] != $GLOBALS["USER"]->GetID() || COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y")) { $this->arResult["IS_SOCNET_GROUP_CLOSED"] = true; } } return $params; }
public static function OnGetNotifySchema() { $arResult = array("socialnetwork" => array("invite_group" => array("NAME" => GetMessage("SONET_NS_INVITE_GROUP")), "inout_group" => array("NAME" => GetMessage("SONET_NS_INOUT_GROUP")), "moderators_group" => array("NAME" => GetMessage("SONET_NS_MODERATORS_GROUP")), "owner_group" => array("NAME" => GetMessage("SONET_NS_OWNER_GROUP")), "sonet_group_event" => array("NAME" => GetMessage("SONET_NS_SONET_GROUP_EVENT")))); if (CSocNetUser::IsFriendsAllowed()) { /* $arResult["socialnetwork"]["invite_user"] = Array( "NAME" => GetMessage("SONET_NS_INVITE_USER") ); */ $arResult["socialnetwork"]["inout_user"] = array("NAME" => GetMessage("SONET_NS_FRIEND")); } return $arResult; }
public static function OnFillSocNetMenu(&$arResult, $arParams = array()) { global $USER; $arResult["AllowSettings"]["group_lists"] = true; $arResult["CanView"]["group_lists"] = (array_key_exists("ActiveFeatures", $arResult) ? array_key_exists("group_lists", $arResult["ActiveFeatures"]) : true) && CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), $arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], "group_lists", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["Title"]["group_lists"] = array_key_exists("ActiveFeatures", $arResult) && array_key_exists("group_lists", $arResult["ActiveFeatures"]) && strlen($arResult["ActiveFeatures"]["group_lists"]) > 0 ? $arResult["ActiveFeatures"]["group_lists"] : GetMessage("LISTS_SOCNET_TAB"); if (!array_key_exists("SEF_MODE", $arResult) || $arResult["SEF_MODE"] != "N") { if (isset($arResult["Urls"])) { $arResult["Urls"]["group_lists"] = $arResult["Urls"]["view"] . "lists/"; } } else { if (!array_key_exists("PAGE_VAR", $arResult)) { $arResult["PAGE_VAR"] = "page"; } if (!array_key_exists("GROUP_VAR", $arResult)) { $arResult["GROUP_VAR"] = "group_id"; } $arResult["Urls"]["group_lists"] = "?" . $arResult["PAGE_VAR"] . "=group_lists&" . $arResult["GROUP_VAR"] . "=" . $arResult["Group"]["ID"]; } }
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; }
function __GCEGetGroup(&$group_id, &$arGroupProperties = array(), &$arGroupTmp = array(), $tab = false) { if (!CModule::IncludeModule("socialnetwork")) { $group_id = 0; return; } $arGroup = CSocNetGroup::GetByID($group_id); if ($arGroup && ($tab == "edit" && ($arGroup["OWNER_ID"] == $GLOBALS["USER"]->GetID() || CSocNetUser::IsCurrentUserModuleAdmin()) || $tab == "invite" && (CSocNetUser::IsCurrentUserModuleAdmin() || CSocNetGroup::CanUserInitiate($GLOBALS["USER"]->GetID(), $group_id)))) { $arGroupTmp["NAME"] = $arGroup["NAME"]; $arGroupTmp["DESCRIPTION"] = $arGroup["DESCRIPTION"]; $arGroupTmp["IMAGE_ID_DEL"] = "N"; $arGroupTmp["SUBJECT_ID"] = $arGroup["SUBJECT_ID"]; $arGroupTmp["VISIBLE"] = $arGroup["VISIBLE"]; $arGroupTmp["OPENED"] = $arGroup["OPENED"]; $arGroupTmp["CLOSED"] = $arGroup["CLOSED"]; $arGroupTmp["KEYWORDS"] = $arGroup["KEYWORDS"]; $arGroupTmp["OWNER_ID"] = $arGroup["OWNER_ID"]; $arGroupTmp["INITIATE_PERMS"] = $arGroup["INITIATE_PERMS"]; $arGroupTmp["SPAM_PERMS"] = $arGroup["SPAM_PERMS"]; $arGroupTmp["IMAGE_ID"] = $arGroup["IMAGE_ID"]; $arGroupTmp["IMAGE_ID_FILE"] = CFile::GetFileArray($arGroup["IMAGE_ID"]); $arGroupTmp["IMAGE_ID_IMG"] = '<img src="' . ($arGroupTmp["IMAGE_ID_FILE"] != false ? $arGroupTmp["IMAGE_ID_FILE"]["SRC"] : "/bitrix/images/1.gif") . '" height="60" class="sonet-group-create-popup-image" id="sonet_group_create_popup_image" border="0">'; foreach ($arGroupProperties as $field => $arUserField) { if (array_key_exists($field, $arGroup)) { $arGroupProperties[$field]["VALUE"] = $arGroup["~" . $field]; $arGroupProperties[$field]["ENTITY_VALUE_ID"] = $arGroup["ID"]; } } $arGroupTmp["IS_EXTRANET_GROUP"] = "N"; if (CModule::IncludeModule("extranet") && CExtranet::IsExtranetSocNetGroup($group_id)) { $arGroupTmp["IS_EXTRANET_GROUP"] = "Y"; } } else { $arGroupTmp["VISIBLE"] = "Y"; $arGroupTmp["IS_EXTRANET_GROUP"] = "N"; $group_id = 0; } }
public static function GetStatus($arParams = Array()) { if (!is_array($arParams)) $arParams = Array(); $arID = Array(); if (isset($arParams['ID']) && is_array($arParams['ID']) && !empty($arParams['ID'])) { foreach ($arParams['ID'] as $key => $value) $arID[] = intval($value); } else if (isset($arParams['ID']) && intval($arParams['ID']) > 0) { $arID[] = intval($arParams['ID']); } global $USER; if(!isset($arParams['ID']) && !IsModuleInstalled('intranet') && is_object($USER)) { $arID[] = $USER->GetID(); if (CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed()) { $dbFriends = CSocNetUserRelations::GetList(array(),array("USER_ID" => $USER->GetID(), "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID")); if ($dbFriends) { while ($arFriends = $dbFriends->GetNext(true, false)) { $friendId = $pref = (IntVal($USER->GetID()) == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]; $arID[] = $friendId; } } } } $arUsers = Array(); $dbUsers = CUser::GetList(($sort_by = 'ID'), ($sort_dir = 'asc'), array('LAST_ACTIVITY' => '180'), array('FIELDS' => array("ID"))); while ($arUser = $dbUsers->GetNext(false, false)) { if (!empty($arID) && !in_array($arUser["ID"], $arID)) continue; $arUsers[$arUser["ID"]] = Array( 'id' => $arUser["ID"], 'status' => 'online', ); } return Array('users' => $arUsers); }
function GetSocNetPostPerms($postId = 0, $bNeedFull = false, $userId = false) { if (!$userId) { $userId = IntVal($GLOBALS["USER"]->GetID()); $bByUserId = false; } else { $userId = IntVal($userId); $bByUserId = true; } $postId = IntVal($postId); if ($postId <= 0) { return false; } $perms = BLOG_PERMS_DENY; $arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]); if (!$bByUserId) { $blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog"); if ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) { $perms = $arAvailPerms[count($arAvailPerms) - 1]; } } else { if (CSocNetUser::IsUserModuleAdmin($userId)) { $perms = $arAvailPerms[count($arAvailPerms) - 1]; } } $arPost = CBlogPost::GetByID($postId); if ($arPost["AUTHOR_ID"] == $userId) { $perms = BLOG_PERMS_FULL; } if ($perms <= BLOG_PERMS_DENY) { $arPerms = CBlogPost::GetSocNetPerms($postId); $arEntities = array(); if (isset($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId]) && !empty($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId])) { $arEntities = $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId]; } else { $dbA = CAccess::GetUserCodes($userId); while ($arA = $dbA->Fetch()) { if ($arA["PROVIDER_ID"] == "intranet") { $arEntities["DR"][] = $arA["ACCESS_CODE"]; } elseif ($arA["PROVIDER_ID"] == "socnetgroup") { $g = substr($arA["ACCESS_CODE"], 2); $gId = IntVal($g); $gR = substr($g, strpos($g, "_") + 1); $arEntities["SG"][$gId][] = $gR; } } $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId] = $arEntities; } foreach ($arPerms as $t => $val) { foreach ($val as $id => $p) { if ($userId > 0 && $t == "U" && $userId == $id) { $perms = BLOG_PERMS_READ; if (in_array("US" . $userId, $p)) { // if author $perms = BLOG_PERMS_FULL; } break; } if (in_array("G2", $p)) { $perms = BLOG_PERMS_READ; break; } if ($userId > 0 && in_array("AU", $p)) { $perms = BLOG_PERMS_READ; break; } if ($t == "SG") { if (!empty($arEntities["SG"][$id])) { foreach ($arEntities["SG"][$id] as $gr) { if (in_array("SG" . $id . "_" . $gr, $p)) { $perms = BLOG_PERMS_READ; break; } } } } if ($t == "DR") { if (in_array("DR" . $id, $arEntities["DR"])) { $perms = BLOG_PERMS_READ; break; } } } if ($perms > BLOG_PERMS_DENY) { break; } } if ($bNeedFull && $perms <= BLOG_PERMS_FULL) { $arGroupsId = array(); if (!empty($arPerms["SG"])) { foreach ($arPerms["SG"] as $gid => $val) { if (!empty($arEntities["SG"][$gid])) { $arGroupsId[] = $gid; } } } $operation = array("full_post", "moderate_post", "write_post", "premoderate_post"); if (!empty($arGroupsId)) { foreach ($operation as $v) { if ($perms <= BLOG_PERMS_READ) { $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v); if (!empty($f)) { foreach ($f as $gid => $val) { if (in_array($val, $arEntities["SG"][$gid])) { switch ($v) { case "full_post": $perms = BLOG_PERMS_FULL; break; case "moderate_post": $perms = BLOG_PERMS_MODERATE; break; case "write_post": $perms = BLOG_PERMS_WRITE; break; case "premoderate_post": $perms = BLOG_PERMS_PREMODERATE; break; } } } } } } } } } return $perms; }
public static function inviteGroupUsers($arFields) { global $USER; $groupID = $arFields['GROUP_ID']; $arUserID = $arFields['USER_ID']; $message = $arFields['MESSAGE']; if(intval($groupID) <= 0) throw new Exception('Wrong group ID'); if ( (is_array($arUserID) && count($arUserID) <= 0) || (!is_array($arUserID) && intval($arUserID) <= 0) ) throw new Exception('Wrong user IDs'); if (!is_array($arUserID)) $arUserID = array($arUserID); $arSuccessID = array(); $dbRes = CSocNetGroup::GetList(array(), array( "ID" => $groupID, "CHECK_PERMISSIONS" => $USER->GetID(), )); $arGroup = $dbRes->Fetch(); if(is_array($arGroup)) { foreach($arUserID as $user_id) { $isCurrentUserTmp = ($USER->GetID() == $user_id); $canInviteGroup = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $user_id, "invitegroup", CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)); $user2groupRelation = CSocNetUserToGroup::GetUserRole($user_id, $arGroup["ID"]); if ( !$isCurrentUserTmp && $canInviteGroup && !$user2groupRelation && CSocNetUserToGroup::SendRequestToJoinGroup($USER->GetID(), $user_id, $arGroup["ID"], $message, true) ) $arSuccessID[] = $user_id; } } else throw new Exception('Socialnetwork group not found'); return $arSuccessID; }
function __SLEGetLogRecord($logID, $arParams, $arCurrentUserSubscribe, $current_page_date) { static $isExtranetInstalled, $isExtranetSite, $isExtranetUser, $arUserIdVisible, $arAvailableExtranetUserID, $isExtranetAdmin, $bCurrentUserIsAdmin, $arSocNetFeaturesSettings; if (!$isExtranetInstalled) { $isExtranetInstalled = CModule::IncludeModule("extranet") ? "Y" : "N"; $isExtranetSite = $isExtranetInstalled == "Y" && CExtranet::IsExtranetSite() ? "Y" : "N"; $isExtranetUser = $isExtranetInstalled == "Y" && !CExtranet::IsIntranetUser() ? "Y" : "N"; $isExtranetAdmin = $isExtranetInstalled == "Y" && CExtranet::IsExtranetAdmin() ? "Y" : "N"; $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures(); if ($isExtranetUser == "Y") { $arUserIdVisible = CExtranet::GetMyGroupsUsersSimple(SITE_ID); } elseif ($isExtranetInstalled == "Y" && $isExtranetUser != "Y") { if ($isExtranetAdmin == "Y" && $bCurrentUserIsAdmin) { $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsers(SITE_ID); } else { $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsersSimple(CExtranet::GetExtranetSiteID()); } } } $cache_time = 31536000; $arEvent = array(); $cache = new CPHPCache(); $arCacheID = array(); $arKeys = array("AVATAR_SIZE", "DESTINATION_LIMIT", "CHECK_PERMISSIONS_DEST", "NAME_TEMPLATE", "NAME_TEMPLATE_WO_NOBR", "SHOW_LOGIN", "DATE_TIME_FORMAT", "PATH_TO_USER", "PATH_TO_GROUP", "PATH_TO_CONPANY_DEPARTMENT"); foreach ($arKeys as $param_key) { if (array_key_exists($param_key, $arParams)) { $arCacheID[$param_key] = $arParams[$param_key]; } else { $arCacheID[$param_key] = false; } } $cache_id = "log_post_" . $logID . "_" . md5(serialize($arCacheID)) . "_" . SITE_TEMPLATE_ID . "_" . SITE_ID . "_" . LANGUAGE_ID . "_" . FORMAT_DATETIME . "_" . CTimeZone::GetOffset(); $cache_path = "/sonet/log/" . intval(intval($logID) / 1000) . "/" . $logID . "/entry/"; if (is_object($cache) && $cache->InitCache($cache_time, $cache_id, $cache_path)) { $arCacheVars = $cache->GetVars(); $arEvent["FIELDS_FORMATTED"] = $arCacheVars["FIELDS_FORMATTED"]; if (array_key_exists("CACHED_CSS_PATH", $arEvent["FIELDS_FORMATTED"])) { if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) && strlen($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) > 0) { $GLOBALS['APPLICATION']->SetAdditionalCSS($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]); } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"])) { foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"] as $css_path) { $GLOBALS['APPLICATION']->SetAdditionalCSS($css_path); } } } if (array_key_exists("CACHED_JS_PATH", $arEvent["FIELDS_FORMATTED"])) { if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]) && $arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] !== '') { $GLOBALS['APPLICATION']->AddHeadScript($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]); } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"])) { foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] as $js_path) { $GLOBALS['APPLICATION']->AddHeadScript($js_path); } } } } else { if (is_object($cache)) { $cache->StartDataCache($cache_time, $cache_id, $cache_path); } $arFilter = array("ID" => $logID); $arListParams = array("CHECK_RIGHTS" => "N", "USE_FOLLOW" => "N", "USE_SUBSCRIBE" => "N"); $arSelect = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "SOURCE_TYPE"); $dbEvent = CSocNetLog::GetList(array(), $arFilter, false, false, $arSelect, $arListParams); if ($arEvent = $dbEvent->GetNext()) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path); $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arEvent["USER_ID"])); $GLOBALS["CACHE_MANAGER"]->RegisterTag("SONET_LOG_" . intval($arEvent["ID"])); if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group_" . $arEvent["ENTITY_ID"]); } } $arEvent["EVENT_ID_FULLSET"] = CSocNetLogTools::FindFullSetEventIDByEventID($arEvent["EVENT_ID"]); if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) { static $arSiteWorkgroupsPage; if (!$arSiteWorkgroupsPage && (IsModuleInstalled("extranet") || is_set($arEvent["URL"]) && strpos($arEvent["URL"], "#GROUPS_PATH#") !== false)) { $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($arEvent["URL"]) && isset($arSiteWorkgroupsPage[SITE_ID])) { $arEvent["URL"] = str_replace("#GROUPS_PATH#", $arSiteWorkgroupsPage[SITE_ID], $arEvent["URL"]); } } $arEventTmp = CSocNetLogTools::FindLogEventByID($arEvent["EVENT_ID"]); if ($arEventTmp && isset($arEventTmp["CLASS_FORMAT"]) && isset($arEventTmp["METHOD_FORMAT"])) { $arEvent["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("SONET_LOG", $arEvent["ID"], LANGUAGE_ID); $arEvent["FIELDS_FORMATTED"] = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arEvent, $arParams); if (is_array($arEvent["FIELDS_FORMATTED"])) { if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"])) { if (in_array($arEvent["EVENT_ID"], array('calendar'))) { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]); } else { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = CSocNetTextParser::closetags(htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"])); } } if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"])) { $arFields2Cache = array("URL", "STYLE", "DESTINATION", "DESTINATION_MORE", "TITLE_24", "TITLE_24_2", "TITLE_24_2_STYLE", "IS_IMPORTANT", "MESSAGE", "FOOTER_MESSAGE", "MESSAGE_TITLE_24", "DATETIME_FORMATTED", "LOG_DATE_FORMAT", "MENU", "COMMENT_URL"); foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"][$field]); } } } if (isset($arEvent["FIELDS_FORMATTED"]["EVENT"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT"])) { $arFields2Cache = array("ID", "URL", "USER_ID", "ENTITY_TYPE", "ENTITY_ID", "EVENT_ID", "EVENT_ID_FULLSET", "TITLE", "MESSAGE", "SOURCE_ID", "PARAMS", "RATING_TYPE_ID", "RATING_ENTITY_ID"); foreach ($arEvent["FIELDS_FORMATTED"]["EVENT"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["EVENT"][$field]); } } } if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"])) { $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL", "IS_EXTRANET"); foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"][$field]); } } if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"])) { $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL"); foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"][$field]); } } } } if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"])) { $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL"); foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["ENTITY"][$field]); } } if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"])) { $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL"); foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"][$field]); } } } } $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["UF"] = $arEvent["UF"]; } else { $bEmpty = true; } } if (!$bEmpty) { $dateFormated = FormatDate($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATE), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]))); $timeFormated = FormatDateFromDB(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]), stripos($arParams["DATE_TIME_FORMAT"], 'a') || ($arParams["DATE_TIME_FORMAT"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'H:MI TT' : 'H:MI T' : 'HH:MI'); $dateTimeFormated = FormatDate(!empty($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] == "FULL" ? $GLOBALS["DB"]->DateFormatToPHP(str_replace(":SS", "", FORMAT_DATETIME)) : $arParams["DATE_TIME_FORMAT"] : $GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]))); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $dateTimeFormated = ToLower($dateTimeFormated); $dateFormated = ToLower($dateFormated); $timeFormated = ToLower($timeFormated); } // strip current year if (!empty($arParams['DATE_TIME_FORMAT']) && ($arParams['DATE_TIME_FORMAT'] == 'j F Y G:i' || $arParams['DATE_TIME_FORMAT'] == 'j F Y g:i a')) { $dateTimeFormated = ltrim($dateTimeFormated, '0'); $curYear = date('Y'); $dateTimeFormated = str_replace(array('-' . $curYear, '/' . $curYear, ' ' . $curYear, '.' . $curYear), '', $dateTimeFormated); } $arEvent["MESSAGE_FORMAT"] = htmlspecialcharsback($arEvent["MESSAGE"]); if (StrLen($arEvent["CALLBACK_FUNC"]) > 0) { if (StrLen($arEvent["MODULE_ID"]) > 0) { CModule::IncludeModule($arEvent["MODULE_ID"]); } $arEvent["MESSAGE_FORMAT"] = call_user_func($arEvent["CALLBACK_FUNC"], $arEvent); } $arEvent["FIELDS_FORMATTED"]["LOG_TIME_FORMAT"] = $timeFormated; $arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_TS"] = MakeTimeStamp($arEvent["LOG_UPDATE"]); $arEvent["FIELDS_FORMATTED"]["LOG_DATE_TS"] = MakeTimeStamp($arEvent["LOG_DATE"]); $arEvent["FIELDS_FORMATTED"]["LOG_DATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_DATE"]), "SHORT"); $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"]; }
public static function InitUsersTmp($message, $titleTemplate1, $titleTemplate2, $arParams, $bCurrentUserIsAdmin = "unknown", $bRSS = false) { $arUsersID = explode(",", $message); $message = ""; $title = ""; $bFirst = true; $count = 0; if ($bCurrentUserIsAdmin == "unknown") $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); foreach ($arUsersID as $userID) { list($titleTmp, $messageTmp) = CSocNetLog::InitUserTmp($userID, $arParams, $bCurrentUserIsAdmin, $bRSS); if (StrLen($titleTmp) > 0) { if (!$bFirst) $title .= ", "; $title .= $titleTmp; $count++; } if (StrLen($messageTmp) > 0) { if (!$bFirst) $message .= " "; $message .= $messageTmp; } $bFirst = false; } return array(Str_Replace("#TITLE#", $title, (($count > 1) ? $titleTemplate2 : $titleTemplate1)), $message); }
if ($arUser['PERSONAL_BIRTHDAY']) { $arBirthDate = ParseDateTime($arUser['PERSONAL_BIRTHDAY'], CSite::GetDateFormat('SHORT')); $arUser['IS_BIRTHDAY'] = intval($arBirthDate['MM']) == date('n') && intval($arBirthDate['DD']) == date('j'); } $arUser['IS_FEATURED'] = CIntranetUtils::IsUserHonoured($arUser['ID']); $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']); $arResult["SEARCH"][$i]["USER"] = $arUser; } } } $arResult['USER_PROP'] = array(); $arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER", 0, LANGUAGE_ID); if (!empty($arRes)) { foreach ($arRes as $key => $val) { $arResult['USER_PROP'][$val["FIELD_NAME"]] = strLen($val["EDIT_FORM_LABEL"]) > 0 ? $val["EDIT_FORM_LABEL"] : $val["FIELD_NAME"]; } } } $arrDropdown = array(); $arResult["DROPDOWN_SONET"] = array(); $EntityType = array_key_exists("arrFILTER", $arParams) && in_array("socialnetwork_group", $arParams["arrFILTER"]) ? SONET_ENTITY_GROUP : SONET_ENTITY_USER; $EntityID = $EntityType == SONET_ENTITY_GROUP ? $arParams["arrFILTER_socialnetwork"][0] : $arParams["arrFILTER_socialnetwork_user"]; $arActiveFeaturesNames = CSocNetFeatures::GetActiveFeaturesNames($EntityType, $EntityID); foreach ($arParams["arrWHERE_SONET"] as $feature_id) { if (strlen($feature_id) > 0 && array_key_exists($feature_id, $arActiveFeaturesNames) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $EntityType, $EntityID, $feature_id, $arSocNetFeaturesSettings[$feature_id]["minoperation"][0], CSocNetUser::IsCurrentUserModuleAdmin()) && array_key_exists($feature_id, $arSocNetFeaturesSettings)) { $arrDropdown[$feature_id] = strlen($arActiveFeaturesNames[$feature_id]) > 0 ? $arActiveFeaturesNames[$feature_id] : GetMessage("SEARCH_CONTENT_TYPE_" . strtoupper($feature_id) . "_" . $EntityType); } } if (count($arrDropdown) > 0) { $arResult["DROPDOWN_SONET"] = htmlspecialcharsex($arrDropdown); }
/******************************************************************** Default params # 1 ********************************************************************/ $arResult["TOPIC"] = array(); $arResult["FORUM"] = CForumNew::GetByID($arParams["FID"]); $arParams["PERMISSION_ORIGINAL"] = ForumCurrUserPermissions($arParams["FID"]); $arParams["PERMISSION"] = "A"; $arError = array(); $arNote = array(); /******************************************************************** /Default params #1 ********************************************************************/ /******************************************************************** Main Data & Permissions ********************************************************************/ $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); if (empty($arResult["FORUM"])) { ShowError(GetMessage("F_FID_IS_LOST")); CHTTP::SetStatus("404 Not Found"); return false; } elseif ($arParams["MODE"] == "GROUP" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum") || $arParams["MODE"] != "GROUP" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "forum")) { ShowError(GetMessage("FORUM_SONET_MODULE_NOT_AVAIBLE")); return false; } else { $user_id = $USER->GetID(); if ($arParams["MODE"] == "GROUP") { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "full", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "Y"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "newtopic", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "M"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "answer", $bCurrentUserIsAdmin)) {
LocalRedirect($APPLICATION->GetCurPageParam("invite_sent=Y", array("invite_user_id", "employee"))); } } } $parser = new CSocNetTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]); $arResult["Requests"] = false; $dbRequests = CSocNetUserToGroup::GetList(array("DATE_CREATE" => "ASC"), array("GROUP_ID" => $arResult["Group"]["ID"], "ROLE" => SONET_ROLES_REQUEST, "INITIATED_BY_TYPE" => SONET_INITIATED_BY_GROUP), false, $arNavParams, array("ID", "USER_ID", "DATE_CREATE", "DATE_UPDATE", "MESSAGE", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER")); if ($dbRequests) { $arResult["Requests"] = array(); $arResult["Requests"]["List"] = false; while ($arRequests = $dbRequests->GetNext()) { if ($arResult["Requests"]["List"] == false) { $arResult["Requests"]["List"] = array(); } $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arRequests["USER_ID"])); $canViewProfile = CSocNetUserPerms::CanPerformOperation($USER->GetID(), $arRequests["USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin()); if (intval($arRequests["USER_PERSONAL_PHOTO"]) <= 0) { switch ($arRequests["USER_PERSONAL_GENDER"]) { case "M": $suffix = "male"; break; case "F": $suffix = "female"; break; default: $suffix = "unknown"; } $arRequests["USER_PERSONAL_PHOTO"] = COption::GetOptionInt("socialnetwork", "default_user_picture_" . $suffix, false, SITE_ID); } $arImage = CSocNetTools::InitImage($arRequests["USER_PERSONAL_PHOTO"], 150, "/bitrix/images/socialnetwork/nopic_user_150.gif", 150, $pu, $canViewProfile); $arResult["Requests"]["List"][] = array("ID" => $arRequests["ID"], "USER_ID" => $arRequests["USER_ID"], "USER_NAME" => $arRequests["USER_NAME"], "USER_LAST_NAME" => $arRequests["USER_LAST_NAME"], "USER_SECOND_NAME" => $arRequests["USER_SECOND_NAME"], "USER_LOGIN" => $arRequests["USER_LOGIN"], "USER_PERSONAL_PHOTO" => $arRequests["USER_PERSONAL_PHOTO"], "USER_PERSONAL_PHOTO_FILE" => $arImage["FILE"], "USER_PERSONAL_PHOTO_IMG" => $arImage["IMG"], "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "DATE_CREATE" => FormatDateFromDB($arRequests["DATE_CREATE"]), "MESSAGE" => $parser->convert($arRequests["~MESSAGE"], false, array(), array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LIST" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "SMILES" => "Y", "UPLOAD" => "N", "NL2BR" => "N")));
function RejectRequestToBeMember($userID, $groupID, $arRelationID) { global $APPLICATION, $DB; $userID = IntVal($userID); if ($userID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_USERID"), "ERROR_USERID"); return false; } $groupID = IntVal($groupID); if ($groupID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_GROUPID"), "ERROR_GROUPID"); return false; } if (!is_array($arRelationID)) { return true; } $arGroup = CSocNetGroup::GetByID($groupID); if (!$arGroup || !is_array($arGroup)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_ERROR_NO_GROUP_ID"), "ERROR_NO_GROUP"); return false; } $arGroupSites = array(); $rsGroupSite = CSocNetGroup::GetSite($groupID); while ($arGroupSite = $rsGroupSite->Fetch()) { $arGroupSites[] = $arGroupSite["LID"]; } $userRole = CSocNetUserToGroup::GetUserRole($userID, $groupID); $bUserIsMember = $userRole && in_array($userRole, array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR, SONET_ROLES_USER)); $bCanInitiate = $GLOBALS["USER"]->IsAdmin() || CSocNetUser::IsCurrentUserModuleAdmin($arGroupSites) || $userRole && ($arGroup["INITIATE_PERMS"] == SONET_ROLES_OWNER && $userID == $arGroup["OWNER_ID"] || $arGroup["INITIATE_PERMS"] == SONET_ROLES_MODERATOR && in_array($userRole, array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR)) || $arGroup["INITIATE_PERMS"] == SONET_ROLES_USER && $bUserIsMember); if (!$bCanInitiate) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_ERROR_NO_PERMS"), "ERROR_NO_PERMS"); return false; } $bSuccess = true; $tmp_count = count($arRelationID); for ($i = 0; $i < $tmp_count; $i++) { $arRelationID[$i] = IntVal($arRelationID[$i]); if ($arRelationID[$i] <= 0) { continue; } $arRelation = CSocNetUserToGroup::GetByID($arRelationID[$i]); if (!$arRelation) { continue; } if ($arRelation["GROUP_ID"] != $groupID || $arRelation["INITIATED_BY_TYPE"] != SONET_INITIATED_BY_USER || $arRelation["ROLE"] != SONET_ROLES_REQUEST) { continue; } if (CSocNetUserToGroup::Delete($arRelation["ID"])) { $arMessageFields = array("FROM_USER_ID" => $userID, "TO_USER_ID" => $arRelation["USER_ID"], "MESSAGE" => str_replace("#NAME#", $arGroup["NAME"], GetMessage("SONET_UG_REJECT_MEMBER_MESSAGE_G")), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM); CSocNetMessages::Add($arMessageFields); } else { $errorMessage = ""; if ($e = $APPLICATION->GetException()) { $errorMessage = $e->GetString(); } if (StrLen($errorMessage) <= 0) { $errorMessage = GetMessage("SONET_UR_ERROR_CREATE_USER2GROUP"); } $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CONFIRM_MEMBER"); $bSuccess = false; } } return $bSuccess; }
public static function GetSocNetUserPerms($postId = 0, $authorId = 0) { global $APPLICATION, $USER, $AR_BLOG_PERMS, $BLOG_POST; $userId = IntVal($USER->GetID()); $postId = IntVal($postId); $authorId = IntVal($authorId); if($postId <= 0) return false; $perms = BLOG_PERMS_DENY; $blogModulePermissions = $APPLICATION->GetGroupRight("blog"); if($authorId > 0 && $userId == $authorId) $perms = BLOG_PERMS_FULL; elseif ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) { end($AR_BLOG_PERMS); $perms = key($AR_BLOG_PERMS); reset($AR_BLOG_PERMS); } if($perms <= BLOG_PERMS_DENY) { $arPerms = CBlogPost::GetSocNetPerms($postId); $arEntities = Array(); if (isset($BLOG_POST["UAC_CACHE_".$userId]) && !empty($BLOG_POST["UAC_CACHE_".$userId])) { $arEntities = $BLOG_POST["UAC_CACHE_".$userId]; } else { $dbA = CAccess::GetUserCodes($userId); while($arA = $dbA->Fetch()) { if($arA["PROVIDER_ID"] == "intranet") { $arEntities["DR"][$arA["ACCESS_CODE"]] = $arA["ACCESS_CODE"]; } elseif($arA["PROVIDER_ID"] == "socnetgroup") { $g = substr($arA["ACCESS_CODE"], 2); $gId = IntVal($g); $gR = substr($g, strpos($g, "_")+1); $arEntities["SG"][$gId][$gR] = $gR; } } $BLOG_POST["UAC_CACHE_".$userId] = $arEntities; } if(!empty($arEntities["DR"]) && !empty($arPerms["DR"])) { foreach($arPerms["DR"] as $id => $val) { if(isset($arEntities["DR"]["DR".$id])) { $perms = BLOG_PERMS_READ; break; } } } if((!empty($arPerms["U"][$userId]) && in_array("US".$userId, $arPerms["U"][$userId])) || ($authorId >0 && $userId == $authorId)) // if author $perms = BLOG_PERMS_FULL; else { if($authorId <= 0) { foreach($arPerms["U"] as $id => $p) { if(in_array("US".$id, $p)) { $authorId = $id; break; } } } if(!empty($arPerms["U"][$userId]) || (!empty($arPerms["U"][$authorId]) && in_array("US".$authorId, $arPerms["U"][$authorId])) || $perms == BLOG_PERMS_READ) { if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment")) $perms = BLOG_PERMS_WRITE; elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment")) $perms = BLOG_PERMS_PREMODERATE; elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment")) $perms = BLOG_PERMS_READ; } } if($perms <= BLOG_PERMS_FULL) { $arGroupsId = Array(); if(!empty($arPerms["SG"])) { foreach($arPerms["SG"] as $gid => $val) { //if(!empty($arEntities["SG"][$gid])) $arGroupsId[] = $gid; } $operation = Array("full_comment", "moderate_comment", "write_comment", "premoderate_comment"); if($perms < BLOG_PERMS_READ) $operation[] = "view_comment"; } if(!empty($arGroupsId)) { foreach($operation as $v) { if($perms <= BLOG_PERMS_READ) { $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v); if(!empty($f)) { foreach($f as $gid => $val) { if((!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid])) || $val == SONET_ROLES_ALL || ($userId > 0 && $val == SONET_ROLES_AUTHORIZED)) { switch($v) { case "full_comment": $perms = BLOG_PERMS_FULL; break; case "moderate_comment": $perms = BLOG_PERMS_MODERATE; break; case "write_comment": $perms = BLOG_PERMS_WRITE; break; case "premoderate_comment": $perms = BLOG_PERMS_PREMODERATE; break; case "view_comment": $perms = BLOG_PERMS_READ; break; } } } } } } } } } return $perms; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("socialnetwork")) { return false; } $arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER"); $userProp = array(); if (!empty($arRes)) { foreach ($arRes as $key => $val) { $userProp[$val["FIELD_NAME"]] = strLen($val["EDIT_FORM_LABEL"]) > 0 ? $val["EDIT_FORM_LABEL"] : $val["FIELD_NAME"]; } } $userProp1 = CSocNetUser::GetFields(); unset($userProp1["PASSWORD"]); $arComponentParameters = array("GROUPS" => array("VARIABLE_ALIASES" => array("NAME" => GetMessage("SONET_VARIABLE_ALIASES"))), "PARAMETERS" => array("SET_NAV_CHAIN" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_SET_NAVCHAIN"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "PAGE_VAR" => array("NAME" => GetMessage("SONET_PAGE_VAR"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "VARIABLE_ALIASES"), "USER_VAR" => array("NAME" => GetMessage("SONET_USER_VAR"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "VARIABLE_ALIASES"), "PATH_TO_USER" => array("NAME" => GetMessage("SONET_PATH_TO_USER"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "PATH_TO_SEARCH" => array("NAME" => GetMessage("SONET_PATH_TO_SEARCH"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "PATH_TO_SEARCH_INNER" => array("NAME" => GetMessage("SONET_PATH_TO_SEARCH_INNER"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "PATH_TO_USER_FRIENDS_ADD" => array("NAME" => GetMessage("SONET_PATH_TO_USER_FRIENDS_ADD"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "PATH_TO_MESSAGE_FORM" => array("NAME" => GetMessage("SONET_PATH_TO_MESSAGE_FORM"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "PATH_TO_MESSAGES_CHAT" => array("NAME" => GetMessage("SONET_PATH_TO_MESSAGES_CHAT"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "URL_TEMPLATES"), "ITEMS_COUNT" => array("NAME" => GetMessage("SONET_ITEMS_COUNT"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 25, "PARENT" => "VISUAL"), "DATE_TIME_FORMAT" => CComponentUtil::GetDateTimeFormatField(GetMessage("SONET_DATE_TIME_FORMAT"), "VISUAL"), "SET_TITLE" => array(), "SHOW_USERS_WITHOUT_FILTER_SET" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_SHOW_USERS_WITHOUT_FILTER_SET"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "USER_FIELDS_SEARCH_SIMPLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_FIELDS_SIMPLE"), "TYPE" => "LIST", "VALUES" => $userProp1, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_PROPERTIES_SEARCH_SIMPLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_PROPERTY_SIMPLE"), "TYPE" => "LIST", "VALUES" => $userProp, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_FIELDS_SEARCH_ADV" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_FIELDS_ADV"), "TYPE" => "LIST", "VALUES" => $userProp1, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_PROPERTIES_SEARCH_ADV" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_PROPERTY_ADV"), "TYPE" => "LIST", "VALUES" => $userProp, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_FIELDS_LIST" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_FIELDS_LIST"), "TYPE" => "LIST", "VALUES" => $userProp1, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_PROPERTIES_LIST" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_USER_PROPERTY_LIST"), "TYPE" => "LIST", "VALUES" => $userProp, "MULTIPLE" => "Y", "DEFAULT" => array()), "USER_FIELDS_SEARCHABLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_SONET_USER_FIELDS_SEARCHABLE"), "TYPE" => "LIST", "VALUES" => $userProp1, "MULTIPLE" => "Y", "DEFAULT" => array("NAME", "SECOND_NAME", "LAST_NAME", "LOGIN", "PERSONAL_BIRTHDAY", "PERSONAL_PROFESSION", "PERSONAL_GENDER", "PERSONAL_COUNTRY", "PERSONAL_STATE", "PERSONAL_CITY", "PERSONAL_ZIP", "PERSONAL_STREET", "PERSONAL_MAILBOX", "WORK_COMPANY", "WORK_DEPARTMENT", "WORK_POSITION", "WORK_COUNTRY", "WORK_STATE", "WORK_CITY", "WORK_ZIP", "WORK_STREET", "WORK_MAILBOX")), "USER_PROPERTY_SEARCHABLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_SONET_USER_PROPERTY_SEARCHABLE"), "TYPE" => "LIST", "VALUES" => $userProp, "MULTIPLE" => "Y", "DEFAULT" => array()), 'SHOW_YEAR' => array('TYPE' => 'LIST', 'MULTIPLE' => 'N', 'DEFAULT' => 'Y', 'VALUES' => array('Y' => GetMessage('INTR_ISBN_PARAM_SHOW_YEAR_VALUE_Y'), 'M' => GetMessage('INTR_ISBN_PARAM_SHOW_YEAR_VALUE_M'), 'N' => GetMessage('INTR_ISBN_PARAM_SHOW_YEAR_VALUE_N')), 'NAME' => GetMessage('INTR_ISBN_PARAM_SHOW_YEAR'), "PARENT" => "ADDITIONAL_SETTINGS"), "CACHE_TIME" => array('DEFAULT' => 3600), "NAME_TEMPLATE" => array("TYPE" => "LIST", "NAME" => GetMessage("SONET_NAME_TEMPLATE"), "VALUES" => CComponentUtil::GetDefaultNameTemplates(), "MULTIPLE" => "N", "ADDITIONAL_VALUES" => "Y", "DEFAULT" => "", "PARENT" => "VISUAL"))); $arComponentParameters["PARAMETERS"]["ALLOW_RATING_SORT"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_ALLOW_RATING_SORT"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y"); $arComponentParameters["PARAMETERS"]["SHOW_RATING"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SHOW_RATING"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("SHOW_RATING_CONFIG"), "Y" => GetMessage("MAIN_YES"), "N" => GetMessage("MAIN_NO")), "MULTIPLE" => "N", "DEFAULT" => ""); if ($arCurrentValues["SHOW_RATING"] != "N" || $arCurrentValues["ALLOW_RATING_SORT"] == "Y") { $arRatingsList = array(); $db_res = CRatings::GetList($aSort = array("ID" => "ASC"), array("ACTIVE" => "Y", "ENTITY_ID" => "USER")); while ($res = $db_res->Fetch()) { $arRatingsList[$res["ID"]] = "[ " . $res["ID"] . " ] " . $res["NAME"]; } $arComponentParameters["PARAMETERS"]["RATING_ID"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SONET_RATING_ID"), "TYPE" => "LIST", "VALUES" => $arRatingsList, "DEFAULT" => "", "REFRESH" => "Y"); $arComponentParameters["PARAMETERS"]["RATING_TYPE"] = array("NAME" => GetMessage("RATING_TYPE"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("RATING_TYPE_CONFIG"), "like" => GetMessage("RATING_TYPE_LIKE_TEXT"), "like_graphic" => GetMessage("RATING_TYPE_LIKE_GRAPHIC"), "standart_text" => GetMessage("RATING_TYPE_STANDART_TEXT"), "standart" => GetMessage("RATING_TYPE_STANDART_GRAPHIC")), "MULTIPLE" => "N", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS"); }
function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arParams = array()) { global $DB, $arSocNetAllowedEntityTypes, $USER, $USER_FIELD_MANAGER; $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc(); $obUserFieldsSql = new CUserTypeSQL(); $obUserFieldsSql->SetEntity("SONET_LOG", "L.ID"); $obUserFieldsSql->SetSelect($arSelectFields); $obUserFieldsSql->SetFilter($arFilter); $obUserFieldsSql->SetOrder($arOrder); if (count($arSelectFields) <= 0) { $arSelectFields = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "RATING_TOTAL_VALUE", "RATING_TOTAL_VOTES", "RATING_TOTAL_POSITIVE_VOTES", "RATING_TOTAL_NEGATIVE_VOTES", "RATING_USER_VOTE_VALUE", "SOURCE_TYPE"); if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") { $arSelectFields[] = "FAVORITES_USER_ID"; } } static $arFields1 = array("ID" => array("FIELD" => "L.ID", "TYPE" => "int"), "TMP_ID" => array("FIELD" => "L.TMP_ID", "TYPE" => "int"), "SOURCE_ID" => array("FIELD" => "L.SOURCE_ID", "TYPE" => "int"), "ENTITY_TYPE" => array("FIELD" => "L.ENTITY_TYPE", "TYPE" => "string"), "ENTITY_ID" => array("FIELD" => "L.ENTITY_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "L.USER_ID", "TYPE" => "int"), "EVENT_ID" => array("FIELD" => "L.EVENT_ID", "TYPE" => "string"), "LOG_DATE" => array("FIELD" => "L.LOG_DATE", "TYPE" => "datetime"), "LOG_DATE_TS" => array("FIELD" => "UNIX_TIMESTAMP(L.LOG_DATE)", "TYPE" => "int"), "LOG_UPDATE" => array("FIELD" => "L.LOG_UPDATE", "TYPE" => "datetime"), "TITLE_TEMPLATE" => array("FIELD" => "L.TITLE_TEMPLATE", "TYPE" => "string"), "TITLE" => array("FIELD" => "L.TITLE", "TYPE" => "string"), "MESSAGE" => array("FIELD" => "L.MESSAGE", "TYPE" => "string"), "TEXT_MESSAGE" => array("FIELD" => "L.TEXT_MESSAGE", "TYPE" => "string"), "URL" => array("FIELD" => "L.URL", "TYPE" => "string"), "MODULE_ID" => array("FIELD" => "L.MODULE_ID", "TYPE" => "string"), "CALLBACK_FUNC" => array("FIELD" => "L.CALLBACK_FUNC", "TYPE" => "string"), "EXTERNAL_ID" => array("FIELD" => "L.EXTERNAL_ID", "TYPE" => "string"), "PARAMS" => array("FIELD" => "L.PARAMS", "TYPE" => "string"), "COMMENTS_COUNT" => array("FIELD" => "L.COMMENTS_COUNT", "TYPE" => "int"), "ENABLE_COMMENTS" => array("FIELD" => "L.ENABLE_COMMENTS", "TYPE" => "string"), "SOURCE_TYPE" => array("FIELD" => "L.SOURCE_TYPE", "TYPE" => "string"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OWNER_ID" => array("FIELD" => "G.OWNER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_INITIATE_PERMS" => array("FIELD" => "G.INITIATE_PERMS", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_VISIBLE" => array("FIELD" => "G.VISIBLE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OPENED" => array("FIELD" => "G.OPENED", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_IMAGE_ID" => array("FIELD" => "G.IMAGE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_GENDER" => array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "CREATED_BY_NAME" => array("FIELD" => "U1.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LAST_NAME" => array("FIELD" => "U1.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_SECOND_NAME" => array("FIELD" => "U1.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LOGIN" => array("FIELD" => "U1.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_PHOTO" => array("FIELD" => "U1.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_GENDER" => array("FIELD" => "U1.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "USER_ID|COMMENT_USER_ID" => array("FIELD" => "L.USER_ID|LC.USER_ID", "WHERE" => array("CSocNetLog", "GetSimpleOrQuery"), "FROM" => "LEFT JOIN b_sonet_log_comment LC ON LC.LOG_ID = L.ID")); $arFields = array("RATING_TYPE_ID" => array("FIELD" => "L.RATING_TYPE_ID", "TYPE" => "string"), "RATING_ENTITY_ID" => array("FIELD" => "L.RATING_ENTITY_ID", "TYPE" => "int"), "RATING_TOTAL_VALUE" => array("FIELD" => $DB->IsNull('RG.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_VOTES', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_POSITIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_NEGATIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID")); if (isset($USER) && is_object($USER)) { $arFields["RATING_USER_VOTE_VALUE"] = array("FIELD" => $DB->IsNull('RV.VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RV ON L.RATING_TYPE_ID = RV.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RV.ENTITY_ID AND RV.USER_ID = " . intval($USER->GetID())); if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") { $join_type = "LEFT"; $field_value = $DB->IsNull("SLF.USER_ID", "0"); foreach ($arFilter as $key => $value) { if (strpos($key, "FAVORITES_USER_ID") !== false) { $join_type = "INNER"; $field_value = "SLF.USER_ID"; break; } } $arFields["FAVORITES_USER_ID"] = array("FIELD" => $field_value, "TYPE" => "double", "FROM" => $join_type . " JOIN b_sonet_log_favorites SLF ON L.ID = SLF.LOG_ID AND SLF.USER_ID = " . intval($USER->GetID())); } } if (isset($USER) && is_object($USER) && $USER->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") { $default_follow = CSocNetLogFollow::GetDefaultValue($USER->GetID()); $default_field = $default_follow == "Y" ? "LOG_UPDATE" : "LOG_DATE"; $arFields["DATE_FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN L." . $default_field . "\n\t\t\t\t\tWHEN LFW.FOLLOW_DATE IS NOT NULL\n\t\t\t\t\t\tTHEN LFW.FOLLOW_DATE\n\t\t\t\t\tWHEN LFW.TYPE = 'Y'\n\t\t\t\t\t\tTHEN L.LOG_UPDATE\n\t\t\t\t\tELSE L.LOG_DATE\n\t\t\t\tEND", "TYPE" => "datetime", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID")); $arFields["FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN '" . $default_follow . "'\n\t\t\t\t\tELSE LFW.TYPE\n\t\t\t\tEND", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID")); if (!in_array("FOLLOW", $arSelectFields)) { $arSelectFields[] = "FOLLOW"; } } if (array_key_exists("SITE_ID", $arFilter)) { $arFields["SITE_ID"] = array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_site SLS ON L.ID = SLS.LOG_ID"); if (is_array($arFilter["SITE_ID"])) { $site_cnt = 0; foreach ($arFilter["SITE_ID"] as $site_id_tmp) { if ($site_id_tmp) { $site_cnt++; } } $strDistinct = $site_cnt > 1 ? " DISTINCT " : " "; } else { $strDistinct = " "; } foreach ($arSelectFields as $i => $strFieldTmp) { if ($strFieldTmp == "SITE_ID") { unset($arSelectFields[$i]); } } foreach ($arOrder as $by => $order) { if (!in_array($by, $arSelectFields)) { $arSelectFields[] = $by; } } } else { $arFields["SITE_ID"] = array("FIELD" => "L.SITE_ID", "TYPE" => "string"); $strDistinct = " "; } if (array_key_exists("USER_ID", $arFilter) && !array_key_exists("ENTITY_TYPE", $arFilter)) { $arCBFilterEntityType = array(); foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) { if (array_key_exists("USE_CB_FILTER", $arEntityTypeTmp) && $arEntityTypeTmp["USE_CB_FILTER"] == "Y") { $arCBFilterEntityType[] = $entity_type_tmp; } } if (is_array($arCBFilterEntityType) && count($arCBFilterEntityType) > 0) { $arFilter["ENTITY_TYPE"] = $arCBFilterEntityType; } } if (array_key_exists("LOG_RIGHTS", $arFilter)) { $Rights = array(); if (is_array($arFilter["LOG_RIGHTS"])) { foreach ($arFilter["LOG_RIGHTS"] as $str) { if (trim($str)) { $Rights[] = trim($str); } } } elseif (trim($arFilter["LOG_RIGHTS"])) { $Rights = trim($arFilter["LOG_RIGHTS"]); } unset($arFilter["LOG_RIGHTS"]); if (is_array($Rights) && !empty($Rights) || !is_array($Rights)) { $arFilter["LOG_RIGHTS"] = $Rights; $arFields["LOG_RIGHTS"] = array("FIELD" => "SLR0.GROUP_CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log_right SLR0 ON L.ID = SLR0.LOG_ID"); } if (is_array($Rights) && count($Rights) > 1) { $strDistinct = " DISTINCT "; } } if (array_key_exists("USER_ID|COMMENT_USER_ID", $arFilter)) { $strDistinct = " DISTINCT "; } if ($arParams["IS_CRM"] == "Y") { $events = GetModuleEvents("socialnetwork", "OnFillSocNetLogFields"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } } $arFields = array_merge($arFields1, $arFields); $arSqls = CSocNetGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql); $listEvents = GetModuleEvents("socialnetwork", "OnBuildSocNetLogSql"); while ($arEvent = $listEvents->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$arFields, &$arOrder, &$arFilter, &$arGroupBy, &$arSelectFields, &$arSqls)); } $r = $obUserFieldsSql->GetFilter(); if (strlen($r) > 0) { $strSqlUFFilter = " (" . $r . ") "; } $arSqls["RIGHTS"] = ""; $arSqls["CRM_RIGHTS"] = ""; if (!empty($arParams) && (array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" || array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y") && !array_key_exists("USER_ID", $arParams) && is_object($USER)) { $arParams["USER_ID"] = $USER->GetID(); } if (!empty($arParams) && array_key_exists("USER_ID", $arParams) && $arParams["CHECK_CRM_RIGHTS"] != "Y") { $arParams["CHECK_RIGHTS"] = "Y"; } if (!empty($arParams) && ($arParams["USE_SUBSCRIBE"] == "Y" || $arParams["USE_FOLLOW"] == "Y")) { if (!array_key_exists("SUBSCRIBE_USER_ID", $arParams)) { if (array_key_exists("USER_ID", $arParams) && intval($arParams["USER_ID"]) > 0) { $arParams["SUBSCRIBE_USER_ID"] = $arParams["USER_ID"]; } elseif (is_object($USER)) { $arParams["SUBSCRIBE_USER_ID"] = $USER->GetID(); } } if ($arParams["USE_SUBSCRIBE"] == "Y" && !array_key_exists("MY_ENTITIES", $arParams)) { foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) { if (array_key_exists("HAS_MY", $arEntityTypeTmp) && $arEntityTypeTmp["HAS_MY"] == "Y" && array_key_exists("CLASS_MY", $arEntityTypeTmp) && array_key_exists("METHOD_MY", $arEntityTypeTmp) && strlen($arEntityTypeTmp["CLASS_MY"]) > 0 && strlen($arEntityTypeTmp["METHOD_MY"]) > 0 && method_exists($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])) { $arMyEntities[$entity_type_tmp] = call_user_func(array($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])); } } $arParams["MY_ENTITIES"] = $arMyEntities; } } if (!empty($arParams) && array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) { $acc = new CAccess(); $acc->UpdateCodes(); $arSqls["RIGHTS"] = "EXISTS ( SELECT SLR.ID FROM b_sonet_log_right SLR\n\t\t\t\tLEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . (is_object($USER) ? intval($USER->GetID()) : 0) . ")\n\t\t\t\tWHERE L.ID = SLR.LOG_ID " . (is_object($USER) && $USER->IsAuthorized() && $arParams["MY_GROUPS_ONLY"] == "Y" ? " AND (\n\t\t\t\t\t\t\t\t(SLR.GROUP_CODE LIKE 'SG%' AND (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")) \n\t\t\t\t\t\t\t\tOR SLR.GROUP_CODE = 'U" . intval($USER->GetID()) . "'\n\t\t\t\t\t\t\t)" : " AND (\n\t\t\t\t\t\t\t\t0=1 " . (is_object($USER) && CSocNetUser::IsCurrentUserModuleAdmin() ? " OR SLR.GROUP_CODE = 'SA'" : "") . (is_object($USER) && $USER->IsAuthorized() ? " OR (SLR.GROUP_CODE = 'AU')" : "") . " OR (SLR.GROUP_CODE = 'G2')" . (is_object($USER) && $USER->IsAuthorized() ? " OR (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")" : "") . "\n\t\t\t\t\t\t\t)") . ")"; } if (!empty($arParams) && array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) { $permParams = array('ALIAS_PREFIX' => 'L', 'PERM_TYPE' => 'READ', 'FILTER_PARAMS' => isset($arParams['CUSTOM_FILTER_PARAMS']) ? $arParams['CUSTOM_FILTER_PARAMS'] : array(), 'OPTIONS' => array('ENTITY_TYPE_COLUMN' => 'ENTITY_TYPE', 'IDENTITY_COLUMN' => 'ENTITY_ID')); $altPerms = array(); $events = GetModuleEvents("socialnetwork", "OnBuildSocNetLogPerms"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$altPerms, $permParams)); } if (!empty($altPerms)) { foreach ($altPerms as $permSql) { if ($permSql === false) { //Access denied $dbRes = new CDBResult(); $dbRes->InitFromArray(array()); return $dbRes; } if (is_string($permSql) && $permSql !== '') { if ($arSqls['CRM_RIGHTS'] !== '') { $arSqls['CRM_RIGHTS'] .= ' AND '; } $arSqls['CRM_RIGHTS'] = $permSql; } } } } if ($arParams["USE_SUBSCRIBE"] == "Y" && intval($arParams["SUBSCRIBE_USER_ID"]) > 0) { $arSqls["SUBSCRIBE"] = CSocNetLogEvents::GetSQL($arParams["SUBSCRIBE_USER_ID"], is_array($arParams["MY_ENTITIES"]) ? $arParams["MY_ENTITIES"] : array(), $arParams["TRANSPORT"], $arParams["VISIBLE"]); $arParams["MIN_ID_JOIN"] = true; } $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", $strDistinct, $arSqls["SELECT"]); $strMinIDJoin = ""; if (is_array($arGroupBy) && count($arGroupBy) == 0) { $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " "; $bWhereStarted = false; if (strlen($arSqls["WHERE"]) > 0) { $strSql .= "WHERE " . $arSqls["WHERE"] . " "; $bWhereStarted = true; } if (strlen($strSqlUFFilter) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " "; $bWhereStarted = true; } if (strlen($arSqls["RIGHTS"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["CRM_RIGHTS"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["SUBSCRIBE"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") "; $bWhereStarted = true; } if (strlen($arSqls["GROUPBY"]) > 0) { $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " "; } //echo "!1!=".htmlspecialcharsbx($strSql)."<br>"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { return $arRes["CNT"]; } else { return False; } } $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " "; $bWhereStarted = false; if (strlen($arSqls["WHERE"]) > 0) { $strSql .= "WHERE " . $arSqls["WHERE"] . " "; $bWhereStarted = true; } if (strlen($strSqlUFFilter) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " "; $bWhereStarted = true; } if (strlen($arSqls["RIGHTS"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["CRM_RIGHTS"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["SUBSCRIBE"]) > 0) { $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") "; $bWhereStarted = true; } if (strlen($arSqls["GROUPBY"]) > 0) { $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " "; } if (strlen($arSqls["ORDERBY"]) > 0) { $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " "; } if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) { if (isset($arNavStartParams["nRecordCount"]) && intval($arNavStartParams["nRecordCount"]) > 0) { $cnt = intval($arNavStartParams["nRecordCount"]); } else { $strSql_tmp = "SELECT COUNT('x') as CNT " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " "; $bWhereStarted = false; if (strlen($arSqls["WHERE"]) > 0) { $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " "; $bWhereStarted = true; } if (strlen($strSqlUFFilter) > 0) { $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " "; $bWhereStarted = true; } if (strlen($arSqls["RIGHTS"]) > 0) { $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["CRM_RIGHTS"]) > 0) { $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " "; $bWhereStarted = true; } if (strlen($arSqls["SUBSCRIBE"]) > 0) { $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") "; $bWhereStarted = true; } if (strlen($arSqls["GROUPBY"]) > 0) { $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " "; } //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>"; $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $cnt = 0; if (strlen($arSqls["GROUPBY"]) <= 0) { if ($arRes = $dbRes->Fetch()) { $cnt = $arRes["CNT"]; } } else { // рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд $cnt = $dbRes->SelectedRowsCount(); } // for empty 2nd page show if ($arNavStartParams["bSkipPageReset"] && $arNavStartParams["nPageSize"] >= $cnt) { $cnt = $arNavStartParams["nPageSize"] + $cnt; } } $dbRes = new CDBResult(); //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>"; $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG")); $dbRes->NavQuery($strSql, $cnt, $arNavStartParams); } else { if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) { $strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]); } //echo "!3!=".htmlspecialcharsbx($strSql)."<br>"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG")); } return $dbRes; }
<?php define("STOP_STATISTICS", true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; require_once "functions.php"; CModule::IncludeModule('socialnetwork'); if (!$USER->IsAuthorized()) { die; } $SITE_ID = isset($_GET["SITE_ID"]) ? $_GET["SITE_ID"] : SITE_ID; if ($_REQUEST["mode"] == "search") { CUtil::decodeURIComponent($_GET); $APPLICATION->RestartBuffer(); CSocNetTools::InitGlobalExtranetArrays($SITE_ID); $arFilter = array("SITE_ID" => $SITE_ID, "%NAME" => $_GET["query"]); if (!CSocNetUser::IsCurrentUserModuleAdmin($SITE_ID)) { $arFilter["CHECK_PERMISSIONS"] = $USER->GetID(); } $rsGroups = CSocNetGroup::GetList(array("NAME" => "ASC"), $arFilter); $arGroups = array(); while ($arGroup = $rsGroups->Fetch()) { if (isset($GLOBALS["arExtranetGroupID"]) && is_array($GLOBALS["arExtranetGroupID"]) && in_array($arGroup["ID"], $GLOBALS["arExtranetGroupID"])) { $arGroup["IS_EXTRANET"] = "Y"; } $arGroups[] = group2JSItem($arGroup); } if (isset($_REQUEST["features_perms"]) && sizeof($_REQUEST["features_perms"]) == 2) { filterByFeaturePerms($arGroups, $_REQUEST["features_perms"]); } Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo CUtil::PhpToJsObject($arGroups);
$arResult["BLOG"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_BLOG_TITLE")); if (array_key_exists("blog", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "blog", "view_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("blog") >= "W") && CModule::IncludeModule("blog")) { $arResult["BLOG"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["blog"]) > 0) { $arResult["BLOG"]["TITLE"] = $arResult["ActiveFeatures"]["blog"]; } } $arResult["forum"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_FORUM_TITLE")); if (array_key_exists("forum", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "forum", "view", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("forum") >= "W") && CModule::IncludeModule("forum")) { $arResult["forum"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["forum"]) > 0) { $arResult["forum"]["TITLE"] = $arResult["ActiveFeatures"]["forum"]; } } $arResult["tasks"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_TASKS_TITLE")); if (array_key_exists("tasks", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "tasks", "view", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("intranet") >= "W") && CModule::IncludeModule("intranet")) { $arResult["tasks"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["tasks"]) > 0) { $arResult["tasks"]["TITLE"] = $arResult["ActiveFeatures"]["tasks"]; } } } } if (array_key_exists("RatingMultiple", $arResult) && count($arResult["RatingMultiple"]) > 0) { foreach ($arParams["RATING_ID_ARR"] as $rating_id) { if (array_key_exists($rating_id, $arResult["RatingMultiple"])) { $arResult["RatingMultiple"][$rating_id]["VALUE"] = $arResult["User"]["RATING_" . $rating_id . "_CURRENT_VALUE"]; } } } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } /** * @var array $arParams * @var array $arResult * @var CMain $APPLICATION * @var CUser $USER */ $rights = "N"; if (\CSocNetUser::IsCurrentUserModuleAdmin() || $APPLICATION->GetGroupRight("blog") >= "W") { $rights = "ALL"; } else { if (IsModuleInstalled("intranet") && $USER->IsAuthorized()) { $rights = "OWN"; } else { if (!IsModuleInstalled("intranet")) { $rights = $arResult["Perm"] < BLOG_PERMS_FULL ? "OWNLAST" : "ALL"; } } } $eventHandlerID = AddEventHandler('main', 'system.field.view.file', array('CBlogTools', 'blogUFfileShow')); $arResult["OUTPUT_LIST"] = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => 'BLOG_COMMENT_BG_', "RATING_TYPE_ID" => $arParams["SHOW_RATING"] == "Y" ? "BLOG_COMMENT" : "", "ENTITY_XML_ID" => $arParams["ENTITY_XML_ID"], "RECORDS" => $arResult["RECORDS"], "NAV_STRING" => $arResult["NAV_STRING"], "NAV_RESULT" => $arResult["NAV_RESULT"], "PREORDER" => "N", "RIGHTS" => array("MODERATE" => $arResult["Perm"] >= BLOG_PERMS_MODERATE ? "Y" : "N", "EDIT" => $rights, "DELETE" => $rights), "VISIBLE_RECORDS_COUNT" => $arResult["newCount"], "ERROR_MESSAGE" => $arResult["ERROR_MESSAGE"] ?: $arResult["COMMENT_ERROR"], "OK_MESSAGE" => $arResult["MESSAGE"], "RESULT" => $arResult["ajax_comment"] ?: $_GET["commentId"], "PUSH&PULL" => $arResult["PUSH&PULL"], "VIEW_URL" => str_replace("#comment_id#", "#ID#", $arResult["urlMobileToComment"]), "EDIT_URL" => str_replace("#comment_id#", "#ID#", $arResult["urlMobileToComment"]), "MODERATE_URL" => str_replace(array("hide_comment_id=", "#comment_id#"), array("#action#_comment_id=", "#ID#"), $arResult["urlMobileToHide"]), "DELETE_URL" => str_replace("#comment_id#", "#ID#", $arResult["urlMobileToDelete"]), "AUTHOR_URL" => "/mobile/users/?user_id=#user_id#", "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams['SHOW_LOGIN'], "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT"], "LAZYLOAD" => $arParams["LAZYLOAD"], "NOTIFY_TAG" => $arParams["bFromList"] ? "BLOG|COMMENT" : "", "NOTIFY_TEXT" => $arParams["bFromList"] ? TruncateText(str_replace(array("\r\n", "\n"), " ", $arParams["POST_DATA"]["~TITLE"]), 100) : "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => $arResult["CanUserComment"] ? "Y" : "N", "IMAGE_SIZE" => $arParams["IMAGE_SIZE"], "mfi" => $arParams["mfi"], "FORM" => array("ID" => $this->__component->__name, "URL" => $APPLICATION->GetCurPageParam("", array("sessid", "comment_post_id", "act", "post", "comment", "decode", "ACTION", "ENTITY_TYPE_ID", "ENTITY_ID", "empty_get_form", "empty_get_comments")))), $this->__component); if ($eventHandlerID > 0) { RemoveEventHandler('main', 'system.field.view.file', $eventHandlerID); } if ($arResult["CanUserComment"] == "Y") { ob_start(); include_once __DIR__ . "/script.php";
/** @var string $parentComponentPath */ /** @var string $parentComponentTemplate */ $this->setFrameMode(false); if (!CModule::IncludeModule('lists')) { ShowError(GetMessage("CC_BLL_MODULE_NOT_INSTALLED")); return; } $IBLOCK_ID = intval($arParams["~IBLOCK_ID"]); if (isset($_GET["list_section_id"])) { $section_id = intval($_GET["list_section_id"]); } else { $section_id = intval($arParams["~SECTION_ID"]); } if (intval($arParams["~SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork")) { $arSonetGroup = CSocNetGroup::GetByID(intval($arParams["~SOCNET_GROUP_ID"])); if (is_array($arSonetGroup) && $arSonetGroup["CLOSED"] == "Y" && !CSocNetUser::IsCurrentUserModuleAdmin() && ($arSonetGroup["OWNER_ID"] != $GLOBALS["USER"]->GetID() || COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y")) { $arResult["IS_SOCNET_GROUP_CLOSED"] = true; } } $lists_perm = CListPermissions::CheckAccess($USER, $arParams["~IBLOCK_TYPE_ID"], $IBLOCK_ID, $arParams["~SOCNET_GROUP_ID"]); if ($lists_perm < 0) { switch ($lists_perm) { case CListPermissions::WRONG_IBLOCK_TYPE: ShowError(GetMessage("CC_BLL_WRONG_IBLOCK_TYPE")); return; case CListPermissions::WRONG_IBLOCK: ShowError(GetMessage("CC_BLL_WRONG_IBLOCK")); return; case CListPermissions::LISTS_FOR_SONET_GROUP_DISABLED: ShowError(GetMessage("CC_BLL_LISTS_FOR_SONET_GROUP_DISABLED")); return;
if ($gadget["BLOG_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog")) { continue; } if ($gadget["FORUM_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "forum")) { continue; } if ($gadget["FORUM_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "search")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "search")) { continue; } if ($gadget["WIKI_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki") || !CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki", "view", CSocNetUser::IsCurrentUserModuleAdmin()))) { continue; } if ($gadget["GROUP"]["ID"] == "") { $gadget["GROUP"]["ID"] = "other"; } if (!isset($gadget["TOTALLY_FIXED"]) || !$gadget["TOTALLY_FIXED"]) { if (!is_array($gadget["GROUP"]["ID"])) { $arGroups[$gadget["GROUP"]["ID"]]["GADGETS"][] = $gadget["ID"]; } else { foreach ($gadget["GROUP"]["ID"] as $group_id) { if (in_array($arParams["MODE"], array("SU", "SG")) && $group_id != "sonet" || !in_array($arParams["MODE"], array("SU", "SG")) && $group_id == "sonet" || $arParams["MODE"] == "AI" && $group_id != "admin" || $arParams["MODE"] != "AI" && $group_id == "admin") { continue; } $arGroups[$group_id]["GADGETS"][] = $gadget["ID"]; }
if (in_array($arUser["ID"], $arUsersInListID)) { continue; } $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arUser["ID"])); $canViewProfile = CSocNetUserPerms::CanPerformOperation($arResult["UserSelf"]["ID"], $arUser["ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin()); $strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arUser, $bUseLogin); $arResult["Friends"][] = array("USER_ID" => $arUser["ID"], "USER_NAME" => $arUser["NAME"], "USER_LAST_NAME" => $arUser["LAST_NAME"], "USER_SECOND_NAME" => $arUser["SECOND_NAME"], "USER_LOGIN" => $arUser["LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arUser["ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arUser["IS_ONLINE"] == "Y"); } } //Recent users $arResult["RecentUsers"] = array(); $arNavParams = array("nPageSize" => 20, "bDescPageNumbering" => false); $dbMessages = CSocNetMessages::GetMessagesUsers($GLOBALS["USER"]->GetID(), $arNavParams); while ($arMessages = $dbMessages->GetNext()) { $pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arMessages["ID"])); $canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arMessages["ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin()); $arTmpUser = array("NAME" => $arMessages["~NAME"], "LAST_NAME" => $arMessages["~LAST_NAME"], "SECOND_NAME" => $arMessages["~SECOND_NAME"], "LOGIN" => $arMessages["~LOGIN"]); $strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arTmpUser, $bUseLogin); $arResult["RecentUsers"][] = array("USER_ID" => $arMessages["ID"], "USER_NAME" => $arMessages["NAME"], "USER_LAST_NAME" => $arMessages["LAST_NAME"], "USER_SECOND_NAME" => $arMessages["SECOND_NAME"], "USER_LOGIN" => $arMessages["LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arMessages["ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arMessages["IS_ONLINE"] == "Y"); } $arResult["PrintSmilesList"] = CSocNetSmile::PrintSmilesList(0, LANGUAGE_ID, $arParams["PATH_TO_SMILE"]); $strNow = CSocNetMessages::Now(); $strNow_ts = MakeTimeStamp($strNow, "YYYY-MM-DD HH:MI:SS") + CTimeZone::GetOffset(); $arResult["Now"] = date("Y-m-d H:i:s", $strNow_ts); //user options require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . strtolower($GLOBALS['DB']->type) . "/favorites.php"; $arResult["USER_OPTIONS"] = CUserOptions::GetOption('socnet', 'chat', array()); if ($arResult["USER_OPTIONS"]["sound"] != "N") { $arResult["USER_OPTIONS"]["sound"] = "Y"; } if ($arResult["USER_OPTIONS"]["contacts"] != "Y") {
unset($arFilter[">PERMS"]); } $arSelectedFields = array("ID", "BLOG_ID", "TITLE", "DATE_PUBLISH", "AUTHOR_ID", "DETAIL_TEXT", "BLOG_ACTIVE", "BLOG_URL", "BLOG_GROUP_ID", "BLOG_GROUP_SITE_ID", "AUTHOR_LOGIN", "AUTHOR_NAME", "AUTHOR_LAST_NAME", "AUTHOR_SECOND_NAME", "BLOG_USER_ALIAS", "BLOG_OWNER_ID", "VIEWS", "NUM_COMMENTS", "ATTACH_IMG", "BLOG_SOCNET_GROUP_ID", "CODE", "MICRO"); if (CModule::IncludeModule("socialnetwork") && $arParams["USE_SOCNET"] == "Y") { unset($arFilter[">PERMS"]); $arFilter["BLOG_USE_SOCNET"] = "Y"; if (IntVal($arParams["SOCNET_GROUP_ID"]) <= 0 && IntVal($arParams["USER_ID"]) <= 0) { $arFilter["FOR_USER"] = $user_id; } else { if (IntVal($arParams["USER_ID"]) > 0) { $arFilter["AUTHOR_ID"] = $arParams["USER_ID"]; $arFilter["FOR_USER"] = $user_id; } elseif (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { $arFilter["SOCNET_GROUP_ID"] = $arParams["SOCNET_GROUP_ID"]; $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "full_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("blog") >= "W") { $perms = BLOG_PERMS_FULL; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "write_post")) { $perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "view_post")) { $perms = BLOG_PERMS_READ; } } } } if ($perms != BLOG_PERMS_DENY) { $SORT = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]); if ($arParams["MESSAGE_COUNT"] > 0) { $COUNT = array("nTopCount" => $arParams["MESSAGE_COUNT"]); } else { $COUNT = false;
public function AddUser($chatId, $userId) { global $DB; $chatId = intval($chatId); if ($chatId <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_CHAT_ID"), "EMPTY_CHAT_ID"); return false; } $arUserId = array(); if (is_array($userId)) { $arUserId = \CIMContactList::PrepareUserIds($userId); } else { if (intval($userId) > 0) { $arUserId[intval($userId)] = intval($userId); } } if ($this->user_id > 0) { $arUserId[$this->user_id] = $this->user_id; } if (count($arUserId) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_USER_ID"), "EMPTY_USER_ID"); return false; } if ($this->user_id > 0 && !IsModuleInstalled('intranet') && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed()) { $arFriendUsers = array(); $dbFriends = CSocNetUserRelations::GetList(array(), array("USER_ID" => $this->user_id, "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID", "DATE_CREATE", "DATE_UPDATE", "INITIATED_BY")); while ($arFriends = $dbFriends->Fetch()) { $friendId = $this->user_id == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]; $arFriendUsers[$friendId] = $friendId; } foreach ($arUserId as $id => $userId) { if ($userId == $this->user_id) { continue; } if (!isset($arFriendUsers[$userId]) && CIMSettings::GetPrivacy(CIMSettings::PRIVACY_CHAT, $userId) == CIMSettings::PRIVACY_RESULT_CONTACT) { unset($arUserId[$id]); } } if (count($arUserId) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_USER_ID_BY_PRIVACY"), "EMPTY_USER_ID_BY_PRIVACY"); return false; } } $strSql = "\n\t\t\tSELECT\n\t\t\t\tR.CHAT_ID, C.TITLE CHAT_TITLE, C.AUTHOR_ID CHAT_AUTHOR_ID, C.EXTRANET CHAT_EXTRANET, C.TYPE CHAT_TYPE\n\t\t\tFROM b_im_relation R\n\t\t\tLEFT JOIN b_im_chat C ON R.CHAT_ID = C.ID\n\t\t\tWHERE\n\t\t\t\t" . ($this->user_id > 0 ? "R.USER_ID = " . $this->user_id . " AND " : "") . "\n\t\t\t\tR.MESSAGE_TYPE IN ('" . IM_MESSAGE_OPEN . "','" . IM_MESSAGE_CHAT . "')\n\t\t\t\tAND R.CHAT_ID = " . $chatId . "\n\t\t"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { $extranetFlag = $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false); $chatTitle = $arRes['CHAT_TITLE']; $chatAuthorId = intval($arRes['CHAT_AUTHOR_ID']); $chatType = intval($arRes['CHAT_TYPE']); $arRelation = self::GetRelationById($chatId); $arExistUser = array(); foreach ($arRelation as $relation) { $arExistUser[] = $relation['USER_ID']; } if (count($arRelation) + count($arUserId) > 500) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_MAX_USER", array('#COUNT#' => 500)), "MAX_USER"); return false; } $arUserId = array_diff($arUserId, $arExistUser); if (empty($arUserId)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_NOTHING_TO_ADD"), "NOTHING_TO_ADD"); return false; } $arUserSelect = $arUserId; if ($this->user_id > 0) { $arUserSelect[] = $this->user_id; } $arUsers = CIMContactList::GetUserData(array('ID' => array_values($arUserSelect), 'DEPARTMENT' => 'N', 'USE_CACHE' => 'N')); $arUsers = $arUsers['users']; if ($extranetFlag !== true) { $isExtranet = false; foreach ($arUsers as $userData) { if ($userData['extranet']) { $isExtranet = true; break; } } if ($isExtranet || $extranetFlag === "") { IM\ChatTable::update($chatId, array('EXTRANET' => $isExtranet ? "Y" : "N")); } $extranetFlag = $isExtranet; } $arUsersName = array(); foreach ($arUserId as $userId) { $arUsersName[] = htmlspecialcharsback($arUsers[$userId]['name']); } if ($this->user_id > 0) { $message = GetMessage("IM_CHAT_JOIN_" . $arUsers[$this->user_id]['gender'], array('#USER_1_NAME#' => htmlspecialcharsback($arUsers[$this->user_id]['name']), '#USER_2_NAME#' => implode(', ', $arUsersName))); } else { if (count($arUsersName) > 1) { $message = GetMessage("IM_CHAT_SELF_JOIN", array('#USERS_NAME#' => implode(', ', $arUsersName))); } else { $arUserList = array_values($arUserId); $message = GetMessage("IM_CHAT_SELF_JOIN_" . $arUsers[$arUserList[0]]['gender'], array('#USER_NAME#' => implode(', ', $arUsersName))); } } $fileMaxId = CIMDisk::GetMaxFileId($chatId); $maxId = 0; $strSql = "SELECT MAX(ID) ID FROM b_im_message WHERE CHAT_ID = " . $chatId . " GROUP BY CHAT_ID"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arMax = $dbRes->Fetch()) { $maxId = $arMax['ID']; } $update = array(); $publicPullWatch = false; if ($chatType == IM_MESSAGE_OPEN && CModule::IncludeModule("pull")) { $publicPullWatch = true; } foreach ($arUserId as $userId) { if ($publicPullWatch) { CPullWatch::Delete($userId, 'IM_PUBLIC_' . $chatId); } CIMContactList::SetRecent(array('ENTITY_ID' => $chatId, 'MESSAGE_ID' => $maxId, 'CHAT_TYPE' => $arRes['CHAT_TYPE'], 'USER_ID' => $userId)); $hideHistory = CIMSettings::GetStartChatMessage() == CIMSettings::START_MESSAGE_LAST && $arRes['CHAT_TYPE'] == IM_MESSAGE_CHAT; if ($arRes['CHAT_TYPE'] != IM_MESSAGE_PRIVATE && $arUsers[$userId]['extranet']) { $hideHistory = true; } $orm = IM\RelationTable::add(array("CHAT_ID" => $chatId, "MESSAGE_TYPE" => $arRes['CHAT_TYPE'], "USER_ID" => $userId, "START_ID" => $hideHistory ? $maxId + 1 : 0, "LAST_ID" => $maxId, "LAST_SEND_ID" => $maxId, "LAST_FILE_ID" => $hideHistory ? $fileMaxId : 0)); $update[] = $orm->getId(); CIMContactList::CleanChatCache($userId); } CIMDisk::ChangeFolderMembers($chatId, $arUserId); if (CModule::IncludeModule("pull")) { foreach ($arRelation as $ar) { CPullStack::AddByUser($ar['USER_ID'], array('module_id' => 'im', 'command' => 'chatUserAdd', 'params' => array('chatId' => $chatId, 'chatTitle' => $chatTitle, 'chatOwner' => $chatAuthorId, 'chatExtranet' => $extranetFlag, 'users' => $arUsers, 'newUsers' => $arUserId))); } } $lastId = self::AddMessage(array("TO_CHAT_ID" => $chatId, "MESSAGE" => $message, "FROM_USER_ID" => $this->user_id, "SYSTEM" => 'Y')); if (IsModuleInstalled('replica')) { if ($lastId && CIMSettings::GetStartChatMessage() == CIMSettings::START_MESSAGE_LAST && $arRes['CHAT_TYPE'] == IM_MESSAGE_CHAT) { foreach ($update as $relId) { IM\RelationTable::update($relId, array('START_ID' => $lastId)); } } } return true; } $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_AUTHORIZE_ERROR"), "AUTHORIZE_ERROR"); return false; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arComponentProps = CComponentUtil::GetComponentProps("bitrix:socialnetwork.log.ex", $arCurrentValues); $arEntityType = array("" => GetMessage("GD_LOG_P_ENTITY_TYPE_VALUE_ALL"), SONET_ENTITY_USER => GetMessage("GD_LOG_P_ENTITY_TYPE_VALUE_USER"), SONET_ENTITY_GROUP => GetMessage("GD_LOG_P_ENTITY_TYPE_VALUE_GROUP")); $arEventID = array("" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_ALL"), "system" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_SYSTEM"), "system_groups" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_SYSTEM_GROUPS"), "forum" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_FORUM"), "blog" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_BLOG"), "photo" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_PHOTO"), "calendar" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_CALENDAR"), "files" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_FILES"), "tasks" => GetMessage("GD_LOG_P_EVENT_ID_VALUE_TASKS")); if (CModule::IncludeModule("socialnetwork") && CSocNetUser::IsFriendsAllowed()) { $arEventID["system_friends"] = GetMessage("GD_LOG_P_EVENT_ID_VALUE_SYSTEM_FRIENDS"); } $arParameters = array("PARAMETERS" => array("USER_VAR" => $arComponentProps["PARAMETERS"]["USER_VAR"], "GROUP_VAR" => $arComponentProps["PARAMETERS"]["GROUP_VAR"], "PAGE_VAR" => $arComponentProps["PARAMETERS"]["PAGE_VAR"], "PATH_TO_USER" => $arComponentProps["PARAMETERS"]["PATH_TO_USER"], "PATH_TO_GROUP" => $arComponentProps["PARAMETERS"]["PATH_TO_GROUP"], "LIST_URL" => array("NAME" => GetMessage("GD_LOG_P_URL"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "/company/personal/log/")), "USER_PARAMETERS" => array("LOG_CNT" => array("NAME" => GetMessage("GD_LOG_P_LOG_CNT"), "TYPE" => "STRING", "DEFAULT" => "7"), "ENTITY_TYPE" => array("NAME" => GetMessage("GD_LOG_P_ENTITY_TYPE"), "TYPE" => "LIST", "VALUES" => $arEntityType, "MULTIPLE" => "N", "DEFAULT" => ""), "EVENT_ID" => array("NAME" => GetMessage("GD_LOG_P_EVENT_ID"), "TYPE" => "LIST", "VALUES" => $arEventID, "MULTIPLE" => "Y", "DEFAULT" => ""), "AVATAR_SIZE" => array("NAME" => GetMessage("GD_LOG_AVATAR_SIZE"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 3), "AVATAR_SIZE_COMMENT" => array("NAME" => GetMessage("GD_LOG_AVATAR_SIZE_COMMENT"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 3))); $arParameters["PARAMETERS"]["USER_VAR"]["DEFAULT"] = "user_id"; $arParameters["PARAMETERS"]["GROUP_VAR"]["DEFAULT"] = "group_id"; $arParameters["PARAMETERS"]["PAGE_VAR"]["DEFAULT"] = "page"; $arParameters["PARAMETERS"]["PATH_TO_USER"]["DEFAULT"] = "/company/personal/user/#user_id#/"; $arParameters["PARAMETERS"]["PATH_TO_GROUP"]["DEFAULT"] = "/workgroups/group/#group_id#/";
$cache->EndDataCache($arCacheData); } } $arResult["arUser"]["urlToPostImportant"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_IMPORTANT"], array("user_id" => $arPost["AUTHOR_ID"])); $arResult["CanComment"] = $GLOBALS["USER"]->IsAuthorized(); $arResult["dest_users"] = array(); foreach ($arResult["Post"]["SPERM"] as $key => $value) { foreach ($value as $kk => $vv) { $arResult["PostSrc"]["SPERM"][$key][] = $kk; if ($key == "U") { $arResult["dest_users"][] = $kk; } } } $arResult["PostSrc"]["HAVE_ALL_IN_ADR"] = $arResult["Post"]["HAVE_ALL_IN_ADR"]; if ($arParams["CHECK_PERMISSIONS_DEST"] == "N" && !CSocNetUser::IsCurrentUserModuleAdmin() && is_object($GLOBALS["USER"])) { $arResult["Post"]["SPERM_HIDDEN"] = 0; $arGroupID = CSocNetLogTools::GetAvailableGroups($arResult["bExtranetUser"] ? "Y" : "N", $arResult["bExtranetSite"] ? "Y" : "N"); if (!$arResult["bExtranetUser"] && CModule::IncludeModule("extranet")) { $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsersSimple(CExtranet::GetExtranetSiteID()); } foreach ($arResult["Post"]["SPERM"] as $group_code => $arBlogSPerm) { foreach ($arBlogSPerm as $entity_id => $arBlogSPermDesc) { if ($group_code == "SG" && !in_array($entity_id, $arGroupID) || $group_code == "DR" && $arResult["bExtranetUser"] || $group_code == "U" && isset($arUserIdVisible) && is_array($arUserIdVisible) && !in_array($entity_id, $arUserIdVisible) || $group_code == "U" && isset($arBlogSPermDesc["IS_EXTRANET"]) && $arBlogSPermDesc["IS_EXTRANET"] == "Y" && isset($arAvailableExtranetUserID) && is_array($arAvailableExtranetUserID) && !in_array($entity_id, $arAvailableExtranetUserID)) { unset($arResult["Post"]["SPERM"][$group_code][$entity_id]); $arResult["Post"]["SPERM_HIDDEN"]++; $arResult["PostSrc"]["SPERM_HIDDEN"][] = $group_code . $entity_id; } } } }
function GetUsersBlogs($params, $arPath) { global $USER; $blog = CBlogMetaWeblog::DecodeParams($params[0]["#"]["value"][0]["#"]); $user = CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]); $password = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]); if (CBlogMetaWeblog::Authorize($user, $password)) { $result = ''; $userId = $USER->GetID(); $dbBlog = CBlog::GetList(array(), array("OWNER_ID" => $userId, "GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y"), false, false, array("ID", "URL", "NAME", "OWNER_ID")); while ($arBlog = $dbBlog->GetNext()) { if (strlen($arPath["PATH_TO_BLOG"]) > 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", ""); } if (strlen($serverName) <= 0) { $serverName = $_SERVER["SERVER_NAME"]; } $path2Blog = "http://" . $serverName . CComponentEngine::MakePathFromTemplate($arPath["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"])); } else { $path2Blog = $arBlog["URL"]; } $result .= ' <value> <struct> <member> <name>url</name> <value>' . $path2Blog . '</value> </member> <member> <name>blogid</name> <value>' . $arBlog["ID"] . '</value> </member> <member> <name>blogName</name> <value>' . $arBlog["NAME"] . '</value> </member> </struct> </value> '; } if (CModule::IncludeModule("socialnetwork")) { $arGroupFilter = array("USER_ID" => $userId, "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => SITE_ID, "GROUP_ACTIVE" => "Y"); $dbGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arGroupFilter, false, false, array("ID", "GROUP_ID", "GROUP_OWNER_ID", "GROUP_NAME", "GROUP_SITE_ID")); while ($arGroups = $dbGroups->GetNext()) { $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroups["GROUP_ID"], "blog", "write_post", CSocNetUser::IsCurrentUserModuleAdmin($arGroups["GROUP_SITE_ID"]))) { $perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroups["GROUP_ID"], "blog", "full_post")) { $perms = BLOG_PERMS_FULL; } if ($perms >= BLOG_PERMS_WRITE) { $dbBlog = CBlog::GetList(array(), array("SOCNET_GROUP_ID" => $arGroups["GROUP_ID"], "GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y"), false, false, array("ID", "URL", "NAME")); if ($arBlog = $dbBlog->GetNext()) { $result .= ' <value> <struct> <member> <name>url</name> <value>' . $arBlog["URL"] . '</value> </member> <member> <name>blogid</name> <value>' . $arBlog["ID"] . '</value> </member> <member> <name>blogName</name> <value>' . $arBlog["NAME"] . '</value> </member> </struct> </value> '; } } } } if (strlen($result) > 0) { return '<params> <param> <value> <array> <data>' . $result . '</data> </array> </value> </param> </params>'; } else { return '<fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value><string>User hasn\'t blog.</string></value> </member> </struct> </value> </fault>'; } } else { return '<fault> <value> <struct> <member> <name>faultCode</name> <value><int>3</int></value> </member> <member> <name>faultString</name> <value><string>' . $arAuthResult["MESSAGE"] . '</string></value> </member> </struct> </value> </fault>'; } }
$arFieldsFilter = array(); if (array_key_exists("FILTER", $_POST) && is_array($_POST["FILTER"]) && Count($_POST["FILTER"]) > 0) { foreach ($_POST["FILTER"] as $key => $value) { if (array_key_exists($key, $arResult["TaskFields"]) && $arResult["TaskFields"][$key]["FILTERABLE"]) { if ($key == "TASKSTATUS") { if ($_POST["TASK_PROP_STATUS"] == "active") { $arFieldsFilter[$key] = "active"; } elseif ($_POST["TASK_PROP_STATUS"] == "selected") { $arFieldsFilter[$key] = $value; } } elseif ($arResult["TaskFields"][$key]["TYPE"] == "user") { if (array_key_exists("USER_TYPE_FILTER", $_POST) && is_array($_POST["USER_TYPE_FILTER"])) { if ($_POST["USER_TYPE_FILTER"][$key] == "current") { $arFieldsFilter[$key] = "current"; } elseif ($_POST["USER_TYPE_FILTER"][$key] == "selected") { $arFoundUsers = CSocNetUser::SearchUser($value, true); if ($arFoundUsers && is_array($arFoundUsers) && count($arFoundUsers) > 0) { foreach ($arFoundUsers as $userID => $userName) { $arFieldsFilter[$key] = IntVal($userID); break; } } } } } elseif ($arResult["TaskFields"][$key]["TYPE"] == "datetime") { if (array_key_exists("DATE_TYPE_FILTER", $_POST) && is_array($_POST["DATE_TYPE_FILTER"])) { if ($_POST["DATE_TYPE_FILTER"][$key] == "current") { $arFieldsFilter[$key] = "current"; } elseif ($_POST["DATE_TYPE_FILTER"][$key] == "selected") { $arFieldsFilter[$key] = $value; }