grouprss.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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('STATUSNET') && !defined('LACONICA')) {
  31. exit(1);
  32. }
  33. require_once INSTALLDIR.'/lib/rssaction.php';
  34. define('MEMBERS_PER_SECTION', 27);
  35. /**
  36. * Group RSS feed
  37. *
  38. * @category Group
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  42. * @link http://status.net/
  43. */
  44. class groupRssAction extends Rss10Action
  45. {
  46. /** group we're viewing. */
  47. var $group = null;
  48. /**
  49. * Is this page read-only?
  50. *
  51. * @return boolean true
  52. */
  53. function isReadOnly($args)
  54. {
  55. return true;
  56. }
  57. /**
  58. * Prepare the action
  59. *
  60. * Reads and validates arguments and instantiates the attributes.
  61. *
  62. * @param array $args $_REQUEST args
  63. *
  64. * @return boolean success flag
  65. */
  66. function prepare($args)
  67. {
  68. parent::prepare($args);
  69. $nickname_arg = $this->arg('nickname');
  70. $nickname = common_canonical_nickname($nickname_arg);
  71. // Permanent redirect on non-canonical nickname
  72. if ($nickname_arg != $nickname) {
  73. $args = array('nickname' => $nickname);
  74. common_redirect(common_local_url('showgroup', $args), 301);
  75. }
  76. if (!$nickname) {
  77. // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname.
  78. $this->clientError(_('No nickname.'), 404);
  79. }
  80. $local = Local_group::getKV('nickname', $nickname);
  81. if (!$local) {
  82. // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist.
  83. $this->clientError(_('No such group.'), 404);
  84. }
  85. $this->group = User_group::getKV('id', $local->group_id);
  86. if (!$this->group) {
  87. // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group.
  88. $this->clientError(_('No such group.'), 404);
  89. }
  90. $this->notices = $this->getNotices($this->limit);
  91. return true;
  92. }
  93. function getNotices($limit=0)
  94. {
  95. $group = $this->group;
  96. if (is_null($group)) {
  97. return null;
  98. }
  99. $notices = array();
  100. $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
  101. while ($notice->fetch()) {
  102. $notices[] = clone($notice);
  103. }
  104. return $notices;
  105. }
  106. function getChannel()
  107. {
  108. $group = $this->group;
  109. $c = array('url' => common_local_url('grouprss',
  110. array('nickname' =>
  111. $group->nickname)),
  112. // TRANS: Message is used as link title. %s is a user nickname.
  113. 'title' => sprintf(_('%s timeline'), $group->nickname),
  114. 'link' => common_local_url('showgroup', array('nickname' => $group->nickname)),
  115. // TRANS: Message is used as link description. %1$s is a group name, %2$s is a site name.
  116. 'description' => sprintf(_('Updates from members of %1$s on %2$s!'),
  117. $group->nickname, common_config('site', 'name')));
  118. return $c;
  119. }
  120. function getImage()
  121. {
  122. return $this->group->homepage_logo;
  123. }
  124. }