3 * Register new account page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) FusionForge Team
7 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge 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 General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once('../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfcommon.'include/account.php';
28 require_once $gfcommon.'include/timezones.php';
30 if (forge_get_config ('user_registration_restricted')) {
31 session_require_global_perm ('forge_admin');
34 $unix_name = getStringFromRequest('unix_name');
35 $firstname = getStringFromRequest('firstname');
36 $lastname = getStringFromRequest('lastname');
37 $password1 = getStringFromRequest('password1');
38 $password2 = getStringFromRequest('password2');
39 $email = getStringFromRequest('email');
40 $mail_site = getIntFromRequest('mail_site');
41 $mail_va = getIntFromRequest('mail_va');
43 $language_id = getIntFromRequest('language_id');
44 $timezone = getStringFromRequest('timezone');
45 $jabber_address = getStringFromRequest('jabber_address');
46 $jabber_only = getStringFromRequest('jabber_only');
47 $theme_id = getIntFromRequest('theme_id');
48 $address = getStringFromRequest('address');
49 $address2 = getStringFromRequest('address2');
50 $phone = getStringFromRequest('phone');
51 $fax = getStringFromRequest('fax');
52 $title = getStringFromRequest('title');
53 $ccode = getStringFromRequest('ccode');
54 $accept_conditions = getIntFromRequest ('accept_conditions');
56 if (forge_get_config('use_ssl') && !session_issecure()) {
57 //force use of SSL for login
58 header('Location: https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
61 if (!$theme_id || !is_numeric($theme_id)) {
62 $theme_id=$HTML->getThemeIdFromName(forge_get_config('default_theme'));
65 if (getStringFromRequest('submit')) {
67 Adding call to library rather than
68 logic that used to be coded in this page
70 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
71 exit_form_double_submit('my');
74 if (forge_get_config('user_registration_accept_conditions') && ! $accept_conditions) {
75 $warning_msg = _("You can't register an account unless you accept the terms of use.") ;
77 $activate_immediately = getIntFromRequest('activate_immediately');
78 if (($activate_immediately == 1) &&
79 forge_check_global_perm ('forge_admin')) {
81 $activate_immediately = true;
84 $activate_immediately = false;
87 $new_user = new GFUser();
88 $register = $new_user->create($unix_name,$firstname,$lastname,$password1,$password2,
89 $email,$mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,'',
90 $address,$address2,$phone,$fax,$title,$ccode,$send_mail);
92 site_header(array('title'=>'Register Confirmation'));
96 if ($activate_immediately) {
97 if (!$new_user->setStatus('A')) {
98 print '<span class="error">' .
99 _('Error during user activation but after user registration (user is now in pending state and will not get a notification eMail!)') .
101 print '<p>' . sprintf(_("Could not activate newly registered user's forge account: %s"), htmlspecialchars($new_user->getErrorMessage())) . '</p>';
102 $HTML->footer(array());
108 printf(_('You have registered the %1$s account on %2$s.'),
109 $new_user->getUnixName(),
110 forge_get_config ('forge_name'));
112 print '<p>' . _('A confirmation email is being sent to verify the submitted email address. Visiting the link sent in this email will activate the account.') . '</p>';
115 printf (_('You have registered and activated user %1$s on %2$s. They will not receive an eMail about this fact.'), $unix_name, forge_get_config('forge_name'));
118 site_footer(array());
121 $error_msg = $new_user->getErrorMessage();
122 if (isset($register_error)) {
123 $error_msg .= ' '.$register_error;
129 if (!isset($timezone) || empty($timezone) || !preg_match('/^[-a-zA-Z0-9_\/\.+]+$/', $timezone)) {
130 $timezone = forge_get_config('default_timezone') ? forge_get_config('default_timezone') : 'GMT' ;
132 if (!isset($ccode) || empty($ccode) || !preg_match('/^[a-zA-Z]{2}$/', $ccode)) {
133 $ccode = forge_get_config('default_country_code');
136 site_header(array('title'=>_('User Account Registration')));
139 <form action="<?php echo util_make_url('/account/register.php'); ?>" method="post">
140 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
143 if (forge_get_config('require_unique_email')) {
144 echo _('Login Name (no uppercase letters; leave empty to have it generated automatically):');
146 echo _('Login Name (do not use uppercase letters):'); echo utils_requiredField();
148 <input type="text" name="unix_name" value="<?php print(htmlspecialchars($unix_name)); ?>" />
151 <?php echo _('Password (min. 6 chars):'); echo utils_requiredField(); ?><br />
152 <input type="password" name="password1" />
155 <?php echo _('Password (repeat):'); echo utils_requiredField(); ?><br />
156 <input type="password" name="password2" />
159 <?php echo _('Title:'); ?><br />
160 <input type="text" name="title" value="<?php echo htmlspecialchars($title); ?>" size="10" />
163 <?php echo _('First Name:'); echo utils_requiredField(); ?><br />
164 <input size="30" type="text" name="firstname" value="<?php print(htmlspecialchars($firstname)); ?>" />
167 <?php echo _('Last Name:'); echo utils_requiredField(); ?><br />
168 <input size="30" type="text" name="lastname" value="<?php print(htmlspecialchars($lastname)); ?>" />
171 <?php echo _('Language Choice:'); ?><br />
172 <?php echo html_get_language_popup ('language_id', language_name_to_lang_id (choose_language_from_context ())); ?>
175 <?php echo _('Timezone:'); ?><br />
176 <?php echo html_get_timezone_popup('timezone', $timezone); ?>
179 <?php echo _('Theme'); ?><br />
180 <?php echo html_get_theme_popup('theme_id', $theme_id); ?>
183 <?php echo _('Country:'); ?><br />
184 <?php echo html_get_ccode_popup('ccode', $ccode); ?>
188 echo _('Email Address:') . utils_requiredField() . "<br />\n<em>";
189 printf(_('This email address will be verified before account activation. You will receive a mail forward account at <loginname@%1$s> that will forward to this address.'), forge_get_config('users_host')); ?></em>
190 <br /><input size="30" type="text" name="email" value="<?php print(htmlspecialchars($email)); ?>" />
194 if (forge_get_config('use_jabber')) {
195 echo _('Jabber Address:').'<br />
196 <input size="30" type="text" name="jabber_address" value="'.
197 htmlspecialchars($jabber_address) .'" /><br />
198 <input type="checkbox" name="jabber_only" value="1" />
199 '._('Send auto-generated notices only to my Jabber address').'.';
204 <?php echo _('Address:'); ?><br />
205 <input type="text" name="address" value="<?php echo htmlspecialchars($address); ?>" size="80" />
208 <?php echo _('Address:'); ?><br />
209 <input type="text" name="address2" value="<?php echo htmlspecialchars($address2); ?>" size="80" />
212 <?php echo _('Phone:'); ?><br />
213 <input type="text" name="phone" value="<?php echo htmlspecialchars($phone); ?>" size="20" />
216 <?php echo _('FAX:'); ?><br />
217 <input type="text" name="fax" value="<?php echo htmlspecialchars($fax); ?>" size="20" />
220 <input type="checkbox" name="mail_site" value="1" checked="checked" />
221 <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
224 <input type="checkbox" name="mail_va" value="1" />
225 <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
227 <?php if (forge_get_config('user_registration_accept_conditions')) { ?>
229 <input type="checkbox" name="accept_conditions" value="1" />
230 <?php printf (_('Do you accept the <a href="%1$s">terms of use</a> for this site?'),
231 util_make_url ('/terms.php')); ?>
234 <?php if (forge_check_global_perm('forge_admin')) { ?>
235 <p><input type="checkbox" name="activate_immediately" value="1" />
236 <?php print _('Activate this user immediately') ; ?>
240 <?php printf(_('Fields marked with %s are mandatory.'), utils_requiredField()); ?>
243 <input type="submit" name="submit" value="<?php echo _('Register'); ?>" />
246 <p><a href="pending-resend.php"><?php echo _('Resend confirmation email to a pending account'); ?></a></p>
248 <?php site_footer(array());
252 // c-file-style: "bsd"