[Fusionforge-commits] r12152 - in trunk/src: db www/activity

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Fri Feb 4 14:12:28 CET 2011


Author: nerville
Date: 2011-02-04 14:12:28 +0100 (Fri, 04 Feb 2011)
New Revision: 12152

Added:
   trunk/src/db/20110211-docman-activityvw.sql
Modified:
   trunk/src/www/activity/index.php
Log:
add docman in activity

Added: trunk/src/db/20110211-docman-activityvw.sql
===================================================================
--- trunk/src/db/20110211-docman-activityvw.sql	                        (rev 0)
+++ trunk/src/db/20110211-docman-activityvw.sql	2011-02-04 13:12:28 UTC (rev 12152)
@@ -0,0 +1,4 @@
+DROP VIEW activity_vw;
+CREATE VIEW activity_vw AS
+    ((((SELECT agl.group_id, 'trackeropen'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, a.summary AS description, a.open_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), users u WHERE (u.user_id = a.submitted_by) UNION SELECT agl.group_id, 'trackerclose'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, a.summary AS description, a.close_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), users u WHERE ((u.user_id = a.assigned_to) AND (a.close_date > 0))) UNION SELECT agl.group_id, 'commit'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, pcdm.log_text AS description, pcdm.cvs_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), plugin_cvstracker_data_master pcdm, plugin_cvstracker_data_artifact pcda, users u WHERE (((pcdm.holder_id = pcda.id) AND (pcda.group_artifact_id = a.artifact_id)) AND (u.user_name = pcdm.author))) UNION SELECT frsp.group_id, 'frsrelease'::text AS section, frsp.package_id AS ref_id, frsr.release_id AS subref_id, frsr.name AS description, frsr.release_date AS activity_date, u.user_id, u.user_name, u.realname FROM (frs_package frsp JOIN frs_release frsr USING (package_id)), users u WHERE (u.user_id = frsr.released_by)) UNION SELECT fgl.group_id, 'forumpost'::text AS section, fgl.group_forum_id AS ref_id, forum.msg_id AS subref_id, forum.subject AS description, forum.post_date AS activity_date, u.user_id, u.user_name, u.realname FROM (forum_group_list fgl JOIN forum USING (group_forum_id)), users u WHERE (u.user_id = forum.posted_by)) UNION select group_id, 'docmannew'::text AS section, doc_group AS ref_id, docid AS subref_id, filename AS description, createdate AS activity_date, created_by as user_id , user_name, realname FROM docdata_vw;
+

Modified: trunk/src/www/activity/index.php
===================================================================
--- trunk/src/www/activity/index.php	2011-02-04 13:03:26 UTC (rev 12151)
+++ trunk/src/www/activity/index.php	2011-02-04 13:12:28 UTC (rev 12152)
@@ -4,7 +4,7 @@
  *
  * Copyright 1999 dtype
  * Copyright 2006 (c) GForge, LLC
- * Copyright 2010 (c) Franck Villaume
+ * Copyright 2010-2011, Franck Villaume - Capgemini
  * http://fusionforge.org/
  *
  * This file is part of FusionForge.
@@ -30,47 +30,47 @@
 $group_id = getIntFromRequest("group_id");
 $received_begin = getStringFromRequest("start_date");
 $received_end = getStringFromRequest("end_date");
-$show=getArrayFromRequest("show");
+$show = getArrayFromRequest("show");
 
-session_require_perm ('project_read', $group_id) ;
+session_require_perm('project_read', $group_id);
 
-$date_format = _('%Y-%m-%d') ;
+$date_format = _('%Y-%m-%d');
 
 if (!$received_begin || $received_begin==0) {
 	$begin = (time()-(30*86400));
-	$rendered_begin = strftime($date_format, $begin) ;
+	$rendered_begin = strftime($date_format, $begin);
 } else {
-	$tmp = strptime ($received_begin, $date_format);
+	$tmp = strptime($received_begin, $date_format);
 	if (!$tmp) {
 		$begin = (time()-(30*86400));
-		$rendered_begin = strftime($date_format, $begin) ;
+		$rendered_begin = strftime($date_format, $begin);
 	} else {
-		$begin = mktime (0,0,0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year'] + 1900);
-		$rendered_begin = $received_begin ;
+		$begin = mktime(0, 0, 0, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
+		$rendered_begin = $received_begin;
 	}
 }
 
-if (!$received_end || $received_end==0) {
-	$end = time() ;
-	$rendered_end = strftime($date_format, $end) ;
+if (!$received_end || $received_end == 0) {
+	$end = time();
+	$rendered_end = strftime($date_format, $end);
 } else {
-	$tmp = strptime ($received_end, $date_format);
+	$tmp = strptime($received_end, $date_format);
 	if (!$tmp) {
-		$end = time() ;
-		$rendered_end = strftime($date_format, $end) ;
+		$end = time();
+		$rendered_end = strftime($date_format, $end);
 	} else {
-		$end = mktime (0,0,0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year'] + 1900);
-		$rendered_end = $received_end ;
+		$end = mktime(0, 0, 0,$tmp['tm_mon']+1,$tmp['tm_mday'],$tmp['tm_year'] + 1900);
+		$rendered_end = $received_end;
 	}
 }
 
 if ($begin > $end) {
-	$tmp=$end;
-	$end=$begin;
-	$begin=$tmp;
-	$tmp=$rendered_end;
-	$rendered_end=$rendered_begin;
-	$rendered_begin=$tmp;
+	$tmp = $end;
+	$end = $begin;
+	$begin = $tmp;
+	$tmp = $rendered_end;
+	$rendered_end = $rendered_begin;
+	$rendered_begin = $tmp;
 }
 
 if (!$group_id) {
@@ -81,54 +81,60 @@
 	exit_permission_denied('home');
 }
 
-site_project_header(array('title'=>_('Activity'),'group'=>$group_id,'toptab'=>'activity'));
+site_project_header(array('title'=>_('Activity'), 'group'=>$group_id, 'toptab'=>'activity'));
 
-$ids=array();
-$texts=array();
+$ids = array();
+$texts = array();
 
-if (forge_get_config('use_forum') && $group->usesForum ()) {
-	$ids[]='forumpost';
-	$texts[]=_('Forum Post');
+if (forge_get_config('use_forum') && $group->usesForum()) {
+	$ids[]		= 'forumpost';
+	$texts[]	= _('Forum Post');
 }
 
-if (forge_get_config('use_tracker') && $group->usesTracker ()) {
-	$ids[]='trackeropen';
-	$texts[]=_('Tracker Opened');
-	$ids[]='trackerclose';
-	$texts[]=_('Tracker Closed');
+if (forge_get_config('use_tracker') && $group->usesTracker()) {
+	$ids[]		= 'trackeropen';
+	$texts[]	= _('Tracker Opened');
+	$ids[]		= 'trackerclose';
+	$texts[]	= _('Tracker Closed');
 }
 
-if (forge_get_config('use_news') && $group->usesNews ()) {
-	$ids[]='news';
-	$texts[]=_('News');
+if (forge_get_config('use_news') && $group->usesNews()) {
+	$ids[]		= 'news';
+	$texts[]	= _('News');
 }
 
-if (forge_get_config('use_scm') && $group->usesSCM ()) {
-	$ids[]='commit';
-	$texts[]=_('Commits');
+if (forge_get_config('use_scm') && $group->usesSCM()) {
+	$ids[]		= 'commit';
+	$texts[]	= _('Commits');
 }
 
-if (forge_get_config('use_frs') && $group->usesFRS ()) {
-	$ids[]='frsrelease';
-	$texts[]=_('FRS Release');
+if (forge_get_config('use_frs') && $group->usesFRS()) {
+	$ids[]		= 'frsrelease';
+	$texts[]	= _('FRS Release');
 }
 
+if (forge_get_config('use_frs') && $group->usesDocman()) {
+	$ids[]		= 'docmannew';
+	$texts[]	= _('New Documents');
+	$ids[]		= 'docmanupdate';
+	$texts[]	= _('Updated Documents');
+}
+
 if (count($show) < 1) {
-	$section=$ids;
+	$section = $ids;
 } else {
-	$section=$show;
+	$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)));
 
-$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)));
-
 if (db_error()) {
-	exit_error(db_error(),'home');
+	exit_error(db_error(), 'home');
 }
 
 $results = array();
@@ -137,24 +143,24 @@
 }
 
 // If plugins wants to add activities.
-$hookParams['group'] = $group_id ;
+$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) ;
+plugin_hook("activity", $hookParams);
 
 if (count($show) < 1) {
-	$show=$ids;
+	$show = $ids;
 }
 foreach ($show as $showthis) {
-	if (array_search($showthis,$ids) === false) {
-		exit_error(_('Invalid Data Passed to query'),'home');
+	if (array_search($showthis, $ids) === false) {
+		exit_error(_('Invalid Data Passed to query'), 'home');
 	}
 }
-$multiselect=html_build_multiple_select_box_from_arrays($ids,$texts,'show[]',$show,5,false);
+$multiselect = html_build_multiple_select_box_from_arrays($ids, $texts, 'show[]', $show, 5, false);
 
 ?>
 <br />
@@ -179,7 +185,7 @@
 </table>
 </form>
 <?php
-if (count($results)<1) {
+if (count($results) < 1) {
 	echo '<p class="warning_msg">' . _('No Activity Found') . '</p>';
 } else {
 
@@ -197,124 +203,116 @@
 		
 		$s = $arr['section'];
 		$ref = $arr['ref_id'];
+		$group_id = $arr['group_id'];
 		
 		if (!isset($cached_perms[$s][$ref])) {
 			switch ($s) {
-			case 'commit':
-			case 'trackeropen':
-			case 'trackerclose':
-				$cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read') ;
-				break;
-			case 'frsrelease':
-				$cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read') ;
-				break;
-			case 'forumpost':
-				$cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read') ;
-				break;
-			case 'news':
-				$cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read') ;
-				break;
-			default:
-				// Must be a bug somewhere, we're supposed to handle all types
-				$cached_perms[$s][$ref] = false;
-			}
-		}
-
-		return $cached_perms[$s][$ref];
-	}
-
-
-	usort($results, 'date_compare');
-
-	?>
-<br />
-	<?php
-
-
-	$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)));
-	if (db_error()) {
-		exit_error(db_error(),'home');
-	}
-
-	$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 (!check_perm_for_activity($arr)) {
-				continue;
-			}
-			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']);
-			}
-			switch (@$arr['section']) {
-				case 'commit': {
-					$icon=html_image("ic/cvs16b.png","20","20",array("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 'commit':
+				case 'trackeropen':
 				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'));
+					$cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read');
 					break;
 				}
 				case 'frsrelease': {
-					$icon=html_image("ic/cvs16b.png","20","20",array("alt"=>"SCM"));
-					$url=util_make_link ('/frs/?release_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('FRS Release').' '.$arr['description']);
+					$cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read');
 					break;
 				}
-				case 'forumpost': {
-					$icon=html_image("ic/forum20g.png","20","20",array("alt"=>"Forum"));
-					$url=util_make_link ('/forum/message.php?msg_id='.$arr['subref_id'].'&group_id='.$arr['group_id'],_('Forum Post ').' '.$arr['description']);
+				case 'forumpost':
+				case 'news': {
+					$cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
 					break;
 				}
-				case 'news': {
-					$icon=html_image("ic/write16w.png","20","20",array("alt"=>"News"));
-					$url=util_make_link ('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
+				case 'docmannew':
+				case 'docmanupdate': {
+					$cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
 					break;
 				}
 				default: {
-					$icon = isset($arr['icon']) ? $arr['icon'] : '';
-					$url  = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
+					// Must be a bug somewhere, we're supposed to handle all types
+					$cached_perms[$s][$ref] = false;
 				}
+			}
+		}
+		return $cached_perms[$s][$ref];
+	}
 
+	usort($results, 'date_compare');
+	?>
+	<?php
+
+	$theader=array();
+	$theader[]=_('Time');
+	$theader[]=_('Activity');
+	$theader[]=_('By');
+
+	echo $HTML->listTableTop($theader);
+
+	$j = 0;
+	$last_day = 0;
+	foreach ($results as $arr) {
+		if (!check_perm_for_activity($arr)) {
+			continue;
+		}
+		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']);
+		}
+		switch (@$arr['section']) {
+			case 'commit': {
+				$icon = html_image("ic/cvs16b.png","20","20",array("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;
 			}
-			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_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
-			} else {
-				echo $arr['realname'];
+			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;
 			}
-			echo '</td></tr>';
+			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("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("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("alt"=>"News"));
+				$url = util_make_link ('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
+				break;
+			}
+			case 'docmannew':
+			case 'docmanupdate': {
+				$icon = html_image("ic/docman16b.png", "20", "20", array("alt"=>"Documents"));
+				$url = util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['ref_id'],_('Document').' '.$arr['description']);
+				break;
+			}
+			default: {
+				$icon = isset($arr['icon']) ? $arr['icon'] : '';
+				$url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
+			}
 		}
+		echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
+		<td>    '.date('H:i:s',$arr['activity_date']).'</td>
+		<td>'.$icon .' '.$url.'</td><td>';
 
-		echo $HTML->listTableBottom($theader);
+		if (isset($arr['user_name']) && $arr['user_name']) {
+			echo util_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
+		} else {
+			echo $arr['realname'];
+		}
+		echo '</td></tr>';
 	}
+	echo $HTML->listTableBottom($theader);
 }
 
 site_project_footer(array());




More information about the Fusionforge-commits mailing list