users.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:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 110
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    23
include_once("inc/header.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    24
verify_permission(user_view_others) ? $perm_view_others = "1" : $perm_view_others = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    25
verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    26
verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    27
verify_permission(templ_perm_edit) ? $perm_templ_perm_edit = "1" : $perm_templ_perm_edit = "0" ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    28
verify_permission(is_ueberuser) ? $perm_is_godlike = "1" : $perm_is_godlike = "0" ; 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
105
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    30
unset($commit_button);
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    31
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    32
if (isset($_POST['commit'])) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    33
	foreach ($_POST['user'] as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    34
		update_user_details($user);
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    35
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    38
$users = get_user_detail_list("");
110
455405c757e1 [feladat @ 210]
rejo
parents: 105
diff changeset
    39
echo "    <h2>" . _('User administration') . "</h2>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    40
echo "    <form method=\"post\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    41
echo "     <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    42
echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    43
echo "       <th>&nbsp;</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    44
echo "       <th>" . _('Username') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    45
echo "       <th>" . _('Fullname') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    46
echo "       <th>" . _('Description') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    47
echo "       <th>" . _('Emailaddress') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    48
echo "       <th>" . _('Template') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    49
echo "       <th>" . _('Enabled') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    50
echo "      </tr>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    52
foreach ($users as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    53
	if ($user['active'] == "1" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    54
		$active = " checked";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    55
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    56
		$active = "";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    57
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    58
	if (($user['uid'] == $_SESSION["userid"] && $perm_edit_own == "1") || ($user['uid'] != $_SESSION["userid"] && $perm_edit_others == "1" )) {
105
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    59
		$commit_button = "1";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    60
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    61
		echo "      <input type=\"hidden\" name=\"user[" . $user['uid'] . "][uid]\" value=\"" . $user['uid'] . "\">\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    62
		echo "      <tr>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    63
		echo "       <td>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    64
		echo "        <a href=\"edit_user.php?id=" . $user['uid'] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _('Edit user') . "\" ]></a>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    65
		echo "        <a href=\"delete_user.php?id=" . $user['uid'] . "\"><img src=\"images/delete.gif\" alt=\"[ " . _('Delete user') . "\" ]></a>\n";
105
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    66
		echo "       </td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    67
		echo "       <td><input type=\"text\" name=\"user[" . $user['uid'] . "][username]\" value=\"" . $user['username'] . "\"></td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    68
		echo "       <td><input type=\"text\" name=\"user[" . $user['uid'] . "][fullname]\" value=\"" . $user['fullname'] . "\"></td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    69
		echo "       <td><input type=\"text\" name=\"user[" . $user['uid'] . "][descr]\" value=\"" . $user['descr'] . "\"></td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    70
		echo "       <td><input type=\"text\" name=\"user[" . $user['uid'] . "][email]\" value=\"" . $user['email'] . "\"></td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    71
		echo "       <td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    72
		if ($perm_templ_perm_edit == "1") {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    73
			echo "        <select name=\"user[" . $user['uid'] . "][templ_id]\">\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    74
			foreach (list_permission_templates() as $template) {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    75
				($template['id'] == $user['tpl_id']) ? $select = " SELECTED" : $select = "" ;
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    76
				echo "          <option value=\"" . $template['id'] . "\"" . $select . ">" . $template['name'] . "</option>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    77
			}
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    78
			echo "         </select>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    79
		} else {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    80
			echo $user['tpl_name'];
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    81
		}
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    82
		echo "       </td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    83
		echo "       <td><input type=\"checkbox\" name=\"user[" . $user['uid'] . "][active]\"" . $active . "></td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    84
		echo "      </tr>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    85
	} else {
105
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    86
		echo "      <tr>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    87
		echo "       <td>&nbsp;</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    88
		echo "       <td>" . $user['username'] . "</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    89
		echo "       <td>" . $user['fullname'] . "</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    90
		echo "       <td>" . $user['descr'] . "</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    91
		echo "       <td>" . $user['email'] . "</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    92
		echo "       <td>" . $user['tpl_name'] . "</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    93
		if ($active == " checked") {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    94
			echo "       <td>Yes</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    95
		} else {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    96
			echo "       <td>No</td>\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    97
		}
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
    98
		echo "      </tr>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    99
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   101
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   102
echo "     </table>\n";
105
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
   103
if ($commit_button) {
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
   104
	echo "     <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
df46fd74c2ee [feladat @ 205]
rejo
parents: 99
diff changeset
   105
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   106
echo "    </form>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
99
a4b469dac161 [feladat @ 199]
rejo
parents: 82
diff changeset
   108
echo "    <ul>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   109
if ($perm_templ_perm_edit == "1") {
110
455405c757e1 [feladat @ 210]
rejo
parents: 105
diff changeset
   110
	echo "<li><a href=\"list_perm_templ.php\">" . _('Edit permission template') . "</a>.</li>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   111
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   112
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   113
if (verify_permission(user_add_new)) {
99
a4b469dac161 [feladat @ 199]
rejo
parents: 82
diff changeset
   114
	echo "<li><a href=\"add_user.php\">" . _('Add user') . "</a>.</li>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   115
}
99
a4b469dac161 [feladat @ 199]
rejo
parents: 82
diff changeset
   116
echo "    </ul>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   117
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   118
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
?>