Revision: 2715
          https://sourceforge.net/p/mrbs/code/2715/
Author:   cimorrison
Date:     2013-03-10 11:29:11 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Made Delete work with this_and_future

Modified Paths:
--------------
    mrbs/branches/this_and_future/web/del_entry.php
    mrbs/branches/this_and_future/web/view_entry.php

Modified: mrbs/branches/this_and_future/web/del_entry.php
===================================================================
--- mrbs/branches/this_and_future/web/del_entry.php     2013-03-10 10:12:40 UTC 
(rev 2714)
+++ mrbs/branches/this_and_future/web/del_entry.php     2013-03-10 11:29:11 UTC 
(rev 2715)
@@ -2,18 +2,14 @@
 // $Id$
 
 // Deletes an entry, or a series.    The $id is always the id of
-// an individual entry.   If $series is set then the entire series
-// of wich $id is a member should be deleted. [Note - this use of
-// $series is inconsistent with use in the rest of MRBS where it
-// means that $id is the id of an entry in the repeat table.   This
-// should be fixed sometime.]
+// an individual entry.
 
 require "defaultincludes.inc";
 require_once "mrbs_sql.inc";
 
 // Get non-standard form variables
 $id = get_form_var('id', 'int');
-$series = get_form_var('series', 'int');
+$time_subset = get_form_var('time_subset', 'int');
 $returl = get_form_var('returl', 'string');
 $action = get_form_var('action', 'string');
 $note = get_form_var('note', 'string', '');
@@ -37,6 +33,7 @@
   $returl .= "?year=$year&month=$month&day=$day&area=$area";
 }
 
+
 if ($info = mrbsGetBookingInfo($id, FALSE, TRUE))
 {
   $user = getUserName();
@@ -68,13 +65,39 @@
       // If this is an individual entry of a series then force the entry_type
       // to be a changed entry, so that when we create the iCalendar object we 
know that
       // we only want to delete the individual entry
-      if (!$series && ($mail_previous['rep_type'] != REP_NONE))
+      if (($time_subset == THIS_ENTRY) && ($mail_previous['rep_type'] != 
REP_NONE))
       {
         $mail_previous['entry_type'] = ENTRY_RPT_CHANGED;
       }
     }
+    
+    // Check to see whether this is the special case of a "this and future" 
booking
+    // where this entry is at the start of the series, in which case it's 
really
+    // the whole series we're dealing with
+    if ($time_subset == THIS_AND_FUTURE)
+    {
+      $original_booking = mrbsGetBooking($id);
+      if ($original_booking['start_time'] == $info['start_time'])
+      {
+        $time_subset = WHOLE_SERIES;
+      }
+    }
+    
+    // If it's a genuine this_and_future operation then it's really a 
modification
+    // of san existing booking.
+    if ($time_subset == THIS_AND_FUTURE)
+    {
+      $original_booking['end_date'] = $info['start_time'] - 1;  // Truncate 
the booking
+      $result = mrbsMakeBookings(array($original_booking), $id, FALSE, FALSE, 
$info['room_id'], $notify_by_email, WHOLE_SERIES);
+      mrbsDelEntry($user, $id, TRUE);
+      Header("Location: $returl");
+      exit();
+    }
+    
+    // Otherwise we go ahead and delete the entry/series
+    $whole_series = ($time_subset == WHOLE_SERIES);
     sql_begin();
-    $start_times = mrbsDelEntry(getUserName(), $id, $series, 1);
+    $start_times = mrbsDelEntry(getUserName(), $id, $whole_series, 1);
     sql_commit();
     // [At the moment MRBS does not inform the user if it was only able to
     // delete some members of a series but not all.    This could happen for
@@ -87,20 +110,18 @@
       if ($notify_by_email)
       {
         // Now that we've finished with mrbsDelEntry, change the id so that 
it's
-        // the repeat_id if we're looking at a series.   (This is a complete 
hack, 
-        // but brings us back into line with the rest of MRBS until the anomaly
-        // of del_entry is fixed) 
-        if ($series)
+        // the repeat_id if we're looking at a series.
+        if ($whole_series)
         {
           $mail_previous['id'] = $mail_previous['repeat_id'];
         }
         if (isset($action) && ($action == "reject"))
         {
-          $result = notifyAdminOnDelete($mail_previous, $series, $start_times, 
$action, $note);
+          $result = notifyAdminOnDelete($mail_previous, $whole_series, 
$start_times, $action, $note);
         }
         else
         {
-          $result = notifyAdminOnDelete($mail_previous, $series, $start_times);
+          $result = notifyAdminOnDelete($mail_previous, $whole_series, 
$start_times);
         }
       }
       Header("Location: $returl");

Modified: mrbs/branches/this_and_future/web/view_entry.php
===================================================================
--- mrbs/branches/this_and_future/web/view_entry.php    2013-03-10 10:12:40 UTC 
(rev 2714)
+++ mrbs/branches/this_and_future/web/view_entry.php    2013-03-10 11:29:11 UTC 
(rev 2715)
@@ -128,21 +128,8 @@
 
 if (isset($delete_button))
 {
-  switch ($time_subset)
-  {
-    case THIS_ENTRY:
-      header("Location: del_entry.php?id=$id&series=0&returl=$returl");
-      break;
-    case THIS_AND_FUTURE:
-      echo "Not yet implemented";
-      exit;
-      break;
-    case WHOLE_SERIES:
-      header("Location: 
del_entry.php?id=$id&series=1&day=$day&month=$month&year=$year&returl=$returl");
-      break;
-    default:
-      break;
-  }
+  header("Location: 
del_entry.php?id=$id&time_subset=$time_subset&day=$day&month=$month&year=$year&returl=$returl");
+  exit;
 }
 
 if (isset($copy_button))
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to