Server IP : 85.193.89.191 / Your IP : 18.217.46.173 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/bitrix/components/bitrix/sender.config.role.edit/ |
Upload File : |
<?php define('STOP_STATISTICS', true); define('BX_SECURITY_SHOW_MESSAGE', true); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php'); use Bitrix\Main\Localization\Loc; use Bitrix\Sender\Access\AccessController; use Bitrix\Sender\Access\ActionDictionary; use Bitrix\Sender\Access\Service\RolePermissionService; use Bitrix\Sender\Security; use Bitrix\Sender\Security\User; if (!Bitrix\Main\Loader::includeModule('sender')) { return; } class ConfigRoleEditSenderAjaxController extends \Bitrix\Main\Engine\Controller { public function savePermissionsAction(array $userGroups, array $parameters) { if (!Security\Role\Manager::canUse()) { return; } if(!AccessController::can( User::current()->getId(), ActionDictionary::ACTION_SETTINGS_EDIT )) { return; } if (!is_array($userGroups) || empty($userGroups) || !check_bitrix_sessid()) { return; } try { $permissionService = new RolePermissionService(); $dealCategoryId = $parameters['dealCategoryId'] ?? 0; $permissionService ->saveRolePermissions($userGroups, $dealCategoryId); (new \Bitrix\Sender\Access\Service\RoleRelationService()) ->saveRoleRelation($userGroups); return [ 'USER_GROUPS' => $permissionService->getUserGroups($dealCategoryId), 'ACCESS_RIGHTS' => $permissionService->getAccessRights() ]; } catch (\Exception $e) { $this->errorCollection[] = new \Bitrix\Main\Error(Loc::getMessage('SENDER_CONFIG_PERMISSIONS_DB_ERROR')); } } public function deleteRoleAction(int $roleId) { if(!AccessController::can( User::current()->getId(), ActionDictionary::ACTION_SETTINGS_EDIT )) { return; } if (!is_int($roleId) || !check_bitrix_sessid()) { return; } try { (new RolePermissionService())->deleteRole($roleId); } catch (\Bitrix\Main\DB\SqlQueryException $e) { $this->errorCollection[] = new \Bitrix\Main\Error( Loc::getMessage('SENDER_CONFIG_ROLE_DELETE_DB_ERROR') ); } } /** * * @param array $parameters * * @return array */ public function loadAction(array $parameters) { $dealCategoryId = $parameters['dealCategoryId'] ?? 0; $permissionService = new RolePermissionService(); return [ 'USER_GROUPS' => $permissionService->getUserGroups($dealCategoryId), 'ACCESS_RIGHTS' => $permissionService->getAccessRights() ]; } }