/**
  *
  * @param User $user
  * @param boolean $indent
  * @param boolean $outputMode: UserActivityStream::OUTPUT_STRING to return a string,
  *                           or UserActivityStream::OUTPUT_RAW to go to raw output.
  *                           Raw output mode will attempt to stream, keeping less
  *                           data in memory but will leave $this->activities incomplete.
  */
 function __construct($user, $indent = true, $outputMode = UserActivityStream::OUTPUT_STRING)
 {
     parent::__construct($user, null, $indent);
     $this->outputMode = $outputMode;
     if ($this->outputMode == self::OUTPUT_STRING) {
         // String buffering? Grab all the notices now.
         $notices = $this->getNotices();
     } elseif ($this->outputMode == self::OUTPUT_RAW) {
         // Raw output... need to restructure from the stringer init.
         $this->xw = new XMLWriter();
         $this->xw->openURI('php://output');
         if (is_null($indent)) {
             $indent = common_config('site', 'indent');
         }
         $this->xw->setIndent($indent);
         // We'll fetch notices later.
         $notices = array();
     } else {
         throw new Exception('Invalid outputMode provided to ' . __METHOD__);
     }
     // Assume that everything but notices is feasible
     // to pull at once and work with in memory...
     $subscriptions = $this->getSubscriptions();
     $subscribers = $this->getSubscribers();
     $groups = $this->getGroups();
     $faves = $this->getFaves();
     $objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices);
     // Sort by create date
     usort($objs, 'UserActivityStream::compareObject');
     // We'll keep these around for later, and interleave them into
     // the output stream with the user's notices.
     foreach ($objs as $obj) {
         $this->activities[] = $obj->asActivity();
     }
 }
 function __construct($user, $indent = true)
 {
     parent::__construct($user, null, $indent);
     $subscriptions = $this->getSubscriptions();
     $subscribers = $this->getSubscribers();
     $groups = $this->getGroups();
     $faves = $this->getFaves();
     $notices = $this->getNotices();
     $objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices);
     // Sort by create date
     usort($objs, 'UserActivityStream::compareObject');
     foreach ($objs as $obj) {
         $act = $obj->asActivity();
         // Only show the author sub-element if it's different from default user
         $str = $act->asString(false, $act->actor->id != $this->user->uri);
         $this->addEntryRaw($str);
     }
 }