]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/EmailRegistration/forms/confirmregistration.php
Allow changing nick on EmailRegistration
[quix0rs-gnu-social.git] / plugins / EmailRegistration / forms / confirmregistration.php
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
31 if (!defined('STATUSNET')) {
32     // This check helps protect against security problems;
33     // your code file can't be executed directly from the web.
34     exit(1);
35 }
36
37 /**
38  * Registration confirmation form
39  *
40  * @category  Email registration
41  * @package   StatusNet
42  * @author    Evan Prodromou <evan@status.net>
43  * @copyright 2011 StatusNet, Inc.
44  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45  * @link      http://status.net/
46  */
47 class ConfirmRegistrationForm extends Form
48 {
49     protected $code;
50     protected $nickname;
51     protected $email;
52
53     function __construct($out, $nickname, $email, $code)
54     {
55         parent::__construct($out);
56         $this->nickname = $nickname;
57         $this->email = $email;
58         $this->code = $code;
59     }
60
61     function formData()
62     {
63         $this->out->element('p', 'instructions',
64                             // TRANS: Form instructions.
65                             sprintf(_m('Enter a password to confirm your new account.')));
66
67         $this->hidden('code', $this->code);
68
69         $this->out->elementStart('ul', 'form_data');
70
71         $this->elementStart('li');
72
73         // TRANS: Field label in e-mail registration form.
74         $this->element('label', array('for' => 'nickname'), _m('LABEL','User name'));
75
76         $this->element('input', array('name' => 'nickname',
77                                       'type' => 'text',
78                                       'id' => 'nickname',
79                                       'value' => $this->nickname));
80
81         $this->elementEnd('li');
82
83         $this->elementStart('li');
84
85         // TRANS: Field label.
86         $this->element('label', array('for' => 'email-ignore'), _m('Email address'));
87
88         $this->element('input', array('name' => 'email-ignore',
89                                       'type' => 'text',
90                                       'id' => 'email-ignore',
91                                       'disabled' => 'true',
92                                       'value' => $this->email));
93
94         $this->elementEnd('li');
95
96         $this->elementStart('li');
97         // TRANS: Field label on account registration page.
98         $this->password('password1', _m('Password'),
99                         // TRANS: Field title on account registration page.
100                         _m('6 or more characters.'));
101         $this->elementEnd('li');
102         $this->elementStart('li');
103         // TRANS: Field label on account registration page. In this field the password has to be entered a second time.
104         $this->password('password2', _m('PASSWORD','Confirm'),
105                         // TRANS: Field title on account registration page.
106                         _m('Same as password above.'));
107         $this->elementEnd('li');
108
109         $this->elementStart('li');
110
111         $this->element('input', array('name' => 'tos',
112                                       'type' => 'checkbox',
113                                       'class' => 'checkbox',
114                                       'id' => 'tos',
115                                       'value' => 'true'));
116         $this->text(' ');
117
118         $this->elementStart('label', array('class' => 'checkbox',
119                                            'for' => 'tos'));
120
121         // TRANS: Checkbox title for terms of service and privacy policy.
122         $this->raw(sprintf(_m('I agree to the <a href="%1$s">Terms of service</a> and '.
123                              '<a href="%1$s">Privacy policy</a> of this site.'),
124                            common_local_url('doc', array('title' => 'tos')),
125                            common_local_url('doc', array('title' => 'privacy'))));
126
127         $this->elementEnd('label');
128
129         $this->elementEnd('li');
130
131         $this->out->elementEnd('ul');
132     }
133
134     function method()
135     {
136         return 'post';
137     }
138
139     /**
140      * Buttons for form actions
141      *
142      * Submit and cancel buttons (or whatever)
143      * Sub-classes should overload this to show their own buttons.
144      *
145      * @return void
146      */
147
148     function formActions()
149     {
150         // TRANS: Button text for action to register.
151         $this->out->submit('submit', _m('BUTTON', 'Register'));
152     }
153
154     /**
155      * ID of the form
156      *
157      * Should be unique on the page. Sub-classes should overload this
158      * to show their own IDs.
159      *
160      * @return int ID of the form
161      */
162
163     function id()
164     {
165         return 'form_email_registration';
166     }
167
168     /**
169      * Action of the form.
170      *
171      * URL to post to. Should be overloaded by subclasses to give
172      * somewhere to post to.
173      *
174      * @return string URL to post to
175      */
176
177     function action()
178     {
179         return common_local_url('register');
180     }
181
182     function formClass()
183     {
184         return 'form_confirm_registration form_settings';
185     }
186 }