Changeset:
8d8697fc032c
https://sourceforge.net/p/mrbs/hg-code/ci/8d8697fc032c34c4c83956b8ae84c02edb0e04cd
Author:
Campbell Morrison <[email protected]>
Date:
Sun Apr 02 16:56:22 2017 +0100
Log message:
Merge with default
diffstat:
web/edit_entry_handler.php | 1 -
web/functions_table.inc | 2534 ++++++++++++++++++++++----------------------
2 files changed, 1267 insertions(+), 1268 deletions(-)
diffs (truncated from 2549 to 300 lines):
diff -r 32ff03eb6c8e -r 8d8697fc032c web/edit_entry_handler.php
--- a/web/edit_entry_handler.php Wed Mar 29 14:30:30 2017 +0100
+++ b/web/edit_entry_handler.php Sun Apr 02 16:56:22 2017 +0100
@@ -604,7 +604,6 @@
}
}
-
// If we haven't been given a sensible date then get out of here and don't try
and make a booking
if (!isset($start_day) || !isset($start_month) || !isset($start_year) ||
!checkdate($start_month, $start_day, $start_year))
{
diff -r 32ff03eb6c8e -r 8d8697fc032c web/functions_table.inc
--- a/web/functions_table.inc Wed Mar 29 14:30:30 2017 +0100
+++ b/web/functions_table.inc Sun Apr 02 16:56:22 2017 +0100
@@ -1,1267 +1,1267 @@
-<?php
-namespace MRBS;
-
-// width of the row label columns in the day and week views
-$first_last_width = 1; // (%)
-$column_hidden_width = 0; // (%) width of the column for hidden days (set to
0 for no column at all; 1 for a narrow column);
- // when $times_along_top is TRUE, hidden days
(rows) are not shown at all
-
-function map_add_booking ($entry, &$column, $am7, $pm7)
-{
- // Enters the contents of the booking found in $entry into $column, which is
- // a column of the map of the bookings being prepared ready for display.
- //
- // $column the column of the map that is being prepared (see below)
- // $entry a booking from the database
- // $am7 the start of the first slot of the booking day (Unix timestamp)
- // $pm7 the start of the last slot of the booking day (Unix timestamp)
-
- // $entry is expected to have the following keys, when present:
- // room_id
- // start_time
- // end_time
- // name
- // repeat_id
- // id
- // type
- // description
- // create_by
- // status
-
- // $column is a column of the map of the screen that will be displayed
- // It looks like:
- // $column[s][n][id]
- // [is_repeat]
- // [is_multiday_start] a boolean indicating if the booking
stretches
- // beyond the day start
- // [is_multiday_end] a boolean indicating if the booking
stretches
- // beyond the day end
- // [color]
- // [data]
- // [long_descr]
- // [create_by]
- // [room_id]
- // [start_time]
- // [slots]
- // [status]
-
- // s is the number of nominal seconds (ie ignoring DST changes] since the
- // start of the calendar day which has the start of the booking day
-
- // slots records the duration of the booking in number of time slots.
- // Used to calculate how high to make the block used for clipping
- // overflow descriptions.
-
- // Fill in the map for this meeting. Start at the meeting start time,
- // or the day start time, whichever is later. End one slot before the
- // meeting end time (since the next slot is for meetings which start then),
- // or at the last slot in the day, whichever is earlier.
- // Time is of the format HHMM without leading zeros.
- //
- // [n] exists because it's possible that there may be multiple bookings
- // in the same time slot. Normally this won't be the case. However it
- // can arise legitimately if you increase the resolution, or shift the
- // displayed day. For example if you previously had a resolution of 1800
- // seconds you might have a booking (A) for 1000-1130 and another (B) for
1130-1230.
- // If you then increase the resolution to 3600 seconds, these two bookings
- // will both occupy the 1100-1200 time slot. [n] starts at 0. For
- // the example above the map for the room would look like this
- //
- // 0 1
- // 1000 A
- // 1100 A B
- // 1200 B
- //
- // Adjust the starting and ending times so that bookings which don't
- // start or end at a recognized time still appear.
-
- global $resolution;
- global $is_private_field;
-
- $user = getUserName();
- if (is_private_event($entry['status'] & STATUS_PRIVATE) &&
- !getWritable($entry['create_by'], $user, $entry['room_id']))
- {
- $entry['status'] |= STATUS_PRIVATE; // Set the private bit
- if ($is_private_field['entry.name'])
- {
- $entry['name'] = "[".get_vocab('unavailable')."]";
- }
- if ($is_private_field['entry.description'])
- {
- $entry['description'] = "[".get_vocab('unavailable')."]";
- }
- if (!empty($is_private_field['entry.type']))
- {
- $entry['type'] = 'private_type';
- }
- }
- else
- {
- $entry['status'] &= ~STATUS_PRIVATE; // Clear the private bit
- }
-
- $is_multiday_start = ($entry['start_time'] < $am7);
- $is_multiday_end = ($entry['end_time'] > ($pm7 + $resolution));
-
- $start_t = max(round_t_down($entry['start_time'], $resolution, $am7), $am7);
- $end_t = min(round_t_up($entry['end_time'], $resolution, $am7) -
$resolution, $pm7);
-
- // calculate the times used for indexing - we index by nominal seconds since
the start
- // of the calendar day which has the start of the booking day
- $start_s = nominal_seconds($start_t);
- $end_s = nominal_seconds($end_t);
-
- for ($s = $start_s; $s <= $end_s; $s += $resolution)
- {
- // find the first free index (in case there are multiple bookings in a
timeslot)
- $n = 0;
- while (!empty($column[$s][$n]["id"]))
- {
- $n++;
- }
-
- // fill in the id, type and start time
- $column[$s][$n]["id"] = $entry['id'];
- $column[$s][$n]["is_repeat"] = isset($entry['repeat_id']);
- $column[$s][$n]["is_multiday_start"] = $is_multiday_start;
- $column[$s][$n]["is_multiday_end"] = $is_multiday_end;
- $column[$s][$n]["status"] = $entry['status'];
- $column[$s][$n]["color"] = $entry['type'];
- $column[$s][$n]["start_time"] = hour_min($start_s);
- $column[$s][$n]["slots"] = NULL; // to avoid undefined index NOTICE errors
- // if it's a multiple booking also fill in the name and description
- if ($n > 0)
- {
- $column[$s][$n]["data"] = $entry['name'];
- $column[$s][$n]["long_descr"] = $entry['description'];
- $column[$s][$n]["create_by"] = $entry['create_by'];
- $column[$s][$n]["room_id"] = $entry['room_id'];
- }
- // otherwise just leave them blank (we'll fill in the first whole slot
later)
- // use NULL rather than '' just in case the value really is ''
- else
- {
- $column[$s][$n]["data"] = NULL;
- $column[$s][$n]["long_descr"] = NULL;
- $column[$s][$n]["create_by"] = NULL;
- $column[$s][$n]["room_id"] = NULL;
- }
- } // end for
-
-
- // Show the name of the booker, the description and the number of complete
- // slots in the first complete slot that the booking happens in, or at the
- // start of the day if it started before today.
-
- // Find the number of time slots that the booking occupies, and the index
- // of the first slot that this booking has entirely to itself
- // We need to adjust the start and end times for DST transitions as the
display
- // ignores DST
- $n_slots = intval((($end_t - $start_t) - cross_dst($start_t,
$end_t))/$resolution) + 1;
- $first_slot = $start_s;
-
- // If the last time slot is already occupied, we have a multiple
- // booking in the last slot, so decrement the number of slots that
- // we will display for this booking
- if (isset($column[$end_s][1]["id"]))
- {
- $n_slots--;
- // If we're only the second booking to land on this time slot
- // then we'll have to adjust the information held for the first booking
- // (unless it's just one slot long in the first place, when it
- // doesn't matter as it will now be part of a multiple booking).
- // If we are the third booking or more, then it will have already
- // been adjusted.
- if (!isset($column[$end_s][2]["id"]))
- {
- if ($column[$end_s][0]["slots"] > 1)
- {
- // Move the name and description into the new first slot and decrement
the number of slots
- $column[$end_s + $resolution][0]["data"] =
$column[$end_s][0]["data"];
- $column[$end_s + $resolution][0]["long_descr"] =
$column[$end_s][0]["long_descr"];
- $column[$end_s + $resolution][0]["create_by"] =
$column[$end_s][0]["create_by"];
- $column[$end_s + $resolution][0]["room_id"] =
$column[$end_s][0]["room_id"];
- $column[$end_s + $resolution][0]["slots"] =
$column[$end_s][0]["slots"] - 1;
- }
- }
- }
-
- // and if the first time slot is already occupied, decrement
- // again, adjust the first slot for this booking
- if (isset($column[$start_s][1]["id"]))
- {
- $n_slots--;
- $first_slot += $resolution;
- // If we're only the second booking to land on this time slot
- // then we'll have to adjust the information held for the first booking
- if (!isset($column[$start_s][2]["id"]))
- {
- // Find the first slot ($s) of the first booking
- $first_booking_id = $column[$start_s][0]["id"];
- $r = $start_s;
- // If you've got to the first slot of the day then that must be the
- // first slot of the first booking
- while ($r > $am7)
- {
- // Otherwise, step back one slot.
- $r -= $resolution;
- // If that slot contains the first booking, then step back again
- if (isset($column[$r]))
- {
- foreach ($column[$r] as $booking)
- {
- if ($booking["id"] == $first_booking_id)
- {
- continue 2; // next iteration of the while loop
- }
- }
- }
- // If not, then we've stepped back one slot past the start of
- // the first booking, so step forward again and finish
- $r += $resolution;
- break;
- } // end while
-
- // Now we've found the time ($r) of the first slot of the first booking
- // we need to find its index ($i)
- foreach ($column[$r] as $i => $booking)
- {
- if ($booking["id"] == $first_booking_id)
- {
- break;
- }
- }
-
- // Finally decrement the slot count for the first booking
- // no need to worry about count going < 1: the multiple booking display
- // does not use the slot count.
- $column[$r][$i]["slots"]--;
- // and put the name and description in the multiply booked slot
- $column[$start_s][0]["data"] = $column[$r][$i]["data"];
- $column[$start_s][0]["long_descr"] = $column[$r][$i]["long_descr"];
- $column[$start_s][0]["create_by"] = $column[$r][$i]["create_by"];
- $column[$start_s][0]["room_id"] = $column[$r][$i]["room_id"];
- }
- }
-
- // now we've got all the information we can enter it in the first complete
- // slot for the booking (provided it's not a multiple booking slot)
- if (!isset($column[$first_slot][1]["id"]))
- {
- $column[$first_slot][0]["data"] = $entry['name'];
- $column[$first_slot][0]["long_descr"] = $entry['description'];
- $column[$first_slot][0]["create_by"] = $entry['create_by'];
- $column[$first_slot][0]["room_id"] = $entry['room_id'];
- $column[$first_slot][0]["slots"] = $n_slots;
- }
-
-} // end function map_add_booking()
-
-
-
-function cell_html($cell, $query_strings, $is_invalid = FALSE)
-{
- // draws a single cell in the main table of the day and week views
- //
- // $cell is a two dimensional array that is part of the map of the whole
- // display and looks like this:
- //
- // $cell[n][id]
- // [is_repeat]
- // [is_multiday_start]
- // [is_multiday_end]
- // [color]
- // [data]
- // [long_descr]
- // [create_by]
- // [room_id]
- // [start_time]
- // [slots]
- // [status]
- //
- // where n is the number of the booking in the cell. There can be none,
one or many
- // bookings in a cell. If there are no bookings then a blank cell is
drawn with a link
- // to the edit entry form. If there is one booking, then the booking is
shown in that
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits