Skip to content

Commit 76a1008

Browse files
committed
updated client form
1 parent 4e44dd7 commit 76a1008

File tree

7 files changed

+319
-47
lines changed

7 files changed

+319
-47
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ class tform {
104104
var $errorMessage = '';
105105

106106
var $dateformat = "d.m.Y";
107-
var $formDef;
107+
var $formDef;
108108
var $wordbook;
109109
var $module;
110110
var $primary_id;
111+
var $diffrec = array();
111112

112113
/**
113114
* Laden der Tabellendefinition
@@ -611,7 +612,7 @@ function validateField($field_name, $field_value, $validators) {
611612
$validator_class = $validator['class'];
612613
$validator_function = $validator['function'];
613614
$app->uses($validator_class);
614-
$this->errorMessage .= $app->$validator_class->$validator_function($validator);
615+
$this->errorMessage .= $app->$validator_class->$validator_function($field_name, $field_value, $validator);
615616
} else {
616617
$this->errorMessage .= "Custom validator class or function is empty<br>\r\n";
617618
}
@@ -852,6 +853,8 @@ function datalogSave($action,$primary_id,$record_new) {
852853

853854
// Insert the server_id, if the record has a server_id
854855
$server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0;
856+
857+
$this->diffrec = $diffrec;
855858

856859
if(count($diffrec) > 0) {
857860

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007, Till Brehm, Falko Timme, 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+
class validate_client {
33+
34+
/*
35+
Validator function to check if a username is unique.
36+
*/
37+
function username_unique($field_name, $field_value, $validator) {
38+
global $app;
39+
40+
if($app->tform->action == 'NEW') {
41+
$num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."'");
42+
if($num_rec["number"] > 0) {
43+
$errmsg = $validator['errmsg'];
44+
if(isset($this->wordbook[$errmsg])) {
45+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
46+
} else {
47+
return $errmsg."<br>\r\n";
48+
}
49+
}
50+
} else {
51+
$num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."' AND client_id != ".$app->tform->primary_id);
52+
if($num_rec["number"] > 0) {
53+
$errmsg = $validator['errmsg'];
54+
if(isset($app->tform->wordbook[$errmsg])) {
55+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
56+
} else {
57+
return $errmsg."<br>\r\n";
58+
}
59+
}
60+
}
61+
}
62+
63+
64+
65+
66+
}

interface/web/client/client_edit.php

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,68 @@
4949

5050
// Loading classes
5151
$app->uses('tpl,tform,tform_actions');
52+
$app->load('tform_actions');
5253

53-
// let tform_actions handle the page
54-
$app->tform_actions->onLoad();
54+
class page_action extends tform_actions {
55+
56+
/*
57+
This function is called automatically right after
58+
the data was successful inserted in the database.
59+
*/
60+
function onAfterInsert() {
61+
global $app;
62+
// Create the group for the client
63+
$sql = "INSERT INTO sys_group (name,description,client_id) VALUES ('".addslashes($this->dataRecord["username"])."','',".$this->id.")";
64+
$app->db->query($sql);
65+
$groupid = $app->db->insertID();
66+
67+
$username = addslashes($this->dataRecord["username"]);
68+
$password = addslashes($this->dataRecord["password"]);
69+
$modules = 'mail';
70+
$startmodule = 'mail';
71+
$usertheme = addslashes($this->dataRecord["usertheme"]);
72+
$type = 'user';
73+
$active = 1;
74+
$language = addslashes($this->dataRecord["language"]);
75+
76+
// Create the controlpaneluser for the client
77+
$sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
78+
VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groupid,$groupid,".$this->id.")";
79+
$app->db->query($sql);
80+
}
81+
82+
83+
/*
84+
This function is called automatically right after
85+
the data was successful updated in the database.
86+
*/
87+
function onAfterUpdate() {
88+
global $app;
89+
90+
// username changed
91+
if(isset($app->tform->diffrec['username'])) {
92+
$username = addslashes($this->dataRecord["username"]);
93+
$client_id = $this->id;
94+
$sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id";
95+
$app->db->query($sql);
96+
$sql = "UPDATE sys_group SET name = '$username' WHERE client_id = $client_id";
97+
$app->db->query($sql);
98+
}
99+
100+
// password changed
101+
if($this->dataRecord["password"] != '') {
102+
$password = addslashes($this->dataRecord["password"]);
103+
$sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id";
104+
}
105+
106+
107+
108+
}
109+
110+
111+
}
112+
113+
$page = new page_action;
114+
$page->onLoad();
55115

56116
?>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
'username' => array (
8787
'datatype' => 'VARCHAR',
8888
'formtype' => 'TEXT',
89+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
90+
'errmsg'=> 'username_error_empty'),
91+
1 => array ( 'type' => 'CUSTOM',
92+
'class' => 'validate_client',
93+
'function' => 'username_unique',
94+
'errmsg'=> 'username_error_unique'),
95+
),
8996
'default' => '',
9097
'value' => '',
9198
'separator' => '',
@@ -120,7 +127,7 @@
120127
'datatype' => 'VARCHAR',
121128
'formtype' => 'SELECT',
122129
'default' => 'default',
123-
'value' => array('default' => 'default','grey' => 'grey'),
130+
'value' => array('default' => 'default'),
124131
'separator' => '',
125132
'width' => '30',
126133
'maxlength' => '255',
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
<?php
2-
$wb["username_txt"] = 'Username';
3-
$wb["password_txt"] = 'Password';
4-
$wb["language_txt"] = 'Language';
5-
$wb["usertheme_txt"] = 'Theme';
6-
$wb["btn_save_txt"] = 'Save';
7-
$wb["btn_cancel_txt"] = 'Cancel';
8-
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
9-
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
10-
$wb["limit_mailalias_txt"] = 'Max. number of email aliases and redirects';
11-
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
12-
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
13-
$wb["limit_mailfilter_txt"] = 'Max. number of email filters';
14-
$wb["limit_fetchmail_txt"] = 'Max. number of fetchmail accounts';
15-
$wb["limit_mailquota_txt"] = 'Mailbox quota';
16-
$wb["company_name_txt"] = 'Company name';
17-
$wb["contact_name_txt"] = 'Contact name';
18-
$wb["street_txt"] = 'Street';
19-
$wb["zip_txt"] = 'ZIP';
20-
$wb["city_txt"] = 'City';
21-
$wb["state_txt"] = 'State';
22-
$wb["country_txt"] = 'Country';
23-
$wb["telephone_txt"] = 'Telephone';
24-
$wb["mobile_txt"] = 'Mobile';
25-
$wb["fax_txt"] = 'Fax';
26-
$wb["email_txt"] = 'Email';
27-
$wb["internet_txt"] = 'Internet';
28-
$wb["icq_txt"] = 'ICQ';
29-
$wb["notes_txt"] = 'Notes';
30-
$wb["company_txt"] = 'Company';
31-
$wb["title_txt"] = 'Title';
32-
$wb["firstname_txt"] = 'Firstname';
33-
$wb["surname_txt"] = 'Surname';
34-
$wb["limit_client_txt"] = 'limit_client';
35-
$wb["limit_domain_txt"] = 'limit_domain';
36-
$wb["limit_subdomain_txt"] = 'limit_subdomain';
37-
$wb["limit_webquota_txt"] = 'limit_webquota';
38-
$wb["limit_database_txt"] = 'limit_database';
39-
$wb["ip_address_txt"] = 'ip_address';
40-
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
41-
$wb["firstname_error_empty"] = 'Firstname is empty.';
42-
$wb["contact_error_empty"] = 'Contact name is empty.';
1+
<?php
2+
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
3+
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
4+
$wb["limit_mailalias_txt"] = 'Max. number of email aliases and redirects';
5+
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
6+
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
7+
$wb["limit_mailfilter_txt"] = 'Max. number of email filters';
8+
$wb["limit_fetchmail_txt"] = 'Max. number of fetchmail accounts';
9+
$wb["limit_mailquota_txt"] = 'Mailbox quota';
10+
$wb["btn_save_txt"] = 'Save';
11+
$wb["btn_cancel_txt"] = 'Cancel';
12+
$wb["company_name_txt"] = 'Company name';
13+
$wb["contact_name_txt"] = 'Contact name';
14+
$wb["username_txt"] = 'Username';
15+
$wb["password_txt"] = 'Password';
16+
$wb["language_txt"] = 'Language';
17+
$wb["usertheme_txt"] = 'Theme';
18+
$wb["street_txt"] = 'Street';
19+
$wb["zip_txt"] = 'ZIP';
20+
$wb["city_txt"] = 'City';
21+
$wb["state_txt"] = 'State';
22+
$wb["country_txt"] = 'Country';
23+
$wb["telephone_txt"] = 'Telephone';
24+
$wb["mobile_txt"] = 'Mobile';
25+
$wb["fax_txt"] = 'Fax';
26+
$wb["email_txt"] = 'Email';
27+
$wb["internet_txt"] = 'Internet';
28+
$wb["icq_txt"] = 'ICQ';
29+
$wb["notes_txt"] = 'Notes';
30+
$wb["company_txt"] = 'Company';
31+
$wb["title_txt"] = 'Title';
32+
$wb["firstname_txt"] = 'Firstname';
33+
$wb["surname_txt"] = 'Surname';
34+
$wb["limit_client_txt"] = 'limit_client';
35+
$wb["limit_domain_txt"] = 'limit_domain';
36+
$wb["limit_subdomain_txt"] = 'limit_subdomain';
37+
$wb["limit_webquota_txt"] = 'limit_webquota';
38+
$wb["limit_database_txt"] = 'limit_database';
39+
$wb["ip_address_txt"] = 'ip_address';
40+
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
41+
$wb["firstname_error_empty"] = 'Firstname is empty.';
42+
$wb["contact_error_empty"] = 'Contact name is empty.';
4343
?>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<table width="500" border="0" cellspacing="0" cellpadding="2">
2+
<tr>
3+
<td class="frmText11">{tmpl_var name='company_name_txt'}:</td>
4+
<td class="frmText11"><input name="company_name" type="text" class="text" value="{tmpl_var name='company_name'}" size="30" maxlength="255"></td>
5+
</tr>
6+
<tr>
7+
<td class="frmText11">{tmpl_var name='contact_name_txt'}:</td>
8+
<td class="frmText11"><input name="contact_name" type="text" class="text" value="{tmpl_var name='contact_name'}" size="30" maxlength="255"></td>
9+
</tr>
10+
<tr>
11+
<td class="frmText11">{tmpl_var name='username_txt'}:</td>
12+
<td class="frmText11"><input name="username" type="text" class="text" value="{tmpl_var name='username'}" size="30" maxlength="255"></td>
13+
</tr>
14+
<tr>
15+
<td class="frmText11">{tmpl_var name='password_txt'}:</td>
16+
<td class="frmText11"><input name="password" type="password" class="text" value="{tmpl_var name='password'}" size="30" maxlength="255"></td>
17+
</tr>
18+
<tr>
19+
<td class="frmText11">{tmpl_var name='language_txt'}:</td>
20+
<td class="frmText11">
21+
<select name="language" class="text">
22+
{tmpl_var name='language'}
23+
</select>
24+
</td>
25+
</tr>
26+
<tr>
27+
<td class="frmText11">{tmpl_var name='usertheme_txt'}:</td>
28+
<td class="frmText11">
29+
<select name="usertheme" class="text">
30+
{tmpl_var name='usertheme'}
31+
</select>
32+
</td>
33+
</tr>
34+
<tr>
35+
<td class="frmText11">{tmpl_var name='street_txt'}:</td>
36+
<td class="frmText11"><input name="street" type="text" class="text" value="{tmpl_var name='street'}" size="30" maxlength="255"></td>
37+
</tr>
38+
<tr>
39+
<td class="frmText11">{tmpl_var name='zip_txt'}:</td>
40+
<td class="frmText11"><input name="zip" type="text" class="text" value="{tmpl_var name='zip'}" size="10" maxlength="255"></td>
41+
</tr>
42+
<tr>
43+
<td class="frmText11">{tmpl_var name='city_txt'}:</td>
44+
<td class="frmText11"><input name="city" type="text" class="text" value="{tmpl_var name='city'}" size="30" maxlength="255"></td>
45+
</tr>
46+
<tr>
47+
<td class="frmText11">{tmpl_var name='state_txt'}:</td>
48+
<td class="frmText11"><input name="state" type="text" class="text" value="{tmpl_var name='state'}" size="30" maxlength="255"></td>
49+
</tr>
50+
<tr>
51+
<td class="frmText11">{tmpl_var name='country_txt'}:</td>
52+
<td class="frmText11"><input name="country" type="text" class="text" value="{tmpl_var name='country'}" size="30" maxlength="255"></td>
53+
</tr>
54+
<tr>
55+
<td class="frmText11">{tmpl_var name='telephone_txt'}:</td>
56+
<td class="frmText11"><input name="telephone" type="text" class="text" value="{tmpl_var name='telephone'}" size="30" maxlength="255"></td>
57+
</tr>
58+
<tr>
59+
<td class="frmText11">{tmpl_var name='mobile_txt'}:</td>
60+
<td class="frmText11"><input name="mobile" type="text" class="text" value="{tmpl_var name='mobile'}" size="30" maxlength="255"></td>
61+
</tr>
62+
<tr>
63+
<td class="frmText11">{tmpl_var name='fax_txt'}:</td>
64+
<td class="frmText11"><input name="fax" type="text" class="text" value="{tmpl_var name='fax'}" size="30" maxlength="255"></td>
65+
</tr>
66+
<tr>
67+
<td class="frmText11">{tmpl_var name='email_txt'}:</td>
68+
<td class="frmText11"><input name="email" type="text" class="text" value="{tmpl_var name='email'}" size="30" maxlength="255"></td>
69+
</tr>
70+
<tr>
71+
<td class="frmText11">{tmpl_var name='internet_txt'}:</td>
72+
<td class="frmText11"><input name="internet" type="text" class="text" value="{tmpl_var name='internet'}" size="30" maxlength="255"></td>
73+
</tr>
74+
<tr>
75+
<td class="frmText11">{tmpl_var name='icq_txt'}:</td>
76+
<td class="frmText11"><input name="icq" type="text" class="text" value="{tmpl_var name='icq'}" size="30" maxlength="255"></td>
77+
</tr>
78+
<tr>
79+
<td class="frmText11">{tmpl_var name='notes_txt'}:</td>
80+
<td class="frmText11"><textarea name='notes' cols='30' rows='10'>{tmpl_var name='notes'}</textarea></td>
81+
</tr> <tr>
82+
<td class="frmText11">&nbsp;</td>
83+
<td class="frmText11">&nbsp;</td>
84+
</tr>
85+
<tr>
86+
<td>&nbsp;</td>
87+
<td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><div class="buttonEnding"></div>&nbsp;
88+
<input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><div class="buttonEnding"></div>
89+
</td>
90+
</tr>
91+
</table>
92+
<input type="hidden" name="id" value="{tmpl_var name='id'}">

0 commit comments

Comments
 (0)