示例#1
0
 public function saveCommentAction()
 {
     $this->_helper->layout->disableLayout();
     //$this->_helper->viewRenderer->setNoRender(true);
     $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 wall.</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['wall_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->sendNotificationMail("comment", $params);
         }
         //display comment
         $commentM = new Application_Model_Comment();
         $this->view->comment = $commentM->find($id);
     } else {
         exit("error");
     }
 }
 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;
     }
 }
示例#3
0
 public function myMessagesAction()
 {
     $this->_helper->layout->setLayout('2column');
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     $msg = $this->_getParam('msg');
     $reply = $this->_getParam('reply');
     $username = $this->_getParam('username');
     $form = new Application_Form_CreateMessages();
     $this->view->form = $form;
     $this->view->selectedTab = 0;
     //set update messages
     if (isset($_SESSION['session_error_msg']) && $_SESSION['session_error_msg'] != "") {
         $session_error_msg = $_SESSION['session_error_msg'];
         if ($session_error_msg == "success") {
             $this->view->msg = "Message has been sent.";
             $this->view->selectedTab = 2;
         }
         if ($session_error_msg == "failed") {
             $this->view->msg = "Message can not be sent, please try again later.";
             $this->view->selectedTab = 2;
         }
         if ($session_error_msg == "accept") {
             $this->view->msg = "Friend request has beed accepted.";
             $this->view->selectedTab = 1;
         }
         if ($session_error_msg == "decline") {
             $this->view->msg = "Friend request has beed declined.";
             $this->view->selectedTab = 1;
         }
         unset($_SESSION['session_error_msg']);
     }
     //set reply message
     if (!empty($reply)) {
         $id = base64_decode($reply);
         $modelMessages = new Application_Model_Message();
         $modelUser = new Application_Model_User();
         $valMessages = $modelMessages->find($id);
         $messageSenderId = $valMessages->getFromId();
         $valUser = $modelUser->find($messageSenderId);
         $senderName = $valUser->getFirstName() . ' ' . $valUser->getLastName();
         $valMessage = $modelMessages->find($id);
         $msg_subject = "Re: " . $valMessage->getSubject();
         $this->view->receipentArr = array("receipent_id" => $messageSenderId, "receipent_name" => $senderName, "msg_subject" => $msg_subject);
         //$form->getElement('toEmail')->setValue($senderName);
         //$form->getElement('toId')->setValue($messageSenderId);
         //$form->getElement('subject')->setValue($valMessage->getSubject());
         $this->view->selectedTab = 2;
     }
     //send message to particuar user
     if (!empty($username)) {
         $id = base64_decode($username);
         $modelUser = new Application_Model_User();
         $userRes = $modelUser->find($id);
         if (false !== $userRes) {
             $senderName = $userRes->getFirstName() . ' ' . $userRes->getLastName();
             $msg_subject = "Hello";
             $this->view->receipentArr = array("receipent_id" => $id, "receipent_name" => $senderName, "msg_subject" => $msg_subject);
         }
         $this->view->selectedTab = 2;
     }
     //get inbox message and search
     $messageM = new Application_Model_Message();
     $searchParams = $this->getRequest()->getParams();
     $where = "to_id='{$userId}'";
     $search_message = false;
     if (isset($searchParams['msgsearch']) && $searchParams['msgsearch'] != '' && $searchParams['msgsearch'] != 'Search Messages') {
         $msgsearch = $searchParams['msgsearch'];
         $where .= " and (subject like '%{$msgsearch}%' OR body like '%{$msgsearch}%')";
         $this->view->msgsearch = $msgsearch;
         $this->view->param = array("msgsearch" => $msgsearch);
         $this->view->selectedTab = 0;
         $search_message = true;
     }
     $settings = new Admin_Model_GlobalSettings();
     $page_size = $settings->settingValue('message_pagination_size');
     $page = $this->_getParam('page', 1);
     $pageObj = new Base_Paginator();
     $paginator = $pageObj->fetchPageData($messageM, $page, $page_size, $where, 'id desc');
     $this->view->total = $pageObj->getTotalCount();
     $this->view->messages = $paginator;
     /*----------------------- START SENT MESSAGE ------------------------*/
     $whereSent = "from_id='{$userId}'";
     $paginator = $pageObj->fetchPageData($messageM, $page, $page_size, $whereSent, 'id desc');
     $this->view->totalSent = $pageObj->getTotalCount();
     $this->view->sentMessages = $paginator;
     /*------------------------ END SENT MESSAGE -------------------------*/
     $friendM = new Application_Model_Friend();
     $where = "friend_id='{$userId}' and status='pending'";
     $friendMN = $friendM->fetchAll($where);
     $this->view->friend = $friendMN;
     //send message
     if ($this->getRequest()->isPost() && $search_message == false) {
         $params = $this->getRequest()->getPost();
         $error = "";
         if (!isset($params['toEmail']) || count($params['toEmail']) < 1) {
             $error = "Please select receipents.";
         }
         if (empty($params['subject']) || $params['subject'] == "") {
             $error .= "<br />Subject can not be left blank.";
         }
         if (empty($params['body']) || $params['body'] == "") {
             $error .= "<br />Message can not be left blank.";
         }
         if ($error == "") {
             //send email to all receipents
             for ($cntR = 0; $cntR < count($params['toEmail']); $cntR++) {
                 //if(!empty($params['toId']))
                 if (is_numeric($params['toEmail'][$cntR])) {
                     $params['toId'] = $params['toEmail'][$cntR];
                     $params['status'] = 'inbox';
                     $params['fromId'] = $userId;
                     $params['parentId'] = 0;
                     $params['read'] = 0;
                     $messages = new Application_Model_Message($params);
                     $savemsg = $messages->save();
                     /*------------------------- 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;
                     $userNs = new Zend_Session_Namespace('members');
                     $loggedInUserId = $userNs->userId;
                     $valfrom = $userObj->find($loggedInUserId);
                     $option['fromName'] = $valfrom->getFirstName() . ' ' . $valfrom->getLastName();
                     $mail = new Base_Mail();
                     $mail->sendNotificationMail("message_notification", $option);
                 } else {
                     $_SESSION['session_error_msg'] = "failed";
                     $this->_redirect($this->view->seoUrl('/gapper/my-messages/'));
                 }
             }
             //end of for
             $_SESSION['session_error_msg'] = "success";
             $this->_redirect($this->view->seoUrl('/gapper/my-messages/'));
         } else {
             $form->getElement('subject')->setValue($params['subject']);
             $form->getElement('body')->setValue($params['body']);
             $this->view->msg = $error;
             $this->view->selectedTab = 2;
         }
         $this->view->form = $form;
     }
     //end if
 }