Skip to content
Snippets Groups Projects
Commit cd6f16c1 authored by Till Brehm's avatar Till Brehm
Browse files

Fixed #4056 certain Limits don't save

parent f7fc296e
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,6 @@ class client_templates { ...@@ -19,7 +19,6 @@ class client_templates {
global $app, $conf; global $app, $conf;
if(!is_array($templates)) return false; if(!is_array($templates)) return false;
$new_tpl = array(); $new_tpl = array();
$used_assigned = array(); $used_assigned = array();
$needed_types = array(); $needed_types = array();
...@@ -155,7 +154,6 @@ class client_templates { ...@@ -155,7 +154,6 @@ class client_templates {
/* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */ /* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */
if (strpos($k, 'limit') !== false or strpos($k, 'default') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec'){ if (strpos($k, 'limit') !== false or strpos($k, 'default') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec'){
$app->log('Template processing key ' . $k . ' for client ' . $clientId, LOGLEVEL_DEBUG); $app->log('Template processing key ' . $k . ' for client ' . $clientId, LOGLEVEL_DEBUG);
/* process the numerical limits */ /* process the numerical limits */
if (is_numeric($v)){ if (is_numeric($v)){
/* switch for special cases */ /* switch for special cases */
...@@ -195,6 +193,24 @@ class client_templates { ...@@ -195,6 +193,24 @@ class client_templates {
$limits[$k] = array(); $limits[$k] = array();
} }
$limits_values = $limits[$k];
if (is_string($limits[$k])){
$limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]);
}
$additional_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $v);
$app->log('Template processing key ' . $k . ' type CHECKBOXARRAY, lim / add: ' . implode(',', $limits_values) . ' / ' . implode(',', $additional_values) . ' for client ' . $clientId, LOGLEVEL_DEBUG);
/* unification of limits_values (master template) and additional_values (additional template) */
$limits_unified = array();
foreach($form["tabs"]["limits"]["fields"][$k]["value"] as $key => $val){
if (in_array($key, $limits_values) || in_array($key, $additional_values)) $limits_unified[] = $key;
}
$limits[$k] = implode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits_unified);
break;
case 'MULTIPLE':
if (!isset($limits[$k])){
$limits[$k] = array();
}
$limits_values = $limits[$k]; $limits_values = $limits[$k];
if (is_string($limits[$k])){ if (is_string($limits[$k])){
$limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]); $limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]);
...@@ -245,7 +261,7 @@ class client_templates { ...@@ -245,7 +261,7 @@ class client_templates {
if (strpos($k, 'default') !== false and $v == 0) { if (strpos($k, 'default') !== false and $v == 0) {
continue; // template doesn't define default server, client's default musn't be changed continue; // template doesn't define default server, client's default musn't be changed
} }
if ((strpos($k, 'limit') !== false or strpos($k, 'default') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){ if ((strpos($k, 'limit') !== false or strpos($k, 'default') !== false or strpos($k, '_servers') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){
if ($update != '') $update .= ', '; if ($update != '') $update .= ', ';
$update .= '?? = ?'; $update .= '?? = ?';
$update_values[] = $k; $update_values[] = $k;
......
...@@ -126,6 +126,18 @@ $form["tabs"]['limits'] = array ( ...@@ -126,6 +126,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''), 'value' => array(''),
'name' => 'default_mailserver' 'name' => 'default_mailserver'
),*/ ),*/
'mail_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'value' => '',
'name' => 'mail_servers'
),
'limit_maildomain' => array ( 'limit_maildomain' => array (
'datatype' => 'INTEGER', 'datatype' => 'INTEGER',
'formtype' => 'TEXT', 'formtype' => 'TEXT',
...@@ -432,6 +444,18 @@ $form["tabs"]['limits'] = array ( ...@@ -432,6 +444,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''), 'value' => array(''),
'name' => 'default_webserver' 'name' => 'default_webserver'
),*/ ),*/
'web_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'value' => '',
'name' => 'web_servers'
),
'limit_web_domain' => array ( 'limit_web_domain' => array (
'datatype' => 'INTEGER', 'datatype' => 'INTEGER',
'formtype' => 'TEXT', 'formtype' => 'TEXT',
...@@ -644,11 +668,6 @@ $form["tabs"]['limits'] = array ( ...@@ -644,11 +668,6 @@ $form["tabs"]['limits'] = array (
'class'=> 'custom_datasource', 'class'=> 'custom_datasource',
'function'=> 'client_servers' 'function'=> 'client_servers'
), ),
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'dns_servers_used'),
),
'value' => '', 'value' => '',
'name' => 'dns_servers' 'name' => 'dns_servers'
), ),
...@@ -733,6 +752,18 @@ $form["tabs"]['limits'] = array ( ...@@ -733,6 +752,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''), 'value' => array(''),
'name' => 'default_dbserver' 'name' => 'default_dbserver'
),*/ ),*/
'db_servers' => array (
'datatype' => 'VARCHAR',
'formtype' => 'MULTIPLE',
'separator' => ',',
'default' => '1',
'datasource' => array ( 'type' => 'CUSTOM',
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'value' => '',
'name' => 'db_servers'
),
'limit_database' => array ( 'limit_database' => array (
'datatype' => 'INTEGER', 'datatype' => 'INTEGER',
'formtype' => 'TEXT', 'formtype' => 'TEXT',
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
<div id="collapseWeb" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingWeb"> <div id="collapseWeb" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingWeb">
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
<label for="web_servers" class="col-sm-3 control-label">{tmpl_var name='web_servers_txt'}</label>
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='web_servers_placeholder'}" multiple name="web_servers[]" id="web_servers" class="form-control">
{tmpl_var name='web_servers'}
</select></div>
</div>
<div class="form-group">
<label for="limit_web_domain" class="col-sm-3 control-label">{tmpl_var name='limit_web_domain_txt'}</label> <label for="limit_web_domain" class="col-sm-3 control-label">{tmpl_var name='limit_web_domain_txt'}</label>
<div class="col-sm-9"><input type="text" name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" class="form-control" /></div></div> <div class="col-sm-9"><input type="text" name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" class="form-control" /></div></div>
<div class="form-group"> <div class="form-group">
...@@ -141,6 +147,13 @@ ...@@ -141,6 +147,13 @@
<div id="collapseMail" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingMail"> <div id="collapseMail" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingMail">
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
<label for="mail_servers" class="col-sm-3 control-label">{tmpl_var name='mail_servers_txt'}</label>
<div class="col-sm-9">
<select data-placeholder="{tmpl_var name='mail_servers_placeholder'}" multiple name="mail_servers[]" id="mail_servers" class="form-control">
{tmpl_var name='mail_servers'}
</select></div>
</div>
<div class="form-group">
<label for="limit_maildomain" class="col-sm-3 control-label">{tmpl_var name='limit_maildomain_txt'}</label> <label for="limit_maildomain" class="col-sm-3 control-label">{tmpl_var name='limit_maildomain_txt'}</label>
<div class="col-sm-9"><input type="text" name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" class="form-control" /></div></div> <div class="col-sm-9"><input type="text" name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" class="form-control" /></div></div>
<div class="form-group"> <div class="form-group">
...@@ -197,6 +210,12 @@ ...@@ -197,6 +210,12 @@
<div id="collapseXMPP" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingXMPP"> <div id="collapseXMPP" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingXMPP">
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
<label for="xmpp_servers" class="col-sm-3 control-label">{tmpl_var name='xmpp_servers_txt'}</label>
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='xmpp_servers_placeholder'}" multiple name="xmpp_servers[]" id="xmpp_servers" class="form-control">
{tmpl_var name='xmpp_servers'}
</select></div>
</div>
<div class="form-group">
<label for="limit_xmpp_domain" class="col-sm-3 control-label">{tmpl_var name='limit_xmpp_domain_txt'}</label> <label for="limit_xmpp_domain" class="col-sm-3 control-label">{tmpl_var name='limit_xmpp_domain_txt'}</label>
<div class="col-sm-9"><input type="text" name="limit_xmpp_domain" id="limit_xmpp_domain" value="{tmpl_var name='limit_xmpp_domain'}" class="form-control" /></div></div> <div class="col-sm-9"><input type="text" name="limit_xmpp_domain" id="limit_xmpp_domain" value="{tmpl_var name='limit_xmpp_domain'}" class="form-control" /></div></div>
<div class="form-group"> <div class="form-group">
...@@ -264,6 +283,12 @@ ...@@ -264,6 +283,12 @@
<div id="collapseDB" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingDB"> <div id="collapseDB" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingDB">
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
<label for="db_servers" class="col-sm-3 control-label">{tmpl_var name='db_servers_txt'}</label>
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='db_servers_placeholder'}" multiple name="db_servers[]" id="db_servers" class="form-control">
{tmpl_var name='db_servers'}
</select></div>
</div>
<div class="form-group">
<label for="limit_database" class="col-sm-3 control-label">{tmpl_var name='limit_database_txt'}</label> <label for="limit_database" class="col-sm-3 control-label">{tmpl_var name='limit_database_txt'}</label>
<div class="col-sm-9"><input type="text" name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" class="form-control" /></div></div> <div class="col-sm-9"><input type="text" name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" class="form-control" /></div></div>
<div class="form-group"> <div class="form-group">
......
...@@ -502,7 +502,7 @@ var ISPConfig = { ...@@ -502,7 +502,7 @@ var ISPConfig = {
if(addTplId > 0) { if(addTplId > 0) {
var newVal = tpl_add.split('/'); var newVal = tpl_add.split('/');
ISPConfig.new_tpl_add_id += 1; ISPConfig.new_tpl_add_id += 1;
var delbtn = $('&nbsp;<a href="#"><span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a>').attr('class', 'btn btn-danger btn-xs').click(function(e) { var delbtn = $('<a href="#"><span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a>').attr('class', 'btn btn-danger btn-xs').click(function(e) {
e.preventDefault(); e.preventDefault();
ISPConfig.delAdditionalTemplate($(this).parent().attr('rel')); ISPConfig.delAdditionalTemplate($(this).parent().attr('rel'));
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment