From f3c43b1411112441b93f0293c6e538f0a7f1b80b Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Tue, 31 Dec 2019 21:51:40 +0100 Subject: [PATCH 1/2] Check if we actually have a service enabled --- interface/lib/classes/system.inc.php | 12 +++++++ interface/web/mail/lib/module.conf.php | 48 ++++++++++++++------------ 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/interface/lib/classes/system.inc.php b/interface/lib/classes/system.inc.php index 89507ea68c..a4e1d06550 100644 --- a/interface/lib/classes/system.inc.php +++ b/interface/lib/classes/system.inc.php @@ -39,6 +39,18 @@ class system { if(!preg_match('/^[a-z]+$/', $service)) $app->error('Invalid service '.$service); + // Check the servers table to see which kinds of servers we actually have enabled. + // simple query cache + if($this->server_count===null) { + $this->server_count = $app->db->queryOneRecord("SELECT SUM(mail_server) as mail, SUM(web_server) AS web, SUM(dns_server) AS dns, SUM(file_server) AS file, + SUM(db_server) AS db, SUM(vserver_server) AS vserver, SUM(proxy_server) AS proxy, SUM(firewall_server) AS firewall, SUM(xmpp_server) AS xmpp + FROM `server` WHERE mirror_server_id = 0"); + } + // Check if we have the service enabled. + if ($this->server_count[$service] == 0) { + return FALSE; + } + if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') return true; //* We do not check admin-users // simple query cache diff --git a/interface/web/mail/lib/module.conf.php b/interface/web/mail/lib/module.conf.php index cc100cd7d2..5a06eb8b65 100644 --- a/interface/web/mail/lib/module.conf.php +++ b/interface/web/mail/lib/module.conf.php @@ -150,31 +150,33 @@ if($app->auth->get_client_limit($userid, 'fetchmail') != 0) } //**** XMPP Menu -$items = array(); - -if($app->auth->get_client_limit($userid, 'xmpp_domain') != 0) -{ - $items[] = array( 'title' => 'XMPP Domain', - 'target' => 'content', - 'link' => 'mail/xmpp_domain_list.php', - 'html_id' => 'xmpp_domain_list'); +if ($app->system->has_service($userid, 'xmpp')) { + $items = array(); + + if($app->auth->get_client_limit($userid, 'xmpp_domain') != 0) + { + $items[] = array( 'title' => 'XMPP Domain', + 'target' => 'content', + 'link' => 'mail/xmpp_domain_list.php', + 'html_id' => 'xmpp_domain_list'); + } + + if($app->auth->get_client_limit($userid, 'xmpp_user') != 0) + { + $items[] = array( 'title' => 'XMPP Account', + 'target' => 'content', + 'link' => 'mail/xmpp_user_list.php', + 'html_id' => 'xmpp_user_list'); + } + + if(count($items)) + { + $module['nav'][] = array( 'title' => 'Jabber / XMPP', + 'open' => 1, + 'items' => $items); + } } -if($app->auth->get_client_limit($userid, 'xmpp_user') != 0) -{ - $items[] = array( 'title' => 'XMPP Account', - 'target' => 'content', - 'link' => 'mail/xmpp_user_list.php', - 'html_id' => 'xmpp_user_list'); -} - -if(count($items) && $app->system->has_service($userid, 'xmpp')) - $module['nav'][] = array( 'title' => 'Jabber / XMPP', - 'open' => 1, - 'items' => $items); - - - //**** Statistics menu $items = array(); -- GitLab From c8ac70ba7ccf3ba14eab6c9ad934808b5fdf9869 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Wed, 22 Jul 2020 15:04:44 +0200 Subject: [PATCH 2/2] space to tabs --- interface/lib/classes/system.inc.php | 22 ++++++------- interface/web/mail/lib/module.conf.php | 44 +++++++++++++------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/interface/lib/classes/system.inc.php b/interface/lib/classes/system.inc.php index a4e1d06550..484ef2b665 100644 --- a/interface/lib/classes/system.inc.php +++ b/interface/lib/classes/system.inc.php @@ -39,17 +39,17 @@ class system { if(!preg_match('/^[a-z]+$/', $service)) $app->error('Invalid service '.$service); - // Check the servers table to see which kinds of servers we actually have enabled. - // simple query cache - if($this->server_count===null) { - $this->server_count = $app->db->queryOneRecord("SELECT SUM(mail_server) as mail, SUM(web_server) AS web, SUM(dns_server) AS dns, SUM(file_server) AS file, - SUM(db_server) AS db, SUM(vserver_server) AS vserver, SUM(proxy_server) AS proxy, SUM(firewall_server) AS firewall, SUM(xmpp_server) AS xmpp - FROM `server` WHERE mirror_server_id = 0"); - } - // Check if we have the service enabled. - if ($this->server_count[$service] == 0) { - return FALSE; - } + // Check the servers table to see which kinds of servers we actually have enabled. + // simple query cache + if($this->server_count === null) { + $this->server_count = $app->db->queryOneRecord("SELECT SUM(mail_server) as mail, SUM(web_server) AS web, SUM(dns_server) AS dns, SUM(file_server) AS file, + SUM(db_server) AS db, SUM(vserver_server) AS vserver, SUM(proxy_server) AS proxy, SUM(firewall_server) AS firewall, SUM(xmpp_server) AS xmpp + FROM `server` WHERE mirror_server_id = 0"); + } + // Check if we have the service enabled. + if ($this->server_count[$service] == 0) { + return FALSE; + } if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') return true; //* We do not check admin-users diff --git a/interface/web/mail/lib/module.conf.php b/interface/web/mail/lib/module.conf.php index 5a06eb8b65..d9d97bc8b2 100644 --- a/interface/web/mail/lib/module.conf.php +++ b/interface/web/mail/lib/module.conf.php @@ -153,28 +153,28 @@ if($app->auth->get_client_limit($userid, 'fetchmail') != 0) if ($app->system->has_service($userid, 'xmpp')) { $items = array(); - if($app->auth->get_client_limit($userid, 'xmpp_domain') != 0) - { - $items[] = array( 'title' => 'XMPP Domain', - 'target' => 'content', - 'link' => 'mail/xmpp_domain_list.php', - 'html_id' => 'xmpp_domain_list'); - } - - if($app->auth->get_client_limit($userid, 'xmpp_user') != 0) - { - $items[] = array( 'title' => 'XMPP Account', - 'target' => 'content', - 'link' => 'mail/xmpp_user_list.php', - 'html_id' => 'xmpp_user_list'); - } - - if(count($items)) - { - $module['nav'][] = array( 'title' => 'Jabber / XMPP', - 'open' => 1, - 'items' => $items); - } + if($app->auth->get_client_limit($userid, 'xmpp_domain') != 0) + { + $items[] = array( 'title' => 'XMPP Domain', + 'target' => 'content', + 'link' => 'mail/xmpp_domain_list.php', + 'html_id' => 'xmpp_domain_list'); + } + + if($app->auth->get_client_limit($userid, 'xmpp_user') != 0) + { + $items[] = array( 'title' => 'XMPP Account', + 'target' => 'content', + 'link' => 'mail/xmpp_user_list.php', + 'html_id' => 'xmpp_user_list'); + } + + if(count($items)) + { + $module['nav'][] = array( 'title' => 'Jabber / XMPP', + 'open' => 1, + 'items' => $items); + } } //**** Statistics menu -- GitLab