public static function getAllowableUserGroups($documentType)
 {
     $storageId = self::getStorageIdByType($documentType);
     if (!$storageId) {
         throw new CBPArgumentNullException('documentType');
     }
     /** @var Storage $storage */
     $storage = Storage::loadById($storageId, array('ROOT_OBJECT'));
     if (!$storage) {
         throw new CBPArgumentNullException('documentType');
     }
     if ($storage->getProxyType() instanceof ProxyType\Group) {
         if (Loader::includeModule("socialnetwork")) {
             $resultUserGroups = array();
             $resultUserGroups["author"] = Loc::getMessage("DISK_USER_GROUPS_AUTHOR");
             $resultUserGroups[SONET_ROLES_OWNER] = Loc::getMessage("DISK_USER_GROUPS_OWNER");
             $resultUserGroups[SONET_ROLES_MODERATOR] = Loc::getMessage("DISK_USER_GROUPS_MODS");
             $resultUserGroups[SONET_ROLES_USER] = Loc::getMessage("DISK_USER_GROUPS_MEMBERS");
             return $resultUserGroups;
         }
     } else {
         $resultUserGroups = array('Author' => Loc::getMessage("DISK_USER_GROUPS_AUTHOR"));
         $groupIds = array(1);
         foreach (Driver::getInstance()->getRightsManager()->getSpecificRights($storage->getRootObject()) as $right) {
             if (preg_match("/^G(\\d+)\$/", $right['ACCESS_CODE'], $match)) {
                 $groupIds[] = $match[1];
             }
         }
         unset($right);
         //Crutch for Bitrix24 context (user group management is not supported)
         if (ModuleManager::isModuleInstalled('bitrix24')) {
             $siteId = \CAllSite::getDefSite();
             $employeeGroup = \CGroup::getList($by = '', $order = '', array('STRING_ID' => 'EMPLOYEES_' . $siteId, 'STRING_ID_EXACT_MATCH' => 'Y'))->fetch();
             if ($employeeGroup) {
                 $employeeGroupId = (int) $employeeGroup['ID'];
                 if (!in_array($employeeGroupId, $groupIds, true)) {
                     $groupIds[] = $employeeGroupId;
                 }
             }
         }
         $dbGroupsList = \CGroup::getListEx(array('NAME' => 'ASC'), array('ID' => $groupIds));
         while ($group = $dbGroupsList->fetch()) {
             $resultUserGroups[$group['ID']] = $group['NAME'];
         }
         return $resultUserGroups;
     }
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 public function GetAllowableUserGroups($documentType)
 {
     if ($storage = self::needProxyToDiskByDocType($documentType)) {
         return self::proxyToDisk(__FUNCTION__, array(\Bitrix\Disk\BizProcDocumentCompatible::generateDocumentType($storage->getId())));
     }
     $iblockId = intval(substr($documentType, strlen("iblock_")));
     if ($iblockId <= 0) {
         throw new CBPArgumentOutOfRangeException("documentType", $documentType);
     }
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     $iblockId = intval(substr($documentType, strlen("iblock_")));
     $arResult = array("Author" => GetMessage("IBD_DOCUMENT_AUTHOR"));
     $arRes = array(1);
     if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") === "E") {
         $obRights = new CIBlockRights($iblockId);
         foreach ($obRights->GetGroups("element_bizproc_start") as $GROUP_CODE) {
             if (preg_match("/^G(\\d+)\$/", $GROUP_CODE, $match)) {
                 $arRes[] = $match[1];
             }
         }
     } else {
         $arGroups = CIBlock::GetGroupPermissions($iblockId);
         foreach ($arGroups as $groupId => $perm) {
             if ($perm >= "R") {
                 $arRes[] = $groupId;
             }
         }
     }
     //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 ($arEmployeeGroup = $dbResult->Fetch()) {
             $employeeGroupID = intval($arEmployeeGroup['ID']);
             if (!in_array($employeeGroupID, $arRes, true)) {
                 $arRes[] = $employeeGroupID;
             }
         }
     }
     $dbGroupsList = CGroup::GetListEx(array("NAME" => "ASC"), array("ID" => $arRes));
     while ($arGroup = $dbGroupsList->Fetch()) {
         $arResult[$arGroup["ID"]] = $arGroup["NAME"];
     }
     return $arResult;
 }