2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
14 include_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 include_once(TR_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');
17 if (isset($_POST['cancel'])) {
18 $msg->addFeedback('CANCELLED');
19 Header('Location: ../index.php');
23 if (isset($_POST['submit'])) {
24 /* password check: password is verified front end by javascript. here is to handle the errors from javascript */
25 if ($_POST['password_error'] <> "")
27 $pwd_errors = explode(",", $_POST['password_error']);
29 foreach ($pwd_errors as $pwd_error)
31 if ($pwd_error == "missing_password")
32 $missing_fields[] = _AT('password');
34 $msg->addError($pwd_error);
38 if (!$msg->containsErrors()) {
39 // insert into the db.
40 $password = $addslashes($_POST['form_password_hidden']);
42 $usersDAO = new UsersDAO();
44 if (!$usersDAO->setPassword($_GET['id'], $password))
46 require(TR_INCLUDE_PATH.'header.inc.php');
47 $msg->printErrors('DB_NOT_UPDATED');
48 require(TR_INCLUDE_PATH.'footer.inc.php');
53 $user_row = $usersDAO->getUserByID($_GET['id']);
55 $tmp_message = _AT('password_change_msg')."\n\n";
56 $tmp_message .= _AT('web_site').' : '.TR_BASE_HREF."\n";
57 $tmp_message .= _AT('login_name').' : '.$user_row['login']."\n";
59 require(TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php');
60 $mail = new TransformableMailer;
61 $mail->From = $_config['contact_email'];
62 $mail->AddAddress($user_row['email']);
63 $mail->Subject = $_config['site_name'] . ': ' . _AT('password_changed');
64 $mail->Body = $tmp_message;
68 $msg->addError('SENDING_ERROR');
72 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
75 header('Location: index.php');
80 /* template starts here */
81 $savant->display('user/user_password.tmpl.php');