repeat.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 $notice = null; // Notice that is being repeated.
  42. protected $repeat = null; // The resulting repeat object/notice.
  43. function title()
  44. {
  45. return _m('TITLE', 'Repeat notice');
  46. }
  47. protected function doPreparation()
  48. {
  49. $id = $this->trimmed('notice');
  50. if (empty($id)) {
  51. // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
  52. $this->clientError(_('No notice specified.'));
  53. }
  54. $this->notice = Notice::getKV('id', $id);
  55. if (!$this->notice instanceof Notice) {
  56. // TRANS: Client error displayed when trying to repeat a non-existing notice.
  57. $this->clientError(_('Notice not found.'));
  58. }
  59. $this->repeat = $this->notice->repeat($this->scoped, 'web');
  60. if (!$this->repeat instanceof Notice) {
  61. // TRANS: Error when unable to repeat a notice for unknown reason.
  62. $this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!'));
  63. }
  64. return true;
  65. }
  66. /**
  67. * Class handler.
  68. *
  69. * @param array $args query arguments
  70. *
  71. * @return void
  72. */
  73. protected function showContent()
  74. {
  75. $this->element('p', array('id' => 'repeat_response',
  76. 'class' => 'repeated'),
  77. // TRANS: Confirmation text after repeating a notice.
  78. _('Repeated!'));
  79. }
  80. }