Revision: 1295
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1295&view=rev
Author:   cimorrison
Date:     2010-02-10 16:31:57 +0000 (Wed, 10 Feb 2010)

Log Message:
-----------
Fixed bug which caused the duration to be blank in email notifications for 
bookings when "All day" was checked.

Modified Paths:
--------------
    mrbs/trunk/web/edit_entry_handler.php
    mrbs/trunk/web/functions.inc

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2010-02-10 12:53:12 UTC (rev 
1294)
+++ mrbs/trunk/web/edit_entry_handler.php       2010-02-10 16:31:57 UTC (rev 
1295)
@@ -222,17 +222,17 @@
   $minute = $period;
 }
 
-// Get the duration in seconds
-$dur_seconds = $duration;
-$enable_periods ? fromPeriodString($period, $dur_seconds, $dur_units) : 
fromTimeString($dur_seconds, $dur_units);
-
-
 if (isset($all_day) && ($all_day == "yes"))
 {
-  if ( $enable_periods )
+  if ($enable_periods)
   {
+    $max_periods = count($periods);
     $starttime = mktime(12, 0, 0, $month, $day, $year);
     $endtime   = mktime(12, $max_periods, 0, $month, $day, $year);
+    // We need to set the duration and units because they are needed for email 
notifications
+    $duration = $max_periods;
+    $dur_units = "periods";
+    // No need to convert into something sensible, because they already are
   }
   else
   {
@@ -245,10 +245,19 @@
     $endtime += $resolution;                // add on the duration (in 
seconds) of the last slot as
                                             // $eveningends and 
$eveningends_minutes specify the 
                                             // beginning of the last slot
+    // We need to set the duration and units because they are needed for email 
notifications
+    $duration = $endtime - $starttime;
+    $dur_units = "seconds";
+    // Convert them into something sensible (but don't translate because
+    // that's done later)
+    toTimeString($duration, $dur_units, FALSE);
   }
 }
 else
 {
+  // Get the duration in seconds
+  $dur_seconds = $duration;
+  $enable_periods ? fromPeriodString($period, $dur_seconds, $dur_units) : 
fromTimeString($dur_seconds, $dur_units);
   if (!$twentyfourhour_format)
   {
     if (isset($ampm) && ($ampm == "pm") && ($hour<12))

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2010-02-10 12:53:12 UTC (rev 1294)
+++ mrbs/trunk/web/functions.inc        2010-02-10 16:31:57 UTC (rev 1295)
@@ -104,7 +104,7 @@
 }
 
 
-function toTimeString(&$dur, &$units)
+function toTimeString(&$dur, &$units, $translate=TRUE)
 {
   if (abs($dur) >= 60)
   {
@@ -125,38 +125,43 @@
           if ((abs($dur) >= 52) && ($dur % 52 == 0))
           {
             $dur  /= 52;
-            $units = get_vocab("years");
+            $units = "years";
           }
           else
           {
-            $units = get_vocab("weeks");
+            $units = "weeks";
           }
         }
         else
         {
-          $units = get_vocab("days");
+          $units = "days";
         }
       }
       else
       {
-        $units = get_vocab("hours");
+        $units = "hours";
       }
     }
     else
     {
-      $units = get_vocab("minutes");
+      $units = "minutes";
     }
   }
   else
   {
-    $units = get_vocab("seconds");
+    $units = "seconds";
   }
+  // Translate into local language if required
+  if ($translate)
+  {
+    $units = get_vocab($units);
+  }
 }
 
 
 // Converts a time period of $units into seconds, when it is originally
 // expressed in $dur_units.   (Almost the inverse of toTimeString(),
-// but note that toTimeString() does language translation)
+// but note that toTimeString() can do language translation)
 function fromTimeString(&$units, $dur_units)
 {
   if (!isset($units) || !isset($dur_units))
@@ -184,7 +189,7 @@
 }
 
 
-function toPeriodString($start_period, &$dur, &$units)
+function toPeriodString($start_period, &$dur, &$units, $translate=TRUE)
 {
   global $periods;
 
@@ -196,7 +201,7 @@
   {
     if( $start_period == 0 && $dur == $max_periods )
     {
-      $units = get_vocab("days");
+      $units = $translate ? get_vocab("days") : "days";
       $dur = 1;
       return;
     }
@@ -205,26 +210,26 @@
     if(($dur >= 24) && is_int($dur))
     {
       $dur /= 24;
-      $units = get_vocab("days");
+      $units = $translate ? get_vocab("days") : "days";
       return;
     }
     else
     {
       $dur *= 60;
       $dur = ($dur % $max_periods) + floor( $dur/(24*60) ) * $max_periods;
-      $units = get_vocab("periods");
+      $units = $translate ? get_vocab("periods") : "periods";
       return;
     }
   }
   else
   {
-    $units = get_vocab("periods");
+    $units = $translate ? get_vocab("periods") : "periods";
   }
 }
 
 // Converts a period of $units starting at $start_period into seconds, when it 
is
 // originally expressed in $dur_units (periods or days).   (Almost the inverse 
of
-// toPeriodString(), but note that toPeriodString() does language translation)
+// toPeriodString(), but note that toPeriodString() can do language 
translation)
 function fromPeriodString($start_period, &$units, $dur_units)
 {
   global $periods;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to