confirmregistration.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, StatusNet, Inc.
  5. *
  6. * Registration confirmation form
  7. *
  8. * PHP version 5
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Email registration
  24. * @package StatusNet
  25. * @author Evan Prodromou <evan@status.net>
  26. * @copyright 2011 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. // This check helps protect against security problems;
  32. // your code file can't be executed directly from the web.
  33. exit(1);
  34. }
  35. /**
  36. * Registration confirmation form
  37. *
  38. * @category Email registration
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @copyright 2011 StatusNet, Inc.
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  43. * @link http://status.net/
  44. */
  45. class ConfirmRegistrationForm extends Form
  46. {
  47. protected $action;
  48. protected $code;
  49. protected $nickname;
  50. protected $email;
  51. public function __construct($out, $nickname, $email, $code)
  52. {
  53. parent::__construct($out);
  54. $this->action = $out;
  55. $this->nickname = $nickname;
  56. $this->email = $email;
  57. $this->code = $code;
  58. }
  59. public function formData()
  60. {
  61. $this->out->element('p', 'instructions',
  62. // TRANS: Form instructions.
  63. sprintf(_m('Enter a password to confirm your new account.'))
  64. );
  65. $this->hidden('code', $this->code);
  66. $this->out->elementStart('ul', 'form_data');
  67. // Hook point for captcha etc
  68. Event::handle('StartRegistrationFormData', array($this->action));
  69. $this->elementStart('li');
  70. // TRANS: Field label in e-mail registration form.
  71. $this->element('label', array('for' => 'nickname'), _m('LABEL', 'User name'));
  72. $this->element('input', array('name' => 'nickname',
  73. 'type' => 'text',
  74. 'id' => 'nickname',
  75. 'value' => $this->nickname));
  76. $this->elementEnd('li');
  77. $this->elementStart('li');
  78. // TRANS: Field label.
  79. $this->element('label', array('for' => 'email-ignore'), _m('Email address'));
  80. $this->element('input', array('name' => 'email-ignore',
  81. 'type' => 'text',
  82. 'id' => 'email-ignore',
  83. 'disabled' => 'true',
  84. 'value' => $this->email));
  85. $this->elementEnd('li');
  86. $this->elementStart('li');
  87. // TRANS: Field label on account registration page.
  88. $this->password('password1', _m('Password'),
  89. // TRANS: Field title on account registration page.
  90. _m('6 or more characters.')
  91. );
  92. $this->elementEnd('li');
  93. $this->elementStart('li');
  94. // TRANS: Field label on account registration page. In this field the password has to be entered a second time.
  95. $this->password('password2', _m('PASSWORD', 'Confirm'),
  96. // TRANS: Field title on account registration page.
  97. _m('Same as password above.')
  98. );
  99. $this->elementEnd('li');
  100. // Hook point for captcha etc
  101. Event::handle('EndRegistrationFormData', array($this->action));
  102. $this->elementStart('li');
  103. $this->element('input', array('name' => 'tos',
  104. 'type' => 'checkbox',
  105. 'class' => 'checkbox',
  106. 'id' => 'tos',
  107. 'value' => 'true'));
  108. $this->text(' ');
  109. $this->elementStart('label', array('class' => 'checkbox',
  110. 'for' => 'tos'));
  111. // TRANS: Checkbox title for terms of service and privacy policy.
  112. $this->raw(sprintf(
  113. _m('I agree to the <a href="%1$s">Terms of service</a> and '.
  114. '<a href="%1$s">Privacy policy</a> of this site.'),
  115. common_local_url('doc', array('title' => 'tos')),
  116. common_local_url('doc', array('title' => 'privacy'))
  117. ));
  118. $this->elementEnd('label');
  119. $this->elementEnd('li');
  120. $this->out->elementEnd('ul');
  121. }
  122. public function method()
  123. {
  124. return 'post';
  125. }
  126. /**
  127. * Buttons for form actions
  128. *
  129. * Submit and cancel buttons (or whatever)
  130. * Sub-classes should overload this to show their own buttons.
  131. *
  132. * @return void
  133. */
  134. public function formActions()
  135. {
  136. // TRANS: Button text for action to register.
  137. $this->out->submit('submit', _m('BUTTON', 'Register'));
  138. }
  139. /**
  140. * ID of the form
  141. *
  142. * Should be unique on the page. Sub-classes should overload this
  143. * to show their own IDs.
  144. *
  145. * @return int ID of the form
  146. */
  147. public function id()
  148. {
  149. return 'form_email_registration';
  150. }
  151. /**
  152. * Action of the form.
  153. *
  154. * URL to post to. Should be overloaded by subclasses to give
  155. * somewhere to post to.
  156. *
  157. * @return string URL to post to
  158. */
  159. public function action()
  160. {
  161. return common_local_url('register');
  162. }
  163. public function formClass()
  164. {
  165. return 'form_confirm_registration form_settings';
  166. }
  167. }