[Fusionforge-commits] r8502 - trunk/gforge/www/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Dec 10 14:16:57 CET 2009


Author: lolando
Date: 2009-12-10 14:16:57 +0100 (Thu, 10 Dec 2009)
New Revision: 8502

Modified:
   trunk/gforge/www/admin/admin_table.php
   trunk/gforge/www/admin/grouplist.php
Log:
db_query_qpa for a few admin pages

Modified: trunk/gforge/www/admin/admin_table.php
===================================================================
--- trunk/gforge/www/admin/admin_table.php	2009-12-10 13:16:43 UTC (rev 8501)
+++ trunk/gforge/www/admin/admin_table.php	2009-12-10 13:16:57 UTC (rev 8502)
@@ -76,14 +76,19 @@
 	
 	$field_list = getStringFromRequest('__fields__');
 	$fields = split(",", $field_list);
-	$values = array();
+	$values = array(); $v = array ();
+	$qpa = db_construct_qpa (false, 'INSERT INTO ' . $table . ' (' . $field_list . ') VALUES (') ;
+	
+	$i = 1 ;
 	foreach ($fields as $field) {
-		$values[] = "'".getStringFromPost($field)."'";
+		$v[] = '$'.$i;
+		$i++ ;
+		$values[] = getStringFromPost($field);
 	}
 
-	$sql = "INSERT INTO $table (".$field_list.") VALUES (".implode(",", $values).")";
+	$qpa = db_construct_qpa ($qpa, implode (',', $v), $values) ;
 
-	if (db_query($sql)) {
+	if (db_query_qpa($qpa)) {
 		printf(_('%1$s successfully added.'), ucfirst(getUnitLabel($unit)));
 	} else {
 		form_release_key(getStringFromRequest('form_key'));
@@ -216,20 +221,52 @@
 function admin_table_postedit($table, $unit, $primary_key, $id) {
 	global $HTTP_POST_VARS;
 
-	$sql = 'UPDATE '.$table.' SET ';
+	$qpa = db_construct_qpa (false, 'UPDATE ' . $table . ' SET ') ;
+	
+	$i = 0 ;
 	while (list($var, $val) = each($HTTP_POST_VARS)) {
+		if ($i > 0) {
+			$qpa = db_construct_qpa ($qpa, ', ') ;
+		}
+		$i++ ;
 		if ($var != $primary_key) {
-			$sql .= "$var='". htmlspecialchars($val) ."', ";
+			$qpa = db_construct_qpa ($qpa, "$var=$1", array ($val)) ;
 		}
 	}
-	$sql = ereg_replace(', $', ' ', $sql);
-	$sql .= "WHERE $primary_key=$id";
+	$qpa = db_construct_qpa ($qpa, 'WHERE '.$primary_key.'=$1',
+				 array ($id)) ;
 
-	if (db_query($sql)) {
+	if (db_query_qpa($qpa)) {
 		printf(_('%1$s successfully modified.'), ucfirst(getUnitLabel($unit)));
 	} else {
 		echo db_error();
 	}
+
+
+
+
+
+	$field_list = getStringFromRequest('__fields__');
+	$fields = split(",", $field_list);
+	$values = array(); $v = array ();
+	$qpa = db_construct_qpa (false, 'INSERT INTO ' . $table . ' (' . $field_list . ') VALUES (') ;
+	
+	$i = 1 ;
+	foreach ($fields as $field) {
+		$v[] = '$'.$i;
+		$i++ ;
+		$values[] = getStringFromPost($field);
+	}
+
+	$qpa = db_construct_qpa ($qpa, implode (',', $v), $values) ;
+
+	if (db_query_qpa($qpa)) {
+		printf(_('%1$s successfully added.'), ucfirst(getUnitLabel($unit)));
+	} else {
+		form_release_key(getStringFromRequest('form_key'));
+		echo db_error();
+	}
+
 }
 
 /**

Modified: trunk/gforge/www/admin/grouplist.php
===================================================================
--- trunk/gforge/www/admin/grouplist.php	2009-12-10 13:16:43 UTC (rev 8501)
+++ trunk/gforge/www/admin/grouplist.php	2009-12-10 13:16:57 UTC (rev 8502)
@@ -55,12 +55,12 @@
 					       'P',
 					       $form_pending ? 1 : 0)) ;
 	} else {
-		$res = db_query("SELECT group_name,register_time,unix_group_name,groups.group_id,is_public,status,license_name, COUNT(user_group.group_id) AS members "
-			. "FROM groups LEFT JOIN user_group ON user_group.group_id=groups.group_id, licenses "
-			. "WHERE license_id=license "
-			. ($status?"AND status='$status' ":"")
-			. "GROUP BY group_name,register_time,unix_group_name,groups.group_id,is_public,status,license_name "
-			. "ORDER BY $sortorder");
+		$qpa = db_construct_qpa (false, 'SELECT group_name,register_time,unix_group_name,groups.group_id,is_public,status,license_name, COUNT(user_group.group_id) AS members FROM groups LEFT JOIN user_group ON user_group.group_id=groups.group_id, licenses WHERE license_id=license') ;
+		if ($status) {
+			$qpa = db_construct_qpa ($qpa, ' AND status=$1', array ($status)) ;
+		}
+		$qpa = db_construct_qpa ($qpa, ' GROUP BY group_name,register_time,unix_group_name,groups.group_id,is_public,status,license_name ORDER BY '.$sortorder) ;
+		$res = db_query_qpa ($qpa) ;
 	}
 } else {
 	echo "<p>"._('Group List for Category:').' ';
@@ -133,4 +133,9 @@
 
 site_admin_footer(array());
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>




More information about the Fusionforge-commits mailing list