Beispiel #1
0
 /**
  * Method to retrieve activities via AJAX
  **/
 public function ajaxGetActivities($exclusions, $type, $userId, $latestId = 0, $isProfile = 'false', $filter = '', $app = '', $appId = '')
 {
     $response = new JAXResponse();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $filterInput = JFilterInput::getInstance();
     $exclusions = $filterInput->clean($exclusions, 'string');
     $type = $filterInput->clean($type, 'string');
     $userId = $filterInput->clean($userId, 'int');
     $latestId = $filterInput->clean($latestId, 'int');
     $isProfile = $filterInput->clean($isProfile, 'string');
     $app = $filterInput->clean($app, 'string');
     $appId = $filterInput->clean($appId, 'int');
     CFactory::load('libraries', 'activities');
     $act = new CActivityStream();
     if (($app == 'group' || $app) == 'event' && $appId > 0) {
         // for application stream
         $option = array('app' => $app . 's', 'apptype' => $app, 'exclusions' => $exclusions);
         $option[$app . 'id'] = $appId;
         //application id for the right application
         $option['latestId'] = $latestId > 0 ? $latestId : 0;
         $html = $act->getAppHTML($option);
     } else {
         if ($type == 'active-profile' || $type == 'me-and-friends' || $filter == 'friends' || $filter == 'self' || $type == 'active-profile-and-friends') {
             // For main and profile stream
             CFactory::load('helpers', 'time');
             $friendsModel = CFactory::getModel('Friends');
             if ($isProfile != 'false') {
                 //requested from profile
                 $target = array($userId);
                 //by default, target is self
                 if ($filter == 'friends') {
                     $target = $friendsModel->getFriendIds($userId);
                 }
                 $html = $act->getHTML($userId, $target, null, $config->get('maxactivities'), 'profile', '', true, COMMUNITY_SHOW_ACTIVITY_MORE, $exclusions, COMMUNITY_SHOW_ACTIVITY_ARCHIVED, 'all', $latestId);
             } else {
                 $html = $act->getHTML($userId, $friendsModel->getFriendIds($userId), null, $config->get('maxactivities'), '', '', true, COMMUNITY_SHOW_ACTIVITY_MORE, $exclusions, COMMUNITY_SHOW_ACTIVITY_ARCHIVED, 'all', $latestId);
             }
         } else {
             $html = $act->getHTML('', '', null, $config->get('maxactivities'), '', '', true, COMMUNITY_SHOW_ACTIVITY_MORE, $exclusions, COMMUNITY_SHOW_ACTIVITY_ARCHIVED, 'all', $latestId);
         }
     }
     $html = trim($html, " \n\t\r");
     $text = JText::_('COM_COMMUNITY_ACTIVITIES_NEW_UPDATES');
     if ($latestId == 0) {
         // Append new data at bottom.
         $response->addScriptCall('joms.activities.append', $html);
     } else {
         if ($html != '') {
             $response->addScriptCall('joms.activities.appendLatest', $html, $config->get('stream_refresh_interval'), $text);
         } else {
             $response->addScriptCall('joms.activities.nextActivitiesCheck', $config->get('stream_refresh_interval'));
         }
     }
     return $response->sendResponse();
 }