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';
24 * Widget_ProjectPublicAreas
27 class Widget_ProjectPublicAreas extends Widget {
28 function __construct() {
29 $this->Widget('projectpublicareas');
33 return _('Public Areas');
36 function getContent() {
37 $request =& HTTPRequest::instance();
38 $group_id = $request->get('group_id');
39 $pm = ProjectManager::instance();
40 $project = $pm->getProject($group_id);
41 $HTML = $GLOBALS['HTML'];
42 // ################# Homepage Link
44 echo '<div class="public-area-box" rel="doap:homepage">';
45 echo util_make_link($project->getHomePage(),
46 $HTML->getHomePic(_('Home Page')) . ' ' .
47 _('Project Home Page'), false, true);
50 // ################## ArtifactTypes
52 if ($project->usesTracker()) {
53 echo '<div class="public-area-box">'."\n";
54 $link_content = $HTML->getFollowPic(_('Tracker')) . ' ' . _('Tracker');
55 echo util_make_link ( '/tracker/?group_id=' . $group_id, $link_content);
57 $result=db_query_params ('SELECT agl.*,aca.count,aca.open_count
58 FROM artifact_group_list agl
59 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
61 ORDER BY group_artifact_id ASC',
65 while ($row = db_fetch_array($result)) {
66 if (!forge_check_perm('tracker',$row['group_artifact_id'],'read')) {
72 if (count($rows) < 1) {
73 echo "<br />\n<em>"._('There are no trackers available').'</em>';
75 echo "\n".'<ul class="tracker" rel="doap:bug-database">'."\n";
76 foreach ($rows as $row) {
77 // tracker REST paths are something like : /tracker/cm/project/A_PROJECT/atid/NUMBER to plan compatibility
78 // with OSLC-CM server API
79 $group_artifact_id = $row['group_artifact_id'];
80 $tracker_stdzd_uri = util_make_url('/tracker/cm/project/'. $project->getUnixName() .'/atid/'. $group_artifact_id);
81 echo "\t".'<li about="'. $tracker_stdzd_uri . '" typeof="sioc:Container">'."\n";
82 print '<span rel="http://www.w3.org/2002/07/owl#sameAs">'."\n";
83 echo util_make_link ('/tracker/?atid='. $group_artifact_id . '&group_id='.$group_id.'&func=browse',$row['name']) . ' ' ;
84 echo "</span>\n"; // /owl:sameAs
85 printf(ngettext('(<strong>%1$s</strong> open / <strong>%2$s</strong> total)', '(<strong>%1$s</strong> open / <strong>%2$s</strong> total)', $row['open_count']), $row['open_count'], $row['count']);
87 print '<span rel="sioc:has_space" resource="" ></span>'."\n";
97 // ################## forums
99 if ($project->usesForum()) {
100 echo '<div class="public-area-box">'."\n";
101 // print '<hr size="1" /><a rel="sioc:container_of" href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
102 $ff = new ForumFactory($project);
103 $f_arr = $ff->getForums();
104 $forums_count = count($f_arr);
106 foreach ($f_arr as $f) {
107 $messages_count += $f->getMessageCount();
110 $link_content = $HTML->getForumPic('') . ' ' . _('Public Forums');
111 echo util_make_link ( '/forum/?group_id=' . $group_id, $link_content);
113 printf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
115 printf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
120 // ##################### Doc Manager
122 if ($project->usesDocman()) {
123 echo '<div class="public-area-box">'."\n";
124 $link_content = $HTML->getDocmanPic('') . ' ' . _('DocManager: Project Documentation');
125 // <a rel="sioc:container_of" xmlns:sioc="http://rdfs.org/sioc/ns#" href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
126 print util_make_link( '/docman/?group_id='.$group_id, $link_content);
130 // ##################### Mailing lists
132 if ($project->usesMail()) {
133 echo '<div class="public-area-box">'."\n";
134 $link_content = $HTML->getMailPic('') . ' ' . _('Mailing Lists');
135 print util_make_link( '/mail/?group_id='.$group_id, $link_content);
136 $n = project_get_mail_list_count($group_id);
138 printf(ngettext('(<strong>%1$s</strong> public mailing list)', '(<strong>%1$s</strong> public mailing lists)', $n), $n);
142 // ##################### Task Manager
144 if ($project->usesPm()) {
145 echo '<div class="public-area-box">'."\n";
146 $link_content = $HTML->getPmPic('') . ' ' . _('Tasks');
147 print util_make_link( '/pm/?group_id='.$group_id, $link_content);
149 $pgf = new ProjectGroupFactory ($project);
150 $pgs = $pgf->getProjectGroups();
152 if (count($pgs) < 1) {
153 echo "<br />\n<em>"._('There are no subprojects available').'</em>';
155 echo "\n".'<ul class="task-manager">';
156 foreach ($pgs as $pg) {
158 print util_make_link ('/pm/task.php?group_project_id='.$pg->getID().'&group_id='.$group_id.'&func=browse',$pg->getName());
166 // ######################### Surveys
168 if ($project->usesSurvey()) {
169 echo '<div class="public-area-box">'."\n";
170 $link_content = $HTML->getSurveyPic('') . ' ' . _('Surveys');
171 echo util_make_link( '/survey/?group_id='.$group_id, $link_content);
172 echo ' (<strong>'. project_get_survey_count($group_id) .'</strong> ' . _('surveys').')';
176 // ######################### SCM
178 if ($project->usesSCM()) {
179 echo '<div class="public-area-box">'."\n";
181 $link_content = $HTML->getScmPic('') . ' ' . _('SCM Repository');
182 // print '<hr size="1" /><a rel="doap:repository" href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
183 print util_make_link( '/scm/?group_id='.$group_id, $link_content);
185 $hook_params = array () ;
186 $hook_params['group_id'] = $group_id ;
187 plugin_hook ("scm_stats", $hook_params) ;
191 // ######################### Plugins
193 $hook_params = array ();
194 $hook_params['group_id'] = $group_id;
195 plugin_hook ("project_public_area", $hook_params);
197 // ######################## AnonFTP
199 // CB hide FTP if desired
200 if ($project->usesFTP()) {
201 if ($project->isActive()) {
202 echo '<div class="public-area-box">'."\n";
204 $link_content = $HTML->getFtpPic('') . ' ' . _('Anonymous FTP Space');
205 // print '<a rel="doap:anonymous root" href="ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName() .'/">';
206 if (forge_get_config('use_project_vhost')) {
207 print util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
209 print util_make_link('ftp://' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
216 function canBeUsedByProject(&$project) {
220 function getDescription() {
221 return _('List all available services for this project along with some information next to it. Click on any of this item to access a service.<br />The role of this area is pretty much equivalent to the Project Main Menu at the top of the screen except that it shows additional information about each of the service (e.g. total number of open bugs, tasks, ...)');