3 * Change user's email page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once '../env.inc.php';
25 require_once $gfcommon.'include/pre.php';
27 session_require_login () ;
29 if (getStringFromRequest('submit')) {
30 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
31 exit_form_double_submit('my');
34 $newemail = getStringFromRequest('newemail');
36 if (!validate_email($newemail)) {
37 form_release_key(getStringFromRequest('form_key'));
38 exit_error(_('Invalid email address.'),'my');
41 $confirm_hash = substr(md5($GLOBALS['session_ser'] . time()),0,16);
43 $u =& user_get_object(user_getid());
44 if (!$u || !is_object($u)) {
45 form_release_key(getStringFromRequest('form_key'));
46 exit_error(_('Could Not Get User'),'my');
47 } elseif ($u->isError()) {
48 form_release_key(getStringFromRequest('form_key'));
49 exit_error($u->getErrorMessage(),'my');
52 if (!$u->setNewEmailAndHash($newemail, $confirm_hash)) {
53 form_release_key(getStringFromRequest('form_key'));
54 exit_error($u->getErrorMessage(),'my');
57 $message = sprintf(_('You have requested a change of email address on %1$s.
58 Please visit the following URL to complete the email change:
63 forge_get_config ('forge_name'),
64 util_make_url ('/account/change_email-complete.php?ch=_'.$confirm_hash));
66 util_send_message($newemail,sprintf(_('%1$s Verification'), forge_get_config ('forge_name')),$message);
68 site_user_header(array('title'=>_('Email Change Confirmation')));
70 print '<p>' . _('An email has been sent to the new address. Follow the instructions in the email to complete the email change.') . '</p>';
71 printf ('<a href="%1$s">[ Home ]</a>', util_make_url ('/'));
73 site_user_footer(array());
78 site_user_header(array('title'=>_('Email change')));
80 echo '<p>' . _('Changing your email address will require confirmation from your new email address, so that we can ensure we have a good email address on file.') . '</p>';
81 echo '<p>' . _('We need to maintain an accurate email address for each user due to the level of access we grant via this account. If we need to reach a user for issues arriving from a shell or project account, it is important that we be able to do so.') . '</p>';
82 echo '<p>' . _('Submitting the form below will mail a confirmation URL to the new email address. Visiting this link will complete the email change.') . '</p>';
85 <form action="<?php echo util_make_url('/account/change_email.php'); ?>" method="post">
87 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
88 <?php echo _('New Email Address:') ?>
89 <input type="text" name="newemail" maxlength="255" />
90 <input type="submit" name="submit" value="<?php echo _('Send Confirmation to New Address') ?>" />
94 <p><?php echo util_make_link('/', _('Return')); ?></p>
97 site_user_footer(array());
101 // c-file-style: "bsd"