From 0e3e3c99217c80068fe620460c7a331c34fe1b40 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Tue, 25 Feb 2014 09:29:50 -0500 Subject: [PATCH] Merge branch 'master' into 'master' --- interface/web/sites/database_edit.php | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php index 2249351..6ae8856 100644 --- a/interface/web/sites/database_edit.php +++ b/interface/web/sites/database_edit.php @@ -166,7 +166,7 @@ if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT db_servers, limit_database FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT db_servers, limit_database, limit_database_quota FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = $client_group_id"); // When the record is updated if($this->id > 0) { @@ -191,6 +191,20 @@ } } + // Check client quota + if ($client['limit_database_quota'] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT sum(database_quota) as db_quota FROM web_database WHERE sys_groupid = $client_group_id"); + $db_quota = $tmp['db_quota']; + $new_db_quota = $app->functions->intval($this->dataRecord["database_quota"]); + if(($db_quota + $new_db_quota > $client['limit_database_quota']) || ($new_db_quota < 0 && $client['limit_database_quota'] >= 0)) { + $max_free_quota = floor($client['limit_database_quota'] - $db_quota); + if($max_free_quota < 0) $max_free_quota = 0; + $app->tform->errorMessage .= $app->tform->lng("limit_database_quota_free_txt").": ".$max_free_quota." MB<br>"; + $this->dataRecord['database_quota'] = $max_free_quota; + } + unset($tmp); + } + } } else { // check if client of database parent domain is client of db user! -- Gitblit v1.9.1