diff --git a/classes/bo_availability/bo_info.php b/classes/bo_availability/bo_info.php index 84ff52cb1..4389ec19e 100644 --- a/classes/bo_availability/bo_info.php +++ b/classes/bo_availability/bo_info.php @@ -892,6 +892,32 @@ public static function render_button( return $returnarray; } + /** + * If billboard is activated, we want to overwrite the warning messages with the billboard text. + * + * @param booking_option_settings $settings + * @param string $role + * @param string $label + * + * @return void + * + */ + private static function overwrite_warnings_with_billboard(booking_option_settings $settings, string $role, string &$label) { + // TODO maybe implement settings for plugin if billboard is activated. + if ($role == 'button') { + return; + } + // Fetch settings of instance to see if alert needs to be overwritten. + $instance = singleton_service::get_instance_of_booking_by_bookingid($settings->bookingid); + $jsondata = json_decode($instance->settings->json); + if (empty($jsondata->billboardtext)) { + return; + } + $formattext = format_text($jsondata->billboardtext); + + $label = $formattext; + } + /** * To sort the prepages, depending on blocking conditions array. * This is also used to determine the total number of pages displayed. diff --git a/lib.php b/lib.php index 468d0dfd7..1fd14493f 100755 --- a/lib.php +++ b/lib.php @@ -853,6 +853,12 @@ function booking_update_instance($booking) { } else { booking::add_data_to_json($booking, "disablebooking", 1); } + if (empty($booking->overwriteblockingwarnings)) { + // This will store the correct JSON to $optionvalues->json. + booking::remove_key_from_json($booking, "billboardtext"); + } else { + booking::add_data_to_json($booking, "billboardtext", $booking->billboardtext); + } // Update, delete or insert answers. if (!empty($booking->option)) { diff --git a/mod_form.php b/mod_form.php index 57e9372e9..1ccb4e983 100755 --- a/mod_form.php +++ b/mod_form.php @@ -875,6 +875,10 @@ public function definition() { $mform->addElement('advcheckbox', 'removeuseronunenrol', get_string("removeuseronunenrol", "booking")); + $mform->addElement('advcheckbox', 'overwriteblockingwarnings', get_string("overwriteblockingwarnings", "booking")); + $mform->addElement('textarea', 'billboardtext', + get_string("billboardtext", "booking"), null, null); + // Booking option text. $mform->addElement('header', 'bookingoptiontextheader', get_string('textdependingonstatus', 'booking'));