5 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/admin/db/users_db.inc");
14 simple_page_mode(false);
15 //-------------------------------------------------------------------------------------------------
17 function can_process()
20 if (strlen($_POST['user_id']) < 4)
22 display_error( _("The user login entered must be at least 4 characters long."));
27 if ($_POST['password'] != "")
29 if (strlen($_POST['password']) < 4)
31 display_error( _("The password entered must be at least 4 characters long."));
32 set_focus('password');
36 if (strstr($_POST['password'], $_POST['user_id']) != false)
38 display_error( _("The password cannot contain the user login."));
39 set_focus('password');
47 //-------------------------------------------------------------------------------------------------
49 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
54 if ($selected_id != '')
56 update_user($_POST['user_id'], $_POST['real_name'], $_POST['phone'],
57 $_POST['email'], $_POST['Access'], $_POST['language']);
59 if ($_POST['password'] != "")
60 update_user_password($_POST['user_id'], md5($_POST['password']));
62 display_notification_centered(_("The selected user has been updated."));
66 add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']),
67 $_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language']);
69 display_notification_centered(_("A new user has been added."));
75 //-------------------------------------------------------------------------------------------------
77 if ($Mode == 'Delete')
79 delete_user($selected_id);
80 display_notification_centered(_("User has been deleted."));
84 //-------------------------------------------------------------------------------------------------
88 unset($_POST); // clean all input fields
91 $result = get_users();
93 start_table($table_style);
95 if ($_SESSION["wa_current_user"]->access == 2)
96 $th = array(_("User login"), _("Full Name"), _("Phone"),
97 _("E-mail"), _("Last Visit"), _("Access Level"), "", "");
99 $th = array(_("User login"), _("Full Name"), _("Phone"),
100 _("E-mail"), _("Last Visit"), _("Access Level"), "");
103 $k = 0; //row colour counter
105 while ($myrow = db_fetch($result))
108 alt_table_row_color($k);
110 $last_visit_date = sql2date($myrow["last_visit_date"]);
112 /*The security_headings array is defined in config.php */
114 label_cell($myrow["user_id"]);
115 label_cell($myrow["real_name"]);
116 label_cell($myrow["phone"]);
117 label_cell($myrow["email"]);
118 label_cell($last_visit_date, "nowrap");
119 label_cell($security_headings[$myrow["full_access"]]);
120 edit_button_cell("Edit".$myrow["user_id"], _("Edit"));
121 if (strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username) &&
122 $_SESSION["wa_current_user"]->access == 2)
123 edit_button_cell("Delete".$myrow["user_id"], _("Delete"));
128 } //END WHILE LIST LOOP
134 //-------------------------------------------------------------------------------------------------
137 start_table($table_style2);
138 if ($selected_id != '')
140 if ($Mode == 'Edit') {
141 //editing an existing User
142 $myrow = get_user($selected_id);
144 $_POST['user_id'] = $myrow["user_id"];
145 $_POST['real_name'] = $myrow["real_name"];
146 $_POST['phone'] = $myrow["phone"];
147 $_POST['email'] = $myrow["email"];
148 $_POST['Access'] = $myrow["full_access"];
149 $_POST['language'] = $myrow["language"];
151 hidden('selected_id', $selected_id);
155 label_row(_("User login:"), $_POST['user_id']);
158 { //end of if $selected_id only do the else when a new record is being entered
159 text_row(_("User Login:"), "user_id", null, 22, 20);
161 $_POST['password'] = "";
163 label_cell(_("Password:"));
164 label_cell("<input type='password' name='password' size=22 maxlength=20 value='" . $_POST['password'] . "'>");
167 if ($selected_id != '')
169 table_section_title(_("Enter a new password to change, leave empty to keep current."));
172 text_row_ex(_("Full Name").":", 'real_name', 50);
174 text_row_ex(_("Telephone No.:"), 'phone', 30);
176 text_row_ex(_("Email Address:"), 'email', 50);
178 security_headings_list_row(_("Access Level:"), 'Access', null);
180 languages_list_row(_("Language:"), 'language', null);
184 submit_add_or_update_center($selected_id == '', '', true);