Commit 4a542659 authored by tbrehm's avatar tbrehm

Implemented: FS#851 - Add client wide website quota (group quota)

parent 1d8123a2
......@@ -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',
......
......@@ -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',
......
......@@ -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',
......
......@@ -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',
......
......@@ -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';
?>
......@@ -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
......@@ -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';
?>
......@@ -103,6 +103,10 @@
<label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
<input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
<input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='web_php_options_txt'}</p>
<div class="multiField">
......
......@@ -61,6 +61,10 @@
<label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
<input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
<input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
<input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
......
......@@ -88,6 +88,10 @@
<label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
<input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
<input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='web_php_options_txt'}</p>
<div class="multiField">
......
......@@ -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';
?>
......@@ -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."<br>";
// 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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment