Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pending()
- {
- $my = CFactory::getUser();
- if($my->id == 0)
- {
- return $this->blockUnregister();
- }
- $view = $this->getView('friends');
- $model =& $this->getModel('friends');
- $usermodel =& $this->getModel('user');
- // @todo: make sure the rejectId and approveId is valid for this user
- if($id = JRequest::getVar('rejectId', 0, 'GET'))
- {
- $mainframe =& JFactory::getApplication();
- if(! $model->rejectRequest($id)){
- $mainframe->enqueueMessage(JText::sprintf('CC RRIEND REQUEST REJECT FAILED', $id));
- }
- }
- if($id = JRequest::getVar('approveId', 0, 'GET'))
- {
- $mainframe =& JFactory::getApplication();
- $connected = $model->approveRequest($id);
- // If approbe id is not valid or already approve, $connected will
- // be null.. yuck
- if($connected) {
- $act = new stdClass();
- $act->cmd = 'friends.request.approve';
- $act->actor = $connected[0];
- $act->target = $connected[1];
- $act->title = JText::_('CC ACTIVITIES FRIENDS NOW');
- $act->content = '';
- $act->app = 'friends';
- $act->cid = 0;
- CFactory::load ( 'libraries', 'activities' );
- CActivityStream::add($act);
- //add user points - give points to both parties
- CFactory::load( 'libraries' , 'userpoints' );
- CUserPoints::assignPoint('friends.request.approve');
- $friendId = ( $connected[0] == $my->id ) ? $connected[1] : $connected[0];
- $friend = CFactory::getUser($friendId);
- CUserPoints::assignPoint('friends.request.approve', $friendId);
- $mainframe->enqueueMessage(JText::sprintf('CC FRIENDS NOW', $friend->getDisplayName()));
- }
- }
- $data = new stdClass();
- $rpending = $model->getPending($my->id);
- $data->pending = $rpending;
- $data->pagination =& $model->getPagination();
- echo $view->get(__FUNCTION__, $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement