/**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     $lastEventTime = $this->eventList->getLastEventTime();
     // removes orphaned and non-accessable events
     UserActivityEventHandler::validateEvents($this->eventList);
     DashboardHandler::getInstance()->loadBoxes('com.woltlab.wcf.user.MembersListPage', $this);
     WCF::getTPL()->assign(array('eventList' => $this->eventList, 'lastEventTime' => $lastEventTime, 'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.user.MembersListPage'), 'sidebarName' => 'com.woltlab.wcf.user.MembersListPage', 'allowSpidersToIndexThisPage' => true));
 }
 /**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     $this->eventList = new ViewableUserActivityEventList();
     $this->eventList->sqlLimit = RECENT_ACTIVITY_SIDEBAR_ITEMS;
     $this->eventList->readObjects();
     // removes orphaned and non-accessable events
     UserActivityEventHandler::validateEvents($this->eventList);
     $this->fetched();
 }
 /**
  * Loads a list of recent activity entries.
  * 
  * @return	array
  */
 public function load()
 {
     $eventList = new ViewableUserActivityEventList();
     if ($this->parameters['lastEventID']) {
         $eventList->getConditionBuilder()->add("user_activity_event.time <= ?", array($this->parameters['lastEventTime']));
         $eventList->getConditionBuilder()->add("user_activity_event.eventID < ?", array($this->parameters['lastEventID']));
     } else {
         $eventList->getConditionBuilder()->add("user_activity_event.time < ?", array($this->parameters['lastEventTime']));
     }
     // profile view
     if ($this->parameters['userID']) {
         $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", array($this->parameters['userID']));
     } else {
         if ($this->parameters['filteredByFollowedUsers'] && count(WCF::getUserProfileHandler()->getFollowingUsers())) {
             $eventList->getConditionBuilder()->add('user_activity_event.userID IN (?)', array(WCF::getUserProfileHandler()->getFollowingUsers()));
         }
     }
     $eventList->readObjects();
     $lastEventTime = $eventList->getLastEventTime();
     if (!$lastEventTime) {
         return array();
     }
     // removes orphaned and non-accessable events
     UserActivityEventHandler::validateEvents($eventList);
     if (!count($eventList)) {
         return array();
     }
     // parse template
     WCF::getTPL()->assign(array('eventList' => $eventList));
     $events = $eventList->getObjects();
     return array('lastEventID' => end($events)->eventID, 'lastEventTime' => $lastEventTime, 'template' => WCF::getTPL()->fetch('recentActivityListItem'));
 }
 /**
  * @see	\wcf\system\menu\user\profile\content\IUserProfileMenuContent::getContent()
  */
 public function getContent($userID)
 {
     $eventList = new ViewableUserActivityEventList();
     $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", array($userID));
     $eventList->readObjects();
     $lastEventTime = $eventList->getLastEventTime();
     if ($lastEventTime) {
         UserActivityEventHandler::validateEvents($eventList);
     }
     WCF::getTPL()->assign(array('eventList' => $eventList, 'lastEventTime' => $lastEventTime, 'placeholder' => WCF::getLanguage()->get('wcf.user.profile.content.recentActivity.noEntries'), 'userID' => $userID));
     return WCF::getTPL()->fetch('recentActivities');
 }
 /**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     if (WCF::getUser()->userID && count(WCF::getUserProfileHandler()->getFollowingUsers())) {
         $this->canFilterByFollowedUsers = true;
     }
     $this->eventList = new ViewableUserActivityEventList();
     if ($this->canFilterByFollowedUsers && WCF::getUser()->recentActivitiesFilterByFollowing) {
         $this->filteredByFollowedUsers = true;
         $this->eventList->getConditionBuilder()->add('user_activity_event.userID IN (?)', array(WCF::getUserProfileHandler()->getFollowingUsers()));
     }
     $this->eventList->sqlLimit = RECENT_ACTIVITY_ITEMS;
     $this->eventList->readObjects();
     $this->lastEventTime = $this->eventList->getLastEventTime();
     // removes orphaned and non-accessable events
     UserActivityEventHandler::validateEvents($this->eventList);
     $this->fetched();
 }
 /**
  * Validates an event list and removes orphaned events.
  * 
  * @param	\wcf\data\user\activity\event\ViewableUserActivityEventList	$eventList
  */
 public static function validateEvents(ViewableUserActivityEventList $eventList)
 {
     $eventIDs = $eventList->validateEvents();
     // remove orphaned event ids
     if (!empty($eventIDs)) {
         $sql = "DELETE FROM\twcf" . WCF_N . "_user_activity_event\n\t\t\t\tWHERE\t\teventID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         foreach ($eventIDs as $eventID) {
             $statement->execute(array($eventID));
         }
     }
 }