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
26 class Widget_ProjectPublicAreas extends Widget {
27 function Widget_ProjectPublicAreas() {
28 $this->Widget('projectpublicareas');
31 return _('Public Areas');
33 function getContent() {
34 $request =& HTTPRequest::instance();
35 $group_id = $request->get('group_id');
36 $pm = ProjectManager::instance();
37 $project = $pm->getProject($group_id);
38 $HTML = $GLOBALS['HTML'];
39 // ################# Homepage Link
41 echo '<div class="public-area-box" rel="doap:homepage">';
42 echo util_make_link ('http://' . $project->getHomePage(), $HTML->getHomePic(_('Home Page')) . ' ' . _('Project Home Page'), false, true);
45 // ################## ArtifactTypes
47 if ($project->usesTracker()) {
48 echo '<div class="public-area-box">'."\n";
49 $link_content = $HTML->getFollowPic(_('Tracker')) . ' ' . _('Tracker');
50 echo util_make_link ( '/tracker/?group_id=' . $group_id, $link_content);
52 $result=db_query_params ('SELECT agl.*,aca.count,aca.open_count
53 FROM artifact_group_list agl
54 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
57 ORDER BY group_artifact_id ASC',
60 $rows = db_numrows($result);
62 if (!$result || $rows < 1) {
63 echo "<br />\n<em>"._('There are no public trackers available').'</em>';
65 echo "\n".'<ul class="tracker" rel="doap:bug-database">'."\n";
66 for ($j = 0; $j < $rows; $j++) {
67 // tracker REST paths are something like : /tracker/cm/project/A_PROJECT/atid/NUMBER to plan compatibility
68 // with OSLC-CM server API
69 $group_artifact_id = db_result($result, $j, 'group_artifact_id');
70 $tracker_stdzd_uri = util_make_url('/tracker/cm/project/'. $project->getUnixName() .'/atid/'. $group_artifact_id);
71 echo "\t".'<li about="'. $tracker_stdzd_uri . '" typeof="sioc:Container">'."\n";
72 print '<span rel="http://www.w3.org/2002/07/owl#sameAs">'."\n";
73 echo util_make_link ('/tracker/?atid='. $group_artifact_id . '&group_id='.$group_id.'&func=browse',db_result($result, $j, 'name')) . ' ' ;
74 echo "</span>\n"; // /owl:sameAs
75 printf(ngettext('(<strong>%1$s</strong> open / <strong>%2$s</strong> total)', '(<strong>%1$s</strong> open / <strong>%2$s</strong> total)', (int) db_result($result, $j, 'open_count')), (int) db_result($result, $j, 'open_count'), (int) db_result($result, $j, 'count'));
76 echo '<br />'; //.db_result($result, $j, 'description');
77 print '<span rel="sioc:has_space" resource="" ></span>'."\n";
85 // ################## forums
87 if ($project->usesForum()) {
88 echo '<div class="public-area-box">'."\n";
89 // print '<hr size="1" /><a rel="sioc:container_of" href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
90 $link_content = $HTML->getForumPic('') . ' ' . _('Public Forums');
91 echo util_make_link ( '/forum/?group_id=' . $group_id, $link_content);
93 $messages_count = project_get_public_forum_message_count($group_id);
94 $forums_count = project_get_public_forum_count($group_id);
95 printf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
97 printf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
102 // ##################### Doc Manager
104 if ($project->usesDocman()) {
105 echo '<div class="public-area-box">'."\n";
106 $link_content = $HTML->getDocmanPic('') . ' ' . _('DocManager: Project Documentation');
107 // <a rel="sioc:container_of" xmlns:sioc="http://rdfs.org/sioc/ns#" href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
108 print util_make_link( '/docman/?group_id='.$group_id, $link_content);
112 // ##################### Mailing lists
114 if ($project->usesMail()) {
115 echo '<div class="public-area-box">'."\n";
116 $link_content = $HTML->getMailPic('') . ' ' . _('Mailing Lists');
117 print util_make_link( '/mail/?group_id='.$group_id, $link_content);
118 $n = project_get_mail_list_count($group_id);
120 printf(ngettext('(<strong>%1$s</strong> public mailing list)', '(<strong>%1$s</strong> public mailing lists)', $n), $n);
124 // ##################### Task Manager
126 if ($project->usesPm()) {
127 echo '<div class="public-area-box">'."\n";
128 $link_content = $HTML->getPmPic('') . ' ' . _('Tasks');
129 print util_make_link( '/pm/?group_id='.$group_id, $link_content);
131 $result = db_query_params ('SELECT * FROM project_group_list WHERE group_id=$1 AND is_public=1',
133 $rows = db_numrows($result);
134 if (!$result || $rows < 1) {
135 echo "<br />\n<em>"._('There are no public subprojects available').'</em>';
137 echo "\n".'<ul class="task-manager">';
138 for ($j = 0; $j < $rows; $j++) {
140 print util_make_link ('/pm/task.php?group_project_id='.db_result($result, $j, 'group_project_id').'&group_id='.$group_id.'&func=browse',db_result($result, $j, 'project_name'));
148 // ######################### Surveys
150 if ($project->usesSurvey()) {
151 echo '<div class="public-area-box">'."\n";
152 $link_content = $HTML->getSurveyPic('') . ' ' . _('Surveys');
153 echo util_make_link( '/survey/?group_id='.$group_id, $link_content);
154 echo ' (<strong>'. project_get_survey_count($group_id) .'</strong> ' . _('surveys').')';
158 // ######################### SCM
160 if ($project->usesSCM()) {
161 echo '<div class="public-area-box">'."\n";
163 $link_content = $HTML->getScmPic('') . ' ' . _('SCM Repository');
164 // print '<hr size="1" /><a rel="doap:repository" href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
165 print util_make_link( '/scm/?group_id='.$group_id, $link_content);
167 $hook_params = array () ;
168 $hook_params['group_id'] = $group_id ;
169 plugin_hook ("scm_stats", $hook_params) ;
173 // ######################### Plugins
175 $hook_params = array ();
176 $hook_params['group_id'] = $group_id;
177 plugin_hook ("project_public_area", $hook_params);
179 // ######################## AnonFTP
181 // CB hide FTP if desired
182 if ($project->usesFTP()) {
183 if ($project->isActive()) {
184 echo '<div class="public-area-box">'."\n";
186 $link_content = $HTML->getFtpPic('') . ' ' . _('Anonymous FTP Space');
187 // print '<a rel="doap:anonymous root" href="ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName() .'/">';
188 print util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
194 plugin_hook("cal_link_group",$group_id);
196 function canBeUsedByProject(&$project) {
199 function getDescription() {
200 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, ...)');