protected function add() { $iFriendId = $this->httpRequest->post('friendId', 'int'); $iMemberId = $this->session->get('member_id'); if ($iMemberId == $iFriendId) { $this->_sMsg = jsonMsg(0, t('You cannot be your own friend.')); } else { $this->_mStatus = $this->_oFriendModel->add($this->session->get('member_id'), $iFriendId, $this->dateTime->get()->dateTime('Y-m-d H:i:s')); if ($this->_mStatus == 'error') { $this->_sMsg = jsonMsg(0, t('Unable to add to friends list, please try later.')); } elseif ($this->_mStatus == 'friend_exists') { $this->_sMsg = jsonMsg(0, t('This profile already exists in your friends list.')); } elseif ($this->_mStatus == 'id_does_not_exist') { $this->_sMsg = jsonMsg(0, t('Profile ID does not exist.')); // Should never happen unless someone changes the source code with firebug or other } elseif ($this->_mStatus == 'success') { $this->_sMsg = jsonMsg(1, t('This profile has been successfully added to your friends list.')); $oUserModel = new UserCoreModel(); if (!$oUserModel->isNotification($iFriendId, 'friendRequest') && $oUserModel->isOnline($iFriendId, 0)) { // Send mail if the notification is accepted and the user isn't connected NOW. $this->sendMail($iFriendId, $oUserModel); } unset($oUserModel); } } echo $this->_sMsg; }