Instantly share code, notes, and snippets.

@iredun /init.php
Last active Jan 18, 2017

Embed
What would you like to do?
Выводит инфоблоки в админке только текущего сайта (https://dev.1c-bitrix.ru/community/webdev/user/11948/blog/2692/)
<?
AddEventHandler('main', 'OnBuildGlobalMenu', 'ASDOnBuildGlobalMenu');
function ASDOnBuildGlobalMenu(&$aGlobalMenu, &$aModuleMenu)
{
$arSites = array(
'www.site.ru' => 's1',
'site.ru' => 's1',
);
$arIBsites = array();
$rsIB = $GLOBALS['DB']->Query("SELECT * FROM b_iblock_site;");
while ($arIB = $rsIB->Fetch())
$arIBsites[$arIB['IBLOCK_ID']] = $arIB['SITE_ID'];
foreach ($aModuleMenu as $k => &$v)
{
if($v['parent_menu']=='global_menu_content' && $v['module_id']=='iblock' && $v['page_icon']!='iblock_page_icon_settings')
{
$cUnsets = 0;
$cAll = count($v['items']);
foreach ($v['items'] as $kk => $vv)
{
$BID = array_pop(explode('/', $vv['items_id']));
if ($arIBsites[$BID] != $arSites[$_SERVER['SERVER_NAME']])
{
unset($v['items'][$kk]);
$cUnsets++;
}
}
if ($cUnsets == $cAll)
unset($aModuleMenu[$k]);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment