X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=inline;f=lib%2Fcontact.php;h=fdbd169aa3873e4f926a74e1628f9aa6eca69315;hb=009c426bb2c9a34e5e7d7527242536da3bea7aaa;hp=56327de6e736e6367f731eeb948c7d49917d2155;hpb=e72f4914ec908eb1af63129346d32d3cbd45b4e0;p=readifood.git
diff --git a/lib/contact.php b/lib/contact.php
index 56327de..fdbd169 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();
}
@@ -578,7 +593,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);