X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fallrss.php;h=05787f3f73cb8cdc5398cb4dc8c7140facc371cc;hb=34db24e4d53d017a3f77807ac69b067f31728716;hp=7aab423b2725d8100c4494e92be62c9edfae5eb3;hpb=735b8ddc676cc7d85ca4256994755e61ea6023a1;p=quix0rs-gnu-social.git diff --git a/actions/allrss.php b/actions/allrss.php index 7aab423b27..05787f3f73 100644 --- a/actions/allrss.php +++ b/actions/allrss.php @@ -1,5 +1,17 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,68 +29,104 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/rssaction.php'; + +/** + * RSS feed for user and friends timeline. + * + * Formatting of RSS handled by Rss10Action + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ +class AllrssAction extends Rss10Action +{ + var $user = null; + + /** + * Initialization. + * + * @return boolean false if user doesn't exist + */ + function prepare($args) + { + parent::prepare($args); + $nickname = $this->trimmed('nickname'); + $this->user = User::staticGet('nickname', $nickname); -require_once(INSTALLDIR.'/lib/rssaction.php'); + if (!$this->user) { + $this->clientError(_('No such user.')); + return false; + } else { + return true; + } + } -// Formatting of RSS handled by Rss10Action + /** + * Get notices + * + * @param integer $limit max number of notices to return + * + * @return array notices + */ + function getNotices($limit=0) + { + $user = $this->user; + $notice = $user->noticesWithFriends(0, $limit); + + while ($notice->fetch()) { + $notices[] = clone($notice); + } -class AllrssAction extends Rss10Action { + return $notices; + } - var $user = NULL; + /** + * Get channel. + * + * @return array associative array on channel information + */ + function getChannel() + { + $user = $this->user; + $c = array('url' => common_local_url('allrss', + array('nickname' => + $user->nickname)), + 'title' => sprintf(_('%s and friends'), $user->nickname), + 'link' => common_local_url('all', + array('nickname' => + $user->nickname)), + 'description' => sprintf(_('Feed for friends of %s'), $user->nickname)); + return $c; + } - 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'); + /** + * Get image. + * + * @return string user avatar URL or null + */ + function getImage() + { + $user = $this->user; + $profile = $user->getProfile(); + if (!$profile) { + return null; + } + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + return $avatar ? $avatar->url : null; + } - $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR'); - $notice->whereAdd('profile_id = ' . $user->id, 'OR'); + function isReadOnly() + { + return true; + } +} - $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; - $c = array('url' => common_local_url('allrss', - array('nickname' => - $user->nickname)), - 'title' => $user->nickname . _t(' and friends'), - 'link' => common_local_url('all', - array('nickname' => - $user->nickname)), - 'description' => _t('Microblog feed for ') . $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