From 5dfcbb4efaf6b4172d95ba13fadf3e8cc97370fb Mon Sep 17 00:00:00 2001 From: Magdalena Holczik Date: Tue, 22 Oct 2024 15:07:39 +0200 Subject: [PATCH] GH-638 get id of condition for apply_billboard --- classes/bo_availability/bo_condition.php | 7 +++++++ classes/bo_availability/bo_info.php | 20 +++++++++++-------- .../conditions/allowedtobookininstance.php | 10 ++++++++++ .../conditions/alreadybooked.php | 10 ++++++++++ .../conditions/alreadyreserved.php | 10 ++++++++++ .../conditions/askforconfirmation.php | 10 ++++++++++ .../conditions/booking_time.php | 10 ++++++++++ .../conditions/bookingpolicy.php | 10 ++++++++++ .../conditions/bookitbutton.php | 10 ++++++++++ .../conditions/bookondetail.php | 10 ++++++++++ .../conditions/bookwithcredits.php | 10 ++++++++++ .../conditions/bookwithsubscription.php | 10 ++++++++++ .../conditions/campaign_blockbooking.php | 10 ++++++++++ .../conditions/cancelmyself.php | 10 ++++++++++ .../conditions/capbookingchoose.php | 10 ++++++++++ .../conditions/confirmation.php | 10 ++++++++++ .../conditions/confirmbookit.php | 10 ++++++++++ .../conditions/confirmbookwithcredits.php | 10 ++++++++++ .../confirmbookwithsubscription.php | 10 ++++++++++ .../conditions/confirmcancel.php | 10 ++++++++++ .../bo_availability/conditions/customform.php | 10 ++++++++++ .../conditions/electivebookitbutton.php | 10 ++++++++++ .../conditions/electivenotbookable.php | 10 ++++++++++ .../conditions/enrolledincohorts.php | 10 ++++++++++ .../conditions/enrolledincourse.php | 10 ++++++++++ .../conditions/fullybooked.php | 10 ++++++++++ .../bo_availability/conditions/isbookable.php | 18 ++++++++++++++++- .../conditions/isbookableinstance.php | 10 ++++++++++ .../conditions/iscancelled.php | 10 ++++++++++ .../bo_availability/conditions/isloggedin.php | 10 ++++++++++ .../conditions/isloggedinprice.php | 11 ++++++++++ .../conditions/max_number_of_bookings.php | 10 ++++++++++ .../conditions/noshoppingcart.php | 11 ++++++++++ .../conditions/notifymelist.php | 11 ++++++++++ .../conditions/onwaitinglist.php | 10 ++++++++++ .../conditions/optionhasstarted.php | 10 ++++++++++ .../conditions/previouslybooked.php | 10 ++++++++++ .../bo_availability/conditions/priceisset.php | 11 ++++++++++ .../conditions/selectusers.php | 10 ++++++++++ .../bo_availability/conditions/subbooking.php | 11 ++++++++++ .../conditions/subbooking_blocks.php | 11 ++++++++++ .../conditions/userprofilefield_1_default.php | 10 ++++++++++ .../conditions/userprofilefield_2_custom.php | 10 ++++++++++ .../subconditions/alreadybooked.php | 10 ++++++++++ .../subconditions/bookitbutton.php | 10 ++++++++++ .../subconditions/isbookable.php | 10 ++++++++++ .../subconditions/priceisset.php | 10 ++++++++++ lib.php | 2 ++ mod_form.php | 8 +++++--- settings.php | 15 +++++++++----- 50 files changed, 499 insertions(+), 17 deletions(-) diff --git a/classes/bo_availability/bo_condition.php b/classes/bo_availability/bo_condition.php index 8590eb820..cdf81f10a 100644 --- a/classes/bo_availability/bo_condition.php +++ b/classes/bo_availability/bo_condition.php @@ -155,4 +155,11 @@ public function render_button(booking_option_settings $settings, * @return array */ public function return_sql(): array; + + /** + * Returns the id of the condition. + * + * @return int + */ + public function get_id(): int; } diff --git a/classes/bo_availability/bo_info.php b/classes/bo_availability/bo_info.php index 4389ec19e..53048a6c6 100644 --- a/classes/bo_availability/bo_info.php +++ b/classes/bo_availability/bo_info.php @@ -902,20 +902,24 @@ public static function render_button( * @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; + public static function apply_billboard(bo_condition $condition, booking_option_settings $settings): string { + if (empty(get_config('booking', 'conditionsoverwritingbillboard'))) { + return ''; + } + if (in_array($condition->get_id(), MOD_BOOKING_CONDTIONS_EXCLUDED_FROM_OVERWRITING_DESCRIPTION_BILLBOARD)) { + return ''; } + // Fetch settings of instance to see if alert needs to be overwritten. $instance = singleton_service::get_instance_of_booking_by_bookingid($settings->bookingid); + if (empty($instance->settings->json)) { + return ''; + } $jsondata = json_decode($instance->settings->json); if (empty($jsondata->billboardtext)) { - return; + return ''; } - $formattext = format_text($jsondata->billboardtext); - - $label = $formattext; + return format_text($jsondata->billboardtext); } /** diff --git a/classes/bo_availability/conditions/allowedtobookininstance.php b/classes/bo_availability/conditions/allowedtobookininstance.php index f23ece958..54d59b257 100644 --- a/classes/bo_availability/conditions/allowedtobookininstance.php +++ b/classes/bo_availability/conditions/allowedtobookininstance.php @@ -64,6 +64,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/alreadybooked.php b/classes/bo_availability/conditions/alreadybooked.php index 815c266ec..2d0dee1fb 100644 --- a/classes/bo_availability/conditions/alreadybooked.php +++ b/classes/bo_availability/conditions/alreadybooked.php @@ -49,6 +49,16 @@ class alreadybooked implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ALREADYBOOKED; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/alreadyreserved.php b/classes/bo_availability/conditions/alreadyreserved.php index e46a065c9..f2a4d2cb0 100644 --- a/classes/bo_availability/conditions/alreadyreserved.php +++ b/classes/bo_availability/conditions/alreadyreserved.php @@ -46,6 +46,16 @@ class alreadyreserved implements bo_condition { /** @var int $id default conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ALREADYRESERVED; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/askforconfirmation.php b/classes/bo_availability/conditions/askforconfirmation.php index 097262dfa..8c07bad14 100644 --- a/classes/bo_availability/conditions/askforconfirmation.php +++ b/classes/bo_availability/conditions/askforconfirmation.php @@ -53,6 +53,16 @@ class askforconfirmation implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ASKFORCONFIRMATION; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/booking_time.php b/classes/bo_availability/conditions/booking_time.php index c74222e2f..c2c8896e3 100644 --- a/classes/bo_availability/conditions/booking_time.php +++ b/classes/bo_availability/conditions/booking_time.php @@ -55,6 +55,16 @@ class booking_time implements bo_condition { /** @var bool $overridable Indicates if the condition can be overriden. */ public $overridable = true; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/bookingpolicy.php b/classes/bo_availability/conditions/bookingpolicy.php index b0040e806..d1abed874 100644 --- a/classes/bo_availability/conditions/bookingpolicy.php +++ b/classes/bo_availability/conditions/bookingpolicy.php @@ -51,6 +51,16 @@ class bookingpolicy implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKINGPOLICY; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/bookitbutton.php b/classes/bo_availability/conditions/bookitbutton.php index bf259b960..aedde677f 100644 --- a/classes/bo_availability/conditions/bookitbutton.php +++ b/classes/bo_availability/conditions/bookitbutton.php @@ -57,6 +57,16 @@ class bookitbutton implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKITBUTTON; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/bookondetail.php b/classes/bo_availability/conditions/bookondetail.php index 8fab667f5..4a3b81688 100644 --- a/classes/bo_availability/conditions/bookondetail.php +++ b/classes/bo_availability/conditions/bookondetail.php @@ -50,6 +50,16 @@ class bookondetail implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKONDETAIL; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/bookwithcredits.php b/classes/bo_availability/conditions/bookwithcredits.php index 13fc2be95..326667bfc 100644 --- a/classes/bo_availability/conditions/bookwithcredits.php +++ b/classes/bo_availability/conditions/bookwithcredits.php @@ -57,6 +57,16 @@ class bookwithcredits implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKWITHCREDITS; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/bookwithsubscription.php b/classes/bo_availability/conditions/bookwithsubscription.php index e6024e626..3fba462ee 100644 --- a/classes/bo_availability/conditions/bookwithsubscription.php +++ b/classes/bo_availability/conditions/bookwithsubscription.php @@ -57,6 +57,16 @@ class bookwithsubscription implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKWITHSUBSCRIPTION; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/campaign_blockbooking.php b/classes/bo_availability/conditions/campaign_blockbooking.php index b7f32287d..9e1008756 100644 --- a/classes/bo_availability/conditions/campaign_blockbooking.php +++ b/classes/bo_availability/conditions/campaign_blockbooking.php @@ -54,6 +54,16 @@ class campaign_blockbooking implements bo_condition { /** @var string $blockinglabel String to display when blocking. */ private $blockinglabel = ''; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/cancelmyself.php b/classes/bo_availability/conditions/cancelmyself.php index 9b5b6b6a4..f84aa17d2 100644 --- a/classes/bo_availability/conditions/cancelmyself.php +++ b/classes/bo_availability/conditions/cancelmyself.php @@ -53,6 +53,16 @@ class cancelmyself implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CANCELMYSELF; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/capbookingchoose.php b/classes/bo_availability/conditions/capbookingchoose.php index ab6e777d0..a3f522996 100644 --- a/classes/bo_availability/conditions/capbookingchoose.php +++ b/classes/bo_availability/conditions/capbookingchoose.php @@ -49,6 +49,16 @@ class capbookingchoose implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CAPBOOKINGCHOOSE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/confirmation.php b/classes/bo_availability/conditions/confirmation.php index 704f1109b..15fc10e2b 100644 --- a/classes/bo_availability/conditions/confirmation.php +++ b/classes/bo_availability/conditions/confirmation.php @@ -52,6 +52,16 @@ class confirmation implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CONFIRMATION; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/confirmbookit.php b/classes/bo_availability/conditions/confirmbookit.php index 96b71c6c4..65a46b6c7 100644 --- a/classes/bo_availability/conditions/confirmbookit.php +++ b/classes/bo_availability/conditions/confirmbookit.php @@ -50,6 +50,16 @@ class confirmbookit implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CONFIRMBOOKIT; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/confirmbookwithcredits.php b/classes/bo_availability/conditions/confirmbookwithcredits.php index ecfcfac61..4b6927227 100644 --- a/classes/bo_availability/conditions/confirmbookwithcredits.php +++ b/classes/bo_availability/conditions/confirmbookwithcredits.php @@ -50,6 +50,16 @@ class confirmbookwithcredits implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CONFIRMBOOKWITHCREDITS; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/confirmbookwithsubscription.php b/classes/bo_availability/conditions/confirmbookwithsubscription.php index e97101d46..6b6072a08 100644 --- a/classes/bo_availability/conditions/confirmbookwithsubscription.php +++ b/classes/bo_availability/conditions/confirmbookwithsubscription.php @@ -50,6 +50,16 @@ class confirmbookwithsubscription implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CONFIRMBOOKWITHSUBSCRIPTION; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/confirmcancel.php b/classes/bo_availability/conditions/confirmcancel.php index 30ad90d72..c4973b6b6 100644 --- a/classes/bo_availability/conditions/confirmcancel.php +++ b/classes/bo_availability/conditions/confirmcancel.php @@ -51,6 +51,16 @@ class confirmcancel implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_CONFIRMCANCEL; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/customform.php b/classes/bo_availability/conditions/customform.php index ee696e39e..50392ca9f 100644 --- a/classes/bo_availability/conditions/customform.php +++ b/classes/bo_availability/conditions/customform.php @@ -72,6 +72,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/electivebookitbutton.php b/classes/bo_availability/conditions/electivebookitbutton.php index f0649952f..e2932ac28 100644 --- a/classes/bo_availability/conditions/electivebookitbutton.php +++ b/classes/bo_availability/conditions/electivebookitbutton.php @@ -57,6 +57,16 @@ class electivebookitbutton implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ELECTIVEBOOKITBUTTON; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/electivenotbookable.php b/classes/bo_availability/conditions/electivenotbookable.php index 4a1004512..61850ff26 100644 --- a/classes/bo_availability/conditions/electivenotbookable.php +++ b/classes/bo_availability/conditions/electivenotbookable.php @@ -56,6 +56,16 @@ class electivenotbookable implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ELECTIVENOTBOOKABLE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/enrolledincohorts.php b/classes/bo_availability/conditions/enrolledincohorts.php index 660264f79..b83148f84 100644 --- a/classes/bo_availability/conditions/enrolledincohorts.php +++ b/classes/bo_availability/conditions/enrolledincohorts.php @@ -68,6 +68,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/enrolledincourse.php b/classes/bo_availability/conditions/enrolledincourse.php index 3cc434bc3..0323a8cfa 100644 --- a/classes/bo_availability/conditions/enrolledincourse.php +++ b/classes/bo_availability/conditions/enrolledincourse.php @@ -67,6 +67,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/fullybooked.php b/classes/bo_availability/conditions/fullybooked.php index b52088b57..1de90f285 100644 --- a/classes/bo_availability/conditions/fullybooked.php +++ b/classes/bo_availability/conditions/fullybooked.php @@ -55,6 +55,16 @@ class fullybooked implements bo_condition { /** @var bool $overridable Indicates if the condition can be overriden. */ public $overridable = true; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/isbookable.php b/classes/bo_availability/conditions/isbookable.php index a5bbc5d62..dd966ee4a 100644 --- a/classes/bo_availability/conditions/isbookable.php +++ b/classes/bo_availability/conditions/isbookable.php @@ -49,6 +49,16 @@ class isbookable implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISBOOKABLE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool @@ -150,7 +160,13 @@ public function get_description(booking_option_settings $settings, $userid = nul $isavailable = $this->is_available($settings, $userid, $not); - $description = $this->get_description_string($isavailable, $full); + if (!$isavailable && !empty($billboardtext = bo_info::apply_billboard($this, $settings))) { + $description = $billboardtext; + // Overwrite Buttontype if needed. + } else { + $description = $this->get_description_string($isavailable, $full); + + } return [$isavailable, $description, MOD_BOOKING_BO_PREPAGE_NONE, MOD_BOOKING_BO_BUTTON_MYALERT]; } diff --git a/classes/bo_availability/conditions/isbookableinstance.php b/classes/bo_availability/conditions/isbookableinstance.php index e628978a2..f9f53c835 100644 --- a/classes/bo_availability/conditions/isbookableinstance.php +++ b/classes/bo_availability/conditions/isbookableinstance.php @@ -50,6 +50,16 @@ class isbookableinstance implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISBOOKABLEINSTANCE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/iscancelled.php b/classes/bo_availability/conditions/iscancelled.php index 922e3f674..01f89270e 100644 --- a/classes/bo_availability/conditions/iscancelled.php +++ b/classes/bo_availability/conditions/iscancelled.php @@ -49,6 +49,16 @@ class iscancelled implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISCANCELLED; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/isloggedin.php b/classes/bo_availability/conditions/isloggedin.php index 5704b95f4..c68143f67 100644 --- a/classes/bo_availability/conditions/isloggedin.php +++ b/classes/bo_availability/conditions/isloggedin.php @@ -48,6 +48,16 @@ class isloggedin implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISLOGGEDIN; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/isloggedinprice.php b/classes/bo_availability/conditions/isloggedinprice.php index 52c2af5ca..1df1e2e93 100644 --- a/classes/bo_availability/conditions/isloggedinprice.php +++ b/classes/bo_availability/conditions/isloggedinprice.php @@ -27,6 +27,7 @@ namespace mod_booking\bo_availability\conditions; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\price; use MoodleQuickForm; @@ -49,6 +50,16 @@ class isloggedinprice implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISLOGGEDINPRICE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/max_number_of_bookings.php b/classes/bo_availability/conditions/max_number_of_bookings.php index 5732745d2..10aa830e2 100644 --- a/classes/bo_availability/conditions/max_number_of_bookings.php +++ b/classes/bo_availability/conditions/max_number_of_bookings.php @@ -53,6 +53,16 @@ class max_number_of_bookings implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_MAX_NUMBER_OF_BOOKINGS; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/noshoppingcart.php b/classes/bo_availability/conditions/noshoppingcart.php index ae316c62c..47d8d7782 100644 --- a/classes/bo_availability/conditions/noshoppingcart.php +++ b/classes/bo_availability/conditions/noshoppingcart.php @@ -28,6 +28,7 @@ use context_module; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\price; use mod_booking\singleton_service; @@ -53,6 +54,16 @@ class noshoppingcart implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_NOSHOPPINGCART; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/notifymelist.php b/classes/bo_availability/conditions/notifymelist.php index 20c6e4532..03ca7d07e 100644 --- a/classes/bo_availability/conditions/notifymelist.php +++ b/classes/bo_availability/conditions/notifymelist.php @@ -28,6 +28,7 @@ use context_system; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\output\button_notifyme; use mod_booking\singleton_service; @@ -55,6 +56,16 @@ class notifymelist implements bo_condition { /** @var bool $overridable Indicates if the condition can be overriden. */ public $overridable = true; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/onwaitinglist.php b/classes/bo_availability/conditions/onwaitinglist.php index be09a575e..13861a24f 100644 --- a/classes/bo_availability/conditions/onwaitinglist.php +++ b/classes/bo_availability/conditions/onwaitinglist.php @@ -53,6 +53,16 @@ class onwaitinglist implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ONWAITINGLIST; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/optionhasstarted.php b/classes/bo_availability/conditions/optionhasstarted.php index b75df977c..f9226869f 100644 --- a/classes/bo_availability/conditions/optionhasstarted.php +++ b/classes/bo_availability/conditions/optionhasstarted.php @@ -52,6 +52,16 @@ class optionhasstarted implements bo_condition { /** @var bool $overridable Indicates if the condition can be overriden. */ public $overridable = true; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/previouslybooked.php b/classes/bo_availability/conditions/previouslybooked.php index 5ed672be9..863fe5fc6 100644 --- a/classes/bo_availability/conditions/previouslybooked.php +++ b/classes/bo_availability/conditions/previouslybooked.php @@ -71,6 +71,16 @@ public function __construct(?int $id = null, ?booking_option_settings $settings } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/priceisset.php b/classes/bo_availability/conditions/priceisset.php index 181fc8f39..1161c6800 100644 --- a/classes/bo_availability/conditions/priceisset.php +++ b/classes/bo_availability/conditions/priceisset.php @@ -28,6 +28,7 @@ use context_module; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\local\modechecker; use mod_booking\price; @@ -55,6 +56,16 @@ class priceisset implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_PRICEISSET; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/selectusers.php b/classes/bo_availability/conditions/selectusers.php index b40e2ec7c..a381aece9 100644 --- a/classes/bo_availability/conditions/selectusers.php +++ b/classes/bo_availability/conditions/selectusers.php @@ -74,6 +74,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/subbooking.php b/classes/bo_availability/conditions/subbooking.php index 5ead4ec1d..45f25380d 100644 --- a/classes/bo_availability/conditions/subbooking.php +++ b/classes/bo_availability/conditions/subbooking.php @@ -28,6 +28,7 @@ use context_system; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\singleton_service; use mod_booking\subbookings\subbookings_info; @@ -53,6 +54,16 @@ class subbooking implements bo_condition { a "soft block" so they appear in prepage modals but do not block the booking process. */ + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/subbooking_blocks.php b/classes/bo_availability/conditions/subbooking_blocks.php index 28b44b7a2..e784bafa2 100644 --- a/classes/bo_availability/conditions/subbooking_blocks.php +++ b/classes/bo_availability/conditions/subbooking_blocks.php @@ -27,6 +27,7 @@ namespace mod_booking\bo_availability\conditions; use mod_booking\bo_availability\bo_condition; +use mod_booking\bo_availability\bo_info; use mod_booking\booking_option_settings; use mod_booking\singleton_service; use mod_booking\subbookings\subbookings_info; @@ -48,6 +49,16 @@ class subbooking_blocks implements bo_condition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_SUBBOOKINGBLOCKS; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/userprofilefield_1_default.php b/classes/bo_availability/conditions/userprofilefield_1_default.php index 2ef942f12..6faee6d3d 100644 --- a/classes/bo_availability/conditions/userprofilefield_1_default.php +++ b/classes/bo_availability/conditions/userprofilefield_1_default.php @@ -72,6 +72,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/conditions/userprofilefield_2_custom.php b/classes/bo_availability/conditions/userprofilefield_2_custom.php index 696b50e1c..a1dc2eda2 100644 --- a/classes/bo_availability/conditions/userprofilefield_2_custom.php +++ b/classes/bo_availability/conditions/userprofilefield_2_custom.php @@ -72,6 +72,16 @@ public function __construct(?int $id = null) { } } + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/subconditions/alreadybooked.php b/classes/bo_availability/subconditions/alreadybooked.php index e01ca3801..52e9acb2b 100644 --- a/classes/bo_availability/subconditions/alreadybooked.php +++ b/classes/bo_availability/subconditions/alreadybooked.php @@ -50,6 +50,16 @@ class alreadybooked implements bo_subcondition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ALREADYBOOKED; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/subconditions/bookitbutton.php b/classes/bo_availability/subconditions/bookitbutton.php index d6e61bb4b..fe4aac056 100644 --- a/classes/bo_availability/subconditions/bookitbutton.php +++ b/classes/bo_availability/subconditions/bookitbutton.php @@ -51,6 +51,16 @@ class bookitbutton implements bo_subcondition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_BOOKITBUTTON; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/subconditions/isbookable.php b/classes/bo_availability/subconditions/isbookable.php index 71ed588a1..cbb79df93 100644 --- a/classes/bo_availability/subconditions/isbookable.php +++ b/classes/bo_availability/subconditions/isbookable.php @@ -52,6 +52,16 @@ class isbookable implements bo_subcondition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_ISBOOKABLE; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/classes/bo_availability/subconditions/priceisset.php b/classes/bo_availability/subconditions/priceisset.php index 11ff26c2a..66c2fae35 100644 --- a/classes/bo_availability/subconditions/priceisset.php +++ b/classes/bo_availability/subconditions/priceisset.php @@ -52,6 +52,16 @@ class priceisset implements bo_subcondition { /** @var int $id Standard Conditions have hardcoded ids. */ public $id = MOD_BOOKING_BO_COND_PRICEISSET; + /** + * Get the condition id. + * + * @return int + * + */ + public function get_id(): int { + return $this->id; + } + /** * Needed to see if class can take JSON. * @return bool diff --git a/lib.php b/lib.php index 1fd14493f..0cf54d836 100755 --- a/lib.php +++ b/lib.php @@ -288,6 +288,8 @@ define('MOD_BOOKING_CLASSES_EXCLUDED_FROM_CHANGES_TRACKING', [ ]); +define('MOD_BOOKING_CONDTIONS_EXCLUDED_FROM_OVERWRITING_DESCRIPTION_BILLBOARD', [ +]); /** * Booking get coursemodule info. * diff --git a/mod_form.php b/mod_form.php index 1ccb4e983..50db12d96 100755 --- a/mod_form.php +++ b/mod_form.php @@ -875,9 +875,11 @@ 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); + if (get_config('booking', 'conditionsoverwritingbillboard')) { + $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', diff --git a/settings.php b/settings.php index e28054207..1d5ff2fca 100755 --- a/settings.php +++ b/settings.php @@ -267,11 +267,6 @@ get_string('displayloginbuttonforbookingoptions', 'mod_booking'), get_string('displayloginbuttonforbookingoptions_desc', 'mod_booking'), 1)); - $settings->add( - new admin_setting_configcheckbox('booking/bookonlyondetailspage', - get_string('bookonlyondetailspage', 'mod_booking'), - get_string('bookonlyondetailspage_desc', 'mod_booking'), 0)); - $coloroptions = [ 'primary' => get_string('cdo:buttoncolor:primary', 'mod_booking'), 'secondary' => get_string('cdo:buttoncolor:secondary', 'mod_booking'), @@ -292,6 +287,16 @@ get_string('linktomoodlecourseonbookedbutton', 'mod_booking'), get_string('linktomoodlecourseonbookedbutton_desc', 'mod_booking'), 1)); + $settings->add( + new admin_setting_configcheckbox('booking/conditionsoverwritingbillboard', + get_string('conditionsoverwritingbillboard', 'mod_booking'), + get_string('conditionsoverwritingbillboard_desc', 'mod_booking'), 0)); + + $settings->add( + new admin_setting_configcheckbox('booking/bookonlyondetailspage', + get_string('bookonlyondetailspage', 'mod_booking'), + get_string('bookonlyondetailspage_desc', 'mod_booking'), 0)); + $settings->add( new admin_setting_configcheckbox('booking/openbookingdetailinsametab', get_string('openbookingdetailinsametab', 'mod_booking'),