Skip to content

Commit 85c90f8

Browse files
committed
- Added a tools module.
- Added a form to change the language and password of the current user.
1 parent 3819087 commit 85c90f8

File tree

8 files changed

+359
-1
lines changed

8 files changed

+359
-1
lines changed

install/tpl/config.inc.php.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ define('ISPC_WEB_TEMP_PATH', ISPC_WEB_PATH.'/temp'); // Path for downloads, ac
5959
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
6060

6161
//** Interface settings
62-
define('ISPC_INTERFACE_MODULES_ENABLED', 'mail,sites,dns');
62+
define('ISPC_INTERFACE_MODULES_ENABLED', 'mail,sites,dns,tools');
6363

6464

6565
/*

interface/lib/classes/tform_actions.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ function onLoad() {
6060

6161
// show print version of the form
6262
if(isset($_GET["print_form"]) && $_GET["print_form"] == 1) {
63+
die('Function disabled.');
6364
$this->onPrintForm();
6465
}
6566

6667
// send this form by email
6768
if(isset($_GET["send_form_by_mail"]) && $_GET["send_form_by_mail"] == 1) {
69+
die('Function disabled.');
6870
$this->onMailSendForm();
6971
}
7072

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/*
32+
Form Definition
33+
34+
Tabellendefinition
35+
36+
Datentypen:
37+
- INTEGER (Wandelt Ausdr�cke in Int um)
38+
- DOUBLE
39+
- CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
40+
- VARCHAR (kein weiterer Format Check)
41+
- TEXT (kein weiterer Format Check)
42+
- DATE (Datumsformat, Timestamp Umwandlung)
43+
44+
Formtype:
45+
- TEXT (normales Textfeld)
46+
- TEXTAREA (normales Textfeld)
47+
- PASSWORD (Feldinhalt wird nicht angezeigt)
48+
- SELECT (Gibt Werte als option Feld aus)
49+
- RADIO
50+
- CHECKBOX
51+
- CHECKBOXARRAY
52+
- FILE
53+
54+
VALUE:
55+
- Wert oder Array
56+
57+
Hinweis:
58+
Das ID-Feld ist nicht bei den Table Values einzuf�gen.
59+
60+
61+
*/
62+
63+
$form['title'] = 'User Settings';
64+
$form['description'] = 'Form to edit the user password and language.';
65+
$form['name'] = 'usersettings';
66+
$form['action'] = 'user_settings.php';
67+
$form['db_table'] = 'sys_user';
68+
$form['db_table_idx'] = 'userid';
69+
$form["db_history"] = "no";
70+
$form['tab_default'] = 'users';
71+
$form['list_default'] = 'index.php';
72+
$form['auth'] = 'yes';
73+
74+
//* 0 = id of the user, > 0 id must match with id of current user
75+
$form['auth_preset']['userid'] = 0;
76+
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
77+
$form['auth_preset']['groupid'] = 0;
78+
79+
//** Permissions are: r = read, i = insert, u = update, d = delete
80+
$form['auth_preset']['perm_user'] = 'riud';
81+
$form['auth_preset']['perm_group'] = 'riud';
82+
$form['auth_preset']['perm_other'] = '';
83+
84+
//* Languages
85+
$language_list = array();
86+
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
87+
while ($file = @readdir ($handle)) {
88+
if ($file != '.' && $file != '..') {
89+
if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
90+
$tmp = substr($file, 0, 2);
91+
$language_list[$tmp] = $tmp;
92+
}
93+
}
94+
}
95+
96+
$form['tabs']['users'] = array (
97+
'title' => 'Settings',
98+
'width' => 80,
99+
'template' => 'templates/user_settings.htm',
100+
'fields' => array (
101+
##################################
102+
# Beginn Datenbankfelder
103+
##################################
104+
'passwort' => array (
105+
'datatype' => 'VARCHAR',
106+
'formtype' => 'PASSWORD',
107+
'regex' => '',
108+
'errmsg' => '',
109+
'default' => '',
110+
'value' => '',
111+
'separator' => '',
112+
'width' => '15',
113+
'maxlength' => '100',
114+
'rows' => '',
115+
'cols' => ''
116+
),
117+
'language' => array (
118+
'datatype' => 'VARCHAR',
119+
'formtype' => 'SELECT',
120+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
121+
'errmsg'=> 'language_is_empty'),
122+
1 => array ( 'type' => 'REGEX',
123+
'regex' => '/^[a-z]{2}$/i',
124+
'errmsg'=> 'language_regex_mismatch'),
125+
),
126+
'regex' => '',
127+
'errmsg' => '',
128+
'default' => '',
129+
'value' => $language_list,
130+
'separator' => '',
131+
'width' => '30',
132+
'maxlength' => '2',
133+
'rows' => '',
134+
'cols' => ''
135+
)
136+
##################################
137+
# ENDE Datenbankfelder
138+
##################################
139+
)
140+
);
141+
142+
143+
?>

interface/web/tools/index.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
32+
/******************************************
33+
* Begin Form configuration
34+
******************************************/
35+
36+
$tform_def_file = "form/user_settings.tform.php";
37+
38+
/******************************************
39+
* End Form configuration
40+
******************************************/
41+
42+
require_once('../../lib/config.inc.php');
43+
require_once('../../lib/app.inc.php');
44+
45+
//* Check permissions for module
46+
$app->auth->check_module_permissions('tools');
47+
48+
echo $app->lng('ISPConfig Tools');
49+
50+
?>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$wb["passwort_txt"] = 'Passwort';
3+
$wb["language_txt"] = 'Language';
4+
$wb["btn_save_txt"] = 'Save';
5+
$wb["btn_cancel_txt"] = 'Cancel';
6+
?>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
global $conf;
4+
5+
$module['name'] = 'tools';
6+
$module['title'] = 'Tools';
7+
$module['template'] = 'module.tpl.htm';
8+
$module['startpage'] = 'tools/index.php';
9+
$module['tab_width'] = '60';
10+
11+
12+
//**** Change User password
13+
$items = array();
14+
15+
$items[] = array( 'title' => 'Password and Language',
16+
'target' => 'content',
17+
'link' => 'tools/user_settings.php');
18+
19+
20+
$module['nav'][] = array( 'title' => 'User Settings',
21+
'open' => 1,
22+
'items' => $items);
23+
24+
25+
$menu_dir = ISPC_WEB_PATH.'/tools/lib/menu.d';
26+
27+
if (is_dir($menu_dir)) {
28+
if ($dh = opendir($menu_dir)) {
29+
//** Go trough all files in the menu dir
30+
while (($file = readdir($dh)) !== false) {
31+
if($file != '.' && $file != '..' && substr($file,-9,9) == '.menu.php') {
32+
include_once($menu_dir.'/'.$file);
33+
}
34+
}
35+
}
36+
}
37+
38+
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<table width="500" border="0" cellspacing="0" cellpadding="2">
2+
<tr>
3+
<td class="frmText11">{tmpl_var name='passwort_txt'}:</td>
4+
<td class="frmText11"><input name="passwort" type="password" class="text" value="{tmpl_var name='passwort'}" size="15" maxlength="100"></td>
5+
</tr>
6+
<tr>
7+
<td class="frmText11">{tmpl_var name='passwort_txt'}:</td>
8+
<td class="frmText11"><input name="passwort2" type="password" class="text" value="" size="15" maxlength="100"></td>
9+
</tr>
10+
<tr>
11+
<td class="frmText11">{tmpl_var name='language_txt'}:</td>
12+
<td class="frmText11">
13+
<select name="language" class="text">
14+
{tmpl_var name='language'}
15+
</select>
16+
</td>
17+
</tr> <tr>
18+
<td class="frmText11">&nbsp;</td>
19+
<td class="frmText11">&nbsp;</td>
20+
</tr>
21+
<tr>
22+
<td>&nbsp;</td>
23+
<td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','tools/user_settings.php');"><div class="buttonEnding"></div>&nbsp;
24+
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('tools/index.php');"><div class="buttonEnding"></div>
25+
</td>
26+
</tr>
27+
</table>
28+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/*
3+
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/user_settings.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
44+
//* Check permissions for module
45+
$app->auth->check_module_permissions('tools');
46+
47+
// Loading classes
48+
$app->uses('tpl,tform,tform_actions');
49+
$app->load('tform_actions');
50+
51+
class page_action extends tform_actions {
52+
53+
function onLoad() {
54+
global $app, $conf, $tform_def_file;
55+
56+
// Loading template classes and initialize template
57+
if(!is_object($app->tpl)) $app->uses('tpl');
58+
if(!is_object($app->tform)) $app->uses('tform');
59+
60+
$app->tpl->newTemplate("tabbed_form.tpl.htm");
61+
62+
// Load table definition from file
63+
$app->tform->loadFormDef($tform_def_file);
64+
65+
// Importing ID
66+
$this->id = $_SESSION['s']['user']['userid'];
67+
68+
if(count($_POST) > 1) {
69+
$this->dataRecord = $_POST;
70+
$this->onSubmit();
71+
} else {
72+
$this->onShow();
73+
}
74+
}
75+
76+
function onBeforeUpdate() {
77+
global $app, $conf;
78+
79+
if($_POST['passwort'] != $_POST['passwort2']) {
80+
$app->tform->errorMessage = 'The passwords in the second password field does not match the first password.';
81+
}
82+
83+
}
84+
85+
86+
}
87+
88+
$page = new page_action;
89+
$page->onLoad();
90+
91+
?>

0 commit comments

Comments
 (0)