X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=inline;f=lib%2Fcontact.php;h=f3764064943e1601fbd5e65634093c33933ae828;hb=a1bc70f4ac65ec18d45b80c5c71b62d55dc363d3;hp=b6809822b7f292d9a19d174066e13c49dc93f77d;hpb=fe4e5568f9cec5d1bf46a3f40b4a99985f7a5abc;p=readifood.git
diff --git a/lib/contact.php b/lib/contact.php
index b680982..f376406 100644
--- a/lib/contact.php
+++ b/lib/contact.php
@@ -280,7 +280,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 +335,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 +428,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 +503,7 @@
$contact = new Contact;
if (! update_contact($contact, $area_id, true)) return false;
+ $name = $contact->getDisplayname();
return $contact->getId();
}