public function getfriendsbdyAction()
 {
     if ($this->auth->hasIdentity()) {
         $getfriendsbdy = new Application_Model_Friend($this->registry['DB']);
         $this->view->results = $getfriendsbdy->getfriendsbday();
     }
 }
Esempio n. 2
0
 public function save(Application_Model_Friend $friend)
 {
     $data = array('id' => $friend->getId(), 'user_id' => $friend->getUserId(), 'friend_user_id' => $friend->getFriendUserId(), 'confirmed' => $friend->getConfirmed());
     if (null === ($id = $friend->getId())) {
         unset($data['id']);
         return $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
 }
 public function confirmAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $user_id = $request->getParam('user_id');
     $friend_user_id = $request->getParam('friend_user_id');
     $friendMapper = new Application_Model_FriendMapper();
     $friend = new Application_Model_Friend();
     $friend->setId($id);
     $friend->setUserId($user_id);
     $friend->setFriendUserId($friend_user_id);
     $friend->setConfirmed(1);
     try {
         $friendMapper->save($friend);
         $this->view->msg = 'Friend successfully confirmed';
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getFile(), $e->getPrevious());
     }
 }
 public function autoFriendNameAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     $friendM = new Application_Model_Friend();
     $frienddata = $friendM->fetchAll();
     $friendids = array();
     foreach ($frienddata as $friend) {
         $friendids[] = $friend->getFriendId();
     }
     $q = strtolower($this->_getParam('term'));
     if (!$q) {
         return;
     }
     $where = "status='active'";
     //$where = "first_name like '%{$q}%' ";
     $where .= " AND (CONCAT(first_name,' ',last_name ) LIKE '%{$q}%' OR username LIKE '%{$q}%')";
     $userM = new Application_Model_User();
     $res = $userM->fetchAll($where, null, 11);
     $result = array();
     foreach ($res as $row) {
         if (in_array($row->getId(), $friendids)) {
             //array_push($result, array("id"=>$row->getId(), "value" => $row->getFirstName()));
             $name = $row->getFirstName() . " " . $row->getLastName();
             array_push($result, array("id" => $row->getId(), "value" => $name));
         }
     }
     echo Zend_Json::encode($result);
 }
Esempio n. 5
0
 public function deleteProfileAction()
 {
     $id = $this->getRequest()->getParam('id');
     $friendm = new Application_Model_Friend();
     $userdata = $friendm->find($id);
     $userId = $userdata->getUserId();
     $friendId = $userdata->getFriendId();
     $friendm->delete("id = {$id}");
     $friendm->delete("user_id = {$friendId} and friend_id={$userId}");
     $this->_redirect('/gapper/my-friends');
 }
Esempio n. 6
0
 /**
  * @Created By 	: Mahipal Singh Adhikari
  * @Created On 	: 28-Dec-2010
  * @Description	: Get the Login User and User's connection
  * @Input		: $user_id(int), $friend_id(int)
  * @Return		: returns String(connection type) if exists relation otherwise returns False
  **/
 public function getUserConnection($user_id, $friend_id)
 {
     $connection = false;
     //if logged in user viewing own
     if ($user_id == $friend_id) {
         $connection = "own";
     }
     //now if user is logged in i.e. $friend_id is not null, check connection with user
     if (isset($friend_id) && is_numeric($friend_id)) {
         $friendM = new Application_Model_Friend();
         $friend_cond = "user_id='{$user_id}' AND friend_id='{$friend_id}' AND status='accept'";
         $conTypeObj = $friendM->fetchRow($friend_cond);
         //if logged in user connected with this user
         if (false !== $conTypeObj) {
             $con_type = $conTypeObj->getConnectionType();
             $connection = $con_type;
         }
         //end if
     }
     //end if
     return $connection;
 }
Esempio n. 7
0
 public function acceptFAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $params = $this->getRequest()->getParams();
     $id = $params['id'];
     $friendM = new Application_Model_Friend();
     $friendM = $friendM->find($id);
     $friendM->setStatus('accept');
     $friendM->save();
     $fdata['friendId'] = $friendM->getUserId();
     $fdata['userId'] = $friendM->getFriendId();
     $fdata['connectionType'] = $friendM->getConnectionType();
     $fdata['status'] = 'accept';
     //print_r($fdata);exit;
     $friendM = new Application_Model_Friend($fdata);
     $friendM->save();
     //set session and redirect user
     $_SESSION['session_error_msg'] = "accept";
     $this->_redirect($this->view->seoUrl('/gapper/my-messages/'));
 }
Esempio n. 8
0
 public function getUserFriend($user_id, $detail = false)
 {
     $arrFriend = array();
     $friendM = new Application_Model_Friend();
     $friends = $friendM->fetchAll("user_id='{$user_id}' and status='accept'");
     if (count($friends) > 0) {
         foreach ($friends as $friend) {
             if ($detail == false) {
                 $arrFriend[] = $friend->getFriendId();
             } else {
                 //send friend detail
             }
         }
     } else {
         return false;
     }
     return $arrFriend;
 }
Esempio n. 9
0
 /**
  * @Created By 	: Mahipal Singh Adhikari
  * @Created On 	: 17-Nov-2010
  * @Description	: This function is used to check user privacy settings for his profile
  * @Input		: $user_id(int), $friend_id(int), $permission_id(int)
  * @Return		: boolean(True or False)
  **/
 public function checkUserPrivacySettings($user_id, $friend_id, $permission_id)
 {
     $permit = false;
     //if no parameters sent, return false
     if (!isset($user_id) && $user_id == "" || !isset($permission_id) && $permission_id) {
         return false;
     }
     //if logged in user viewing own
     if ($user_id == $friend_id) {
         return true;
     }
     //now get user permission settings
     $UserPermissionObj = new Application_Model_UserPermission();
     $wherePerCond = "user_id='{$user_id}' AND permission_id={$permission_id}";
     $permission = $UserPermissionObj->fetchRow($wherePerCond);
     if (false == $permission) {
         return false;
     }
     $permissionId = $permission->getId();
     $permission = $permission->getFriendGroupId();
     //echo "<br />permission=".$permission." for id=".$friend_id."<br />";
     //if permission is public return true
     if ($permission == 1) {
         return true;
         //display to public
     }
     //now if user is logged in i.e. $friend_id is not null, check connection with user
     if (isset($friend_id) && is_numeric($friend_id)) {
         $friendM = new Application_Model_Friend();
         $friend_cond = "user_id='{$user_id}' AND friend_id='{$friend_id}' AND status='accept'";
         $conTypeObj = $friendM->fetchRow($friend_cond);
         //if logged in user connected with this user
         if (false !== $conTypeObj) {
             $con_type = $conTypeObj->getConnectionType();
             //echo "<br />connection type=".$con_type."<br />";
             if ($con_type == "friend" && ($permission == 2 || $permission == 4)) {
                 $permit = true;
                 //display to Friends & Family AND Friends, Family and Mates
             } else {
                 if ($con_type == "family" && ($permission == 2 || $permission == 4)) {
                     $permit = true;
                     //display to Friends & Family AND Friends, Family and Mates
                 } else {
                     if ($con_type == "travelmate" && ($permission == 3 || $permission == 4)) {
                         $permit = true;
                         //display to Travel Mates AND Friends, Family and Mates
                     } else {
                         $permit = false;
                     }
                 }
             }
         } else {
             $permit = false;
         }
     }
     //end if
     return $permit;
 }
Esempio n. 10
0
 public function exportAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     include_once LIBRARY_PATH . "/Base/Excel/PHPExcel.php";
     $objPHPExcel = new PHPExcel();
     $where = "1=1 AND status!='deleted'";
     $order = "addedon DESC";
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'S. No.')->setCellValue('B1', 'Username')->setCellValue('C1', 'First Name')->setCellValue('D1', 'Surname')->setCellValue('E1', 'Email')->setCellValue('F1', 'Gender')->setCellValue('G1', 'Number of Friends')->setCellValue('H1', 'Created On');
     $model = new Application_Model_User();
     $users = $model->fetchAll($where, $order);
     if (count($users) > 0) {
         $i = 2;
         $sno = 1;
         foreach ($users as $_user) {
             //select users Numbers of friends
             $noOfFriends = 0;
             $friendM = new Application_Model_Friend();
             $userFriends = $friendM->countUserFriends($_user->getId());
             $noOfFriends = $userFriends["totalFriends"];
             //$country = $_user->findParentRow('Application_Model_DbTable_Country','Country');
             // $state  =  $_user->findParentRow('Application_Model_DbTable_State','State');
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $sno)->setCellValue('B' . $i, $_user->getUsername())->setCellValue('C' . $i, $_user->getFirstName())->setCellValue('D' . $i, $_user->getLastName())->setCellValue('E' . $i, $_user->getEmail())->setCellValue('F' . $i, ucfirst($_user->getSex()))->setCellValue('G' . $i, $noOfFriends)->setCellValue('H' . $i, date("M j, Y", $_user->getAddedOn()));
             $i++;
             $sno++;
         }
     }
     // Rename sheet
     $objPHPExcel->getActiveSheet()->setTitle('Users');
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(35);
     $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(45);
     $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
     //$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     if ($this->_getParam('type') == 'xls') {
         // Redirect output to a client’s web browser (Excel5)
         header('Content-Type: application/vnd.ms-excel');
         header('Content-Disposition: attachment;filename="users.xls"');
         header('Cache-Control: max-age=0');
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     } else {
         if ($this->_getParam('type') == 'pdf') {
             // Redirect output to a client’s web browser (Excel2007)
             header('Content-Type: application/pdf');
             header('Content-Disposition: attachment;filename="users.pdf"');
             header('Cache-Control: max-age=0');
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
         } else {
             if ($this->_getParam('type') == 'csv') {
                 // Redirect output to a client’s web browser (Excel5)
                 header('Content-Type: application/vnd.ms-excel');
                 header('Content-Disposition: attachment;filename="users.csv"');
                 header('Cache-Control: max-age=0');
                 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
             }
         }
     }
     $objWriter->save('php://output');
 }
Esempio n. 11
0
 public function getfriendslistAction()
 {
     if ($this->auth->hasIdentity()) {
         $frd = new Application_Model_Friend($this->registry['DB']);
         $userid = $this->getRequest()->getParam('userid');
         $this->view->results = $frd->getfriends($userid);
     }
 }