Example #1
0
 /**
  * Laod the app given the username and appname
  * If it doesn't exist, check if it is a core apps and create an entry
  */
 public function loadUserApp($userid, $element)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . $db->quoteName('#__community_apps') . ' ' . 'WHERE ' . $db->quoteName('apps') . '=' . $db->Quote($element) . '	AND ' . $db->quoteName('userid') . '=' . $db->Quote($userid);
     //echo $strSQL;
     $db->setQuery($query);
     $result = $db->loadObject();
     if ($result) {
         $this->bind($result);
     } else {
         // if it doen's exist, it could be core apps. Look into current
         // dispatcher
         $dispatcher = CDispatcher::getInstanceStatic();
         $observers = $dispatcher->getObservers();
         for ($i = 0; $i < count($observers); $i++) {
             $plgObj = $observers[$i];
             if (is_object($plgObj)) {
                 $plgObjWrapper = new CPluginWrapper($plgObj);
                 if ($plgObjWrapper->getPluginType() == 'community' && $plgObj->params != null && $plgObj->params->get('coreapp', 0) == 1 && method_exists($plgObj, 'onProfileDisplay')) {
                     // Ok, now we confirm that this plugin is valid
                     // The app should be displayed, just that it is not in the
                     // db yet.
                     // @todo: Get the position and privacy from backend
                     $this->apps = $element;
                     $this->userid = $userid;
                     $this->position = $plgObj->params->get('position', 'content');
                     $this->privacy = $plgObj->params->get('privacy', 0);
                     $this->store();
                 }
             }
         }
     }
     // If id still not loaded. Something is messed up and this object is no good
     return !empty($this->id);
 }
Example #2
0
 /**
  * Return the list of all user-apps, in proper order
  *
  * @param	int		user id
  * @return	array	of objects
  */
 public function getUserApps($userid, $state = 0)
 {
     $db = $this->getDBO();
     $query = 'SELECT ' . $db->quoteName('element') . ' FROM ' . $db->quoteName(PLUGIN_TABLE_NAME) . ' WHERE ' . $db->quoteName(EXTENSION_ENABLE_COL_NAME) . '=' . $db->Quote(1) . ' ' . 'AND ' . $db->quoteName('folder') . '=' . $db->Quote('community');
     $db->setQuery($query);
     $elementsResult = $db->loadColumn();
     if ($elementsResult) {
         $elements = "'" . implode($elementsResult, "','") . "'";
     }
     $query = 'SELECT DISTINCT a.* FROM ' . $db->quoteName('#__community_apps') . ' AS a ' . 'WHERE a.' . $db->quoteName('userid') . '=' . $db->Quote($userid) . ' ' . 'AND a.' . $db->quoteName('apps') . '!=' . $db->Quote('news_feed') . 'AND a.' . $db->quoteName('apps') . '!=' . $db->Quote('profile') . 'AND a.' . $db->quoteName('apps') . '!=' . $db->Quote('friends');
     if (!empty($elements)) {
         $query .= 'AND a.' . $db->quoteName('apps') . ' IN (' . $elements . ') ';
     }
     $query .= 'ORDER BY a.' . $db->quoteName('ordering');
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     // If no data yet, we load default apps
     // and add them to db
     if (empty($result)) {
         $result = $this->getCoreApps();
         foreach ($result as $row) {
             $row->userid = $userid;
             // We need to load the positions based on plugins default config
             $dispatcher = CDispatcher::getInstanceStatic();
             $observers = $dispatcher->getObservers();
             for ($i = 0; $i < count($observers); $i++) {
                 $plgObj = $observers[$i];
                 if (is_object($plgObj)) {
                     $plgObjWrapper = new CPluginWrapper($plgObj);
                     if ($plgObjWrapper->getPluginType() == 'community' && $plgObj->params != null && $plgObjWrapper->getPluginName() == $row->apps) {
                         $row->position = $plgObj->params->get('position', 'content');
                         $row->privacy = $plgObj->params->get('privacy', 0);
                     }
                 }
             }
             $db->insertObject('#__community_apps', $row);
             if ($db->getErrorNum()) {
                 JError::raiseError(500, $db->stderr());
             }
         }
         // Reload the apps
         // @todo: potential duplicate code
         $sql = 'SELECT * FROM ' . $db->quoteName('#__community_apps') . ' WHERE ' . $db->quoteName('userid') . '=' . $db->Quote($userid) . ' AND ' . $db->quoteName('apps') . '!=' . $db->Quote('news_feed') . ' AND ' . $db->quoteName('apps') . '!=' . $db->Quote('profile') . ' AND ' . $db->quoteName('apps') . '!=' . $db->Quote('friends') . ' ORDER BY ' . $db->quoteName('ordering');
         $db->setQuery($sql);
         $result = $db->loadObjectList();
         if ($db->getErrorNum()) {
             JError::raiseError(500, $db->stderr());
         }
     }
     // For 2.2 onwards, wall apps WILL NOT be displayed in the profile page, we need
     // to splice the array out!
     $offset = null;
     for ($i = 0; $i < count($result); $i++) {
         if ($result[$i]->apps == 'walls') {
             $offset = $i;
         }
     }
     if (!is_null($offset)) {
         array_splice($result, $offset, 1);
     }
     return $result;
 }
Example #3
0
 /**
  * Used to trigger applications
  * @param	string	eventName
  * @param	array	params to pass to the function
  * @param	bool	do we need to use custom user ordering ?
  * 
  * returns	Array	An array of object that the caller can then manipulate later.	 	 	 	 
  **/
 public function triggerEvent($event, $arrayParams = null, $needOrdering = false)
 {
     $mainframe =& JFactory::getApplication();
     $dispatcher =& CDispatcher::getInstanceStatic();
     $content = array();
     // Avoid problem with php 5.3
     if (is_null($arrayParams)) {
         $arrayParams = array();
     }
     // @todo: Fix ordering so we only load according to user ordering or site wide plugin ordering.
     // as we cannot use the mainframe to trigger because all the data are already outputed, no way to manipulate it.
     switch ($event) {
         case 'onProfileDisplay':
             $content = $this->_triggerOnProfileDisplay($event);
             break;
         case 'onFormDisplay':
             // We need to merge the arrays
             $content = $this->_triggerOnFormDisplay($event, $arrayParams);
             break;
         default:
             // Trigger system events
             $systemObj = new CEventTrigger();
             call_user_func_array(array(&$systemObj, $event), $arrayParams);
             $observers =& $dispatcher->getObservers();
             //$dispatcher->trigger( $event , $arrayParams );
             for ($i = 0; $i < count($observers); $i++) {
                 $plgObj = $observers[$i];
                 if (is_object($plgObj)) {
                     $plgObjWrapper = new CPluginWrapper($plgObj);
                     if ($plgObjWrapper->getPluginType() == 'community' && method_exists($plgObj, $event) && $plgObjWrapper->getPluginName() != 'input') {
                         // Format the applications with proper heading
                         // Trigger external apps
                         $content[] = call_user_func_array(array(&$plgObj, $event), $arrayParams);
                     }
                 }
             }
             break;
     }
     $this->triggerCount++;
     return $content;
 }
Example #4
0
 /**
  * Return an array of activity data
  * 
  * @param mixed $type string or arrayn or string
  */
 private function _getData($options)
 {
     $dispatcher =& CDispatcher::getInstanceStatic();
     $observers =& $dispatcher->getObservers();
     $plgObj = false;
     for ($i = 0; $i < count($observers); $i++) {
         if ($observers[$i] instanceof plgCommunityWordfilter) {
             $plgObj = $observers[$i];
         }
     }
     // Default params
     $default = array('actor' => 0, 'target' => 0, 'date' => null, 'app' => null, 'cid' => null, 'groupid' => null, 'eventid' => null, 'maxList' => 20, 'type' => '', 'exclusions' => null, 'displayArchived' => false);
     $options = array_merge($default, $options);
     extract($options);
     CFactory::load('libraries', 'mapping');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'groups');
     CFactory::load('libraries', 'events');
     CFactory::load('helpers', 'friends');
     $activities = CFactory::getModel('activities');
     $appModel = CFactory::getModel('apps');
     $html = '';
     $numLines = 0;
     $my = CFactory::getUser();
     $actorId = $actor;
     $htmlData = array();
     $config = CFactory::getConfig();
     //Get blocked list
     $model = CFactory::getModel('block');
     $blockLists = $model->getBanList($my->id);
     $blockedUserId = array();
     foreach ($blockLists as $blocklist) {
         $blockedUserId[] = $blocklist->blocked_userid;
     }
     // Exclude banned userid
     if (!empty($target) && !empty($blockedUserId)) {
         $target = array_diff($target, $blockedUserId);
     }
     if (!empty($app)) {
         $rows = $activities->getAppActivities($options);
     } else {
         $rows = $activities->getActivities($actor, $target, $date, $maxList, $config->get('respectactivityprivacy'), $exclusions, $displayArchived);
     }
     $day = -1;
     // If exclusion is set, we need to remove activities that arrives
     // after the exclusion list is set.
     // Inject additional properties for processing
     for ($i = 0; $i < count($rows); $i++) {
         $row =& $rows[$i];
         // A 'used' activities = activities that has been aggregated
         $row->used = false;
         // If the id is larger than any of the exclusion list,
         // we simply hide it
         if (isset($exclusion) && $exclusion > 0 && $row->id > $exclusions) {
             $row->used = true;
         }
     }
     unset($row);
     $dayinterval = ACTIVITY_INTERVAL_DAY;
     $lastTitle = '';
     // Experimental Viewer Sensitive Profile Status
     $viewer = CFactory::getUser()->id;
     $view = JRequest::getCmd('view');
     foreach ($rows as $row) {
         /*
         if ($row->app=='profile')
         {
         	// strip off {actor} and {target} from the previous format
         	$row->title		= CString::str_ireplace('{actor} to {target}', '', $row->title);
         	$row->title		= CString::str_ireplace('{actor}', '', $row->title);
         	$row->title		= CString::str_ireplace('{target}', '', $row->title);
         	// self-post status and status from other on viewer's profile - don't display target
         	// @todo: this really need to go to the template instead
         	$titleString	= ($row->actor == $row->target || $row->target == 0 ) ? '{actor}' : '{actor} <span class="com_icons com_icons12 com_icons-inline com_icons-rarr">ยป</span> {target}';
         	$titleString	= '<div class="newsfeed-content-actor">'.$titleString. '</div>%1$s';
         	$row->title		= JText::sprintf($titleString,$row->title);
         }
         */
         if ($row->app == 'events.wall' || $row->app == 'groups.wall') {
             //add actor
             //$row->title		= JText::sprintf('COM_COMMUNITY_ACTIVITIES_STATUS_MESSAGE',$row->title);
         }
     }
     for ($i = 0; $i < count($rows) && count($htmlData) <= $maxList; $i++) {
         $row = $rows[$i];
         $oRow =& $rows[$i];
         // The original object
         // store aggregated activities
         $oRow->activities = array();
         if (!$row->used && count($htmlData) <= $maxList) {
             $oRow =& $rows[$i];
             if (!isset($row->used)) {
                 $row->used = false;
             }
             if ($day != $row->getDayDiff()) {
                 $act = new stdClass();
                 $act->type = 'content';
                 $day = $row->getDayDiff();
                 if ($day == 0) {
                     $act->title = JText::_('TODAY');
                 } else {
                     if ($day == 1) {
                         $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_YESTERDAY');
                     } else {
                         if ($day < 7) {
                             $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_DAYS_AGO', $day);
                         } else {
                             if ($day >= 7 && $day < 30) {
                                 $dayinterval = ACTIVITY_INTERVAL_WEEK;
                                 $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_WEEK_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_WEEK_AGO_MANY', intval($day / $dayinterval));
                             } else {
                                 if ($day >= 30) {
                                     $dayinterval = ACTIVITY_INTERVAL_MONTH;
                                     $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_MONTH_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_MONTH_AGO_MANY', intval($day / $dayinterval));
                                 }
                             }
                         }
                     }
                 }
                 // set to a new 'title' type if this new one has a new title
                 // only add if this is a new title
                 if ($act->title != $lastTitle) {
                     $lastTitle = $act->title;
                     $act->type = 'title';
                     $htmlData[] = $act;
                 }
             }
             $act = new stdClass();
             $act->type = 'content';
             // Set to compact view if necessary
             // This method is a bit crude, but we have no other reliable data
             // to choose which will go to compact view
             // Attend an event
             $act->compactView = !(strpos($oRow->params, 'action=events.attendence.attend') === FALSE);
             $act->compactView = $act->compactView || !(strpos($oRow->params, '"action":"events.attendence.attend"') === FALSE);
             // Create an event
             $act->compactView = $act->compactView || !(strpos($oRow->params, 'action=events.create') === FALSE);
             $act->compactView = $act->compactView || !(strpos($oRow->params, '"action":"events.create"') === FALSE);
             // Update/join group
             $act->compactView = $act->compactView || $oRow->app == 'groups' && empty($oRow->content);
             // Add as friend
             $act->compactView = $act->compactView || $oRow->app == 'friends';
             // Add/Remove app. This is tricky since string is hard-coded
             // and no other info is available
             $act->compactView = $act->compactView || $oRow->title == JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED');
             // Feature a user
             $act->compactView = $act->compactView || $oRow->app == 'users';
             $title = $row->title;
             $app = $row->app;
             $cid = $row->cid;
             $actor = $row->actor;
             //Check for event or group title if exists
             if ($row->eventid) {
                 $eventModel = CFactory::getModel('events');
                 $act->appTitle = $eventModel->getTitle($row->eventid);
             } else {
                 if ($row->groupid) {
                     $groupModel = CFactory::getModel('groups');
                     $act->appTitle = $groupModel->getGroupName($row->groupid);
                 }
             }
             for ($j = $i; $j < count($rows) && $row->getDayDiff() == $day; $j++) {
                 $row = $rows[$j];
                 // we aggregate stream that has the same content on the same day.
                 // we should not however aggregate content that does not support
                 // multiple content. How do we detect? easy, they don't have
                 // {multiple} in the title string
                 // However, if the activity is from the same user, we only want
                 // to show the laste acitivity
                 if ($row->getDayDiff() == $day && $row->title == $title && $app == $row->app && $cid == $row->cid && (JString::strpos($row->title, '{/multiple}') !== FALSE || $row->actor == $actor)) {
                     // @rule: If an exclusion is added, we need to fetch activities without these items.
                     // Aggregated activities should also be excluded.
                     $row->used = true;
                     $oRow->activities[] = $row;
                 }
             }
             $app = !empty($oRow->app) ? $this->_appLink($oRow->app, $oRow->actor, $oRow->target, $oRow->title) : '';
             $oRow->title = CString::str_ireplace('{app}', $app, $oRow->title);
             $favicon = '';
             // this should not really be empty
             if (!empty($oRow->app)) {
                 // Favicon override with group image for known group stream data
                 //if(in_array($oRow->app, CGroups::getStreamAppCode())){
                 if ($oRow->groupid) {
                     // check if the image icon exist in template folder
                     $favicon = JURI::root() . 'components/com_community/assets/favicon/groups.png';
                     if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . 'groups.png')) {
                         $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/groups.png';
                     }
                 }
                 // Favicon override with event image for known event stream data
                 // This would override group favicon
                 if ($oRow->eventid) {
                     // check if the image icon exist in template folder
                     $favicon = JURI::root() . 'components/com_community/assets/favicon/events.png';
                     if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . 'groups.png')) {
                         $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/events.png';
                     }
                 }
                 // If it is not group or event stream, use normal favicon search
                 if (!($oRow->groupid || $oRow->eventid)) {
                     // check if the image icon exist in template folder
                     if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . $oRow->app . '.png')) {
                         $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/' . $oRow->app . '.png';
                     } else {
                         // check if the image icon exist in asset folder
                         if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'assets' . DS . 'favicon' . DS . $oRow->app . '.png')) {
                             $favicon = JURI::root() . 'components/com_community/assets/favicon/' . $oRow->app . '.png';
                         } elseif (JFile::exists(CPluginHelper::getPluginPath('community', $oRow->app) . DS . $oRow->app . DS . 'favicon.png')) {
                             $favicon = JURI::root() . CPluginHelper::getPluginURI('community', $oRow->app) . '/' . $oRow->app . '/favicon.png';
                         } else {
                             $favicon = JURI::root() . 'components/com_community/assets/favicon/default.png';
                         }
                     }
                 }
             } else {
                 $favicon = JURI::root() . 'components/com_community/assets/favicon/default.png';
             }
             $act->favicon = $favicon;
             $target = $this->_targetLink($oRow->target, true);
             $oRow->title = CString::str_ireplace('{target}', $target, $oRow->title);
             if (count($oRow->activities) > 1) {
                 // multiple
                 $actorsLink = '';
                 foreach ($oRow->activities as $actor) {
                     if (empty($actorsLink)) {
                         $actorsLink = $this->_actorLink(intval($actor->actor));
                     } else {
                         // only add if this actor is NOT already linked
                         $alink = $this->_actorLink(intval($actor->actor));
                         $pos = strpos($actorsLink, $alink);
                         if ($pos === false) {
                             $actorsLink .= ', ' . $alink;
                         }
                     }
                 }
                 $actorLink = $this->_actorLink(intval($oRow->actor));
                 $count = count($oRow->activities);
                 $oRow->title = preg_replace('/\\{single\\}(.*?)\\{\\/single\\}/i', '', $oRow->title);
                 $search = array('{multiple}', '{/multiple}');
                 $oRow->title = CString::str_ireplace($search, '', $oRow->title);
                 //Joomla 1.6 CString::str_ireplace issue of not replacing correctly strings with backslashes
                 $oRow->title = str_ireplace($search, '', $oRow->title);
                 $oRow->title = CString::str_ireplace('{actors}', $actorsLink, $oRow->title);
                 $oRow->title = CString::str_ireplace('{actor}', $actorLink, $oRow->title);
                 $oRow->title = CString::str_ireplace('{count}', $count, $oRow->title);
             } else {
                 // single
                 $actorLink = $this->_actorLink(intval($oRow->actor));
                 $oRow->title = preg_replace('/\\{multiple\\}(.*)\\{\\/multiple\\}/i', '', $oRow->title);
                 $search = array('{single}', '{/single}');
                 $oRow->title = CString::str_ireplace($search, '', $oRow->title);
                 $oRow->title = CString::str_ireplace('{actor}', $actorLink, $oRow->title);
             }
             // If the param contains any data, replace it with the content
             preg_match_all("/{(.*?)}/", $oRow->title, $matches, PREG_SET_ORDER);
             if (!empty($matches)) {
                 $params = new CParameter($oRow->params);
                 foreach ($matches as $val) {
                     $replaceWith = $params->get($val[1], null);
                     //if the replacement start with 'index.php', we can CRoute it
                     if (strpos($replaceWith, 'index.php') === 0) {
                         $replaceWith = CRoute::_($replaceWith);
                     }
                     if (!is_null($replaceWith)) {
                         $oRow->title = CString::str_ireplace($val[0], $replaceWith, $oRow->title);
                     }
                 }
             }
             // Format the title
             $oRow->title = $plgObj ? $plgObj->_censor($oRow->title) : $oRow->title;
             $oRow->title = $this->_formatTitle($oRow);
             $act->id = $oRow->id;
             $act->title = $oRow->title;
             $act->actor = $oRow->actor;
             $act->target = $oRow->target;
             $act->content = $this->getActivityContent($oRow);
             $timeFormat = $config->get('activitiestimeformat');
             $dayFormat = $config->get('activitiesdayformat');
             $date = CTimeHelper::getDate($oRow->created);
             $createdTime = '';
             if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
                 $createdTime = $date->toFormat($dayinterval == ACTIVITY_INTERVAL_DAY ? $timeFormat : $dayFormat, true);
             } else {
                 $createdTime = CTimeHelper::timeLapse($date);
             }
             $act->created = $createdTime;
             $act->createdDate = C_JOOMLA_15 == 1 ? $date->toFormat(JText::_('DATE_FORMAT_LC2')) : $date->Format(JText::_('DATE_FORMAT_LC2'));
             $act->createdDateRaw = $oRow->created;
             $act->app = $oRow->app;
             $act->eventid = $oRow->eventid;
             $act->groupid = $oRow->groupid;
             $act->group_access = $oRow->group_access;
             $act->event_access = $oRow->event_access;
             $act->location = $oRow->getLocation();
             $act->commentCount = $oRow->getCommentCount();
             $act->commentAllowed = $oRow->allowComment();
             $act->commentLast = $oRow->getLastComment();
             $act->likeCount = $oRow->getLikeCount();
             $act->likeAllowed = $oRow->allowLike();
             $act->isFriend = $my->isFriendWith($act->actor);
             $act->isMyGroup = $my->isInGroup($oRow->groupid);
             $act->isMyEvent = $my->isInEvent($oRow->eventid);
             $act->userLiked = $oRow->userLiked($my->id);
             $htmlData[] = $act;
         }
     }
     $objActivity = new stdClass();
     $objActivity->data = $htmlData;
     return $objActivity;
 }
Example #5
0
 public function _triggerAllFieldsLoad($event, $arrayParams)
 {
     $dispatcher = CDispatcher::getInstanceStatic();
     $observers = $dispatcher->getObservers();
     $result = $arrayParams[0];
     for ($i = 0; $i < count($observers); $i++) {
         $plgObj = $observers[$i];
         if (is_object($plgObj)) {
             $plgObjWrapper = new CPluginWrapper($plgObj);
             if ($plgObjWrapper->getPluginType() == 'community' && method_exists($plgObj, $event)) {
                 $content = call_user_func_array(array(&$plgObj, $event), $arrayParams);
                 // Merge it to flatten the layers.
                 if (is_array($content)) {
                     $result = array_merge($result, $content);
                 }
             }
         }
     }
     return $result;
 }
Example #6
0
 /**
  * Return an array of activity data
  *
  * @param type $options
  * @return mixed $type string or arrayn or string
  */
 private function _getData($options)
 {
     $dispatcher = CDispatcher::getInstanceStatic();
     $observers = $dispatcher->getObservers();
     $plgObj = false;
     for ($i = 0; $i < count($observers); $i++) {
         if ($observers[$i] instanceof plgCommunityWordfilter) {
             $plgObj = $observers[$i];
         }
     }
     // Default params
     $default = array('actid' => null, 'actor' => 0, 'target' => 0, 'date' => null, 'app' => null, 'cid' => null, 'groupid' => null, 'eventid' => null, 'maxList' => 20, 'type' => '', 'exclusions' => null, 'displayArchived' => false);
     /* Merge with input options */
     $options = array_merge($default, $options);
     extract($options);
     /* Get models */
     $activities = CFactory::getModel('activities');
     /* Variables */
     $my = CFactory::getUser();
     $htmlData = array();
     $config = CFactory::getConfig();
     $blockLists = $my->getBlockedUsers();
     $blockedUserId = array();
     foreach ($blockLists as $blocklist) {
         $blockedUserId[] = $blocklist->blocked_userid;
     }
     // Exclude banned userid
     if (!empty($target) && !empty($blockedUserId)) {
         $target = array_diff($target, $blockedUserId);
     }
     if (!empty($app)) {
         $rows = $activities->getAppActivities($options);
     } else {
         $rows = $activities->getActivities($actor, $target, $date, $maxList, $config->get('respectactivityprivacy'), $exclusions, $displayArchived, $actid, $groupid, $eventid, $options);
     }
     $day = -1;
     // If exclusion is set, we need to remove activities that arrives
     // after the exclusion list is set.
     // Inject additional properties for processing
     for ($i = 0; $i < count($rows); $i++) {
         $row = $rows[$i];
         // A 'used' activities = activities that has been aggregated
         $row->used = false;
         // If the id is larger than any of the exclusion list,
         // we simply hide it
         if (isset($exclusion) && $exclusion > 0 && $row->id > $exclusions) {
             $row->used = true;
         }
     }
     unset($row);
     $dayinterval = ACTIVITY_INTERVAL_DAY;
     $lastTitle = '';
     for ($i = 0; $i < count($rows) && count($htmlData) <= $maxList; $i++) {
         $row = $rows[$i];
         $oRow = $rows[$i];
         // The original object
         // store aggregated activities
         $oRow->activities = array();
         if (!$row->used && count($htmlData) <= $maxList) {
             $oRow = $rows[$i];
             if (!isset($row->used)) {
                 $row->used = false;
             }
             if ($day != $row->getDayDiff()) {
                 $act = new stdClass();
                 $act->type = 'content';
                 $day = $row->getDayDiff();
                 if ($day == 0) {
                     $act->title = JText::_('TODAY');
                 } else {
                     if ($day == 1) {
                         $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_YESTERDAY');
                     } else {
                         if ($day < 7) {
                             $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_DAYS_AGO', $day);
                         } else {
                             if ($day >= 7 && $day < 30) {
                                 $dayinterval = ACTIVITY_INTERVAL_WEEK;
                                 $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_WEEK_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_WEEK_AGO_MANY', intval($day / $dayinterval));
                             } else {
                                 if ($day >= 30) {
                                     $dayinterval = ACTIVITY_INTERVAL_MONTH;
                                     $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_MONTH_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_MONTH_AGO_MANY', intval($day / $dayinterval));
                                 }
                             }
                         }
                     }
                 }
                 // set to a new 'title' type if this new one has a new title
                 // only add if this is a new title
                 if ($act->title != $lastTitle) {
                     $lastTitle = $act->title;
                     $act->type = 'title';
                     $htmlData[] = $act;
                 }
             }
             $act = new stdClass();
             $act->type = 'content';
             $title = $row->title;
             $app = $row->app;
             $cid = $row->cid;
             $actor = $row->actor;
             $commentTypeId = $row->comment_type . $row->comment_id;
             //Check for event or group title if exists
             if ($row->eventid) {
                 $eventModel = CFactory::getModel('events');
                 $act->appTitle = $eventModel->getTitle($row->eventid);
             } else {
                 if ($row->groupid) {
                     $groupModel = CFactory::getModel('groups');
                     $act->appTitle = $groupModel->getGroupName($row->groupid);
                 }
             }
             for ($j = $i; $j < count($rows) && $row->getDayDiff() == $day; $j++) {
                 $row = $rows[$j];
                 // we aggregate stream that has the same content on the same day.
                 // we should not however aggregate content that does not support
                 // multiple content. How do we detect? easy, they don't have
                 // {multiple} in the title string
                 // However, if the activity is from the same user, we only want
                 // to show the laste acitivity
                 if ($row->getDayDiff() == $day && $row->title == $title && $app == $row->app && $cid == $row->cid && (JString::strpos($row->title, '{/multiple}') !== FALSE || $row->actor == $actor) && $commentTypeId == $row->comment_type . $row->comment_id && $row->app != "photos") {
                     // @rule: If an exclusion is added, we need to fetch activities without these items.
                     // Aggregated activities should also be excluded.
                     // $row->used = true;
                     $oRow->activities[] = $row;
                 }
             }
             $app = !empty($oRow->app) ? $this->_appLink($oRow->app, $oRow->actor, $oRow->target, $oRow->title) : '';
             $oRow->title = CString::str_ireplace('{app}', $app, $oRow->title);
             $favicon = '';
             // this should not really be empty
             if (!empty($oRow->app)) {
                 // Favicon override with group image for known group stream data
                 //if(in_array($oRow->app, CGroups::getStreamAppCode())){
                 if ($oRow->groupid) {
                     // check if the image icon exist in template folder
                     $favicon = JURI::root() . 'components/com_community/assets/favicon/groups.png';
                     if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon/groups.png')) {
                         $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/groups.png';
                     }
                 }
                 // Favicon override with event image for known event stream data
                 // This would override group favicon
                 if ($oRow->eventid) {
                     // check if the image icon exist in template folder
                     $favicon = JURI::root() . 'components/com_community/assets/favicon/events.png';
                     if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon/groups.png')) {
                         $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/events.png';
                     }
                 }
                 // If it is not group or event stream, use normal favicon search
                 if (!($oRow->groupid || $oRow->eventid)) {
                     // check if the image icon exist in template folder
                     if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon' . '/' . $oRow->app . '.png')) {
                         $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/' . $oRow->app . '.png';
                     } else {
                         $CPluginHelper = new CPluginHelper();
                         // check if the image icon exist in asset folder
                         if (JFile::exists(JPATH_ROOT . '/components/com_community/assets/favicon' . '/' . $oRow->app . '.png')) {
                             $favicon = JURI::root(true) . '/components/com_community/assets/favicon/' . $oRow->app . '.png';
                         } elseif (JFile::exists($CPluginHelper->getPluginPath('community', $oRow->app) . '/' . $oRow->app . '/favicon.png')) {
                             $favicon = JURI::root(true) . "/" . $CPluginHelper->getPluginURI('community', $oRow->app) . '/' . $oRow->app . '/favicon.png';
                         } else {
                             $favicon = JURI::root(true) . '/components/com_community/assets/favicon/default.png';
                         }
                     }
                 }
             } else {
                 $favicon = JURI::root(true) . '/components/com_community/assets/favicon/default.png';
             }
             $act->favicon = $favicon;
             $target = $this->_targetLink($oRow->target, true);
             $act->title = $oRow->title;
             $act->id = $oRow->id;
             $act->cid = $oRow->cid;
             $act->title = $oRow->title;
             $act->actor = $oRow->actor;
             $act->actors = $oRow->actors;
             $act->target = $oRow->target;
             $act->access = $oRow->access;
             $timeFormat = $config->get('activitiestimeformat');
             $dayFormat = $config->get('activitiesdayformat');
             $date = CTimeHelper::getDate($oRow->created);
             // Do not modify created time
             // $createdTime = '';
             // if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
             // 	$createdTime = $date->format($dayinterval == ACTIVITY_INTERVAL_DAY ? $timeFormat : $dayFormat, true);
             // } else {
             // 	$createdTime = CTimeHelper::timeLapse($date);
             // }
             $act->created = $oRow->created;
             $act->createdDate = $date->Format(JText::_('DATE_FORMAT_LC2'));
             $act->createdDateRaw = $oRow->created;
             $act->app = $oRow->app;
             $act->eventid = $oRow->eventid;
             $act->groupid = $oRow->groupid;
             $act->group_access = $oRow->group_access;
             $act->event_access = $oRow->event_access;
             $act->location = $oRow->getLocation();
             $act->commentCount = $oRow->getCommentCount();
             $act->commentAllowed = $oRow->allowComment();
             $act->commentLast = $oRow->getLastComment();
             $act->commentsAll = $oRow->getCommentsAll();
             $act->likeCount = $oRow->getLikeCount();
             $act->likeAllowed = $oRow->allowLike();
             $act->isFriend = $my->isFriendWith($act->actor);
             $act->isMyGroup = $my->isInGroup($oRow->groupid);
             $act->isMyEvent = $my->isInEvent($oRow->eventid);
             $act->userLiked = $oRow->userLiked($my->id);
             $act->latitude = $oRow->latitude;
             $act->longitude = $oRow->longitude;
             $act->params = !empty($oRow->params) ? $oRow->params : '';
             // Create and pass album, videos, groups, event object
             switch ($act->app) {
                 case 'photos':
                     // Album object
                     $act->album = JTable::getInstance('Album', 'CTable');
                     $act->album->load($act->cid);
                     $oRow->album = $act->album;
                     break;
                 case 'videos':
                     // Album object
                     $act->video = JTable::getInstance('Video', 'CTable');
                     $act->video->load($act->cid);
                     $oRow->video = $act->video;
                     break;
             }
             // get the content
             $act->content = $this->getActivityContent($oRow);
             //$act->title		= $this->getActivityTitle($oRow);
             $act->title = $oRow->title;
             $act->content = $oRow->content;
             $htmlData[] = $act;
         }
     }
     $objActivity = new stdClass();
     $objActivity->data = $htmlData;
     return $objActivity;
 }