diff --git a/install/sql/incremental/upd_0017.sql b/install/sql/incremental/upd_0017.sql
new file mode 100644
index 0000000000000000000000000000000000000000..07a4d78905d34b3556ace4f7103a4579efdb1c7f
--- /dev/null
+++ b/install/sql/incremental/upd_0017.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `client_template` ADD `limit_openvz_vm` int(11) NOT NULL DEFAULT '0' AFTER `limit_mailmailinglist` ,
+ADD `limit_openvz_vm_template_id` int(11) NOT NULL DEFAULT '0' AFTER `limit_openvz_vm`;
\ No newline at end of file
diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php
index eb61dc9db885576350dc024808aae57548b39283..7b64147b79d33c99796978b60320d29e5e8c28a2 100644
--- a/interface/web/client/form/client.tform.php
+++ b/interface/web/client/form/client.tform.php
@@ -827,6 +827,31 @@ $form["tabs"]['limits'] = array (
'rows' => '',
'cols' => ''
),
+ 'limit_openvz_vm' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'TEXT',
+ 'validators' => array ( 0 => array ( 'type' => 'ISINT',
+ 'errmsg'=> 'limit_openvz_vm_error_notint'),
+ ),
+ 'default' => '0',
+ 'value' => '',
+ 'separator' => '',
+ 'width' => '10',
+ 'maxlength' => '10',
+ 'rows' => '',
+ 'cols' => ''
+ ),
+ 'limit_openvz_vm_template_id' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'SELECT',
+ 'default' => '',
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
+ 'keyfield'=> 'template_id',
+ 'valuefield'=> 'template_name'
+ ),
+ 'value' => array(0 => ' ')
+ ),
##################################
# END Datatable fields
##################################
diff --git a/interface/web/client/form/client_template.tform.php b/interface/web/client/form/client_template.tform.php
index 628def1a6989cfa5a797b342136b8103c5abc63d..d38fdd55207347b4d2a191340eb3faa5f8bbb580 100644
--- a/interface/web/client/form/client_template.tform.php
+++ b/interface/web/client/form/client_template.tform.php
@@ -515,6 +515,31 @@ $form["tabs"]['limits'] = array (
'rows' => '',
'cols' => ''
),
+ 'limit_openvz_vm' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'TEXT',
+ 'validators' => array ( 0 => array ( 'type' => 'ISINT',
+ 'errmsg'=> 'limit_openvz_vm_error_notint'),
+ ),
+ 'default' => '0',
+ 'value' => '',
+ 'separator' => '',
+ 'width' => '10',
+ 'maxlength' => '10',
+ 'rows' => '',
+ 'cols' => ''
+ ),
+ 'limit_openvz_vm_template_id' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'SELECT',
+ 'default' => '',
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
+ 'keyfield'=> 'template_id',
+ 'valuefield'=> 'template_name'
+ ),
+ 'value' => array(0 => ' ')
+ ),
##################################
# END Datatable fields
##################################
diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php
index 715a892edade7cfb4b147db197049bc201d2bbc0..a402bc7cf9c10d23ad656838594d8111d851f1e8 100644
--- a/interface/web/client/form/reseller.tform.php
+++ b/interface/web/client/form/reseller.tform.php
@@ -817,6 +817,31 @@ $form["tabs"]['limits'] = array (
'rows' => '',
'cols' => ''
),
+ 'limit_openvz_vm' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'TEXT',
+ 'validators' => array ( 0 => array ( 'type' => 'ISINT',
+ 'errmsg'=> 'limit_openvz_vm_error_notint'),
+ ),
+ 'default' => '0',
+ 'value' => '',
+ 'separator' => '',
+ 'width' => '10',
+ 'maxlength' => '10',
+ 'rows' => '',
+ 'cols' => ''
+ ),
+ 'limit_openvz_vm_template_id' => array (
+ 'datatype' => 'INTEGER',
+ 'formtype' => 'SELECT',
+ 'default' => '',
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
+ 'keyfield'=> 'template_id',
+ 'valuefield'=> 'template_name'
+ ),
+ 'value' => array(0 => ' ')
+ ),
##################################
# END Datatable fields
##################################
diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng
index 8ce69611875c98aa2371a5e510126a5bf935c76d..36d3da2375bba3489116960aaf5f5caa7122e341 100644
--- a/interface/web/client/lib/lang/en_client.lng
+++ b/interface/web/client/lib/lang/en_client.lng
@@ -104,4 +104,7 @@ $wb["customer_no_txt"] = 'Customer No.';
$wb["vat_id_txt"] = 'VAT ID';
$wb["required_fields_txt"] = '* Required fields';
$wb['company_id_txt'] = 'Company/Entrepreneur ID';
+$wb["limit_openvz_vm_txt"] = 'Max. number of virtual servers';
+$wb["limit_openvz_vm_template_id_txt"] = 'Force virtual server template';
+$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
?>
diff --git a/interface/web/client/lib/lang/en_client_template.lng b/interface/web/client/lib/lang/en_client_template.lng
index 3ad34449e604faca62a2ded2522385d106cb43f3..c6d99770ecb97fbb82dc2dd7fcbcc0f01bb2df6c 100644
--- a/interface/web/client/lib/lang/en_client_template.lng
+++ b/interface/web/client/lib/lang/en_client_template.lng
@@ -64,4 +64,7 @@ $wb["limit_web_quota_txt"] = 'Web Quota';
$wb["limit_traffic_quota_txt"] = 'Traffic Quota';
$wb["limit_trafficquota_error_notint"] = 'Traffic Quota must be a number.';
$wb["template_del_aborted_txt"] = 'Delete aborted. There is still a client which has this template selected.';
+$wb["limit_openvz_vm_txt"] = 'Max. number of virtual servers';
+$wb["limit_openvz_vm_template_id_txt"] = 'Force virtual server template';
+$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
?>
\ 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 44de4f9795122f85f2f203efb637b70d025893b5..a553dd731c8be7866aef6dafb15dd22d88c09f3b 100644
--- a/interface/web/client/lib/lang/en_reseller.lng
+++ b/interface/web/client/lib/lang/en_reseller.lng
@@ -103,4 +103,7 @@ $wb["limit_trafficquota_error_notint"] = 'Traffic Quota must be a number.';
$wb["customer_no_txt"] = 'Customer No.';
$wb["vat_id_txt"] = 'VAT ID';
$wb["required_fields_txt"] = '* Required fields';
+$wb["limit_openvz_vm_txt"] = 'Max. number of virtual servers';
+$wb["limit_openvz_vm_template_id_txt"] = 'Force virtual server template';
+$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
?>
diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm
index c8b8819dd07a2cae39739c72f15a0de3a143e2a6..74b28ef67ffdcf1f3c42cc557f25b0630e1649b3 100644
--- a/interface/web/client/templates/client_edit_limits.htm
+++ b/interface/web/client/templates/client_edit_limits.htm
@@ -189,6 +189,16 @@
MB
+
+
+
+
+
+
+
+
diff --git a/interface/web/client/templates/client_template_edit_limits.htm b/interface/web/client/templates/client_template_edit_limits.htm
index a1c67129e947e0634a7121d3365d358e589d2f5b..12fba84e45c42f6ee00b610acb3d3cb8e2a59cb5 100644
--- a/interface/web/client/templates/client_template_edit_limits.htm
+++ b/interface/web/client/templates/client_template_edit_limits.htm
@@ -123,6 +123,16 @@
MB
+
+
+
+
+
+
+
+
diff --git a/interface/web/client/templates/reseller_edit_limits.htm b/interface/web/client/templates/reseller_edit_limits.htm
index 394985129dc2c60c90f5014bc4fbd3003f69cead..1e3151015e5ec3afecaebd8025e48d2a9b3b6123 100644
--- a/interface/web/client/templates/reseller_edit_limits.htm
+++ b/interface/web/client/templates/reseller_edit_limits.htm
@@ -182,6 +182,16 @@
MB
+
+
+
+
+
+
+
+
diff --git a/interface/web/vm/form/openvz_vm.tform.php b/interface/web/vm/form/openvz_vm.tform.php
index 3a93fb1f06832f4509c654ad3fbc6ddbc8de542d..3d75e8464b154c52b91c65188031b3550bab9172 100644
--- a/interface/web/vm/form/openvz_vm.tform.php
+++ b/interface/web/vm/form/openvz_vm.tform.php
@@ -63,7 +63,7 @@ $form["tabs"]['main'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
- 'querystring' => 'SELECT server_id,server_name FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
+ 'querystring' => 'SELECT server_id,server_name FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
@@ -74,7 +74,7 @@ $form["tabs"]['main'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
- 'querystring' => 'SELECT ostemplate_id,template_name FROM openvz_ostemplate WHERE {AUTHSQL} ORDER BY template_name',
+ 'querystring' => 'SELECT ostemplate_id,template_name FROM openvz_ostemplate WHERE 1 ORDER BY template_name',
'keyfield'=> 'ostemplate_id',
'valuefield'=> 'template_name'
),
@@ -84,11 +84,13 @@ $form["tabs"]['main'] = array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
+ /*
'datasource' => array ( 'type' => 'SQL',
- 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE {AUTHSQL} ORDER BY template_name',
+ 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
'keyfield'=> 'template_id',
'valuefield'=> 'template_name'
),
+ */
'value' => ''
),
'ip_address' => array (
@@ -99,7 +101,7 @@ $form["tabs"]['main'] = array (
),
'default' => '',
'datasource' => array ( 'type' => 'SQL',
- 'querystring' => "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '{RECORDID}') AND {AUTHSQL} ORDER BY ip_address",
+ 'querystring' => "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '{RECORDID}') ORDER BY ip_address",
'keyfield'=> 'ip_address',
'valuefield'=> 'ip_address'
),
diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php
index 65fbda3155ee621da09c3c91b18bca666835543d..f79a90bd234dd25841a70e93034085f469976e40 100644
--- a/interface/web/vm/openvz_vm_edit.php
+++ b/interface/web/vm/openvz_vm_edit.php
@@ -50,18 +50,53 @@ $app->load('tform_actions');
class page_action extends tform_actions {
+ function onShowNew() {
+ global $app, $conf;
+
+ // we will check only users, not admins
+ if($_SESSION["s"]["user"]["typ"] == 'user') {
+ if(!$app->tform->checkClientLimit('limit_openvz_vm')) {
+ $app->error($app->tform->wordbook["limit_openvz_vm_txt"]);
+ }
+ if(!$app->tform->checkResellerLimit('limit_openvz_vm')) {
+ $app->error('Reseller: '.$app->tform->wordbook["limit_openvz_vm_txt"]);
+ }
+ }
+
+ parent::onShowNew();
+ }
+
function onShowEnd() {
global $app, $conf;
//* Client: If the logged in user is not admin and has no sub clients (no rseller)
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
-
+
+ //* Get the limits of the client
+ $client_group_id = $_SESSION["s"]["user"]["default_group"];
+ $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+
+ //* Fill the template_id field
+ if($client['limit_openvz_vm_template_id'] == 0) {
+ $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
+ } else {
+ $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$client['limit_openvz_vm_template_id'].' ORDER BY template_name';
+ }
+ $records = $app->db->queryAllRecords($sql);
+ if(is_array($records)) {
+ foreach( $records as $rec) {
+ $selected = @($rec["template_id"] == $this->dataRecord["template_id"])?'SELECTED':'';
+ $template_id_select .= "\r\n";
+ }
+ }
+ $app->tpl->setVar("template_id_select",$template_id_select);
+
//* Reseller: If the logged in user is not admin and has sub clients (is a rseller)
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
//* Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"];
- $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+ $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
//* Fill the client select field
@@ -77,6 +112,21 @@ class page_action extends tform_actions {
}
}
$app->tpl->setVar("client_group_id",$client_select);
+
+ //* Fill the template_id field
+ if($client['limit_openvz_vm_template_id'] == 0) {
+ $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
+ } else {
+ $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$client['limit_openvz_vm_template_id'].' ORDER BY template_name';
+ }
+ $records = $app->db->queryAllRecords($sql);
+ if(is_array($records)) {
+ foreach( $records as $rec) {
+ $selected = @($rec["template_id"] == $this->dataRecord["template_id"])?'SELECTED':'';
+ $template_id_select .= "\r\n";
+ }
+ }
+ $app->tpl->setVar("template_id_select",$template_id_select);
//* Admin: If the logged in user is admin
} else {
@@ -93,6 +143,17 @@ class page_action extends tform_actions {
}
}
$app->tpl->setVar("client_group_id",$client_select);
+
+ //* Fill the template_id field
+ $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
+ $records = $app->db->queryAllRecords($sql);
+ if(is_array($records)) {
+ foreach( $records as $rec) {
+ $selected = @($rec["template_id"] == $this->dataRecord["template_id"])?'SELECTED':'';
+ $template_id_select .= "\r\n";
+ }
+ }
+ $app->tpl->setVar("template_id_select",$template_id_select);
}
diff --git a/interface/web/vm/templates/openvz_vm_edit.htm b/interface/web/vm/templates/openvz_vm_edit.htm
index 2f8ac77a65c3184ddf78325273375d3358fdc075..92ec046fd53976d37389ed2bad82be6e62ef78ff 100644
--- a/interface/web/vm/templates/openvz_vm_edit.htm
+++ b/interface/web/vm/templates/openvz_vm_edit.htm
@@ -54,7 +54,7 @@