functions_table.inc (mrbs-1.9.4) | : | functions_table.inc (mrbs-1.10.0) | ||
---|---|---|---|---|
<?php | <?php | |||
namespace MRBS; | namespace MRBS; | |||
use \IntlDateFormatter; | use \IntlDateFormatter; | |||
function map_add_booking(array $entry, &$column, $start_first_slot, $start_last_ | // Prepares an entry for display by (a) adding in registration level information | |||
slot) | // and (b) replacing the text in private fields if necessary. | |||
function prepare_entry(array $entry) : array | ||||
{ | ||||
global $is_private_field, $show_registration_level, $auth; | ||||
// Add in the registration level details | ||||
if ($show_registration_level && $entry['allow_registration']) | ||||
{ | ||||
// Check whether we should be showing the registrants' names | ||||
$show_names = ($auth['show_registrant_names_in_calendar'] && ($entry['n_regi | ||||
stered'] > 0)); | ||||
if ($show_names && !$auth['show_registrant_names_in_public_calendar']) | ||||
{ | ||||
// If we're not allowed to show names in the public calendar, check that t | ||||
he user is logged in | ||||
// and has an access level of at least 1 | ||||
$mrbs_user = session()->getCurrentUser(); | ||||
$show_names = isset($mrbs_user) && ($mrbs_user->level > 0); | ||||
} | ||||
$names = ($show_names) ? implode(', ', auth()->getRegistrantsDisplayNames($e | ||||
ntry)) : ''; | ||||
if ($entry['registrant_limit_enabled']) | ||||
{ | ||||
$tag = ($show_names) ? 'registration_level_limited_with_names' : 'registra | ||||
tion_level_limited'; | ||||
$entry['name'] .= get_vocab($tag, $entry['n_registered'], $entry['registra | ||||
nt_limit'], $names); | ||||
} | ||||
else | ||||
{ | ||||
$tag = ($show_names) ? 'registration_level_unlimited_with_names' : 'regist | ||||
ration_level_unlimited'; | ||||
$entry['name'] .= get_vocab($tag, $entry['n_registered'], $names); | ||||
} | ||||
} | ||||
// Check whether the event is private | ||||
if (is_private_event($entry['private']) && | ||||
!getWritable($entry['create_by'], $entry['room_id'])) | ||||
{ | ||||
$entry['private'] = true; | ||||
foreach (array('name', 'description') as $key) | ||||
{ | ||||
if ($is_private_field["entry.$key"]) | ||||
{ | ||||
$entry[$key] = '[' . get_vocab('unavailable') . ']'; | ||||
} | ||||
} | ||||
if (!empty($is_private_field['entry.type'])) | ||||
{ | ||||
$entry['type'] = 'private_type'; | ||||
} | ||||
} | ||||
else | ||||
{ | ||||
$entry['private'] = false; | ||||
} | ||||
return $entry; | ||||
} | ||||
function map_add_booking(array $entry, &$column, $start_first_slot, $start_last_ | ||||
slot) : void | ||||
{ | { | |||
// Enters the contents of the booking found in $entry into $column, which is | // 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. | // 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) | // $column the column of the map that is being prepared (see below) | |||
// $entry a booking from the database | // $entry a booking from the database | |||
// $start_first_slot the start of the first slot of the booking day (Unix tim estamp) | // $start_first_slot the start of the first slot of the booking day (Unix tim estamp) | |||
// $start_last_slot the start of the last slot of the booking day (Unix time stamp) | // $start_last_slot the start of the last slot of the booking day (Unix time stamp) | |||
// $entry is expected to have the following keys, when present: | // $entry is expected to have the following keys, when present: | |||
skipping to change at line 58 | skipping to change at line 116 | |||
// s is the number of nominal seconds (ie ignoring DST changes] since the | // 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 | // start of the calendar day which has the start of the booking day | |||
// Fill in the map for this meeting. Start at the meeting start time, | // 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 | // 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), | // meeting end time (since the next slot is for meetings which start then), | |||
// or at the last slot in the day, whichever is earlier. | // or at the last slot in the day, whichever is earlier. | |||
// Time is of the format HHMM without leading zeros. | // Time is of the format HHMM without leading zeros. | |||
global $resolution; | global $resolution; | |||
global $is_private_field; | ||||
// We're only interested in entries which occur on this day (it's possible | // We're only interested in entries which occur on this day (it's possible | |||
// for $entry to contain entries for other days) | // for $entry to contain entries for other days) | |||
if (($entry['start_time'] >= $start_last_slot + $resolution) || | if (($entry['start_time'] >= $start_last_slot + $resolution) || | |||
($entry['end_time'] <= $start_first_slot)) | ($entry['end_time'] <= $start_first_slot)) | |||
{ | { | |||
return; | return; | |||
} | } | |||
// Check whether the event is private | $entry = prepare_entry($entry); | |||
if (is_private_event($entry['private']) && | ||||
!getWritable($entry['create_by'], $entry['room_id'])) | ||||
{ | ||||
$entry['private'] = true; | ||||
foreach (array('name', 'description') as $key) | ||||
{ | ||||
if ($is_private_field["entry.$key"]) | ||||
{ | ||||
$entry[$key] = '[' . get_vocab('unavailable') . ']'; | ||||
} | ||||
} | ||||
if (!empty($is_private_field['entry.type'])) | ||||
{ | ||||
$entry['type'] = 'private_type'; | ||||
} | ||||
} | ||||
else | ||||
{ | ||||
$entry['private'] = false; | ||||
} | ||||
// Adjust the starting and ending times so that bookings which don't | // Adjust the starting and ending times so that bookings which don't | |||
// start or end at a recognized time still appear. | // start or end at a recognized time still appear. | |||
$start_t = max(round_t_down($entry['start_time'], $resolution, $start_first_sl ot), $start_first_slot); | $start_t = max(round_t_down($entry['start_time'], $resolution, $start_first_sl ot), $start_first_slot); | |||
$end_t = min(round_t_up($entry['end_time'], $resolution, $start_first_slot) - $resolution, $start_last_slot); | $end_t = min(round_t_up($entry['end_time'], $resolution, $start_first_slot) - $resolution, $start_last_slot); | |||
// Calculate the times used for indexing - we index by nominal seconds since t he start | // Calculate the times used for indexing - we index by nominal seconds since t he start | |||
// of the calendar day which has the start of the booking day | // of the calendar day which has the start of the booking day | |||
$start_s = nominal_seconds($start_t); | $start_s = nominal_seconds($start_t); | |||
$end_s = nominal_seconds($end_t); | $end_s = nominal_seconds($end_t); | |||
skipping to change at line 121 | skipping to change at line 156 | |||
{ | { | |||
if (!isset($column[$s])) | if (!isset($column[$s])) | |||
{ | { | |||
$column[$s] = array(); | $column[$s] = array(); | |||
} | } | |||
array_push($column[$s], $entry); | array_push($column[$s], $entry); | |||
} | } | |||
} // end function map_add_booking() | } // end function map_add_booking() | |||
function map_coalesce_bookings(&$column) | function map_coalesce_bookings(&$column) : void | |||
{ | { | |||
// Coalesces map entries for a room that span consecutive time slots. | // Coalesces map entries for a room that span consecutive time slots. | |||
// | // | |||
// The map_add_booking() function set n_slots=1 for all map entries. For each | // The map_add_booking() function set n_slots=1 for all map entries. For each | |||
// booking in the room that spans multiple consecutive time slots, and that | // booking in the room that spans multiple consecutive time slots, and that | |||
// does not have conflicting bookings, the first entry will have its slot | // does not have conflicting bookings, the first entry will have its slot | |||
// count adjusted, and the continuation entries will have their n_slots | // count adjusted, and the continuation entries will have their n_slots | |||
// attribute set to NULL. | // attribute set to NULL. | |||
// | // | |||
// $column the column of the map to analyze, from map_add_booking() | // $column the column of the map to analyze, from map_add_booking() | |||
skipping to change at line 175 | skipping to change at line 210 | |||
foreach ($column[$s] as &$booking) | foreach ($column[$s] as &$booking) | |||
{ | { | |||
$booking['n_slots'] = 1; | $booking['n_slots'] = 1; | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} // end function map_coalesce_bookings() | } // end function map_coalesce_bookings() | |||
// Returns an array of classes to be used for the entry | // Returns an array of classes to be used for the entry | |||
function get_entry_classes($entry) | function get_entry_classes($entry) : array | |||
{ | { | |||
global $approval_enabled, $confirmation_enabled; | global $approval_enabled, $confirmation_enabled; | |||
$classes = array($entry['type']); | $classes = array($entry['type']); | |||
if ($entry['private']) | if ($entry['private']) | |||
{ | { | |||
$classes[] = 'private'; | $classes[] = 'private'; | |||
} | } | |||
skipping to change at line 217 | skipping to change at line 252 | |||
} | } | |||
else | else | |||
{ | { | |||
$classes[] = 'spaces'; | $classes[] = 'spaces'; | |||
} | } | |||
} | } | |||
return $classes; | return $classes; | |||
} | } | |||
function cell_html(array $cell, array $query_vars, $is_invalid = false) | function cell_html(array $cell, array $query_vars, $is_invalid = false) : string | |||
{ | { | |||
// draws a single cell in the main table of the day and week views | // draws a single cell in the main table of the day and week views | |||
// | // | |||
// $cell is an array of entries that occupy that cell. There can be none, one or many | // $cell is an array of entries that occupy that cell. There can be none, one or many | |||
// bookings in a cell. If there are no bookings then a blank cell is drawn wi th a link | // bookings in a cell. If there are no bookings then a blank cell is drawn wi th a link | |||
// to the edit entry form. If there is one booking, then the booking is sh own in that | // to the edit entry form. If there is one booking, then the booking is sh own in that | |||
// cell. If there is more than one booking then all the bookings are shown. | // cell. If there is more than one booking then all the bookings are shown. | |||
// $query_vars is an array containing the query vars to be used in the link fo r the cell. | // $query_vars is an array containing the query vars to be used in the link fo r the cell. | |||
// It is indexed as follows: | // It is indexed as follows: | |||
skipping to change at line 340 | skipping to change at line 375 | |||
$html .= "</div>"; | $html .= "</div>"; | |||
} | } | |||
} | } | |||
$html .= "</td>\n"; | $html .= "</td>\n"; | |||
} | } | |||
return $html; | return $html; | |||
} // end function draw_cell | } // end function draw_cell | |||
function get_timeslot_text($s, $resolution) | function get_timeslot_text($s, $resolution) : string | |||
{ | { | |||
global $show_slot_endtime; | global $show_slot_endtime; | |||
$result = hour_min($s); | $result = hour_min($s); | |||
if ($show_slot_endtime) | if ($show_slot_endtime) | |||
{ | { | |||
$result .= '-' . hour_min($s + $resolution); | $result .= '-' . hour_min($s + $resolution); | |||
} | } | |||
return $result; | return $result; | |||
} | } | |||
// Draw a time cell to be used in the first and last columns of the day and week views | // Draw a time cell to be used in the first and last columns of the day and week views | |||
// $s the number of seconds since the start of the day (nomin al - not adjusted for DST) | // $s the number of seconds since the start of the day (nomin al - not adjusted for DST) | |||
// $url the url to form the basis of the link in the time cell | // $url the url to form the basis of the link in the time cell | |||
function time_cell_html($s, $url) | function time_cell_html($s, $url) : string | |||
{ | { | |||
global $enable_periods, $resolution; | global $enable_periods, $resolution; | |||
$html = ''; | $html = ''; | |||
$html .= "<th data-seconds=\"$s\">"; | $html .= "<th data-seconds=\"$s\">"; | |||
$html .= '<a href="' . htmlspecialchars($url) . '" title="' . get_vocab("high light_line") . "\">"; | $html .= '<a href="' . htmlspecialchars($url) . '" title="' . get_vocab("high light_line") . "\">"; | |||
if ($enable_periods) | if ($enable_periods) | |||
{ | { | |||
skipping to change at line 383 | skipping to change at line 418 | |||
} | } | |||
$html .= "</a></th>\n"; | $html .= "</a></th>\n"; | |||
return $html; | return $html; | |||
} | } | |||
// Draw a room cell to be used in the header rows/columns of the calendar views | // Draw a room cell to be used in the header rows/columns of the calendar views | |||
// $room contains the room details | // $room contains the room details | |||
// $vars an associative array containing the variables to be used to build the link | // $vars an associative array containing the variables to be used to build the link | |||
function room_cell_html(array $room, array $vars) | function room_cell_html(array $room, array $vars) : string | |||
{ | { | |||
$link = 'index.php?' . http_build_query($vars, '', '&'); | $link = 'index.php?' . http_build_query($vars, '', '&'); | |||
$link = multisite($link); | $link = multisite($link); | |||
switch ($vars['view']) | switch ($vars['view']) | |||
{ | { | |||
case 'day': | case 'day': | |||
$tag = 'viewday'; | $tag = 'viewday'; | |||
break; | break; | |||
case 'week': | case 'week': | |||
skipping to change at line 428 | skipping to change at line 463 | |||
$html .= '</span>'; | $html .= '</span>'; | |||
$html .= '</a>'; | $html .= '</a>'; | |||
$html .= "</th>\n"; | $html .= "</th>\n"; | |||
return $html; | return $html; | |||
} | } | |||
// Draw a day cell to be used in the header rows/columns of the week view | // Draw a day cell to be used in the header rows/columns of the week view | |||
// $text contains the date, formatted as a string (not escaped - allowed to contain HTML tags) | // $text contains the date, formatted as a string (not escaped - allowed to contain HTML tags) | |||
// $link the href to be used for the link | // $link the href to be used for the link | |||
// $date the date in yyyy-mm-dd format | // $date the date in yyyy-mm-dd format | |||
function day_cell_html($text, $link, $date) | function day_cell_html($text, $link, $date) : string | |||
{ | { | |||
$html = ''; | $html = ''; | |||
// Put the date into a data attribute so that it can be picked up by JavaScrip t | // Put the date into a data attribute so that it can be picked up by JavaScrip t | |||
$html .= '<th data-date="' . htmlspecialchars($date) . '">'; | $html .= '<th data-date="' . htmlspecialchars($date) . '">'; | |||
$html .= '<a href="' . htmlspecialchars($link) . '"' . | $html .= '<a href="' . htmlspecialchars($link) . '"' . | |||
' title="' . htmlspecialchars(get_vocab("viewday")) . '">'; | ' title="' . htmlspecialchars(get_vocab("viewday")) . '">'; | |||
$html .= $text; // allowed to contain HTML tags - do not escape | $html .= $text; // allowed to contain HTML tags - do not escape | |||
$html .= '</a>'; | $html .= '</a>'; | |||
$html .= "</th>\n"; | $html .= "</th>\n"; | |||
return $html; | return $html; | |||
} | } | |||
// Output a start table cell tag <td> with class of $classes. | // Output a start table cell tag <td> with class of $classes. | |||
// $classes can be either a string or an array of classes | // $classes can be either a string or an array of classes | |||
// empty or row_highlight if highlighted. | // empty or row_highlight if highlighted. | |||
// $slots is the number of time slots high that the cell should be | // $slots is the number of time slots high that the cell should be | |||
// | // | |||
// $data is an optional third parameter which if set passes an | // $data is an optional third parameter which if set passes an | |||
// associative array of name-value pairs to be used in data attributes | // associative array of name-value pairs to be used in data attributes | |||
function tdcell($classes, $slots, array $data=null) | function tdcell($classes, $slots, ?array $data=null) : string | |||
{ | { | |||
global $times_along_top; | global $times_along_top; | |||
if (isset($classes) && ($classes !== '') && !is_array($classes)) | if (isset($classes) && ($classes !== '') && !is_array($classes)) | |||
{ | { | |||
$classes = array($classes); | $classes = array($classes); | |||
} | } | |||
$html = ''; | $html = ''; | |||
skipping to change at line 487 | skipping to change at line 522 | |||
} | } | |||
} | } | |||
$html .= ">"; | $html .= ">"; | |||
return $html; | return $html; | |||
} | } | |||
// Gets the number of time slots between the beginning and end of the booking | // Gets the number of time slots between the beginning and end of the booking | |||
// day. (This is the normal number on a non-DST transition day) | // day. (This is the normal number on a non-DST transition day) | |||
function get_n_time_slots() | function get_n_time_slots() : int | |||
{ | { | |||
global $morningstarts, $morningstarts_minutes, $eveningends, $eveningends_minu tes; | global $morningstarts, $morningstarts_minutes, $eveningends, $eveningends_minu tes; | |||
global $resolution; | global $resolution; | |||
$start_first = (($morningstarts * 60) + $morningstarts_minutes) * 60; // seconds | $start_first = (($morningstarts * 60) + $morningstarts_minutes) * 60; // seconds | |||
$end_last = ((($eveningends * 60) + $eveningends_minutes) * 60) + $resolution; // seconds | $end_last = ((($eveningends * 60) + $eveningends_minutes) * 60) + $resolution; // seconds | |||
$end_last = $end_last % SECONDS_PER_DAY; | $end_last = $end_last % SECONDS_PER_DAY; | |||
if (day_past_midnight()) | if (day_past_midnight()) | |||
{ | { | |||
$end_last += SECONDS_PER_DAY; | $end_last += SECONDS_PER_DAY; | |||
} | } | |||
return ($end_last - $start_first)/$resolution; | ||||
// Force the result to be an int. It normally will be, but might not be if, s | ||||
ay, | ||||
// $force_resolution is set. | ||||
return intval(($end_last - $start_first)/$resolution); | ||||
} | } | |||
// $s is nominal seconds | // $s is nominal seconds | |||
function get_query_vars($view, $area, $room, $month, $day, $year, $s) | function get_query_vars($view, $area, $room, $month, $day, $year, $s) : array | |||
{ | { | |||
global $morningstarts, $morningstarts_minutes; | global $morningstarts, $morningstarts_minutes; | |||
$result = array(); | $result = array(); | |||
// check to see if the time is really on the next day | // check to see if the time is really on the next day | |||
$date = getdate(mktime(0, 0, $s, $month, $day, $year)); | $date = getdate(mktime(0, 0, $s, $month, $day, $year)); | |||
if (hm_before($date, | if (hm_before($date, | |||
array('hours' => $morningstarts, 'minutes' => $morningstarts_min utes))) | array('hours' => $morningstarts, 'minutes' => $morningstarts_min utes))) | |||
{ | { | |||
skipping to change at line 533 | skipping to change at line 571 | |||
'day' => $day, | 'day' => $day, | |||
'area' => $area); | 'area' => $area); | |||
$result['booking'] = $vars; | $result['booking'] = $vars; | |||
$result['new_periods'] = array_merge($vars, array('room' => $room, 'period' => $period)); | $result['new_periods'] = array_merge($vars, array('room' => $room, 'period' => $period)); | |||
$result['new_times'] = array_merge($vars, array('room' => $room, 'hour' => $ hour, 'minute' => $minute)); | $result['new_times'] = array_merge($vars, array('room' => $room, 'hour' => $ hour, 'minute' => $minute)); | |||
return $result; | return $result; | |||
} | } | |||
function get_times_header_cells($start, $end, $increment) | function get_times_header_cells($start, $end, $increment) : string | |||
{ | { | |||
global $enable_periods; | global $enable_periods; | |||
$html = ''; | $html = ''; | |||
for ($s = $start; $s <= $end; $s += $increment) | for ($s = $start; $s <= $end; $s += $increment) | |||
{ | { | |||
// Put the number of seconds since the start of the day (nominal, ignoring D ST) | // Put the number of seconds since the start of the day (nominal, ignoring D ST) | |||
// in a data attribute so that JavaScript can pick it up | // in a data attribute so that JavaScript can pick it up | |||
$html .= "<th data-seconds=\"$s\">"; | $html .= "<th data-seconds=\"$s\">"; | |||
skipping to change at line 562 | skipping to change at line 600 | |||
{ | { | |||
$html .= htmlspecialchars(get_timeslot_text($s, $increment)); | $html .= htmlspecialchars(get_timeslot_text($s, $increment)); | |||
} | } | |||
$html .= "</span>"; | $html .= "</span>"; | |||
$html .= "</th>\n"; | $html .= "</th>\n"; | |||
} | } | |||
return $html; | return $html; | |||
} | } | |||
function get_rooms_header_cells($rooms, $vars) | function get_rooms_header_cells($rooms, $vars) : string | |||
{ | { | |||
$html = ''; | $html = ''; | |||
foreach($rooms as $room) | foreach($rooms as $room) | |||
{ | { | |||
$vars['room'] = $room['id']; | $vars['room'] = $room['id']; | |||
$html .= room_cell_html($room, $vars); | $html .= room_cell_html($room, $vars); | |||
} | } | |||
return $html; | return $html; | |||
} | } | |||
function day_table_innerhtml($view, $year, $month, $day, $area_id, $room_id, $ti metohighlight=null) | function day_table_innerhtml($view, $year, $month, $day, $area_id, $room_id, $ti metohighlight=null) : string | |||
{ | { | |||
global $enable_periods; | global $enable_periods; | |||
global $times_along_top, $row_labels_both_sides, $column_labels_both_ends; | global $times_along_top, $row_labels_both_sides, $column_labels_both_ends; | |||
global $resolution, $morningstarts, $morningstarts_minutes; | global $resolution, $morningstarts, $morningstarts_minutes; | |||
$rooms = get_rooms($area_id); | $rooms = get_rooms($area_id); | |||
$n_rooms = count($rooms); | $n_rooms = count($rooms); | |||
if ($n_rooms == 0) | if ($n_rooms == 0) | |||
{ | { | |||
skipping to change at line 820 | skipping to change at line 858 | |||
$tbody .= "</tbody>\n"; | $tbody .= "</tbody>\n"; | |||
return $thead . $tfoot . $tbody; | return $thead . $tfoot . $tbody; | |||
} | } | |||
// Returns the HTML for a booking, or a free set of slots | // Returns the HTML for a booking, or a free set of slots | |||
// $slots The number of slots occupied | // $slots The number of slots occupied | |||
// $classes A scalar or array giving the class or classes to be used in the class attribute | // $classes A scalar or array giving the class or classes to be used in the class attribute | |||
// $title The value of the title attribute | // $title The value of the title attribute | |||
// $text The value of the text to be used in the div | // $text The value of the text to be used in the div | |||
function get_flex_div($slots, $classes, $title=null, $text=null) | function get_flex_div($slots, $classes, $title=null, $text=null) : string | |||
{ | { | |||
$result = "<div style=\"flex: $slots\""; | $result = "<div style=\"flex: $slots\""; | |||
if (isset($classes)) | if (isset($classes)) | |||
{ | { | |||
$value = (is_array($classes)) ? implode(' ', $classes) : $classes; | $value = (is_array($classes)) ? implode(' ', $classes) : $classes; | |||
$result .= ' class="' . htmlspecialchars($value) . '"'; | $result .= ' class="' . htmlspecialchars($value) . '"'; | |||
} | } | |||
if (isset($title) && ($title !== '')) | if (isset($title) && ($title !== '')) | |||
skipping to change at line 847 | skipping to change at line 885 | |||
if (isset($text) && ($text != '')) | if (isset($text) && ($text != '')) | |||
{ | { | |||
$result .= htmlspecialchars($title); | $result .= htmlspecialchars($title); | |||
} | } | |||
$result .= '</div>'; | $result .= '</div>'; | |||
return $result; | return $result; | |||
} | } | |||
function week_table_innerhtml($view, $view_all, $year, $month, $day, $area_id, $ room_id, $timetohighlight) | function week_table_innerhtml($view, $view_all, $year, $month, $day, $area_id, $ room_id, $timetohighlight) : string | |||
{ | { | |||
if ($view_all) | if ($view_all) | |||
{ | { | |||
return multiday_view_all_rooms_innerhtml($view, $view_all, $year, $month, $d ay, $area_id, $room_id); | return multiday_view_all_rooms_innerhtml($view, $view_all, $year, $month, $d ay, $area_id, $room_id); | |||
} | } | |||
else | else | |||
{ | { | |||
return week_room_table_innerhtml($view, $view_all, $year, $month, $day, $are a_id, $room_id, $timetohighlight); | return week_room_table_innerhtml($view, $view_all, $year, $month, $day, $are a_id, $room_id, $timetohighlight); | |||
} | } | |||
} | } | |||
function get_date($t, $view) | function get_date($t, $view) : string | |||
{ | { | |||
global $strftime_format; | global $strftime_format; | |||
if ($view == 'month') | if ($view == 'month') | |||
{ | { | |||
return utf8_strftime('%e', $t); | return utf8_strftime('%e', $t); | |||
} | } | |||
else | else | |||
{ | { | |||
return utf8_strftime($strftime_format['weekview_date'], $t); | return utf8_strftime($strftime_format['weekview_date'], $t); | |||
skipping to change at line 1337 | skipping to change at line 1375 | |||
$t = mktime(12, 0, 0, $month, $day_start_week+$j, $year); | $t = mktime(12, 0, 0, $month, $day_start_week+$j, $year); | |||
$date = date('Y-m-d', $t); | $date = date('Y-m-d', $t); | |||
if (is_hidden_day(($j + $weekstarts) % DAYS_PER_WEEK)) | if (is_hidden_day(($j + $weekstarts) % DAYS_PER_WEEK)) | |||
{ | { | |||
continue; | continue; | |||
} | } | |||
$vars = array('view' => 'day', | $vars = array('view' => 'day', | |||
'view_all' => $view_all, | 'view_all' => $view_all, | |||
'year' => strftime("%Y", $t), | 'year' => utf8_strftime("%Y", $t), | |||
'month' => strftime("%m", $t), | 'month' => utf8_strftime("%m", $t), | |||
'day' => strftime('%d', $t), | 'day' => utf8_strftime('%d', $t), | |||
'area' => $area_id, | 'area' => $area_id, | |||
'room' => $room_id); | 'room' => $room_id); | |||
$link = 'index.php?' . http_build_query($vars, '', '&'); | $link = 'index.php?' . http_build_query($vars, '', '&'); | |||
$link = multisite($link); | $link = multisite($link); | |||
$text = utf8_strftime($dformat, $t); | $text = utf8_strftime($dformat, $t); | |||
$header_inner .= day_cell_html($text, $link, $date); | $header_inner .= day_cell_html($text, $link, $date); | |||
} | } | |||
unset($j); // Just so that we pick up any accidental attempt to use it late r | unset($j); // Just so that we pick up any accidental attempt to use it late r | |||
} // end standard view (for the header) | } // end standard view (for the header) | |||
skipping to change at line 1392 | skipping to change at line 1430 | |||
$wt = mktime( 12, 0, 0, $month, $day_start_week + $thisday, $year ); | $wt = mktime( 12, 0, 0, $month, $day_start_week + $thisday, $year ); | |||
$wday = date("d", $wt); | $wday = date("d", $wt); | |||
$wmonth = date("m", $wt); | $wmonth = date("m", $wt); | |||
$wyear = date("Y", $wt); | $wyear = date("Y", $wt); | |||
$wdate = date('Y-n-d', $wt); | $wdate = date('Y-n-d', $wt); | |||
$day_cell_text = utf8_strftime($dformat, $wt); | $day_cell_text = utf8_strftime($dformat, $wt); | |||
$vars = array('view' => 'day', | $vars = array('view' => 'day', | |||
'view_all' => $view_all, | 'view_all' => $view_all, | |||
'year' => strftime("%Y", $wt), | 'year' => utf8_strftime("%Y", $wt), | |||
'month' => strftime("%m", $wt), | 'month' => utf8_strftime("%m", $wt), | |||
'day' => strftime("%d", $wt), | 'day' => utf8_strftime("%d", $wt), | |||
'area' => $area_id, | 'area' => $area_id, | |||
'room' => $room_id); | 'room' => $room_id); | |||
$day_cell_link = 'index.php?' . http_build_query($vars, '', '&'); | $day_cell_link = 'index.php?' . http_build_query($vars, '', '&'); | |||
$day_cell_link = multisite($day_cell_link); | $day_cell_link = multisite($day_cell_link); | |||
$row_label = day_cell_html($day_cell_text, $day_cell_link, $wdate); | $row_label = day_cell_html($day_cell_text, $day_cell_link, $wdate); | |||
$tbody .= $row_label; | $tbody .= $row_label; | |||
for ($s = $morning_slot_seconds; | for ($s = $morning_slot_seconds; | |||
$s <= $evening_slot_seconds; | $s <= $evening_slot_seconds; | |||
skipping to change at line 1637 | skipping to change at line 1675 | |||
else | else | |||
{ | { | |||
return month_room_table_innerhtml($view, $view_all, $year, $month, $day, $ar ea, $room); | return month_room_table_innerhtml($view, $view_all, $year, $month, $day, $ar ea, $room); | |||
} | } | |||
} | } | |||
function month_room_table_innerhtml($view, $view_all, $year, $month, $day, $area , $room) | function month_room_table_innerhtml($view, $view_all, $year, $month, $day, $area , $room) | |||
{ | { | |||
global $weekstarts, $view_week_number, $show_plus_link, $monthly_view_entries_ details; | global $weekstarts, $view_week_number, $show_plus_link, $monthly_view_entries_ details; | |||
global $enable_periods, $morningstarts, $morningstarts_minutes; | global $enable_periods, $morningstarts, $morningstarts_minutes; | |||
global $is_private_field; | ||||
// Check that we've got a valid, enabled room | // Check that we've got a valid, enabled room | |||
if (is_null(get_room_name($room)) || !is_visible($room)) | if (is_null(get_room_name($room)) || !is_visible($room)) | |||
{ | { | |||
// No rooms have been created yet, or else they are all disabled | // No rooms have been created yet, or else they are all disabled | |||
// Add an 'empty' data flag so that the JavaScript knows whether this is a r eal table or not | // Add an 'empty' data flag so that the JavaScript knows whether this is a r eal table or not | |||
return "<tbody data-empty=1><tr><td><h1>".get_vocab("no_rooms_for_area")."</ h1></td></tr></tbody>"; | return "<tbody data-empty=1><tr><td><h1>".get_vocab("no_rooms_for_area")."</ h1></td></tr></tbody>"; | |||
} | } | |||
$html = ''; | $html = ''; | |||
skipping to change at line 1766 | skipping to change at line 1803 | |||
// Show the start/stop times, 1 or 2 per line, linked to view_entry. | // Show the start/stop times, 1 or 2 per line, linked to view_entry. | |||
foreach ($entries as $entry) | foreach ($entries as $entry) | |||
{ | { | |||
// We are only interested in this day's entries | // We are only interested in this day's entries | |||
if (($entry['start_time'] >= $end_last_slot) || | if (($entry['start_time'] >= $end_last_slot) || | |||
($entry['end_time'] <= $start_first_slot)) | ($entry['end_time'] <= $start_first_slot)) | |||
{ | { | |||
continue; | continue; | |||
} | } | |||
// Handle private events | $entry = prepare_entry($entry); | |||
if (is_private_event($entry['private']) && | ||||
!getWritable($entry['create_by'], $room)) | ||||
{ | ||||
$entry['private'] = true; | ||||
if ($is_private_field['entry.name']) | ||||
{ | ||||
$entry['name'] = "[".get_vocab('unavailable')."]"; | ||||
} | ||||
if (!empty($is_private_field['entry.type'])) | ||||
{ | ||||
$entry['type'] = 'private_type'; | ||||
} | ||||
} | ||||
else | ||||
{ | ||||
$entry['private'] = false; | ||||
} | ||||
$classes = get_entry_classes($entry); | $classes = get_entry_classes($entry); | |||
$classes[] = $monthly_view_entries_details; | $classes[] = $monthly_view_entries_details; | |||
$html .= '<div class="' . implode(' ', $classes) . '">'; | $html .= '<div class="' . implode(' ', $classes) . '">'; | |||
$vars = array('id' => $entry["id"], | $vars = array('id' => $entry["id"], | |||
'year' => $year, | 'year' => $year, | |||
'month' => $month, | 'month' => $month, | |||
'day' => $d); | 'day' => $d); | |||
End of changes. 24 change blocks. | ||||
68 lines changed or deleted | 95 lines changed or added |