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 foreach ($groups as $g) {
54 $class="bgcolor-white";
57 $class="bgcolor-grey";
60 $html_my_projects .= '
61 <TR class="'. $class .'"><TD WIDTH="99%">'.
62 '<A href="/projects/'. $g->getUnixName() .'/">'.
63 $g->getPublicName().'</A>';
66 $role_names = array () ;
67 foreach ($roles as $r) {
68 if ($r instanceof RoleExplicit
69 && $r->getHomeProject() != NULL
70 && $r->getHomeProject()->getID() == $g->getID()) {
71 $role_names[] = $r->getName() ;
72 if ($r->hasPermission ('project_admin', $g->getID())) {
78 $html_my_projects .= ' <small><A HREF="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</A></small>';
80 $html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
81 if (!$g->isPublic()) {
82 $html_my_projects .= ' (*)';
83 $private_shown = true;
86 $html_my_projects .= '</TD>'.
87 '<td><A href="rmproject.php?group_id='. $g->getID().
88 '" onClick="return confirm(\''._("Quit this project?").'\')">'.
89 '<IMG SRC="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" HEIGHT="16" WIDTH="16" BORDER="0"></A></TD></TR>';
91 $html_my_projects .= '</td><td> </td></TR>';
95 if (isset($private_shown) && $private_shown) {
96 $html_my_projects .= '
97 <TR class="'.$class .'"><TD colspan="2" class="small">'.
98 '(*) '._("<em>Private project</em>").'</td></tr>';
100 $html_my_projects .= '</table>';
102 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 (!$result || $rows < 1) {
122 'description' => _("You're not a member of any project") . db_error(),
123 'link' => util_make_url()
129 foreach ($projects as $project) {
130 $pid = $project->getID() ;
131 $title = $project->getPublicName() ;
132 $url = util_make_url('/projects/' . $project->getUnixName()) ;
134 if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
138 $desc = "Project: $url\n";
139 if (forge_check_perm ('project_admin', $pid)) {
140 $desc .= '<br />Admin: '. util_make_url('/project/admin/?group_id='.$pid);
145 'description' => $desc,
151 function getDescription() {
152 return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
158 // c-file-style: "bsd"