本文整理汇总了PHP中CIBlock::MkOperationFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::MkOperationFilter方法的具体用法?PHP CIBlock::MkOperationFilter怎么用?PHP CIBlock::MkOperationFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::MkOperationFilter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetQueryBuildArrays
public static function GetQueryBuildArrays($arOrder, $arFilter, $arSelect)
{
global $DB, $USER;
global $stackCacheManager;
$strDefQuantityTrace = COption::GetOptionString('catalog','default_quantity_trace','N');
if ('Y' != $strDefQuantityTrace)
$strDefQuantityTrace = 'N';
$strDefCanBuyZero = COption::GetOptionString('catalog','default_can_buy_zero','N');
if ('Y' != $strDefCanBuyZero)
$strDefCanBuyZero = 'N';
$strDefNegAmount = COption::GetOptionString('catalog','allow_negative_amount','N');
if ('Y' != $strDefNegAmount)
$strDefNegAmount = 'N';
$sResSelect = "";
$sResFrom = "";
$sResWhere = "";
$arResOrder = array();
$arJoinGroup = array();
$arSensID = array(
'PRODUCT_ID' => true,
'CATALOG_GROUP_ID' => true,
'CURRENCY' => true,
'SHOP_QUANTITY' => true,
'PRICE' => true
);
$arOrderTmp = array();
foreach ($arOrder as $key => $val)
{
foreach ($val as $by => $order)
{
if ($arField = CCatalogProduct::ParseQueryBuildField($by))
{
$inum = $arField["NUM"];
$by = $arField["FIELD"];
$res = '';
if (0 >= $inum && array_key_exists($by, $arSensID))
continue;
if ($by == "PRICE")
{
$res = " ".CIBlock::_Order("CAT_P".$inum.".PRICE", $order, "asc")." ";
}
elseif ($by == "CURRENCY")
{
$res = " ".CIBlock::_Order("CAT_P".$inum.".CURRENCY", $order, "asc")." ";
}
elseif ($by == "QUANTITY")
{
$arResOrder[$key] = " ".CIBlock::_Order("CAT_PR.QUANTITY", $order, "asc", false)." ";
continue;
}
elseif ($by == 'WEIGHT')
{
$arResOrder[$key] = " ".CIBlock::_Order("CAT_PR.WEIGHT", $order, "asc", false)." ";
continue;
}
elseif ($by == 'AVAILABLE')
{
$arResOrder[$key] = " ".CIBlock::_Order("CATALOG_AVAILABLE", $order, "desc", false)." ";
continue;
}
else
{
$res = " ".CIBlock::_Order("CAT_P".$inum.".ID", $order, "asc", false)." ";
}
if (!array_key_exists($inum, $arOrderTmp))
$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;
//.........这里部分代码省略.........
示例2: GetQueryBuildArrays
public static function GetQueryBuildArrays($arOrder, $arFilter, $arSelect)
{
global $DB, $USER, $stackCacheManager;
$strDefQuantityTrace = (string) Option::get('catalog', 'default_quantity_trace') == 'Y' ? 'Y' : 'N';
$strDefCanBuyZero = (string) Option::get('catalog', 'default_can_buy_zero') == 'Y' ? 'Y' : 'N';
$strDefNegAmount = (string) Option::get('catalog', 'allow_negative_amount') == 'Y' ? 'Y' : 'N';
$strSubscribe = (string) Option::get('catalog', 'default_subscribe') == 'N' ? 'N' : 'Y';
$sResSelect = '';
$sResFrom = '';
$sResWhere = '';
$arResOrder = array();
$arJoinGroup = array();
$arStoreWhere = array();
$arStore = array();
$arStoreOrder = array();
$arSensID = array('PRODUCT_ID' => true, 'CATALOG_GROUP_ID' => true, 'CURRENCY' => true, 'SHOP_QUANTITY' => true, 'PRICE' => true, 'STORE_AMOUNT' => true);
$arOrderTmp = array();
foreach ($arOrder as $key => $val) {
foreach ($val as $by => $order) {
if ($arField = CCatalogProduct::ParseQueryBuildField($by)) {
$res = '';
$join = true;
$inum = (int) $arField["NUM"];
$by = (string) $arField["FIELD"];
if ($by == '' || $inum <= 0 && isset($arSensID[$by])) {
continue;
}
switch ($by) {
case 'PRICE':
$res = " " . CIBlock::_Order("CAT_P" . $inum . ".PRICE", $order, "asc") . " ";
break;
case 'CURRENCY':
$res = " " . CIBlock::_Order("CAT_P" . $inum . ".CURRENCY", $order, "asc") . " ";
break;
case 'QUANTITY':
$arResOrder[$key] = " " . CIBlock::_Order("CAT_PR.QUANTITY", $order, "asc", false) . " ";
$join = false;
break;
case 'WEIGHT':
$arResOrder[$key] = " " . CIBlock::_Order("CAT_PR.WEIGHT", $order, "asc", false) . " ";
$join = false;
break;
case 'AVAILABLE':
$arResOrder[$key] = " " . CIBlock::_Order("CATALOG_AVAILABLE", $order, "desc", false) . " ";
$join = false;
break;
case 'TYPE':
$arResOrder[$key] = " " . CIBlock::_Order("CAT_PR.TYPE", $order, "asc", false) . " ";
$join = false;
break;
case 'PURCHASING_PRICE':
$arResOrder[$key] = " " . CIBlock::_Order("CAT_PR.PURCHASING_PRICE", $order, "asc") . " ";
$join = false;
break;
case 'PURCHASING_CURRENCY':
$arResOrder[$key] = " " . CIBlock::_Order("CAT_PR.PURCHASING_CURRENCY", $order, "asc") . " ";
$join = false;
break;
case 'STORE_AMOUNT':
$arStore[$inum] = true;
if (!isset($arStoreOrder[$inum])) {
$arStoreOrder[$inum] = array();
}
$arStoreOrder[$inum][$key] = " " . CIBlock::_Order("CAT_SP" . $inum . ".AMOUNT", $order, "asc") . " ";
$join = false;
break;
default:
$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":
//.........这里部分代码省略.........
示例3: getMixedList
protected function getMixedList($arOrder = array("SORT" => "ASC"), $arFilter = array(), $bIncCnt = false, $arSelectedFields = false)
{
$arResult = array();
$notFound = false;
if (is_array($arFilter["S_ID"]) && sizeof($arFilter["S_ID"]) == 1) {
$notFound = $arFilter['S_ID'][0] == 0;
}
if (!$notFound && !$this->isFiltering()) {
$arSectionFilter = array("IBLOCK_ID" => $arFilter["IBLOCK_ID"], "=ID" => $arFilter["S_ID"], "?NAME" => $arFilter["NAME"], ">=TIMESTAMP_X" => $arFilter["DATE_MODIFY_FROM"], "<=TIMESTAMP_X" => $arFilter["DATE_MODIFY_TO"], "CODE" => $arFilter["CODE"], "ACTIVE" => $arFilter["ACTIVE"]);
if (isset($arFilter["CHECK_PERMISSIONS"])) {
$arSectionFilter['CHECK_PERMISSIONS'] = $arFilter["CHECK_PERMISSIONS"];
$arSectionFilter['MIN_PERMISSION'] = isset($arFilter['MIN_PERMISSION']) ? $arFilter['MIN_PERMISSION'] : 'R';
}
if (array_key_exists("SECTION_ID", $arFilter)) {
if (!array_key_exists("INCLUDE_SUBSECTIONS", $arFilter)) {
$arSectionFilter['SECTION_ID'] = $arFilter['SECTION_ID'];
} elseif (!$this->isAdvancedSearchAvailable() && ($margin = $this->getSectionMargin($arFilter['SECTION_ID']))) {
$arSectionFilter['>LEFT_MARGIN'] = $margin['LEFT_MARGIN'];
$arSectionFilter['<RIGHT_MARGIN'] = $margin['RIGHT_MARGIN'];
$arSectionFilter['>DEPTH_LEVEL'] = $margin['DEPTH_LEVEL'];
}
}
$obSection = new \CIBlockSection();
$rsSection = $obSection->GetList($arOrder, $arSectionFilter, $bIncCnt);
while ($arSection = $rsSection->Fetch()) {
$arSection["TYPE"] = "S";
$arResult[] = $arSection;
}
}
$notFound = false;
if (is_array($arFilter["ID"]) && sizeof($arFilter["ID"]) == 1) {
$notFound = $arFilter['ID'][0] == 0;
}
if (!$notFound) {
$arElementFilter = array("IBLOCK_ID" => $arFilter["IBLOCK_ID"], "?NAME" => $arFilter["NAME"], "SECTION_ID" => $arFilter["SECTION_ID"], "=ID" => $arFilter["ID"], ">=TIMESTAMP_X" => $arFilter["DATE_MODIFY_FROM"], "<=TIMESTAMP_X" => $arFilter["DATE_MODIFY_TO"], "CODE" => $arFilter["CODE"], "ACTIVE" => $arFilter["ACTIVE"], "WF_STATUS" => $arFilter["WF_STATUS"], 'INCLUDE_SUBSECTIONS' => $arFilter["INCLUDE_SUBSECTIONS"]);
if (isset($arFilter["CHECK_PERMISSIONS"])) {
$arElementFilter['CHECK_PERMISSIONS'] = $arFilter["CHECK_PERMISSIONS"];
$arElementFilter['MIN_PERMISSION'] = isset($arFilter['MIN_PERMISSION']) ? $arFilter['MIN_PERMISSION'] : 'R';
}
foreach ($arFilter as $key => $value) {
$op = \CIBlock::MkOperationFilter($key);
$newkey = strtoupper($op["FIELD"]);
if (substr($newkey, 0, 9) == "PROPERTY_" || substr($newkey, 0, 8) == "CATALOG_") {
$arElementFilter[$key] = $value;
}
}
if (strlen($arFilter["SECTION_ID"]) <= 0) {
unset($arElementFilter["SECTION_ID"]);
}
if (!is_array($arSelectedFields)) {
$arSelectedFields = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "ACTIVE", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "SHOW_COUNTER", "SHOW_COUNTER_START", "CODE", "EXTERNAL_ID");
}
if (isset($arFilter["CHECK_BP_PERMISSIONS"])) {
$arElementFilter["CHECK_BP_PERMISSIONS"] = $arFilter["CHECK_BP_PERMISSIONS"];
}
$obElement = new \CIBlockElement();
$rsElement = $obElement->GetList($arOrder, $arElementFilter, false, false, $arSelectedFields);
while ($arElement = $rsElement->Fetch()) {
$arElement["TYPE"] = "E";
$arResult[] = $arElement;
}
}
$rsResult = new \CDBResult();
$rsResult->InitFromArray($arResult);
if ($this->isAdminSection()) {
$rsResult = new \CAdminResult($rsResult, $this->getTableId());
$rsResult->NavStart();
} else {
$rsResult->NavStart($this->getGridOptions()->GetNavParams());
}
return $rsResult;
}
示例4: MkFilter
function MkFilter($arFilter, &$arJoinProps, &$arAddWhereFields, $level = 0, $bPropertyLeftJoin = false)
{
global $DB, $USER;
$arSqlSearch = array();
$permSQL = "";
$arSectionFilter = array("LOGIC" => "", "BE" => array(), "BS" => array());
$strSqlSearch = "";
if (!is_array($arFilter)) {
$arFilter = array();
}
foreach ($arFilter as $key => $val) {
$key = strtoupper($key);
$p = strpos($key, "PROPERTY_");
if ($p !== false && $p < 4) {
$arFilter[substr($key, 0, $p) . "PROPERTY"][substr($key, $p + 9)] = $val;
unset($arFilter[$key]);
}
}
if (array_key_exists("LOGIC", $arFilter) && $arFilter["LOGIC"] == "OR") {
$Logic = "OR";
unset($arFilter["LOGIC"]);
$bPropertyLeftJoin = true;
} else {
$Logic = "AND";
}
if ($Logic === "AND" && $level === 0) {
$f = new \Bitrix\Iblock\PropertyIndex\QueryBuilder($arFilter["IBLOCK_ID"]);
if ($f->isValid()) {
$arJoinProps["FC"] = $f->getFilterSql($arFilter, $arSqlSearch);
$arJoinProps["FC_DISTINCT"] = $f->getDistinct();
}
}
foreach ($arFilter as $orig_key => $val) {
$res = CIBlock::MkOperationFilter($orig_key);
$key = $res["FIELD"];
$cOperationType = $res["OPERATION"];
//it was done before $key = strtoupper($key);
switch ($key . "") {
case "ACTIVE":
case "DETAIL_TEXT_TYPE":
case "PREVIEW_TEXT_TYPE":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "string_equal", $bFullJoinTmp, $cOperationType);
break;
case "NAME":
case "XML_ID":
case "TMP_ID":
case "DETAIL_TEXT":
case "SEARCHABLE_CONTENT":
case "PREVIEW_TEXT":
case "CODE":
case "TAGS":
case "WF_COMMENTS":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "string", $bFullJoinTmp, $cOperationType);
break;
case "ID":
if (is_object($val)) {
$arSqlSearch[] = $val->_sql_in("BE." . $key, $cOperationType);
} else {
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType);
}
break;
case "SHOW_COUNTER":
case "WF_PARENT_ELEMENT_ID":
case "WF_STATUS_ID":
case "SORT":
case "CREATED_BY":
case "PREVIEW_PICTURE":
case "DETAIL_PICTURE":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType);
break;
case "IBLOCK_ID":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType);
break;
case "TIMESTAMP_X":
case "DATE_CREATE":
case "SHOW_COUNTER_START":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "date", $bFullJoinTmp, $cOperationType);
break;
case "EXTERNAL_ID":
$arSqlSearch[] = CIBlock::FilterCreateEx("BE.XML_ID", $val, "string", $bFullJoinTmp, $cOperationType);
break;
case "IBLOCK_TYPE":
$flt = CIBlock::FilterCreateEx("B.IBLOCK_TYPE_ID", $val, "string", $bFullJoinTmp, $cOperationType);
$arSqlSearch[] = $flt;
break;
case "CHECK_PERMISSIONS":
if ($val == "Y" && (!is_object($USER) || !$USER->IsAdmin())) {
$permSQL = CIBlockElement::_check_rights_sql($arFilter["MIN_PERMISSION"]);
}
break;
case "CHECK_BP_PERMISSIONS":
if (IsModuleInstalled('bizproc') && (!is_object($USER) || !$USER->IsAdmin())) {
if (is_array($val)) {
$MODULE_ID = $DB->ForSQL($val["MODULE_ID"]);
$ENTITY = $DB->ForSQL($val["ENTITY"]);
$PERMISSION = $DB->ForSQL($val["PERMISSION"]);
$arUserGroups = array();
if (is_array($val["GROUPS"])) {
$USER_ID = intval($val["USER_ID"]);
foreach ($val["GROUPS"] as $GROUP_ID) {
//.........这里部分代码省略.........
示例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") {
//.........这里部分代码省略.........