当前位置: 首页>>代码示例>>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;未经允许,请勿转载。