3 * Project Activity Page
6 * Copyright 2006 (c) GForge, LLC
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2012, Franck Villaume - TrivialDev
9 * http://fusionforge.org/
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once('../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
30 $group_id = getIntFromRequest("group_id");
31 $received_begin = getStringFromRequest("start_date");
32 $received_end = getStringFromRequest("end_date");
33 $show = getArrayFromRequest("show");
35 session_require_perm('project_read', $group_id);
37 $date_format = _('%Y-%m-%d');
39 if (!$received_begin || $received_begin==0) {
40 $begin = (time()-(30*86400));
41 $rendered_begin = strftime($date_format, $begin);
43 $tmp = strptime($received_begin, $date_format);
45 $begin = (time()-(30*86400));
46 $rendered_begin = strftime($date_format, $begin);
48 $begin = mktime(0, 0, 0, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
49 $rendered_begin = $received_begin;
53 if (!$received_end || $received_end == 0) {
55 $rendered_end = strftime($date_format, $end);
57 $tmp = strptime($received_end, $date_format);
60 $rendered_end = strftime($date_format, $end);
62 $end = mktime(0, 0, 0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year'] + 1900);
63 $rendered_end = $received_end;
72 $rendered_end = $rendered_begin;
73 $rendered_begin = $tmp;
79 $group = group_get_object($group_id);
80 if (!$group || !is_object($group)) {
82 } elseif ($group->isError()) {
83 exit_error($group->getErrorMessage(), 'home');
86 site_project_header(array('title'=>_('Activity'), 'group'=>$group_id, 'toptab'=>'activity'));
91 if (forge_get_config('use_forum') && $group->usesForum()) {
93 $texts[] = _('Forum Post');
96 if (forge_get_config('use_tracker') && $group->usesTracker()) {
97 // These lines are currently commented due to lack of explanations.
98 // We need to enable these lines only if you use the commit tracker plugin I suppose.
100 // $texts[] = _('Commit Tracking');
101 $ids[] = 'trackeropen';
102 $texts[] = _('Tracker Opened');
103 $ids[] = 'trackerclose';
104 $texts[] = _('Tracker Closed');
107 if (forge_get_config('use_news') && $group->usesNews()) {
109 $texts[] = _('News');
112 if (forge_get_config('use_frs') && $group->usesFRS()) {
113 $ids[] = 'frsrelease';
114 $texts[] = _('FRS Release');
117 if (forge_get_config('use_docman') && $group->usesDocman()) {
118 $ids[] = 'docmannew';
119 $texts[] = _('New Documents');
120 $ids[] = 'docmanupdate';
121 $texts[] = _('Updated Documents');
124 if (count($show) < 1) {
130 $res = db_query_params('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
131 AND group_id = $3 AND section = ANY ($4) ORDER BY activity_date DESC',
135 db_string_array_to_any_clause($section)));
138 exit_error(db_error(), 'home');
142 while ($arr = db_fetch_array($res)) {
146 // If plugins wants to add activities.
147 $hookParams['group'] = $group_id;
148 $hookParams['results'] = &$results;
149 $hookParams['show'] = &$show;
150 $hookParams['begin'] = $begin;
151 $hookParams['end'] = $end;
152 $hookParams['ids'] = &$ids;
153 $hookParams['texts'] = &$texts;
154 plugin_hook("activity", $hookParams);
156 if (count($show) < 1) {
160 foreach ($show as $showthis) {
161 if (array_search($showthis, $ids) === false) {
162 exit_error(_('Invalid Data Passed to query'), 'home');
165 $multiselect = html_build_multiple_select_box_from_arrays($ids, $texts, 'show[]', $show, count($texts), false);
168 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
169 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
172 <td><strong><?php echo _('Activity') ?></strong></td>
173 <td><strong><?php echo _('Start') ?></strong></td>
174 <td><strong><?php echo _('End') ?></strong></td>
178 <td><?php echo $multiselect; ?></td>
179 <td class="top"><input name="start_date"
180 value="<?php echo $rendered_begin; ?>" size="10" maxlength="10" /></td>
181 <td class="top"><input name="end_date"
182 value="<?php echo $rendered_end; ?>" size="10" maxlength="10" /></td>
184 <input type="submit" name="submit" value="<?php echo _('Submit'); ?>" />
190 if (count($results) < 1) {
191 echo '<p class="information">' . _('No Activity Found') . '</p>';
194 function date_compare($a, $b)
196 if ($a['activity_date'] == $b['activity_date']) {
199 return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
202 $cached_perms = array();
203 function check_perm_for_activity($arr) {
204 global $cached_perms;
205 $s = $arr['section'];
206 $ref = $arr['ref_id'];
207 $group_id = $arr['group_id'];
209 if (!isset($cached_perms[$s][$ref])) {
212 $cached_perms[$s][$ref] = forge_check_perm('scm', $ref, 'read');
217 case 'trackerclose': {
218 $cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read');
222 $cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read');
227 $cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
231 case 'docmanupdate': {
232 $cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
236 // Must be a bug somewhere, we're supposed to handle all types
237 $cached_perms[$s][$ref] = false;
241 return $cached_perms[$s][$ref];
244 usort($results, 'date_compare');
247 $theader[] = _('Time');
248 $theader[] = _('Activity');
249 $theader[] = _('By');
252 echo $HTML->listTableTop($theader);
256 foreach ($results as $arr) {
257 if (!check_perm_for_activity($arr)) {
260 if ($last_day != strftime($date_format, $arr['activity_date'])) {
261 // echo $HTML->listTableBottom($theader);
262 echo '<tr class="tableheading"><td colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
263 // echo $HTML->listTableTop($theader);
264 $last_day=strftime($date_format, $arr['activity_date']);
266 switch (@$arr['section']) {
268 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
269 $url = util_make_link('/scm/'.$arr['ref_id'].$arr['subref_id'],_('scm commit: ').$arr['description']);
273 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
274 $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']);
277 case 'trackeropen': {
278 $icon = html_image('ic/tracker20g.png','','',array('alt'=>'Trackers'));
279 $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'));
282 case 'trackerclose': {
283 $icon = html_image('ic/tracker20g.png','','',array('alt'=>'Trackers'));
284 $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'));
288 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Files'));
289 $url = util_make_link('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
293 $icon = html_image('ic/forum20g.png','','',array("alt"=>'Forum'));
294 $url = util_make_link('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
298 $icon = html_image('ic/write16w.png','','',array('alt'=>'News'));
299 $url = util_make_link('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
303 case 'docmanupdate': {
304 $icon = html_image("ic/docman16b.png", '', '', array("alt"=>"Documents"));
305 $url = util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['ref_id'],_('Document').' '.$arr['description']);
309 $icon = isset($arr['icon']) ? $arr['icon'] : '';
310 $url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
313 echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
314 <td>'.date('H:i:s',$arr['activity_date']).'</td>
315 <td>'.$icon .' '.$url.'</td><td>';
316 if (isset($arr['user_name']) && $arr['user_name']) {
317 echo util_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
319 echo $arr['realname'];
323 echo $HTML->listTableBottom($theader);
326 site_project_footer(array());