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($project->getHomePage(),
43 $HTML->getHomePic(_('Home Page')) . ' ' .
44 _('Project Home Page'), false, true);
47 // ################## ArtifactTypes
49 if ($project->usesTracker()) {
50 echo '<div class="public-area-box">'."\n";
51 $link_content = $HTML->getFollowPic(_('Tracker')) . ' ' . _('Tracker');
52 echo util_make_link ( '/tracker/?group_id=' . $group_id, $link_content);
54 $result=db_query_params ('SELECT agl.*,aca.count,aca.open_count
55 FROM artifact_group_list agl
56 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
58 ORDER BY group_artifact_id ASC',
62 while ($row = db_fetch_array($result)) {
63 if (!forge_check_perm('tracker',$row['group_artifact_id'],'read')) {
69 if (count($rows) < 1) {
70 echo "<br />\n<em>"._('There are no trackers available').'</em>';
72 echo "\n".'<ul class="tracker" rel="doap:bug-database">'."\n";
73 foreach ($rows as $row) {
74 // tracker REST paths are something like : /tracker/cm/project/A_PROJECT/atid/NUMBER to plan compatibility
75 // with OSLC-CM server API
76 $group_artifact_id = $row['group_artifact_id'];
77 $tracker_stdzd_uri = util_make_url('/tracker/cm/project/'. $project->getUnixName() .'/atid/'. $group_artifact_id);
78 echo "\t".'<li about="'. $tracker_stdzd_uri . '" typeof="sioc:Container">'."\n";
79 print '<span rel="http://www.w3.org/2002/07/owl#sameAs">'."\n";
80 echo util_make_link ('/tracker/?atid='. $group_artifact_id . '&group_id='.$group_id.'&func=browse',$row['name']) . ' ' ;
81 echo "</span>\n"; // /owl:sameAs
82 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']);
84 print '<span rel="sioc:has_space" resource="" ></span>'."\n";
94 // ################## forums
96 if ($project->usesForum()) {
97 echo '<div class="public-area-box">'."\n";
98 // print '<hr size="1" /><a rel="sioc:container_of" href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
99 $ff = new ForumFactory($project);
100 $f_arr = $ff->getForums();
101 $forums_count = count($f_arr);
103 foreach ($f_arr as $f) {
104 $messages_count += $f->getMessageCount();
107 $link_content = $HTML->getForumPic('') . ' ' . _('Public Forums');
108 echo util_make_link ( '/forum/?group_id=' . $group_id, $link_content);
110 printf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
112 printf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
117 // ##################### Doc Manager
119 if ($project->usesDocman()) {
120 echo '<div class="public-area-box">'."\n";
121 $link_content = $HTML->getDocmanPic('') . ' ' . _('DocManager: Project Documentation');
122 // <a rel="sioc:container_of" xmlns:sioc="http://rdfs.org/sioc/ns#" href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
123 print util_make_link( '/docman/?group_id='.$group_id, $link_content);
127 // ##################### Mailing lists
129 if ($project->usesMail()) {
130 echo '<div class="public-area-box">'."\n";
131 $link_content = $HTML->getMailPic('') . ' ' . _('Mailing Lists');
132 print util_make_link( '/mail/?group_id='.$group_id, $link_content);
133 $n = project_get_mail_list_count($group_id);
135 printf(ngettext('(<strong>%1$s</strong> public mailing list)', '(<strong>%1$s</strong> public mailing lists)', $n), $n);
139 // ##################### Task Manager
141 if ($project->usesPm()) {
142 echo '<div class="public-area-box">'."\n";
143 $link_content = $HTML->getPmPic('') . ' ' . _('Tasks');
144 print util_make_link( '/pm/?group_id='.$group_id, $link_content);
146 $pgf = new ProjectGroupFactory ($project);
147 $pgs = $pgf->getProjectGroups();
149 if (count($pgs) < 1) {
150 echo "<br />\n<em>"._('There are no subprojects available').'</em>';
152 echo "\n".'<ul class="task-manager">';
153 foreach ($pgs as $pg) {
155 print util_make_link ('/pm/task.php?group_project_id='.$pg->getID().'&group_id='.$group_id.'&func=browse',$pg->getName());
163 // ######################### Surveys
165 if ($project->usesSurvey()) {
166 echo '<div class="public-area-box">'."\n";
167 $link_content = $HTML->getSurveyPic('') . ' ' . _('Surveys');
168 echo util_make_link( '/survey/?group_id='.$group_id, $link_content);
169 echo ' (<strong>'. project_get_survey_count($group_id) .'</strong> ' . _('surveys').')';
173 // ######################### SCM
175 if ($project->usesSCM()) {
176 echo '<div class="public-area-box">'."\n";
178 $link_content = $HTML->getScmPic('') . ' ' . _('SCM Repository');
179 // print '<hr size="1" /><a rel="doap:repository" href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
180 print util_make_link( '/scm/?group_id='.$group_id, $link_content);
182 $hook_params = array () ;
183 $hook_params['group_id'] = $group_id ;
184 plugin_hook ("scm_stats", $hook_params) ;
188 // ######################### Plugins
190 $hook_params = array ();
191 $hook_params['group_id'] = $group_id;
192 plugin_hook ("project_public_area", $hook_params);
194 // ######################## AnonFTP
196 // CB hide FTP if desired
197 if ($project->usesFTP()) {
198 if ($project->isActive()) {
199 echo '<div class="public-area-box">'."\n";
201 $link_content = $HTML->getFtpPic('') . ' ' . _('Anonymous FTP Space');
202 // print '<a rel="doap:anonymous root" href="ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName() .'/">';
203 if (forge_get_config('use_project_vhost')) {
204 print util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
206 print util_make_link('ftp://' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
213 plugin_hook("cal_link_group",$group_id);
215 function canBeUsedByProject(&$project) {
218 function getDescription() {
219 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, ...)');