diff --git a/include/application_queue.php b/include/application_queue.php index 0c7f2f3..d20dca8 100644 --- a/include/application_queue.php +++ b/include/application_queue.php @@ -276,8 +276,11 @@ class application_queue function displayDuplicates() { - echo "Like matches\n"; + echo "Like matches
\n"; $this->displayDuplicateTable(searchForApplication($this->oApp->sName)); + echo "
\n"; + echo "Partial matches
\n"; + $this->displayDuplicateTable(searchForApplicationPartial($this->oApp->sName)); } function displayDuplicateTable($hResult) diff --git a/include/util.php b/include/util.php index 57576ae..4009d1c 100644 --- a/include/util.php +++ b/include/util.php @@ -412,6 +412,34 @@ function cleanupSearchWords($search_words) return $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) +{ + $sSearchWords = cleanupSearchWords($sSearchWords); + $aWords = explode(' ', $sSearchWords); + $sSearchString = ''; + + for($i = 0; $i < sizeof($aWords); $i++) + { + if($i) + $sSearchString .= '%'; + $sSearchString .= $aWords[$i]; + if(strlen($aWords[$i]) > 4) + { + if($i < (sizeof($aWords) - 1)) + $sSearchString .= ' '; + break; + } + } + + $hResult = query_parameters("SELECT * FROM appFamily WHERE state = 'accepted' AND + appName LIKE '?%'", $sSearchString); + + return $hResult; +} + /* search the database and return a hResult from the query_appdb() */ function searchForApplication($search_words) { @@ -524,6 +552,10 @@ function perform_search_and_output_results($search_words) echo "
Like matches
"; $hResult = searchForApplication($search_words); outputSearchTableForhResult($search_words, $hResult); + + echo "
Partial matches
"; + $hResult = searchForApplicationPartial($search_words); + outputSearchTableForhResult($search_words, $hResult); } function display_page_range($iCurrentPage=1, $iPageRange=1, $iTotalPages=1, $sLinkurl=NULL)