- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/user_perms.php
- Класс: CAllSocNetUserPerms
- Вызов: CAllSocNetUserPerms::GetOperationPerms
static function GetOperationPerms($userID, $operation)
{
global $arSocNetUserOperations;
static $arCachedUserPerms;
if (
is_array($userID)
&& !$arCachedUserPerms
)
$arCachedUserPerms = array();
if (!is_array($userID))
{
$userID = intval($userID);
if ($userID <= 0)
return false;
}
$operation = mb_strtolower(Trim($operation));
if (!array_key_exists($operation, $arSocNetUserOperations))
return false;
$arUserPerms = array();
if (
!is_array($userID)
&& isset($GLOBALS["SONET_USER_PERMS_".$userID])
&& is_array($GLOBALS["SONET_USER_PERMS_".$userID])
&& !array_key_exists("SONET_USER_PERMS_".$userID, $_REQUEST)
)
$arUserPerms = $GLOBALS["SONET_USER_PERMS_".$userID];
elseif (
!is_array($userID)
&& isset($arCachedUserPerms[$userID])
&& is_array($arCachedUserPerms[$userID])
&& !array_key_exists("SONET_USER_PERMS_".$userID, $_REQUEST)
)
$arUserPerms = $arCachedUserPerms[$userID];
else
{
$dbResult = CSocNetUserPerms::GetList(Array(), Array("USER_ID" => $userID));
while ($arResult = $dbResult->Fetch())
{
if (!is_array($userID))
$arUserPerms[$arResult["OPERATION_ID"]] = $arResult["RELATION_TYPE"];
else
$arCachedUserPerms[$arResult["USER_ID"]][$arResult["OPERATION_ID"]] = $arResult["RELATION_TYPE"];
}
if (!is_array($userID))
$GLOBALS["SONET_USER_PERMS_".$userID] = $arUserPerms;
}
if (!is_array($userID))
{
$toUserOperationPerms = (
array_key_exists($operation, $arUserPerms)
? $arUserPerms[$operation]
: $arSocNetUserOperations[$operation]
);
if ($toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2)
{
$toUserOperationPerms = SONET_RELATIONS_TYPE_FRIENDS;
}
return $toUserOperationPerms;
}
else
{
foreach ($userID as $user_id_tmp)
if (!array_key_exists($user_id_tmp, $arCachedUserPerms))
$arCachedUserPerms[$user_id_tmp] = array();
return true;
}
}