confirmregistration.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 $code;
  48. protected $nickname;
  49. protected $email;
  50. function __construct($out, $nickname, $email, $code)
  51. {
  52. parent::__construct($out);
  53. $this->nickname = $nickname;
  54. $this->email = $email;
  55. $this->code = $code;
  56. }
  57. function formData()
  58. {
  59. $this->out->element('p', 'instructions',
  60. // TRANS: Form instructions.
  61. sprintf(_m('Enter a password to confirm your new account.')));
  62. $this->hidden('code', $this->code);
  63. $this->out->elementStart('ul', 'form_data');
  64. $this->elementStart('li');
  65. // TRANS: Field label in e-mail registration form.
  66. $this->element('label', array('for' => 'nickname'), _m('LABEL','User name'));
  67. $this->element('input', array('name' => 'nickname',
  68. 'type' => 'text',
  69. 'id' => 'nickname',
  70. 'value' => $this->nickname));
  71. $this->elementEnd('li');
  72. $this->elementStart('li');
  73. // TRANS: Field label.
  74. $this->element('label', array('for' => 'email-ignore'), _m('Email address'));
  75. $this->element('input', array('name' => 'email-ignore',
  76. 'type' => 'text',
  77. 'id' => 'email-ignore',
  78. 'disabled' => 'true',
  79. 'value' => $this->email));
  80. $this->elementEnd('li');
  81. $this->elementStart('li');
  82. // TRANS: Field label on account registration page.
  83. $this->password('password1', _m('Password'),
  84. // TRANS: Field title on account registration page.
  85. _m('6 or more characters.'));
  86. $this->elementEnd('li');
  87. $this->elementStart('li');
  88. // TRANS: Field label on account registration page. In this field the password has to be entered a second time.
  89. $this->password('password2', _m('PASSWORD','Confirm'),
  90. // TRANS: Field title on account registration page.
  91. _m('Same as password above.'));
  92. $this->elementEnd('li');
  93. $this->elementStart('li');
  94. $this->element('input', array('name' => 'tos',
  95. 'type' => 'checkbox',
  96. 'class' => 'checkbox',
  97. 'id' => 'tos',
  98. 'value' => 'true'));
  99. $this->text(' ');
  100. $this->elementStart('label', array('class' => 'checkbox',
  101. 'for' => 'tos'));
  102. // TRANS: Checkbox title for terms of service and privacy policy.
  103. $this->raw(sprintf(_m('I agree to the <a href="%1$s">Terms of service</a> and '.
  104. '<a href="%1$s">Privacy policy</a> of this site.'),
  105. common_local_url('doc', array('title' => 'tos')),
  106. common_local_url('doc', array('title' => 'privacy'))));
  107. $this->elementEnd('label');
  108. $this->elementEnd('li');
  109. $this->out->elementEnd('ul');
  110. }
  111. function method()
  112. {
  113. return 'post';
  114. }
  115. /**
  116. * Buttons for form actions
  117. *
  118. * Submit and cancel buttons (or whatever)
  119. * Sub-classes should overload this to show their own buttons.
  120. *
  121. * @return void
  122. */
  123. function formActions()
  124. {
  125. // TRANS: Button text for action to register.
  126. $this->out->submit('submit', _m('BUTTON', 'Register'));
  127. }
  128. /**
  129. * ID of the form
  130. *
  131. * Should be unique on the page. Sub-classes should overload this
  132. * to show their own IDs.
  133. *
  134. * @return int ID of the form
  135. */
  136. function id()
  137. {
  138. return 'form_email_registration';
  139. }
  140. /**
  141. * Action of the form.
  142. *
  143. * URL to post to. Should be overloaded by subclasses to give
  144. * somewhere to post to.
  145. *
  146. * @return string URL to post to
  147. */
  148. function action()
  149. {
  150. return common_local_url('register');
  151. }
  152. function formClass()
  153. {
  154. return 'form_confirm_registration form_settings';
  155. }
  156. }