grouprss.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Group main page
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Group
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @author Sarven Capadisli <csarven@status.net>
  26. * @copyright 2008-2009 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('GNUSOCIAL')) { exit(1); }
  31. define('MEMBERS_PER_SECTION', 27);
  32. /**
  33. * Group RSS feed
  34. *
  35. * @category Group
  36. * @package StatusNet
  37. * @author Evan Prodromou <evan@status.net>
  38. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  39. * @link http://status.net/
  40. */
  41. class GroupRssAction extends TargetedRss10Action
  42. {
  43. /** group we're viewing. */
  44. protected $group = null;
  45. /**
  46. * Is this page read-only?
  47. *
  48. * @return boolean true
  49. */
  50. function isReadOnly($args)
  51. {
  52. return true;
  53. }
  54. protected function doStreamPreparation()
  55. {
  56. $nickname_arg = $this->arg('nickname');
  57. $nickname = common_canonical_nickname($nickname_arg);
  58. // Permanent redirect on non-canonical nickname
  59. if ($nickname_arg != $nickname) {
  60. $args = array('nickname' => $nickname);
  61. common_redirect(common_local_url('showgroup', $args), 301);
  62. }
  63. if (!$nickname) {
  64. // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
  65. $this->clientError(_('No nickname.'), 404);
  66. }
  67. $local = Local_group::getKV('nickname', $nickname);
  68. if (!$local instanceof Local_group) {
  69. // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
  70. $this->clientError(_('No such group.'), 404);
  71. }
  72. $this->group = $local->getGroup();
  73. $this->target = $this->group->getProfile();
  74. }
  75. protected function getNotices()
  76. {
  77. $stream = $this->group->getNotices(0, $this->limit);
  78. return $stream->fetchAll();
  79. }
  80. function getChannel()
  81. {
  82. $c = array('url' => common_local_url('grouprss',
  83. array('nickname' =>
  84. $this->target->getNickname())),
  85. // TRANS: Message is used as link title. %s is a user nickname.
  86. 'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
  87. 'link' => common_local_url('showgroup', array('nickname' => $this->target->getNickname())),
  88. // TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
  89. 'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
  90. $this->target->getNickname(), common_config('site', 'name')));
  91. return $c;
  92. }
  93. function getImage()
  94. {
  95. return $this->group->homepage_logo;
  96. }
  97. }