Skip to content

Instantly share code, notes, and snippets.

@iredun
Last active January 18, 2017 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iredun/8a7d85433c524b9ebee117c7e5e5a983 to your computer and use it in GitHub Desktop.
Save iredun/8a7d85433c524b9ebee117c7e5e5a983 to your computer and use it in GitHub Desktop.
Выводит инфоблоки в админке только текущего сайта (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