X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=lib%2Farea.php;h=77272f76e9ba375d5d076471f17c9c87da834e59;hb=7e79094af6491632cec5287d4a0471ab4d227726;hp=9670a86c6bb8c3672a0985b8f625f01772da9c50;hpb=87843f0ab772989647ce3116f2508b781f56f0b6;p=readifood.git diff --git a/lib/area.php b/lib/area.php index 9670a86..77272f7 100644 --- a/lib/area.php +++ b/lib/area.php @@ -1,6 +1,7 @@ Added area.
\n"; @@ -8,8 +9,10 @@ } } else if ($_POST['city_id']) { - /* XXX: city_id is actually a string $city_name/$city_id */ - header(sprintf("Location: http%s://%s/%s/in/%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $_POST['city_id'])); + set_last_selected("city_id", $_POST['city_id']); + $city_id = $_POST['city_id']; + $city = get_city_by_id($city_id); + header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $city->getName(), $city_id)); exit; } else if ($_POST['update_area']) { @@ -27,10 +30,12 @@ if (count($areas)) { foreach ($areas as $area) { - echo "Error deleting $name!
\n"; - /* XXX: Why? Check for addresses in use... */ - return false; - } - - return true; - } - function show_area_delivery_days_form($days) { global $week; echo "Delivery days:"; if (check_admin(1)) { for ($i = 0; $i < count($week); $i++) { - echo " $week[$i]\n"; + echo ">\n"; } } else { @@ -182,8 +176,19 @@ return true; } + function confirm_delete_area($name, $id = null, &$city_id = null) { + if (! check_admin(1, "delete an area")) return; + + if (isset($id)) $area = get_area_by_id($id); + else $area = get_area_by_name($name); + if (! $area) return false; + + echo "You must confirm deletion of area " . $area->getName() . ": " . $area->getDeleteLink(true) . "
\n"; + } + function delete_area($name, $id = null, &$city_id = null) { - if (! check_admin(1, "delete a area")) return; + if (! check_admin(1, "delete an area")) return; if (isset($id)) $area = get_area_by_id($id); else $area = get_area_by_name($name); @@ -209,11 +214,13 @@ $area = get_area_by_name($name); if (! $area) return; - echo "\n"; + end_form(); } /* /area/in/Cambridge/1 */ @@ -248,6 +255,10 @@ if (count($args)) { switch ($args[0]) { case "delete": + confirm_delete_area($name, $id, $city_id); + break; + + case "confirmdelete": delete_area($name, $id, $city_id); break; }