From: Iain Patterson Date: Tue, 9 Apr 2013 22:27:17 +0000 (-0400) Subject: Standardise contact and hub display. X-Git-Tag: 2013-04-10~7 X-Git-Url: http://git.iain.cx/?p=readifood.git;a=commitdiff_plain;h=508e918941009544a3992b8ac6815671b93880ca Standardise contact and hub display. Contacts and hubs are very similar, having roles, addresses and entity-specific attributes. Use similar functions and layout when showing them both. --- diff --git a/lib/contact.php b/lib/contact.php index 166fd97..ccc932c 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -44,8 +44,9 @@ exit; } - function show_contact_summary(&$contact) { - echo "
\nContact " . $contact->getLink(); + function show_contact_summary(&$contact, $editing = false) { + if ($editing) echo "

Contact: " . htmlspecialchars($contact->getDisplayname()) . ""; + else echo "
\nContact " . $contact->getStrongLink(); $role = $contact->getRole(); $role_string = get_contact_role_string($contact); if ($role_string) echo " $role_string"; @@ -57,6 +58,8 @@ } $area = get_contact_area($contact); echo " in " . $area->getLink(); + $city = get_contact_city($contact); + echo ", " . $city->getLink(get_city_displayname($city)); } function show_contacts($offset, $per_page, $address_ids) { @@ -422,18 +425,7 @@ if (! $contact) return; echo "

\n"; - echo "

Contact: " . $contact->getDisplayname() . ""; - $role = $contact->getRole(); - $role_string = get_contact_role_string($contact); - if ($role_string) echo " $role_string"; - if ($role & $GLOBALS['ROLE_DONOR']) printf(" Donations", urlencode($contact->getDisplayname()), $contact->getId()); - if ($role & $GLOBALS['ROLE_REQUESTER']) printf(" Referred", urlencode($contact->getDisplayname()), $contact->getId()); - if ($role & $GLOBALS['ROLE_BENEFICIARY']) printf(" Orders", urlencode($contact->getDisplayname()), $contact->getId()); - if (check_admin(1)) { - echo " " . $contact->getDeleteLink(); - } - $city = get_contact_city($contact); - if ($city) echo " in " . $city->getLink(get_city_displayname($city)); + show_contact_summary($contact, true); echo ": "; echo "\n

";