5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010, FusionForge Team
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 $project_agg_arr=array();
28 * project_setup_agg() - Set up a project aggregate array.
30 * @param int Project ID
33 function project_setup_agg($group_id) {
34 global $project_agg_arr,$project_agg_arr_is_set;
35 $res=db_query_params ('SELECT type, count FROM project_sums_agg WHERE group_id=$1',
37 $rows=db_numrows($res);
38 if ($res && $rows > 0) {
39 for ($i=0; $i<$rows; $i++) {
40 $project_agg_arr[db_result($res,$i,'type')]=db_result($res,$i,'count');
43 $project_agg_arr_is_set=true;
47 * project_getaggvalue() - Get a projects aggregate value for a specific type
49 * @param int The group ID
50 * @param string The type
53 function project_getaggvalue($group_id,$type) {
54 global $project_agg_arr,$project_agg_arr_is_set;
55 if (!$project_agg_arr_is_set) {
56 project_setup_agg($group_id);
59 if (isset($project_agg_arr[$type])) {
60 return "$project_agg_arr[$type]";
67 * project_get_mail_list_count() - Get the number of mailing lists for a project.
69 * @param int The group ID
71 function project_get_mail_list_count($group_id) {
72 return project_getaggvalue($group_id,'mail');
76 * project_get_survey_count() - Get the number of surveys for a project.
78 * @param int The group ID
80 function project_get_survey_count($group_id) {
81 return project_getaggvalue($group_id,'surv');
85 * project_summary() - Build a project summary box that projects can insert into their project pages
87 * @param int The group ID
88 * @param string How to return the results.
89 * @param bool Whether to return the results within an HTML table or not
91 function project_summary($group_id,$mode,$no_table) {
93 return 'Error - No Project ID';
99 $project = group_get_object($group_id);
101 if (!$project || !is_object($project)) {
102 return 'Could Not Create Project Object';
103 } elseif ($project->isError()) {
104 return $project->getErrorMessage();
110 <table border=0 width="100%"><tr><td class="tablecontent">';
113 // ################## ArtifactTypes
115 $return .= '<a href="'.util_make_url ('/tracker/?group_id='.$group_id).'">';
116 $return .= html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
117 $return .= ' Tracker</a>';
119 if ($mode != 'compact') {
120 $result=db_query_params ('SELECT agl.*,aca.count,aca.open_count
121 FROM artifact_group_list agl
122 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
123 WHERE agl.group_id=$1
125 ORDER BY group_artifact_id ASC',
128 $rows = db_numrows($result);
130 if (!$result || $rows < 1) {
131 $return .= '<br /><em>'._('There are no public trackers available').'</em>';
133 for ($j = 0; $j < $rows; $j++) {
135 - '.util_make_link ('/tracker/?atid='. db_result($result, $j, 'group_artifact_id') . '&group_id='.$group_id.'&func=browse',db_result($result, $j, 'name'));
136 $return .= sprintf(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')) ;
142 // ##################### Forums
144 if ($project->usesForum()) {
148 $return .= '<a href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
149 $return .= html_image("ic/forum20g.png","20","20",array("alt"=>"Forums"));
150 $return .= ' Forums</a>';
152 $ff = new ForumFactory($project);
153 $f_arr = $ff->getForums();
154 $forums_count = count($f_arr);
156 foreach ($f_arr as $f) {
157 $messages_count += $f->getMessageCount();
160 if ($mode != 'compact') {
161 $return .= sprintf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
163 $return .= sprintf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
168 // ##################### Doc Manager
170 if ($project->usesDocman()) {
174 $return .= '<a href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
175 $return .= html_image("ic/docman16b.png","20","20",array("alt"=>"Docs"));
176 $return .= ' Doc Manager</a>';
179 // ##################### Mailing lists
181 if ($project->usesMail()) {
185 $return .= '<a href="'.util_make_url ('/mail/?group_id='.$group_id).'">';
186 $return .= html_image("ic/mail16b.png","20","20",array("alt"=>"Mail Lists"));
187 $return .= ' Mailing Lists</a>';
189 if ($mode != 'compact') {
190 $return .= " ( <strong>". project_get_mail_list_count($group_id) ."</strong> public lists )";
194 // ##################### Tasks
196 if ($project->usesPm()) {
200 $return .= '<a href="'.util_make_url ('/pm/?group_id='.$group_id).'">';
201 $return .= html_image("ic/taskman20g.png","20","20",array("alt"=>"Tasks"));
202 $return .= ' Task Manager</a>';
204 if ($mode != 'compact') {
205 //get a list of publicly available projects
206 $result = db_query_params ('SELECT * FROM project_group_list WHERE group_id=$1 AND is_public=1',
208 $rows = db_numrows($result);
209 if (!$result || $rows < 1) {
210 $return .= '<br /><em>There are no public subprojects available</em>';
212 for ($j = 0; $j < $rows; $j++) {
214 <br /> - '.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'));
216 db_free_result($result);
221 // ######################### Surveys
223 if ($project->usesSurvey()) {
227 $return .= '<a href="'.util_make_url ('/survey/?group_id='.$group_id).'">';
228 $return .= html_image("ic/survey16b.png","20","20",array("alt"=>"Surveys"));
229 $return .= " Surveys</a>";
230 if ($mode != 'compact') {
231 $return .= ' ( <strong>'. project_get_survey_count($group_id) .'</strong> surveys )';
235 // ######################### SCM
237 if ($project->usesSCM()) {
241 $return .= '<a href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
242 $return .= html_image("ic/cvs16b.png","20","20",array("alt"=>"SCM"));
243 $return .= " SCM Tree</a>";
245 if ($mode != 'compact') {
246 $result = db_query_params ('SELECT SUM(commits) AS commits,SUM(adds) AS adds from stats_cvs_group where group_id=$1',
248 $return .= ' ( <strong>'.db_result($result,0,0).'</strong> commits, <strong>'.db_result($result,0,1).'</strong> adds )';
252 // ######################## Released Files
254 if ($project->isActive()) {
258 $return .= '<a href="'.util_make_url ('/project/showfiles.php?group_id='.$group_id).'">';
259 $return .= html_image("ic/ftp16b.png","20","20",array("alt"=>"FTP"));
260 $return .= " Released Files</a>";
274 // c-file-style: "bsd"