28 private const PROPERTY_LINK_ELEMENT_MASK =
'/^([^.]+)\\.([^.]+)$/';
30 private const JOIN_TYPE_SELECT = 0x01;
31 private const JOIN_TYPE_WHERE = 0x02;
32 private const JOIN_TYPE_GROUP = 0x04;
33 private const JOIN_TYPE_ORDER = 0x08;
78 private static array $propertyIdentifierMasks = [
79 '/^[0-9]+([A-Z_]*)$/',
80 '/^[A-Z_][A-Z0-9_]*$/',
83 private static array $propertyLinkFieldIdentifierMasks = [
85 '/^PROPERTY_[0-9]+$/',
86 '/^PROPERTY_[A-Z_][A-Z0-9_]*$/',
97 $this->userExists = isset(
$USER) &&
$USER instanceof \CUser;
98 $this->userId = ($this->userExists ? (int)
$USER->GetID() : 0);
99 $this->isAdmin = $this->userExists &&
$USER->IsAdmin();
100 $this->iblock =
null;
101 $this->iblockLanguage =
null;
118 $language = static::getIblockLanguage(
$iblock[
'ID']);
122 $this->iblockLanguage = $language;
132 if(mb_substr(
$strField, 0, 9) ==
"PROPERTY_")
152 $db_prop = CIBlockProperty::GetPropertyArray(
154 CIBlock::_MergeIBArrays(
164 $ob->subQueryProp = $db_prop;
183 $this->bWF_SetMove =
false;
190 if($arElement = $rsElement->Fetch())
192 if($arElement[
"WF_PARENT_ELEMENT_ID"] <>
'')
194 $arElement[
"PROPERTY_VALUES"] =
array();
195 $rsProperties = $obElement->GetProperty($arElement[
"IBLOCK_ID"], $arElement[
"WF_PARENT_ELEMENT_ID"],
"sort",
"asc",
array(
"PROPERTY_TYPE"=>
"F"));
196 while($arProperty = $rsProperties->Fetch())
198 if(!array_key_exists($arProperty[
"ID"], $arElement[
"PROPERTY_VALUES"]))
200 $arElement[
"PROPERTY_VALUES"][$arProperty[
"ID"]] =
array();
202 $arElement[
"PROPERTY_VALUES"][$arProperty[
"ID"]][$arProperty[
"PROPERTY_VALUE_ID"]] =
array(
207 $rsProperties = $obElement->GetProperty($arElement[
"IBLOCK_ID"], $arElement[
"ID"]);
208 while($arProperty = $rsProperties->Fetch())
210 if(!array_key_exists($arProperty[
"ID"], $arElement[
"PROPERTY_VALUES"]))
212 $arElement[
"PROPERTY_VALUES"][$arProperty[
"ID"]] =
array();
214 if($arProperty[
"PROPERTY_TYPE"] ==
"F")
216 $arElement[
"PROPERTY_VALUES"][$arProperty[
"ID"]][
"n".$n] =
array(
217 "VALUE" => $arProperty[
"VALUE"],
218 "DESCRIPTION" => $arProperty[
"DESCRIPTION"],
224 $arElement[
"PROPERTY_VALUES"][$arProperty[
"ID"]][$arProperty[
"PROPERTY_VALUE_ID"]] =
array(
225 "VALUE" => $arProperty[
"VALUE"],
226 "DESCRIPTION" => $arProperty[
"DESCRIPTION"],
231 return $obElement->Update($arElement[
"WF_PARENT_ELEMENT_ID"], $arElement,
true);
242 if (CModule::IncludeModule(
"workflow"))
246 $HISTORY_DAYS = COption::GetOptionInt(
"workflow",
"HISTORY_DAYS", -1);
247 if($HISTORY_DAYS >= 0)
249 $arDate = localtime(time());
250 $date = mktime(0, 0, 0, $arDate[4]+1, $arDate[3]-$HISTORY_DAYS, 1900+$arDate[5]);
252 CTimeZone::Disable();
254 SELECT ID, WF_PARENT_ELEMENT_ID
255 FROM b_iblock_element
256 WHERE TIMESTAMP_X <= ".$DB->CharToDateFunction(ConvertTimeStamp($date,
"FULL")).
"
257 AND WF_PARENT_ELEMENT_ID is not null
260 $rsElements =
$DB->Query($strSql);
266 if($rsElements->Fetch())
268 while($arElement = $rsElements->Fetch())
271 if($LAST_ID != $arElement[
"ID"])
285 if(CModule::IncludeModule(
"workflow"))
289 $USER_ID = is_object(
$USER)? (int)
$USER->GetID(): 0;
291 $OLD_ID = (int)$OLD_ID;
292 $NEW_ID = (int)$NEW_ID;
296 $old =
$DB->Query(
"SELECT WF_STATUS_ID FROM b_iblock_element WHERE ID = ".$OLD_ID);
297 if($old_r=$old->Fetch())
300 $oldStatusId = (int)$old_r[
"WF_STATUS_ID"];
303 CTimeZone::Disable();
307 if($new_r=
$new->Fetch())
309 $NEW_STATUS_ID = (int)$new_r[
"WF_STATUS_ID"];
310 $OLD_STATUS_ID = $oldStatusId;
311 $PARENT_ID = (int)$new_r[
"WF_PARENT_ELEMENT_ID"];
313 CTimeZone::Disable();
317 if($parent_r = $parent->Fetch())
320 "TIMESTAMP_X" =>
$DB->GetNowFunction(),
321 "IBLOCK_ELEMENT_ID" => $PARENT_ID,
322 "OLD_STATUS_ID" => $OLD_STATUS_ID,
323 "STATUS_ID" => $NEW_STATUS_ID,
324 "USER_ID" => $USER_ID,
327 if($NEW_STATUS_ID != $OLD_STATUS_ID)
330 $strSql =
"SELECT EMAIL FROM b_user WHERE ID = ".(int)$parent_r[
"CREATED_BY"];
331 $rs =
$DB->Query($strSql);
333 $parent_r[
"CREATED_BY_EMAIL"] =
$ar[
"EMAIL"];
335 $parent_r[
"CREATED_BY_EMAIL"] =
"";
341 FROM b_user U, b_user_group UG
343 UG.GROUP_ID=".$WORKFLOW_ADMIN_GROUP_ID.
"
344 AND U.ID = UG.USER_ID
347 $rs =
$DB->Query($strSql);
351 $arAdmin[
$ar[
"ID"]] =
$ar[
"EMAIL"];
362 INNER JOIN b_user U on U.ID = WM.USER_ID
364 IBLOCK_ELEMENT_ID = ".$PARENT_ID.
"
365 AND OLD_STATUS_ID = ".$NEW_STATUS_ID.
"
367 $rs =
$DB->Query($strSql);
370 $arBCC[
$ar[
"EMAIL"]] =
$ar[
"EMAIL"];
381 INNER JOIN b_workflow_status2group SG on SG.STATUS_ID = S.ID
382 INNER JOIN b_iblock_group IG on IG.GROUP_ID = SG.GROUP_ID
383 INNER JOIN b_user_group UG on UG.GROUP_ID = IG.GROUP_ID
384 INNER JOIN b_user U on U.ID = UG.USER_ID
386 S.ID = ".$NEW_STATUS_ID.
"
388 AND IG.IBLOCK_ID = ".intval($new_r[
"IBLOCK_ID"]).
"
389 AND IG.PERMISSION >= 'U'
390 AND SG.PERMISSION_TYPE = '2'
393 $rs =
$DB->Query($strSql);
396 $arBCC[
$ar[
"EMAIL"]] =
$ar[
"EMAIL"];
405 INNER JOIN b_workflow_status2group SG on SG.STATUS_ID = S.ID
406 INNER JOIN b_user_group UG on UG.GROUP_ID = SG.GROUP_ID
407 INNER JOIN b_user U on U.ID = UG.USER_ID
409 S.ID = ".$NEW_STATUS_ID.
"
412 AND SG.PERMISSION_TYPE = '2'
415 $rs =
$DB->Query($strSql);
418 $arBCC[
$ar[
"EMAIL"]] =
$ar[
"EMAIL"];
421 $iblock_r = CIBlock::GetArrayByID($new_r[
"IBLOCK_ID"]);
422 $iblock_r[
"LID"] =
array();
423 $rsIBlockSite =
$DB->Query(
"SELECT SITE_ID FROM b_iblock_site WHERE IBLOCK_ID= ".(
int)$new_r[
"IBLOCK_ID"]);
424 while($arIBlockSite = $rsIBlockSite->Fetch())
425 $iblock_r[
"LID"][] = $arIBlockSite[
"SITE_ID"];
427 if(array_key_exists($new_r[
"MODIFIED_BY"], $arAdmin))
428 $new_r[
"USER_NAME"] .=
" (Admin)";
432 if(array_key_exists($parent_r[
"CREATED_BY"], $arAdmin))
433 $parent_r[
"CREATED_USER_NAME"] .=
" (Admin)";
436 $arEventFields =
array(
438 "IBLOCK_ID" => $new_r[
"IBLOCK_ID"],
439 "IBLOCK_TYPE" => $iblock_r[
"IBLOCK_TYPE_ID"],
440 "ADMIN_EMAIL" => implode(
",", $arAdmin),
441 "BCC" => implode(
",", $arBCC),
442 "PREV_STATUS_ID" => $OLD_STATUS_ID,
443 "PREV_STATUS_TITLE" => CIblockElement::WF_GetStatusTitle($OLD_STATUS_ID),
444 "STATUS_ID" => $NEW_STATUS_ID,
445 "STATUS_TITLE" => CIblockElement::WF_GetStatusTitle($NEW_STATUS_ID),
446 "DATE_CREATE" => $parent_r[
"DATE_CREATE"],
447 "CREATED_BY_ID" => $parent_r[
"CREATED_BY"],
448 "CREATED_BY_NAME" => $parent_r[
"CREATED_USER_NAME"],
449 "CREATED_BY_EMAIL" => $parent_r[
"CREATED_BY_EMAIL"],
450 "DATE_MODIFY" => $new_r[
"TIMESTAMP_X"],
451 "MODIFIED_BY_ID" => $new_r[
"MODIFIED_BY"],
452 "MODIFIED_BY_NAME" => $new_r[
"USER_NAME"],
453 "NAME" => $new_r[
"NAME"],
454 "SECTION_ID" => $new_r[
"IBLOCK_SECTION_ID"],
455 "PREVIEW_HTML" => ($new_r[
"PREVIEW_TEXT_TYPE"]==
"html" ?$new_r[
"PREVIEW_TEXT"]:TxtToHtml($new_r[
"PREVIEW_TEXT"])),
456 "PREVIEW_TEXT" => ($new_r[
"PREVIEW_TEXT_TYPE"]==
"text"? $new_r[
"PREVIEW_TEXT"]:HtmlToTxt($new_r[
"PREVIEW_TEXT"])),
457 "PREVIEW" => $new_r[
"PREVIEW_TEXT"],
458 "PREVIEW_TYPE" => $new_r[
"PREVIEW_TEXT_TYPE"],
459 "DETAIL_HTML" => ($new_r[
"DETAIL_TEXT_TYPE"]==
"html" ?$new_r[
"DETAIL_TEXT"]:TxtToHtml($new_r[
"DETAIL_TEXT"])),
460 "DETAIL_TEXT" => ($new_r[
"DETAIL_TEXT_TYPE"]==
"text"? $new_r[
"DETAIL_TEXT"]:HtmlToTxt($new_r[
"DETAIL_TEXT"])),
461 "DETAIL" => $new_r[
"DETAIL_TEXT"],
462 "DETAIL_TYPE" => $new_r[
"DETAIL_TEXT_TYPE"],
463 "COMMENTS" => $new_r[
"WF_COMMENTS"]
465 CEvent::Send(
"WF_IBLOCK_STATUS_CHANGE", $iblock_r[
"LID"], $arEventFields);
471 $arEventFields =
array(
473 "IBLOCK_ID" => $new_r[
"IBLOCK_ID"],
474 "IBLOCK_TYPE" => $iblock_r[
"IBLOCK_TYPE_ID"],
475 "ADMIN_EMAIL" => implode(
",", $arAdmin),
476 "BCC" => implode(
",", $arBCC),
477 "STATUS_ID" => $NEW_STATUS_ID,
478 "STATUS_TITLE" => CIblockElement::WF_GetStatusTitle($NEW_STATUS_ID),
479 "DATE_CREATE" => $parent_r[
"DATE_CREATE"],
480 "CREATED_BY_ID" => $parent_r[
"CREATED_BY"],
481 "CREATED_BY_NAME" => $parent_r[
"CREATED_USER_NAME"],
482 "CREATED_BY_EMAIL" => $parent_r[
"CREATED_BY_EMAIL"],
483 "NAME" => $new_r[
"NAME"],
484 "PREVIEW_HTML" => ($new_r[
"PREVIEW_TEXT_TYPE"]==
"html" ?$new_r[
"PREVIEW_TEXT"]:TxtToHtml($new_r[
"PREVIEW_TEXT"])),
485 "PREVIEW_TEXT" => ($new_r[
"PREVIEW_TEXT_TYPE"]==
"text"? $new_r[
"PREVIEW_TEXT"]:HtmlToTxt($new_r[
"PREVIEW_TEXT"])),
486 "PREVIEW" => $new_r[
"PREVIEW_TEXT"],
487 "PREVIEW_TYPE" => $new_r[
"PREVIEW_TEXT_TYPE"],
488 "SECTION_ID" => $new_r[
"IBLOCK_SECTION_ID"],
489 "DETAIL_HTML" => ($new_r[
"DETAIL_TEXT_TYPE"]==
"html" ?$new_r[
"DETAIL_TEXT"]:TxtToHtml($new_r[
"DETAIL_TEXT"])),
490 "DETAIL_TEXT" => ($new_r[
"DETAIL_TEXT_TYPE"]==
"text"? $new_r[
"DETAIL_TEXT"]:HtmlToTxt($new_r[
"DETAIL_TEXT"])),
491 "DETAIL" => $new_r[
"DETAIL_TEXT"],
492 "DETAIL_TYPE" => $new_r[
"DETAIL_TEXT_TYPE"],
493 "COMMENTS" => $new_r[
"WF_COMMENTS"]
495 CEvent::Send(
"WF_NEW_IBLOCK_ELEMENT",$iblock_r[
"LID"], $arEventFields);
508 if(CModule::IncludeModule(
"workflow"))
511 if($HISTORY_COPIES===
false)
512 $HISTORY_COPIES = intval(COption::GetOptionString(
"workflow",
"HISTORY_COPIES",
"10"));
515 $ELEMENT_ID = (int)$ELEMENT_ID;
517 $strSqlSearch =
" AND ID = $ELEMENT_ID ";
518 $strSql =
"SELECT ID FROM b_iblock_element ".
519 "WHERE (ID=WF_PARENT_ELEMENT_ID or (WF_PARENT_ELEMENT_ID IS NULL AND WF_STATUS_ID=1)) ".
521 $z =
$DB->Query($strSql);
522 while (
$zr=
$z->Fetch())
526 "SELECT ID, WF_NEW, WF_PARENT_ELEMENT_ID ".
527 "FROM b_iblock_element ".
528 "WHERE WF_PARENT_ELEMENT_ID = ".$DID.
" ".
529 " AND WF_PARENT_ELEMENT_ID<>ID ".
530 " AND (WF_NEW<>'Y' or WF_NEW is null) ".
532 $t =
$DB->Query($strSql);
534 while ($tr = $t->Fetch())
537 if(
$i>$HISTORY_COPIES)
540 if($LAST_ID!=$tr[
"ID"])
552 if(CModule::IncludeModule(
"workflow"))
554 $limit =
" and ((".$PS.
"WF_STATUS_ID=1 and ".$PS.
"WF_PARENT_ELEMENT_ID is null)";
555 if($SHOW_NEW==
"Y") $limit .=
" or ".$PS.
"WF_NEW='Y' ";
560 $limit =
" AND ".$PS.
"WF_STATUS_ID=1 and ".$PS.
"WF_PARENT_ELEMENT_ID is null ";
573 $z =
$DB->Query(
"SELECT ID, WF_PARENT_ELEMENT_ID FROM b_iblock_element WHERE ID = ".
$ID);
575 $WF_PARENT_ELEMENT_ID = (int)
$zr[
"WF_PARENT_ELEMENT_ID"];
576 if ($WF_PARENT_ELEMENT_ID > 0)
578 $strSql =
"SELECT ID FROM b_iblock_element WHERE WF_PARENT_ELEMENT_ID='".$WF_PARENT_ELEMENT_ID.
"' ORDER BY ID desc";
579 $s =
$DB->Query($strSql);
581 if ($sr && $sr[
"ID"] > 0)
588 $strSql =
"SELECT ID, WF_STATUS_ID FROM b_iblock_element WHERE WF_PARENT_ELEMENT_ID='$ID' ORDER BY ID desc";
589 $s =
$DB->Query($strSql);
591 if ($sr && $sr[
'WF_STATUS_ID'] > 1 && $sr[
"ID"] > 0)
613 $z =
$DB->Query(
"SELECT WF_PARENT_ELEMENT_ID FROM b_iblock_element WHERE ID='$ID'");
618 $PARENT_ID = (int)
$zr[
"WF_PARENT_ELEMENT_ID"];
622 return ($PARENT_ID > 0 ? $PARENT_ID :
$ID);
632 if(CModule::IncludeModule(
"workflow"))
634 $STATUS_ID = (int)$STATUS_ID;
637 $strSql =
"SELECT * FROM b_workflow_status WHERE ID='$STATUS_ID'";
638 $z =
$DB->Query($strSql);
650 if(CModule::IncludeModule(
"workflow"))
652 $ELEMENT_ID = (int)$ELEMENT_ID;
656 $WF_ID = $ELEMENT_ID;
661 "SELECT E.WF_STATUS_ID, S.TITLE ".
662 "FROM b_iblock_element E, b_workflow_status S ".
663 "WHERE E.ID = ".$WF_ID.
" ".
664 " AND S.ID = E.WF_STATUS_ID";
665 $z =
$DB->Query($strSql);
667 $STATUS_ID =
$zr[
"WF_STATUS_ID"];
668 $STATUS_TITLE =
$zr[
"TITLE"];
671 return (
int)$STATUS_ID;
681 if(CModule::IncludeModule(
"workflow"))
691 $arSql = Array(
"ID='".
$ID.
"'",
"WF_PARENT_ELEMENT_ID='".$ID.
"'");
692 foreach($arSql as $where)
694 $strSql =
"SELECT ID, WF_STATUS_ID FROM b_iblock_element WHERE ".$where;
695 $rs =
$DB->Query($strSql);
697 $arStatus[
$ar[
"WF_STATUS_ID"]] =
$ar[
"WF_STATUS_ID"];
702 $arStatus =
array((
int)($STATUS_ID)=>(
int)($STATUS_ID));
710 foreach($arStatus as $STATUS_ID)
713 "SELECT max(G.PERMISSION_TYPE) as MAX_PERMISSION ".
714 "FROM b_workflow_status2group G ".
715 "WHERE G.STATUS_ID = ".$STATUS_ID.
" ".
716 " AND G.GROUP_ID in (".$groups.
") ";
717 $rs =
$DB->Query($strSql);
719 $ar[
"MAX_PERMISSION"] = (int)
$ar[
"MAX_PERMISSION"];
730 return static::WF_GetLockStatus(
$ID, $locked_by, $date_lock) === self::WORKFLOW_STATUS_LOCK;
751 return self::WORKFLOW_STATUS_UNLOCK;
761 when WF_DATE_LOCK is null then '" . self::WORKFLOW_STATUS_UNLOCK .
"'
762 when " . $helper->addSecondsToDateTime($MAX_LOCK * 60,
'WF_DATE_LOCK') .
" < " . $helper->getCurrentDateTimeFunction() .
" then '" . self::WORKFLOW_STATUS_UNLOCK .
"'
763 when WF_LOCKED_BY = " .
$uid .
" then '" . self::WORKFLOW_STATUS_CURRENT_LOCK .
"'
764 else '" . self::WORKFLOW_STATUS_LOCK .
"'
766 FROM b_iblock_element
767 WHERE ID = " .
$ID .
"
778 return self::WORKFLOW_STATUS_UNLOCK;
781 $locked_by = $row[
'WF_LOCKED_BY'];
784 return $row[
'LOCK_STATUS'];
805 if ($bWorkFlow ===
true)
809 'WF_PARENT_ELEMENT_ID',
818 $parentId = (int)$row[
'WF_PARENT_ELEMENT_ID'];
821 $updateIds[] = $parentId;
829 if (!empty($updateIds))
837 .
' ' . $helper->quote(
'WF_DATE_LOCK') .
' = ' . $helper->getCurrentDateTimeFunction() .
','
838 .
' ' . $helper->quote(
'WF_LOCKED_BY') .
' = ' .
$userId
839 .
' where ' . $helper->quote(
'ID') .
' in (' . implode(
',', $updateIds) .
')'
867 if ($bWorkFlow ===
true)
871 'WF_PARENT_ELEMENT_ID',
881 (
int)$row[
'WF_LOCKED_BY'] ===
$userId
890 $parentId = (int)$row[
'WF_PARENT_ELEMENT_ID'];
893 $updateIds[] = $parentId;
898 .
' ' . $helper->quote(
'WF_DATE_LOCK') .
' = null, '
899 .
' ' . $helper->quote(
'WF_LOCKED_BY') .
' = null'
901 .
' ' . $helper->quote(
'ID' ).
' in (' . implode(
',', $updateIds) .
')'
905 $query .=
' or ' . $helper->quote(
'WF_PARENT_ELEMENT_ID') .
' = ' . $parentId;
916 .
' ' . $helper->quote(
'WF_DATE_LOCK') .
' = null, '
917 .
' ' . $helper->quote(
'WF_LOCKED_BY') .
' = null'
919 .
' ' . $helper->quote(
'ID') .
' = ' .
$lastId
940 $ELEMENT_ID = (int)$ELEMENT_ID;
946 if ((
string)
$val ==
'' ||
$val ==
"NOT_REF")
958 $strSqlSearch .=
" and E.ID in (".$str.
")";
961 case "TIMESTAMP_FROM":
962 $strSqlSearch .=
" and E.TIMESTAMP_X>=FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y"),
"d.m.Y").
"')";
965 $strSqlSearch .=
" and E.TIMESTAMP_X<=FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y").
" 23:59:59",
"d.m.Y H:i:s").
"')";
968 case "MODIFIED_USER_ID":
969 $strSqlSearch .=
" and E.MODIFIED_BY='" . (int)
$val .
"'";
972 $strSqlSearch .=
" and E.IBLOCK_ID='" . (int)
$val .
"'";
976 $strSqlSearch .=
" and upper(E.NAME) like upper('".$DB->ForSQL(
$val,255).
"')";
980 $strSqlSearch .=
" and E.WF_STATUS_ID='" . (int)
$val .
"'";
987 $strSqlOrder =
"ORDER BY E.ID";
988 elseif($by ==
"s_timestamp")
989 $strSqlOrder =
"ORDER BY E.TIMESTAMP_X";
990 elseif($by ==
"s_modified_by")
991 $strSqlOrder =
"ORDER BY E.MODIFIED_BY";
993 $strSqlOrder =
"ORDER BY E.NAME";
995 $strSqlOrder =
"ORDER BY E.WF_STATUS_ID";
998 $strSqlOrder =
"ORDER BY E.ID";
1003 $strSqlOrder .=
" desc ";
1009 ".$DB->DateToCharFunction(
"E.TIMESTAMP_X").
" TIMESTAMP_X,
1010 " . self::getUserNameSql(
'U') .
" USER_NAME,
1011 S.TITLE STATUS_TITLE
1014 INNER JOIN b_workflow_status S on S.ID = E.WF_STATUS_ID
1015 LEFT JOIN b_user U ON U.ID = E.MODIFIED_BY
1017 E.WF_PARENT_ELEMENT_ID = ".$ELEMENT_ID.
"
1022 return $DB->Query($strSql);
1032 foreach ($list as $index)
1054 CIBlock::GetArrayByID(
$iblockId,
'ID') ===
null
1060 public function MkFilter(
$arFilter, &$arJoinProps, &$arAddWhereFields, $level = 0, $bPropertyLeftJoin =
false)
1067 $catalogFields = [];
1072 $arSectionFilter = [
1078 $specialFilterKeys = [
1079 'MIN_PERMISSION' =>
true,
1080 'PERMISSIONS_BY' =>
true,
1081 'INCLUDE_SUBSECTIONS' =>
true,
1082 'SECTION_SCOPE' =>
true,
1084 'SHOW_BP_NEW' =>
true,
1085 'SHOW_HISTORY' =>
true,
1097 if (str_ends_with(
$key,
'PROPERTY') && is_array(
$val))
1108 $p = mb_strpos(
$key,
'PROPERTY_');
1109 if (
$p !==
false &&
$p < 4)
1111 $newIndex = mb_substr(
$key, 0,
$p) .
'PROPERTY';
1119 $p = strpos(
$key,
'SUBQUERY');
1120 if (
$p !==
false &&
$p < 4)
1122 if (!empty(
$val) && is_array(
$val))
1138 $bPropertyLeftJoin =
true;
1145 if ($Logic ===
"AND" && $level === 0 && isset(
$arFilter[
'IBLOCK_ID']))
1147 $f = new \Bitrix\Iblock\PropertyIndex\QueryBuilder(
$arFilter[
'IBLOCK_ID']);
1150 $arJoinProps[
'FC'] =
$f->getFilterSql(
$arFilter, $arSqlSearch);
1151 $arJoinProps[
'FC_DISTINCT'] =
$f->getDistinct();
1160 $cOperationType =
$res[
'OPERATION'];
1167 case "DETAIL_TEXT_TYPE":
1168 case "PREVIEW_TEXT_TYPE":
1175 case "PREVIEW_TEXT":
1181 case "SEARCHABLE_CONTENT":
1202 $tableName = FullText::getTableName(
$iblockId);
1205 if (!is_scalar(
$val))
1212 if (mb_strlen(
$val) < Helper::getMinTokenSize())
1221 $arSqlSearch[] = $where;
1222 $arJoinProps[
"BESI"] =
" INNER JOIN " . $tableName .
" " . $alias .
" ON " . $alias .
".ELEMENT_ID = BE.ID ";
1227 if (
$DB->IndexExists(
"b_iblock_element",
array(
"SEARCHABLE_CONTENT")))
1233 if ($cOperationType ==
"FT")
1234 $cOperationType =
"FTL";
1235 elseif ($cOperationType ==
"FTI")
1236 $cOperationType =
"E";
1237 $arSqlSearch[] = CIBlock::FilterCreateEx(
"BE.".
$key,
$val,
"string", $bFullJoinTmp, $cOperationType);
1247 $arSqlSearch[] =
'BE.'.$key.(mb_substr($cOperationType, 0, 1) ==
"N"?
' NOT':
'').
' IN (
1248 SELECT '.
$val->sSelect.
'
1249 FROM '.
$val->sFrom.
'
1260 case "SHOW_COUNTER":
1261 case "WF_PARENT_ELEMENT_ID":
1262 case "WF_STATUS_ID":
1266 case "PREVIEW_PICTURE":
1267 case "DETAIL_PICTURE":
1269 case "IBLOCK_SECTION_ID":
1274 case "SHOW_COUNTER_START":
1276 if($sqlSearch <>
'')
1278 $arSqlSearch[] = $sqlSearch;
1287 case "CHECK_PERMISSIONS":
1290 $minPermission = (string)(
$arFilter[
'MIN_PERMISSION'] ?? CIBlockRights::PUBLIC_READ);
1291 if (strlen($minPermission) !== 1)
1296 $permissionsBy =
null;
1299 $permissionsBy = (int)
$arFilter[
'PERMISSIONS_BY'];
1300 if ($permissionsBy < 0)
1302 $permissionsBy =
null;
1308 if ($permissionsBy !==
null)
1324 case "CHECK_BP_PERMISSIONS":
1329 $MODULE_ID =
$DB->ForSQL(
$val[
"MODULE_ID"]);
1330 $ENTITY =
$DB->ForSQL(
$val[
"ENTITY"]);
1331 $PERMISSION =
$DB->ForSQL(
$val[
"PERMISSION"]);
1332 $arUserGroups =
array();
1333 if(is_array(
$val[
"GROUPS"]))
1335 $USER_ID = intval(
$val[
"USER_ID"]);
1336 foreach(
$val[
"GROUPS"] as $GROUP_ID)
1338 $GROUP_ID = intval($GROUP_ID);
1340 $arUserGroups[$GROUP_ID] = $GROUP_ID;
1350 $MODULE_ID =
"iblock";
1351 $ENTITY =
"CIBlockDocument";
1353 $arUserGroups =
false;
1357 if($PERMISSION ==
"read" || $PERMISSION ==
"write")
1359 if(!is_array($arUserGroups) && is_object(
$USER))
1361 $USER_ID = intval(
$USER->GetID());
1362 $arUserGroups =
$USER->GetUserGroupArray();
1365 if(!is_array($arUserGroups) ||
count($arUserGroups) <= 0)
1366 $arUserGroups =
array(2);
1368 $arSqlSearch[] =
"EXISTS (
1369 SELECT S.DOCUMENT_ID_INT
1371 b_bp_workflow_state S
1372 INNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID
1374 S.DOCUMENT_ID_INT = BE.ID
1375 AND S.MODULE_ID = '$MODULE_ID'
1376 AND S.ENTITY = '$ENTITY'
1377 AND P.PERMISSION = '$PERMISSION'
1379 P.OBJECT_ID IN ('".implode(
"', '", $arUserGroups).
"')
1380 OR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = $USER_ID)
1381 OR (P.OBJECT_ID = ".
$DB->Concat(
"'USER_'",
"'$USER_ID'").
")
1387 case "CHECK_BP_VIRTUAL_PERMISSIONS":
1393 if (!in_array(
$val,
array(
"read",
"create",
"admin")))
1397 $arUserGroups = is_object(
$USER)?
$USER->GetUserGroupArray():
false;
1399 if (!is_array($arUserGroups) || empty($arUserGroups))
1400 $arUserGroups =
array(2);
1402 $arSqlSearch[] =
"EXISTS (
1403 SELECT S.DOCUMENT_ID_INT
1404 FROM b_bp_workflow_state S
1405 INNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID
1406 WHERE S.DOCUMENT_ID_INT = BE.ID
1407 AND S.MODULE_ID = 'bizproc'
1408 AND S.ENTITY = 'CBPVirtualDocument'
1410 (P.PERMISSION = '".$val.
"'
1412 P.OBJECT_ID IN ('".implode(
"', '", $arUserGroups).
"')
1413 OR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = ".
$userId.
")
1414 OR (P.OBJECT_ID = ".
$DB->Concat(
"'USER_'",
"'".
$userId.
"'").
")
1423 case "IBLOCK_SITE_ID":
1426 $arSqlSearch[] = ($cOperationType ==
"N" ?
"NOT " :
"").
"EXISTS (
1427 SELECT IBLOCK_ID FROM b_iblock_site WHERE IBLOCK_ID = B.ID
1431 case "DATE_ACTIVE_FROM":
1433 if ($sqlSearch <>
'')
1435 $arSqlSearch[] = $sqlSearch;
1438 case "DATE_ACTIVE_TO":
1440 if ($sqlSearch <>
'')
1442 $arSqlSearch[] = $sqlSearch;
1445 case "IBLOCK_ACTIVE":
1461 $isCorrect = \CIBlock::isCorrectFullFormatDate(
$DB->ForSql(
$val));
1464 $arSqlSearch[] =
"(BE.ACTIVE_FROM "
1465 . ($cOperationType ==
"N" ?
"<" :
">=")
1466 .
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL")
1467 . ($cOperationType ==
"N" ?
"" :
" OR BE.ACTIVE_FROM IS NULL")
1476 $isCorrect = \CIBlock::isCorrectFullFormatDate(
$DB->ForSql(
$val));
1479 $arSqlSearch[] =
"(BE.ACTIVE_TO "
1480 . ($cOperationType ==
"N" ?
">" :
"<=")
1481 .
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL")
1482 . ($cOperationType ==
"N" ?
"" :
" OR BE.ACTIVE_TO IS NULL")
1490 $arSqlSearch[] = ($cOperationType==
"N"?
" NOT":
"").
"((BE.ACTIVE_TO >= ".
$DB->GetNowFunction().
" OR BE.ACTIVE_TO IS NULL) AND (BE.ACTIVE_FROM <= ".
$DB->GetNowFunction().
" OR BE.ACTIVE_FROM IS NULL))";
1492 case "DATE_MODIFY_FROM":
1496 $isCorrect = \CIBlock::isCorrectFullFormatDate(
$DB->ForSql(
$val));
1499 $arSqlSearch[] =
"(BE.TIMESTAMP_X " .
1500 ($cOperationType ==
"N" ?
"<" :
">=") .
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL") .
1501 ($cOperationType ==
"N" ?
"" :
" OR BE.TIMESTAMP_X IS NULL") .
")";
1505 case "DATE_MODIFY_TO":
1509 $isCorrect = \CIBlock::isCorrectFullFormatDate(
$DB->ForSql(
$val));
1512 $arSqlSearch[] =
"(BE.TIMESTAMP_X " .
1513 ($cOperationType ==
"N" ?
">" :
"<=") .
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL") .
1514 ($cOperationType ==
"N" ?
"" :
" OR BE.TIMESTAMP_X IS NULL") .
")";
1522 case "MODIFIED_USER_ID":
1525 case "CREATED_USER_ID":
1528 case "RATING_USER_ID":
1530 $arJoinProps[
"RVV"] = self::addJoinTypeWhere([
1531 "bFullJoin" => $bFullJoinTmp,
1537 case "WF_LOCK_STATUS":
1541 $lockInterval = (int)Main\Config\Option::get(
'workflow',
'MAX_LOCK_TIME', 60) * 60;
1543 "(case when BE.WF_DATE_LOCK is null then 'green' when "
1544 . $helper->addSecondsToDateTime($lockInterval,
'BE.WF_DATE_LOCK')
1545 .
" < " . $helper->getCurrentDateTimeFunction()
1546 .
" then 'green' when BE.WF_LOCKED_BY = " . $this->userId
1547 .
" then 'yellow' else 'red' end) = '" .
$DB->ForSql(
$val) .
"'"
1549 unset($lockInterval);
1552 case "WF_LAST_STATUS_ID":
1553 $arSqlSearch[] =
"exists (
1557 b_iblock_element history
1559 history.WF_PARENT_ELEMENT_ID = BE.ID
1560 and history.WF_STATUS_ID = ".intval(
$val).
"
1562 select max(history0.ID) LAST_ID
1563 from b_iblock_element history0
1564 where history0.WF_PARENT_ELEMENT_ID = BE.ID
1569 case "SECTION_ACTIVE":
1570 if(
$arFilter[
"INCLUDE_SUBSECTIONS"]===
"Y")
1571 $arSectionFilter[
"BS"][] =
"BSubS.ACTIVE = 'Y'";
1573 $arSectionFilter[
"BS"][] =
"BS.ACTIVE = 'Y'";
1575 case "SECTION_GLOBAL_ACTIVE":
1576 if(
$arFilter[
"INCLUDE_SUBSECTIONS"]===
"Y")
1577 $arSectionFilter[
"BS"][] =
"BSubS.GLOBAL_ACTIVE = 'Y'";
1579 $arSectionFilter[
"BS"][] =
"BS.GLOBAL_ACTIVE = 'Y'";
1582 if (!is_array(
$val))
1585 $arUnknownMargins =
array();
1586 foreach(
$val as
$i=>$section)
1588 if(!is_array($section))
1589 $arUnknownMargins[intval($section)] = intval($section);
1591 if (!empty($arUnknownMargins))
1593 $rs =
$DB->Query(
"SELECT ID, LEFT_MARGIN, RIGHT_MARGIN FROM b_iblock_section WHERE ID in (".implode(
", ", $arUnknownMargins).
")");
1594 while(
$ar =
$rs->Fetch())
1596 $arUnknownMargins[intval(
$ar[
"ID"])] =
array(
1597 intval(
$ar[
"LEFT_MARGIN"]),
1598 intval(
$ar[
"RIGHT_MARGIN"]),
1601 foreach(
$val as
$i=>$section)
1603 if(!is_array($section))
1604 $val[
$i] = $arUnknownMargins[intval($section)];
1608 $arMargins =
array();
1609 foreach(
$val as
$i=>$section)
1611 if(is_array($section) && (
count($section) == 2))
1613 $left = intval($section[0]);
1614 $right = intval($section[1]);
1615 if($left > 0 &&
$right > 0)
1616 $arMargins[$left] =
$right;
1622 foreach($arMargins as $left =>
$right)
1624 if(
$right <= $prev_right)
1625 unset($arMargins[$left]);
1630 if(isset(
$arFilter[
"INCLUDE_SUBSECTIONS"]) &&
$arFilter[
"INCLUDE_SUBSECTIONS"] ===
"Y")
1635 $subsectionWhere =
'';
1636 foreach ($arMargins as $left =>
$right)
1638 if ($subsectionWhere !==
'')
1640 $subsectionWhere .= ($cOperationType ===
'N' ?
' AND ' :
' OR ');
1642 $subsectionWhere .= ($cOperationType ==
"N"?
" NOT ":
" ").
"($bsAlias.LEFT_MARGIN >= ".$left.
" AND $bsAlias.RIGHT_MARGIN <= ".
$right.
")\n";;
1645 if ($subsectionWhere !==
'')
1647 $arSectionFilter[
"BS"][] =
"(".$subsectionWhere.
")";
1649 unset($subsectionWhere);
1656 foreach(
$val as $section_id)
1658 $section_id = (int)$section_id;
1662 if($cOperationType==
"N")
1666 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS<>'N'";
1667 $arSectionFilter[
"LOGIC"] =
"AND";
1670 $arSectionFilter[
"BS"][] =
"BS.ID NOT IN (".implode(
", ",
$arSections).
")";
1674 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS='N'";
1675 $arSectionFilter[
"LOGIC"] =
"OR";
1676 $arSectionFilter[
"BS"][] =
"BS.ID NOT IN (".implode(
", ",
$arSections).
")";
1685 &&
$arFilter[
"INCLUDE_SUBSECTIONS"] ===
"Y"
1690 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS='N'";
1691 $arSectionFilter[
"LOGIC"] =
"OR";
1696 $arSectionFilter[
"BS"][] =
"BS.ID IN (".implode(
", ",
$arSections).
")";
1699 case "SECTION_CODE":
1704 foreach(
$val as $section_code)
1706 $section_code =
$DB->ForSql($section_code);
1710 if($cOperationType==
"N")
1714 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS<>'N'";
1715 $arSectionFilter[
"LOGIC"] =
"AND";
1718 $arSectionFilter[
"BS"][] =
"BS.CODE NOT IN ('".implode(
"', '",
$arSections).
"')";
1722 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS='N'";
1723 $arSectionFilter[
"LOGIC"] =
"OR";
1724 $arSectionFilter[
"BS"][] =
"BS.CODE NOT IN ('".implode(
"', '",
$arSections).
"')";
1731 $arSectionFilter[
"BE"][] =
"BE.IN_SECTIONS='N'";
1732 $arSectionFilter[
"LOGIC"] =
"OR";
1736 $arSectionFilter[
"BS"][] =
"BS.CODE IN ('".implode(
"', '",
$arSections).
"')";
1746 foreach(
$val as $propID=>$propVAL)
1749 $propertyFilter[
"LOGIC"] = $Logic;
1750 $propertyFilter[
"LEFT_JOIN"] = $bPropertyLeftJoin;
1752 if(preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $propertyFilter[
"FIELD"], $arMatch))
1754 if (self::checkPropertyLinkIdentifier($propertyFilter[
'FIELD']))
1757 if (is_array($db_prop) && $db_prop[
"PROPERTY_TYPE"] ==
"E")
1759 $propertyFilter[
"FIELD"] = $arMatch;
1773 if (self::checkPropertyIdentifier($propertyFilter[
'FIELD']))
1789 unset($propertyFilter);
1794 if(is_numeric($orig_key))
1799 if (!isset(
$val[
"~IBLOCK_ID"]))
1806 if (!isset(
$val[
"~IBLOCK_CODE"]))
1814 $arSubSqlSearch = CIBlockElement::MkFilter(
$val, $arJoinProps, $arAddWhereFields, $level + 1, $bPropertyLeftJoin);
1815 if(trim($arSubSqlSearch[0],
"\n\t") <>
'')
1817 $arSqlSearch[] = str_replace(
"\n\t\t\t",
"\n\t\t\t\t", $arSubSqlSearch[0]);
1825 $catalogFields[$orig_key] =
$val;
1826 $arAddWhereFields[$orig_key] =
$val;
1834 $catalogQueryResult = \CProductQueryBuilder::makeFilter($catalogFields);
1836 if (!empty($catalogQueryResult) && !empty($catalogQueryResult[
'filter']))
1838 $arSqlSearch = array_merge($arSqlSearch, $catalogQueryResult[
'filter']);
1840 unset($catalogQueryResult);
1842 unset($catalogFields);
1846 foreach($arSectionFilter[
"BS"] as $strFilter)
1848 if ($strFilter !==
'')
1852 $sWhere .=
"(".$strFilter.
")";
1856 $bINCLUDE_SUBSECTIONS = isset(
$arFilter[
"INCLUDE_SUBSECTIONS"]) &&
$arFilter[
"INCLUDE_SUBSECTIONS"] ===
"Y";
1863 if (
$arFilter[
"SECTION_SCOPE"] ==
"IBLOCK")
1864 $sectionScope =
"AND BSE.ADDITIONAL_PROPERTY_ID IS NULL";
1866 $sectionScope =
"AND BSE.ADDITIONAL_PROPERTY_ID IS NOT NULL";
1867 elseif (preg_match(
"/^PROPERTY_(\\d+)\$/",
$arFilter[
"SECTION_SCOPE"], $match))
1868 $sectionScope =
"AND BSE.ADDITIONAL_PROPERTY_ID = ".$match[1];
1872 if($level == 0 && $Logic ==
"AND" && !
count($arSectionFilter[
"BE"]))
1874 $arJoinProps[
"BES"] .=
" INNER JOIN (
1875 SELECT DISTINCT BSE.IBLOCK_ELEMENT_ID
1876 FROM b_iblock_section_element BSE
1877 ".($bINCLUDE_SUBSECTIONS?
"
1878 INNER JOIN b_iblock_section BSubS ON BSE.IBLOCK_SECTION_ID = BSubS.ID
1879 INNER JOIN b_iblock_section BS ON (BSubS.IBLOCK_ID=BS.IBLOCK_ID
1880 AND BSubS.LEFT_MARGIN>=BS.LEFT_MARGIN
1881 AND BSubS.RIGHT_MARGIN<=BS.RIGHT_MARGIN)
1883 INNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID
1885 WHERE (".
$sWhere.
")$sectionScope
1886 ) BES ON BES.IBLOCK_ELEMENT_ID = BE.ID\n";
1890 $arSqlSearch[] =
"(".(count($arSectionFilter[
"BE"])? implode(
" ".$arSectionFilter[
"LOGIC"].
" ", $arSectionFilter[
"BE"]).
" ".$arSectionFilter[
"LOGIC"]:
"").
" EXISTS (
1891 SELECT BSE.IBLOCK_ELEMENT_ID
1892 FROM b_iblock_section_element BSE
1893 ".($bINCLUDE_SUBSECTIONS?
"
1894 INNER JOIN b_iblock_section BSubS ON BSE.IBLOCK_SECTION_ID = BSubS.ID
1895 INNER JOIN b_iblock_section BS ON (BSubS.IBLOCK_ID=BS.IBLOCK_ID
1896 AND BSubS.LEFT_MARGIN>=BS.LEFT_MARGIN
1897 AND BSubS.RIGHT_MARGIN<=BS.RIGHT_MARGIN)
1899 INNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID
1901 WHERE BSE.IBLOCK_ELEMENT_ID = BE.ID
1902 AND (".
$sWhere.
")$sectionScope
1906 elseif(!empty($arSectionFilter[
"BE"]))
1908 foreach($arSectionFilter[
"BE"] as $strFilter)
1909 $arSqlSearch[] = $strFilter;
1913 foreach($arSqlSearch as $strFilter)
1915 if(trim($strFilter,
"\n\t") !==
'')
1918 $sWhere .=
"\n\t\t\t\t".$Logic.
" ";
1921 $sWhere .=
"(".$strFilter.
")";
1939 $MODULE_ID =
$DB->ForSQL(
$arFilter[
"SHOW_BP_NEW"][
"MODULE_ID"]);
1940 $ENTITY =
$DB->ForSQL(
$arFilter[
"SHOW_BP_NEW"][
"ENTITY"]);
1941 $PERMISSION =
$DB->ForSQL(
$arFilter[
"SHOW_BP_NEW"][
"PERMISSION"]);
1942 $arUserGroups =
array();
1943 if(is_array(
$arFilter[
"SHOW_BP_NEW"][
"GROUPS"]))
1945 $USER_ID = intval(
$arFilter[
"SHOW_BP_NEW"][
"USER_ID"]);
1946 foreach(
$arFilter[
"SHOW_BP_NEW"][
"GROUPS"] as $GROUP_ID)
1948 $GROUP_ID = intval($GROUP_ID);
1950 $arUserGroups[$GROUP_ID] = $GROUP_ID;
1956 $arUserGroups =
false;
1959 if($PERMISSION ==
"read" || $PERMISSION ==
"write")
1961 if(!is_array($arUserGroups))
1963 $USER_ID = is_object(
$USER)? (int)
$USER->GetID(): 0;
1964 if(is_object(
$USER))
1965 $arUserGroups =
$USER->GetUserGroupArray();
1967 if(!is_array($arUserGroups) || empty($arUserGroups))
1968 $arUserGroups =
array(2);
1970 $SHOW_BP_NEW =
" AND EXISTS (
1971 SELECT S.DOCUMENT_ID_INT
1973 b_bp_workflow_state S
1974 INNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID
1976 S.DOCUMENT_ID_INT = BE.ID
1977 AND S.MODULE_ID = '$MODULE_ID'
1978 AND S.ENTITY = '$ENTITY'
1979 AND P.PERMISSION = '$PERMISSION'
1981 P.OBJECT_ID IN ('".implode(
"', '", $arUserGroups).
"')
1982 OR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = $USER_ID)
1983 OR (P.OBJECT_ID = ".
$DB->Concat(
"'USER_'",
"'$USER_ID'").
")
1990 $arSqlSearch[] =
"((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL)".($SHOW_NEW ==
"Y"?
" OR (BE.WF_NEW='Y'".$SHOW_BP_NEW.
")":
"").
")";
1993 $arSqlSearch[] = $permSQL;
1995 if(isset($this) && is_object($this) && isset($this->subQueryProp))
1999 CIBlock::MkOperationFilter(
"!".mb_substr($this->strField, 9))
2002 ,$this->subQueryProp, $arJoinProps, $arSqlSearch
2006 return $arSqlSearch;
2013 $propertyId = $db_prop[
'ID'];
2015 if(
$res[
"OPERATION"]!=
"E")
2016 $cOperationType =
$res[
"OPERATION"];
2019 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"]==
"N")
2021 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2022 $iPropCnt =
count($arJoinProps[
"FPS"]);
2024 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
2028 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"FPV"]))
2029 $iPropCnt =
count($arJoinProps[
"FPV"]);
2031 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
2034 if(!is_array(
$res[
"FIELD"]) && (mb_substr(mb_strtoupper(
$res[
"FIELD"]), -6) ==
'_VALUE'))
2037 $bValueEnum =
false;
2039 if($db_prop[
"PROPERTY_TYPE"] ==
"L" && $bValueEnum)
2041 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"FPEN"]))
2042 $iFpenCnt =
count($arJoinProps[
"FPEN"]);
2044 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
2051 if(is_array(
$res[
"FIELD"]))
2053 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"BE"]))
2054 $iElCnt =
count($arJoinProps[
"BE"]);
2056 $iElCnt = $arJoinProps[
"BE"][$db_prop[
"ID"]][
"CNT"];
2066 if(is_array(
$res[
"FIELD"]))
2068 switch(
$res[
"FIELD"][2].
"")
2071 case "DETAIL_TEXT_TYPE":
2072 case "PREVIEW_TEXT_TYPE":
2073 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".".
$res[
"FIELD"][2], $propVAL,
"string_equal", $bFullJoinTmp, $cOperationType);
2076 $res[
"FIELD"][2] =
"XML_ID";
2081 case "SEARCHABLE_CONTENT":
2082 case "PREVIEW_TEXT":
2086 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".".
$res[
"FIELD"][2], $propVAL,
"string", $bFullJoinTmp, $cOperationType);
2089 case "SHOW_COUNTER":
2090 case "WF_PARENT_ELEMENT_ID":
2091 case "WF_STATUS_ID":
2095 case "PREVIEW_PICTURE":
2096 case "DETAIL_PICTURE":
2098 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".".
$res[
"FIELD"][2], $propVAL,
"number", $bFullJoinTmp, $cOperationType);
2102 case "SHOW_COUNTER_START":
2103 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".".
$res[
"FIELD"][2], $propVAL,
"date", $bFullJoinTmp, $cOperationType);
2105 case "DATE_ACTIVE_FROM":
2106 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".ACTIVE_FROM", $propVAL,
"date", $bFullJoinTmp, $cOperationType);
2108 case "DATE_ACTIVE_TO":
2109 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".ACTIVE_TO", $propVAL,
"date", $bFullJoinTmp, $cOperationType);
2113 $r =
"(BE".$iElCnt.
".ACTIVE_FROM ".($cOperationType==
"N"?
"<":
">=").
$DB->CharToDateFunction(
$DB->ForSql($propVAL),
"FULL").($cOperationType==
"N"?
"":
" OR BE".$iElCnt.
".ACTIVE_FROM IS NULL").
")";
2117 $r =
"(BE".$iElCnt.
".ACTIVE_TO ".($cOperationType==
"N"?
">":
"<=").
$DB->CharToDateFunction(
$DB->ForSql($propVAL),
"FULL").($cOperationType==
"N"?
"":
" OR BE".$iElCnt.
".ACTIVE_TO IS NULL").
")";
2121 $r = ($cOperationType==
"N"?
" NOT":
"").
"((BE".$iElCnt.
".ACTIVE_TO >= ".
$DB->GetNowFunction().
" OR BE".$iElCnt.
".ACTIVE_TO IS NULL) AND (BE".$iElCnt.
".ACTIVE_FROM <= ".
$DB->GetNowFunction().
" OR BE".$iElCnt.
".ACTIVE_FROM IS NULL))";
2123 case "DATE_MODIFY_FROM":
2125 $r =
"(BE".$iElCnt.
".TIMESTAMP_X ".
2126 ( $cOperationType==
"N" ?
"<" :
">=" ).
$DB->CharToDateFunction(
$DB->ForSql($propVAL),
"FULL").
2127 ( $cOperationType==
"N" ?
"" :
" OR BE".$iElCnt.
".TIMESTAMP_X IS NULL").
")";
2129 case "DATE_MODIFY_TO":
2131 $r =
"(BE".$iElCnt.
".TIMESTAMP_X ".
2132 ( $cOperationType==
"N" ?
">" :
"<=" ).
$DB->CharToDateFunction(
$DB->ForSql($propVAL),
"FULL").
2133 ( $cOperationType==
"N" ?
"" :
" OR BE".$iElCnt.
".TIMESTAMP_X IS NULL").
")";
2135 case "MODIFIED_USER_ID":
2136 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".MODIFIED_BY", $propVAL,
"number", $bFullJoinTmp, $cOperationType);
2138 case "CREATED_USER_ID":
2139 $r = CIBlock::FilterCreateEx(
"BE".$iElCnt.
".CREATED_BY", $propVAL,
"number", $bFullJoinTmp, $cOperationType);
2145 if(!is_array($propVAL))
2146 $propVAL =
array($propVAL);
2148 if($db_prop[
"PROPERTY_TYPE"]==
"L")
2151 $r = CIBlock::FilterCreateEx(
"FPEN".$iFpenCnt.
".VALUE", $propVAL,
"string", $bFullJoin, $cOperationType);
2152 elseif($db_prop[
"VERSION"]==2 && $db_prop[
"MULTIPLE"]==
"N")
2153 $r = CIBlock::FilterCreateEx(
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"], $propVAL,
"number", $bFullJoin, $cOperationType);
2155 $r = CIBlock::FilterCreateEx(
"FPV".$iPropCnt.
".VALUE_ENUM", $propVAL,
"number", $bFullJoin, $cOperationType);
2157 elseif($db_prop[
"PROPERTY_TYPE"]==
"N" || $db_prop[
"PROPERTY_TYPE"]==
"G" || $db_prop[
"PROPERTY_TYPE"]==
"E")
2159 if($db_prop[
"VERSION"]==2 && $db_prop[
"MULTIPLE"]==
"N")
2160 $r = CIBlock::FilterCreateEx(
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"], $propVAL,
"number", $bFullJoin, $cOperationType);
2162 $r = CIBlock::FilterCreateEx(
"FPV".$iPropCnt.
".VALUE_NUM", $propVAL,
"number", $bFullJoin, $cOperationType);
2166 if($db_prop[
"VERSION"]==2 && $db_prop[
"MULTIPLE"]==
"N")
2167 $r = CIBlock::FilterCreateEx(
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"], $propVAL,
"string", $bFullJoin, $cOperationType);
2169 $r = CIBlock::FilterCreateEx(
"FPV".$iPropCnt.
".VALUE", $propVAL,
"string", $bFullJoin, $cOperationType);
2175 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"]==
"N")
2177 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2178 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] = $iPropCnt;
2182 $arJoinProps[
'FP'][$propertyId] ??= [
2183 'CNT' =>
count($arJoinProps[
'FP']),
2184 'bFullJoin' =>
false,
2186 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeWhere($arJoinProps[
'FP'][$propertyId]);
2188 if (isset(
$res[
"LEFT_JOIN"]) &&
$res[
"LEFT_JOIN"])
2190 $arJoinProps[
"FP"][$db_prop[
"ID"]][
"bFullJoin"] &= $bFullJoin;
2194 $arJoinProps[
"FP"][$db_prop[
"ID"]][
"bFullJoin"] |= $bFullJoin;
2197 $arJoinProps[
'FPV'][$propertyId] ??= [
2199 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
2200 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2201 'VERSION' => $db_prop[
'VERSION'],
2202 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
2203 'bFullJoin' =>
false,
2205 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeWhere($arJoinProps[
'FPV'][$propertyId]);
2207 if(isset(
$res[
"LEFT_JOIN"]) &&
$res[
"LEFT_JOIN"])
2209 $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"bFullJoin"] &= $bFullJoin;
2213 $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"bFullJoin"] |= $bFullJoin;
2217 if($db_prop[
"PROPERTY_TYPE"]==
"L" && $bValueEnum)
2219 $arJoinProps[
'FPEN'][$propertyId] ??= [
2221 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2222 'VERSION' => $db_prop[
'VERSION'],
2223 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2224 'JOIN' => $iPropCnt,
2225 'bFullJoin' =>
false,
2227 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeWhere($arJoinProps[
'FPEN'][$propertyId]);
2229 if(isset(
$res[
"LEFT_JOIN"]) &&
$res[
"LEFT_JOIN"])
2231 $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"bFullJoin"] &= $bFullJoin;
2235 $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"bFullJoin"] |= $bFullJoin;
2239 if(is_array(
$res[
"FIELD"]))
2241 $arJoinProps[
'BE'][$propertyId] ??= [
2243 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2244 'VERSION' => $db_prop[
'VERSION'],
2245 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2246 'JOIN' => $iPropCnt,
2247 'bJoinIBlock' =>
false,
2248 'bJoinSection' =>
false,
2250 $arJoinProps[
'BE'][$propertyId] = self::addJoinTypeWhere($arJoinProps[
'BE'][$propertyId]);
2253 $arSqlSearch[] = $r;
2260 static $arJoinEFields =
false;
2262 $propertyId = $db_prop[
'ID'];
2265 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"]==
"N")
2267 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2268 $iPropCnt =
count($arJoinProps[
"FPS"]);
2270 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
2274 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"FPV"]))
2275 $iPropCnt =
count($arJoinProps[
"FPV"]);
2277 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
2280 if($db_prop[
"PROPERTY_TYPE"] ==
"L")
2282 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"FPEN"]))
2283 $iFpenCnt =
count($arJoinProps[
"FPEN"]);
2285 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
2299 if(!$arJoinEFields) $arJoinEFields =
array(
2301 "TIMESTAMP_X" =>
"BE#i#.TIMESTAMP_X",
2302 "MODIFIED_BY" =>
"BE#i#.MODIFIED_BY",
2303 "CREATED" =>
"BE#i#.DATE_CREATE",
2304 "CREATED_DATE" =>
$DB->DateFormatToDB(
"YYYY.MM.DD",
"BE#i#.DATE_CREATE"),
2305 "CREATED_BY" =>
"BE#i#.CREATED_BY",
2306 "IBLOCK_ID" =>
"BE#i#.IBLOCK_ID",
2307 "ACTIVE" =>
"BE#i#.ACTIVE",
2308 "ACTIVE_FROM" =>
"BE#i#.ACTIVE_FROM",
2309 "ACTIVE_TO" =>
"BE#i#.ACTIVE_TO",
2310 "SORT" =>
"BE#i#.SORT",
2311 "NAME" =>
"BE#i#.NAME",
2312 "SHOW_COUNTER" =>
"BE#i#.SHOW_COUNTER",
2313 "SHOW_COUNTER_START" =>
"BE#i#.SHOW_COUNTER_START",
2314 "CODE" =>
"BE#i#.CODE",
2315 "TAGS" =>
"BE#i#.TAGS",
2316 "XML_ID" =>
"BE#i#.XML_ID",
2317 "STATUS" =>
"BE#i#.WF_STATUS_ID",
2320 $jProp_ID = mb_substr($by[2], 9);
2321 $db_jprop = CIBlockProperty::GetPropertyArray($jProp_ID, CIBlock::_MergeIBArrays($db_prop[
"LINK_IBLOCK_ID"]));
2322 if ($bSort && $db_jprop[
"PROPERTY_TYPE"] !=
"L")
2326 if(array_key_exists($by[2], $arJoinEFields))
2329 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"BE"]))
2330 $iElCnt =
count($arJoinProps[
"BE"]);
2332 $iElCnt = $arJoinProps[
"BE"][$db_prop[
"ID"]][
"CNT"];
2334 $arSqlOrder[$by[0]] = CIBlock::_Order(str_replace(
"#i#", $iElCnt, $arJoinEFields[$by[2]]),
$order,
"desc");
2336 elseif(mb_substr($by[2], 0, 9) ==
"PROPERTY_")
2338 if(is_array($db_jprop))
2341 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"BE"]))
2342 $iElCnt =
count($arJoinProps[
"BE"]);
2344 $iElCnt = $arJoinProps[
"BE"][$db_prop[
"ID"]][
"CNT"];
2346 if($db_jprop[
"VERSION"] == 2 && $db_jprop[
"MULTIPLE"]==
"N")
2348 if(!array_key_exists($db_jprop[
"IBLOCK_ID"], $arJoinProps[
"BE_FPS"]))
2349 $ijPropCnt =
count($arJoinProps[
"BE_FPS"]);
2351 $ijPropCnt = $arJoinProps[
"BE_FPS"][$db_jprop[
"IBLOCK_ID"]][
"CNT"];
2355 if(!array_key_exists($db_jprop[
"ID"], $arJoinProps[
"BE_FPV"]))
2356 $ijPropCnt =
count($arJoinProps[
"BE_FPV"]);
2358 $ijPropCnt = $arJoinProps[
"BE_FPV"][$db_jprop[
"ID"]][
"CNT"];
2361 if($db_jprop[
"PROPERTY_TYPE"] ==
"L")
2363 if(!array_key_exists($db_jprop[
"ID"], $arJoinProps[
"BE_FPEN"]))
2364 $ijFpenCnt =
count($arJoinProps[
"BE_FPEN"]);
2366 $ijFpenCnt = $arJoinProps[
"BE_FPEN"][$db_jprop[
"ID"]][
"CNT"];
2369 if($db_jprop[
"PROPERTY_TYPE"]==
"L" && $bSort)
2370 $arSqlOrder[
"PROPERTY_".$by[1].
"_".$by[2]] = CIBlock::_Order(
"JFPEN".$ijFpenCnt.
".SORT",
$order,
"desc");
2371 elseif($db_jprop[
"PROPERTY_TYPE"]==
"L")
2372 $arSqlOrder[
"PROPERTY_".$by[1].
"_".$by[2]] = CIBlock::_Order(
"JFPEN".$ijFpenCnt.
".VALUE",
$order,
"desc");
2373 elseif($db_jprop[
"VERSION"]==2 && $db_jprop[
"MULTIPLE"]==
"N")
2374 $arSqlOrder[
"PROPERTY_".$by[1].
"_".$by[2]] = CIBlock::_Order(
"JFPS".$ijPropCnt.
".PROPERTY_".$db_jprop[
"ORIG_ID"],
$order,
"desc");
2375 elseif($db_jprop[
"PROPERTY_TYPE"]==
"N")
2376 $arSqlOrder[
"PROPERTY_".$by[1].
"_".$by[2]] = CIBlock::_Order(
"JFPV".$ijPropCnt.
".VALUE_NUM",
$order,
"desc");
2378 $arSqlOrder[
"PROPERTY_".$by[1].
"_".$by[2]] = CIBlock::_Order(
"JFPV".$ijPropCnt.
".VALUE",
$order,
"desc");
2385 if ($bSort && $db_prop[
"PROPERTY_TYPE"] !=
"L")
2388 if($db_prop[
"PROPERTY_TYPE"]==
"L" && $bSort)
2389 $arSqlOrder[$by] = CIBlock::_Order(
"FPEN".$iFpenCnt.
".SORT",
$order,
"desc");
2390 elseif($db_prop[
"PROPERTY_TYPE"]==
"L")
2391 $arSqlOrder[$by] = CIBlock::_Order(
"FPEN".$iFpenCnt.
".VALUE",
$order,
"desc");
2392 elseif($db_prop[
"VERSION"]==2 && $db_prop[
"MULTIPLE"]==
"N")
2393 $arSqlOrder[$by] = CIBlock::_Order(
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"],
$order,
"desc");
2394 elseif($db_prop[
"PROPERTY_TYPE"]==
"N")
2395 $arSqlOrder[$by] = CIBlock::_Order(
"FPV".$iPropCnt.
".VALUE_NUM",
$order,
"desc");
2397 $arSqlOrder[$by] = CIBlock::_Order(
"FPV".$iPropCnt.
".VALUE",
$order,
"desc");
2401 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"]==
"N")
2403 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2404 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] = $iPropCnt;
2408 $arJoinProps[
'FP'][$propertyId] ??= [
2409 'CNT' =>
count($arJoinProps[
'FP']),
2410 'bFullJoin' =>
false,
2412 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeOrder($arJoinProps[
'FP'][$propertyId]);
2414 $arJoinProps[
'FPV'][$propertyId] ??= [
2416 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
2417 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2418 'VERSION' => $db_prop[
'VERSION'],
2419 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
2420 'bFullJoin' =>
false,
2422 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeOrder($arJoinProps[
'FPV'][$propertyId]);
2427 $arJoinProps[
'FPEN'][$propertyId] ??= [
2429 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2430 'VERSION' => $db_prop[
'VERSION'],
2431 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2432 'JOIN' => $iPropCnt,
2433 'bFullJoin' =>
false,
2435 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeOrder($arJoinProps[
'FPEN'][$propertyId]);
2440 $arJoinProps[
'BE'][$propertyId] ??= [
2442 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2443 'VERSION' => $db_prop[
'VERSION'],
2444 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2445 'JOIN' => $iPropCnt,
2446 'bJoinIBlock' =>
false,
2447 'bJoinSection' =>
false,
2449 $arJoinProps[
'BE'][$propertyId] = self::addJoinTypeOrder($arJoinProps[
'BE'][$propertyId]);
2451 if(is_array($db_jprop))
2453 if($db_jprop[
"VERSION"] == 2 && $db_jprop[
"MULTIPLE"]==
"N")
2455 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']] ??= [
2456 'CNT' => $ijPropCnt,
2459 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']] = self::addJoinTypeOrder(
2460 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']]
2465 $arJoinProps[
'BE_FP'][$db_jprop[
'ID']] ??= [
2466 "CNT" =>
count($arJoinProps[
"BE_FP"]),
2468 "bFullJoin" =>
false,
2470 $arJoinProps[
'BE_FP'][$db_jprop[
'ID']] = self::addJoinTypeOrder($arJoinProps[
'BE_FP'][$db_jprop[
'ID']]);
2472 $arJoinProps[
'BE_FPV'][$db_jprop[
'ID']] ??= [
2473 'CNT' => $ijPropCnt,
2474 'IBLOCK_ID' => $db_jprop[
'IBLOCK_ID'],
2475 'MULTIPLE' => $db_jprop[
'MULTIPLE'],
2476 'VERSION' => $db_jprop[
'VERSION'],
2477 'JOIN' => $arJoinProps[
'BE_FP'][$db_jprop[
'ID']][
'CNT'],
2478 'BE_JOIN' => $iElCnt,
2479 'bFullJoin' =>
false,
2481 $arJoinProps[
'BE_FPV'][$db_jprop[
'ID']] = self::addJoinTypeOrder(
2482 $arJoinProps[
'BE_FPV'][$db_jprop[
'ID']]
2486 if ($ijFpenCnt >= 0)
2488 $arJoinProps[
'BE_FPEN'][$db_jprop[
'ID']] ??= [
2489 'CNT' => $ijFpenCnt,
2490 'MULTIPLE' => $db_jprop[
'MULTIPLE'],
2491 'VERSION' => $db_jprop[
'VERSION'],
2492 'ORIG_ID' => $db_jprop[
'ORIG_ID'],
2493 'JOIN' => $ijPropCnt,
2494 'bFullJoin' =>
false,
2496 $arJoinProps[
'BE_FPEN'][$db_jprop[
'ID']] = self::addJoinTypeOrder(
2497 $arJoinProps[
'BE_FPEN'][$db_jprop[
'ID']]
2506 $propertyId = $db_prop[
'ID'];
2508 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"]==
"N")
2510 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2511 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
2512 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
2517 $arJoinProps[
'FP'][$propertyId] ??= [
2518 'CNT' =>
count($arJoinProps[
'FP']),
2519 'bFullJoin' =>
false,
2521 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeGroup($arJoinProps[
'FP'][$propertyId]);
2523 $arJoinProps[
'FPV'][$propertyId] ??= [
2524 'CNT' =>
count($arJoinProps[
'FPV']),
2525 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
2526 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2527 'VERSION' => $db_prop[
'VERSION'],
2528 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2529 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
2530 'bFullJoin' =>
false,
2532 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeGroup($arJoinProps[
'FPV'][$propertyId]);
2534 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
2537 if($db_prop[
"PROPERTY_TYPE"]==
"L")
2539 $arJoinProps[
'FPEN'][$propertyId] ??= [
2540 'CNT' =>
count($arJoinProps[
'FPEN']),
2541 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2542 'VERSION' => $db_prop[
'VERSION'],
2543 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2544 'JOIN' => $iPropCnt,
2545 'bFullJoin' =>
false,
2547 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeGroup($arJoinProps[
'FPEN'][$propertyId]);
2549 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
2551 return ($bSort?
", FPEN".$iFpenCnt.
".SORT":
", FPEN".$iFpenCnt.
".VALUE, FPEN".$iFpenCnt.
".ID");
2553 elseif($db_prop[
"VERSION"]==2 && $db_prop[
"MULTIPLE"]==
"N")
2555 return ", FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"];
2557 elseif($db_prop[
"PROPERTY_TYPE"]==
"N")
2559 return ", FPV".$iPropCnt.
".VALUE, FPV".$iPropCnt.
".VALUE_NUM";
2563 return ", FPV".$iPropCnt.
".VALUE";
2571 if($bSort && $db_prop[
"PROPERTY_TYPE"] !=
"L")
2574 static $arJoinEFields =
false;
2576 $propertyId = $db_prop[
'ID'];
2581 $bSubQuery = isset($this) && is_object($this) && isset($this->subQueryProp);
2583 $arSelect =
array();
2586 if(is_array($PR_ID))
2588 if(!$arJoinEFields) $arJoinEFields =
array(
2590 "TIMESTAMP_X" =>
$DB->DateToCharFunction(
"BE#i#.TIMESTAMP_X"),
2591 "MODIFIED_BY" =>
"BE#i#.MODIFIED_BY",
2592 "DATE_CREATE" =>
$DB->DateToCharFunction(
"BE#i#.DATE_CREATE"),
2593 "CREATED_BY" =>
"BE#i#.CREATED_BY",
2594 "IBLOCK_ID" =>
"BE#i#.IBLOCK_ID",
2595 "ACTIVE" =>
"BE#i#.ACTIVE",
2596 "ACTIVE_FROM" =>
$DB->DateToCharFunction(
"BE#i#.ACTIVE_FROM"),
2597 "ACTIVE_TO" =>
$DB->DateToCharFunction(
"BE#i#.ACTIVE_TO"),
2598 "SORT" =>
"BE#i#.SORT",
2599 "NAME" =>
"BE#i#.NAME",
2600 "PREVIEW_PICTURE" =>
"BE#i#.PREVIEW_PICTURE",
2601 "PREVIEW_TEXT" =>
"BE#i#.PREVIEW_TEXT",
2602 "PREVIEW_TEXT_TYPE" =>
"BE#i#.PREVIEW_TEXT_TYPE",
2603 "DETAIL_PICTURE" =>
"BE#i#.DETAIL_PICTURE",
2604 "DETAIL_TEXT" =>
"BE#i#.DETAIL_TEXT",
2605 "DETAIL_TEXT_TYPE" =>
"BE#i#.DETAIL_TEXT_TYPE",
2606 "SHOW_COUNTER" =>
"BE#i#.SHOW_COUNTER",
2607 "SHOW_COUNTER_START" =>
$DB->DateToCharFunction(
"BE#i#.SHOW_COUNTER_START"),
2608 "CODE" =>
"BE#i#.CODE",
2609 "TAGS" =>
"BE#i#.TAGS",
2610 "XML_ID" =>
"BE#i#.XML_ID",
2611 "IBLOCK_SECTION_ID" =>
"BE#i#.IBLOCK_SECTION_ID",
2612 "IBLOCK_TYPE_ID"=>
"B#i#.IBLOCK_TYPE_ID",
2613 "IBLOCK_CODE"=>
"B#i#.CODE",
2614 "IBLOCK_NAME"=>
"B#i#.NAME",
2615 "IBLOCK_EXTERNAL_ID"=>
"B#i#.XML_ID",
2616 "DETAIL_PAGE_URL" =>
"
2629 replace(B#i#.DETAIL_PAGE_URL, '#ID#', BE#i#.ID)
2630 , '#ELEMENT_ID#', BE#i#.ID)
2631 , '#CODE#', ".$DB->IsNull(
"BE#i#.CODE",
"''").
")
2632 , '#ELEMENT_CODE#', ".
$DB->IsNull(
"BE#i#.CODE",
"''").
")
2633 , '#EXTERNAL_ID#', ".
$DB->IsNull(
"BE#i#.XML_ID",
"''").
")
2634 , '#IBLOCK_TYPE_ID#', B#i#.IBLOCK_TYPE_ID)
2635 , '#IBLOCK_ID#', BE#i#.IBLOCK_ID)
2636 , '#IBLOCK_CODE#', ".
$DB->IsNull(
"B#i#.CODE",
"''").
")
2637 , '#IBLOCK_EXTERNAL_ID#', ".
$DB->IsNull(
"B#i#.XML_ID",
"''").
")
2639 , '#SERVER_NAME#', '".
$DB->ForSQL(SITE_SERVER_NAME).
"')
2640 , '#SECTION_ID#', ".
$DB->IsNull(
"BE#i#.IBLOCK_SECTION_ID",
"''").
")
2641 , '#SECTION_CODE#', ".
$DB->IsNull(
"BS#i#.CODE",
"''").
")
2643 "LIST_PAGE_URL" =>
"
2649 replace(B#i#.LIST_PAGE_URL, '#IBLOCK_TYPE_ID#', B#i#.IBLOCK_TYPE_ID)
2650 , '#IBLOCK_ID#', BE#i#.IBLOCK_ID)
2651 , '#IBLOCK_CODE#', ".$DB->IsNull(
"B#i#.CODE",
"''").
")
2652 , '#IBLOCK_EXTERNAL_ID#', ".
$DB->IsNull(
"B#i#.XML_ID",
"''").
")
2654 , '#SERVER_NAME#', '".
$DB->ForSQL(SITE_SERVER_NAME).
"')
2659 if(array_key_exists($PR_ID[2], $arJoinEFields))
2662 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"] ==
"N")
2665 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2666 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
2667 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
2672 $arJoinProps[
'FP'][$propertyId] ??= [
2673 'CNT' =>
count($arJoinProps[
'FP']),
2674 'bFullJoin' =>
false,
2676 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'FP'][$propertyId]);
2679 $arJoinProps[
'FPV'][$propertyId] ??= [
2680 'CNT' =>
count($arJoinProps[
'FPV']),
2681 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
2682 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2683 'VERSION' => $db_prop[
'VERSION'],
2684 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2685 'JOIN' => $arJoinProps[
'FP'][$db_prop[
'ID']][
'CNT'],
2686 'bFullJoin' =>
false,
2688 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'FPV'][$propertyId]);
2690 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
2693 $arJoinProps[
'BE'][$propertyId] ??= [
2694 'CNT' =>
count($arJoinProps[
'BE']),
2695 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2696 'VERSION' => $db_prop[
'VERSION'],
2697 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2698 'JOIN' => $iPropCnt,
2699 'bJoinIBlock' =>
false,
2700 'bJoinSection' =>
false,
2702 $arJoinProps[
'BE'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'BE'][$propertyId]);
2704 $iElCnt = $arJoinProps[
"BE"][$db_prop[
"ID"]][
"CNT"];
2708 $PR_ID[2] ==
"LIST_PAGE_URL"
2709 || $PR_ID[2] ==
"IBLOCK_TYPE_ID"
2710 || $PR_ID[2] ==
"IBLOCK_CODE"
2711 || $PR_ID[2] ==
"IBLOCK_NAME"
2712 || $PR_ID[2] ==
"IBLOCK_EXTERNAL_ID"
2714 $arJoinProps[
"BE"][$db_prop[
"ID"]][
"bJoinIBlock"] =
true;
2717 if($PR_ID[2] ==
"DETAIL_PAGE_URL")
2719 $arJoinProps[
"BE"][$db_prop[
"ID"]][
"bJoinIBlock"] =
true;
2720 $arJoinProps[
"BE"][$db_prop[
"ID"]][
"bJoinSection"] =
true;
2723 $arSelect[str_replace(
"#i#", $iElCnt, $arJoinEFields[$PR_ID[2]])] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2], $this->arIBlockLongProps);
2726 elseif(mb_substr($PR_ID[2], 0, 9) ==
"PROPERTY_")
2728 $jProp_ID = mb_substr($PR_ID[2], 9);
2729 $db_jprop = CIBlockProperty::GetPropertyArray($jProp_ID, CIBlock::_MergeIBArrays($db_prop[
"LINK_IBLOCK_ID"]));
2730 if(is_array($db_jprop))
2732 if($db_prop[
"VERSION"] == 2 && $db_prop[
"MULTIPLE"] ==
"N")
2735 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
2736 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
2737 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
2742 $arJoinProps[
'FP'][$propertyId] ??= [
2743 'CNT' =>
count($arJoinProps[
'FP']),
2744 'bFullJoin' =>
false,
2746 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'FP'][$propertyId]);
2749 $arJoinProps[
'FPV'][$propertyId] ??= [
2750 'CNT' =>
count($arJoinProps[
'FPV']),
2751 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
2752 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2753 'VERSION' => $db_prop[
'VERSION'],
2754 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
2755 'bFullJoin' =>
false,
2757 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'FPV'][$propertyId]);
2759 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
2762 $arJoinProps[
'BE'][$propertyId] ??= [
2763 'CNT' =>
count($arJoinProps[
'BE']),
2764 'MULTIPLE' => $db_prop[
'MULTIPLE'],
2765 'VERSION' => $db_prop[
'VERSION'],
2766 'ORIG_ID' => $db_prop[
'ORIG_ID'],
2767 'JOIN' => $iPropCnt,
2768 'bJoinIBlock' =>
false,
2769 'bJoinSection' =>
false,
2771 $arJoinProps[
'BE'][$propertyId] = self::addJoinTypeSelect($arJoinProps[
'BE'][$propertyId]);
2773 $iElCnt = $arJoinProps[
"BE"][$db_prop[
"ID"]][
"CNT"];
2775 if($db_jprop[
"USER_TYPE"]!=
"")
2777 $arUserType = CIBlockProperty::GetUserType($db_jprop[
"USER_TYPE"]);
2778 if(array_key_exists(
"ConvertFromDB", $arUserType))
2779 $this->arIBlockConvProps[
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE"] =
array(
2780 "ConvertFromDB" => $arUserType[
"ConvertFromDB"],
2781 "PROPERTY" => $db_jprop,
2785 $comp_prop_id = $db_jprop[
"ID"].
"~".$db_prop[
"ID"];
2788 if($db_jprop[
"VERSION"] == 2)
2791 if($db_jprop[
"MULTIPLE"] ==
"N")
2794 if($db_jprop[
"PROPERTY_TYPE"]==
"N")
2795 $this->arIBlockNumProps[
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE"] = $db_prop;
2798 if($db_jprop[
"PROPERTY_TYPE"]==
"L")
2801 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']] ??= [
2802 'CNT' =>
count($arJoinProps[
'BE_FPS']),
2805 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']] = self::addJoinTypeSelect(
2806 $arJoinProps[
'BE_FPS'][$db_jprop[
'IBLOCK_ID']]
2809 $ijPropCnt = $arJoinProps[
"BE_FPS"][$db_jprop[
"IBLOCK_ID"]][
"CNT"];
2811 $arJoinProps[
'BE_FPEN'][$comp_prop_id] ??= [
2812 "CNT" =>
count($arJoinProps[
"BE_FPEN"]),
2815 "ORIG_ID" => $db_jprop[
"ORIG_ID"],
2816 "JOIN" => $ijPropCnt,
2817 "bFullJoin" =>
false,
2819 $arJoinProps[
'BE_FPEN'][$comp_prop_id] = self::addJoinTypeSelect(
2820 $arJoinProps[
'BE_FPEN'][$comp_prop_id]
2823 $ijFpenCnt = $arJoinProps[
"BE_FPEN"][$comp_prop_id][
"CNT"];
2825 $arSelect[
"JFPEN".$ijFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2826 $arSelect[
"JFPEN".$ijFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_ENUM_ID", $this->arIBlockLongProps);
2831 $singleValueKey = $db_jprop[
'IBLOCK_ID'] .
'~' . $db_prop[
'ID'];
2833 $arJoinProps[
'BE_FPS'][$singleValueKey] ??= [
2834 'CNT' =>
count($arJoinProps[
'BE_FPS']),
2837 $arJoinProps[
'BE_FPS'][$singleValueKey] = self::addJoinTypeSelect(
2838 $arJoinProps[
'BE_FPS'][$singleValueKey]
2841 $ijPropCnt = $arJoinProps[
"BE_FPS"][$singleValueKey][
"CNT"];
2842 unset($singleValueKey);
2844 $arSelect[
"JFPS".$ijPropCnt.
".PROPERTY_".$db_jprop[
"ORIG_ID"]] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2845 if(
$sGroupBy==
"" && $db_jprop[
"WITH_DESCRIPTION"] ==
"Y")
2846 $arSelect[
"JFPS".$ijPropCnt.
".DESCRIPTION_".$db_jprop[
"ORIG_ID"]] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_DESCRIPTION", $this->arIBlockLongProps);
2852 $arSelect[
$DB->Concat(
"BE".$iElCnt.
".ID",
"':'",$db_jprop[
"ORIG_ID"])] =
CIBlockElement::MkAlias($mal, $PR_ID[2].
"_".$PR_ID[1].
"_VALUE_ID", $this->arIBlockLongProps);
2858 $arJoinProps[
'BE_FP'][$comp_prop_id] ??= [
2859 'CNT' =>
count($arJoinProps[
'BE_FP']),
2861 'bFullJoin' =>
false,
2863 $arJoinProps[
'BE_FP'][$comp_prop_id] = self::addJoinTypeSelect(
2864 $arJoinProps[
'BE_FP'][$comp_prop_id]
2868 $arJoinProps[
'BE_FPV'][$comp_prop_id] ??= [
2869 'CNT' =>
count($arJoinProps[
'BE_FPV']),
2872 'IBLOCK_ID' => $db_jprop[
'IBLOCK_ID'],
2873 'JOIN' => $arJoinProps[
'BE_FP'][$comp_prop_id][
'CNT'],
2874 'BE_JOIN' => $iElCnt,
2875 'bFullJoin' =>
false,
2877 $arJoinProps[
'BE_FPV'][$comp_prop_id] = self::addJoinTypeSelect(
2878 $arJoinProps[
'BE_FPV'][$comp_prop_id]
2881 $ijPropCnt = $arJoinProps[
"BE_FPV"][$comp_prop_id][
"CNT"];
2884 if($db_jprop[
"PROPERTY_TYPE"]==
"L")
2887 $arJoinProps[
'BE_FPEN'][$comp_prop_id] ??= [
2888 'CNT' =>
count($arJoinProps[
'BE_FPEN']),
2891 'ORIG_ID' => $db_jprop[
'ORIG_ID'],
2892 'JOIN' => $ijPropCnt,
2893 'bFullJoin' =>
false,
2895 $arJoinProps[
'BE_FPEN'][$comp_prop_id] = self::addJoinTypeSelect(
2896 $arJoinProps[
'BE_FPEN'][$comp_prop_id]
2899 $ijFpenCnt = $arJoinProps[
"BE_FPEN"][$comp_prop_id][
"CNT"];
2901 $arSelect[
"JFPEN".$ijFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2902 $arSelect[
"JFPEN".$ijFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_ENUM_ID", $this->arIBlockLongProps);
2906 $arSelect[
"JFPV".$ijPropCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2913 $arJoinProps[
'BE_FP'][$comp_prop_id] ??= [
2914 'CNT' =>
count($arJoinProps[
'BE_FP']),
2916 'bFullJoin' =>
false,
2918 $arJoinProps[
'BE_FP'][$comp_prop_id] = self::addJoinTypeSelect(
2919 $arJoinProps[
'BE_FP'][$comp_prop_id]
2923 $arJoinProps[
'BE_FPV'][$comp_prop_id] ??= [
2924 'CNT' =>
count($arJoinProps[
'BE_FPV']),
2925 'MULTIPLE' => $db_jprop[
'MULTIPLE'],
2927 'IBLOCK_ID' => $db_jprop[
'IBLOCK_ID'],
2928 'JOIN' => $arJoinProps[
'BE_FP'][$comp_prop_id][
'CNT'],
2929 'BE_JOIN' => $iElCnt,
2930 'bFullJoin' =>
false,
2932 $arJoinProps[
'BE_FPV'][$comp_prop_id] = self::addJoinTypeSelect(
2933 $arJoinProps[
'BE_FPV'][$comp_prop_id]
2936 $ijPropCnt = $arJoinProps[
"BE_FPV"][$comp_prop_id][
"CNT"];
2939 if($db_jprop[
"PROPERTY_TYPE"]==
"L")
2942 $arJoinProps[
'BE_FPEN'][$comp_prop_id] ??= [
2943 'CNT' =>
count($arJoinProps[
'BE_FPEN']),
2944 'MULTIPLE' => $db_jprop[
'MULTIPLE'],
2946 'ORIG_ID' => $db_jprop[
'ORIG_ID'],
2947 'JOIN' => $ijPropCnt,
2948 'bFullJoin' =>
false,
2950 $arJoinProps[
'BE_FPEN'][$comp_prop_id] = self::addJoinTypeSelect(
2951 $arJoinProps[
'BE_FPEN'][$comp_prop_id]
2954 $ijFpenCnt = $arJoinProps[
"BE_FPEN"][$comp_prop_id][
"CNT"];
2956 $arSelect[
"JFPEN".$ijFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2957 $arSelect[
"JFPEN".$ijFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_ENUM_ID", $this->arIBlockLongProps);
2961 $arSelect[
"JFPV".$ijPropCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE", $this->arIBlockLongProps);
2966 $arSelect[
"JFPV".$ijPropCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID[1].
"_".$PR_ID[2].
"_VALUE_ID", $this->arIBlockLongProps);
2975 if($db_prop[
"USER_TYPE"]!=
"")
2977 $arUserType = CIBlockProperty::GetUserType($db_prop[
"USER_TYPE"]);
2978 if(array_key_exists(
"ConvertFromDB", $arUserType))
2979 $this->arIBlockConvProps[
"PROPERTY_".$PR_ID.
"_VALUE"] =
array(
2980 "ConvertFromDB" => $arUserType[
"ConvertFromDB"],
2981 "PROPERTY" => $db_prop,
2986 if($db_prop[
"VERSION"] == 2)
2989 if($db_prop[
"MULTIPLE"] ==
"N")
2992 if($db_prop[
"PROPERTY_TYPE"]==
"N")
2993 $this->arIBlockNumProps[
"PROPERTY_".$PR_ID.
"_VALUE"] = $db_prop;
2996 if($db_prop[
"PROPERTY_TYPE"]==
"L")
2999 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
3000 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
3001 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
3003 if(!array_key_exists($db_prop[
"ID"], $arJoinProps[
"FPEN"]))
3005 $arJoinProps[
'FPEN'][$propertyId] ??= [
3006 'CNT' =>
count($arJoinProps[
'FPEN']),
3009 'ORIG_ID' => $db_prop[
'ORIG_ID'],
3010 'JOIN' => $iPropCnt,
3011 'bFullJoin' =>
false,
3013 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeSelect(
3014 $arJoinProps[
'FPEN'][$propertyId]
3017 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
3020 $arSelect[
"FPEN".$iFpenCnt.
".SORT"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_SORT", $this->arIBlockLongProps);
3021 $arSelect[
"FPEN".$iFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3022 $arSelect[
"FPEN".$iFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_ENUM_ID", $this->arIBlockLongProps);
3027 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
3028 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
3029 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
3031 $arSelect[
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"]] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3032 if(
$sGroupBy==
"" && $db_prop[
"WITH_DESCRIPTION"] ==
"Y")
3039 $arSelect[
$DB->Concat(
"BE.ID",
"':'",$db_prop[
"ORIG_ID"])] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE_ID", $this->arIBlockLongProps);
3045 if(!$bWasGroup && !$bSubQuery)
3048 if(!array_key_exists($db_prop[
"IBLOCK_ID"], $arJoinProps[
"FPS"]))
3049 $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]] =
count($arJoinProps[
"FPS"]);
3050 $iPropCnt = $arJoinProps[
"FPS"][$db_prop[
"IBLOCK_ID"]];
3052 $arSelect[
"FPS".$iPropCnt.
".PROPERTY_".$db_prop[
"ORIG_ID"]] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3053 if(
$sGroupBy==
"" && $db_prop[
"WITH_DESCRIPTION"] ==
"Y")
3054 $arSelect[
"FPS".$iPropCnt.
".DESCRIPTION_".$db_prop[
"ORIG_ID"]] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_DESCRIPTION", $this->arIBlockLongProps);
3057 $this->arIBlockMultProps[
"PROPERTY_".$PR_ID.
"_VALUE"] = $db_prop;
3063 $arJoinProps[
'FP'][$propertyId] ??= [
3064 'CNT' =>
count($arJoinProps[
'FP']),
3065 'bFullJoin' =>
false,
3067 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeSelect(
3068 $arJoinProps[
'FP'][$propertyId]
3072 $arJoinProps[
'FPV'][$propertyId] ??= [
3073 'CNT' =>
count($arJoinProps[
'FPV']),
3074 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
3077 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
3078 'bFullJoin' =>
false,
3080 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeSelect(
3081 $arJoinProps[
'FPV'][$propertyId]
3084 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
3087 if($db_prop[
"PROPERTY_TYPE"]==
"L")
3090 $arJoinProps[
'FPEN'][$propertyId] ??= [
3091 'CNT' =>
count($arJoinProps[
'FPEN']),
3094 'ORIG_ID' => $db_prop[
'ORIG_ID'],
3095 'JOIN' => $iPropCnt,
3096 'bFullJoin' =>
false,
3098 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeSelect(
3099 $arJoinProps[
'FPEN'][$propertyId]
3102 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
3105 $arSelect[
"FPEN".$iFpenCnt.
".SORT"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_SORT", $this->arIBlockLongProps);
3106 $arSelect[
"FPEN".$iFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3107 $arSelect[
"FPEN".$iFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_ENUM_ID", $this->arIBlockLongProps);
3111 $arSelect[
"FPV".$iPropCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3119 $arJoinProps[
'FP'][$propertyId] ??= [
3120 'CNT' =>
count($arJoinProps[
'FP']),
3121 'bFullJoin' =>
false,
3123 $arJoinProps[
'FP'][$propertyId] = self::addJoinTypeSelect(
3124 $arJoinProps[
'FP'][$propertyId]
3128 $arJoinProps[
'FPV'][$propertyId] ??= [
3129 'CNT' =>
count($arJoinProps[
'FPV']),
3130 'IBLOCK_ID' => $db_prop[
'IBLOCK_ID'],
3131 'MULTIPLE' => $db_prop[
'MULTIPLE'],
3133 'JOIN' => $arJoinProps[
'FP'][$propertyId][
'CNT'],
3134 'bFullJoin' =>
false,
3136 $arJoinProps[
'FPV'][$propertyId] = self::addJoinTypeSelect(
3137 $arJoinProps[
'FPV'][$propertyId]
3139 $iPropCnt = $arJoinProps[
"FPV"][$db_prop[
"ID"]][
"CNT"];
3142 if($db_prop[
"PROPERTY_TYPE"]==
"L")
3145 $arJoinProps[
'FPEN'][$propertyId] ??= [
3146 'CNT' =>
count($arJoinProps[
'FPEN']),
3147 'MULTIPLE' => $db_prop[
'MULTIPLE'],
3149 'ORIG_ID' => $db_prop[
'ORIG_ID'],
3150 'JOIN' => $iPropCnt,
3151 'bFullJoin' =>
false,
3153 $arJoinProps[
'FPEN'][$propertyId] = self::addJoinTypeSelect(
3154 $arJoinProps[
'FPEN'][$propertyId]
3157 $iFpenCnt = $arJoinProps[
"FPEN"][$db_prop[
"ID"]][
"CNT"];
3160 $arSelect[
"FPEN".$iFpenCnt.
".SORT"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_SORT", $this->arIBlockLongProps);
3161 $arSelect[
"FPEN".$iFpenCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3162 $arSelect[
"FPEN".$iFpenCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_ENUM_ID", $this->arIBlockLongProps);
3170 'PROPERTY_' . $PR_ID .
'_VALUE_NUM',
3171 $this->arIBlockLongProps
3174 $arSelect[
"FPV".$iPropCnt.
".VALUE"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE", $this->arIBlockLongProps);
3179 $arSelect[
"FPV".$iPropCnt.
".ID"] =
CIBlockElement::MkAlias($mal,
"PROPERTY_".$PR_ID.
"_VALUE_ID", $this->arIBlockLongProps);
3186 foreach($arSelect as $column => $alias)
3188 if(preg_match(
'/^(FPV\\d+)\\.VALUE/', $column, $match))
3190 $sSelect .=
", ".$match[1].
".VALUE_NUM";
3193 elseif(preg_match(
'/^(FPS\\d+)\\.PROPERTY_/', $column))
3202 foreach($arSelect as $column => $alias)
3203 $sSelect .=
", ".$column.
" as ".$alias;
3209 if($max_alias_len && mb_strlen($alias) > $max_alias_len)
3213 $alias =
"ALIAS_".$alias_index.
"_";
3224 private static function checkPropertyIdentifier(
int|
string $identifier): bool
3226 $identifier = (string)$identifier;
3227 if ($identifier ===
'')
3234 foreach (self::$propertyIdentifierMasks as $mask)
3236 if (preg_match($mask, $identifier, $prepared))
3252 private static function checkPropertyLinkIdentifier(
string $identifier): bool
3254 if ($identifier ===
'')
3260 if (!preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $identifier, $prepared))
3265 if (!static::checkPropertyIdentifier($prepared[1]))
3272 foreach (self::$propertyLinkFieldIdentifierMasks as $mask)
3274 if (preg_match($mask, $prepared[2], $subprepared))
3285 &$arIblockElementFields,
3290 &$arAddSelectFields,
3302 &$arAddOrderByFields
3306 is_array($arSelectFields)
3307 && (in_array(
"DETAIL_PAGE_URL", $arSelectFields) || in_array(
"CANONICAL_PAGE_URL", $arSelectFields))
3308 && !in_array(
"LANG_DIR", $arSelectFields)
3311 $arSelectFields[] =
"LANG_DIR";
3316 if (empty($arSelectFields))
3318 $arSelectFields = [
'*'];
3321 if ($arGroupBy ===
true)
3326 if (empty($arGroupBy) && is_array($arGroupBy))
3328 $this->bOnlyCount =
true;
3399 $this->arIBlockMultProps = [];
3400 $this->arIBlockAllProps = [];
3401 $this->arIBlockNumProps = [];
3406 $iblockIds = CIBlock::_MergeIBArrays(
3410 $orderAlias =
array(
3411 'EXTERNAL_ID' =>
'XML_ID',
3412 'DATE_ACTIVE_FROM' =>
'ACTIVE_FROM',
3413 'DATE_ACTIVE_TO' =>
'ACTIVE_TO'
3416 $arAddOrderByFields = [];
3418 if (!is_array($arOrder))
3422 foreach($arOrder as $by=>
$order)
3425 $by = mb_strtoupper($by);
3427 if (isset($orderAlias[$by]))
3428 $by = $orderAlias[$by];
3430 if (isset($arSqlOrder[$by]))
3436 $arAddOrderByFields[$iOrdNum] = Array($by=>
$order);
3438 $arSqlOrder[$iOrdNum] =
false;
3443 elseif($by ==
"NAME") $arSqlOrder[$by] = CIBlock::_Order(
"BE.NAME",
$order,
"desc",
false);
3444 elseif($by ==
"STATUS") $arSqlOrder[$by] = CIBlock::_Order(
"BE.WF_STATUS_ID",
$order,
"desc");
3445 elseif($by ==
"XML_ID") $arSqlOrder[$by] = CIBlock::_Order(
"BE.XML_ID",
$order,
"desc");
3446 elseif($by ==
"CODE") $arSqlOrder[$by] = CIBlock::_Order(
"BE.CODE",
$order,
"desc");
3447 elseif($by ==
"TAGS") $arSqlOrder[$by] = CIBlock::_Order(
"BE.TAGS",
$order,
"desc");
3448 elseif($by ==
"TIMESTAMP_X") $arSqlOrder[$by] = CIBlock::_Order(
"BE.TIMESTAMP_X",
$order,
"desc");
3449 elseif($by ==
"CREATED") $arSqlOrder[$by] = CIBlock::_Order(
"BE.DATE_CREATE",
$order,
"desc");
3450 elseif($by ==
"CREATED_DATE") $arSqlOrder[$by] = CIBlock::_Order(
$DB->DateFormatToDB(
"YYYY.MM.DD",
"BE.DATE_CREATE"),
$order,
"desc");
3451 elseif($by ==
"IBLOCK_ID") $arSqlOrder[$by] = CIBlock::_Order(
"BE.IBLOCK_ID",
$order,
"desc");
3452 elseif($by ==
"MODIFIED_BY") $arSqlOrder[$by] = CIBlock::_Order(
"BE.MODIFIED_BY",
$order,
"desc");
3453 elseif($by ==
"CREATED_BY") $arSqlOrder[$by] = CIBlock::_Order(
"BE.CREATED_BY",
$order,
"desc");
3454 elseif($by ==
"ACTIVE") $arSqlOrder[$by] = CIBlock::_Order(
"BE.ACTIVE",
$order,
"desc");
3455 elseif($by ==
"ACTIVE_FROM") $arSqlOrder[$by] = CIBlock::_Order(
"BE.ACTIVE_FROM",
$order,
"desc");
3456 elseif($by ==
"ACTIVE_TO") $arSqlOrder[$by] = CIBlock::_Order(
"BE.ACTIVE_TO",
$order,
"desc");
3457 elseif($by ==
"SORT") $arSqlOrder[$by] = CIBlock::_Order(
"BE.SORT",
$order,
"desc");
3458 elseif($by ==
"IBLOCK_SECTION_ID") $arSqlOrder[$by] = CIBlock::_Order(
"BE.IBLOCK_SECTION_ID",
$order,
"desc");
3459 elseif($by ==
"SHOW_COUNTER") $arSqlOrder[$by] = CIBlock::_Order(
"BE.SHOW_COUNTER",
$order,
"desc");
3460 elseif($by ==
"SHOW_COUNTER_START") $arSqlOrder[$by] = CIBlock::_Order(
"BE.SHOW_COUNTER_START",
$order,
"desc");
3461 elseif($by ==
"RAND") $arSqlOrder[$by] = CIBlockElement::GetRandFunction();
3462 elseif($by ==
"SHOWS") $arSqlOrder[$by] = CIBlock::_Order(
'SHOWS',
$order,
"desc",
false);
3463 elseif($by ==
"HAS_PREVIEW_PICTURE") $arSqlOrder[$by] = CIBlock::_Order(CIBlock::_NotEmpty(
"BE.PREVIEW_PICTURE"),
$order,
"desc",
false);
3464 elseif($by ==
"HAS_DETAIL_PICTURE") $arSqlOrder[$by] = CIBlock::_Order(CIBlock::_NotEmpty(
"BE.DETAIL_PICTURE"),
$order,
"desc",
false);
3465 elseif($by ==
"RATING_TOTAL_VALUE")
3467 $arSqlOrder[$by] = CIBlock::_Order(
"RV.TOTAL_VALUE",
$order,
"desc");
3468 $arJoinProps[
"RV"] =
true;
3472 if (!empty($arGroupBy) && is_array($arGroupBy))
3474 $arSqlOrder[$by] =
' '.CIBlock::_Order(
'CNT',
$order,
'desc',
false).
' ';
3477 elseif(mb_substr($by, 0, 9) ==
"PROPERTY_")
3479 $propID = mb_strtoupper(mb_substr($by_orig, 9));
3480 if (preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $propID, $arMatch))
3482 if (self::checkPropertyLinkIdentifier($propID))
3484 $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], $iblockIds);
3493 if (self::checkPropertyIdentifier($propID))
3495 $db_prop = CIBlockProperty::GetPropertyArray($propID, $iblockIds);
3503 elseif(mb_substr($by, 0, 13) ==
"PROPERTYSORT_")
3505 $propID = mb_strtoupper(mb_substr($by_orig, 13));
3506 if (preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $propID, $arMatch))
3508 if (self::checkPropertyLinkIdentifier($propID))
3510 $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], $iblockIds);
3519 if (self::checkPropertyIdentifier($propID))
3521 $db_prop = CIBlockProperty::GetPropertyArray($propID, $iblockIds);
3532 if (!isset($arSqlOrder[$by]))
3534 $arSqlOrder[$by] = CIBlock::_Order(
"BE.ID",
$order,
"desc");
3539 if (isset($arSqlOrder[$by]) && is_array($arSqlOrder[$by]))
3541 if (!empty($arGroupBy) && is_array($arGroupBy))
3542 $arGroupBy[] = $arSqlOrder[$by][1];
3544 $arSelectFields[] = $arSqlOrder[$by][1];
3546 $arIblockElementFields[$arSqlOrder[$by][1]] = $arSqlOrder[$by][0];
3548 $arSqlOrder[$by] = $arSqlOrder[$by][2];
3554 if (!empty($arGroupBy) && is_array($arGroupBy))
3556 if ($by ==
"STATUS")
3558 $arGroupBy[] =
"WF_STATUS_ID";
3560 elseif ($by ==
"CREATED")
3562 $arGroupBy[] =
"DATE_CREATE";
3566 $arGroupBy[] =
"SHOW_COUNTER";
3567 $arGroupBy[] =
"SHOW_COUNTER_START_X";
3576 if ($by ==
"STATUS")
3578 $arSelectFields[] =
"WF_STATUS_ID";
3580 elseif ($by ==
"CREATED")
3582 $arSelectFields[] =
"DATE_CREATE";
3586 $arSelectFields[] =
'SHOWS';
3587 $arSelectFields[] =
"SHOW_COUNTER";
3588 $arSelectFields[] =
"SHOW_COUNTER_START_X";
3592 $arSelectFields[] = $by;
3599 if(!empty($arGroupBy) && is_array($arGroupBy))
3601 $arSelectFields = $arGroupBy;
3603 foreach($arSelectFields as
$key=>
$val)
3606 if(array_key_exists(
$val, $arIblockElementFields))
3608 $sGroupBy.=
",".preg_replace(
"/(\s+AS\s+[A-Z_]+)/i",
"", $arIblockElementFields[
$val]);
3612 $PR_ID = mb_strtoupper(mb_substr(
$val, 9));
3613 if($db_prop = CIBlockProperty::GetPropertyArray($PR_ID, $iblockIds))
3616 elseif(mb_substr(
$val, 0, 13) ==
"PROPERTYSORT_")
3618 $PR_ID = mb_strtoupper(mb_substr(
$val, 13));
3619 if($db_prop = CIBlockProperty::GetPropertyArray($PR_ID, $iblockIds))
3630 $arAddSelectFields = [];
3631 if($this->bOnlyCount)
3633 $sSelect =
"COUNT(%%_DISTINCT_%% BE.ID) as CNT ";
3638 $arDisplayedColumns =
array();
3640 foreach($arSelectFields as
$key=>
$val)
3643 if(array_key_exists(
$val, $arIblockElementFields))
3645 if(isset($arDisplayedColumns[
$val]))
3647 $arDisplayedColumns[
$val] =
true;
3655 $arPropertyFilter =
array(
3659 if(array_key_exists(
"IBLOCK_ID",
$arFilter))
3662 $arPropertyFilter[
"IBLOCK_ID"] =
$arFilter[
"IBLOCK_ID"][0];
3664 $arPropertyFilter[
"IBLOCK_ID"] =
$arFilter[
"IBLOCK_ID"];
3666 if(!array_key_exists(
"IBLOCK_ID", $arPropertyFilter))
3668 if(array_key_exists(
"IBLOCK_CODE",
$arFilter))
3671 $arPropertyFilter[
"IBLOCK_CODE"] =
$arFilter[
"IBLOCK_CODE"][0];
3673 $arPropertyFilter[
"IBLOCK_CODE"] =
$arFilter[
"IBLOCK_CODE"];
3681 $rs_prop = CIBlockProperty::GetList(
array(
"sort"=>
"asc"), $arPropertyFilter);
3682 while($db_prop = $rs_prop->Fetch())
3683 $this->arIBlockAllProps[]=$db_prop;
3685 foreach($this->arIBlockAllProps as $db_prop)
3687 if($db_prop[
"USER_TYPE"]!=
"")
3689 $arUserType = CIBlockProperty::GetUserType($db_prop[
"USER_TYPE"]);
3690 if(array_key_exists(
"ConvertFromDB", $arUserType))
3691 $this->arIBlockConvProps[
"PROPERTY_".$db_prop[
"ID"]] =
array(
3692 "ConvertFromDB"=>$arUserType[
"ConvertFromDB"],
3693 "PROPERTY"=>$db_prop,
3696 $db_prop[
"ORIG_ID"] = $db_prop[
"ID"];
3697 if($db_prop[
"MULTIPLE"]==
"Y")
3698 $this->arIBlockMultProps[
"PROPERTY_".$db_prop[
"ID"]] = $db_prop;
3699 $iblock_id = $db_prop[
"IBLOCK_ID"];
3701 if($iblock_id!==
false)
3703 if(!array_key_exists($iblock_id, $arJoinProps[
"FPS"]))
3704 $arJoinProps[
"FPS"][$iblock_id] =
count($arJoinProps[
"FPS"]);
3705 $iPropCnt = $arJoinProps[
"FPS"][$iblock_id];
3707 $sSelect .=
", FPS".$iPropCnt.
".*";
3712 $PR_ID = mb_strtoupper(
$val);
3713 if(isset($arDisplayedColumns[$PR_ID]))
3715 $arDisplayedColumns[$PR_ID] =
true;
3716 $PR_ID = mb_substr($PR_ID, 9);
3718 $iblockIds = CIBlock::_MergeIBArrays(
3723 if(preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $PR_ID, $arMatch))
3725 if (self::checkPropertyLinkIdentifier($PR_ID))
3727 $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], $iblockIds);
3728 if (is_array($db_prop) && $db_prop[
"PROPERTY_TYPE"] ==
"E")
3736 if (self::checkPropertyIdentifier($PR_ID))
3738 $db_prop = CIBlockProperty::GetPropertyArray($PR_ID, $iblockIds);
3746 elseif(mb_substr(
$val, 0, 13) ==
"PROPERTYSORT_")
3748 $PR_ID = mb_strtoupper(
$val);
3749 if(isset($arDisplayedColumns[$PR_ID]))
3751 $arDisplayedColumns[$PR_ID] =
true;
3752 $PR_ID = mb_substr($PR_ID, 13);
3754 if(preg_match(self::PROPERTY_LINK_ELEMENT_MASK, $PR_ID, $arMatch))
3756 if (self::checkPropertyLinkIdentifier($PR_ID))
3758 $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], $iblockIds);
3759 if (is_array($db_prop) && $db_prop[
"PROPERTY_TYPE"] ==
"E")
3765 if (self::checkPropertyIdentifier($PR_ID))
3767 if ($db_prop = CIBlockProperty::GetPropertyArray($PR_ID, $iblockIds))
3778 $arAddSelectFields[] =
$val;
3781 $val ==
"RATING_TOTAL_VALUE"
3782 ||
$val ==
"RATING_TOTAL_VOTES"
3783 ||
$val ==
"RATING_TOTAL_POSITIVE_VOTES"
3784 ||
$val ==
"RATING_TOTAL_NEGATIVE_VOTES"
3787 if(isset($arDisplayedColumns[
$val]))
3789 $arDisplayedColumns[
$val] =
true;
3792 $arJoinProps[
"RV"] =
true;
3796 if(isset($arDisplayedColumns[
$val]))
3798 $arDisplayedColumns[
$val] =
true;
3802 if ($this->userExists)
3804 $sSelect.=
",".$DB->IsNull(
'RVU.VALUE',
'0').
" as ".
$val;
3805 $arJoinProps[
"RVU"] =
true;
3815 $sSelect .=
',' . CIBlockElement::GetShowedFunction() .
' as ' .
$val;
3821 foreach($arIblockElementFields as
$key=>
$val)
3823 if(isset($arDisplayedColumns[
$key]))
3825 $arDisplayedColumns[
$key] =
true;
3826 $arSelectFields[]=
$key;
3833 if(isset($arDisplayedColumns[
"DETAIL_PAGE_URL"]))
3834 $arAddFields =
array(
"LANG_DIR",
"ID",
"CODE",
"EXTERNAL_ID",
"IBLOCK_SECTION_ID",
"IBLOCK_TYPE_ID",
"IBLOCK_ID",
"IBLOCK_CODE",
"IBLOCK_EXTERNAL_ID",
"LID");
3835 elseif(isset($arDisplayedColumns[
"CANONICAL_PAGE_URL"]))
3836 $arAddFields =
array(
"LANG_DIR",
"ID",
"CODE",
"EXTERNAL_ID",
"IBLOCK_SECTION_ID",
"IBLOCK_TYPE_ID",
"IBLOCK_ID",
"IBLOCK_CODE",
"IBLOCK_EXTERNAL_ID",
"LID");
3837 elseif(isset($arDisplayedColumns[
"SECTION_PAGE_URL"]))
3838 $arAddFields =
array(
"LANG_DIR",
"ID",
"CODE",
"EXTERNAL_ID",
"IBLOCK_SECTION_ID",
"IBLOCK_TYPE_ID",
"IBLOCK_ID",
"IBLOCK_CODE",
"IBLOCK_EXTERNAL_ID",
"LID");
3839 elseif(isset($arDisplayedColumns[
"LIST_PAGE_URL"]))
3840 $arAddFields =
array(
"LANG_DIR",
"IBLOCK_TYPE_ID",
"IBLOCK_ID",
"IBLOCK_CODE",
"IBLOCK_EXTERNAL_ID",
"LID");
3842 $arAddFields =
array();
3845 if(isset($arDisplayedColumns[
"DETAIL_TEXT"]))
3846 $arAddFields[] =
"DETAIL_TEXT_TYPE";
3847 if(isset($arDisplayedColumns[
"PREVIEW_TEXT"]))
3848 $arAddFields[] =
"PREVIEW_TEXT_TYPE";
3850 foreach($arAddFields as
$key)
3852 if(isset($arDisplayedColumns[
$key]))
3854 $arDisplayedColumns[
$key] =
true;
3855 $arSelectFields[]=
$key;
3862 $sSelect = mb_substr(
$sSelect, 1).
", COUNT(%%_DISTINCT_%% BE.ID) as CNT ";
3871 $arAddWhereFields = [];
3874 $arAddWhereFields =
$arFilter[
"CATALOG"];
3878 $arSqlSearch = CIBlockElement::MkFilter(
$arFilter, $arJoinProps, $arAddWhereFields);
3879 $this->bDistinct =
false;
3880 $sSectionWhere =
"";
3883 foreach ($arSqlSearch as $condition)
3885 if (trim($condition,
"\n\t") !==
'')
3887 $sWhere .=
"\n\t\t\tAND (" . $condition .
")";
3895 public function Add(
$arFields, $bWorkFlow=
false, $bUpdateSearch=
true, $bResizePictures=
false)
3899 if ($this->iblock !==
null && $this->iblock[
'ID'] === (
int)
$arFields[
"IBLOCK_ID"])
3909 $bWorkFlow = $bWorkFlow && $existIblock && (
$arIBlock[
"WORKFLOW"] !=
"N") && $this->workflowIncluded;
3910 $bBizProc = $existIblock && (
$arIBlock[
"BIZPROC"] ==
"Y") && $this->bizprocInstalled;
3934 if(array_key_exists(
"IBLOCK_SECTION_ID",
$arFields))
3936 if (!isset(
$arFields[
"IBLOCK_SECTION"]))
3947 if($bResizePictures)
3949 $arDef =
$arIBlock[
"FIELDS"][
"PREVIEW_PICTURE"][
"DEFAULT_VALUE"];
3952 $arDef[
"FROM_DETAIL"] ===
"Y"
3954 && is_array(
$arFields[
"DETAIL_PICTURE"])
3955 &&
$arFields[
"DETAIL_PICTURE"][
"size"] > 0
3957 $arDef[
"UPDATE_WITH_DETAIL"] ===
"Y"
3958 ||
$arFields[
"PREVIEW_PICTURE"][
"size"] <= 0
3962 $arNewPreview =
$arFields[
"DETAIL_PICTURE"];
3963 $arNewPreview[
"COPY_FILE"] =
"Y";
3966 && is_array(
$arFields[
"PREVIEW_PICTURE"])
3967 && isset(
$arFields[
"PREVIEW_PICTURE"][
"description"])
3970 $arNewPreview[
"description"] =
$arFields[
"PREVIEW_PICTURE"][
"description"];
3973 $arFields[
"PREVIEW_PICTURE"] = $arNewPreview;
3978 && is_array(
$arFields[
"PREVIEW_PICTURE"])
3979 && $arDef[
"SCALE"] ===
"Y"
3982 $arNewPicture = CIBlock::ResizePicture(
$arFields[
"PREVIEW_PICTURE"], $arDef);
3983 if(is_array($arNewPicture))
3985 $arNewPicture[
"description"] =
$arFields[
"PREVIEW_PICTURE"][
"description"];
3986 $arFields[
"PREVIEW_PICTURE"] = $arNewPicture;
3988 elseif($arDef[
"IGNORE_ERRORS"] !==
"Y")
3997 && is_array(
$arFields[
"PREVIEW_PICTURE"])
3998 && $arDef[
"USE_WATERMARK_FILE"] ===
"Y"
4001 $arFields[
"PREVIEW_PICTURE"][
"copy"] ??=
null;
4003 $arFields[
"PREVIEW_PICTURE"][
"tmp_name"] <>
''
4006 || (
$arFields[
"PREVIEW_PICTURE"][
"COPY_FILE"] ==
"Y" && !
$arFields[
"PREVIEW_PICTURE"][
"copy"])
4010 $tmp_name = CTempFile::GetFileName(basename(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"]));
4012 copy(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"], $tmp_name);
4013 $arFields[
"PREVIEW_PICTURE"][
"copy"] =
true;
4014 $arFields[
"PREVIEW_PICTURE"][
"tmp_name"] = $tmp_name;
4017 CIBlock::FilterPicture(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"],
array(
4018 "name" =>
"watermark",
4019 "position" => $arDef[
"WATERMARK_FILE_POSITION"],
4022 "alpha_level" => 100 - min(max($arDef[
"WATERMARK_FILE_ALPHA"], 0), 100),
4023 "file" =>
$_SERVER[
"DOCUMENT_ROOT"].
Rel2Abs(
"/", $arDef[
"WATERMARK_FILE"]),
4029 && is_array(
$arFields[
"PREVIEW_PICTURE"])
4030 && $arDef[
"USE_WATERMARK_TEXT"] ===
"Y"
4033 $arFields[
"PREVIEW_PICTURE"][
"copy"] ??=
null;
4035 $arFields[
"PREVIEW_PICTURE"][
"tmp_name"] <>
''
4038 || (
$arFields[
"PREVIEW_PICTURE"][
"COPY_FILE"] ==
"Y" && !
$arFields[
"PREVIEW_PICTURE"][
"copy"])
4042 $tmp_name = CTempFile::GetFileName(basename(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"]));
4044 copy(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"], $tmp_name);
4045 $arFields[
"PREVIEW_PICTURE"][
"copy"] =
true;
4046 $arFields[
"PREVIEW_PICTURE"][
"tmp_name"] = $tmp_name;
4049 CIBlock::FilterPicture(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"],
array(
4050 "name" =>
"watermark",
4051 "position" => $arDef[
"WATERMARK_TEXT_POSITION"],
4053 "coefficient" => $arDef[
"WATERMARK_TEXT_SIZE"],
4054 "text" => $arDef[
"WATERMARK_TEXT"],
4055 "font" =>
$_SERVER[
"DOCUMENT_ROOT"].
Rel2Abs(
"/", $arDef[
"WATERMARK_TEXT_FONT"]),
4056 "color" => $arDef[
"WATERMARK_TEXT_COLOR"],
4060 $arDef =
$arIBlock[
"FIELDS"][
"DETAIL_PICTURE"][
"DEFAULT_VALUE"];
4064 && is_array(
$arFields[
"DETAIL_PICTURE"])
4065 && $arDef[
"SCALE"] ===
"Y"
4068 $arNewPicture = CIBlock::ResizePicture(
$arFields[
"DETAIL_PICTURE"], $arDef);
4069 if(is_array($arNewPicture))
4071 $arNewPicture[
"description"] =
$arFields[
"DETAIL_PICTURE"][
"description"];
4072 $arFields[
"DETAIL_PICTURE"] = $arNewPicture;
4074 elseif($arDef[
"IGNORE_ERRORS"] !==
"Y")
4083 && is_array(
$arFields[
"DETAIL_PICTURE"])
4084 && $arDef[
"USE_WATERMARK_FILE"] ===
"Y"
4087 $arFields[
"DETAIL_PICTURE"][
"copy"] ??=
null;
4089 $arFields[
"DETAIL_PICTURE"][
"tmp_name"] <>
''
4092 || (
$arFields[
"DETAIL_PICTURE"][
"COPY_FILE"] ==
"Y" && !
$arFields[
"DETAIL_PICTURE"][
"copy"])
4096 $tmp_name = CTempFile::GetFileName(basename(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"]));
4098 copy(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"], $tmp_name);
4099 $arFields[
"DETAIL_PICTURE"][
"copy"] =
true;
4100 $arFields[
"DETAIL_PICTURE"][
"tmp_name"] = $tmp_name;
4103 CIBlock::FilterPicture(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"],
array(
4104 "name" =>
"watermark",
4105 "position" => $arDef[
"WATERMARK_FILE_POSITION"],
4108 "alpha_level" => 100 - min(max($arDef[
"WATERMARK_FILE_ALPHA"], 0), 100),
4109 "file" =>
$_SERVER[
"DOCUMENT_ROOT"].
Rel2Abs(
"/", $arDef[
"WATERMARK_FILE"]),
4115 && is_array(
$arFields[
"DETAIL_PICTURE"])
4116 && $arDef[
"USE_WATERMARK_TEXT"] ===
"Y"
4119 $arFields[
"DETAIL_PICTURE"][
"copy"] ??=
null;
4121 $arFields[
"DETAIL_PICTURE"][
"tmp_name"] <>
''
4124 || (
$arFields[
"DETAIL_PICTURE"][
"COPY_FILE"] ==
"Y" && !
$arFields[
"DETAIL_PICTURE"][
"copy"])
4128 $tmp_name = CTempFile::GetFileName(basename(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"]));
4130 copy(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"], $tmp_name);
4131 $arFields[
"DETAIL_PICTURE"][
"copy"] =
true;
4132 $arFields[
"DETAIL_PICTURE"][
"tmp_name"] = $tmp_name;
4135 CIBlock::FilterPicture(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"],
array(
4136 "name" =>
"watermark",
4137 "position" => $arDef[
"WATERMARK_TEXT_POSITION"],
4139 "coefficient" => $arDef[
"WATERMARK_TEXT_SIZE"],
4140 "text" => $arDef[
"WATERMARK_TEXT"],
4141 "font" =>
$_SERVER[
"DOCUMENT_ROOT"].
Rel2Abs(
"/", $arDef[
"WATERMARK_TEXT_FONT"]),
4142 "color" => $arDef[
"WATERMARK_TEXT_COLOR"],
4147 $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates(
$arFields[
"IBLOCK_ID"], 0);
4148 if(array_key_exists(
"PREVIEW_PICTURE",
$arFields))
4150 if (is_array(
$arFields[
"PREVIEW_PICTURE"]))
4153 (
$arFields[
"PREVIEW_PICTURE"][
"name"] ??
'') ===
''
4154 && (
$arFields[
"PREVIEW_PICTURE"][
"del"] ??
'') ===
''
4161 $arFields[
"PREVIEW_PICTURE"][
"MODULE_ID"] =
"iblock";
4164 ,
"ELEMENT_PREVIEW_PICTURE_FILE_NAME"
4172 if((
int)
$arFields[
"PREVIEW_PICTURE"] <= 0)
4177 if(array_key_exists(
"DETAIL_PICTURE",
$arFields))
4179 if (is_array(
$arFields[
"DETAIL_PICTURE"]))
4182 (
$arFields[
"DETAIL_PICTURE"][
"name"] ??
'') ===
''
4183 && (
$arFields[
"DETAIL_PICTURE"][
"del"] ??
'') ===
''
4190 $arFields[
"DETAIL_PICTURE"][
"MODULE_ID"] =
"iblock";
4193 ,
"ELEMENT_DETAIL_PICTURE_FILE_NAME"
4201 if((
int)
$arFields[
"DETAIL_PICTURE"] <= 0)
4232 $arFields[
"SEARCHABLE_CONTENT"] =
false;
4233 if ($this->searchIncluded)
4238 if (isset(
$arFields[
"PREVIEW_TEXT_TYPE"]) &&
$arFields[
"PREVIEW_TEXT_TYPE"] ==
"html")
4244 $arFields[
"SEARCHABLE_CONTENT"] .=
"\r\n".$arFields[
"PREVIEW_TEXT"];
4256 $arFields[
"SEARCHABLE_CONTENT"] .=
"\r\n".$arFields[
"DETAIL_TEXT"];
4270 if(array_key_exists(
"PREVIEW_PICTURE",
$arFields))
4272 $SAVED_PREVIEW_PICTURE =
$arFields[
"PREVIEW_PICTURE"];
4273 if(is_array(
$arFields[
"PREVIEW_PICTURE"]))
4274 CFile::SaveForDB(
$arFields,
"PREVIEW_PICTURE",
"iblock");
4276 $COPY_PREVIEW_PICTURE =
$arFields[
"PREVIEW_PICTURE"];
4279 if(array_key_exists(
"DETAIL_PICTURE",
$arFields))
4281 $SAVED_DETAIL_PICTURE =
$arFields[
"DETAIL_PICTURE"];
4282 if(is_array(
$arFields[
"DETAIL_PICTURE"]))
4283 CFile::SaveForDB(
$arFields,
"DETAIL_PICTURE",
"iblock");
4285 $COPY_DETAIL_PICTURE =
$arFields[
"DETAIL_PICTURE"];
4289 if ($this->userExists)
4298 foreach (
GetModuleEvents(
"iblock",
"OnIBlockElementAdd",
true) as $arEvent)
4301 $IBLOCK_SECTION_ID =
$arFields[
"IBLOCK_SECTION_ID"] ??
null;
4304 $ID =
$DB->Add(
"b_iblock_element",
$arFields,
array(
"DETAIL_TEXT",
"SEARCHABLE_CONTENT"),
"iblock");
4306 if(array_key_exists(
"PREVIEW_PICTURE",
$arFields))
4309 $arFields[
"PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE;
4312 if(array_key_exists(
"DETAIL_PICTURE",
$arFields))
4315 $arFields[
"DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE;
4320 $DB->Query(
"INSERT INTO b_iblock_element_prop_s".
$arFields[
"IBLOCK_ID"].
"(IBLOCK_ELEMENT_ID)VALUES(".
$ID.
")");
4328 $updateFields =
array();
4332 $updateFields[
"XML_ID"] =
$ID;
4334 if (!$this->searchIncluded)
4338 if (FullText::doesIblockSupportByData(
$arIBlock))
4340 $searchIndexParams = [
4341 'ELEMENT_ID' =>
$ID,
4342 'SEARCH_CONTENT' =>
$arFields[
'SEARCHABLE_CONTENT'],
4345 FullText::add(
$arIBlock[
'ID'], $searchIndexParams);
4348 $updateFields[
'SEARCHABLE_CONTENT'] =
$arFields[
'SEARCHABLE_CONTENT'];
4351 if (!empty($updateFields))
4353 $updateQuery =
$DB->PrepareUpdate(
"b_iblock_element", $updateFields,
"iblock");
4354 if ($updateQuery !=
"")
4356 $updateQuery .=
', TIMESTAMP_X = TIMESTAMP_X';
4357 $DB->Query(
"UPDATE b_iblock_element SET ".$updateQuery.
" WHERE ID = ".
$ID);
4360 unset($updateFields);
4369 $obElementRights->ChangeParents(
array(),
array(0));
4371 $obElementRights->SetRights(
$arFields[
"RIGHTS"]);
4374 if (array_key_exists(
"IPROPERTY_TEMPLATES",
$arFields))
4376 $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates(
$arIBlock[
"ID"],
$ID);
4377 $ipropTemplates->set(
$arFields[
"IPROPERTY_TEMPLATES"]);
4380 if ($bUpdateSearch && $this->searchIncluded)
4388 !isset(
$arFields[
"WF_PARENT_ELEMENT_ID"])
4389 &&
$arIBlock[
"FIELDS"][
"LOG_ELEMENT_ADD"][
"IS_REQUIRED"] ==
"Y"
4398 $rsElement = CIBlockElement::GetList(
array(),
array(
"=ID"=>
$ID),
false,
false,
array(
"LIST_PAGE_URL",
"NAME",
"CODE"));
4399 $arElement = $rsElement->GetNext();
4402 "CODE" => $arElement[
"CODE"],
4403 "NAME" => $arElement[
"NAME"],
4404 "ELEMENT_NAME" =>
$arIBlock[
"ELEMENT_NAME"],
4405 "USER_ID" => $this->userId,
4406 "IBLOCK_PAGE_URL" => $arElement[
"LIST_PAGE_URL"],
4410 "IBLOCK_ELEMENT_ADD",
4417 if($bWorkFlow && (
int)(
$arFields[
"WF_PARENT_ELEMENT_ID"] ??
null) <= 0)
4423 $arNewFields[
"PREVIEW_PICTURE"] = $COPY_PREVIEW_PICTURE ??
null;
4424 $arNewFields[
"DETAIL_PICTURE"] = $COPY_DETAIL_PICTURE ??
null;
4426 if (isset($arNewFields[
'PROPERTY_VALUES']) && is_array($arNewFields[
'PROPERTY_VALUES']))
4429 $db_prop = CIBlockProperty::GetList(
array(),
array(
4431 "CHECK_PERMISSIONS" =>
"N",
4432 "PROPERTY_TYPE" =>
"F",
4434 while($arProp = $db_prop->Fetch())
4437 unset($arNewFields[
"PROPERTY_VALUES"][$arProp[
"CODE"]]);
4438 unset($arNewFields[
"PROPERTY_VALUES"][$arProp[
"ID"]]);
4439 $arNewFields[
"PROPERTY_VALUES"][$arProp[
"ID"]] =
array();
4445 while($arProp =
$props->Fetch())
4447 $arNewFields[
"PROPERTY_VALUES"][$arProp[
"ID"]][$arProp[
'PROPERTY_VALUE_ID']] =
array(
4448 "VALUE" => $arProp[
"VALUE"],
4449 "DESCRIPTION" => $arProp[
"DESCRIPTION"],
4455 $WF_ID = $this->
Add($arNewFields);
4456 if($this->bWF_SetMove)
4468 && is_array(
$arFields[
"PREVIEW_PICTURE"])
4469 && (
$arFields[
"PREVIEW_PICTURE"][
"COPY_FILE"] ??
'') ===
"Y"
4470 && (
$arFields[
"PREVIEW_PICTURE"][
"copy"] ??
null)
4473 @unlink(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"]);
4474 @rmdir(dirname(
$arFields[
"PREVIEW_PICTURE"][
"tmp_name"]));
4479 && is_array(
$arFields[
"DETAIL_PICTURE"])
4480 && (
$arFields[
"DETAIL_PICTURE"][
"COPY_FILE"] ??
'') ===
"Y"
4481 && (
$arFields[
"DETAIL_PICTURE"][
"copy"] ??
null)
4484 @unlink(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"]);
4485 @rmdir(dirname(
$arFields[
"DETAIL_PICTURE"][
"tmp_name"]));
4490 foreach (
GetModuleEvents(
"iblock",
"OnAfterIBlockElementAdd",
true) as $arEvent)
4493 CIBlock::clearIblockTagCache(
$arIBlock[
'ID']);
4504 $FILE_ID = (int)$FILE_ID;
4508 if($ELEMENT_ID !==
false)
4510 $ELEMENT_ID = (int)$ELEMENT_ID;
4511 if($ELEMENT_ID <= 0)
4518 if($ELEMENT_ID===
false)
4520 $rsElement =
$DB->Query(
"SELECT IBLOCK_ID, WF_PARENT_ELEMENT_ID from b_iblock_element WHERE ID = ".$ELEMENT_ID);
4521 $arElement = $rsElement->Fetch();
4525 $PARENT_ID = $arElement[
"WF_PARENT_ELEMENT_ID"];
4539 if(
$TYPE ===
"PROPERTY" && $VERSION==2)
4545 WHERE P.IBLOCK_ID = ".$IBLOCK_ID.
"
4546 AND P.PROPERTY_TYPE = 'F'
4547 AND P.MULTIPLE = 'N'
4549 $rs =
$DB->Query($strSQL);
4550 while(
$ar =
$rs->Fetch())
4551 $arProps[] =
" V.PROPERTY_".(int)
$ar[
"ID"].
" = ".$FILE_ID;
4554 if($ELEMENT_ID ===
false)
4559 "E.ID=".(
int)$PARENT_ID,
4560 "E.WF_PARENT_ELEMENT_ID=".(
int)$PARENT_ID
4568 "E.ID=".(
int)$PARENT_ID,
4569 "E.WF_PARENT_ELEMENT_ID=".(
int)$PARENT_ID.
" AND E.ID <> ".$ELEMENT_ID
4577 "E.WF_PARENT_ELEMENT_ID=".$ELEMENT_ID
4582 foreach($arWhere as $strWhere)
4584 if(
$TYPE ===
"PREVIEW")
4588 from b_iblock_element E
4590 AND PREVIEW_PICTURE = ".$FILE_ID.
"
4598 from b_iblock_element E
4600 AND DETAIL_PICTURE = ".$FILE_ID.
"
4611 ,b_iblock_property P
4612 ,b_iblock_element_prop_m".$IBLOCK_ID.
" V
4615 AND P.IBLOCK_ID = E.IBLOCK_ID
4616 AND P.PROPERTY_TYPE = 'F'
4617 AND V.IBLOCK_ELEMENT_ID = E.ID
4618 AND V.IBLOCK_PROPERTY_ID = P.ID
4619 AND V.VALUE_NUM = ".$FILE_ID.
"
4628 ,b_iblock_property P
4629 ,b_iblock_element_property V
4632 AND P.IBLOCK_ID = E.IBLOCK_ID
4633 AND P.PROPERTY_TYPE = 'F'
4634 AND V.IBLOCK_ELEMENT_ID = E.ID
4635 AND V.IBLOCK_PROPERTY_ID = P.ID
4636 AND V.VALUE_NUM = ".$FILE_ID.
"
4641 $rs =
$DB->Query($strSQL);
4644 $CNT += (int)
$ar[
"CNT"];
4649 if(!empty($arProps))
4658 ,b_iblock_property P
4659 ,b_iblock_element_prop_s".$IBLOCK_ID.
" V
4662 AND P.IBLOCK_ID = E.IBLOCK_ID
4663 AND P.PROPERTY_TYPE = 'F'
4664 AND V.IBLOCK_ELEMENT_ID = E.ID
4665 AND (".implode(
" OR ", $arProps).
")
4667 $rs =
$DB->Query($strSQL);
4669 $CNT += (int)
$ar[
"CNT"];
4678 CFile::Delete($FILE_ID);
4687 $USER_ID = is_object(
$USER)? (int)
$USER->GetID() : 0;
4695 foreach (
GetModuleEvents(
"iblock",
"OnBeforeIBlockElementDelete",
true) as $arEvent)
4704 $err = $ex->GetString();
4705 $err_id = $ex->GetID();
4714 "WF_PARENT_ELEMENT_ID='".$ID.
"'",
4716 foreach($arSql as $strWhere)
4722 ,WF_PARENT_ELEMENT_ID
4726 ,XML_ID as EXTERNAL_ID
4729 FROM b_iblock_element
4733 $z =
$DB->Query($strSql);
4734 while (
$zr =
$z->Fetch())
4736 $elementId = (int)
$zr[
"ID"];
4740 $arIblock = CIBlock::GetArrayByID(
$zr[
'IBLOCK_ID']);
4741 $arIBlockFields = $arIblock[
"FIELDS"];
4743 (
int)
$zr[
"WF_PARENT_ELEMENT_ID"]<=0
4744 && $arIBlockFields[
"LOG_ELEMENT_DELETE"][
"IS_REQUIRED"] ==
"Y"
4751 $rsElement = CIBlockElement::GetList(
array(),
array(
"=ID"=>
$ID),
false,
false,
array(
"LIST_PAGE_URL",
"NAME",
"CODE"));
4752 $arElement = $rsElement->GetNext();
4755 "CODE" => $arElement[
"CODE"],
4756 "NAME" => $arElement[
"NAME"],
4757 "ELEMENT_NAME" => $arIblock[
"ELEMENT_NAME"],
4758 "USER_ID" => $USER_ID,
4759 "IBLOCK_PAGE_URL" => $arElement[
"LIST_PAGE_URL"],
4763 "IBLOCK_ELEMENT_DELETE",
4773 foreach (
GetModuleEvents(
"iblock",
"OnIBlockElementDelete",
true) as $arEvent)
4781 if(!
$DB->Query(
"DELETE FROM b_iblock_element_prop_m".$zr[
"IBLOCK_ID"].
" WHERE IBLOCK_ELEMENT_ID = ".$elementId))
4783 if(!
$DB->Query(
"DELETE FROM b_iblock_element_prop_s".$zr[
"IBLOCK_ID"].
" WHERE IBLOCK_ELEMENT_ID = ".$elementId))
4788 if(!
$DB->Query(
"DELETE FROM b_iblock_element_property WHERE IBLOCK_ELEMENT_ID = ".$elementId))
4792 static $arDelCache =
array();
4793 if(!
is_set($arDelCache,
$zr[
"IBLOCK_ID"]))
4795 $arDelCache[
$zr[
"IBLOCK_ID"]] = [];
4796 $db_ps =
$DB->Query(
"SELECT ID,IBLOCK_ID,VERSION,MULTIPLE FROM b_iblock_property WHERE PROPERTY_TYPE='E' AND (LINK_IBLOCK_ID=".
$zr[
"IBLOCK_ID"].
" OR LINK_IBLOCK_ID=0 OR LINK_IBLOCK_ID IS NULL)");
4797 while($ar_ps = $db_ps->Fetch())
4799 if($ar_ps[
"VERSION"]==2)
4801 if($ar_ps[
"MULTIPLE"]==
"Y")
4802 $strTable =
"b_iblock_element_prop_m".$ar_ps[
"IBLOCK_ID"];
4804 $strTable =
"b_iblock_element_prop_s".$ar_ps[
"IBLOCK_ID"];
4808 $strTable =
"b_iblock_element_property";
4810 $arDelCache[
$zr[
"IBLOCK_ID"]][$strTable][] = $ar_ps[
"ID"];
4814 if($arDelCache[
$zr[
"IBLOCK_ID"]])
4816 foreach($arDelCache[
$zr[
"IBLOCK_ID"]] as $strTable=>$arProps)
4818 if(strncmp(
"b_iblock_element_prop_s", $strTable, 23)==0)
4820 $tableFields =
$DB->GetTableFields($strTable);
4821 foreach($arProps as $prop_id)
4823 $strSql =
"UPDATE ".$strTable.
" SET PROPERTY_".$prop_id.
"=null";
4824 if (isset($tableFields[
"DESCRIPTION_".$prop_id]))
4825 $strSql .=
",DESCRIPTION_".$prop_id.
"=null";
4826 $strSql .=
" WHERE PROPERTY_".$prop_id.
"=".
$zr[
"ID"];
4827 if(!
$DB->Query($strSql))
4831 elseif(strncmp(
"b_iblock_element_prop_m", $strTable, 23)==0)
4833 $tableFields =
$DB->GetTableFields(str_replace(
"prop_m",
"prop_s", $strTable));
4834 $strSql =
"SELECT IBLOCK_PROPERTY_ID, IBLOCK_ELEMENT_ID FROM ".$strTable.
" WHERE IBLOCK_PROPERTY_ID IN (".implode(
", ", $arProps).
") AND VALUE_NUM=".
$zr[
"ID"];
4835 $rs =
$DB->Query($strSql);
4836 while(
$ar =
$rs->Fetch())
4839 UPDATE ".str_replace(
"prop_m",
"prop_s", $strTable).
"
4840 SET PROPERTY_".
$ar[
"IBLOCK_PROPERTY_ID"].
"=null
4841 ".(isset($tableFields[
"DESCRIPTION_".
$ar[
"IBLOCK_PROPERTY_ID"]])?
",DESCRIPTION_".$ar[
"IBLOCK_PROPERTY_ID"].
"=null":
"").
"
4842 WHERE IBLOCK_ELEMENT_ID = ".
$ar[
"IBLOCK_ELEMENT_ID"].
"
4844 if(!
$DB->Query($strSql))
4847 $strSql =
"DELETE FROM ".$strTable.
" WHERE IBLOCK_PROPERTY_ID IN (".implode(
", ", $arProps).
") AND VALUE_NUM=".
$zr[
"ID"];
4848 if(!
$DB->Query($strSql))
4853 $strSql =
"DELETE FROM ".$strTable.
" WHERE IBLOCK_PROPERTY_ID IN (".implode(
", ", $arProps).
") AND VALUE_NUM=".
$zr[
"ID"];
4854 if(!
$DB->Query($strSql))
4860 if(!
$DB->Query(
"DELETE FROM b_iblock_section_element WHERE IBLOCK_ELEMENT_ID = ".$elementId))
4864 $obIBlockElementRights->DeleteAllRights();
4866 $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates(
$zr[
"IBLOCK_ID"],
$zr[
"ID"]);
4867 $ipropTemplates->delete();
4869 if((
int)
$zr[
"WF_PARENT_ELEMENT_ID"]<=0 &&
$zr[
"WF_STATUS_ID"]==1 && CModule::IncludeModule(
"search"))
4877 if(CModule::IncludeModule(
"workflow"))
4878 $DB->Query(
"DELETE FROM b_workflow_move WHERE IBLOCK_ELEMENT_ID=".$elementId);
4880 $DB->Query(
"DELETE FROM b_iblock_element_lock WHERE IBLOCK_ELEMENT_ID=".$elementId);
4881 $DB->Query(
"DELETE FROM b_rating_vote WHERE ENTITY_TYPE_ID = 'IBLOCK_ELEMENT' AND ENTITY_ID = ".$elementId);
4882 $DB->Query(
"DELETE FROM b_rating_voting WHERE ENTITY_TYPE_ID = 'IBLOCK_ELEMENT' AND ENTITY_ID = ".$elementId);
4884 if (FullText::doesIblockSupportByData($arIblock))
4886 FullText::delete($arIblock[
"ID"], $elementId);
4889 if(!
$DB->Query(
"DELETE FROM b_iblock_element WHERE ID=".$elementId))
4892 if (isset(self::$elementIblock[$elementId]))
4893 unset(self::$elementIblock[$elementId]);
4897 if(CModule::IncludeModule(
"bizproc"))
4900 CBPDocument::OnDocumentDelete([
"iblock",
"CIBlockDocument",
$zr[
"ID"]], $arErrorsTmp);
4903 foreach (
GetModuleEvents(
"iblock",
"OnAfterIBlockElementDelete",
true) as $arEvent)
4906 CIBlock::clearIblockTagCache(
$zr[
'IBLOCK_ID']);
4921 return CIBlockElement::GetList(
array(),
array(
"ID"=>(
int)
$ID,
"SHOW_HISTORY"=>
"Y"));
4936 if (!isset(self::$elementIblock[
$ID]))
4938 self::$elementIblock[
$ID] =
false;
4939 $strSql =
"select IBLOCK_ID from b_iblock_element where ID=".$ID;
4940 $rsItems =
$DB->Query($strSql);
4941 if ($arItem = $rsItems->Fetch())
4942 self::$elementIblock[
$ID] = (int)$arItem[
'IBLOCK_ID'];
4943 unset($arItem, $rsItems);
4945 return self::$elementIblock[
$ID];
4961 foreach ($list as $index => $id)
4963 if (!empty(self::$elementIblock[$id]))
4965 $output[$id] = self::$elementIblock[$id];
4966 unset($list[$index]);
4972 foreach (array_chunk($list, 500) as $pageIds)
4974 $strSql =
"select IBLOCK_ID,ID from b_iblock_element where ID in (".join(
', ', $pageIds).
")";
4975 $rsItems =
$DB->Query($strSql);
4976 while ($itemData = $rsItems->Fetch())
4978 $output[$itemData[
'ID']] = self::$elementIblock[$itemData[
'ID']] = (int)$itemData[
'IBLOCK_ID'];
4980 unset($itemData, $rsItems);
4994 $this->LAST_ERROR =
"";
4999 $db_events =
GetModuleEvents(
"iblock",
"OnStartIBlockElementAdd",
true);
5004 $db_events =
GetModuleEvents(
"iblock",
"OnStartIBlockElementUpdate",
true);
5007 foreach ($db_events as $arEvent)
5010 if($bEventRes===
false)
5015 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_ELEMENT_NAME").
"<br>";
5020 && !
$DB->IsDate(
$arFields[
"ACTIVE_FROM"],
false, LANG,
"FULL")
5022 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_ACTIVE_FROM").
"<br>";
5027 && !
$DB->IsDate(
$arFields[
"ACTIVE_TO"],
false, LANG,
"FULL")
5029 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_ACTIVE_TO").
"<br>";
5035 && array_key_exists(
"bucket",
$arFields[
"PREVIEW_PICTURE"])
5036 && is_object(
$arFields[
"PREVIEW_PICTURE"][
"bucket"])
5045 $this->LAST_ERROR .=
$error.
"<br>";
5047 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_ERR_PREVIEW_PICTURE").
"<br>".
$error.
"<br>";
5052 (
int)
$arFields[
"WF_PARENT_ELEMENT_ID"] <= 0
5063 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_ERR_PREVIEW_PICTURE").
"<br>";
5072 && array_key_exists(
"bucket",
$arFields[
"DETAIL_PICTURE"])
5073 && is_object(
$arFields[
"DETAIL_PICTURE"][
"bucket"])
5082 $this->LAST_ERROR .=
$error.
"<br>";
5084 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_ERR_DETAIL_PICTURE").
"<br>".
$error.
"<br>";
5089 (
int)(
$arFields[
"WF_PARENT_ELEMENT_ID"]) <= 0
5100 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_ERR_DETAIL_PICTURE").
"<br>";
5105 if(array_key_exists(
"TAGS",
$arFields) && CModule::IncludeModule(
'search'))
5111 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_BLOCK_ID").
"<br>";
5118 $res =
$DB->Query(
"SELECT IBLOCK_ID FROM b_iblock_element WHERE ID=".intval(
$ID));
5124 static $IBLOCK_CACHE =
array();
5136 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_BLOCK_ID").
"<br>";
5140 if (!is_array(
$arFields[
'IBLOCK_SECTION']))
5150 $WF_PARENT_ELEMENT_ID = (int)(
$arFields[
"WF_PARENT_ELEMENT_ID"] ?? 0);
5153 $WF_PARENT_ELEMENT_ID == 0
5154 || $WF_PARENT_ELEMENT_ID == (
int)
$ID
5158 && is_array(
$ar[
"CODE"][
"DEFAULT_VALUE"])
5159 &&
$ar[
"CODE"][
"DEFAULT_VALUE"][
"UNIQUE"] ==
"Y"
5164 FROM b_iblock_element
5167 AND WF_PARENT_ELEMENT_ID IS NULL
5168 AND ID <> ".(
int)
$ID
5171 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_DUP_ELEMENT_CODE").
"<br>";
5175 $arOldElement =
false;
5176 foreach(
$ar as $FIELD_ID => $field)
5178 if(preg_match(
"/^(SECTION_|LOG_)/", $FIELD_ID))
5181 if($field[
"IS_REQUIRED"] ===
"Y")
5187 case "PREVIEW_TEXT_TYPE":
5188 case "DETAIL_TEXT_TYPE":
5192 case "IBLOCK_SECTION":
5193 if(
$ID===
false || array_key_exists($FIELD_ID,
$arFields))
5207 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5210 case "PREVIEW_PICTURE":
5211 case "DETAIL_PICTURE":
5212 if(
$ID !==
false && !$arOldElement)
5214 $rs =
$DB->Query(
"SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = ".intval(
$ID));
5215 $arOldElement =
$rs->Fetch();
5217 if($arOldElement && $arOldElement[$FIELD_ID] > 0)
5224 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5228 if(!array_key_exists($FIELD_ID,
$arFields))
5230 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5236 || (array_key_exists(
"error",
$arFields[$FIELD_ID]) &&
$arFields[$FIELD_ID][
"error"] !== 0)
5239 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5244 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5249 if (
$ID !==
false && array_key_exists($FIELD_ID,
$arFields))
5253 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5257 if(
$ID===
false || array_key_exists($FIELD_ID,
$arFields))
5264 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_BAD_FIELD",
array(
"#FIELD_NAME#" => $field[
"NAME"])).
"<br>";
5274 array_key_exists(
"PROPERTY_VALUES",
$arFields)
5275 && is_array(
$arFields[
"PROPERTY_VALUES"])
5282 foreach(
$arFields[
"PROPERTY_VALUES"] as
$key => $property_values)
5285 if(is_array($property_values))
5287 if(array_key_exists(
"VALUE", $property_values))
5291 elseif(array_key_exists(
"tmp_name", $property_values))
5297 foreach($property_values as $key2 => $property_value)
5299 if(is_array($property_value) && array_key_exists(
"VALUE", $property_value))
5314 $arProperty = CIBlockProperty::GetPropertyArray(
$key,
$IBLOCK_ID);
5316 if($arProperty[
"USER_TYPE"] !=
"")
5317 $arUserType = CIBlockProperty::GetUserType($arProperty[
"USER_TYPE"]);
5319 $arUserType =
array();
5321 if (isset($arUserType[
'CheckFields']))
5323 foreach ($property_values as $singleValue)
5325 $arError = call_user_func_array(
5326 $arUserType[
'CheckFields'],
5329 [
'VALUE' => $singleValue],
5332 if (is_array($arError))
5334 foreach ($arError as $err_mess)
5336 $this->LAST_ERROR .= $err_mess .
'<br>';
5340 unset($singleValue);
5347 $arProperty[
"IS_REQUIRED"] ==
"Y"
5348 && $arProperty[
'PROPERTY_TYPE'] ==
'F'
5355 foreach($property_values as $key2 => $property_value)
5358 is_array($property_value)
5359 && array_key_exists(
"tmp_name", $property_value)
5360 && array_key_exists(
"size", $property_value)
5363 if($property_value[
'size'] > 0)
5369 elseif(intval($property_value) > 0)
5379 $arProperty[
"IBLOCK_ID"],
5383 "ID" => $arProperty[
"ORIG_ID"],
5389 while (
$a=$dbProperty->Fetch())
5391 if (
$a[
"VALUE"] > 0)
5395 foreach ($property_values as $key2 => $property_value)
5397 if (is_array($property_value))
5399 if ((
int)($property_value[
'size'] ??
null) > 0)
5404 elseif (($property_value[
'del'] ??
null) ===
'Y')
5409 elseif ((
int)$property_value > 0)
5419 $correctValue =
true;
5421 $arProperty[
"IS_REQUIRED"] ==
"Y"
5422 && $arProperty[
'PROPERTY_TYPE'] !=
'F'
5426 foreach ($property_values as $singleValue)
5428 if (isset($arUserType[
'GetLength']))
5430 $len += call_user_func_array(
5431 $arUserType[
'GetLength'],
5434 [
'VALUE' => $singleValue],
5440 if ($singleValue ===
null)
5444 if (is_scalar($singleValue))
5446 if ((
string)$singleValue !==
'')
5453 $correctValue =
false;
5461 unset($singleValue);
5468 $this->LAST_ERROR .=
5470 'IBLOCK_BAD_PROPERTY',
5471 array(
'#PROPERTY#' => $arProperty[
'NAME'])
5478 $this->LAST_ERROR .=
5480 'IBLOCK_BAD_REQUIRED_PROPERTY_VALUE',
5481 array(
'#PROPERTY#' => $arProperty[
'NAME'])
5488 if($arProperty[
'PROPERTY_TYPE'] ==
'F')
5490 $bImageOnly = False;
5491 $arImageExtentions = explode(
",", mb_strtoupper(CFile::GetImageExtensions()));
5492 if($arProperty[
"FILE_TYPE"] <>
'')
5495 $arAvailTypes = explode(
",", mb_strtoupper($arProperty[
"FILE_TYPE"]));
5496 foreach($arAvailTypes as $avail_type)
5498 if(!in_array(trim($avail_type), $arImageExtentions))
5500 $bImageOnly = False;
5506 foreach($property_values as $key2 => $property_value)
5509 !is_array($property_value)
5510 && (
int)$property_value > 0
5511 && isset(
$arFields[
'WF_PARENT_ELEMENT_ID'])
5512 && (
int)
$arFields[
'WF_PARENT_ELEMENT_ID'] > 0
5518 $this->LAST_ERROR .=
GetMessage(
"IBLOCK_ERR_FILE_PROPERTY").
"<br>";
5521 elseif(is_array($property_value))
5524 array_key_exists(
'bucket', $property_value)
5525 && is_object($property_value[
"bucket"])
5534 $error = CFile::CheckImageFile($property_value);
5536 $error = CFile::CheckFile($property_value, 0,
false, $arProperty[
"FILE_TYPE"]);
5541 if (!$this->isAdmin)
5550 $this->LAST_ERROR .=
$error.
"<br>";
5559 $db_events =
GetModuleEvents(
"iblock",
"OnBeforeIBlockElementAdd",
true);
5563 $db_events =
GetModuleEvents(
"iblock",
"OnBeforeIBlockElementUpdate",
true);
5566 foreach($db_events as $arEvent)
5569 if($bEventRes===
false)
5572 $this->LAST_ERROR .= $err->GetString().
"<br>";
5576 $this->LAST_ERROR .=
"Unknown error.<br>";
5585 && empty($this->LAST_ERROR)
5586 && (COption::GetOptionInt(
"main",
"disk_space") > 0)
5591 $this->LAST_ERROR = $quota->LAST_ERROR;
5595 if(!empty($this->LAST_ERROR))
5613 CIBlockElement::SetPropertyValues($ELEMENT_ID,
$IBLOCK_ID, $PROPERTY_VALUE, $PROPERTY_CODE);
5624 "TIMESTAMP_X" =>
"BS.TIMESTAMP_X",
5625 "MODIFIED_BY" =>
"BS.MODIFIED_BY",
5626 "DATE_CREATE" =>
"BS.DATE_CREATE",
5627 "CREATED_BY" =>
"BS.CREATED_BY",
5628 "IBLOCK_ID" =>
"BS.IBLOCK_ID",
5629 "IBLOCK_SECTION_ID" =>
"BS.IBLOCK_SECTION_ID",
5630 "ACTIVE" =>
"BS.ACTIVE",
5631 "GLOBAL_ACTIVE" =>
"BS.GLOBAL_ACTIVE",
5632 "SORT" =>
"BS.SORT",
5633 "NAME" =>
"BS.NAME",
5634 "PICTURE" =>
"BS.PICTURE",
5635 "LEFT_MARGIN" =>
"BS.LEFT_MARGIN",
5636 "RIGHT_MARGIN" =>
"BS.RIGHT_MARGIN",
5637 "DEPTH_LEVEL" =>
"BS.DEPTH_LEVEL",
5638 "DESCRIPTION" =>
"BS.DESCRIPTION",
5639 "DESCRIPTION_TYPE" =>
"BS.DESCRIPTION_TYPE",
5640 "SEARCHABLE_CONTENT" =>
"BS.SEARCHABLE_CONTENT",
5641 "CODE" =>
"BS.CODE",
5642 "XML_ID" =>
"BS.XML_ID",
5643 "EXTERNAL_ID" =>
"BS.XML_ID",
5644 "TMP_ID" =>
"BS.TMP_ID",
5645 "DETAIL_PICTURE" =>
"BS.DETAIL_PICTURE",
5646 "SOCNET_GROUP_ID" =>
"BS.SOCNET_GROUP_ID",
5648 "LIST_PAGE_URL" =>
"B.LIST_PAGE_URL",
5649 "SECTION_PAGE_URL" =>
"B.SECTION_PAGE_URL",
5650 "IBLOCK_TYPE_ID" =>
"B.IBLOCK_TYPE_ID",
5651 "IBLOCK_CODE" =>
"B.CODE",
5652 "IBLOCK_EXTERNAL_ID" =>
"B.XML_ID",
5654 "IBLOCK_ELEMENT_ID" =>
"SE.IBLOCK_ELEMENT_ID",
5655 "ADDITIONAL_PROPERTY_ID" =>
"SE.ADDITIONAL_PROPERTY_ID",
5671 $arSqlSelect =
array();
5672 foreach($arSelect as &$field)
5674 $field = mb_strtoupper($field);
5676 $arSqlSelect[$field] =
$arFields[$field].
" AS ".$field;
5681 if (array_key_exists(
"DESCRIPTION", $arSqlSelect))
5682 $arSqlSelect[
"DESCRIPTION_TYPE"] =
$arFields[
"DESCRIPTION_TYPE"].
" AS DESCRIPTION_TYPE";
5684 if(array_key_exists(
"LIST_PAGE_URL", $arSqlSelect) || array_key_exists(
"SECTION_PAGE_URL", $arSqlSelect))
5686 $arSqlSelect[
"ID"] =
$arFields[
"ID"].
" AS ID";
5687 $arSqlSelect[
"CODE"] =
$arFields[
"CODE"].
" AS CODE";
5688 $arSqlSelect[
"EXTERNAL_ID"] =
$arFields[
"EXTERNAL_ID"].
" AS EXTERNAL_ID";
5689 $arSqlSelect[
"IBLOCK_TYPE_ID"] =
$arFields[
"IBLOCK_TYPE_ID"].
" AS IBLOCK_TYPE_ID";
5690 $arSqlSelect[
"IBLOCK_ID"] =
$arFields[
"IBLOCK_ID"].
" AS IBLOCK_ID";
5691 $arSqlSelect[
"IBLOCK_CODE"] =
$arFields[
"IBLOCK_CODE"].
" AS IBLOCK_CODE";
5692 $arSqlSelect[
"IBLOCK_EXTERNAL_ID"] =
$arFields[
"IBLOCK_EXTERNAL_ID"].
" AS IBLOCK_EXTERNAL_ID";
5693 $arSqlSelect[
"GLOBAL_ACTIVE"] =
$arFields[
"GLOBAL_ACTIVE"].
" AS GLOBAL_ACTIVE";
5696 if (!empty($arSelect))
5698 $strSelect = implode(
", ", $arSqlSelect);
5707 ,B.CODE as IBLOCK_CODE
5708 ,B.XML_ID as IBLOCK_EXTERNAL_ID
5709 ,BS.XML_ID as EXTERNAL_ID
5710 ,SE.IBLOCK_ELEMENT_ID
5718 b_iblock_section_element SE
5719 INNER JOIN b_iblock_section BS ON SE.IBLOCK_SECTION_ID = BS.ID
5720 INNER JOIN b_iblock B ON B.ID = BS.IBLOCK_ID
5722 SE.IBLOCK_ELEMENT_ID in (".implode(
", ", $sqlID).
")
5723 ".($bElementOnly?
"AND SE.ADDITIONAL_PROPERTY_ID IS NULL ":
"").
"
5736 $sectionId = (int)$sectionId;
5741 SE.IBLOCK_SECTION_ID as IBLOCK_SECTION_ID_NEW
5742 ,E.IBLOCK_SECTION_ID
5746 b_iblock_section_element SE
5747 INNER JOIN b_iblock_element E ON E.ID = SE.IBLOCK_ELEMENT_ID
5749 SE.IBLOCK_ELEMENT_ID = ".
$ID.
"
5750 AND SE.IBLOCK_SECTION_ID = ".$sectionId.
"
5751 AND SE.ADDITIONAL_PROPERTY_ID IS NULL
5756 $oldInSections =
$res[
"IN_SECTIONS"];
5757 $newInSections =
"Y";
5758 $oldSectionId = (int)
$res[
"IBLOCK_SECTION_ID"];
5759 $newSectionId = (int)
$res[
"IBLOCK_SECTION_ID_NEW"];
5772 ,MIN(SE.IBLOCK_SECTION_ID) as MIN_IBLOCK_SECTION_ID
5773 ,E.IBLOCK_SECTION_ID
5777 b_iblock_section_element SE
5778 INNER JOIN b_iblock_element E ON E.ID = SE.IBLOCK_ELEMENT_ID
5780 SE.IBLOCK_ELEMENT_ID = ".
$ID.
"
5781 AND SE.ADDITIONAL_PROPERTY_ID IS NULL
5790 $oldInSections =
$res[
"IN_SECTIONS"];
5791 $newInSections = (
$res[
"C"] > 0?
"Y":
"N");
5792 $oldSectionId = (int)
$res[
"IBLOCK_SECTION_ID"];
5793 $newSectionId = (int)
$res[
"MIN_IBLOCK_SECTION_ID"];
5797 $arIBlock[
"FIELDS"][
"IBLOCK_SECTION"][
"DEFAULT_VALUE"][
"KEEP_IBLOCK_SECTION_ID"] ===
"Y"
5798 && $oldInSections === $newInSections
5801 $res2 =
$DB->Query(
"
5803 SE.IBLOCK_SECTION_ID
5805 b_iblock_section_element SE
5807 SE.IBLOCK_ELEMENT_ID = ".
$ID.
"
5808 AND SE.IBLOCK_SECTION_ID = ".$oldSectionId.
"
5809 AND SE.ADDITIONAL_PROPERTY_ID IS NULL
5811 $res2 = $res2->Fetch();
5822 $oldInSections =
"";
5823 $newInSections =
"N";
5830 $oldInSections != $newInSections
5831 || ($oldSectionId != $newSectionId)
5835 UPDATE b_iblock_element SET
5836 IN_SECTIONS = '".$newInSections.
"',
5837 IBLOCK_SECTION_ID= ".($newSectionId > 0? $newSectionId:
"NULL").
"
5855 $arToDelete =
array();
5856 $arToInsert =
array();
5861 $section_id = intval($section_id);
5864 if(!isset($min_new_id) || $section_id < $min_new_id)
5865 $min_new_id = $section_id;
5867 $arToInsert[$section_id] = $section_id;
5876 $arToInsert[$section_id] = $section_id;
5877 $min_new_id = $section_id;
5881 $originalInsert = $arToInsert;
5882 $additionalInsert =
array();
5884 $arOldParents =
array();
5885 $arNewParents = $arToInsert;
5886 $bParentsChanged =
false;
5892 SELECT * FROM b_iblock_section_element
5893 WHERE IBLOCK_ELEMENT_ID = ".
$ID.
"
5894 AND ADDITIONAL_PROPERTY_ID IS NULL
5897 while(
$ar =
$rs->Fetch())
5899 $section_id = intval(
$ar[
"IBLOCK_SECTION_ID"]);
5900 $arOldParents[] = $section_id;
5902 if(!isset($min_old_id) || $section_id < $min_old_id)
5903 $min_old_id = $section_id;
5905 if(isset($arToInsert[$section_id]))
5907 unset($arToInsert[$section_id]);
5911 if (isset($originalInsert[$section_id]))
5912 $additionalInsert[$section_id] = $section_id;
5913 $arToDelete[] = $section_id;
5917 if(!empty($arToDelete))
5919 $bParentsChanged =
true;
5921 DELETE FROM b_iblock_section_element
5922 WHERE IBLOCK_ELEMENT_ID = ".
$ID.
"
5923 AND ADDITIONAL_PROPERTY_ID IS NULL
5924 AND IBLOCK_SECTION_ID in (".implode(
", ", $arToDelete).
")
5928 if (!empty($additionalInsert))
5930 foreach ($additionalInsert as $index)
5931 $arToInsert[$index] = $index;
5935 if(!empty($arToInsert))
5937 $bParentsChanged =
true;
5939 INSERT INTO b_iblock_section_element(IBLOCK_SECTION_ID, IBLOCK_ELEMENT_ID)
5941 FROM b_iblock_section S, b_iblock_element E
5942 WHERE S.IBLOCK_ID = E.IBLOCK_ID
5943 AND S.ID IN (".implode(
", ", $arToInsert).
")
5948 if($bParentsChanged && $bRightsIBlock)
5951 if(empty($arOldParents))
5952 $arOldParents[] = 0;
5953 if(empty($arNewParents))
5954 $arNewParents[] = 0;
5956 $obElementRights->ChangeParents($arOldParents, $arNewParents);
5959 if($sectionId !==
null || ($min_old_id !== $min_new_id))
5964 return !empty($arToDelete) || !empty($arToInsert);
5981 (
$p = CFile::MakeFileArray($old_id))
5985 $p[
'description'] =
$arFields[$fname][
'description'];
5986 $p[
"OLD_VALUE"] =
true;
5993 static $max_file_size =
null;
5995 $arFile = CFile::MakeFileArray($FILE_ID);
5996 if($arFile && $arFile[
"tmp_name"])
5998 if(!isset($max_file_size))
5999 $max_file_size = COption::GetOptionInt(
"search",
"max_file_size", 0)*1024;
6001 if($max_file_size > 0 && $arFile[
"size"] > $max_file_size)
6005 $file_abs_path =
$io->GetLogicalName($arFile[
"tmp_name"]);
6008 foreach(
GetModuleEvents(
"search",
"OnSearchGetFileContent",
true) as $arEvent)
6028 static $strElementSql =
false;
6032 SELECT BE.ID, BE.NAME, BE.XML_ID as EXTERNAL_ID,
6033 BE.PREVIEW_TEXT_TYPE, BE.PREVIEW_TEXT, BE.CODE,
6035 BE.DETAIL_TEXT_TYPE, BE.DETAIL_TEXT, BE.IBLOCK_ID, B.IBLOCK_TYPE_ID,
6036 ".$DB->DateToCharFunction(
"BE.TIMESTAMP_X").
" as LAST_MODIFIED,
6037 ".
$DB->DateToCharFunction(
"BE.ACTIVE_FROM").
" as DATE_FROM,
6038 ".
$DB->DateToCharFunction(
"BE.ACTIVE_TO").
" as DATE_TO,
6039 BE.IBLOCK_SECTION_ID,
6040 B.CODE as IBLOCK_CODE, B.XML_ID as IBLOCK_EXTERNAL_ID, B.DETAIL_PAGE_URL,
6041 B.VERSION, B.RIGHTS_MODE, B.SOCNET_GROUP_ID
6042 FROM b_iblock_element BE, b_iblock B
6043 WHERE BE.IBLOCK_ID=B.ID
6046 AND B.INDEX_ELEMENT='Y'
6051 $dbrIBlockElement =
$DB->Query($strElementSql.$ID);
6053 if($arIBlockElement = $dbrIBlockElement->Fetch())
6057 '=ID=' . urlencode($arIBlockElement[
'ID'])
6058 .
'&EXTERNAL_ID=' . urlencode((
string)$arIBlockElement[
'EXTERNAL_ID'])
6059 .
'&IBLOCK_SECTION_ID=' . urlencode((
string)$arIBlockElement[
'IBLOCK_SECTION_ID'])
6060 .
'&IBLOCK_TYPE_ID=' . urlencode($arIBlockElement[
'IBLOCK_TYPE_ID'])
6061 .
'&IBLOCK_ID=' . urlencode($arIBlockElement[
'IBLOCK_ID'])
6062 .
'&IBLOCK_CODE=' . urlencode((
string)$arIBlockElement[
'IBLOCK_CODE'])
6063 .
'&IBLOCK_EXTERNAL_ID=' . urlencode((
string)$arIBlockElement[
'IBLOCK_EXTERNAL_ID'])
6064 .
'&CODE=' . urlencode((
string)$arIBlockElement[
'CODE'])
6073 "FROM b_iblock_group ".
6074 "WHERE IBLOCK_ID= ".$IBLOCK_ID.
" ".
6075 " AND PERMISSION>='R' ".
6076 "ORDER BY GROUP_ID";
6078 $dbrIBlockGroup =
$DB->Query($strSql);
6079 while($arIBlockGroup = $dbrIBlockGroup->Fetch())
6082 if($arIBlockGroup[
"GROUP_ID"]==2)
break;
6084 unset($arIBlockGroup);
6085 unset($dbrIBlockGroup);
6088 static $arSITE =
array();
6094 "FROM b_iblock_site ".
6095 "WHERE IBLOCK_ID= ".$IBLOCK_ID;
6097 $dbrIBlockSite =
$DB->Query($strSql);
6098 while($arIBlockSite = $dbrIBlockSite->Fetch())
6099 $arSITE[
$IBLOCK_ID][] = $arIBlockSite[
"SITE_ID"];
6100 unset($arIBlockSite);
6101 unset($dbrIBlockSite);
6105 ($arIBlockElement[
"PREVIEW_TEXT_TYPE"]==
"html" ?
6107 $arIBlockElement[
"PREVIEW_TEXT"]
6109 ($arIBlockElement[
"DETAIL_TEXT_TYPE"]==
"html" ?
6111 $arIBlockElement[
"DETAIL_TEXT"]
6118 $rsProperties = CIBlockProperty::GetList(
6119 array(
"sort"=>
"asc",
"id"=>
"asc"),
6124 "CHECK_PERMISSIONS"=>
"N",
6127 while(
$ar = $rsProperties->Fetch())
6129 if(
$ar[
"USER_TYPE"] <>
'')
6131 $arUT = CIBlockProperty::GetUserType(
$ar[
"USER_TYPE"]);
6132 if(isset($arUT[
"GetSearchContent"]))
6133 $ar[
"GetSearchContent"] = $arUT[
"GetSearchContent"];
6134 elseif(isset($arUT[
"GetPublicViewHTML"]))
6135 $ar[
"GetSearchContent"] = $arUT[
"GetPublicViewHTML"];
6140 unset($rsProperties);
6144 $strProperties =
"";
6147 if($arIBlockElement[
"VERSION"]==1)
6151 from b_iblock_element_property
6152 where IBLOCK_ELEMENT_ID=".$arIBlockElement[
"ID"].
"
6157 $strProperties .=
"\r\n";
6159 if (isset($arProperty[
"GetSearchContent"]) && $arProperty[
"GetSearchContent"])
6162 call_user_func_array($arProperty[
"GetSearchContent"],
6175 $strProperties .= $arEnum[
"VALUE"];
6180 if(is_array($arFile))
6182 $strProperties .= $arFile[
"CONTENT"];
6183 $arIBlockElement[
"TAGS"] .=
",".$arFile[
"PROPERTIES"][COption::GetOptionString(
"search",
"page_tag_property")];
6188 $strProperties .=
$ar[
"VALUE"];
6197 where IBLOCK_ELEMENT_ID=".$arIBlockElement[
"ID"].
"
6202 $strProperties .=
"\r\n";
6204 if($arProperty[
"GetSearchContent"])
6207 call_user_func_array($arProperty[
"GetSearchContent"],
6216 elseif($arProperty[
"PROPERTY_TYPE"]==
'L')
6220 $strProperties .= $arEnum[
"VALUE"];
6222 elseif($arProperty[
"PROPERTY_TYPE"]==
'F')
6225 if(is_array($arFile))
6227 $strProperties .= $arFile[
"CONTENT"];
6228 $arIBlockElement[
"TAGS"] .=
",".$arFile[
"PROPERTIES"][COption::GetOptionString(
"search",
"page_tag_property")];
6233 $strProperties .=
$ar[
"VALUE"];
6239 where IBLOCK_ELEMENT_ID=".$arIBlockElement[
"ID"].
"
6245 if( array_key_exists(
"PROPERTY_".$property_id,
$ar)
6246 && $property[
"MULTIPLE"]==
"N"
6247 &&
$ar[
"PROPERTY_".$property_id] <>
'')
6249 $strProperties .=
"\r\n";
6250 if($property[
"GetSearchContent"])
6253 call_user_func_array($property[
"GetSearchContent"],
6256 array(
"VALUE" =>
$ar[
"PROPERTY_".$property_id]),
6262 elseif($property[
"PROPERTY_TYPE"]==
'L')
6266 $strProperties .= $arEnum[
"VALUE"];
6268 elseif($property[
"PROPERTY_TYPE"]==
'F')
6271 if(is_array($arFile))
6273 $strProperties .= $arFile[
"CONTENT"];
6274 $arIBlockElement[
"TAGS"] .=
",".$arFile[
"PROPERTIES"][COption::GetOptionString(
"search",
"page_tag_property")];
6279 $strProperties .=
$ar[
"PROPERTY_".$property_id];
6286 $BODY .= $strProperties;
6288 if($arIBlockElement[
"RIGHTS_MODE"] !==
"E")
6295 $arPermissions = $obElementRights->GetGroups(
array(
"element_read"));
6299 "LAST_MODIFIED" => ($arIBlockElement[
"DATE_FROM"] <>
''?$arIBlockElement[
"DATE_FROM"]:$arIBlockElement[
"LAST_MODIFIED"]),
6300 "DATE_FROM" => ($arIBlockElement[
"DATE_FROM"] <>
''? $arIBlockElement[
"DATE_FROM"] :
false),
6301 "DATE_TO" => ($arIBlockElement[
"DATE_TO"] <>
''? $arIBlockElement[
"DATE_TO"] :
false),
6302 "TITLE" => $arIBlockElement[
"NAME"],
6303 "PARAM1" => $arIBlockElement[
"IBLOCK_TYPE_ID"],
6306 "PERMISSIONS" => $arPermissions,
6307 "URL" => $DETAIL_URL,
6309 "TAGS" => $arIBlockElement[
"TAGS"],
6312 if ($arIBlockElement[
"SOCNET_GROUP_ID"] > 0)
6314 "socnet_group" => $arIBlockElement[
"SOCNET_GROUP_ID"],
6331 $propertyID =
array();
6332 if (isset($propertyFilter[
'ID']))
6334 $propertyID = (is_array($propertyFilter[
'ID']) ? $propertyFilter[
'ID'] :
array($propertyFilter[
'ID']));
6341 $element->strField =
"ID";
6350 INNER JOIN b_iblock_element_prop_s".
$IBLOCK_ID.
" BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID
6351 WHERE 1=1 ".$element->sWhere.
"
6353 BEP.IBLOCK_ELEMENT_ID
6358 BE.ID IBLOCK_ELEMENT_ID
6359 ,BEP.IBLOCK_PROPERTY_ID
6363 ",BEP.ID PROPERTY_VALUE_ID
6370 LEFT JOIN b_iblock_element_property BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID ".
6371 (!empty($propertyID) ?
"AND BEP.IBLOCK_PROPERTY_ID IN (" . implode(
', ', $propertyID) .
")" :
"") .
6372 "WHERE 1=1 " . $element->sWhere .
"
6374 BEP.IBLOCK_ELEMENT_ID, BEP.IBLOCK_PROPERTY_ID, BEP.ID
6378 $rs->setMode($extMode);
6386 $propertiesList =
array();
6387 $shortProperties =
array();
6388 $userTypesList =
array();
6390 $selectListMultiply =
array(
'SORT' => SORT_ASC,
'VALUE' => SORT_STRING);
6391 $selectAllMultiply =
array(
'PROPERTY_VALUE_ID' => SORT_ASC);
6394 'ID',
'IBLOCK_ID',
'NAME',
'ACTIVE',
'SORT',
'CODE',
'DEFAULT_VALUE',
'PROPERTY_TYPE',
'ROW_COUNT',
'COL_COUNT',
'LIST_TYPE',
6395 'MULTIPLE',
'XML_ID',
'FILE_TYPE',
'MULTIPLE_CNT',
'LINK_IBLOCK_ID',
'WITH_DESCRIPTION',
'SEARCHABLE',
'FILTRABLE',
6396 'IS_REQUIRED',
'VERSION',
'USER_TYPE',
'USER_TYPE_SETTINGS',
'HINT'
6401 $usePropertyId = (isset(
$options[
'USE_PROPERTY_ID']) &&
$options[
'USE_PROPERTY_ID'] ==
'Y');
6403 $propertyFieldList =
array();
6404 if (!empty(
$options[
'PROPERTY_FIELDS']) && is_array(
$options[
'PROPERTY_FIELDS']))
6406 if (!empty($propertyFieldList))
6408 if (!in_array(
'ID', $propertyFieldList))
6409 $propertyFieldList[] =
'ID';
6412 if (in_array(
'NAME', $propertyFieldList))
6413 $propertyFieldList[] =
'~NAME';
6414 if (in_array(
'DEFAULT_VALUE', $propertyFieldList))
6415 $propertyFieldList[] =
'~DEFAULT_VALUE';
6417 $propertyFieldList = array_fill_keys($propertyFieldList,
true);
6420 $propertyListFilter =
array(
6421 'IBLOCK_ID' => $iblockID
6423 $propertyID =
array();
6424 if (isset($propertyFilter[
'ID']))
6426 $propertyID = (is_array($propertyFilter[
'ID']) ? $propertyFilter[
'ID'] :
array($propertyFilter[
'ID']));
6429 if (!empty($propertyID))
6431 $propertyListFilter[
'@ID'] = $propertyID;
6433 elseif (isset($propertyFilter[
'CODE']))
6435 if (!is_array($propertyFilter[
'CODE']))
6436 $propertyFilter[
'CODE'] =
array($propertyFilter[
'CODE']);
6437 $propertyCodes =
array();
6438 if (!empty($propertyFilter[
'CODE']))
6440 foreach ($propertyFilter[
'CODE'] as &
$code)
6444 $propertyCodes[] =
$code;
6448 if (!empty($propertyCodes))
6449 $propertyListFilter[
'@CODE'] = $propertyCodes;
6450 unset($propertyCodes);
6452 $propertyListFilter[
'=ACTIVE'] = (
6453 isset($propertyFilter[
'ACTIVE']) && ($propertyFilter[
'ACTIVE'] ==
'Y' || $propertyFilter[
'ACTIVE'] ==
'N')
6454 ? $propertyFilter[
'ACTIVE']
6458 $propertyID =
array();
6461 'filter' => $propertyListFilter,
6462 'order' =>
array(
'SORT'=>
'ASC',
'ID'=>
'ASC'),
6467 while ($property = $propertyIterator->fetch())
6469 $propertyID[] = (int)$property[
'ID'];
6470 $property[
'CODE'] = trim((
string)$property[
'CODE']);
6471 if ($property[
'CODE'] ===
'')
6472 $property[
'CODE'] = $property[
'ID'];
6473 $code = ($usePropertyId ? $property[
'ID'] : $property[
'CODE']);
6476 $property[
'~NAME'] = $property[
'NAME'];
6477 if (preg_match(
"/[;&<>\"]/", $property[
'NAME']))
6481 if ($property[
'USER_TYPE'])
6483 $userType = CIBlockProperty::GetUserType($property[
'USER_TYPE']);
6484 if (isset($userType[
'ConvertFromDB']))
6486 $userTypesList[$property[
'ID']] = $userType;
6487 if (array_key_exists(
'DEFAULT_VALUE', $property))
6490 'VALUE' => $property[
'DEFAULT_VALUE'],
6491 'DESCRIPTION' =>
'',
6493 $value = call_user_func_array(
6494 $userType[
'ConvertFromDB'],
6497 $property[
'DEFAULT_VALUE'] = $value[
'VALUE'] ??
'';
6502 if (!empty($property[
'USER_TYPE_SETTINGS']))
6504 $property[
'USER_TYPE_SETTINGS'] = unserialize($property[
'USER_TYPE_SETTINGS'], [
'allowed_classes' =>
false]);
6509 $property[
'~DEFAULT_VALUE'] = $property[
'DEFAULT_VALUE'] ??
null;
6511 isset($property[
'DEFAULT_VALUE'])
6513 is_array($property[
'DEFAULT_VALUE'])
6514 || preg_match(
"/[;&<>\"]/", $property[
'DEFAULT_VALUE'])
6522 $propertiesList[
$code] = $property;
6523 $shortProperties[
$code] = (!empty($propertyFieldList)
6524 ? array_intersect_key($property, $propertyFieldList)
6528 unset($property, $propertyIterator);
6530 if (empty($propertiesList))
6533 $enumList =
array();
6535 $emptyResult = empty(
$result);
6542 while ($value = $valuesRes->Fetch())
6544 $elementID = (int)$value[
'IBLOCK_ELEMENT_ID'];
6556 $elementValues =
array();
6557 $existDescription = isset($value[
'DESCRIPTION']);
6558 foreach ($propertiesList as
$code => $property)
6560 $existElementDescription = isset($value[
'DESCRIPTION']) && array_key_exists($property[
'ID'], $value[
'DESCRIPTION']);
6561 $existElementPropertyID = isset($value[
'PROPERTY_VALUE_ID']) && array_key_exists($property[
'ID'], $value[
'PROPERTY_VALUE_ID']);
6562 $elementValues[
$code] = $shortProperties[
$code];
6564 $elementValues[
$code][
'VALUE_ENUM'] =
null;
6565 $elementValues[
$code][
'VALUE_XML_ID'] =
null;
6566 $elementValues[
$code][
'VALUE_SORT'] =
null;
6567 $elementValues[
$code][
'VALUE'] =
null;
6569 if (
'Y' === $property[
'MULTIPLE'])
6571 $elementValues[
$code][
'PROPERTY_VALUE_ID'] =
false;
6572 if (!isset($value[$property[
'ID']]) || empty($value[$property[
'ID']]))
6574 $elementValues[
$code][
'DESCRIPTION'] =
false;
6575 $elementValues[
$code][
'VALUE'] =
false;
6578 $elementValues[
$code][
'~DESCRIPTION'] =
false;
6579 $elementValues[
$code][
'~VALUE'] =
false;
6583 $elementValues[
$code][
'VALUE_ENUM_ID'] =
false;
6584 $elementValues[
$code][
'VALUE_ENUM'] =
false;
6585 $elementValues[
$code][
'VALUE_XML_ID'] =
false;
6586 $elementValues[
$code][
'VALUE_SORT'] =
false;
6591 if ($existElementPropertyID)
6593 $elementValues[
$code][
'PROPERTY_VALUE_ID'] = $value[
'PROPERTY_VALUE_ID'][$property[
'ID']];
6595 if (isset($userTypesList[$property[
'ID']]))
6597 foreach ($value[$property[
'ID']] as $valueKey => $oneValue)
6599 $raw = call_user_func_array(
6600 $userTypesList[$property[
'ID']][
'ConvertFromDB'],
6604 'VALUE' => $oneValue,
6605 'DESCRIPTION' => ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']][$valueKey] :
null),
6609 $value[$property[
'ID']][$valueKey] = $raw[
'VALUE'] ??
null;
6610 if (!$existDescription)
6612 $value[
'DESCRIPTION'] =
array();
6613 $existDescription =
true;
6615 if (!$existElementDescription)
6617 $value[
'DESCRIPTION'][$property[
'ID']] =
array();
6618 $existElementDescription =
true;
6620 $value[
'DESCRIPTION'][$property[
'ID']][$valueKey] = (string)$raw[
'DESCRIPTION'];
6622 if (isset($oneValue))
6627 if (empty($value[$property[
'ID']]))
6629 $elementValues[
$code][
'VALUE_ENUM_ID'] = $value[$property[
'ID']];
6630 $elementValues[
$code][
'DESCRIPTION'] = ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
array());
6634 $selectedValues =
array();
6635 foreach ($value[$property[
'ID']] as $listKey => $listValue)
6637 if (!isset($enumList[$property[
'ID']][$listValue]))
6639 if (!isset($enumList[$property[
'ID']]))
6640 $enumList[$property[
'ID']] = [];
6641 $enumList[$property[
'ID']][$listValue] =
false;
6642 $enumIterator = Iblock\PropertyEnumerationTable::getList(
array(
6643 'select' =>
array(
'ID',
'VALUE',
'SORT',
'XML_ID'),
6644 'filter' =>
array(
'=ID' => $listValue,
'=PROPERTY_ID' => $property[
'ID'])
6646 $row = $enumIterator->fetch();
6647 unset($enumIterator);
6650 $enumList[$property[
'ID']][$listValue] =
array(
6652 'VALUE' => $row[
'VALUE'],
6653 'SORT' => $row[
'SORT'],
6654 'XML_ID' => $row[
'XML_ID']
6659 if (!empty($enumList[$property[
'ID']][$listValue]))
6661 $selectedValues[$listKey] = $enumList[$property[
'ID']][$listValue];
6662 $selectedValues[$listKey][
'DESCRIPTION'] = (
6663 $existElementDescription && array_key_exists($listKey, $value[
'DESCRIPTION'][$property[
'ID']])
6664 ? $value[
'DESCRIPTION'][$property[
'ID']][$listKey]
6667 $selectedValues[$listKey][
'PROPERTY_VALUE_ID'] = (
6668 $existElementPropertyID && array_key_exists($listKey, $value[
'PROPERTY_VALUE_ID'][$property[
'ID']])
6669 ? $value[
'PROPERTY_VALUE_ID'][$property[
'ID']][$listKey]
6674 if (empty($selectedValues))
6676 $elementValues[
$code][
'VALUE_ENUM_ID'] = $value[$property[
'ID']];
6677 $elementValues[
$code][
'DESCRIPTION'] = ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
array());
6682 $elementValues[
$code][
'VALUE_SORT'] =
array();
6683 $elementValues[
$code][
'VALUE_ENUM_ID'] =
array();
6685 $elementValues[
$code][
'VALUE_ENUM'] =
array();
6686 $elementValues[
$code][
'VALUE_XML_ID'] =
array();
6687 $elementValues[
$code][
'DESCRIPTION'] =
array();
6688 $elementValues[
$code][
'PROPERTY_VALUE_ID'] =
array();
6689 foreach ($selectedValues as $listValue)
6691 $elementValues[
$code][
'VALUE_SORT'][] = $listValue[
'SORT'];
6692 $elementValues[
$code][
'VALUE_ENUM_ID'][] = $listValue[
'ID'];
6693 $elementValues[
$code][
'VALUE'][] = $listValue[
'VALUE'];
6694 $elementValues[
$code][
'VALUE_ENUM'][] = $listValue[
'VALUE'];
6695 $elementValues[
$code][
'VALUE_XML_ID'][] = $listValue[
'XML_ID'];
6696 $elementValues[
$code][
'PROPERTY_VALUE_ID'][] = $listValue[
'PROPERTY_VALUE_ID'];
6697 $elementValues[
$code][
'DESCRIPTION'][] = $listValue[
'DESCRIPTION'];
6699 unset($selectedValues);
6705 if (empty($value[$property[
'ID']]) || !$existElementPropertyID || isset($userTypesList[$property[
'ID']]))
6707 $elementValues[
$code][
'VALUE'] = $value[$property[
'ID']];
6708 $elementValues[
$code][
'DESCRIPTION'] = ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
array());
6712 $selectedValues =
array();
6713 foreach ($value[
'PROPERTY_VALUE_ID'][$property[
'ID']] as $propKey => $propValueID)
6715 $selectedValues[$propKey] =
array(
6716 'PROPERTY_VALUE_ID' => $propValueID,
6717 'VALUE' => $value[$property[
'ID']][$propKey],
6719 if ($existElementDescription)
6721 $selectedValues[$propKey][
'DESCRIPTION'] = $value[
'DESCRIPTION'][$property[
'ID']][$propKey];
6724 unset($propValueID, $propKey);
6727 $elementValues[
$code][
'PROPERTY_VALUE_ID'] =
array();
6729 $elementValues[
$code][
'DESCRIPTION'] =
array();
6730 foreach ($selectedValues as &$propValue)
6732 $elementValues[
$code][
'PROPERTY_VALUE_ID'][] = $propValue[
'PROPERTY_VALUE_ID'];
6733 $elementValues[
$code][
'VALUE'][] = $propValue[
'VALUE'];
6734 if ($existElementDescription)
6736 $elementValues[
$code][
'DESCRIPTION'][] = $propValue[
'DESCRIPTION'];
6739 unset($propValue, $selectedValues);
6746 $elementValues[
$code][
'~VALUE'] = $elementValues[
$code][
'VALUE'];
6747 if (is_array($elementValues[
$code][
'VALUE']))
6749 foreach ($elementValues[
$code][
'VALUE'] as &$oneValue)
6751 $isArr = is_array($oneValue);
6752 if ($isArr || (
'' !== $oneValue &&
null !== $oneValue))
6754 if ($isArr || preg_match(
"/[;&<>\"]/", $oneValue))
6760 if (isset($oneValue))
6765 if (
'' !== $elementValues[
$code][
'VALUE'] &&
null !== $elementValues[
$code][
'VALUE'])
6767 if (preg_match(
"/[;&<>\"]/", $elementValues[
$code][
'VALUE']))
6774 $elementValues[
$code][
'~DESCRIPTION'] = $elementValues[
$code][
'DESCRIPTION'];
6775 if (is_array($elementValues[
$code][
'DESCRIPTION']))
6777 foreach ($elementValues[
$code][
'DESCRIPTION'] as &$oneDescr)
6779 $isArr = is_array($oneDescr);
6780 if ($isArr || (!$isArr &&
'' !== $oneDescr &&
null !== $oneDescr))
6782 if ($isArr || preg_match(
"/[;&<>\"]/", $oneDescr))
6788 if (isset($oneDescr))
6793 if (
'' !== $elementValues[
$code][
'DESCRIPTION'] &&
null !== $elementValues[
$code][
'DESCRIPTION'])
6795 if (preg_match(
"/[;&<>\"]/", $elementValues[
$code][
'DESCRIPTION']))
6805 $elementValues[
$code][
'VALUE_ENUM'] = ($iblockExtVersion ?
'' :
null);
6806 $elementValues[
$code][
'PROPERTY_VALUE_ID'] = ($iblockExtVersion ?
$elementID.
':'.$property[
'ID'] :
null);
6808 if (!isset($value[$property[
'ID']]) ||
false === $value[$property[
'ID']])
6810 $elementValues[
$code][
'DESCRIPTION'] =
'';
6811 $elementValues[
$code][
'VALUE'] =
'';
6814 $elementValues[
$code][
'~DESCRIPTION'] =
'';
6815 $elementValues[
$code][
'~VALUE'] =
'';
6819 $elementValues[
$code][
'VALUE_ENUM_ID'] =
null;
6824 if ($existElementPropertyID)
6826 $elementValues[
$code][
'PROPERTY_VALUE_ID'] = $value[
'PROPERTY_VALUE_ID'][$property[
'ID']];
6828 if (isset($userTypesList[$property[
'ID']]))
6830 $raw = call_user_func_array(
6831 $userTypesList[$property[
'ID']][
'ConvertFromDB'],
6835 'VALUE' => $value[$property[
'ID']],
6836 'DESCRIPTION' => ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
null)
6840 $value[$property[
'ID']] = $raw[
'VALUE'] ??
null;
6841 if (!$existDescription)
6843 $value[
'DESCRIPTION'] =
array();
6844 $existDescription =
true;
6846 $value[
'DESCRIPTION'][$property[
'ID']] = (string)($raw[
'DESCRIPTION'] ??
null);
6847 $existElementDescription =
true;
6851 $elementValues[
$code][
'VALUE_ENUM_ID'] = $value[$property[
'ID']];
6852 if (!isset($enumList[$property[
'ID']][$value[$property[
'ID']]]))
6854 if (!isset($enumList[$property[
'ID']]))
6855 $enumList[$property[
'ID']] = [];
6856 $enumList[$property[
'ID']][$value[$property[
'ID']]] =
false;
6857 $enumIterator = Iblock\PropertyEnumerationTable::getList(
array(
6858 'select' =>
array(
'ID',
'VALUE',
'SORT',
'XML_ID'),
6859 'filter' =>
array(
'=ID' => $value[$property[
'ID']],
'=PROPERTY_ID' => $property[
'ID'])
6861 $row = $enumIterator->fetch();
6862 unset($enumIterator);
6865 $enumList[$property[
'ID']][$value[$property[
'ID']]] =
array(
6867 'VALUE' => $row[
'VALUE'],
6868 'SORT' => $row[
'SORT'],
6869 'XML_ID' => $row[
'XML_ID']
6874 if (!empty($enumList[$property[
'ID']][$value[$property[
'ID']]]))
6876 $elementValues[
$code][
'VALUE'] = $enumList[$property[
'ID']][$value[$property[
'ID']]][
'VALUE'];
6877 $elementValues[
$code][
'VALUE_ENUM'] = $elementValues[
$code][
'VALUE'];
6878 $elementValues[
$code][
'VALUE_XML_ID'] = $enumList[$property[
'ID']][$value[$property[
'ID']]][
'XML_ID'];
6879 $elementValues[
$code][
'VALUE_SORT'] = $enumList[$property[
'ID']][$value[$property[
'ID']]][
'SORT'];
6881 $elementValues[
$code][
'DESCRIPTION'] = ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
null);
6885 $elementValues[
$code][
'VALUE'] = $value[$property[
'ID']];
6886 $elementValues[
$code][
'DESCRIPTION'] = ($existElementDescription ? $value[
'DESCRIPTION'][$property[
'ID']] :
null);
6892 $elementValues[
$code][
'~VALUE'] = $elementValues[
$code][
'VALUE'];
6893 $isArr = is_array($elementValues[
$code][
'VALUE']);
6894 if ($isArr || (
'' !== $elementValues[
$code][
'VALUE'] &&
null !== $elementValues[
$code][
'VALUE']))
6896 if ($isArr || preg_match(
"/[;&<>\"]/", $elementValues[
$code][
'VALUE']))
6902 $elementValues[
$code][
'~DESCRIPTION'] = $elementValues[
$code][
'DESCRIPTION'];
6903 $isArr = is_array($elementValues[
$code][
'DESCRIPTION']);
6904 if ($isArr || (
'' !== $elementValues[
$code][
'DESCRIPTION'] &&
null !== $elementValues[
$code][
'DESCRIPTION']))
6906 if ($isArr || preg_match(
"/[;&<>\"]/", $elementValues[
$code][
'DESCRIPTION']))
6920 unset($elementValues);
6939 $ELEMENT_ID = (int)$ELEMENT_ID;
6945 switch(mb_strtoupper(
$key))
6950 $strSqlSearch .=
"AND BP.ACTIVE='".$val.
"'\n";
6956 $strSqlSearch .=
"AND BP.SEARCHABLE='".$val.
"'\n";
6962 $strSqlSearch .=
"AND ".CIBlock::_Upper(
"BP.NAME").
" LIKE ".CIBlock::_Upper(
"'".
$DB->ForSql(
$val).
"'").
"\n";
6970 $strSqlSearch .=
"AND BP.ID in (".implode(
", ", array_map(
"intval",
$val)).
")\n";
6975 $strSqlSearch .=
"AND BP.ID=".intval(
$val).
"\n";
6978 case "PROPERTY_TYPE":
6981 $strSqlSearch .=
"AND BP.PROPERTY_TYPE='".$DB->ForSql(
$val).
"'\n";
6987 $strSqlSearch .=
"AND ".CIBlock::_Upper(
"BP.CODE").
" LIKE ".CIBlock::_Upper(
"'".
$DB->ForSql(
$val).
"'").
"\n";
6995 $strSqlSearch .=
"AND BEP.ID IS NULL\n";
6999 $strSqlSearch .=
"AND BEP.ID IS NOT NULL\n";
7006 $arSqlOrder =
array();
7009 foreach($arOrder as $by=>
$order)
7015 $by = mb_strtolower($by);
7016 if($by ==
"sort") $arSqlOrder[
"BP.SORT"]=
$order;
7019 elseif($by ==
"active") $arSqlOrder[
"BP.ACTIVE"]=
$order;
7020 elseif($by ==
"value_id") $arSqlOrder[
"BEP.ID"]=
$order;
7021 elseif($by ==
"enum_sort") $arSqlOrder[
"BEPE.SORT"]=
$order;
7023 $arSqlOrder[
"BP.SORT"]=
$order;
7028 if($by ==
"id") $arSqlOrder[
"BP.ID"]=
"asc";
7029 elseif($by ==
"name") $arSqlOrder[
"BP.NAME"]=
"asc";
7030 elseif($by ==
"active") $arSqlOrder[
"BP.ACTIVE"]=
"asc";
7031 elseif($by ==
"value_id") $arSqlOrder[
"BEP.ID"]=
$order;
7032 elseif($by ==
"enum_sort") $arSqlOrder[
"BEPE.SORT"]=
$order;
7035 $arSqlOrder[
"BP.SORT"]=
"asc";
7041 $arSqlOrder[
"BP.SORT"]=
"asc";
7042 $arSqlOrder[
"BP.ID"]=
"asc";
7043 $arSqlOrder[
"BEPE.SORT"]=
"asc";
7044 $arSqlOrder[
"BEP.ID"]=
"asc";
7049 $arSqlOrder[
"BP.SORT"]=
"desc";
7050 $arSqlOrder[
"BP.ID"]=
"desc";
7051 $arSqlOrder[
"BEPE.SORT"]=
"desc";
7052 $arSqlOrder[
"BEP.ID"]=
"desc";
7058 $strSqlOrder.=
", ".$key.
" ".
$val;
7060 if($strSqlOrder!=
"")
7061 $strSqlOrder =
' ORDER BY '.mb_substr($strSqlOrder, 1);
7064 $strTable =
"b_iblock_element_prop_m".$IBLOCK_ID;
7066 $strTable =
"b_iblock_element_property";
7069 SELECT BP.*, BEP.ID as PROPERTY_VALUE_ID, BEP.VALUE, BEP.DESCRIPTION, BEPE.VALUE VALUE_ENUM, BEPE.XML_ID VALUE_XML_ID, BEPE.SORT VALUE_SORT
7071 INNER JOIN b_iblock_property BP ON B.ID=BP.IBLOCK_ID
7072 LEFT JOIN ".$strTable.
" BEP ON (BP.ID = BEP.IBLOCK_PROPERTY_ID AND BEP.IBLOCK_ELEMENT_ID = ".$ELEMENT_ID.
")
7073 LEFT JOIN b_iblock_property_enum BEPE ON (BP.PROPERTY_TYPE = 'L' AND BEPE.ID=BEP.VALUE_ENUM AND BEPE.PROPERTY_ID=BP.ID)
7083 $arElements =
array();
7084 $rs =
$DB->Query($strSql);
7085 while(
$ar =
$rs->Fetch())
7087 if(
$ar[
"VERSION"]==2 &&
$ar[
"MULTIPLE"]==
"N")
7089 if (!isset($arElements[$ELEMENT_ID]))
7093 FROM b_iblock_element_prop_s".$ar[
"IBLOCK_ID"].
"
7094 WHERE IBLOCK_ELEMENT_ID = ".$ELEMENT_ID.
"
7096 $rs2 =
$DB->Query($strSql);
7097 $arElements[$ELEMENT_ID] = $rs2->Fetch();
7101 is_array($arElements[$ELEMENT_ID])
7102 && isset($arElements[$ELEMENT_ID][
"PROPERTY_".
$ar[
"ID"]])
7103 && $arElements[$ELEMENT_ID][
"PROPERTY_".$ar[
"ID"]] !==
''
7105 if ($emptyFilter || $notEmptyValue)
7107 $val = $arElements[$ELEMENT_ID][
"PROPERTY_".$ar[
"ID"]] ??
null;
7108 $ar[
"PROPERTY_VALUE_ID"] = $ELEMENT_ID .
":" .
$ar[
"ID"];
7109 if (
$ar[
"PROPERTY_TYPE"]==
"L" && (
int)
$val > 0)
7114 $ar[
"VALUE_ENUM"] = $arEnum[
"VALUE"];
7115 $ar[
"VALUE_XML_ID"] = $arEnum[
"XML_ID"];
7116 $ar[
"VALUE_SORT"] = $arEnum[
"SORT"];
7121 $ar[
"VALUE_ENUM"] =
"";
7125 $val = CIBlock::NumberFormat(
$val);
7127 $ar[
"DESCRIPTION"] = $arElements[$ELEMENT_ID][
"DESCRIPTION_".$ar[
"ID"]] ??
null;
7135 if ($notEmptyFilter &&
$ar[
"PROPERTY_VALUE_ID"] ==
"")
7155 if(!isset($_SESSION[
"IBLOCK_COUNTER"]) || !is_array($_SESSION[
"IBLOCK_COUNTER"]))
7156 $_SESSION[
"IBLOCK_COUNTER"] =
array();
7157 if(in_array(
$ID, $_SESSION[
"IBLOCK_COUNTER"]))
7159 $_SESSION[
"IBLOCK_COUNTER"][] =
$ID;
7161 $DB->StartUsingMasterOnly();
7163 "UPDATE b_iblock_element SET ".
7164 " TIMESTAMP_X = ".($DB->type==
"ORACLE"?
" NULL":
"TIMESTAMP_X").
", ".
7165 " SHOW_COUNTER_START = ".
$DB->IsNull(
"SHOW_COUNTER_START",
$DB->CurrentTimeFunction()).
", ".
7166 " SHOW_COUNTER = ".$DB->IsNull(
"SHOW_COUNTER", 0).
" + 1 ".
7168 $DB->Query($strSql,
false,
"",
array(
"ignore_dml"=>
true));
7169 $DB->StopUsingMasterOnly();
7183 $propertyId = (int)$property[
'ID'];
7184 $elementId = (int)$iblock_element_id;
7187 $iblockId = (int)$property[
'IBLOCK_ID'];
7188 if ($property[
'MULTIPLE'] ===
'Y')
7192 FROM b_iblock_element_prop_m" .
$iblockId .
"
7194 IBLOCK_ELEMENT_ID=" . $elementId .
"
7195 AND IBLOCK_PROPERTY_ID=" . $propertyId .
"
7202 b_iblock_element_prop_s" .
$iblockId .
"
7204 PROPERTY_" . $propertyId .
"=null
7207 IBLOCK_ELEMENT_ID=" . $elementId .
"
7215 b_iblock_element_property
7217 IBLOCK_ELEMENT_ID=" . $elementId .
"
7218 AND IBLOCK_PROPERTY_ID=" . $propertyId .
"
7226 if (!is_array($PROPERTY_VALUES))
7231 if (!is_array($FLAGS))
7242 $ELEMENT_ID = (int)$ELEMENT_ID;
7243 if ($ELEMENT_ID <= 0)
7251 $ar = static::GetIBlockByID($ELEMENT_ID);
7260 $uniq_flt =
$IBLOCK_ID.
"|SetPropertyValuesEx";
7272 "CHECK_PERMISSIONS"=>
"N",
7275 while(
$ar =
$rs->Fetch())
7277 $ar[
"ConvertToDB"] =
false;
7278 if(
$ar[
"USER_TYPE"]!=
"")
7280 $arUserType = CIBlockProperty::GetUserType(
$ar[
"USER_TYPE"]);
7281 if(array_key_exists(
"ConvertToDB", $arUserType))
7282 $ar[
"ConvertToDB"] = $arUserType[
"ConvertToDB"];
7297 foreach($PROPERTY_VALUES as
$key=>$value)
7300 if(array_key_exists(
$key, $PROPS_CACHE[0]))
7308 if(
$key <= 0 || !array_key_exists(
$key, $PROPS_CACHE))
7312 $propertyList[
$key] = $PROPS_CACHE[
$key];
7313 if($PROPS_CACHE[
$key][
"PROPERTY_TYPE"]==
"F")
7315 if(is_array($value))
7317 $ar = array_keys($value);
7318 if(array_key_exists(
"tmp_name", $value) || array_key_exists(
"del", $value))
7320 $uni_value =
array(
array(
"ID"=>0,
"VALUE"=>$value,
"DESCRIPTION"=>
""));
7324 $uni_value =
array(
array(
"ID"=>0,
"VALUE"=>$value[
"VALUE"],
"DESCRIPTION"=>$value[
"DESCRIPTION"]));
7328 $uni_value =
array(
array(
"ID"=>0,
"VALUE"=>$value[
"VALUE"],
"DESCRIPTION"=>
""));
7332 $uni_value =
array();
7333 foreach($value as $id=>
$val)
7337 if(array_key_exists(
"tmp_name",
$val) || array_key_exists(
"del",
$val))
7339 $uni_value[] =
array(
"ID"=>$id,
"VALUE"=>
$val,
"DESCRIPTION"=>
"");
7344 if(
$ar[0]===
"VALUE" &&
$ar[1]===
"DESCRIPTION")
7345 $uni_value[] =
array(
"ID"=>$id,
"VALUE"=>
$val[
"VALUE"],
"DESCRIPTION"=>
$val[
"DESCRIPTION"]);
7347 $uni_value[] =
array(
"ID"=>$id,
"VALUE"=>
$val[
"VALUE"],
"DESCRIPTION"=>
"");
7356 $uni_value =
array();
7359 elseif(!is_array($value))
7361 $uni_value =
array(
array(
"VALUE"=>$value,
"DESCRIPTION"=>
""));
7365 $ar = array_keys($value);
7368 $uni_value =
array(
array(
"VALUE"=>$value[
"VALUE"],
"DESCRIPTION"=>$value[
"DESCRIPTION"]));
7372 $uni_value =
array(
array(
"VALUE"=>$value[
"VALUE"],
"DESCRIPTION"=>
""));
7376 $uni_value =
array();
7377 foreach($value as $id=>
$val)
7380 $uni_value[] =
array(
"VALUE"=>
$val,
"DESCRIPTION"=>
"");
7384 if(
$ar[0]===
"VALUE" &&
$ar[1]===
"DESCRIPTION")
7385 $uni_value[] =
array(
"VALUE"=>
$val[
"VALUE"],
"DESCRIPTION"=>
$val[
"DESCRIPTION"]);
7387 $uni_value[] =
array(
"VALUE"=>
$val[
"VALUE"],
"DESCRIPTION"=>
"");
7393 $arValueCounters =
array();
7394 foreach($uni_value as
$val)
7396 if(!array_key_exists(
$key, $arProps))
7399 $arValueCounters[
$key] = 0;
7402 if($PROPS_CACHE[
$key][
"ConvertToDB"]!==
false)
7404 $arProperty = $PROPS_CACHE[
$key];
7405 $arProperty[
"ELEMENT_ID"] = $ELEMENT_ID;
7406 $val = call_user_func_array($PROPS_CACHE[
$key][
"ConvertToDB"],
array($arProperty,
$val));
7410 (!is_array(
$val[
"VALUE"]) && (
string)
$val[
"VALUE"] <>
'')
7411 || (is_array(
$val[
"VALUE"]) && !empty(
$val[
"VALUE"]))
7415 $arValueCounters[
$key] == 0
7416 || $PROPS_CACHE[
$key][
"MULTIPLE"]==
"Y"
7419 if(!is_array(
$val[
"VALUE"]) || !isset(
$val[
"VALUE"][
"del"]))
7420 $arValueCounters[
$key]++;
7428 if (empty($arProps))
7434 $arDBProps =
array();
7435 if(!array_key_exists(
"NewElement", $FLAGS))
7437 if($PROPS_CACHE[
"VERSION"]==1)
7441 from b_iblock_element_property
7442 where IBLOCK_ELEMENT_ID=".$ELEMENT_ID.
"
7443 AND IBLOCK_PROPERTY_ID in (".implode(
", ", array_keys($arProps)).
")
7447 if(!array_key_exists(
$ar[
"IBLOCK_PROPERTY_ID"], $arDBProps))
7448 $arDBProps[
$ar[
"IBLOCK_PROPERTY_ID"]] =
array();
7449 $arDBProps[
$ar[
"IBLOCK_PROPERTY_ID"]][
$ar[
"ID"]] =
$ar;
7457 where IBLOCK_ELEMENT_ID=".$ELEMENT_ID.
"
7458 AND IBLOCK_PROPERTY_ID in (".implode(
", ", array_keys($arProps)).
")
7462 if(!array_key_exists(
$ar[
"IBLOCK_PROPERTY_ID"], $arDBProps))
7463 $arDBProps[
$ar[
"IBLOCK_PROPERTY_ID"]] =
array();
7464 $arDBProps[
$ar[
"IBLOCK_PROPERTY_ID"]][
$ar[
"ID"]] =
$ar;
7469 where IBLOCK_ELEMENT_ID=".$ELEMENT_ID.
"
7473 foreach($PROPS_CACHE as $property_id=>$property)
7475 if( array_key_exists($property_id, $arProps)
7476 && array_key_exists(
"PROPERTY_".$property_id,
$ar)
7477 && $property[
"MULTIPLE"]==
"N"
7478 &&
$ar[
"PROPERTY_".$property_id] <>
'')
7481 "IBLOCK_PROPERTY_ID" => $property_id,
7482 "VALUE" =>
$ar[
"PROPERTY_".$property_id],
7483 "DESCRIPTION" =>
$ar[
"DESCRIPTION_".$property_id],
7485 if(!array_key_exists($pr[
"IBLOCK_PROPERTY_ID"], $arDBProps))
7486 $arDBProps[$pr[
"IBLOCK_PROPERTY_ID"]] =
array();
7487 $arDBProps[$pr[
"IBLOCK_PROPERTY_ID"]][$ELEMENT_ID.
":".$property_id] = $pr;
7494 insert into b_iblock_element_prop_s".
$IBLOCK_ID.
"
7495 (IBLOCK_ELEMENT_ID) values (".$ELEMENT_ID.
")
7501 foreach (
GetModuleEvents(
"iblock",
"OnIBlockElementSetPropertyValuesEx",
true) as $arEvent)
7503 if (isset($arEvent))
7506 $arFilesToDelete =
array();
7508 foreach($arProps as $property_id=>$values)
7510 if($PROPS_CACHE[$property_id][
"PROPERTY_TYPE"]==
"F")
7512 foreach($values as
$i=>$value)
7514 $val = $value[
"VALUE"];
7515 if(
$val[
"del"] <>
'')
7521 $val[
"MODULE_ID"] =
"iblock";
7522 unset(
$val[
"old_file"]);
7524 if($value[
"DESCRIPTION"] <>
'')
7525 $val[
"description"] = $value[
"DESCRIPTION"];
7527 $val = CFile::SaveFile(
$val,
"iblock");
7532 unset($arProps[$property_id][
$i]);
7536 $arProps[$property_id][
$i][
"VALUE"] = intval(
$val);
7537 if($value[
"DESCRIPTION"] ==
'')
7538 $arProps[$property_id][
$i][
"DESCRIPTION"]=$arDBProps[$property_id][$value[
"ID"]][
"DESCRIPTION"];
7540 elseif($value[
"DESCRIPTION"] <>
'')
7542 $arProps[$property_id][
$i][
"VALUE"] = $arDBProps[$property_id][$value[
"ID"]][
"VALUE"];
7544 unset($arDBProps[$property_id][$value[
"ID"]]);
7548 $arProps[$property_id][
$i][
"VALUE"] = $arDBProps[$property_id][$value[
"ID"]][
"VALUE"];
7550 unset($arDBProps[$property_id][$value[
"ID"]]);
7554 if(array_key_exists($property_id, $arDBProps))
7556 foreach($arDBProps[$property_id] as $id=>$value)
7557 $arFilesToDelete[] =
array($value[
"VALUE"], $ELEMENT_ID,
"PROPERTY", -1,
$IBLOCK_ID);
7562 foreach($arFilesToDelete as
$ar)
7563 call_user_func_array(
array(
"CIBlockElement",
"DeleteFile"),
$ar);
7566 if(!array_key_exists(
"NewElement", $FLAGS))
7568 foreach($arProps as $property_id=>$values)
7570 if($PROPS_CACHE[$property_id][
"PROPERTY_TYPE"]!=
"F")
7572 if(array_key_exists($property_id, $arDBProps))
7574 $db_values = $arDBProps[$property_id];
7578 foreach($values as $id=>$value)
7581 foreach($db_values as $db_id=>$db_row)
7584 strcmp($value[
'VALUE'], $db_row[
'VALUE']) === 0
7586 (
string)($value[
'DESCRIPTION'] ??
''),
7587 (
string)($db_row[
'DESCRIPTION'] ??
'')
7591 unset($db_values[$db_id]);
7604 unset($arProps[$property_id]);
7605 unset($arDBProps[$property_id]);
7612 unset($arProps[$property_id]);
7620 "b_iblock_element_property" =>
array(),
7622 "b_iblock_section_element" =>
array(),
7626 "b_iblock_element_property" =>
array(),
7630 "b_iblock_element_property" =>
array(),
7632 "b_iblock_section_element" =>
array(),
7641 foreach($arDBProps as $property_id=>$values)
7643 if($PROPS_CACHE[$property_id][
"VERSION"]==1)
7645 $ar2Delete[
"b_iblock_element_property"][$property_id]=
true;
7647 elseif($PROPS_CACHE[$property_id][
"MULTIPLE"]==
"Y")
7649 $ar2Delete[
"b_iblock_element_prop_m".$IBLOCK_ID][$property_id]=
true;
7650 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
false;
7654 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
false;
7656 if($PROPS_CACHE[$property_id][
"PROPERTY_TYPE"]==
"G")
7657 $ar2Delete[
"b_iblock_section_element"][$property_id]=
true;
7660 foreach($arProps as $property_id=>$values)
7662 $db_prop = $PROPS_CACHE[$property_id];
7663 if($db_prop[
"PROPERTY_TYPE"]==
"L" && !array_key_exists(
"DoNotValidateLists",$FLAGS))
7666 foreach($values as $value)
7668 $value[
"VALUE"] = intval($value[
"VALUE"]);
7669 if($value[
"VALUE"]>0)
7670 $arID[]=$value[
"VALUE"];
7674 if($db_prop[
"VERSION"]==1)
7676 $ar2Insert[
"sqls"][
"b_iblock_element_property"][$property_id] =
"
7677 INSERT INTO b_iblock_element_property
7678 (IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_ENUM)
7679 SELECT ".$ELEMENT_ID.
", P.ID, PEN.ID, PEN.ID
7682 ,b_iblock_property_enum PEN
7684 P.ID=".$property_id.
"
7685 AND P.ID=PEN.PROPERTY_ID
7686 AND PEN.ID IN (".implode(
", ",$arID).
")
7689 elseif($db_prop[
"MULTIPLE"]==
"Y")
7691 $ar2Insert[
"sqls"][
"b_iblock_element_prop_m".$IBLOCK_ID][$property_id] =
"
7692 INSERT INTO b_iblock_element_prop_m".$IBLOCK_ID.
"
7693 (IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_ENUM)
7694 SELECT ".$ELEMENT_ID.
", P.ID, PEN.ID, PEN.ID
7697 ,b_iblock_property_enum PEN
7699 P.ID=".$property_id.
"
7700 AND P.ID=PEN.PROPERTY_ID
7701 AND PEN.ID IN (".implode(
", ",$arID).
")
7703 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
false;
7711 ,b_iblock_property_enum PEN
7713 P.ID=".$property_id.
"
7714 AND P.ID=PEN.PROPERTY_ID
7715 AND PEN.ID IN (".implode(
", ",$arID).
")
7718 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
array(
"VALUE"=>
$ar[
"ID"],
"DESCRIPTION"=>
"");
7723 if($db_prop[
"PROPERTY_TYPE"]==
"G")
7726 foreach($values as $value)
7728 $value[
"VALUE"] = intval($value[
"VALUE"]);
7729 if($value[
"VALUE"]>0)
7730 $arID[]=$value[
"VALUE"];
7734 if($db_prop[
"VERSION"]==1)
7736 $ar2Insert[
"sqls"][
"b_iblock_element_property"][$property_id] =
"
7737 INSERT INTO b_iblock_element_property
7738 (IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM)
7739 SELECT ".$ELEMENT_ID.
", P.ID, S.ID, S.ID
7744 P.ID=".$property_id.
"
7745 AND S.IBLOCK_ID = P.LINK_IBLOCK_ID
7746 AND S.ID IN (".implode(
", ",$arID).
")
7749 elseif($db_prop[
"MULTIPLE"]==
"Y")
7751 $ar2Insert[
"sqls"][
"b_iblock_element_prop_m".$IBLOCK_ID][$property_id] =
"
7752 INSERT INTO b_iblock_element_prop_m".$IBLOCK_ID.
"
7753 (IBLOCK_ELEMENT_ID, IBLOCK_PROPERTY_ID, VALUE, VALUE_NUM)
7754 SELECT ".$ELEMENT_ID.
", P.ID, S.ID, S.ID
7759 P.ID=".$property_id.
"
7760 AND S.IBLOCK_ID = P.LINK_IBLOCK_ID
7761 AND S.ID IN (".implode(
", ",$arID).
")
7763 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
false;
7773 P.ID=".$property_id.
"
7774 AND S.IBLOCK_ID = P.LINK_IBLOCK_ID
7775 AND S.ID IN (".implode(
", ",$arID).
")
7778 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
array(
"VALUE"=>
$ar[
"ID"],
"DESCRIPTION"=>
"");
7780 $ar2Insert[
"sqls"][
"b_iblock_section_element"][$property_id] =
"
7781 INSERT INTO b_iblock_section_element
7782 (IBLOCK_ELEMENT_ID, IBLOCK_SECTION_ID, ADDITIONAL_PROPERTY_ID)
7783 SELECT ".$ELEMENT_ID.
", S.ID, P.ID
7784 FROM b_iblock_property P, b_iblock_section S
7785 WHERE P.ID=".$property_id.
"
7786 AND S.IBLOCK_ID = P.LINK_IBLOCK_ID
7787 AND S.ID IN (".implode(
", ",$arID).
")
7792 foreach($values as $value)
7794 if($db_prop[
"VERSION"]==1)
7796 $ar2Insert[
"values"][
"b_iblock_element_property"][$property_id][]=$value;
7798 elseif($db_prop[
"MULTIPLE"]==
"Y")
7800 $ar2Insert[
"values"][
"b_iblock_element_prop_m".$IBLOCK_ID][$property_id][]=$value;
7801 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=
false;
7805 $ar2Update[
"b_iblock_element_prop_s".$IBLOCK_ID][$property_id]=$value;
7810 foreach($ar2Delete as
$table=>$arID)
7814 if(
$table==
"b_iblock_section_element")
7817 where IBLOCK_ELEMENT_ID = ".$ELEMENT_ID.
"
7818 and ADDITIONAL_PROPERTY_ID in (".implode(
", ", array_keys($arID)).
")
7823 where IBLOCK_ELEMENT_ID = ".$ELEMENT_ID.
"
7824 and IBLOCK_PROPERTY_ID in (".implode(
", ", array_keys($arID)).
")
7829 foreach($ar2Insert[
"values"] as
$table=>$properties)
7832 insert into ".$table.
"
7833 (IBLOCK_PROPERTY_ID, IBLOCK_ELEMENT_ID, VALUE, VALUE_ENUM, VALUE_NUM, DESCRIPTION)
7837 $maxValuesLen =
$DB->type==
"MYSQL"?1024:0;
7839 foreach ($properties as $property_id=>$values)
7841 foreach ($values as $value)
7843 if ((
string)$value[
"VALUE"] <>
'')
7846 $strSqlValues .=
",\n(".
7849 "'".$DB->ForSQL($value[
"VALUE"]).
"', ".
7850 intval($value[
"VALUE"]).
", ".
7851 CIBlock::roundDB($value[
"VALUE"]).
", ".
7855 if (mb_strlen($strSqlValues) > $maxValuesLen)
7857 $DB->Query($strSqlPrefix.mb_substr($strSqlValues, 2));
7862 if($strSqlValues <>
'')
7864 $DB->Query($strSqlPrefix.mb_substr($strSqlValues, 2));
7869 foreach($ar2Insert[
"sqls"] as
$table=>$properties)
7871 foreach($properties as $property_id=>$sql)
7877 foreach($ar2Update as
$table=>$properties)
7879 $tableFields =
$DB->GetTableFields(
$table);
7880 if(
count($properties)>0)
7883 foreach($properties as $property_id=>$value)
7885 if($value===
false || (
string)$value[
"VALUE"] ===
'')
7887 $arFields[] =
"PROPERTY_".$property_id.
" = null";
7888 if (isset($tableFields[
"DESCRIPTION_".$property_id]))
7890 $arFields[] =
"DESCRIPTION_".$property_id.
" = null";
7895 $arFields[] =
"PROPERTY_".$property_id.
" = '".
$DB->ForSQL($value[
"VALUE"]).
"'";
7896 if (isset($tableFields[
"DESCRIPTION_".$property_id]))
7898 if($value[
"DESCRIPTION"] <>
'')
7900 $arFields[] =
"DESCRIPTION_".$property_id.
" = '".
$DB->ForSQL($value[
"DESCRIPTION"]).
"'";
7904 $arFields[] =
"DESCRIPTION_".$property_id.
" = null";
7912 where IBLOCK_ELEMENT_ID = ".$ELEMENT_ID.
"
7920 foreach (
GetModuleEvents(
"iblock",
"OnAfterIBlockElementSetPropertyValuesEx",
true) as $arEvent)
7932 $minPermission = (strlen($minPermission) === 1) ? $minPermission : CIBlockRights::PUBLIC_READ;
7934 if ($permissionsBy !==
null && $permissionsBy < 0)
7936 $permissionsBy =
null;
7939 if ($permissionsBy !==
null)
7942 $groupList = CUser::GetUserGroup($permissionsBy);
7943 $authorized =
false;
7950 $groupList =
$USER->GetUserGroupArray();
7951 $authorized =
$USER->IsAuthorized();
7957 $authorized =
false;
7961 $simplePermissions =
"
7963 FROM b_iblock_group IBG
7964 WHERE IBG.GROUP_ID IN (" . implode(
',', $groupList) .
")
7965 AND IBG.PERMISSION >= '" . $helper->forSql($minPermission) .
"'
7967 if (!defined(
'ADMIN_SECTION'))
7969 $simplePermissions .=
"
7970 AND (IBG.PERMISSION='" . CIBlockRights::FULL_ACCESS .
"' OR B.ACTIVE='Y')
7973 $simplePermissions =
"B.ID IN (" . $simplePermissions .
")";
7975 if ($minPermission >= CIBlockRights::FULL_ACCESS)
7977 $operation = CIBlockElementRights::OPERATION_RIGHTS_EDIT;
7979 elseif ($minPermission >= CIBlockRights::EDIT_ACCESS)
7981 $operation = CIBlockElementRights::OPERATION_EDIT;
7983 elseif ($minPermission >= CIBlockRights::PUBLIC_READ)
7985 $operation = CIBlockElementRights::OPERATION_READ;
7995 $acc->UpdateCodes($permissionsBy !==
null ? [
'USER_ID' => $permissionsBy] :
false);
7999 if ($operation === CIBlockElementRights::OPERATION_READ)
8001 $extendedPermissions =
"
8002 SELECT ER.ELEMENT_ID
8003 FROM b_iblock_element_right ER
8004 INNER JOIN b_iblock_right IBR ON IBR.ID = ER.RIGHT_ID
8005 " . (
$userId > 0 ?
'LEFT':
'INNER')
8006 .
" JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " .
$userId .
"
8007 WHERE ER.ELEMENT_ID = BE.ID
8008 AND IBR.OP_EREAD = 'Y'
8009 " . ($authorized ||
$userId > 0
8011 AND (UA.USER_ID IS NOT NULL
8012 " . ($authorized ?
"OR IBR.GROUP_CODE = 'AU'":
'') .
"
8013 " . (
$userId > 0 ?
"OR (IBR.GROUP_CODE = 'CR' AND BE.CREATED_BY = " .
$userId .
")":
'') .
"
8020 " . $simplePermissions .
"
8026 $extendedPermissions =
"
8027 SELECT ER.ELEMENT_ID
8028 FROM b_iblock_element_right ER
8029 INNER JOIN b_iblock_right IBR ON IBR.ID = ER.RIGHT_ID
8030 INNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID
8031 INNER JOIN b_operation O ON O.ID = T.OPERATION_ID
8032 " . (
$userId > 0 ?
'LEFT':
'INNER')
8033 .
" JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " .
$userId .
"
8034 WHERE ER.ELEMENT_ID = BE.ID
8035 AND O.NAME = '" . $operation .
"'
8036 " . ($authorized ||
$userId > 0
8038 AND (UA.USER_ID IS NOT NULL
8039 " . ($authorized ?
"OR IBR.GROUP_CODE = 'AU'":
'') .
"
8040 " . (
$userId > 0 ?
"OR (IBR.GROUP_CODE = 'CR' AND BE.CREATED_BY = " .
$userId .
")":
'') .
"
8047 " . $simplePermissions .
"
8053 $extendedPermissions =
'';
8055 " . $simplePermissions .
"
8060 'SIMPLE' => $simplePermissions,
8061 'EXTENDED' =>
'EXISTS (' . $extendedPermissions .
')',
8068 $mode = match (CIBlock::GetArrayByID(
$iblockId,
'RIGHTS_MODE'))
8082 if ($permissionsBy !==
null)
8084 $permissionsBy = (int)$permissionsBy;
8087 return static::getCheckRightsSql(
null, (
string)$min_permission, $permissionsBy);
8093 $tableFields =
$DB->GetTableFields(
"b_iblock_element_prop_s".$iblock_id);
8094 if (isset($tableFields[
"DESCRIPTION_".$property_id]))
8100 return ", DESCRIPTION_".$property_id.
"=".$sqlValue;
8122 return $helper->getOrderByIntField(
'BE.ID',
$order,
false);
8134 return CIBlock::_Order(
'BE.ID',
$order,
'desc',
false);
8139 if ($id <= 0 || empty(
$fields))
8146 $properties =
array();
8150 $properties = $list;
8155 foreach (array_keys($list) as $index)
8157 $properties[$index] = $list[$index];
8161 if (!empty($properties))
8168 from b_iblock_element_property
8169 where IBLOCK_ELEMENT_ID=".$id.
"
8170 and IBLOCK_PROPERTY_ID in (".implode(
", ", array_keys($properties)).
")
8177 from b_iblock_element_prop_m".
$iblock[
'ID'].
"
8178 where IBLOCK_ELEMENT_ID=".$id.
"
8179 and IBLOCK_PROPERTY_ID in (".implode(
", ", array_keys($properties)).
")
8185 $property = $properties[$row[
"IBLOCK_PROPERTY_ID"]];
8186 if (isset($property[
"GetSearchContent"]))
8189 call_user_func_array($property[
"GetSearchContent"],
8192 array(
"VALUE" => $row[
"VALUE"]),
8201 if ($arEnum !==
false)
8207 if(is_array($arFile))
8209 $result .= $arFile[
"CONTENT"];
8221 from b_iblock_element_prop_s".
$iblock[
'ID'].
"
8222 where IBLOCK_ELEMENT_ID=".$id.
"
8226 foreach($properties as $propertyId => $item)
8228 $fieldId =
'PROPERTY_'.$propertyId;
8229 if (isset($row[$fieldId])
8230 && $item[
"MULTIPLE"] ==
"N"
8231 && $row[$fieldId] !=
'')
8234 if (isset($item[
"GetSearchContent"]))
8237 call_user_func_array($item[
"GetSearchContent"],
8240 array(
"VALUE" => $row[$fieldId]),
8255 if(is_array($arFile))
8257 $result .= $arFile[
"CONTENT"];
8269 if (isset(
$fields[
"PREVIEW_TEXT"]))
8271 if (isset(
$fields[
"PREVIEW_TEXT_TYPE"]) &&
$fields[
"PREVIEW_TEXT_TYPE"] ==
"html")
8274 $result .=
"\r\n".$fields[
"PREVIEW_TEXT"];
8276 if (isset(
$fields[
"DETAIL_TEXT"]))
8278 if (isset(
$fields[
"DETAIL_TEXT_TYPE"]) &&
$fields[
"DETAIL_TEXT_TYPE"] ==
"html")
8281 $result .=
"\r\n".$fields[
"DETAIL_TEXT"];
8292 'ID',
'IBLOCK_ID',
'NAME',
'SORT',
'MULTIPLE',
'WITH_DESCRIPTION',
8293 'PROPERTY_TYPE',
'USER_TYPE',
'USER_TYPE_SETTINGS_LIST',
'LINK_IBLOCK_ID'
8296 'order' =>
array(
'SORT' =>
'ASC',
'ID' =>
'ASC'),
8297 'cache' =>
array(
'ttl' => 86400)
8301 $row[
'USER_TYPE'] = (string)$row[
'USER_TYPE'];
8302 if (!is_array($row[
'USER_TYPE_SETTINGS_LIST']))
8304 $row[
'USER_TYPE_SETTINGS_LIST'] =
null;
8306 $row[
'USER_TYPE_SETTINGS'] = $row[
'USER_TYPE_SETTINGS_LIST'];
8307 unset($row[
'USER_TYPE_SETTINGS_LIST']);
8308 if ($row[
'USER_TYPE'] !=
'')
8310 $userType = CIBlockProperty::GetUserType($row[
'USER_TYPE']);
8311 if (isset($userType[
'GetSearchContent']))
8313 $row[
'GetSearchContent'] = $userType[
'GetSearchContent'];
8315 elseif (isset($userType[
'GetPublicViewHTML']))
8317 $row[
'GetSearchContent'] = $userType[
'GetPublicViewHTML'];
8331 if (!isset($this->indexedProperties[
$iblockId]))
8334 '=IBLOCK_ID' => $iblockId,
8336 '=SEARCHABLE' =>
'Y'
8338 if (empty($this->indexedProperties[
$iblockId]))
8343 return (!empty($this->indexedProperties[
$iblockId]) ? $this->indexedProperties[
$iblockId] :
null);
8352 if (!$this->catalogIncluded)
8357 if (!isset($this->offerProperties[
$iblockId]))
8363 $ids = Catalog\Product\PropertyCatalogFeature::getOfferTreePropertyCodes(
$catalog[
'IBLOCK_ID']);
8367 '=IBLOCK_ID' =>
$catalog[
'IBLOCK_ID'],
8371 if (empty($this->offerProperties[
$iblockId]))
8378 return (!empty($this->offerProperties[
$iblockId]) ? $this->offerProperties[
$iblockId] :
null);
8388 if ($this->iblock !==
null && $this->iblock[
'ID'] ===
$iblockId)
8404 $language = static::getIblockLanguage(
$iblock[
'ID']);
8414 if (isset(
$iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE']))
8416 if (
$iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE'][
'TRANSLITERATION'] ===
'Y'
8417 &&
$iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE'][
'USE_GOOGLE'] ===
'N'
8421 $config[
'LANGUAGE_ID'] = $language;
8424 if (
$config[
'LANGUAGE_ID'] !==
null)
8427 'max_len' =>
$config[
'TRANS_LEN'],
8428 'change_case' =>
$config[
'TRANS_CASE'],
8429 'replace_space' =>
$config[
'TRANS_SPACE'],
8430 'replace_other' =>
$config[
'TRANS_OTHER'],
8431 'delete_repeat_replace' => (
$config[
'TRANS_EAT'] ==
'Y'),
8449 $filter = static::getPublicElementsOrmFilter([
8453 if ($elementId !==
null)
8480 $checkSimilar = (
$options[
'CHECK_SIMILAR'] ??
'N') ===
'Y';
8488 'filter' => static::getPublicElementsOrmFilter([
8490 '%=CODE' =>
$code .
'%',
8495 if ($checkSimilar && $elementId === (
int)$row[
'ID'])
8499 $list[$row[
'CODE']] =
true;
8503 if (isset($list[
$code]))
8507 while (isset($list[
$code .
$i]))
8521 if (!isset($element[
'NAME']) || $element[
'NAME'] ===
'')
8535 if ($this->iblock !==
null && $this->iblock[
'ID'] ===
$iblockId)
8550 if (isset(
$iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE']))
8558 if (
$iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE'][
'TRANSLITERATION'] ===
'Y'
8560 $iblock[
'FIELDS'][
'CODE'][
'DEFAULT_VALUE'][
'UNIQUE'] ===
'Y'
8561 || (
$options[
'CHECK_UNIQUE'] ??
'N') ===
'Y'
8565 $id = (int)($element[
'ID'] ??
null);
8586 $iterator = Iblock\IblockSiteTable::getList([
8587 'select' => [
'LANGUAGE_ID' =>
'SITE.LANGUAGE_ID'],
8588 'filter' => [
'=IBLOCK_ID' =>
$iblockId],
8592 $result[$row[
'LANGUAGE_ID']] =
true;
8602 $filter[
'==WF_PARENT_ELEMENT_ID'] =
null;
8612 private static function getUserNameSql(
string $tableAlias): string
8617 return $helper->getConcatFunction(
8619 $tableAlias .
'.LOGIN',
8621 $helper->getIsNullFunction($tableAlias .
'.NAME',
"''"),
8623 $helper->getIsNullFunction($tableAlias .
'.LAST_NAME',
"''")
8627 private static function isJoinForCount(
int $joinType): bool
8629 return ($joinType & self::JOIN_TYPE_WHERE) !== 0 || ($joinType & self::JOIN_TYPE_GROUP) !== 0;
8635 (
int)($row[
'bFullJoin'] ??
false) === 1
8636 || self::isJoinForCount($row[
'JOIN_TYPE'] ?? 0)
8640 private static function addJoinType(
array $row,
int $joinType):
array
8642 $row[
'JOIN_TYPE'] ??= 0;
8643 $row[
'JOIN_TYPE'] |= $joinType;
8648 private static function addJoinTypeSelect(
array $row):
array
8650 return self::addJoinType($row, self::JOIN_TYPE_SELECT);
8653 private static function addJoinTypeWhere(
array $row):
array
8655 return self::addJoinType($row, self::JOIN_TYPE_WHERE);
8658 private static function addJoinTypeGroup(
array $row):
array
8660 return self::addJoinType($row, self::JOIN_TYPE_GROUP);
8663 private static function addJoinTypeOrder(
array $row):
array
8665 return self::addJoinType($row, self::JOIN_TYPE_ORDER);
if($canUseYandexMarket) $strWarning
const PROPERTY_STORAGE_COMMON
const PROPERTY_STORAGE_SEPARATE
static deleteElementIndex($iblockId, $elementId)
static updateElementIndex($iblockId, $elementId)
static resolveElement($iblockId, $elementId)
static makeFileName(\Bitrix\Iblock\InheritedProperty\BaseTemplate $ipropTemplates, string $templateName, array $fields, array $file)
static getConnection($name="")
static get($moduleId, $name, $default="", $siteId=false)
static includeModule($moduleName)
static isModuleInstalled($moduleName)
static getRow(array $parameters)
static getList(array $parameters=array())
static normalizeArrayValuesByInt(&$map, $sorted=true)
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
toString(Context\Culture $culture=null)
static __GetFileContent($FILE_ID)
static useCountJoin(array $row)
static WF_Lock($lastId, $bWorkFlow=true)
static __GetDescriptionUpdateSql($iblock_id, $property_id, $description=false)
static GetPropertyValues($IBLOCK_ID, $arElementFilter, $extMode=false, $propertyFilter=array())
static GetElementGroups($ID, $bElementOnly=false, $arSelect=array())
static WF_CleanUpHistoryCopies($ELEMENT_ID=false, $HISTORY_COPIES=false)
setIblock(?int $iblockId)
getUniqueMnemonicCode(string $code, ?int $elementId, int $iblockId, array $options=[])
static WF_GetLockStatus($ID, &$locked_by, &$date_lock)
CheckFields(&$arFields, $ID=false, $bCheckDiskQuota=true)
static WF_GetStatusTitle($STATUS_ID)
static SetPropertyValueCode($ELEMENT_ID, $PROPERTY_CODE, $PROPERTY_VALUE)
WF_SetMove($NEW_ID, $OLD_ID=0)
static GetRealElement($ID)
MkPropertySelect($PR_ID, $db_prop, &$arJoinProps, $bWasGroup, $sGroupBy, &$sSelect, $bSort=false)
static WF_GetCurrentStatus($ELEMENT_ID, &$STATUS_TITLE)
const WORKFLOW_STATUS_CURRENT_LOCK
static getIblockLanguage(int $iblockId)
static DeleteFile($FILE_ID, $ELEMENT_ID, $TYPE=false, $PARENT_ID=-1, $IBLOCK_ID=false, $bCheckOnly=false)
static SetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUES, $FLAGS=[])
static GetIBlockByID($ID)
static GetIBlockByIDList(array $list)
MkPropertyFilter($res, $cOperationType, $propVAL, $db_prop, &$arJoinProps, &$arSqlSearch)
static WF_IsLocked($ID, &$locked_by, &$date_lock)
const WORKFLOW_STATUS_LOCK
getIndexedProperties(int $iblockId)
getPropertiesByFilter(array $filter)
MkPropertyGroup($db_prop, &$arJoinProps, $bSort=false)
static RecalcSections($ID, $sectionId=null)
getSearchableContent(int $id, array $fields, array $iblock)
static GetPropertyValuesArray(&$result, $iblockID, $filter, $propertyFilter=array(), $options=array())
MkPropertyOrder($by, $order, $bSort, $db_prop, &$arJoinProps, &$arSqlOrder)
static getSingleIblockIdFromFilter(array $filter)
static WF_CleanUpHistory()
static SubQuery($strField, $arFilter)
static WF_GetHistoryList($ELEMENT_ID, $by='s_id', $order='desc', $arFilter=[])
PrepareGetList(&$arIblockElementFields, &$arJoinProps, &$arSelectFields, &$sSelect, &$arAddSelectFields, &$arFilter, &$sWhere, &$sSectionWhere, &$arAddWhereFields, &$arGroupBy, &$sGroupBy, &$arOrder, &$arSqlOrder, &$arAddOrderByFields)
static WF_GetStatusPermission($STATUS_ID, $ID=false)
createMnemonicCode(array $element, array $options=[])
isExistsMnemonicCode(string $code, ?int $elementId, int $iblockId)
static SetElementSection($ID, $arSections, $bNew=false, $bRightsIBlock=0, $sectionId=null)
Add($arFields, $bWorkFlow=false, $bUpdateSearch=true, $bResizePictures=false)
static WF_GetSqlLimit($PS="BE.", $SHOW_NEW="N")
static DeletePropertySQL($property, $iblock_element_id)
static GetIBVersion($iblock_id)
getOfferProperties(int $iblockId)
generateMnemonicCode(string $name, int $iblockId, array $options=[])
static getPublicElementsOrmFilter(array $filter)
static GetProperty($IBLOCK_ID, $ELEMENT_ID, $by="sort", $order="asc", $arFilter=Array())
static _check_rights_sql($min_permission, $permissionsBy=null)
static WF_UnLock($lastId, $bWorkFlow=true)
const WORKFLOW_STATUS_UNLOCK
static UpdateSearch($ID, $bOverWrite=false)
static getCheckRightsSql(?int $iblockId, string $minPermission, ?int $permissionsBy=null)
__InitFile($old_id, &$arFields, $fname)
MkAlias($max_alias_len, $alias, &$arIBlockLongProps)
static MkOperationFilter($key)
static FilterCreateEx($fname, $vals, $type, &$bFullJoin, $cOperationType=false, $bSkipEmpty=true)
static _MergeIBArrays($iblock_id, $iblock_code=false, $iblock_id2=false, $iblock_code2=false)
static GetPropertyArray($ID, $IBLOCK_ID, $bCached=true)
static DeleteIndex($MODULE_ID, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false)
static Index($MODULE_ID, $ITEM_ID, $arFields, $bOverWrite=false, $SEARCH_SESS_ID='')
static recalculateDb(bool $mode=true)
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
prepareSql($arSelectFields=array(), $arFilter=array(), $arGroupBy=false, $arOrder=array("SORT"=>"ASC"))
static isValidField(string $field)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
global $BX_IBLOCK_PROP_CACHE
global $IBLOCK_ACTIVE_DATE_FORMAT
global $ar_IBLOCK_SITE_FILTER_CACHE
$_SERVER["DOCUMENT_ROOT"]
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
const SITE_DIR(!defined('LANG'))
ExecuteModuleEventEx($arEvent, $arParams=[])
IsModuleInstalled($module_id)
HasScriptExtension($check_name)
FmtDate($str_date, $format=false, $site=false, $bSearchInSitesOnly=false)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Rel2Abs($curdir, $relpath)
GetMessage($name, $aReplace=null)
if(!function_exists(__NAMESPACE__.'\\___972068685'))
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties