4 |
andreas |
1 |
<?
|
|
|
2 |
require_once('version.inc');
|
|
|
3 |
require_once('dbaccess.inc');
|
|
|
4 |
require_once('language.inc');
|
|
|
5 |
require_once('header.inc');
|
|
|
6 |
require_once('crypt.inc');
|
|
|
7 |
require_once('settings.inc');
|
|
|
8 |
require_once('menu.inc');
|
|
|
9 |
|
|
|
10 |
function SaveNewRole() {
|
|
|
11 |
$kr_num = $_REQUEST['kr_num'];
|
|
|
12 |
$kr_role = $_REQUEST['kr_role'];
|
|
|
13 |
|
|
|
14 |
$db = OpenDB();
|
|
|
15 |
$query = "select kr_role from key_role where kr_num = $kr_num";
|
|
|
16 |
$result = QueryDB($db, $query);
|
|
|
17 |
$numrows = numrowsDB($result);
|
|
|
18 |
|
|
|
19 |
if ($numrows == 1) {
|
|
|
20 |
Error("Schlüssel $kr_num ist bereits vorhanden!\n");
|
|
|
21 |
closeDB($db);
|
|
|
22 |
return false;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
$query = "insert into key_role (kr_num, kr_role) values ($kr_num, '$kr_role')";
|
|
|
26 |
|
|
|
27 |
if (!TQueryDB($db, $query)) {
|
|
|
28 |
Error("SQL-Error: $query");
|
|
|
29 |
closeDB($db);
|
|
|
30 |
return false;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
closeDB($db);
|
|
|
34 |
return true;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
function SaveEditRole() {
|
|
|
38 |
$kr_num = $_REQUEST['kr_num'];
|
|
|
39 |
$kr_role = $_REQUEST['kr_role'];
|
|
|
40 |
|
|
|
41 |
$db = OpenDB();
|
|
|
42 |
$query = "select kr_role from key_role where kr_num = $kr_num";
|
|
|
43 |
$result = QueryDB($db, $query);
|
|
|
44 |
$numrows = numrowsDB($result);
|
|
|
45 |
|
|
|
46 |
if ($numrows != 1) {
|
|
|
47 |
Error("Schlüssel $kr_num ist nicht vorhanden!\n");
|
|
|
48 |
closeDB($db);
|
|
|
49 |
return false;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
$query = "update key_role set kr_role = '$kr_role' where kr_num = $kr_num";
|
|
|
53 |
|
|
|
54 |
if (!TQueryDB($db, $query)) {
|
|
|
55 |
Error("SQL-Error: $query");
|
|
|
56 |
closeDB($db);
|
|
|
57 |
return false;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
closeDB($db);
|
|
|
61 |
return true;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
$newrole = $_REQUEST['newrole'];
|
|
|
65 |
$editrole = $_REQUEST['editrole'];
|
|
|
66 |
|
|
|
67 |
if (!isset($editrole)) {
|
|
|
68 |
$editrole = 0;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$savenewrole = $_REQUEST['savenewrole'];
|
|
|
72 |
$saveeditrole = $_REQUEST['saveeditrole'];
|
|
|
73 |
|
|
|
74 |
if (isset($savenewrole)) {
|
|
|
75 |
SaveNewRole();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
if (isset($saveeditrole)) {
|
|
|
79 |
SaveEditRole();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
?>
|
|
|
83 |
<form action="role.php" method="post">
|
|
|
84 |
<input type="hidden" name="headline" value="18">
|
|
|
85 |
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>">
|
|
|
86 |
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
|
|
|
87 |
<input type="hidden" name="unum" value="<? echo "$unum"; ?>">
|
|
|
88 |
<button type="submit" name="newrole" value="newrole"><img src="image/button_newrole.png" border=0 alt="Neue Rolle"></button>
|
|
|
89 |
<?php
|
|
|
90 |
$db = OpenDB();
|
|
|
91 |
$query = "select kr_num, kr_role from key_role order by kr_num";
|
|
|
92 |
$result = QueryDB($db, $query);
|
|
|
93 |
|
|
|
94 |
if (!$result) {
|
|
|
95 |
echo "</table></form><br>\n";
|
|
|
96 |
Error("SQL-Error: $query");
|
|
|
97 |
require('footer.inc');
|
|
|
98 |
exit;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
$numrows = numrowsDB($result);
|
|
|
102 |
|
|
|
103 |
if ($numrows > 0 || isset($newrole)) {
|
|
|
104 |
?>
|
|
|
105 |
<table border=1>
|
|
|
106 |
<tr>
|
|
|
107 |
<td class="tbhead"> </td>
|
|
|
108 |
<td class="tbhead">Key</td>
|
|
|
109 |
<td class="tbhead">Text</td>
|
|
|
110 |
</tr>
|
|
|
111 |
<?php
|
|
|
112 |
$row = 0;
|
|
|
113 |
|
|
|
114 |
while ($row < $numrows) {
|
|
|
115 |
$data = fetchDB($result, $row);
|
|
|
116 |
$kr_num = $data[0];
|
|
|
117 |
$kr_role = $data[1];
|
|
|
118 |
|
|
|
119 |
if ($kr_num == $editrole) {
|
|
|
120 |
echo "<input type=\"hidden\" name=\"kr_num\" value=\"$kr_num\">\n";
|
|
|
121 |
echo "<tr><td><button type=\"submit\" name=\"saveeditrole\" value=\"$kr_num\"><img src=\"image/new.png\" border=0 alt=\"Edit\"></button></td>";
|
|
|
122 |
echo "<td>$kr_num</td>";
|
|
|
123 |
echo "<td><input type=\"text\" name=\"kr_role\" value=\"$kr_role\" size=40 maxlength=50></td></tr>\n";
|
|
|
124 |
} else {
|
|
|
125 |
echo "<tr><td><button type=\"submit\" name=\"editrole\" value=\"$kr_num\"><img src=\"image/edit.png\" border=0 alt=\"Edit\"></button></td>";
|
|
|
126 |
echo "<td>$kr_num</td><td>$kr_role</td></tr>";
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
$row++;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
if (isset($newrole)) {
|
|
|
133 |
echo "<tr><td><button type=\"submit\" name=\"savenewrole\" value=\"savenewrole\"><img src=\"image/new.png\" border=0 alt=\"Neu\"></button></td>";
|
|
|
134 |
echo "<td><input type=\"text\" name=\"kr_num\" size=7 maxlength=7></td>";
|
|
|
135 |
echo "<td><input type=\"text\" name=\"kr_role\" size=40 maxlength=50></td></tr>\n";
|
|
|
136 |
}
|
|
|
137 |
?>
|
|
|
138 |
</table>
|
|
|
139 |
<button type="submit" name="newrole" value="new"><img src="image/button_newrole.png" border=0 alt="Neue Rolle"></button>
|
|
|
140 |
</form>
|
|
|
141 |
<?php
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
require('footer.inc');
|
|
|
145 |
?>
|
|
|
146 |
|