edit_perm_templ.php
author rejo
Mon, 31 Mar 2008 21:10:19 +0000
changeset 120 982f722376b4
parent 119 f74e4f88b680
child 126 cb06e3e29ed8
permissions -rw-r--r--
[feladat @ 223] Bugfix. No domain id was provided when entering 'edit record' page from a search query. Changed code so 'edit record' does not rely on domain id provided by user but determines it from the record id that is about to be changed. This closes ticket:31.
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
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 116
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
82
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
89
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    41
	$templ = get_permission_template_details($id);
82
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
89
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    49
	echo "     <table>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    50
	echo "      <tr>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    51
	echo "       <th>" . _('Name') . "</th>\n"; 
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    52
	echo "       <td><input class=\"wide\" type=\"text\" name=\"templ_name\" value=\"" . $templ['name'] . "\"></td>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    53
	echo "      </tr>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    54
	echo "      <tr>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    55
	echo "       <th>" . _('Description') . "</th>\n"; 
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    56
	echo "       <td><input class=\"wide\" type=\"text\" name=\"templ_descr\" value=\"" . $templ['descr'] . "\"></td>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    57
	echo "      </tr>\n";
61c49e66c9b0 [feladat @ 189]
rejo
parents: 85
diff changeset
    58
	echo "     </table>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    59
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    60
	echo "     <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    61
	echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    62
	echo "       <th>&nbsp;</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    63
	echo "       <th>" . _('Name') . "</th>\n"; 
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    64
	echo "       <th>" . _('Description') . "</th>\n"; 
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    65
	echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    66
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    67
	foreach ($perms_avail as $perm_a) {
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    68
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    69
		echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    70
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    71
		$has_perm = "";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    72
		foreach ($perms_templ as $perm_t) {
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    73
			if (in_array( $perm_a['id'], $perm_t )) {
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    74
				$has_perm = "checked";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    75
			}
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    76
		}
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    77
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    78
		echo "       <td><input type=\"checkbox\" name=\"perm_id[]\" value=\"" . $perm_a['id'] . "\" " . $has_perm . "></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    79
		echo "       <td>" . $perm_a['name'] . "</td>\n";
116
cc09385a62aa [feladat @ 219]
rejo
parents: 89
diff changeset
    80
		echo "       <td>" . _($perm_a['descr']) . "</td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    81
		echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    82
	}
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    83
	echo "     </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    84
	echo "     <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    85
	echo "     </form>\n";
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    86
}
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    87
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    88
include_once("inc/footer.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents:
diff changeset
    89
?>