- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_type.php
- Класс: CCalendarType
- Вызов: CCalendarType::GetOperations
static function GetOperations($xmlId, $userId = null)
{
global $USER;
if (!$userId)
{
$userId = CCalendar::GetCurUserId();
}
$opCacheKey = $xmlId.'_'.$userId;
if (isset(self::$userOperationsCache[$opCacheKey]) && is_array(self::$userOperationsCache[$opCacheKey]))
{
$result = self::$userOperationsCache[$opCacheKey];
}
else
{
$arCodes = [];
if ($userId)
{
$arCodes = Util::getUserAccessCodes($userId);
}
if(!in_array('G2', $arCodes, true))
{
$arCodes[] = 'G2';
}
if($userId && !in_array('AU', $arCodes, true) && (int)$USER->GetId() === (int)$userId)
{
$arCodes[] = 'AU';
}
if($userId && !in_array('UA', $arCodes, true) && (int)$USER->GetId() === (int)$userId)
{
$arCodes[] = 'UA';
}
$key = $xmlId.'|'.implode(',', $arCodes);
if(!isset(self::$arOp[$key]) || !is_array(self::$arOp[$key]))
{
if(!isset(self::$Permissions[$xmlId]))
{
self::GetArrayPermissions([$xmlId]);
}
$perms = self::$Permissions[$xmlId];
self::$arOp[$key] = [];
if(is_array($perms))
{
foreach($perms as $code => $taskId)
{
if (in_array($code, $arCodes, true))
{
self::$arOp[$key] = array_merge(self::$arOp[$key], CTask::GetOperations($taskId, true));
}
}
}
}
$result = self::$userOperationsCache[$opCacheKey] = self::$arOp[$key];
}
return $result;
}