From d15b1d004258adf5b366ab5432555dccd2351a23 Mon Sep 17 00:00:00 2001 From: Magdalena Holczik Date: Tue, 22 Oct 2024 15:36:37 +0200 Subject: [PATCH] GH-638 apply billboard in conditions --- .../bo_availability/conditions/allowedtobookininstance.php | 4 ++++ classes/bo_availability/conditions/alreadybooked.php | 6 +++++- classes/bo_availability/conditions/alreadyreserved.php | 6 +++++- classes/bo_availability/conditions/booking_time.php | 6 +++++- classes/bo_availability/conditions/bookingpolicy.php | 6 +++++- classes/bo_availability/conditions/bookondetail.php | 6 +++++- .../bo_availability/conditions/campaign_blockbooking.php | 4 ++++ classes/bo_availability/conditions/customform.php | 6 +++++- classes/bo_availability/conditions/enrolledincohorts.php | 4 ++++ classes/bo_availability/conditions/enrolledincourse.php | 4 ++++ classes/bo_availability/conditions/fullybooked.php | 6 +++++- classes/bo_availability/conditions/isbookable.php | 6 +++++- classes/bo_availability/conditions/isbookableinstance.php | 6 +++++- classes/bo_availability/conditions/iscancelled.php | 6 +++++- classes/bo_availability/conditions/isloggedin.php | 6 +++++- .../bo_availability/conditions/max_number_of_bookings.php | 6 +++++- classes/bo_availability/conditions/notifymelist.php | 6 +++++- classes/bo_availability/conditions/optionhasstarted.php | 6 +++++- classes/bo_availability/conditions/previouslybooked.php | 4 ++++ classes/bo_availability/conditions/selectusers.php | 6 +++++- classes/bo_availability/conditions/subbooking.php | 6 +++++- classes/bo_availability/conditions/subbooking_blocks.php | 6 +++++- .../conditions/userprofilefield_1_default.php | 6 +++++- .../conditions/userprofilefield_2_custom.php | 6 +++++- 24 files changed, 115 insertions(+), 19 deletions(-) diff --git a/classes/bo_availability/conditions/allowedtobookininstance.php b/classes/bo_availability/conditions/allowedtobookininstance.php index 54d59b257..ea80d9009 100644 --- a/classes/bo_availability/conditions/allowedtobookininstance.php +++ b/classes/bo_availability/conditions/allowedtobookininstance.php @@ -410,6 +410,10 @@ public function render_button( * @return string */ private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } global $DB; if ($isavailable) { diff --git a/classes/bo_availability/conditions/alreadybooked.php b/classes/bo_availability/conditions/alreadybooked.php index fb18334ba..1f649642c 100644 --- a/classes/bo_availability/conditions/alreadybooked.php +++ b/classes/bo_availability/conditions/alreadybooked.php @@ -245,7 +245,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondalreadybookedfullavailable', 'mod_booking') : get_string('bocondalreadybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/alreadyreserved.php b/classes/bo_availability/conditions/alreadyreserved.php index e99ce71e9..cfcd4c6d9 100644 --- a/classes/bo_availability/conditions/alreadyreserved.php +++ b/classes/bo_availability/conditions/alreadyreserved.php @@ -242,7 +242,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondalreadyreservedfullavailable', 'mod_booking') : get_string('bocondalreadyreservedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/booking_time.php b/classes/bo_availability/conditions/booking_time.php index c2c8896e3..3872c8b19 100644 --- a/classes/bo_availability/conditions/booking_time.php +++ b/classes/bo_availability/conditions/booking_time.php @@ -333,7 +333,11 @@ public function render_button(booking_option_settings $settings, * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = get_string('bocondbookingtimeavailable', 'mod_booking'); } else { diff --git a/classes/bo_availability/conditions/bookingpolicy.php b/classes/bo_availability/conditions/bookingpolicy.php index 25307de3c..94705a21f 100644 --- a/classes/bo_availability/conditions/bookingpolicy.php +++ b/classes/bo_availability/conditions/bookingpolicy.php @@ -256,7 +256,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondalreadybookedfullavailable', 'mod_booking') : get_string('bocondalreadybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/bookondetail.php b/classes/bo_availability/conditions/bookondetail.php index 3f31ef018..7c7f2044a 100644 --- a/classes/bo_availability/conditions/bookondetail.php +++ b/classes/bo_availability/conditions/bookondetail.php @@ -251,7 +251,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondalreadybookedfullavailable', 'mod_booking') : get_string('bocondalreadybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/campaign_blockbooking.php b/classes/bo_availability/conditions/campaign_blockbooking.php index 0c3403be2..24d2e4813 100644 --- a/classes/bo_availability/conditions/campaign_blockbooking.php +++ b/classes/bo_availability/conditions/campaign_blockbooking.php @@ -237,6 +237,10 @@ public function render_button( * @return string */ private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = ''; } else { diff --git a/classes/bo_availability/conditions/customform.php b/classes/bo_availability/conditions/customform.php index 50392ca9f..9b130edd8 100644 --- a/classes/bo_availability/conditions/customform.php +++ b/classes/bo_availability/conditions/customform.php @@ -495,7 +495,11 @@ public function render_button(booking_option_settings $settings, * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('boconduserprofilefieldfullavailable', 'mod_booking') : get_string('boconduserprofilefieldavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/enrolledincohorts.php b/classes/bo_availability/conditions/enrolledincohorts.php index b83148f84..4a3e62d65 100644 --- a/classes/bo_availability/conditions/enrolledincohorts.php +++ b/classes/bo_availability/conditions/enrolledincohorts.php @@ -522,6 +522,10 @@ public function render_button( * @return string */ private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } global $DB; if ($isavailable) { diff --git a/classes/bo_availability/conditions/enrolledincourse.php b/classes/bo_availability/conditions/enrolledincourse.php index 0323a8cfa..aff43de45 100644 --- a/classes/bo_availability/conditions/enrolledincourse.php +++ b/classes/bo_availability/conditions/enrolledincourse.php @@ -429,6 +429,10 @@ public function render_button( * @return string */ private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } global $DB; if ($isavailable) { diff --git a/classes/bo_availability/conditions/fullybooked.php b/classes/bo_availability/conditions/fullybooked.php index 0b2018a56..11bccb28b 100644 --- a/classes/bo_availability/conditions/fullybooked.php +++ b/classes/bo_availability/conditions/fullybooked.php @@ -248,7 +248,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondfullybookedfullavailable', 'mod_booking') : get_string('bocondfullybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/isbookable.php b/classes/bo_availability/conditions/isbookable.php index 182d71b83..a0d230577 100644 --- a/classes/bo_availability/conditions/isbookable.php +++ b/classes/bo_availability/conditions/isbookable.php @@ -229,7 +229,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondisbookablefullavailable', 'mod_booking') : get_string('bocondisbookableavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/isbookableinstance.php b/classes/bo_availability/conditions/isbookableinstance.php index 79f58c601..db8d2b2fa 100644 --- a/classes/bo_availability/conditions/isbookableinstance.php +++ b/classes/bo_availability/conditions/isbookableinstance.php @@ -224,7 +224,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondisbookablefullavailable', 'mod_booking') : get_string('bocondisbookableavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/iscancelled.php b/classes/bo_availability/conditions/iscancelled.php index e30fbb16a..e16eba0b1 100644 --- a/classes/bo_availability/conditions/iscancelled.php +++ b/classes/bo_availability/conditions/iscancelled.php @@ -217,7 +217,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondiscancelledfullavailable', 'mod_booking') : get_string('bocondiscancelledavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/isloggedin.php b/classes/bo_availability/conditions/isloggedin.php index 5744816be..6effce42f 100644 --- a/classes/bo_availability/conditions/isloggedin.php +++ b/classes/bo_availability/conditions/isloggedin.php @@ -230,7 +230,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondisloggedinfullavailable', 'mod_booking') : get_string('bocondisloggedinavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/max_number_of_bookings.php b/classes/bo_availability/conditions/max_number_of_bookings.php index 2ff4a6f63..550abda5a 100644 --- a/classes/bo_availability/conditions/max_number_of_bookings.php +++ b/classes/bo_availability/conditions/max_number_of_bookings.php @@ -240,7 +240,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondmaxnumberofbookingsfullavailable', 'mod_booking') : get_string('bocondmaxnumberofbookingsavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/notifymelist.php b/classes/bo_availability/conditions/notifymelist.php index fb171dd33..2a790d395 100644 --- a/classes/bo_availability/conditions/notifymelist.php +++ b/classes/bo_availability/conditions/notifymelist.php @@ -269,7 +269,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondalreadybookedfullavailable', 'mod_booking') : get_string('bocondalreadybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/optionhasstarted.php b/classes/bo_availability/conditions/optionhasstarted.php index 947fa6a11..34316052a 100644 --- a/classes/bo_availability/conditions/optionhasstarted.php +++ b/classes/bo_availability/conditions/optionhasstarted.php @@ -227,7 +227,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondoptionhasstartedfullavailable', 'mod_booking') : get_string('bocondoptionhasstartedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/previouslybooked.php b/classes/bo_availability/conditions/previouslybooked.php index 863fe5fc6..5ce2ae7c9 100644 --- a/classes/bo_availability/conditions/previouslybooked.php +++ b/classes/bo_availability/conditions/previouslybooked.php @@ -402,6 +402,10 @@ public function render_button( */ private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } + if ($isavailable) { $description = $full ? get_string('bocondpreviouslybookedfullavailable', 'mod_booking') : get_string('bocondpreviouslybookedavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/selectusers.php b/classes/bo_availability/conditions/selectusers.php index a381aece9..413190f03 100644 --- a/classes/bo_availability/conditions/selectusers.php +++ b/classes/bo_availability/conditions/selectusers.php @@ -403,7 +403,11 @@ public function render_button(booking_option_settings $settings, * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } global $DB; if ($isavailable) { $description = $full ? get_string('bocondselectusersfullavailable', 'mod_booking') : diff --git a/classes/bo_availability/conditions/subbooking.php b/classes/bo_availability/conditions/subbooking.php index 558f96d61..95b4362a2 100644 --- a/classes/bo_availability/conditions/subbooking.php +++ b/classes/bo_availability/conditions/subbooking.php @@ -249,7 +249,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondsubbookingfullavailable', 'mod_booking') : get_string('bocondsubbookingavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/subbooking_blocks.php b/classes/bo_availability/conditions/subbooking_blocks.php index 2d827074c..8acbd2172 100644 --- a/classes/bo_availability/conditions/subbooking_blocks.php +++ b/classes/bo_availability/conditions/subbooking_blocks.php @@ -246,7 +246,11 @@ public function render_button( * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondisbookablefullavailable', 'mod_booking') : get_string('bocondisbookableavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/userprofilefield_1_default.php b/classes/bo_availability/conditions/userprofilefield_1_default.php index 6faee6d3d..6382f93bb 100644 --- a/classes/bo_availability/conditions/userprofilefield_1_default.php +++ b/classes/bo_availability/conditions/userprofilefield_1_default.php @@ -506,7 +506,11 @@ public function render_button(booking_option_settings $settings, * @param booking_option_settings $settings * @return string */ - private function get_description_string($isavailable, $full, $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('boconduserprofilefieldfullavailable', 'mod_booking') : get_string('boconduserprofilefieldavailable', 'mod_booking'); diff --git a/classes/bo_availability/conditions/userprofilefield_2_custom.php b/classes/bo_availability/conditions/userprofilefield_2_custom.php index 11ce217fc..3ce70cdd7 100644 --- a/classes/bo_availability/conditions/userprofilefield_2_custom.php +++ b/classes/bo_availability/conditions/userprofilefield_2_custom.php @@ -630,7 +630,11 @@ public function render_button(booking_option_settings $settings, * @param booking_option_settings $settings * @return string */ - private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings, booking_option_settings $settings) { + private function get_description_string(bool $isavailable, bool $full, booking_option_settings $settings) { + + if (!$isavailable && !empty($desc = bo_info::apply_billboard($this, $settings))) { + return $desc; + } if ($isavailable) { $description = $full ? get_string('bocondcustomuserprofilefieldfullavailable', 'mod_booking') : get_string('bocondcustomuserprofilefieldavailable', 'mod_booking');