public static function CheckCurrentUserGroups() { global $USER; $user_id = is_object($USER)? intval($USER->GetID()): 0; if($user_id > 0) { $arGroupCodes = array('AU', 'U'.$user_id); // Authorized foreach($USER->GetUserGroupArray() as $group_id) { $arGroupCodes[] = 'G'.$group_id; } foreach (GetModuleEvents("search", "OnSearchCheckPermissions", true) as $arEvent) { $arCodes = ExecuteModuleEventEx($arEvent, array(null)); if(is_array($arCodes)) { $arGroupCodes = array_merge($arGroupCodes, $arCodes); } } $ob = new CSearchUser($user_id); $ob->SetGroups($arGroupCodes); } }
function OnUserRelationsChange($user_id) { if (CModule::IncludeModule('search')) { CSearchUser::DeleteByUserID($user_id); } $provider = new CSocNetGroupAuthProvider(); $provider->DeleteByUser($user_id); $provider = new CSocNetUserAuthProvider(); $provider->DeleteByUser($user_id); }
function CheckCurrentUserGroups() { global $USER; $user_id = intval($USER->GetID()); if ($user_id > 0) { $ob = new CSearchUser($user_id); if (!$ob->IsGroupsExists()) { $arGroupCodes = array('AU', 'U' . $user_id); // Authorized foreach ($USER->GetUserGroupArray() as $group_id) { $arGroupCodes[] = 'G' . $group_id; } $events = GetModuleEvents("search", "OnSearchCheckPermissions"); while ($arEvent = $events->Fetch()) { $arCodes = ExecuteModuleEventEx($arEvent, array($FIELD)); if (is_array($arCodes)) { $arGroupCodes = array_merge($arGroupCodes, $arCodes); } } $ob->AddGroups($arGroupCodes); } } }
function OnUserRelationsChange($user_id) { if (CModule::IncludeModule('search')) { CSearchUser::DeleteByUserID($user_id); } $provider = new CSocNetGroupAuthProvider(); $provider->DeleteByUser($user_id); $provider = new CSocNetUserAuthProvider(); $provider->DeleteByUser($user_id); $dbFriend = CSocNetUserRelations::GetRelatedUsers($user_id, SONET_RELATIONS_FRIEND); while ($arFriend = $dbFriend->Fetch()) { $friendID = $user_id == $arFriend["FIRST_USER_ID"] ? $arFriend["SECOND_USER_ID"] : $arFriend["FIRST_USER_ID"]; $provider->DeleteByUser($friendID); } }
function CheckPermissions($FIELD = "sc.ID") { global $USER; $arResult = array(); if($USER->IsAdmin()) { $arResult[] = "1=1"; } else { if($USER->GetID() > 0) { CSearchUser::CheckCurrentUserGroups(); $arResult[] = " EXISTS ( SELECT 1 FROM b_search_content_right scg WHERE ".$FIELD." = scg.SEARCH_CONTENT_ID AND scg.GROUP_CODE IN ( SELECT GROUP_CODE FROM b_search_user_right WHERE USER_ID = ".$USER->GetID()." ) )"; } else { $arResult[] = " EXISTS ( SELECT 1 FROM b_search_content_right scg WHERE ".$FIELD." = scg.SEARCH_CONTENT_ID AND scg.GROUP_CODE = 'G2' )"; } } return "((".implode(") OR (", $arResult)."))"; }
function CheckPermissions() { global $USER; $DB = CDatabase::GetModuleConnection('search'); $arResult = array(); if(!$USER->IsAdmin()) { if($USER->GetID() > 0) { CSearchUser::CheckCurrentUserGroups(); $rs = $DB->Query("SELECT GROUP_CODE FROM b_search_user_right WHERE USER_ID = ".$USER->GetID()); while ($ar = $rs->Fetch()) $arResult[] = $ar["GROUP_CODE"]; } else { $arResult[] = "G2"; } } return $this->rights($arResult); }