5 * SourceForge: Breaking Down the Barriers to Open Source Development
6 * Copyright 1999-2001 (c) VA Linux Systems
7 * http://sourceforge.net
11 $project_agg_arr=array();
14 * project_setup_agg() - Set up a project aggregate array.
19 function project_setup_agg($group_id) {
20 global $project_agg_arr,$project_agg_arr_is_set;
21 $res=db_query_params ('SELECT type, count FROM project_sums_agg WHERE group_id=$1',
23 $rows=db_numrows($res);
24 if ($res && $rows > 0) {
25 for ($i=0; $i<$rows; $i++) {
26 $project_agg_arr[db_result($res,$i,'type')]=db_result($res,$i,'count');
29 $project_agg_arr_is_set=true;
33 * project_getaggvalue() - Get a projects aggregate value for a specific type
35 * @param int The group ID
36 * @param string The type
39 function project_getaggvalue($group_id,$type) {
40 global $project_agg_arr,$project_agg_arr_is_set;
41 if (!$project_agg_arr_is_set) {
42 project_setup_agg($group_id);
45 if (@$project_agg_arr[$type]) {
46 return "$project_agg_arr[$type]";
53 * project_get_mail_list_count() - Get the number of mailing lists for a project.
55 * @param int The group ID
57 function project_get_mail_list_count($group_id) {
58 return project_getaggvalue($group_id,'mail');
62 * project_get_survey_count() - Get the number of surveys for a project.
64 * @param int The group ID
66 function project_get_survey_count($group_id) {
67 return project_getaggvalue($group_id,'surv');
71 * project_get_public_forum_count() - Get the number of public forums for a project.
73 * @param int The group ID
75 function project_get_public_forum_count($group_id) {
76 return project_getaggvalue($group_id, 'fora');
80 * project_get_public_forum_message_count() - Get the number of messages within public forums for a project.
82 * @param int The group ID
84 function project_get_public_forum_message_count($group_id) {
85 return project_getaggvalue($group_id, 'fmsg');
89 * project_summary() - Build a project summary box that projects can insert into their project pages
91 * @param int The group ID
92 * @param string How to return the results.
93 * @param bool Whether to return the results within an HTML table or not
95 function project_summary($group_id,$mode,$no_table) {
97 return 'Error - No Group ID';
103 $project =& group_get_object($group_id);
105 if (!$project || !is_object($project)) {
106 return 'Could Not Create Project Object';
107 } elseif ($project->isError()) {
108 return $project->getErrorMessage();
114 <table border=0 width="100%"><tr><td class="tablecontent">';
117 // ################## ArtifactTypes
119 $return .= '<a href="'.util_make_url ('/tracker/?group_id='.$group_id).'">';
120 $return .= html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
121 $return .= ' Tracker</a>';
123 if ($mode != 'compact') {
124 $result=db_query_params ('SELECT agl.*,aca.count,aca.open_count
125 FROM artifact_group_list agl
126 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
127 WHERE agl.group_id=$1
129 ORDER BY group_artifact_id ASC',
132 $rows = db_numrows($result);
134 if (!$result || $rows < 1) {
135 $return .= '<br /><em>'._('There are no public trackers available').'</em>';
137 for ($j = 0; $j < $rows; $j++) {
139 - '.util_make_link ('/tracker/?atid='. db_result($result, $j, 'group_artifact_id') . '&group_id='.$group_id.'&func=browse',db_result($result, $j, 'name'));
140 $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')) ;
146 // ##################### Forums
148 if ($project->usesForum()) {
152 $return .= '<a href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
153 $return .= html_image("ic/forum20g.png","20","20",array("border"=>"0","alt"=>"Forums"));
154 $return .= ' Forums</a>';
156 if ($mode != 'compact') {
157 $return .= " ( <strong>". project_get_public_forum_message_count($group_id) ."</strong> messages in ";
158 $return .= "<strong>". project_get_public_forum_count($group_id) ."</strong> forums )\n";
162 // ##################### Doc Manager
164 if ($project->usesDocman()) {
168 $return .= '<a href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
169 $return .= html_image("ic/docman16b.png","20","20",array("border"=>"0","alt"=>"Docs"));
170 $return .= ' Doc Manager</a>';
173 // ##################### Mailing lists
175 if ($project->usesMail()) {
179 $return .= '<a href="'.util_make_url ('/mail/?group_id='.$group_id).'">';
180 $return .= html_image("ic/mail16b.png","20","20",array("border"=>"0","alt"=>"Mail Lists"));
181 $return .= ' Mailing Lists</a>';
183 if ($mode != 'compact') {
184 $return .= " ( <strong>". project_get_mail_list_count($group_id) ."</strong> public lists )";
188 // ##################### Tasks
190 if ($project->usesPm()) {
194 $return .= '<a href="'.util_make_url ('/pm/?group_id='.$group_id).'">';
195 $return .= html_image("ic/taskman20g.png","20","20",array("border"=>"0","alt"=>"Tasks"));
196 $return .= ' Task Manager</a>';
198 if ($mode != 'compact') {
199 //get a list of publicly available projects
200 $result = db_query_params ('SELECT * FROM project_group_list WHERE group_id=$1 AND is_public=1',
202 $rows = db_numrows($result);
203 if (!$result || $rows < 1) {
204 $return .= '<br /><em>There are no public subprojects available</em>';
206 for ($j = 0; $j < $rows; $j++) {
208 <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'));
210 db_free_result($result);
215 // ######################### Surveys
217 if ($project->usesSurvey()) {
221 $return .= '<a href="'.util_make_url ('/survey/?group_id='.$group_id).'">';
222 $return .= html_image("ic/survey16b.png","20","20",array("border"=>"0","alt"=>"Surveys"));
223 $return .= " Surveys</a>";
224 if ($mode != 'compact') {
225 $return .= ' ( <strong>'. project_get_survey_count($group_id) .'</strong> surveys )';
229 // ######################### SCM
231 if ($project->usesSCM()) {
235 $return .= '<a href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
236 $return .= html_image("ic/cvs16b.png","20","20",array("border"=>"0","alt"=>"SCM"));
237 $return .= " SCM Tree</a>";
239 if ($mode != 'compact') {
240 $result = db_query_params ('SELECT SUM(commits) AS commits,SUM(adds) AS adds from stats_cvs_group where group_id=$1',
242 $return .= ' ( <strong>'.db_result($result,0,0).'</strong> commits, <strong>'.db_result($result,0,1).'</strong> adds )';
246 // ######################## Released Files
248 if ($project->isActive()) {
252 $return .= '<a href="'.util_make_url ('/project/showfiles.php?group_id='.$group_id).'">';
253 $return .= html_image("ic/ftp16b.png","20","20",array("border"=>"0","alt"=>"FTP"));
254 $return .= " Released Files</a>";
268 // c-file-style: "bsd"