groupmessage.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, StatusNet, Inc.
  5. *
  6. * Form for posting a group message
  7. *
  8. * PHP version 5
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category GroupPrivateMessage
  24. * @package StatusNet
  25. * @author Evan Prodromou <evan@status.net>
  26. * @copyright 2011 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. // This check helps protect against security problems;
  32. // your code file can't be executed directly from the web.
  33. exit(1);
  34. }
  35. /**
  36. * Form for posting a group message
  37. *
  38. * @category GroupPrivateMessage
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @copyright 2011 StatusNet, Inc.
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  43. * @link http://status.net/
  44. */
  45. class GroupMessageForm extends Form
  46. {
  47. var $group;
  48. var $content;
  49. /**
  50. * Constructor
  51. *
  52. * @param HTMLOutputter $out Output context
  53. * @param User_group $group Group to post to
  54. *
  55. * @todo add a drop-down list to post to any group
  56. */
  57. function __construct($out, $group, $content=null)
  58. {
  59. parent::__construct($out);
  60. $this->group = $group;
  61. $this->content = $content;
  62. }
  63. /**
  64. * Action for the form
  65. */
  66. function action()
  67. {
  68. return common_local_url('newgroupmessage',
  69. array('nickname' => $this->group->nickname));
  70. }
  71. /**
  72. * Legend for the form
  73. *
  74. * @param
  75. *
  76. * @return
  77. */
  78. function formLegend()
  79. {
  80. $this->out->element('legend',
  81. null,
  82. // TRANS: Form legend for sending private message to group %s.
  83. sprintf(_m('Message to %s'), $this->group->nickname));
  84. }
  85. /**
  86. * id for the form
  87. *
  88. * @param
  89. *
  90. * @return
  91. */
  92. function id()
  93. {
  94. return 'form_notice-group-message';
  95. }
  96. /**
  97. * class for the form
  98. *
  99. * @param
  100. *
  101. * @return
  102. */
  103. function formClass()
  104. {
  105. return 'form_notice';
  106. }
  107. /**
  108. * Entry data
  109. *
  110. * @param
  111. *
  112. * @return
  113. */
  114. function formData()
  115. {
  116. $this->out->element('label', array('for' => 'notice_data-text',
  117. 'id' => 'notice_data-text-label'),
  118. // TRANS: Field label for private group message to group %s.
  119. sprintf(_m('Direct message to %s'), $this->group->nickname));
  120. $this->out->element('textarea', array('id' => 'notice_data-text',
  121. 'cols' => 35,
  122. 'rows' => 4,
  123. 'name' => 'content'),
  124. ($this->content) ? $this->content : '');
  125. $contentLimit = Message::maxContent();
  126. if ($contentLimit > 0) {
  127. $this->out->elementStart('dl', 'form_note');
  128. // TRANS: Indicator for number of chatacters still available for notice.
  129. $this->out->element('dt', null, _m('Available characters'));
  130. $this->out->element('dd', array('class' => 'count'),
  131. $contentLimit);
  132. $this->out->elementEnd('dl');
  133. }
  134. }
  135. /**
  136. * Legend for the form
  137. *
  138. * @param
  139. *
  140. * @return
  141. */
  142. function formActions()
  143. {
  144. $this->out->element('input', array('id' => 'notice_action-submit',
  145. 'class' => 'submit',
  146. 'name' => 'message_send',
  147. 'type' => 'submit',
  148. // TRANS: Send button text for sending private group notice.
  149. 'value' => _m('Send button for sending notice', 'Send')));
  150. }
  151. }