Skip to content

Commit

Permalink
GH-638 create billboard settings
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Oct 24, 2024
1 parent cfcb728 commit 571def9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions classes/bo_availability/bo_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 571def9

Please sign in to comment.