Fix openID auth paths
[busui.git] / include / common-transit.inc.php
blob:a/include/common-transit.inc.php -> blob:b/include/common-transit.inc.php
--- a/include/common-transit.inc.php
+++ b/include/common-transit.inc.php
@@ -23,21 +23,41 @@
 
 function service_period($date = "") {
 
-    if (isset($_SESSION['service_period']))
-        return $_SESSION['service_period'];
+    if (isset($_REQUEST['service_period'])) {
+        return $_REQUEST['service_period'];
+    }
+
     $override = getServiceOverride($date);
-    if ($override['service_id']) {
-        return $override['service_id'];
-    }
-
-    switch (date('w', ($date != "" ? $date : time()))) {
-        case 0:
-            return 'sunday';
-        case 6:
-            return 'saturday';
+    if (isset($override['service_id'])) {
+        return strtolower($override['service_id']);
+    }
+    $date = ($date != "" ? $date : time());
+    $dow = date('w', $date);
+    
+        switch ($dow) {
+            case 0:
+                return 'sunday';
+            case 6:
+                return 'saturday';
+            default:
+                return 'weekday';
+        }
+}
+
+function service_ids($service_period) {
+    switch ($service_period) {
+        case 'sunday':
+            return Array("Sunday", "Sunday");
+        case 'saturday':
+            return Array("Saturday", "Saturday");
         default:
-            return 'weekday';
-    }
+            //return 'weekday';
+            return Array("Weekday", "Weekday-SchoolVacation");
+    }
+}
+
+function valid_service_ids() {
+    return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday'));
 }
 
 function midnight_seconds($time = "") {