本文整理汇总了PHP中CIBlock::FilterCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::FilterCreate方法的具体用法?PHP CIBlock::FilterCreate怎么用?PHP CIBlock::FilterCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::FilterCreate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetQueryBuildArrays
//.........这里部分代码省略.........
$arOrderTmp[$inum] = array();
$arOrderTmp[$inum][$key] = $res;
$arJoinGroup[$inum] = true;
}
}
}
$arWhereTmp = array();
$arAddJoinOn = array();
$filter_keys = (!is_array($arFilter) ? array() : array_keys($arFilter));
for ($i=0, $cnt = count($filter_keys); $i < $cnt; $i++)
{
$key = strtoupper($filter_keys[$i]);
$val = $arFilter[$filter_keys[$i]];
$res = CIBlock::MkOperationFilter($key);
$key = $res["FIELD"];
$cOperationType = $res["OPERATION"];
if ($arField = CCatalogProduct::ParseQueryBuildField($key))
{
$key = $arField["FIELD"];
$inum = $arField["NUM"];
if (0 >= $inum && array_key_exists($key, $arSensID))
continue;
$res = "";
switch($key)
{
case "PRODUCT_ID":
$res = CIBlock::FilterCreate("CAT_P".$inum.".PRODUCT_ID", $val, "number", $cOperationType);
break;
case "CATALOG_GROUP_ID":
$res = CIBlock::FilterCreate("CAT_P".$inum.".CATALOG_GROUP_ID", $val, "number", $cOperationType);
break;
case "CURRENCY":
$res = CIBlock::FilterCreate("CAT_P".$inum.".CURRENCY", $val, "string", $cOperationType);
break;
case "SHOP_QUANTITY":
$res = ' 1=1 ';
$arAddJoinOn[$inum] =
(($cOperationType=="N") ? " NOT " : " ").
" ((CAT_P".$inum.".QUANTITY_FROM <= ".intval($val)." OR CAT_P".$inum.".QUANTITY_FROM IS NULL) AND (CAT_P".$inum.".QUANTITY_TO >= ".intval($val)." OR CAT_P".$inum.".QUANTITY_TO IS NULL)) ";
break;
case "PRICE":
$res = CIBlock::FilterCreate("CAT_P".$inum.".PRICE", $val, "number", $cOperationType);
break;
case "QUANTITY":
$res = CIBlock::FilterCreate("CAT_PR.QUANTITY", $val, "number", $cOperationType);
break;
case "AVAILABLE":
if ('N' !== $val)
$val = 'Y';
$res =
" (IF (
CAT_PR.QUANTITY > 0 OR
IF (CAT_PR.QUANTITY_TRACE = 'D', '".$strDefQuantityTrace."', CAT_PR.QUANTITY_TRACE) = 'N' OR
IF (CAT_PR.CAN_BUY_ZERO = 'D', '".$strDefCanBuyZero."', CAT_PR.CAN_BUY_ZERO) = 'Y',
'Y', 'N'
) ".(($cOperationType=="N") ? "<>" : "=")." '".$val."') ";
break;
case "WEIGHT":
$res = CIBlock::FilterCreate("CAT_PR.WEIGHT", $val, "number", $cOperationType);
示例2: GetList
/**
* <p>Возвращает список свойств по фильтру <i>arFilter</i> отсортированные в порядке <i>arOrder</i>. Метод статический.</p>
*
*
* @param array $arrayarOrder = Array() Массив для сортировки, имеющий вид <i>by1=>order1[,by2=>order2 [, ..]]</i>,
* где:<i> by</i> - поле сортировки, может принимать значения: <ul> <li> <b>id</b> -
* код;</li> <li> <b>block_id</b> - код информационного блока, которому
* принадлежит свойство; <b>name</b> - название;</li> <li> <b>name</b> - название;</li>
* <li> <b>active</b> - активность;</li> <li> <b>sort</b> - индекс сортировки;</li> <li>
* <b>timestamp_x</b> - дата последнего изменения</li> <li> <b>searchable</b> - по
* признаку участия значения свойства в поиске; </li> <li> <b>filtrable</b> - по
* признаку участия свойства в фильре на странице списка элементов;
* </li> <li> <b>order</b> - порядок сортировки, может принимать значения: <ul> <li>
* <b>asc</b> - по возрастанию;</li> <li> <b>desc</b> - по убыванию;</li> </ul> </li> </ul>
*
* @param array $arrayarFilter = Array() Массив вида <i> array("фильтруемое поле"=>"значение" [, ...])</i>. Ни один
* параметр фильтра не принимает массивы. <i>Фильтруемое поле</i>
* может принимать значения: <ul> <li> <b>ACTIVE</b> - фильтр по активности
* (Y|N);</li> <li> <b>ID</b> - по ID свойства, только число;</li> <li> <b>CODE</b> - по
* символьному коду (по шаблону [%_]), только строка;</li> <li> <b>NAME</b> - по
* названию свойства (по шаблону [%_]);</li> <li> <b>EXTERNAL_ID</b> или <b>XML_ID </b>- по
* внешнему коду(по шаблону [%_]). Возможно использование отрицания,
* указав <i>!EXTERNAL_ID</i>;</li> <li> <b>PROPERTY_TYPE</b> - по типу свойства: <ul> <li> <b>S</b> -
* строка</li> <li> <b>N</b> - число</li> <li> <b>L</b> - список</li> <li> <b>F</b> - файл</li> <li>
* <b>G</b> - привязка к разделу</li> <li> <b>E</b> - привязка к элементу</li> </ul> </li>
* <li> <b>USER_TYPE</b> - по пользовательскому типу свойства; <ul> <li> <b>UserID</b> -
* Привязка к пользователю</li> <li> <b>DateTime</b> - Дата/Время</li> <li> <b>EList</b> -
* Привязка к элементам в виде списка</li> <li> <b>FileMan</b> - Привязка к
* файлу (на сервере)</li> <li> <b>map_yandex</b> - Привязка к Яndex.Карте</li> <li>
* <b>HTML</b> - HTML/текст</li> <li> <b>map_google</b> - Привязка к карте Google Maps</li> <li>
* <b>ElementXmlID</b> - Привязка к элементам по XML_ID</li> <li> <b>Sequence</b> - Счетчик</li>
* <li> <b>EAutocomplete</b> - Привязка к элементам с автозаполнением</li> <li>
* <b>SKU</b> - Привязка к товарам (SKU)</li> <li> <b>video</b> - Видео</li> <li> <b>TopicID</b> -
* Привязка к теме форума</li> </ul> Кроме того, можно использовать
* идентификаторы пользовательских типов свойств инфоблока,
* добавленных сторонними модулями. </li> <li> <b>SEARCHABLE</b> - по признаку
* участия значения свойства в поиске (Y|N); </li> <li> <b>FILTRABLE</b> - по
* признаку участия свойства в фильре на странице списка элементов
* (Y|N);</li> <li> <b>VERSION</b> - по флагу хранения значений свойств элементов
* инфоблока;</li> <li> <b>MIN_PERMISSION</b> - фильтр по правам доступа, по
* умолчанию принимает <i>R</i> (уровень доступа <i>Чтение</i>);</li> <li>
* <b>CHECK_PERMISSIONS</b> - если установлено значение "N", то проверки прав не
* происходит; <br> </li> <li> <b>IBLOCK_ID</b> - по коду информационного блока,
* которому принадлежит свойство;</li> <li> <b>IBLOCK_CODE</b> - по символьному
* коду информационного блока, которому принадлежит свойство;</li> <li>
* <b>LINK_IBLOCK_ID</b> - по коду связанного информационного блока (может
* быть указан для свойств типа "E" и "G");</li> <li> <b>MULTIPLE</b> - Проверка на
* множественность. по умолчанию N.</li> </ul> Необязательное. По
* умолчанию записи не фильтруются.
*
* @return CDBResult <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a>
*
* <h4>Example</h4>
* <pre>
* <?<br>$IBLOCK_ID = 11;<br>$properties = CIBlockProperty::GetList(Array("sort"=>"asc", "name"=>"asc"), Array("ACTIVE"=>"Y", "IBLOCK_ID"=>$IBLOCK_ID));<br>while ($prop_fields = $properties->GetNext())<br>{<br> echo $prop_fields["ID"]." - ".$prop_fields["NAME"]."<br>";<br>}<br>?><br>
* </pre>
*
*
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/iblock/fields.php#fproperty">Поля свойства</a> </li> </ul> <a
* name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/getlist.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array())
{
global $DB;
$strSql = "\n\t\t\tSELECT BP.*\n\t\t\tFROM b_iblock_property BP\n\t\t";
$bJoinIBlock = false;
$arSqlSearch = "";
foreach ($arFilter as $key => $val) {
$val = $DB->ForSql($val);
$key = strtoupper($key);
switch ($key) {
case "ACTIVE":
case "SEARCHABLE":
case "FILTRABLE":
case "IS_REQUIRED":
case "MULTIPLE":
if ($val == "Y" || $val == "N") {
$arSqlSearch[] = "BP." . $key . " = '" . $val . "'";
}
break;
case "?CODE":
case "?NAME":
$arSqlSearch[] = CIBlock::FilterCreate("BP." . substr($key, 1), $val, "string", "E");
break;
case "CODE":
case "NAME":
$arSqlSearch[] = "UPPER(BP." . $key . ") LIKE UPPER('" . $val . "')";
break;
case "XML_ID":
case "EXTERNAL_ID":
$arSqlSearch[] = "BP.XML_ID LIKE '" . $val . "'";
break;
case "!XML_ID":
//.........这里部分代码省略.........
示例3: GetList
public static function GetList($arOrder = array("SORT" => "ASC", "VALUE" => "ASC"), $arFilter = array())
{
global $DB;
$arSqlSearch = array();
foreach ($arFilter as $key => $val) {
if ($key[0] == "!") {
$key = substr($key, 1);
$bInvert = true;
} else {
$bInvert = false;
}
$key = strtoupper($key);
switch ($key) {
case "CODE":
$arSqlSearch[] = CIBlock::FilterCreate("P.CODE", $val, "string", $bInvert);
break;
case "IBLOCK_ID":
$arSqlSearch[] = CIBlock::FilterCreate("P.IBLOCK_ID", $val, "number", $bInvert);
break;
case "DEF":
$arSqlSearch[] = CIBlock::FilterCreate("BEN.DEF", $val, "string_equal", $bInvert);
break;
case "EXTERNAL_ID":
$arSqlSearch[] = CIBlock::FilterCreate("BEN.XML_ID", $val, "string_equal", $bInvert);
break;
case "VALUE":
case "XML_ID":
case "TMP_ID":
$arSqlSearch[] = CIBlock::FilterCreate("BEN." . $key, $val, "string", $bInvert);
break;
case "PROPERTY_ID":
if (is_numeric(substr($val, 0, 1))) {
$arSqlSearch[] = CIBlock::FilterCreate("P.ID", $val, "number", $bInvert);
} else {
$arSqlSearch[] = CIBlock::FilterCreate("P.CODE", $val, "string", $bInvert);
}
break;
case "PROPERTY_ACTIVE":
$arSqlSearch[] = CIBlock::FilterCreate("P.ACTIVE", $val, "string_equal", $bInvert);
break;
case "ID":
case "SORT":
$arSqlSearch[] = CIBlock::FilterCreate("BEN." . $key, $val, "number", $bInvert);
break;
}
}
$strSqlSearch = "";
foreach (array_filter($arSqlSearch) as $sqlCondition) {
$strSqlSearch .= " AND (" . $sqlCondition . ") ";
}
$arSqlOrder = array();
foreach ($arOrder as $by => $order) {
$order = strtolower($order) != "asc" ? "desc" : "asc";
$by = strtoupper($by);
switch ($by) {
case "ID":
case "PROPERTY_ID":
case "VALUE":
case "XML_ID":
case "EXTERNAL_ID":
case "DEF":
$arSqlOrder[$by] = "BEN." . $by . " " . $order;
break;
case "PROPERTY_SORT":
$arSqlOrder[$by] = "P.SORT " . $order;
break;
case "PROPERTY_CODE":
$arSqlOrder[$by] = "P.CODE " . $order;
break;
default:
$arSqlOrder["SORT"] = " BEN.SORT " . $order;
break;
}
}
if (!empty($arSqlOrder)) {
$strSqlOrder = "ORDER BY " . implode(", ", $arSqlOrder);
} else {
$strSqlOrder = "";
}
$strSql = "\n\t\t\tSELECT\n\t\t\t\tBEN.*,\n\t\t\t\tBEN.XML_ID as EXTERNAL_ID,\n\t\t\t\tP.NAME as PROPERTY_NAME,\n\t\t\t\tP.CODE as PROPERTY_CODE,\n\t\t\t\tP.SORT as PROPERTY_SORT\n\t\t\tFROM\n\t\t\t\tb_iblock_property_enum BEN,\n\t\t\t\tb_iblock_property P\n\t\t\tWHERE\n\t\t\t\tBEN.PROPERTY_ID=P.ID\n\t\t\t{$strSqlSearch}\n\t\t\t{$strSqlOrder}\n\t\t";
$rs = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
return new CIBlockPropertyEnumResult($rs);
}
示例4: GetQueryBuildArrays
//.........这里部分代码省略.........
$res = " " . CIBlock::_Order("CAT_P" . $inum . ".ID", $order, "asc", false) . " ";
break;
}
if ($join) {
if (!isset($arOrderTmp[$inum])) {
$arOrderTmp[$inum] = array();
}
$arOrderTmp[$inum][$key] = $res;
$arJoinGroup[$inum] = true;
}
}
}
}
$productWhere = array();
$arWhereTmp = array();
$arAddJoinOn = array();
$filter_keys = !is_array($arFilter) ? array() : array_keys($arFilter);
for ($i = 0, $cnt = count($filter_keys); $i < $cnt; $i++) {
$key = strtoupper($filter_keys[$i]);
$val = $arFilter[$filter_keys[$i]];
$res = CIBlock::MkOperationFilter($key);
$key = $res["FIELD"];
$cOperationType = $res["OPERATION"];
if ($arField = CCatalogProduct::ParseQueryBuildField($key)) {
$res = '';
$join = true;
$key = (string) $arField["FIELD"];
$inum = (int) $arField["NUM"];
if ($key == '' || $inum <= 0 && isset($arSensID[$key])) {
continue;
}
switch ($key) {
case "PRODUCT_ID":
$res = CIBlock::FilterCreate("CAT_P" . $inum . ".PRODUCT_ID", $val, "number", $cOperationType);
break;
case "CATALOG_GROUP_ID":
$res = CIBlock::FilterCreate("CAT_P" . $inum . ".CATALOG_GROUP_ID", $val, "number", $cOperationType);
break;
case "CURRENCY":
$res = CIBlock::FilterCreate("CAT_P" . $inum . ".CURRENCY", $val, "string", $cOperationType);
break;
case "SHOP_QUANTITY":
$val = (int) $val;
$res = ' 1=1 ';
$arAddJoinOn[$inum] = ($cOperationType == "N" ? " NOT " : " ") . " ((CAT_P" . $inum . ".QUANTITY_FROM <= " . $val . " OR CAT_P" . $inum . ".QUANTITY_FROM IS NULL) AND (CAT_P" . $inum . ".QUANTITY_TO >= " . $val . " OR CAT_P" . $inum . ".QUANTITY_TO IS NULL)) ";
break;
case "PRICE":
$res = CIBlock::FilterCreate("CAT_P" . $inum . ".PRICE", $val, "number", $cOperationType);
break;
case "QUANTITY":
$res = CIBlock::FilterCreate("CAT_PR.QUANTITY", $val, "number", $cOperationType);
$join = false;
break;
case "AVAILABLE":
if ('N' !== $val) {
$val = 'Y';
}
$res = " (IF (\n\t\t\t\t\tCAT_PR.QUANTITY > 0 OR\n\t\t\t\t\tIF (CAT_PR.QUANTITY_TRACE = 'D', '" . $strDefQuantityTrace . "', CAT_PR.QUANTITY_TRACE) = 'N' OR\n\t\t\t\t\tIF (CAT_PR.CAN_BUY_ZERO = 'D', '" . $strDefCanBuyZero . "', CAT_PR.CAN_BUY_ZERO) = 'Y',\n\t\t\t\t\t'Y', 'N'\n\t\t\t\t\t) " . ($cOperationType == "N" ? "<>" : "=") . " '" . $val . "') ";
$join = false;
break;
case "WEIGHT":
$res = CIBlock::FilterCreate("CAT_PR.WEIGHT", $val, "number", $cOperationType);
$join = false;
break;
case 'TYPE':
$res = CIBlock::FilterCreate("CAT_PR.TYPE", $val, "number", $cOperationType);
示例5: UpdateList
protected function UpdateList($arFields, $arFilter = array())
{
global $DB, $USER, $USER_FIELD_MANAGER;
$strUpdate = $DB->PrepareUpdate("b_iblock_section", $arFields, "iblock", false, "BS");
if ($strUpdate == "") {
return false;
}
if (isset($arFilter["IBLOCK_ID"]) && $arFilter["IBLOCK_ID"] > 0) {
$obUserFieldsSql = new CUserTypeSQL();
$obUserFieldsSql->SetEntity("IBLOCK_" . $arFilter["IBLOCK_ID"] . "_SECTION", "BS.ID");
$obUserFieldsSql->SetFilter($arFilter);
} else {
foreach ($arFilter as $key => $val) {
$res = CIBlock::MkOperationFilter($key);
if (preg_match("/^UF_/", $res["FIELD"])) {
trigger_error("arFilter parameter of the CIBlockSection::GetList contains user fields, but has no IBLOCK_ID field.", E_USER_WARNING);
break;
}
}
}
$arJoinProps = array();
$bJoinFlatProp = false;
$arSqlSearch = CIBlockSection::GetFilter($arFilter);
$bCheckPermissions = !array_key_exists("CHECK_PERMISSIONS", $arFilter) || $arFilter["CHECK_PERMISSIONS"] !== "N";
$bIsAdmin = is_object($USER) && $USER->IsAdmin();
if ($bCheckPermissions && !$bIsAdmin) {
$arSqlSearch[] = CIBlockSection::_check_rights_sql($arFilter["MIN_PERMISSION"]);
}
if (array_key_exists("PROPERTY", $arFilter)) {
$val = $arFilter["PROPERTY"];
foreach ($val as $propID => $propVAL) {
$res = CIBlock::MkOperationFilter($propID);
$propID = $res["FIELD"];
$cOperationType = $res["OPERATION"];
if ($db_prop = CIBlockProperty::GetPropertyArray($propID, CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"]))) {
$bSave = false;
if (array_key_exists($db_prop["ID"], $arJoinProps)) {
$iPropCnt = $arJoinProps[$db_prop["ID"]];
} elseif ($db_prop["VERSION"] != 2 || $db_prop["MULTIPLE"] == "Y") {
$bSave = true;
$iPropCnt = count($arJoinProps);
}
if (!is_array($propVAL)) {
$propVAL = array($propVAL);
}
if ($db_prop["PROPERTY_TYPE"] == "N" || $db_prop["PROPERTY_TYPE"] == "G" || $db_prop["PROPERTY_TYPE"] == "E") {
if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
$r = CIBlock::FilterCreate("FPS.PROPERTY_" . $db_prop["ORIG_ID"], $propVAL, "number", $cOperationType);
$bJoinFlatProp = $db_prop["IBLOCK_ID"];
} else {
$r = CIBlock::FilterCreate("FPV" . $iPropCnt . ".VALUE_NUM", $propVAL, "number", $cOperationType);
}
} else {
if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
$r = CIBlock::FilterCreate("FPS.PROPERTY_" . $db_prop["ORIG_ID"], $propVAL, "string", $cOperationType);
$bJoinFlatProp = $db_prop["IBLOCK_ID"];
} else {
$r = CIBlock::FilterCreate("FPV" . $iPropCnt . ".VALUE", $propVAL, "string", $cOperationType);
}
}
if (strlen($r) > 0) {
if ($bSave) {
$db_prop["iPropCnt"] = $iPropCnt;
$arJoinProps[$db_prop["ID"]] = $db_prop;
}
$arSqlSearch[] = $r;
}
}
}
}
$strSqlSearch = "";
foreach ($arSqlSearch as $r) {
if (strlen($r) > 0) {
$strSqlSearch .= "\n\t\t\t\tAND (" . $r . ") ";
}
}
if (isset($obUserFieldsSql)) {
$r = $obUserFieldsSql->GetFilter();
if (strlen($r) > 0) {
$strSqlSearch .= "\n\t\t\t\tAND (" . $r . ") ";
}
}
$strProp1 = "";
foreach ($arJoinProps as $propID => $db_prop) {
if ($db_prop["VERSION"] == 2) {
$strTable = "b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"];
} else {
$strTable = "b_iblock_element_property";
}
$i = $db_prop["iPropCnt"];
$strProp1 .= "\n\t\t\t\tLEFT JOIN b_iblock_property FP" . $i . " ON FP" . $i . ".IBLOCK_ID=B.ID AND\n\t\t\t\t" . (IntVal($propID) > 0 ? " FP" . $i . ".ID=" . IntVal($propID) . " " : " FP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "' ") . "\n\t\t\t\tLEFT JOIN " . $strTable . " FPV" . $i . " ON FP" . $i . ".ID=FPV" . $i . ".IBLOCK_PROPERTY_ID AND FPV" . $i . ".IBLOCK_ELEMENT_ID=BE.ID ";
}
if ($bJoinFlatProp) {
$strProp1 .= "\n\t\t\t\tLEFT JOIN b_iblock_element_prop_s" . $bJoinFlatProp . " FPS ON FPS.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t";
}
$strSql = "\n\t\t\tUPDATE\n\t\t\tb_iblock_section BS\n\t\t\t\tINNER JOIN b_iblock B ON BS.IBLOCK_ID = B.ID\n\t\t\t\t" . (isset($obUserFieldsSql) ? $obUserFieldsSql->GetJoin("BS.ID") : "") . "\n\t\t\t" . (strlen($strProp1) > 0 ? "\tINNER JOIN b_iblock_section BSTEMP ON BSTEMP.IBLOCK_ID = BS.IBLOCK_ID\n\t\t\t\t\tLEFT JOIN b_iblock_section_element BSE ON BSE.IBLOCK_SECTION_ID=BSTEMP.ID\n\t\t\t\t\tLEFT JOIN b_iblock_element BE ON (BSE.IBLOCK_ELEMENT_ID=BE.ID\n\t\t\t\t\t\tAND ((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL )\n\t\t\t\t\t\tAND BE.IBLOCK_ID = BS.IBLOCK_ID\n\t\t\t\t" . ($arFilter["CNT_ALL"] == "Y" ? " OR BE.WF_NEW='Y' " : "") . ")\n\t\t\t\t" . ($arFilter["CNT_ACTIVE"] == "Y" ? " AND BE.ACTIVE='Y'\n\t\t\t\t\tAND (BE.ACTIVE_TO >= " . $DB->CurrentTimeFunction() . " OR BE.ACTIVE_TO IS NULL)\n\t\t\t\t\tAND (BE.ACTIVE_FROM <= " . $DB->CurrentTimeFunction() . " OR BE.ACTIVE_FROM IS NULL)" : "") . ")\n\t\t\t\t\t" . $strProp1 . " " : "") . "\n\t\t\tSET " . $strUpdate . "\n\t\t\tWHERE 1=1\n\t\t\t" . (strlen($strProp1) > 0 ? "\tAND BSTEMP.LEFT_MARGIN >= BS.LEFT_MARGIN\n\t\t\t\t\tAND BSTEMP.RIGHT_MARGIN <= BS.RIGHT_MARGIN " : "") . "\n\t\t\t" . $strSqlSearch . "\n\t\t";
return $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
}
示例6: GetList
public static function GetList($arOrder = array("SORT" => "ASC"), $arFilter = array(), $bIncCnt = false)
{
global $DB, $USER;
$strSqlSearch = "";
$bAddSites = false;
foreach ($arFilter as $key => $val) {
$res = CIBlock::MkOperationFilter($key);
$key = strtoupper($res["FIELD"]);
$cOperationType = $res["OPERATION"];
switch ($key) {
case "ACTIVE":
$sql = CIBlock::FilterCreate("B.ACTIVE", $val, "string_equal", $cOperationType);
break;
case "LID":
case "SITE_ID":
$sql = CIBlock::FilterCreate("BS.SITE_ID", $val, "string_equal", $cOperationType);
if (strlen($sql)) {
$bAddSites = true;
}
break;
case "NAME":
case "CODE":
case "XML_ID":
case "PROPERTY_INDEX":
$sql = CIBlock::FilterCreate("B." . $key, $val, "string", $cOperationType);
break;
case "EXTERNAL_ID":
$sql = CIBlock::FilterCreate("B.XML_ID", $val, "string", $cOperationType);
break;
case "TYPE":
$sql = CIBlock::FilterCreate("B.IBLOCK_TYPE_ID", $val, "string", $cOperationType);
break;
case "ID":
case "VERSION":
case "SOCNET_GROUP_ID":
$sql = CIBlock::FilterCreate("B." . $key, $val, "number", $cOperationType);
break;
default:
$sql = "";
break;
}
if (strlen($sql)) {
$strSqlSearch .= " AND (" . $sql . ") ";
}
}
$bCheckPermissions = !array_key_exists("CHECK_PERMISSIONS", $arFilter) || $arFilter["CHECK_PERMISSIONS"] !== "N" || array_key_exists("OPERATION", $arFilter);
$bIsAdmin = is_object($USER) && $USER->IsAdmin();
if ($bCheckPermissions && !$bIsAdmin) {
$min_permission = strlen($arFilter["MIN_PERMISSION"]) == 1 ? $arFilter["MIN_PERMISSION"] : "R";
if (is_object($USER)) {
$iUserID = intval($USER->GetID());
$strGroups = $USER->GetGroups();
$bAuthorized = $USER->IsAuthorized();
} else {
$iUserID = 0;
$strGroups = "2";
$bAuthorized = false;
}
$stdPermissions = "\n\t\t\t\tSELECT IBLOCK_ID\n\t\t\t\tFROM b_iblock_group IBG\n\t\t\t\tWHERE IBG.GROUP_ID IN (" . $strGroups . ")\n\t\t\t\tAND IBG.PERMISSION >= '" . $min_permission . "'\n\t\t\t";
if (!defined("ADMIN_SECTION")) {
$stdPermissions .= "\n\t\t\t\t\tAND (IBG.PERMISSION='X' OR B.ACTIVE='Y')\n\t\t\t\t";
}
if (strlen($arFilter["OPERATION"]) > 0) {
$operation = "'" . $DB->ForSql($arFilter["OPERATION"]) . "'";
} elseif ($min_permission >= "X") {
$operation = "'iblock_edit'";
} elseif ($min_permission >= "U") {
$operation = "'element_edit'";
} elseif ($min_permission >= "S") {
$operation = "'iblock_admin_display'";
} else {
$operation = "'section_read', 'element_read', 'section_element_bind', 'section_section_bind'";
}
if ($operation) {
$acc = new CAccess();
$acc->UpdateCodes();
$extPermissions = "\n\t\t\t\t\tSELECT IBLOCK_ID\n\t\t\t\t\tFROM b_iblock_right IBR\n\t\t\t\t\tINNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID\n\t\t\t\t\tINNER JOIN b_operation O ON O.ID = T.OPERATION_ID\n\t\t\t\t\t" . ($iUserID > 0 ? "LEFT" : "INNER") . " JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " . $iUserID . "\n\t\t\t\t\tWHERE IBR.ENTITY_TYPE = 'iblock'\n\t\t\t\t\tAND O.NAME in (" . $operation . ")\n\t\t\t\t\t" . ($bAuthorized ? "AND (UA.USER_ID IS NOT NULL OR IBR.GROUP_CODE = 'AU')" : "") . "\n\t\t\t\t";
$sqlPermissions = "AND (\n\t\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\t\tOR (B.RIGHTS_MODE = 'E' AND B.ID IN ({$extPermissions}))\n\t\t\t\t)";
} else {
$sqlPermissions = "AND (\n\t\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\t)";
}
} else {
$sqlPermissions = "";
}
if ($bAddSites) {
$sqlJoinSites = "LEFT JOIN b_iblock_site BS ON B.ID=BS.IBLOCK_ID\n\t\t\t\t\tLEFT JOIN b_lang L ON L.LID=BS.SITE_ID";
} else {
$sqlJoinSites = "INNER JOIN b_lang L ON L.LID=B.LID";
}
if (!$bIncCnt) {
$strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.*\n\t\t\t\t\t,B.XML_ID as EXTERNAL_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("B.TIMESTAMP_X") . " as TIMESTAMP_X\n\t\t\t\t\t,L.DIR as LANG_DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\t" . $sqlJoinSites . "\n\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t" . $sqlPermissions . "\n\t\t\t\t\t" . $strSqlSearch . "\n\t\t\t";
} else {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tB.*\n\t\t\t\t\t,B.XML_ID as EXTERNAL_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("B.TIMESTAMP_X") . " as TIMESTAMP_X\n\t\t\t\t\t,L.DIR as LANG_DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t,COUNT(DISTINCT BE.ID) as ELEMENT_CNT\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\t" . $sqlJoinSites . "\n\t\t\t\t\tLEFT JOIN b_iblock_element BE ON (BE.IBLOCK_ID=B.ID\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t(BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL )\n\t\t\t\t\t\t\t" . ($arFilter["CNT_ALL"] == "Y" ? " OR BE.WF_NEW='Y' " : "") . "\n\t\t\t\t\t\t)\n\t\t\t\t\t\t" . ($arFilter["CNT_ACTIVE"] == "Y" ? "AND BE.ACTIVE='Y'\n\t\t\t\t\t\tAND (BE.ACTIVE_TO >= " . $DB->CurrentDateFunction() . " OR BE.ACTIVE_TO IS NULL)\n\t\t\t\t\t\tAND (BE.ACTIVE_FROM <= " . $DB->CurrentDateFunction() . " OR BE.ACTIVE_FROM IS NULL)\n\t\t\t\t\t\t" : "") . "\n\t\t\t\t\t)\n\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t" . $sqlPermissions . "\n\t\t\t\t\t" . $strSqlSearch . "\n\t\t\t\tGROUP BY B.ID\n\t\t\t";
}
$arSqlOrder = array();
if (is_array($arOrder)) {
foreach ($arOrder as $by => $order) {
$by = strtolower($by);
$order = strtolower($order);
if ($order != "asc") {
//.........这里部分代码省略.........