Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sender/lib/access/install/ |
Upload File : |
<?php namespace Bitrix\Sender\Access\Install; use Bitrix\Sender\Access\Role\RoleTable; use Bitrix\Sender\Access\Role\RoleUtil; use Bitrix\Sender\Access\Service\RolePermissionService; class AccessInstaller { /** * Use for install agent and install data to DB * @return string */ public static function installAgent() { self::fillSystemPermissions(); return ''; } /** * fill data by presetted array */ private static function fillSystemPermissions() :void { $map = RoleUtil::preparedRoleMap(); $query = []; try { $oldRolesList = RoleTable::getList(['select' => ['ID', 'XML_ID']])->fetchAll(); $xmlIds = array_flip(array_column($oldRolesList, 'XML_ID')); foreach ($map as $roleKey => $permissions) { $roleName = RoleUtil::getLocalizedName($roleKey); $roleId = isset($xmlIds[$roleKey]) ? $oldRolesList[$xmlIds[$roleKey]]['ID'] : (new RolePermissionService())->saveRole($roleName); $query = array_merge($query, RoleUtil::buildInsertPermissionQuery($permissions, $roleId)); } RoleUtil::insertPermissions($query); } catch (\Exception $e) { } } }