當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CCrmFieldMulti::PrepareExternalFilter方法代碼示例

本文整理匯總了PHP中CCrmFieldMulti::PrepareExternalFilter方法的典型用法代碼示例。如果您正苦於以下問題:PHP CCrmFieldMulti::PrepareExternalFilter方法的具體用法?PHP CCrmFieldMulti::PrepareExternalFilter怎麽用?PHP CCrmFieldMulti::PrepareExternalFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CCrmFieldMulti的用法示例。


在下文中一共展示了CCrmFieldMulti::PrepareExternalFilter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Prepare

 public function Prepare($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arOptions = array())
 {
     global $DB;
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     // ID must present in select (If select is empty it will be filled by CSqlUtil::PrepareSql)
     if (!is_array($arSelectFields)) {
         $arSelectFields = array();
     }
     if (count($arSelectFields) > 0 && !in_array('*', $arSelectFields, true) && !in_array('ID', $arSelectFields, true)) {
         $arSelectFields[] = 'ID';
     }
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     $arOptions['DB_TYPE'] = $this->dbType;
     $isExternalContext = isset($arOptions['IS_EXTERNAL_CONTEXT']) && ($arOptions['IS_EXTERNAL_CONTEXT'] === true || $arOptions['IS_EXTERNAL_CONTEXT'] === 'Y');
     if ($isExternalContext) {
         // Sanitizing of filter data
         if (isset($arFilter['__JOINS'])) {
             unset($arFilter['__JOINS']);
         }
         if (isset($arFilter['CHECK_PERMISSIONS'])) {
             unset($arFilter['CHECK_PERMISSIONS']);
         }
     }
     // Processing of special fields
     if ($this->fmEntityID !== '' && isset($arFilter['FM'])) {
         CCrmFieldMulti::PrepareExternalFilter($arFilter, array('ENTITY_ID' => $this->fmEntityID, 'MASTER_ALIAS' => $this->tableAlias, 'MASTER_IDENTITY' => 'ID'));
     }
     // Processing user fields
     $ufSelectSql = null;
     $ufFilterSql = null;
     if ($this->ufEntityID !== '') {
         $ufSelectSql = new CUserTypeSQL();
         $ufSelectSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID');
         $ufSelectSql->SetSelect($arSelectFields);
         $ufSelectSql->SetOrder($arOrder);
         $ufFilterSql = new CUserTypeSQL();
         $ufFilterSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID');
         $ufFilterSql->SetFilter($arFilter);
         $userType = new CCrmUserType($GLOBALS['USER_FIELD_MANAGER'], $this->ufEntityID);
         $userType->ListPrepareFilter($arFilter);
     }
     $this->sqlData = CSqlUtil::PrepareSql($this->fields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $arOptions);
     $this->sqlData['SELECT'] = str_replace('%%_DISTINCT_%% ', '', $this->sqlData['SELECT']);
     // 'Joins' implement custom filter logic
     $joins = array();
     if (isset($arFilter['__JOINS'])) {
         if (is_array($arFilter['__JOINS'])) {
             $joins = $arFilter['__JOINS'];
         }
         unset($arFilter['__JOINS']);
     }
     if (count($joins) > 0) {
         foreach ($joins as &$join) {
             // INNER JOINs will be added tostart
             $this->Add2SqlData($join['SQL'], 'FROM', !isset($join['TYPE']) || $join['TYPE'] === 'INNER', isset($join['REPLACE']) ? $join['REPLACE'] : '');
         }
         unset($join);
     }
     // Apply user permission logic
     if (count($this->permissionCallback) > 0) {
         if ((!array_key_exists('CHECK_PERMISSIONS', $arFilter) || $arFilter['CHECK_PERMISSIONS'] !== 'N') && !CCrmPerms::IsAdmin()) {
             $arPermType = !isset($arFilter['PERMISSION']) ? 'READ' : (is_array($arFilter['PERMISSION']) ? $arFilter['PERMISSION'] : array($arFilter['PERMISSION']));
             $permissionSql = call_user_func_array($this->permissionCallback, array($this->tableAlias, $arPermType, $arOptions));
             if (is_bool($permissionSql) && !$permissionSql) {
                 $CDBResult = new CDBResult();
                 $CDBResult->InitFromArray(array());
                 return $CDBResult;
             }
             if ($permissionSql !== '') {
                 $sqlType = isset($arOptions['PERMISSION_SQL_TYPE']) && $arOptions['PERMISSION_SQL_TYPE'] === 'FROM' ? 'FROM' : 'WHERE';
                 $this->Add2SqlData($permissionSql, $sqlType, $sqlType === 'FROM');
             }
         }
     }
     // Apply custom SQL logic
     if (count($this->afterPrepareSqlCallback) > 0) {
         $arUserSql = call_user_func_array($this->afterPrepareSqlCallback, array($this, $arOrder, $arFilter, $arGroupBy, $arSelectFields));
         if (is_array($arUserSql)) {
             if (isset($arUserSql['FROM'])) {
                 $this->Add2SqlData($arUserSql['FROM'], 'FROM');
             }
             if (isset($arUserSql['WHERE'])) {
                 $this->Add2SqlData($arUserSql['WHERE'], 'WHERE');
             }
         }
     }
     if ($ufSelectSql) {
         // Adding user fields to SELECT
         $this->Add2SqlData($ufSelectSql->GetSelect(), 'SELECT');
         // Adding user fields to ORDER BY
         if (is_array($arOrder)) {
             foreach ($arOrder as $orderKey => $order) {
                 $orderSql = $ufSelectSql->GetOrder($orderKey);
//.........這裏部分代碼省略.........
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:101,代碼來源:crm_entity_list_builder.php


注:本文中的CCrmFieldMulti::PrepareExternalFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。