/** * Gets security context (access provider) for user. * Attention! File/Folder can use anywhere and SecurityContext have to check rights anywhere (any module). * @param mixed $user User which use for check rights. * @return SecurityContext */ public function getSecurityContextByUser($user) { if ($this->isCurrentUser($user)) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (Loader::includeModule('socialnetwork') && \CSocnetUser::isCurrentUserModuleAdmin()) { return new FakeSecurityContext($user); } if (UserModel::isCurrentUserAdmin()) { return new FakeSecurityContext($user); } } else { $userId = UserModel::resolveUserId($user); /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if ($userId && Loader::includeModule('socialnetwork') && \CSocnetUser::isUserModuleAdmin($userId)) { return new FakeSecurityContext($user); } try { if ($userId && ModuleManager::isModuleInstalled('bitrix24') && Loader::includeModule('bitrix24') && \CBitrix24::isPortalAdmin($userId)) { return new FakeSecurityContext($user); } elseif ($userId) { //Check user group 1 ('Admins') $tmpUser = new \CUser(); $arGroups = $tmpUser->getUserGroup($userId); if (in_array(1, $arGroups)) { return new FakeSecurityContext($user); } } } catch (\Exception $e) { } } return new DiskSecurityContext($user); }
protected function getSecurityContextByUser($user) { $diskSecurityContext = new DiskSecurityContext($user); if (Loader::includeModule('socialnetwork')) { if (\CSocnetUser::isCurrentUserModuleAdmin()) { $diskSecurityContext = new FakeSecurityContext($user); } } if (User::isCurrentUserAdmin()) { $diskSecurityContext = new FakeSecurityContext($user); } return $diskSecurityContext; }
/** * Gets security context (access provider) for user. * Attention! File/Folder can use anywhere and SecurityContext have to check rights anywhere (any module). * @param mixed $user User which use for check rights. * @return SecurityContext */ public function getSecurityContextByUser($user) { if ($this->isCurrentUser($user)) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (Loader::includeModule('socialnetwork') && \CSocnetUser::isCurrentUserModuleAdmin()) { return new FakeSecurityContext($user); } if (UserModel::isCurrentUserAdmin()) { return new FakeSecurityContext($user); } } return new DiskSecurityContext($user); }
private function getSecurityContextByUser($user) { $diskSecurityContext = new DiskSecurityContext($user); if (Loader::includeModule('socialnetwork')) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (\CSocnetUser::isCurrentUserModuleAdmin()) { $diskSecurityContext = new FakeSecurityContext($user); } } if (User::isCurrentUserAdmin()) { $diskSecurityContext = new FakeSecurityContext($user); } return $diskSecurityContext; }