3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once('Widget.class.php');
22 require_once('common/rss/RSS.class.php');
29 class Widget_MyProjects extends Widget {
30 function Widget_MyProjects() {
31 $this->Widget('myprojects');
34 return _("My Projects");
37 function getContent() {
38 $html_my_projects = '';
40 $user = session_get_user () ;
41 $groups = $user->getGroups() ;
42 sortProjectList ($groups) ;
43 $roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
44 sortRoleList ($roles) ;
46 if (count ($groups) < 1) {
47 $html_my_projects .= _("You're not a member of any project");
49 $html_my_projects .= '<table style="width:100%">';
51 $ra = RoleAnonymous::getInstance() ;
52 foreach ($groups as $g) {
55 $class="bgcolor-white";
58 $class="bgcolor-grey";
61 $html_my_projects .= '
62 <TR class="'. $class .'"><TD WIDTH="99%">'.
63 '<A href="/projects/'. $g->getUnixName() .'/">'.
64 $g->getPublicName().'</A>';
67 $role_names = array () ;
68 foreach ($roles as $r) {
69 if ($r instanceof RoleExplicit
70 && $r->getHomeProject() != NULL
71 && $r->getHomeProject()->getID() == $g->getID()) {
72 $role_names[] = $r->getName() ;
73 if ($r->hasPermission ('project_admin', $g->getID())) {
79 $html_my_projects .= ' <small><A HREF="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</A></small>';
81 $html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
82 if (!$ra->hasPermission('project_read', $g->getID())) {
83 $html_my_projects .= ' (*)';
84 $private_shown = true;
87 $html_my_projects .= '</TD>'.
88 '<td><A href="rmproject.php?group_id='. $g->getID().
89 '" onClick="return confirm(\''._("Quit this project?").'\')">'.
90 '<IMG SRC="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" HEIGHT="16" WIDTH="16" BORDER="0"></A></TD></TR>';
92 $html_my_projects .= '</td><td> </td></TR>';
96 if (isset($private_shown) && $private_shown) {
97 $html_my_projects .= '
98 <tr class="'.$class .'"><td colspan="2" class="small">'.
99 '(*) <em>' . _("Private project").'</em></td></tr>';
101 $html_my_projects .= '</table>';
103 return $html_my_projects;
108 function displayRss() {
109 $rss = new RSS(array(
110 'title' => forge_get_config('forge_name').' - MyProjects',
111 'description' => 'My projects',
112 'link' => get_server_url(),
113 'language' => 'en-us',
114 'copyright' => 'Copyright Xerox',
115 'pubDate' => gmdate('D, d M Y G:i:s',time()).' GMT',
117 $projects = UserManager::instance()->getCurrentUser()->getGroups() ;
118 sortProjectList ($projects) ;
120 if (!$result || $rows < 1) {
123 'description' => _("You're not a member of any project") . db_error(),
124 'link' => util_make_url()
130 foreach ($projects as $project) {
131 $pid = $project->getID() ;
132 $title = $project->getPublicName() ;
133 $url = util_make_url('/projects/' . $project->getUnixName()) ;
135 if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
139 $desc = "Project: $url\n";
140 if (forge_check_perm ('project_admin', $pid)) {
141 $desc .= '<br />Admin: '. util_make_url('/project/admin/?group_id='.$pid);
146 'description' => $desc,
152 function getDescription() {
153 return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
159 // c-file-style: "bsd"