From 310ef22fd996a21642cc63b33829cc1f397269d7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 May 2008 07:29:54 -0400 Subject: abstract out RSS 1.0 generation to allow multiple streams darcs-hash:20080522112954-84dde-aa5087977298f5169148383e82e22241e613b1f2.gz --- actions/userrss.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 actions/userrss.php (limited to 'actions/userrss.php') diff --git a/actions/userrss.php b/actions/userrss.php new file mode 100644 index 000000000..92a6bccc9 --- /dev/null +++ b/actions/userrss.php @@ -0,0 +1,80 @@ +. + */ + +if (!defined('LACONICA')) { exit(1); } + +require_once(INSTALLDIR.'/lib/rssaction.php'); + +// Formatting of RSS handled by Rss10Action + +class UserrssAction extends Rss10Action { + + var $user = NULL; + + function init() { + $nickname = $this->trimmed('nickname'); + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { + common_user_error(_t('No such nickname.')); + return false; + } else { + return true; + } + } + + function get_notices($limit=0) { + + $user = $this->user; + $notices = array(); + + $notice = DB_DataObject::factory('notice'); + $notice->profile_id = $user->id; # user id === profile id + $notice->orderBy('created DESC'); + if ($limit != 0) { + $notice->limit(0, $limit); + } + $notice->find(); + + while ($notice->fetch()) { + $notices[] = clone($notice); + } + + return $notices; + } + + function get_channel() { + $user = $this->user; + $profile = $user->getProfile(); + $c = array('url' => common_local_url('userrss', + array('nickname' => + $user->nickname)), + 'title' => $user->nickname, + 'link' => $profile->profileurl, + 'description' => _t('Microblog by ') . $user->nickname); + return $c; + } + + function get_image() { + $user = $this->user; + $profile = $user->getProfile(); + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + return ($avatar) ? $avatar->url : NULL; + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf