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 $roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
43 if (count ($groups) < 1) {
44 $html_my_projects .= _("You're not a member of any project");
46 $html_my_projects .= '<table style="width:100%">';
48 foreach ($groups as $g) {
51 $class="bgcolor-white";
54 $class="bgcolor-grey";
57 $html_my_projects .= '
58 <TR class="'. $class .'"><TD WIDTH="99%">'.
59 '<A href="/projects/'. $g->getUnixName() .'/">'.
60 $g->getPublicName().'</A>';
64 foreach ($roles as $r) {
65 if ($r instanceof RoleExplicit
66 && $r->getHomeProject() != NULL
67 && $r->getHomeProject()->getID() == $g->getID()) {
69 if ($r->hasPermission ('project_admin', $g->getID())) {
76 $html_my_projects .= ' <small><A HREF="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</A></small>';
78 if (!$g->isPublic()) {
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>';
92 if (isset($private_shown) && $private_shown) {
93 $html_my_projects .= '
94 <TR class="'.$class .'"><TD colspan="2" class="small">'.
95 '(*) '._("<em>Private project</em>").'</td></tr>';
97 $html_my_projects .= '</table>';
99 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 $result = db_query_params("SELECT groups.group_name,"
115 . "groups.unix_group_name,"
117 . "groups.is_public,"
118 . "user_group.admin_flags "
119 . "FROM groups,user_group "
120 . "WHERE groups.group_id=user_group.group_id "
121 . "AND user_group.user_id=$1"
122 . "AND groups.status='A' ORDER BY group_name",array(UserManager::instance()->getCurrentUser()->getID() ));
123 $rows=db_numrows($result);
124 if (!$result || $rows < 1) {
127 'description' => _("You're not a member of any project") . db_error(),
128 'link' => util_make_url()
131 for ($i=0; $i<$rows; $i++) {
132 $title = db_result($result,$i,'group_name');
133 if ( db_result($result,$i,'is_public') == 0 ) {
137 $desc = 'Project: '. util_make_url('/project/admin/?group_id='.db_result($result,$i,'group_id')) ."<br />\n";
138 if ( strpos(db_result($result,$i,'admin_flags') , 'A')==0 ) {
139 $desc .= 'Admin: '. util_make_url('/project/admin/?group_id='.db_result($result,$i,'group_id'));
144 'description' => $desc,
145 'link' => util_make_url('/projects/'. db_result($result,$i,'unix_group_name'))
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"