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");
36 function getContent() {
37 $html_my_projects = '';
39 $user = session_get_user () ;
40 $groups = $user->getGroups() ;
41 sortProjectList ($groups) ;
42 $roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
43 sortRoleList ($roles) ;
45 if (count ($groups) < 1) {
46 $html_my_projects .= _("You're not a member of any project");
48 $html_my_projects .= '<table style="width:100%">';
50 foreach ($groups as $g) {
53 $class="bgcolor-white";
56 $class="bgcolor-grey";
59 $html_my_projects .= '
60 <TR class="'. $class .'"><TD 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 (!$g->isPublic()) {
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" HEIGHT="16" WIDTH="16" BORDER="0"></A></TD></TR>';
90 $html_my_projects .= '</td><td> </td></TR>';
94 if (isset($private_shown) && $private_shown) {
95 $html_my_projects .= '
96 <TR class="'.$class .'"><TD colspan="2" class="small">'.
97 '(*) '._("<em>Private project</em>").'</td></tr>';
99 $html_my_projects .= '</table>';
101 return $html_my_projects;
106 function displayRss() {
107 $rss = new RSS(array(
108 'title' => forge_get_config('forge_name').' - MyProjects',
109 'description' => 'My projects',
110 'link' => get_server_url(),
111 'language' => 'en-us',
112 'copyright' => 'Copyright Xerox',
113 'pubDate' => gmdate('D, d M Y G:i:s',time()).' GMT',
115 $projects = UserManager::instance()->getCurrentUser()->getGroups() ;
116 sortProjectList ($projects) ;
118 if (!$result || $rows < 1) {
121 'description' => _("You're not a member of any project") . db_error(),
122 'link' => util_make_url()
128 foreach ($projects as $project) {
129 $pid = $project->getID() ;
130 $title = $project->getPublicName() ;
131 $url = util_make_url('/projects/' . $project->getUnixName()) ;
133 if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
137 $desc = "Project: $url\n";
138 if (forge_check_perm ('project_admin', $pid)) {
139 $desc .= '<br />Admin: '. util_make_url('/project/admin/?group_id='.$pid);
144 '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"