[Fusionforge-commits] FusionForge branch master updated. 8e34148293a3e3a011313f643e94ab93fd92287d

Franck Villaume nerville at fusionforge.org
Fri Aug 22 10:27:18 CEST 2014


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  8e34148293a3e3a011313f643e94ab93fd92287d (commit)
      from  9f8cee04a6952d5f7accfc916c3e1e7f3b14661f (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 -----------------------------------------------------------------
commit 8e34148293a3e3a011313f643e94ab93fd92287d
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri Aug 22 10:24:28 2014 +0200

    Project report: use Tracker object rather than sql query

diff --git a/src/common/tracker/ArtifactsForUser.class.php b/src/common/tracker/ArtifactsForUser.class.php
index dcc5925..a53d8c9 100644
--- a/src/common/tracker/ArtifactsForUser.class.php
+++ b/src/common/tracker/ArtifactsForUser.class.php
@@ -4,6 +4,7 @@
  *
  * Copyright 2002, GForge, LLC
  * Copyright 2009, Roland Mas
+ * Copyright 2014, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -34,10 +35,10 @@ class ArtifactsForUser extends Error {
 	var $Artifact;
 
 	/**
-	* __construct - Creates a new ArtifactsForUser object
-	*
-	* @param	object	$user	the User object for which to collect artifacts
-	*/
+	 * __construct - Creates a new ArtifactsForUser object
+	 *
+	 * @param	object	$user	the User object for which to collect artifacts
+	 */
 	function __construct(&$user) {
 		$this->User =& $user;
 	}
@@ -70,30 +71,44 @@ class ArtifactsForUser extends Error {
 	}
 
 	/**
-	* getAssignedArtifactsByGroup - Get the users's assigned artifacts
-	* @return	Artifact[]	The array of Artifacts
-	*/
-	function &getAssignedArtifactsByGroup() {
-		return $this->getArtifactsFromSQLwithParams('SELECT * FROM artifact_vw av WHERE av.assigned_to=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id DESC',
-							    array($this->User->getID())) ;
+	 * getAssignedArtifactsByGroup - Get the users's assigned artifacts
+	 *
+	 * @param	string		$order	Optional complementary column order
+	 * @param	string		$sort	Default is DESC
+	 * @return	Artifact[]	The array of Artifacts
+	 */
+	function &getAssignedArtifactsByGroup($order = NULL, $sort = 'DESC') {
+		$sqlstring = 'SELECT * FROM artifact_vw av WHERE av.assigned_to=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id';
+		if ($order) {
+			$sqlstring .= ', '.$order;
+		}
+		$sqlstring .= ' '.$sort;
+
+		return $this->getArtifactsFromSQLwithParams($sqlstring, array($this->User->getID()));
 
 	}
 
 	/**
-	* getSubmittedArtifactsByGroup
-	*
-	* @return	Artifact[]	The array of Artifacts
-	*/
-	function &getSubmittedArtifactsByGroup() {
-		return $this->getArtifactsFromSQLwithParams('SELECT * FROM artifact_vw av WHERE av.submitted_by=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id DESC',
-							    array($this->User->getID())) ;
+	 * getSubmittedArtifactsByGroup
+	 *
+	 * @param	string		$order	Optional complementary column order
+	 * @param	string		$sort	Default is DESC
+	 * @return	Artifact[]	The array of Artifacts
+	 */
+	function &getSubmittedArtifactsByGroup($order = NULL, $sort = 'DESC') {
+		$sqlstring = 'SELECT * FROM artifact_vw av WHERE av.submitted_by=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id';
+		if ($order) {
+			$sqlstring .= ', '.$order;
+		}
+		$sqlstring .= ' '.$sort;
+		return $this->getArtifactsFromSQLwithParams($sqlstring, array($this->User->getID()));
 	}
 
 	/**
-	* getMonitoredArtifacts
-	*
-	* @return	Artifact[]	The array of Artifacts
-	*/
+	 * getMonitoredArtifacts
+	 *
+	 * @return	Artifact[]	The array of Artifacts
+	 */
 	function & getMonitoredArtifacts() {
 		$artifacts = array();
 
diff --git a/src/www/project/report/index.php b/src/www/project/report/index.php
index e3b44d4..9b61fa6 100644
--- a/src/www/project/report/index.php
+++ b/src/www/project/report/index.php
@@ -25,6 +25,7 @@
 
 require_once '../../env.inc.php';
 require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'tracker/ArtifactsForUser.class.php';
 
 global $HTML;
 
@@ -165,35 +166,22 @@ foreach ($group->getUsers() as $member) {
 	echo $HTML->multiTableRow(array(), $cells);
 
 	// print out all the artifacts assigned to this person
-	$artifact_group=db_query_params("SELECT group_artifact_id, name
-				FROM artifact_group_list
-				WHERE group_id=$1
-				ORDER BY group_artifact_id DESC", array($group_id));
-
-	while ( $artifact_type =db_fetch_array($artifact_group) ) {
-		$artifacts=db_query_params("SELECT * FROM artifact_vw
-					WHERE assigned_to=$1
-					AND status_id='1'
-					AND group_artifact_id=$2
-					ORDER BY priority DESC", array($member->getID(), $artifact_type['group_artifact_id']));
-
-		$num_artifacts=db_numrows($artifacts);
-		for ($m=0; $m < $num_artifacts; $m++) {
-			$cells = array();
-			$cells[][] = util_make_link('/tracker/?func=detail&aid='. db_result($artifacts, $m, 'artifact_id') .'&group_id='.$group_id.'&atid='.$artifact_type['group_artifact_id'], $artifact_type['name'].' '.db_result($artifacts, $m, 'artifact_id'));
-			$cells[][] = db_result($artifacts, $m, 'summary');
-			$cells[][] = GetTime( time() - db_result($artifacts, $m, 'open_date'));
-
-			$messages = db_query_params("select adddate FROM artifact_message_user_vw ".
+	$afu = new ArtifactsForUser($member);
+	$artifacts = $afu->getAssignedArtifactsByGroup();
+	foreach ($artifacts as $artifact) {
+		$cells = array();
+		$cells[][] = util_make_link('/tracker/?func=detail&aid='. $artifact->getID() .'&group_id='.$group_id.'&atid='.$artifact->ArtifactType->getID(), $artifact->ArtifactType->getName().' '.$artifact->getID());
+		$cells[][] = $artifact->getSummary();
+		$cells[][] = GetTime( time() - $artifact->getOpenDate());
+		$messages = db_query_params("select adddate FROM artifact_message_user_vw ".
 						"WHERE artifact_id=$1 ".
-						"ORDER by adddate DESC", array(db_result($artifacts, $m, 'artifact_id')));
-			if ( db_numrows($messages)) {
-				$cells[][] = GetTime( time () - db_result($messages, 0, 'adddate'));
-			} else {
-				$cells[][] = GetTime( time () - db_result($artifacts, $m, 'open_date'));;
-			}
-			echo $HTML->multiTableRow(array('class' => 'priority'.db_result($artifacts, $m, 'priority')), $cells);
-                }
+						"ORDER by adddate DESC", array($artifact->getID()));
+		if ( db_numrows($messages)) {
+			$cells[][] = GetTime(time() - db_result($messages, 0, 'adddate'));
+		} else {
+			$cells[][] = GetTime(time() - $artifact->getOpenDate());;
+		}
+		echo $HTML->multiTableRow(array('class' => 'priority'.$artifact->getPriority()), $cells);
 	}
 	$task_group=db_query_params("SELECT ptv.*,g.group_name,pgl.project_name
 				FROM project_task_vw ptv,

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

Summary of changes:
 src/common/tracker/ArtifactsForUser.class.php |   57 ++++++++++++++++---------
 src/www/project/report/index.php              |   44 +++++++------------
 2 files changed, 52 insertions(+), 49 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list