/**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->_profile = Profile::staticGet('id', $this->trimmed('profile'));
     if (empty($this->_profile)) {
         // TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
         throw new ClientException(_('No such profile.'), 404);
     }
     $offset = ($this->page - 1) * $this->count;
     $limit = $this->count + 1;
     $this->_faves = Fave::byProfile($this->_profile->id, $offset, $limit);
     return true;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->_profile = Profile::getKV('id', $this->trimmed('profile'));
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
         throw new ClientException(_('No such profile.'), 404);
     }
     $offset = ($this->page - 1) * $this->count;
     $limit = $this->count + 1;
     $this->_faves = Fave::byProfile($this->_profile->id, $offset, $limit);
     return true;
 }
 function dumpFaves($user, $dir)
 {
     common_log(LOG_INFO, 'dumping faves by ' . $user->nickname . ' to directory ' . $dir);
     $page = 1;
     do {
         $fave = Fave::byProfile($user->id, ($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
         while ($fave->fetch()) {
             try {
                 $fname = $dir . '/' . common_date_iso8601($fave->modified) . '-fave-' . $fave->notice_id . '.atom';
                 $act = $fave->asActivity();
                 $data = $act->asString(false, false, false);
                 common_log(LOG_INFO, 'dumping fave of ' . $fave->notice_id . ' to file ' . $fname);
                 file_put_contents($fname, $data);
                 $data = null;
             } catch (Exception $e) {
                 common_log(LOG_ERR, "Error backing up fave of " . $fave->notice_id . ": " . $e->getMessage());
                 continue;
             }
         }
         $page++;
     } while ($fave->N > NOTICES_PER_PAGE);
 }