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