From 715adfedb1c47adeef762da70837fde580d54497 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 11 Mar 2022 16:43:05 +0100 Subject: [PATCH] Menu: Provide own class for dashboard homes navigation items --- library/Icinga/Web/HomeMenu.php | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 library/Icinga/Web/HomeMenu.php diff --git a/library/Icinga/Web/HomeMenu.php b/library/Icinga/Web/HomeMenu.php new file mode 100644 index 000000000..423048c8a --- /dev/null +++ b/library/Icinga/Web/HomeMenu.php @@ -0,0 +1,41 @@ +initHome(); + } + + public function initHome() + { + $user = Dashboard::getUser(); + $dashboardItem = $this->getItem('dashboard'); + + $homes = Home::on(Dashboard::getConn()); + $homes->filter(Filter::equal('username', $user->getUsername())); + + foreach ($homes as $home) { + $dashboardHome = new DashboardHome($home->name, [ + 'uuid' => $home->id, + 'label' => t($home->label), + 'priority' => $home->priority, + 'type' => $home->type, + ]); + + $dashboardItem->addChild($dashboardHome); + } + } +}