[Fusionforge-commits] r8178 - trunk/gforge/www/news

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Sep 25 11:52:21 CEST 2009


Author: lolando
Date: 2009-09-25 11:52:21 +0200 (Fri, 25 Sep 2009)
New Revision: 8178

Modified:
   trunk/gforge/www/news/index.php
   trunk/gforge/www/news/news_utils.php
Log:
db_query_params() migration

Modified: trunk/gforge/www/news/index.php
===================================================================
--- trunk/gforge/www/news/index.php	2009-09-25 08:28:13 UTC (rev 8177)
+++ trunk/gforge/www/news/index.php	2009-09-25 09:52:21 UTC (rev 8178)
@@ -42,12 +42,6 @@
 if ( !$group_id || $group_id < 0 || !is_numeric($group_id) ) {
 	$group_id = 0;
 }
-if ($group_id && ($group_id != $sys_news_group)) {
-	$sql="SELECT * FROM news_bytes WHERE group_id='$group_id' AND is_approved <> '4' ORDER BY post_date DESC";
-} else {
-	$sql="SELECT * FROM news_bytes WHERE is_approved='1' ORDER BY post_date DESC";
-}
-
 if ( !$offset || $offset < 0 || !is_numeric($offset) ) {
 	$offset = 0;
 }
@@ -55,7 +49,16 @@
 	$limit = 50;
 }
 
-$result=db_query($sql,$limit+1,$offset);
+if ($group_id && ($group_id != $sys_news_group)) {
+	$result = db_query_params ('SELECT * FROM news_bytes WHERE group_id=$1 AND is_approved <> 4 ORDER BY post_date DESC',
+				   array ($group_id),
+				   $limit+1,
+				   $offset);
+} else {
+	$result = db_query_params ('SELECT * FROM news_bytes WHERE is_approved=1 ORDER BY post_date DESC',
+				   array ());
+}
+
 $rows=db_numrows($result);
 $more=0;
 if ($rows>$limit) {

Modified: trunk/gforge/www/news/news_utils.php
===================================================================
--- trunk/gforge/www/news/news_utils.php	2009-09-25 08:28:13 UTC (rev 8177)
+++ trunk/gforge/www/news/news_utils.php	2009-09-25 09:52:21 UTC (rev 8178)
@@ -88,30 +88,30 @@
 	/*
 		Show a simple list of the latest news items with a link to the forum
 	*/
-
-	if ($group_id != $sys_news_group) {
-		$wclause="news_bytes.group_id='$group_id' AND news_bytes.is_approved <> '4'";
-	} else {
-		$wclause='news_bytes.is_approved=1';
-	}
-
-	$sql="SELECT groups.group_name,groups.unix_group_name,groups.group_id,
-		groups.type_id,users.user_name,users.realname,
-		news_bytes.forum_id,news_bytes.summary,news_bytes.post_date,news_bytes.details 
-		FROM users,news_bytes,groups 
-		WHERE $wclause 
-		AND users.user_id=news_bytes.submitted_by 
-		AND news_bytes.group_id=groups.group_id 
-		AND groups.status='A'
-		ORDER BY post_date DESC";
-
 	if ($tail_headlines == -1) {
-		$result=db_query($sql);
-	} else {
-		$result=db_query($sql,$limit+$tail_headlines);
+		$l = 0 ;
+	} elso {
+		$l = $limit + $tail_headlines ;
 	}
+	$result = db_query_params ('
+SELECT groups.group_name, groups.unix_group_name, groups.group_id,
+       groups.type_id, users.user_name, users.realname,
+       news_bytes.forum_id, news_bytes.summary, news_bytes.post_date,
+       news_bytes.details
+FROM users,news_bytes,groups
+WHERE (news_bytes.group_id=$1 AND news_bytes.is_approved <> 4 OR 1!=$2)
+  AND (news_bytes.is_approved=1 OR 1 != $3)
+  AND users.user_id=news_bytes.submitted_by
+  AND news_bytes.group_id=groups.group_id
+  AND groups.status=$4
+ORDER BY post_date DESC',
+				   array ($group_id,
+					  $group_id != $sys_news_group ? 1 : 0,
+					  $group_id != $sys_news_group ? 0 : 1,
+					  'A'),
+				   $l);
 	$rows=db_numrows($result);
-	
+
 	$return = '';
 
 	if (!$result || $rows < 1) {
@@ -161,8 +161,8 @@
 					date(_('Y-m-d H:i'),db_result($result,$i,'post_date')). '</em>' .
 					$proj_name . $summ_txt;
 
-				$sql="SELECT total FROM forum_group_list_vw WHERE group_forum_id='" . db_result($result,$i,'forum_id') . "'";
-				$res2 = db_query($sql);
+				$res2 = db_query_params ('SELECT total FROM forum_group_list_vw WHERE group_forum_id=$1',
+							 array (db_result($result,$i,'forum_id')));
 				$num_comments = db_result($res2,0,'total');
 
 				if (!$num_comments) {




More information about the Fusionforge-commits mailing list