repeat.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Repeat action.
  4. *
  5. * PHP version 5
  6. *
  7. * @category Action
  8. * @package StatusNet
  9. * @author Evan Prodromou <evan@status.net>
  10. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  11. * @link http://status.net/
  12. *
  13. * StatusNet - the distributed open-source microblogging tool
  14. * Copyright (C) 2008, 2009, StatusNet, Inc.
  15. *
  16. * This program is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License as published by
  18. * the Free Software Foundation, either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. */
  29. if (!defined('GNUSOCIAL')) { exit(1); }
  30. /**
  31. * Repeat action
  32. *
  33. * @category Action
  34. * @package StatusNet
  35. * @author Evan Prodromou <evan@status.net>
  36. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  37. * @link http://status.net/
  38. */
  39. class RepeatAction extends FormAction
  40. {
  41. protected $needPost = true; // At least for now, until repeat interface is available
  42. protected $notice = null; // Notice that is being repeated.
  43. protected $repeat = null; // The resulting repeat object/notice.
  44. protected function prepare(array $args=array())
  45. {
  46. parent::prepare($args);
  47. $id = $this->trimmed('notice');
  48. if (empty($id)) {
  49. // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
  50. $this->clientError(_('No notice specified.'));
  51. }
  52. $this->notice = Notice::getKV('id', $id);
  53. if (!$this->notice instanceof Notice) {
  54. // TRANS: Client error displayed when trying to repeat a non-existing notice.
  55. $this->clientError(_('Notice not found.'));
  56. }
  57. $this->repeat = $this->notice->repeat($this->scoped, 'web');
  58. if (!$this->repeat instanceof Notice) {
  59. // TRANS: Error when unable to repeat a notice for unknown reason.
  60. $this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!'));
  61. }
  62. return true;
  63. }
  64. /**
  65. * Class handler.
  66. *
  67. * @param array $args query arguments
  68. *
  69. * @return void
  70. */
  71. protected function showContent()
  72. {
  73. $this->element('p', array('id' => 'repeat_response',
  74. 'class' => 'repeated'),
  75. // TRANS: Confirmation text after repeating a notice.
  76. _('Repeated!'));
  77. }
  78. }