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 = _('My Account');
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 options'));
125 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
128 <?php echo _('Account options:'); ?>
131 <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Profile').'</strong>'); ?></li>
132 <?php if(forge_get_config('use_people')) { ?>
133 <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></li>
137 <table class="infotable">
140 <td><?php echo _('Member since')._(':'); ?> </td>
141 <td><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></td>
144 <td><?php echo _('User Id')._(':'); ?> </td>
145 <td><?php print $u->getID(); ?></td>
149 <td><?php echo _('Login Name')._(':'); ?> </td>
150 <td><?php print $u->getUnixName(); ?>
151 <br /><a href="change_pw.php"><?php echo _('Change Password'); ?></a>
156 <td><?php echo _('First Name:').utils_requiredField(); ?></td>
158 <label for="firstname">
159 <input id="firstname" required="required" type="text" name="firstname" value="<?php print $u->getFirstName(); ?>"/>
165 <td><?php echo _('Last Name:').utils_requiredField(); ?></td>
167 <label for="lastname">
168 <input id="lastname" required="required" type="text" name="lastname" value="<?php print $u->getLastName(); ?>"/>
174 <td><?php echo _('Language')._(':'); ?> </td>
175 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
180 <td><?php echo _('Timezone:'); ?> </td>
181 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
186 <td><?php echo _('Theme')._(':'); ?> </td>
187 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
192 <td><?php echo _('Country:'); ?> </td>
193 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
198 <td><?php echo _('Email Address') . _(': '); ?> </td>
199 <td><?php print $u->getEmail(); ?>
200 <br /><a href="change_email.php">[<?php echo _('Change Email Address'); ?>]</a>
205 <td><?php echo _('Address') . _(':'); ?></td>
207 <label for="address">
208 <input id="address" type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
214 <td><?php echo _('Address (continued)') . _(':'); ?></td>
216 <label for="address2">
217 <input id="address2" type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
224 <td><?php echo _('Phone')._(':'); ?></td>
227 <input id="phone" type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
233 <td><?php echo _('Fax')._(':'); ?></td>
236 <input id="fax" type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
242 <td><?php echo _('Title')._(':'); ?></td>
245 <input id="title" type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
251 echo $HTML->boxBottom();
252 // ############################# Preferences
253 echo $HTML->boxTop(_('Preferences'));
257 <label for="mail_site">
258 <input id="mail_site" type="checkbox" name="mail_site" value="1"<?php
259 if ($u->getMailingsPrefs('site')) print ' checked="checked"'; ?> />
261 <?php echo _('Receive Email about Site Updates <em>(Very low traffic and includes security notices. Highly Recommended.)</em>'); ?>
265 <label for="mail_va">
266 <input id="mail_va" type="checkbox" name="mail_va" value="1"<?php
267 if ($u->getMailingsPrefs('va')) print ' checked="checked"'; ?> />
269 <?php echo _('Receive additional community mailings. <em>(Low traffic.)</em>'); ?>
273 <?php if (forge_get_config('use_ratings')) { ?>
274 <label for="use_ratings">
275 <input id="use_ratings" type="checkbox" name="use_ratings" value="1"<?php
276 if ($u->usesRatings()) print ' checked="checked"'; ?> />
278 <?php printf(_('Participate in peer ratings. <em>(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.)</em>'),util_make_url_u ($u->getUnixName(),$u->getId()));
282 <label for="use_tooltips">
283 <input id="use_tooltips" type="checkbox" name="use_tooltips" value="1"<?php
284 if ($u->usesTooltips()) print ' checked="checked"'; ?> />
286 <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.');
291 // displays a "Use xxxx Plugin" checkbox
292 plugin_hook("userisactivecheckbox", $hookParams);
294 echo $HTML->boxBottom();
296 // ############################### Shell Account
298 if (forge_get_config('use_shell')) {
299 echo $HTML->boxTop(_('Shell Account Information')."");
300 if ($u->getUnixStatus() == 'A') {
302 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
303 <br />'._('SSH Shared Authorized Keys').': <strong>';
305 $sshKeysArray = $u->getAuthorizedKeys();
306 if (is_array($sshKeysArray) && count($sshKeysArray)) {
307 $tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Uploaded'), _('Ready ?'));
308 $classth = array('', '', '', '', '');
309 echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
310 foreach($sshKeysArray as $sshKey) {
312 echo '<td>'.$sshKey['name'].'</td>';
313 echo '<td>'.$sshKey['algorithm'].'</td>';
314 echo '<td>'.$sshKey['fingerprint'].'</td>';
315 echo '<td>'.date(_('Y-m-d H:i'), $sshKey['upload']).'</td>';
316 if ($sshKey['deploy']) {
317 $image = html_image('docman/validate.png', 22, 22, array('alt'=>_('ssh key is deployed.'), 'class'=>'tabtitle', 'title'=>_('ssh key is deployed.')));
319 $image = html_image('waiting.png', 22, 22, array('alt'=>_('ssh key is not deployed yet.'), 'class'=>'tabtitle', 'title'=>_('ssh key is not deployed yet.')));
321 echo '<td>'.$image.'</td>';
324 echo $HTML->listTableBottom();
329 print '<br />' . util_make_link("account/editsshkeys.php",_('Edit Keys'));
331 echo '<div class="warning_msg">'._('Shell Account deactivated').'</div>';
333 echo $HTML->boxBottom();
341 <span><?php echo sprintf(_('%s Mandatory fields'), utils_requiredField())?></span>
343 <p class="align-center">
344 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
345 <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
350 site_user_footer(array());
354 // c-file-style: "bsd"