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'); } }
public function deletemsgAction() { if ($this->getRequest()->isPost() && $this->_ajaxRequest) { if ($mid = $this->getRequest()->getParam('mid', FALSE)) { $messageService = new Service_Message(); if ($messageService->deleteMessage($mid, $this->_user->id)) { $this->_response->appendBody('1'); return; } else { $this->_response->appendBody('0'); return; } } else { $this->_response->appendBody('0'); return; } } else { return $this->_redirect("/messages"); } }