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');
30 class Widget_MyProjects extends Widget {
31 function Widget_MyProjects() {
32 $this->Widget('myprojects');
35 return _("My Projects");
38 function getContent() {
40 $html_my_projects = '';
42 $user = session_get_user();
43 $groups = $user->getGroups();
44 sortProjectList($groups);
45 $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
46 sortRoleList ($roles) ;
48 if (count ($groups) < 1) {
49 $html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
51 $html_my_projects .= '<table style="width:100%">';
53 $ra = RoleAnonymous::getInstance();
54 foreach ($groups as $g) {
56 $html_my_projects .= '
57 <tr '. $HTML->boxGetAltRowStyle($i) .'"><td width="99%">'.
58 '<a href="/projects/'. $g->getUnixName() .'/">'.
59 $g->getPublicName().'</a>';
62 $role_names = array();
63 foreach ($roles as $r) {
64 if ($r instanceof RoleExplicit
65 && $r->getHomeProject() != NULL
66 && $r->getHomeProject()->getID() == $g->getID()) {
67 $role_names[] = $r->getName();
68 if ($r->hasPermission('project_admin', $g->getID())) {
74 $html_my_projects .= ' <small><a href="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</a></small>';
76 $html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
77 if (!$ra->hasPermission('project_read', $g->getID())) {
78 $html_my_projects .= ' (*)';
79 $private_shown = true;
82 $html_my_projects .= '</td>'.
83 '<td><a href="rmproject.php?group_id='. $g->getID().
84 '" onClick="return confirm(\''._("Quit this project?").'\')">'.
85 '<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" height="16" width="16" border="0" /></a></td></tr>';
87 $html_my_projects .= '</td><td> </td></tr>';
90 $html_my_projects .= '</table>';
91 if (isset($private_shown) && $private_shown) {
92 $html_my_projects .= '
93 <span>(*) '._("<em>Private project</em>").'</span>';
97 return $html_my_projects;
104 function displayRss() {
105 $rss = new RSS(array(
106 'title' => forge_get_config('forge_name').' - MyProjects',
107 'description' => 'My projects',
108 'link' => get_server_url(),
109 'language' => 'en-us',
110 'copyright' => 'Copyright Xerox',
111 'pubDate' => gmdate('D, d M Y G:i:s',time()).' GMT',
113 $projects = UserManager::instance()->getCurrentUser()->getGroups();
114 sortProjectList($projects);
116 if (!$result || $rows < 1) {
119 'description' => _("You're not a member of any project") . db_error(),
120 'link' => util_make_url()
126 foreach ($projects as $project) {
127 $pid = $project->getID();
128 $title = $project->getPublicName();
129 $url = util_make_url('/projects/' . $project->getUnixName());
131 if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
135 $desc = "Project: $url\n";
136 if (forge_check_perm ('project_admin', $pid)) {
137 $desc .= '<br />Admin: '. util_make_url('/project/admin/?group_id='.$pid);
142 'description' => $desc,
148 function getDescription() {
149 return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
155 // c-file-style: "bsd"