X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Fcontact.php;h=f3764064943e1601fbd5e65634093c33933ae828;hb=f181270af10ecded4b40d9ad3f838216835eb5f4;hp=56327de6e736e6367f731eeb948c7d49917d2155;hpb=e72f4914ec908eb1af63129346d32d3cbd45b4e0;p=readifood.git diff --git a/lib/contact.php b/lib/contact.php index 56327de..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(); } @@ -578,7 +589,7 @@ } } else if ($parameters[0] == "search") { - search_contacts(0, 10, $parameters[1]); + search_contacts(0, 10, urldecode($parameters[1])); } } list($name, $id, $args) = parse_parameters($parameters);