[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1951-gc4f2be9

Franck Villaume nerville at libremir.placard.fr.eu.org
Sat Jun 24 13:54:56 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  c4f2be97751369c26123e4cb0fb528d4230496c2 (commit)
       via  a9e8bad27e133a82983c2ba3c318350f5e225eed (commit)
       via  9280054f57d0df0ea14b6a8978f4fdd56a982e5c (commit)
      from  0170215c3c23ddef84c42d1b7069731e8ee5575c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=c4f2be97751369c26123e4cb0fb528d4230496c2

commit c4f2be97751369c26123e4cb0fb528d4230496c2
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Jun 24 13:54:15 2017 +0200

    introduce generic Activity object to factorize code

diff --git a/src/common/include/Activity.class.php b/src/common/include/Activity.class.php
new file mode 100644
index 0000000..d548605
--- /dev/null
+++ b/src/common/include/Activity.class.php
@@ -0,0 +1,207 @@
+<?php
+/**
+ * Activity Class
+ *
+ * Copyright 2017, Franck Villaume - TrivialDev
+ * http://fusionforge.org/
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+class Activity extends FFError {
+
+	//No constructor. Inherit from FFError.
+	function check_perm_for_activity($arr, &$cached_perms) {
+		$s = $arr['section'];
+		$ref = $arr['ref_id'];
+		$group_id = $arr['group_id'];
+
+		if (!isset($cached_perms[$s][$ref])) {
+			switch ($s) {
+				case 'scm': {
+					$cached_perms[$s][$ref] = forge_check_perm('scm', $group_id, 'read');
+					break;
+				}
+				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':
+				case 'news': {
+					$cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
+					break;
+				}
+				case 'taskopen':
+				case 'taskclose':
+				case 'taskdelete': {
+					$cached_perms[$s][$ref] = forge_check_perm('pm', $ref, 'read');
+					break;
+				}
+				case 'docmannew':
+				case 'docmanupdate':
+				case 'docgroupnew': {
+					$cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
+					break;
+				}
+				case 'mediawiki':
+					$cached_perms[$s][$ref] = forge_check_perm('plugin_mediawiki_read', $group_id, '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];
+	}
+
+	static function date_compare($a, $b) {
+		if ($a['activity_date'] == $b['activity_date']) {
+			return 0;
+		}
+		return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
+	}
+
+	function getDisplayInfo($arr) {
+		$docmanerror = 0;
+		switch (@$arr['section']) {
+			case 'scm': {
+				$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Source Code')));
+				$url = util_make_link('/scm/'.$arr['ref_id'].$arr['subref_id'],_('scm commit')._(': ').$arr['description']);
+				break;
+			}
+			case 'trackeropen': {
+				$icon = $HTML->getOpenTicketPic(_('Tracker Open'), 'trackeropen');
+				$url = util_make_link('/tracker/a_follow.php/'.$arr['subref_id'],_('Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description'].' '._('Opened'));
+				break;
+			}
+			case 'trackerclose': {
+				$icon = $HTML->getClosedTicketPic(_('Tracker Closed'), 'trackerclose');
+				$url = util_make_link('/tracker/a_follow.php/'.$arr['subref_id'],_('Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description'].' '._('Closed'));
+				break;
+			}
+			case 'frsrelease': {
+				$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Files')));
+				$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','','',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','','',array('alt'=>_('News')));
+				$url = util_make_link('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
+				break;
+			}
+			case 'taskopen': {
+				$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
+				$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
+				break;
+			}
+			case 'taskclose': {
+				$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
+				$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
+				break;
+			}
+
+			case 'taskdelete': {
+				$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
+				$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
+				break;
+			}
+			case 'docmannew':
+			case 'docmanupdate': {
+				$document = document_get_object($arr['subref_id'], $arr['group_id']);
+				$stateid = $document->getStateID();
+				if ($stateid != 1 && !forge_check_perm('docman', $arr['group_id'], 'approve')) {
+					$docmanerror = 1;
+					break;
+				}
+				$dg = documentgroup_get_object($arr['ref_id'], $arr['group_id']);
+				if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
+					$docmanerror = 1;
+					break;
+				}
+				$icon = html_image($document->getFileTypeImage(), 22, 22, array('alt' => $document->getFileType()));
+				$url = util_make_link($document->getPermalink(),_('Document').' '.$arr['description']);
+				break;
+			}
+			case 'docgroupnew': {
+				$dg = documentgroup_get_object($arr['subref_id'], $arr['group_id']);
+				if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
+					$docmanerror = 1;
+					break;
+				}
+				$icon = $HTML->getFolderPic('', _('Directory'));
+				if ($dg->getState() == 2) {
+					$view = 'listtrashfile';
+				} else {
+					$view = 'listfile';
+				}
+				$url = util_make_link('/docman/?group_id='.$arr['group_id'].'&view='.$view.'&dirid='.$arr['subref_id'],_('Directory').' '.$arr['description']);
+				break;
+			}
+			default: {
+				$icon = isset($arr['icon']) ? $arr['icon'] : '';
+				$url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
+			}
+		}
+		if ($docmanerror) {
+			return false;
+		}
+		return $icon .' '.$url;
+	}
+
+	function getActivitiesForProject($group_id, $begin, $end, $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()) {
+			$this->setError(db_error());
+			return false;
+		}
+
+		$results = array();
+		while ($arr = db_fetch_array($res)) {
+			$results[] = $arr;
+		}
+		return $results;
+	}
+
+	function getActivitiesForProjects($selected_groups, $begin, $end) {
+		$activities = array();
+		$res = db_query_params('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
+					AND group_id = ANY ($3) ORDER BY activity_date DESC',
+				array($begin, $end, db_int_array_to_any_clause($selected_groups)));
+		if ($res && db_numrows($res) > 0) {
+			while ($arr = db_fetch_array($res)) {
+				$activities[] = $arr;
+			}
+		}
+		return $activities;
+	}
+}
diff --git a/src/common/widget/Widget_HomeDetailActivityMostActiveProjectWeek.class.php b/src/common/widget/Widget_HomeDetailActivityMostActiveProjectWeek.class.php
index 0cf1b08..6c92a92 100644
--- a/src/common/widget/Widget_HomeDetailActivityMostActiveProjectWeek.class.php
+++ b/src/common/widget/Widget_HomeDetailActivityMostActiveProjectWeek.class.php
@@ -18,6 +18,7 @@
  */
 
 require_once 'Widget.class.php';
+require_once $gfcommon.'include/Activity.class.php';
 
 class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 
@@ -44,17 +45,11 @@ class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 				$count++;
 			}
 		}
-		$activities = array();
-		$begin = (time()-(7*86400));
+		$begin = (time() - (7 * 86400));
 		$end = time();
-		$res = db_query_params('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2
-					AND group_id = ANY ($3) ORDER BY activity_date DESC',
-				array($begin, $end, db_int_array_to_any_clause($selected_groups)));
-		if ($res && db_numrows($res) > 0) {
-			while ($arr = db_fetch_array($res)) {
-				$activities[] = $arr;
-			}
-		}
+		$ffactivity = new Activity();
+		$activities = $ffactivity->getActivitiesForProjects($selected_groups, $begin, $end);
+
 		foreach ($selected_groups as $group_id) {
 			// If plugins wants to add activities.
 			$hookParams['group'] = $group_id;
@@ -66,12 +61,12 @@ class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 		if (count($activities) > 0) {
 			$date_format = _('%Y-%m-%d');
 			$date_format_js = _('yy-mm-dd');
-			usort($activities, 'Widget_HomeDetailActivityMostActiveProjectWeek::date_compare');
+			usort($activities, 'Activity::date_compare');
 			$displayTableTop = 0;
 			$last_day = 0;
 			foreach ($activities as $activity) {
 				$docmanerror = 0;
-				if (!$this->check_perm_for_activity($activity)) {
+				if (!$ffactivity->check_perm_for_activity($activity, $this->cached_perms)) {
 					continue;
 				}
 				if (!$displayTableTop) {
@@ -84,74 +79,8 @@ class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 					echo $HTML->listTableTop($theader);
 					$displayTableTop = 1;
 				}
-				switch (@$activity['section']) {
-					case 'scm': {
-						$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Source Code')));
-						$url = util_make_link('/scm/'.$activity['ref_id'].$activity['subref_id'],_('scm commit')._(': ').$activity['description']);
-						break;
-					}
-					case 'trackeropen': {
-						$icon = $HTML->getOpenTicketPic(_('Tracker Open'), 'trackeropen');
-						$url = util_make_link('/tracker/a_follow.php/'.$activity['subref_id'],_('Tracker Item').' [#'.$activity['subref_id'].'] '.$activity['description'].' '._('Open'));
-						break;
-					}
-					case 'trackerclose': {
-						$icon = $HTML->getClosedTicketPic(_('Tracker Closed'), 'trackerclose');
-						$url = util_make_link('/tracker/a_follow.php/'.$activity['subref_id'],_('Tracker Item').' [#'.$activity['subref_id'].'] '.$activity['description'].' '._('Closed'));
-						break;
-					}
-					case 'frsrelease': {
-						$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Files')));
-						$url = util_make_link('/frs/?release_id='.$activity['subref_id'].'&group_id='.$activity['group_id'],_('FRS Release').' '.$activity['description']);
-						break;
-					}
-					case 'forumpost': {
-						$icon = html_image('ic/forum20g.png','','',array('alt'=>_('Forum')));
-						$url = util_make_link('/forum/message.php?msg_id='.$activity['subref_id'].'&group_id='.$activity['group_id'],_('Forum Post').' '.$activity['description']);
-						break;
-					}
-					case 'news': {
-						$icon = html_image('ic/write16w.png','','',array('alt'=>_('News')));
-						$url = util_make_link('/forum/forum.php?forum_id='.$activity['subref_id'],_('News').' '.$activity['description']);
-						break;
-					}
-					case 'taskopen':
-					case 'taskclose':
-					case 'taskdelete': {
-						$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
-						$url = util_make_link('/pm/t_follow.php/'.$activity['subref_id'],_('Tasks').' '.$activity['description']);
-						break;
-					}
-					case 'docmannew':
-					case 'docmanupdate': {
-						$document = document_get_object($activity['subref_id'], $activity['group_id']);
-						$stateid = $document->getStateID();
-						if ($stateid != 1 && !forge_check_perm('docman', $activity['group_id'], 'approve')) {
-							$docmanerror = 1;
-						}
-						$dg = documentgroup_get_object($activity['ref_id'], $activity['group_id']);
-						if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
-							$docmanerror = 1;
-						}
-						$icon = html_image('ic/docman16b.png', '', '', array('alt'=>_('Documents')));
-						$url = util_make_link($document->getPermalink(),_('Document').' '.$activity['description']);
-						break;
-					}
-					case 'docgroupnew': {
-						$dg = documentgroup_get_object($activity['subref_id'], $activity['group_id']);
-						if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
-							$docmanerror = 1;
-						}
-						$icon = html_image('ic/cfolder15.png', '', '', array("alt"=>_('Directory')));
-						$url = util_make_link('docman/?group_id='.$activity['group_id'].'&view=listfile&dirid='.$activity['subref_id'],_('Directory').' '.$activity['description']);
-						break;
-					}
-					default: {
-						$icon = isset($activity['icon']) ? $activity['icon'] : '';
-						$url = '<a href="'.$activity['link'].'">'.$activity['title'].'</a>';
-					}
-				}
-				if ($docmanerror) {
+				$displayinfo = $ffactivity->getDisplayInfo($arr);
+				if (!$displayinfo) {
 					continue;
 				}
 				if ($last_day != strftime($date_format, $activity['activity_date'])) {
@@ -161,11 +90,11 @@ class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 					$last_day=strftime($date_format, $activity['activity_date']);
 				}
 				$cells = array();
-				$cells[][] = date('H:i:s',$activity['activity_date']);
+				$cells[][] = date('H:i:s', $activity['activity_date']);
 				$group_object = group_get_object($activity['group_id']);
 
 				$cells[][] = util_make_link_g($group_object->getUnixName(), $activity['group_id'], $group_object->getPublicName());
-				$cells[][] = $icon .' '.$url;
+				$cells[][] = $displayinfo;
 				if (isset($activity['user_name']) && $activity['user_name']) {
 					$cells[][] = util_display_user($activity['user_name'], $activity['user_id'],$activity['realname']);
 				} else {
@@ -189,57 +118,4 @@ class Widget_HomeDetailActivityMostActiveProjectWeek extends Widget {
 	function isAvailable() {
 		return isset($this->content['title']);
 	}
-
-	function date_compare($a, $b) {
-		if ($a['activity_date'] == $b['activity_date']) {
-			return 0;
-		}
-		return ($a['activity_date'] > $b['activity_date']) ? -1 : 1;
-	}
-
-	function check_perm_for_activity($arr) {
-		$s = $arr['section'];
-		$ref = $arr['ref_id'];
-		$group_id = $arr['group_id'];
-
-		if (!isset($this->cached_perms[$s][$ref])) {
-			switch ($s) {
-				case 'scm': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('scm', $group_id, 'read');
-					break;
-				}
-				case 'trackeropen':
-				case 'trackerclose': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('tracker', $ref, 'read');
-					break;
-				}
-				case 'frsrelease': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('frs', $ref, 'read');
-					break;
-				}
-				case 'forumpost':
-				case 'news': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
-					break;
-				}
-				case 'taskopen':
-				case 'taskclose':
-				case 'taskdelete': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('pm', $ref, 'read');
-					break;
-				}
-				case 'docmannew':
-				case 'docmanupdate':
-				case 'docgroupnew': {
-					$this->cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
-					break;
-				}
-				default: {
-					// Must be a bug somewhere, we're supposed to handle all types
-					$this->cached_perms[$s][$ref] = false;
-				}
-			}
-		}
-		return $this->cached_perms[$s][$ref];
-	}
 }
diff --git a/src/www/activity/index.php b/src/www/activity/index.php
index e3d921b..895104b 100644
--- a/src/www/activity/index.php
+++ b/src/www/activity/index.php
@@ -28,6 +28,7 @@
 
 require_once '../env.inc.php';
 require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'include/Activity.class.php';
 require_once $gfcommon.'docman/Document.class.php';
 require_once $gfcommon.'docman/DocumentGroup.class.php';
 
@@ -44,12 +45,12 @@ $date_format = _('%Y-%m-%d');
 $date_format_js = _('yy-mm-dd');
 
 if (!$received_begin || $received_begin == 0) {
-	$begin = (time()-(30*86400));
+	$begin = (time() - (30 * 86400));
 	$rendered_begin = strftime($date_format, $begin);
 } else {
 	$tmp = strptime($received_begin, $date_format);
 	if (!$tmp) {
-		$begin = (time()-(30*86400));
+		$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'] + 1900);
@@ -70,7 +71,7 @@ if (!$received_end || $received_end == 0) {
 		$end = time();
 		$rendered_end = strftime($date_format, $end);
 	} else {
-		$end = mktime(23, 59, 59, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
+		$end = mktime(23, 59, 59, $tmp['tm_mon'] + 1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
 		$rendered_end = $received_end;
 	}
 }
@@ -151,22 +152,11 @@ if (count($show) < 1) {
 	$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)));
-
-if (db_error()) {
-	exit_error(db_error(), 'home');
-}
-
-$results = array();
-while ($arr = db_fetch_array($res)) {
-	$results[] = $arr;
+$ffactivity = new Activity();
+$results = $ffactivity->getActivitiesForProject($group_id, $begin, $end, $section);
+if ($results === false) {
+	exit_error(_('Unable to get activities')._(':').$ffactivity->getErrorMessage(), 'home');
 }
-
 // If plugins wants to add activities.
 $hookParams['group'] = $group_id;
 $hookParams['results'] = &$results;
@@ -175,7 +165,7 @@ $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;
@@ -229,74 +219,16 @@ echo $HTML->closeForm();
 	if (count($results) < 1) {
 		echo $HTML->information(_('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;
-		}
-
 		$cached_perms = array();
-		function check_perm_for_activity($arr) {
-			global $cached_perms;
-			$s = $arr['section'];
-			$ref = $arr['ref_id'];
-			$group_id = $arr['group_id'];
-
-			if (!isset($cached_perms[$s][$ref])) {
-				switch ($s) {
-					case 'scm': {
-						$cached_perms[$s][$ref] = forge_check_perm('scm', $group_id, 'read');
-						break;
-					}
-					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':
-					case 'news': {
-						$cached_perms[$s][$ref] = forge_check_perm('forum', $ref, 'read');
-						break;
-					}
-					case 'taskopen':
-					case 'taskclose':
-					case 'taskdelete': {
-						$cached_perms[$s][$ref] = forge_check_perm('pm', $ref, 'read');
-						break;
-					}
-					case 'docmannew':
-					case 'docmanupdate':
-					case 'docgroupnew': {
-						$cached_perms[$s][$ref] = forge_check_perm('docman', $group_id, 'read');
-						break;
-					}
-                                        case 'mediawiki':
-                                                $cached_perms[$s][$ref] = forge_check_perm('plugin_mediawiki_read', $group_id, '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');
+		usort($results, 'Activity::date_compare');
 
 		$displayTableTop = 0;
 		$j = 0;
 		$last_day = 0;
 		foreach ($results as $arr) {
 			$docmanerror = 0;
-			if (!check_perm_for_activity($arr)) {
+			if (!$ffactivity->check_perm_for_activity($arr, $cached_perms)) {
 				continue;
 			}
 			if (!$displayTableTop) {
@@ -308,100 +240,19 @@ echo $HTML->closeForm();
 				echo $HTML->listTableTop($theader);
 				$displayTableTop = 1;
 			}
-			switch (@$arr['section']) {
-				case 'scm': {
-					$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Source Code')));
-					$url = util_make_link('/scm/'.$arr['ref_id'].$arr['subref_id'],_('scm commit')._(': ').$arr['description']);
-					break;
-				}
-				case 'trackeropen': {
-					$icon = $HTML->getOpenTicketPic(_('Tracker Open'), 'trackeropen');
-					$url = util_make_link('/tracker/a_follow.php/'.$arr['subref_id'],_('Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description'].' '._('Opened'));
-					break;
-				}
-				case 'trackerclose': {
-					$icon = $HTML->getClosedTicketPic(_('Tracker Closed'), 'trackerclose');
-					$url = util_make_link('/tracker/a_follow.php/'.$arr['subref_id'],_('Tracker Item').' [#'.$arr['subref_id'].'] '.$arr['description'].' '._('Closed'));
-					break;
-				}
-				case 'frsrelease': {
-					$icon = html_image('ic/cvs16b.png','','',array('alt'=>_('Files')));
-					$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','','',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','','',array('alt'=>_('News')));
-					$url = util_make_link('/forum/forum.php?forum_id='.$arr['subref_id'],_('News').' '.$arr['description']);
-					break;
-				}
-				case 'taskopen': {
-					$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
-					$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
-					break;
-				}
-				case 'taskclose': {
-					$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
-					$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
-					break;
-				}
-
-				case 'taskdelete': {
-					$icon = html_image('ic/taskman20w.png','','',array('alt'=>_('Tasks')));
-					$url = util_make_link('/pm/t_follow.php/'.$arr['subref_id'],_('Tasks').' '.$arr['description']);
-					break;
-				}
-				case 'docmannew':
-				case 'docmanupdate': {
-					$document = document_get_object($arr['subref_id'], $arr['group_id']);
-					$stateid = $document->getStateID();
-					if ($stateid != 1 && !forge_check_perm('docman', $arr['group_id'], 'approve')) {
-						$docmanerror = 1;
-						break;
-					}
-					$dg = documentgroup_get_object($arr['ref_id'], $arr['group_id']);
-					if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
-						$docmanerror = 1;
-						break;
-					}
-					$icon = html_image($document->getFileTypeImage(), 22, 22, array('alt' => $document->getFileType()));
-					$url = util_make_link($document->getPermalink(),_('Document').' '.$arr['description']);
-					break;
-				}
-				case 'docgroupnew': {
-					$dg = documentgroup_get_object($arr['subref_id'], $arr['group_id']);
-					if (!$dg || $dg->isError() || !$dg->getPath(true, false)) {
-						$docmanerror = 1;
-						break;
-					}
-					$icon = $HTML->getFolderPic('', _('Directory'));
-					if ($dg->getState() == 2) {
-						$view = 'listtrashfile';
-					} else {
-						$view = 'listfile';
-					}
-					$url = util_make_link('/docman/?group_id='.$arr['group_id'].'&view='.$view.'&dirid='.$arr['subref_id'],_('Directory').' '.$arr['description']);
-					break;
-				}
-				default: {
-					$icon = isset($arr['icon']) ? $arr['icon'] : '';
-					$url = '<a href="'.$arr['link'].'">'.$arr['title'].'</a>';
-				}
-			}
-			if ($docmanerror) {
+
+			$displayinfo = $ffactivity->getDisplayInfo($arr);
+			if (!$displayinfo) {
 				continue;
 			}
+
 			if ($last_day != strftime($date_format, $arr['activity_date'])) {
 				echo '<tr class="tableheading"><td colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
 				$last_day=strftime($date_format, $arr['activity_date']);
 			}
 			$cells = array();
 			$cells[][] = date('H:i:s',$arr['activity_date']);
-			$cells[][] = $icon .' '.$url;
+			$cells[][] = $displayinfo;
 			if (isset($arr['user_name']) && $arr['user_name']) {
 				$cells[][] = util_display_user($arr['user_name'], $arr['user_id'],$arr['realname']);
 			} else {

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=a9e8bad27e133a82983c2ba3c318350f5e225eed

commit a9e8bad27e133a82983c2ba3c318350f5e225eed
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Jun 24 13:53:41 2017 +0200

    coding-style

diff --git a/src/plugins/globalactivity/www/index.php b/src/plugins/globalactivity/www/index.php
index 758be71..3b225e3 100644
--- a/src/plugins/globalactivity/www/index.php
+++ b/src/plugins/globalactivity/www/index.php
@@ -34,31 +34,32 @@ global $HTML;
 
 $received_begin = getStringFromRequest("start_date");
 $received_end = getStringFromRequest("end_date");
-$show = getArrayFromRequest("show",array('forumpost',
-										 'trackeropen',
-										 'trackerclose',
-										 'news',
-										 'taskopen',
-										 'taskclose',
-										 'taskdelete',
-										 'frsrelease',
-										 'docmannew',
-										 'docmanupdate',
-										 'docgroupnew'
+$show = getArrayFromRequest('show', array('forumpost',
+					  'trackeropen',
+					  'trackerclose',
+					  'news',
+					  'taskopen',
+					  'taskclose',
+					  'taskdelete',
+					  'frsrelease',
+					  'docmannew',
+					  'docmanupdate',
+					  'docgroupnew',
+					  'mediawiki'
 ));
 
 $date_format = _('%Y-%m-%d');
 
-if (!$received_begin || $received_begin==0) {
-	$begin = (time()-(30*86400));
+if (!$received_begin || $received_begin == 0) {
+	$begin = (time() - (30 * 86400));
 	$rendered_begin = strftime($date_format, $begin);
 } else {
 	$tmp = strptime($received_begin, $date_format);
 	if (!$tmp) {
-		$begin = (time()-(7*86400));
+		$begin = (time() - (7 * 86400));
 		$rendered_begin = strftime($date_format, $begin);
 	} else {
-		$begin = mktime(0, 0, 0, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
+		$begin = mktime(0, 0, 0, $tmp['tm_mon'] + 1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
 		$rendered_begin = $received_begin;
 	}
 }
@@ -76,7 +77,7 @@ if (!$received_end || $received_end == 0) {
 		$end = time();
 		$rendered_end = strftime($date_format, $end);
 	} else {
-		$end = mktime(23, 59, 59, $tmp['tm_mon']+1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
+		$end = mktime(23, 59, 59, $tmp['tm_mon'] + 1, $tmp['tm_mday'], $tmp['tm_year'] + 1900);
 		$rendered_end = $received_end;
 	}
 }
@@ -96,7 +97,7 @@ $ids = array();
 $texts = array();
 
 try {
-	$results = $plugin->getData($begin,$end,$show,$ids,$texts);
+	$results = $plugin->getData($begin, $end, $show, $ids, $texts);
 } catch (Exception $e) {
 	exit_error($e->getMessage(), 'home');
 }
@@ -138,8 +139,6 @@ if (count($ids) < 1) {
 	if (count($results) < 1) {
 		echo $HTML->information(_('No Activity Found'));
 	} else {
-
-
 		$displayTableTop = 0;
 		$last_day = 0;
 		foreach ($results as $arr) {

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=9280054f57d0df0ea14b6a8978f4fdd56a982e5c

commit 9280054f57d0df0ea14b6a8978f4fdd56a982e5c
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Jun 24 13:53:00 2017 +0200

    use HTML helper. More get*Pic functions

diff --git a/src/common/widget/Widget_TrackerComment.class.php b/src/common/widget/Widget_TrackerComment.class.php
index f558c79..1dd25c5 100644
--- a/src/common/widget/Widget_TrackerComment.class.php
+++ b/src/common/widget/Widget_TrackerComment.class.php
@@ -144,7 +144,7 @@ class Widget_TrackerComment extends Widget {
 			if ($group->usesPM()) {
 				$tabberContent .= html_e('div', array('id' => 'tabber-tasks', 'class' => 'tabbertab'),
 							$ath->renderRelatedTasks($group, $ah, 'trackerform').
-							util_make_link('/tracker/?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid, html_image('ic/taskman20w.png', 20, 20).'<strong>'._('Build Task Relation').'</strong>'));
+							util_make_link('/tracker/?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid, $HTML->getPmPic().'<strong>'._('Build Task Relation').'</strong>'));
 			}
 		}
 		$attachmentContent = '';
diff --git a/src/www/include/Layout.class.php b/src/www/include/Layout.class.php
index 4ca8af0..eadc88f 100644
--- a/src/www/include/Layout.class.php
+++ b/src/www/include/Layout.class.php
@@ -1049,6 +1049,18 @@ abstract class Layout extends FFError {
 		return $this->getPicto('ic/tag.png', $title, $alt, 20, 20, $otherAttr);
 	}
 
+	function getNewsPic($title = '', $alt = '', $otherAttr = array()) {
+		return $this->getPicto('ic/write16w.png', $title, $alt, 20, 20, $otherAttr);
+	}
+
+	function getPointerUp($title = '', $alt = '', $otherAttr = array()) {
+		return $this->getPicto('ic/pointer_up.png', $title, $alt, 20, 20, $otherAttr);
+	}
+
+	function getPointerDown($title = '', $alt = '', $otherAttr = array()) {
+		return $this->getPicto('ic/pointer_down.png', $title, $alt, 20, 20, $otherAttr);
+	}
+
 	function getPicto($url, $title, $alt, $width = 20, $height = 20, $otherAttr = array()) {
 		if ($title != '') {
 			$otherAttr['title'] = $title;

-----------------------------------------------------------------------

Summary of changes:
 src/common/include/Activity.class.php              | 207 +++++++++++++++++++++
 ...meDetailActivityMostActiveProjectWeek.class.php | 146 ++-------------
 src/common/widget/Widget_TrackerComment.class.php  |   2 +-
 src/plugins/globalactivity/www/index.php           |  37 ++--
 src/www/activity/index.php                         | 181 ++----------------
 src/www/include/Layout.class.php                   |  12 ++
 6 files changed, 265 insertions(+), 320 deletions(-)
 create mode 100644 src/common/include/Activity.class.php


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list