* Copyright 2006 (c) GForge, LLC
* http://gforge.org
*
- * @version $Id$
*/
require_once('../env.inc.php');
-require_once('pre.php');
+require_once $gfwww.'include/pre.php';
/*
- Project Summary Page
- Written by dtype Oct. 1999
-*/
+ Project Summary Page
+ Written by dtype Oct. 1999
+ */
$group_id = getIntFromRequest("group_id");
-$begin = getStringFromRequest("start_date");
-$end = getStringFromRequest("end_date");
+$received_begin = getStringFromRequest("start_date");
+$received_end = getStringFromRequest("end_date");
$show=getArrayFromRequest("show");
-if (!$begin || $begin==0) {
+$date_format = _('%Y-%m-%d') ;
+
+if (!$received_begin || $received_begin==0) {
$begin = (time()-(30*86400));
+ $rendered_begin = strftime($date_format, $begin) ;
} else {
- $begin = strtotime($begin);
+ $tmp = strptime ($received_begin, $date_format);
+ if (!$tmp) {
+ $begin = (time()-(30*86400));
+ $rendered_begin = strftime($date_format, $begin) ;
+ } else {
+ $begin = mktime (0,0,0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year']);
+ $rendered_begin = $received_begin ;
+ }
}
-if (!$end || $end==0) {
- $end = time();
+
+if (!$received_end || $received_end==0) {
+ $end = time() ;
+ $rendered_end = strftime($date_format, $end) ;
} else {
- $end=strtotime($end)+86400;
+ $tmp = strptime ($received_end, $date_format);
+ if (!$tmp) {
+ $end = time() ;
+ $rendered_end = strftime($date_format, $end) ;
+ } else {
+ $end = mktime (0,0,0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year']) + 86400;
+ $rendered_end = $received_end ;
+ }
}
+
if ($begin > $end) {
- $endtmp=$end;
+ $tmp=$end;
$end=$begin;
- $begin=$endtmp;
+ $begin=$tmp;
+ $tmp=$rendered_end;
+ $rendered_end=$rendered_begin;
+ $rendered_begin=$tmp;
}
+
if (!$group_id) {
exit_no_group();
}
$ids=array();
$texts=array();
-if ($GLOBALS['sys_use_forum']) {
+if ($GLOBALS['sys_use_forum'] && $group->usesForum ()) {
$ids[]='forumpost';
$texts[]=_('Forum Post');
}
-if ($GLOBALS['sys_use_tracker']) {
+if ($GLOBALS['sys_use_tracker'] && $group->usesTracker ()) {
$ids[]='trackeropen';
$texts[]=_('Tracker Opened');
$ids[]='trackerclose';
$texts[]=_('Tracker Closed');
}
-if ($GLOBALS['sys_use_news']) {
+if ($GLOBALS['sys_use_news'] && $group->usesNews ()) {
$ids[]='news';
$texts[]=_('News');
}
-if ($GLOBALS['sys_use_scm']) {
+if ($GLOBALS['sys_use_scm'] && $group->usesSCM ()) {
$ids[]='commit';
$texts[]=_('Commits');
}
-if ($GLOBALS['sys_use_frs']) {
+if ($GLOBALS['sys_use_frs'] && $group->usesFRS ()) {
$ids[]='frsrelease';
$texts[]=_('FRS Release');
}
+if (count($show) < 1) {
+ $section=$ids;
+} else {
+ $section=$show;
+}
+
+
+$res=db_query_params ('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
+ AND group_id=$3 AND section = ANY ($4) ORDER BY activity_date DESC',
+ array($begin,
+ $end,
+ $group_id,
+ db_string_array_to_any_clause ($section)));
+echo db_error();
+
+$results = array();
+while ($arr =& db_fetch_array($res)) {
+ $results[] = $arr;
+}
+
+// If plugins wants to add activities.
+$hookParams['group'] = $group_id ;
+$hookParams['results'] = &$results;
+$hookParams['show'] = &$show;
+$hookParams['begin'] = $begin;
+$hookParams['end'] = $end;
+$hookParams['ids'] = &$ids;
+$hookParams['texts'] = &$texts;
+plugin_hook ("activity", $hookParams) ;
+
if (count($show) < 1) {
$show=$ids;
}
}
$multiselect=html_build_multiple_select_box_from_arrays($ids,$texts,'show[]',$show,5,false);
-$sql="SELECT * FROM activity_vw WHERE activity_date BETWEEN '".$begin."' AND '".$end."'
- AND group_id='$group_id' AND section IN ('".implode("','",$show)."') ORDER BY activity_date DESC";
-//echo $sql;
-$res=db_query($sql);
-echo db_error();
-
-$rows=db_numrows($res);
-if ($rows<1) {
- echo _('No Activity Found');
-} else {
-
- ?>
+?>
<br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<input type="hidden" name="group_id" value="<?php echo $group_id; ?>"/>
+<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
<table border="0" cellspacing="0" cellpadding="3">
-<tr>
- <td><strong><?php echo _('Activity') ?></strong></td>
- <td><strong><?php echo _('Start') ?></strong></td>
- <td><strong><?php echo _('End') ?></strong></td>
- <td></td>
-</tr>
-<tr>
- <td><?php echo $multiselect; ?></td>
- <td valign="top"><input name="start_date" value="<?php echo date(_('Y-m-d'),$begin); ?>" size="10" maxlength="10" /></td>
- <td valign="top"><input name="end_date" value="<?php echo date(_('Y-m-d'),$end); ?>" size="10" maxlength="10" /></td>
- <td valign="top"><input type="submit" name="submit" value="Submit"/></td>
-</tr>
+ <tr>
+ <td><strong><?php echo _('Activity') ?></strong></td>
+ <td><strong><?php echo _('Start') ?></strong></td>
+ <td><strong><?php echo _('End') ?></strong></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td><?php echo $multiselect; ?></td>
+ <td valign="top"><input name="start_date"
+ value="<?php echo $rendered_begin; ?>" size="10" maxlength="10" /></td>
+ <td valign="top"><input name="end_date"
+ value="<?php echo $rendered_end; ?>" size="10" maxlength="10" /></td>
+ <td valign="top"><input type="submit" name="submit"
+ value="<?php echo _('Submit'); ?>" /></td>
+ </tr>
</table>
</form>
+<?php
+if (count($results)<1) {
+ echo _('No Activity Found');
+} else {
+
+ function date_compare($a, $b)
+ {
+ if ($a['activity_date'] == $b['activity_date']) {
+ return 0;
+ }
+ return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
+ }
+
+ usort($results, 'date_compare');
+
+ ?>
<br />
<?php
- $theader=array();
- $theader[]=_('Time');
- $theader[]=_('Activity');
- $theader[]=_('By');
-
- echo $HTML->listTableTop($theader);
-
- $j=0;
- $last_day = 0;
- while ($arr =& db_fetch_array($res)) {
- if ($last_day != date('Y-M-d',$arr['activity_date'])) {
- // echo $HTML->listTableBottom($theader);
- echo '<tr class="tableheading"><td colspan="3">'.date(_('Y-m-d'),$arr['activity_date']).'</td></tr>';
- // echo $HTML->listTableTop($theader);
- $last_day=date('Y-M-d',$arr['activity_date']);
- }
- switch ($arr['section']) {
- case 'commit': {
- $icon=html_image("ic/cvs16b.png","20","20",array("border"=>"0","alt"=>"SCM"));
- $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Commit for Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description']);
- break;
- }
- case 'trackeropen': {
- $icon=html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
- $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Tracker Item').' [#'.$arr['subref_id'].' '.$arr['description'].' ] '._('Opened'));
- break;
- }
- case 'trackerclose': {
- $icon=html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
- $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Tracker Item').' [#'.$arr['subref_id'].' '.$arr['description'].' ] '._('Closed'));
- break;
- }
- case 'frsrelease': {
- $icon=html_image("ic/cvs16b.png","20","20",array("border"=>"0","alt"=>"SCM"));
- $url=util_make_link ('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
- break;
+
+ $res=db_query_params ('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
+ AND group_id=$3 AND section = ANY ($4) ORDER BY activity_date DESC',
+ array($begin,
+ $end,
+ $group_id,
+ db_string_array_to_any_clause ($show)));
+ echo db_error();
+
+ $rows=db_numrows($res);
+ if ($rows<1) {
+ echo _('No Activity Found');
+ } else {
+
+ $theader=array();
+ $theader[]=_('Time');
+ $theader[]=_('Activity');
+ $theader[]=_('By');
+
+ echo $HTML->listTableTop($theader);
+
+ $j=0;
+ $last_day = 0;
+ foreach ($results as $arr) {
+ if ($last_day != strftime($date_format,$arr['activity_date'])) {
+ // echo $HTML->listTableBottom($theader);
+ echo '<tr class="tableheading"><td colspan="3">'.strftime($date_format,$arr['activity_date']).'</td></tr>';
+ // echo $HTML->listTableTop($theader);
+ $last_day=strftime($date_format,$arr['activity_date']);
}
- case 'forumpost': {
- $icon=html_image("ic/forum20g.png","20","20",array("border"=>"0","alt"=>"Forum"));
- $url=util_make_link ('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
- break;
+ switch ($arr['section']) {
+ case 'commit': {
+ $icon=html_image("ic/cvs16b.png","20","20",array("border"=>"0","alt"=>"SCM"));
+ $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Commit for Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description']);
+ break;
+ }
+ case 'trackeropen': {
+ $icon=html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
+ $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Tracker Item').' [#'.$arr['subref_id'].' '.$arr['description'].' ] '._('Opened'));
+ break;
+ }
+ case 'trackerclose': {
+ $icon=html_image("ic/tracker20g.png",'20','20',array('alt'=>'Tracker'));
+ $url=util_make_link ('/tracker/?func=detail&atid='.$arr['ref_id'].'&aid='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Tracker Item').' [#'.$arr['subref_id'].' '.$arr['description'].' ] '._('Closed'));
+ break;
+ }
+ case 'frsrelease': {
+ $icon=html_image("ic/cvs16b.png","20","20",array("border"=>"0","alt"=>"SCM"));
+ $url=util_make_link ('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
+ break;
+ }
+ case 'forumpost': {
+ $icon=html_image("ic/forum20g.png","20","20",array("border"=>"0","alt"=>"Forum"));
+ $url=util_make_link ('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
+ break;
+ }
+ case 'news': {
+ $icon=html_image("ic/write16w.png","20","20",array("border"=>"0","alt"=>"News"));
+ $url=util_make_link ('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
+ break;
+ }
+ default: {
+ $icon = isset($arr['icon']) ? $arr['icon'] : '';
+ $url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
+ }
+
}
- case 'news': {
- $icon=html_image("ic/write16w.png","20","20",array("border"=>"0","alt"=>"News"));
- $url=util_make_link ('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
- break;
+ echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
+ <td> '.date('H:i:s',$arr['activity_date']).'</td>
+ <td>'.$icon .' '.$url.'</td><td>';
+ if (isset($arr['user_name']) && $arr['user_name']) {
+ echo util_make_link_u($arr['user_name'],$arr['user_id'],$arr['realname']);
+ } else {
+ echo $arr['realname'];
}
+ echo '</td></tr>';
}
- if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
- $userlink='/developer/?user_id='.$arr['user_id'];
- } else {
- $userlink='/users/'.$arr['user_name'].'/';
- }
- echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
- <td> '.date('H:i:s',$arr['activity_date']).'</td>
- <td>'.$icon .' '.$url.'</td>
- <td>'.util_make_link ($userlink,$arr['realname']).'</td>
- </tr>';
- }
-
- echo $HTML->listTableBottom($theader);
+ echo $HTML->listTableBottom($theader);
+ }
}
site_project_footer(array());