Skip to content

Commit 58b3418

Browse files
author
Till Brehm
committed
Implemented #5420 Improve input filters for Tools > Interface settings
1 parent 559c694 commit 58b3418

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

interface/web/admin/form/users.tform.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@
199199
'startmodule' => array (
200200
'datatype' => 'VARCHAR',
201201
'formtype' => 'SELECT',
202+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
203+
'errmsg'=> 'startmodule_empty'),
204+
1 => array ( 'type' => 'REGEX',
205+
'regex' => '/^[a-z0-9\_]{0,64}$/',
206+
'errmsg'=> 'startmodule_regex'),
207+
),
202208
'regex' => '',
203209
'errmsg' => '',
204210
'default' => '',
@@ -212,6 +218,12 @@
212218
'app_theme' => array (
213219
'datatype' => 'VARCHAR',
214220
'formtype' => 'RADIO',
221+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
222+
'errmsg'=> 'app_theme_empty'),
223+
1 => array ( 'type' => 'REGEX',
224+
'regex' => '/^[a-z0-9\_]{0,64}$/',
225+
'errmsg'=> 'app_theme_regex'),
226+
),
215227
'regex' => '',
216228
'errmsg' => '',
217229
'default' => 'default',

interface/web/admin/lib/lang/en_users.lng

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ $wb['username_error_collision'] = 'The username may not be web or web plus a num
3333
$wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin';
3434
$wb['lost_password_function_txt'] = 'Forgot password function is available';
3535
$wb['no_user_insert'] = 'CP-Users of type -user- get added and updated automatically when you add a client or reseller.';
36+
$wb['startmodule_empty'] = 'Startmodule empty.';
37+
$wb['startmodule_regex'] = 'Invalid chars in Startmodule.';
38+
$wb['app_theme_empty'] = 'App theme empty.';
39+
$wb['app_theme_regex'] = 'Invalid chars in App theme.';
3640
?>

interface/web/tools/form/interface_settings.tform.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@
144144
'startmodule' => array (
145145
'datatype' => 'VARCHAR',
146146
'formtype' => 'SELECT',
147+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
148+
'errmsg'=> 'startmodule_empty'),
149+
1 => array ( 'type' => 'REGEX',
150+
'regex' => '/^[a-z0-9\_]{0,64}$/',
151+
'errmsg'=> 'startmodule_regex'),
152+
),
147153
'regex' => '',
148154
'errmsg' => '',
149155
'default' => '',
@@ -157,6 +163,12 @@
157163
'app_theme' => array (
158164
'datatype' => 'VARCHAR',
159165
'formtype' => 'SELECT',
166+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
167+
'errmsg'=> 'app_theme_empty'),
168+
1 => array ( 'type' => 'REGEX',
169+
'regex' => '/^[a-z0-9\_]{0,64}$/',
170+
'errmsg'=> 'app_theme_regex'),
171+
),
160172
'regex' => '',
161173
'errmsg' => '',
162174
'default' => 'default',

interface/web/tools/interface_settings.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ function onBeforeInsert() {
8181
if(!in_array($this->dataRecord['startmodule'], $this->dataRecord['modules'])) {
8282
$app->tform->errorMessage .= $app->tform->wordbook['startmodule_err'];
8383
}
84-
$this->updateSessionTheme();
8584
}
8685

8786
function onInsert() {
@@ -96,7 +95,6 @@ function onBeforeUpdate() {
9695
if(@is_array($this->dataRecord['modules']) && !in_array($this->dataRecord['startmodule'], $this->dataRecord['modules'])) {
9796
$app->tform->errorMessage .= $app->tform->wordbook['startmodule_err'];
9897
}
99-
$this->updateSessionTheme();
10098
}
10199

102100
function updateSessionTheme() {
@@ -120,6 +118,9 @@ function onAfterInsert() {
120118
}
121119

122120
function onAfterUpdate() {
121+
122+
$this->updateSessionTheme();
123+
123124
if($this->_theme_changed == true) {
124125
// not the best way, but it works
125126
header('Content-Type: text/html');

interface/web/tools/lib/lang/en_interface.lng

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ $wb["interface_desc_txt"] = 'Modify your interface';
44
$wb["language_txt"] = 'Language';
55
$wb["startmodule_txt"] = 'Startmodule';
66
$wb["app_theme_txt"] = 'Design';
7+
$wb['startmodule_empty'] = 'Startmodule empty.';
8+
$wb['startmodule_regex'] = 'Invalid chars in Startmodule.';
9+
$wb['app_theme_empty'] = 'App theme empty.';
10+
$wb['app_theme_regex'] = 'Invalid chars in App theme.';
711
?>

0 commit comments

Comments
 (0)