mailboxaction.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * common superclass for direct messages inbox and outbox
  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 Message
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2008 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET') && !defined('LACONICA')) {
  30. exit(1);
  31. }
  32. /**
  33. * common superclass for direct messages inbox and outbox
  34. *
  35. * @category Message
  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. * @see InboxAction
  41. * @see OutboxAction
  42. */
  43. class MailboxAction extends Action
  44. {
  45. var $page = null;
  46. function prepare($args)
  47. {
  48. parent::prepare($args);
  49. $nickname = common_canonical_nickname($this->arg('nickname'));
  50. $this->user = User::getKV('nickname', $nickname);
  51. $this->page = $this->trimmed('page');
  52. if (!$this->page) {
  53. $this->page = 1;
  54. }
  55. common_set_returnto($this->selfUrl());
  56. return true;
  57. }
  58. /**
  59. * output page based on arguments
  60. *
  61. * @param array $args HTTP arguments (from $_REQUEST)
  62. *
  63. * @return void
  64. */
  65. function handle($args)
  66. {
  67. parent::handle($args);
  68. if (!$this->user) {
  69. // TRANS: Client error displayed when trying to access a mailbox without providing a user.
  70. $this->clientError(_('No such user.'), 404);
  71. }
  72. $cur = common_current_user();
  73. if (!$cur || $cur->id != $this->user->id) {
  74. // TRANS: Client error displayed when trying to access a mailbox that is not of the logged in user.
  75. $this->clientError(_('Only the user can read their own mailboxes.'), 403);
  76. }
  77. $this->showPage();
  78. }
  79. function showNoticeForm()
  80. {
  81. $message_form = new MessageForm($this);
  82. $message_form->show();
  83. }
  84. function showContent()
  85. {
  86. $message = $this->getMessages();
  87. if ($message) {
  88. $ml = $this->getMessageList($message);
  89. $cnt = $ml->show();
  90. $this->pagination($this->page > 1,
  91. $cnt > MESSAGES_PER_PAGE,
  92. $this->page,
  93. $this->trimmed('action'),
  94. array('nickname' => $this->user->nickname));
  95. } else {
  96. $this->element('p',
  97. 'guide',
  98. // TRANS: Message displayed when there are no private messages in the inbox of a user.
  99. _('You have no private messages. '.
  100. 'You can send private message to engage other users in conversation. '.
  101. 'People can send you messages for your eyes only.'));
  102. }
  103. }
  104. function getMessages()
  105. {
  106. return null;
  107. }
  108. function getMessageList($message)
  109. {
  110. return null;
  111. }
  112. /**
  113. * Show the page notice
  114. *
  115. * Shows instructions for the page
  116. *
  117. * @return void
  118. */
  119. function showPageNotice()
  120. {
  121. $instr = $this->getInstructions();
  122. $output = common_markup_to_html($instr);
  123. $this->elementStart('div', 'instructions');
  124. $this->raw($output);
  125. $this->elementEnd('div');
  126. }
  127. /**
  128. * Mailbox actions are read only
  129. *
  130. * @param array $args other arguments
  131. *
  132. * @return boolean
  133. */
  134. function isReadOnly($args)
  135. {
  136. return true;
  137. }
  138. function showObjectNav()
  139. {
  140. $mm = new MailboxMenu($this);
  141. $mm->show();
  142. }
  143. }