public function travelWallAction()
 {
     $username = $this->_getParam('username');
     $user = $this->getLeftPanel($username);
     $this->view->userObject = $user;
     $userM = new Application_Model_User();
     //Redirect user if not active, added by Mahipal Adhikari on 3-jan-2011
     if (false === $userM->checkUserActiveStatus($user->getId())) {
         $this->_helper->redirector('index', 'index');
     }
     /************************ Check user privacy settings START *****************/
     $userNs = new Zend_Session_Namespace('members');
     $loggedin_id = $userNs->userId;
     $user_id = $user->getId();
     //now check user profile privacy permissions
     $view_profile = false;
     $view_profile = $userM->checkUserPrivacySettings($user_id, $loggedin_id, 2);
     //if logged in user has no permission then display error page
     if (!$view_profile) {
         $this->view->user_id = $user_id;
         $this->render('error');
     }
     /************************ Check user privacy settings END *****************/
     //only users friend can post on Travel Wall
     $this->view->postWallAccess = false;
     if (false !== $userM->getUserConnection($user_id, $loggedin_id)) {
         $this->view->postWallAccess = true;
     }
     $this->view->loginUrl = "";
     $facebook = $this->view->facebook();
     if ($user->getFacebookId() == "" || is_null($user->getFacebookId())) {
         $this->view->loginUrl = $facebook->getLoginUrl();
     }
     if ($this->getRequest()->isPost()) {
         $userId = $user->getId();
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $params = $this->getRequest()->getParams();
         //$params['userId'] = $userId;
         //Added by Mahipal Adhikari on 28-Jan-2011, to save user profile id in which wall is posted and commented above
         $params['userId'] = $loggedin_id;
         $params['status'] = nl2br($params['status']);
         $wall = new Application_Model_Wall($params);
         $id = $wall->save();
         if ($id > 0) {
             //added by mahipal on 28-jan-2011
             /********  send email to User to whom wall is submitted START *************/
             $userM = new Application_Model_User();
             //get user details who submit comment
             $user = $userM->find($loggedin_id);
             $CommentedByName = $user->getFirstName() . " " . $user->getLastName();
             //get user details to whom wall is posted
             $objCommentedUser = $userM->find($params['profileId']);
             $mailOptions['CommentedPersonName'] = $objCommentedUser->getFirstName();
             $mailOptions['Comment'] = $params['status'];
             $mailOptions['wall_id'] = $id;
             $mailOptions['CommentedByName'] = $CommentedByName;
             $mailOptions['email'] = $objCommentedUser->getEmail();
             //send email to user if not posting own profile
             if ($params['profileId'] != $loggedin_id) {
                 $mail = new Base_Mail();
                 $mail->sendTravelWallEmail($mailOptions);
             }
             /********  send email to User to whom wall is submitted END *************/
             $arrayResult = array("id" => $id, 'error' => 0);
             //insert into feeds for logged in user
             $userM = new Application_Model_User();
             $userM = $userM->find($userId);
             $feed = "<b>" . $userM->getFirstName() . " " . $userM->getLastName() . "</b> | " . $params['status'] . "<br>";
             $feed .= "<span>1 Min ago</span> | <span>Comment</span> | <span><b>Like</b>";
             $feeds = new Application_Model_Feeds();
             $feeds->setUserId($userId);
             $feeds->setType('wall');
             $feeds->setFeed($feed);
             $feeds->save();
             // insert into feeds for friends
         } else {
             $arrayResult = array('error' => 1);
         }
         if (isset($params['facebook'])) {
             if ($user->getFacebookId() != "" && !is_null($user->getFacebookId())) {
                 $statusUpdate = $facebook->api('/' . $user->getFacebookId() . '/feed', 'post', array('message' => $params['status'], 'cb' => ''));
             }
         }
         echo Zend_Json::encode($arrayResult);
     }
     //Get last update
     $whereUser = "******";
     $arrUser = $userM->fetchAll($whereUser);
     $userId = $arrUser[0]->id;
     $objModelWall = new Application_Model_Wall();
     //$whereWall	=	"active_status=1 AND user_id={$userId}";
     $whereWall = "active_status=1 AND user_id={$userId} AND profile_id={$userId}";
     $orderWall = "addedon DESC";
     $countWall = 1;
     $offsetWall = 0;
     $arrWall = $objModelWall->fetchAll($whereWall, $orderWall, $countWall, $offsetWall);
     if ($arrWall) {
         $latestUpdates = $arrWall[0]->status;
         $latestupdatesDate = date("d F Y, g:i a", $arrWall[0]->addedon);
         $this->view->latestUpdates = $latestUpdates;
         $this->view->latestupdatesDate = $latestupdatesDate;
     }
 }
Пример #2
0
 public function myTravelWallAction()
 {
     $userNs = new Zend_Session_Namespace('members');
     //get particular wall information to display, added by mahipal on 10-Dec-2010
     $wall_id = "";
     $wall_id = $this->_getParam('wall_id');
     if (isset($wall_id) && $wall_id != "") {
         $this->view->wall_id = $wall_id;
     }
     $blockM = new Base_View_Block();
     $blockM->removeBlock("weather", "myaccount");
     $blockM->removeBlock("time", "myaccount");
     $blockM->removeBlock("whats-going-on", "myaccount");
     $blockM->removeBlock("journal", "myaccount");
     $user = new Application_Model_User();
     $user = $user->find($userNs->userId);
     $this->view->loginUrl = "";
     $facebook = $this->view->facebook();
     if ($user->getFacebookId() == "" || is_null($user->getFacebookId())) {
         //$return_url=Zend_Registry::get('siteurl')."/index/facebook-connect/";
         $return_url = Zend_Registry::get('siteurl') . "/index/do-fb-return/";
         $cancel_url = Zend_Registry::get('siteurl') . "/index/cancel-facebook";
         $this->view->loginUrl = $loginUrl = $facebook->getLoginUrl(array("cancel_url" => $cancel_url, "next" => $return_url, "req_perms" => "offline_access,publish_stream,read_stream,email,user_birthday,user_location", "display" => "popup"));
     }
     //get user facebook friend list, for testing
     //$statusUpdate = $facebook->api('/'.$user->getFacebookId().'/friends', 'get');
     ///https://api.facebook.com/method/liveMessage.send?recipient=qa&event_name=asdfads&message=asdfdasfadsf&access_token=...
     //$statusUpdate = $facebook->api('/100001442260018/feed', 'post', array('message'=> "please join gd", 'cb' => ''));
     //var_dump($statusUpdate );
     /*----facebook----*/
     /*$me=array();
     		$facebook=$this->view->facebook();
     		$session=$facebook->getSession();
     		if ($session) 
     		{
     		  try {
     		    $me = $facebook->api('/me');
     		  	} catch (FacebookApiException $e) {
     		    error_log($e);
     		  	}
     		}
     		if($me){
     	  		$this->view->loginUrl="";
     	  	}else{
     	  		$this->view->loginUrl = $facebook->getLoginUrl();
     	  	}*/
     /*-----------------*/
     if ($this->getRequest()->isPost()) {
         $userId = $user->getId();
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $params = $this->getRequest()->getParams();
         $params['userId'] = $userId;
         //Added by Mahipal Adhikari on 28-Jan-2011, to save user profile id in which wall is posted
         $profileId = 0;
         //if($params["wall_flag"] != "my-travel-feed")
         $profileId = $userId;
         //posting on own wall
         $params['profileId'] = $profileId;
         $params['status'] = nl2br($params['status']);
         $wall = new Application_Model_Wall($params);
         $id = $wall->save();
         if ($id > 0) {
             $arrayResult = array("id" => $id, 'error' => 0);
             //insert into feeds for logged in user
             $userM = new Application_Model_User();
             $userM = $userM->find($userId);
             $feed = "<b>" . $userM->getFirstName() . " " . $userM->getLastName() . "</b> | " . $params['status'] . "<br>";
             $feed .= "<span>1 Min ago</span> | <span>Comment</span> | <span><b>Like</b>";
             $feeds = new Application_Model_Feeds();
             $feeds->setUserId($userId);
             $feeds->setType('wall');
             $feeds->setFeed($feed);
             $feeds->save();
             //------------------------
         } else {
             $arrayResult = array('error' => 1);
         }
         if (isset($params['facebook'])) {
             if ($user->getFacebookId() != "" && !is_null($user->getFacebookId())) {
                 $statusUpdate = $facebook->api('/' . $user->getFacebookId() . '/feed', 'post', array('message' => $params['status'], 'cb' => ''));
             }
         }
         echo Zend_Json::encode($arrayResult);
     }
 }