Skip to content
Snippets Groups Projects
Commit a5326549 authored by Till Brehm's avatar Till Brehm
Browse files

Merge branch '6528-account-limit-incorrectly-informed-in-dashboard-ispconfig-3-2-10' into 'develop'

Resolve "Account limit incorrectly informed in dashboard - ISPConfig 3.2.10"

Closes #6528

See merge request ispconfig/ispconfig3!1771
parents 45ac1c93 224a5966
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class dashlet_databasequota { class dashlet_databasequota {
function show($limit_to_client_id = null) { function show() {
global $app; global $app;
//* Loading Template //* Loading Template
...@@ -23,30 +23,19 @@ class dashlet_databasequota { ...@@ -23,30 +23,19 @@ class dashlet_databasequota {
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng'; $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng';
if(is_file($lng_file)) include $lng_file; if(is_file($lng_file)) include $lng_file;
$tpl->setVar($wb); $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); //print_r($databases);
$has_databasequota = false; $has_databasequota = false;
$total_used = 0;
if(is_array($databases) && !empty($databases)){ if(is_array($databases) && !empty($databases)){
foreach ($databases as &$db) {
$total_used += $db['used_raw'] * 1000 * 1000;
}
$databases = $app->functions->htmlentities($databases); $databases = $app->functions->htmlentities($databases);
$tpl->setloop('databasequota', $databases); $tpl->setloop('databasequota', $databases);
$has_databasequota = isset($databases[0]['used']); $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();
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class dashlet_limits class dashlet_limits
{ {
public function show($limit_to_client_id = 0) public function show()
{ {
global $app, $conf; global $app, $conf;
...@@ -147,35 +147,33 @@ class dashlet_limits ...@@ -147,35 +147,33 @@ class dashlet_limits
} }
$tpl->setVar($wb); $tpl->setVar($wb);
if ($limit_to_client_id == 0) { if ($app->auth->is_admin()) {
$client_id = $_SESSION['s']['user']['client_id']; $user_is_admin = true;
$user_is_admin = true;
} else { } 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"]); if ($user_is_admin == false) {
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $client_id); $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(); $rows = array();
foreach ($limits as $limit) { foreach ($limits as $limit) {
$field = $limit['field']; $field = $limit['field'];
$value = $client[$field];
if ($user_is_admin) { if ($user_is_admin) {
$value = $wb['unlimited_txt']; $value = $wb['unlimited_txt'];
} else { } else {
$value = $client[$field]; $value = $client[$field];
} }
if ($value != 0 || $value == $wb['unlimited_txt']) { if ($value != 0 || $value == $wb['unlimited_txt']) {
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value;
if (isset($limit['q_type']) && $limit['q_type'] != '') { 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"; $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB";
} else { } 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)); $percentage = ($value == '-1' || intval($value) == 0 || trim($value) == '' ? -1 : round(100 * (int)$usage / (int)$value));
$progressbar = $percentage > 100 ? 100 : $percentage; $progressbar = $percentage > 100 ? 100 : $percentage;
...@@ -197,7 +195,7 @@ class dashlet_limits ...@@ -197,7 +195,7 @@ class dashlet_limits
return $tpl->grab(); return $tpl->grab();
} }
public function _get_limit_usage($limit, $limit_to_client_id) public function _get_limit_usage($limit)
{ {
global $app; global $app;
...@@ -205,15 +203,12 @@ class dashlet_limits ...@@ -205,15 +203,12 @@ class dashlet_limits
if ($limit['db_where'] != '') { if ($limit['db_where'] != '') {
$sql .= $limit['db_where']." AND "; $sql .= $limit['db_where']." AND ";
} }
$sql .= $app->tform->getAuthSQL('r', '', $limit_to_client_id); $sql .= $app->tform->getAuthSQL('r');
// TEST to show reseller data.
//$sql .= $app->tform->getAuthSQL('r', '', 0, '3,28,39');
//echo $sql;
$rec = $app->db->queryOneRecord($sql, $limit['db_table']); $rec = $app->db->queryOneRecord($sql, $limit['db_table']);
return $rec['number']; return $rec['number'];
} }
public function _get_assigned_quota($limit, $limit_to_client_id) public function _get_assigned_quota($limit)
{ {
global $app; global $app;
...@@ -221,7 +216,7 @@ class dashlet_limits ...@@ -221,7 +216,7 @@ class dashlet_limits
if ($limit['db_where'] != '') { if ($limit['db_where'] != '') {
$sql .= $limit['db_where']." AND "; $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']); $rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']);
if ($limit['db_table']=='mail_user') { if ($limit['db_table']=='mail_user') {
$quotaMB = $rec['number'] / 1048576; $quotaMB = $rec['number'] / 1048576;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class dashlet_mailquota { class dashlet_mailquota {
function show($limit_to_client_id = null) { function show() {
global $app; global $app;
//* Loading Template //* Loading Template
...@@ -16,33 +16,23 @@ class dashlet_mailquota { ...@@ -16,33 +16,23 @@ class dashlet_mailquota {
if(is_file($lng_file)) include $lng_file; if(is_file($lng_file)) include $lng_file;
$tpl->setVar($wb); $tpl->setVar($wb);
if ($_SESSION["s"]["user"]["typ"] != 'admin') { $emails = $app->quota_lib->get_mailquota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
$client_id = $_SESSION['s']['user']['client_id'];
} else {
$client_id = $limit_to_client_id;
}
$emails = $app->quota_lib->get_mailquota_data($client_id);
//print_r($emails); //print_r($emails);
$has_mailquota = false; $has_mailquota = false;
$total_used = 0;
if(is_array($emails) && !empty($emails)){ if(is_array($emails) && !empty($emails)){
foreach($emails as &$email) { foreach($emails as &$email) {
$email['email'] = $app->functions->idn_decode($email['email']); $email['email'] = $app->functions->idn_decode($email['email']);
$total_used += $email['used_raw'];
} }
unset($email); unset($email);
// email username is quoted in quota.lib already, so no htmlentities here to prevent double encoding // email username is quoted in quota.lib already, so no htmlentities here to prevent double encoding
//$emails = $app->functions->htmlentities($emails); //$emails = $app->functions->htmlentities($emails);
$tpl->setloop('mailquota', $emails); $tpl->setloop('mailquota', $emails);
$has_mailquota = isset($emails[0]['used']); $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();
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class dashlet_quota { class dashlet_quota {
function show($limit_to_client_id = null) { function show() {
global $app; global $app;
//* Loading Template //* Loading Template
...@@ -24,13 +24,7 @@ class dashlet_quota { ...@@ -24,13 +24,7 @@ class dashlet_quota {
if(is_file($lng_file)) include $lng_file; if(is_file($lng_file)) include $lng_file;
$tpl->setVar($wb); $tpl->setVar($wb);
if ($_SESSION["s"]["user"]["typ"] != 'admin') { $sites = $app->quota_lib->get_quota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
$client_id = $_SESSION['s']['user']['client_id'];
} else {
$client_id = $limit_to_client_id;
}
$sites = $app->quota_lib->get_quota_data($client_id);
//print_r($sites); //print_r($sites);
$has_quota = false; $has_quota = false;
...@@ -38,19 +32,18 @@ class dashlet_quota { ...@@ -38,19 +32,18 @@ class dashlet_quota {
foreach($sites as &$site) { foreach($sites as &$site) {
$site['domain'] = $app->functions->idn_decode($site['domain']); $site['domain'] = $app->functions->idn_decode($site['domain']);
$site['progressbar'] = $site['hd_quota']; $site['progressbar'] = $site['hd_quota'];
$total_used += $site['used_raw'] * 1000;
} }
unset($site); unset($site);
$sites = $app->functions->htmlentities($sites); $sites = $app->functions->htmlentities($sites);
$tpl->setloop('quota', $sites); $tpl->setloop('quota', $sites);
$has_quota = isset($sites[0]['used']); $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();
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment