3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2010, Franck Villaume - Capgemini
5 * Copyright 2013, French Ministry of National Education
6 * Copyright 2013, Franck Villaume - TrivialDev
8 * This file is a part of Fusionforge.
10 * Fusionforge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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
21 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
24 require_once 'Widget.class.php';
25 require_once 'common/rss/RSS.class.php';
33 class Widget_MyProjects extends Widget {
34 function __construct() {
35 $this->Widget('myprojects');
38 return _("My Projects");
41 function getContent() {
43 $html_my_projects = '';
45 $user = session_get_user();
46 $groups = $user->getGroups();
47 sortProjectList($groups);
48 $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
49 sortRoleList ($roles) ;
51 if (count ($groups) < 1) {
52 $html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
54 $html_my_projects .= '<table style="width:100%">';
56 $ra = RoleAnonymous::getInstance();
57 foreach ($groups as $g) {
59 $html_my_projects .= '
60 <tr '. $HTML->boxGetAltRowStyle($i) .'"><td style="width:99%">'.
61 '<a href="/projects/'. $g->getUnixName() .'/">'.
62 $g->getPublicName().'</a>';
65 $role_names = array();
66 foreach ($roles as $r) {
67 if ($r instanceof RoleExplicit
68 && $r->getHomeProject() != NULL
69 && $r->getHomeProject()->getID() == $g->getID()) {
70 $role_names[] = $r->getName();
71 if ($r->hasPermission('project_admin', $g->getID())) {
77 $html_my_projects .= ' <small><a href="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</a></small>';
79 $html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
80 if (!$ra->hasPermission('project_read', $g->getID())) {
81 $html_my_projects .= ' (*)';
82 $private_shown = true;
85 $html_my_projects .= '</td>'.
86 '<td><a href="rmproject.php?group_id='. $g->getID().
87 '" onClick="return confirm(\''._("Quit this project?").'\')">'.
88 '<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" alt="'._('Leave project').'" height="16" width="16" /></a></td></tr>';
90 $html_my_projects .= '</td><td> </td></tr>';
93 $html_my_projects .= '</table>';
94 if (isset($private_shown) && $private_shown) {
95 $html_my_projects .= '
96 <span>(*) <em>'._("Private project").'</em></span>';
100 return $html_my_projects;
107 function displayRss() {
108 $rss = new RSS(array(
109 'title' => forge_get_config('forge_name').' - '. _('MyProjects'),
110 'description' => _('My projects'),
111 'link' => get_server_url(),
112 'language' => 'en-us',
113 'copyright' => 'Copyright Xerox',
114 'pubDate' => gmdate('D, d M Y G:i:s',time()).' GMT',
116 $projects = UserManager::instance()->getCurrentUser()->getGroups();
117 sortProjectList($projects);
119 if (!$projects || count($projects) < 1) {
121 'title' => forge_get_config('forge_name'),
122 'description' => _("You're not a member of any project") . db_error(),
123 'link' => util_make_url()
127 foreach ($projects as $project) {
128 $pid = $project->getID();
129 $title = $project->getPublicName();
130 $url = util_make_url('/projects/' . $project->getUnixName());
132 if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
136 $desc = "Project: $url\n";
137 if (forge_check_perm ('project_admin', $pid)) {
138 $desc .= '<br />Admin: '. util_make_url('/project/admin/?group_id='.$pid);
143 'description' => $desc,
150 function getDescription() {
151 return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
157 // c-file-style: "bsd"