X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=inline;f=lib%2Fhub.php;h=79051f8bc120c0a5d08c05c9891c7c0111d860cf;hb=643b013ffaadfb032001ed0dde02176a2c382313;hp=48b45ae992ff64808ef3b55691abfcd275869a61;hpb=6fdbfe32798452ec1c0fdbda57edabb892518409;p=readifood.git diff --git a/lib/hub.php b/lib/hub.php index 48b45ae..79051f8 100644 --- a/lib/hub.php +++ b/lib/hub.php @@ -40,18 +40,28 @@ exit; } + function show_hub_summary(&$hub, $editing = false) { + if ($editing) echo "
Hub: " . htmlspecialchars($hub->getName()) . "";
+ else echo "
\nHub " . $hub->getStrongLink();
+ $role = $hub->getRole();
+ $role_string = get_hub_role_string($hub);
+ if ($role_string) echo " $role_string";
+ if ($role & $GLOBALS['ROLE_COLLECTION']) printf(" Donations", urlencode($hub->getName()), $hub->getId());
+ if ($role & $GLOBALS['ROLE_DISTRIBUTION']) printf(" Orders", urlencode($hub->getName()), $hub->getId());
+ if (check_admin(1)) {
+ echo " " . $hub->getDeleteLink();
+ }
+ $area = get_hub_area($hub);
+ if ($area) echo " in " . $area->getLink();
+ $city = get_hub_city($hub);
+ if ($city) echo ", " . $city->getLink(get_city_displayname($city));
+ }
+
function show_hubs($offset, $per_page, $address_ids) {
$q = new HubQuery;
$hubs = $q->filterByAddressId($address_ids)->find();
if (count($hubs)) {
- foreach ($hubs as $hub) {
- echo "
\nhub " . $hub->getLink();
- if (check_admin(1)) {
- echo " " . $hub->getDeleteLink();
- }
- $area = get_hub_area($hub);
- echo " in " . $area->getLink();
- }
+ foreach ($hubs as $hub) show_hub_summary($hub);
}
else echo " none";
}
@@ -70,7 +80,7 @@
$address_ids = array();
foreach ($addresses as $address) $address_ids[] = $address->getId();
- echo "
hubs in city " . $city->getLink(get_city_displayname($city)) . ":"; + echo "
Hubs in city " . $city->getLink(get_city_displayname($city)) . ":"; return show_hubs($offset, $per_page, $address_ids); } else echo "
No such city!
\n"; @@ -98,7 +108,6 @@ return; } - echo "\n"; } function show_hub_cities_form($city_id = null) { @@ -118,7 +126,6 @@ return; } - echo "\n"; } function show_hub_forms($city_id) { + form("noprint standout"); show_hub_areas_form($city_id); show_hub_cities_form($city_id); + end_form(); + } + + function show_hub_role_form($role) { + return show_role_form($role, $GLOBALS['hub_roles']); } function show_hub_form($hub = null, $area_id = null) { if (! $hub) $hub = new Hub; + /* Role. */ + echo "