Skip to content

Commit cd6f16c

Browse files
author
Till Brehm
committed
Fixed #4056 certain Limits don't save
1 parent f7fc296 commit cd6f16c

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed

interface/lib/classes/client_templates.inc.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function update_client_templates($clientId, $templates = array()) {
1919
global $app, $conf;
2020

2121
if(!is_array($templates)) return false;
22-
2322
$new_tpl = array();
2423
$used_assigned = array();
2524
$needed_types = array();
@@ -155,7 +154,6 @@ function apply_client_templates($clientId) {
155154
/* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */
156155
if (strpos($k, 'limit') !== false or strpos($k, 'default') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec'){
157156
$app->log('Template processing key ' . $k . ' for client ' . $clientId, LOGLEVEL_DEBUG);
158-
159157
/* process the numerical limits */
160158
if (is_numeric($v)){
161159
/* switch for special cases */
@@ -195,6 +193,24 @@ function apply_client_templates($clientId) {
195193
$limits[$k] = array();
196194
}
197195

196+
$limits_values = $limits[$k];
197+
if (is_string($limits[$k])){
198+
$limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]);
199+
}
200+
$additional_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $v);
201+
$app->log('Template processing key ' . $k . ' type CHECKBOXARRAY, lim / add: ' . implode(',', $limits_values) . ' / ' . implode(',', $additional_values) . ' for client ' . $clientId, LOGLEVEL_DEBUG);
202+
/* unification of limits_values (master template) and additional_values (additional template) */
203+
$limits_unified = array();
204+
foreach($form["tabs"]["limits"]["fields"][$k]["value"] as $key => $val){
205+
if (in_array($key, $limits_values) || in_array($key, $additional_values)) $limits_unified[] = $key;
206+
}
207+
$limits[$k] = implode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits_unified);
208+
break;
209+
case 'MULTIPLE':
210+
if (!isset($limits[$k])){
211+
$limits[$k] = array();
212+
}
213+
198214
$limits_values = $limits[$k];
199215
if (is_string($limits[$k])){
200216
$limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]);
@@ -245,7 +261,7 @@ function apply_client_templates($clientId) {
245261
if (strpos($k, 'default') !== false and $v == 0) {
246262
continue; // template doesn't define default server, client's default musn't be changed
247263
}
248-
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)){
264+
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)){
249265
if ($update != '') $update .= ', ';
250266
$update .= '?? = ?';
251267
$update_values[] = $k;

interface/web/client/form/client_template.tform.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@
126126
'value' => array(''),
127127
'name' => 'default_mailserver'
128128
),*/
129+
'mail_servers' => array (
130+
'datatype' => 'VARCHAR',
131+
'formtype' => 'MULTIPLE',
132+
'separator' => ',',
133+
'default' => '1',
134+
'datasource' => array ( 'type' => 'CUSTOM',
135+
'class'=> 'custom_datasource',
136+
'function'=> 'client_servers'
137+
),
138+
'value' => '',
139+
'name' => 'mail_servers'
140+
),
129141
'limit_maildomain' => array (
130142
'datatype' => 'INTEGER',
131143
'formtype' => 'TEXT',
@@ -432,6 +444,18 @@
432444
'value' => array(''),
433445
'name' => 'default_webserver'
434446
),*/
447+
'web_servers' => array (
448+
'datatype' => 'VARCHAR',
449+
'formtype' => 'MULTIPLE',
450+
'separator' => ',',
451+
'default' => '1',
452+
'datasource' => array ( 'type' => 'CUSTOM',
453+
'class'=> 'custom_datasource',
454+
'function'=> 'client_servers'
455+
),
456+
'value' => '',
457+
'name' => 'web_servers'
458+
),
435459
'limit_web_domain' => array (
436460
'datatype' => 'INTEGER',
437461
'formtype' => 'TEXT',
@@ -644,11 +668,6 @@
644668
'class'=> 'custom_datasource',
645669
'function'=> 'client_servers'
646670
),
647-
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
648-
'class' => 'validate_client',
649-
'function' => 'check_used_servers',
650-
'errmsg'=> 'dns_servers_used'),
651-
),
652671
'value' => '',
653672
'name' => 'dns_servers'
654673
),
@@ -733,6 +752,18 @@
733752
'value' => array(''),
734753
'name' => 'default_dbserver'
735754
),*/
755+
'db_servers' => array (
756+
'datatype' => 'VARCHAR',
757+
'formtype' => 'MULTIPLE',
758+
'separator' => ',',
759+
'default' => '1',
760+
'datasource' => array ( 'type' => 'CUSTOM',
761+
'class'=> 'custom_datasource',
762+
'function'=> 'client_servers'
763+
),
764+
'value' => '',
765+
'name' => 'db_servers'
766+
),
736767
'limit_database' => array (
737768
'datatype' => 'INTEGER',
738769
'formtype' => 'TEXT',

interface/web/client/templates/client_template_edit_limits.htm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ <h4 class="panel-title">
1818
<div id="collapseWeb" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingWeb">
1919
<div class="panel-body">
2020
<div class="form-group">
21+
<label for="web_servers" class="col-sm-3 control-label">{tmpl_var name='web_servers_txt'}</label>
22+
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='web_servers_placeholder'}" multiple name="web_servers[]" id="web_servers" class="form-control">
23+
{tmpl_var name='web_servers'}
24+
</select></div>
25+
</div>
26+
<div class="form-group">
2127
<label for="limit_web_domain" class="col-sm-3 control-label">{tmpl_var name='limit_web_domain_txt'}</label>
2228
<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>
2329
<div class="form-group">
@@ -141,6 +147,13 @@ <h4 class="panel-title">
141147
<div id="collapseMail" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingMail">
142148
<div class="panel-body">
143149
<div class="form-group">
150+
<label for="mail_servers" class="col-sm-3 control-label">{tmpl_var name='mail_servers_txt'}</label>
151+
<div class="col-sm-9">
152+
<select data-placeholder="{tmpl_var name='mail_servers_placeholder'}" multiple name="mail_servers[]" id="mail_servers" class="form-control">
153+
{tmpl_var name='mail_servers'}
154+
</select></div>
155+
</div>
156+
<div class="form-group">
144157
<label for="limit_maildomain" class="col-sm-3 control-label">{tmpl_var name='limit_maildomain_txt'}</label>
145158
<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>
146159
<div class="form-group">
@@ -197,6 +210,12 @@ <h4 class="panel-title">
197210
<div id="collapseXMPP" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingXMPP">
198211
<div class="panel-body">
199212
<div class="form-group">
213+
<label for="xmpp_servers" class="col-sm-3 control-label">{tmpl_var name='xmpp_servers_txt'}</label>
214+
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='xmpp_servers_placeholder'}" multiple name="xmpp_servers[]" id="xmpp_servers" class="form-control">
215+
{tmpl_var name='xmpp_servers'}
216+
</select></div>
217+
</div>
218+
<div class="form-group">
200219
<label for="limit_xmpp_domain" class="col-sm-3 control-label">{tmpl_var name='limit_xmpp_domain_txt'}</label>
201220
<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>
202221
<div class="form-group">
@@ -264,6 +283,12 @@ <h4 class="panel-title">
264283
<div id="collapseDB" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingDB">
265284
<div class="panel-body">
266285
<div class="form-group">
286+
<label for="db_servers" class="col-sm-3 control-label">{tmpl_var name='db_servers_txt'}</label>
287+
<div class="col-sm-9"><select data-placeholder="{tmpl_var name='db_servers_placeholder'}" multiple name="db_servers[]" id="db_servers" class="form-control">
288+
{tmpl_var name='db_servers'}
289+
</select></div>
290+
</div>
291+
<div class="form-group">
267292
<label for="limit_database" class="col-sm-3 control-label">{tmpl_var name='limit_database_txt'}</label>
268293
<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>
269294
<div class="form-group">

interface/web/themes/default/assets/javascripts/ispconfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ var ISPConfig = {
502502
if(addTplId > 0) {
503503
var newVal = tpl_add.split('/');
504504
ISPConfig.new_tpl_add_id += 1;
505-
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) {
505+
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) {
506506
e.preventDefault();
507507
ISPConfig.delAdditionalTemplate($(this).parent().attr('rel'));
508508
});

0 commit comments

Comments
 (0)