edit_entry_handler.php (mrbs-1.9.4) | : | edit_entry_handler.php (mrbs-1.10.0) | ||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
namespace MRBS; | namespace MRBS; | |||
require 'defaultincludes.inc'; | require 'defaultincludes.inc'; | |||
require_once 'mrbs_sql.inc'; | require_once 'mrbs_sql.inc'; | |||
require_once 'functions_ical.inc'; | require_once 'functions_ical.inc'; | |||
require_once 'functions_mail.inc'; | require_once 'functions_mail.inc'; | |||
use MRBS\Form\Form; | use MRBS\Form\Form; | |||
use MRBS\Form\ElementInputSubmit; | use MRBS\Form\ElementInputSubmit; | |||
function invalid_booking($message) | function invalid_booking(string $message) : void | |||
{ | { | |||
global $view, $view_all, $year, $month, $day, $area, $room; | global $view, $view_all, $year, $month, $day, $area, $room; | |||
$context = array( | $context = array( | |||
'view' => $view, | 'view' => $view, | |||
'view_all' => $view_all, | 'view_all' => $view_all, | |||
'year' => $year, | 'year' => $year, | |||
'month' => $month, | 'month' => $month, | |||
'day' => $day, | 'day' => $day, | |||
'area' => $area, | 'area' => $area, | |||
skipping to change at line 793 | skipping to change at line 793 | |||
db()->begin(); | db()->begin(); | |||
$transaction_ok = true; | $transaction_ok = true; | |||
$result = mrbsMakeBookings($bookings, $this_id, $just_check, $skip, $original_ro om_id, $send_mail, $edit_type); | $result = mrbsMakeBookings($bookings, $this_id, $just_check, $skip, $original_ro om_id, $send_mail, $edit_type); | |||
// If we weren't just checking and this was a successful booking and | // If we weren't just checking and this was a successful booking and | |||
// we were editing an existing booking, then delete the old booking | // we were editing an existing booking, then delete the old booking | |||
if (!$just_check && $result['valid_booking'] && isset($id)) | if (!$just_check && $result['valid_booking'] && isset($id)) | |||
{ | { | |||
$transaction_ok = mrbsDelEntry($id, ($edit_type == "series"), 1); | $transaction_ok = mrbsDelEntry($id, ($edit_type == "series"), true); | |||
} | } | |||
if ($transaction_ok) | if ($transaction_ok) | |||
{ | { | |||
db()->commit(); | db()->commit(); | |||
} | } | |||
else | else | |||
{ | { | |||
db()->rollback(); | db()->rollback(); | |||
trigger_error('Edit failed.', E_USER_WARNING); | trigger_error('Edit failed.', E_USER_WARNING); | |||
skipping to change at line 859 | skipping to change at line 859 | |||
'area' => $area, | 'area' => $area, | |||
'room' => isset($room) ? $room : null | 'room' => isset($room) ? $room : null | |||
); | ); | |||
print_header($context); | print_header($context); | |||
echo "<h2>" . get_vocab("sched_conflict") . "</h2>\n"; | echo "<h2>" . get_vocab("sched_conflict") . "</h2>\n"; | |||
if (!empty($result['violations']['errors'])) | if (!empty($result['violations']['errors'])) | |||
{ | { | |||
echo "<p>\n"; | echo "<p>\n"; | |||
echo get_vocab("rules_broken") . ":\n"; | echo get_vocab("rules_broken") . "\n"; | |||
echo "</p>\n"; | echo "</p>\n"; | |||
echo "<ul>\n"; | echo "<ul>\n"; | |||
foreach ($result['violations']['errors'] as $rule) | foreach ($result['violations']['errors'] as $rule) | |||
{ | { | |||
echo "<li>$rule</li>\n"; | echo "<li>$rule</li>\n"; | |||
} | } | |||
echo "</ul>\n"; | echo "</ul>\n"; | |||
} | } | |||
if (!empty($result['conflicts'])) | if (!empty($result['conflicts'])) | |||
{ | { | |||
skipping to change at line 884 | skipping to change at line 884 | |||
foreach ($result['conflicts'] as $conflict) | foreach ($result['conflicts'] as $conflict) | |||
{ | { | |||
echo "<li>$conflict</li>\n"; | echo "<li>$conflict</li>\n"; | |||
} | } | |||
echo "</ul>\n"; | echo "</ul>\n"; | |||
} | } | |||
} | } | |||
echo "<div id=\"submit_buttons\">\n"; | echo "<div id=\"submit_buttons\">\n"; | |||
// Back button | ||||
$form = new Form(); | $form = new Form(); | |||
$form->setAttributes(array('method' => 'post', | $form->setAttributes(array( | |||
'action' => multisite($returl))); | 'method' => 'post', | |||
'action' => multisite(this_page()) | ||||
)); | ||||
// Back button | ||||
$submit = new ElementInputSubmit(); | $submit = new ElementInputSubmit(); | |||
$submit->setAttribute('value', get_vocab('back')); | $submit->setAttributes(array( | |||
'formaction' => multisite('edit_entry.php'), | ||||
'name' => 'back_button', | ||||
'value' => get_vocab('back') | ||||
)); | ||||
$form->addElement($submit); | $form->addElement($submit); | |||
$form->render(); | ||||
// Skip and Book button (to book the entries that don't conflict) | // Skip and Book button (to book the entries that don't conflict) | |||
// Only show this button if there were no policies broken and it's a series | // Only show this button if there were no policies broken and it's a series | |||
if (empty($result['violations']['errors']) && | if (empty($result['violations']['errors']) && | |||
isset($rep_type) && ($rep_type != REP_NONE)) | isset($rep_type) && ($rep_type != REP_NONE)) | |||
{ | { | |||
$form = new Form(); | $submit = new ElementInputSubmit(); | |||
$submit->setAttributes(array( | ||||
$form->setAttributes(array('method' => 'post', | 'value' => get_vocab('skip_and_book'), | |||
'action' => multisite(this_page()))); | 'title' => get_vocab('skip_and_book_note') | |||
)); | ||||
$form->addElement($submit); | ||||
// Force a skip next time round | ||||
$skip = 1; | ||||
} | ||||
// Put the booking data in as hidden inputs | // Put the booking data in as hidden inputs | |||
$skip = 1; // Force a skip next time round | // First the ordinary fields | |||
// First the ordinary fields | foreach ($form_vars as $var => $var_type) | |||
foreach ($form_vars as $var => $var_type) | { | |||
if ($var_type == 'array') | ||||
{ | { | |||
if ($var_type == 'array') | // See the comment at the top of the page about array formats | |||
foreach ($$var as $value) | ||||
{ | { | |||
// See the comment at the top of the page about array formats | if (isset($value)) | |||
foreach ($$var as $value) | ||||
{ | { | |||
if (isset($value)) | $form->addHiddenInput("${var}[]", $value); | |||
{ | ||||
$form->addHiddenInput("${var}[]", $value); | ||||
} | ||||
} | } | |||
} | } | |||
elseif (isset($$var)) | ||||
{ | ||||
$form->addHiddenInput($var, $$var); | ||||
} | ||||
} | } | |||
// Then the custom fields | elseif (isset($$var)) | |||
foreach($fields as $field) | ||||
{ | { | |||
if (array_key_exists($field['name'], $custom_fields) && isset($custom_fields | $form->addHiddenInput($var, $$var); | |||
[$field['name']])) | ||||
{ | ||||
$form->addHiddenInput(VAR_PREFIX . $field['name'], $custom_fields[$field[' | ||||
name']]); | ||||
} | ||||
} | } | |||
// Submit button | ||||
$submit = new ElementInputSubmit(); | ||||
$submit->setAttributes(array('value' => get_vocab('skip_and_book'), | ||||
'title' => get_vocab('skip_and_book_note'))); | ||||
$form->addElement($submit); | ||||
$form->render(); | ||||
} | } | |||
// Then the custom fields | ||||
foreach($fields as $field) | ||||
{ | ||||
if (array_key_exists($field['name'], $custom_fields) && isset($custom_fields[$ | ||||
field['name']])) | ||||
{ | ||||
$form->addHiddenInput(VAR_PREFIX . $field['name'], $custom_fields[$field['na | ||||
me']]); | ||||
} | ||||
} | ||||
$form->render(); | ||||
echo "</div>\n"; | echo "</div>\n"; | |||
print_footer(); | print_footer(); | |||
End of changes. 18 change blocks. | ||||
44 lines changed or deleted | 45 lines changed or added |