public function userAccountSettingsAction() { $users = Application_Model_Users::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'changepassword': if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $userId = ""; if (isset($postData['user_id'])) { $userId = $postData['user_id']; } $oldpassword = ""; //SEND ALL 3 PASSWORDS WITH MD5 FORMAT WHILE HITTING URL if (isset($postData['oldPassword'])) { $oldpassword = $postData['oldPassword']; } $newpassword = ""; if (isset($postData['newPassword'])) { $newpassword = $postData['newPassword']; } $renewpassword = ""; if (isset($postData['reNewPassword'])) { $renewpassword = $postData['reNewPassword']; } if ($userId != '') { $checkoldPassword = $users->authenticateByUserID($userId, md5(sha1($oldpassword))); if ($checkoldPassword) { if ($oldpassword != '' && $newpassword != '' && $renewpassword != '') { if ($newpassword == $renewpassword) { if ($oldpassword != $newpassword) { $Updatepassword = $users->updateUserCreds($userId, $newpassword); if ($Updatepassword) { $response->code = 200; $response->message = "Update Successful"; $response->data = $Updatepassword; } else { $response->code = 100; $response->message = "Invalid Password format"; $response->data = null; } } else { $response->code = 100; $response->message = "New password cannot be same as old password"; $response->data = null; } } else { $response->code = 100; $response->message = "Password didnot match"; $response->data = null; } } else { $response->code = 100; $response->message = "You missed something"; $response->data = null; } } else { $response->code = 401; $response->message = "Your old Passowrd is incorrect"; $response->data = null; } } else { $response->code = 401; $response->message = "You need to login to change password"; $response->data = null; } echo json_encode($response, true); break; } } } }
public function setLocationAction() { // die("ok"); $objUserModel = Application_Model_Users::getInstance(); if ($this->getRequest()->isPost()) { $userId = $this->getRequest()->getPost('uid'); $lat = $this->getRequest()->getPost('lat'); $lng = $this->getRequest()->getPost('lon'); $result = $objUserModel->setUserLocation($userId, $lat, $lng); if ($result) { echo json_encode($result); } else { return 0; } } else { die("not a post"); } }
public function hotelsReviewsAction() { $users = Application_Model_Users::getInstance(); $reviewsratings = Application_Model_Reviews::getInstance(); $hotelssummaryModel = Application_Model_HotelDetails::getInstance(); $response = new stdClass(); $method = $this->getRequest()->getParam('method'); if ($method) { switch ($method) { case 'AddReviews': if ($this->getRequest()->isPost()) { $userid = $this->getRequest()->getPost('user_id'); $starratings = $this->getRequest()->getPost('star_rating'); $reviewdesc = $this->getRequest()->getPost('review_desc'); $hotelid = $this->getRequest()->getPost('hotel_id'); if ($userid != '') { $Userscredentials = $users->validateByUserId($userid); if ($Userscredentials) { if ($hotelid != '' && $reviewdesc != '' && $starratings != '') { $addReview = $reviewsratings->isavailablereview($hotelid, $userid); if (empty($addReview)) { $data['user_id'] = $userid; $data['review_type'] = 0; $data['review_for_id'] = $hotelid; $data['review_rating'] = $starratings; $data['review_description'] = $reviewdesc; $data['review_status'] = 0; $addReview = $reviewsratings->addReview($data); if ($addReview) { $avgofStarRatings = $reviewsratings->getavgratingsofindividualHotel($hotelid); if ($avgofStarRatings) { $addavgRatetoindividualshotels = $hotelssummaryModel->updatehotels($hotelid, $avgofStarRatings); $Admincredentials = $users->validateByAdminId(2); if ($Admincredentials != '') { $admin_id = $Admincredentials['user_id']; $objNotification = Engine_Plugins_Functions::getInstance(); $sent_by = $userid; $sent_to = $admin_id; $noti_url = "/admin/notification"; $Noti_message = "New Review for Product is pending for You"; $addNotification = $objNotification->sendNotificationWithUrl($sent_by, $sent_to, $Noti_message, $noti_url); } $response->code = 200; $response->message = "Review Successfully Added"; $response->data = $addReview; } else { $response->code = 100; $response->message = "Something went wrong"; $response->data = null; } } else { $response->code = 100; $response->message = "Something went wrong..Review Not added, Try again."; $response->data = null; } } else { $response->code = 100; $response->message = "Review Already Added, You can add one review to one product."; $response->data = $addReview; } } else { $response->code = 100; $response->message = "You missed something."; $response->data = null; } } else { $response->code = 100; $response->message = "Their is No user for this ID."; $response->data = null; } } else { $response->code = 100; $response->message = "You need to login to Add Review."; $response->data = null; } } else { $response->code = 401; $response->message = "Access Denied"; $response->data = null; } echo json_encode($response, true); die; break; case 'getReviews': if ($this->getRequest()->isPost()) { $hotelid = $this->getRequest()->getPost('hotel_id'); if ($hotelid != '') { $hotelReviewDetails = $reviewsratings->gethotelsReviewsWithLimit($hotelid); if ($hotelReviewDetails) { $response->code = 200; $response->message = "Suiccessful"; $response->data = $hotelReviewDetails; } else { $response->code = 200; $response->message = "Something went wrong"; } } else { $response->code = 200; $response->message = "Hotel ID should not be Null"; } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); die; break; } } }
public function forgotPasswordAction() { $response = new stdClass(); if ($this->getRequest()->isPost()) { $users = Application_Model_Users::getInstance(); $mailer = Engine_Mailer_MandrillApp_Mailer::getInstance(); $method = $this->getRequest()->getPost('method'); switch ($method) { case "EnterEmailId": if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $fpwemail = ''; if (isset($postData['EmailId'])) { $fpwemail = $postData['EmailId']; } if ($fpwemail != '') { $resetcode = mt_rand(100000, 999999); $exists = $users->checkMail($fpwemail, $resetcode); $uname = $exists['uname']; if ($exists) { //Mandrill mail $template_name = 'ResetPW'; $to = $fpwemail; $username = "******"; $subject = "Ziingo Reset password"; $mergevars = array(array('name' => 'resetcode', 'content' => $resetcode), array('name' => 'usermail', 'content' => $fpwemail), array('name' => 'support', 'content' => "Ziingo Support")); $result = $mailer->sendtemplate($template_name, $to, $username, $subject, $mergevars); //Mandrill mail ends if ($result[0]['status'] == "sent") { // if (true) { $response->code = 200; $response->message = "Mail Sent with Reset code"; $response->data = 1; } } else { $response->code = 100; $response->message = "Email Doesnt Exist. Enter correct Email."; $response->data = null; } } else { $response->code = 100; $response->message = "You missed something"; $response->data = null; } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); break; case "verifyResetCode": if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $fpwemail = ''; if (isset($postData['EmailId'])) { $fpwemail = $postData['EmailId']; } $resetcode = ''; if (isset($postData['resetcode'])) { $resetcode = $postData['resetcode']; } if ($fpwemail != '' && $resetcode != '') { $exists = $users->verifyResetCode($fpwemail, $resetcode); if ($exists) { $response->code = 200; $response->message = "Reset Code Verified Successfully."; $response->data = $exists; } else { $response->code = 100; $response->message = "Reset Code Didnt Matched, Enter Correct Reset Code."; $response->data = null; } } else { $response->code = 100; $response->message = "You missed something"; $response->data = null; } // } else { // $response->code = 401; // $response->message = "Access Denied"; // $response->data = null; // } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); break; case "resetPassword": if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getParams(); $fpwemail = ''; if (isset($postData['EmailId'])) { $fpwemail = $postData['EmailId']; } $resetcode = ''; if (isset($postData['resetcode'])) { $resetcode = $postData['resetcode']; } $password = ''; //Send Password in md5 format if (isset($postData['Password'])) { $password = $postData['Password']; } $re_password = ''; if (isset($postData['rePassword'])) { $re_password = $postData['rePassword']; } if ($fpwemail != '' && $resetcode != '' && $password != '' && $re_password != '') { if ($password == $re_password) { $updated = $users->resetPassword($fpwemail, $resetcode, $password); if ($updated) { $response->code = 200; $response->message = "Password Changed Successfully."; $response->data = $updated; } else { $response->code = 100; $response->message = "Something went Wrong. Provide Correct Input."; $response->data = null; } } else { $response->code = 100; $response->message = "Password Didnt match"; $response->data = null; } } else { $response->code = 100; $response->message = "You missed something"; $response->data = null; } // } else { // $response->code = 401; // $response->message = "Access Denied"; // $response->data = null; // } } else { $response->code = 401; $response->message = "Invalid request"; $response->data = null; } echo json_encode($response, true); break; default: break; } } }