3 * User account main page - show settings with means to change them
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010-2011, Franck Villaume - Capgemini
7 * Copyright 2011, Alain Peyrat - Alcatel-Lucent
8 * Copyright 2012-2013, Franck Villaume - TrivialDev
9 * Copyright 2013, French Ministry of National Education
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once '../env.inc.php';
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfcommon.'include/timezones.php';
31 session_require_login();
33 // get global users vars
34 $u = session_get_user();
35 if (!$u || !is_object($u)) {
36 exit_error(_('Could Not Get User'));
37 } elseif ($u->isError()) {
38 exit_error($u->getErrorMessage(),'my');
41 $action = getStringFromRequest('action');
45 include ($gfcommon."account/actions/$action.php");
50 if (getStringFromRequest('submit')) {
51 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
52 exit_form_double_submit('my');
55 $firstname = getStringFromRequest('firstname');
56 $lastname = getStringFromRequest('lastname');
57 $language = getIntFromRequest('language');
58 $timezone = getStringFromRequest('timezone');
59 $theme_id = getIntFromRequest('theme_id');
60 $ccode = getStringFromRequest('ccode');
61 $address = getStringFromRequest('address');
62 $address2 = getStringFromRequest('address2');
63 $phone = getStringFromRequest('phone');
64 $fax = getStringFromRequest('fax');
65 $title = getStringFromRequest('title');
66 $mail_site = getStringFromRequest('mail_site');
67 $mail_va = getStringFromRequest('mail_va');
68 $remember_user = getStringFromRequest('remember_user');
69 $use_ratings = getStringFromRequest('use_ratings');
70 $use_tooltips = getIntFromRequest('use_tooltips');
73 if (!strlen(trim($firstname))) {
74 $error_msg = _('You must supply a first name.');
76 } elseif (!strlen(trim($lastname))) {
77 $error_msg = _('You must supply a last name.');
83 //needs security audit
85 // set cookie, expire in 3 months
86 setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
89 setcookie("sf_user_hash",'',0,'/');
92 // Refresh page if language or theme changed
93 $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
95 if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
96 '',0,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
97 form_release_key(getStringFromRequest('form_key'));
98 $error_msg = $u->getErrorMessage();
99 $refresh_url = '/account/?error_msg='.urlencode($error_msg);
101 $feedback = _('Updated');
102 $refresh_url = '/account/?feedback='.urlencode($feedback);
106 session_redirect($refresh_url);
111 $hookParams['user'] = user_get_object(user_getid());
112 if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
113 plugin_hook("userisactivecheckboxpost", $hookParams);
116 use_javascript('/js/sortable.js');
117 $title = _('Account Maintenance');
118 site_user_header(array('title'=>$title));
120 echo '<form action="'.util_make_url('/account/').'" method="post">';
121 echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
122 echo $HTML->boxTop(_('Account Maintenance'));
126 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
129 <?php echo _('Account options:'); ?>
132 <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Profile').'</strong>'); ?></li>
133 <?php if(forge_get_config('use_people')) { ?>
134 <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></li>
138 <table class="infotable">
141 <td><?php echo _('Member since')._(':'); ?> </td>
142 <td><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></td>
145 <td><?php echo _('User Id')._(':'); ?> </td>
146 <td><?php print $u->getID(); ?></td>
150 <td><?php echo _('Login Name')._(':'); ?> </td>
151 <td><?php print $u->getUnixName(); ?>
152 <br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a>
157 <td><?php echo _('First Name:').utils_requiredField(); ?></td>
159 <input required="required" type="text" name="firstname" value="<?php print $u->getFirstName(); ?>" />
164 <td><?php echo _('Last Name:').utils_requiredField(); ?></td>
166 <input required="required" type="text" name="lastname" value="<?php print $u->getLastName(); ?>" />
171 <td><?php echo _('Language')._(':'); ?> </td>
172 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
177 <td><?php echo _('Timezone:'); ?> </td>
178 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
183 <td><?php echo _('Theme')._(':'); ?> </td>
184 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
189 <td><?php echo _('Country:'); ?> </td>
190 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
195 <td><?php echo _('Email Address') . _(': '); ?> </td>
196 <td><?php print $u->getEmail(); ?>
197 <br /><a href="change_email.php">[<?php echo _('Change Email Address'); ?>]</a>
202 <td><?php echo _('Address') . _(':'); ?></td>
204 <input type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
209 <td><?php echo _('Address (continued)') . _(':'); ?></td>
211 <input type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
216 <td><?php echo _('Phone')._(':'); ?></td>
218 <input type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
223 <td><?php echo _('Fax')._(':'); ?></td>
225 <input type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
230 <td><?php echo _('Title')._(':'); ?></td>
232 <input type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
237 echo $HTML->boxBottom();
238 // ############################# Preferences
239 echo $HTML->boxTop(_('Preferences')); ?>
242 <input type="checkbox" name="mail_site" value="1"<?php
243 if ($u->getMailingsPrefs('site')) print ' checked="checked"'; ?> />
244 <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
248 <input type="checkbox" name="mail_va" value="1"<?php
249 if ($u->getMailingsPrefs('va')) print ' checked="checked"'; ?> />
250 <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
255 <input type="checkbox" name="remember_user" value="1"<?php
256 if ($sf_user_hash) print ' checked="checked"'; ?> />
257 <?php printf(_('"Remember me". <i>(Allows to access your <a href="%s">personal page</a> without being logged in. You will still need to login explicitly before making any changes.)</i>'),util_make_url ('/my/'));
261 <?php if (forge_get_config('use_ratings')) { ?>
263 <input type="checkbox" name="use_ratings" value="1"<?php
264 if ($u->usesRatings()) print ' checked="checked"'; ?> />
265 <?php printf(_('Participate in peer ratings. <i>(Allows you to rate other users using several criteria as well as to be rated by others. More information is available on your <a href="%s">user page</a> if you have chosen to participate in ratings.)</i>'),util_make_url_u ($u->getUnixName(),$u->getId()));
269 <input type="checkbox" name="use_tooltips" value="1"<?php
270 if ($u->usesTooltips()) print ' checked="checked"'; ?> />
271 <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.');
275 // displays a "Use xxxx Plugin" checkbox
276 plugin_hook("userisactivecheckbox", $hookParams);
279 echo $HTML->boxBottom();
281 // ############################### Shell Account
283 if (forge_get_config('use_shell')) {
284 echo $HTML->boxTop(_('Shell Account Information')."");
285 if ($u->getUnixStatus() == 'A') {
287 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
288 <br />'._('SSH Shared Authorized Keys').': <strong>';
290 $sshKeysArray = $u->getAuthorizedKeys();
291 if (is_array($sshKeysArray) && count($sshKeysArray)) {
292 $tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Uploaded'), _('Ready ?'));
293 $classth = array('', '', '', '', '');
294 echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
295 foreach($sshKeysArray as $sshKey) {
297 echo '<td>'.$sshKey['name'].'</td>';
298 echo '<td>'.$sshKey['algorithm'].'</td>';
299 echo '<td>'.$sshKey['fingerprint'].'</td>';
300 echo '<td>'.date(_('Y-m-d H:i'), $sshKey['upload']).'</td>';
301 if ($sshKey['deploy']) {
302 $image = html_image('docman/validate.png', 22, 22, array('alt'=>_('ssh key is deployed.'), 'class'=>'tabtitle', 'title'=>_('ssh key is deployed.')));
304 $image = html_image('waiting.png', 22, 22, array('alt'=>_('ssh key is not deployed yet.'), 'class'=>'tabtitle', 'title'=>_('ssh key is not deployed yet.')));
306 echo '<td>'.$image.'</td>';
309 echo $HTML->listTableBottom();
314 print '<br />' . util_make_link("account/editsshkeys.php",_('Edit Keys'));
316 echo '<div class="warning_msg">'._('Shell Account deactivated').'</div>';
318 echo $HTML->boxBottom();
326 <span><?php echo sprintf(_('%s Mandatory fields'), utils_requiredField())?></span>
328 <p class="align-center">
329 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
330 <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
335 site_user_footer(array());
339 // c-file-style: "bsd"