From 5f6053ab415c056940be3985b4ebac5ce48285fd Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sat, 14 May 2005 00:42:25 +0000 Subject: [PATCH] When processing an application automatically perform a search of the database for the application name and display a table at the top of the page. This makes it easier to determine if the submission is a duplicate. Remove obsolete comments for admins. Add a 'back' link to the top of the page to make it easier to go back without scrolling to the bottom of the page. --- admin/adminAppQueue.php | 15 +++++----- include/util.php | 62 +++++++++++++++++++++++++++++++++++++++++ search.php | 56 ++----------------------------------- 3 files changed, 71 insertions(+), 62 deletions(-) diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index c651b49..91e78a2 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -52,6 +52,8 @@ if ($_REQUEST['sub']) echo '
',"\n"; echo '',"\n"; + echo html_back_link(1,'adminAppQueue.php'); + if ($oVersion) //app version { //help @@ -91,20 +93,17 @@ if ($_REQUEST['sub']) echo '
',"\n"; } else // application { + echo html_frame_start("Potential duplicate applications in the database","90%","",0); + $hResult = searchForApplication($oApp->sName); + outputSearchTableForhResult($oApp->sName, $hResult); + echo html_frame_end(" "); + //help echo "
\n\n"; echo "

This is the full view of the application waiting to be approved. \n"; echo "You need to pick a category before submitting \n"; echo "it into the database. If you approve this application,\n"; echo "an email will be sent to the author of the submission.

\n"; - echo "

There are two kinds of applications in this database:

\n"; - echo "
    \n"; - echo "
  1. App Family This is a parent group application, that will have multiple versions under it.
    \n"; - echo " To add this submission as a Family, choose 'Application' from the type drop down. Then set the category.\n"; - echo " The version and app parent fields will be ignored in this type.
    \n"; - echo " If the vendor does not exist, leave the vendor drop down unset, and the field will be used.
  2. \n"; - echo "

  3. App Version This type of application will be nested under the selected application parent.\n"; - echo " The category, name, and vendor fields will be ignored.
  4. \n"; echo "

    Click delete to remove the selected item from the queue. An email will automatically be sent to the\n"; echo "submitter to let them know the item was deleted.

    \n\n"; echo "
\n\n"; diff --git a/include/util.php b/include/util.php index b5e8ed5..c35dbc7 100644 --- a/include/util.php +++ b/include/util.php @@ -301,4 +301,66 @@ function outputTopXRowAppsFromRating($rating, $num_apps) } } +/* search the database and return a hResult from the query_appdb() */ +function searchForApplication($search_words) +{ + $sQuery = "SELECT * + FROM appFamily + WHERE appName != 'NONAME' + AND queued = 'false' + AND (appName LIKE '%".addslashes($search_words)."%' + OR keywords LIKE '%".addslashes($search_words)."%') + ORDER BY appName"; + $hResult = query_appdb($sQuery); + return $hResult; +} + +function outputSearchTableForhResult($search_words, $hResult) +{ + if(mysql_num_rows($hResult) == 0) + { + // do something + echo html_frame_start("","98%"); + echo "No matches found for '". urlencode($search_words) . "'\n"; + echo html_frame_end(); + } else + { + echo html_frame_start("","98%","",0); + echo "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c = 0; + while($ob = mysql_fetch_object($hResult)) + { + //skip if a NONAME + if ($ob->appName == "NONAME") { continue; } + + //set row color + $bgcolor = ($c % 2) ? 'color0' : 'color1'; + + //count versions + $query = query_appdb("SELECT count(*) as versions FROM appVersion WHERE appId = $ob->appId AND versionName != 'NONAME'"); + $y = mysql_fetch_object($query); + + //display row + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "\n"; + echo "
Application NameDescriptionNo. Versions
".html_ahref($ob->appName,"appview.php?appId=$ob->appId")."".trim_description($ob->description)."$y->versions  
$c match(es) found
\n\n"; + echo html_frame_end(); + } +} + ?> \ No newline at end of file diff --git a/search.php b/search.php index 20a5d8d..48fb294 100644 --- a/search.php +++ b/search.php @@ -10,62 +10,10 @@ include("path.php"); require(BASE."include/incl.php"); require(BASE."include/application.php"); -$sQuery = "SELECT * - FROM appFamily - WHERE appName != 'NONAME' - AND queued = 'false' - AND (appName LIKE '%".addslashes($_REQUEST['q'])."%' - OR keywords LIKE '%".addslashes($_REQUEST['q'])."%') - ORDER BY appName"; -$hResult = query_appdb($sQuery); apidb_header("Search Results"); -if(mysql_num_rows($hResult) == 0) -{ - // do something - echo html_frame_start("","98%"); - echo "No matches found for ". urlencode($_REQUEST['q']) . "\n"; - echo html_frame_end(); -} -else -{ - - echo html_frame_start("","98%","",0); - echo "\n\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; - - $c = 0; - while($ob = mysql_fetch_object($hResult)) - { - //skip if a NONAME - if ($ob->appName == "NONAME") { continue; } - - //set row color - $bgcolor = ($c % 2) ? 'color0' : 'color1'; - - //count versions - $query = query_appdb("SELECT count(*) as versions FROM appVersion WHERE appId = $ob->appId AND versionName != 'NONAME'"); - $y = mysql_fetch_object($query); - - //display row - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; - - $c++; - } - - echo "\n"; - echo "
Application NameDescriptionNo. Versions
".html_ahref($ob->appName,"appview.php?appId=$ob->appId")."".trim_description($ob->description)."$y->versions  
$c match(es) found
\n\n"; -} - +$hResult = searchForApplication($_REQUEST['q']); +outputSearchTableForhResult($_REQUEST['q'], $hResult); apidb_footer(); ?>