3 * User information page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2018, Franck Villaume - TrivialDev
9 * http://fusionforge.org/
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/User.class.php';
31 $expl_pathinfo = explode('/', getStringFromServer('REQUEST_URI'));
33 if (!$expl_pathinfo[2]) {
34 exit_error(_('No User Name Provided'));
37 $default_content_type = 'text/html';
39 $content_type = util_negociate_alternate_content_types($script, $default_content_type);
41 $username = urldecode($expl_pathinfo[2]);
42 //get the user object based on the user_name in the URL
43 $user = user_get_object_by_name($username);
45 // If restricted mode, display only people who are sharing a project with the current user.
46 if (forge_get_config('restrict_users_visibility')) {
47 if (!session_loggedin()) {
48 exit_permission_denied();
51 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
52 exit_permission_denied();
55 $u2gl = $user->getGroupIds();
57 foreach ($u2gl as $u2g) {
58 if (forge_check_perm('project_read', $u2g)) {
64 exit_permission_denied();
68 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
69 exit_error(_('That user does not exist.'));
71 // if a custom content-type is selected, then redirect to plugin's rendering
72 if($content_type != $default_content_type) {
73 $hook_params = array();
74 $hook_params['username'] = $username;
75 $hook_params['accept'] = $content_type;
76 $hook_params['return'] = '';
77 plugin_hook_by_reference('content_negociated_user_home', $hook_params);
78 if ($hook_params['content_type'] != '') {
79 header('Content-type: '. $hook_params['content_type']);
80 echo $hook_params['content'];
82 header('HTTP/1.1 406 Not Acceptable',true,406);
85 } else { // default HTML view
86 //now show the user page
87 $title = '<i>'.$username.'</i> '._('Profile');
88 if (forge_get_config('use_diary') && session_loggedin() && ($user->getID() != user_getid())) {
89 if ($user->isMonitoredBy(user_getid())) {
90 $action = 'deletemonitoring';
91 $titleMonitor = _('Stop monitoring this user');
92 $image = $HTML->getStopMonitoringPic($titleMonitor, '');
94 $action = 'addmonitoring';
95 $titleMonitor = _('Start monitoring this user');
96 $image = $HTML->getStartMonitoringPic($titleMonitor, '');
98 $title .= util_make_link('/account/?action='.$action.'&diary_user='.$user->getID(), $image, array('title' => $titleMonitor));
100 $HTML->header(array('title' => $title));
102 if (forge_get_config('user_home_widget')) {
103 if (session_loggedin() && ($user->getID() == user_getid())) {
105 FROM layouts AS l INNER JOIN owner_layouts AS o ON(l.id = o.layout_id)
106 WHERE o.owner_type = $1
110 $res = db_query_params($sql,array(WidgetLayoutManager::OWNER_TYPE_USERHOME, $user->getID()));
111 $layout_id = db_result($res, 0 , 'id');
116 echo html_ao('ul', array('class' => 'widget_toolbar'));
117 $url = '/widgets/widgets.php?owner='.WidgetLayoutManager::OWNER_TYPE_USERHOME.$user->getID().'&layout_id='.$layout_id;
118 $labels = array(_('Add widgets'), _('Customize Layout'));
119 $urls = array($url, $url.'&update=layout');
120 for ($i = 0; $i < count($urls); $i++) {
121 echo html_e('li', array(), util_make_link($urls[$i], $labels[$i]));
125 $lm = new WidgetLayoutManager();
126 $lm->displayLayout($user->getID(), WidgetLayoutManager::OWNER_TYPE_USERHOME);
128 include $gfwww.'include/user_home.php';
136 // c-file-style: "bsd"