当前位置: 首页>>代码示例>>PHP>>正文


PHP CCrmPerms::GetUserAttrForSelectEntity方法代码示例

本文整理汇总了PHP中CCrmPerms::GetUserAttrForSelectEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmPerms::GetUserAttrForSelectEntity方法的具体用法?PHP CCrmPerms::GetUserAttrForSelectEntity怎么用?PHP CCrmPerms::GetUserAttrForSelectEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCrmPerms的用法示例。


在下文中一共展示了CCrmPerms::GetUserAttrForSelectEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: OnSearchCheckPermissions

 function OnSearchCheckPermissions($FIELD)
 {
     global $USER;
     $CCrmPerms = new CCrmPerms($USER->GetID());
     $arAttr['LEAD'] = $CCrmPerms->GetUserAttrForSelectEntity('LEAD', 'READ');
     $arAttr['DEAL'] = $CCrmPerms->GetUserAttrForSelectEntity('DEAL', 'READ');
     $arAttr['INVOICE'] = $CCrmPerms->GetUserAttrForSelectEntity('INVOICE', 'READ');
     $arAttr['QUOTE'] = $CCrmPerms->GetUserAttrForSelectEntity('QUOTE', 'READ');
     $arAttr['CONTACT'] = $CCrmPerms->GetUserAttrForSelectEntity('CONTACT', 'READ');
     $arAttr['COMPANY'] = $CCrmPerms->GetUserAttrForSelectEntity('COMPANY', 'READ');
     $arRel = array();
     foreach ($arAttr as $ENTITY_TYPE => $_arRel) {
         foreach ($_arRel as $arRelType) {
             if (empty($arRelType)) {
                 $arRel[] = $ENTITY_TYPE;
                 continue;
             }
             $arattr_d = array();
             $sattr_s = '';
             $sattr_u = '';
             $sattr_o = '';
             foreach ($arRelType as $_s) {
                 if ($_s[0] == 'U') {
                     $sattr_u = $_s;
                 } else {
                     if ($_s[0] == 'D') {
                         $arattr_d[] = $_s;
                     } else {
                         if ($_s[0] == 'S') {
                             $sattr_s = $_s;
                         } else {
                             if ($_s[0] == 'O') {
                                 $sattr_o = $_s;
                             }
                         }
                     }
                 }
             }
             $sattr = $ENTITY_TYPE;
             if (!empty($arattr_d)) {
                 foreach ($arattr_d as $sattr_d) {
                     $sattr = $sattr_u !== '' ? "{$ENTITY_TYPE}_{$sattr_u}_{$sattr_d}" : "{$ENTITY_TYPE}_{$sattr_d}";
                     if (!empty($sattr_s)) {
                         $sattr .= '_' . $sattr_s;
                     }
                     $arRel[] = $sattr;
                 }
                 if (!empty($sattr_o)) {
                     $sattr .= '_' . $sattr_o;
                     $arRel[] = $sattr;
                 }
             } else {
                 if (!empty($sattr_u)) {
                     $sattr .= '_' . $sattr_u;
                 }
                 if (!empty($sattr_s)) {
                     $sattr .= '_' . $sattr_s;
                 }
                 if (!empty($sattr_o)) {
                     $sattr .= '_' . $sattr_o;
                 }
                 $arRel[] = $sattr;
             }
         }
     }
     return $arRel;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:67,代码来源:crm_search.php

示例2: GetList

 public static function GetList($arSort = array(), $arFilter = array(), $nPageTop = false)
 {
     global $DB, $USER;
     $currentUser = isset($USER) && (get_class($USER) === 'CUser' || $USER instanceof CUser) ? $USER : new CUser();
     $arSqlSearch = array();
     $strSqlSearch = "";
     $err_mess = self::err_mess() . '<br />Function: GetList<br />Line: ';
     if (isset($arFilter['ENTITY'])) {
         $ar = explode('_', $arFilter['ENTITY']);
         $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetLongEntityType($ar[0]);
         $arFilter['ENTITY_ID'] = intval($ar[1]);
         unset($arFilter['ENTITY']);
     }
     // permission check
     $strPermission = "";
     if (!$currentUser->IsAdmin()) {
         $CCrmPerms = new CCrmPerms($currentUser->GetID());
         $arUserAttr = array();
         $arEntity = array();
         if (empty($arFilter['ENTITY_TYPE'])) {
             $arEntity = array('LEAD', 'DEAL', 'CONTACT', 'COMPANY', 'QUOTE');
         } else {
             if (is_array($arFilter['ENTITY_TYPE'])) {
                 $arEntity = $arFilter['ENTITY_TYPE'];
             } else {
                 $arEntity = array($arFilter['ENTITY_TYPE']);
             }
         }
         $arInEntity = array();
         foreach ($arEntity as $sEntityType) {
             $arEntityAttr = $CCrmPerms->GetUserAttrForSelectEntity($sEntityType, 'READ');
             $arUserAttr[$sEntityType] = $arEntityAttr;
         }
         if (empty($arUserAttr)) {
             $CDBResult = new CDBResult();
             $CDBResult->InitFromArray(array());
             return $CDBResult;
         }
         $arUserPerm = array();
         foreach ($arUserAttr as $sEntityType => $_arAttrs) {
             if (isset($_arAttrs[0]) && is_array($_arAttrs[0]) && empty($_arAttrs[0])) {
                 $arInEntity[] = $sEntityType;
                 continue;
             }
             foreach ($_arAttrs as $_arAttr) {
                 if (empty($_arAttr)) {
                     continue;
                 }
                 $_icnt = count($_arAttr);
                 $_idcnt = -1;
                 foreach ($_arAttr as $sAttr) {
                     if ($sAttr[0] == 'D') {
                         $_idcnt++;
                     }
                 }
                 if ($_icnt == 1 && ($_idcnt == 1 || $_idcnt == -1)) {
                     $_idcnt = 0;
                 }
                 $arUserPerm[] = "(P.ENTITY = '{$sEntityType}' AND SUM(CASE WHEN P.ATTR = '" . implode("' or P.ATTR = '", $_arAttr) . "' THEN 1 ELSE 0 END) = " . ($_icnt - $_idcnt) . ')';
             }
         }
         $arPermission = array();
         if (!empty($arInEntity)) {
             $arPermission[] = " CER.ENTITY_TYPE IN ('" . implode("','", $arInEntity) . "')";
         }
         if (!empty($arUserPerm)) {
             $arPermission[] = "\n\t\t\t\t\t\tEXISTS(\n\t\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\t\tFROM b_crm_entity_perms P\n\t\t\t\t\t\t\tWHERE P.ENTITY = CER.ENTITY_TYPE AND CER.ENTITY_ID = P.ENTITY_ID\n\t\t\t\t\t\t\tGROUP BY P.ENTITY, P.ENTITY_ID\n\t\t\t\t\t\t\tHAVING " . implode(" \n\t\t\t\t\t\t\t\tOR ", $arUserPerm) . "\n\t\t\t\t\t\t)";
         }
         if (!empty($arPermission)) {
             $strPermission = 'AND (' . implode(' OR ', $arPermission) . ')';
         }
     }
     $sOrder = '';
     foreach ($arSort as $key => $val) {
         $ord = strtoupper($val) != 'ASC' ? 'DESC' : 'ASC';
         switch (strtoupper($key)) {
             case 'ID':
                 $sOrder .= ', CER.ID ' . $ord;
                 break;
             case 'CREATED_BY_ID':
                 $sOrder .= ', CE.CREATED_BY_ID ' . $ord;
                 break;
             case 'EVENT_TYPE':
                 $sOrder .= ', CE.EVENT_TYPE ' . $ord;
                 break;
             case 'ENTITY_TYPE':
                 $sOrder .= ', CER.ENTITY_TYPE ' . $ord;
                 break;
             case 'ENTITY_ID':
                 $sOrder .= ', CER.ENTITY_ID ' . $ord;
                 break;
             case 'EVENT_ID':
                 $sOrder .= ', CE.EVENT_ID ' . $ord;
                 break;
             case 'DATE_CREATE':
                 $sOrder .= ', CE.DATE_CREATE ' . $ord;
                 break;
             case 'EVENT_NAME':
                 $sOrder .= ', CE.EVENT_NAME 	 ' . $ord;
                 break;
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:crm_event.php


注:本文中的CCrmPerms::GetUserAttrForSelectEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。