userrss.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2008, 2009, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('GNUSOCIAL')) { exit(1); }
  20. // Formatting of RSS handled by Rss10Action
  21. class UserrssAction extends TargetedRss10Action
  22. {
  23. protected $tag = null;
  24. protected function doStreamPreparation()
  25. {
  26. parent::doStreamPreparation();
  27. $this->tag = $this->trimmed('tag');
  28. }
  29. protected function getNotices()
  30. {
  31. if (!empty($this->tag)) {
  32. $stream = $this->getTarget()->getTaggedNotices($this->tag, 0, $this->limit);
  33. return $stream->fetchAll();
  34. }
  35. // otherwise we fetch a normal user stream
  36. $stream = $this->getTarget()->getNotices(0, $this->limit);
  37. return $stream->fetchAll();
  38. }
  39. function getChannel()
  40. {
  41. $c = array('url' => common_local_url('userrss',
  42. array('nickname' =>
  43. $this->target->getNickname())),
  44. // TRANS: Message is used as link title. %s is a user nickname.
  45. 'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
  46. 'link' => $this->target->getUrl(),
  47. // TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
  48. 'description' => sprintf(_('Updates from %1$s on %2$s!'),
  49. $this->target->getNickname(), common_config('site', 'name')));
  50. return $c;
  51. }
  52. // override parent to add X-SUP-ID URL
  53. function initRss()
  54. {
  55. $url = common_local_url('sup', null, null, $this->target->getID());
  56. header('X-SUP-ID: '.$url);
  57. parent::initRss();
  58. }
  59. function isReadOnly($args)
  60. {
  61. return true;
  62. }
  63. }