Revision: 2588
          https://sourceforge.net/p/mrbs/code/2588/
Author:   cimorrison
Date:     2012-12-12 18:17:37 +0000 (Wed, 12 Dec 2012)
Log Message:
-----------
Fixed problem with misleading email notifications (see SF Bugs 255)

Modified Paths:
--------------
    mrbs/trunk/web/approve_entry_handler.php
    mrbs/trunk/web/functions_mail.inc
    mrbs/trunk/web/mrbs_sql.inc

Modified: mrbs/trunk/web/approve_entry_handler.php
===================================================================
--- mrbs/trunk/web/approve_entry_handler.php    2012-12-12 13:50:19 UTC (rev 
2587)
+++ mrbs/trunk/web/approve_entry_handler.php    2012-12-12 18:17:37 UTC (rev 
2588)
@@ -22,6 +22,7 @@
 
 // Initialise $mail_previous so that we can use it as a parameter for 
notifyAdminOnBooking
 $mail_previous = array();
+$start_times = array();
 
 // Give the return URL a query string if it doesn't already have one
 if (strpos($returl, '?') === FALSE)
@@ -100,7 +101,7 @@
     // so that we will kniow whether to include iCalendar information in the 
email)
     get_area_settings($data['area_id']);
     // Send the email
-    $result = notifyAdminOnBooking($data, $mail_previous, $is_new_entry, 
$series, $action, $note);
+    $result = notifyAdminOnBooking($data, $mail_previous, $is_new_entry, 
$series, $start_times, $action, $note);
   }
 }
 

Modified: mrbs/trunk/web/functions_mail.inc
===================================================================
--- mrbs/trunk/web/functions_mail.inc   2012-12-12 13:50:19 UTC (rev 2587)
+++ mrbs/trunk/web/functions_mail.inc   2012-12-12 18:17:37 UTC (rev 2588)
@@ -359,15 +359,14 @@
 // Generate a list of repeat dates for a series
 //
 // $reps is an array of start_times that have been created/modified/deleted.
-// If not specified the function works them out for itself from the repeat data
-// [In the future it would be better if everything passed in $reps]
-function create_repeat_list($data, $action, $as_html, $reps=NULL)
+function create_repeat_list($data, $action, $as_html, $reps)
 {
   global $max_rep_entrys;
   
-  if ($data['rep_type'] == REP_NONE)
+  if (($data['rep_type'] == REP_NONE) ||
+       in_array($action, array('more_info', 'remind')))
   {
-    return;
+    return '';
   }
 
   // The introductory text
@@ -391,20 +390,6 @@
     }
   }
   
-  if (!isset($reps))
-  {
-    $reps = mrbsGetRepeatEntryList($data['start_time'], 
-                                   $data['end_date'],
-                                   $rep_details, 
-                                   $max_rep_entrys);
-  
-    // Remove any dates that could not be booked due to conflicts              
                 
-    if (!empty($data['skip_list']))
-    {
-      $reps = array_diff($reps, $data['skip_list']);
-    }
-  }
-                                                         
   $result .= create_date_list($reps, $as_html);
   
   // Now add in the list of repeat bookings that could not be booked
@@ -424,7 +409,7 @@
 
 // $start_times is an array of start_times that have been 
created/modified/deleted.
 // If not specified the function works them out for itself from the repeat data
-function create_body($data, $mail_previous, $compare, $series, $action, 
$as_html=FALSE, $note='', $start_times=NULL)
+function create_body($data, $mail_previous, $compare, $series, $action, 
$as_html=FALSE, $note='', $start_times)
 {
   global $returl, $mrbs_company;
   global $enable_periods, $approval_enabled, $confirmation_enabled;
@@ -905,11 +890,12 @@
  * @param array   $mail_previous contains the data for the previous entry, or 
is an empty array
  * @param bool    $new_entry     whether this is a new entry or not
  * @param bool    $series        whether this is a series or not
+ * @param   array $start_times   an array of start times that have been made
  * @param string  $action        the booking action (eg "delete", "more_info", 
etc.)
  * @param string  $note          a note that is used with "more_info"
  * @return bool                  TRUE or PEAR error object if fails
  */
-function notifyAdminOnBooking($data, $mail_previous, $new_entry, $series, 
$action="book", $note='')
+function notifyAdminOnBooking($data, $mail_previous, $new_entry, $series, 
$start_times, $action="book", $note='')
 {
   global $mail_settings, $enable_periods;
   
@@ -976,13 +962,13 @@
   // Create the text body
   $compare = !$new_entry;
   $text_body = array();
-  $text_body['content'] = create_body($data, $mail_previous, $compare, 
$series, $action, FALSE, $note);
+  $text_body['content'] = create_body($data, $mail_previous, $compare, 
$series, $action, FALSE, $note, $start_times);
   
   // Create the HTML body
   $html_body = array();
   if ($mail_settings['html'])
   {
-    $html_body['content'] = create_body($data, $mail_previous, $compare, 
$series, $action, TRUE, $note);
+    $html_body['content'] = create_body($data, $mail_previous, $compare, 
$series, $action, TRUE, $note, $start_times);
     $html_body['cid'] = generate_global_uid("html");
   }
   

Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2012-12-12 13:50:19 UTC (rev 2587)
+++ mrbs/trunk/web/mrbs_sql.inc 2012-12-12 18:17:37 UTC (rev 2588)
@@ -1043,6 +1043,12 @@
       fatal_error(FALSE, get_vocab("fatal_db_error"));
     }
   }
+  
+  if (is_array($start_times))
+  {
+    asort($start_times);
+  }
+  
   return $start_times;
 }
 
@@ -1626,6 +1632,7 @@
       $details = mrbsCreateRepeatingEntrys($booking);
       $new_id = $details['id'];
       $is_repeat_table = $details['series'];
+      asort($details['start_times']);
       $result['start_times'] = $details['start_times'];
     }
     else
@@ -1679,7 +1686,7 @@
           $mail_previous = array();
         }
         // Send the email
-        notifyAdminOnBooking($booking, $mail_previous, !isset($id), 
$is_repeat_table);
+        notifyAdminOnBooking($booking, $mail_previous, !isset($id), 
$is_repeat_table, $result['start_times']);
       }
     }   
   } // end foreach $bookings
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to