1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
<?php
/**
* project_summary.php
*
* SourceForge: Breaking Down the Barriers to Open Source Development
* Copyright 1999-2001 (c) VA Linux Systems
* http://sourceforge.net
*
* @version $Id: project_summary.php 3116 2004-07-21 23:40:22Z cbayle $
*/
$project_agg_arr=array();
/**
* project_setup_agg() - Set up a project aggregate array.
*
* @param int Group ID
* @access private
*/
function project_setup_agg($group_id) {
global $project_agg_arr,$project_agg_arr_is_set;
$res=db_query("SELECT type, count FROM project_sums_agg WHERE group_id=$group_id");
$rows=db_numrows($res);
if ($res && $rows > 0) {
for ($i=0; $i<$rows; $i++) {
$project_agg_arr[db_result($res,$i,'type')]=db_result($res,$i,'count');
}
}
$project_agg_arr_is_set=true;
}
/**
* project_getaggvalue() - Get a projects aggregate value for a specific type
*
* @param int The group ID
* @param string The type
* @access private
*/
function project_getaggvalue($group_id,$type) {
global $project_agg_arr,$project_agg_arr_is_set;
if (!$project_agg_arr_is_set) {
project_setup_agg($group_id);
}
if ($project_agg_arr[$type]) {
return "$project_agg_arr[$type]";
} else {
return '0';
}
}
/**
* project_get_mail_list_count() - Get the number of mailing lists for a project.
*
* @param int The group ID
*/
function project_get_mail_list_count($group_id) {
return project_getaggvalue($group_id,'mail');
}
/**
* project_get_survey_count() - Get the number of surveys for a project.
*
* @param int The group ID
*/
function project_get_survey_count($group_id) {
return project_getaggvalue($group_id,'surv');
}
/**
* project_get_public_forum_count() - Get the number of public forums for a project.
*
* @param int The group ID
*/
function project_get_public_forum_count($group_id) {
return project_getaggvalue($group_id, 'fora');
}
/**
* project_get_public_forum_message_count() - Get the number of messages within public forums for a project.
*
* @param int The group ID
*/
function project_get_public_forum_message_count($group_id) {
return project_getaggvalue($group_id, 'fmsg');
}
/**
* project_summary() - Build a project summary box that projects can insert into their project pages
*
* @param int The group ID
* @param string How to return the results.
* @param bool Whether to return the results within an HTML table or not
*/
function project_summary($group_id,$mode,$no_table) {
global $Language;
if (!$group_id) {
return 'Error - No Group ID';
}
if (!$mode) {
$mode='full';
}
$project =& group_get_object($group_id);
// ################## forums
if (!$project || !is_object($project)) {
return 'Could Not Create Project Object';
} elseif ($project->isError()) {
return $project->getErrorMessage();
}
if (!$no_table) {
$return .= '
<table border=0 width="100%"><tr><td bgcolor="#EAECEF">';
}
// ################## ArtifactTypes
$return .= '<a href="/tracker/?group_id='.$group_id.'">';
$return .= html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
$return .= ' Tracker</a>';
if ($mode != 'compact') {
$result=db_query("SELECT agl.*,aca.count,aca.open_count
FROM artifact_group_list agl
LEFT JOIN artifact_counts_agg aca USING (group_artifact_id)
WHERE agl.group_id='$group_id'
AND agl.is_public=1
ORDER BY group_artifact_id ASC");
$rows = db_numrows($result);
if (!$result || $rows < 1) {
$return .= '<br /><em>'.$Language->getText('project_home','no_trackers').'</em>';
} else {
for ($j = 0; $j < $rows; $j++) {
$return .= '<p>
- <a href="/tracker/?atid='. db_result($result, $j, 'group_artifact_id') .
'&group_id='.$group_id.'&func=browse">'. db_result($result, $j, 'name') .'</a>
( <strong>'. db_result($result, $j, 'open_count') .' '.$Language->getText('general','open').' / '. db_result($result, $j, 'count') . $Language->getText('general','total').' </strong> )<br />'.
db_result($result, $j, 'description') . '</p>';
}
}
}
// ##################### Doc Manager
if ($project->usesForum()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/forum/?group_id='.$group_id.'">';
$return .= html_image("ic/forum20g.png","20","20",array("border"=>"0","ALT"=>"Forums"));
$return .= ' Forums</a>';
if ($mode != 'compact') {
$return .= " ( <strong>". project_get_public_forum_message_count($group_id) ."</strong> messages in ";
$return .= "<strong>". project_get_public_forum_count($group_id) ."</strong> forums )\n";
}
}
// ##################### Doc Manager
if ($project->usesDocman()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/docman/?group_id='.$group_id.'">';
$return .= html_image("ic/docman16b.png","20","20",array("border"=>"0","alt"=>"Docs"));
$return .= ' Doc Manager</a>';
}
// ##################### Mailing lists
if ($project->usesMail()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/mail/?group_id='.$group_id.'">';
$return .= html_image("ic/mail16b.png","20","20",array("border"=>"0","alt"=>"Mail Lists"));
$return .= ' Mailing Lists</a>';
if ($mode != 'compact') {
$return .= " ( <strong>". project_get_mail_list_count($group_id) ."</strong> public lists )";
}
}
// ##################### Task Manager
if ($project->usesPm()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/pm/?group_id='.$group_id.'">';
$return .= html_image("ic/taskman20g.png","20","20",array("border"=>"0","ALT"=>"Tasks"));
$return .= ' Task Manager</a>';
if ($mode != 'compact') {
//get a list of publicly available projects
$sql="SELECT * FROM project_group_list WHERE group_id='$group_id' AND is_public=1";
$result = db_query ($sql);
$rows = db_numrows($result);
if (!$result || $rows < 1) {
$return .= '<br /><em>There are no public subprojects available</em>';
} else {
for ($j = 0; $j < $rows; $j++) {
$return .= '
<br /> - <a href="/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').'</a>';
}
db_free_result($result);
}
}
}
// ######################### Surveys
if ($project->usesSurvey()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/survey/?group_id='.$group_id.'">';
$return .= html_image("ic/survey16b.png","20","20",array("border"=>"0","alt"=>"Surveys"));
$return .= " Surveys</a>";
if ($mode != 'compact') {
$return .= ' ( <strong>'. project_get_survey_count($group_id) .'</strong> surveys )';
}
}
// ######################### SCM
if ($project->usesSCM()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/scm/?group_id='.$group_id.'">';
$return .= html_image("ic/cvs16b.png","20","20",array("border"=>"0","ALT"=>"SCM"));
$return .= " SCM Tree</a>";
if ($mode != 'compact') {
$sql = "SELECT SUM(commits) AS commits,SUM(adds) AS adds from stats_cvs_group where group_id='$group_id'";
$result = db_query($sql);
$return .= ' ( <strong>'.db_result($result,0,0).'</strong> commits, <strong>'.db_result($result,0,1).'</strong> adds )';
}
}
// ######################## Released Files
if ($project->isActive()) {
$return .= '
<hr size="1" />';
$return .= '<a href="/project/showfiles.php?group_id='.$group_id.'">';
$return .= html_image("ic/ftp16b.png","20","20",array("border"=>"0","alt"=>"FTP"));
$return .= " Released Files</a>";
}
if (!$no_table) {
$return .= '
</td></tr></table>';
}
return $return;
}
?>
|