CCrmSearch::OnSearchCheckPermissions

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmSearch
  4. OnSearchCheckPermissions
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_search.php
  • Класс: \CCrmSearch
  • Вызов: CCrmSearch::OnSearchCheckPermissions
static function OnSearchCheckPermissions($FIELD)
{
	$arAttr = array();
	if(CCrmPerms::IsAdmin())
	{
		$arAttr['LEAD'] = $arAttr['DEAL'] = $arAttr['INVOICE'] =
			$arAttr['QUOTE'] = $arAttr['CONTACT'] = $arAttr['COMPANY'] = array(array());

		foreach(\Bitrix\Crm\Category\DealCategory::getAllPermissionEntityTypes() as $permEntity)
		{
			$arAttr[$permEntity] = array(array());
		}
	}
	else
	{
		$CCrmPerms = CCrmPerms::GetCurrentUserPermissions();
		$arAttr['LEAD'] = $CCrmPerms->GetUserAttrForSelectEntity('LEAD', 'READ');
		$arAttr['DEAL'] = $CCrmPerms->GetUserAttrForSelectEntity('DEAL', 'READ');

		foreach(\Bitrix\Crm\Category\DealCategory::getAllPermissionEntityTypes() as $permEntity)
		{
			$arAttr[$permEntity] = $CCrmPerms->GetUserAttrForSelectEntity($permEntity, '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;
			}

			if (!empty($arattr_d))
			{
				foreach ($arattr_d as $sattr_d)
				{
					$sattr = "{$ENTITY_TYPE}_{$sattr_d}";
					if (!empty($sattr_s))
					{
						$sattr .= '_'.$sattr_s;
					}

					$arRel[] = $sattr;
				}
				if (!empty($sattr_o))
				{
					$arRel[] = "{$ENTITY_TYPE}_{$sattr_o}";
				}
			}
			else
			{
				$sattr = $ENTITY_TYPE;
				if (!empty($sattr_u))
				{
					$sattr .= '_' . $sattr_u;
				}
				if (!empty($sattr_o))
				{
					$sattr .= '_' . $sattr_o;
				}
				if (!empty($sattr_s))
				{
					$sattr .= '_' . $sattr_s;
				}
				$arRel[] = $sattr;
			}
		}
	}

	return $arRel;
}

Добавить комментарий