Example #1
0
 /**
  * Sends the newly generated password to the email of user using the given username in the model.
  * @return boolean whether successfuly send password
  */
 public function send_password($user_id)
 {
     $userModel = new SuUser();
     $model = new Admin_ajax();
     $password = $userModel->random_password();
     $this->user_password = md5($password);
     $userData = $this->getUserData($user_id);
     $userData['user_password'] = $password;
     ///////////////////////////////////////////////////////////////////////
     ///////////Create Forgot password email Template //////////////////////
     ///////////////////////////////////////////////////////////////////////
     $tempemaildata = $model->customOneRowQuery("SELECT * FROM `su_notification_templates`  WHERE type='email' and alias='forgotpassward'");
     $emailtemplate = new Template();
     $emailtemplate->setKeys($userData);
     $emailText = $emailtemplate->replace($tempemaildata['content']);
     ///////////////////////////////////////////////////////////////////////
     ///////////End Create Forgot password email Template //////////////////
     ///////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////
     ///////////Create Forgot password email Template //////////////////////
     ///////////////////////////////////////////////////////////////////////
     $tempsmsdata = $model->customOneRowQuery("SELECT * FROM `su_notification_templates`  WHERE type='sms' and alias='forgotpassward'");
     $smstemplate = new Template();
     $smstemplate->setKeys($userData);
     $smsText = $smstemplate->replace($tempsmsdata['content']);
     //print_r($userData);die;
     ///////////////////////////////////////////////////////////////////////
     ///////////End Create Forgot password email Template //////////////////
     ///////////////////////////////////////////////////////////////////////
     //        $data = array("name" => $userData["user_fname"], "email" => $userData["user_email"], "password" => $password);
     //        $msg_data = 'Below are the new password for PayWayhelp account :
     //
     //                   Username/Email : ' . $userData["user_email"] . '
     //
     //                   Password :  '******'';
     // if ($insert) {
     if (isset($userData["user_notification"]) && $userData["user_notification"] == 'both') {
         //$UserEmail = new UserEmail($this->username,$this->user_password);
         $UserEmail = new UserEmail();
         //$status = $UserEmail->SendMail($userData["user_email"], 'Reset Password', 'reset_password', $data);
         $UserEmail->SendCustomMail($userData["user_email"], "Paywayhelp : Reset Password", $emailText);
         //sms api
         //$msg_id = $this->send_sms_via_gateway($userData["user_fname"], 'Reset Password', $msg_data);
         $msg_id = $this->send_sms_via_gateway($userData["user_phoneNumber"], 'Reset Password', $smsText);
         //add message data
         $admin_ajax->insert_data('su_message', array('message_id' => $msg_id, 'message_user' => $user_id, 'message_date' => date('Y-m-d H:i:s')));
     } elseif (isset($userData["user_notification"]) && $userData["user_notification"] == 'mail') {
         $UserEmail = new UserEmail();
         //$status = $UserEmail->SendMail($userData["user_email"], 'Reset Password', 'reset_password', $data);
         $UserEmail->SendCustomMail($userData["user_email"], "Paywayhelp : Reset Password", $emailText);
     } elseif (isset($userData["user_notification"]) && $userData["user_notification"] == 'sms') {
         //sms api
         $msg_id = $this->send_sms_via_gateway($userData["user_phoneNumber"], 'Reset Password', $smsText);
         //add message data
         $admin_ajax->insert_data('su_message', array('message_id' => $msg_id, 'message_user' => $user_id, 'message_date' => date('Y-m-d H:i:s')));
     }
     return $msg_id;
     /*  } else {
         return false;
         } */
 }