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-2014, 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';
35 session_require_login();
37 // get global users vars
38 $u = session_get_user();
39 if (!$u || !is_object($u)) {
40 exit_error(_('Could Not Get User'));
41 } elseif ($u->isError()) {
42 exit_error($u->getErrorMessage(),'my');
45 $action = getStringFromRequest('action');
49 include ($gfcommon."account/actions/$action.php");
54 if (getStringFromRequest('submit')) {
55 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
56 exit_form_double_submit('my');
59 $firstname = getStringFromRequest('firstname');
60 $lastname = getStringFromRequest('lastname');
61 $language = getIntFromRequest('language');
62 $timezone = getStringFromRequest('timezone');
63 $theme_id = getIntFromRequest('theme_id');
64 $ccode = getStringFromRequest('ccode');
65 $address = getStringFromRequest('address');
66 $address2 = getStringFromRequest('address2');
67 $phone = getStringFromRequest('phone');
68 $fax = getStringFromRequest('fax');
69 $title = getStringFromRequest('title');
70 $mail_site = getStringFromRequest('mail_site');
71 $mail_va = getStringFromRequest('mail_va');
72 $remember_user = getStringFromRequest('remember_user');
73 $use_ratings = getStringFromRequest('use_ratings');
74 $use_tooltips = getIntFromRequest('use_tooltips');
77 if (!strlen(trim($firstname))) {
78 $error_msg = _('You must supply a first name');
80 } elseif (!strlen(trim($lastname))) {
81 $error_msg = _('You must supply a last name');
86 // Refresh page if language or theme changed
87 $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
89 if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
90 '',0,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
91 form_release_key(getStringFromRequest('form_key'));
92 $error_msg = $u->getErrorMessage();
94 $feedback = _('Updated');
98 session_redirect('/account/');
103 $hookParams['user'] = user_get_object(user_getid());
104 if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
105 plugin_hook("userisactivecheckboxpost", $hookParams);
108 use_javascript('/js/sortable.js');
109 $title = _('My Account');
110 site_user_header(array('title'=>$title));
112 echo $HTML->openForm(array('action' => util_make_uri('/account/'), 'method' => 'post'));
113 echo html_e('input', array('type' => 'hidden', 'name' => 'form_key', 'value' => form_generate_key()));
114 echo $HTML->boxTop(_('Account options'));
115 echo html_e('p', array(), _('Welcome').html_e('strong', array(), $u->getRealName()));
116 echo html_e('p', array(), _('Account options')._(':'));
118 echo html_e('li', array(), util_make_link_u($u->getUnixName(),$u->getID(),html_e('strong', array(), _('View My Profile'))));
119 if(forge_get_config('use_people')) {
120 echo html_e('li', array(), util_make_link('/people/editprofile.php', html_e('strong', array(), _('Edit My Skills Profile'))));
122 echo html_ac(html_ap() - 1);
123 echo $HTML->listTableTop(array(), array(), 'infotable');
127 <td><?php echo _('Member since')._(':'); ?></td>
128 <td><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></td>
131 <td><?php echo _('User Id')._(':'); ?></td>
132 <td><?php print $u->getID(); ?></td>
136 <td><?php echo _('Login Name')._(':'); ?></td>
137 <td><?php print $u->getUnixName(); ?>
138 <br /><a href="change_pw.php"><?php echo _('Change Password'); ?></a>
143 <td><?php echo _('First Name').utils_requiredField()._(':'); ?></td>
145 <label for="firstname">
146 <input id="firstname" required="required" type="text" name="firstname" value="<?php print $u->getFirstName(); ?>"/>
152 <td><?php echo _('Last Name').utils_requiredField()._(':'); ?></td>
154 <label for="lastname">
155 <input id="lastname" required="required" type="text" name="lastname" value="<?php print $u->getLastName(); ?>"/>
161 <td><?php echo _('Language')._(':'); ?></td>
162 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
167 <td><?php echo _('Timezone:'); ?></td>
168 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
173 <td><?php echo _('Theme')._(':'); ?></td>
174 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
179 <td><?php echo _('Country:'); ?></td>
180 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
185 <td><?php echo _('Email Address')._(': '); ?></td>
186 <td><?php print $u->getEmail(); ?>
187 <br /><a href="change_email.php">[<?php echo _('Change Email Address'); ?>]</a>
192 <td><?php echo _('Address')._(':'); ?></td>
194 <label for="address">
195 <input id="address" type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
201 <td><?php echo _('Address (continued)')._(':'); ?></td>
203 <label for="address2">
204 <input id="address2" type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
210 <td><?php echo _('Phone')._(':'); ?></td>
213 <input id="phone" type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
219 <td><?php echo _('Fax')._(':'); ?></td>
222 <input id="fax" type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
228 <td><?php echo _('Title')._(':'); ?></td>
231 <input id="title" type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
236 echo $HTML->listTableBottom();
237 echo $HTML->boxBottom();
238 // ############################# Preferences
239 echo $HTML->boxTop(_('Preferences'));
243 <input id="mail_site" type="checkbox" name="mail_site" value="1"<?php
244 if ($u->getMailingsPrefs('site')) print ' checked="checked"'; ?> />
245 <label for="mail_site">
246 <?php echo _('Receive Email about Site Updates <em>(Very low traffic and includes security notices. Highly Recommended.)</em>'); ?>
251 <input id="mail_va" type="checkbox" name="mail_va" value="1"<?php
252 if ($u->getMailingsPrefs('va')) print ' checked="checked"'; ?> />
253 <label for="mail_va">
254 <?php echo _('Receive additional community mailings. <em>(Low traffic.)</em>'); ?>
259 <?php if (forge_get_config('use_ratings')) { ?>
260 <input id="use_ratings" type="checkbox" name="use_ratings" value="1"<?php
261 if ($u->usesRatings()) print ' checked="checked"'; ?> />
262 <label for="use_ratings">
263 <?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())); ?>
269 <input id="use_tooltips" type="checkbox" name="use_tooltips" value="1"<?php
270 if ($u->usesTooltips()) print ' checked="checked"'; ?> />
271 <label for="use_tooltips">
272 <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.'); ?>
277 // displays a "Use xxxx Plugin" checkbox
278 plugin_hook("userisactivecheckbox", $hookParams);
280 echo $HTML->boxBottom();
282 // ############################### Shell Account
284 if (forge_get_config('use_shell')) {
285 echo $HTML->boxTop(_('Shell Account Information')."");
286 if ($u->getUnixStatus() == 'A') {
288 <br />'._('Shell box')._(': ').'<strong>'.forge_get_config('shell_host').'</strong>
289 <br />'._('SSH Shared Authorized Keys')._(': ').'<strong>';
290 $sshKeysArray = $u->getAuthorizedKeys();
291 if (is_array($sshKeysArray) && count($sshKeysArray)) {
292 $tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Uploaded'));
293 $classth = array('', '', '', '');
294 echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
295 foreach($sshKeysArray as $sshKey) {
297 $cells[][] = $sshKey['name'];
298 $cells[][] = $sshKey['algorithm'];
299 $cells[][] = $sshKey['fingerprint'];
300 $cells[][] = date(_('Y-m-d H:i'), $sshKey['upload']);
301 echo $HTML->multiTableRow(array(), $cells);
303 echo $HTML->listTableBottom();
308 print '<br />' . util_make_link('/account/editsshkeys.php', _('Edit Keys'));
310 echo $HTML->warning_msg(_('Shell Account deactivated'));
312 echo $HTML->boxBottom();
314 echo $HTML->addRequiredFieldsInfoBox();
315 echo html_e('p', array('class' => 'align-center'),
316 html_e('input', array('type' => 'submit', 'name' => 'submit', 'value' => _('Update'))).
317 html_e('input', array('type' => 'reset', 'name' => 'reset', 'value' => _('Reset Changes'))));
318 echo $HTML->closeForm();
323 // c-file-style: "bsd"