repliesrss.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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('STATUSNET') && !defined('LACONICA')) { exit(1); }
  20. require_once(INSTALLDIR.'/lib/rssaction.php');
  21. // Formatting of RSS handled by Rss10Action
  22. class RepliesrssAction extends Rss10Action
  23. {
  24. var $user = null;
  25. function prepare($args)
  26. {
  27. parent::prepare($args);
  28. $nickname = $this->trimmed('nickname');
  29. $this->user = User::getKV('nickname', $nickname);
  30. if (!$this->user) {
  31. // TRANS: Client error displayed when providing a non-existing nickname in a RSS 1.0 action.
  32. $this->clientError(_('No such user.'));
  33. } else {
  34. $this->notices = $this->getNotices($this->limit);
  35. return true;
  36. }
  37. }
  38. function getNotices($limit=0)
  39. {
  40. $user = $this->user;
  41. $notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
  42. $notices = array();
  43. while ($notice->fetch()) {
  44. $notices[] = clone($notice);
  45. }
  46. return $notices;
  47. }
  48. function getChannel()
  49. {
  50. $user = $this->user;
  51. $c = array('url' => common_local_url('repliesrss',
  52. array('nickname' =>
  53. $user->nickname)),
  54. // TRANS: RSS reply feed title. %s is a user nickname.
  55. 'title' => sprintf(_("Replies to %s"), $user->nickname),
  56. 'link' => common_local_url('replies',
  57. array('nickname' =>
  58. $user->nickname)),
  59. // TRANS: RSS reply feed description.
  60. // TRANS: %1$s is a user nickname, %2$s is the StatusNet site name.
  61. 'description' => sprintf(_('Replies to %1$s on %2$s.'),
  62. $user->nickname, common_config('site', 'name')));
  63. return $c;
  64. }
  65. function getImage()
  66. {
  67. $profile = $this->user->getProfile();
  68. return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
  69. }
  70. function isReadOnly($args)
  71. {
  72. return true;
  73. }
  74. }