[Fusionforge-commits] r7684 - trunk/gforge/common/reporting

Roland Mas lolando at libremir.placard.fr.eu.org
Mon May 18 18:18:23 CEST 2009


Author: lolando
Date: 2009-05-18 18:18:23 +0200 (Mon, 18 May 2009)
New Revision: 7684

Modified:
   trunk/gforge/common/reporting/Report.class.php
   trunk/gforge/common/reporting/ReportDownloads.class.php
   trunk/gforge/common/reporting/ReportGroupAdded.class.php
   trunk/gforge/common/reporting/ReportGroupCum.class.php
   trunk/gforge/common/reporting/ReportProjectAct.class.php
   trunk/gforge/common/reporting/ReportProjectTime.class.php
   trunk/gforge/common/reporting/ReportSiteAct.class.php
   trunk/gforge/common/reporting/ReportSiteTime.class.php
   trunk/gforge/common/reporting/ReportTrackerAct.class.php
   trunk/gforge/common/reporting/ReportUserAct.class.php
   trunk/gforge/common/reporting/ReportUserAdded.class.php
   trunk/gforge/common/reporting/ReportUserCum.class.php
   trunk/gforge/common/reporting/ReportUserTime.class.php
   trunk/gforge/common/reporting/TimeEntry.class.php
   trunk/gforge/common/reporting/report_utils.php
Log:
db_query_params transition: started on common/reporting

Modified: trunk/gforge/common/reporting/Report.class.php
===================================================================
--- trunk/gforge/common/reporting/Report.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/Report.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -59,7 +60,8 @@
  */
 function getMinDate() {
 	if (!$this->site_start_date) {
-		$res=db_query("select min(add_date) AS start_date from users where add_date > 0;");
+		$res = db_query_params ('SELECT MIN(add_date) AS start_date FROM users WHERE add_date > 0',
+					array ());
 		$this->site_start_date=db_result($res,0,'start_date');
 	}
 	return $this->site_start_date;

Modified: trunk/gforge/common/reporting/ReportDownloads.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportDownloads.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportDownloads.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -1,6 +1,9 @@
 <?php
 /*
+ * FusionForge reporting system
+ *
  * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -68,14 +71,12 @@
 		}
 
 		if (!$package_id) {
-			$sql = "SELECT package_id
-                        FROM frs_package
-                        WHERE frs_package.group_id = '$group_id'";
-			$res=db_query($sql);
+			$res = db_query_params ('SELECT package_id FROM frs_package WHERE frs_package.group_id = $1',
+						array ($group_id)) ;
 			$package_id = db_result($res, 0, 'package_id');
 		}
 
-		$sql = "SELECT frs_package.name, frs_release.name,
+		$res = db_query_params ('SELECT frs_package.name, frs_release.name,
                        frs_file.filename, users.realname,
                        frs_dlstats_file.month || lpad(frs_dlstats_file.day,2,0),
                        users.user_name
@@ -85,13 +86,16 @@
                   AND frs_dlstats_file.file_id = frs_file.file_id
                   AND frs_file.release_id = frs_release.release_id
                   AND frs_release.package_id = frs_package.package_id
-                  AND frs_package.group_id = '$group_id'
-                  AND frs_release.package_id = '$package_id' 
-                  AND frs_dlstats_file.month >= $start_m 
-                  AND frs_dlstats_file.month <= $end_m
+                  AND frs_package.group_id = $1
+                  AND frs_release.package_id = $2
+                  AND frs_dlstats_file.month >= $3
+                  AND frs_dlstats_file.month <= $4
                 ORDER BY frs_dlstats_file.month DESC,
-                       frs_dlstats_file.day DESC";
-		$res=db_query($sql);
+                       frs_dlstats_file.day DESC',
+					array ($group_id,
+					       $package_id,
+					       $start_m,
+					       $end_m)) ;
 
 		$this->start_date=$start;
 		$this->end_date=$end;

Modified: trunk/gforge/common/reporting/ReportGroupAdded.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportGroupAdded.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportGroupAdded.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -39,20 +40,17 @@
 	}
 
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_groups_added_monthly 
-			WHERE month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_added_monthly WHERE month BETWEEN $1 AND $2 ORDER BY month',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_groups_added_weekly 
-			WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_added_weekly WHERE week BETWEEN $1 AND $1 ORDER BY week',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_groups_added_daily 
-			WHERE day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_added_daily WHERE day BETWEEN $1 AND $2 ORDER BY day ASC',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportGroupCum.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportGroupCum.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportGroupCum.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -39,20 +40,17 @@
 	}
 
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_groups_cum_monthly 
-			WHERE month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_cum_monthly WHERE month BETWEEN $1 AND $2 ORDER BY month',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_groups_cum_weekly 
-			WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_cum_weekly WHERE week BETWEEN $1 AND $2 ORDER BY week',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_groups_cum_daily 
-			WHERE day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_groups_cum_daily WHERE day BETWEEN $1 AND $2 ORDER BY day',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportProjectAct.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportProjectAct.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportProjectAct.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -45,20 +46,20 @@
 		return false;
 	}
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_group_act_monthly 
-			WHERE group_id='$group_id' AND month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_group_act_monthly WHERE group_id=$1 AND month BETWEEN $2 AND $3 ORDER BY month',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_group_act_weekly 
-			WHERE group_id='$group_id' AND week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_group_act_weekly WHERE group_id=$1 AND week BETWEEN $2 AND $3 ORDER BY week',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_group_act_daily 
-			WHERE group_id='$group_id' AND day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_group_act_daily WHERE group_id=$1 AND day BETWEEN $2 AND $3 ORDER BY day',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportProjectTime.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportProjectTime.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportProjectTime.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -47,60 +48,67 @@
 	//	Task report
 	//
 	if (!$type || $type=='tasks') {
-
-		$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
 			WHERE pgl.group_project_id=pt.group_project_id
-			AND pgl.group_id='$group_id'
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			AND pgl.group_id=$1
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.project_task_id=pt.project_task_id
 			GROUP BY pt.summary
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	//
 	//	Category report
 	//
 	} elseif ($type=='category') {
 
-		$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, rep_time_category rtc, project_task pt, project_group_list pgl
-			WHERE pgl.group_id='$group_id' 
+			WHERE pgl.group_id=$1
 			AND pgl.group_project_id=pt.group_project_id
 			AND rtt.project_task_id=pt.project_task_id
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.time_code=rtc.time_code
 			GROUP BY rtc.category_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	//
 	//	Percentage this user spent on a specific subproject
 	//
 	} elseif ($type=='subproject') {
 
-		$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
-			WHERE pgl.group_id='$group_id'
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE pgl.group_id=$1
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.project_task_id=pt.project_task_id
 			AND pt.group_project_id=pgl.group_project_id
 			GROUP BY pgl.project_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	} else {
 
 	//
 	//	Biggest Users
 	//
-		$res=db_query("SELECT u.realname, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT u.realname, sum(rtt.hours) AS hours 
 			FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
-			WHERE pgl.group_id='$group_id'
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE pgl.group_id=$1
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.project_task_id=pt.project_task_id
 			AND pt.group_project_id=pgl.group_project_id
 			AND u.user_id=rtt.user_id
 			GROUP BY u.realname
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($group_id,
+					       $start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportSiteAct.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportSiteAct.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportSiteAct.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -41,20 +42,17 @@
 	}
 
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_site_act_monthly_vw 
-			WHERE month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_site_act_monthly_vw WHERE month BETWEEN $1 AND $2 ORDER BY month ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_site_act_weekly_vw 
-			WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_site_act_weekly_vw WHERE week BETWEEN $1 AND $2 ORDER BY week ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_site_act_daily_vw 
-			WHERE day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_site_act_daily_vw WHERE day BETWEEN $1 AND $2 ORDER BY day ASC',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportSiteTime.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportSiteTime.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportSiteTime.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -42,49 +43,51 @@
 	//	Task report
 	//
 	if (!$type || $type=='tasks') {
-
-		$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
 			WHERE pgl.group_project_id=pt.group_project_id
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			AND rtt.report_date BETWEEN $1 AND $2
 			AND rtt.project_task_id=pt.project_task_id
 			GROUP BY pt.summary
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($start,
+					       $end)) ;
 	//
 	//	Category report
 	//
 	} elseif ($type=='category') {
-
-		$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, rep_time_category rtc
-			WHERE rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.report_date BETWEEN $1 AND $2
 			AND rtt.time_code=rtc.time_code
 			GROUP BY rtc.category_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($start,
+					       $end)) ;
 	//
 	//	Percentage this user spent on a specific subproject
 	//
 	} elseif ($type=='subproject') {
 
-		$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
-			WHERE rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.report_date BETWEEN $1 AND $2
 			AND rtt.project_task_id=pt.project_task_id
 			AND pt.group_project_id=pgl.group_project_id
 			GROUP BY pgl.project_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($start,
+					       $end)) ;
 	} else {
 
-		$res=db_query("SELECT u.realname, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT u.realname, sum(rtt.hours) AS hours 
 			FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
-			WHERE rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.report_date BETWEEN $1 AND $2
 			AND u.user_id=rtt.user_id
 			GROUP BY u.realname
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportTrackerAct.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportTrackerAct.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportTrackerAct.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -93,39 +94,42 @@
 }
 
 function getAverageTime($atid,$start,$end) {
-	$sql="SELECT avg((close_date-open_date)/(24*60*60)) AS avgtime
+	$res = db_query_params ('SELECT avg((close_date-open_date)/(24*60*60)) AS avgtime
 		FROM artifact
-		WHERE group_artifact_id='$atid'
+		WHERE group_artifact_id=$1
 		AND close_date > 0
-		AND (open_date >= '$start' AND open_date <= '$end')";
-	$res=db_query($sql);
-echo db_error();
+		AND open_date BETWEEN $2 AND $3',
+				array ($atid,
+				       $start,
+				       $end));
+	echo db_error();
 	return db_result($res,0,0);
 }
 
 function getOpenCount($atid,$start,$end) {
-	$sql="SELECT count(*)
+	$res = db_query_params ('SELECT count(*)
 		FROM artifact
 		WHERE 
-		group_artifact_id='$atid'
-		AND open_date >= '$start'
-		AND open_date <= '$end'";
-
-	$res=db_query($sql);
-echo db_error();
+		group_artifact_id=$1
+		AND open_date BETWEEN $2 AND $3',
+				array ($atid,
+				       $start,
+				       $end));
+	echo db_error();
 	return db_result($res,0,0);
 }
 
 function getStillOpenCount($atid,$start,$end) {
-	$sql="SELECT count(*)
+	$res = db_query_params ('SELECT count(*)
 		FROM artifact
 		WHERE 
-		group_artifact_id='$atid'
-		AND open_date <= '$end'
-		AND (close_date >= '$end' OR close_date < 1 OR close_date is null)";
-
-	$res=db_query($sql);
-echo db_error();
+		group_artifact_id=$1
+		AND open_date <= $2
+		AND (close_date >= $3 OR close_date < 1 OR close_date is null)',
+				array ($atid,
+				       $end, // Yes, really.
+				       $end)) ;
+	echo db_error();
 	return db_result($res,0,0);
 }
 

Modified: trunk/gforge/common/reporting/ReportUserAct.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportUserAct.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportUserAct.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -45,20 +46,20 @@
 		return false;
 	}
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_user_act_monthly 
-			WHERE user_id='$user_id' AND month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_user_act_monthly WHERE user_id=$1 AND month BETWEEN $2 AND $3 ORDER BY month ASC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_user_act_weekly 
-			WHERE user_id='$user_id' AND week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_user_act_weekly WHERE user_id=$1 AND week BETWEEN $2 AND $3 ORDER BY week ASC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_user_act_daily 
-			WHERE user_id='$user_id' AND day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_user_act_daily WHERE user_id=$1 AND day BETWEEN $2 AND $3 ORDER BY day ASC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportUserAdded.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportUserAdded.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportUserAdded.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -39,20 +40,17 @@
 	}
 
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_users_added_monthly 
-			WHERE month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_users_added_monthly WHERE month BETWEEN $1 AND $2 ORDER BY month ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_users_added_weekly 
-			WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_users_added_weekly WHERE week BETWEEN $1 AND $2 ORDER BY week ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_users_added_daily 
-			WHERE day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_users_added_daily WHERE day BETWEEN $1 AND $2 ORDER BY day ASC',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportUserCum.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportUserCum.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportUserCum.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -39,20 +40,17 @@
 	}
 
 	if (!$span || $span == REPORT_TYPE_MONTHLY) {
-
-		$res=db_query("SELECT * FROM rep_users_cum_monthly 
-			WHERE month BETWEEN '$start' AND '$end' ORDER BY month");
-
+		$res = db_query_params ('SELECT * FROM rep_users_cum_monthly WHERE month BETWEEN $1 AND $2 ORDER BY month ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_WEEKLY) {
-
-		$res=db_query("SELECT * FROM rep_users_cum_weekly 
-			WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
-
+		$res = db_query_params ('SELECT * FROM rep_users_cum_weekly WHERE week BETWEEN $1 AND $2 ORDER BY week ASC',
+					array ($start,
+					       $end)) ;
 	} elseif ($span == REPORT_TYPE_DAILY) {
-
-		$res=db_query("SELECT * FROM rep_users_cum_daily 
-			WHERE day BETWEEN '$start' AND '$end' ORDER BY day ASC");
-
+		$res = db_query_params ('SELECT * FROM rep_users_cum_daily WHERE day BETWEEN $1 AND $2 ORDER BY day ASC',
+					array ($start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/ReportUserTime.class.php
===================================================================
--- trunk/gforge/common/reporting/ReportUserTime.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/ReportUserTime.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -47,42 +48,45 @@
 	//	Task report
 	//
 	if (!$type || $type=='tasks') {
-
-		$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt
-			WHERE rtt.user_id='$user_id' 
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.user_id=$1 
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.project_task_id=pt.project_task_id
 			GROUP BY pt.summary
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	//
 	//	Category report
 	//
 	} elseif ($type=='category') {
-
-		$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, rep_time_category rtc
-			WHERE rtt.user_id='$user_id' 
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.user_id=$1 
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.time_code=rtc.time_code
 			GROUP BY rtc.category_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	//
 	//	Percentage this user spent on a specific subproject
 	//
 	} elseif ($type=='subproject') {
-
-		$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours 
+		$res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours 
 			FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
-			WHERE rtt.user_id='$user_id' 
-			AND rtt.report_date BETWEEN '$start' AND '$end' 
+			WHERE rtt.user_id=$1 
+			AND rtt.report_date BETWEEN $2 AND $3
 			AND rtt.project_task_id=pt.project_task_id
 			AND pt.group_project_id=pgl.group_project_id
 			GROUP BY pgl.project_name
-			ORDER BY hours DESC");
-
+			ORDER BY hours DESC',
+					array ($user_id,
+					       $start,
+					       $end)) ;
 	}
 
 	$this->start_date=$start;

Modified: trunk/gforge/common/reporting/TimeEntry.class.php
===================================================================
--- trunk/gforge/common/reporting/TimeEntry.class.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/TimeEntry.class.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -80,11 +81,13 @@
     function create($projectTaskId, $week, $daysAdjust, $timeCode, $hours)
     {
         $report_date=($week + ($days_adjust*REPORT_DAY_SPAN))+(12*60*60);
-        $res=db_query("INSERT INTO rep_time_tracking (user_id,week,report_date,project_task_id,time_code,hours)
-                       VALUES ('".user_getid()."','$week','$report_date','$projectTaskId','$timeCode','$hours')");
-        //$res=db_query("INSERT INTO rep_time_tracking (user_id,week,report_date,project_task_id,time_code,hours)
-        //               VALUES (103,'$week','$report_date','$projectTaskId','$timeCode','$hours')");
-        //print_r($res); exit;
+        $res = db_query_params ('INSERT INTO rep_time_tracking (user_id,week,report_date,project_task_id,time_code,hours) VALUES ($1,$2,$3,$4,$5,$6)',
+				array (user_getid(),
+				       $week,
+				       $report_date,
+				       $projectTaskId,
+				       $timeCode,
+				       $hours)) ;
         if (!$res) {
             exit_error('Error',db_error());
         } else {

Modified: trunk/gforge/common/reporting/report_utils.php
===================================================================
--- trunk/gforge/common/reporting/report_utils.php	2009-05-18 09:33:00 UTC (rev 7683)
+++ trunk/gforge/common/reporting/report_utils.php	2009-05-18 16:18:23 UTC (rev 7684)
@@ -3,6 +3,7 @@
  * FusionForge reporting system
  *
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -100,16 +101,17 @@
 
 	if ($start_with) {
 		if ( $sys_database_type == "mysql" ) {
-			$sql2=" AND (lastname LIKE '$start_with%' OR user_name LIKE '$start_with%')";
+			$res = db_query_mysql ("SELECT user_id,realname FROM users WHERE status='A' AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) AND (lastname LIKE '$start_with%' OR user_name LIKE '$start_with%') ORDER BY lastname") ;
 		} else {
-			$sql2=" AND (lastname ILIKE '$start_with%' OR user_name ILIKE '$start_with%')";
+			$res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) AND (lastname LIKE $2 OR user_name LIKE $3) ORDER BY lastname',
+						array ('A',
+						       "$start_with%",
+						       "$start_with%")) ;
 		}
+	} else {
+		$res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) ORDER BY lastname',
+					array ('A')) ;
 	}
-
-	$res=db_query("SELECT user_id,realname 
-		FROM users 
-		WHERE status='A' $sql2 
-		AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) ORDER BY lastname");
 	return html_build_select_box($res, $name, $selected, false);
 }
 
@@ -118,22 +120,24 @@
 
 	if ($start_with) {
 		if ( $sys_database_type == "mysql" ) {
-			$sql2=" AND lastname LIKE '$start_with%' ";
+			$res = db_query_mysql ("SELECT user_id,realname FROM users WHERE status='A' AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) AND (lastname LIKE '$start_with%' OR user_name LIKE '$start_with%') ORDER BY lastname") ;
 		} else {
-			$sql2=" AND lastname ILIKE '$start_with%' ";
+			$res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) AND (lastname LIKE $2 OR user_name LIKE $3) ORDER BY lastname',
+						array ('A',
+						       "$start_with%",
+						       "$start_with%")) ;
 		}
+	} else {
+		$res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) ORDER BY lastname',
+					array ('A')) ;
 	}
-
-	$res=db_query("SELECT user_id,realname 
-		FROM users 
-		WHERE status='A' $sql2 
-		AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) ORDER BY lastname");
 	return html_build_select_box($res, $name, $selected, false);
 }
 
 function report_group_box($name='g_id', $selected='1') {
 
-	$res=db_query("SELECT group_id,group_name FROM groups WHERE status='A' ORDER BY group_name");
+	$res = db_query_params ('SELECT group_id,group_name FROM groups WHERE status=$1 ORDER BY group_name',
+				array ('A')) ;
 	return html_build_select_box($res, $name, $selected, false);
 }
 
@@ -206,7 +210,8 @@
 function report_time_category_box($name='category',$selected=false) {
 	global $report_time_category_res;
 	if (!$report_time_category_res) {
-		$report_time_category_res=db_query("SELECT * FROM rep_time_category");
+		$report_time_category_res = db_query_params ('SELECT * FROM rep_time_category',
+							     array()) ;
 	}
 	return html_build_select_box($report_time_category_res,$name,$selected,false);
 }
@@ -238,11 +243,8 @@
 }
 
 function report_package_box($group_id, $name='dev_id', $selected='') {
-
-	$sql = "SELECT package_id, name
-                FROM frs_package
-                WHERE frs_package.group_id = '$group_id'";
-	$res=db_query($sql);
+	$res = db_query_params ('SELECT package_id, name FROM frs_package WHERE frs_package.group_id = $1',
+				array ($group_id));
 	return html_build_select_box($res, $name, $selected, false);
 }
 




More information about the Fusionforge-commits mailing list