oauthappssettings.php 3.6 KB

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