oauthappssettings.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. * List the OAuth applications that a user has registered with this instance
  18. *
  19. * @category Settings
  20. * @package GNUsocial
  21. * @author Zach Copley <zach@status.net>
  22. * @copyright 2008-2009 StatusNet, Inc.
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Show a user's registered OAuth applications
  28. *
  29. * @category Settings
  30. * @package GNUsocial
  31. * @author Zach Copley <zach@status.net>
  32. * @copyright 2008-2009 StatusNet, Inc.
  33. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  34. *
  35. * @see SettingsAction
  36. */
  37. class OauthappssettingsAction extends SettingsAction
  38. {
  39. protected $page = null;
  40. protected function doPreparation()
  41. {
  42. $this->page = $this->int('page') ?: 1;
  43. }
  44. /**
  45. * Title of the page
  46. *
  47. * @return string Title of the page
  48. */
  49. public function title()
  50. {
  51. // TRANS: Page title for OAuth applications
  52. return _('OAuth applications');
  53. }
  54. /**
  55. * Instructions for use
  56. *
  57. * @return instructions for use
  58. */
  59. public function getInstructions()
  60. {
  61. // TRANS: Page instructions for OAuth applications
  62. return _('Applications you have registered');
  63. }
  64. public function showContent()
  65. {
  66. $offset = ($this->page - 1) * APPS_PER_PAGE;
  67. $limit = APPS_PER_PAGE + 1;
  68. $application = new Oauth_application();
  69. $application->owner = $this->scoped->getID();
  70. $application->whereAdd("name <> 'anonymous'");
  71. $application->limit($offset, $limit);
  72. $application->orderBy('created DESC, id DESC');
  73. $application->find();
  74. $cnt = 0;
  75. if ($application) {
  76. $al = new ApplicationList($application, $this->scoped, $this);
  77. $cnt = $al->show();
  78. if (0 == $cnt) {
  79. $this->showEmptyListMessage();
  80. }
  81. }
  82. $this->elementStart('p', ['id' => 'application_register']);
  83. $this->element(
  84. 'a',
  85. [
  86. 'href' => common_local_url('newapplication'),
  87. 'class' => 'more',
  88. ],
  89. // TRANS: Link description to add a new OAuth application.
  90. 'Register a new application'
  91. );
  92. $this->elementEnd('p');
  93. $this->pagination(
  94. $this->page > 1,
  95. $cnt > APPS_PER_PAGE,
  96. $this->page,
  97. 'oauthappssettings'
  98. );
  99. }
  100. public function showEmptyListMessage()
  101. {
  102. // TRANS: Empty list message on page with OAuth applications. Markup allowed
  103. $message = sprintf(_('You have not registered any applications yet.'));
  104. $this->elementStart('div', 'guide');
  105. $this->raw(common_markup_to_html($message));
  106. $this->elementEnd('div');
  107. }
  108. }