--- a/users.php Wed Mar 12 20:45:56 2008 +0000
+++ b/users.php Tue Mar 25 22:45:31 2008 +0000
@@ -20,144 +20,80 @@
*/
require_once("inc/toolkit.inc.php");
+include_once("inc/header.inc.php");
+verify_permission(user_view_others) ? $perm_view_others = "1" : $perm_view_others = "0" ;
+verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
+verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
+verify_permission(templ_perm_edit) ? $perm_templ_perm_edit = "1" : $perm_templ_perm_edit = "0" ;
+verify_permission(is_ueberuser) ? $perm_is_godlike = "1" : $perm_is_godlike = "0" ;
-if(isset($_POST["submit"])
-&& isset($_POST['username']) && $_POST["username"] != ""
-&& isset($_POST['password']) && $_POST["password"] != ""
-&& isset($_POST['fullname']) && $_POST["fullname"] != ""
-&& isset($_POST['email']) && $_POST["email"] != ""
-&& isset($_POST['level']) && $_POST["level"] > 0)
-{
- if(substr_count($_POST["username"], " ") == 0)
- {
- if(strlen($_POST["password"]) < 8)
- {
- $error = _('Password length should be at least 8 characters.');
- }
- else
- {
- add_user($_POST["username"], $_POST["password"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $_POST["active"]);
- clean_page("users.php");
- }
+if (isset($_POST['commit'])) {
+ foreach ($_POST['user'] as $user) {
+ update_user_details($user);
}
- else
- {
- $error = _('Usernames can\'t contain spaces');
- }
-}
-elseif(isset($_POST["submit"]))
-{
- $error = _('Please fill in all fields');
}
-include_once("inc/header.inc.php");
-if (isset($error) && $error != "")
-{
-?>
- <div class="error"><?php echo $error ; ?></div>
-<?php
-}
-?>
- <h2><?php echo _('User admin'); ?></h2>
-<?php
-if (!level(10))
-{
- error(ERR_LEVEL_10);
-}
-?>
- <h3><?php echo _('Current users'); ?></h3>
-<?php
-$users = show_users('');
-?>
+$users = get_user_detail_list("");
+echo " <h2>" . _('User admin') . "</h2>\n";
+echo " <form method=\"post\">\n";
+echo " <table>\n";
+echo " <tr>\n";
+echo " <th> </th>\n";
+echo " <th>" . _('Username') . "</th>\n";
+echo " <th>" . _('Fullname') . "</th>\n";
+echo " <th>" . _('Description') . "</th>\n";
+echo " <th>" . _('Emailaddress') . "</th>\n";
+echo " <th>" . _('Template') . "</th>\n";
+echo " <th>" . _('Enabled') . "</th>\n";
+echo " </tr>\n";
- <table>
- <tr>
- <th> </th>
- <th><?php echo _('Name'); ?></th>
- <th><?php echo _('Zones'); ?> (<?php echo _('access'); ?>)</th>
- <th><?php echo _('Zones'); ?> (<?php echo _('owner'); ?>)</th>
- <th><?php echo _('Zone list'); ?></th>
- <th><?php echo _('Level'); ?></th>
- <th><?php echo _('Status'); ?></th>
- </tr>
-<?php
-$users = show_users('',ROWSTART,ROWAMOUNT);
-foreach ($users as $c)
-{
- $domains = get_domains_from_userid($c["id"]);
- $num_zones_access = count($domains);
-?>
- <tr>
- <td class="n"><a href="delete_user.php?id=<?php echo $c["id"] ?>"><img src="images/delete.gif" alt="[ <?php echo _('Delete user'); ?> ]"></a></td>
- <td class="n"><a href="edit_user.php?id=<?php echo $c["id"] ?>"><?php echo $c["fullname"] ?></A> (<?php echo $c["username"] ?>)</td>
- <td class="n"><?php echo $num_zones_access ?></td>
- <td class="n"><?php echo $c["numdomains"] ?></td>
- <td class="n">
- <?php
- foreach ($domains as $d)
- {
- ?><a href="delete_domain.php?id=<?php echo $d["id"] ?>"><img src="images/delete.gif" alt="[ <?php echo _('Delete domain'); ?> ]"></a> <a href="edit.php?id=<?php echo $d["id"] ?>"><?php echo $d["name"] ?><?php if ($d["partial"] == "1") { echo " *"; } ; ?></a><br><?php
- }
- ?></td>
- <td class="n"><?php echo $c["level"] ?></td>
- <td class="n"><?php echo get_status($c["active"]) ?></td>
- </tr><?php
- print "\n";
+foreach ($users as $user) {
+ if ($user['active'] == "1" ) {
+ $active = " checked";
+ } else {
+ $active = "";
+ }
+ echo " <input type=\"hidden\" name=\"user[" . $user['uid'] . "][uid]\" value=\"" . $user['uid'] . "\">\n";
+ echo " <tr>\n";
+ echo " <td>\n";
+ if (($user['uid'] == $_SESSION["userid"] && $perm_edit_own == "1") || ($user['uid'] != $_SESSION["userid"] && $perm_edit_others == "1" )) {
+ echo " <a href=\"edit_user.php?id=" . $user['uid'] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _('Edit user') . "\" ]></a>\n";
+ echo " <a href=\"delete_user.php?id=" . $user['uid'] . "\"><img src=\"images/delete.gif\" alt=\"[ " . _('Delete user') . "\" ]></a>\n";
+ } else {
+ echo " \n";
+ }
+ echo " </td>\n";
+ echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][username]\" value=\"" . $user['username'] . "\"></td>\n";
+ echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][fullname]\" value=\"" . $user['fullname'] . "\"></td>\n";
+ echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][descr]\" value=\"" . $user['descr'] . "\"></td>\n";
+ echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][email]\" value=\"" . $user['email'] . "\"></td>\n";
+ echo " <td>\n";
+ echo " <select name=\"user[" . $user['uid'] . "][templ_id]\">\n";
+
+ foreach (list_permission_templates() as $template) {
+ ($template['id'] == $user['tpl_id']) ? $select = " SELECTED" : $select = "" ;
+ echo " <option value=\"" . $template['id'] . "\"" . $select . ">" . $template['name'] . "</option>\n";
+ }
+ echo " </select>\n";
+ echo " </td>\n";
+ echo " <td><input type=\"checkbox\" name=\"user[" . $user['uid'] . "][active]\"" . $active . "></td>\n";
+ echo " </tr>\n";
}
-?>
-
- </table>
- <p><?php echo _('Users may only change some of the records of zones marked with an (*).'); ?></p>
- <p><?php echo _('Number of users') ;?>: <?php echo count($users); ?>.</p>
- <div class="showmax">
-<?php
-show_pages(count($users),ROWAMOUNT);
-?>
- </div> <?php // eo div showmax ?>
+
+echo " </table>\n";
+echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
+echo " </form>\n";
- <h3><?php echo _('Create new user'); ?></h3>
- <form method="post" action="users.php">
- <table>
- <tr>
- <td class="n"><?php echo _('User name'); ?>:</td>
- <td class="n"><input type="text" class="input" name="username" value="<?php if (isset($error)) print $_POST["username"]; ?>"></td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Full name'); ?>:</td>
- <td class="n"><input type="text" class="input" NAME="fullname" VALUE="<?php if (isset($error)) print $_POST["fullname"]; ?>"></td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Password'); ?>:</td>
- <td class="n"><input type="password" class="input" NAME="password" VALUE="<?php if (isset($error)) print $_POST["password"]; ?>"></td>
- </tr>
- <tr>
- <td class="n"><?php echo _('E-mail'); ?>:</td>
- <td class="n"><input type="text" class="input" NAME="email" VALUE="<?php if (isset($error)) print $_POST["email"]; ?>"></td>
- </tr>
- <tr>
- <td class="n"><?php echo _('User level'); ?>:</td>
- <td class="n">
- <select name="level">
- <option value="1">1 (<?php echo leveldescription(1) ?>)</option>
- <option value="5">5 (<?php echo leveldescription(5) ?>)</option>
- <option value="10">10 (<?php echo leveldescription(10) ?>)</option>
- </select>
- </td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Description'); ?>:</td>
- <td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"><?php if (isset($error)) print $_POST["description"]; ?></textarea></td>
- </tr>
- <tr>
- <td class="n"><?php echo _('Active'); ?>:</td>
- <td class="n"><input type="checkbox" name="active" value="1" checked></td>
- </tr>
- <tr>
- <td class="n"> </td>
- <td class="n"><input type="submit" class="button" name="submit" value="<?php echo _('Add user'); ?>"></td>
- </tr>
- </table>
- </form>
-<?php
+echo " <p>\n";
+if ($perm_templ_perm_edit == "1") {
+ echo _('Edit') . " <a href=\"list_perm_templ.php\">" . _('permission templates') . "</a>. \n";
+}
+
+if (verify_permission(user_add_new)) {
+ echo _('Add') . " <a href=\"add_user.php\">" . _('user') . "</a>. \n";
+}
+echo " </p>\n";
+
+
include_once("inc/footer.inc.php");
?>