public static function MergeRights($IBLOCK_TYPE_ID, $DB, $POST) { $arResult = array(); //1) Put into result protected from changes rights $arListsPerm = CLists::GetPermission($IBLOCK_TYPE_ID); foreach ($DB as $RIGHT_ID => $arRight) { //1) protect groups from module settings if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) { $arResult[$RIGHT_ID] = $arRight; } else { //2) protect groups with iblock_% operations $arOperations = CTask::GetOperations($arRight['TASK_ID'], true); foreach ($arOperations as $operation) { if (preg_match("/^iblock_(?!admin)/", $operation)) { $arResult[$RIGHT_ID] = $arRight; break; } } } } //2) Leave in POST only safe rights foreach ($POST as $RIGHT_ID => $arRight) { //1) protect groups from module settings if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) { unset($POST[$RIGHT_ID]); } else { //2) protect groups with iblock_% operations $arOperations = CTask::GetOperations($arRight['TASK_ID'], true); foreach ($arOperations as $operation) { if (preg_match("/^iblock_(?!admin)/", $operation)) { unset($POST[$RIGHT_ID]); break; } } } } //3) Join POST to result foreach ($POST as $RIGHT_ID => $arRight) { foreach ($arResult as $RIGHT_ID2 => $arRight2) { if ($arRight["GROUP_CODE"] == $arRight2["GROUP_CODE"]) { unset($arResult[$RIGHT_ID2]); } } $arResult[$RIGHT_ID] = $arRight; } return $arResult; }
$arResult["HIGHLIGHT"] = array("groups" => array("disabled" => true)); } } else { if ($arParams["SOCNET_GROUP_ID"]) { $arResult["HIGHLIGHT"] = array("socnetgroup" => array("group_id" => $arParams["SOCNET_GROUP_ID"])); } else { $arResult["HIGHLIGHT"] = null; } } if ($arResult["ELEMENT_ID"]) { $obRights = new CIBlockElementRights($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"]); } else { $obRights = new CIBlockSectionRights($arResult["IBLOCK_ID"], intval($data["IBLOCK_SECTION_ID"])); } $arResult["RIGHTS"] = $obRights->GetRights(array("parents" => array($data["IBLOCK_SECTION_ID"]))); $arListsPerm = CLists::GetPermission($arParams["~IBLOCK_TYPE_ID"]); foreach ($arResult["RIGHTS"] as $RIGHT_ID => $arRight) { //1) protect groups from module settings $match = array(); if (preg_match("/^G(\\d)\$/", $arRight["GROUP_CODE"], $match) && is_array($arListsPerm) && in_array($match[1], $arListsPerm)) { unset($arResult["RIGHTS"][$RIGHT_ID]); $arResult["SELECTED"][$arRight["GROUP_CODE"]] = true; } else { //2) protect groups with iblock_% operations $arOperations = CTask::GetOperations($arRight['TASK_ID'], true); foreach ($arOperations as $operation) { if (preg_match("/^iblock_(?!admin)/", $operation)) { unset($arResult["RIGHTS"][$RIGHT_ID]); $arResult["SELECTED"][$arRight["GROUP_CODE"]] = true; break; }
<tr> <td valign="top" colspan="2"> <table border="0" cellspacing="0" cellpadding="0" class="internal" align="center" id="tblRIGHTS"> <tr class="heading"> <td><?php echo GetMessage("LISTS_OPTIONS_USER_GROUPS"); ?> </td> <td><?php echo GetMessage("LISTS_OPTIONS_IBLOCK_TYPES"); ?> </td> </tr> <?php $i = 0; foreach (CLists::GetPermission() as $type_id => $groups) { foreach ($groups as $group) { ?> <tr> <td><?php echo SelectBoxFromArray("group_right[n" . $i . "]", $arGroups, $group, GetMessage("LISTS_OPTIONS_CHOOSE_GROUP")); ?> </td> <td><?php echo SelectBoxFromArray("type_right[n" . $i . "]", $arIBTypes, $type_id, GetMessage("LISTS_OPTIONS_CHOOSE_TYPE")); ?> </td> </tr> <?php $i++; }
function installDemoData() { if(!CModule::IncludeModule("iblock")) return; $currentPermissions = CLists::GetPermission(); $socnet_iblock_type_id = COption::GetOptionString("lists", "socnet_iblock_type_id"); $isSocnetInstalled = IsModuleInstalled('socialnetwork'); $arTypes = array(); if (empty($currentPermissions)) { $arTypes[] = array( "ID" => "lists", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 80, "LANG" => array(), ); } if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) { $arTypes[] = array( "ID" => "lists_socnet", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 83, "LANG" => array(), ); } $arLanguages = array(); if (!empty($arTypes)) { $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { $arLanguages[] = $arLanguage["LID"]; } } foreach ($arTypes as $arType) { $dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"])); if (!$dbType->Fetch()) { foreach($arLanguages as $languageID) { IncludeModuleLangFile(__FILE__, $languageID); $code = strtoupper($arType["ID"]); $arType["LANG"][$languageID]["NAME"] = GetMessage($code."_TYPE_NAME"); $arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code."_ELEMENT_NAME"); if ($arType["SECTIONS"] == "Y") $arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code."_SECTION_NAME"); } $iblockType = new CIBlockType; $iblockType->Add($arType); } } if (empty($currentPermissions)) { CLists::SetPermission('lists', array(1)); } if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) { COption::SetOptionString("lists", "socnet_iblock_type_id", "lists_socnet"); CLists::EnableSocnet(true); } }
public static function OnSharepointCheckAccess($iblock_id) { global $USER; $arIBlock = CIBlock::GetArrayByID($iblock_id); if ($arIBlock) { //Check if iblock is list $arListsPerm = CLists::GetPermission($arIBlock["IBLOCK_TYPE_ID"]); if (count($arListsPerm)) { //User groups $arUserGroups = $USER->GetUserGroupArray(); //One of lists admins if (count(array_intersect($arListsPerm, $arUserGroups))) { return true; } else { return false; } } } }
function installDemoData() { if (!CModule::IncludeModule("iblock")) { return; } $currentPermissions = CLists::GetPermission(); unset($currentPermissions["bitrix_processes"]); unset($currentPermissions["lists"]); $socnet_iblock_type_id = COption::GetOptionString("lists", "socnet_iblock_type_id"); $isSocnetInstalled = IsModuleInstalled('socialnetwork'); $arTypes = array(); if (empty($currentPermissions)) { $arTypes[] = array("ID" => "lists", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 80, "LANG" => array()); $arTypes[] = array("ID" => "bitrix_processes", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 90, "LANG" => array()); } if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) { $arTypes[] = array("ID" => "lists_socnet", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 83, "LANG" => array()); } $arLanguages = array(); if (!empty($arTypes)) { $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { $arLanguages[] = $arLanguage["LID"]; } } foreach ($arTypes as $arType) { $dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"])); if (!$dbType->Fetch()) { foreach ($arLanguages as $languageID) { IncludeModuleLangFile(__FILE__, $languageID); $code = strtoupper($arType["ID"]); $arType["LANG"][$languageID]["NAME"] = GetMessage($code . "_TYPE_NAME"); $arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code . "_ELEMENT_NAME"); if ($arType["SECTIONS"] == "Y") { $arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code . "_SECTION_NAME"); } } $iblockType = new CIBlockType(); $iblockType->Add($arType); } } if (empty($currentPermissions)) { CLists::SetPermission('lists', array(1)); CLists::SetPermission('bitrix_processes', array(1)); } $defaultSiteId = CSite::GetDefSite(); $siteObject = CSite::GetByID($defaultSiteId); $site = $siteObject->fetch(); $defaultLang = $site ? $site['LANGUAGE_ID'] : 'en'; if ($defaultLang == 'ua') { $defaultLang = 'ru'; } \Bitrix\Lists\Importer::installProcesses($defaultLang); if (IsModuleInstalled("bitrix24")) { \Bitrix\Main\Config\Option::set("lists", "livefeed_url", "/company/processes/"); } else { \Bitrix\Main\Config\Option::set("lists", "livefeed_url", "/services/processes/"); } if ($isSocnetInstalled && strlen($socnet_iblock_type_id) <= 0) { COption::SetOptionString("lists", "socnet_iblock_type_id", "lists_socnet"); CLists::EnableSocnet(true); } }
} elseif (($ID <= 0 || $bCopy) && !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "iblock_admin_display")) { $bBadBlock = true; } elseif (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit")) { $bBadBlock = false; } elseif ($bWorkflow && ($WF == "Y" || $view == "Y")) { $bBadBlock = false; } elseif ($bBizproc) { $bBadBlock = false; } elseif (($ID <= 0 || $bCopy) && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "section_element_bind")) { $bBadBlock = false; } //This is temporary permissions check //will b removed ASAP if ($bBadBlock && CModule::IncludeModule('lists')) { //Find out if there is some groups to edit lists (so it's lists) $arListsPerm = CLists::GetPermission($arIBlock["IBLOCK_TYPE_ID"]); if (count($arListsPerm)) { if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_read")) { $bBadBlock = false; } else { //Check permissions for add or edit iblock $arUserGroups = $USER->GetUserGroupArray(); if (count(array_intersect($arListsPerm, $arUserGroups))) { $bBadBlock = false; } } } } } if ($bBadBlock) { $error = new _CIBlockError(1, "BAD_IBLOCK", GetMessage("IBLOCK_BAD_IBLOCK"));