3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2012,2014,2016, Franck Villaume - TrivialDev
5 * http://fusionforge.org
7 * This file is a part of Fusionforge.
9 * Fusionforge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * Fusionforge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
23 require_once 'Widget.class.php';
26 * Widget_ProjectPublicAreas
29 class Widget_ProjectPublicAreas extends Widget {
30 function __construct() {
31 $this->Widget('projectpublicareas');
35 return _('Public Tools');
38 function getContent() {
41 $request =& HTTPRequest::instance();
42 $group_id = $request->get('group_id');
43 $pm = ProjectManager::instance();
44 $project = $pm->getProject($group_id);
45 $HTML = $GLOBALS['HTML'];
46 // ################# Homepage Link
48 $result .= html_e('div', array('class' => 'public-area-box', 'rel' => 'doap:homepage'),
49 util_make_link($project->getHomePage(), $HTML->getHomePic(_('Home Page')). ' ' ._('Project Home Page'), false, true));
51 // ################## ArtifactTypes
53 if ($project->usesTracker()) {
54 $result .= '<div class="public-area-box">'."\n";
55 $link_content = $HTML->getFollowPic(_('Tracker')) . ' ' . _('Tracker');
56 $result .= util_make_link('/tracker/?group_id=' . $group_id, $link_content);
58 $res = db_query_params ('SELECT agl.*,aca.count,aca.open_count
59 FROM artifact_group_list agl
60 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
62 ORDER BY group_artifact_id ASC',
66 while ($row = db_fetch_array($res)) {
67 if (!forge_check_perm('tracker',$row['group_artifact_id'],'read')) {
73 if (count($rows) < 1) {
74 $result .= "<br />\n<em>"._('There are no trackers available').'</em>';
76 $elementsLi = array();
77 foreach ($rows as $row) {
78 // tracker REST paths are something like : /tracker/cm/project/A_PROJECT/atid/NUMBER to plan compatibility
79 // with OSLC-CM server API
80 $group_artifact_id = $row['group_artifact_id'];
81 $tracker_stdzd_uri = util_make_url('/tracker/cm/project/'. $project->getUnixName() .'/atid/'. $group_artifact_id);
82 $contentLi = '<span rel="http://www.w3.org/2002/07/owl#sameAs">'."\n";
83 $contentLi .= util_make_link('/tracker/?atid='. $group_artifact_id . '&group_id='.$group_id.'&func=browse', $row['name']) . ' ' ;
84 $contentLi .= "</span>\n"; // /owl:sameAs
85 $contentLi .= sprintf(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']);
86 $contentLi .= '<br />';
87 $contentLi .= '<span rel="sioc:has_space" resource="" ></span>'."\n";
88 $elementLi[] = array('content' => $contentLi, 'attrs' => array('about' => $tracker_stdzd_uri, 'typeof' => 'sioc:Container'));
90 $result .= $HTML->html_list($elementsLi, array('class' => 'tracker', 'rel' => 'doap:bug-database'));
93 $result .= "</div>\n";
96 // ################## forums
98 if ($project->usesForum()) {
99 $result .= '<div class="public-area-box">'."\n";
100 // $result .= '<hr size="1" /><a rel="sioc:container_of" href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
101 $ff = new ForumFactory($project);
102 $f_arr = $ff->getForums();
103 $forums_count = count($f_arr);
105 foreach ($f_arr as $f) {
106 $messages_count += $f->getMessageCount();
109 $link_content = $HTML->getForumPic('') . ' ' . _('Public Forums');
110 $result .= util_make_link('/forum/?group_id=' . $group_id, $link_content);
112 $result .= sprintf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
113 $result .= ' ' . _('in') . ' ';
114 $result .= sprintf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
116 $result .= "\n</div>";
119 // ##################### Doc Manager
121 if ($project->usesDocman()) {
122 $result .= '<div class="public-area-box">';
123 $link_content = $HTML->getDocmanPic('') . ' ' . _('DocManager: Project Documentation');
124 // <a rel="sioc:container_of" xmlns:sioc="http://rdfs.org/sioc/ns#" href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
125 $result .= util_make_link('/docman/?group_id='.$group_id, $link_content);
129 // ##################### FRS
131 if ($project->usesFRS()) {
132 $result .= '<div class="public-area-box">';
133 $link_content = $HTML->getDownloadPic('') . ' ' . _('Files');
134 // <a rel="sioc:container_of" xmlns:sioc="http://rdfs.org/sioc/ns#" href="'.util_make_url ('/frs/?group_id='.$group_id).'">';
135 $result .= util_make_link('/frs/?group_id='.$group_id, $link_content);
139 // ##################### Mailing lists
141 if ($project->usesMail()) {
142 $result .= '<div class="public-area-box">';
143 $link_content = $HTML->getMailPic('') . ' ' . _('Mailing Lists');
144 $result .= util_make_link('/mail/?group_id='.$group_id, $link_content);
145 $n = project_get_mail_list_count($group_id);
147 $result .= sprintf(ngettext('(<strong>%s</strong> public mailing list)', '(<strong>%s</strong> public mailing lists)', $n), $n);
148 $result .= "\n</div>\n";
151 // ##################### Task Manager
153 if ($project->usesPm()) {
154 $result .= '<div class="public-area-box">';
155 $link_content = $HTML->getPmPic('') . ' ' . _('Tasks');
156 $result .= util_make_link('/pm/?group_id='.$group_id, $link_content);
158 $pgf = new ProjectGroupFactory ($project);
159 $pgs = $pgf->getProjectGroups();
161 if (count($pgs) < 1) {
162 $result .= "<br />\n<em>"._('There are no subprojects available').'</em>';
164 $result .= "\n".'<ul class="task-manager">';
165 foreach ($pgs as $pg) {
166 $result .= "\n\t<li>";
167 $result .= util_make_link('/pm/task.php?group_project_id='.$pg->getID().'&group_id='.$group_id.'&func=browse',$pg->getName());
170 $result .= "\n</ul>";
172 $result .= "\n</div>\n";
175 // ######################### Surveys
177 if ($project->usesSurvey()) {
178 $result .= '<div class="public-area-box">'."\n";
179 $link_content = $HTML->getSurveyPic('') . ' ' . _('Surveys');
180 $result .= util_make_link('/survey/?group_id='.$group_id, $link_content);
181 $result .= ' (<strong>'. project_get_survey_count($group_id) .'</strong> ' . _('surveys').')';
182 $result .= "\n</div>\n";
185 // ######################### SCM
187 if ($project->usesSCM()) {
188 $result .= '<div class="public-area-box">'."\n";
190 $link_content = $HTML->getScmPic('') . ' ' . _('SCM Repository');
191 // $result .= '<hr size="1" /><a rel="doap:repository" href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
192 $result .= util_make_link('/scm/?group_id='.$group_id, $link_content);
194 $hook_params = array () ;
195 $hook_params['group_id'] = $group_id ;
196 $hook_params['result'] = &$result;
197 plugin_hook ("scm_stats", $hook_params) ;
198 $result .= "\n</div>\n";
201 // ######################### Plugins
203 $hook_params = array ();
204 $hook_params['group_id'] = $group_id;
205 $hook_params['result'] = &$result;
206 plugin_hook ("project_public_area", $hook_params);
208 // ######################## AnonFTP
210 // CB hide FTP if desired
211 if ($project->usesFTP()) {
212 if ($project->isActive()) {
213 $result .= '<div class="public-area-box">'."\n";
215 $link_content = $HTML->getFtpPic('') . ' ' . _('Anonymous FTP Space');
216 // $result .= '<a rel="doap:anonymous root" href="ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName() .'/">';
217 if (forge_get_config('use_project_vhost')) {
218 $result .= util_make_link('ftp://' . $project->getUnixName() . '.' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
220 $result .= util_make_link('ftp://' . forge_get_config('web_host') . '/pub/'. $project->getUnixName(), $link_content, false, true);
222 $result .= "\n</div>\n";
229 function canBeUsedByProject(&$project) {
233 function getDescription() {
234 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.')
236 . _('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, ...)');