Commit acdd2013 authored by tbrehm's avatar tbrehm

FS#1262 - client menu depending on limits

parent 7abfaee9
......@@ -29,6 +29,12 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class auth {
var $client_limits = null;
public function get_user_id()
{
return $_SESSION['s']['user']['userid'];
}
public function is_admin() {
if($_SESSION['s']['user']['typ'] == 'admin') {
......@@ -36,7 +42,7 @@ class auth {
} else {
return false;
}
}
}
public function has_clients($userid) {
global $app, $conf;
......@@ -69,6 +75,25 @@ class auth {
return false;
}
}
//** This function returns given client limit as integer, -1 means no limit
public function get_client_limit($userid, $limitname)
{
global $app;
// simple query cache
if($this->client_limits===null)
$this->client_limits = $app->db->queryOneRecord("SELECT client.* FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
// isn't client -> no limit
if(!$this->client_limits)
return -1;
if(isset($this->client_limits['limit_'.$limitname]))
return $this->client_limits['limit_'.$limitname];
else
trigger_error('Wrong limit identifier');
}
//** This function removes a given group id from a given user.
public function remove_group_from_user($userid,$groupid) {
......@@ -99,8 +124,7 @@ class auth {
exit;
}
}
}
?>
\ No newline at end of file
<?php
$userid=$app->auth->get_user_id();
$module['name'] = 'mail';
$module['title'] = 'top_menu_email';
$module['template'] = 'module.tpl.htm';
......@@ -10,60 +12,86 @@ $module['tab_width'] = '';
//**** Email accounts menu
$items = array();
$items[] = array( 'title' => 'Domain',
'target' => 'content',
'link' => 'mail/mail_domain_list.php',
'html_id' => 'mail_domain_list');
$items[] = array( 'title' => 'Domain Alias',
'target' => 'content',
'link' => 'mail/mail_aliasdomain_list.php',
'html_id' => 'mail_aliasdomain_list');
if($app->auth->get_client_limit($userid,'maildomain') != 0)
{
$items[] = array( 'title' => 'Domain',
'target' => 'content',
'link' => 'mail/mail_domain_list.php',
'html_id' => 'mail_domain_list');
}
if($app->auth->get_client_limit($userid,'mailaliasdomain') != 0)
{
$items[] = array( 'title' => 'Domain Alias',
'target' => 'content',
'link' => 'mail/mail_aliasdomain_list.php',
'html_id' => 'mail_aliasdomain_list');
}
$items[] = array( 'title' => 'Email Mailbox',
'target' => 'content',
'link' => 'mail/mail_user_list.php',
'html_id' => 'mail_user_list');
if($app->auth->get_client_limit($userid,'mailbox') != 0)
{
$items[] = array( 'title' => 'Email Mailbox',
'target' => 'content',
'link' => 'mail/mail_user_list.php',
'html_id' => 'mail_user_list');
}
$items[] = array( 'title' => 'Email Alias',
'target' => 'content',
'link' => 'mail/mail_alias_list.php',
'html_id' => 'mail_alias_list');
if($app->auth->get_client_limit($userid,'mailalias') != 0)
{
$items[] = array( 'title' => 'Email Alias',
'target' => 'content',
'link' => 'mail/mail_alias_list.php',
'html_id' => 'mail_alias_list');
}
$items[] = array( 'title' => 'Email Forward',
'target' => 'content',
'link' => 'mail/mail_forward_list.php',
'html_id' => 'mail_forward_list');
if($app->auth->get_client_limit($userid,'mailforward') != 0)
{
$items[] = array( 'title' => 'Email Forward',
'target' => 'content',
'link' => 'mail/mail_forward_list.php',
'html_id' => 'mail_forward_list');
}
$items[] = array( 'title' => 'Email Catchall',
'target' => 'content',
'link' => 'mail/mail_domain_catchall_list.php',
'html_id' => 'mail_domain_catchall_list');
if($app->auth->get_client_limit($userid,'mailcatchall') != 0)
{
$items[] = array( 'title' => 'Email Catchall',
'target' => 'content',
'link' => 'mail/mail_domain_catchall_list.php',
'html_id' => 'mail_domain_catchall_list');
}
$items[] = array( 'title' => 'Email Routing',
'target' => 'content',
'link' => 'mail/mail_transport_list.php',
'html_id' => 'mail_transport_list');
if($app->auth->get_client_limit($userid,'mailrouting') != 0)
{
$items[] = array( 'title' => 'Email Routing',
'target' => 'content',
'link' => 'mail/mail_transport_list.php',
'html_id' => 'mail_transport_list');
}
$module['nav'][] = array( 'title' => 'Email Accounts',
'open' => 1,
'items' => $items);
if(count($items))
{
$module['nav'][] = array( 'title' => 'Email Accounts',
'open' => 1,
'items' => $items);
}
//**** Spamfilter menu
$items = array();
$items[] = array( 'title' => 'Whitelist',
'target' => 'content',
'link' => 'mail/spamfilter_whitelist_list.php',
'html_id' => 'spamfilter_whitelist_list');
$items[] = array( 'title' => 'Blacklist',
'target' => 'content',
'link' => 'mail/spamfilter_blacklist_list.php',
'html_id' => 'spamfilter_blacklist_list');
if($app->auth->get_client_limit($userid,'spamfilter_wblist') != 0)
{
$items[] = array( 'title' => 'Whitelist',
'target' => 'content',
'link' => 'mail/spamfilter_whitelist_list.php',
'html_id' => 'spamfilter_whitelist_list');
$items[] = array( 'title' => 'Blacklist',
'target' => 'content',
'link' => 'mail/spamfilter_blacklist_list.php',
'html_id' => 'spamfilter_blacklist_list');
}
if($_SESSION['s']['user']['typ'] == 'admin') {
if($app->auth->is_admin()) {
$items[] = array( 'title' => 'User / Domain',
'target' => 'content',
......@@ -79,23 +107,30 @@ if($_SESSION['s']['user']['typ'] == 'admin') {
// 'target' => 'content',
// 'link' => 'mail/spamfilter_config_list.php');
}
$module['nav'][] = array( 'title' => 'Spamfilter',
'open' => 1,
'items' => $items);
if(count($items))
{
$module['nav'][] = array( 'title' => 'Spamfilter',
'open' => 1,
'items' => $items);
}
//**** Fetchmail menu
$items = array();
$items[] = array( 'title' => 'Fetchmail',
'target' => 'content',
'link' => 'mail/mail_get_list.php',
'html_id' => 'mail_get_list');
if($app->auth->get_client_limit($userid,'fetchmail') != 0)
{
$items[] = array( 'title' => 'Fetchmail',
'target' => 'content',
'link' => 'mail/mail_get_list.php',
'html_id' => 'mail_get_list');
$module['nav'][] = array( 'title' => 'Fetchmail',
'open' => 1,
'items' => $items);
}
$module['nav'][] = array( 'title' => 'Fetchmail',
'open' => 1,
'items' => $items);
//**** Statistics menu
$items = array();
......
<?php
$userid=$app->auth->get_user_id();
$module["name"] = "sites";
$module["title"] = "top_menu_sites";
$module["template"] = "module.tpl.htm";
......@@ -9,112 +11,127 @@ $module["tab_width"] = '';
/*
Websites menu
*/
$items=array();
if($app->auth->get_client_limit($userid,'web_domain') != 0)
{
$items[] = array( 'title' => "Website",
'target' => 'content',
'link' => 'sites/web_domain_list.php',
'html_id' => 'domain_list');
}
if($app->auth->get_client_limit($userid,'web_subdomain') != 0)
{
$items[] = array( 'title' => "Subdomain",
'target' => 'content',
'link' => 'sites/web_subdomain_list.php',
'html_id' => 'subdomain_list');
}
if($app->auth->get_client_limit($userid,'web_aliasdomain') != 0)
{
$items[] = array( 'title' => "Aliasdomain",
'target' => 'content',
'link' => 'sites/web_aliasdomain_list.php',
'html_id' => 'aliasdomain_list');
}
if(count($items))
{
$module["nav"][] = array( 'title' => 'Websites',
'open' => 1,
'items' => $items);
}
$items[] = array( 'title' => "Website",
'target' => 'content',
'link' => 'sites/web_domain_list.php',
'html_id' => 'domain_list');
$items[] = array( 'title' => "Subdomain",
'target' => 'content',
'link' => 'sites/web_subdomain_list.php',
'html_id' => 'subdomain_list');
$items[] = array( 'title' => "Aliasdomain",
'target' => 'content',
'link' => 'sites/web_aliasdomain_list.php',
'html_id' => 'aliasdomain_list');
$module["nav"][] = array( 'title' => 'Websites',
'open' => 1,
'items' => $items);
// clean up
unset($items);
/*
FTP User menu
*/
$items[] = array( 'title' => "FTP-User",
'target' => 'content',
'link' => 'sites/ftp_user_list.php',
'html_id' => 'ftp_user_list');
$module["nav"][] = array( 'title' => 'FTP',
'open' => 1,
'items' => $items);
// clean up
unset($items);
if($app->auth->get_client_limit($userid,'ftp_user') != 0)
{
$items=array();
$items[] = array( 'title' => "FTP-User",
'target' => 'content',
'link' => 'sites/ftp_user_list.php',
'html_id' => 'ftp_user_list');
$module["nav"][] = array( 'title' => 'FTP',
'open' => 1,
'items' => $items);
}
/*
Shell User menu
FTP User menu
*/
$items[] = array( 'title' => "Shell-User",
'target' => 'content',
'link' => 'sites/shell_user_list.php',
'html_id' => 'shell_user_list');
$module["nav"][] = array( 'title' => 'Shell',
'open' => 1,
'items' => $items);
// clean up
unset($items);
/*
* Webdav User menu
*/
$items[] = array( 'title' => "Webdav-User",
'target' => 'content',
'link' => 'sites/webdav_user_list.php',
'html_id' => 'webdav_user_list');
$module["nav"][] = array( 'title' => 'Webdav',
'open' => 1,
'items' => $items);
// clean up
unset($items);
if($app->auth->get_client_limit($userid,'shell_user') != 0)
{
$items=array();
$items[] = array( 'title' => "Shell-User",
'target' => 'content',
'link' => 'sites/shell_user_list.php',
'html_id' => 'shell_user_list');
$module["nav"][] = array( 'title' => 'Shell',
'open' => 1,
'items' => $items);
}
/*
Databases menu
*/
if($app->auth->get_client_limit($userid,'database') != 0)
{
$items=array();
$items[] = array( 'title' => "Database",
'target' => 'content',
'link' => 'sites/database_list.php',
'html_id' => 'database_list'
);
$module["nav"][] = array( 'title' => 'Database',
'open' => 1,
'items' => $items);
}
$items[] = array( 'title' => "Database",
'target' => 'content',
'link' => 'sites/database_list.php',
'html_id' => 'database_list');
$module["nav"][] = array( 'title' => 'Database',
'open' => 1,
'items' => $items);
/*
* Webdav User menu
*/
if($app->auth->get_client_limit($userid,'webdav_user') != 0)
{
$items=array();
$items[] = array( 'title' => "Webdav-User",
'target' => 'content',
'link' => 'sites/webdav_user_list.php',
'html_id' => 'webdav_user_list');
$module["nav"][] = array( 'title' => 'Webdav',
'open' => 1,
'items' => $items);
}
/*
Cron menu
*/
$items = array();
$items[] = array( 'title' => "Cron Jobs",
'target' => 'content',
'link' => 'sites/cron_list.php',
'html_id' => 'cron_list');
$module["nav"][] = array( 'title' => 'Cron',
'open' => 1,
'items' => $items);
if($app->auth->get_client_limit($userid,'cron') != 0)
{
$items = array();
$items[] = array( 'title' => "Cron Jobs",
'target' => 'content',
'link' => 'sites/cron_list.php',
'html_id' => 'cron_list');
$module["nav"][] = array( 'title' => 'Cron',
'open' => 1,
'items' => $items);
}
//**** Statistics menu
$items = array();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment