/** * @param $documentType * @param bool $withExtended * @return array|bool */ public function GetAllowableUserGroups($documentType, $withExtended = false) { $documentType = trim($documentType); if (strlen($documentType) <= 0) { return false; } $iblockId = intval(substr($documentType, strlen("iblock_"))); $result = array("Author" => GetMessage("IBD_DOCUMENT_AUTHOR")); $groupsId = array(1); $extendedGroupsCode = array(); if (CIBlock::getArrayByID($iblockId, "RIGHTS_MODE") === "E") { $rights = new CIBlockRights($iblockId); foreach ($rights->getGroups() as $iblockGroupCode) { if (preg_match("/^G(\\d+)\$/", $iblockGroupCode, $match)) { $groupsId[] = $match[1]; } else { $extendedGroupsCode[] = $iblockGroupCode; } } } else { foreach (CIBlock::getGroupPermissions($iblockId) as $groupId => $perm) { if ($perm > "R") { $groupsId[] = $groupId; } } } $groupsIterator = CGroup::getListEx(array("NAME" => "ASC"), array("ID" => $groupsId)); while ($group = $groupsIterator->fetch()) { $result[$group["ID"]] = $group["NAME"]; } if ($withExtended && $extendedGroupsCode) { foreach ($extendedGroupsCode as $groupCode) { $result['group_' . $groupCode] = CBPHelper::getExtendedGroupName($groupCode); } } return $result; }