Skip to content

Commit

Permalink
GH-638 get id of condition for apply_billboard
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Oct 22, 2024
1 parent 3b3b063 commit 5dfcbb4
Show file tree
Hide file tree
Showing 50 changed files with 499 additions and 17 deletions.
7 changes: 7 additions & 0 deletions classes/bo_availability/bo_condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
20 changes: 12 additions & 8 deletions classes/bo_availability/bo_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/allowedtobookininstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/alreadybooked.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/alreadyreserved.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/askforconfirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/booking_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/bookingpolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/bookitbutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/bookondetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/bookwithcredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/bookwithsubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/campaign_blockbooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/cancelmyself.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/capbookingchoose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/confirmbookit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/confirmbookwithcredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/confirmbookwithsubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/confirmcancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/customform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions classes/bo_availability/conditions/electivebookitbutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 5dfcbb4

Please sign in to comment.