inbox.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * GNUsocial implementation of Direct Messages
  18. *
  19. * @package GNUsocial
  20. * @author Mikael Nordfeldth <mmn@hethane.se>
  21. * @author Bruno Casteleiro <brunoccast@fc.up.pt>
  22. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Action handler for the inbox
  28. *
  29. * @category Plugin
  30. * @package GNUsocial
  31. * @author Mikael Nordfeldth <mmn@hethane.se>
  32. * @author Bruno Casteleiro <brunoccast@fc.up.pt>
  33. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  34. */
  35. class InboxAction extends MailboxAction
  36. {
  37. /**
  38. * Title of the page.
  39. *
  40. * @return string page title
  41. */
  42. function title() : string
  43. {
  44. if ($this->page > 1) {
  45. // TRANS: Title for all but the first page of the inbox page.
  46. // TRANS: %1$s is the user's nickname, %2$s is the page number.
  47. return sprintf(_m('Inbox for %1$s - page %2$d'), $this->user->getNickname(),
  48. $this->page);
  49. } else {
  50. // TRANS: Title for the first page of the inbox page.
  51. // TRANS: %s is the user's nickname.
  52. return sprintf(_m('Inbox for %s'), $this->user->getNickname());
  53. }
  54. }
  55. /**
  56. * Retrieve the messages for this user and this page.
  57. *
  58. * @return Notice data object with stream for messages
  59. */
  60. function getMessages()
  61. {
  62. return MessageModel::inboxMessages($this->user, $this->page);
  63. }
  64. /**
  65. * Retrieve inbox MessageList widget
  66. */
  67. function getMessageList($message)
  68. {
  69. return new InboxMessageList($this, $message);
  70. }
  71. /**
  72. * Instructions for using this page.
  73. *
  74. * @return string localised instructions for using the page
  75. */
  76. function getInstructions() : string
  77. {
  78. // TRANS: Instructions for user inbox page.
  79. return _m('This is your inbox, which lists your incoming private messages.');
  80. }
  81. }