本文整理汇总了PHP中CCrmPerms::GetEntityRelations方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmPerms::GetEntityRelations方法的具体用法?PHP CCrmPerms::GetEntityRelations怎么用?PHP CCrmPerms::GetEntityRelations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmPerms
的用法示例。
在下文中一共展示了CCrmPerms::GetEntityRelations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetAllowableUserGroups
public static function GetAllowableUserGroups($documentType)
{
$documentType = trim($documentType);
if (strlen($documentType) <= 0) {
return false;
}
$arDocumentID = self::GetDocumentInfo($documentType);
if ($arDocumentID !== false) {
$documentType = $arDocumentID['TYPE'];
}
$arResult = array('author' => GetMessage('CRM_DOCUMENT_AUTHOR'));
$arGroupsID = array(1);
$arUsersID = array();
$arRelations = CCrmPerms::GetEntityRelations($documentType, BX_CRM_PERM_SELF);
foreach ($arRelations as $relation) {
$preffix = substr($relation, 0, 1);
if ($preffix === 'G') {
$arGroupsID[] = intval(substr($relation, 1));
} elseif ($preffix === 'U') {
$arUsersID[] = substr($relation, 1);
}
}
//Crutch for Bitrix24 context (user group management is not suppotted)
if (IsModuleInstalled('bitrix24')) {
$siteID = CAllSite::GetDefSite();
$dbResult = CGroup::GetList($by = '', $order = '', array('STRING_ID' => 'EMPLOYEES_' . $siteID, 'STRING_ID_EXACT_MATCH' => 'Y'));
if ($arEmloyeeGroup = $dbResult->Fetch()) {
$employeeGroupID = intval($arEmloyeeGroup['ID']);
if (!in_array($employeeGroupID, $arGroupsID, true)) {
$arGroupsID[] = $employeeGroupID;
}
}
}
if (!empty($arGroupsID)) {
$dbGroupList = CGroup::GetListEx(array('NAME' => 'ASC'), array('ID' => $arGroupsID));
while ($arGroup = $dbGroupList->Fetch()) {
$arResult[$arGroup['ID']] = $arGroup['NAME'];
}
}
if (isset(self::$UNGROUPED_USERS[$documentType])) {
unset(self::$UNGROUPED_USERS[$documentType]);
}
self::$UNGROUPED_USERS[$documentType] = $arUsersID;
if (!empty($arUsersID)) {
//Group with empty name will be hidden in group list
$arResult['ungrouped'] = '';
//$arResult['ungrouped'] = GetMessage('CRM_DOCUMENT_UNGROUPED_USERS');
}
return $arResult;
}