Ejemplo n.º 1
0
 public function requestfriendshipAction()
 {
     if ($this->getRequest()->isPost() && $this->_ajaxRequest) {
         if ($user = $this->getRequest()->getParam('user', FALSE)) {
             $friendService = new Service_Friend();
             if (is_array($result = $friendService->addRequest($this->_user->id, $user))) {
                 $this->_response->appendBody("1");
                 $messageService = new Service_Message();
                 $userService = new Service_User();
                 $userProfile = $userService->getUserProfile($this->_user->id);
                 $subject = "New Friend Request";
                 $content = "Hi<br/><br/>You have received a friend request from " . $userProfile->fName . " " . $userProfile->lName . ".<br/><br/>Please <a target='_blank' href='user/acceptrequest/" . $result['id'] . "'>Accept</a> or <a target='_blank' href='user/rejectrequest/" . $result['id'] . "'>Reject</a>";
                 $messageService->addNew($this->_user->id, $user, 'n', NULL, $subject, $content);
                 return;
             } else {
                 $this->_response->appendBody('0');
                 return;
             }
         } else {
             $this->_response->appendBody('0');
             return;
         }
     } else {
         return $this->_redirect('/profile');
     }
 }
Ejemplo n.º 2
0
 public function sendAction()
 {
     if ($this->getRequest()->isPost() && $this->_ajaxRequest) {
         $values = $this->getRequest()->getPost();
         if ($values['subject'] == "" || count($values['recipients']) == 0 || $values['content'] == "") {
             $this->_response->appendBody(Zend_Json::encode(array('result' => 'missing value')));
             return;
         }
         $recipients = array();
         foreach ($values['recipients'] as $rec) {
             $recipients[] = $rec['id'];
         }
         if (count($recipients) == 1) {
             $recipients = $recipients[0];
         }
         $messageService = new Service_Message();
         if (is_array($result = $messageService->addNew($this->_user->id, $recipients, $values['type'], $values['ref'] == "" ? NULL : $values['ref'], $values['subject'], $values['content']))) {
             $this->_response->appendBody(Zend_Json::encode($result));
             return;
         } else {
             $this->_response->appendBody(Zend_Json::encode(array('result' => $result)));
             return;
         }
     }
 }