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


PHP CCrmCompany::BuildPermSql方法代码示例

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


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

示例1: BuildPermSql

 public static function BuildPermSql($aliasPrefix = 'A', $permType = 'READ', $arOptions = array())
 {
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     $userPermissions = isset($arOptions['PERMS']) ? $arOptions['PERMS'] : null;
     $userID = $userPermissions !== null && is_object($userPermissions) ? $userPermissions->GetUserID() : 0;
     if (CCrmPerms::IsAdmin($userID)) {
         return '';
     }
     if (!CCrmPerms::IsAccessEnabled($userPermissions)) {
         // User does not have permissions at all.
         return false;
     }
     $entitiesSql = array();
     $permOptions = array_merge(array('IDENTITY_COLUMN' => 'OWNER_ID'), $arOptions);
     $entitiesSql[strval(CCrmOwnerType::Lead)] = CCrmLead::BuildPermSql($aliasPrefix, $permType, $permOptions);
     $entitiesSql[strval(CCrmOwnerType::Deal)] = CCrmDeal::BuildPermSql($aliasPrefix, $permType, $permOptions);
     $entitiesSql[strval(CCrmOwnerType::Contact)] = CCrmContact::BuildPermSql($aliasPrefix, $permType, $permOptions);
     $entitiesSql[strval(CCrmOwnerType::Company)] = CCrmCompany::BuildPermSql($aliasPrefix, $permType, $permOptions);
     $entitiesSql[strval(CCrmOwnerType::Invoice)] = CCrmInvoice::BuildPermSql($aliasPrefix, $permType, $permOptions);
     foreach ($entitiesSql as $entityTypeID => $entitySql) {
         if (!is_string($entitySql)) {
             //If $entityPermSql is not string - acces denied. Clear permission SQL and related records will be ignored.
             unset($entitiesSql[$entityTypeID]);
             continue;
         }
         if ($entitySql !== '') {
             $entitiesSql[$entityTypeID] = '(' . $aliasPrefix . '.OWNER_TYPE_ID = ' . $entityTypeID . ' AND (' . $entitySql . ') )';
         } else {
             // No permissions check - fetch all related records
             $entitiesSql[$entityTypeID] = '(' . $aliasPrefix . '.OWNER_TYPE_ID = ' . $entityTypeID . ')';
         }
     }
     //If $entitiesSql is empty - user does not have permissions at all.
     if (empty($entitiesSql)) {
         return false;
     }
     $userID = CCrmSecurityHelper::GetCurrentUserID();
     if ($userID > 0) {
         //Allow responsible user to view activity without permissions check.
         return $aliasPrefix . '.RESPONSIBLE_ID = ' . $userID . ' OR ' . implode(' OR ', $entitiesSql);
     } else {
         return implode(' OR ', $entitiesSql);
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:46,代码来源:crm_activity.php

示例2: BuildPermSql

 public static function BuildPermSql($aliasPrefix = 'CE', $permType = 'READ')
 {
     if (empty($arFilter['ENTITY_TYPE'])) {
         $arEntity = array(CCrmOwnerType::LeadName, CCrmOwnerType::DealName, CCrmOwnerType::QuoteName, CCrmOwnerType::ContactName, CCrmOwnerType::CompanyName);
     } elseif (isset($arFilter['ENTITY_TYPE']) && is_array($arFilter['ENTITY_TYPE'])) {
         $arEntity = $arFilter['ENTITY_TYPE'];
     } else {
         $arEntity = array($arFilter['ENTITY_TYPE']);
     }
     $entitiesSql = array();
     $permOptions = array('IDENTITY_COLUMN' => 'ENTITY_ID');
     foreach ($arEntity as $entityType) {
         if ($entityType === CCrmOwnerType::LeadName) {
             $entitiesSql[CCrmOwnerType::LeadName] = CCrmLead::BuildPermSql('CER', $permType, $permOptions);
         } elseif ($entityType === CCrmOwnerType::DealName) {
             $entitiesSql[CCrmOwnerType::DealName] = CCrmDeal::BuildPermSql('CER', $permType, $permOptions);
         } elseif ($entityType === CCrmOwnerType::QuoteName) {
             $entitiesSql[CCrmOwnerType::QuoteName] = CCrmQuote::BuildPermSql('CER', $permType, $permOptions);
         } elseif ($entityType === CCrmOwnerType::ContactName) {
             $entitiesSql[CCrmOwnerType::ContactName] = CCrmContact::BuildPermSql('CER', $permType, $permOptions);
         } elseif ($entityType === CCrmOwnerType::CompanyName) {
             $entitiesSql[CCrmOwnerType::CompanyName] = CCrmCompany::BuildPermSql('CER', $permType, $permOptions);
         }
     }
     foreach ($entitiesSql as $entityType => $entitySql) {
         if (!is_string($entitySql)) {
             //If $entityPermSql is not string - acces denied. Clear permission SQL and related records will be ignored.
             unset($entitiesSql[$entityType]);
             continue;
         }
         if ($entitySql !== '') {
             $entitiesSql[$entityType] = "(CER.ENTITY_TYPE = '{$entityType}' AND ({$entitySql}))";
         } else {
             // No permissions check - fetch all related records
             $entitiesSql[$entityType] = "(CER.ENTITY_TYPE = '{$entityType}')";
         }
     }
     //If $entitiesSql is empty - user does not have permissions at all.
     if (empty($entitiesSql)) {
         return false;
     }
     return implode(' OR ', $entitiesSql);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:43,代码来源:crm_event.php


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