17 $stepResult = Stepper::FINISH_EXECUTION;
19 if (!\
Bitrix\Main\Loader::includeModule(
'disk'))
24 $storageId = (int)Option::get(
'im',
'disk_storage_id', 0);
30 $topFolder = \Bitrix\Disk\Internals\FolderTable::getRow([
33 '=STORAGE_ID' => $storageId,
34 '=TYPE' => \
Bitrix\Disk\Internals\FolderTable::TYPE_FOLDER,
35 '=CODE' =>
'CALL_BACKGROUND',
38 if (!$topFolder || (
int)$topFolder[
'ID'] <= 0)
42 $topFolderId = (int)$topFolder[
'ID'];
44 $stepVars = Option::get(self::$moduleId, self::OPTION_NAME,
'');
45 $stepVars = ($stepVars !==
"" ? @unserialize($stepVars, [
'allowed_classes' =>
false]) : []);
46 $stepVars = (is_array($stepVars) ? $stepVars : []);
49 '=STORAGE_ID' => $storageId,
50 '=TYPE' => \Bitrix\Disk\Internals\FolderTable::TYPE_FOLDER,
51 '=PARENT_ID' => $topFolderId,
52 'CODE' =>
'CALL_BACKGROUND_%',
60 'count' => (int)\
Bitrix\Disk\Internals\FolderTable::getCount($filter),
64 if ($stepVars[
'count'] > 0)
66 $option[
'progress'] = 1;
67 $option[
'steps'] =
'';
68 $option[
'count'] = $stepVars[
'count'];
70 $filter[
'>ID'] = $stepVars[
'lastId'];
72 $diskRightsManager = \Bitrix\Disk\Driver::getInstance()->getRightsManager();
73 $accessTaskFull = $diskRightsManager->getTaskIdByName(\
Bitrix\Disk\RightsManager::TASK_FULL);
75 $cursor = \Bitrix\Disk\Folder::getList([
76 'select' => [
'ID',
'CREATED_BY'],
78 'order' => [
'ID' =>
'ASC'],
79 'limit' => self::LIMIT,
82 foreach ($cursor as $row)
84 $folder = \Bitrix\Disk\Folder::loadById((
int)$row[
'ID']);
85 if ($folder instanceof \
Bitrix\Disk\Folder)
87 $diskRightsManager->append(
91 'ACCESS_CODE' =>
'U'. (
int)$row[
'CREATED_BY'],
92 'TASK_ID' => $accessTaskFull,
97 $stepVars[
'number'] ++;
98 $stepVars[
'lastId'] = (int)$row[
'ID'];
104 Option::set(self::$moduleId, self::OPTION_NAME, serialize($stepVars));
105 $stepResult = Stepper::CONTINUE_EXECUTION;
109 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);
112 $option[
'progress'] = round($stepVars[
'number'] * 100 / $stepVars[
'count']);
113 $option[
'steps'] = $stepVars[
'number'];
115 elseif ($stepVars[
'count'] == 0)
117 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);