Moving 2.0 development version to main trunk.
[fa-stable.git] / admin / change_current_user_password.php
1 <?php
2
3 $page_security=1;
4 $path_to_root="..";
5 include_once($path_to_root . "/includes/session.inc");
6
7 page(_("Change password"));
8
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
11
12 include_once($path_to_root . "/admin/db/users_db.inc");
13
14 $selected_id = $_SESSION["wa_current_user"]->username;
15
16
17 function can_process()
18 {
19
20         if (strlen($_POST['password']) < 4)
21         {
22                 display_error( _("The password entered must be at least 4 characters long."));
23                 set_focus('password');
24                 return false;
25         }
26
27         if (strstr($_POST['password'], $_POST['user_id']) != false)
28         {
29                 display_error( _("The password cannot contain the user login."));
30                 set_focus('password');
31                 return false;
32         }
33
34         if ($_POST['password'] != $_POST['passwordConfirm'])
35         {
36                 display_error( _("The passwords entered are not the same."));
37                 set_focus('password');
38                 return false;
39         }
40
41         return true;
42 }
43
44 if (isset($_POST['UPDATE_ITEM']))
45 {
46
47         if (can_process())
48         {
49                 update_user_password($_POST['user_id'], md5($_POST['password']));
50             display_notification(_("Your password has been updated."));
51                 $Ajax->activate('_page_body');
52         }
53 }
54
55 start_form();
56
57 start_table($table_style);
58
59 $myrow = get_user($selected_id);
60
61 $_POST['user_id'] = $myrow["user_id"];
62 hidden('selected_id', $selected_id);
63 hidden('user_id', $_POST['user_id']);
64
65 label_row(_("User login:"), $_POST['user_id']);
66
67 $_POST['password'] = "";
68 $_POST['passwordConfirm'] = "";
69
70 start_row();
71 label_cell(_("Password:"));
72 label_cell("<input type='password' name='password' size=22 maxlength=20 value='" . $_POST['password'] . "'>");
73 end_row();
74
75 start_row();
76 label_cell(_("Repeat password:"));
77 label_cell("<input type='password' name='passwordConfirm' size=22 maxlength=20 value='" . $_POST['passwordConfirm'] . "'>");
78 end_row();
79
80 table_section_title(_("Enter your new password in the fields."));
81
82 end_table(1);
83
84 submit_center( 'UPDATE_ITEM', _('Change password'), true, '', true);
85 end_form();
86 end_page();
87 ?>