Split hub roles.
[readifood.git] / lib / functions.php
index b019e93..86c8140 100644 (file)
     return get_city_contacts($city_id, $GLOBALS['ROLE_DRIVER']);
   }
 
-  function get_contact_role_string($contact) {
-    global $roles;
-
-    $role = $contact->getRole();
+  function get_role_string($object, $roles) {
+    $role = $object->getRole();
 
     $selected = array();
 
     return implode(", ", $selected);
   }
 
+  function get_contact_role_string($contact) {
+    return get_role_string($contact, $GLOBALS['contact_roles']);
+  }
+
+  function get_hub_role_string($hub) {
+    return get_role_string($hub, $GLOBALS['hub_roles']);
+  }
+
+  function show_role_form($role, $roles) {
+    for ($i = 0; $i < count($roles); $i++) {
+      echo " <input type=\"checkbox\" name=\"role_$i\"";
+      if ($role & (1 << $i)) echo " checked";
+      echo ">$roles[$i]\n";
+    }
+  }
+
   function get_area_hubs($area_id = null) {
     $q = new HubQuery;
     if (isset($area_id)) $q->useAddressQuery()->filterByAreaId($area_id)->endUse();