[Fusionforge-commits] r8149 - in trunk/gforge: plugins/globalsearch/www www/admin www/project/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Sep 23 17:17:36 CEST 2009


Author: lolando
Date: 2009-09-23 17:17:36 +0200 (Wed, 23 Sep 2009)
New Revision: 8149

Modified:
   trunk/gforge/plugins/globalsearch/www/index.php
   trunk/gforge/www/admin/unsubscribe.php
   trunk/gforge/www/admin/userlist.php
   trunk/gforge/www/project/admin/massadd.php
Log:
Started removing non-portable ILIKE constructs in SQL

Modified: trunk/gforge/plugins/globalsearch/www/index.php
===================================================================
--- trunk/gforge/plugins/globalsearch/www/index.php	2009-09-23 15:17:20 UTC (rev 8148)
+++ trunk/gforge/plugins/globalsearch/www/index.php	2009-09-23 15:17:36 UTC (rev 8149)
@@ -109,16 +109,16 @@
         Query to find projects
 */
 
-// If multiple words, separate them and put ILIKE (pgsql's 
-// case-insensitive LIKE) in between
 // XXX:SQL: this assumes db understands backslash-quoting
 
 $array=explode(" ",quotemeta($gwords));
 // we need to use double-backslashes in SQL
 $array_re=explode(" ",addslashes(quotemeta($gwords)));
 
-$gwords1="project_title ILIKE '%" . implode($array,"%' $crit project_title ILIKE '%") ."%'";
-$gwords2="project_description ILIKE '%" . implode($array,"%' $crit project_description ILIKE '%") . "%'";
+$gwords1="lower(project_title) LIKE '%" . implode(array_map ('strtolower', $array),
+						  "%' $crit lower(project_title) LIKE '%") ."%'";
+$gwords2="lower(project_description) LIKE '%" . implode(array_map ('strtolower', $array),
+							"%' $crit lower(project_description) LIKE '%") . "%'";
 
 $sql = "SELECT project_title, project_link, project_description, title, link 
 FROM plugin_globalsearch_assoc_site_project, plugin_globalsearch_assoc_site 

Modified: trunk/gforge/www/admin/unsubscribe.php
===================================================================
--- trunk/gforge/www/admin/unsubscribe.php	2009-09-23 15:17:20 UTC (rev 8148)
+++ trunk/gforge/www/admin/unsubscribe.php	2009-09-23 15:17:36 UTC (rev 8149)
@@ -106,23 +106,12 @@
 <?php
 
 if ($pattern) {
-	$sql = "
-		SELECT *
-		FROM users";
-	if ( $sys_database_type == "mysql" ) {
-		$sql .= "
-		WHERE user_name LIKE $1
-		OR realname LIKE $1
-		OR email LIKE $1
-		";
-	} else {
-		$sql .= "
-		WHERE user_name LIKE $1
-		OR realname ILIKE $1
-		OR email ILIKE $1
-		";
-	}
-	$res = db_query_params($sql, array("%".$pattern."%"));
+	$res = db_query_params('SELECT *
+		FROM users
+		WHERE lower(user_name) LIKE $1
+		OR lower(realname) LIKE $1
+		OR lower(email) LIKE $1',
+			       array (strtolower ("%$pattern%")));
 
 	$title=array();
 	$title[]='&nbsp;';

Modified: trunk/gforge/www/admin/userlist.php
===================================================================
--- trunk/gforge/www/admin/userlist.php	2009-09-23 15:17:20 UTC (rev 8148)
+++ trunk/gforge/www/admin/userlist.php	2009-09-23 15:17:36 UTC (rev 8149)
@@ -144,8 +144,8 @@
 	print "\n</p>";
 
 	if ($user_name_search) {
-		$result = db_query_params ('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users WHERE user_name ILIKE $1 OR lastname ILIKE $1 ORDER BY lastname',
-					   array ("$user_name_search%"));
+		$result = db_query_params ('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users WHERE lower(user_name) LIKE $1 OR lower(lastname) LIKE $1 ORDER BY lastname',
+					   array (strtolower("$user_name_search%")));
 	} else {
 		$sortorder = getStringFromRequest('sortorder', 'user_name');
 		$result = db_query_params("SELECT user_name,lastname,firstname,user_id,status,add_date FROM users ORDER BY $1", array($sortorder));

Modified: trunk/gforge/www/project/admin/massadd.php
===================================================================
--- trunk/gforge/www/project/admin/massadd.php	2009-09-23 15:17:20 UTC (rev 8148)
+++ trunk/gforge/www/project/admin/massadd.php	2009-09-23 15:17:36 UTC (rev 8149)
@@ -39,18 +39,11 @@
 	exit_error('Error',$group->getErrorMessage());
 }
 
-$sw = getStringFromRequest('sw');
-if (!$sw) {
-	$sw='A';
-}
+$sw = getStringFromRequest('sw', 'A');
 
-$sql="SELECT user_id,user_name,lastname,firstname FROM users ";
-if ($sys_database_type == "mysql") {
-	$sql.="WHERE status='A' and type_id='1' and lastname LIKE $1 ";
-} else {
-	$sql.="WHERE status='A' and type_id='1' and lastname ILIKE $1 ";
-}
-$res=db_query_params($sql, array($sw."%"));
+$res = db_query_params('SELECT user_id,user_name,lastname,firstname FROM users WHERE status=$1 and type_id=1 and lower(lastname) LIKE $2',
+		       array('A',
+			     strtolower ($sw."%")));
 
 $accumulated_ids = getStringFromRequest('accumulated_ids');
 if (!$accumulated_ids) {




More information about the Fusionforge-commits mailing list