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');
127 $ids[] = 'docgroupnew';
128 $texts[] = _('New Directories');
131 if (count($show) < 1) {
137 $res = db_query_params('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
138 AND group_id = $3 AND section = ANY ($4) ORDER BY activity_date DESC',
142 db_string_array_to_any_clause($section)));
145 exit_error(db_error(), 'home');
149 while ($arr = db_fetch_array($res)) {
153 // If plugins wants to add activities.
154 $hookParams['group'] = $group_id;
155 $hookParams['results'] = &$results;
156 $hookParams['show'] = &$show;
157 $hookParams['begin'] = $begin;
158 $hookParams['end'] = $end;
159 $hookParams['ids'] = &$ids;
160 $hookParams['texts'] = &$texts;
161 plugin_hook("activity", $hookParams);
163 if (count($show) < 1) {
167 foreach ($show as $showthis) {
168 if (array_search($showthis, $ids) === false) {
169 exit_error(_('Invalid Data Passed to query'), 'home');
172 $multiselect = html_build_multiple_select_box_from_arrays($ids, $texts, 'show[]', $show, count($texts), false);
175 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
176 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
179 <td><strong><?php echo _('Activity') ?></strong></td>
180 <td><strong><?php echo _('Start') ?></strong></td>
181 <td><strong><?php echo _('End') ?></strong></td>
185 <td><?php echo $multiselect; ?></td>
186 <td class="top"><input name="start_date"
187 value="<?php echo $rendered_begin; ?>" size="10" maxlength="10" /></td>
188 <td class="top"><input name="end_date"
189 value="<?php echo $rendered_end; ?>" size="10" maxlength="10" /></td>
191 <input type="submit" name="submit" value="<?php echo _('Submit'); ?>" />
197 if (count($results) < 1) {
198 echo '<p class="information">' . _('No Activity Found') . '</p>';
201 function date_compare($a, $b)
203 if ($a['activity_date'] == $b['activity_date']) {
206 return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
209 $cached_perms = array();
210 function check_perm_for_activity($arr) {
211 global $cached_perms;
212 $s = $arr['section'];
213 $ref = $arr['ref_id'];
214 $group_id = $arr['group_id'];
216 if (!isset($cached_perms[$s][$ref])) {
219 $cached_perms[$s][$ref] = forge_check_perm('scm', $ref, 'read');
224 case 'trackerclose': {
225 $cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read');
229 $cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read');
234 $cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
239 case 'docgroupnew': {
240 $cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
244 // Must be a bug somewhere, we're supposed to handle all types
245 $cached_perms[$s][$ref] = false;
249 return $cached_perms[$s][$ref];
252 usort($results, 'date_compare');
255 $theader[] = _('Time');
256 $theader[] = _('Activity');
257 $theader[] = _('By');
260 echo $HTML->listTableTop($theader);
264 foreach ($results as $arr) {
265 if (!check_perm_for_activity($arr)) {
268 if ($last_day != strftime($date_format, $arr['activity_date'])) {
269 // echo $HTML->listTableBottom($theader);
270 echo '<tr class="tableheading"><td colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
271 // echo $HTML->listTableTop($theader);
272 $last_day=strftime($date_format, $arr['activity_date']);
274 switch (@$arr['section']) {
276 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
277 $url = util_make_link('/scm/'.$arr['ref_id'].$arr['subref_id'],_('scm commit: ').$arr['description']);
281 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Source Code'));
282 $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']);
285 case 'trackeropen': {
286 $icon = html_image('ic/tracker20g.png','','',array('alt'=>'Trackers'));
287 $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'));
290 case 'trackerclose': {
291 $icon = html_image('ic/tracker20g.png','','',array('alt'=>'Trackers'));
292 $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'));
296 $icon = html_image('ic/cvs16b.png','','',array('alt'=>'Files'));
297 $url = util_make_link('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
301 $icon = html_image('ic/forum20g.png','','',array("alt"=>'Forum'));
302 $url = util_make_link('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
306 $icon = html_image('ic/write16w.png','','',array('alt'=>'News'));
307 $url = util_make_link('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
311 case 'docmanupdate': {
312 $icon = html_image("ic/docman16b.png", '', '', array("alt"=>"Documents"));
313 $url = util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['ref_id'],_('Document').' '.$arr['description']);
316 case 'docgroupnew': {
317 $icon = html_image("ic/cfolder15.png", '', '', array("alt"=>"Directory"));
318 $url = util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['subref_id'],_('Directory').' '.$arr['description']);
322 $icon = isset($arr['icon']) ? $arr['icon'] : '';
323 $url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
326 echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
327 <td>'.date('H:i:s',$arr['activity_date']).'</td>
328 <td>'.$icon .' '.$url.'</td><td>';
329 if (isset($arr['user_name']) && $arr['user_name']) {
330 echo util_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
332 echo $arr['realname'];
336 echo $HTML->listTableBottom($theader);
339 site_project_footer(array());