3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2010, Franck Villaume - Capgemini
6 * This file is a part of Codendi.
8 * Codendi is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Codendi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
22 require_once 'Widget.class.php';
23 require_once 'common/rss/RSS.class.php';
31 class Widget_MyProjects extends Widget {
32 function __construct() {
33 $this->Widget('myprojects');
36 return _("My Projects");
39 function getContent() {
41 $html_my_projects = '';
43 $user = session_get_user();
44 $groups = $user->getGroups();
45 sortProjectList($groups);
46 $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
47 sortRoleList ($roles) ;
49 if (count ($groups) < 1) {
50 $html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
52 $html_my_projects .= '<table style="width:100%">';
54 $ra = RoleAnonymous::getInstance();
55 foreach ($groups as $g) {
57 $html_my_projects .= '
58 <tr '. $HTML->boxGetAltRowStyle($i) .'"><td width="99%">'.
59 '<a href="/projects/'. $g->getUnixName() .'/">'.
60 $g->getPublicName().'</a>';
63 $role_names = array();
64 foreach ($roles as $r) {
65 if ($r instanceof RoleExplicit
66 && $r->getHomeProject() != NULL
67 && $r->getHomeProject()->getID() == $g->getID()) {
68 $role_names[] = $r->getName();
69 if ($r->hasPermission('project_admin', $g->getID())) {
75 $html_my_projects .= ' <small><a href="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</a></small>';
77 $html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
78 if (!$ra->hasPermission('project_read', $g->getID())) {
79 $html_my_projects .= ' (*)';
80 $private_shown = true;
83 $html_my_projects .= '</td>'.
84 '<td><a href="rmproject.php?group_id='. $g->getID().
85 '" onClick="return confirm(\''._("Quit this project?").'\')">'.
86 '<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" height="16" width="16" border="0" /></a></td></tr>';
88 $html_my_projects .= '</td><td> </td></tr>';
91 $html_my_projects .= '</table>';
92 if (isset($private_shown) && $private_shown) {
93 $html_my_projects .= '
94 <span>(*) '._("<em>Private project</em>").'</span>';
98 return $html_my_projects;
105 function displayRss() {
106 $rss = new RSS(array(
107 'title' => forge_get_config('forge_name').' - MyProjects',
108 'description' => 'My projects',
109 'link' => get_server_url(),
110 'language' => 'en-us',
111 'copyright' => 'Copyright Xerox',
112 'pubDate' => gmdate('D, d M Y G:i:s',time()).' GMT',
114 $projects = UserManager::instance()->getCurrentUser()->getGroups();
115 sortProjectList($projects);
117 if (!$result || $rows < 1) {
120 'description' => _("You're not a member of any project") . db_error(),
121 '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,
149 function getDescription() {
150 return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
156 // c-file-style: "bsd"