本文整理汇总了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;
}
示例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;
//.........这里部分代码省略.........