public function addAction($id = null)
 {
     $this->view->disable();
     $userSession = $this->session->get("userSession");
     if ($this->request->isGet() && isset($id)) {
         $members = Members::findFirstById($id);
         if (!$members) {
             return $this->response->redirect($this->request->getHTTPReferer());
         }
     }
     if ($this->request->isGet()) {
         $friendRequest = new FriendRequests();
         $friendRequest->created = date('Y-m-d H:i:s');
         $friendRequest->modified = date('Y-m-d H:i:s');
         $friendRequest->member_id = $id;
         $friendRequest->requester_id = $userSession['id'];
         $friendRequest->status = 'Requested';
         if ($friendRequest->create()) {
             //error_log('ID :'.$id);
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>You\'re friend request has been submitted.');
             return $this->response->redirect($this->request->getHTTPReferer());
         }
     }
 }
예제 #2
0
 /**
  * Queries the friends and users table to match the query given.
  * If no query is provided it returns all friends.
  *
  * @return array
  */
 public function execute()
 {
     $notification = new FriendRequests();
     return $notification->get($this->getUserId(), null);
 }