Example #1
0
 public function checkRelation($userId, $loggedinUserId)
 {
     $objModelUser = new Application_Model_User();
     $strPermission = "permission='5'";
     if ($loggedinUserId != "") {
         $strPermission .= " OR permission='1'";
     }
     $relation = $objModelUser->getUserConnection($userId, $loggedinUserId);
     switch ($relation) {
         case 'friend':
             $strPermission .= " OR permission='2' OR  permission='6'";
             break;
         case 'own':
             $strPermission .= " OR permission='2' OR  permission='3' OR  permission='4'";
             break;
         case 'family':
             $strPermission .= " OR permission='3' OR  permission='6'";
             break;
     }
     return $strPermission;
 }
 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;
     }
 }
Example #3
0
 /**
  * @Created By	: Mahipal Singh Adhikari
  * @Created On	: 28-Mar-2011
  * @Description	: Used to check individual blog permission check
  * @Param		: int - $userId, int-$loggedinUserId, int-$blogPermission
  * @Return		: boolean
  */
 public function checkBlogPrivacySettings($userId, $loggedinUserId, $blogPermission = 0)
 {
     $strPermissionArr = array(5);
     //select default public
     $view = false;
     //if user is Logged In & Permission is 1 (GD community)
     if ($loggedinUserId != "" && $blogPermission == 1) {
         $strPermissionArr = array(1, 5);
     }
     $objModelUser = new Application_Model_User();
     $relation = $objModelUser->getUserConnection($userId, $loggedinUserId);
     if (false !== $relation) {
         switch ($relation) {
             case 'own':
                 $strPermissionArr = array(1, 2, 4, 5, 6);
                 break;
             case 'friend':
                 $strPermissionArr = array(1, 2, 5, 6);
                 break;
             case 'family':
                 $strPermissionArr = array(1, 5, 6);
                 break;
         }
     }
     if (in_array($blogPermission, $strPermissionArr)) {
         $view = true;
     }
     return $view;
 }