Commit cd6f16c1 authored by Till Brehm's avatar Till Brehm
Browse files

Fixed #4056 certain Limits don't save

parent f7fc296e
......@@ -19,7 +19,6 @@ class client_templates {
global $app, $conf;
if(!is_array($templates)) return false;
$new_tpl = array();
$used_assigned = array();
$needed_types = array();
......@@ -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) */
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);
/* process the numerical limits */
if (is_numeric($v)){
/* switch for special cases */
......@@ -195,6 +193,24 @@ class client_templates {
$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];
if (is_string($limits[$k])){
$limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]);
......@@ -245,7 +261,7 @@ class client_templates {
if (strpos($k, 'default') !== false and $v == 0) {
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 .= ', ';
$update .= '?? = ?';
$update_values[] = $k;
......
......@@ -126,6 +126,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''),
'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 (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -432,6 +444,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''),
'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 (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -644,11 +668,6 @@ $form["tabs"]['limits'] = array (
'class'=> 'custom_datasource',
'function'=> 'client_servers'
),
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'check_used_servers',
'errmsg'=> 'dns_servers_used'),
),
'value' => '',
'name' => 'dns_servers'
),
......@@ -733,6 +752,18 @@ $form["tabs"]['limits'] = array (
'value' => array(''),
'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 (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......
......@@ -18,6 +18,12 @@
<div id="collapseWeb" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingWeb">
<div class="panel-body">
<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>
<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">
......@@ -141,6 +147,13 @@
<div id="collapseMail" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingMail">
<div class="panel-body">
<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>
<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">
......@@ -197,6 +210,12 @@
<div id="collapseXMPP" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingXMPP">
<div class="panel-body">
<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>
<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">
......@@ -264,6 +283,12 @@
<div id="collapseDB" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingDB">
<div class="panel-body">
<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>
<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">
......
......@@ -502,7 +502,7 @@ var ISPConfig = {
if(addTplId > 0) {
var newVal = tpl_add.split('/');
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();
ISPConfig.delAdditionalTemplate($(this).parent().attr('rel'));
});
......
  • After this update, when editing clients none of the previously selected servers show for Web/Email/XMPP/Database. The selected nameserver does display. I can select servers again and hit save, there are no errors, but when editing the client again those fields are empty.

    The same fields are fine for a reseller, ie. they show the correct/previously saved servers.

  • Ok, so the reseller is still broken. The behaviour that you describe for the client is the intended behaviour, as manually selected servers have to be replaced by the ones that are selected in the templates. Edit the templates and select the desired servers, you will see that they get applied to the client then when you edit and save the client.

Supports Markdown
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