X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Fcontact.php;h=80139892fd7e271edd12730f3003d4dbd4b943cf;hb=c302638e3b5c08805b56db1e2f9d1c0dce494f3c;hp=b6809822b7f292d9a19d174066e13c49dc93f77d;hpb=02df6557b464ce5034693e5175c4bab8809158bc;p=readifood.git
diff --git a/lib/contact.php b/lib/contact.php
index b680982..8013989 100644
--- a/lib/contact.php
+++ b/lib/contact.php
@@ -1,10 +1,12 @@
Added contact.
\n";
@@ -32,12 +34,14 @@
exit;
}
else if ($_POST['show_in_area']) {
+ set_last_selected("area_id", $_POST['area_id']);
$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['show_in_city']) {
+ set_last_selected("city_id", $_POST['city_id']);
$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']));
@@ -280,7 +284,13 @@
/* Postcode. */
echo "\n";
echo " Postcode | \n";
- echo " "; input("postcode", $address->getPostcode()); echo get_address_map_link($address); echo " | \n";
+ $postcode = $address->getPostcode();
+ if (validate_postcode($postcode)) {
+ echo " "; input("postcode", $postcode); echo get_address_map_link($address); echo " | \n";
+ }
+ else {
+ echo " "; input("postcode", $address->getPostcode()); echo " (invalid) | \n";
+ }
echo "
\n";
/* Telephone. */
@@ -329,9 +339,9 @@
echo " ";
for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) {
if (1 << $i == $GLOBALS['PARCEL_TOILETRY']) continue;
- echo " getParcel() & (1 << $i)) echo " checked";
- echo ">$parcel_contents[$i]\n";
+ echo ">\n";
}
echo " | \n";
echo "\n";
@@ -422,7 +432,11 @@
/* Get address. */
$area_id = $_POST['area_id'];
$line = $_POST['address'];
- $postcode = $_POST['postcode'];
+ $postcode = trim($_POST['postcode']);
+ if ($postcode) {
+ $postcode = format_postcode($_POST['postcode'], true);
+ if (! $postcode) return false;
+ }
$q = new AddressQuery;
/* XXX: Finding by area properly? */
$address = $q->filterByAreaId($area_id)->filterByLine($line)->filterByPostcode($postcode)->findOneOrCreate();
@@ -493,6 +507,7 @@
$contact = new Contact;
if (! update_contact($contact, $area_id, true)) return false;
+ $name = $contact->getDisplayname();
return $contact->getId();
}