You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

edit_perm_templ.php 3.5KB

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