Revision: 2710
          https://sourceforge.net/p/mrbs/code/2710/
Author:   cimorrison
Date:     2013-03-03 14:56:58 +0000 (Sun, 03 Mar 2013)
Log Message:
-----------
Made edit_entry work for this_and_future.   (Email notifications not yet 
working)

Modified Paths:
--------------
    mrbs/branches/this_and_future/web/edit_entry.php
    mrbs/branches/this_and_future/web/edit_entry_handler.php
    mrbs/branches/this_and_future/web/mrbs_sql.inc
    mrbs/branches/this_and_future/web/view_entry.php

Modified: mrbs/branches/this_and_future/web/edit_entry.php
===================================================================
--- mrbs/branches/this_and_future/web/edit_entry.php    2013-03-03 08:53:15 UTC 
(rev 2709)
+++ mrbs/branches/this_and_future/web/edit_entry.php    2013-03-03 14:56:58 UTC 
(rev 2710)
@@ -588,7 +588,7 @@
 $period = get_form_var('period', 'int');
 $id = get_form_var('id', 'int');
 $copy = get_form_var('copy', 'int');
-$edit_type = get_form_var('edit_type', 'string', '');
+$time_subset = get_form_var('time_subset', 'int', THIS_ENTRY);
 $returl = get_form_var('returl', 'string');
 // The following variables are used when coming via a JavaScript drag select
 $drag = get_form_var('drag', 'int');
@@ -832,7 +832,7 @@
     {
       // If we're editing the series we want the start_time and end_time to be 
the
       // start and of the first entry of the series, not the start of this 
entry
-      if ($edit_type == "series")
+      if ($time_subset == WHOLE_SERIES)
       {
         $start_time = $row['start_time'];
         $end_time = $row['end_time'];
@@ -882,7 +882,7 @@
 else
 {
   // It is a new booking. The data comes from whichever button the user clicked
-  $edit_type     = "series";
+  $time_subset   = THIS_ENTRY;
   $name          = "";
   $create_by     = $user;
   $description   = $default_description;
@@ -1088,26 +1088,26 @@
 
 if (isset($id) && !isset($copy))
 {
-  if ($edit_type == "series")
+  if ($time_subset == THIS_ENTRY)
   {
-    $token = "editseries";
+    $token = "editentry";
   }
   else
   {
-    $token = "editentry";
+    $token = "editseries";
   }
 }
 else
 {
   if (isset($copy))
   {
-    if ($edit_type == "series")
+    if ($time_subset == THIS_ENTRY)
     {
-      $token = "copyseries";
+      $token = "copyentry";
     }
     else
     {
-      $token = "copyentry";
+      $token = "copyseries";
     }
   }
   else
@@ -1172,19 +1172,19 @@
 
 
 // Show the repeat fields if (a) it's a new booking and repeats are allowed,
-// or else if it's an existing booking and it's a series.  (It's not 
particularly obvious but
-// if edit_type is "series" then it means that either you're editing an 
existing
-// series or else you're making a new booking.  This should be tidied up 
sometime!)
-if (($edit_type == "series") && $repeats_allowed)
+// or (b) it's an existing booking and it's a series.
+if ( (!isset($id) && $repeats_allowed) ||
+     (isset($id) && ($rep_type != REP_NONE)) )
 {
-  // If repeats aren't allowed or this is not a series then disable
-  // the repeat fields - they're for information only
+  // If repeats aren't allowed then disable the repeat fields - they're for
+  // information only.
+  //
   // (NOTE: when repeat bookings are restricted to admins, an ordinary user
   // would not normally be able to get to the stage of trying to edit a series.
   // But we have to cater for the possibility because it could happen if (a) 
the
   // series was created before the policy was introduced or (b) the user has
   // been demoted since the series was created).
-  $disabled = ($edit_type != "series") || !$repeats_allowed;
+  $disabled = !$repeats_allowed;
   
   echo "<fieldset id=\"rep_info\">\n";
   echo "<legend></legend>\n";
@@ -1342,7 +1342,7 @@
     <input type="hidden" name="returl" value="<?php echo 
htmlspecialchars($returl) ?>">
     <input type="hidden" name="create_by" value="<?php echo 
htmlspecialchars($create_by)?>">
     <input type="hidden" name="rep_id" value="<?php echo $rep_id?>">
-    <input type="hidden" name="edit_type" value="<?php echo $edit_type?>">
+    <input type="hidden" name="time_subset" value="<?php echo $time_subset?>">
     <?php
     // The original_room_id will only be set if this was an existing booking.
     // If it is an existing booking then edit_entry_handler needs to know the

Modified: mrbs/branches/this_and_future/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/this_and_future/web/edit_entry_handler.php    2013-03-03 
08:53:15 UTC (rev 2709)
+++ mrbs/branches/this_and_future/web/edit_entry_handler.php    2013-03-03 
14:56:58 UTC (rev 2710)
@@ -69,7 +69,7 @@
                   'returl'             => 'string',
                   'id'                 => 'int',
                   'rep_id'             => 'int',
-                  'edit_type'          => 'string',
+                  'time_subset'        => 'int',
                   'rep_type'           => 'int',
                   'rep_end_day'        => 'int',
                   'rep_end_month'      => 'int',
@@ -228,6 +228,7 @@
   $end_year = $start_year;
 }
 
+
 // If this is an Ajax request and we're being asked to commit the booking, then
 // we'll only have been supplied with parameters that need to be changed.  
Fill in
 // the rest from the existing boking information.
@@ -237,6 +238,7 @@
 if ($ajax && $commit)
 {
   $old_booking = mrbsGetBookingInfo($id, FALSE);
+  
   foreach ($formvars as $var => $var_type)
   {
     if (!isset($$var) || (($var_type == 'array') && empty($$var)))
@@ -641,13 +643,26 @@
 
 $just_check = $ajax && function_exists('json_encode') && !$commit;
 $this_id = (isset($id)) ? $id : NULL;
-$result = mrbsMakeBookings($bookings, $this_id, $just_check, $skip, 
$original_room_id, $need_to_send_mail, $edit_type);
+$result = mrbsMakeBookings($bookings, $this_id, $just_check, $skip, 
$original_room_id, $need_to_send_mail, $time_subset);
 
 // If we weren't just checking and this was a succesful booking and
 // we were editing an existing booking, then delete the old booking
 if (!$just_check && $result['valid_booking'] && isset($id))
 {
-  mrbsDelEntry($user, $id, ($edit_type == "series"), 1);
+  switch ($time_subset)
+  {
+    case THIS_ENTRY:
+      mrbsDelEntry($user, $id, FALSE);
+      break;
+    case THIS_AND_FUTURE:
+      mrbsDelEntry($user, $id, TRUE, TRUE, $booking['start_time']);
+      break;
+    case WHOLE_SERIES:
+      mrbsDelEntry($user, $id, TRUE, TRUE);
+      break;
+    default:
+      break;
+  }
 }
 
 // If this is an Ajax request, output the result and finish

Modified: mrbs/branches/this_and_future/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/this_and_future/web/mrbs_sql.inc      2013-03-03 08:53:15 UTC 
(rev 2709)
+++ mrbs/branches/this_and_future/web/mrbs_sql.inc      2013-03-03 14:56:58 UTC 
(rev 2710)
@@ -386,12 +386,13 @@
  * $id     - The entry to delete
  * $series - If set, delete the series, except user modified entries
  * $all    - If set, include user modified entries in the series delete
+ * $from   - If set, delete all entries from and including this start_time
  *
  * Returns FALSE if an error occured, otherwise an array of start_times that
  * have been deleted.
  *
  */
-function mrbsDelEntry($user, $id, $series, $all)
+function mrbsDelEntry($user, $id, $series, $all=FALSE, $from=NULL)
 {
   global $tbl_entry, $tbl_repeat;
   
@@ -422,6 +423,11 @@
 
   for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
   {
+    if (isset($from) && ($row['start_time'] < $from))
+    {
+      continue;
+    }
+    
     if(!getWritable($row['create_by'], $user, $room_id))
     {
       continue;

Modified: mrbs/branches/this_and_future/web/view_entry.php
===================================================================
--- mrbs/branches/this_and_future/web/view_entry.php    2013-03-03 08:53:15 UTC 
(rev 2709)
+++ mrbs/branches/this_and_future/web/view_entry.php    2013-03-03 14:56:58 UTC 
(rev 2710)
@@ -122,21 +122,8 @@
 // PHASE 2
 if (isset($edit_button))
 {
-  switch ($time_subset)
-  {
-    case THIS_ENTRY:
-      header("Location: edit_entry.php?id=$id&returl=$returl");
-      break;
-    case THIS_AND_FUTURE:
-      echo "Not yet implemented";
-      exit;
-      break;
-    case WHOLE_SERIES:
-      header("Location: 
edit_entry.php?id=$id&edit_type=series&day=$day&month=$month&year=$year&returl=$returl");
-      break;
-    default:
-      break;
-  }
+  header("Location: 
edit_entry.php?id=$id&time_subset=$time_subset&day=$day&month=$month&year=$year&returl=$returl");
+  exit;
 }
 
 if (isset($delete_button))
@@ -160,21 +147,8 @@
 
 if (isset($copy_button))
 {
-  switch ($time_subset)
-  {
-    case THIS_ENTRY:
-      header("Location: edit_entry.php?id=$id&copy=1&returl=$returl");
-      break;
-    case THIS_AND_FUTURE:
-      echo "Not yet implemented";
-      exit;
-      break;
-    case WHOLE_SERIES:
-      header("Location: 
edit_entry.php?id=$id&copy=1&edit_type=series&day=$day&month=$month&year=$year&returl=$returl");
-      break;
-    default:
-      break;
-  }
+  header("Location: 
edit_entry.php?id=$id&copy=1&time_subset=$time_subset&day=$day&month=$month&year=$year&returl=$returl");
+  exit;
 }
 
 
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to