Advertisement
the0938

Exclude Bitrix Admin Menu Sections

Feb 27th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. AddEventHandler('main', 'OnBuildGlobalMenu', function(&$globalMenu, &$moduleMenu)
  2. {
  3.     global $USER;
  4.  
  5.     if ($USER->IsAdmin())
  6.     {
  7.         return;
  8.     }
  9.  
  10.     $hideSections = [
  11.         'global_menu_services',
  12.         'global_menu_marketing'
  13.     ];
  14.    
  15.     $hideTitles = [
  16.         'Настройка информационных блоков'
  17.     ];
  18.    
  19.     foreach ($globalMenu as $section => $item)
  20.     {
  21.         $isHide = in_array($section, $hideSections);
  22.  
  23.         // Было бы неплохо добавить к переменной $isHide еще и проверку попадания в массив $hideTitles.
  24.  
  25.         if ($isHide)
  26.         {
  27.             unset($globalMenu[$section]);
  28.         }
  29.     }
  30.    
  31.     foreach ($moduleMenu as $name => $item)
  32.     {
  33.         $section = $item['parent_menu'];
  34.         $title = $item['title'];
  35.  
  36.         $isHide = in_array($section, $hideSections) || in_array($title, $hideTitles);
  37.  
  38.         if ($isHide)
  39.         {
  40.             unset($moduleMenu[$key]);
  41.         }
  42.     }
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement