3 * User account main page - show settings with means to change them
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume
7 * Copyright (C) 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 $feedback = htmlspecialchars(getStringFromRequest('feedback'));
30 $error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
32 session_require_login () ;
34 // get global users vars
35 $u =& user_get_object(user_getid());
36 if (!$u || !is_object($u)) {
37 exit_error(_('Could Not Get User'));
38 } elseif ($u->isError()) {
39 exit_error($u->getErrorMessage(),'my');
42 if (getStringFromRequest('submit')) {
43 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
44 exit_form_double_submit('my');
48 $firstname = getStringFromRequest('firstname');
49 $lastname = getStringFromRequest('lastname');
50 $language = getIntFromRequest('language');
51 $timezone = getStringFromRequest('timezone');
52 $theme_id = getIntFromRequest('theme_id');
53 $ccode = getStringFromRequest('ccode');
54 $address = getStringFromRequest('address');
55 $address2 = getStringFromRequest('address2');
56 $phone = getStringFromRequest('phone');
57 $fax = getStringFromRequest('fax');
58 $title = getStringFromRequest('title');
59 $jabber_address = getStringFromRequest('jabber');
60 $jabber_only = getStringFromRequest('jabber');
61 $mail_site = getStringFromRequest('mail_site');
62 $mail_va = getStringFromRequest('mail_va');
63 $remember_user = getStringFromRequest('remember_user');
64 $use_ratings = getStringFromRequest('use_ratings');
67 //needs security audit
69 // set cookie, expire in 3 months
70 setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
73 setcookie("sf_user_hash",'',0,'/');
76 // Refresh page if language or theme changed
77 $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
79 if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
80 $jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)) {
81 form_release_key(getStringFromRequest('form_key'));
82 $error_msg = $u->getErrorMessage();
83 $refresh_url = '/account/?error_msg='.urlencode($error_msg);
85 $feedback = _('Updated');
86 $refresh_url = '/account/?feedback='.urlencode($feedback);
90 session_redirect($refresh_url);
94 $title = _('Account Maintenance');
95 site_user_header(array('title'=>$title));
97 echo '<form action="'.util_make_url('/account/').'" method="post">';
98 echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
99 echo $HTML->boxTop(_('Account Maintenance'));
103 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
106 <?php echo _('Account options:'); ?>
109 <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Profile').'</strong>'); ?></li>
110 <?php if(forge_get_config('use_people')) { ?>
111 <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></li>
114 <?php echo $HTML->boxBottom(); ?>
117 <table width="100%" border="0">
120 <td><?php echo _('Member since:'); ?> </td>
121 <td><strong><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></strong></td>
124 <td><?php echo _('User Id:'); ?> </td>
125 <td><strong><?php print $u->getID(); ?></strong></td>
129 <td><?php echo _('Login name:'); ?> </td>
130 <td><strong><?php print $u->getUnixName(); ?></strong>
131 <br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a>
136 <td><?php echo _('First Name:'); ?></td>
138 <input type="text" name="firstname" value="<?php print $u->getFirstName(); ?>" />
143 <td><?php echo _('Last Name:'); ?></td>
145 <input type="text" name="lastname" value="<?php print $u->getLastName(); ?>" />
150 <td><?php echo _('Language:'); ?> </td>
151 <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
156 <td><?php echo _('Timezone:'); ?> </td>
157 <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
162 <td><?php echo _('Theme:'); ?> </td>
163 <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
168 <td><?php echo _('Country:'); ?> </td>
169 <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
174 <td><?php echo _('Email Addr:'); ?> </td>
175 <td><strong><?php print $u->getEmail(); ?></strong>
176 <br /><a href="change_email.php">[<?php echo _('Change Email Addr'); ?>]</a>
181 <td><?php echo _('Address:'); ?></td>
183 <input type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/>
188 <td><?php echo _('Address:'); ?></td>
190 <input type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/>
195 <td><?php echo _('Phone:'); ?></td>
197 <input type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/>
202 <td><?php echo _('FAX:'); ?></td>
204 <input type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/>
209 <td><?php echo _('Title:'); ?></td>
211 <input type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/>
216 if (forge_get_config('use_jabber')) {
217 echo '<tr valign="top">
218 <td>'. _('Jabber Address:') .'</td>
220 <input size=30 type="text" name="jabber_address" value="'. $u->getJabberAddress() .'" /><p />
221 <input type="checkbox" name="jabber_only" value="1" '.(($u->getJabberOnly()) ? 'checked="CHECKED"' : '' ).' />
222 '._('Send auto-generated notices only to my Jabber address').'.
232 // ############################# Preferences
233 echo $HTML->boxTop(_('Preferences')); ?>
235 <input type="checkbox" name="mail_site" value="1"<?php
236 if ($u->getMailingsPrefs('site')) print " checked=\"checked\""; ?> />
237 <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
239 <p /><input type="checkbox" name="mail_va" value="1"<?php
240 if ($u->getMailingsPrefs('va')) print " checked=\"checked\""; ?> />
241 <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
243 <p /><input type="checkbox" name="remember_user" value="1"<?php
244 if ($sf_user_hash) print " checked=\"checked\""; ?> />
245 <?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/'));
249 <?php if (forge_get_config('use_ratings')) { ?>
250 <input type="checkbox" name="use_ratings" value="1"<?php
251 if ($u->usesRatings()) print ' checked="checked"'; ?> />
252 <?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()));
256 $hookParams['user']= user_get_object(user_getid());
257 if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
258 plugin_hook("userisactivecheckboxpost", $hookParams);
260 plugin_hook("userisactivecheckbox", $hookParams);
265 <?php echo $HTML->boxBottom();
267 // ############################### Shell Account
269 if (($u->getUnixStatus() == 'A') && (forge_get_config('use_shell'))) {
270 echo $HTML->boxTop(_('Shell Account Information')."");
272 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
273 <br />'._('SSH Shared Authorized Keys').': <strong>';
274 // get shared key count from db
275 $expl_keys = explode("\n", $u->getAuthorizedKeys());
277 print (sizeof($expl_keys));
282 print '<br />' . util_make_link ("account/editsshkeys.php",_('Edit Keys')) ;
283 echo $HTML->boxBottom();
292 <p style="text-align: center;">
293 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
294 <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
299 site_user_footer(array());
303 // c-file-style: "bsd"