bernd commited on 2008-09-22 17:29:57
Zeige 2 geänderte Dateien mit 93 Einfügungen und 1 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1158 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 |
+require_once('inc/base.php'); |
|
3 | 4 |
|
4 | 5 |
function list_system_users() |
5 | 6 |
{ |
... | ... |
@@ -27,4 +28,41 @@ function list_customers() |
27 | 28 |
} |
28 | 29 |
|
29 | 30 |
|
30 |
-?> |
|
31 |
+function find_customers($string) |
|
32 |
+{ |
|
33 |
+ $string = mysql_real_escape_string(chop($string)); |
|
34 |
+ $return = array(); |
|
35 |
+ $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN kundendaten.kundenkontakt AS kk ". |
|
36 |
+ "ON (kk.kundennr = k.id) LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ". |
|
37 |
+ "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ". |
|
38 |
+ "nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ". |
|
39 |
+ "adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ". |
|
40 |
+ "ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ". |
|
41 |
+ "notizen LIKE '%{$string}%' OR kk.name LIKE '%{$string}%' OR ". |
|
42 |
+ "kk.wert LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ". |
|
43 |
+ "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';"); |
|
44 |
+ while ($entry = mysql_fetch_assoc($result)) |
|
45 |
+ $return[] = $entry['id']; |
|
46 |
+ |
|
47 |
+ return $return; |
|
48 |
+} |
|
49 |
+ |
|
50 |
+ |
|
51 |
+function find_users_for_customer($id) |
|
52 |
+{ |
|
53 |
+ $id = (int) $id; |
|
54 |
+ $return = array(); |
|
55 |
+ $result = db_query("SELECT uid, username FROM system.useraccounts WHERE ". |
|
56 |
+ "kunde='{$id}';"); |
|
57 |
+ while ($entry = mysql_fetch_assoc($result)) |
|
58 |
+ $return[$entry['uid']] = $entry['username']; |
|
59 |
+ |
|
60 |
+ return $return; |
|
61 |
+} |
|
62 |
+ |
|
63 |
+ |
|
64 |
+ |
|
65 |
+ |
|
66 |
+ |
|
67 |
+ |
|
68 |
+ |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 |
+require_once('inc/base.php'); |
|
3 | 4 |
require_once('inc/debug.php'); |
4 | 5 |
|
5 | 6 |
require_once('session/start.php'); |
... | ... |
@@ -7,6 +8,24 @@ require_once('su.php'); |
7 | 8 |
|
8 | 9 |
require_role(ROLE_SYSADMIN); |
9 | 10 |
|
11 |
+if (isset($_GET['type'])) |
|
12 |
+{ |
|
13 |
+ check_form_token('su_su_ajax', $_GET['formtoken']); |
|
14 |
+ $role = NULL; |
|
15 |
+ if ($_GET['type'] == 'customer') { |
|
16 |
+ $role = find_role($_GET['id'], '', True); |
|
17 |
+ setup_session($role, $_GET['id']); |
|
18 |
+ } elseif ($_GET['type'] == 'systemuser') { |
|
19 |
+ $role = find_role($_GET['uid'], '', True); |
|
20 |
+ setup_session($role, $_GET['uid']); |
|
21 |
+ } else { |
|
22 |
+ system_failure('unknown type'); |
|
23 |
+ } |
|
24 |
+ |
|
25 |
+ header('Location: ../../go/index/index'); |
|
26 |
+ die(); |
|
27 |
+} |
|
28 |
+ |
|
10 | 29 |
if (isset($_POST['submit'])) |
11 | 30 |
{ |
12 | 31 |
check_form_token('su_su'); |
... | ... |
@@ -26,6 +43,41 @@ output('<h3>Benutzer wechseln</h3> |
26 | 43 |
<p>Hiermit können Sie (als Admin) das Webinterface mit den Rechten eines beliebigen anderen Benutzers benutzen.</p> |
27 | 44 |
'); |
28 | 45 |
|
46 |
+$debug = ''; |
|
47 |
+if ($debugmode) |
|
48 |
+ $debug = 'debug&'; |
|
49 |
+ |
|
50 |
+html_header('<script type="text/javascript" src="'.$prefix.'js/ajax.js" ></script> |
|
51 |
+<script type="text/javascript"> |
|
52 |
+<!-- |
|
53 |
+ |
|
54 |
+function doRequest() { |
|
55 |
+ ajax_request(\'su_ajax\', \''.$debug.'q=\'+document.getElementById(\'query\').value, got_response) |
|
56 |
+} |
|
57 |
+ |
|
58 |
+function keyPressed() { |
|
59 |
+ if(window.mytimeout) window.clearTimeout(window.mytimeout); |
|
60 |
+ window.mytimeout = window.setTimeout(doRequest, 500); |
|
61 |
+ return true; |
|
62 |
+} |
|
63 |
+ |
|
64 |
+function got_response() { |
|
65 |
+ if (xmlHttp.readyState == 4) { |
|
66 |
+ document.getElementById(\'response\').innerHTML = xmlHttp.responseText; |
|
67 |
+ } |
|
68 |
+} |
|
69 |
+ |
|
70 |
+// --> |
|
71 |
+</script> |
|
72 |
+'); |
|
73 |
+ |
|
74 |
+output(html_form('su_su_ajax', '', '', '<strong>Suchtext:</strong> <input type="text" id="query" onkeyup="keyPressed()" /> |
|
75 |
+')); |
|
76 |
+output('<div id="response"></div> |
|
77 |
+<div style="height: 3em;"> </div>'); |
|
78 |
+ |
|
79 |
+ |
|
80 |
+ |
|
29 | 81 |
$users = list_system_users(); |
30 | 82 |
$options = ''; |
31 | 83 |
foreach ($users as $user) |
32 | 84 |