Your IP : 216.73.216.170
<?
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');
$offset = 3;
$dzoRootId = 499;
$entity = \Bitrix\Iblock\Model\Section::compileEntityByIblock(IBLOCK_DEPARTMENT);
$bs = new CIBlockSection;
$dzoRootSection = $entity::getList([
'filter' => ['ID' => $dzoRootId, 'ACTIVE' => 'Y'],
'select' => ['ID', 'NAME', 'LEFT_MARGIN', 'RIGHT_MARGIN']
])->fetch();
if (!$dzoRootSection) {
echo "Wrong DZO Root Section!\n";
die();
}
$dzoSections = $entity::getList([
'filter' => [
'ACTIVE' => 'Y',
'>=LEFT_MARGIN' => $dzoRootSection['LEFT_MARGIN'],
'<=RIGHT_MARGIN' => $dzoRootSection['RIGHT_MARGIN'],
'!UF_HEAD' => false,
],
'select' => ['ID', 'NAME', 'LEFT_MARGIN', 'RIGHT_MARGIN', 'UF_HEAD']
])->fetchAll();
foreach ($dzoSections as $section) {
$head = $section['UF_HEAD'];
$departments = getUserInfoById($head, ['UF_DEPARTMENT'])['UF_DEPARTMENT'];
if (!in_array($section['ID'], $departments)) {
$departments[] = $section['ID'];
$USER->Update($head, ['UF_DEPARTMENT' => $departments]);
break;
}
// okp($section);
}