From: Iain Patterson Date: Mon, 13 May 2013 12:22:26 +0000 (-0400) Subject: Correctly filter city or area. X-Git-Tag: 2013-05-13^0 X-Git-Url: http://git.iain.cx/?p=readifood.git;a=commitdiff_plain;h=47051a8cfc285b2324230d620c7ddb41cd61c00c Correctly filter city or area. When separate dropdowns for city and area are shown in one form we must ensure that the correct search criterion is applied. Previously we checked for an area or city ID parameter but both of those will be present in the form submission. Instead we check for the name of the submit button. --- diff --git a/lib/contact.php b/lib/contact.php index de4dc82..25aab58 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -31,13 +31,13 @@ header(sprintf("Location: http%s://%s/%s/search/%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($_POST['search_contact']))); exit; } - else if ($_POST['area_id']) { + else if ($_POST['show_in_area']) { $q = new AreaQuery; $area = $q->findOneById($_POST['area_id']); header(sprintf("Location: http%s://%s/%s/in/area/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($area->getName()), $_POST['area_id'])); exit; } - else if ($_POST['city_id']) { + else if ($_POST['show_in_city']) { $q = new CityQuery; $city = $q->findOneById($_POST['city_id']); header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($city->getName()), $_POST['city_id'])); @@ -142,7 +142,7 @@ option("area_id", $area->getId(), get_area_displayname($area)); } echo "\n"; - echo "\n"; + submit("show_in_area", "Show"); } function show_contact_cities_form($city_id = null) { @@ -167,7 +167,7 @@ option("city_id", $city->getId(), get_city_displayname($city), $city_id); } echo "\n"; - echo "\n"; + submit("show_in_city", "Show"); } function show_contact_search_form() { diff --git a/lib/donation.php b/lib/donation.php index 4d928fb..afcd01b 100644 --- a/lib/donation.php +++ b/lib/donation.php @@ -25,14 +25,14 @@ echo "

No such contact!

\n"; } } - else if ($_POST['area_id']) { + else if ($_POST['show_in_area']) { $q = new AreaQuery; $area = $q->findOneById($_POST['area_id']); /* XXX: Function to build URL because we need to set a class in links. */ header(sprintf("Location: http%s://%s/%s/in/area/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($area->getName()), $_POST['area_id'])); exit; } - else if ($_POST['city_id']) { + else if ($_POST['show_in_city']) { $q = new CityQuery; $city = $q->findOneById($_POST['city_id']); header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($city->getName()), $_POST['city_id'])); @@ -141,7 +141,7 @@ option("area_id", $area->getId(), get_area_displayname($area)); } echo "\n"; - echo "\n"; + submit("show_in_area", "Show"); } function show_donation_cities_form($city_id = null) { @@ -166,7 +166,7 @@ option("city_id", $city->getId(), get_city_displayname($city), $city_id); } echo "\n"; - echo "\n"; + submit("show_in_city", "Show"); } function show_donation_forms($city_id) { diff --git a/lib/hub.php b/lib/hub.php index 7a18d47..12f27cf 100644 --- a/lib/hub.php +++ b/lib/hub.php @@ -27,13 +27,13 @@ echo "

No such hub!

\n"; } } - else if ($_POST['area_id']) { + else if ($_POST['show_in_area']) { $q = new AreaQuery; $area = $q->findOneById($_POST['area_id']); header(sprintf("Location: http%s://%s/%s/in/area/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($area->getName()), $_POST['area_id'])); exit; } - else if ($_POST['city_id']) { + else if ($_POST['show_in_city']) { $q = new CityQuery; $city = $q->findOneById($_POST['city_id']); header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($city->getName()), $_POST['city_id'])); @@ -121,7 +121,7 @@ option("area_id", $area->getId(), get_area_displayname($area)); } echo "\n"; - echo "\n"; + submit("show_in_area", "Show"); } function show_hub_cities_form($city_id = null) { @@ -146,7 +146,7 @@ option("city_id", $city->getId(), get_city_displayname($city), $city_id); } echo "\n"; - echo "\n"; + submit("show_in_city", "Show"); } function show_hub_forms($city_id) {