diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php index 3a4cc1603cca1972f8711c7e09ff19f7c53cc8f9..a8f1f966a788f394ec1c355c4fe21dbf08a94fe3 100644 --- a/interface/lib/classes/auth.inc.php +++ b/interface/lib/classes/auth.inc.php @@ -53,6 +53,13 @@ class auth { } } + public function is_reseller() { + if($this->has_clients($_SESSION['s']['user']['userid'])) { + return true; + } else { + return false; + } + } public function has_clients($userid) { global $app, $conf; diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 629da2fb0e21ad9ecc9dc92f99e29f1665d908c7..f78fb8ad8ecd681e0d7a78a0519f8c1b92b19045 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -287,11 +287,33 @@ class functions { * @return string - formated bytes */ public function formatBytes($size, $precision = 2) { + // 0 is a special as it would give NAN otehrwise. + if ($size == 0) { + return 0; + } + $base=log($size)/log(1024); $suffixes=array('', ' kB', ' MB', ' GB', ' TB'); return round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)]; } + /** + * Function to change bytes to kB, MB, GB or TB or the translated string 'Unlimited' for -1 + * @param int $size - size in bytes + * @param int precicion - after-comma-numbers (default: 2) + * @return string - formated bytes + */ + public function formatBytesOrUnlimited($size, $precision = 2) { + global $app; + + if ($size == -1) { + return $app->lng('unlimited_txt'); + } + else { + return $this->formatBytes($size, $precision); + } + + } /** * Normalize a path and strip duplicate slashes from it @@ -652,6 +674,22 @@ class functions { return $result; } + /** + * Lookup a client's group + all groups he is reselling. + * + * @return string Comma separated list of groupid's + */ + function clientid_to_groups_list($client_id) { + global $app; + + if ($client_id != null) { + // Get the clients groupid, and incase it's a reseller the groupid's of it's clients. + $group = $app->db->queryOneRecord("SELECT GROUP_CONCAT(groupid) AS groups FROM `sys_group` WHERE client_id IN (SELECT client_id FROM `client` WHERE client_id=? OR parent_client_id=?)", $client_id, $client_id); + return $group['groups']; + } + return null; + } + } ?> diff --git a/interface/lib/classes/quota_lib.inc.php b/interface/lib/classes/quota_lib.inc.php index 7c5b388536ec9d0a672d9a3e283d2a5d6b7adc97..1807a18685579c75b76125288018a9b500c2d0cb 100644 --- a/interface/lib/classes/quota_lib.inc.php +++ b/interface/lib/classes/quota_lib.inc.php @@ -14,7 +14,10 @@ class quota_lib { //print_r($monitor_data); // select all websites or websites belonging to client - $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".(($clientid != null)?" AND sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)":'') . " ORDER BY domain", $clientid); + $q = "SELECT * FROM web_domain WHERE type = 'vhost' AND "; + $q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid)); + $q .= " ORDER BY domain"; + $sites = $app->db->queryAllRecords($q, $clientid); //print_r($sites); if(is_array($sites) && !empty($sites)){ @@ -36,9 +39,10 @@ class quota_lib { if (!is_numeric($sites[$i]['hard'])) $sites[$i]['hard']=$sites[$i]['hard'][1]; if (!is_numeric($sites[$i]['files'])) $sites[$i]['files']=$sites[$i]['files'][1]; - $sites[$i]['used_raw'] = $sites[$i]['used']; - $sites[$i]['soft_raw'] = $sites[$i]['soft']; - $sites[$i]['hard_raw'] = $sites[$i]['hard']; + // Convert from kb to bytes, and use -1 for instead of 0 for Unlimited. + $sites[$i]['used_raw'] = $sites[$i]['used'] * 1024; + $sites[$i]['soft_raw'] = ($sites[$i]['soft'] > 0) ? $sites[$i]['soft'] * 1024 : -1; + $sites[$i]['hard_raw'] = ($sites[$i]['hard'] > 0) ? $sites[$i]['hard'] * 1024 : -1; $sites[$i]['files_raw'] = $sites[$i]['files']; $sites[$i]['used_percentage'] = ($sites[$i]['soft'] > 0 && $sites[$i]['used'] > 0 ? round($sites[$i]['used'] * 100 / $sites[$i]['soft']) : 0); @@ -53,29 +57,6 @@ class quota_lib { if($used_ratio >= 0.8) $sites[$i]['display_colour'] = '#fd934f'; if($used_ratio >= 1) $sites[$i]['display_colour'] = '#cc0000'; - if($sites[$i]['used'] > 1024) { - $sites[$i]['used'] = round($sites[$i]['used'] / 1024, 1).' MB'; - } else { - if ($sites[$i]['used'] != '') $sites[$i]['used'] .= ' KB'; - } - - if($sites[$i]['soft'] > 1024) { - $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024, 1).' MB'; - } else { - $sites[$i]['soft'] .= ' KB'; - } - - if($sites[$i]['hard'] > 1024) { - $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024, 1).' MB'; - } else { - $sites[$i]['hard'] .= ' KB'; - } - - if($sites[$i]['soft'] == " KB") $sites[$i]['soft'] = $app->lng('unlimited_txt'); - if($sites[$i]['hard'] == " KB") $sites[$i]['hard'] = $app->lng('unlimited_txt'); - - if($sites[$i]['soft'] == '0 B' || $sites[$i]['soft'] == '0 KB' || $sites[$i]['soft'] == '0') $sites[$i]['soft'] = $app->lng('unlimited_txt'); - if($sites[$i]['hard'] == '0 B' || $sites[$i]['hard'] == '0 KB' || $sites[$i]['hard'] == '0') $sites[$i]['hard'] = $app->lng('unlimited_txt'); /* if(!strstr($sites[$i]['used'],'M') && !strstr($sites[$i]['used'],'K')) $sites[$i]['used'].= ' B'; @@ -83,13 +64,7 @@ class quota_lib { if(!strstr($sites[$i]['hard'],'M') && !strstr($sites[$i]['hard'],'K')) $sites[$i]['hard'].= ' B'; */ } - else { - if (empty($sites[$i]['soft'])) $sites[$i]['soft'] = -1; - if (empty($sites[$i]['hard'])) $sites[$i]['hard'] = -1; - if($sites[$i]['soft'] == '0 B' || $sites[$i]['soft'] == '0 KB' || $sites[$i]['soft'] == '0') $sites[$i]['soft'] = -1; - if($sites[$i]['hard'] == '0 B' || $sites[$i]['hard'] == '0 KB' || $sites[$i]['hard'] == '0') $sites[$i]['hard'] = -1; - } } } @@ -237,7 +212,10 @@ class quota_lib { //print_r($monitor_data); // select all email accounts or email accounts belonging to client - $emails = $app->db->queryAllRecords("SELECT * FROM mail_user".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : '') . " ORDER BY email", $clientid); + $q = "SELECT * FROM mail_user WHERE"; + $q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid)); + $q .= " ORDER BY email"; + $emails = $app->db->queryAllRecords($q, $clientid); //print_r($emails); if(is_array($emails) && !empty($emails)) { @@ -265,17 +243,8 @@ class quota_lib { if($used_ratio >= 0.8) $emails[$i]['display_colour'] = '#fd934f'; if($used_ratio >= 1) $emails[$i]['display_colour'] = '#cc0000'; - if($emails[$i]['quota'] == 0){ - $emails[$i]['quota'] = $app->lng('unlimited_txt'); - } else { - $emails[$i]['quota'] = round($emails[$i]['quota'] / 1048576, 1).' MB'; - } - - - if($emails[$i]['used'] < 1544000) { - $emails[$i]['used'] = round($emails[$i]['used'] / 1024, 1).' KB'; - } else { - $emails[$i]['used'] = round($emails[$i]['used'] / 1048576, 1).' MB'; + if($emails[$i]['quota'] == 0) { + $emails[$i]['quota'] = -1; } } } @@ -302,18 +271,21 @@ class quota_lib { //print_r($monitor_data); // select all databases belonging to client - $databases = $app->db->queryAllRecords("SELECT * FROM web_database".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : '') . " ORDER BY database_name", $clientid); + $q = "SELECT * FROM web_database WHERE"; + $q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid)); + $q .= " ORDER BY database_name"; + $databases = $app->db->queryAllRecords($q); //print_r($databases); if(is_array($databases) && !empty($databases)){ for($i=0;$i 0) && ($databases[$i]['used'] > 0)) ? round($databases[$i]['used_raw'] * 100 / $databases[$i]['database_quota']) : 0; + $databases[$i]['database_quota_raw'] = ($databases[$i]['database_quota'] == -1) ? -1 : $databases[$i]['database_quota'] * 1000 * 1000; + $databases[$i]['used_raw'] = $size; // / 1024 / 1024; //* quota is stored as MB - calculated bytes + $databases[$i]['used_percentage'] = (($databases[$i]['database_quota'] > 0) && ($size > 0)) ? round($databases[$i]['used_raw'] * 100 / $databases[$i]['database_quota_raw']) : 0; if ($readable) { // colours @@ -326,18 +298,8 @@ class quota_lib { if($used_ratio >= 0.8) $databases[$i]['display_colour'] = '#fd934f'; if($used_ratio >= 1) $databases[$i]['display_colour'] = '#cc0000'; - if($databases[$i]['database_quota'] == -1) { - $databases[$i]['database_quota'] = $app->lng('unlimited_txt'); - } else { - $databases[$i]['database_quota'] = $databases[$i]['database_quota'] . ' MB'; - } - if($databases[$i]['used'] < 1544000) { - $databases[$i]['used'] = round($databases[$i]['used'] / 1024, 1).' KB'; - } else { - $databases[$i]['used'] = round($databases[$i]['used'] / 1048576, 1).' MB'; - } } } } diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index 823a9ed3f63f81b67172bff54e4c019c3264666e..7a510a6873b0b87e181f0f016f43856ad4a760c0 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -82,7 +82,7 @@ class page_action extends tform_actions { chdir('../dashboard'); $dashlet_list = array(); - $dashlets = array('databasequota.php', 'limits.php', 'mailquota.php', 'quota.php'); + $dashlets = array('quota.php', 'databasequota.php', 'mailquota.php', 'limits.php'); $current_client_id = $this->id; foreach ($dashlets as $file) { diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index d48dea62299ca28d4b82c3fc65c337dd87b693c9..6d5267bd08b7dbabb47b7026f21d77721978a656 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -45,7 +45,7 @@ $form["action"] = "reseller_edit.php"; $form["db_table"] = "client"; $form["db_table_idx"] = "client_id"; $form["db_history"] = "yes"; -$form["tab_default"] = "address"; +$form["tab_default"] = "info"; $form["list_default"] = "reseller_list.php"; $form["auth"] = 'yes'; @@ -80,6 +80,12 @@ while ($file = @readdir($handle)) { } } +$form["tabs"]['info'] = array( + 'title' => "Info", + 'width' => 100, + 'template' => "templates/reseller_edit_info.htm", + 'fields' => array() +); $form["tabs"]['address'] = array ( 'title' => "Address", 'width' => 100, diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php index 10da3b78e152a20b8c4dd973790f42d2f4e6b80c..4dc89293f9cd91713e137e562e32e61f6bcfb12d 100644 --- a/interface/web/client/reseller_edit.php +++ b/interface/web/client/reseller_edit.php @@ -72,10 +72,45 @@ class page_action extends tform_actions { } } + // Hide the info tab when creating a new client. + unset($app->tform->formDef["tabs"]['info']); + $app->tform->formDef["tab_default"] = "address"; + parent::onShowNew(); } + function onShowEdit() { + global $app, $conf; + chdir('../dashboard'); + + $dashlet_list = array(); + $dashlets = array('quota.php', 'databasequota.php', 'mailquota.php', 'limits.php'); + $current_client_id = $this->id; + + foreach ($dashlets as $file) { + if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) { + $dashlet_name = substr($file, 0, -4); + $dashlet_class = 'dashlet_'.$dashlet_name; + include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; + $dashlet_list[$dashlet_name] = new $dashlet_class; + $dashlets_html .= $dashlet_list[$dashlet_name]->show($current_client_id); + } + } + $app->tpl->setVar('dashlets', $dashlets_html); + + chdir('../client'); + + $tmp = $app->db->queryOneRecord("SELECT company_name, contact_firstname, contact_name, email FROM client WHERE client_id = ?", $current_client_id); + + $app->tpl->setVar('company_name', $tmp['company_name']); + $app->tpl->setVar('contact_name', $tmp['contact_name']); + $app->tpl->setVar('email', $tmp['email']); + + parent::onShowEdit(); + } + + function onSubmit() { global $app, $conf; diff --git a/interface/web/client/templates/reseller_edit_info.htm b/interface/web/client/templates/reseller_edit_info.htm new file mode 100644 index 0000000000000000000000000000000000000000..26e9258d6d64a6cb92ffdd90204984ef418ed259 --- /dev/null +++ b/interface/web/client/templates/reseller_edit_info.htm @@ -0,0 +1,24 @@ + + + + diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php index d8adccd15eb9ba3e82783411a499084ebbf5f474..a78ade4e7c58f644e5bbfbb1d53e66a9e44123d1 100644 --- a/interface/web/dashboard/dashboard.php +++ b/interface/web/dashboard/dashboard.php @@ -214,12 +214,18 @@ if($app->auth->is_admin()) { } } +if ($app->auth->is_admin() || $app->auth->is_reseller()) { + $limit_to_client_id = null; +} +else { + $limit_to_client_id = $_SESSION['s']['user']['client_id']; +} /* Fill the left column */ $leftcol = array(); foreach($leftcol_dashlets as $name) { if(isset($dashlet_list[$name])) { - $leftcol[]['content'] = $dashlet_list[$name]->show(); + $leftcol[]['content'] = $dashlet_list[$name]->show($limit_to_client_id); } } $app->tpl->setloop('leftcol', $leftcol); @@ -228,7 +234,7 @@ $app->tpl->setloop('leftcol', $leftcol); $rightcol = array(); foreach($rightcol_dashlets as $name) { if(isset($dashlet_list[$name])) { - $rightcol[]['content'] = $dashlet_list[$name]->show(); + $rightcol[]['content'] = $dashlet_list[$name]->show($limit_to_client_id); } } $app->tpl->setloop('rightcol', $rightcol); diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php index 4b06599d1caed608b06872e0fb289d77fe96c3f0..2c488e37a6620d2fcce01372ea067ed4551e33d0 100644 --- a/interface/web/dashboard/dashlets/databasequota.php +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -2,7 +2,7 @@ class dashlet_databasequota { - function show() { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -24,27 +24,22 @@ class dashlet_databasequota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - $databases = $app->quota_lib->get_databasequota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); + $databases = $app->quota_lib->get_databasequota_data($limit_to_client_id); //print_r($databases); - $has_databasequota = false; + $total_used = 0; if(is_array($databases) && !empty($databases)){ + foreach ($databases as &$db) { + $db['used'] = $app->functions->formatBytes($db['used_raw'], 0); + $db['database_quota'] = $app->functions->formatBytesOrUnlimited($db['database_quota_raw'], 0); + + $total_used += $db['used_raw']; + } $databases = $app->functions->htmlentities($databases); $tpl->setloop('databasequota', $databases); - $has_databasequota = isset($databases[0]['used']); + $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 2251fd80c299193c5bdfcb17f76983df03a084e1..80fa632d898d999c19eef281ab707afe06012f57 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() + public function show($limit_to_client_id = 0) { global $app, $conf; @@ -147,36 +147,35 @@ class dashlet_limits } $tpl->setVar($wb); - if ($app->auth->is_admin()) { - $user_is_admin = true; - } else { - $user_is_admin = false; + if ($limit_to_client_id != null) { + $client_id = $limit_to_client_id; } - $tpl->setVar('is_admin', $user_is_admin); - - 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); + elseif ($limit_to_client_id == null && $app->auth->is_reseller()) { + $client_id = $_SESSION['s']['user']['client_id']; } + $client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $client_id); $rows = array(); foreach ($limits as $limit) { $field = $limit['field']; - if ($user_is_admin) { - $value = $wb['unlimited_txt']; + $value = $client[$field]; + if ($app->auth->is_admin() && $limit_to_client_id == 0) { + $value = -1; } else { $value = $client[$field]; } + if ($value != 0 || $value == $wb['unlimited_txt']) { - $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; + $suffix = ''; if (isset($limit['q_type']) && $limit['q_type'] != '') { - $usage = $this->_get_assigned_quota($limit) . " MB"; - $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB"; + $usage = $this->_get_assigned_quota($limit, $client_id); + $suffix = ' MB'; } else { - $usage = $this->_get_limit_usage($limit); + $usage = $this->_get_limit_usage($limit, $client_id); } $percentage = ($value == '-1' || intval($value) == 0 || trim($value) == '' ? -1 : round(100 * (int)$usage / (int)$value)); $progressbar = $percentage > 100 ? 100 : $percentage; + $value_formatted = ($value == '-1') ? $wb['unlimited_txt'] : ($value . $suffix); $rows[] = array('field' => $field, 'field_txt' => $wb[$field.'_txt'], 'value' => $value_formatted, @@ -195,7 +194,7 @@ class dashlet_limits return $tpl->grab(); } - public function _get_limit_usage($limit) + public function _get_limit_usage($limit, $limit_to_client_id) { global $app; @@ -203,12 +202,13 @@ class dashlet_limits if ($limit['db_where'] != '') { $sql .= $limit['db_where']." AND "; } - $sql .= $app->tform->getAuthSQL('r'); + $sql .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($limit_to_client_id)); + $rec = $app->db->queryOneRecord($sql, $limit['db_table']); return $rec['number']; } - - public function _get_assigned_quota($limit) + + public function _get_assigned_quota($limit, $limit_to_client_id) { global $app; @@ -216,14 +216,30 @@ class dashlet_limits if ($limit['db_where'] != '') { $sql .= $limit['db_where']." AND "; } - $sql .= $app->tform->getAuthSQL('r'); + $sql .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($limit_to_client_id)); $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; } // Mail quota is in bytes, must be converted to MB else { $quotaMB = $app->functions->intval($rec['number']); - } - return $quotaMB; + } + return $quotaMB; + } + + /** + * Lookup a client's group + all groups he is reselling. + * + * @return string Comma separated list of groupid's + */ + function clientid_to_groups_list($client_id) { + global $app; + + if ($client_id != null) { + // Get the clients groupid, and incase it's a reseller the groupid's of it's clients. + $group = $app->db->queryOneRecord("SELECT GROUP_CONCAT(groupid) AS groups FROM `sys_group` WHERE client_id IN (SELECT client_id FROM `client` WHERE client_id=? OR parent_client_id=?)", $client_id, $client_id); + return $group['groups']; + } + return null; } } diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php index a9434e58eaac846087c77738d9d131ebe4d51abe..88cee26e33d37c26f3fd3db1267540d3573420d7 100644 --- a/interface/web/dashboard/dashlets/mailquota.php +++ b/interface/web/dashboard/dashlets/mailquota.php @@ -2,7 +2,7 @@ class dashlet_mailquota { - function show() { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -16,32 +16,34 @@ class dashlet_mailquota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - $emails = $app->quota_lib->get_mailquota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); + + $emails = $app->quota_lib->get_mailquota_data($limit_to_client_id); //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']); + $email['used'] = $app->functions->formatBytes($email['used_raw'], 0); + // Mail is the exception with 0 == unlimited, instead of -1 + if ($email['quota_raw'] == 0) { + $email['quota_raw'] = -1; + } + + $email['quota'] = $app->functions->formatBytesOrUnlimited($email['quota_raw'], 0); + $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); - return $tpl->grab(); - } + $tpl->setVar('has_mailquota', $has_mailquota); + $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); + return $tpl->grab(); + } + } } - - - - - - - - -?> diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index d0b1be998f7e44f304a4bae9a7aa6b2c296740a7..ce8ee91c75d6cfe969233ee90a8d15a24a139abb 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -2,7 +2,7 @@ class dashlet_quota { - function show() { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -24,35 +24,28 @@ class dashlet_quota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - $sites = $app->quota_lib->get_quota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); - //print_r($sites); + $sites = $app->quota_lib->get_quota_data($limit_to_client_id); $has_quota = false; if(is_array($sites) && !empty($sites)){ foreach($sites as &$site) { $site['domain'] = $app->functions->idn_decode($site['domain']); $site['progressbar'] = $site['hd_quota']; + $site['used'] = $app->functions->formatBytes($site['used_raw'], 0); + $site['hard'] = $app->functions->formatBytesOrUnlimited($site['hard_raw'], 0); + $site['soft'] = $app->functions->formatBytesOrUnlimited($site['soft_raw'], 0); + $total_used += $site['used_raw']; } 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(); + } } - } - - - - - - - - -?> diff --git a/interface/web/dashboard/dashlets/templates/databasequota.htm b/interface/web/dashboard/dashlets/templates/databasequota.htm index 2676b65b35e60bb8d9bef319c551e74dd8959522..5874c4b20afec343afaa034ac1d0f02036807275 100644 --- a/interface/web/dashboard/dashlets/templates/databasequota.htm +++ b/interface/web/dashboard/dashlets/templates/databasequota.htm @@ -14,7 +14,7 @@ {tmpl_var name='database_name'} {tmpl_var name='used'} {tmpl_var name='database_quota'} - {tmpl_if name="quota_raw" op="!=" value="-1"} + {tmpl_if name="database_quota_raw" op="!=" value="-1"}
{tmpl_var name="used_percentage"}% {tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='database_quota'}