5 * SourceForge: Breaking Down the Barriers to Open Source Development
6 * Copyright 1999-2001 (c) VA Linux Systems
7 * http://sourceforge.net
12 $project_agg_arr=array();
15 * project_setup_agg() - Set up a project aggregate array.
20 function project_setup_agg($group_id) {
21 global $project_agg_arr,$project_agg_arr_is_set;
22 $res=db_query("SELECT type, count FROM project_sums_agg WHERE group_id=$group_id");
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("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='$group_id'
129 ORDER BY group_artifact_id ASC");
131 $rows = db_numrows($result);
133 if (!$result || $rows < 1) {
134 $return .= '<br /><em>'._('There are no public trackers available').'</em>';
136 for ($j = 0; $j < $rows; $j++) {
138 - '.util_make_link ('/tracker/?atid='. db_result($result, $j, 'group_artifact_id') . '&group_id='.$group_id.'&func=browse',db_result($result, $j, 'name'));
139 $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')) ;
145 // ##################### Forums
147 if ($project->usesForum()) {
151 $return .= '<a href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
152 $return .= html_image("ic/forum20g.png","20","20",array("border"=>"0","ALT"=>"Forums"));
153 $return .= ' Forums</a>';
155 if ($mode != 'compact') {
156 $return .= " ( <strong>". project_get_public_forum_message_count($group_id) ."</strong> messages in ";
157 $return .= "<strong>". project_get_public_forum_count($group_id) ."</strong> forums )\n";
161 // ##################### Doc Manager
163 if ($project->usesDocman()) {
167 $return .= '<a href="'.util_make_url ('/docman/?group_id='.$group_id).'">';
168 $return .= html_image("ic/docman16b.png","20","20",array("border"=>"0","alt"=>"Docs"));
169 $return .= ' Doc Manager</a>';
172 // ##################### Mailing lists
174 if ($project->usesMail()) {
178 $return .= '<a href="'.util_make_url ('/mail/?group_id='.$group_id).'">';
179 $return .= html_image("ic/mail16b.png","20","20",array("border"=>"0","alt"=>"Mail Lists"));
180 $return .= ' Mailing Lists</a>';
182 if ($mode != 'compact') {
183 $return .= " ( <strong>". project_get_mail_list_count($group_id) ."</strong> public lists )";
187 // ##################### Task Manager
189 if ($project->usesPm()) {
193 $return .= '<a href="'.util_make_url ('/pm/?group_id='.$group_id).'">';
194 $return .= html_image("ic/taskman20g.png","20","20",array("border"=>"0","ALT"=>"Tasks"));
195 $return .= ' Task Manager</a>';
197 if ($mode != 'compact') {
198 //get a list of publicly available projects
199 $sql="SELECT * FROM project_group_list WHERE group_id='$group_id' AND is_public=1";
200 $result = db_query ($sql);
201 $rows = db_numrows($result);
202 if (!$result || $rows < 1) {
203 $return .= '<br /><em>There are no public subprojects available</em>';
205 for ($j = 0; $j < $rows; $j++) {
207 <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'));
209 db_free_result($result);
214 // ######################### Surveys
216 if ($project->usesSurvey()) {
220 $return .= '<a href="'.util_make_url ('/survey/?group_id='.$group_id).'">';
221 $return .= html_image("ic/survey16b.png","20","20",array("border"=>"0","alt"=>"Surveys"));
222 $return .= " Surveys</a>";
223 if ($mode != 'compact') {
224 $return .= ' ( <strong>'. project_get_survey_count($group_id) .'</strong> surveys )';
228 // ######################### SCM
230 if ($project->usesSCM()) {
234 $return .= '<a href="'.util_make_url ('/scm/?group_id='.$group_id).'">';
235 $return .= html_image("ic/cvs16b.png","20","20",array("border"=>"0","ALT"=>"SCM"));
236 $return .= " SCM Tree</a>";
238 if ($mode != 'compact') {
239 $sql = "SELECT SUM(commits) AS commits,SUM(adds) AS adds from stats_cvs_group where group_id='$group_id'";
240 $result = db_query($sql);
241 $return .= ' ( <strong>'.db_result($result,0,0).'</strong> commits, <strong>'.db_result($result,0,1).'</strong> adds )';
245 // ######################## Released Files
247 if ($project->isActive()) {
251 $return .= '<a href="'.util_make_url ('/project/showfiles.php?group_id='.$group_id).'">';
252 $return .= html_image("ic/ftp16b.png","20","20",array("border"=>"0","alt"=>"FTP"));
253 $return .= " Released Files</a>";
267 // c-file-style: "bsd"