Skip to content

Commit

Permalink
GH-638 set defaults, add strings, exclude classes
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Oct 24, 2024
1 parent d15b1d0 commit bfdd20b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion classes/bo_availability/bo_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public static function apply_billboard(bo_condition $condition, booking_option_s
return '';
}
$jsondata = json_decode($instance->settings->json);
if (empty($jsondata->billboardtext)) {
if (empty($jsondata->billboardtext) || empty($jsondata->overwriteblockingwarnings)) {
return '';
}
return format_text($jsondata->billboardtext);
Expand Down
4 changes: 4 additions & 0 deletions lang/de/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
$string['beforecompletedtext_help'] = 'Text der vor dem Abschluss angezeigt wird';
$string['bigbluebuttonmeeting'] = 'BigBlueButton-Meeting';
$string['biggerthan'] = 'ist größer als (Zahl)';
$string['billboardtext'] = 'Text der statt der ursprünglichen Beschreibung angezeigt wird';
$string['blockabove'] = 'Blockiere über';
$string['blockalways'] = 'Blockiere unabhängig von Plätzen';
$string['blockbelow'] = 'Blockiere unter';
Expand Down Expand Up @@ -694,6 +695,8 @@
$string['conditionselectuserfromeventtype'] = 'Rolle wählen';
$string['conditionselectusershoppingcart_desc'] = "Nutzer:in mit Zahlungsverpflichtung ist ausgewählt";
$string['conditionselectusersuserids'] = "Wähle die gewünschten Nutzer:innen";
$string['conditionsoverwritingbillboard'] = 'Überschreiben von Nachrichten zur Buchbarkeit bzw. deren Blockierung ermöglichen';
$string['conditionsoverwritingbillboard_desc'] = 'In den Einstellungen der Buchungsinstanz kann ein Text eingegeben werden, der anstelle von anderen Nachrichten zur (Nicht-)Buchbarkeit angezeigt wird.';
$string['conditiontextfield'] = 'Wert';
$string['configurefields'] = 'Spalten und Felder anpassen';
$string['confirmationmessagesettings'] = 'Buchungsbestätigungseinstellungen';
Expand Down Expand Up @@ -1561,6 +1564,7 @@
$string['overrideoperator'] = 'Operator';
$string['overrideoperator:and'] = 'UND';
$string['overrideoperator:or'] = 'ODER';
$string['overwriteblockingwarnings'] = 'Warnungen mit unten stehendem Text überschreiben';
$string['page:bookingpolicy'] = 'Buchungsbedingungen';
$string['page:bookitbutton'] = 'Buchen';
$string['page:checkout'] = 'Zur Bezahlung';
Expand Down
4 changes: 4 additions & 0 deletions lang/en/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
$string['beforecompletedtext_help'] = 'Message shown after option become booked';
$string['bigbluebuttonmeeting'] = 'BigBlueButton meeting';
$string['biggerthan'] = 'is bigger than (number)';
$string['billboardtext'] = 'Text to be displayed instead of blocking alert text';
$string['blockabove'] = 'Block above';
$string['blockalways'] = 'Block regardless of places';
$string['blockbelow'] = 'Block below';
Expand Down Expand Up @@ -705,6 +706,8 @@
$string['conditionselectuserfromeventtype'] = 'Choose role';
$string['conditionselectusershoppingcart_desc'] = "User with payment obligation is chosen";
$string['conditionselectusersuserids'] = "Select the users you want to target";
$string['conditionsoverwritingbillboard'] = 'Overwrite messages about blocking reasons of bookings';
$string['conditionsoverwritingbillboard_desc'] = 'A text can be entered in the settings of the booking instance that is displayed instead of other messages on blocking reasons of bookings.';
$string['conditiontextfield'] = 'Value';
$string['configurefields'] = 'Configure fields and columns';
$string['confirmactivtyfrom'] = 'Confirm users activity from';
Expand Down Expand Up @@ -1564,6 +1567,7 @@
$string['otherbookingnumber'] = 'Num. of users';
$string['otherbookingoptions'] = 'Accepting from';
$string['otherbookingsuccessfullysaved'] = 'Rule saved!';
$string['overwriteblockingwarnings'] = 'Overwrite blocking warnings with text below';
$string['overridecondition'] = 'Condition';
$string['overrideconditioncheckbox'] = 'Has relation to other condition';
$string['overrideoperator'] = 'Operator';
Expand Down
18 changes: 16 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@
define('MOD_BOOKING_BO_COND_BOOKITBUTTON', -90); // This is only used to show the book it button.
define('MOD_BOOKING_BO_COND_CONFIRMATION', -100); // This is the last page after booking.

// Define the conditions that can not be overwritten via billboard.
define('MOD_BOOKING_CONDTIONS_EXCLUDED_FROM_OVERWRITING_DESCRIPTION_BILLBOARD', [
MOD_BOOKING_BO_COND_ALREADYBOOKED,
MOD_BOOKING_BO_COND_ALREADYRESERVED,
// MOD_BOOKING_BO_COND_ISCANCELLED,
// MOD_BOOKING_BO_COND_ISBOOKABLEINSTANCE,
// MOD_BOOKING_BO_COND_ISBOOKABLE,
MOD_BOOKING_BO_COND_ONWAITINGLIST,
]);

// Define conditions parameters.
define('MOD_BOOKING_CONDPARAM_ALL', 0);
define('MOD_BOOKING_CONDPARAM_HARDCODED_ONLY', 1);
Expand Down Expand Up @@ -288,8 +298,6 @@
define('MOD_BOOKING_CLASSES_EXCLUDED_FROM_CHANGES_TRACKING', [
]);

define('MOD_BOOKING_CONDTIONS_EXCLUDED_FROM_OVERWRITING_DESCRIPTION_BILLBOARD', [
]);
/**
* Booking get coursemodule info.
*
Expand Down Expand Up @@ -856,6 +864,12 @@ function booking_update_instance($booking) {
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, "overwriteblockingwarnings");
} else {
booking::add_data_to_json($booking, "overwriteblockingwarnings", 1);
}
if (empty($booking->billboardtext)) {
// This will store the correct JSON to $optionvalues->json.
booking::remove_key_from_json($booking, "billboardtext");
} else {
Expand Down
4 changes: 4 additions & 0 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,10 @@ public function definition() {
$mform->addElement('advcheckbox', 'overwriteblockingwarnings', get_string("overwriteblockingwarnings", "booking"));
$mform->addElement('textarea', 'billboardtext',
get_string("billboardtext", "booking"), null, null);
$mform->setDefault('overwriteblockingwarnings',
(int)booking::get_value_of_json_by_key($bookingid, 'overwriteblockingwarnings') ?? 0);
$mform->setDefault('billboardtext',
booking::get_value_of_json_by_key($bookingid, 'billboardtext') ?? '');
}

// Booking option text.
Expand Down

0 comments on commit bfdd20b

Please sign in to comment.