Current Path : /home/bitrix/ext_www/community.yacl.site/ |
Current File : /home/bitrix/ext_www/community.yacl.site/dzo_update_juri.php |
<? define("NOT_CHECK_PERMISSIONS", true); if (!$_SERVER["DOCUMENT_ROOT"]) { $_SERVER["DOCUMENT_ROOT"] = realpath(__DIR__); } else { die ('Script for console only'); } require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); require_once $_SERVER["DOCUMENT_ROOT"] . '/local/composer/vendor/autoload.php'; use Bitrix\Main\Type\DateTime; use Bitrix\Main\Loader; use Bitrix\Highloadblock\HighloadBlockTable as HLBT; use Bitrix\Disk\Security\DiskSecurityContext; use Bitrix\Disk\Security\SecurityContext; use Bitrix\Disk\Storage; use Bitrix\Main\Localization\Loc; Loader::includeModule('tasks'); Loader::includeModule('iblock'); $juriAllDepartments = [ 287, 288, 290 ]; $juriSectionMapping = [ 770 => 489, 884 => 502, 857 => 482, 973 => 482, 947 => 500, 961 => 482, ]; $userList = \Bitrix\Main\UserTable::getList([ 'filter' => ['ACTIVE' => 'Y', 'UF_DEPARTMENT' => array_keys($juriSectionMapping)], 'select' => ['ID', 'UF_DEPARTMENT'] ])->fetchAll(); foreach ($userList as $userInfo) { okp($userInfo); $departments = $userInfo['UF_DEPARTMENT']; foreach ($juriSectionMapping as $currentDepartment => $newDepartment) { if (in_array($currentDepartment, $departments)) { $departments[] = $newDepartment; } } $departments = array_merge($departments, $juriAllDepartments); okp($departments); // $USER->Update($userInfo['ID'], ['UF_DEPARTMENT' => $departments]); }