Su-Login für Admins
bernd

bernd commited on 2007-07-30 13:02:55
Zeige 4 geänderte Dateien mit 105 Einfügungen und 2 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@567 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -4,9 +4,8 @@ $menu = array();
4 4
 
5 5
 $role = $_SESSION['role'];
6 6
 
7
-switch ($role)
7
+if ($role & ROLE_CUSTOMER)
8 8
 {
9
-  case ROLE_CUSTOMER:
10 9
   $menu["jabber_accounts"] = array("label" => "Jabber", "file" => "accounts.php", "weight" => 10);
11 10
     
12 11
 }
... ...
@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+
4
+function list_system_users()
5
+{
6
+  require_role(ROLE_SYSADMIN);
7
+
8
+  $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
9
+  
10
+  $ret = array();
11
+  while ($item = mysql_fetch_object($result))
12
+    array_push($ret, $item);
13
+  return $ret;
14
+}
15
+
16
+
17
+function list_customers()
18
+{
19
+  require_role(ROLE_SYSADMIN);
20
+
21
+  $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
22
+  
23
+  $ret = array();
24
+  while ($item = mysql_fetch_object($result))
25
+    array_push($ret, $item);
26
+  return $ret;
27
+}
28
+
29
+
30
+?>
... ...
@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+$menu = array();
4
+
5
+$role = $_SESSION['role'];
6
+
7
+if ($role & ROLE_SYSADMIN)
8
+{
9
+  $menu["su_su"] = array("label" => "Su-Login", "file" => "su.php", "weight" => -10);
10
+}
11
+
12
+if (empty($menu))
13
+  $menu = false;
14
+
15
+?>
... ...
@@ -0,0 +1,59 @@
1
+<?php
2
+
3
+require_once('inc/debug.php');
4
+
5
+require_once('session/start.php');
6
+require_once('su.php');
7
+
8
+require_role(ROLE_SYSADMIN);
9
+
10
+if (isset($_POST['submit']))
11
+{
12
+  check_form_token('su_su');
13
+  $id = (int) $_POST['destination'];
14
+  $role = find_role($id, '', True);
15
+  setup_session($role, $id);
16
+
17
+  header('Location: ../../go/index/index.php');
18
+  die();
19
+}
20
+
21
+
22
+
23
+$title = "Benutzer wechseln";
24
+
25
+output('<h3>Benutzer wechseln</h3>
26
+<p>Hiermit können Sie (als Admin) das Webinterface mit den Rechten eines beliebigen anderen Benutzers benutzen.</p>
27
+<p>Benutzer auswählen: ');
28
+
29
+$users = list_system_users();
30
+$options = '';
31
+foreach ($users as $user)
32
+{
33
+  $options .= "  <option value=\"{$user->uid}\">{$user->username} ({$user->uid})</option>\n";
34
+}
35
+
36
+output(html_form('su_su', 'su.php', '', '<select name="destination" size="1">
37
+'.$options.'
38
+</select>
39
+<input type="submit" name="submit" value="zum Benutzer wechseln" />
40
+'));
41
+output('<p>Kunde auswählen: ');
42
+
43
+$customers = list_customers();
44
+$options = '';
45
+foreach ($customers as $customer)
46
+{
47
+  $options .= "  <option value=\"{$customer->id}\">{$customer->id} - {$customer->name}</option>\n";
48
+}
49
+
50
+output(html_form('su_su', 'su.php', '', '<select name="destination" size="1">
51
+'.$options.'
52
+</select>
53
+<input type="submit" name="submit" value="zum Kunden wechseln" />
54
+'));
55
+output("<br />");
56
+
57
+
58
+
59
+?>
0 60