From 4a5426596f30ca2c71357377fc7705766b2599b4 Mon Sep 17 00:00:00 2001 From: tbrehm Date: Wed, 28 Oct 2009 16:38:05 +0000 Subject: [PATCH] Implemented: FS#851 - Add client wide website quota (group quota) --- install/sql/ispconfig3.sql | 2 ++ interface/web/client/form/client.tform.php | 14 ++++++++++++++ .../web/client/form/client_template.tform.php | 14 ++++++++++++++ interface/web/client/form/reseller.tform.php | 14 ++++++++++++++ interface/web/client/lib/lang/en_client.lng | 1 + .../web/client/lib/lang/en_client_template.lng | 1 + interface/web/client/lib/lang/en_reseller.lng | 1 + .../web/client/templates/client_edit_limits.htm | 4 ++++ .../templates/client_template_edit_limits.htm | 4 ++++ .../client/templates/reseller_edit_limits.htm | 4 ++++ interface/web/sites/lib/lang/en_web_domain.lng | 1 + interface/web/sites/web_domain_edit.php | 17 ++++++++++++++++- 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index de421b7408..09384519c3 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -82,6 +82,7 @@ CREATE TABLE `client` ( `default_webserver` int(11) unsigned NOT NULL default '1', `limit_web_ip` text, `limit_web_domain` int(11) NOT NULL default '-1', + `limit_web_quota` int(11) NOT NULL default '-1', `web_php_options` varchar(255) NOT NULL default 'no,fast-cgi,cgi,mod,suphp', `limit_web_subdomain` int(11) NOT NULL default '-1', `limit_web_aliasdomain` int(11) NOT NULL default '-1', @@ -138,6 +139,7 @@ CREATE TABLE `client_template` ( `limit_spamfilter_policy` int(11) NOT NULL default '0', `limit_web_ip` text, `limit_web_domain` int(11) NOT NULL default '-1', + `limit_web_quota` int(11) NOT NULL default '-1', `limit_web_subdomain` int(11) NOT NULL default '-1', `limit_web_aliasdomain` int(11) NOT NULL default '-1', `limit_ftp_user` int(11) NOT NULL default '-1', diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 9a7b6e0884..cd599dfa1e 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -529,6 +529,20 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'limit_web_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'web_php_options' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOXARRAY', diff --git a/interface/web/client/form/client_template.tform.php b/interface/web/client/form/client_template.tform.php index e26f037e30..6f924501f3 100644 --- a/interface/web/client/form/client_template.tform.php +++ b/interface/web/client/form/client_template.tform.php @@ -297,6 +297,20 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'limit_web_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'limit_web_aliasdomain' => array ( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index d069e00ef8..a7c5ea6b08 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -515,6 +515,20 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'limit_web_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'web_php_options' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOXARRAY', diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index 4be403341d..4c0332cc6c 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -91,4 +91,5 @@ $wb["template_additional_txt"] = 'Addon template'; $wb["ssh_chroot_txt"] = 'SSH-Chroot Options'; $wb["web_php_options_txt"] = 'PHP Options'; $wb["limit_client_error"] = 'The max. number of clients is reached.'; +$wb["limit_web_quota_txt"] = 'Web Quota'; ?> diff --git a/interface/web/client/lib/lang/en_client_template.lng b/interface/web/client/lib/lang/en_client_template.lng index d403dfda50..f7299744a8 100644 --- a/interface/web/client/lib/lang/en_client_template.lng +++ b/interface/web/client/lib/lang/en_client_template.lng @@ -54,4 +54,5 @@ $wb["limit_database_error_notint"] = 'The database limit must be a number.'; $wb["limit_cron_error_notint"] = 'The cron limit must be a number.'; $wb["limit_cron_error_frequency"] = 'The cron frequency limit must be a number.'; $wb["error_template_name_empty"] = 'Please enter a Template name'; +$wb["limit_web_quota_txt"] = 'Web Quota'; ?> \ No newline at end of file diff --git a/interface/web/client/lib/lang/en_reseller.lng b/interface/web/client/lib/lang/en_reseller.lng index 906fd44bcb..e3e7e30704 100644 --- a/interface/web/client/lib/lang/en_reseller.lng +++ b/interface/web/client/lib/lang/en_reseller.lng @@ -90,4 +90,5 @@ $wb["ssh_chroot_txt"] = 'SSH-Chroot Options'; $wb["web_php_options_txt"] = 'PHP Options'; $wb["limit_client_error"] = 'The max. number of clients is reached.'; $wb["limit_client_error_positive"] = 'The number of clients must be > 0'; +$wb["limit_web_quota_txt"] = 'Web Quota'; ?> diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm index 2927ca4d08..1acad9d36d 100644 --- a/interface/web/client/templates/client_edit_limits.htm +++ b/interface/web/client/templates/client_edit_limits.htm @@ -103,6 +103,10 @@ +
+ +  MB +

{tmpl_var name='web_php_options_txt'}

diff --git a/interface/web/client/templates/client_template_edit_limits.htm b/interface/web/client/templates/client_template_edit_limits.htm index 81f2595425..8f5d3d2655 100644 --- a/interface/web/client/templates/client_template_edit_limits.htm +++ b/interface/web/client/templates/client_template_edit_limits.htm @@ -61,6 +61,10 @@
+
+ +  MB +
diff --git a/interface/web/client/templates/reseller_edit_limits.htm b/interface/web/client/templates/reseller_edit_limits.htm index 7e027e44e0..d413eb5dc7 100644 --- a/interface/web/client/templates/reseller_edit_limits.htm +++ b/interface/web/client/templates/reseller_edit_limits.htm @@ -88,6 +88,10 @@
+
+ +  MB +

{tmpl_var name='web_php_options_txt'}

diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index 109d8e7af4..ecda409b20 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -48,4 +48,5 @@ $wb['error_ssl_country_empty'] = 'SSL Country is empty.'; $wb["client_group_id_txt"] = 'Client'; $wb["stats_password_txt"] = 'Webstatistics password'; $wb["allow_override_txt"] = 'Allow Override'; +$wb["limit_web_quota_free_txt"] = 'Max. available Harddisk Quota'; ?> diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 51ce098591..93911c8de4 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -214,7 +214,22 @@ class page_action extends tform_actions { 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 limit_web_domain, default_webserver, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT limit_web_domain, default_webserver, parent_client_id, limit_web_quota FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + //* Check the website quota + if(isset($_POST["hd_quota"]) && $client["limit_web_quota"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND sys_groupid = $client_group_id"); + $webquota = $tmp["webquota"] / 1024 / 1024; + $new_web_quota = intval($this->dataRecord["hd_quota"]); + if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota == -1 && $client["limit_web_quota"] != -1)) { + $max_free_quota = floor($client["limit_web_quota"] - $webquota); + $app->tform->errorMessage .= $app->tform->lng("limit_web_quota_free_txt").": ".$max_free_quota."
"; + // Set the quota field to the max free space + $this->dataRecord["hd_quota"] = $max_free_quota; + } + unset($tmp); + unset($tmp_quota); + } // When the record is updated if($this->id > 0) { -- GitLab