|
1 <?php |
|
2 |
|
3 /* PowerAdmin, a friendly web-based admin tool for PowerDNS. |
|
4 * See <https://rejo.zenger.nl/poweradmin> for more details. |
|
5 * |
|
6 * Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl> |
|
7 * |
|
8 * This program is free software: you can redistribute it and/or modify |
|
9 * it under the terms of the GNU General Public License as published by |
|
10 * the Free Software Foundation, either version 3 of the License, or |
|
11 * (at your option) any later version. |
|
12 * |
|
13 * This program is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 * GNU General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 */ |
|
21 |
|
22 require_once("inc/toolkit.inc.php"); |
|
23 include_once("inc/header.inc.php"); |
|
24 |
|
25 $id = "-1"; |
|
26 if ((isset($_GET['id'])) || (v_num($_GET['id']))) { |
|
27 $id = $_GET['id'] ; |
|
28 } |
|
29 |
|
30 if ($id == "-1") { |
|
31 error(ERR_INV_INPUT); |
|
32 } elseif (!verify_permission(templ_perm_edit)) { |
|
33 error(ERR_PERM_EDIT_PERM_TEMPL); |
|
34 } else { |
|
35 $id = $_GET['id']; |
|
36 |
|
37 if (isset($_POST['commit'])) { |
|
38 update_perm_templ_details($_POST); |
|
39 } |
|
40 |
|
41 $templ_details = get_permission_template_details($id); |
|
42 $perms_templ = get_permissions_by_template_id($id); |
|
43 $perms_avail = get_permissions_by_template_id(); |
|
44 |
|
45 echo " <h2>" . _('Edit permission template') . "</h2>\n"; |
|
46 echo " <form method=\"post\">\n"; |
|
47 echo " <input type=\"hidden\" name=\"templ_id\" value=\"" . $id . "\">\n"; |
|
48 |
|
49 foreach ($templ_details as $templ) { |
|
50 echo " <table>\n"; |
|
51 echo " <tr>\n"; |
|
52 echo " <th>" . _('Name') . "</th>\n"; |
|
53 echo " <td><input class=\"wide\" type=\"text\" name=\"templ_name\" value=\"" . $templ['name'] . "\"></td>\n"; |
|
54 echo " </tr>\n"; |
|
55 echo " <tr>\n"; |
|
56 echo " <th>" . _('Description') . "</th>\n"; |
|
57 echo " <td><input class=\"wide\" type=\"text\" name=\"templ_descr\" value=\"" . $templ['descr'] . "\"></td>\n"; |
|
58 echo " </tr>\n"; |
|
59 echo " </table>\n"; |
|
60 } |
|
61 |
|
62 echo " <table>\n"; |
|
63 echo " <tr>\n"; |
|
64 echo " <th> </th>\n"; |
|
65 echo " <th>" . _('Name') . "</th>\n"; |
|
66 echo " <th>" . _('Description') . "</th>\n"; |
|
67 echo " </tr>\n"; |
|
68 |
|
69 foreach ($perms_avail as $perm_a) { |
|
70 |
|
71 echo " <tr>\n"; |
|
72 |
|
73 $has_perm = ""; |
|
74 foreach ($perms_templ as $perm_t) { |
|
75 if (in_array( $perm_a['id'], $perm_t )) { |
|
76 $has_perm = "checked"; |
|
77 } |
|
78 } |
|
79 |
|
80 echo " <td><input type=\"checkbox\" name=\"perm_id[]\" value=\"" . $perm_a['id'] . "\" " . $has_perm . "></td>\n"; |
|
81 echo " <td>" . $perm_a['name'] . "</td>\n"; |
|
82 echo " <td>" . $perm_a['descr'] . "</td>\n"; |
|
83 echo " </tr>\n"; |
|
84 } |
|
85 echo " </table>\n"; |
|
86 echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n"; |
|
87 echo " </form>\n"; |
|
88 |
|
89 } |
|
90 |
|
91 include_once("inc/footer.inc.php"); |
|
92 ?> |