22 private $changedFields = [];
23 private $changedFieldsForChildSections = [];
28 private $sectionCopier =
null;
37 $this->child[] = $child;
47 $this->sectionCopier = $sectionCopier;
52 $this->changedFields = array_merge($this->changedFields, $changedFields);
57 $this->changedFieldsForChildSections = array_merge(
58 $this->changedFieldsForChildSections, $changedFieldsForChildSections);
70 $sectionObject = new \CIBlockSection;
76 if ($sectionObject->LAST_ERROR)
78 $this->result->addError(
new Error($sectionObject->LAST_ERROR, self::SECTION_COPY_ERROR));
82 $this->result->addError(
new Error(
"Unknown error", self::SECTION_COPY_ERROR));
97 $queryObject = \CIBlockSection::getList([], [
"ID" =>
$entityId,
"CHECK_PERMISSIONS" =>
"N"],
false);
110 if (!empty($this->changedFields))
115 if (!empty(
$fields[
"PICTURE"]))
119 if (!empty(
$fields[
"DETAIL_PICTURE"]))
121 $fields[
"DETAIL_PICTURE"] = \CFile::makeFileArray(
$fields[
"DETAIL_PICTURE"]);
150 $results[] = $copyChildrenResult = $this->copyChildSections($sectionId, $copiedSectionId);
152 $copyResult = $copyChildrenResult->getData();
153 $sectionsRatio[$sectionId] = $this->getSectionsMapIds($copyResult);
154 $sectionsRatio[$sectionId] = $sectionsRatio[$sectionId] + [$sectionId => $copiedSectionId];
158 foreach ($this->child as $child)
160 if ($child instanceof ElementChild)
162 $child->setEnumRatio($enumRatio);
163 $child->setSectionsRatio($sectionsRatio);
166 $results[] = $child->copy($sectionId, $copiedSectionId);
168 if (method_exists($child,
"getEnumRatio"))
170 $enumRatio = $child->getEnumRatio();
177 private function copyChildSections(
int $sectionId,
int $copiedSectionId)
179 if (!$this->sectionCopier)
184 $this->cleanChangedFields();
188 $queryObject = \CIBlockSection::getList([], [
189 "SECTION_ID" => $sectionId,
"CHECK_PERMISSIONS" =>
"N"],
false, [
"ID"]);
190 while ($section = $queryObject->fetch())
192 $container =
new Container($section[
"ID"]);
193 $container->setParentId($copiedSectionId);
194 $containerCollection[] = $container;
197 if (!$containerCollection->isEmpty())
199 return $this->sectionCopier->copy($containerCollection);
210 if (
$key == get_class() && is_array($values))
212 $sectionMapIds = $sectionMapIds + $this->getSectionsMapIds($values);
216 $sectionMapIds[
$key] = $values;
219 return $sectionMapIds;
224 foreach ($this->changedFields as $fieldId => $fieldValue)
226 if (array_key_exists($fieldId,
$fields))
228 $fields[$fieldId] = $fieldValue;
232 foreach ($this->changedFieldsForChildSections as $fieldId => $fieldValue)
234 if (array_key_exists($fieldId,
$fields))
236 $fields[$fieldId] = $fieldValue;
243 private function cleanChangedFields()
245 $this->changedFields = [];
248 private function getRights(
int $iblockId,
int $elementId)
252 $objectRights = new \CIBlockSectionRights(
$iblockId, $elementId);
254 $groupCodeIgnoreList = $this->getGroupCodeIgnoreList(
$iblockId);
256 foreach ($objectRights->getRights() as
$right)
258 if (!in_array(
$right[
"GROUP_CODE"], $groupCodeIgnoreList))
261 "GROUP_CODE" =>
$right[
"GROUP_CODE"],
263 "TASK_ID" =>
$right[
"TASK_ID"],
273 $groupCodeIgnoreList = [];
275 $rightObject = new \CIBlockRights(
$iblockId);
276 foreach ($rightObject->getRights() as
$right)
278 $groupCodeIgnoreList[] =
$right[
"GROUP_CODE"];
281 return $groupCodeIgnoreList;
getResult(array $results=[])
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)