Alexander Nicolaysen Sørnes : Fix Potential Duplicates table when viewing a non-queued app
Alexander Nicolaysen Sørnes
asornes at winehq.org
Sun Jun 28 08:43:08 CDT 2009
Module: appdb
Branch: master
Commit: 077ecab9f9044a593af0a70266149e5557442c33
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=077ecab9f9044a593af0a70266149e5557442c33
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Sun Jun 28 15:41:54 2009 +0200
Fix Potential Duplicates table when viewing a non-queued app
---
include/application_queue.php | 4 ++--
include/util.php | 19 ++++++++++++++-----
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/application_queue.php b/include/application_queue.php
index c3c51d1..5710cba 100644
--- a/include/application_queue.php
+++ b/include/application_queue.php
@@ -291,10 +291,10 @@ class application_queue
function displayDuplicates()
{
echo "<b>Like matches</b><br />\n";
- $this->displayDuplicateTable(searchForApplication($this->oApp->sName));
+ $this->displayDuplicateTable(searchForApplication($this->oApp->sName, $this->oApp->objectGetId()));
echo "<br />\n";
echo "<b>Partial matches</b><br />\n";
- $this->displayDuplicateTable(searchForApplicationPartial($this->oApp->sName));
+ $this->displayDuplicateTable(searchForApplicationPartial($this->oApp->sName, $this->oApp->objectGetId()));
}
function displayDuplicateTable($hResult)
diff --git a/include/util.php b/include/util.php
index 5d9cb8b..a8bce6c 100644
--- a/include/util.php
+++ b/include/util.php
@@ -443,8 +443,9 @@ function cleanupSearchWords($search_words)
/* A common error for users is to submit a new app entry for a new app version,
such as C&C Red Alert 2 Yuri's Revenge when we already have C&C Red Alert 2.
- Search for the first word in the search query */
-function searchForApplicationPartial($sSearchWords)
+ Search for the first word in the search query.
+ iExcludeAppId can be useful when showing a list of duplicate entries */
+function searchForApplicationPartial($sSearchWords, $iExcludeAppId = null)
{
/* This would yield too many results and stress MySQL */
if(strlen($sSearchWords) < 4)
@@ -474,14 +475,18 @@ function searchForApplicationPartial($sSearchWords)
}
}
+ $sExcludeApps = '';
+ if($iExcludeAppId && is_numeric($iExcludeAppId))
+ $sExcludeApps = " AND appId != '$iExcludeAppId' ";
+
$hResult = query_parameters("SELECT * FROM appFamily WHERE state = 'accepted' AND
- (appName LIKE '?%' OR appName LIKE '?')", $sSearchString.$sEnsureExactWord, $sSearchString);
+ (appName LIKE '?%' OR appName LIKE '?')$sExcludeApps", $sSearchString.$sEnsureExactWord, $sSearchString);
return $hResult;
}
/* search the database and return a hResult from the query_appdb() */
-function searchForApplication($search_words)
+function searchForApplication($search_words, $iExcludeAppId = null)
{
/* This would yield too many results and stress MySQL */
if(strlen($search_words) < 4)
@@ -505,6 +510,10 @@ function searchForApplication($search_words)
$search_words = str_replace(' ', '%', query_escape_string($search_words));
+ $sExcludeApps = '';
+ if($iExcludeAppId && is_numeric($iExcludeAppId))
+ $sExcludeApps = " AND appId != '$iExcludeAppId' ";
+
/* base query */
$sQuery = "SELECT *
FROM appFamily
@@ -513,7 +522,7 @@ function searchForApplication($search_words)
AND (appName LIKE '%?%'
OR keywords LIKE '%?%'";
- $sQuery.=" ) ORDER BY appName";
+ $sQuery.=" ) $sExcludeApps ORDER BY appName";
$hResult = query_parameters($sQuery, $search_words, $search_words);
return $hResult;
More information about the wine-cvs
mailing list