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, Franck Villaume - TrivialDev
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'include/timezones.php';
30 session_require_login();
32 // get global users vars
33 $u = session_get_user();
34 if (!$u || !is_object($u)) {
35 exit_error(_('Could Not Get User'));
36 } elseif ($u->isError()) {
37 exit_error($u->getErrorMessage(),'my');
40 $action = getStringFromRequest('action');
44 include ($gfcommon."account/actions/$action.php");
49 if (getStringFromRequest('submit')) {
50 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
51 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 $jabber_address = getStringFromRequest('jabber_address');
67 $jabber_only = getStringFromRequest('jabber_only');
68 $mail_site = getStringFromRequest('mail_site');
69 $mail_va = getStringFromRequest('mail_va');
70 $remember_user = getStringFromRequest('remember_user');
71 $use_ratings = getStringFromRequest('use_ratings');
72 $use_tooltips = getIntFromRequest('use_tooltips');
75 //needs security audit
77 // set cookie, expire in 3 months
78 setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
81 setcookie("sf_user_hash",'',0,'/');
84 // Refresh page if language or theme changed
85 $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
87 if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
88 $jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
89 form_release_key(getStringFromRequest('form_key'));
90 $error_msg = $u->getErrorMessage();
91 $refresh_url = '/account/?error_msg='.urlencode($error_msg);
93 $feedback = _('Updated');
94 $refresh_url = '/account/?feedback='.urlencode($feedback);
98 session_redirect($refresh_url);
102 $hookParams['user'] = user_get_object(user_getid());
103 if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
104 plugin_hook("userisactivecheckboxpost", $hookParams);
107 use_javascript('/js/sortable.js');
108 $title = _('Account Maintenance');
109 site_user_header(array('title'=>$title));
111 echo '<form action="'.util_make_url('/account/').'" method="post">';
112 echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
113 echo $HTML->boxTop(_('Account Maintenance'));
117 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
120 <?php echo _('Account options:'); ?>
123 <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Profile').'</strong>'); ?></li>
124 <?php if(forge_get_config('use_people')) { ?>
125 <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></li>
128 <?php echo $HTML->boxBottom(); ?>
131 <table width="100%" border="0">
134 <td><?php echo _('Member since:'); ?> </td>
135 <td><strong><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></strong></td>
138 <td><?php echo _('User Id:'); ?> </td>
139 <td><strong><?php print $u->getID(); ?></strong></td>
143 <td><?php echo _('Login name:'); ?> </td>
144 <td><strong><?php print $u->getUnixName(); ?></strong>
145 <br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a>
150 <td><?php echo _('First Name:'); ?></td>
152 <input type="text" name="firstname" value="<?php print $u->getFirstName(); ?>" />
157 <td><?php echo _('Last Name:'); ?></td>
159 <input type="text" name="lastname" value="<?php print $u->getLastName(); ?>" />
164 <td><?php echo _('Language:'); ?> </td>
165 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
170 <td><?php echo _('Timezone:'); ?> </td>
171 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
176 <td><?php echo _('Theme:'); ?> </td>
177 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
182 <td><?php echo _('Country:'); ?> </td>
183 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
188 <td><?php echo _('Email Addr:'); ?> </td>
189 <td><strong><?php print $u->getEmail(); ?></strong>
190 <br /><a href="change_email.php">[<?php echo _('Change Email Addr'); ?>]</a>
195 <td><?php echo _('Address:'); ?></td>
197 <input type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
202 <td><?php echo _('Address:'); ?></td>
204 <input type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
209 <td><?php echo _('Phone:'); ?></td>
211 <input type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
216 <td><?php echo _('FAX:'); ?></td>
218 <input type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
223 <td><?php echo _('Title:'); ?></td>
225 <input type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
230 if (forge_get_config('use_jabber')) {
231 echo '<tr valign="top">
232 <td>'. _('Jabber Address:') .'</td>
234 <input size="30" type="text" name="jabber_address" value="'. $u->getJabberAddress() .'" /><p />
235 <input type="checkbox" name="jabber_only" value="1" '.(($u->getJabberOnly()) ? 'checked="CHECKED"' : '' ).' />
236 '._('Send auto-generated notices only to my Jabber address').'.
246 // ############################# Preferences
247 echo $HTML->boxTop(_('Preferences')); ?>
250 <input type="checkbox" name="mail_site" value="1"<?php
251 if ($u->getMailingsPrefs('site')) print " checked=\"checked\""; ?> />
252 <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
256 <input type="checkbox" name="mail_va" value="1"<?php
257 if ($u->getMailingsPrefs('va')) print " checked=\"checked\""; ?> />
258 <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
263 <input type="checkbox" name="remember_user" value="1"<?php
264 if ($sf_user_hash) print " checked=\"checked\""; ?> />
265 <?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/'));
269 <?php if (forge_get_config('use_ratings')) { ?>
271 <input type="checkbox" name="use_ratings" value="1"<?php
272 if ($u->usesRatings()) print ' checked="checked"'; ?> />
273 <?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()));
277 <input type="checkbox" name="use_tooltips" value="1"<?php
278 if ($u->usesTooltips()) print ' checked="checked"'; ?> />
279 <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.');
285 // displays a "Use xxxx Plugin" checkbox
286 plugin_hook("userisactivecheckbox", $hookParams);
291 echo $HTML->boxBottom();
293 // ############################### Shell Account
295 if (forge_get_config('use_shell')) {
296 echo $HTML->boxTop(_('Shell Account Information')."");
297 if ($u->getUnixStatus() == 'A') {
299 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
300 <br />'._('SSH Shared Authorized Keys').': <strong>';
302 $sshKeysArray = $u->getAuthorizedKeys();
303 if (is_array($sshKeysArray) && count($sshKeysArray)) {
304 $tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Uploaded'), _('Ready ?'));
305 $classth = array('', '', '', '', '');
306 echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
307 foreach($sshKeysArray as $sshKey) {
309 echo '<td>'.$sshKey['name'].'</td>';
310 echo '<td>'.$sshKey['algorithm'].'</td>';
311 echo '<td>'.$sshKey['fingerprint'].'</td>';
312 echo '<td>'.date(_('Y-m-d H:i'), $sshKey['upload']).'</td>';
313 if ($sshKey['deploy']) {
314 $image = html_image('docman/validate.png', 22, 22, array('alt'=>_('ssh key is deployed.'), 'class'=>'tabtitle', 'title'=>_('ssh key is deployed.')));
316 $image = html_image('waiting.png', 22, 22, array('alt'=>_('ssh key is not deployed yet.'), 'class'=>'tabtitle', 'title'=>_('ssh key is not deployed yet.')));
318 echo '<td>'.$image.'</td>';
321 echo $HTML->listTableBottom();
326 print '<br />' . util_make_link("account/editsshkeys.php",_('Edit Keys'));
328 echo '<div class="warning_msg">'._('Shell Account deactivated').'</div>';
330 echo $HTML->boxBottom();
339 <p style="text-align: center;">
340 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
341 <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
346 site_user_footer(array());
350 // c-file-style: "bsd"