Zeige Menüpunkt für su_customer auch wenn das systemusers-Modul nicht da ist. Datei su_customer vergessen, ist jetzt im GIT
Bernd Wurst

Bernd Wurst commited on 2015-11-01 06:34:08
Zeige 2 geänderte Dateien mit 82 Einfügungen und 0 Löschungen.

... ...
@@ -18,7 +18,11 @@ $role = $_SESSION['role'];
18 18
 
19 19
 if ($role & ROLE_CUSTOMER)
20 20
 {
21
+  if (have_module('systemuser')) {
21 22
     $menu["su_su_customer"] = array("label" => "Benutzer wechseln", "file" => "su_customer", "weight" => -10, "submenu" => "systemuser_account");
23
+  } else {
24
+    $menu["su_su_customer"] = array("label" => "Benutzer wechseln", "file" => "su_customer", "weight" => 90);
25
+  }
22 26
 }
23 27
 if ($role & ROLE_SYSADMIN)
24 28
 {
... ...
@@ -0,0 +1,78 @@
1
+<?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2014 by schokokeks.org Hosting, namely
6
+  Bernd Wurst <bernd@schokokeks.org>
7
+  Hanno Böck <hanno@schokokeks.org>
8
+
9
+To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10
+
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12
+http://creativecommons.org/publicdomain/zero/1.0/
13
+
14
+Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15
+*/
16
+
17
+require_once('inc/base.php');
18
+require_once('inc/security.php');
19
+require_once('inc/debug.php');
20
+
21
+require_once('session/start.php');
22
+require_once('su.php');
23
+
24
+require_role(ROLE_CUSTOMER);
25
+
26
+if (isset($_GET['uid']))
27
+{
28
+  $uid = (int) $_GET['uid'];
29
+  $token = $_GET['token'];
30
+  $cid = (int) $_SESSION['customerinfo']['customerno'];
31
+  $users = find_users_for_customer($cid);
32
+  $found = false;
33
+  foreach ($users as $u) {
34
+    if ($uid == $u['uid']) {
35
+      $found = true;
36
+    }
37
+  }
38
+  if (! $found) {
39
+    system_failure('Unerlaubter Useraccount');
40
+  }
41
+
42
+  if (!isset($_SESSION['su_customer_timestamp']) || $_SESSION['su_customer_timestamp'] < time() - 30) {
43
+    system_failure("Aus Sicherheitsgründen muss die Auswahl auf dieser Seite innerhalb von 30 Sekunden getroffen werden.");
44
+  }
45
+
46
+  if (!isset($_SESSION['su_customer_token']) || $_SESSION['su_customer_token'] != $token) {
47
+    system_failure("Ungültige Reihenfolge der Aufrufe");
48
+  }
49
+
50
+  su('u', $uid);
51
+}
52
+
53
+title("Benutzer wechseln");
54
+
55
+output('<p>Hiermit können Sie das Webinterface mit den Rechten eines beliebigen anderen Benutzers aus Ihrem Kundenaccount benutzen.</p>
56
+');
57
+
58
+$token = random_string(20);
59
+$_SESSION['su_customer_token'] = $token;
60
+$_SESSION['su_customer_timestamp'] = time();
61
+
62
+$cid = (int) $_SESSION['customerinfo']['customerno'];
63
+$users = find_users_for_customer($cid);
64
+
65
+output('<p>Zu Ihrem Kundenkonto gehören die folgenden Benutzer. Klicken Sie einen Benutzernamen an um zu diesem zu wechseln.</p><ul>');
66
+
67
+foreach ($users as $u) {
68
+  if ($u['uid'] == $_SESSION['userinfo']['uid']) {
69
+    output("<li>{$u['username']} - (Eigener Benutzeraccount)</li>");
70
+    continue;
71
+  }
72
+  $realname = $u['name'];
73
+  if ($realname) {
74
+    $realname = ' - '.$realname;
75
+  }
76
+  output("<li>".internal_link('', "{$u['username']}{$realname}", "uid={$u['uid']}&token={$token}")."</li>");
77
+}
78
+output('</ul>');
0 79