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
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once('../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfcommon.'include/timezones.php';
29 session_require_login();
31 // get global users vars
32 $u = session_get_user();
33 if (!$u || !is_object($u)) {
34 exit_error(_('Could Not Get User'));
35 } elseif ($u->isError()) {
36 exit_error($u->getErrorMessage(),'my');
39 if (getStringFromRequest('submit')) {
40 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
41 exit_form_double_submit('my');
44 $firstname = getStringFromRequest('firstname');
45 $lastname = getStringFromRequest('lastname');
46 $language = getIntFromRequest('language');
47 $timezone = getStringFromRequest('timezone');
48 $theme_id = getIntFromRequest('theme_id');
49 $ccode = getStringFromRequest('ccode');
50 $address = getStringFromRequest('address');
51 $address2 = getStringFromRequest('address2');
52 $phone = getStringFromRequest('phone');
53 $fax = getStringFromRequest('fax');
54 $title = getStringFromRequest('title');
55 $jabber_address = getStringFromRequest('jabber');
56 $jabber_only = getStringFromRequest('jabber');
57 $mail_site = getStringFromRequest('mail_site');
58 $mail_va = getStringFromRequest('mail_va');
59 $remember_user = getStringFromRequest('remember_user');
60 $use_ratings = getStringFromRequest('use_ratings');
61 $use_tooltips = (getStringFromRequest('use_tooltips')) ? getStringFromRequest('use_tooltips') : 0;
64 //needs security audit
66 // set cookie, expire in 3 months
67 setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
70 setcookie("sf_user_hash",'',0,'/');
73 // Refresh page if language or theme changed
74 $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
76 if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
77 $jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
78 form_release_key(getStringFromRequest('form_key'));
79 $error_msg = $u->getErrorMessage();
80 $refresh_url = '/account/?error_msg='.urlencode($error_msg);
82 $feedback = _('Updated');
83 $refresh_url = '/account/?feedback='.urlencode($feedback);
87 session_redirect($refresh_url);
91 $hookParams['user'] = user_get_object(user_getid());
92 if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
93 plugin_hook("userisactivecheckboxpost", $hookParams);
96 $title = _('Account Maintenance');
97 site_user_header(array('title'=>$title));
99 echo '<form action="'.util_make_url('/account/').'" method="post">';
100 echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
101 echo $HTML->boxTop(_('Account Maintenance'));
105 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
108 <?php echo _('Account options:'); ?>
111 <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Profile').'</strong>'); ?></li>
112 <?php if(forge_get_config('use_people')) { ?>
113 <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></li>
116 <?php echo $HTML->boxBottom(); ?>
119 <table width="100%" border="0">
122 <td><?php echo _('Member since:'); ?> </td>
123 <td><strong><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></strong></td>
126 <td><?php echo _('User Id:'); ?> </td>
127 <td><strong><?php print $u->getID(); ?></strong></td>
131 <td><?php echo _('Login name:'); ?> </td>
132 <td><strong><?php print $u->getUnixName(); ?></strong>
133 <br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a>
138 <td><?php echo _('First Name:'); ?></td>
140 <input type="text" name="firstname" value="<?php print $u->getFirstName(); ?>" />
145 <td><?php echo _('Last Name:'); ?></td>
147 <input type="text" name="lastname" value="<?php print $u->getLastName(); ?>" />
152 <td><?php echo _('Language:'); ?> </td>
153 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
158 <td><?php echo _('Timezone:'); ?> </td>
159 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
164 <td><?php echo _('Theme:'); ?> </td>
165 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
170 <td><?php echo _('Country:'); ?> </td>
171 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
176 <td><?php echo _('Email Addr:'); ?> </td>
177 <td><strong><?php print $u->getEmail(); ?></strong>
178 <br /><a href="change_email.php">[<?php echo _('Change Email Addr'); ?>]</a>
183 <td><?php echo _('Address:'); ?></td>
185 <input type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
190 <td><?php echo _('Address:'); ?></td>
192 <input type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
197 <td><?php echo _('Phone:'); ?></td>
199 <input type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
204 <td><?php echo _('FAX:'); ?></td>
206 <input type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
211 <td><?php echo _('Title:'); ?></td>
213 <input type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
218 if (forge_get_config('use_jabber')) {
219 echo '<tr valign="top">
220 <td>'. _('Jabber Address:') .'</td>
222 <input size=30 type="text" name="jabber_address" value="'. $u->getJabberAddress() .'" /><p />
223 <input type="checkbox" name="jabber_only" value="1" '.(($u->getJabberOnly()) ? 'checked="CHECKED"' : '' ).' />
224 '._('Send auto-generated notices only to my Jabber address').'.
234 // ############################# Preferences
235 echo $HTML->boxTop(_('Preferences')); ?>
237 <input type="checkbox" name="mail_site" value="1"<?php
238 if ($u->getMailingsPrefs('site')) print " checked=\"checked\""; ?> />
239 <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
241 <p /><input type="checkbox" name="mail_va" value="1"<?php
242 if ($u->getMailingsPrefs('va')) print " checked=\"checked\""; ?> />
243 <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
245 <p /><input type="checkbox" name="remember_user" value="1"<?php
246 if ($sf_user_hash) print " checked=\"checked\""; ?> />
247 <?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/'));
251 <?php if (forge_get_config('use_ratings')) { ?>
252 <input type="checkbox" name="use_ratings" value="1"<?php
253 if ($u->usesRatings()) print ' checked="checked"'; ?> />
254 <?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()));
257 <input type="checkbox" name="use_tooltips" value="1"<?php
258 if ($u->usesTooltips()) print ' checked="checked"'; ?> />
259 <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.');
263 // displays a "Use xxxx Plugin" checkbox
264 plugin_hook("userisactivecheckbox", $hookParams);
268 <?php echo $HTML->boxBottom();
270 // ############################### Shell Account
272 if (($u->getUnixStatus() == 'A') && (forge_get_config('use_shell'))) {
273 echo $HTML->boxTop(_('Shell Account Information')."");
275 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
276 <br />'._('SSH Shared Authorized Keys').': <strong>';
277 // get shared key count from db
278 $expl_keys = explode("\n", $u->getAuthorizedKeys());
280 print (sizeof($expl_keys));
285 print '<br />' . util_make_link ("account/editsshkeys.php",_('Edit Keys')) ;
286 echo $HTML->boxBottom();
295 <p style="text-align: center;">
296 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
297 <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
302 site_user_footer(array());
306 // c-file-style: "bsd"