Skip to content

Commit b2ea522

Browse files
committed
Fixed: FS#684 - client templates not complete
1 parent cc604f7 commit b2ea522

File tree

5 files changed

+84
-11
lines changed

5 files changed

+84
-11
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table client_template add column web_php_options varchar(255) not null default 'no' after limit_web_quota;
2+
alter table client_template add column ssh_chroot varchar(255) not null default 'no' after limit_shell_user;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,14 @@
325325
'rows' => '',
326326
'cols' => ''
327327
),
328+
'web_php_options' => array (
329+
'datatype' => 'VARCHAR',
330+
'formtype' => 'CHECKBOXARRAY',
331+
'default' => '',
332+
'separator' => ',',
333+
'valuelimit' => 'client:web_php_options',
334+
'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
335+
),
328336
'limit_web_aliasdomain' => array (
329337
'datatype' => 'INTEGER',
330338
'formtype' => 'TEXT',
@@ -381,6 +389,14 @@
381389
'rows' => '',
382390
'cols' => ''
383391
),
392+
'ssh_chroot' => array (
393+
'datatype' => 'VARCHAR',
394+
'formtype' => 'CHECKBOXARRAY',
395+
'default' => '',
396+
'separator' => ',',
397+
'valuelimit' => 'client:ssh_chroot',
398+
'value' => array('no' => 'None', 'jailkit' => 'Jailkit')
399+
),
384400
'limit_webdav_user' => array (
385401
'datatype' => 'INTEGER',
386402
'formtype' => 'TEXT',

interface/web/client/lib/lang/en_client_template.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@ $wb["template_del_aborted_txt"] = 'Delete aborted. There is still a client which
6767
$wb["limit_openvz_vm_txt"] = 'Max. number of virtual servers';
6868
$wb["limit_openvz_vm_template_id_txt"] = 'Force virtual server template';
6969
$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
70+
$wb["ssh_chroot_txt"] = 'SSH-Chroot Options';
71+
$wb["web_php_options_txt"] = 'PHP Options';
7072
?>

interface/web/client/templates/client_template_edit_limits.htm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
6969
<label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
7070
<input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
7171
</div>
72+
<div class="ctrlHolder">
73+
<p class="label">{tmpl_var name='web_php_options_txt'}</p>
74+
<div class="multiField">
75+
{tmpl_var name='web_php_options'}
76+
</div>
77+
</div>
7278
<div class="ctrlHolder">
7379
<label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
7480
<input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
@@ -85,6 +91,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
8591
<label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
8692
<input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
8793
</div>
94+
<div class="ctrlHolder">
95+
<p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
96+
<div class="multiField">
97+
{tmpl_var name='ssh_chroot'}
98+
</div>
99+
</div>
88100
<div class="ctrlHolder">
89101
<label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
90102
<input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />

interface/web/client/tools.inc.php

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,57 @@ function applyClientTemplates($clientId){
5959
/* maybe the template is deleted in the meantime */
6060
if (is_array($addLimits)){
6161
foreach($addLimits as $k => $v){
62-
if($k == 'limit_cron_type') {
63-
$limits[$k] = $v;
64-
} elseif($k == 'limit_cron_frequency') {
65-
if($v < $limits[$k]) $limits[$k] = $v;
66-
} else {
67-
if ($limits[$k] > -1){
68-
if ($v == -1) {
69-
$limits[$k] = -1;
70-
} else {
71-
$limits[$k] += $v;
62+
/* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */
63+
if (strpos($k, 'limit') !== false){
64+
/* process the numerical limits */
65+
if (is_numeric($v)){
66+
/* switch for special cases */
67+
switch ($k){
68+
case 'limit_cron_frequency':
69+
if ($v < $limits[$k]) $limits[$k] = $v;
70+
/* silent adjustment of the minimum cron frequency to 1 minute */
71+
/* maybe this control test should be done via validator definition in tform.php file, but I don't know how */
72+
if ($limits[$k] < 1) $limits[$k] = 1;
73+
break;
74+
75+
default:
76+
if ($limits[$k] > -1){
77+
if ($v == -1){
78+
$limits[$k] = -1;
79+
}
80+
else {
81+
$limits[$k] += $v;
82+
}
83+
}
84+
}
85+
}
86+
/* process the string limits (CHECKBOXARRAY, SELECT etc.) */
87+
elseif (is_string($v)){
88+
switch ($app->tform->formDef["tabs"]["limits"]["fields"][$k]['formtype']){
89+
case 'CHECKBOXARRAY':
90+
if (!isset($limits[$k])){
91+
$limits[$k] = array();
92+
}
93+
94+
$limits_values = $limits[$k];
95+
if (is_string($limits[$k])){
96+
$limits_values = explode($app->tform->formDef["tabs"]["limits"]["fields"][$k]["separator"],$limits[$k]);
97+
}
98+
$additional_values = explode($app->tform->formDef["tabs"]["limits"]["fields"][$k]["separator"],$v);
99+
100+
/* unification of limits_values (master template) and additional_values (additional template) */
101+
$limits_unified = array();
102+
foreach($app->tform->formDef["tabs"]["limits"]["fields"][$k]["value"] as $key => $val){
103+
if (in_array($key,$limits_values) || in_array($key,$additional_values)) $limits_unified[] = $key;
104+
}
105+
$limits[$k] = implode($app->tform->formDef["tabs"]["limits"]["fields"][$k]["separator"],$limits_unified);
106+
break;
107+
108+
case 'SELECT':
109+
$limit_values = array_keys($app->tform->formDef["tabs"]["limits"]["fields"][$k]["value"]);
110+
/* choose the lower index of the two SELECT items */
111+
$limits[$k] = $limit_values[min(array_search($limits[$k], $limit_values), array_search($v, $limit_values))];
112+
break;
72113
}
73114
}
74115
}
@@ -82,7 +123,7 @@ function applyClientTemplates($clientId){
82123
*/
83124
$update = '';
84125
foreach($limits as $k => $v){
85-
if (strpos($k, 'limit') !== false && !is_array($v)){
126+
if ((strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options') && !is_array($v)){
86127
if ($update != '') $update .= ', ';
87128
$update .= '`' . $k . "`='" . $v . "'";
88129
}

0 commit comments

Comments
 (0)