- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
- Класс: CCalendar
- Вызов: CCalendar::GetPermissions
static function GetPermissions($Params = [])
{
global $USER;
$type = $Params['type'] ?? self::$type;
$ownerId = (int)($Params['ownerId'] ?? self::$ownerId);
$userId = (int)($Params['userId'] ?? self::$userId);
$bView = true;
$bEdit = true;
$bEditSection = true;
$accessController = new TypeAccessController($userId);
$typeModel = TypeModel::createFromXmlId($type);
$request = [
ActionDictionary::ACTION_TYPE_VIEW => [],
ActionDictionary::ACTION_TYPE_EDIT => [],
];
$result = $accessController->batchCheck($request, $typeModel);
if ($type === 'user' && (int)$ownerId !== (int)$userId)
{
$bEdit = false;
$bEditSection = false;
}
else
{
$bView = $result[ActionDictionary::ACTION_TYPE_VIEW];
$bEdit = $result[ActionDictionary::ACTION_TYPE_EDIT];
$bEditSection = $result[ActionDictionary::ACTION_TYPE_EDIT];
}
if (($type === 'group') && !$USER->CanDoOperation('edit_php'))
{
$keyOwner = 'SG'.$ownerId.'_A';
$keyMod = 'SG'.$ownerId.'_E';
$keyMember = 'SG'.$ownerId.'_K';
$codes = Util::getUserAccessCodes($userId);
if (Loader::includeModule("socialnetwork"))
{
$group = CSocNetGroup::getByID($ownerId);
if(!empty($group['CLOSED']) && $group['CLOSED'] === 'Y' &&
BitrixMainConfigOption::get('socialnetwork', 'work_with_closed_groups', 'N') === 'N')
{
self::$isArchivedGroup = true;
}
}
if (in_array($keyOwner, $codes, true))// Is owner
{
$bEdit = true;
$bEditSection = true;
}
elseif(!self::$isArchivedGroup && in_array($keyMod, $codes, true))// Is moderator
{
$bEdit = true;
$bEditSection = true;
}
elseif(!self::$isArchivedGroup && in_array($keyMember, $codes, true))// Is member
{
$bEdit = true;
$bEditSection = false;
}
else
{
$bEdit = false;
$bEditSection = false;
}
}
if (($Params['setProperties'] ?? '') !== false)
{
self::$perm['view'] = $bView;
self::$perm['edit'] = $bEdit;
self::$perm['section_edit'] = $bEditSection;
}
return array(
'view' => $bView,
'edit' => $bEdit,
'section_edit' => $bEditSection,
);
}