bernd commited on 2007-07-28 18:07:01
Zeige 5 geänderte Dateien mit 224 Einfügungen und 0 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@563 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once('session/start.php'); |
|
4 |
+ |
|
5 |
+require_once('useraccounts.php'); |
|
6 |
+ |
|
7 |
+require_role(ROLE_CUSTOMER); |
|
8 |
+ |
|
9 |
+$title = "System-Benutzeraccounts"; |
|
10 |
+ |
|
11 |
+ |
|
12 |
+output("<h3>System-Benutzeraccounts</h3>"); |
|
13 |
+ |
|
14 |
+if (! customer_may_have_useraccounts()) |
|
15 |
+{ |
|
16 |
+ warning("Sie haben bisher keine Benutzeraccounts. Der erste (»Stamm-«)Account muss von einem Administrator angelegt werden."); |
|
17 |
+} |
|
18 |
+else |
|
19 |
+{ |
|
20 |
+ $accounts = list_useraccounts(); |
|
21 |
+ output("<p>Folgende Benutzeraccounts haben Sie bisher:</p>"); |
|
22 |
+ output("<table><tr><th>Benutzername</th><th>Name</th><th>Erstellt am</th><th>Speicherplatz</th></tr>"); |
|
23 |
+ foreach ($accounts as $acc) |
|
24 |
+ { |
|
25 |
+ output("<tr><td>".internal_link('edit.php', $acc->username, "uid={$acc->uid}")."</td><td>{$acc->name}</td><td>{$acc->erstellungsdatum}</td><td>{$acc->softquota} MB</td></tr>"); |
|
26 |
+ } |
|
27 |
+ output("</table><br />"); |
|
28 |
+} |
|
29 |
+ |
|
30 |
+ |
|
31 |
+?> |
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once('session/start.php'); |
|
4 |
+ |
|
5 |
+require_once('useraccounts.php'); |
|
6 |
+ |
|
7 |
+require_role(ROLE_CUSTOMER); |
|
8 |
+ |
|
9 |
+ |
|
10 |
+$title = "System-Benutzeraccounts"; |
|
11 |
+ |
|
12 |
+ |
|
13 |
+$account = get_account_details($_GET['uid']); |
|
14 |
+ |
|
15 |
+output("<h3>Bearbeiten von Benutzer »{$account['username']}«</h3>"); |
|
16 |
+ |
|
17 |
+output(html_form('systemuser_edit', 'save.php', 'action=edit', ' |
|
18 |
+<table> |
|
19 |
+<tr><td>Benutzername:</td><td><strong>'.$account['username'].'</strong></td></tr> |
|
20 |
+<tr><td>richtiger Name:<br /><span style="font-size:85%;">(wenn nicht »'.$_SESSION['customerinfo']['name'].'«)</span></td><td><input type="text" name="fullname" value="'.$account['name'].'" /></td></tr> |
|
21 |
+<tr><td>Passwort:</td><td><input type="password" name="newpass" value="" /><br /><span style="font-size:85%;">(Bitte leer lassen um das Passwort nicht zu ändern!)</span></td></tr> |
|
22 |
+<tr><td>Wiederholung:</td><td><input type="password" name="newpass2" value="" /></td></tr> |
|
23 |
+</table> |
|
24 |
+<br /> |
|
25 |
+<input type="hidden" name="uid" value="'.$account['uid'].'" /> |
|
26 |
+<input type="submit" name="submit" value="Speichern" /> |
|
27 |
+')); |
|
28 |
+ |
|
29 |
+ |
|
30 |
+ |
|
31 |
+?> |
... | ... |
@@ -0,0 +1,57 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once("inc/debug.php"); |
|
4 |
+require_once("inc/db_connect.php"); |
|
5 |
+ |
|
6 |
+require_role(ROLE_CUSTOMER); |
|
7 |
+ |
|
8 |
+ |
|
9 |
+function customer_may_have_useraccounts() |
|
10 |
+{ |
|
11 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
12 |
+ $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}"); |
|
13 |
+ return (mysql_num_rows($result) > 0); |
|
14 |
+} |
|
15 |
+ |
|
16 |
+ |
|
17 |
+ |
|
18 |
+function list_useraccounts() |
|
19 |
+{ |
|
20 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
21 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,softquota FROM system.useraccounts WHERE kunde={$customerno}"); |
|
22 |
+ $ret = array(); |
|
23 |
+ while ($item = mysql_fetch_object($result)) |
|
24 |
+ { |
|
25 |
+ DEBUG('Useraccount: '.print_r($item, true)); |
|
26 |
+ array_push($ret, $item); |
|
27 |
+ } |
|
28 |
+ return $ret; |
|
29 |
+} |
|
30 |
+ |
|
31 |
+ |
|
32 |
+function get_account_details($uid) |
|
33 |
+{ |
|
34 |
+ $uid = (int) $uid; |
|
35 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
36 |
+ $result = db_query("SELECT uid,username,name,softquota FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
37 |
+ if (mysql_num_rows($result) == 0) |
|
38 |
+ system_failure("Cannot find the requestes useraccount (for this customer)."); |
|
39 |
+ return mysql_fetch_array($result); |
|
40 |
+} |
|
41 |
+ |
|
42 |
+ |
|
43 |
+ |
|
44 |
+function set_systemuser_details($uid, $fullname, $quota) |
|
45 |
+{ |
|
46 |
+ $uid = (int) $uid; |
|
47 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
48 |
+ $fullname = maybe_null(mysql_real_escape_string($fullname)); |
|
49 |
+ $quota = (int) $quota; |
|
50 |
+ |
|
51 |
+ db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
|
52 |
+ logger("modules/systemuser/include/useraccounts.php", "systemuser", "updated real name for uid {$uid}"); |
|
53 |
+ |
|
54 |
+} |
|
55 |
+ |
|
56 |
+ |
|
57 |
+?> |
... | ... |
@@ -0,0 +1,17 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+$menu = array(); |
|
4 |
+ |
|
5 |
+$role = $_SESSION['role']; |
|
6 |
+ |
|
7 |
+switch ($role) |
|
8 |
+{ |
|
9 |
+ case ROLE_CUSTOMER: |
|
10 |
+ $menu["systemuser"] = array("label" => "Benutzeraccounts", "file" => "accounts.php", "weight" => 30); |
|
11 |
+ |
|
12 |
+} |
|
13 |
+ |
|
14 |
+if (empty($menu)) |
|
15 |
+ $menu = false; |
|
16 |
+ |
|
17 |
+?> |
... | ... |
@@ -0,0 +1,88 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once('session/start.php'); |
|
4 |
+ |
|
5 |
+require_once('useraccounts.php'); |
|
6 |
+ |
|
7 |
+require_once('inc/security.php'); |
|
8 |
+ |
|
9 |
+ |
|
10 |
+require_role(ROLE_CUSTOMER); |
|
11 |
+ |
|
12 |
+require_once("inc/debug.php"); |
|
13 |
+global $debugmode; |
|
14 |
+ |
|
15 |
+if ($_GET['action'] == 'new') |
|
16 |
+{ |
|
17 |
+ system_failure('not implemented'); |
|
18 |
+ /* |
|
19 |
+ check_form_token('jabber_new_account'); |
|
20 |
+ if (filter_input_username($_POST['local']) == '' || |
|
21 |
+ $_POST['domain'] == '' || |
|
22 |
+ filter_shell($_POST['password']) == '') |
|
23 |
+ { |
|
24 |
+ input_error('Sie müssen alle Felder ausfüllen!'); |
|
25 |
+ } |
|
26 |
+ else |
|
27 |
+ { |
|
28 |
+ create_jabber_account($_POST['local'], $_POST['domain'], $_POST['password']); |
|
29 |
+ if (! $debugmode) |
|
30 |
+ header('Location: accounts.php'); |
|
31 |
+ } |
|
32 |
+ */ |
|
33 |
+} |
|
34 |
+elseif ($_GET['action'] == 'edit') |
|
35 |
+{ |
|
36 |
+ $error = false; |
|
37 |
+ check_form_token('systemuser_edit'); |
|
38 |
+ if ($_POST['newpass'] != '') |
|
39 |
+ { |
|
40 |
+ if ($_POST['newpass2'] == '' || |
|
41 |
+ $_POST['newpass'] != $_POST['newpass2']) |
|
42 |
+ { |
|
43 |
+ input_error('Bitte zweimal ein neues Passwort eingeben!'); |
|
44 |
+ $error = true; |
|
45 |
+ } |
|
46 |
+ else |
|
47 |
+ { |
|
48 |
+ $user = get_account_details($_POST['uid']); |
|
49 |
+ # set_systemuser_password kommt aus den Session-Funktionen! |
|
50 |
+ set_systemuser_password($user['uid'], $_POST['newpass']); |
|
51 |
+ } |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ set_systemuser_details($_POST['uid'], $_POST['fullname'], $_POST['quota']); |
|
55 |
+ if (! ($debugmode || $error)) |
|
56 |
+ header('Location: accounts.php'); |
|
57 |
+ |
|
58 |
+} |
|
59 |
+elseif ($_GET['action'] == 'delete') |
|
60 |
+{ |
|
61 |
+ system_failure("Benutzeraccounts zu löschen ist momentan nicht über diese Oberfläche möglich. Bitte wenden Sie sich an einen Administrator."); |
|
62 |
+ /* |
|
63 |
+ $account_string = filter_input_general( $account['local'].'@'.$account['domain'] ); |
|
64 |
+ $sure = user_is_sure(); |
|
65 |
+ if ($sure === NULL) |
|
66 |
+ { |
|
67 |
+ are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?"); |
|
68 |
+ } |
|
69 |
+ elseif ($sure === true) |
|
70 |
+ { |
|
71 |
+ delete_jabber_account($account['id']); |
|
72 |
+ if (! $debugmode) |
|
73 |
+ header("Location: accounts.php"); |
|
74 |
+ } |
|
75 |
+ elseif ($sure === false) |
|
76 |
+ { |
|
77 |
+ if (! $debugmode) |
|
78 |
+ header("Location: accounts.php"); |
|
79 |
+ } |
|
80 |
+ */ |
|
81 |
+} |
|
82 |
+else |
|
83 |
+ system_failure("Unimplemented action"); |
|
84 |
+ |
|
85 |
+output(''); |
|
86 |
+ |
|
87 |
+ |
|
88 |
+?> |
|
0 | 89 |