Exemplo n.º 1
0
 /**
  * remove friend
  */
 public function removeFriend($friendid)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $model = CFactory::getModel('friends');
     $my = CFactory::getUser();
     $viewName = $jinput->get->get('view', '');
     //JRequest::getVar('view','','GET');
     if (CSystemHelper::communityViewExists($viewName)) {
         $view = CFactory::getView($viewName);
     }
     if ($model->deleteFriend($my->id, $friendid)) {
         // Substract the friend count
         $model->updateFriendCount($my->id);
         $model->updateFriendCount($friendid);
         //add user points
         // we deduct poinst to both parties
         //CFactory::load( 'libraries' , 'userpoints' );
         CUserPoints::assignPoint('friends.remove');
         CUserPoints::assignPoint('friends.remove', $friendid);
         $friend = CFactory::getUser($friendid);
         if (isset($view)) {
             $view->addInfo(JText::sprintf('COM_COMMUNITY_FRIENDS_REMOVED', $friend->getDisplayName()));
         }
         //@todo notify friend after remove them from our friend list
         //trigger for onFriendRemove
         $eventObject = new stdClass();
         $eventObject->profileOwnerId = $my->id;
         $eventObject->friendId = $friendid;
         $this->_triggerFriendEvents('onFriendRemove', $eventObject);
         unset($eventObject);
     } else {
         if (isset($view)) {
             $view->addinfo(JText::_('COM_COMMUNITY_FRIENDS_REMOVING_FRIEND_ERROR'));
         }
     }
 }