Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1.     function pending()
  2.     {  
  3.  
  4.         $my     = CFactory::getUser();
  5.         if($my->id == 0)
  6.         {
  7.            return $this->blockUnregister();
  8.         }
  9.  
  10.         $view       = $this->getView('friends');
  11.         $model      =& $this->getModel('friends');
  12.         $usermodel  =& $this->getModel('user');
  13.  
  14.         // @todo: make sure the rejectId and approveId is valid for this user
  15.         if($id = JRequest::getVar('rejectId', 0, 'GET'))
  16.         {
  17.             $mainframe =& JFactory::getApplication();
  18.  
  19.             if(! $model->rejectRequest($id)){
  20.                 $mainframe->enqueueMessage(JText::sprintf('CC RRIEND REQUEST REJECT FAILED', $id));
  21.             }
  22.         }
  23.  
  24.         if($id = JRequest::getVar('approveId', 0, 'GET'))
  25.         {
  26.             $mainframe =& JFactory::getApplication();
  27.             $connected = $model->approveRequest($id);
  28.  
  29.             // If approbe id is not valid or already approve, $connected will
  30.             // be null.. yuck
  31.             if($connected) {
  32.                 $act = new stdClass();
  33.                 $act->cmd       = 'friends.request.approve';
  34.                 $act->actor     = $connected[0];
  35.                 $act->target    = $connected[1];
  36.                 $act->title     = JText::_('CC ACTIVITIES FRIENDS NOW');
  37.                 $act->content   = '';
  38.                 $act->app       = 'friends';
  39.                 $act->cid       = 0;
  40.  
  41.                 CFactory::load ( 'libraries', 'activities' );
  42.                 CActivityStream::add($act);
  43.                
  44.                 //add user points - give points to both parties
  45.                 CFactory::load( 'libraries' , 'userpoints' );      
  46.                 CUserPoints::assignPoint('friends.request.approve');               
  47.  
  48.                 $friendId = ( $connected[0] == $my->id ) ? $connected[1] : $connected[0];
  49.                 $friend = CFactory::getUser($friendId);
  50.                 CUserPoints::assignPoint('friends.request.approve', $friendId);
  51.  
  52.                 $mainframe->enqueueMessage(JText::sprintf('CC FRIENDS NOW', $friend->getDisplayName()));
  53.             }
  54.         }
  55.  
  56.         $data       = new stdClass();
  57.         $rpending   = $model->getPending($my->id);
  58.  
  59.         $data->pending      = $rpending;
  60.         $data->pagination   =& $model->getPagination();
  61.  
  62.         echo $view->get(__FUNCTION__, $data);
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement