include_once($path_to_root . "/admin/db/users_db.inc");
-if (isset($_GET['selected_id']))
-{
- $selected_id = $_GET['selected_id'];
-}
-elseif (isset($_POST['selected_id']))
-{
- $selected_id = $_POST['selected_id'];
-}
-
-//-------------------------------------------------------------------------------------------------
-
-if (isset($_GET['AddedID']))
-{
- display_notification_centered(_("A new user has been added."));
-}
-
-if (isset($_GET['UpdatedID']))
-{
- display_notification_centered(_("The selected user has been updated."));
-}
-
-if (isset($_GET['DeletedID']))
-{
- display_notification_centered(_("User has been deleted."));
-}
-
+simple_page_mode(false);
//-------------------------------------------------------------------------------------------------
function can_process()
if (strlen($_POST['password']) < 4)
{
display_error( _("The password entered must be at least 4 characters long."));
- set_focus('password');
+ set_focus('password');
return false;
}
if (strstr($_POST['password'], $_POST['user_id']) != false)
{
display_error( _("The password cannot contain the user login."));
- set_focus('password');
+ set_focus('password');
return false;
}
}
//-------------------------------------------------------------------------------------------------
-if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
+if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
{
if (can_process())
{
- if (isset($selected_id))
+ if ($selected_id != '')
{
update_user($_POST['user_id'], $_POST['real_name'], $_POST['phone'],
$_POST['email'], $_POST['Access'], $_POST['language']);
if ($_POST['password'] != "")
update_user_password($_POST['user_id'], md5($_POST['password']));
- unset($selected_id);
- meta_forward($_SERVER['PHP_SELF'], "UpdatedID=1");
+ display_notification_centered(_("The selected user has been updated."));
}
else
{
add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']),
$_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language']);
- unset($selected_id);
- meta_forward($_SERVER['PHP_SELF'], "AddedID=1");
+ display_notification_centered(_("A new user has been added."));
}
+ $Mode = 'RESET';
}
}
//-------------------------------------------------------------------------------------------------
-if (isset($_GET['delete']))
+if ($Mode == 'Delete')
{
delete_user($selected_id);
- unset($selected_id);
-
- meta_forward($_SERVER['PHP_SELF'], "DeletedID=1");
+ display_notification_centered(_("User has been deleted."));
+ $Mode = 'RESET';
}
//-------------------------------------------------------------------------------------------------
+if ($Mode == 'RESET')
+{
+ $selected_id = '';
+ unset($_POST); // clean all input fields
+}
$result = get_users();
-
+start_form();
start_table($table_style);
if ($_SESSION["wa_current_user"]->access == 2)
label_cell($myrow["email"]);
label_cell($last_visit_date, "nowrap");
label_cell($security_headings[$myrow["full_access"]]);
- edit_link_cell("selected_id=".$myrow["user_id"]);
+ edit_button_cell("Edit".$myrow["user_id"], _("Edit"));
if (strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username) &&
$_SESSION["wa_current_user"]->access == 2)
- delete_link_cell("selected_id=".$myrow["user_id"]."&delete=1");
+ edit_button_cell("Delete".$myrow["user_id"], _("Delete"));
+ else
+ label_cell('');
end_row();
} //END WHILE LIST LOOP
end_table();
+end_form();
+echo '<br>';
//-------------------------------------------------------------------------------------------------
-
-hyperlink_no_params($_SERVER['PHP_SELF'], _("New User"));
-
start_form();
start_table($table_style2);
-if (isset($selected_id))
+if ($selected_id != '')
{
- //editing an existing User
-
- $myrow = get_user($selected_id);
-
- $_POST['user_id'] = $myrow["user_id"];
- $_POST['real_name'] = $myrow["real_name"];
- $_POST['phone'] = $myrow["phone"];
- $_POST['email'] = $myrow["email"];
- $_POST['Access'] = $myrow["full_access"];
- $_POST['language'] = $myrow["language"];
-
+ if ($Mode == 'Edit') {
+ //editing an existing User
+ $myrow = get_user($selected_id);
+
+ $_POST['user_id'] = $myrow["user_id"];
+ $_POST['real_name'] = $myrow["real_name"];
+ $_POST['phone'] = $myrow["phone"];
+ $_POST['email'] = $myrow["email"];
+ $_POST['Access'] = $myrow["full_access"];
+ $_POST['language'] = $myrow["language"];
+ }
hidden('selected_id', $selected_id);
- hidden('user_id', $_POST['user_id']);
+ hidden('user_id');
start_row();
label_row(_("User login:"), $_POST['user_id']);
-
}
else
{ //end of if $selected_id only do the else when a new record is being entered
label_cell("<input type='password' name='password' size=22 maxlength=20 value='" . $_POST['password'] . "'>");
end_row();
-if (isset($selected_id))
+if ($selected_id != '')
{
table_section_title(_("Enter a new password to change, leave empty to keep current."));
}
text_row_ex(_("Email Address:"), 'email', 50);
-security_headings_list_row(_("Access Level:"), "Access", null);
+security_headings_list_row(_("Access Level:"), 'Access', null);
languages_list_row(_("Language:"), 'language', null);
end_table(1);
-submit_add_or_update_center(!isset($selected_id));
+submit_add_or_update_center($selected_id == '', '', true);
end_form();
end_page();