3 * Project Activity Page
6 * Copyright 2006 (c) GForge, LLC
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2012, Franck Villaume - TrivialDev
9 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
10 * http://fusionforge.org/
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 require_once('../env.inc.php');
29 require_once $gfcommon.'include/pre.php';
31 $group_id = getIntFromRequest("group_id");
32 $received_begin = getStringFromRequest("start_date");
33 $received_end = getStringFromRequest("end_date");
34 $show = getArrayFromRequest("show");
36 session_require_perm('project_read', $group_id);
38 $date_format = _('%Y-%m-%d');
40 if (!$received_begin || $received_begin==0) {
41 $begin = (time()-(30*86400));
42 $rendered_begin = strftime($date_format, $begin);
44 $tmp = strptime($received_begin, $date_format);
46 $begin = (time()-(30*86400));
47 $rendered_begin = strftime($date_format, $begin);
49 $begin = mktime(0, 0, 0, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
50 $rendered_begin = $received_begin;
54 if (!$received_end || $received_end == 0) {
56 $rendered_end = strftime($date_format, $end);
58 $tmp = strptime($received_end, $date_format);
61 $rendered_end = strftime($date_format, $end);
63 $end = mktime(0, 0, 0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year'] + 1900);
64 $rendered_end = $received_end;
73 $rendered_end = $rendered_begin;
74 $rendered_begin = $tmp;
80 $group = group_get_object($group_id);
81 if (!$group || !is_object($group)) {
83 } elseif ($group->isError()) {
84 exit_error($group->getErrorMessage(), 'home');
85 } elseif (!forge_get_config('use_activity')) {
87 } elseif (!$group->usesActivity()) {
88 exit_project_disabled();
91 site_project_header(array('title'=>_('Activity'), 'group'=>$group_id, 'toptab'=>'activity'));
96 if (forge_get_config('use_forum') && $group->usesForum()) {
98 $texts[] = _('Forum Post');
101 if (forge_get_config('use_tracker') && $group->usesTracker()) {
102 // These lines are currently commented due to lack of explanations.
103 // We need to enable these lines only if you use the commit tracker plugin I suppose.
104 // $ids[] = 'commit';
105 // $texts[] = _('Commit Tracking');
106 $ids[] = 'trackeropen';
107 $texts[] = _('Tracker Opened');
108 $ids[] = 'trackerclose';
109 $texts[] = _('Tracker Closed');
112 if (forge_get_config('use_news') && $group->usesNews()) {
114 $texts[] = _('News');
117 if (forge_get_config('use_frs') && $group->usesFRS()) {
118 $ids[] = 'frsrelease';
119 $texts[] = _('FRS Release');
122 if (forge_get_config('use_docman') && $group->usesDocman()) {
123 $ids[] = 'docmannew';
124 $texts[] = _('New Documents');
125 $ids[] = 'docmanupdate';
126 $texts[] = _('Updated Documents');
129 if (count($show) < 1) {
135 $res = db_query_params('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
136 AND group_id = $3 AND section = ANY ($4) ORDER BY activity_date DESC',
140 db_string_array_to_any_clause($section)));
143 exit_error(db_error(), 'home');
147 while ($arr = db_fetch_array($res)) {
151 // If plugins wants to add activities.
152 $hookParams['group'] = $group_id;
153 $hookParams['results'] = &$results;
154 $hookParams['show'] = &$show;
155 $hookParams['begin'] = $begin;
156 $hookParams['end'] = $end;
157 $hookParams['ids'] = &$ids;
158 $hookParams['texts'] = &$texts;
159 plugin_hook("activity", $hookParams);
161 if (count($show) < 1) {
165 foreach ($show as $showthis) {
166 if (array_search($showthis, $ids) === false) {
167 exit_error(_('Invalid Data Passed to query'), 'home');
170 $multiselect = html_build_multiple_select_box_from_arrays($ids, $texts, 'show[]', $show, count($texts), false);
173 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
174 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
177 <td><strong><?php echo _('Activity') ?></strong></td>
178 <td><strong><?php echo _('Start') ?></strong></td>
179 <td><strong><?php echo _('End') ?></strong></td>
183 <td><?php echo $multiselect; ?></td>
184 <td class="top"><input name="start_date"
185 value="<?php echo $rendered_begin; ?>" size="10" maxlength="10" /></td>
186 <td class="top"><input name="end_date"
187 value="<?php echo $rendered_end; ?>" size="10" maxlength="10" /></td>
189 <input type="submit" name="submit" value="<?php echo _('Submit'); ?>" />
195 if (count($results) < 1) {
196 echo '<p class="information">' . _('No Activity Found') . '</p>';
199 function date_compare($a, $b)
201 if ($a['activity_date'] == $b['activity_date']) {
204 return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
207 $cached_perms = array();
208 function check_perm_for_activity($arr) {
209 global $cached_perms;
210 $s = $arr['section'];
211 $ref = $arr['ref_id'];
212 $group_id = $arr['group_id'];
214 if (!isset($cached_perms[$s][$ref])) {
217 $cached_perms[$s][$ref] = forge_check_perm('scm', $ref, 'read');
222 case 'trackerclose': {
223 $cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read');
227 $cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read');
232 $cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
236 case 'docmanupdate': {
237 $cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
241 // Must be a bug somewhere, we're supposed to handle all types
242 $cached_perms[$s][$ref] = false;
246 return $cached_perms[$s][$ref];
249 usort($results, 'date_compare');
252 $theader[] = _('Time');
253 $theader[] = _('Activity');
254 $theader[] = _('By');
257 echo $HTML->listTableTop($theader);
261 foreach ($results as $arr) {
262 if (!check_perm_for_activity($arr)) {
265 if ($last_day != strftime($date_format, $arr['activity_date'])) {
266 // echo $HTML->listTableBottom($theader);
267 echo '<tr class="tableheading"><td colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
268 // echo $HTML->listTableTop($theader);
269 $last_day=strftime($date_format, $arr['activity_date']);
271 switch (@$arr['section']) {
273 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
274 $url = util_make_link('/scm/'.$arr['ref_id'].$arr['subref_id'],_('scm commit: ').$arr['description']);
278 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
279 $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']);
282 case 'trackeropen': {
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'].' '._('Opened'));
287 case 'trackerclose': {
288 $icon = html_image('ic/tracker20g.png','','',array('alt'=>'Trackers'));
289 $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'));
293 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Files'));
294 $url = util_make_link('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
298 $icon = html_image('ic/forum20g.png','','',array("alt"=>'Forum'));
299 $url = util_make_link('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
303 $icon = html_image('ic/write16w.png','','',array('alt'=>'News'));
304 $url = util_make_link('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
308 case 'docmanupdate': {
309 $icon = html_image("ic/docman16b.png", '', '', array("alt"=>"Documents"));
310 $url = util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['ref_id'],_('Document').' '.$arr['description']);
314 $icon = isset($arr['icon']) ? $arr['icon'] : '';
315 $url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
318 echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
319 <td>'.date('H:i:s',$arr['activity_date']).'</td>
320 <td>'.$icon .' '.$url.'</td><td>';
321 if (isset($arr['user_name']) && $arr['user_name']) {
322 echo util_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
324 echo $arr['realname'];
328 echo $HTML->listTableBottom($theader);
331 site_project_footer(array());