public function recoverUsername(Application_Model_User $user) { $options['email'] = $user->getEmail(); $options['username'] = $user->getUsername(); $options['firstName'] = $user->getFirstName(); $options['lastName'] = $user->getLastName(); $Mail = new Base_Mail(); $Mail->sendForgotUsernameMail($options); }
public function errorAction() { //$this->_helper->layout->setLayout('home-layout'); $errors = $this->_getParam('error_handler'); $flag = true; switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: //var_dump($this->_getParam('controller')); $userM = new Application_Model_User(); $user = $userM->fetchRow("username='******'controller')}'"); if ($user !== false) { $flag = false; //Forward to the controller $this->_forward('index', 'profile', 'default', array('id' => $user->getId())); } case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Page not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = 'Application error'; break; } // Log exception, if logger available if ($log = $this->getLog()) { $log->crit($this->view->message, $errors->exception); } // conditionally display exceptions //var_dump($this->getInvokeArg('displayExceptions')); if ($this->getInvokeArg('displayExceptions') == true) { $this->view->exception = $errors->exception; } $this->view->request = $errors->request; $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $this->view->error_flag = $config->error_flag; //Mail $options['message'] = $this->view->message; if ($this->getInvokeArg('displayExceptions') == true) { $options['exception'] = $this->view->exception->getMessage(); $options['traceString'] = $this->view->exception->getTraceAsString(); } $options['params'] = $this->view->request->getParams(); $options['requesturi'] = $this->view->request->getRequestUri(); $options['siteurl'] = Zend_Registry::get('siteurl'); $mail = new Base_Mail(); if ($flag == true) { $mail->sendErrorMail($options); } }
public static function getInstance($dbwrite) { if (!self::$instance) { self::$instance = new self($dbwrite); } return self::$instance; }
public function messagesAction() { $username = $this->_getParam('username'); $user = $this->getLeftPanel($username); //Redirect user if not active, added by Mahipal Adhikari on 3-jan-2011 $userM = new Application_Model_User(); if (false === $userM->checkUserActiveStatus($user->getId())) { $this->_helper->redirector('index', 'index'); } //diaply username on left panel of user profile page $this->view->userObject = $user; $userNs = new Zend_Session_Namespace('members'); $form = new Application_Form_CreateMessages(); if ($userNs->userId) { $form->getElement('toEmail')->setValue($user->getFirstName() . ' ' . $user->getLastName()); $form->getElement('toId')->setValue($user->getId()); } $this->view->form = $form; if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getPost(); if ($form->isValid($params)) { $params['status'] = 'inbox'; //$params['fromId'] = $userId; $params['fromId'] = $userNs->userId; $params['parentId'] = 0; $messages = new Application_Model_Message($params); $savemsg = $messages->save(); if ($savemsg) { /*------------------------- NOTIFICATION EMAIL ---------------------------*/ $userObj = new Application_Model_User(); $valTo = $userObj->find($params['toId']); $toFirstName = $valTo->getFirstName(); $toLastName = $valTo->getLastName(); $option['toName'] = $toFirstName . ' ' . $toLastName; $option['toEmail'] = trim($valTo->getEmail()); $option['message'] = $params['body']; $option['messageId'] = $savemsg; $valfrom = $userObj->find($userNs->userId); $option['fromName'] = $valfrom->getFirstName() . ' ' . $valfrom->getLastName(); $mail = new Base_Mail(); $mail->sendNotificationMail("message_notification", $option); $_SESSION["flash_msg"] = "Message has been sent."; $form->reset(); } else { $_SESSION["flash_msg"] = "Error occured while sending message, please try again later."; } //redirect user $this->_redirect($this->view->seoUrl('/profile/messages/username/' . $username)); } $this->view->form = $form; } }
public function changeRequestStatusAction() { $id = $this->_getParam('id'); $request = $this->getRequest(); if ($request->isPost()) { $options = $request->getPost(); if (trim($options['remarks']) == '' && $options['submit'] == "Close Request") { $this->_flashMessenger->addMessage(array('error' => 'Please enter remarks.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/change-request-status/id/' . $id)); } else { if ($options['submit'] == 'Cancel') { $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/request-received')); } else { $usersNs = new Zend_Session_Namespace("members"); $userId = $usersNs->userId; $model = new Application_Model_Request(); $model = $model->find($id); $model->setStatus("close"); $model->setUserId($userId); $model->setRemarks($options['remarks']); if ($model->save()) { //send email notificaiton to requested by person $mail = new Base_Mail(); $mail->sendRequestCompleteNotification($id); $this->_flashMessenger->addMessage(array('success' => 'Request status changed successfully')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/request-received')); } } } } $model = new Application_Model_Request(); $model = $model->find($id); if (false === $model) { $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/request-received')); } $this->view->request = $model; if ($model->getStatus() == "close") { $pageA = $this->view->navigation()->findActive($this->view->navigation()->getContainer()); if (isset($pageA['page'])) { $pageA['page']->setLabel("View Request Status"); } } }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 27-Jan-2011 * @Description : Report Journal/Wall and other items as abuse to admin */ public function reportAbuseAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //get request parameters $item_id = $this->_getParam('item_id'); $item_type = $this->_getParam('item_type'); //get logged in user ID $usersNs = new Zend_Session_Namespace('members'); $user_id = $usersNs->userId; if ($user_id == "" || $user_id == 0) { $JsonResultArray = array('error' => 1, 'response' => "Please login to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_id == "" || $item_id == 0) { $JsonResultArray = array('error' => 2, 'response' => "No item is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_type == "") { $JsonResultArray = array('error' => 2, 'response' => "No item type is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } //Get user report abuse info for item $modelM = new Application_Model_ReportAbuse(); $modelRes = $modelM->fetchRow("item_id={$item_id} AND item_type='{$item_type}' AND user_id={$user_id}"); if ($modelRes && $modelRes->getStatus() == 1) { $JsonResultArray = array('error' => 2, 'response' => "You've already reported this as abuse."); echo Zend_Json::encode($JsonResultArray); exit; } else { $params["itemId"] = $item_id; $params["itemType"] = $item_type; $params["userId"] = $user_id; $params["comment"] = ""; $params["status"] = 1; $modelM->setOptions($params); $dbRes = $modelM->save(); if ($dbRes) { //get item type information $itemTitle = ""; $authorId = ""; $author = ""; if ($item_type == 'blog') { $blogM = new Application_Model_Blog(); $blogRes = $blogM->find($item_id); $itemTitle = $blogRes->getTitle(); $authorId = $blogRes->getUserId(); $blog_url = Zend_Registry::get('siteurl') . "/journal/view-post/blog_id/" . $item_id; $itemTitle = "<a href='" . $blog_url . "' target='_blank'>" . $itemTitle . "</a>"; } else { if ($item_type == 'wall') { $wallM = new Application_Model_Wall(); $wallRes = $wallM->find($item_id); $itemTitle = $wallRes->getStatus(); $authorId = $wallRes->getUserId(); } else { if ($item_type == 'photo') { $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $albumPhotoRes = $objModelAlbumPhoto->find($item_id); $itemTitle = $albumPhotoRes->getName(); $authorId = $albumPhotoRes->getUserId(); } } } //get Blog/Wall owner/author user information if ($authorId != "") { $useAuthor = new Application_Model_User(); $authorRes = $useAuthor->find($authorId); $author = ucfirst($authorRes->getFirstName()) . " " . ucfirst($authorRes->getLastName()) . " (" . $authorRes->getUsername() . ")"; } //get user information who is reporting abuse item $userM = new Application_Model_User(); $userR = $userM->find($user_id); $reporterName = ucfirst($userR->getFirstName()) . " " . ucfirst($userR->getLastName()) . " (" . $userR->getUsername() . ")"; $reporterEmail = $userR->getEmail(); //Now send report abuse email to Administrator $settings = new Admin_Model_GlobalSettings(); $admin_email = $settings->settingValue('report_abuse'); //$admin_email = "*****@*****.**"; $mailOptions['receiver_email'] = $admin_email; $mailOptions['item_type'] = ucfirst($item_type); $mailOptions['item_title'] = $itemTitle; $mailOptions['item_author'] = $author; $mailOptions['reporter_name'] = $reporterName; $mailOptions['reporter_email'] = $reporterEmail; //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendReportAbuseEmail($mailOptions); //send response $JsonResultArray = array('error' => 3, 'response' => "Consider it reported!"); } else { $JsonResultArray = array('error' => 2, 'response' => "Error occured, please try again later."); } } echo Zend_Json::encode($JsonResultArray); exit; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 10-Dec-2010 * @Description: Save comment for journal section (from Journals, View Post page) */ public function saveJournalCommentAction() { $this->_helper->layout->disableLayout(); $userNs = new Zend_Session_Namespace('members'); $this->view->userId = $userNs->userId; if (is_null($userNs->userId) && !numeric($userNs->userId)) { echo "<span style='color:#ff0000;'>Please login to submit your comment on this blog.</span>"; exit; } if ($this->_getParam('comment') == "" || $this->_getParam('comment') == "Comment...") { echo "<span style='color:#ff0000;'>Please enter your comment.</span>"; exit; } $commentM = new Application_Model_Comment(); $commentM->setComment($this->_getParam('comment')); $commentM->setItemId($this->_getParam('item_id')); $commentM->setItemType($this->_getParam('item_type')); $commentM->setParentId(0); $commentM->setPublish(1); $commentM->setUserId($userNs->userId); $id = $commentM->save(); $this->view->item_id = $this->_getParam('item_id'); //get user details who submit comment $userM = new Application_Model_User(); $user = $userM->find($userNs->userId); $strCommentedByName = $user->getFirstName() . " " . $user->getLastName(); //get user details to who wrote the blog (blog owner details) $commentedUserId = $this->_getParam('user_id'); $objCommentedUser = $userM->find($commentedUserId); $params['CommentedPersonName'] = $objCommentedUser->getFirstName() . " " . $objCommentedUser->getLastName(); $params['Comment'] = $this->_getParam('comment'); $params['blog_id'] = $this->_getParam('item_id'); $params['CommentedByName'] = $strCommentedByName; $params['email'] = $objCommentedUser->getEmail(); //now send notification email to blog owner user if ($id > 0) { //send email to user if not commenting own profile if ($commentedUserId != $userNs->userId) { $mail = new Base_Mail(); $mail->sendBlogCommentEmail($params); } //display comment $commentM = new Application_Model_Comment(); $this->view->comment = $commentM->find($id); } else { exit("error"); } $this->render('save-comment'); }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 1-Dec-2010 * @Description: Send recommendation email to admin and save data into database table */ public function sendpoiAction() { die("This functionality is not available for the moment"); exit; $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $userNs = new Zend_Session_Namespace('members'); $user_id = $userNs->userId; if (strtolower($this->_getParam('poi_captcha')) != $_SESSION['securimage_code_value']) { $response = "<span style='color:#ff0000;'>Entered spam protection code is not valid.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; } //save poi recommendation $poiR = new Application_Model_PoiRecommendation(); $poiR->setName($this->_getParam('poi_name')); $poiR->setEmail($this->_getParam('poi_email')); $poiR->setRecommendation($this->_getParam('poi_comments')); $poiR->setCountryId($this->_getParam('country_id')); $poiR->setUserId($user_id); $poiR->setStatus(1); $id = $poiR->save(); //send email and display response if ($id > 0) { //send email to admin $settings = new Admin_Model_GlobalSettings(); $admin_email = $settings->settingValue('admin_email'); //$admin_email = "*****@*****.**"; //set sender information $mailOptions['sender_name'] = ucwords($this->_getParam('poi_name')); $mailOptions['sender_email'] = $this->_getParam('poi_email'); $mailOptions['sender_comments'] = $this->_getParam('poi_comments'); //set receiver information $mailOptions['receiver_email'] = $admin_email; //$mailOptions['receiver_name'] = "Administrator"; //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendPoiRecommendation($mailOptions); //set confirmation message to display $response = "<span style='color:#ff0000;'>Your recommendation has been sent to the Gap Daemon Team for review.</span>"; $JsonResultArray = array('error' => 0, 'response' => $response); } else { $response = "<span style='color:#ff0000;'>Error occured, Please try again later.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); } echo Zend_Json::encode($JsonResultArray); exit; }
public function addFriendAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $userNs = new Zend_Session_Namespace('members'); $userId = $userNs->userId; $params = $this->getRequest()->getParams(); $friendId = $params['id']; $connectionType = $params['ftype']; //check user login if (!isset($userId) && !is_numeric($userId)) { $userM = new Application_Model_User(); $profileUser = $userM->find($friendId); $profileUrl = "/"; if (false !== $profileUser) { $profileUrl = "/" . $profileUser->getUsername(); } $JsonResultArray = array('error' => 1, 'response' => "Please login to make this request.", "profileUrl" => $profileUrl); echo Zend_Json::encode($JsonResultArray); exit; } $friendM = new Application_Model_Friend(); $frienddata = $friendM->fetchRow("user_id = '{$userId}' and friend_id = '{$friendId}'"); $reqStatus = ""; if (false !== $frienddata) { $reqStatus = $frienddata->getStatus(); if ($reqStatus == "pending") { $response = "You already have sent friend request to this user."; } else { if ($reqStatus == "accept") { $response = "This user already added in your friend list."; } else { if ($reqStatus == "decline") { //update friend request status to pending $frienddata->setStatus("pending"); $frienddata->save(); //send friend request email to user $userObj = new Application_Model_User(); //get sender information $Sender = $userObj->find($userId); $mailOptions['sender_email'] = $Sender->getEmail(); $mailOptions['sender_name'] = ucwords($Sender->getFirstName()) . ' ' . ucwords($Sender->getLastName()); //get receiver information $Receiver = $userObj->find($friendId); $mailOptions['receiver_email'] = $Receiver->getEmail(); $mailOptions['receiver_name'] = ucwords($Receiver->getFirstName()) . ' ' . ucwords($Receiver->getLastName()); $mailOptions['con_type'] = ucwords($connectionType); //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendFriendRequest($mailOptions); $response = "Your friend request has been sent."; } else { $response = "Error occured, please contact system administrator."; } } } } else { $data['userId'] = $userId; $data['friendId'] = $friendId; $data['connectionType'] = $connectionType; $data['status'] = 'pending'; $friendM = new Application_Model_Friend($data); $res = $friendM->save(); if ($res) { //send friend request email to user $userObj = new Application_Model_User(); //get sender information $Sender = $userObj->find($userId); $mailOptions['sender_email'] = $Sender->getEmail(); $mailOptions['sender_name'] = ucwords($Sender->getFirstName()) . ' ' . ucwords($Sender->getLastName()); //get receiver information $Receiver = $userObj->find($friendId); $mailOptions['receiver_email'] = $Receiver->getEmail(); $mailOptions['receiver_name'] = ucwords($Receiver->getFirstName()) . ' ' . ucwords($Receiver->getLastName()); $mailOptions['con_type'] = ucwords($connectionType); //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendFriendRequest($mailOptions); $response = "Your friend request has been sent."; } else { $response = "Error occured please try again later."; } } $JsonResultArray = array('error' => 2, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; }