Commit f414abda authored by tbrehm's avatar tbrehm

Added Limits for OpenVZ virtual servers in VM module.

parent f8442b33
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
......@@ -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
##################################
......
......@@ -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
##################################
......
......@@ -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
##################################
......
......@@ -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.';
?>
......@@ -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
......@@ -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.';
?>
......@@ -189,6 +189,16 @@
<label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
<input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm">{tmpl_var name='limit_openvz_vm_txt'}</label>
<input name="limit_openvz_vm" id="limit_openvz_vm" value="{tmpl_var name='limit_openvz_vm'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm_template_id">{tmpl_var name='limit_openvz_vm_template_id_txt'}</label>
<select name="limit_openvz_vm_template_id" id="limit_openvz_vm_template_id" class="selectInput">
{tmpl_var name='limit_openvz_vm_template_id'}
</select>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
......@@ -123,6 +123,16 @@
<label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
<input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm">{tmpl_var name='limit_openvz_vm_txt'}</label>
<input name="limit_openvz_vm" id="limit_openvz_vm" value="{tmpl_var name='limit_openvz_vm'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm_template_id">{tmpl_var name='limit_openvz_vm_template_id_txt'}</label>
<select name="limit_openvz_vm_template_id" id="limit_openvz_vm_template_id" class="selectInput">
{tmpl_var name='limit_openvz_vm_template_id'}
</select>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
......@@ -182,6 +182,16 @@
<label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
<input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm">{tmpl_var name='limit_openvz_vm_txt'}</label>
<input name="limit_openvz_vm" id="limit_openvz_vm" value="{tmpl_var name='limit_openvz_vm'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="limit_openvz_vm_template_id">{tmpl_var name='limit_openvz_vm_template_id_txt'}</label>
<select name="limit_openvz_vm_template_id" id="limit_openvz_vm_template_id" class="selectInput">
{tmpl_var name='limit_openvz_vm_template_id'}
</select>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
......@@ -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'
),
......
......@@ -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 .= "<option value='$rec[template_id]' $selected>$rec[template_name]</option>\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 .= "<option value='$rec[template_id]' $selected>$rec[template_name]</option>\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 .= "<option value='$rec[template_id]' $selected>$rec[template_name]</option>\r\n";
}
}
$app->tpl->setVar("template_id_select",$template_id_select);
}
......
......@@ -54,7 +54,7 @@
<div class="ctrlHolder">
<label for="template_id">{tmpl_var name='template_id_txt'}</label>
<select name="template_id" id="template_id" class="selectInput">
{tmpl_var name='template_id'}
{tmpl_var name='template_id_select'}
</select>
</div>
<div class="ctrlHolder">
......
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