@@ -14,60 +14,60 @@ |
||
14 | 14 | class EE_Not_Approved_Registration_message_type extends EE_Registration_Base_message_type |
15 | 15 | { |
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
19 | - $this->name = 'not_approved_registration'; |
|
20 | - $this->description = __('This message type is for messages sent to registrants when their registration is set to the not approved status.', 'event_espresso'); |
|
21 | - $this->label = array( |
|
22 | - 'singular' => __('not approved registration', 'event_espresso'), |
|
23 | - 'plural' => __('not approved registrations', 'event_espresso') |
|
24 | - ); |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + $this->name = 'not_approved_registration'; |
|
20 | + $this->description = __('This message type is for messages sent to registrants when their registration is set to the not approved status.', 'event_espresso'); |
|
21 | + $this->label = array( |
|
22 | + 'singular' => __('not approved registration', 'event_espresso'), |
|
23 | + 'plural' => __('not approved registrations', 'event_espresso') |
|
24 | + ); |
|
25 | 25 | |
26 | - $this->_master_templates = array( |
|
27 | - 'email' => 'registration' |
|
28 | - ); |
|
26 | + $this->_master_templates = array( |
|
27 | + 'email' => 'registration' |
|
28 | + ); |
|
29 | 29 | |
30 | - parent::__construct(); |
|
31 | - } |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * _set_contexts |
|
38 | - * This sets up the contexts associated with the message_type |
|
39 | - * |
|
40 | - * @access protected |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - protected function _set_contexts() |
|
44 | - { |
|
45 | - $this->_context_label = array( |
|
46 | - 'label' => __('recipient', 'event_espresso'), |
|
47 | - 'plural' => __('recipients', 'event_espresso'), |
|
48 | - 'description' => __('Recipient\'s are who will receive the template. You may want different registration details sent out depending on who the recipient is', 'event_espresso') |
|
49 | - ); |
|
36 | + /** |
|
37 | + * _set_contexts |
|
38 | + * This sets up the contexts associated with the message_type |
|
39 | + * |
|
40 | + * @access protected |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + protected function _set_contexts() |
|
44 | + { |
|
45 | + $this->_context_label = array( |
|
46 | + 'label' => __('recipient', 'event_espresso'), |
|
47 | + 'plural' => __('recipients', 'event_espresso'), |
|
48 | + 'description' => __('Recipient\'s are who will receive the template. You may want different registration details sent out depending on who the recipient is', 'event_espresso') |
|
49 | + ); |
|
50 | 50 | |
51 | - $this->_contexts = array( |
|
52 | - 'admin' => array( |
|
53 | - 'label' => __('Event Admin', 'event_espresso'), |
|
54 | - 'description' => __('This template is what event administrators will receive when registration status is set to not approved.', 'event_espresso') |
|
55 | - ), |
|
56 | - 'primary_attendee' => array( |
|
57 | - 'label' => __('Primary Registrant', 'event_espresso'), |
|
58 | - 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive when the registration status is not approved.', 'event_espresso') |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
51 | + $this->_contexts = array( |
|
52 | + 'admin' => array( |
|
53 | + 'label' => __('Event Admin', 'event_espresso'), |
|
54 | + 'description' => __('This template is what event administrators will receive when registration status is set to not approved.', 'event_espresso') |
|
55 | + ), |
|
56 | + 'primary_attendee' => array( |
|
57 | + 'label' => __('Primary Registrant', 'event_espresso'), |
|
58 | + 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive when the registration status is not approved.', 'event_espresso') |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function _primary_attendee_addressees() |
|
66 | - { |
|
67 | - $cached = $this->_single_message; |
|
68 | - $this->_single_message = false; |
|
69 | - $addressees = parent::_primary_attendee_addressees(); |
|
70 | - $this->_single_message = $cached; |
|
71 | - return $addressees; |
|
72 | - } |
|
65 | + protected function _primary_attendee_addressees() |
|
66 | + { |
|
67 | + $cached = $this->_single_message; |
|
68 | + $this->_single_message = false; |
|
69 | + $addressees = parent::_primary_attendee_addressees(); |
|
70 | + $this->_single_message = $cached; |
|
71 | + return $addressees; |
|
72 | + } |
|
73 | 73 | } |
@@ -16,59 +16,59 @@ |
||
16 | 16 | class EE_Registration_Summary_message_type extends EE_Registration_Base_message_type |
17 | 17 | { |
18 | 18 | |
19 | - public function __construct() |
|
20 | - { |
|
21 | - $this->name = 'registration_summary'; |
|
22 | - $this->description = __('This message type provides a summary notification to Primary Registrants and Admin recipients when there are multiple registrations in a transaction with different statuses.', 'event_espresso'); |
|
23 | - $this->label = array( |
|
24 | - 'singular' => __('registration multi-status summary', 'event_espresso'), |
|
25 | - 'plural' => __('registrations multi-status summary', 'event_espresso') |
|
26 | - ); |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + $this->name = 'registration_summary'; |
|
22 | + $this->description = __('This message type provides a summary notification to Primary Registrants and Admin recipients when there are multiple registrations in a transaction with different statuses.', 'event_espresso'); |
|
23 | + $this->label = array( |
|
24 | + 'singular' => __('registration multi-status summary', 'event_espresso'), |
|
25 | + 'plural' => __('registrations multi-status summary', 'event_espresso') |
|
26 | + ); |
|
27 | 27 | |
28 | - $this->_master_templates = array( |
|
29 | - 'email' => 'registration' |
|
30 | - ); |
|
28 | + $this->_master_templates = array( |
|
29 | + 'email' => 'registration' |
|
30 | + ); |
|
31 | 31 | |
32 | - parent::__construct(); |
|
33 | - } |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * _set_contexts |
|
39 | - * This sets up the contexts associated with the message_type |
|
40 | - * |
|
41 | - * @access protected |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - protected function _set_contexts() |
|
45 | - { |
|
46 | - $this->_context_label = array( |
|
47 | - 'label' => __('recipient', 'event_espresso'), |
|
48 | - 'plural' => __('recipients', 'event_espresso'), |
|
49 | - 'description' => __('Recipient\'s are who will receive the template. You may want different details sent out depending on who the recipient is. To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso') |
|
50 | - ); |
|
37 | + /** |
|
38 | + * _set_contexts |
|
39 | + * This sets up the contexts associated with the message_type |
|
40 | + * |
|
41 | + * @access protected |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + protected function _set_contexts() |
|
45 | + { |
|
46 | + $this->_context_label = array( |
|
47 | + 'label' => __('recipient', 'event_espresso'), |
|
48 | + 'plural' => __('recipients', 'event_espresso'), |
|
49 | + 'description' => __('Recipient\'s are who will receive the template. You may want different details sent out depending on who the recipient is. To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso') |
|
50 | + ); |
|
51 | 51 | |
52 | - $this->_contexts = array( |
|
53 | - 'admin' => array( |
|
54 | - 'label' => __('Event Admin', 'event_espresso'), |
|
55 | - 'description' => __('This template is what event administrators will receive when a transaction is finalized that has registrations with multiple different statuses.', 'event_espresso') |
|
56 | - ), |
|
57 | - 'primary_attendee' => array( |
|
58 | - 'label' => __('Primary Registrant', 'event_espresso'), |
|
59 | - 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive when the transaction completed has registrations with different statuses. By default it is a summary email of all registrations for all events on the transaction and their status.', 'event_espresso') |
|
60 | - ) |
|
61 | - ); |
|
62 | - } |
|
52 | + $this->_contexts = array( |
|
53 | + 'admin' => array( |
|
54 | + 'label' => __('Event Admin', 'event_espresso'), |
|
55 | + 'description' => __('This template is what event administrators will receive when a transaction is finalized that has registrations with multiple different statuses.', 'event_espresso') |
|
56 | + ), |
|
57 | + 'primary_attendee' => array( |
|
58 | + 'label' => __('Primary Registrant', 'event_espresso'), |
|
59 | + 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive when the transaction completed has registrations with different statuses. By default it is a summary email of all registrations for all events on the transaction and their status.', 'event_espresso') |
|
60 | + ) |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - protected function _primary_attendee_addressees() |
|
67 | - { |
|
68 | - $cached = $this->_single_message; |
|
69 | - $this->_single_message = false; |
|
70 | - $addressees = parent::_primary_attendee_addressees(); |
|
71 | - $this->_single_message = $cached; |
|
72 | - return $addressees; |
|
73 | - } |
|
66 | + protected function _primary_attendee_addressees() |
|
67 | + { |
|
68 | + $cached = $this->_single_message; |
|
69 | + $this->_single_message = false; |
|
70 | + $addressees = parent::_primary_attendee_addressees(); |
|
71 | + $this->_single_message = $cached; |
|
72 | + return $addressees; |
|
73 | + } |
|
74 | 74 | } |
@@ -14,44 +14,44 @@ |
||
14 | 14 | class EE_Payment_message_type extends EE_Payment_Base_message_type |
15 | 15 | { |
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | 19 | |
20 | - // setup type details for reference |
|
21 | - $this->name = 'payment'; |
|
22 | - $this->description = __('This message type is used for all payment notification messages that go out including any manual payments entered by an event administrator.', 'event_espresso'); |
|
23 | - $this->label = array( |
|
24 | - 'singular' => __('payment received', 'event_espresso'), |
|
25 | - 'plural' => __('payments received', 'event_espresso') |
|
26 | - ); |
|
20 | + // setup type details for reference |
|
21 | + $this->name = 'payment'; |
|
22 | + $this->description = __('This message type is used for all payment notification messages that go out including any manual payments entered by an event administrator.', 'event_espresso'); |
|
23 | + $this->label = array( |
|
24 | + 'singular' => __('payment received', 'event_espresso'), |
|
25 | + 'plural' => __('payments received', 'event_espresso') |
|
26 | + ); |
|
27 | 27 | |
28 | - parent::__construct(); |
|
29 | - } |
|
28 | + parent::__construct(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * _set_contexts |
|
33 | - * This sets up the contexts associated with the message_type |
|
34 | - * |
|
35 | - * @access protected |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - protected function _set_contexts() |
|
39 | - { |
|
40 | - $this->_context_label = array( |
|
41 | - 'label' => __('recipient', 'event_espresso'), |
|
42 | - 'plural' => __('recipients', 'event_espresso'), |
|
43 | - 'description' => __('Recipient\'s are who will receive the template. You may want different payment details sent out depending on who the recipient is', 'event_espresso') |
|
44 | - ); |
|
31 | + /** |
|
32 | + * _set_contexts |
|
33 | + * This sets up the contexts associated with the message_type |
|
34 | + * |
|
35 | + * @access protected |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + protected function _set_contexts() |
|
39 | + { |
|
40 | + $this->_context_label = array( |
|
41 | + 'label' => __('recipient', 'event_espresso'), |
|
42 | + 'plural' => __('recipients', 'event_espresso'), |
|
43 | + 'description' => __('Recipient\'s are who will receive the template. You may want different payment details sent out depending on who the recipient is', 'event_espresso') |
|
44 | + ); |
|
45 | 45 | |
46 | - $this->_contexts = array( |
|
47 | - 'admin' => array( |
|
48 | - 'label' => __('Event Admin', 'event_espresso'), |
|
49 | - 'description' => __('This template is what event administrators will receive on a successful payment', 'event_espresso') |
|
50 | - ), |
|
51 | - 'primary_attendee' => array( |
|
52 | - 'label' => __('Primary Registrant', 'event_espresso'), |
|
53 | - 'description' => __('This template is what the primary registrant (the person who made the main registration) will receive on successful payment', 'event_espresso') |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
46 | + $this->_contexts = array( |
|
47 | + 'admin' => array( |
|
48 | + 'label' => __('Event Admin', 'event_espresso'), |
|
49 | + 'description' => __('This template is what event administrators will receive on a successful payment', 'event_espresso') |
|
50 | + ), |
|
51 | + 'primary_attendee' => array( |
|
52 | + 'label' => __('Primary Registrant', 'event_espresso'), |
|
53 | + 'description' => __('This template is what the primary registrant (the person who made the main registration) will receive on successful payment', 'event_espresso') |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -13,123 +13,123 @@ |
||
13 | 13 | class EE_Invoice_message_type extends EE_message_type |
14 | 14 | { |
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->name = 'invoice'; |
|
19 | - $this->description = __('The invoice message type is triggered via a url on the thank you page and via at url generated by the [INVOICE_URL] or [INVOICE_LINK] shortcode.', 'event_espresso'); |
|
20 | - $this->label = array( |
|
21 | - 'singular' => __('invoice', 'event_espresso'), |
|
22 | - 'plural' => __('invoices', 'event_espresso') |
|
23 | - ); |
|
24 | - $this->_master_templates = array(); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->name = 'invoice'; |
|
19 | + $this->description = __('The invoice message type is triggered via a url on the thank you page and via at url generated by the [INVOICE_URL] or [INVOICE_LINK] shortcode.', 'event_espresso'); |
|
20 | + $this->label = array( |
|
21 | + 'singular' => __('invoice', 'event_espresso'), |
|
22 | + 'plural' => __('invoices', 'event_espresso') |
|
23 | + ); |
|
24 | + $this->_master_templates = array(); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @see parent::get_priority() for documentation. |
|
32 | - * @return int |
|
33 | - */ |
|
34 | - public function get_priority() |
|
35 | - { |
|
36 | - return EEM_Message::priority_high; |
|
37 | - } |
|
30 | + /** |
|
31 | + * @see parent::get_priority() for documentation. |
|
32 | + * @return int |
|
33 | + */ |
|
34 | + public function get_priority() |
|
35 | + { |
|
36 | + return EEM_Message::priority_high; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * This method returns whether this message type should always generate a new copy |
|
42 | - * when requested, or if links can be to the already generated copy. |
|
43 | - * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
44 | - * Invoices always generate. |
|
45 | - * @return bool false means can link to generated EE_Message. true must regenerate. |
|
46 | - */ |
|
47 | - public function always_generate() |
|
48 | - { |
|
49 | - return true; |
|
50 | - } |
|
40 | + /** |
|
41 | + * This method returns whether this message type should always generate a new copy |
|
42 | + * when requested, or if links can be to the already generated copy. |
|
43 | + * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
44 | + * Invoices always generate. |
|
45 | + * @return bool false means can link to generated EE_Message. true must regenerate. |
|
46 | + */ |
|
47 | + public function always_generate() |
|
48 | + { |
|
49 | + return true; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - protected function _set_admin_pages() |
|
54 | - { |
|
55 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
56 | - } |
|
53 | + protected function _set_admin_pages() |
|
54 | + { |
|
55 | + $this->admin_registered_pages = array( 'events_edit' => true ); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - protected function _set_data_handler() |
|
61 | - { |
|
62 | - $this->_data_handler = 'Gateways'; |
|
63 | - } |
|
60 | + protected function _set_data_handler() |
|
61 | + { |
|
62 | + $this->_data_handler = 'Gateways'; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - protected function _set_with_messengers() |
|
68 | - { |
|
69 | - $this->_with_messengers = array( |
|
70 | - 'html' => array( 'pdf' ) |
|
71 | - ); |
|
72 | - } |
|
67 | + protected function _set_with_messengers() |
|
68 | + { |
|
69 | + $this->_with_messengers = array( |
|
70 | + 'html' => array( 'pdf' ) |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
77 | - { |
|
78 | - // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
79 | - $transaction = $registration->transaction(); |
|
80 | - if ($transaction instanceof EE_Transaction) { |
|
81 | - return array( $transaction ); |
|
82 | - } |
|
83 | - return array(); |
|
84 | - } |
|
76 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
77 | + { |
|
78 | + // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
79 | + $transaction = $registration->transaction(); |
|
80 | + if ($transaction instanceof EE_Transaction) { |
|
81 | + return array( $transaction ); |
|
82 | + } |
|
83 | + return array(); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | 87 | |
88 | - protected function _set_admin_settings_fields() |
|
89 | - { |
|
90 | - $this->_admin_settings_fields = array(); |
|
91 | - } |
|
88 | + protected function _set_admin_settings_fields() |
|
89 | + { |
|
90 | + $this->_admin_settings_fields = array(); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | - protected function _set_contexts() |
|
96 | - { |
|
97 | - $this->_context_label = array( |
|
98 | - 'label' => __('recipient', 'event_espresso'), |
|
99 | - 'plural' => __('recipients', 'event_espresso'), |
|
100 | - 'description' => __('Recipient\'s are who will view the invoice.', 'event_espresso') |
|
101 | - ); |
|
95 | + protected function _set_contexts() |
|
96 | + { |
|
97 | + $this->_context_label = array( |
|
98 | + 'label' => __('recipient', 'event_espresso'), |
|
99 | + 'plural' => __('recipients', 'event_espresso'), |
|
100 | + 'description' => __('Recipient\'s are who will view the invoice.', 'event_espresso') |
|
101 | + ); |
|
102 | 102 | |
103 | - $this->_contexts = array( |
|
104 | - 'purchaser' => array( |
|
105 | - 'label' => __('Purchaser', 'event_espresso'), |
|
106 | - 'description' => __('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
103 | + $this->_contexts = array( |
|
104 | + 'purchaser' => array( |
|
105 | + 'label' => __('Purchaser', 'event_espresso'), |
|
106 | + 'description' => __('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * used to set the valid shortcodes for the receipt message type |
|
116 | - * |
|
117 | - * @since 4.5.0 |
|
118 | - * |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - protected function _set_valid_shortcodes() |
|
122 | - { |
|
123 | - $this->_valid_shortcodes['purchaser'] = array( |
|
124 | - 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event', 'event_meta', 'messenger', 'organization', 'primary_registration_list', 'primary_registration_details', 'ticket_list', 'ticket', 'transaction', 'venue', 'line_item_list', 'payment_list', 'line_item', 'payment' |
|
125 | - ); |
|
126 | - } |
|
114 | + /** |
|
115 | + * used to set the valid shortcodes for the receipt message type |
|
116 | + * |
|
117 | + * @since 4.5.0 |
|
118 | + * |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + protected function _set_valid_shortcodes() |
|
122 | + { |
|
123 | + $this->_valid_shortcodes['purchaser'] = array( |
|
124 | + 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event', 'event_meta', 'messenger', 'organization', 'primary_registration_list', 'primary_registration_details', 'ticket_list', 'ticket', 'transaction', 'venue', 'line_item_list', 'payment_list', 'line_item', 'payment' |
|
125 | + ); |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | |
130 | 130 | |
131 | - protected function _purchaser_addressees() |
|
132 | - { |
|
133 | - return parent::_primary_attendee_addressees(); |
|
134 | - } |
|
131 | + protected function _purchaser_addressees() |
|
132 | + { |
|
133 | + return parent::_primary_attendee_addressees(); |
|
134 | + } |
|
135 | 135 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function _set_admin_pages() |
54 | 54 | { |
55 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
55 | + $this->admin_registered_pages = array('events_edit' => true); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | protected function _set_with_messengers() |
68 | 68 | { |
69 | 69 | $this->_with_messengers = array( |
70 | - 'html' => array( 'pdf' ) |
|
70 | + 'html' => array('pdf') |
|
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // receipt message type data handler is 'Gateways' and it expects a transaction object. |
79 | 79 | $transaction = $registration->transaction(); |
80 | 80 | if ($transaction instanceof EE_Transaction) { |
81 | - return array( $transaction ); |
|
81 | + return array($transaction); |
|
82 | 82 | } |
83 | 83 | return array(); |
84 | 84 | } |
@@ -13,142 +13,142 @@ |
||
13 | 13 | class EE_Receipt_message_type extends EE_message_type |
14 | 14 | { |
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->name = 'receipt'; |
|
19 | - $this->description = __('The receipt message type is triggered via a url on the thank you page and via at url generated by the [RECEIPT_URL] shortcode.', 'event_espresso'); |
|
20 | - $this->label = array( |
|
21 | - 'singular' => __('receipt', 'event_espresso'), |
|
22 | - 'plural' => __('receipts', 'event_espresso') |
|
23 | - ); |
|
24 | - $this->_master_templates = array(); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->name = 'receipt'; |
|
19 | + $this->description = __('The receipt message type is triggered via a url on the thank you page and via at url generated by the [RECEIPT_URL] shortcode.', 'event_espresso'); |
|
20 | + $this->label = array( |
|
21 | + 'singular' => __('receipt', 'event_espresso'), |
|
22 | + 'plural' => __('receipts', 'event_espresso') |
|
23 | + ); |
|
24 | + $this->_master_templates = array(); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @see parent::get_priority() for documentation. |
|
32 | - * @return int |
|
33 | - */ |
|
34 | - public function get_priority() |
|
35 | - { |
|
36 | - return EEM_Message::priority_high; |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * This method returns whether this message type should always generate a new copy |
|
43 | - * when requested, or if links can be to the already generated copy. |
|
44 | - * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
45 | - * Receipts always generate |
|
46 | - * @return bool false means can link to generated EE_Message. true must regenerate. |
|
47 | - */ |
|
48 | - public function always_generate() |
|
49 | - { |
|
50 | - return true; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - protected function _set_admin_pages() |
|
55 | - { |
|
56 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - protected function _set_data_handler() |
|
62 | - { |
|
63 | - $this->_data_handler = 'Gateways'; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - protected function _set_with_messengers() |
|
69 | - { |
|
70 | - $this->_with_messengers = array( |
|
71 | - 'html' => array( 'pdf' ) |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
78 | - { |
|
79 | - // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
80 | - $transaction = $registration->transaction(); |
|
81 | - if ($transaction instanceof EE_Transaction) { |
|
82 | - return array( $transaction ); |
|
83 | - } |
|
84 | - return array(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - protected function _set_admin_settings_fields() |
|
90 | - { |
|
91 | - $this->_admin_settings_fields = array(); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - protected function _set_contexts() |
|
97 | - { |
|
98 | - $this->_context_label = array( |
|
99 | - 'label' => __('recipient', 'event_espresso'), |
|
100 | - 'plural' => __('recipients', 'event_espresso'), |
|
101 | - 'description' => __('Recipient\'s are who will view the receipt.', 'event_espresso') |
|
102 | - ); |
|
103 | - |
|
104 | - $this->_contexts = array( |
|
105 | - 'purchaser' => array( |
|
106 | - 'label' => __('Purchaser', 'event_espresso'), |
|
107 | - 'description' => __('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
108 | - ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * used to set the valid shortcodes for the receipt message type |
|
117 | - * |
|
118 | - * @since 4.5.0 |
|
119 | - * |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - protected function _set_valid_shortcodes() |
|
123 | - { |
|
124 | - $this->_valid_shortcodes['purchaser'] = array( |
|
125 | - 'attendee_list', |
|
126 | - 'attendee', |
|
127 | - 'datetime_list', |
|
128 | - 'datetime', |
|
129 | - 'event_list', |
|
130 | - 'event', |
|
131 | - 'event_meta', |
|
132 | - 'messenger', |
|
133 | - 'organization', |
|
134 | - 'primary_registration_list', |
|
135 | - 'primary_registration_details', |
|
136 | - 'ticket_list', |
|
137 | - 'ticket', |
|
138 | - 'transaction', |
|
139 | - 'venue', |
|
140 | - 'line_item_list', |
|
141 | - 'payment_list', |
|
142 | - 'line_item', |
|
143 | - 'payment' |
|
144 | - ); |
|
145 | - } |
|
146 | - |
|
30 | + /** |
|
31 | + * @see parent::get_priority() for documentation. |
|
32 | + * @return int |
|
33 | + */ |
|
34 | + public function get_priority() |
|
35 | + { |
|
36 | + return EEM_Message::priority_high; |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * This method returns whether this message type should always generate a new copy |
|
43 | + * when requested, or if links can be to the already generated copy. |
|
44 | + * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
45 | + * Receipts always generate |
|
46 | + * @return bool false means can link to generated EE_Message. true must regenerate. |
|
47 | + */ |
|
48 | + public function always_generate() |
|
49 | + { |
|
50 | + return true; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + protected function _set_admin_pages() |
|
55 | + { |
|
56 | + $this->admin_registered_pages = array( 'events_edit' => true ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + protected function _set_data_handler() |
|
62 | + { |
|
63 | + $this->_data_handler = 'Gateways'; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + protected function _set_with_messengers() |
|
69 | + { |
|
70 | + $this->_with_messengers = array( |
|
71 | + 'html' => array( 'pdf' ) |
|
72 | + ); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
78 | + { |
|
79 | + // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
80 | + $transaction = $registration->transaction(); |
|
81 | + if ($transaction instanceof EE_Transaction) { |
|
82 | + return array( $transaction ); |
|
83 | + } |
|
84 | + return array(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + protected function _set_admin_settings_fields() |
|
90 | + { |
|
91 | + $this->_admin_settings_fields = array(); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + protected function _set_contexts() |
|
97 | + { |
|
98 | + $this->_context_label = array( |
|
99 | + 'label' => __('recipient', 'event_espresso'), |
|
100 | + 'plural' => __('recipients', 'event_espresso'), |
|
101 | + 'description' => __('Recipient\'s are who will view the receipt.', 'event_espresso') |
|
102 | + ); |
|
103 | + |
|
104 | + $this->_contexts = array( |
|
105 | + 'purchaser' => array( |
|
106 | + 'label' => __('Purchaser', 'event_espresso'), |
|
107 | + 'description' => __('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
108 | + ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * used to set the valid shortcodes for the receipt message type |
|
117 | + * |
|
118 | + * @since 4.5.0 |
|
119 | + * |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + protected function _set_valid_shortcodes() |
|
123 | + { |
|
124 | + $this->_valid_shortcodes['purchaser'] = array( |
|
125 | + 'attendee_list', |
|
126 | + 'attendee', |
|
127 | + 'datetime_list', |
|
128 | + 'datetime', |
|
129 | + 'event_list', |
|
130 | + 'event', |
|
131 | + 'event_meta', |
|
132 | + 'messenger', |
|
133 | + 'organization', |
|
134 | + 'primary_registration_list', |
|
135 | + 'primary_registration_details', |
|
136 | + 'ticket_list', |
|
137 | + 'ticket', |
|
138 | + 'transaction', |
|
139 | + 'venue', |
|
140 | + 'line_item_list', |
|
141 | + 'payment_list', |
|
142 | + 'line_item', |
|
143 | + 'payment' |
|
144 | + ); |
|
145 | + } |
|
146 | + |
|
147 | 147 | |
148 | 148 | |
149 | 149 | |
150 | - protected function _purchaser_addressees() |
|
151 | - { |
|
152 | - return parent::_primary_attendee_addressees(); |
|
153 | - } |
|
150 | + protected function _purchaser_addressees() |
|
151 | + { |
|
152 | + return parent::_primary_attendee_addressees(); |
|
153 | + } |
|
154 | 154 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | protected function _set_admin_pages() |
55 | 55 | { |
56 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
56 | + $this->admin_registered_pages = array('events_edit' => true); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function _set_with_messengers() |
69 | 69 | { |
70 | 70 | $this->_with_messengers = array( |
71 | - 'html' => array( 'pdf' ) |
|
71 | + 'html' => array('pdf') |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // receipt message type data handler is 'Gateways' and it expects a transaction object. |
80 | 80 | $transaction = $registration->transaction(); |
81 | 81 | if ($transaction instanceof EE_Transaction) { |
82 | - return array( $transaction ); |
|
82 | + return array($transaction); |
|
83 | 83 | } |
84 | 84 | return array(); |
85 | 85 | } |
@@ -14,59 +14,59 @@ |
||
14 | 14 | class EE_Pending_Approval_message_type extends EE_Registration_Base_message_type |
15 | 15 | { |
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
19 | - $this->name = 'pending_approval'; |
|
20 | - $this->description = __('This message type is used for recipients who have Pending Payment registration status.', 'event_espresso'); |
|
21 | - $this->label = array( |
|
22 | - 'singular' => __('registration pending payment', 'event_espresso'), |
|
23 | - 'plural' => __('registrations pending payment', 'event_espresso') |
|
24 | - ); |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + $this->name = 'pending_approval'; |
|
20 | + $this->description = __('This message type is used for recipients who have Pending Payment registration status.', 'event_espresso'); |
|
21 | + $this->label = array( |
|
22 | + 'singular' => __('registration pending payment', 'event_espresso'), |
|
23 | + 'plural' => __('registrations pending payment', 'event_espresso') |
|
24 | + ); |
|
25 | 25 | |
26 | - $this->_master_templates = array( |
|
27 | - 'email' => 'registration' |
|
28 | - ); |
|
26 | + $this->_master_templates = array( |
|
27 | + 'email' => 'registration' |
|
28 | + ); |
|
29 | 29 | |
30 | - parent::__construct(); |
|
31 | - } |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * _set_contexts |
|
37 | - * This sets up the contexts associated with the message_type |
|
38 | - * |
|
39 | - * @access protected |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function _set_contexts() |
|
43 | - { |
|
44 | - $this->_context_label = array( |
|
45 | - 'label' => __('recipient', 'event_espresso'), |
|
46 | - 'plural' => __('recipients', 'event_espresso'), |
|
47 | - 'description' => __('Recipient\'s are who will receive the template. You may want different pending approval details sent out depending on who the recipient is. To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso') |
|
48 | - ); |
|
35 | + /** |
|
36 | + * _set_contexts |
|
37 | + * This sets up the contexts associated with the message_type |
|
38 | + * |
|
39 | + * @access protected |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function _set_contexts() |
|
43 | + { |
|
44 | + $this->_context_label = array( |
|
45 | + 'label' => __('recipient', 'event_espresso'), |
|
46 | + 'plural' => __('recipients', 'event_espresso'), |
|
47 | + 'description' => __('Recipient\'s are who will receive the template. You may want different pending approval details sent out depending on who the recipient is. To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso') |
|
48 | + ); |
|
49 | 49 | |
50 | - $this->_contexts = array( |
|
51 | - 'admin' => array( |
|
52 | - 'label' => __('Event Admin', 'event_espresso'), |
|
53 | - 'description' => __('This template is what event administrators will receive when a message is sent to registrants with the pending payment registration status.', 'event_espresso') |
|
54 | - ), |
|
55 | - 'primary_attendee' => array( |
|
56 | - 'label' => __('Primary Registrant', 'event_espresso'), |
|
57 | - 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive on when their registration status is pending payment.', 'event_espresso') |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
50 | + $this->_contexts = array( |
|
51 | + 'admin' => array( |
|
52 | + 'label' => __('Event Admin', 'event_espresso'), |
|
53 | + 'description' => __('This template is what event administrators will receive when a message is sent to registrants with the pending payment registration status.', 'event_espresso') |
|
54 | + ), |
|
55 | + 'primary_attendee' => array( |
|
56 | + 'label' => __('Primary Registrant', 'event_espresso'), |
|
57 | + 'description' => __('This template is what the primary registrant (the person who completed the initial transaction) will receive on when their registration status is pending payment.', 'event_espresso') |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - protected function _primary_attendee_addressees() |
|
65 | - { |
|
66 | - $cached = $this->_single_message; |
|
67 | - $this->_single_message = false; |
|
68 | - $addressees = parent::_primary_attendee_addressees(); |
|
69 | - $this->_single_message = $cached; |
|
70 | - return $addressees; |
|
71 | - } |
|
64 | + protected function _primary_attendee_addressees() |
|
65 | + { |
|
66 | + $cached = $this->_single_message; |
|
67 | + $this->_single_message = false; |
|
68 | + $addressees = parent::_primary_attendee_addressees(); |
|
69 | + $this->_single_message = $cached; |
|
70 | + return $addressees; |
|
71 | + } |
|
72 | 72 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | { |
409 | 409 | // validate context |
410 | 410 | // valid context? |
411 | - if (! isset($this->_contexts[ $context ])) { |
|
411 | + if ( ! isset($this->_contexts[$context])) { |
|
412 | 412 | throw new EE_Error( |
413 | 413 | sprintf( |
414 | 414 | __('The context %s is not a valid context for %s.', 'event_espresso'), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | public function get_data_for_context($context, EE_Registration $registration, $id = 0) |
465 | 465 | { |
466 | 466 | // valid context? |
467 | - if (! isset($this->_contexts[ $context ])) { |
|
467 | + if ( ! isset($this->_contexts[$context])) { |
|
468 | 468 | throw new EE_Error( |
469 | 469 | sprintf( |
470 | 470 | __('The context %s is not a valid context for %s.', 'event_espresso'), |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $this->_get_data_for_context($context, $registration, $id), |
480 | 480 | $this |
481 | 481 | ); |
482 | - $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this); |
|
482 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
483 | 483 | // if empty then something went wrong! |
484 | 484 | if (empty($data)) { |
485 | 485 | throw new EE_Error( |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | public function with_messengers() |
540 | 540 | { |
541 | 541 | return apply_filters( |
542 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this), |
|
542 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), |
|
543 | 543 | $this->_with_messengers |
544 | 544 | ); |
545 | 545 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | { |
601 | 601 | // first class specific filter then filter that by the global filter. |
602 | 602 | $master_templates = apply_filters( |
603 | - 'FHEE__' . get_class($this) . '__get_master_templates', |
|
603 | + 'FHEE__'.get_class($this).'__get_master_templates', |
|
604 | 604 | $this->_master_templates |
605 | 605 | ); |
606 | 606 | return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | $addressees = array(); |
625 | 625 | $original_contexts = $this->_contexts; |
626 | 626 | // if incoming context then limit to that context |
627 | - if (! empty($context)) { |
|
628 | - $cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : ''; |
|
629 | - if (! empty($cntxt)) { |
|
630 | - $this->_contexts = array(); |
|
631 | - $this->_contexts[ $context ] = $cntxt; |
|
627 | + if ( ! empty($context)) { |
|
628 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
629 | + if ( ! empty($cntxt)) { |
|
630 | + $this->_contexts = array(); |
|
631 | + $this->_contexts[$context] = $cntxt; |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | $this->_set_default_addressee_data(); |
@@ -653,13 +653,13 @@ discard block |
||
653 | 653 | { |
654 | 654 | // at a minimum, we NEED EE_Attendee objects. |
655 | 655 | if (empty($this->_data->attendees)) { |
656 | - return false; // there's no data to process! |
|
656 | + return false; // there's no data to process! |
|
657 | 657 | } |
658 | 658 | // process addressees for each context. Child classes will have to have methods for |
659 | 659 | // each context defined to handle the processing of the data object within them |
660 | 660 | foreach ($this->_contexts as $context => $details) { |
661 | - $xpctd_method = '_' . $context . '_addressees'; |
|
662 | - if (! method_exists($this, $xpctd_method)) { |
|
661 | + $xpctd_method = '_'.$context.'_addressees'; |
|
662 | + if ( ! method_exists($this, $xpctd_method)) { |
|
663 | 663 | throw new EE_Error( |
664 | 664 | sprintf( |
665 | 665 | __( |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ) |
672 | 672 | ); |
673 | 673 | } |
674 | - $this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method)); |
|
674 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
675 | 675 | } |
676 | 676 | return true; // data was processed successfully. |
677 | 677 | } |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | 'total_ticket_count' => $this->_data->total_ticket_count, |
708 | 708 | ); |
709 | 709 | if (is_array($this->_data->primary_attendee_data)) { |
710 | - $this->_default_addressee_data = array_merge( |
|
710 | + $this->_default_addressee_data = array_merge( |
|
711 | 711 | $this->_default_addressee_data, |
712 | 712 | $this->_data->primary_attendee_data |
713 | 713 | ); |
@@ -750,25 +750,25 @@ discard block |
||
750 | 750 | 'email', |
751 | 751 | 'messenger', |
752 | 752 | ); |
753 | - $contexts = $this->get_contexts(); |
|
753 | + $contexts = $this->get_contexts(); |
|
754 | 754 | foreach ($contexts as $context => $details) { |
755 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
755 | + $this->_valid_shortcodes[$context] = $all_shortcodes; |
|
756 | 756 | // make sure non admin context does not include the event_author shortcodes |
757 | 757 | if ($context != 'admin') { |
758 | - if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) { |
|
759 | - unset($this->_valid_shortcodes[ $context ][ $key ]); |
|
758 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
759 | + unset($this->_valid_shortcodes[$context][$key]); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | } |
763 | 763 | // make sure admin context does not include the recipient_details shortcodes |
764 | 764 | // IF we have admin context hooked in message types might not have that context. |
765 | - if (! empty($this->_valid_shortcodes['admin'])) { |
|
765 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
766 | 766 | if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
767 | - unset($this->_valid_shortcodes['admin'][ $key ]); |
|
767 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
768 | 768 | } |
769 | 769 | // make sure admin context does not include the recipient_details shortcodes |
770 | 770 | if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
771 | - unset($this->_valid_shortcodes['admin'][ $key ]); |
|
771 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | public function reset_valid_shortcodes_config($new_config) |
784 | 784 | { |
785 | 785 | foreach ($new_config as $context => $shortcodes) { |
786 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
786 | + $this->_valid_shortcodes[$context] = $shortcodes; |
|
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
@@ -807,11 +807,11 @@ discard block |
||
807 | 807 | foreach ($this->_data->events as $line_ref => $event) { |
808 | 808 | $admin_id = $this->_get_event_admin_id($event['ID']); |
809 | 809 | // make sure we are just including the events that belong to this admin! |
810 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
810 | + $admin_events[$admin_id][$line_ref] = $event; |
|
811 | 811 | } |
812 | 812 | // k now we can loop through the event_admins and setup the addressee data. |
813 | 813 | foreach ($admin_events as $admin_id => $event_details) { |
814 | - $aee = array( |
|
814 | + $aee = array( |
|
815 | 815 | 'user_id' => $admin_id, |
816 | 816 | 'events' => $event_details, |
817 | 817 | 'attendees' => $this->_data->attendees, |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | } |
869 | 869 | // is $this->_regs_for_sending present? |
870 | 870 | // If so, let's make sure we ONLY generate addressee for registrations in that array. |
871 | - if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
871 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
872 | 872 | $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
873 | 873 | if (empty($regs_allowed)) { |
874 | 874 | continue; |
@@ -886,10 +886,10 @@ discard block |
||
886 | 886 | } |
887 | 887 | $already_processed[] = $att_id; |
888 | 888 | foreach ($details as $item => $value) { |
889 | - $aee[ $item ] = $value; |
|
889 | + $aee[$item] = $value; |
|
890 | 890 | if ($item === 'line_ref') { |
891 | 891 | foreach ($value as $event_id) { |
892 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
892 | + $aee['events'][$event_id] = $this->_data->events[$event_id]; |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | if ($item === 'attendee_email') { |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | } |
902 | 902 | // note the FIRST reg object in this array is the one |
903 | 903 | // we'll use for this attendee as the primary registration for this attendee. |
904 | - $aee['reg_obj'] = reset($this->_data->attendees[ $att_id ]['reg_objs']); |
|
904 | + $aee['reg_obj'] = reset($this->_data->attendees[$att_id]['reg_objs']); |
|
905 | 905 | $aee['attendees'] = $this->_data->attendees; |
906 | 906 | $aee['recipient_id'] = $att_id; |
907 | 907 | $aee['recipient_type'] = 'Attendee'; |
@@ -17,915 +17,915 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * message type child classes will set what contexts are associated with the message type via this array. |
|
22 | - * format: |
|
23 | - * array( |
|
24 | - * 'context' => array( |
|
25 | - * 'label' => __('Context Label', 'event_espresso'), |
|
26 | - * 'description' => __('Context description (for help popups)', 'event_espresso') |
|
27 | - * )); |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - protected $_contexts = array(); |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.) |
|
36 | - * Format: |
|
37 | - * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' ); |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - protected $_context_label; |
|
42 | - |
|
43 | - |
|
44 | - /** MESSAGE ASSEMBLING PROPERTIES **/ |
|
45 | - /** |
|
46 | - * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger. |
|
47 | - * |
|
48 | - * @var array of message objects. |
|
49 | - */ |
|
50 | - public $messages = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * The following holds the templates that will be used to assemble the message object for the messenger. |
|
54 | - * |
|
55 | - * @var array |
|
56 | - */ |
|
57 | - protected $_templates; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * If a specific template is being parsed, this will hold the message template group GRP_ID for that template. |
|
62 | - * |
|
63 | - * @var int. |
|
64 | - */ |
|
65 | - protected $_GRP_ID; |
|
66 | - |
|
67 | - |
|
68 | - /** OTHER INFO PROPERTIES **/ |
|
69 | - /** |
|
70 | - * This will hold the count of the message objects in the messages array. This could be used for determining if |
|
71 | - * batching/queueing is needed. |
|
72 | - * |
|
73 | - * @var int |
|
74 | - */ |
|
75 | - public $count = 0; |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of |
|
80 | - * this message type at time of sending. |
|
81 | - * |
|
82 | - * @var EE_messenger |
|
83 | - */ |
|
84 | - protected $_active_messenger; |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates |
|
89 | - * |
|
90 | - * @var object |
|
91 | - */ |
|
92 | - protected $_shortcode_replace; |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * The purpose for this property is to simply allow message types to indicate if the message generated is intended |
|
97 | - * for only single context. Child message types should redefine this variable (if necessary) in the |
|
98 | - * _set_data_Handler() method. |
|
99 | - * |
|
100 | - * @var boolean |
|
101 | - */ |
|
102 | - protected $_single_message = false; |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * This will hold an array of specific reg_ids that are receiving messages. |
|
107 | - * |
|
108 | - * @since 4.7.x |
|
109 | - * @var array |
|
110 | - */ |
|
111 | - protected $_regs_for_sending = array(); |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * This holds the data passed to this class from the controller and also the final processed data. |
|
116 | - * |
|
117 | - * @var object |
|
118 | - */ |
|
119 | - protected $_data; |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * this is just a flag indicating whether we're in preview mode or not. |
|
124 | - * |
|
125 | - * @var bool |
|
126 | - */ |
|
127 | - protected $_preview = false; |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This just holds defaults for addressee data that children merge with their data array setup |
|
132 | - * |
|
133 | - * @var array |
|
134 | - */ |
|
135 | - protected $_default_addressee_data; |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Child classes declare through this property what handler they want to use for the incoming data and this string |
|
140 | - * is used to instantiate the EE_Messages_incoming_data child class for that handler. |
|
141 | - * |
|
142 | - * @var string |
|
143 | - */ |
|
144 | - protected $_data_handler; |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * This holds any specific fields for holding any settings related to a message type (if any needed) |
|
149 | - * |
|
150 | - * @var array |
|
151 | - */ |
|
152 | - protected $_admin_settings_fields = array(); |
|
153 | - |
|
154 | - /** |
|
155 | - * this property will hold any existing setting that may have been set in the admin. |
|
156 | - * |
|
157 | - * @var array |
|
158 | - */ |
|
159 | - protected $_existing_admin_settings = array(); |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * This is used to designate the generating and alternative sending messengers for a message type. It is set via |
|
164 | - * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message |
|
165 | - * type. However ONLY the generating messengers are used for creating templates for this message type. Should be |
|
166 | - * in this format: |
|
167 | - * { |
|
168 | - * |
|
169 | - * @type string $generating_messenger the name of the generating messenger. Generating |
|
170 | - * messengers are used for generating templates, |
|
171 | - * doing validation and defining valid shortcodes. |
|
172 | - * { |
|
173 | - * @type string $sending_messenger values are the name(s) for the sending |
|
174 | - * messengers. sending messengers are |
|
175 | - * just valid delivery vehicles that will utilize |
|
176 | - * the templates (and generated EE_message |
|
177 | - * objects from the generating messengers). |
|
178 | - * } |
|
179 | - * } |
|
180 | - * @since 4.5.0 |
|
181 | - * @var array |
|
182 | - */ |
|
183 | - protected $_with_messengers = array(); |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects. |
|
188 | - * |
|
189 | - * @access protected |
|
190 | - * @var array |
|
191 | - */ |
|
192 | - protected $_addressees = array(); |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * This allows each message type to set what alternate messenger&message type combination can be used for fallback |
|
197 | - * default templates if there are no specific ones defined for this messenger and message type. Should be in the |
|
198 | - * format: |
|
199 | - * array( |
|
200 | - * 'messenger' => 'message_type', |
|
201 | - * 'another_messenger' => another_message_type |
|
202 | - * ); |
|
203 | - * This is set in the message type constructor. |
|
204 | - * |
|
205 | - * @var array |
|
206 | - */ |
|
207 | - protected $_master_templates = array(); |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * This holds whatever the set template pack is for a message template group when generating messages. |
|
212 | - * |
|
213 | - * @since 4.5.0 |
|
214 | - * @var EE_Messages_Template_Pack |
|
215 | - */ |
|
216 | - protected $_template_pack; |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * This holds whatever the set variation is for a message template group when generating messages. |
|
221 | - * |
|
222 | - * @since 4.5.0 |
|
223 | - * @var string |
|
224 | - */ |
|
225 | - protected $_variation; |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * EE_message_type constructor. |
|
230 | - */ |
|
231 | - public function __construct() |
|
232 | - { |
|
233 | - $this->_messages_item_type = 'message_type'; |
|
234 | - $this->_set_contexts(); |
|
235 | - $this->_set_with_messengers(); |
|
236 | - parent::__construct(); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * This sets the data handler for the message type. It must be used to define the _data_handler property. It is |
|
242 | - * called when messages are setup. |
|
243 | - * |
|
244 | - * @abstract |
|
245 | - * @access protected |
|
246 | - * @return void |
|
247 | - */ |
|
248 | - abstract protected function _set_data_handler(); |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and |
|
253 | - * ID (which should be the primary key id for the base class). Client code doesn't have to know what a message |
|
254 | - * type's data handler is. |
|
255 | - * |
|
256 | - * @since 4.5.0 |
|
257 | - * @param string $context This should be a string matching a valid context for the message type. |
|
258 | - * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people |
|
259 | - * guessing a url). |
|
260 | - * @param int $id Optional. Integer corresponding to the value for the primary key of a |
|
261 | - * EE_Base_Class_Object |
|
262 | - * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
|
263 | - */ |
|
264 | - abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * _set_contexts |
|
269 | - * This sets up the contexts associated with the message_type |
|
270 | - * |
|
271 | - * @abstract |
|
272 | - * @access protected |
|
273 | - * @return void |
|
274 | - */ |
|
275 | - abstract protected function _set_contexts(); |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger(). |
|
280 | - * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific |
|
281 | - * EE_Base_Class that is required in generating a message for a message type recipient then the message |
|
282 | - * type should override this method and use the given params to generate the correct ID. |
|
283 | - * |
|
284 | - * @param string $context The message type context. |
|
285 | - * @param EE_Registration $registration Registration object |
|
286 | - * @deprecated 4.9.0 |
|
287 | - * @return int |
|
288 | - */ |
|
289 | - protected function _get_id_for_msg_url($context, EE_Registration $registration) |
|
290 | - { |
|
291 | - return 0; |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * This sets up any action/filter hooks this message type puts in place for a specific messenger. Note that by |
|
297 | - * default this does nothing. Child classes will need to override if they want to add specific hooks for a |
|
298 | - * messenger. |
|
299 | - * |
|
300 | - * @since 1.0.0 |
|
301 | - * @return void |
|
302 | - */ |
|
303 | - protected function _do_messenger_hooks() |
|
304 | - { |
|
305 | - return; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * This is a public wrapper for the protected _do_messenger_hooks() method. |
|
311 | - * For backward compat reasons, this was done rather than making the protected method public. |
|
312 | - * |
|
313 | - * @param EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able |
|
314 | - * to know what messenger is being used to send the message at the time of |
|
315 | - * sending. |
|
316 | - * @since 4.9.0 |
|
317 | - */ |
|
318 | - public function do_messenger_hooks($messenger = null) |
|
319 | - { |
|
320 | - $this->_active_messenger = $messenger; |
|
321 | - $this->_do_messenger_hooks(); |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * This method returns whether this message type should always generate a new copy |
|
327 | - * when requested, or if links can be to the already generated copy. |
|
328 | - * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
329 | - * Child classes should override this if different from the default of false. |
|
330 | - * |
|
331 | - * @return bool false means can link to generated EE_Message. true must regenerate. |
|
332 | - */ |
|
333 | - public function always_generate() |
|
334 | - { |
|
335 | - return false; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * Returns the priority for the message type. |
|
341 | - * Priorities are defined as constants on EEM_Message. Currently there are three priorities: |
|
342 | - * - EEM_Message::priority_high |
|
343 | - * - EEM_Message::priority_medium |
|
344 | - * - EEM_Message::priority_low |
|
345 | - * Priority is used to determine the weight the message type is given when queuing for generation and/or sending. |
|
346 | - * |
|
347 | - * @see EEM_Message for more phpdocs on priority. |
|
348 | - * The default priority for all message_types is EEM_Message::priority_low. Message Types wanting to give |
|
349 | - * a higher priority must override this method. Also note, messengers are able to override priorities |
|
350 | - * queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger |
|
351 | - * which displays things in the browser. |
|
352 | - * @since 4.9.0 |
|
353 | - * @return int |
|
354 | - */ |
|
355 | - public function get_priority() |
|
356 | - { |
|
357 | - return EEM_Message::priority_low; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * This runs the _set_data_handler() method for message types and then returns what got set. |
|
363 | - * |
|
364 | - * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
|
365 | - * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
|
366 | - */ |
|
367 | - public function get_data_handler($data) |
|
368 | - { |
|
369 | - $this->_data = $data; |
|
370 | - $this->_set_data_handler(); |
|
371 | - return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * This is called externally to reset the value of the $_data property for the message type. |
|
377 | - * Please note the value of the _data is highly volatile. It was added as an interim measure ensuring |
|
378 | - * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called |
|
379 | - * (and for back compat reasons). This particular method is used in |
|
380 | - * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is |
|
381 | - * cleaned before subsequent EE_Message generation in the same request. |
|
382 | - * |
|
383 | - * @todo This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to |
|
384 | - * ensure that there is no manipulation of the _data property during run time so there's a clear |
|
385 | - * expectation of what it is. Likely we need to ensure that _data is not persisted IN the message type |
|
386 | - * at all. |
|
387 | - * @internal Plugin authors, do not implement this method, it is subject to change. |
|
388 | - * @since 4.9 |
|
389 | - */ |
|
390 | - public function reset_data() |
|
391 | - { |
|
392 | - $this->_data = null; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * This does some validation of incoming params gets the url trigger from the defined method in the specific child |
|
398 | - * class and then filters the results. |
|
399 | - * |
|
400 | - * @param string $context The message type context |
|
401 | - * @param string $sending_messenger The sending messenger |
|
402 | - * @param EE_Registration $registration Registration object |
|
403 | - * @throws EE_Error |
|
404 | - * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
|
405 | - * @return string generated url |
|
406 | - */ |
|
407 | - public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) |
|
408 | - { |
|
409 | - // validate context |
|
410 | - // valid context? |
|
411 | - if (! isset($this->_contexts[ $context ])) { |
|
412 | - throw new EE_Error( |
|
413 | - sprintf( |
|
414 | - __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
415 | - $context, |
|
416 | - get_class($this) |
|
417 | - ) |
|
418 | - ); |
|
419 | - } |
|
420 | - // valid sending_messenger? |
|
421 | - $not_valid_msgr = false; |
|
422 | - foreach ($this->_with_messengers as $generating => $sendings) { |
|
423 | - if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
424 | - $not_valid_msgr = true; |
|
425 | - } |
|
426 | - } |
|
427 | - if ($not_valid_msgr) { |
|
428 | - throw new EE_Error( |
|
429 | - sprintf( |
|
430 | - __( |
|
431 | - 'The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', |
|
432 | - 'event_espresso' |
|
433 | - ), |
|
434 | - $sending_messenger, |
|
435 | - get_class($this) |
|
436 | - ) |
|
437 | - ); |
|
438 | - } |
|
439 | - return EEH_MSG_Template::generate_url_trigger( |
|
440 | - $sending_messenger, |
|
441 | - $this->_active_messenger->name, |
|
442 | - $context, |
|
443 | - $this->name, |
|
444 | - $registration, |
|
445 | - $this->_GRP_ID, |
|
446 | - $this->_get_id_for_msg_url($context, $registration) |
|
447 | - ); |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows |
|
453 | - * for filtering. This is (currently) called by the EED_Messages module. |
|
454 | - * |
|
455 | - * @since 4.5.0 |
|
456 | - * @throws EE_Error |
|
457 | - * @param string $context This should be a string matching a valid context for the message type. |
|
458 | - * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people |
|
459 | - * guessing a url). |
|
460 | - * @param int $id Optional. Integer corresponding to the value for the primary key of a |
|
461 | - * EE_Base_Class_Object |
|
462 | - * @return mixed (EE_Base_Class||EE_Base_Class[]) |
|
463 | - */ |
|
464 | - public function get_data_for_context($context, EE_Registration $registration, $id = 0) |
|
465 | - { |
|
466 | - // valid context? |
|
467 | - if (! isset($this->_contexts[ $context ])) { |
|
468 | - throw new EE_Error( |
|
469 | - sprintf( |
|
470 | - __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
471 | - $context, |
|
472 | - get_class($this) |
|
473 | - ) |
|
474 | - ); |
|
475 | - } |
|
476 | - // get data and apply global and class specific filters on it. |
|
477 | - $data = apply_filters( |
|
478 | - 'FHEE__EE_message_type__get_data_for_context__data', |
|
479 | - $this->_get_data_for_context($context, $registration, $id), |
|
480 | - $this |
|
481 | - ); |
|
482 | - $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this); |
|
483 | - // if empty then something went wrong! |
|
484 | - if (empty($data)) { |
|
485 | - throw new EE_Error( |
|
486 | - sprintf( |
|
487 | - __( |
|
488 | - 'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', |
|
489 | - 'event_espresso' |
|
490 | - ), |
|
491 | - $id, |
|
492 | - $this->name |
|
493 | - ) |
|
494 | - ); |
|
495 | - } |
|
496 | - return $data; |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * This returns the contents of the _data property. |
|
502 | - * Please note the value of the _data is highly volatile. It was added as an interim measure ensuring |
|
503 | - * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called. |
|
504 | - * |
|
505 | - * @todo This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to |
|
506 | - * ensure that there is no manipulation of the _data property during run time so there's a clear |
|
507 | - * expectation of what it is. |
|
508 | - * @internal Plugin authors, do not implement this method, it is subject to change. |
|
509 | - * @return mixed |
|
510 | - */ |
|
511 | - public function get_data() |
|
512 | - { |
|
513 | - return $this->_data; |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * used to set the $_with_messengers property. (this is a default, child classes SHOULD override) |
|
519 | - * |
|
520 | - * @see property definition for description of setup. |
|
521 | - * @since 4.5.0 |
|
522 | - * @abstract |
|
523 | - * @return void |
|
524 | - */ |
|
525 | - protected function _set_with_messengers() |
|
526 | - { |
|
527 | - $this->_with_messengers = array( |
|
528 | - 'email' => array('html'), |
|
529 | - ); |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - /** |
|
534 | - * Return the value of the _with_messengers property |
|
535 | - * |
|
536 | - * @since 4.5.0 |
|
537 | - * @return array |
|
538 | - */ |
|
539 | - public function with_messengers() |
|
540 | - { |
|
541 | - return apply_filters( |
|
542 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this), |
|
543 | - $this->_with_messengers |
|
544 | - ); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class |
|
550 | - * callback function if that page is registered via the `_admin_registered_page` property set by the child class. |
|
551 | - * * |
|
552 | - * |
|
553 | - * @param string $page the slug of the EE admin page |
|
554 | - * @param array $messengers an array of active messenger objects |
|
555 | - * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages) |
|
556 | - * @param array $extra This is just an extra argument that can be used to pass additional data for setting up |
|
557 | - * page content. |
|
558 | - * @access public |
|
559 | - * @return string |
|
560 | - */ |
|
561 | - public function get_message_type_admin_page_content( |
|
562 | - $page, |
|
563 | - $action = null, |
|
564 | - $extra = array(), |
|
565 | - $messengers = array() |
|
566 | - ) { |
|
567 | - // we can also further refine the context by action (if present). |
|
568 | - return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
569 | - } |
|
570 | - |
|
571 | - |
|
572 | - /** |
|
573 | - * @return array |
|
574 | - */ |
|
575 | - public function get_contexts() |
|
576 | - { |
|
577 | - return $this->_contexts; |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * This just returns the context label for a given context (as set in $_context_label property) |
|
583 | - * |
|
584 | - * @access public |
|
585 | - * @return array |
|
586 | - */ |
|
587 | - public function get_context_label() |
|
588 | - { |
|
589 | - return $this->_context_label; |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * This just returns the (filtered) _master_templates property. |
|
595 | - * |
|
596 | - * @see property definition for documentation. |
|
597 | - * @return array |
|
598 | - */ |
|
599 | - public function get_master_templates() |
|
600 | - { |
|
601 | - // first class specific filter then filter that by the global filter. |
|
602 | - $master_templates = apply_filters( |
|
603 | - 'FHEE__' . get_class($this) . '__get_master_templates', |
|
604 | - $this->_master_templates |
|
605 | - ); |
|
606 | - return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
607 | - } |
|
608 | - |
|
609 | - |
|
610 | - /** |
|
611 | - * Accepts an incoming data handler which contains data for processing, and returns an array of |
|
612 | - * EE_Messages_Addressee objects. |
|
613 | - * |
|
614 | - * @param EE_Messages_incoming_data $data |
|
615 | - * @param string $context Limit addressees to specific context. |
|
616 | - * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
|
617 | - * that context |
|
618 | - * @throws EE_Error |
|
619 | - */ |
|
620 | - public function get_addressees(EE_Messages_incoming_data $data, $context = '') |
|
621 | - { |
|
622 | - // override _data |
|
623 | - $this->_data = $data; |
|
624 | - $addressees = array(); |
|
625 | - $original_contexts = $this->_contexts; |
|
626 | - // if incoming context then limit to that context |
|
627 | - if (! empty($context)) { |
|
628 | - $cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : ''; |
|
629 | - if (! empty($cntxt)) { |
|
630 | - $this->_contexts = array(); |
|
631 | - $this->_contexts[ $context ] = $cntxt; |
|
632 | - } |
|
633 | - } |
|
634 | - $this->_set_default_addressee_data(); |
|
635 | - if ($this->_process_data()) { |
|
636 | - $addressees = $this->_addressees; |
|
637 | - } |
|
638 | - |
|
639 | - // reset contexts and addressees |
|
640 | - $this->_contexts = $original_contexts; |
|
641 | - $this->_addressees = array(); |
|
642 | - return $addressees; |
|
643 | - } |
|
644 | - |
|
645 | - |
|
646 | - /** |
|
647 | - * processes the data object so we get |
|
648 | - * |
|
649 | - * @throws EE_Error |
|
650 | - * @return bool true means data was processed successfully, false means not. |
|
651 | - */ |
|
652 | - protected function _process_data() |
|
653 | - { |
|
654 | - // at a minimum, we NEED EE_Attendee objects. |
|
655 | - if (empty($this->_data->attendees)) { |
|
656 | - return false; // there's no data to process! |
|
657 | - } |
|
658 | - // process addressees for each context. Child classes will have to have methods for |
|
659 | - // each context defined to handle the processing of the data object within them |
|
660 | - foreach ($this->_contexts as $context => $details) { |
|
661 | - $xpctd_method = '_' . $context . '_addressees'; |
|
662 | - if (! method_exists($this, $xpctd_method)) { |
|
663 | - throw new EE_Error( |
|
664 | - sprintf( |
|
665 | - __( |
|
666 | - 'The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', |
|
667 | - 'event_espresso' |
|
668 | - ), |
|
669 | - $this->label['singular'], |
|
670 | - $xpctd_method |
|
671 | - ) |
|
672 | - ); |
|
673 | - } |
|
674 | - $this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method)); |
|
675 | - } |
|
676 | - return true; // data was processed successfully. |
|
677 | - } |
|
678 | - |
|
679 | - |
|
680 | - /** |
|
681 | - * sets the default_addressee_data property, |
|
682 | - * |
|
683 | - * @access private |
|
684 | - * @return void |
|
685 | - */ |
|
686 | - private function _set_default_addressee_data() |
|
687 | - { |
|
688 | - $this->_default_addressee_data = array( |
|
689 | - 'billing' => $this->_data->billing, |
|
690 | - 'taxes' => $this->_data->taxes, |
|
691 | - 'tax_line_items' => $this->_data->tax_line_items, |
|
692 | - 'additional_line_items' => $this->_data->additional_line_items, |
|
693 | - 'grand_total_line_item' => $this->_data->grand_total_line_item, |
|
694 | - 'txn' => $this->_data->txn, |
|
695 | - 'payments' => $this->_data->payments, |
|
696 | - 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
697 | - ? $this->_data->payment |
|
698 | - : null, |
|
699 | - 'reg_objs' => $this->_data->reg_objs, |
|
700 | - 'registrations' => $this->_data->registrations, |
|
701 | - 'datetimes' => $this->_data->datetimes, |
|
702 | - 'tickets' => $this->_data->tickets, |
|
703 | - 'line_items_with_children' => $this->_data->line_items_with_children, |
|
704 | - 'questions' => $this->_data->questions, |
|
705 | - 'answers' => $this->_data->answers, |
|
706 | - 'txn_status' => $this->_data->txn_status, |
|
707 | - 'total_ticket_count' => $this->_data->total_ticket_count, |
|
708 | - ); |
|
709 | - if (is_array($this->_data->primary_attendee_data)) { |
|
710 | - $this->_default_addressee_data = array_merge( |
|
711 | - $this->_default_addressee_data, |
|
712 | - $this->_data->primary_attendee_data |
|
713 | - ); |
|
714 | - $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj']; |
|
715 | - $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj']; |
|
716 | - } |
|
717 | - } |
|
718 | - |
|
719 | - |
|
720 | - |
|
721 | - /******************** |
|
20 | + /** |
|
21 | + * message type child classes will set what contexts are associated with the message type via this array. |
|
22 | + * format: |
|
23 | + * array( |
|
24 | + * 'context' => array( |
|
25 | + * 'label' => __('Context Label', 'event_espresso'), |
|
26 | + * 'description' => __('Context description (for help popups)', 'event_espresso') |
|
27 | + * )); |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + protected $_contexts = array(); |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.) |
|
36 | + * Format: |
|
37 | + * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' ); |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + protected $_context_label; |
|
42 | + |
|
43 | + |
|
44 | + /** MESSAGE ASSEMBLING PROPERTIES **/ |
|
45 | + /** |
|
46 | + * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger. |
|
47 | + * |
|
48 | + * @var array of message objects. |
|
49 | + */ |
|
50 | + public $messages = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * The following holds the templates that will be used to assemble the message object for the messenger. |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + protected $_templates; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * If a specific template is being parsed, this will hold the message template group GRP_ID for that template. |
|
62 | + * |
|
63 | + * @var int. |
|
64 | + */ |
|
65 | + protected $_GRP_ID; |
|
66 | + |
|
67 | + |
|
68 | + /** OTHER INFO PROPERTIES **/ |
|
69 | + /** |
|
70 | + * This will hold the count of the message objects in the messages array. This could be used for determining if |
|
71 | + * batching/queueing is needed. |
|
72 | + * |
|
73 | + * @var int |
|
74 | + */ |
|
75 | + public $count = 0; |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of |
|
80 | + * this message type at time of sending. |
|
81 | + * |
|
82 | + * @var EE_messenger |
|
83 | + */ |
|
84 | + protected $_active_messenger; |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates |
|
89 | + * |
|
90 | + * @var object |
|
91 | + */ |
|
92 | + protected $_shortcode_replace; |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * The purpose for this property is to simply allow message types to indicate if the message generated is intended |
|
97 | + * for only single context. Child message types should redefine this variable (if necessary) in the |
|
98 | + * _set_data_Handler() method. |
|
99 | + * |
|
100 | + * @var boolean |
|
101 | + */ |
|
102 | + protected $_single_message = false; |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * This will hold an array of specific reg_ids that are receiving messages. |
|
107 | + * |
|
108 | + * @since 4.7.x |
|
109 | + * @var array |
|
110 | + */ |
|
111 | + protected $_regs_for_sending = array(); |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * This holds the data passed to this class from the controller and also the final processed data. |
|
116 | + * |
|
117 | + * @var object |
|
118 | + */ |
|
119 | + protected $_data; |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * this is just a flag indicating whether we're in preview mode or not. |
|
124 | + * |
|
125 | + * @var bool |
|
126 | + */ |
|
127 | + protected $_preview = false; |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This just holds defaults for addressee data that children merge with their data array setup |
|
132 | + * |
|
133 | + * @var array |
|
134 | + */ |
|
135 | + protected $_default_addressee_data; |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Child classes declare through this property what handler they want to use for the incoming data and this string |
|
140 | + * is used to instantiate the EE_Messages_incoming_data child class for that handler. |
|
141 | + * |
|
142 | + * @var string |
|
143 | + */ |
|
144 | + protected $_data_handler; |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * This holds any specific fields for holding any settings related to a message type (if any needed) |
|
149 | + * |
|
150 | + * @var array |
|
151 | + */ |
|
152 | + protected $_admin_settings_fields = array(); |
|
153 | + |
|
154 | + /** |
|
155 | + * this property will hold any existing setting that may have been set in the admin. |
|
156 | + * |
|
157 | + * @var array |
|
158 | + */ |
|
159 | + protected $_existing_admin_settings = array(); |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * This is used to designate the generating and alternative sending messengers for a message type. It is set via |
|
164 | + * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message |
|
165 | + * type. However ONLY the generating messengers are used for creating templates for this message type. Should be |
|
166 | + * in this format: |
|
167 | + * { |
|
168 | + * |
|
169 | + * @type string $generating_messenger the name of the generating messenger. Generating |
|
170 | + * messengers are used for generating templates, |
|
171 | + * doing validation and defining valid shortcodes. |
|
172 | + * { |
|
173 | + * @type string $sending_messenger values are the name(s) for the sending |
|
174 | + * messengers. sending messengers are |
|
175 | + * just valid delivery vehicles that will utilize |
|
176 | + * the templates (and generated EE_message |
|
177 | + * objects from the generating messengers). |
|
178 | + * } |
|
179 | + * } |
|
180 | + * @since 4.5.0 |
|
181 | + * @var array |
|
182 | + */ |
|
183 | + protected $_with_messengers = array(); |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects. |
|
188 | + * |
|
189 | + * @access protected |
|
190 | + * @var array |
|
191 | + */ |
|
192 | + protected $_addressees = array(); |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * This allows each message type to set what alternate messenger&message type combination can be used for fallback |
|
197 | + * default templates if there are no specific ones defined for this messenger and message type. Should be in the |
|
198 | + * format: |
|
199 | + * array( |
|
200 | + * 'messenger' => 'message_type', |
|
201 | + * 'another_messenger' => another_message_type |
|
202 | + * ); |
|
203 | + * This is set in the message type constructor. |
|
204 | + * |
|
205 | + * @var array |
|
206 | + */ |
|
207 | + protected $_master_templates = array(); |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * This holds whatever the set template pack is for a message template group when generating messages. |
|
212 | + * |
|
213 | + * @since 4.5.0 |
|
214 | + * @var EE_Messages_Template_Pack |
|
215 | + */ |
|
216 | + protected $_template_pack; |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * This holds whatever the set variation is for a message template group when generating messages. |
|
221 | + * |
|
222 | + * @since 4.5.0 |
|
223 | + * @var string |
|
224 | + */ |
|
225 | + protected $_variation; |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * EE_message_type constructor. |
|
230 | + */ |
|
231 | + public function __construct() |
|
232 | + { |
|
233 | + $this->_messages_item_type = 'message_type'; |
|
234 | + $this->_set_contexts(); |
|
235 | + $this->_set_with_messengers(); |
|
236 | + parent::__construct(); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * This sets the data handler for the message type. It must be used to define the _data_handler property. It is |
|
242 | + * called when messages are setup. |
|
243 | + * |
|
244 | + * @abstract |
|
245 | + * @access protected |
|
246 | + * @return void |
|
247 | + */ |
|
248 | + abstract protected function _set_data_handler(); |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and |
|
253 | + * ID (which should be the primary key id for the base class). Client code doesn't have to know what a message |
|
254 | + * type's data handler is. |
|
255 | + * |
|
256 | + * @since 4.5.0 |
|
257 | + * @param string $context This should be a string matching a valid context for the message type. |
|
258 | + * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people |
|
259 | + * guessing a url). |
|
260 | + * @param int $id Optional. Integer corresponding to the value for the primary key of a |
|
261 | + * EE_Base_Class_Object |
|
262 | + * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
|
263 | + */ |
|
264 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * _set_contexts |
|
269 | + * This sets up the contexts associated with the message_type |
|
270 | + * |
|
271 | + * @abstract |
|
272 | + * @access protected |
|
273 | + * @return void |
|
274 | + */ |
|
275 | + abstract protected function _set_contexts(); |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger(). |
|
280 | + * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific |
|
281 | + * EE_Base_Class that is required in generating a message for a message type recipient then the message |
|
282 | + * type should override this method and use the given params to generate the correct ID. |
|
283 | + * |
|
284 | + * @param string $context The message type context. |
|
285 | + * @param EE_Registration $registration Registration object |
|
286 | + * @deprecated 4.9.0 |
|
287 | + * @return int |
|
288 | + */ |
|
289 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) |
|
290 | + { |
|
291 | + return 0; |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * This sets up any action/filter hooks this message type puts in place for a specific messenger. Note that by |
|
297 | + * default this does nothing. Child classes will need to override if they want to add specific hooks for a |
|
298 | + * messenger. |
|
299 | + * |
|
300 | + * @since 1.0.0 |
|
301 | + * @return void |
|
302 | + */ |
|
303 | + protected function _do_messenger_hooks() |
|
304 | + { |
|
305 | + return; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * This is a public wrapper for the protected _do_messenger_hooks() method. |
|
311 | + * For backward compat reasons, this was done rather than making the protected method public. |
|
312 | + * |
|
313 | + * @param EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able |
|
314 | + * to know what messenger is being used to send the message at the time of |
|
315 | + * sending. |
|
316 | + * @since 4.9.0 |
|
317 | + */ |
|
318 | + public function do_messenger_hooks($messenger = null) |
|
319 | + { |
|
320 | + $this->_active_messenger = $messenger; |
|
321 | + $this->_do_messenger_hooks(); |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * This method returns whether this message type should always generate a new copy |
|
327 | + * when requested, or if links can be to the already generated copy. |
|
328 | + * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
329 | + * Child classes should override this if different from the default of false. |
|
330 | + * |
|
331 | + * @return bool false means can link to generated EE_Message. true must regenerate. |
|
332 | + */ |
|
333 | + public function always_generate() |
|
334 | + { |
|
335 | + return false; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * Returns the priority for the message type. |
|
341 | + * Priorities are defined as constants on EEM_Message. Currently there are three priorities: |
|
342 | + * - EEM_Message::priority_high |
|
343 | + * - EEM_Message::priority_medium |
|
344 | + * - EEM_Message::priority_low |
|
345 | + * Priority is used to determine the weight the message type is given when queuing for generation and/or sending. |
|
346 | + * |
|
347 | + * @see EEM_Message for more phpdocs on priority. |
|
348 | + * The default priority for all message_types is EEM_Message::priority_low. Message Types wanting to give |
|
349 | + * a higher priority must override this method. Also note, messengers are able to override priorities |
|
350 | + * queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger |
|
351 | + * which displays things in the browser. |
|
352 | + * @since 4.9.0 |
|
353 | + * @return int |
|
354 | + */ |
|
355 | + public function get_priority() |
|
356 | + { |
|
357 | + return EEM_Message::priority_low; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * This runs the _set_data_handler() method for message types and then returns what got set. |
|
363 | + * |
|
364 | + * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
|
365 | + * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
|
366 | + */ |
|
367 | + public function get_data_handler($data) |
|
368 | + { |
|
369 | + $this->_data = $data; |
|
370 | + $this->_set_data_handler(); |
|
371 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * This is called externally to reset the value of the $_data property for the message type. |
|
377 | + * Please note the value of the _data is highly volatile. It was added as an interim measure ensuring |
|
378 | + * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called |
|
379 | + * (and for back compat reasons). This particular method is used in |
|
380 | + * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is |
|
381 | + * cleaned before subsequent EE_Message generation in the same request. |
|
382 | + * |
|
383 | + * @todo This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to |
|
384 | + * ensure that there is no manipulation of the _data property during run time so there's a clear |
|
385 | + * expectation of what it is. Likely we need to ensure that _data is not persisted IN the message type |
|
386 | + * at all. |
|
387 | + * @internal Plugin authors, do not implement this method, it is subject to change. |
|
388 | + * @since 4.9 |
|
389 | + */ |
|
390 | + public function reset_data() |
|
391 | + { |
|
392 | + $this->_data = null; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * This does some validation of incoming params gets the url trigger from the defined method in the specific child |
|
398 | + * class and then filters the results. |
|
399 | + * |
|
400 | + * @param string $context The message type context |
|
401 | + * @param string $sending_messenger The sending messenger |
|
402 | + * @param EE_Registration $registration Registration object |
|
403 | + * @throws EE_Error |
|
404 | + * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
|
405 | + * @return string generated url |
|
406 | + */ |
|
407 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) |
|
408 | + { |
|
409 | + // validate context |
|
410 | + // valid context? |
|
411 | + if (! isset($this->_contexts[ $context ])) { |
|
412 | + throw new EE_Error( |
|
413 | + sprintf( |
|
414 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
415 | + $context, |
|
416 | + get_class($this) |
|
417 | + ) |
|
418 | + ); |
|
419 | + } |
|
420 | + // valid sending_messenger? |
|
421 | + $not_valid_msgr = false; |
|
422 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
423 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
424 | + $not_valid_msgr = true; |
|
425 | + } |
|
426 | + } |
|
427 | + if ($not_valid_msgr) { |
|
428 | + throw new EE_Error( |
|
429 | + sprintf( |
|
430 | + __( |
|
431 | + 'The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', |
|
432 | + 'event_espresso' |
|
433 | + ), |
|
434 | + $sending_messenger, |
|
435 | + get_class($this) |
|
436 | + ) |
|
437 | + ); |
|
438 | + } |
|
439 | + return EEH_MSG_Template::generate_url_trigger( |
|
440 | + $sending_messenger, |
|
441 | + $this->_active_messenger->name, |
|
442 | + $context, |
|
443 | + $this->name, |
|
444 | + $registration, |
|
445 | + $this->_GRP_ID, |
|
446 | + $this->_get_id_for_msg_url($context, $registration) |
|
447 | + ); |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows |
|
453 | + * for filtering. This is (currently) called by the EED_Messages module. |
|
454 | + * |
|
455 | + * @since 4.5.0 |
|
456 | + * @throws EE_Error |
|
457 | + * @param string $context This should be a string matching a valid context for the message type. |
|
458 | + * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people |
|
459 | + * guessing a url). |
|
460 | + * @param int $id Optional. Integer corresponding to the value for the primary key of a |
|
461 | + * EE_Base_Class_Object |
|
462 | + * @return mixed (EE_Base_Class||EE_Base_Class[]) |
|
463 | + */ |
|
464 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) |
|
465 | + { |
|
466 | + // valid context? |
|
467 | + if (! isset($this->_contexts[ $context ])) { |
|
468 | + throw new EE_Error( |
|
469 | + sprintf( |
|
470 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
471 | + $context, |
|
472 | + get_class($this) |
|
473 | + ) |
|
474 | + ); |
|
475 | + } |
|
476 | + // get data and apply global and class specific filters on it. |
|
477 | + $data = apply_filters( |
|
478 | + 'FHEE__EE_message_type__get_data_for_context__data', |
|
479 | + $this->_get_data_for_context($context, $registration, $id), |
|
480 | + $this |
|
481 | + ); |
|
482 | + $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this); |
|
483 | + // if empty then something went wrong! |
|
484 | + if (empty($data)) { |
|
485 | + throw new EE_Error( |
|
486 | + sprintf( |
|
487 | + __( |
|
488 | + 'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', |
|
489 | + 'event_espresso' |
|
490 | + ), |
|
491 | + $id, |
|
492 | + $this->name |
|
493 | + ) |
|
494 | + ); |
|
495 | + } |
|
496 | + return $data; |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * This returns the contents of the _data property. |
|
502 | + * Please note the value of the _data is highly volatile. It was added as an interim measure ensuring |
|
503 | + * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called. |
|
504 | + * |
|
505 | + * @todo This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to |
|
506 | + * ensure that there is no manipulation of the _data property during run time so there's a clear |
|
507 | + * expectation of what it is. |
|
508 | + * @internal Plugin authors, do not implement this method, it is subject to change. |
|
509 | + * @return mixed |
|
510 | + */ |
|
511 | + public function get_data() |
|
512 | + { |
|
513 | + return $this->_data; |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * used to set the $_with_messengers property. (this is a default, child classes SHOULD override) |
|
519 | + * |
|
520 | + * @see property definition for description of setup. |
|
521 | + * @since 4.5.0 |
|
522 | + * @abstract |
|
523 | + * @return void |
|
524 | + */ |
|
525 | + protected function _set_with_messengers() |
|
526 | + { |
|
527 | + $this->_with_messengers = array( |
|
528 | + 'email' => array('html'), |
|
529 | + ); |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + /** |
|
534 | + * Return the value of the _with_messengers property |
|
535 | + * |
|
536 | + * @since 4.5.0 |
|
537 | + * @return array |
|
538 | + */ |
|
539 | + public function with_messengers() |
|
540 | + { |
|
541 | + return apply_filters( |
|
542 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this), |
|
543 | + $this->_with_messengers |
|
544 | + ); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class |
|
550 | + * callback function if that page is registered via the `_admin_registered_page` property set by the child class. |
|
551 | + * * |
|
552 | + * |
|
553 | + * @param string $page the slug of the EE admin page |
|
554 | + * @param array $messengers an array of active messenger objects |
|
555 | + * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages) |
|
556 | + * @param array $extra This is just an extra argument that can be used to pass additional data for setting up |
|
557 | + * page content. |
|
558 | + * @access public |
|
559 | + * @return string |
|
560 | + */ |
|
561 | + public function get_message_type_admin_page_content( |
|
562 | + $page, |
|
563 | + $action = null, |
|
564 | + $extra = array(), |
|
565 | + $messengers = array() |
|
566 | + ) { |
|
567 | + // we can also further refine the context by action (if present). |
|
568 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
569 | + } |
|
570 | + |
|
571 | + |
|
572 | + /** |
|
573 | + * @return array |
|
574 | + */ |
|
575 | + public function get_contexts() |
|
576 | + { |
|
577 | + return $this->_contexts; |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * This just returns the context label for a given context (as set in $_context_label property) |
|
583 | + * |
|
584 | + * @access public |
|
585 | + * @return array |
|
586 | + */ |
|
587 | + public function get_context_label() |
|
588 | + { |
|
589 | + return $this->_context_label; |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * This just returns the (filtered) _master_templates property. |
|
595 | + * |
|
596 | + * @see property definition for documentation. |
|
597 | + * @return array |
|
598 | + */ |
|
599 | + public function get_master_templates() |
|
600 | + { |
|
601 | + // first class specific filter then filter that by the global filter. |
|
602 | + $master_templates = apply_filters( |
|
603 | + 'FHEE__' . get_class($this) . '__get_master_templates', |
|
604 | + $this->_master_templates |
|
605 | + ); |
|
606 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
607 | + } |
|
608 | + |
|
609 | + |
|
610 | + /** |
|
611 | + * Accepts an incoming data handler which contains data for processing, and returns an array of |
|
612 | + * EE_Messages_Addressee objects. |
|
613 | + * |
|
614 | + * @param EE_Messages_incoming_data $data |
|
615 | + * @param string $context Limit addressees to specific context. |
|
616 | + * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
|
617 | + * that context |
|
618 | + * @throws EE_Error |
|
619 | + */ |
|
620 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') |
|
621 | + { |
|
622 | + // override _data |
|
623 | + $this->_data = $data; |
|
624 | + $addressees = array(); |
|
625 | + $original_contexts = $this->_contexts; |
|
626 | + // if incoming context then limit to that context |
|
627 | + if (! empty($context)) { |
|
628 | + $cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : ''; |
|
629 | + if (! empty($cntxt)) { |
|
630 | + $this->_contexts = array(); |
|
631 | + $this->_contexts[ $context ] = $cntxt; |
|
632 | + } |
|
633 | + } |
|
634 | + $this->_set_default_addressee_data(); |
|
635 | + if ($this->_process_data()) { |
|
636 | + $addressees = $this->_addressees; |
|
637 | + } |
|
638 | + |
|
639 | + // reset contexts and addressees |
|
640 | + $this->_contexts = $original_contexts; |
|
641 | + $this->_addressees = array(); |
|
642 | + return $addressees; |
|
643 | + } |
|
644 | + |
|
645 | + |
|
646 | + /** |
|
647 | + * processes the data object so we get |
|
648 | + * |
|
649 | + * @throws EE_Error |
|
650 | + * @return bool true means data was processed successfully, false means not. |
|
651 | + */ |
|
652 | + protected function _process_data() |
|
653 | + { |
|
654 | + // at a minimum, we NEED EE_Attendee objects. |
|
655 | + if (empty($this->_data->attendees)) { |
|
656 | + return false; // there's no data to process! |
|
657 | + } |
|
658 | + // process addressees for each context. Child classes will have to have methods for |
|
659 | + // each context defined to handle the processing of the data object within them |
|
660 | + foreach ($this->_contexts as $context => $details) { |
|
661 | + $xpctd_method = '_' . $context . '_addressees'; |
|
662 | + if (! method_exists($this, $xpctd_method)) { |
|
663 | + throw new EE_Error( |
|
664 | + sprintf( |
|
665 | + __( |
|
666 | + 'The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', |
|
667 | + 'event_espresso' |
|
668 | + ), |
|
669 | + $this->label['singular'], |
|
670 | + $xpctd_method |
|
671 | + ) |
|
672 | + ); |
|
673 | + } |
|
674 | + $this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method)); |
|
675 | + } |
|
676 | + return true; // data was processed successfully. |
|
677 | + } |
|
678 | + |
|
679 | + |
|
680 | + /** |
|
681 | + * sets the default_addressee_data property, |
|
682 | + * |
|
683 | + * @access private |
|
684 | + * @return void |
|
685 | + */ |
|
686 | + private function _set_default_addressee_data() |
|
687 | + { |
|
688 | + $this->_default_addressee_data = array( |
|
689 | + 'billing' => $this->_data->billing, |
|
690 | + 'taxes' => $this->_data->taxes, |
|
691 | + 'tax_line_items' => $this->_data->tax_line_items, |
|
692 | + 'additional_line_items' => $this->_data->additional_line_items, |
|
693 | + 'grand_total_line_item' => $this->_data->grand_total_line_item, |
|
694 | + 'txn' => $this->_data->txn, |
|
695 | + 'payments' => $this->_data->payments, |
|
696 | + 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
697 | + ? $this->_data->payment |
|
698 | + : null, |
|
699 | + 'reg_objs' => $this->_data->reg_objs, |
|
700 | + 'registrations' => $this->_data->registrations, |
|
701 | + 'datetimes' => $this->_data->datetimes, |
|
702 | + 'tickets' => $this->_data->tickets, |
|
703 | + 'line_items_with_children' => $this->_data->line_items_with_children, |
|
704 | + 'questions' => $this->_data->questions, |
|
705 | + 'answers' => $this->_data->answers, |
|
706 | + 'txn_status' => $this->_data->txn_status, |
|
707 | + 'total_ticket_count' => $this->_data->total_ticket_count, |
|
708 | + ); |
|
709 | + if (is_array($this->_data->primary_attendee_data)) { |
|
710 | + $this->_default_addressee_data = array_merge( |
|
711 | + $this->_default_addressee_data, |
|
712 | + $this->_data->primary_attendee_data |
|
713 | + ); |
|
714 | + $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj']; |
|
715 | + $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj']; |
|
716 | + } |
|
717 | + } |
|
718 | + |
|
719 | + |
|
720 | + |
|
721 | + /******************** |
|
722 | 722 | * setup default shared addressee object/contexts |
723 | 723 | * These can be utilized simply by defining the context in the child message type. |
724 | 724 | * They can also be overridden if a specific message type needs to do something different for that context. |
725 | 725 | ****************/ |
726 | - /** |
|
727 | - * see abstract declaration in parent class for details, children message types can |
|
728 | - * override these valid shortcodes if desired (we include all for all contexts by default). |
|
729 | - */ |
|
730 | - protected function _set_valid_shortcodes() |
|
731 | - { |
|
732 | - $all_shortcodes = array( |
|
733 | - 'attendee_list', |
|
734 | - 'attendee', |
|
735 | - 'datetime_list', |
|
736 | - 'datetime', |
|
737 | - 'event_list', |
|
738 | - 'event_meta', |
|
739 | - 'event', |
|
740 | - 'organization', |
|
741 | - 'recipient_details', |
|
742 | - 'recipient_list', |
|
743 | - 'ticket_list', |
|
744 | - 'ticket', |
|
745 | - 'transaction', |
|
746 | - 'venue', |
|
747 | - 'primary_registration_details', |
|
748 | - 'primary_registration_list', |
|
749 | - 'event_author', |
|
750 | - 'email', |
|
751 | - 'messenger', |
|
752 | - ); |
|
753 | - $contexts = $this->get_contexts(); |
|
754 | - foreach ($contexts as $context => $details) { |
|
755 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
756 | - // make sure non admin context does not include the event_author shortcodes |
|
757 | - if ($context != 'admin') { |
|
758 | - if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) { |
|
759 | - unset($this->_valid_shortcodes[ $context ][ $key ]); |
|
760 | - } |
|
761 | - } |
|
762 | - } |
|
763 | - // make sure admin context does not include the recipient_details shortcodes |
|
764 | - // IF we have admin context hooked in message types might not have that context. |
|
765 | - if (! empty($this->_valid_shortcodes['admin'])) { |
|
766 | - if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
767 | - unset($this->_valid_shortcodes['admin'][ $key ]); |
|
768 | - } |
|
769 | - // make sure admin context does not include the recipient_details shortcodes |
|
770 | - if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
771 | - unset($this->_valid_shortcodes['admin'][ $key ]); |
|
772 | - } |
|
773 | - } |
|
774 | - } |
|
775 | - |
|
776 | - |
|
777 | - /** |
|
778 | - * Used by Validators to modify the valid shortcodes. |
|
779 | - * |
|
780 | - * @param array $new_config array of valid shortcodes (by context) |
|
781 | - * @return void sets valid_shortcodes property |
|
782 | - */ |
|
783 | - public function reset_valid_shortcodes_config($new_config) |
|
784 | - { |
|
785 | - foreach ($new_config as $context => $shortcodes) { |
|
786 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
787 | - } |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - /** |
|
792 | - * returns an array of addressee objects for event_admins |
|
793 | - * |
|
794 | - * @access protected |
|
795 | - * @return array array of EE_Messages_Addressee objects |
|
796 | - * @throws EE_Error |
|
797 | - * @throws InvalidArgumentException |
|
798 | - * @throws InvalidDataTypeException |
|
799 | - * @throws InvalidInterfaceException |
|
800 | - */ |
|
801 | - protected function _admin_addressees() |
|
802 | - { |
|
803 | - $admin_events = array(); |
|
804 | - $addressees = array(); |
|
805 | - // first we need to get the event admin user id for all the events |
|
806 | - // and setup an addressee object for each unique admin user. |
|
807 | - foreach ($this->_data->events as $line_ref => $event) { |
|
808 | - $admin_id = $this->_get_event_admin_id($event['ID']); |
|
809 | - // make sure we are just including the events that belong to this admin! |
|
810 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
811 | - } |
|
812 | - // k now we can loop through the event_admins and setup the addressee data. |
|
813 | - foreach ($admin_events as $admin_id => $event_details) { |
|
814 | - $aee = array( |
|
815 | - 'user_id' => $admin_id, |
|
816 | - 'events' => $event_details, |
|
817 | - 'attendees' => $this->_data->attendees, |
|
818 | - 'recipient_id' => $admin_id, |
|
819 | - 'recipient_type' => 'WP_User', |
|
820 | - ); |
|
821 | - $aee = array_merge($this->_default_addressee_data, $aee); |
|
822 | - $addressees[] = new EE_Messages_Addressee($aee); |
|
823 | - } |
|
824 | - return $addressees; |
|
825 | - } |
|
826 | - |
|
827 | - |
|
828 | - /** |
|
829 | - * Takes care of setting up the addressee object(s) for the primary attendee. |
|
830 | - * |
|
831 | - * @access protected |
|
832 | - * @return array of EE_Addressee objects |
|
833 | - * @throws EE_Error |
|
834 | - */ |
|
835 | - protected function _primary_attendee_addressees() |
|
836 | - { |
|
837 | - $aee = $this->_default_addressee_data; |
|
838 | - $aee['events'] = $this->_data->events; |
|
839 | - $aee['attendees'] = $this->_data->attendees; |
|
840 | - $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
|
841 | - $aee['recipient_type'] = 'Attendee'; |
|
842 | - // great now we can instantiate the $addressee object and return (as an array); |
|
843 | - $add[] = new EE_Messages_Addressee($aee); |
|
844 | - return $add; |
|
845 | - } |
|
846 | - |
|
847 | - |
|
848 | - /** |
|
849 | - * Takes care of setting up the addressee object(s) for the registered attendees |
|
850 | - * |
|
851 | - * @access protected |
|
852 | - * @return array of EE_Addressee objects |
|
853 | - */ |
|
854 | - protected function _attendee_addressees() |
|
855 | - { |
|
856 | - $add = array(); |
|
857 | - // we just have to loop through the attendees. We'll also set the attached events for each attendee. |
|
858 | - // use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
|
859 | - $already_processed = array(); |
|
860 | - foreach ($this->_data->attendees as $att_id => $details) { |
|
861 | - // set the attendee array to blank on each loop; |
|
862 | - $aee = array(); |
|
863 | - if ( |
|
864 | - isset($this->_data->reg_obj) |
|
865 | - && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
866 | - && $this->_single_message |
|
867 | - ) { |
|
868 | - continue; |
|
869 | - } |
|
870 | - // is $this->_regs_for_sending present? |
|
871 | - // If so, let's make sure we ONLY generate addressee for registrations in that array. |
|
872 | - if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
873 | - $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
874 | - if (empty($regs_allowed)) { |
|
875 | - continue; |
|
876 | - } |
|
877 | - } |
|
878 | - if ( |
|
879 | - apply_filters( |
|
880 | - 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
|
881 | - true, |
|
882 | - $this->_data, |
|
883 | - $this |
|
884 | - ) |
|
885 | - && in_array($att_id, $already_processed, true) |
|
886 | - ) { |
|
887 | - continue; |
|
888 | - } |
|
889 | - $already_processed[] = $att_id; |
|
890 | - foreach ($details as $item => $value) { |
|
891 | - $aee[ $item ] = $value; |
|
892 | - if ($item === 'line_ref') { |
|
893 | - foreach ($value as $event_id) { |
|
894 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
895 | - } |
|
896 | - } |
|
897 | - if ($item === 'attendee_email') { |
|
898 | - $aee['attendee_email'] = $value; |
|
899 | - } |
|
900 | - /*if ( $item == 'registration_id' ) { |
|
726 | + /** |
|
727 | + * see abstract declaration in parent class for details, children message types can |
|
728 | + * override these valid shortcodes if desired (we include all for all contexts by default). |
|
729 | + */ |
|
730 | + protected function _set_valid_shortcodes() |
|
731 | + { |
|
732 | + $all_shortcodes = array( |
|
733 | + 'attendee_list', |
|
734 | + 'attendee', |
|
735 | + 'datetime_list', |
|
736 | + 'datetime', |
|
737 | + 'event_list', |
|
738 | + 'event_meta', |
|
739 | + 'event', |
|
740 | + 'organization', |
|
741 | + 'recipient_details', |
|
742 | + 'recipient_list', |
|
743 | + 'ticket_list', |
|
744 | + 'ticket', |
|
745 | + 'transaction', |
|
746 | + 'venue', |
|
747 | + 'primary_registration_details', |
|
748 | + 'primary_registration_list', |
|
749 | + 'event_author', |
|
750 | + 'email', |
|
751 | + 'messenger', |
|
752 | + ); |
|
753 | + $contexts = $this->get_contexts(); |
|
754 | + foreach ($contexts as $context => $details) { |
|
755 | + $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
756 | + // make sure non admin context does not include the event_author shortcodes |
|
757 | + if ($context != 'admin') { |
|
758 | + if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) { |
|
759 | + unset($this->_valid_shortcodes[ $context ][ $key ]); |
|
760 | + } |
|
761 | + } |
|
762 | + } |
|
763 | + // make sure admin context does not include the recipient_details shortcodes |
|
764 | + // IF we have admin context hooked in message types might not have that context. |
|
765 | + if (! empty($this->_valid_shortcodes['admin'])) { |
|
766 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
767 | + unset($this->_valid_shortcodes['admin'][ $key ]); |
|
768 | + } |
|
769 | + // make sure admin context does not include the recipient_details shortcodes |
|
770 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
771 | + unset($this->_valid_shortcodes['admin'][ $key ]); |
|
772 | + } |
|
773 | + } |
|
774 | + } |
|
775 | + |
|
776 | + |
|
777 | + /** |
|
778 | + * Used by Validators to modify the valid shortcodes. |
|
779 | + * |
|
780 | + * @param array $new_config array of valid shortcodes (by context) |
|
781 | + * @return void sets valid_shortcodes property |
|
782 | + */ |
|
783 | + public function reset_valid_shortcodes_config($new_config) |
|
784 | + { |
|
785 | + foreach ($new_config as $context => $shortcodes) { |
|
786 | + $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
787 | + } |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + /** |
|
792 | + * returns an array of addressee objects for event_admins |
|
793 | + * |
|
794 | + * @access protected |
|
795 | + * @return array array of EE_Messages_Addressee objects |
|
796 | + * @throws EE_Error |
|
797 | + * @throws InvalidArgumentException |
|
798 | + * @throws InvalidDataTypeException |
|
799 | + * @throws InvalidInterfaceException |
|
800 | + */ |
|
801 | + protected function _admin_addressees() |
|
802 | + { |
|
803 | + $admin_events = array(); |
|
804 | + $addressees = array(); |
|
805 | + // first we need to get the event admin user id for all the events |
|
806 | + // and setup an addressee object for each unique admin user. |
|
807 | + foreach ($this->_data->events as $line_ref => $event) { |
|
808 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
809 | + // make sure we are just including the events that belong to this admin! |
|
810 | + $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
811 | + } |
|
812 | + // k now we can loop through the event_admins and setup the addressee data. |
|
813 | + foreach ($admin_events as $admin_id => $event_details) { |
|
814 | + $aee = array( |
|
815 | + 'user_id' => $admin_id, |
|
816 | + 'events' => $event_details, |
|
817 | + 'attendees' => $this->_data->attendees, |
|
818 | + 'recipient_id' => $admin_id, |
|
819 | + 'recipient_type' => 'WP_User', |
|
820 | + ); |
|
821 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
822 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
823 | + } |
|
824 | + return $addressees; |
|
825 | + } |
|
826 | + |
|
827 | + |
|
828 | + /** |
|
829 | + * Takes care of setting up the addressee object(s) for the primary attendee. |
|
830 | + * |
|
831 | + * @access protected |
|
832 | + * @return array of EE_Addressee objects |
|
833 | + * @throws EE_Error |
|
834 | + */ |
|
835 | + protected function _primary_attendee_addressees() |
|
836 | + { |
|
837 | + $aee = $this->_default_addressee_data; |
|
838 | + $aee['events'] = $this->_data->events; |
|
839 | + $aee['attendees'] = $this->_data->attendees; |
|
840 | + $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
|
841 | + $aee['recipient_type'] = 'Attendee'; |
|
842 | + // great now we can instantiate the $addressee object and return (as an array); |
|
843 | + $add[] = new EE_Messages_Addressee($aee); |
|
844 | + return $add; |
|
845 | + } |
|
846 | + |
|
847 | + |
|
848 | + /** |
|
849 | + * Takes care of setting up the addressee object(s) for the registered attendees |
|
850 | + * |
|
851 | + * @access protected |
|
852 | + * @return array of EE_Addressee objects |
|
853 | + */ |
|
854 | + protected function _attendee_addressees() |
|
855 | + { |
|
856 | + $add = array(); |
|
857 | + // we just have to loop through the attendees. We'll also set the attached events for each attendee. |
|
858 | + // use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
|
859 | + $already_processed = array(); |
|
860 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
861 | + // set the attendee array to blank on each loop; |
|
862 | + $aee = array(); |
|
863 | + if ( |
|
864 | + isset($this->_data->reg_obj) |
|
865 | + && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
866 | + && $this->_single_message |
|
867 | + ) { |
|
868 | + continue; |
|
869 | + } |
|
870 | + // is $this->_regs_for_sending present? |
|
871 | + // If so, let's make sure we ONLY generate addressee for registrations in that array. |
|
872 | + if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
873 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
874 | + if (empty($regs_allowed)) { |
|
875 | + continue; |
|
876 | + } |
|
877 | + } |
|
878 | + if ( |
|
879 | + apply_filters( |
|
880 | + 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
|
881 | + true, |
|
882 | + $this->_data, |
|
883 | + $this |
|
884 | + ) |
|
885 | + && in_array($att_id, $already_processed, true) |
|
886 | + ) { |
|
887 | + continue; |
|
888 | + } |
|
889 | + $already_processed[] = $att_id; |
|
890 | + foreach ($details as $item => $value) { |
|
891 | + $aee[ $item ] = $value; |
|
892 | + if ($item === 'line_ref') { |
|
893 | + foreach ($value as $event_id) { |
|
894 | + $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
895 | + } |
|
896 | + } |
|
897 | + if ($item === 'attendee_email') { |
|
898 | + $aee['attendee_email'] = $value; |
|
899 | + } |
|
900 | + /*if ( $item == 'registration_id' ) { |
|
901 | 901 | $aee['attendee_registration_id'] = $value; |
902 | 902 | }/**/ |
903 | - } |
|
904 | - // note the FIRST reg object in this array is the one |
|
905 | - // we'll use for this attendee as the primary registration for this attendee. |
|
906 | - $aee['reg_obj'] = reset($this->_data->attendees[ $att_id ]['reg_objs']); |
|
907 | - $aee['attendees'] = $this->_data->attendees; |
|
908 | - $aee['recipient_id'] = $att_id; |
|
909 | - $aee['recipient_type'] = 'Attendee'; |
|
910 | - // merge in the primary attendee data |
|
911 | - $aee = array_merge($this->_default_addressee_data, $aee); |
|
912 | - $add[] = new EE_Messages_Addressee($aee); |
|
913 | - } |
|
914 | - return $add; |
|
915 | - } |
|
916 | - |
|
917 | - |
|
918 | - /** |
|
919 | - * @param $event_id |
|
920 | - * @return int |
|
921 | - * @throws EE_Error |
|
922 | - * @throws InvalidArgumentException |
|
923 | - * @throws InvalidDataTypeException |
|
924 | - * @throws InvalidInterfaceException |
|
925 | - */ |
|
926 | - protected function _get_event_admin_id($event_id) |
|
927 | - { |
|
928 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
929 | - return $event instanceof EE_Event ? $event->wp_user() : 0; |
|
930 | - } |
|
903 | + } |
|
904 | + // note the FIRST reg object in this array is the one |
|
905 | + // we'll use for this attendee as the primary registration for this attendee. |
|
906 | + $aee['reg_obj'] = reset($this->_data->attendees[ $att_id ]['reg_objs']); |
|
907 | + $aee['attendees'] = $this->_data->attendees; |
|
908 | + $aee['recipient_id'] = $att_id; |
|
909 | + $aee['recipient_type'] = 'Attendee'; |
|
910 | + // merge in the primary attendee data |
|
911 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
912 | + $add[] = new EE_Messages_Addressee($aee); |
|
913 | + } |
|
914 | + return $add; |
|
915 | + } |
|
916 | + |
|
917 | + |
|
918 | + /** |
|
919 | + * @param $event_id |
|
920 | + * @return int |
|
921 | + * @throws EE_Error |
|
922 | + * @throws InvalidArgumentException |
|
923 | + * @throws InvalidDataTypeException |
|
924 | + * @throws InvalidInterfaceException |
|
925 | + */ |
|
926 | + protected function _get_event_admin_id($event_id) |
|
927 | + { |
|
928 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
929 | + return $event instanceof EE_Event ? $event->wp_user() : 0; |
|
930 | + } |
|
931 | 931 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | */ |
63 | 63 | protected function _get_subject($custom_subject = '') |
64 | 64 | { |
65 | - if (! empty($custom_subject)) { |
|
65 | + if ( ! empty($custom_subject)) { |
|
66 | 66 | return $custom_subject; |
67 | 67 | } |
68 | 68 | $this->queue->get_message_repository()->rewind(); |
@@ -13,90 +13,90 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * Will hold an EE_Messages_Queue object |
|
18 | - * @type EE_Messages_Queue |
|
19 | - */ |
|
20 | - public $queue = array(); |
|
16 | + /** |
|
17 | + * Will hold an EE_Messages_Queue object |
|
18 | + * @type EE_Messages_Queue |
|
19 | + */ |
|
20 | + public $queue = array(); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param string $messenger_name The messenger being used to send the message |
|
24 | - * @param string $message_type_name The message type being used to grab variations etc. |
|
25 | - * @param EE_Messages_Queue $queue |
|
26 | - * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
27 | - */ |
|
28 | - public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
29 | - { |
|
30 | - $this->queue = $queue; |
|
31 | - parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
32 | - if ($this->valid()) { |
|
33 | - $this->_message->set_content($this->_get_content()); |
|
34 | - $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
35 | - $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
36 | - } |
|
37 | - } |
|
22 | + /** |
|
23 | + * @param string $messenger_name The messenger being used to send the message |
|
24 | + * @param string $message_type_name The message type being used to grab variations etc. |
|
25 | + * @param EE_Messages_Queue $queue |
|
26 | + * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
27 | + */ |
|
28 | + public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
29 | + { |
|
30 | + $this->queue = $queue; |
|
31 | + parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
32 | + if ($this->valid()) { |
|
33 | + $this->_message->set_content($this->_get_content()); |
|
34 | + $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
35 | + $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
43 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
44 | - * @return string; |
|
45 | - */ |
|
46 | - protected function _get_content() |
|
47 | - { |
|
48 | - $content = ''; |
|
49 | - $this->queue->get_message_repository()->rewind(); |
|
50 | - while ($this->queue->get_message_repository()->valid()) { |
|
51 | - $content .= $this->queue->get_message_repository()->current()->content(); |
|
52 | - $this->queue->get_message_repository()->next(); |
|
53 | - } |
|
54 | - return $content; |
|
55 | - } |
|
41 | + /** |
|
42 | + * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
43 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
44 | + * @return string; |
|
45 | + */ |
|
46 | + protected function _get_content() |
|
47 | + { |
|
48 | + $content = ''; |
|
49 | + $this->queue->get_message_repository()->rewind(); |
|
50 | + while ($this->queue->get_message_repository()->valid()) { |
|
51 | + $content .= $this->queue->get_message_repository()->current()->content(); |
|
52 | + $this->queue->get_message_repository()->next(); |
|
53 | + } |
|
54 | + return $content; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
60 | - * @param string $custom_subject |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - protected function _get_subject($custom_subject = '') |
|
65 | - { |
|
66 | - if (! empty($custom_subject)) { |
|
67 | - return $custom_subject; |
|
68 | - } |
|
69 | - $this->queue->get_message_repository()->rewind(); |
|
70 | - $count_of_items = $this->queue->get_message_repository()->count(); |
|
58 | + /** |
|
59 | + * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
60 | + * @param string $custom_subject |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + protected function _get_subject($custom_subject = '') |
|
65 | + { |
|
66 | + if (! empty($custom_subject)) { |
|
67 | + return $custom_subject; |
|
68 | + } |
|
69 | + $this->queue->get_message_repository()->rewind(); |
|
70 | + $count_of_items = $this->queue->get_message_repository()->count(); |
|
71 | 71 | |
72 | - // if $count of items in queue == 1, then let's just return the subject for that item. |
|
73 | - if ($count_of_items === 1) { |
|
74 | - return $this->queue->get_message_repository()->current()->subject(); |
|
75 | - } |
|
76 | - // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
77 | - return sprintf( |
|
78 | - _n( |
|
79 | - 'Showing Aggregate output for 1 result', |
|
80 | - 'Showing Aggregate output for %d items', |
|
81 | - $count_of_items, |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - $count_of_items |
|
85 | - ); |
|
86 | - // phpcs:enable |
|
87 | - } |
|
72 | + // if $count of items in queue == 1, then let's just return the subject for that item. |
|
73 | + if ($count_of_items === 1) { |
|
74 | + return $this->queue->get_message_repository()->current()->subject(); |
|
75 | + } |
|
76 | + // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
77 | + return sprintf( |
|
78 | + _n( |
|
79 | + 'Showing Aggregate output for 1 result', |
|
80 | + 'Showing Aggregate output for %d items', |
|
81 | + $count_of_items, |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + $count_of_items |
|
85 | + ); |
|
86 | + // phpcs:enable |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
92 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
93 | - * @return int; |
|
94 | - */ |
|
95 | - protected function getGroupIdFromMessageRepo() |
|
96 | - { |
|
97 | - $this->queue->get_message_repository()->rewind(); |
|
98 | - if ($this->queue->get_message_repository()->valid()) { |
|
99 | - return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
100 | - } |
|
101 | - } |
|
90 | + /** |
|
91 | + * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
92 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
93 | + * @return int; |
|
94 | + */ |
|
95 | + protected function getGroupIdFromMessageRepo() |
|
96 | + { |
|
97 | + $this->queue->get_message_repository()->rewind(); |
|
98 | + if ($this->queue->get_message_repository()->valid()) { |
|
99 | + return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | } |
@@ -24,9 +24,12 @@ |
||
24 | 24 | <title><?php echo $title; ?></title> |
25 | 25 | <?php if ($enqueue_wp_assets) : ?> |
26 | 26 | <?php wp_head(); ?> |
27 | - <?php else : ?> |
|
27 | + <?php else { |
|
28 | + : ?> |
|
28 | 29 | <?php foreach ($css as $url) :?> |
29 | - <link rel="stylesheet" type="text/css" href="<?php echo $url; ?>"> |
|
30 | + <link rel="stylesheet" type="text/css" href="<?php echo $url; |
|
31 | +} |
|
32 | +?>"> |
|
30 | 33 | <?php endforeach; ?> |
31 | 34 | <script type="text/javascript"> |
32 | 35 | <?php echo $eei18n; ?> |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | <?php echo $eei18n; ?> |
33 | 33 | </script> |
34 | 34 | <?php foreach ($header_js as $key => $url) :?> |
35 | - <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?> |
|
35 | + <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?> |
|
36 | 36 | <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $header_attributes; ?>></script> |
37 | 37 | <?php endforeach; ?> |
38 | 38 | <?php endif; ?> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | <?php echo $content; ?> |
44 | 44 | </div> |
45 | 45 | <?php foreach ($footer_js as $key => $url) : ?> |
46 | - <?php $footer_attributes = isset($footer_js_attributes[ $key ]) ? $footer_js_attributes[ $key ] : ''; ?> |
|
46 | + <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?> |
|
47 | 47 | <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $footer_attributes; ?>></script> |
48 | 48 | <?php endforeach; ?> |
49 | 49 | <?php if ($enqueue_wp_assets) : ?> |