- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
- Класс: CEventCalendar
- Вызов: CEventCalendar::GetPermissions
function GetPermissions($arParams = array())
{
global $USER;
$iblockId = isset($arParams['iblockId']) ? $arParams['iblockId'] : $this->iblockId;
$bOwner = isset($arParams['bOwner']) ? $arParams['bOwner'] : $this->bOwner;
$ownerId = isset($arParams['ownerId']) ? $arParams['ownerId'] : $this->ownerId;
$ownerType = isset($arParams['ownerType']) ? $arParams['ownerType'] : $this->ownerType;
$bCurUser = !isset($arParams['userId']) || $arParams['userId'] == $GLOBALS['USER']->GetID();
$userId = $bCurUser ? $GLOBALS['USER']->GetID() : intval($arParams['userId']);
$bCheckSocNet = !isset($arParams['bCheckSocNet']) || $arParams['bCheckSocNet'] !== false;
if ($bCurUser)
{
$maxPerm = CIBlock::GetPermission($iblockId);
}
else
{
$arGroups = CUser::GetUserGroup($userId);
$arGroupPerm = CIBlock::GetGroupPermissions($iblockId);
$maxPerm = 'D';
foreach($arGroupPerm as $k => $perm)
if (in_array($k, $arGroups) && $perm > $maxPerm)
$maxPerm = $perm;
}
$bAccess = $maxPerm >= 'R';
$bCurUserOwner = $ownerType != 'USER' || $this->ownerId == $userId;
$bReadOnly = $bAccess && $maxPerm < 'W';
// $maxPerm :
// D - denied
// R - check SocNet permissions (if it's socnet)
// >W - turn on GOD-mode
/* modified by wladart */
// to re-calc readonly even if it's not readonly by iblock settings, for all users
//if ($bCheckSocNet && class_exists('CSocNetFeatures'))
if ($bCheckSocNet && $bOwner && class_exists('CSocNetFeatures')) // Check permissions for SocNet
{
$SONET_ENT = $ownerType == 'USER' ? SONET_ENTITY_USER : SONET_ENTITY_GROUP;
if (!CSocNetFeatures::IsActiveFeature($SONET_ENT, $ownerId, "calendar"))
{
$bAccess = false;
$bReadOnly = true;
}
else
{
$bAccess = CSocNetFeaturesPerms::CanPerformOperation($userId, $SONET_ENT, $ownerId, "calendar", 'view');
$bReadOnly = !CSocNetFeaturesPerms::CanPerformOperation($userId, $SONET_ENT, $ownerId, "calendar", 'write');
}
}
if (!$bCurUserOwner)
$bReadOnly = true;
if ($arParams['setProperties'] !== false)
{
$this->bAccess = $bAccess;
$this->bReadOnly = $bReadOnly;
$this->bCurUser = $bCurUser;
$this->userId = $userId;
$this->userName = $USER->IsAuthorized() ? $USER->GetFirstName()." ".$USER->GetLastName() : 'Unknown user';
$this->bCurUserOwner = $bCurUserOwner;
}
return array('bAccess' => $bAccess, 'bReadOnly' => $bReadOnly);
}