Introducing TargetedRss10Action for simplifying RSS 1.0
This commit is contained in:
parent
1cbf2510e7
commit
e46b2803a7
@ -42,52 +42,12 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class AllrssAction extends Rss10Action
|
class AllrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $user = null;
|
protected function getNotices()
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization.
|
|
||||||
*
|
|
||||||
* @param array $args Web and URL arguments
|
|
||||||
*
|
|
||||||
* @return boolean false if user doesn't exist
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$stream = new InboxNoticeStream($this->target);
|
||||||
$nickname = $this->trimmed('nickname');
|
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error when user not found for an rss related action.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$stream = new InboxNoticeStream($this->user->getProfile());
|
|
||||||
$notice = $stream->getNotices(0, $limit, null, null);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,33 +57,17 @@ class AllrssAction extends Rss10Action
|
|||||||
*/
|
*/
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('allrss',
|
$c = array('url' => common_local_url('allrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s and friends'), $user->nickname),
|
'title' => sprintf(_('%s and friends'), $this->target->getNickname()),
|
||||||
'link' => common_local_url('all',
|
'link' => common_local_url('all',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
|
'description' => sprintf(_('Updates from %1$s and friends on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return string user avatar URL or null
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$user = $this->user;
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
if (!$profile) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ define('MEMBERS_PER_SECTION', 27);
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class groupRssAction extends Rss10Action
|
class GroupRssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** group we're viewing. */
|
/** group we're viewing. */
|
||||||
var $group = null;
|
protected $group = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this page read-only?
|
* Is this page read-only?
|
||||||
@ -56,18 +56,8 @@ class groupRssAction extends Rss10Action
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doStreamPreparation()
|
||||||
* Prepare the action
|
|
||||||
*
|
|
||||||
* Reads and validates arguments and instantiates the attributes.
|
|
||||||
*
|
|
||||||
* @param array $args $_REQUEST args
|
|
||||||
*
|
|
||||||
* @return boolean success flag
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$nickname_arg = $this->arg('nickname');
|
$nickname_arg = $this->arg('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
@ -86,52 +76,32 @@ class groupRssAction extends Rss10Action
|
|||||||
|
|
||||||
$local = Local_group::getKV('nickname', $nickname);
|
$local = Local_group::getKV('nickname', $nickname);
|
||||||
|
|
||||||
if (!$local) {
|
if (!$local instanceof Local_group) {
|
||||||
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
// TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
|
||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->group = User_group::getKV('id', $local->group_id);
|
$this->group = $local->getGroup();
|
||||||
|
$this->target = $this->group->getProfile();
|
||||||
if (!$this->group) {
|
|
||||||
// TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
|
|
||||||
$this->clientError(_('No such group.'), 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$group = $this->group;
|
$stream = $this->group->getNotices(0, $this->limit);
|
||||||
|
return $stream->fetchAll();
|
||||||
if (is_null($group)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$group = $this->group;
|
|
||||||
$c = array('url' => common_local_url('grouprss',
|
$c = array('url' => common_local_url('grouprss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$group->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s timeline'), $group->nickname),
|
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||||
'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
|
'link' => common_local_url('showgroup', array('nickname' => $this->target->getNickname())),
|
||||||
// TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
|
'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
|
||||||
$group->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,19 +44,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
*/
|
*/
|
||||||
class NoticesearchrssAction extends Rss10Action
|
class NoticesearchrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
function init()
|
protected function getNotices()
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
$this->notices = $this->getNotices();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
{
|
||||||
$q = $this->trimmed('q');
|
$q = $this->trimmed('q');
|
||||||
$notices = array();
|
$notices = array();
|
||||||
@ -66,8 +54,7 @@ class NoticesearchrssAction extends Rss10Action
|
|||||||
$search_engine = $notice->getSearchEngine('notice');
|
$search_engine = $notice->getSearchEngine('notice');
|
||||||
$search_engine->set_sort_mode('chron');
|
$search_engine->set_sort_mode('chron');
|
||||||
|
|
||||||
if (!$limit) $limit = 20;
|
$search_engine->limit(0, $this->limit, true);
|
||||||
$search_engine->limit(0, $limit, true);
|
|
||||||
if (false === $search_engine->query($q)) {
|
if (false === $search_engine->query($q)) {
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,29 +44,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
*/
|
*/
|
||||||
class PublicrssAction extends Rss10Action
|
class PublicrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Read arguments and initialize members
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization.
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function init()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notices
|
* Get notices
|
||||||
*
|
*
|
||||||
@ -74,15 +51,10 @@ class PublicrssAction extends Rss10Action
|
|||||||
*
|
*
|
||||||
* @return array notices
|
* @return array notices
|
||||||
*/
|
*/
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$notices = array();
|
$stream = Notice::publicStream(0, $this->limit);
|
||||||
$notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
|
return $stream->fetchAll();
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,64 +21,30 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class RepliesrssAction extends Rss10Action
|
class RepliesrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $user = null;
|
protected function getNotices()
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
$stream = $this->target->getReplies(0, $this->limit);
|
||||||
$nickname = $this->trimmed('nickname');
|
return $stream->fetchAll();
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when providing a non-existing nickname in a RSS 1.0 action.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$user = $this->user;
|
|
||||||
|
|
||||||
$notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('repliesrss',
|
$c = array('url' => common_local_url('repliesrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: RSS reply feed title. %s is a user nickname.
|
// TRANS: RSS reply feed title. %s is a user nickname.
|
||||||
'title' => sprintf(_("Replies to %s"), $user->nickname),
|
'title' => sprintf(_("Replies to %s"), $this->target->getNickname()),
|
||||||
'link' => common_local_url('replies',
|
'link' => common_local_url('replies',
|
||||||
array('nickname' =>
|
array('nickname' => $this->target->getNickname())),
|
||||||
$user->nickname)),
|
|
||||||
// TRANS: RSS reply feed description.
|
// TRANS: RSS reply feed description.
|
||||||
// TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
|
// TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
|
||||||
'description' => sprintf(_('Replies to %1$s on %2$s.'),
|
'description' => sprintf(_('Replies to %1$s on %2$s.'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$profile = $this->user->getProfile();
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,33 +20,25 @@
|
|||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class TagrssAction extends Rss10Action
|
class TagrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
var $tag;
|
protected $tag;
|
||||||
|
|
||||||
function prepare($args) {
|
protected function doStreamPreparation()
|
||||||
parent::prepare($args);
|
{
|
||||||
$tag = common_canonical_tag($this->trimmed('tag'));
|
$tag = common_canonical_tag($this->trimmed('tag'));
|
||||||
$this->tag = Notice_tag::getKV('tag', $tag);
|
$this->tag = Notice_tag::getKV('tag', $tag);
|
||||||
if (!$this->tag) {
|
if (!$this->tag instanceof Notice_tag) {
|
||||||
// TRANS: Client error when requesting a tag feed for a non-existing tag.
|
// TRANS: Client error when requesting a tag feed for a non-existing tag.
|
||||||
$this->clientError(_('No such tag.'));
|
$this->clientError(_('No such tag.'));
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($limit=0)
|
protected function getNotices()
|
||||||
{
|
{
|
||||||
$tag = $this->tag;
|
$stream = Notice_tag::getStream($this->tag->tag)->getNotices(0, $this->limit);
|
||||||
|
return $stream->fetchAll();
|
||||||
if (is_null($tag)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice = Notice_tag::getStream($tag->tag)->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
|
|
||||||
return $notice->fetchAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
|
@ -21,94 +21,48 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
|
|
||||||
// Formatting of RSS handled by Rss10Action
|
// Formatting of RSS handled by Rss10Action
|
||||||
|
|
||||||
class UserrssAction extends Rss10Action
|
class UserrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
var $tag = null;
|
protected $tag = null;
|
||||||
|
|
||||||
protected function prepare(array $args=array())
|
protected function doStreamPreparation()
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
|
||||||
$nickname = $this->trimmed('nickname');
|
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
$this->tag = $this->trimmed('tag');
|
$this->tag = $this->trimmed('tag');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->user) {
|
protected function getNotices()
|
||||||
// TRANS: Client error displayed when user not found for an action.
|
{
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->tag)) {
|
if (!empty($this->tag)) {
|
||||||
$this->notices = $this->getTaggedNotices();
|
$stream = $this->target->getTaggedNotices($this->tag, 0, $this->limit);
|
||||||
} else {
|
return $stream->fetchAll();
|
||||||
$this->notices = $this->getNotices();
|
|
||||||
}
|
}
|
||||||
|
// otherwise we fetch a normal user stream
|
||||||
|
|
||||||
return true;
|
$stream = $this->target->getNotices(0, $this->limit);
|
||||||
}
|
return $stream->fetchAll();
|
||||||
|
|
||||||
function getTaggedNotices()
|
|
||||||
{
|
|
||||||
$notice = $this->user->getTaggedNotices(
|
|
||||||
$this->tag,
|
|
||||||
0,
|
|
||||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getNotices()
|
|
||||||
{
|
|
||||||
$notice = $this->user->getNotices(
|
|
||||||
0,
|
|
||||||
($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit
|
|
||||||
);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$profile = $user->getProfile();
|
|
||||||
$c = array('url' => common_local_url('userrss',
|
$c = array('url' => common_local_url('userrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Message is used as link title. %s is a user nickname.
|
// TRANS: Message is used as link title. %s is a user nickname.
|
||||||
'title' => sprintf(_('%s timeline'), $user->nickname),
|
'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
|
||||||
'link' => $profile->profileurl,
|
'link' => $this->target->getUrl(),
|
||||||
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
// TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
|
||||||
'description' => sprintf(_('Updates from %1$s on %2$s!'),
|
'description' => sprintf(_('Updates from %1$s on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
$profile = $this->user->getProfile();
|
|
||||||
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent to add X-SUP-ID URL
|
// override parent to add X-SUP-ID URL
|
||||||
|
|
||||||
function initRss($limit=0)
|
function initRss()
|
||||||
{
|
{
|
||||||
$url = common_local_url('sup', null, null, $this->user->id);
|
$url = common_local_url('sup', null, null, $this->target->getID());
|
||||||
header('X-SUP-ID: '.$url);
|
header('X-SUP-ID: '.$url);
|
||||||
parent::initRss($limit);
|
parent::initRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
|
@ -50,7 +50,7 @@ class Local_group extends Managed_DataObject
|
|||||||
$group->find(true);
|
$group->find(true);
|
||||||
if (!$group instanceof User_group) {
|
if (!$group instanceof User_group) {
|
||||||
common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
|
common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
|
||||||
throw new NoResultException($group);
|
throw new NoSuchGroupException(array('id' => $this->group_id));
|
||||||
}
|
}
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,11 @@ class Profile extends Managed_DataObject
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
|
{
|
||||||
|
return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
|
||||||
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$stream = new TaggedProfileNoticeStream($this, $tag);
|
$stream = new TaggedProfileNoticeStream($this, $tag);
|
||||||
|
@ -55,10 +55,9 @@ class Reply extends Managed_DataObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
static function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$stream = new ReplyNoticeStream($user_id);
|
$stream = new ReplyNoticeStream($user_id);
|
||||||
|
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class Rss10Action extends ManagedAction
|
|||||||
{
|
{
|
||||||
$this->limit = $this->int('limit');
|
$this->limit = $this->int('limit');
|
||||||
|
|
||||||
if ($this->limit == 0) {
|
if (empty($this->limit)) {
|
||||||
$this->limit = DEFAULT_RSS_LIMIT;
|
$this->limit = DEFAULT_RSS_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,10 +73,19 @@ class Rss10Action extends ManagedAction
|
|||||||
|
|
||||||
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
|
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
|
||||||
$this->show_basic_auth_error();
|
$this->show_basic_auth_error();
|
||||||
return;
|
// the above calls 'exit'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->doStreamPreparation();
|
||||||
|
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doStreamPreparation()
|
||||||
|
{
|
||||||
|
// for example if we need to set $this->target or something
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_basic_auth_error()
|
function show_basic_auth_error()
|
||||||
@ -98,7 +107,7 @@ class Rss10Action extends ManagedAction
|
|||||||
* @return array an array of Notice objects sorted in reverse chron
|
* @return array an array of Notice objects sorted in reverse chron
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNotices()
|
protected function getNotices($limit=0)
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -44,54 +44,12 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class BookmarksrssAction extends Rss10Action
|
class BookmarksrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** The user whose bookmarks to display */
|
protected function getNotices()
|
||||||
|
|
||||||
var $user = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the user to display by supplied nickname
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when trying to get the RSS feed with bookmarks of a user that does not exist.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$stream = new BookmarksNoticeStream($this->target->getID(), true);
|
||||||
|
return $stream->getNotices(0, $this->limit)->fetchAll();
|
||||||
$notice = new BookmarksNoticeStream($this->user->id, true);
|
|
||||||
$notice = $notice->getNotices(0, NOTICES_PER_PAGE);
|
|
||||||
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,31 +59,19 @@ class BookmarksrssAction extends Rss10Action
|
|||||||
*/
|
*/
|
||||||
function getChannel()
|
function getChannel()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
|
||||||
$c = array('url' => common_local_url('bookmarksrss',
|
$c = array('url' => common_local_url('bookmarksrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Title of RSS feed with bookmarks of a user.
|
// TRANS: Title of RSS feed with bookmarks of a user.
|
||||||
// TRANS: %s is a user's nickname.
|
// TRANS: %s is a user's nickname.
|
||||||
'title' => sprintf(_("%s's bookmarks"), $user->nickname),
|
'title' => sprintf(_("%s's bookmarks"), $this->target->getNickname()),
|
||||||
'link' => common_local_url('bookmarks',
|
'link' => common_local_url('bookmarks',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$this->target->getNickname())),
|
||||||
// TRANS: Desciption of RSS feed with bookmarks of a user.
|
// TRANS: Desciption of RSS feed with bookmarks of a user.
|
||||||
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
// TRANS: %1$s is a user's nickname, %2$s is the name of the StatusNet site.
|
||||||
'description' => sprintf(_('Bookmarks posted by %1$s on %2$s!'),
|
'description' => sprintf(_('Bookmarks posted by %1$s on %2$s!'),
|
||||||
$user->nickname, common_config('site', 'name')));
|
$this->target->getNickname(), common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,50 +43,15 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class FavoritesrssAction extends Rss10Action
|
class FavoritesrssAction extends TargetedRss10Action
|
||||||
{
|
{
|
||||||
/** The user whose favorites to display */
|
protected function getNotices()
|
||||||
|
|
||||||
var $user = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the user to display by supplied nickname
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
function prepare($args)
|
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
// is this our own stream?
|
||||||
|
$own = $this->scoped instanceof Profile ? $this->target->getID() === $this->scoped->getID() : false;
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
$stream = Fave::stream($this->target->getID(), 0, $this->limit, $own);
|
||||||
$this->user = User::getKV('nickname', $nickname);
|
return $stream->fetchAll();
|
||||||
|
|
||||||
if (!$this->user) {
|
|
||||||
// TRANS: Client error displayed when trying to get the RSS feed with favorites of a user that does not exist.
|
|
||||||
$this->clientError(_('No such user.'));
|
|
||||||
} else {
|
|
||||||
$this->notices = $this->getNotices($this->limit);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notices
|
|
||||||
*
|
|
||||||
* @param integer $limit max number of notices to return
|
|
||||||
*
|
|
||||||
* @return array notices
|
|
||||||
*/
|
|
||||||
function getNotices($limit=0)
|
|
||||||
{
|
|
||||||
$notice = Fave::stream($this->user->id, 0, $limit, $false);
|
|
||||||
$notices = array();
|
|
||||||
while ($notice->fetch()) {
|
|
||||||
$notices[] = clone($notice);
|
|
||||||
}
|
|
||||||
return $notices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,15 +77,4 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
$user->nickname, common_config('site', 'name')));
|
$user->nickname, common_config('site', 'name')));
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function getImage()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user