commit | author | age
|
acbf53
|
1 |
<?php |
T |
2 |
/* |
|
3 |
Copyright (c) 2005, 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/client.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 |
// Checking module permissions |
|
45 |
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) { |
|
46 |
header("Location: ../index.php"); |
|
47 |
exit; |
|
48 |
} |
|
49 |
|
|
50 |
// Loading classes |
|
51 |
$app->uses('tpl,tform,tform_actions'); |
76a100
|
52 |
$app->load('tform_actions'); |
acbf53
|
53 |
|
76a100
|
54 |
class page_action extends tform_actions { |
T |
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(); |
b5a23a
|
66 |
$groups = $groupid; |
76a100
|
67 |
|
T |
68 |
$username = addslashes($this->dataRecord["username"]); |
|
69 |
$password = addslashes($this->dataRecord["password"]); |
b5a23a
|
70 |
$modules = ISPC_INTERFACE_MODULES_ENABLED; |
T |
71 |
if($this->dataRecord["limit_client"] > 0) $modules .= ',client'; |
76a100
|
72 |
$startmodule = 'mail'; |
T |
73 |
$usertheme = addslashes($this->dataRecord["usertheme"]); |
|
74 |
$type = 'user'; |
|
75 |
$active = 1; |
|
76 |
$language = addslashes($this->dataRecord["language"]); |
|
77 |
|
|
78 |
// Create the controlpaneluser for the client |
|
79 |
$sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) |
b5a23a
|
80 |
VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")"; |
76a100
|
81 |
$app->db->query($sql); |
b5a23a
|
82 |
|
T |
83 |
//* If the user who inserted the client is a reseller (not admin), we will have to add this new client group |
|
84 |
//* to his groups, so he can administrate the records of this client. |
|
85 |
if($_SESSION['s']['user']['typ'] == 'user') { |
|
86 |
$app->auth->add_group_to_user($_SESSION['s']['user']['userid'],$groupid); |
|
87 |
$app->db->query("UPDATE client SET parent_client_id = ".intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id); |
|
88 |
} |
|
89 |
|
|
90 |
|
76a100
|
91 |
} |
T |
92 |
|
|
93 |
|
|
94 |
/* |
|
95 |
This function is called automatically right after |
|
96 |
the data was successful updated in the database. |
|
97 |
*/ |
|
98 |
function onAfterUpdate() { |
|
99 |
global $app; |
|
100 |
|
|
101 |
// username changed |
|
102 |
if(isset($app->tform->diffrec['username'])) { |
|
103 |
$username = addslashes($this->dataRecord["username"]); |
|
104 |
$client_id = $this->id; |
|
105 |
$sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; |
|
106 |
$app->db->query($sql); |
|
107 |
$sql = "UPDATE sys_group SET name = '$username' WHERE client_id = $client_id"; |
|
108 |
$app->db->query($sql); |
|
109 |
} |
|
110 |
|
|
111 |
// password changed |
af8f1b
|
112 |
if(isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') { |
76a100
|
113 |
$password = addslashes($this->dataRecord["password"]); |
22e7f9
|
114 |
$client_id = $this->id; |
76a100
|
115 |
$sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id"; |
22e7f9
|
116 |
$app->db->query($sql); |
76a100
|
117 |
} |
T |
118 |
|
b5a23a
|
119 |
// reseller status changed |
T |
120 |
if(isset($this->dataRecord["limit_client"])) { |
|
121 |
$modules = ISPC_INTERFACE_MODULES_ENABLED; |
|
122 |
if($this->dataRecord["limit_client"] > 0) $modules .= ',client'; |
|
123 |
$modules = addslashes($modules); |
|
124 |
$client_id = $this->id; |
|
125 |
$sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id"; |
|
126 |
$app->db->query($sql); |
|
127 |
} |
76a100
|
128 |
} |
T |
129 |
|
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
$page = new page_action; |
|
134 |
$page->onLoad(); |
acbf53
|
135 |
|
b5a2f8
|
136 |
?> |