diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php index 5bb38be8545f757ef343dca1b621a3a838089dc7..4b06599d1caed608b06872e0fb289d77fe96c3f0 100644 --- a/interface/web/dashboard/dashlets/databasequota.php +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -2,7 +2,7 @@ class dashlet_databasequota { - function show($limit_to_client_id = null) { + function show() { global $app; //* Loading Template @@ -23,30 +23,19 @@ class dashlet_databasequota { $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng'; if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($_SESSION["s"]["user"]["typ"] != 'admin') { - $client_id = $_SESSION['s']['user']['client_id']; - } else { - $client_id = $limit_to_client_id; - } - $databases = $app->quota_lib->get_databasequota_data($client_id); + $databases = $app->quota_lib->get_databasequota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); //print_r($databases); $has_databasequota = false; - $total_used = 0; if(is_array($databases) && !empty($databases)){ - foreach ($databases as &$db) { - $total_used += $db['used_raw'] * 1000 * 1000; - } $databases = $app->functions->htmlentities($databases); $tpl->setloop('databasequota', $databases); $has_databasequota = isset($databases[0]['used']); - - $tpl->setVar('has_databasequota', $has_databasequota); - $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); - - return $tpl->grab(); } + $tpl->setVar('has_databasequota', $has_databasequota); + + return $tpl->grab(); } } diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index 79ac2126c831d93cfbaf2fd11edae1cb5f0d974f..50bcad91222b13b1405cd0e85ae336051af1fb0c 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -2,7 +2,7 @@ class dashlet_limits { - public function show($limit_to_client_id = 0) + public function show() { global $app, $conf; @@ -147,35 +147,33 @@ class dashlet_limits } $tpl->setVar($wb); - if ($limit_to_client_id == 0) { - $client_id = $_SESSION['s']['user']['client_id']; - $user_is_admin = true; + if ($app->auth->is_admin()) { + $user_is_admin = true; } else { - $client_id = $limit_to_client_id; - $user_is_admin = false; + $user_is_admin = false; } + $tpl->setVar('is_admin', $user_is_admin); - $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $client_id); - + if ($user_is_admin == false) { + $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); + $client = $app->db->queryOneRecord("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + } $rows = array(); foreach ($limits as $limit) { $field = $limit['field']; - $value = $client[$field]; if ($user_is_admin) { $value = $wb['unlimited_txt']; } else { $value = $client[$field]; } - if ($value != 0 || $value == $wb['unlimited_txt']) { $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; if (isset($limit['q_type']) && $limit['q_type'] != '') { - $usage = $this->_get_assigned_quota($limit, $client_id) . " MB"; + $usage = $this->_get_assigned_quota($limit) . " MB"; $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB"; } else { - $usage = $this->_get_limit_usage($limit, $client_id); + $usage = $this->_get_limit_usage($limit); } $percentage = ($value == '-1' || intval($value) == 0 || trim($value) == '' ? -1 : round(100 * (int)$usage / (int)$value)); $progressbar = $percentage > 100 ? 100 : $percentage; @@ -197,7 +195,7 @@ class dashlet_limits return $tpl->grab(); } - public function _get_limit_usage($limit, $limit_to_client_id) + public function _get_limit_usage($limit) { global $app; @@ -205,15 +203,12 @@ class dashlet_limits if ($limit['db_where'] != '') { $sql .= $limit['db_where']." AND "; } - $sql .= $app->tform->getAuthSQL('r', '', $limit_to_client_id); - // TEST to show reseller data. - //$sql .= $app->tform->getAuthSQL('r', '', 0, '3,28,39'); - //echo $sql; + $sql .= $app->tform->getAuthSQL('r'); $rec = $app->db->queryOneRecord($sql, $limit['db_table']); return $rec['number']; } - public function _get_assigned_quota($limit, $limit_to_client_id) + public function _get_assigned_quota($limit) { global $app; @@ -221,7 +216,7 @@ class dashlet_limits if ($limit['db_where'] != '') { $sql .= $limit['db_where']." AND "; } - $sql .= $app->tform->getAuthSQL('r', '', $limit_to_client_id); + $sql .= $app->tform->getAuthSQL('r'); $rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']); if ($limit['db_table']=='mail_user') { $quotaMB = $rec['number'] / 1048576; diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php index f097005d7f35dc494a63d5c999faeec093639f7a..a9434e58eaac846087c77738d9d131ebe4d51abe 100644 --- a/interface/web/dashboard/dashlets/mailquota.php +++ b/interface/web/dashboard/dashlets/mailquota.php @@ -2,7 +2,7 @@ class dashlet_mailquota { - function show($limit_to_client_id = null) { + function show() { global $app; //* Loading Template @@ -16,33 +16,23 @@ class dashlet_mailquota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($_SESSION["s"]["user"]["typ"] != 'admin') { - $client_id = $_SESSION['s']['user']['client_id']; - } else { - $client_id = $limit_to_client_id; - } - - $emails = $app->quota_lib->get_mailquota_data($client_id); + $emails = $app->quota_lib->get_mailquota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); //print_r($emails); $has_mailquota = false; - $total_used = 0; if(is_array($emails) && !empty($emails)){ foreach($emails as &$email) { $email['email'] = $app->functions->idn_decode($email['email']); - $total_used += $email['used_raw']; } unset($email); // email username is quoted in quota.lib already, so no htmlentities here to prevent double encoding //$emails = $app->functions->htmlentities($emails); $tpl->setloop('mailquota', $emails); $has_mailquota = isset($emails[0]['used']); - - $tpl->setVar('has_mailquota', $has_mailquota); - $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); - - return $tpl->grab(); } + $tpl->setVar('has_mailquota', $has_mailquota); + + return $tpl->grab(); } } diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index a70a1bf25376efd8607e0a5824a88590e8804213..d0b1be998f7e44f304a4bae9a7aa6b2c296740a7 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -2,7 +2,7 @@ class dashlet_quota { - function show($limit_to_client_id = null) { + function show() { global $app; //* Loading Template @@ -24,13 +24,7 @@ class dashlet_quota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($_SESSION["s"]["user"]["typ"] != 'admin') { - $client_id = $_SESSION['s']['user']['client_id']; - } else { - $client_id = $limit_to_client_id; - } - - $sites = $app->quota_lib->get_quota_data($client_id); + $sites = $app->quota_lib->get_quota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); //print_r($sites); $has_quota = false; @@ -38,19 +32,18 @@ class dashlet_quota { foreach($sites as &$site) { $site['domain'] = $app->functions->idn_decode($site['domain']); $site['progressbar'] = $site['hd_quota']; - $total_used += $site['used_raw'] * 1000; } unset($site); $sites = $app->functions->htmlentities($sites); $tpl->setloop('quota', $sites); $has_quota = isset($sites[0]['used']); + } + $tpl->setVar('has_quota', $has_quota); + + return $tpl->grab(); - $tpl->setVar('has_quota', $has_quota); - $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); - return $tpl->grab(); - } } }