コード例 #1
0
 /**
  * @Modified By : Mahipal Singh Adhikari
  * @Modified On : 4-Nov-2010
  * @Modification: Modified to display only public and published blogs, also set eror page for journal privacy
  */
 public function journalsAction()
 {
     $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');
     }
     $this->view->userObject = $user;
     $userNs = new Zend_Session_Namespace('members');
     $this->view->userId = $userNs->userId;
     //get blog owner Journal public/published information
     if ($user->getId()) {
         $journalM = new Application_Model_Journal();
         $journalM = $journalM->fetchRow("user_id='{$user->getId()}'");
         if ($journalM) {
             $this->view->jStatus = $jStatus = $journalM->getStatus();
             $this->view->jPublish = $jPublish = $journalM->getPublish();
             if ($jStatus != "public" || $jPublish != "published") {
                 //$this->view->userName = $username;
                 $this->view->user_id = $user->getId();
                 $this->view->error_message = "Journal is either private or not published by <b>" . $user->getFirstName() . " " . $user->getLastName() . "</b>";
                 $this->render('error');
             }
         } else {
             //$this->view->userName = $username;
             $this->view->user_id = $user->getId();
             $this->view->error_message = "No Journal is created by <b>" . $user->getFirstName() . " " . $user->getLastName() . "</b>";
             $this->render('error');
         }
     }
     //end of if
     /************************ Check user privacy settings START *****************/
     $loggedin_id = $userNs->userId;
     $user_id = $user->getId();
     //echo "user id=".$user_id." and Login id=".$loggedin_id;
     //now check user journal privacy permissions
     $view_profile = false;
     $userObj = new Application_Model_User();
     $view_profile = $userObj->checkUserPrivacySettings($user_id, $loggedin_id, 4);
     //if logged in user has no permission then display error page
     if (!$view_profile) {
         $this->view->user_id = $user->getId();
         $this->render('error');
     }
     /************************ Check user privacy settings END *****************/
     /*------------------------- Set paging START------------------------*/
     $settings = new Admin_Model_GlobalSettings();
     $page_size = $settings->settingValue('journal_page_size');
     //$page_size	= 1;
     /*------------------------- Set paging END------------------------*/
     $blogm = new Application_Model_Blog();
     $whereCond = "user_id='{$user->getId()}' AND status='public' AND publish='published'";
     //$whereCond	= "user_id='{$user->getId()}'";
     $data = $blogm->fetchAll($whereCond, "addedon DESC", $page_size);
     $this->view->data = $data;
     $this->view->userName = $username;
 }
コード例 #2
0
 public function friendsAction()
 {
     $username = $this->_getParam('username');
     $this->view->userName = $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');
     }
     $userNs = new Zend_Session_Namespace("members");
     $loggedInUser = $userNs->userId;
     $this->view->loggedInUser = $loggedInUser;
     /************************ Check user privacy settings START *****************/
     $loggedin_id = $loggedInUser;
     $user_id = $user->getId();
     //echo "user id=".$user_id." and Login id=".$loggedin_id;
     //now check user profile privacy permissions
     $view_profile = false;
     $userObj = new Application_Model_User();
     $view_profile = $userObj->checkUserPrivacySettings($user_id, $loggedin_id, 6);
     //if logged in user has no permission then display error page
     if (!$view_profile) {
         $this->view->user_id = $user->getId();
         $this->render('error');
     }
     /************************ Check user privacy settings END *****************/
     $where = "user_id='{$user->getId()}' AND status='accept'";
     $params = $this->getrequest()->getParams();
     $extra = array();
     //search by Connection Type
     if (isset($params['searchkey']) && $params['searchkey'] != '') {
         $key = $params['searchkey'];
         $this->view->ctype = $key;
         $where .= " AND connection_type = '{$key}'";
         $extra['searchkey'] = $key;
     }
     //search by Name
     if (isset($params['searchname']) && $params['searchname'] != '' && $params['searchname'] != 'Search Names') {
         $userarray[] = -1;
         $searchname = trim($params['searchname']);
         $this->view->searchname = $searchname;
         $user_where_sql = "";
         $user_where_sql .= " CONCAT(first_name,' ',last_name ) LIKE '%{$searchname}%' || username LIKE '%{$searchname}%'";
         $userdata = $userM->fetchAll($user_where_sql);
         if (count($userdata) > 0) {
             foreach ($userdata as $userrow) {
                 $userarray[] = $userrow->getId();
             }
         }
         $userstr = implode(',', $userarray);
         $where .= " AND friend_id IN ({$userstr})";
         $extra['searchname'] = $searchname;
         //set message if no record found
         $this->view->no_record = "Try another search to find what you're looking for.";
     }
     $friendM = new Application_Model_Friend();
     $settings = new Admin_Model_GlobalSettings();
     $page_size = $settings->settingValue('friend_page_size');
     $this->view->page_size = $page_size;
     //$page_size = 1;
     $page = $this->_getParam('page', 1);
     $pageObj = new Base_Paginator();
     $paginator = $pageObj->fetchPageData($friendM, $page, $page_size, $where);
     $this->view->totalFriends = $pageObj->getTotalCount();
     //$this->view->paginator=$paginator;
     $data = $friendM->fetchAll($where, "addedon DESC", $page_size);
     $this->view->data = $data;
 }