17 if(!Loader::includeModule(
"lists"))
20 $className = get_class($this);
21 $option = Option::get(
"lists", $className, 0);
22 $result[
"steps"] = $option;
25 $result[
"steps"] = (int)($result[
"steps"] ?? 0);
27 $queryObject = PropertyTable::getList(array(
28 "select" => array(
"ID",
"IBLOCK_ID",
"USER_TYPE_SETTINGS"),
29 "filter" => array(
"=USER_TYPE" =>
"ECrm")
31 $listIblockId = array();
32 $listPropertyId = array();
33 while($property = $queryObject->fetch())
35 if(is_string($property[
"USER_TYPE_SETTINGS"]) && CheckSerializedData($property[
"USER_TYPE_SETTINGS"]))
37 $property[
"USER_TYPE_SETTINGS"] = unserialize($property[
"USER_TYPE_SETTINGS"], [
'allowed_classes' =>
false]);
39 if(is_array($property[
"USER_TYPE_SETTINGS"]))
41 if(array_key_exists(
"VISIBLE", $property[
"USER_TYPE_SETTINGS"]))
42 unset($property[
"USER_TYPE_SETTINGS"][
"VISIBLE"]);
43 $tmpArray = array_filter($property[
"USER_TYPE_SETTINGS"],
function($mark) {
return $mark ==
"Y"; });
44 if(count($tmpArray) == 1)
46 $listIblockId[] = intval($property[
"IBLOCK_ID"]);
47 $listPropertyId[$property[
"IBLOCK_ID"]][] = intval($property[
"ID"]);
53 $listIblockIdS = implode(
",", $listIblockId);
54 if(empty($listIblockIdS))
59 $sqlString =
"SELECT ID, IBLOCK_ID FROM b_iblock_element WHERE IBLOCK_ID IN (".$listIblockIdS
60 .
") ORDER BY ID ASC LIMIT ".$limit.
" OFFSET ".$result[
"steps"];
61 $queryObject = $connection->query($sqlString);
62 $listElement = $queryObject->fetchAll();
63 $selectedRowsCount = $queryObject->getSelectedRowsCount();
64 $listElementData = array();
65 foreach($listElement as $element)
67 $listElementData[$element[
"IBLOCK_ID"]][] = $element[
"ID"];
70 foreach($listElementData as $iblockId => $listElementId)
72 $queryObject = \CIblockElement::getPropertyValues(
73 $iblockId, array(
"ID" => $listElementId),
false, array(
"ID" => $listPropertyId[$iblockId]));
74 while($propertyValues = $queryObject->fetch())
77 foreach($propertyValues as $propertyId => $propertyValue)
79 if($propertyId ==
"IBLOCK_ELEMENT_ID" || empty($propertyValue))
83 if(is_array($propertyValue))
85 $listPropertyValues = array();
86 foreach ($propertyValue as $value)
90 $explode = explode(
'_', $value);
91 $listPropertyValues[] = intval($explode[1]);
95 $propertyValue = $listPropertyValues;
99 if(!intval($propertyValue))
101 $explode = explode(
'_', $propertyValue);
102 $propertyValue = intval($explode[1]);
106 if($isDamaged && $propertyId)
108 \CIBlockElement::setPropertyValues(
109 $propertyValues[
"IBLOCK_ELEMENT_ID"], $iblockId, $propertyValue, $propertyId);
115 if($selectedRowsCount < $limit)
117 Option::delete(
"lists", array(
"name" => $className));
122 $result[
"steps"] = $result[
"steps"] + $selectedRowsCount;
123 $option = $result[
"steps"];
124 Option::set(
"lists", $className, $option);