apioauthpin.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Action for displaying an OAuth verifier pin
  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 Action
  23. * @package StatusNet
  24. * @author Zach Copley <zach@status.net>
  25. * @copyright 2010 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. * Class for displaying an OAuth verifier pin
  34. *
  35. * XXX: I'm pretty sure we don't need to check the logged in state here. -- Zach
  36. *
  37. * @category Action
  38. * @package StatusNet
  39. * @author Zach Copley <zach@status.net>
  40. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  41. * @link http://status.net/
  42. */
  43. class ApiOAuthPinAction extends InfoAction
  44. {
  45. function __construct($title, $message, $verifier, $desktopMode = false)
  46. {
  47. $this->verifier = $verifier;
  48. $this->title = $title;
  49. $this->desktopMode = $desktopMode;
  50. parent::__construct($title, $message);
  51. }
  52. /**
  53. * Show body - override to add a special CSS class for the pin pages's
  54. * "desktop mode" (minimal display)
  55. *
  56. * Calls template methods
  57. *
  58. * @return nothing
  59. */
  60. function showBody()
  61. {
  62. $bodyClasses = array();
  63. if ($this->desktopMode) {
  64. $bodyClasses[] = 'oauth-desktop-mode';
  65. }
  66. if (common_current_user()) {
  67. $bodyClasses[] = 'user_in';
  68. }
  69. $attrs = array('id' => strtolower($this->trimmed('action')));
  70. if (!empty($bodyClasses)) {
  71. $attrs['class'] = implode(' ', $bodyClasses);
  72. }
  73. $this->elementStart('body', $attrs);
  74. $this->elementStart('div', array('id' => 'wrap'));
  75. if (Event::handle('StartShowHeader', array($this))) {
  76. $this->showHeader();
  77. Event::handle('EndShowHeader', array($this));
  78. }
  79. $this->showCore();
  80. if (Event::handle('StartShowFooter', array($this))) {
  81. $this->showFooter();
  82. Event::handle('EndShowFooter', array($this));
  83. }
  84. $this->elementEnd('div');
  85. $this->showScripts();
  86. $this->elementEnd('body');
  87. }
  88. /**
  89. * A local menu
  90. *
  91. * Shows different login/register actions.
  92. *
  93. * @return void
  94. */
  95. function showLocalNav()
  96. {
  97. // NOP
  98. }
  99. /*
  100. * Override - suppress output in "desktop" mode
  101. */
  102. function showHeader()
  103. {
  104. if ($this->desktopMode == false) {
  105. parent::showHeader();
  106. }
  107. }
  108. /*
  109. * Override - suppress output in "desktop" mode
  110. */
  111. function showAside()
  112. {
  113. if ($this->desktopMode == false) {
  114. parent::showAside();
  115. }
  116. }
  117. /*
  118. * Override - suppress output in "desktop" mode
  119. */
  120. function showFooter()
  121. {
  122. if ($this->desktopMode == false) {
  123. parent::showFooter();
  124. }
  125. }
  126. /**
  127. * Show site notice.
  128. *
  129. * @return nothing
  130. */
  131. function showSiteNotice()
  132. {
  133. // NOP
  134. }
  135. /**
  136. * Show notice form.
  137. *
  138. * Show the form for posting a new notice
  139. *
  140. * @return nothing
  141. */
  142. function showNoticeForm()
  143. {
  144. // NOP
  145. }
  146. /**
  147. * Display content.
  148. *
  149. * @return nothing
  150. */
  151. function showContent()
  152. {
  153. $this->element('div', array('class' => 'info'), $this->message);
  154. $this->element('div', array('id' => 'oauth_pin'), $this->verifier);
  155. }
  156. }