예제 #1
0
 /**
  * Load and return the shared navigation of the given type
  *
  * @param   string  $type
  *
  * @return  Navigation
  */
 public function getSharedNavigation($type)
 {
     $config = Config::navigation($type === 'dashboard-pane' ? 'dashlet' : $type);
     if ($type === 'dashboard-pane') {
         $panes = array();
         foreach ($config as $dashletName => $dashletConfig) {
             if ($this->hasAccessToSharedNavigationItem($dashletConfig)) {
                 // TODO: Throw ConfigurationError if pane or url is missing
                 $panes[$dashletConfig->pane][$dashletName] = $dashletConfig->url;
             }
         }
         $navigation = new Navigation();
         foreach ($panes as $paneName => $dashlets) {
             $navigation->addItem($paneName, array('type' => 'dashboard-pane', 'dashlets' => $dashlets));
         }
     } else {
         $items = array();
         foreach ($config as $name => $typeConfig) {
             if ($this->hasAccessToSharedNavigationItem($typeConfig)) {
                 $items[$name] = $typeConfig;
             }
         }
         $navigation = Navigation::fromConfig($items);
     }
     return $navigation;
 }
예제 #2
0
파일: User.php 프로젝트: AndHab/icingaweb2
 /**
  * Load and return this user's configured navigation of the given type
  *
  * @param   string  $type
  *
  * @return  Navigation
  */
 public function getNavigation($type)
 {
     $config = $this->loadNavigationConfig();
     $config->getConfigObject()->setKeyColumn('name');
     if ($type === 'dashboard-pane') {
         $panes = array();
         foreach ($config->select()->where('type', 'dashlet') as $dashletName => $dashletConfig) {
             // TODO: Throw ConfigurationError if pane or url is missing
             $panes[$dashletConfig->pane][$dashletName] = $dashletConfig->url;
         }
         $navigation = new Navigation();
         foreach ($panes as $paneName => $dashlets) {
             $navigation->addItem($paneName, array('type' => 'dashboard-pane', 'dashlets' => $dashlets));
         }
     } else {
         $navigation = Navigation::fromConfig($config->select()->where('type', $type));
     }
     return $navigation;
 }