@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param $messenger |
85 | 85 | * @param string $orderby |
86 | 86 | * @param string $order |
87 | - * @return array all (including trashed or inactive) message template group objects for the given messenger |
|
87 | + * @return EE_Base_Class[] all (including trashed or inactive) message template group objects for the given messenger |
|
88 | 88 | */ |
89 | 89 | public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') |
90 | 90 | { |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | /** |
342 | 342 | * This sends things to the validator for the given messenger and message type. |
343 | 343 | * |
344 | - * @param array $fields the incoming fields to check. |
|
344 | + * @param string $fields the incoming fields to check. |
|
345 | 345 | * Note this array is in the formatted fields from the form fields setup. |
346 | 346 | * So we need to reformat this into an array of expected field refs by the validator. |
347 | 347 | * Note also that this is not only the fields for the Message Template Group |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'WP_User' => new EE_Belongs_To_Relation() |
45 | 45 | ); |
46 | 46 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
47 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
47 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
48 | 48 | } |
49 | 49 | $this->_caps_slug = 'messages'; |
50 | 50 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $limit = null, |
72 | 72 | $count = false |
73 | 73 | ) { |
74 | - $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
74 | + $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
75 | 75 | return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
76 | 76 | } |
77 | 77 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') |
90 | 90 | { |
91 | 91 | return $this->get_all_deleted_and_undeleted( |
92 | - array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) ) |
|
92 | + array(array('MTP_messenger' => $messenger), 'order_by' => array($orderby => $order)) |
|
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | && $_REQUEST['ee_messenger_filter_by'] != 'none_selected' |
108 | 108 | && $_REQUEST['ee_messenger_filter_by'] != 'all' |
109 | 109 | ) { |
110 | - $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by'] ; |
|
110 | + $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | if (isset($_REQUEST['ee_message_type_filter_by']) |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $global = true, |
142 | 142 | $user_check = false |
143 | 143 | ) { |
144 | - $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
144 | + $_where = $global ? array('MTP_is_global' => true) : array('MTP_is_global' => false); |
|
145 | 145 | $_where['MTP_is_active'] = true; |
146 | 146 | $_where = $this->_maybe_mtp_filters($_where); |
147 | 147 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $_where['MTP_user_id'] = get_current_user_id(); |
156 | 156 | } |
157 | 157 | |
158 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
158 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
159 | 159 | |
160 | 160 | return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $_where = $this->_maybe_mtp_filters(); |
178 | 178 | |
179 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
179 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
180 | 180 | |
181 | 181 | $r_templates = $count |
182 | 182 | ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true) |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function get_all_custom_templates_by_event($EVT_ID, $query_params = array()) |
198 | 198 | { |
199 | - $where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID )); |
|
199 | + $where = array_merge($query_params, array('Event.EVT_ID' => $EVT_ID)); |
|
200 | 200 | return $this->get_all( |
201 | - array( $where ) |
|
201 | + array($where) |
|
202 | 202 | ); |
203 | 203 | } |
204 | 204 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | $count = false, |
224 | 224 | $global = true |
225 | 225 | ) { |
226 | - $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
226 | + $_where = $global ? array('MTP_is_global' => true) : array('MTP_is_global' => false); |
|
227 | 227 | $_where['MTP_is_active'] = true; |
228 | 228 | $_where = $this->_maybe_mtp_filters($_where); |
229 | 229 | |
230 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
230 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
231 | 231 | |
232 | 232 | return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
233 | 233 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | 'MTP_is_active' => $active |
266 | 266 | ); |
267 | 267 | |
268 | - $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit ); |
|
268 | + $query_params = array($_where, 'order_by' => array($orderby=>$order), 'limit' => $limit); |
|
269 | 269 | |
270 | 270 | return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
271 | 271 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $_where['MTP_is_active'] = $active; |
306 | 306 | } |
307 | 307 | |
308 | - $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
308 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
309 | 309 | |
310 | 310 | return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
311 | 311 | } |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | // first let's figure out if the value['content'] in the current index is an array. |
364 | 364 | // If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list'). |
365 | 365 | if (is_array($value['content'])) { |
366 | - $assembled_fields[ $value['name'] ] = $value['content']['main']; |
|
366 | + $assembled_fields[$value['name']] = $value['content']['main']; |
|
367 | 367 | // loop through the content and get the other fields. |
368 | 368 | foreach ($value['content'] as $name => $val) { |
369 | 369 | if ($name == 'main') { |
370 | 370 | continue; |
371 | 371 | } |
372 | - $assembled_fields[ $name ] = $val; |
|
372 | + $assembled_fields[$name] = $val; |
|
373 | 373 | } |
374 | 374 | continue; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // okay if we're here then this is just a straight field=>$value arrangement |
378 | - $assembled_fields[ $value['name'] ] = $value['content']; |
|
378 | + $assembled_fields[$value['name']] = $value['content']; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | // now we've got the assembled_fields. |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | $mt_ref = ucwords(str_replace('_', ' ', $message_type)); |
386 | 386 | $mt_ref = str_replace(' ', '_', $mt_ref); |
387 | 387 | |
388 | - $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator'; |
|
388 | + $classname = 'EE_Messages_'.$m_ref.'_'.$mt_ref.'_Validator'; |
|
389 | 389 | |
390 | - if (!class_exists($classname)) { |
|
390 | + if ( ! class_exists($classname)) { |
|
391 | 391 | $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
392 | 392 | $msg[] = sprintf( |
393 | 393 | __( |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | if (empty($messenger_names) && empty($message_type_names)) { |
426 | 426 | return 0; |
427 | 427 | } |
428 | - if (! empty($messenger_names)) { |
|
429 | - $query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names ); |
|
428 | + if ( ! empty($messenger_names)) { |
|
429 | + $query_args[0]['MTP_messenger'] = array('IN', (array) $messenger_names); |
|
430 | 430 | } |
431 | - if (! empty($message_type_names)) { |
|
432 | - $query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names ); |
|
431 | + if ( ! empty($message_type_names)) { |
|
432 | + $query_args[0]['MTP_message_type'] = array('IN', (array) $message_type_names); |
|
433 | 433 | } |
434 | - return $this->update(array( 'MTP_is_active' => false ), $query_args); |
|
434 | + return $this->update(array('MTP_is_active' => false), $query_args); |
|
435 | 435 | } |
436 | 436 | } |
@@ -11,426 +11,426 @@ |
||
11 | 11 | class EEM_Message_Template_Group extends EEM_Soft_Delete_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the EEM_Message_Template_Group object |
|
15 | - protected static $_instance = null; |
|
16 | - |
|
17 | - |
|
18 | - |
|
19 | - protected function __construct($timezone = null) |
|
20 | - { |
|
21 | - $this->singular_item = __('Message Template Group', 'event_espresso'); |
|
22 | - $this->plural_item = __('Message Template Groups', 'event_espresso'); |
|
23 | - $this->_tables = array( |
|
24 | - 'Message_Template_Group' => new EE_Primary_Table('esp_message_template_group', 'GRP_ID') |
|
25 | - ); |
|
26 | - $this->_fields = array( |
|
27 | - 'Message_Template_Group' => array( |
|
28 | - 'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')), |
|
29 | - 'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), false, ''), |
|
30 | - 'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), false, ''), |
|
31 | - 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), false, get_current_user_id()), |
|
32 | - 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), false, 'email'), |
|
33 | - 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'), |
|
34 | - 'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true), |
|
35 | - 'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false), |
|
36 | - 'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false), |
|
37 | - 'MTP_is_active'=>new EE_Boolean_Field('MTP_is_active', __('Flag indicating whether template group is active', 'event_espresso'), false, true) |
|
38 | - ) |
|
39 | - ); |
|
40 | - $this->_model_relations = array( |
|
41 | - 'Message_Template' => new EE_Has_Many_Relation(), |
|
42 | - 'Message' => new EE_Has_Many_Relation(), |
|
43 | - 'Event' => new EE_HABTM_Relation('Event_Message_Template'), |
|
44 | - 'WP_User' => new EE_Belongs_To_Relation() |
|
45 | - ); |
|
46 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
47 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
48 | - } |
|
49 | - $this->_caps_slug = 'messages'; |
|
50 | - |
|
51 | - parent::__construct($timezone); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * get_all_trashed_message_templates_by_event |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param int $EVT_ID specific event id |
|
61 | - * @param string $orderby |
|
62 | - * @param string $order |
|
63 | - * @param null $limit |
|
64 | - * @param bool $count |
|
65 | - * @return array message template objects that are attached to a specific event. |
|
66 | - */ |
|
67 | - public function get_all_trashed_message_templates_by_event( |
|
68 | - $EVT_ID, |
|
69 | - $orderby = 'GRP_ID', |
|
70 | - $order = 'ASC', |
|
71 | - $limit = null, |
|
72 | - $count = false |
|
73 | - ) { |
|
74 | - $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
75 | - return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * get_all_message_templates_by_messenger |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @param $messenger |
|
85 | - * @param string $orderby |
|
86 | - * @param string $order |
|
87 | - * @return array all (including trashed or inactive) message template group objects for the given messenger |
|
88 | - */ |
|
89 | - public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') |
|
90 | - { |
|
91 | - return $this->get_all_deleted_and_undeleted( |
|
92 | - array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) ) |
|
93 | - ); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * This simply adds on any messenger/message type filters that may be present in the $_POST global |
|
100 | - * @param array $_where any existing where conditions to append these to. |
|
101 | - * @return array original where conditions or original with additional filters. |
|
102 | - */ |
|
103 | - protected function _maybe_mtp_filters($_where = array()) |
|
104 | - { |
|
105 | - // account for messenger or message type filters |
|
106 | - if (isset($_REQUEST['ee_messenger_filter_by']) |
|
107 | - && $_REQUEST['ee_messenger_filter_by'] != 'none_selected' |
|
108 | - && $_REQUEST['ee_messenger_filter_by'] != 'all' |
|
109 | - ) { |
|
110 | - $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by'] ; |
|
111 | - } |
|
112 | - |
|
113 | - if (isset($_REQUEST['ee_message_type_filter_by']) |
|
114 | - && $_REQUEST['ee_message_type_filter_by'] != 'none_selected' |
|
115 | - ) { |
|
116 | - $_where['MTP_message_type'] = $_REQUEST['ee_message_type_filter_by']; |
|
117 | - } |
|
118 | - |
|
119 | - return $_where; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * get_all_active_message_templates groups |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @param string $orderby |
|
129 | - * @param string $order |
|
130 | - * @param null $limit |
|
131 | - * @param bool $count |
|
132 | - * @param bool $global |
|
133 | - * @param bool $user_check |
|
134 | - * @return array all active (non_trashed, active) message template objects |
|
135 | - */ |
|
136 | - public function get_all_active_message_templates( |
|
137 | - $orderby = 'GRP_ID', |
|
138 | - $order = 'ASC', |
|
139 | - $limit = null, |
|
140 | - $count = false, |
|
141 | - $global = true, |
|
142 | - $user_check = false |
|
143 | - ) { |
|
144 | - $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
145 | - $_where['MTP_is_active'] = true; |
|
146 | - $_where = $this->_maybe_mtp_filters($_where); |
|
147 | - |
|
148 | - if ($user_check |
|
149 | - && ! $global |
|
150 | - && ! EE_Registry::instance()->CAP->current_user_can( |
|
151 | - 'ee_read_others_messages', |
|
152 | - 'get_all_active_message_templates' |
|
153 | - ) |
|
154 | - ) { |
|
155 | - $_where['MTP_user_id'] = get_current_user_id(); |
|
156 | - } |
|
157 | - |
|
158 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
159 | - |
|
160 | - return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * retrieve ALL message_template groups from db regardless of wht |
|
167 | - * |
|
168 | - * @access public |
|
169 | - * @param string $orderby |
|
170 | - * @param string $order |
|
171 | - * @param null $limit |
|
172 | - * @param bool $count |
|
173 | - * @return mixed array on success, FALSE on fail |
|
174 | - */ |
|
175 | - public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false) |
|
176 | - { |
|
177 | - $_where = $this->_maybe_mtp_filters(); |
|
178 | - |
|
179 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
180 | - |
|
181 | - $r_templates = $count |
|
182 | - ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true) |
|
183 | - : $this->get_all_deleted_and_undeleted($query_params); |
|
184 | - |
|
185 | - return $r_templates; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * This gets all the custom templates attached to a specific event |
|
193 | - * @param int $EVT_ID event id |
|
194 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
195 | - * @return EE_Message_Template_Group[] |
|
196 | - */ |
|
197 | - public function get_all_custom_templates_by_event($EVT_ID, $query_params = array()) |
|
198 | - { |
|
199 | - $where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID )); |
|
200 | - return $this->get_all( |
|
201 | - array( $where ) |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * get_all_trashed_grouped_message_templates |
|
209 | - * this returns ONLY the template groups where ALL contexts are trashed and none of the group are non-trashed |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @param string $orderby |
|
213 | - * @param string $order |
|
214 | - * @param null $limit |
|
215 | - * @param bool $count |
|
216 | - * @param bool $global |
|
217 | - * @return \EE_Message_Template_Group[] message template groups. |
|
218 | - */ |
|
219 | - public function get_all_trashed_grouped_message_templates( |
|
220 | - $orderby = 'GRP_ID', |
|
221 | - $order = 'ASC', |
|
222 | - $limit = null, |
|
223 | - $count = false, |
|
224 | - $global = true |
|
225 | - ) { |
|
226 | - $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
227 | - $_where['MTP_is_active'] = true; |
|
228 | - $_where = $this->_maybe_mtp_filters($_where); |
|
229 | - |
|
230 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
231 | - |
|
232 | - return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * this returns the message template group(s) for a given event, messenger, and message template |
|
239 | - * |
|
240 | - * @param string $messenger |
|
241 | - * @param string $message_type |
|
242 | - * @param $evt_id |
|
243 | - * @param string $orderby pointless at this point but still included |
|
244 | - * @param string $order |
|
245 | - * @param mixed (array|null) $limit array($offset, $num) |
|
246 | - * @param bool $count true = just return count, false = objects |
|
247 | - * @param bool $active ignore "active" or not. (default only return active) |
|
248 | - * @return \mixed[]) depending on $count. |
|
249 | - */ |
|
250 | - public function get_event_message_templates_by_m_and_mt_and_evt( |
|
251 | - $messenger, |
|
252 | - $message_type, |
|
253 | - $evt_id, |
|
254 | - $orderby = 'GRP_ID', |
|
255 | - $order = 'ASC', |
|
256 | - $limit = null, |
|
257 | - $count = false, |
|
258 | - $active = true |
|
259 | - ) { |
|
260 | - $_where = array( |
|
261 | - 'MTP_messenger' => $messenger, |
|
262 | - 'MTP_message_type' => $message_type, |
|
263 | - 'Event.EVT_ID' => $evt_id, |
|
264 | - 'MTP_is_global' => true, |
|
265 | - 'MTP_is_active' => $active |
|
266 | - ); |
|
267 | - |
|
268 | - $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit ); |
|
269 | - |
|
270 | - return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * get all GLOBAL message template groups for the given messenger and message type |
|
278 | - * |
|
279 | - * @param string $messenger slug for messenger |
|
280 | - * @param string $message_type slug for message type |
|
281 | - * @param string $orderby what column to orderby |
|
282 | - * @param string $order ASC or DESC |
|
283 | - * @param mixed (array|null) $limit array($offset, $num) |
|
284 | - * @param bool $count true = just return count, false = objects |
|
285 | - * @param bool $active ignore "active" or not. (default only return active) - |
|
286 | - * 'all' means return both inactive AND inactive. |
|
287 | - * @return array message template objects that are global (i.e. non-event) |
|
288 | - */ |
|
289 | - public function get_global_message_template_by_m_and_mt( |
|
290 | - $messenger, |
|
291 | - $message_type, |
|
292 | - $orderby = 'GRP_ID', |
|
293 | - $order = 'ASC', |
|
294 | - $limit = null, |
|
295 | - $count = false, |
|
296 | - $active = true |
|
297 | - ) { |
|
298 | - $_where = array( |
|
299 | - 'MTP_messenger' => $messenger, |
|
300 | - 'MTP_message_type' => $message_type, |
|
301 | - 'MTP_is_global' => true, |
|
302 | - ); |
|
303 | - |
|
304 | - if ($active != 'all') { |
|
305 | - $_where['MTP_is_active'] = $active; |
|
306 | - } |
|
307 | - |
|
308 | - $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
309 | - |
|
310 | - return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * get all custom message template groups for the given messenger and message type |
|
318 | - * @param string $messenger messenger |
|
319 | - * @param string $message_type messagetype |
|
320 | - * @param array $query_params same as EEM_Base->get_all() |
|
321 | - * @return EE_Message_Template_Group[] |
|
322 | - */ |
|
323 | - public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array()) |
|
324 | - { |
|
325 | - return $this->get_all( |
|
326 | - array_merge( |
|
327 | - $query_params, |
|
328 | - array( |
|
329 | - array( |
|
330 | - 'MTP_is_global' => false, |
|
331 | - 'MTP_messenger' => $messenger, |
|
332 | - 'MTP_message_type' => $message_type |
|
333 | - ) |
|
334 | - ) |
|
335 | - ) |
|
336 | - ); |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * This sends things to the validator for the given messenger and message type. |
|
343 | - * |
|
344 | - * @param array $fields the incoming fields to check. |
|
345 | - * Note this array is in the formatted fields from the form fields setup. |
|
346 | - * So we need to reformat this into an array of expected field refs by the validator. |
|
347 | - * Note also that this is not only the fields for the Message Template Group |
|
348 | - * but ALSO for Message Template. |
|
349 | - * @param string $context The context the fields were obtained from. |
|
350 | - * @param string $messenger The messenger we are validating |
|
351 | - * @param string $message_type The message type we are validating. |
|
352 | - * @return mixed If the fields all check out then we return true otherwise error messages are returned |
|
353 | - * (indexed by field name); |
|
354 | - * @throws \EE_Error |
|
355 | - */ |
|
356 | - public function validate($fields, $context, $messenger, $message_type) |
|
357 | - { |
|
358 | - |
|
359 | - $assembled_fields = array(); |
|
360 | - |
|
361 | - // let's loop through all the fields and set them up in the right format |
|
362 | - foreach ($fields as $index => $value) { |
|
363 | - // first let's figure out if the value['content'] in the current index is an array. |
|
364 | - // If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list'). |
|
365 | - if (is_array($value['content'])) { |
|
366 | - $assembled_fields[ $value['name'] ] = $value['content']['main']; |
|
367 | - // loop through the content and get the other fields. |
|
368 | - foreach ($value['content'] as $name => $val) { |
|
369 | - if ($name == 'main') { |
|
370 | - continue; |
|
371 | - } |
|
372 | - $assembled_fields[ $name ] = $val; |
|
373 | - } |
|
374 | - continue; |
|
375 | - } |
|
376 | - |
|
377 | - // okay if we're here then this is just a straight field=>$value arrangement |
|
378 | - $assembled_fields[ $value['name'] ] = $value['content']; |
|
379 | - } |
|
380 | - |
|
381 | - // now we've got the assembled_fields. |
|
382 | - // We need to setup the string for the appropriate validator class and call that. |
|
383 | - $m_ref = ucwords(str_replace('_', ' ', $messenger)); |
|
384 | - $m_ref = str_replace(' ', '_', $m_ref); |
|
385 | - $mt_ref = ucwords(str_replace('_', ' ', $message_type)); |
|
386 | - $mt_ref = str_replace(' ', '_', $mt_ref); |
|
387 | - |
|
388 | - $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator'; |
|
389 | - |
|
390 | - if (!class_exists($classname)) { |
|
391 | - $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
392 | - $msg[] = sprintf( |
|
393 | - __( |
|
394 | - 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', |
|
395 | - 'event_espresso' |
|
396 | - ), |
|
397 | - $classname |
|
398 | - ); |
|
399 | - throw new EE_Error(implode('||', $msg)); |
|
400 | - } |
|
401 | - |
|
402 | - $a = new ReflectionClass($classname); |
|
403 | - $_VLD = $a->newInstance($assembled_fields, $context); |
|
404 | - $result = $_VLD->validate(); |
|
405 | - return $result; |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Updates all message template groups matching the incoming arguments to inactive status. |
|
412 | - * |
|
413 | - * @param array $messenger_names The messenger slugs. |
|
414 | - * If empty then all templates matching the message types are marked inactive. |
|
415 | - * Otherwise only templates matching the messengers and message types. |
|
416 | - * @param array $message_type_names The message type slugs. |
|
417 | - * If empty then all templates matching the messengers are marked inactive. |
|
418 | - * Otherwise only templates matching the messengers and message types. |
|
419 | - * |
|
420 | - * @return int count of updated records. |
|
421 | - */ |
|
422 | - public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array()) |
|
423 | - { |
|
424 | - $query_args = array(); |
|
425 | - if (empty($messenger_names) && empty($message_type_names)) { |
|
426 | - return 0; |
|
427 | - } |
|
428 | - if (! empty($messenger_names)) { |
|
429 | - $query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names ); |
|
430 | - } |
|
431 | - if (! empty($message_type_names)) { |
|
432 | - $query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names ); |
|
433 | - } |
|
434 | - return $this->update(array( 'MTP_is_active' => false ), $query_args); |
|
435 | - } |
|
14 | + // private instance of the EEM_Message_Template_Group object |
|
15 | + protected static $_instance = null; |
|
16 | + |
|
17 | + |
|
18 | + |
|
19 | + protected function __construct($timezone = null) |
|
20 | + { |
|
21 | + $this->singular_item = __('Message Template Group', 'event_espresso'); |
|
22 | + $this->plural_item = __('Message Template Groups', 'event_espresso'); |
|
23 | + $this->_tables = array( |
|
24 | + 'Message_Template_Group' => new EE_Primary_Table('esp_message_template_group', 'GRP_ID') |
|
25 | + ); |
|
26 | + $this->_fields = array( |
|
27 | + 'Message_Template_Group' => array( |
|
28 | + 'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')), |
|
29 | + 'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), false, ''), |
|
30 | + 'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), false, ''), |
|
31 | + 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), false, get_current_user_id()), |
|
32 | + 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), false, 'email'), |
|
33 | + 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'), |
|
34 | + 'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true), |
|
35 | + 'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false), |
|
36 | + 'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false), |
|
37 | + 'MTP_is_active'=>new EE_Boolean_Field('MTP_is_active', __('Flag indicating whether template group is active', 'event_espresso'), false, true) |
|
38 | + ) |
|
39 | + ); |
|
40 | + $this->_model_relations = array( |
|
41 | + 'Message_Template' => new EE_Has_Many_Relation(), |
|
42 | + 'Message' => new EE_Has_Many_Relation(), |
|
43 | + 'Event' => new EE_HABTM_Relation('Event_Message_Template'), |
|
44 | + 'WP_User' => new EE_Belongs_To_Relation() |
|
45 | + ); |
|
46 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
47 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
48 | + } |
|
49 | + $this->_caps_slug = 'messages'; |
|
50 | + |
|
51 | + parent::__construct($timezone); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * get_all_trashed_message_templates_by_event |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param int $EVT_ID specific event id |
|
61 | + * @param string $orderby |
|
62 | + * @param string $order |
|
63 | + * @param null $limit |
|
64 | + * @param bool $count |
|
65 | + * @return array message template objects that are attached to a specific event. |
|
66 | + */ |
|
67 | + public function get_all_trashed_message_templates_by_event( |
|
68 | + $EVT_ID, |
|
69 | + $orderby = 'GRP_ID', |
|
70 | + $order = 'ASC', |
|
71 | + $limit = null, |
|
72 | + $count = false |
|
73 | + ) { |
|
74 | + $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
75 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * get_all_message_templates_by_messenger |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @param $messenger |
|
85 | + * @param string $orderby |
|
86 | + * @param string $order |
|
87 | + * @return array all (including trashed or inactive) message template group objects for the given messenger |
|
88 | + */ |
|
89 | + public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') |
|
90 | + { |
|
91 | + return $this->get_all_deleted_and_undeleted( |
|
92 | + array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) ) |
|
93 | + ); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * This simply adds on any messenger/message type filters that may be present in the $_POST global |
|
100 | + * @param array $_where any existing where conditions to append these to. |
|
101 | + * @return array original where conditions or original with additional filters. |
|
102 | + */ |
|
103 | + protected function _maybe_mtp_filters($_where = array()) |
|
104 | + { |
|
105 | + // account for messenger or message type filters |
|
106 | + if (isset($_REQUEST['ee_messenger_filter_by']) |
|
107 | + && $_REQUEST['ee_messenger_filter_by'] != 'none_selected' |
|
108 | + && $_REQUEST['ee_messenger_filter_by'] != 'all' |
|
109 | + ) { |
|
110 | + $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by'] ; |
|
111 | + } |
|
112 | + |
|
113 | + if (isset($_REQUEST['ee_message_type_filter_by']) |
|
114 | + && $_REQUEST['ee_message_type_filter_by'] != 'none_selected' |
|
115 | + ) { |
|
116 | + $_where['MTP_message_type'] = $_REQUEST['ee_message_type_filter_by']; |
|
117 | + } |
|
118 | + |
|
119 | + return $_where; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * get_all_active_message_templates groups |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @param string $orderby |
|
129 | + * @param string $order |
|
130 | + * @param null $limit |
|
131 | + * @param bool $count |
|
132 | + * @param bool $global |
|
133 | + * @param bool $user_check |
|
134 | + * @return array all active (non_trashed, active) message template objects |
|
135 | + */ |
|
136 | + public function get_all_active_message_templates( |
|
137 | + $orderby = 'GRP_ID', |
|
138 | + $order = 'ASC', |
|
139 | + $limit = null, |
|
140 | + $count = false, |
|
141 | + $global = true, |
|
142 | + $user_check = false |
|
143 | + ) { |
|
144 | + $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
145 | + $_where['MTP_is_active'] = true; |
|
146 | + $_where = $this->_maybe_mtp_filters($_where); |
|
147 | + |
|
148 | + if ($user_check |
|
149 | + && ! $global |
|
150 | + && ! EE_Registry::instance()->CAP->current_user_can( |
|
151 | + 'ee_read_others_messages', |
|
152 | + 'get_all_active_message_templates' |
|
153 | + ) |
|
154 | + ) { |
|
155 | + $_where['MTP_user_id'] = get_current_user_id(); |
|
156 | + } |
|
157 | + |
|
158 | + $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
159 | + |
|
160 | + return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * retrieve ALL message_template groups from db regardless of wht |
|
167 | + * |
|
168 | + * @access public |
|
169 | + * @param string $orderby |
|
170 | + * @param string $order |
|
171 | + * @param null $limit |
|
172 | + * @param bool $count |
|
173 | + * @return mixed array on success, FALSE on fail |
|
174 | + */ |
|
175 | + public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false) |
|
176 | + { |
|
177 | + $_where = $this->_maybe_mtp_filters(); |
|
178 | + |
|
179 | + $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
180 | + |
|
181 | + $r_templates = $count |
|
182 | + ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true) |
|
183 | + : $this->get_all_deleted_and_undeleted($query_params); |
|
184 | + |
|
185 | + return $r_templates; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * This gets all the custom templates attached to a specific event |
|
193 | + * @param int $EVT_ID event id |
|
194 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
195 | + * @return EE_Message_Template_Group[] |
|
196 | + */ |
|
197 | + public function get_all_custom_templates_by_event($EVT_ID, $query_params = array()) |
|
198 | + { |
|
199 | + $where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID )); |
|
200 | + return $this->get_all( |
|
201 | + array( $where ) |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * get_all_trashed_grouped_message_templates |
|
209 | + * this returns ONLY the template groups where ALL contexts are trashed and none of the group are non-trashed |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @param string $orderby |
|
213 | + * @param string $order |
|
214 | + * @param null $limit |
|
215 | + * @param bool $count |
|
216 | + * @param bool $global |
|
217 | + * @return \EE_Message_Template_Group[] message template groups. |
|
218 | + */ |
|
219 | + public function get_all_trashed_grouped_message_templates( |
|
220 | + $orderby = 'GRP_ID', |
|
221 | + $order = 'ASC', |
|
222 | + $limit = null, |
|
223 | + $count = false, |
|
224 | + $global = true |
|
225 | + ) { |
|
226 | + $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false ); |
|
227 | + $_where['MTP_is_active'] = true; |
|
228 | + $_where = $this->_maybe_mtp_filters($_where); |
|
229 | + |
|
230 | + $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
231 | + |
|
232 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * this returns the message template group(s) for a given event, messenger, and message template |
|
239 | + * |
|
240 | + * @param string $messenger |
|
241 | + * @param string $message_type |
|
242 | + * @param $evt_id |
|
243 | + * @param string $orderby pointless at this point but still included |
|
244 | + * @param string $order |
|
245 | + * @param mixed (array|null) $limit array($offset, $num) |
|
246 | + * @param bool $count true = just return count, false = objects |
|
247 | + * @param bool $active ignore "active" or not. (default only return active) |
|
248 | + * @return \mixed[]) depending on $count. |
|
249 | + */ |
|
250 | + public function get_event_message_templates_by_m_and_mt_and_evt( |
|
251 | + $messenger, |
|
252 | + $message_type, |
|
253 | + $evt_id, |
|
254 | + $orderby = 'GRP_ID', |
|
255 | + $order = 'ASC', |
|
256 | + $limit = null, |
|
257 | + $count = false, |
|
258 | + $active = true |
|
259 | + ) { |
|
260 | + $_where = array( |
|
261 | + 'MTP_messenger' => $messenger, |
|
262 | + 'MTP_message_type' => $message_type, |
|
263 | + 'Event.EVT_ID' => $evt_id, |
|
264 | + 'MTP_is_global' => true, |
|
265 | + 'MTP_is_active' => $active |
|
266 | + ); |
|
267 | + |
|
268 | + $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit ); |
|
269 | + |
|
270 | + return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * get all GLOBAL message template groups for the given messenger and message type |
|
278 | + * |
|
279 | + * @param string $messenger slug for messenger |
|
280 | + * @param string $message_type slug for message type |
|
281 | + * @param string $orderby what column to orderby |
|
282 | + * @param string $order ASC or DESC |
|
283 | + * @param mixed (array|null) $limit array($offset, $num) |
|
284 | + * @param bool $count true = just return count, false = objects |
|
285 | + * @param bool $active ignore "active" or not. (default only return active) - |
|
286 | + * 'all' means return both inactive AND inactive. |
|
287 | + * @return array message template objects that are global (i.e. non-event) |
|
288 | + */ |
|
289 | + public function get_global_message_template_by_m_and_mt( |
|
290 | + $messenger, |
|
291 | + $message_type, |
|
292 | + $orderby = 'GRP_ID', |
|
293 | + $order = 'ASC', |
|
294 | + $limit = null, |
|
295 | + $count = false, |
|
296 | + $active = true |
|
297 | + ) { |
|
298 | + $_where = array( |
|
299 | + 'MTP_messenger' => $messenger, |
|
300 | + 'MTP_message_type' => $message_type, |
|
301 | + 'MTP_is_global' => true, |
|
302 | + ); |
|
303 | + |
|
304 | + if ($active != 'all') { |
|
305 | + $_where['MTP_is_active'] = $active; |
|
306 | + } |
|
307 | + |
|
308 | + $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
309 | + |
|
310 | + return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * get all custom message template groups for the given messenger and message type |
|
318 | + * @param string $messenger messenger |
|
319 | + * @param string $message_type messagetype |
|
320 | + * @param array $query_params same as EEM_Base->get_all() |
|
321 | + * @return EE_Message_Template_Group[] |
|
322 | + */ |
|
323 | + public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array()) |
|
324 | + { |
|
325 | + return $this->get_all( |
|
326 | + array_merge( |
|
327 | + $query_params, |
|
328 | + array( |
|
329 | + array( |
|
330 | + 'MTP_is_global' => false, |
|
331 | + 'MTP_messenger' => $messenger, |
|
332 | + 'MTP_message_type' => $message_type |
|
333 | + ) |
|
334 | + ) |
|
335 | + ) |
|
336 | + ); |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * This sends things to the validator for the given messenger and message type. |
|
343 | + * |
|
344 | + * @param array $fields the incoming fields to check. |
|
345 | + * Note this array is in the formatted fields from the form fields setup. |
|
346 | + * So we need to reformat this into an array of expected field refs by the validator. |
|
347 | + * Note also that this is not only the fields for the Message Template Group |
|
348 | + * but ALSO for Message Template. |
|
349 | + * @param string $context The context the fields were obtained from. |
|
350 | + * @param string $messenger The messenger we are validating |
|
351 | + * @param string $message_type The message type we are validating. |
|
352 | + * @return mixed If the fields all check out then we return true otherwise error messages are returned |
|
353 | + * (indexed by field name); |
|
354 | + * @throws \EE_Error |
|
355 | + */ |
|
356 | + public function validate($fields, $context, $messenger, $message_type) |
|
357 | + { |
|
358 | + |
|
359 | + $assembled_fields = array(); |
|
360 | + |
|
361 | + // let's loop through all the fields and set them up in the right format |
|
362 | + foreach ($fields as $index => $value) { |
|
363 | + // first let's figure out if the value['content'] in the current index is an array. |
|
364 | + // If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list'). |
|
365 | + if (is_array($value['content'])) { |
|
366 | + $assembled_fields[ $value['name'] ] = $value['content']['main']; |
|
367 | + // loop through the content and get the other fields. |
|
368 | + foreach ($value['content'] as $name => $val) { |
|
369 | + if ($name == 'main') { |
|
370 | + continue; |
|
371 | + } |
|
372 | + $assembled_fields[ $name ] = $val; |
|
373 | + } |
|
374 | + continue; |
|
375 | + } |
|
376 | + |
|
377 | + // okay if we're here then this is just a straight field=>$value arrangement |
|
378 | + $assembled_fields[ $value['name'] ] = $value['content']; |
|
379 | + } |
|
380 | + |
|
381 | + // now we've got the assembled_fields. |
|
382 | + // We need to setup the string for the appropriate validator class and call that. |
|
383 | + $m_ref = ucwords(str_replace('_', ' ', $messenger)); |
|
384 | + $m_ref = str_replace(' ', '_', $m_ref); |
|
385 | + $mt_ref = ucwords(str_replace('_', ' ', $message_type)); |
|
386 | + $mt_ref = str_replace(' ', '_', $mt_ref); |
|
387 | + |
|
388 | + $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator'; |
|
389 | + |
|
390 | + if (!class_exists($classname)) { |
|
391 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
392 | + $msg[] = sprintf( |
|
393 | + __( |
|
394 | + 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', |
|
395 | + 'event_espresso' |
|
396 | + ), |
|
397 | + $classname |
|
398 | + ); |
|
399 | + throw new EE_Error(implode('||', $msg)); |
|
400 | + } |
|
401 | + |
|
402 | + $a = new ReflectionClass($classname); |
|
403 | + $_VLD = $a->newInstance($assembled_fields, $context); |
|
404 | + $result = $_VLD->validate(); |
|
405 | + return $result; |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Updates all message template groups matching the incoming arguments to inactive status. |
|
412 | + * |
|
413 | + * @param array $messenger_names The messenger slugs. |
|
414 | + * If empty then all templates matching the message types are marked inactive. |
|
415 | + * Otherwise only templates matching the messengers and message types. |
|
416 | + * @param array $message_type_names The message type slugs. |
|
417 | + * If empty then all templates matching the messengers are marked inactive. |
|
418 | + * Otherwise only templates matching the messengers and message types. |
|
419 | + * |
|
420 | + * @return int count of updated records. |
|
421 | + */ |
|
422 | + public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array()) |
|
423 | + { |
|
424 | + $query_args = array(); |
|
425 | + if (empty($messenger_names) && empty($message_type_names)) { |
|
426 | + return 0; |
|
427 | + } |
|
428 | + if (! empty($messenger_names)) { |
|
429 | + $query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names ); |
|
430 | + } |
|
431 | + if (! empty($message_type_names)) { |
|
432 | + $query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names ); |
|
433 | + } |
|
434 | + return $this->update(array( 'MTP_is_active' => false ), $query_args); |
|
435 | + } |
|
436 | 436 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | /** |
215 | 215 | * Overrides parent ot also check by the slug |
216 | 216 | * @see EEM_Base::ensure_is_obj() |
217 | - * @param string|int|EE_Payment_Method $base_class_obj_or_id |
|
217 | + * @param EE_Payment_Method $base_class_obj_or_id |
|
218 | 218 | * @param boolean $ensure_is_in_db |
219 | 219 | * @return EE_Payment_Method |
220 | 220 | * @throws EE_Error |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * Note: if an offline payment method was selected on the related transaction then this will have no payment methods returned. |
383 | 383 | * It will ONLY return a payment method for a PAYMENT recorded against the registration. |
384 | 384 | * |
385 | - * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
|
386 | - * @return EE_Payment|null |
|
385 | + * @param EE_Registration $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
|
386 | + * @return null|EE_Base_Class |
|
387 | 387 | */ |
388 | 388 | public function get_last_used_for_registration($registration_or_reg_id) |
389 | 389 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $this->singlular_item = __('Payment Method', 'event_espresso'); |
46 | 46 | $this->plural_item = __('Payment Methods', 'event_espresso'); |
47 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID') ); |
|
47 | + $this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID')); |
|
48 | 48 | $this->_fields = array( |
49 | 49 | 'Payment_Method' => array( |
50 | 50 | 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function get_one_by_slug($slug) |
80 | 80 | { |
81 | - return $this->get_one(array( array( 'PMD_slug' => $slug ) )); |
|
81 | + return $this->get_one(array(array('PMD_slug' => $slug))); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function is_valid_scope($scope) |
110 | 110 | { |
111 | 111 | $scopes = $this->scopes(); |
112 | - if (isset($scopes[ $scope ])) { |
|
112 | + if (isset($scopes[$scope])) { |
|
113 | 113 | return true; |
114 | 114 | } else { |
115 | 115 | return false; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function get_all_active($scope = null, $query_params = array()) |
129 | 129 | { |
130 | - if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
131 | - $query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ); |
|
130 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
131 | + $query_params['order_by'] = array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC'); |
|
132 | 132 | } |
133 | 133 | return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
134 | 134 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | if ($scope) { |
158 | 158 | if ($this->is_valid_scope($scope)) { |
159 | - return array_replace_recursive(array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params); |
|
159 | + return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params); |
|
160 | 160 | } else { |
161 | 161 | throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
162 | 162 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $count = 0; |
166 | 166 | foreach ($this->scopes() as $scope_name => $desc) { |
167 | 167 | $count++; |
168 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
168 | + $acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%'); |
|
169 | 169 | } |
170 | - return array_replace_recursive(array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params); |
|
170 | + return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function get_one_of_type($type) |
207 | 207 | { |
208 | - return $this->get_one(array( array( 'PMD_type' => $type ) )); |
|
208 | + return $this->get_one(array(array('PMD_type' => $type))); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $usable_payment_methods = array(); |
299 | 299 | foreach ($payment_methods as $key => $payment_method) { |
300 | 300 | if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
301 | - $usable_payment_methods[ $key ] = $payment_method; |
|
301 | + $usable_payment_methods[$key] = $payment_method; |
|
302 | 302 | // some payment methods enqueue their scripts in EE_PMT_*::__construct |
303 | 303 | // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
304 | 304 | // its scripts). but for backwards-compat we should continue to do that |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $payment_method |
313 | 313 | ); |
314 | 314 | new PersistentAdminNotice( |
315 | - 'auto-deactivated-' . $payment_method->type(), |
|
315 | + 'auto-deactivated-'.$payment_method->type(), |
|
316 | 316 | sprintf( |
317 | 317 | __( |
318 | 318 | 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ), |
321 | 321 | $payment_method->admin_name(), |
322 | 322 | '<br />', |
323 | - '<a href="' . admin_url('plugins.php') . '">', |
|
323 | + '<a href="'.admin_url('plugins.php').'">', |
|
324 | 324 | '</a>' |
325 | 325 | ), |
326 | 326 | true |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | // give addons a chance to override what payment methods are chosen based on the transaction |
346 | 346 | return apply_filters( |
347 | 347 | 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
348 | - $this->get_all_active($scope, array( 'group_by' => 'PMD_type' )), |
|
348 | + $this->get_all_active($scope, array('group_by' => 'PMD_type')), |
|
349 | 349 | $transaction, |
350 | 350 | $scope |
351 | 351 | ); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | 0 => array( |
370 | 370 | 'Payment.Registration.REG_ID' => $registration_id, |
371 | 371 | ), |
372 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
372 | + 'order_by' => array('Payment.PAY_ID' => 'DESC') |
|
373 | 373 | ); |
374 | 374 | return $this->get_one($query_params); |
375 | 375 | } |
@@ -20,363 +20,363 @@ |
||
20 | 20 | class EEM_Payment_Method extends EEM_Base |
21 | 21 | { |
22 | 22 | |
23 | - const scope_cart = 'CART'; |
|
24 | - |
|
25 | - const scope_admin = 'ADMIN'; |
|
26 | - |
|
27 | - const scope_api = 'API'; |
|
28 | - |
|
29 | - /** |
|
30 | - * |
|
31 | - * @type EEM_Payment_Method |
|
32 | - */ |
|
33 | - protected static $_instance = null; |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * private constructor to prevent direct creation |
|
39 | - * @Constructor |
|
40 | - * @access protected |
|
41 | - * @return EEM_Payment_Method |
|
42 | - */ |
|
43 | - protected function __construct($timezone = null) |
|
44 | - { |
|
45 | - $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
46 | - $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
47 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID') ); |
|
48 | - $this->_fields = array( |
|
49 | - 'Payment_Method' => array( |
|
50 | - 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
51 | - 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), false, 'Admin_Only'), |
|
52 | - 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), false), |
|
53 | - 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), false, ''), |
|
54 | - 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), true), |
|
55 | - 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), true), |
|
56 | - 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), false), |
|
57 | - 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), false, 0), |
|
58 | - 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), false, false), |
|
59 | - 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), false), |
|
60 | - 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), false, false), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), true, ''), |
|
61 | - 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), false, array()), // possible values currently are 'CART','ADMIN','API' |
|
62 | - ) ); |
|
63 | - $this->_model_relations = array( |
|
64 | - 'Payment' => new EE_Has_Many_Relation(), |
|
65 | - 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
66 | - 'Transaction' => new EE_Has_Many_Relation(), |
|
67 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
68 | - ); |
|
69 | - parent::__construct($timezone); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Gets one by the slug provided |
|
76 | - * @param string $slug |
|
77 | - * @return EE_Payment_Method |
|
78 | - */ |
|
79 | - public function get_one_by_slug($slug) |
|
80 | - { |
|
81 | - return $this->get_one(array( array( 'PMD_slug' => $slug ) )); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Gets all the acceptable scopes for payment methods. |
|
88 | - * Keys are their names as store din the DB, and values are nice names for displaying them |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public function scopes() |
|
92 | - { |
|
93 | - return apply_filters( |
|
94 | - 'FHEE__EEM_Payment_Method__scopes', |
|
95 | - array( |
|
96 | - self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
97 | - self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
98 | - ) |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Determines if this is an valid scope |
|
106 | - * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
|
107 | - * @return boolean |
|
108 | - */ |
|
109 | - public function is_valid_scope($scope) |
|
110 | - { |
|
111 | - $scopes = $this->scopes(); |
|
112 | - if (isset($scopes[ $scope ])) { |
|
113 | - return true; |
|
114 | - } else { |
|
115 | - return false; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Gets all active payment methods |
|
123 | - * @param string $scope one of |
|
124 | - * @param array $query_params |
|
125 | - * @throws EE_Error |
|
126 | - * @return EE_Payment_Method[] |
|
127 | - */ |
|
128 | - public function get_all_active($scope = null, $query_params = array()) |
|
129 | - { |
|
130 | - if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
131 | - $query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ); |
|
132 | - } |
|
133 | - return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Counts all active gateways in the specified scope |
|
138 | - * @param string $scope one of EEM_Payment_Method::scope_* |
|
139 | - * @param array $query_params |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function count_active($scope = null, $query_params = array()) |
|
143 | - { |
|
144 | - return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
149 | - * argument to get all active for a given scope |
|
150 | - * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
151 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
152 | - * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
153 | - * @throws EE_Error |
|
154 | - */ |
|
155 | - protected function _get_query_params_for_all_active($scope = null, $query_params = array()) |
|
156 | - { |
|
157 | - if ($scope) { |
|
158 | - if ($this->is_valid_scope($scope)) { |
|
159 | - return array_replace_recursive(array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params); |
|
160 | - } else { |
|
161 | - throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
162 | - } |
|
163 | - } else { |
|
164 | - $acceptable_scopes = array(); |
|
165 | - $count = 0; |
|
166 | - foreach ($this->scopes() as $scope_name => $desc) { |
|
167 | - $count++; |
|
168 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
169 | - } |
|
170 | - return array_replace_recursive(array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
176 | - * argument to get all active for a given scope |
|
177 | - * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
178 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
179 | - * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
180 | - * @throws EE_Error |
|
181 | - */ |
|
182 | - public function get_query_params_for_all_active($scope = null, $query_params = array()) |
|
183 | - { |
|
184 | - return $this->_get_query_params_for_all_active($scope, $query_params); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Gets one active payment method. see @get_all_active for documentation |
|
190 | - * @param string $scope |
|
191 | - * @param array $query_params |
|
192 | - * @return EE_Payment_Method |
|
193 | - */ |
|
194 | - public function get_one_active($scope = null, $query_params = array()) |
|
195 | - { |
|
196 | - return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * Gets one payment method of that type, regardless of whether its active or not |
|
203 | - * @param string $type |
|
204 | - * @return EE_Payment_Method |
|
205 | - */ |
|
206 | - public function get_one_of_type($type) |
|
207 | - { |
|
208 | - return $this->get_one(array( array( 'PMD_type' => $type ) )); |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * Overrides parent ot also check by the slug |
|
215 | - * @see EEM_Base::ensure_is_obj() |
|
216 | - * @param string|int|EE_Payment_Method $base_class_obj_or_id |
|
217 | - * @param boolean $ensure_is_in_db |
|
218 | - * @return EE_Payment_Method |
|
219 | - * @throws EE_Error |
|
220 | - */ |
|
221 | - public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = false) |
|
222 | - { |
|
223 | - // first: check if it's a slug |
|
224 | - if (is_string($base_class_obj_or_id)) { |
|
225 | - $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
226 | - if ($obj) { |
|
227 | - return $obj; |
|
228 | - } |
|
229 | - } |
|
230 | - // ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
|
231 | - try { |
|
232 | - return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
233 | - } catch (EE_Error $e) { |
|
234 | - // handle it outside the catch |
|
235 | - } |
|
236 | - throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * Gets the ID of this object, or if its a string finds the object's id |
|
243 | - * associated with that slug |
|
244 | - * @param mixed $base_obj_or_id_or_slug |
|
245 | - * @return int |
|
246 | - */ |
|
247 | - public function ensure_is_ID($base_obj_or_id_or_slug) |
|
248 | - { |
|
249 | - if (is_string($base_obj_or_id_or_slug)) { |
|
250 | - // assume it's a slug |
|
251 | - $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
252 | - } |
|
253 | - return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
|
260 | - * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
|
261 | - */ |
|
262 | - public function verify_button_urls($payment_methods = null) |
|
263 | - { |
|
264 | - $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
265 | - foreach ($payment_methods as $payment_method) { |
|
266 | - try { |
|
267 | - // If there is really no button URL at all, or if the button URLs still point to decaf folder even |
|
268 | - // though this is a caffeinated install, reset it to the default. |
|
269 | - $current_button_url = $payment_method->button_url(); |
|
270 | - if (empty($current_button_url) |
|
271 | - || ( |
|
272 | - strpos($current_button_url, 'decaf') !== false |
|
273 | - && strpos($payment_method->type_obj()->default_button_url(), 'decaf') === false |
|
274 | - ) |
|
275 | - ) { |
|
276 | - $payment_method->save( |
|
277 | - [ |
|
278 | - 'PMD_button_url' => $payment_method->type_obj()->default_button_url() |
|
279 | - ] |
|
280 | - ); |
|
281 | - } |
|
282 | - } catch (EE_Error $e) { |
|
283 | - $payment_method->set_active(false); |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Overrides parent to not only turn wpdb results into EE_Payment_Method objects, |
|
292 | - * but also verifies the payment method type of each is a usable object. If not, |
|
293 | - * deactivate it, sets a notification, and deactivates it |
|
294 | - * |
|
295 | - * @param array $rows |
|
296 | - * @return EE_Payment_Method[] |
|
297 | - * @throws InvalidDataTypeException |
|
298 | - */ |
|
299 | - protected function _create_objects($rows = array()) |
|
300 | - { |
|
301 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
302 | - $payment_methods = parent::_create_objects($rows); |
|
303 | - /* @var $payment_methods EE_Payment_Method[] */ |
|
304 | - $usable_payment_methods = array(); |
|
305 | - foreach ($payment_methods as $key => $payment_method) { |
|
306 | - if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
307 | - $usable_payment_methods[ $key ] = $payment_method; |
|
308 | - // some payment methods enqueue their scripts in EE_PMT_*::__construct |
|
309 | - // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
|
310 | - // its scripts). but for backwards-compat we should continue to do that |
|
311 | - $payment_method->type_obj(); |
|
312 | - } elseif ($payment_method->active()) { |
|
313 | - // only deactivate and notify the admin if the payment is active somewhere |
|
314 | - $payment_method->deactivate(); |
|
315 | - $payment_method->save(); |
|
316 | - do_action( |
|
317 | - 'AHEE__EEM_Payment_Method___create_objects_auto_deactivated_payment_method', |
|
318 | - $payment_method |
|
319 | - ); |
|
320 | - new PersistentAdminNotice( |
|
321 | - 'auto-deactivated-' . $payment_method->type(), |
|
322 | - sprintf( |
|
323 | - __( |
|
324 | - 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
|
325 | - 'event_espresso' |
|
326 | - ), |
|
327 | - $payment_method->admin_name(), |
|
328 | - '<br />', |
|
329 | - '<a href="' . admin_url('plugins.php') . '">', |
|
330 | - '</a>' |
|
331 | - ), |
|
332 | - true |
|
333 | - ); |
|
334 | - } |
|
335 | - } |
|
336 | - return $usable_payment_methods; |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * Gets all the payment methods which can be used for transaction |
|
343 | - * (according to the relations between payment methods and events, and |
|
344 | - * the currencies used for the transaction and their relation to payment methods) |
|
345 | - * @param EE_Transaction $transaction |
|
346 | - * @param string $scope @see EEM_Payment_Method::get_all_for_events |
|
347 | - * @return EE_Payment_Method[] |
|
348 | - */ |
|
349 | - public function get_all_for_transaction($transaction, $scope) |
|
350 | - { |
|
351 | - // give addons a chance to override what payment methods are chosen based on the transaction |
|
352 | - return apply_filters( |
|
353 | - 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
|
354 | - $this->get_all_active($scope, array( 'group_by' => 'PMD_type' )), |
|
355 | - $transaction, |
|
356 | - $scope |
|
357 | - ); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Returns the payment method used for the last payment made for a registration. |
|
363 | - * |
|
364 | - * Note: if an offline payment method was selected on the related transaction then this will have no payment methods returned. |
|
365 | - * It will ONLY return a payment method for a PAYMENT recorded against the registration. |
|
366 | - * |
|
367 | - * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
|
368 | - * @return EE_Payment|null |
|
369 | - */ |
|
370 | - public function get_last_used_for_registration($registration_or_reg_id) |
|
371 | - { |
|
372 | - $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
373 | - |
|
374 | - $query_params = array( |
|
375 | - 0 => array( |
|
376 | - 'Payment.Registration.REG_ID' => $registration_id, |
|
377 | - ), |
|
378 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
379 | - ); |
|
380 | - return $this->get_one($query_params); |
|
381 | - } |
|
23 | + const scope_cart = 'CART'; |
|
24 | + |
|
25 | + const scope_admin = 'ADMIN'; |
|
26 | + |
|
27 | + const scope_api = 'API'; |
|
28 | + |
|
29 | + /** |
|
30 | + * |
|
31 | + * @type EEM_Payment_Method |
|
32 | + */ |
|
33 | + protected static $_instance = null; |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * private constructor to prevent direct creation |
|
39 | + * @Constructor |
|
40 | + * @access protected |
|
41 | + * @return EEM_Payment_Method |
|
42 | + */ |
|
43 | + protected function __construct($timezone = null) |
|
44 | + { |
|
45 | + $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
46 | + $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
47 | + $this->_tables = array( 'Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID') ); |
|
48 | + $this->_fields = array( |
|
49 | + 'Payment_Method' => array( |
|
50 | + 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
51 | + 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), false, 'Admin_Only'), |
|
52 | + 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), false), |
|
53 | + 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), false, ''), |
|
54 | + 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), true), |
|
55 | + 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), true), |
|
56 | + 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), false), |
|
57 | + 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), false, 0), |
|
58 | + 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), false, false), |
|
59 | + 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), false), |
|
60 | + 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), false, false), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), true, ''), |
|
61 | + 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), false, array()), // possible values currently are 'CART','ADMIN','API' |
|
62 | + ) ); |
|
63 | + $this->_model_relations = array( |
|
64 | + 'Payment' => new EE_Has_Many_Relation(), |
|
65 | + 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
66 | + 'Transaction' => new EE_Has_Many_Relation(), |
|
67 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
68 | + ); |
|
69 | + parent::__construct($timezone); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Gets one by the slug provided |
|
76 | + * @param string $slug |
|
77 | + * @return EE_Payment_Method |
|
78 | + */ |
|
79 | + public function get_one_by_slug($slug) |
|
80 | + { |
|
81 | + return $this->get_one(array( array( 'PMD_slug' => $slug ) )); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Gets all the acceptable scopes for payment methods. |
|
88 | + * Keys are their names as store din the DB, and values are nice names for displaying them |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public function scopes() |
|
92 | + { |
|
93 | + return apply_filters( |
|
94 | + 'FHEE__EEM_Payment_Method__scopes', |
|
95 | + array( |
|
96 | + self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
97 | + self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
98 | + ) |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Determines if this is an valid scope |
|
106 | + * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
|
107 | + * @return boolean |
|
108 | + */ |
|
109 | + public function is_valid_scope($scope) |
|
110 | + { |
|
111 | + $scopes = $this->scopes(); |
|
112 | + if (isset($scopes[ $scope ])) { |
|
113 | + return true; |
|
114 | + } else { |
|
115 | + return false; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Gets all active payment methods |
|
123 | + * @param string $scope one of |
|
124 | + * @param array $query_params |
|
125 | + * @throws EE_Error |
|
126 | + * @return EE_Payment_Method[] |
|
127 | + */ |
|
128 | + public function get_all_active($scope = null, $query_params = array()) |
|
129 | + { |
|
130 | + if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
131 | + $query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ); |
|
132 | + } |
|
133 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Counts all active gateways in the specified scope |
|
138 | + * @param string $scope one of EEM_Payment_Method::scope_* |
|
139 | + * @param array $query_params |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function count_active($scope = null, $query_params = array()) |
|
143 | + { |
|
144 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
149 | + * argument to get all active for a given scope |
|
150 | + * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
151 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
152 | + * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
153 | + * @throws EE_Error |
|
154 | + */ |
|
155 | + protected function _get_query_params_for_all_active($scope = null, $query_params = array()) |
|
156 | + { |
|
157 | + if ($scope) { |
|
158 | + if ($this->is_valid_scope($scope)) { |
|
159 | + return array_replace_recursive(array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params); |
|
160 | + } else { |
|
161 | + throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
162 | + } |
|
163 | + } else { |
|
164 | + $acceptable_scopes = array(); |
|
165 | + $count = 0; |
|
166 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
167 | + $count++; |
|
168 | + $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
169 | + } |
|
170 | + return array_replace_recursive(array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
176 | + * argument to get all active for a given scope |
|
177 | + * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
178 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
179 | + * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
180 | + * @throws EE_Error |
|
181 | + */ |
|
182 | + public function get_query_params_for_all_active($scope = null, $query_params = array()) |
|
183 | + { |
|
184 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Gets one active payment method. see @get_all_active for documentation |
|
190 | + * @param string $scope |
|
191 | + * @param array $query_params |
|
192 | + * @return EE_Payment_Method |
|
193 | + */ |
|
194 | + public function get_one_active($scope = null, $query_params = array()) |
|
195 | + { |
|
196 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * Gets one payment method of that type, regardless of whether its active or not |
|
203 | + * @param string $type |
|
204 | + * @return EE_Payment_Method |
|
205 | + */ |
|
206 | + public function get_one_of_type($type) |
|
207 | + { |
|
208 | + return $this->get_one(array( array( 'PMD_type' => $type ) )); |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * Overrides parent ot also check by the slug |
|
215 | + * @see EEM_Base::ensure_is_obj() |
|
216 | + * @param string|int|EE_Payment_Method $base_class_obj_or_id |
|
217 | + * @param boolean $ensure_is_in_db |
|
218 | + * @return EE_Payment_Method |
|
219 | + * @throws EE_Error |
|
220 | + */ |
|
221 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = false) |
|
222 | + { |
|
223 | + // first: check if it's a slug |
|
224 | + if (is_string($base_class_obj_or_id)) { |
|
225 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
226 | + if ($obj) { |
|
227 | + return $obj; |
|
228 | + } |
|
229 | + } |
|
230 | + // ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
|
231 | + try { |
|
232 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
233 | + } catch (EE_Error $e) { |
|
234 | + // handle it outside the catch |
|
235 | + } |
|
236 | + throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * Gets the ID of this object, or if its a string finds the object's id |
|
243 | + * associated with that slug |
|
244 | + * @param mixed $base_obj_or_id_or_slug |
|
245 | + * @return int |
|
246 | + */ |
|
247 | + public function ensure_is_ID($base_obj_or_id_or_slug) |
|
248 | + { |
|
249 | + if (is_string($base_obj_or_id_or_slug)) { |
|
250 | + // assume it's a slug |
|
251 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
252 | + } |
|
253 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
|
260 | + * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
|
261 | + */ |
|
262 | + public function verify_button_urls($payment_methods = null) |
|
263 | + { |
|
264 | + $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
265 | + foreach ($payment_methods as $payment_method) { |
|
266 | + try { |
|
267 | + // If there is really no button URL at all, or if the button URLs still point to decaf folder even |
|
268 | + // though this is a caffeinated install, reset it to the default. |
|
269 | + $current_button_url = $payment_method->button_url(); |
|
270 | + if (empty($current_button_url) |
|
271 | + || ( |
|
272 | + strpos($current_button_url, 'decaf') !== false |
|
273 | + && strpos($payment_method->type_obj()->default_button_url(), 'decaf') === false |
|
274 | + ) |
|
275 | + ) { |
|
276 | + $payment_method->save( |
|
277 | + [ |
|
278 | + 'PMD_button_url' => $payment_method->type_obj()->default_button_url() |
|
279 | + ] |
|
280 | + ); |
|
281 | + } |
|
282 | + } catch (EE_Error $e) { |
|
283 | + $payment_method->set_active(false); |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Overrides parent to not only turn wpdb results into EE_Payment_Method objects, |
|
292 | + * but also verifies the payment method type of each is a usable object. If not, |
|
293 | + * deactivate it, sets a notification, and deactivates it |
|
294 | + * |
|
295 | + * @param array $rows |
|
296 | + * @return EE_Payment_Method[] |
|
297 | + * @throws InvalidDataTypeException |
|
298 | + */ |
|
299 | + protected function _create_objects($rows = array()) |
|
300 | + { |
|
301 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
302 | + $payment_methods = parent::_create_objects($rows); |
|
303 | + /* @var $payment_methods EE_Payment_Method[] */ |
|
304 | + $usable_payment_methods = array(); |
|
305 | + foreach ($payment_methods as $key => $payment_method) { |
|
306 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
307 | + $usable_payment_methods[ $key ] = $payment_method; |
|
308 | + // some payment methods enqueue their scripts in EE_PMT_*::__construct |
|
309 | + // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
|
310 | + // its scripts). but for backwards-compat we should continue to do that |
|
311 | + $payment_method->type_obj(); |
|
312 | + } elseif ($payment_method->active()) { |
|
313 | + // only deactivate and notify the admin if the payment is active somewhere |
|
314 | + $payment_method->deactivate(); |
|
315 | + $payment_method->save(); |
|
316 | + do_action( |
|
317 | + 'AHEE__EEM_Payment_Method___create_objects_auto_deactivated_payment_method', |
|
318 | + $payment_method |
|
319 | + ); |
|
320 | + new PersistentAdminNotice( |
|
321 | + 'auto-deactivated-' . $payment_method->type(), |
|
322 | + sprintf( |
|
323 | + __( |
|
324 | + 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
|
325 | + 'event_espresso' |
|
326 | + ), |
|
327 | + $payment_method->admin_name(), |
|
328 | + '<br />', |
|
329 | + '<a href="' . admin_url('plugins.php') . '">', |
|
330 | + '</a>' |
|
331 | + ), |
|
332 | + true |
|
333 | + ); |
|
334 | + } |
|
335 | + } |
|
336 | + return $usable_payment_methods; |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * Gets all the payment methods which can be used for transaction |
|
343 | + * (according to the relations between payment methods and events, and |
|
344 | + * the currencies used for the transaction and their relation to payment methods) |
|
345 | + * @param EE_Transaction $transaction |
|
346 | + * @param string $scope @see EEM_Payment_Method::get_all_for_events |
|
347 | + * @return EE_Payment_Method[] |
|
348 | + */ |
|
349 | + public function get_all_for_transaction($transaction, $scope) |
|
350 | + { |
|
351 | + // give addons a chance to override what payment methods are chosen based on the transaction |
|
352 | + return apply_filters( |
|
353 | + 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
|
354 | + $this->get_all_active($scope, array( 'group_by' => 'PMD_type' )), |
|
355 | + $transaction, |
|
356 | + $scope |
|
357 | + ); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Returns the payment method used for the last payment made for a registration. |
|
363 | + * |
|
364 | + * Note: if an offline payment method was selected on the related transaction then this will have no payment methods returned. |
|
365 | + * It will ONLY return a payment method for a PAYMENT recorded against the registration. |
|
366 | + * |
|
367 | + * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
|
368 | + * @return EE_Payment|null |
|
369 | + */ |
|
370 | + public function get_last_used_for_registration($registration_or_reg_id) |
|
371 | + { |
|
372 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
373 | + |
|
374 | + $query_params = array( |
|
375 | + 0 => array( |
|
376 | + 'Payment.Registration.REG_ID' => $registration_id, |
|
377 | + ), |
|
378 | + 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
379 | + ); |
|
380 | + return $this->get_one($query_params); |
|
381 | + } |
|
382 | 382 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * instantiate a new price object with blank/empty properties |
67 | 67 | * |
68 | 68 | * @access public |
69 | - * @return mixed array on success, FALSE on fail |
|
69 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
70 | 70 | */ |
71 | 71 | public function get_new_price() |
72 | 72 | { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @access public |
98 | 98 | * @param int $EVT_ID |
99 | - * @return array on success |
|
99 | + * @return EE_Base_Class[] on success |
|
100 | 100 | */ |
101 | 101 | public function get_all_event_prices($EVT_ID = 0) |
102 | 102 | { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @access public |
224 | 224 | * @param \EE_Price $price_a |
225 | 225 | * @param \EE_Price $price_b |
226 | - * @return bool false on fail |
|
226 | + * @return integer false on fail |
|
227 | 227 | */ |
228 | 228 | public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b) |
229 | 229 | { |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @access public |
242 | 242 | * @param \EE_Price $price_a |
243 | 243 | * @param \EE_Price $price_b |
244 | - * @return bool false on fail |
|
244 | + * @return integer false on fail |
|
245 | 245 | */ |
246 | 246 | public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b) |
247 | 247 | { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @access public |
260 | 260 | * @param int $type - PRT_ID |
261 | - * @return boolean false on fail |
|
261 | + * @return EE_Base_Class[] false on fail |
|
262 | 262 | */ |
263 | 263 | public function get_all_prices_that_are_type($type = 0) |
264 | 264 | { |
@@ -10,279 +10,279 @@ |
||
10 | 10 | class EEM_Price extends EEM_Soft_Delete_Base |
11 | 11 | { |
12 | 12 | |
13 | - // private instance of the EEM_Price object |
|
14 | - protected static $_instance = null; |
|
15 | - |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * private constructor to prevent direct creation |
|
20 | - * @Constructor |
|
21 | - * @access protected |
|
22 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
23 | - * @return EEM_Price |
|
24 | - */ |
|
25 | - protected function __construct($timezone) |
|
26 | - { |
|
27 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
28 | - $this->singular_item = __('Price', 'event_espresso'); |
|
29 | - $this->plural_item = __('Prices', 'event_espresso'); |
|
30 | - |
|
31 | - $this->_tables = array( |
|
32 | - 'Price'=>new EE_Primary_Table('esp_price', 'PRC_ID') |
|
33 | - ); |
|
34 | - $this->_fields = array( |
|
35 | - 'Price'=> array( |
|
36 | - 'PRC_ID'=>new EE_Primary_Key_Int_Field('PRC_ID', 'Price ID'), |
|
37 | - 'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false, null, 'Price_Type'), |
|
38 | - 'PRC_amount'=>new EE_Money_Field('PRC_amount', 'Price Amount', false, 0), |
|
39 | - 'PRC_name'=>new EE_Plain_Text_Field('PRC_name', 'Name of Price', false, ''), |
|
40 | - 'PRC_desc'=>new EE_Post_Content_Field('PRC_desc', 'Price Description', false, ''), |
|
41 | - 'PRC_is_default'=>new EE_Boolean_Field('PRC_is_default', 'Flag indicating whether price is a default price', false, false), |
|
42 | - 'PRC_overrides'=>new EE_Integer_Field('PRC_overrides', 'Price ID for a global Price that will be overridden by this Price ( for replacing default prices )', true, 0), |
|
43 | - 'PRC_order'=>new EE_Integer_Field('PRC_order', 'Order of Application of Price (lower numbers apply first?)', false, 1), |
|
44 | - 'PRC_deleted'=>new EE_Trashed_Flag_Field('PRC_deleted', 'Flag Indicating if this has been deleted or not', false, false), |
|
45 | - 'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'), true, 0), |
|
46 | - 'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), false), |
|
47 | - ) |
|
48 | - ); |
|
49 | - $this->_model_relations = array( |
|
50 | - 'Ticket'=>new EE_HABTM_Relation('Ticket_Price'), |
|
51 | - 'Price_Type'=>new EE_Belongs_To_Relation(), |
|
52 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
53 | - ); |
|
54 | - // this model is generally available for reading |
|
55 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event'); |
|
56 | - // account for default tickets in the caps |
|
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
58 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
60 | - parent::__construct($timezone); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * instantiate a new price object with blank/empty properties |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @return mixed array on success, FALSE on fail |
|
70 | - */ |
|
71 | - public function get_new_price() |
|
72 | - { |
|
73 | - return $this->create_default_object(); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * retrieve ALL prices from db |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return EE_PRice[] |
|
85 | - */ |
|
86 | - public function get_all_prices() |
|
87 | - { |
|
88 | - // retrieve all prices |
|
89 | - return $this->get_all(array('order_by'=>array('PRC_amount'=>'ASC'))); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * retrieve all active prices for a particular event |
|
96 | - * |
|
97 | - * @access public |
|
98 | - * @param int $EVT_ID |
|
99 | - * @return array on success |
|
100 | - */ |
|
101 | - public function get_all_event_prices($EVT_ID = 0) |
|
102 | - { |
|
103 | - return $this->get_all(array( |
|
104 | - array( |
|
105 | - 'EVT_ID'=>$EVT_ID, |
|
106 | - 'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax) |
|
107 | - ), |
|
108 | - 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
109 | - )); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event |
|
115 | - * |
|
116 | - * @access public |
|
117 | - * @param boolean $count return count |
|
118 | - * @return array on success |
|
119 | - * @return boolean false on fail |
|
120 | - */ |
|
121 | - public function get_all_default_prices($count = false) |
|
122 | - { |
|
123 | - $_where = array( |
|
124 | - 'Price_Type.PBT_ID'=>array('!=',4), |
|
125 | - 'PRC_deleted' => 0, |
|
126 | - 'PRC_is_default' => 1 |
|
127 | - ); |
|
128 | - $_query_params = array( |
|
129 | - $_where, |
|
130 | - 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
131 | - ); |
|
132 | - return $count ? $this->count(array($_where)) : $this->get_all($_query_params); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * retrieve all prices that are taxes |
|
146 | - * |
|
147 | - * @access public |
|
148 | - * @return array on success |
|
149 | - * @return array top-level keys are the price's order and their values are an array, |
|
150 | - * next-level keys are the price's ID, and their values are EE_Price objects |
|
151 | - */ |
|
152 | - public function get_all_prices_that_are_taxes() |
|
153 | - { |
|
154 | - $taxes = array(); |
|
155 | - $all_taxes = $this->get_all(array( |
|
156 | - array( 'Price_Type.PBT_ID'=> EEM_Price_Type::base_type_tax ), |
|
157 | - 'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' ) |
|
158 | - )); |
|
159 | - foreach ($all_taxes as $tax) { |
|
160 | - if ($tax instanceof EE_Price) { |
|
161 | - $taxes[ $tax->order() ][ $tax->ID() ] = $tax; |
|
162 | - } |
|
163 | - } |
|
164 | - return $taxes; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * retrieve all prices for an ticket plus default global prices, but not taxes |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @param int $TKT_ID the id of the event. If not included then we assume that this is a new ticket. |
|
176 | - * @return boolean false on fail |
|
177 | - */ |
|
178 | - public function get_all_ticket_prices_for_admin($TKT_ID = 0) |
|
179 | - { |
|
180 | - $array_of_price_objects = array(); |
|
181 | - if (empty($TKT_ID)) { |
|
182 | - // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active |
|
183 | - // return that list |
|
184 | - $default_prices = $this->get_all_default_prices(); |
|
185 | - |
|
186 | - if ($default_prices) { |
|
187 | - foreach ($default_prices as $price) { |
|
188 | - if ($price instanceof EE_Price) { |
|
189 | - $array_of_price_objects[ $price->type() ][] = $price; |
|
190 | - } |
|
191 | - } |
|
192 | - return $array_of_price_objects; |
|
193 | - } else { |
|
194 | - return array(); |
|
195 | - } |
|
196 | - } else { |
|
197 | - $ticket_prices = $this->get_all(array( |
|
198 | - array( |
|
199 | - 'TKT_ID'=>$TKT_ID, |
|
200 | - 'PRC_deleted' => 0 |
|
201 | - ), |
|
202 | - 'order_by'=> array('PRC_order' => 'ASC') |
|
203 | - )); |
|
204 | - } |
|
205 | - |
|
206 | - if (!empty($ticket_prices)) { |
|
207 | - foreach ($ticket_prices as $price) { |
|
208 | - if ($price instanceof EE_Price) { |
|
209 | - $array_of_price_objects[ $price->type() ][] = $price; |
|
210 | - } |
|
211 | - } |
|
212 | - return $array_of_price_objects; |
|
213 | - } else { |
|
214 | - return false; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * _sort_event_prices_by_type |
|
222 | - * |
|
223 | - * @access public |
|
224 | - * @param \EE_Price $price_a |
|
225 | - * @param \EE_Price $price_b |
|
226 | - * @return bool false on fail |
|
227 | - */ |
|
228 | - public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b) |
|
229 | - { |
|
230 | - if ($price_a->type_obj()->order() == $price_b->type_obj()->order()) { |
|
231 | - return $this->_sort_event_prices_by_order($price_a, $price_b); |
|
232 | - } |
|
233 | - return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * _sort_event_prices_by_order |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param \EE_Price $price_a |
|
243 | - * @param \EE_Price $price_b |
|
244 | - * @return bool false on fail |
|
245 | - */ |
|
246 | - public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b) |
|
247 | - { |
|
248 | - if ($price_a->order() == $price_b->order()) { |
|
249 | - return 0; |
|
250 | - } |
|
251 | - return $price_a->order() < $price_b->order() ? -1 : 1; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * get all prices of a specific type |
|
258 | - * |
|
259 | - * @access public |
|
260 | - * @param int $type - PRT_ID |
|
261 | - * @return boolean false on fail |
|
262 | - */ |
|
263 | - public function get_all_prices_that_are_type($type = 0) |
|
264 | - { |
|
265 | - return $this->get_all(array( |
|
266 | - array( |
|
267 | - 'PRT_ID'=>$type |
|
268 | - ), |
|
269 | - 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
270 | - )); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Returns an array of the normal 'order_by' query parameter provided to the get_all query. |
|
277 | - * Of course you don't have to use it, but this is the order we usually want to sort prices by |
|
278 | - * @return array which can be used like so: $this->get_all(array(array(...where stuff...),'order_by'=>$this->_order_by_array_for_get_all_method())); |
|
279 | - */ |
|
280 | - public function _order_by_array_for_get_all_method() |
|
281 | - { |
|
282 | - return array( |
|
283 | - 'PRC_order'=>'ASC', |
|
284 | - 'Price_Type.PRT_order'=>'ASC', |
|
285 | - 'PRC_ID'=>'ASC' |
|
286 | - ); |
|
287 | - } |
|
13 | + // private instance of the EEM_Price object |
|
14 | + protected static $_instance = null; |
|
15 | + |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * private constructor to prevent direct creation |
|
20 | + * @Constructor |
|
21 | + * @access protected |
|
22 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
23 | + * @return EEM_Price |
|
24 | + */ |
|
25 | + protected function __construct($timezone) |
|
26 | + { |
|
27 | + require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
28 | + $this->singular_item = __('Price', 'event_espresso'); |
|
29 | + $this->plural_item = __('Prices', 'event_espresso'); |
|
30 | + |
|
31 | + $this->_tables = array( |
|
32 | + 'Price'=>new EE_Primary_Table('esp_price', 'PRC_ID') |
|
33 | + ); |
|
34 | + $this->_fields = array( |
|
35 | + 'Price'=> array( |
|
36 | + 'PRC_ID'=>new EE_Primary_Key_Int_Field('PRC_ID', 'Price ID'), |
|
37 | + 'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false, null, 'Price_Type'), |
|
38 | + 'PRC_amount'=>new EE_Money_Field('PRC_amount', 'Price Amount', false, 0), |
|
39 | + 'PRC_name'=>new EE_Plain_Text_Field('PRC_name', 'Name of Price', false, ''), |
|
40 | + 'PRC_desc'=>new EE_Post_Content_Field('PRC_desc', 'Price Description', false, ''), |
|
41 | + 'PRC_is_default'=>new EE_Boolean_Field('PRC_is_default', 'Flag indicating whether price is a default price', false, false), |
|
42 | + 'PRC_overrides'=>new EE_Integer_Field('PRC_overrides', 'Price ID for a global Price that will be overridden by this Price ( for replacing default prices )', true, 0), |
|
43 | + 'PRC_order'=>new EE_Integer_Field('PRC_order', 'Order of Application of Price (lower numbers apply first?)', false, 1), |
|
44 | + 'PRC_deleted'=>new EE_Trashed_Flag_Field('PRC_deleted', 'Flag Indicating if this has been deleted or not', false, false), |
|
45 | + 'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'), true, 0), |
|
46 | + 'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), false), |
|
47 | + ) |
|
48 | + ); |
|
49 | + $this->_model_relations = array( |
|
50 | + 'Ticket'=>new EE_HABTM_Relation('Ticket_Price'), |
|
51 | + 'Price_Type'=>new EE_Belongs_To_Relation(), |
|
52 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
53 | + ); |
|
54 | + // this model is generally available for reading |
|
55 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event'); |
|
56 | + // account for default tickets in the caps |
|
57 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
58 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
59 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
60 | + parent::__construct($timezone); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * instantiate a new price object with blank/empty properties |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @return mixed array on success, FALSE on fail |
|
70 | + */ |
|
71 | + public function get_new_price() |
|
72 | + { |
|
73 | + return $this->create_default_object(); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * retrieve ALL prices from db |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return EE_PRice[] |
|
85 | + */ |
|
86 | + public function get_all_prices() |
|
87 | + { |
|
88 | + // retrieve all prices |
|
89 | + return $this->get_all(array('order_by'=>array('PRC_amount'=>'ASC'))); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * retrieve all active prices for a particular event |
|
96 | + * |
|
97 | + * @access public |
|
98 | + * @param int $EVT_ID |
|
99 | + * @return array on success |
|
100 | + */ |
|
101 | + public function get_all_event_prices($EVT_ID = 0) |
|
102 | + { |
|
103 | + return $this->get_all(array( |
|
104 | + array( |
|
105 | + 'EVT_ID'=>$EVT_ID, |
|
106 | + 'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax) |
|
107 | + ), |
|
108 | + 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
109 | + )); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event |
|
115 | + * |
|
116 | + * @access public |
|
117 | + * @param boolean $count return count |
|
118 | + * @return array on success |
|
119 | + * @return boolean false on fail |
|
120 | + */ |
|
121 | + public function get_all_default_prices($count = false) |
|
122 | + { |
|
123 | + $_where = array( |
|
124 | + 'Price_Type.PBT_ID'=>array('!=',4), |
|
125 | + 'PRC_deleted' => 0, |
|
126 | + 'PRC_is_default' => 1 |
|
127 | + ); |
|
128 | + $_query_params = array( |
|
129 | + $_where, |
|
130 | + 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
131 | + ); |
|
132 | + return $count ? $this->count(array($_where)) : $this->get_all($_query_params); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * retrieve all prices that are taxes |
|
146 | + * |
|
147 | + * @access public |
|
148 | + * @return array on success |
|
149 | + * @return array top-level keys are the price's order and their values are an array, |
|
150 | + * next-level keys are the price's ID, and their values are EE_Price objects |
|
151 | + */ |
|
152 | + public function get_all_prices_that_are_taxes() |
|
153 | + { |
|
154 | + $taxes = array(); |
|
155 | + $all_taxes = $this->get_all(array( |
|
156 | + array( 'Price_Type.PBT_ID'=> EEM_Price_Type::base_type_tax ), |
|
157 | + 'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' ) |
|
158 | + )); |
|
159 | + foreach ($all_taxes as $tax) { |
|
160 | + if ($tax instanceof EE_Price) { |
|
161 | + $taxes[ $tax->order() ][ $tax->ID() ] = $tax; |
|
162 | + } |
|
163 | + } |
|
164 | + return $taxes; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * retrieve all prices for an ticket plus default global prices, but not taxes |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @param int $TKT_ID the id of the event. If not included then we assume that this is a new ticket. |
|
176 | + * @return boolean false on fail |
|
177 | + */ |
|
178 | + public function get_all_ticket_prices_for_admin($TKT_ID = 0) |
|
179 | + { |
|
180 | + $array_of_price_objects = array(); |
|
181 | + if (empty($TKT_ID)) { |
|
182 | + // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active |
|
183 | + // return that list |
|
184 | + $default_prices = $this->get_all_default_prices(); |
|
185 | + |
|
186 | + if ($default_prices) { |
|
187 | + foreach ($default_prices as $price) { |
|
188 | + if ($price instanceof EE_Price) { |
|
189 | + $array_of_price_objects[ $price->type() ][] = $price; |
|
190 | + } |
|
191 | + } |
|
192 | + return $array_of_price_objects; |
|
193 | + } else { |
|
194 | + return array(); |
|
195 | + } |
|
196 | + } else { |
|
197 | + $ticket_prices = $this->get_all(array( |
|
198 | + array( |
|
199 | + 'TKT_ID'=>$TKT_ID, |
|
200 | + 'PRC_deleted' => 0 |
|
201 | + ), |
|
202 | + 'order_by'=> array('PRC_order' => 'ASC') |
|
203 | + )); |
|
204 | + } |
|
205 | + |
|
206 | + if (!empty($ticket_prices)) { |
|
207 | + foreach ($ticket_prices as $price) { |
|
208 | + if ($price instanceof EE_Price) { |
|
209 | + $array_of_price_objects[ $price->type() ][] = $price; |
|
210 | + } |
|
211 | + } |
|
212 | + return $array_of_price_objects; |
|
213 | + } else { |
|
214 | + return false; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * _sort_event_prices_by_type |
|
222 | + * |
|
223 | + * @access public |
|
224 | + * @param \EE_Price $price_a |
|
225 | + * @param \EE_Price $price_b |
|
226 | + * @return bool false on fail |
|
227 | + */ |
|
228 | + public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b) |
|
229 | + { |
|
230 | + if ($price_a->type_obj()->order() == $price_b->type_obj()->order()) { |
|
231 | + return $this->_sort_event_prices_by_order($price_a, $price_b); |
|
232 | + } |
|
233 | + return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * _sort_event_prices_by_order |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param \EE_Price $price_a |
|
243 | + * @param \EE_Price $price_b |
|
244 | + * @return bool false on fail |
|
245 | + */ |
|
246 | + public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b) |
|
247 | + { |
|
248 | + if ($price_a->order() == $price_b->order()) { |
|
249 | + return 0; |
|
250 | + } |
|
251 | + return $price_a->order() < $price_b->order() ? -1 : 1; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * get all prices of a specific type |
|
258 | + * |
|
259 | + * @access public |
|
260 | + * @param int $type - PRT_ID |
|
261 | + * @return boolean false on fail |
|
262 | + */ |
|
263 | + public function get_all_prices_that_are_type($type = 0) |
|
264 | + { |
|
265 | + return $this->get_all(array( |
|
266 | + array( |
|
267 | + 'PRT_ID'=>$type |
|
268 | + ), |
|
269 | + 'order_by'=>$this->_order_by_array_for_get_all_method() |
|
270 | + )); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Returns an array of the normal 'order_by' query parameter provided to the get_all query. |
|
277 | + * Of course you don't have to use it, but this is the order we usually want to sort prices by |
|
278 | + * @return array which can be used like so: $this->get_all(array(array(...where stuff...),'order_by'=>$this->_order_by_array_for_get_all_method())); |
|
279 | + */ |
|
280 | + public function _order_by_array_for_get_all_method() |
|
281 | + { |
|
282 | + return array( |
|
283 | + 'PRC_order'=>'ASC', |
|
284 | + 'Price_Type.PRT_order'=>'ASC', |
|
285 | + 'PRC_ID'=>'ASC' |
|
286 | + ); |
|
287 | + } |
|
288 | 288 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected function __construct($timezone) |
26 | 26 | { |
27 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
27 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
28 | 28 | $this->singular_item = __('Price', 'event_espresso'); |
29 | 29 | $this->plural_item = __('Prices', 'event_espresso'); |
30 | 30 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | 'WP_User' => new EE_Belongs_To_Relation(), |
53 | 53 | ); |
54 | 54 | // this model is generally available for reading |
55 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event'); |
|
55 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('PRC_is_default', 'Ticket.Datetime.Event'); |
|
56 | 56 | // account for default tickets in the caps |
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
58 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
58 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('PRC_is_default', 'Ticket.Datetime.Event'); |
|
60 | 60 | parent::__construct($timezone); |
61 | 61 | } |
62 | 62 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $this->get_all(array( |
104 | 104 | array( |
105 | 105 | 'EVT_ID'=>$EVT_ID, |
106 | - 'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax) |
|
106 | + 'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax) |
|
107 | 107 | ), |
108 | 108 | 'order_by'=>$this->_order_by_array_for_get_all_method() |
109 | 109 | )); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function get_all_default_prices($count = false) |
122 | 122 | { |
123 | 123 | $_where = array( |
124 | - 'Price_Type.PBT_ID'=>array('!=',4), |
|
124 | + 'Price_Type.PBT_ID'=>array('!=', 4), |
|
125 | 125 | 'PRC_deleted' => 0, |
126 | 126 | 'PRC_is_default' => 1 |
127 | 127 | ); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | { |
154 | 154 | $taxes = array(); |
155 | 155 | $all_taxes = $this->get_all(array( |
156 | - array( 'Price_Type.PBT_ID'=> EEM_Price_Type::base_type_tax ), |
|
157 | - 'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' ) |
|
156 | + array('Price_Type.PBT_ID'=> EEM_Price_Type::base_type_tax), |
|
157 | + 'order_by' => array('Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC') |
|
158 | 158 | )); |
159 | 159 | foreach ($all_taxes as $tax) { |
160 | 160 | if ($tax instanceof EE_Price) { |
161 | - $taxes[ $tax->order() ][ $tax->ID() ] = $tax; |
|
161 | + $taxes[$tax->order()][$tax->ID()] = $tax; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | return $taxes; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | if ($default_prices) { |
187 | 187 | foreach ($default_prices as $price) { |
188 | 188 | if ($price instanceof EE_Price) { |
189 | - $array_of_price_objects[ $price->type() ][] = $price; |
|
189 | + $array_of_price_objects[$price->type()][] = $price; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | return $array_of_price_objects; |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | )); |
204 | 204 | } |
205 | 205 | |
206 | - if (!empty($ticket_prices)) { |
|
206 | + if ( ! empty($ticket_prices)) { |
|
207 | 207 | foreach ($ticket_prices as $price) { |
208 | 208 | if ($price instanceof EE_Price) { |
209 | - $array_of_price_objects[ $price->type() ][] = $price; |
|
209 | + $array_of_price_objects[$price->type()][] = $price; |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | return $array_of_price_objects; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * return an array of Base types. Keys are INTs which are used in the database, |
29 | 29 | * values are text-representations of the base type. |
30 | - * @return array |
|
30 | + * @return integer |
|
31 | 31 | */ |
32 | 32 | public function get_base_types() |
33 | 33 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * instantiate a new price type object with blank/empty properties |
108 | 108 | * |
109 | 109 | * @access public |
110 | - * @return mixed array on success, FALSE on fail |
|
110 | + * @return EE_Price_Type array on success, FALSE on fail |
|
111 | 111 | */ |
112 | 112 | public function get_new_price_type() |
113 | 113 | { |
@@ -11,108 +11,108 @@ discard block |
||
11 | 11 | class EEM_Price_Type extends EEM_Soft_Delete_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Price Type object |
|
15 | - protected static $_instance = null; |
|
16 | - // An array of the price type objects |
|
17 | - public $type = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Price Base types |
|
21 | - * |
|
22 | - * @access private |
|
23 | - * @var int |
|
24 | - */ |
|
25 | - public $base_types = null; |
|
26 | - |
|
27 | - /** |
|
28 | - * return an array of Base types. Keys are INTs which are used in the database, |
|
29 | - * values are text-representations of the base type. |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function get_base_types() |
|
33 | - { |
|
34 | - return $this->base_types; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Gets the name of the base |
|
39 | - * @param type $base_type_int |
|
40 | - * @return type |
|
41 | - */ |
|
42 | - public function get_base_type_name($base_type_int) |
|
43 | - { |
|
44 | - return $this->base_types[ $base_type_int ]; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * constants for price base types. In the DB, we decided to store the price base type |
|
49 | - * as an integer. So, to avoid just having magic numbers everwhere (eg, querying for |
|
50 | - * all price types with PBT_ID = 2), we define these constants, to make code more understandable. |
|
51 | - * So, as an example, to query for all price types that are a tax, we'd do |
|
52 | - * EEM_PRice_Type::instance()->get_all(array(array('PBT_ID'=>EEM_Price_Type::base_type_tax))) |
|
53 | - * instead of |
|
54 | - * EEM_Price_Type::instance()->get_all(array(array('PBT_ID'=>2))) |
|
55 | - * Although the 2nd is shorter, it's much less obvious what it's doing. Also, should these magic IDs ever |
|
56 | - * change, we can continue to use the constant, by simply change its value. |
|
57 | - */ |
|
58 | - const base_type_base_price = 1; |
|
59 | - const base_type_discount = 2; |
|
60 | - const base_type_surcharge = 3; |
|
61 | - const base_type_tax = 4; |
|
62 | - /** |
|
63 | - * private constructor to prevent direct creation |
|
64 | - * @Constructor |
|
65 | - * @access protected |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - protected function __construct($timezone = null) |
|
69 | - { |
|
70 | - $this->base_types = array( |
|
71 | - EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'), |
|
72 | - EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'), |
|
73 | - EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'), |
|
74 | - EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') ); |
|
75 | - $this->singular_item = __('Price Type', 'event_espresso'); |
|
76 | - $this->plural_item = __('Price Types', 'event_espresso'); |
|
77 | - |
|
78 | - $this->_tables = array( |
|
79 | - 'Price_Type'=>new EE_Primary_Table('esp_price_type', 'PRT_ID') |
|
80 | - ); |
|
81 | - $this->_fields = array( |
|
82 | - 'Price_Type'=>array( |
|
83 | - 'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')), |
|
84 | - 'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''), |
|
85 | - 'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types), |
|
86 | - 'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false), |
|
87 | - 'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0), |
|
88 | - 'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false), |
|
89 | - 'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), false), |
|
90 | - ) |
|
91 | - ); |
|
92 | - $this->_model_relations = array( |
|
93 | - 'Price'=>new EE_Has_Many_Relation(), |
|
94 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
95 | - ); |
|
96 | - // this model is generally available for reading |
|
97 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
98 | - // all price types are "default" in terms of capability names |
|
99 | - $this->_caps_slug = 'default_price_types'; |
|
100 | - parent::__construct($timezone); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * instantiate a new price type object with blank/empty properties |
|
108 | - * |
|
109 | - * @access public |
|
110 | - * @return mixed array on success, FALSE on fail |
|
111 | - */ |
|
112 | - public function get_new_price_type() |
|
113 | - { |
|
114 | - return EE_Price_Type::new_instance(); |
|
115 | - } |
|
14 | + // private instance of the Price Type object |
|
15 | + protected static $_instance = null; |
|
16 | + // An array of the price type objects |
|
17 | + public $type = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Price Base types |
|
21 | + * |
|
22 | + * @access private |
|
23 | + * @var int |
|
24 | + */ |
|
25 | + public $base_types = null; |
|
26 | + |
|
27 | + /** |
|
28 | + * return an array of Base types. Keys are INTs which are used in the database, |
|
29 | + * values are text-representations of the base type. |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function get_base_types() |
|
33 | + { |
|
34 | + return $this->base_types; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Gets the name of the base |
|
39 | + * @param type $base_type_int |
|
40 | + * @return type |
|
41 | + */ |
|
42 | + public function get_base_type_name($base_type_int) |
|
43 | + { |
|
44 | + return $this->base_types[ $base_type_int ]; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * constants for price base types. In the DB, we decided to store the price base type |
|
49 | + * as an integer. So, to avoid just having magic numbers everwhere (eg, querying for |
|
50 | + * all price types with PBT_ID = 2), we define these constants, to make code more understandable. |
|
51 | + * So, as an example, to query for all price types that are a tax, we'd do |
|
52 | + * EEM_PRice_Type::instance()->get_all(array(array('PBT_ID'=>EEM_Price_Type::base_type_tax))) |
|
53 | + * instead of |
|
54 | + * EEM_Price_Type::instance()->get_all(array(array('PBT_ID'=>2))) |
|
55 | + * Although the 2nd is shorter, it's much less obvious what it's doing. Also, should these magic IDs ever |
|
56 | + * change, we can continue to use the constant, by simply change its value. |
|
57 | + */ |
|
58 | + const base_type_base_price = 1; |
|
59 | + const base_type_discount = 2; |
|
60 | + const base_type_surcharge = 3; |
|
61 | + const base_type_tax = 4; |
|
62 | + /** |
|
63 | + * private constructor to prevent direct creation |
|
64 | + * @Constructor |
|
65 | + * @access protected |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + protected function __construct($timezone = null) |
|
69 | + { |
|
70 | + $this->base_types = array( |
|
71 | + EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'), |
|
72 | + EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'), |
|
73 | + EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'), |
|
74 | + EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') ); |
|
75 | + $this->singular_item = __('Price Type', 'event_espresso'); |
|
76 | + $this->plural_item = __('Price Types', 'event_espresso'); |
|
77 | + |
|
78 | + $this->_tables = array( |
|
79 | + 'Price_Type'=>new EE_Primary_Table('esp_price_type', 'PRT_ID') |
|
80 | + ); |
|
81 | + $this->_fields = array( |
|
82 | + 'Price_Type'=>array( |
|
83 | + 'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')), |
|
84 | + 'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''), |
|
85 | + 'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types), |
|
86 | + 'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false), |
|
87 | + 'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0), |
|
88 | + 'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false), |
|
89 | + 'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), false), |
|
90 | + ) |
|
91 | + ); |
|
92 | + $this->_model_relations = array( |
|
93 | + 'Price'=>new EE_Has_Many_Relation(), |
|
94 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
95 | + ); |
|
96 | + // this model is generally available for reading |
|
97 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
98 | + // all price types are "default" in terms of capability names |
|
99 | + $this->_caps_slug = 'default_price_types'; |
|
100 | + parent::__construct($timezone); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * instantiate a new price type object with blank/empty properties |
|
108 | + * |
|
109 | + * @access public |
|
110 | + * @return mixed array on success, FALSE on fail |
|
111 | + */ |
|
112 | + public function get_new_price_type() |
|
113 | + { |
|
114 | + return EE_Price_Type::new_instance(); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
@@ -131,33 +131,33 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param type $query_params |
133 | 133 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
134 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
135 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
134 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
135 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
136 | 136 | * @return boolean |
137 | 137 | */ |
138 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
139 | - { |
|
138 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
139 | + { |
|
140 | 140 | |
141 | - $would_be_deleted_price_types = $this->get_all_deleted_and_undeleted($query_params); |
|
142 | - $would_be_deleted_price_type_ids = array_keys($would_be_deleted_price_types); |
|
141 | + $would_be_deleted_price_types = $this->get_all_deleted_and_undeleted($query_params); |
|
142 | + $would_be_deleted_price_type_ids = array_keys($would_be_deleted_price_types); |
|
143 | 143 | |
144 | - $ID = $query_params[0][ $this->get_primary_key_field()->get_name() ]; |
|
144 | + $ID = $query_params[0][ $this->get_primary_key_field()->get_name() ]; |
|
145 | 145 | |
146 | - // check if any prices use this price type |
|
147 | - $prc_query_params = array(array('PRT_ID'=>array('IN',$would_be_deleted_price_type_ids))); |
|
148 | - if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) { |
|
149 | - $prices_names_and_ids = array(); |
|
150 | - foreach ($prices as $price) { |
|
151 | - /* @var $price EE_Price */ |
|
152 | - $prices_names_and_ids[] = $price->name()."(".$price->ID().")"; |
|
153 | - } |
|
154 | - $msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type. If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids)); |
|
155 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
156 | - return false; |
|
157 | - } |
|
146 | + // check if any prices use this price type |
|
147 | + $prc_query_params = array(array('PRT_ID'=>array('IN',$would_be_deleted_price_type_ids))); |
|
148 | + if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) { |
|
149 | + $prices_names_and_ids = array(); |
|
150 | + foreach ($prices as $price) { |
|
151 | + /* @var $price EE_Price */ |
|
152 | + $prices_names_and_ids[] = $price->name()."(".$price->ID().")"; |
|
153 | + } |
|
154 | + $msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type. If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids)); |
|
155 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
156 | + return false; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | 160 | |
161 | - return parent::delete_permanently($query_params); |
|
162 | - } |
|
161 | + return parent::delete_permanently($query_params); |
|
162 | + } |
|
163 | 163 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function get_base_type_name($base_type_int) |
43 | 43 | { |
44 | - return $this->base_types[ $base_type_int ]; |
|
44 | + return $this->base_types[$base_type_int]; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'WP_User' => new EE_Belongs_To_Relation(), |
95 | 95 | ); |
96 | 96 | // this model is generally available for reading |
97 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
97 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
98 | 98 | // all price types are "default" in terms of capability names |
99 | 99 | $this->_caps_slug = 'default_price_types'; |
100 | 100 | parent::__construct($timezone); |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $would_be_deleted_price_types = $this->get_all_deleted_and_undeleted($query_params); |
142 | 142 | $would_be_deleted_price_type_ids = array_keys($would_be_deleted_price_types); |
143 | 143 | |
144 | - $ID = $query_params[0][ $this->get_primary_key_field()->get_name() ]; |
|
144 | + $ID = $query_params[0][$this->get_primary_key_field()->get_name()]; |
|
145 | 145 | |
146 | 146 | // check if any prices use this price type |
147 | - $prc_query_params = array(array('PRT_ID'=>array('IN',$would_be_deleted_price_type_ids))); |
|
147 | + $prc_query_params = array(array('PRT_ID'=>array('IN', $would_be_deleted_price_type_ids))); |
|
148 | 148 | if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) { |
149 | 149 | $prices_names_and_ids = array(); |
150 | 150 | foreach ($prices as $price) { |
@@ -15,8 +15,6 @@ discard block |
||
15 | 15 | * This function is a singleton method used to instantiate the EEM_Attendee object |
16 | 16 | * |
17 | 17 | * @access public |
18 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
19 | - * @return EEM_System_Status |
|
20 | 18 | */ |
21 | 19 | public static function instance() |
22 | 20 | { |
@@ -157,7 +155,7 @@ discard block |
||
157 | 155 | |
158 | 156 | /** |
159 | 157 | * |
160 | - * @return array like EE_Config class |
|
158 | + * @return EE_Config like EE_Config class |
|
161 | 159 | */ |
162 | 160 | public function get_ee_config() |
163 | 161 | { |
@@ -214,7 +212,7 @@ discard block |
||
214 | 212 | |
215 | 213 | /** |
216 | 214 | * Checks if site responds ot HTTPS |
217 | - * @return boolean |
|
215 | + * @return string |
|
218 | 216 | */ |
219 | 217 | public function get_https_enabled() |
220 | 218 | { |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | $active_plugins = array_map('strtolower', $active_plugins); |
94 | 94 | $plugin_info = array(); |
95 | 95 | foreach ($active_plugins as $plugin) { |
96 | - $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
96 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
97 | 97 | |
98 | - $plugin_info[ $plugin ] = $plugin_data; |
|
98 | + $plugin_info[$plugin] = $plugin_data; |
|
99 | 99 | } |
100 | 100 | return $plugin_info; |
101 | 101 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | { |
109 | 109 | $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
110 | 110 | if ($wp_memory_int < 67108864) { |
111 | - $wp_memory_to_display = '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"') . '</mark>'; |
|
111 | + $wp_memory_to_display = '<mark class="error">'.sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"').'</mark>'; |
|
112 | 112 | } else { |
113 | - $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>'; |
|
113 | + $wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>'; |
|
114 | 114 | } |
115 | 115 | return array( |
116 | 116 | 'name'=>get_bloginfo('name', 'display'), |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
150 | 150 | $presentable_migration_scripts = array(); |
151 | 151 | foreach ($options as $option_array) { |
152 | - $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']); |
|
152 | + $presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name'])] = maybe_unserialize($option_array['option_value']); |
|
153 | 153 | } |
154 | 154 | return $presentable_migration_scripts; |
155 | 155 | // return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran(); |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | |
176 | 176 | $pi = preg_replace( |
177 | 177 | array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
178 | - '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
178 | + '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
179 | 179 | "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
180 | 180 | '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
181 | 181 | .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
182 | 182 | '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
183 | 183 | '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
184 | 184 | "# +#", '#<tr>#', '#</tr>#'), |
185 | - array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
185 | + array('$1', '', '', '', '</$1>'."\n", '<', ' ', ' ', ' ', '', ' ', |
|
186 | 186 | '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
187 | 187 | "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
188 | 188 | '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
189 | - '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
189 | + '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n". |
|
190 | 190 | '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
191 | 191 | ob_get_clean() |
192 | 192 | ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | foreach ($askapache as $m) { |
207 | 207 | $m2 = isset($m[2]) ? $m[2] : null; |
208 | 208 | } |
209 | - $pi[ $n ][ $m[1] ]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m, 2); |
|
209 | + $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | return $pi; |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function get_wp_maintenance_mode() |
237 | 237 | { |
238 | - $opened = file_exists(ABSPATH . '.maintenance'); |
|
239 | - return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso') ; |
|
238 | + $opened = file_exists(ABSPATH.'.maintenance'); |
|
239 | + return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso'); |
|
240 | 240 | } |
241 | 241 | /** |
242 | 242 | * Whether or not logging is enabled |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function get_logging_enabled() |
246 | 246 | { |
247 | - $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a'); |
|
248 | - return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ; |
|
247 | + $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a'); |
|
248 | + return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>'); |
|
249 | 249 | } |
250 | 250 | /** |
251 | 251 | * Whether curl ro fsock works |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } elseif ($curl_works) { |
263 | 263 | $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
264 | 264 | } else { |
265 | - $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
265 | + $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso').'</mark>'; |
|
266 | 266 | } |
267 | 267 | return $status; |
268 | 268 | } |
@@ -6,79 +6,79 @@ discard block |
||
6 | 6 | class EEM_System_Status |
7 | 7 | { |
8 | 8 | |
9 | - // private instance of the EEM_System_Status object |
|
10 | - protected static $_instance = null; |
|
9 | + // private instance of the EEM_System_Status object |
|
10 | + protected static $_instance = null; |
|
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * This function is a singleton method used to instantiate the EEM_Attendee object |
|
16 | - * |
|
17 | - * @access public |
|
18 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
19 | - * @return EEM_System_Status |
|
20 | - */ |
|
21 | - public static function instance() |
|
22 | - { |
|
14 | + /** |
|
15 | + * This function is a singleton method used to instantiate the EEM_Attendee object |
|
16 | + * |
|
17 | + * @access public |
|
18 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
19 | + * @return EEM_System_Status |
|
20 | + */ |
|
21 | + public static function instance() |
|
22 | + { |
|
23 | 23 | |
24 | - // check if instance of EEM_System_Status already exists |
|
25 | - if (self::$_instance === null) { |
|
26 | - // instantiate EEM_System_Status |
|
27 | - self::$_instance = new self(); |
|
28 | - } |
|
29 | - return self::$_instance; |
|
30 | - } |
|
31 | - private function __construct() |
|
32 | - { |
|
33 | - } |
|
34 | - /** |
|
35 | - * |
|
36 | - * @return array where each key is a function name on this class, and each value is SOMETHING-- |
|
37 | - * it might be a value, an array, or an object |
|
38 | - */ |
|
39 | - public function get_system_stati() |
|
40 | - { |
|
41 | - return apply_filters( |
|
42 | - 'FHEE__EEM_System_Status__get_system_stati', |
|
43 | - array( |
|
44 | - 'ee_version'=>$this->get_ee_version(), |
|
45 | - 'ee_activation_history'=>$this->get_ee_activation_history(), |
|
46 | - 'ee_config'=>$this->get_ee_config(), |
|
47 | - 'ee_migration_history'=>$this->get_ee_migration_history(), |
|
48 | - 'active_plugins'=>$this->get_active_plugins(), |
|
49 | - 'wp_settings'=>$this->get_wp_settings(), |
|
50 | - 'wp_maintenance_mode' => $this->get_wp_maintenance_mode(), |
|
51 | - 'https_enabled'=>$this->get_https_enabled(), |
|
52 | - 'logging_enabled' => $this->get_logging_enabled(), |
|
53 | - 'remote_posting' => $this->get_remote_posting(), |
|
54 | - 'php_version'=>$this->php_version(), |
|
55 | - 'php.ini_settings'=>$this->get_php_ini_all(), |
|
56 | - 'php_info'=>$this->get_php_info(), |
|
57 | - ), |
|
58 | - $this |
|
59 | - ); |
|
60 | - } |
|
61 | - /** |
|
62 | - * |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function get_ee_version() |
|
66 | - { |
|
67 | - return espresso_version(); |
|
68 | - } |
|
69 | - /** |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function php_version() |
|
74 | - { |
|
75 | - return phpversion(); |
|
76 | - } |
|
77 | - /** |
|
78 | - * |
|
79 | - * @return array, where each key is a plugin name (lower-cased), values are sub-arrays. |
|
80 | - * Sub-arrays like described in wp function get_plugin_data. Ie, * |
|
81 | - * 'Name' => 'Plugin Name', |
|
24 | + // check if instance of EEM_System_Status already exists |
|
25 | + if (self::$_instance === null) { |
|
26 | + // instantiate EEM_System_Status |
|
27 | + self::$_instance = new self(); |
|
28 | + } |
|
29 | + return self::$_instance; |
|
30 | + } |
|
31 | + private function __construct() |
|
32 | + { |
|
33 | + } |
|
34 | + /** |
|
35 | + * |
|
36 | + * @return array where each key is a function name on this class, and each value is SOMETHING-- |
|
37 | + * it might be a value, an array, or an object |
|
38 | + */ |
|
39 | + public function get_system_stati() |
|
40 | + { |
|
41 | + return apply_filters( |
|
42 | + 'FHEE__EEM_System_Status__get_system_stati', |
|
43 | + array( |
|
44 | + 'ee_version'=>$this->get_ee_version(), |
|
45 | + 'ee_activation_history'=>$this->get_ee_activation_history(), |
|
46 | + 'ee_config'=>$this->get_ee_config(), |
|
47 | + 'ee_migration_history'=>$this->get_ee_migration_history(), |
|
48 | + 'active_plugins'=>$this->get_active_plugins(), |
|
49 | + 'wp_settings'=>$this->get_wp_settings(), |
|
50 | + 'wp_maintenance_mode' => $this->get_wp_maintenance_mode(), |
|
51 | + 'https_enabled'=>$this->get_https_enabled(), |
|
52 | + 'logging_enabled' => $this->get_logging_enabled(), |
|
53 | + 'remote_posting' => $this->get_remote_posting(), |
|
54 | + 'php_version'=>$this->php_version(), |
|
55 | + 'php.ini_settings'=>$this->get_php_ini_all(), |
|
56 | + 'php_info'=>$this->get_php_info(), |
|
57 | + ), |
|
58 | + $this |
|
59 | + ); |
|
60 | + } |
|
61 | + /** |
|
62 | + * |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function get_ee_version() |
|
66 | + { |
|
67 | + return espresso_version(); |
|
68 | + } |
|
69 | + /** |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function php_version() |
|
74 | + { |
|
75 | + return phpversion(); |
|
76 | + } |
|
77 | + /** |
|
78 | + * |
|
79 | + * @return array, where each key is a plugin name (lower-cased), values are sub-arrays. |
|
80 | + * Sub-arrays like described in wp function get_plugin_data. Ie, * |
|
81 | + * 'Name' => 'Plugin Name', |
|
82 | 82 | 'PluginURI' => 'Plugin URI', |
83 | 83 | 'Version' => 'Version', |
84 | 84 | 'Description' => 'Description', |
@@ -87,221 +87,221 @@ discard block |
||
87 | 87 | 'TextDomain' => 'Text Domain', |
88 | 88 | 'DomainPath' => 'Domain Path', |
89 | 89 | 'Network' => 'Network', |
90 | - */ |
|
91 | - public function get_active_plugins() |
|
92 | - { |
|
93 | - $active_plugins = (array) get_option('active_plugins', array()); |
|
94 | - if (is_multisite()) { |
|
95 | - $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
96 | - } |
|
97 | - $active_plugins = array_map('strtolower', $active_plugins); |
|
98 | - $plugin_info = array(); |
|
99 | - foreach ($active_plugins as $plugin) { |
|
100 | - $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
90 | + */ |
|
91 | + public function get_active_plugins() |
|
92 | + { |
|
93 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
94 | + if (is_multisite()) { |
|
95 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
96 | + } |
|
97 | + $active_plugins = array_map('strtolower', $active_plugins); |
|
98 | + $plugin_info = array(); |
|
99 | + foreach ($active_plugins as $plugin) { |
|
100 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
101 | 101 | |
102 | - $plugin_info[ $plugin ] = $plugin_data; |
|
103 | - } |
|
104 | - return $plugin_info; |
|
105 | - } |
|
102 | + $plugin_info[ $plugin ] = $plugin_data; |
|
103 | + } |
|
104 | + return $plugin_info; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * |
|
109 | - * @return array with keys 'home_url' and 'site_url' |
|
110 | - */ |
|
111 | - public function get_wp_settings() |
|
112 | - { |
|
113 | - $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
|
114 | - if ($wp_memory_int < 67108864) { |
|
115 | - $wp_memory_to_display = '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"') . '</mark>'; |
|
116 | - } else { |
|
117 | - $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>'; |
|
118 | - } |
|
119 | - return array( |
|
120 | - 'name'=>get_bloginfo('name', 'display'), |
|
121 | - 'is_multisite'=>is_multisite(), |
|
122 | - 'version'=> get_bloginfo('version', 'display'), |
|
123 | - 'home_url'=>home_url(), |
|
124 | - 'site_url'=>site_url(), |
|
125 | - 'WP_DEBUG'=>WP_DEBUG, |
|
126 | - 'permalink_structure'=>get_option('permalink_structure'), |
|
127 | - 'theme'=>wp_get_theme(), |
|
128 | - 'gmt_offset'=>get_option('gmt_offset'), |
|
129 | - 'timezone_string'=>get_option('timezone_string'), |
|
130 | - 'admin_email'=> get_bloginfo('admin_email', 'display'), |
|
131 | - 'language'=>get_bloginfo('language', 'display'), |
|
132 | - 'wp_max_upload_size' => size_format(wp_max_upload_size()), |
|
133 | - 'wp_memory' => $wp_memory_to_display |
|
134 | - ); |
|
135 | - } |
|
107 | + /** |
|
108 | + * |
|
109 | + * @return array with keys 'home_url' and 'site_url' |
|
110 | + */ |
|
111 | + public function get_wp_settings() |
|
112 | + { |
|
113 | + $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
|
114 | + if ($wp_memory_int < 67108864) { |
|
115 | + $wp_memory_to_display = '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"') . '</mark>'; |
|
116 | + } else { |
|
117 | + $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>'; |
|
118 | + } |
|
119 | + return array( |
|
120 | + 'name'=>get_bloginfo('name', 'display'), |
|
121 | + 'is_multisite'=>is_multisite(), |
|
122 | + 'version'=> get_bloginfo('version', 'display'), |
|
123 | + 'home_url'=>home_url(), |
|
124 | + 'site_url'=>site_url(), |
|
125 | + 'WP_DEBUG'=>WP_DEBUG, |
|
126 | + 'permalink_structure'=>get_option('permalink_structure'), |
|
127 | + 'theme'=>wp_get_theme(), |
|
128 | + 'gmt_offset'=>get_option('gmt_offset'), |
|
129 | + 'timezone_string'=>get_option('timezone_string'), |
|
130 | + 'admin_email'=> get_bloginfo('admin_email', 'display'), |
|
131 | + 'language'=>get_bloginfo('language', 'display'), |
|
132 | + 'wp_max_upload_size' => size_format(wp_max_upload_size()), |
|
133 | + 'wp_memory' => $wp_memory_to_display |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Gets an array of information about the history of ee versions installed |
|
139 | - * @return array |
|
140 | - */ |
|
141 | - public function get_ee_activation_history() |
|
142 | - { |
|
143 | - return get_option('espresso_db_update'); |
|
144 | - } |
|
137 | + /** |
|
138 | + * Gets an array of information about the history of ee versions installed |
|
139 | + * @return array |
|
140 | + */ |
|
141 | + public function get_ee_activation_history() |
|
142 | + { |
|
143 | + return get_option('espresso_db_update'); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed |
|
149 | - * @return EE_Data_Migration_Script_Base[] |
|
150 | - */ |
|
151 | - public function get_ee_migration_history() |
|
152 | - { |
|
153 | - $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
|
154 | - $presentable_migration_scripts = array(); |
|
155 | - foreach ($options as $option_array) { |
|
156 | - $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']); |
|
157 | - } |
|
158 | - return $presentable_migration_scripts; |
|
147 | + /** |
|
148 | + * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed |
|
149 | + * @return EE_Data_Migration_Script_Base[] |
|
150 | + */ |
|
151 | + public function get_ee_migration_history() |
|
152 | + { |
|
153 | + $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
|
154 | + $presentable_migration_scripts = array(); |
|
155 | + foreach ($options as $option_array) { |
|
156 | + $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']); |
|
157 | + } |
|
158 | + return $presentable_migration_scripts; |
|
159 | 159 | // return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran(); |
160 | - } |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * |
|
164 | - * @return array like EE_Config class |
|
165 | - */ |
|
166 | - public function get_ee_config() |
|
167 | - { |
|
168 | - return EE_Config::instance(); |
|
169 | - } |
|
162 | + /** |
|
163 | + * |
|
164 | + * @return array like EE_Config class |
|
165 | + */ |
|
166 | + public function get_ee_config() |
|
167 | + { |
|
168 | + return EE_Config::instance(); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463 |
|
173 | - * @return array like the output of phpinfo(), but in an array |
|
174 | - */ |
|
175 | - public function get_php_info() |
|
176 | - { |
|
177 | - ob_start(); |
|
178 | - phpinfo(-1); |
|
171 | + /** |
|
172 | + * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463 |
|
173 | + * @return array like the output of phpinfo(), but in an array |
|
174 | + */ |
|
175 | + public function get_php_info() |
|
176 | + { |
|
177 | + ob_start(); |
|
178 | + phpinfo(-1); |
|
179 | 179 | |
180 | - $pi = preg_replace( |
|
181 | - array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
|
182 | - '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
183 | - "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
|
184 | - '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
|
185 | - .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
|
186 | - '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
|
187 | - '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
|
188 | - "# +#", '#<tr>#', '#</tr>#'), |
|
189 | - array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
190 | - '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
|
191 | - "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
|
192 | - '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
|
193 | - '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
194 | - '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
|
195 | - ob_get_clean() |
|
196 | - ); |
|
180 | + $pi = preg_replace( |
|
181 | + array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
|
182 | + '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
183 | + "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
|
184 | + '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
|
185 | + .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
|
186 | + '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
|
187 | + '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
|
188 | + "# +#", '#<tr>#', '#</tr>#'), |
|
189 | + array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
190 | + '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
|
191 | + "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
|
192 | + '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
|
193 | + '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
194 | + '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
|
195 | + ob_get_clean() |
|
196 | + ); |
|
197 | 197 | |
198 | - $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>')); |
|
199 | - unset($sections[0]); |
|
198 | + $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>')); |
|
199 | + unset($sections[0]); |
|
200 | 200 | |
201 | - $pi = array(); |
|
202 | - foreach ($sections as $section) { |
|
203 | - $n = substr($section, 0, strpos($section, '</h2>')); |
|
204 | - preg_match_all( |
|
205 | - '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
|
206 | - $section, |
|
207 | - $askapache, |
|
208 | - PREG_SET_ORDER |
|
209 | - ); |
|
210 | - foreach ($askapache as $m) { |
|
211 | - $m2 = isset($m[2]) ? $m[2] : null; |
|
212 | - } |
|
213 | - $pi[ $n ][ $m[1] ]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m, 2); |
|
214 | - } |
|
201 | + $pi = array(); |
|
202 | + foreach ($sections as $section) { |
|
203 | + $n = substr($section, 0, strpos($section, '</h2>')); |
|
204 | + preg_match_all( |
|
205 | + '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
|
206 | + $section, |
|
207 | + $askapache, |
|
208 | + PREG_SET_ORDER |
|
209 | + ); |
|
210 | + foreach ($askapache as $m) { |
|
211 | + $m2 = isset($m[2]) ? $m[2] : null; |
|
212 | + } |
|
213 | + $pi[ $n ][ $m[1] ]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m, 2); |
|
214 | + } |
|
215 | 215 | |
216 | - return $pi; |
|
217 | - } |
|
216 | + return $pi; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Checks if site responds ot HTTPS |
|
221 | - * @return boolean |
|
222 | - */ |
|
223 | - public function get_https_enabled() |
|
224 | - { |
|
225 | - $home = str_replace("http://", "https://", home_url()); |
|
226 | - $response = wp_remote_get($home); |
|
227 | - if ($response instanceof WP_Error) { |
|
228 | - $error_string = ''; |
|
229 | - foreach ($response->errors as $short_name => $description_array) { |
|
230 | - $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array); |
|
231 | - } |
|
232 | - return $error_string; |
|
233 | - } |
|
234 | - return "ok!"; |
|
235 | - } |
|
236 | - /** |
|
237 | - * Whether or not a .maintenance file is detected |
|
238 | - * @return string descripting wp_maintenance_mode status |
|
239 | - */ |
|
240 | - public function get_wp_maintenance_mode() |
|
241 | - { |
|
242 | - $opened = file_exists(ABSPATH . '.maintenance'); |
|
243 | - return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso') ; |
|
244 | - } |
|
245 | - /** |
|
246 | - * Whether or not logging is enabled |
|
247 | - * @return string descripting logging's status |
|
248 | - */ |
|
249 | - public function get_logging_enabled() |
|
250 | - { |
|
251 | - $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a'); |
|
252 | - return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ; |
|
253 | - } |
|
254 | - /** |
|
255 | - * Whether curl ro fsock works |
|
256 | - * @return string describing posting's status |
|
257 | - */ |
|
258 | - public function get_remote_posting() |
|
259 | - { |
|
260 | - $fsock_works = function_exists('fsockopen'); |
|
261 | - $curl_works = function_exists('curl_init'); |
|
262 | - if ($fsock_works && $curl_works) { |
|
263 | - $status = __('Your server has fsockopen and cURL enabled.', 'event_espresso'); |
|
264 | - } elseif ($fsock_works) { |
|
265 | - $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
|
266 | - } elseif ($curl_works) { |
|
267 | - $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
|
268 | - } else { |
|
269 | - $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
270 | - } |
|
271 | - return $status; |
|
272 | - } |
|
273 | - /** |
|
274 | - * Gets all the php.ini settings |
|
275 | - * @return array |
|
276 | - */ |
|
277 | - public function get_php_ini_all() |
|
278 | - { |
|
279 | - return ini_get_all(); |
|
280 | - } |
|
281 | - /** |
|
282 | - * Transforms the php.ini notation for numbers (like '2M') to an integer. |
|
283 | - * |
|
284 | - * @param type $size |
|
285 | - * @return int |
|
286 | - */ |
|
287 | - public function let_to_num($size) |
|
288 | - { |
|
289 | - $l = substr($size, -1); |
|
290 | - $ret = substr($size, 0, -1); |
|
291 | - // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
292 | - switch (strtoupper($l)) { |
|
293 | - case 'P': |
|
294 | - $ret *= 1024; |
|
295 | - case 'T': |
|
296 | - $ret *= 1024; |
|
297 | - case 'G': |
|
298 | - $ret *= 1024; |
|
299 | - case 'M': |
|
300 | - $ret *= 1024; |
|
301 | - case 'K': |
|
302 | - $ret *= 1024; |
|
303 | - } |
|
304 | - // phpcs:enable |
|
305 | - return $ret; |
|
306 | - } |
|
219 | + /** |
|
220 | + * Checks if site responds ot HTTPS |
|
221 | + * @return boolean |
|
222 | + */ |
|
223 | + public function get_https_enabled() |
|
224 | + { |
|
225 | + $home = str_replace("http://", "https://", home_url()); |
|
226 | + $response = wp_remote_get($home); |
|
227 | + if ($response instanceof WP_Error) { |
|
228 | + $error_string = ''; |
|
229 | + foreach ($response->errors as $short_name => $description_array) { |
|
230 | + $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array); |
|
231 | + } |
|
232 | + return $error_string; |
|
233 | + } |
|
234 | + return "ok!"; |
|
235 | + } |
|
236 | + /** |
|
237 | + * Whether or not a .maintenance file is detected |
|
238 | + * @return string descripting wp_maintenance_mode status |
|
239 | + */ |
|
240 | + public function get_wp_maintenance_mode() |
|
241 | + { |
|
242 | + $opened = file_exists(ABSPATH . '.maintenance'); |
|
243 | + return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso') ; |
|
244 | + } |
|
245 | + /** |
|
246 | + * Whether or not logging is enabled |
|
247 | + * @return string descripting logging's status |
|
248 | + */ |
|
249 | + public function get_logging_enabled() |
|
250 | + { |
|
251 | + $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a'); |
|
252 | + return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ; |
|
253 | + } |
|
254 | + /** |
|
255 | + * Whether curl ro fsock works |
|
256 | + * @return string describing posting's status |
|
257 | + */ |
|
258 | + public function get_remote_posting() |
|
259 | + { |
|
260 | + $fsock_works = function_exists('fsockopen'); |
|
261 | + $curl_works = function_exists('curl_init'); |
|
262 | + if ($fsock_works && $curl_works) { |
|
263 | + $status = __('Your server has fsockopen and cURL enabled.', 'event_espresso'); |
|
264 | + } elseif ($fsock_works) { |
|
265 | + $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
|
266 | + } elseif ($curl_works) { |
|
267 | + $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
|
268 | + } else { |
|
269 | + $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
270 | + } |
|
271 | + return $status; |
|
272 | + } |
|
273 | + /** |
|
274 | + * Gets all the php.ini settings |
|
275 | + * @return array |
|
276 | + */ |
|
277 | + public function get_php_ini_all() |
|
278 | + { |
|
279 | + return ini_get_all(); |
|
280 | + } |
|
281 | + /** |
|
282 | + * Transforms the php.ini notation for numbers (like '2M') to an integer. |
|
283 | + * |
|
284 | + * @param type $size |
|
285 | + * @return int |
|
286 | + */ |
|
287 | + public function let_to_num($size) |
|
288 | + { |
|
289 | + $l = substr($size, -1); |
|
290 | + $ret = substr($size, 0, -1); |
|
291 | + // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
292 | + switch (strtoupper($l)) { |
|
293 | + case 'P': |
|
294 | + $ret *= 1024; |
|
295 | + case 'T': |
|
296 | + $ret *= 1024; |
|
297 | + case 'G': |
|
298 | + $ret *= 1024; |
|
299 | + case 'M': |
|
300 | + $ret *= 1024; |
|
301 | + case 'K': |
|
302 | + $ret *= 1024; |
|
303 | + } |
|
304 | + // phpcs:enable |
|
305 | + return $ret; |
|
306 | + } |
|
307 | 307 | } |
@@ -32,8 +32,6 @@ |
||
32 | 32 | * ) |
33 | 33 | * ) |
34 | 34 | * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
35 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
36 | - * set to true, it will be stored as an INT |
|
37 | 35 | */ |
38 | 36 | public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
39 | 37 | { |
@@ -3,114 +3,114 @@ |
||
3 | 3 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
4 | 4 | { |
5 | 5 | |
6 | - protected $_wp_post_stati; |
|
6 | + protected $_wp_post_stati; |
|
7 | 7 | |
8 | 8 | |
9 | - /** |
|
10 | - * constructor |
|
11 | - * |
|
12 | - * @param string $table_column column on table |
|
13 | - * @param string $nicename nice name for column(field) |
|
14 | - * @param bool $nullable is this field nullable |
|
15 | - * @param string $default_value default status |
|
16 | - * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
17 | - * they can be registered via this property. The format of the array should be |
|
18 | - * as follows: array( |
|
19 | - * 'status_reference' => array( |
|
20 | - * 'label' => __('Status Reference Label', 'event_espresso') |
|
21 | - * 'public' => true, //'Whether posts of this status should be shown on the |
|
22 | - * frontend of the site' |
|
23 | - * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
24 | - * excluded from wp searches' |
|
25 | - * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
26 | - * in queries for the admin "all" view in list table views. |
|
27 | - * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
28 | - * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
29 | - * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
30 | - * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
31 | - * on the admin screen( or you won't see your status count ). |
|
32 | - * ) |
|
33 | - * ) |
|
34 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
35 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
36 | - * set to true, it will be stored as an INT |
|
37 | - */ |
|
38 | - public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
39 | - { |
|
40 | - $this->_register_new_stati($new_stati); |
|
41 | - $this->_set_allowed_enum_values(); |
|
42 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
43 | - } |
|
9 | + /** |
|
10 | + * constructor |
|
11 | + * |
|
12 | + * @param string $table_column column on table |
|
13 | + * @param string $nicename nice name for column(field) |
|
14 | + * @param bool $nullable is this field nullable |
|
15 | + * @param string $default_value default status |
|
16 | + * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
17 | + * they can be registered via this property. The format of the array should be |
|
18 | + * as follows: array( |
|
19 | + * 'status_reference' => array( |
|
20 | + * 'label' => __('Status Reference Label', 'event_espresso') |
|
21 | + * 'public' => true, //'Whether posts of this status should be shown on the |
|
22 | + * frontend of the site' |
|
23 | + * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
24 | + * excluded from wp searches' |
|
25 | + * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
26 | + * in queries for the admin "all" view in list table views. |
|
27 | + * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
28 | + * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
29 | + * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
30 | + * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
31 | + * on the admin screen( or you won't see your status count ). |
|
32 | + * ) |
|
33 | + * ) |
|
34 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
35 | + * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
36 | + * set to true, it will be stored as an INT |
|
37 | + */ |
|
38 | + public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
39 | + { |
|
40 | + $this->_register_new_stati($new_stati); |
|
41 | + $this->_set_allowed_enum_values(); |
|
42 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * This registers any new statuses sent via the $new_stati array on construct |
|
48 | - * |
|
49 | - * @access protected |
|
50 | - * @param array $new_stati statuses |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - protected function _register_new_stati($new_stati) |
|
54 | - { |
|
46 | + /** |
|
47 | + * This registers any new statuses sent via the $new_stati array on construct |
|
48 | + * |
|
49 | + * @access protected |
|
50 | + * @param array $new_stati statuses |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + protected function _register_new_stati($new_stati) |
|
54 | + { |
|
55 | 55 | |
56 | - foreach ((array) $new_stati as $status_key => $status_args) { |
|
57 | - $args = array( |
|
58 | - 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
59 | - 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
60 | - 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
61 | - 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
62 | - 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
63 | - 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
64 | - ); |
|
65 | - register_post_status($status_key, $status_args); |
|
66 | - } |
|
67 | - } |
|
56 | + foreach ((array) $new_stati as $status_key => $status_args) { |
|
57 | + $args = array( |
|
58 | + 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
59 | + 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
60 | + 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
61 | + 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
62 | + 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
63 | + 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
64 | + ); |
|
65 | + register_post_status($status_key, $status_args); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
72 | - * |
|
73 | - * @access protected |
|
74 | - * @regurn void |
|
75 | - */ |
|
76 | - protected function _set_allowed_enum_values() |
|
77 | - { |
|
78 | - // first let's get the post_statuses |
|
79 | - global $wp_post_statuses; |
|
80 | - $this->_wp_post_stati = $wp_post_statuses; |
|
70 | + /** |
|
71 | + * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
72 | + * |
|
73 | + * @access protected |
|
74 | + * @regurn void |
|
75 | + */ |
|
76 | + protected function _set_allowed_enum_values() |
|
77 | + { |
|
78 | + // first let's get the post_statuses |
|
79 | + global $wp_post_statuses; |
|
80 | + $this->_wp_post_stati = $wp_post_statuses; |
|
81 | 81 | |
82 | - foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
83 | - $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
84 | - } |
|
85 | - } |
|
82 | + foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
83 | + $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Before calling parent, first double-checks our list of acceptable post |
|
89 | - * types is up-to-date |
|
90 | - * |
|
91 | - * @param string $value_inputted_for_field_on_model_object |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
95 | - { |
|
96 | - $this->_set_allowed_enum_values(); |
|
97 | - return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
98 | - } |
|
87 | + /** |
|
88 | + * Before calling parent, first double-checks our list of acceptable post |
|
89 | + * types is up-to-date |
|
90 | + * |
|
91 | + * @param string $value_inputted_for_field_on_model_object |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
95 | + { |
|
96 | + $this->_set_allowed_enum_values(); |
|
97 | + return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | |
102 | - // helper methods for getting various $wp_post_statuses stuff. |
|
102 | + // helper methods for getting various $wp_post_statuses stuff. |
|
103 | 103 | |
104 | - /** |
|
105 | - * This just returns the status object for the given status |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
109 | - * @param string $status What status object you want |
|
110 | - * @return std_object the status object or FALSE if it doesn't exist. |
|
111 | - */ |
|
112 | - public function get_status_object($status) |
|
113 | - { |
|
114 | - return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
115 | - } |
|
104 | + /** |
|
105 | + * This just returns the status object for the given status |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
109 | + * @param string $status What status object you want |
|
110 | + * @return std_object the status object or FALSE if it doesn't exist. |
|
111 | + */ |
|
112 | + public function get_status_object($status) |
|
113 | + { |
|
114 | + return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
115 | + } |
|
116 | 116 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->_wp_post_stati = $wp_post_statuses; |
81 | 81 | |
82 | 82 | foreach ($this->_wp_post_stati as $post_status => $args_object) { |
83 | - $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
83 | + $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -111,6 +111,6 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_status_object($status) |
113 | 113 | { |
114 | - return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
114 | + return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
115 | 115 | } |
116 | 116 | } |
@@ -44,19 +44,33 @@ discard block |
||
44 | 44 | |
45 | 45 | private $_group_by_sql; |
46 | 46 | |
47 | + /** |
|
48 | + * @param string $limit_sql |
|
49 | + */ |
|
47 | 50 | public function set_limit_sql($limit_sql) |
48 | 51 | { |
49 | 52 | $this->_limit_sql = $limit_sql; |
50 | 53 | } |
51 | 54 | |
55 | + /** |
|
56 | + * @param string $order_by_sql |
|
57 | + */ |
|
52 | 58 | public function set_order_by_sql($order_by_sql) |
53 | 59 | { |
54 | 60 | $this->_order_by_sql = $order_by_sql; |
55 | 61 | } |
62 | + |
|
63 | + /** |
|
64 | + * @param string $group_by_sql |
|
65 | + */ |
|
56 | 66 | public function set_group_by_sql($group_by_sql) |
57 | 67 | { |
58 | 68 | $this->_group_by_sql = $group_by_sql; |
59 | 69 | } |
70 | + |
|
71 | + /** |
|
72 | + * @param string $having_sql |
|
73 | + */ |
|
60 | 74 | public function set_having_sql($having_sql) |
61 | 75 | { |
62 | 76 | $this->_having_sql = $having_sql; |
@@ -81,7 +95,6 @@ discard block |
||
81 | 95 | * |
82 | 96 | * @param type $model_included_name |
83 | 97 | * @param type $join_sql |
84 | - * @param type $data_types |
|
85 | 98 | */ |
86 | 99 | public function __construct($model_included_name = array(), $join_sql = '') |
87 | 100 | { |
@@ -14,141 +14,141 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
16 | 16 | */ |
17 | - private $_join_sql; |
|
17 | + private $_join_sql; |
|
18 | 18 | /** |
19 | 19 | * |
20 | 20 | * @var array stating all the models that have been included thus far,so we don't get duplicates. |
21 | 21 | * Keys are the model relation chains to them from the queried model |
22 | 22 | * (eg, "Registration.Transaction.Payment"), and valuesare model names (eg "Payment") |
23 | 23 | */ |
24 | - private $_models_included; |
|
24 | + private $_models_included; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * After we've acquired all the data types, we can create this sql. |
28 | 28 | * @var string |
29 | 29 | */ |
30 | - private $_where_sql; |
|
30 | + private $_where_sql; |
|
31 | 31 | /** |
32 | 32 | * Full join sql. Eg, in a select query, that's everything after the "FROM", and before the "WHERE", so it includes |
33 | 33 | * the declaration of the main model's tables, and then appends all the joining sql to other models |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_main_join_sql; |
|
36 | + private $_main_join_sql; |
|
37 | 37 | |
38 | 38 | |
39 | - private $_limit_sql; |
|
39 | + private $_limit_sql; |
|
40 | 40 | |
41 | - private $_order_by_sql; |
|
41 | + private $_order_by_sql; |
|
42 | 42 | |
43 | - private $_having_sql; |
|
43 | + private $_having_sql; |
|
44 | 44 | |
45 | - private $_group_by_sql; |
|
45 | + private $_group_by_sql; |
|
46 | 46 | |
47 | - public function set_limit_sql($limit_sql) |
|
48 | - { |
|
49 | - $this->_limit_sql = $limit_sql; |
|
50 | - } |
|
47 | + public function set_limit_sql($limit_sql) |
|
48 | + { |
|
49 | + $this->_limit_sql = $limit_sql; |
|
50 | + } |
|
51 | 51 | |
52 | - public function set_order_by_sql($order_by_sql) |
|
53 | - { |
|
54 | - $this->_order_by_sql = $order_by_sql; |
|
55 | - } |
|
56 | - public function set_group_by_sql($group_by_sql) |
|
57 | - { |
|
58 | - $this->_group_by_sql = $group_by_sql; |
|
59 | - } |
|
60 | - public function set_having_sql($having_sql) |
|
61 | - { |
|
62 | - $this->_having_sql = $having_sql; |
|
63 | - } |
|
64 | - public function get_limit_sql() |
|
65 | - { |
|
66 | - return $this->_limit_sql; |
|
67 | - } |
|
68 | - public function get_order_by_sql() |
|
69 | - { |
|
70 | - return $this->_order_by_sql; |
|
71 | - } |
|
72 | - public function get_group_by_sql() |
|
73 | - { |
|
74 | - return $this->_group_by_sql; |
|
75 | - } |
|
76 | - public function get_having_sql() |
|
77 | - { |
|
78 | - return $this->_having_sql; |
|
79 | - } |
|
52 | + public function set_order_by_sql($order_by_sql) |
|
53 | + { |
|
54 | + $this->_order_by_sql = $order_by_sql; |
|
55 | + } |
|
56 | + public function set_group_by_sql($group_by_sql) |
|
57 | + { |
|
58 | + $this->_group_by_sql = $group_by_sql; |
|
59 | + } |
|
60 | + public function set_having_sql($having_sql) |
|
61 | + { |
|
62 | + $this->_having_sql = $having_sql; |
|
63 | + } |
|
64 | + public function get_limit_sql() |
|
65 | + { |
|
66 | + return $this->_limit_sql; |
|
67 | + } |
|
68 | + public function get_order_by_sql() |
|
69 | + { |
|
70 | + return $this->_order_by_sql; |
|
71 | + } |
|
72 | + public function get_group_by_sql() |
|
73 | + { |
|
74 | + return $this->_group_by_sql; |
|
75 | + } |
|
76 | + public function get_having_sql() |
|
77 | + { |
|
78 | + return $this->_having_sql; |
|
79 | + } |
|
80 | 80 | /** |
81 | 81 | * |
82 | 82 | * @param type $model_included_name |
83 | 83 | * @param type $join_sql |
84 | 84 | * @param type $data_types |
85 | 85 | */ |
86 | - public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | - { |
|
88 | - $this->_models_included = $model_included_name; |
|
89 | - $this->_join_sql = $join_sql; |
|
90 | - } |
|
86 | + public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | + { |
|
88 | + $this->_models_included = $model_included_name; |
|
89 | + $this->_join_sql = $join_sql; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
94 | 94 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
95 | 95 | */ |
96 | - public function merge($other_model_query_info_carrier) |
|
97 | - { |
|
98 | - if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | - $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | - $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | - } |
|
103 | - // otherwise don't merge our data. |
|
104 | - // yes, this means that we must immediately merge any model data into our grand list |
|
105 | - // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | - // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | - } |
|
96 | + public function merge($other_model_query_info_carrier) |
|
97 | + { |
|
98 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | + $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | + } |
|
103 | + // otherwise don't merge our data. |
|
104 | + // yes, this means that we must immediately merge any model data into our grand list |
|
105 | + // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | + // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | + } |
|
108 | 108 | /** |
109 | 109 | * Checks whether or not we have already included all the models mentione din $model_names on the query info varrier |
110 | 110 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
111 | 111 | * @return boolean |
112 | 112 | */ |
113 | - protected function _have_already_included_one_of_these_models($model_names) |
|
114 | - { |
|
115 | - foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | - if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | - return true; |
|
118 | - } |
|
119 | - } |
|
120 | - return false; |
|
121 | - } |
|
113 | + protected function _have_already_included_one_of_these_models($model_names) |
|
114 | + { |
|
115 | + foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | + return true; |
|
118 | + } |
|
119 | + } |
|
120 | + return false; |
|
121 | + } |
|
122 | 122 | /** |
123 | 123 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
124 | 124 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
125 | 125 | */ |
126 | - public function get_model_names_included() |
|
127 | - { |
|
128 | - return $this->_models_included; |
|
129 | - } |
|
126 | + public function get_model_names_included() |
|
127 | + { |
|
128 | + return $this->_models_included; |
|
129 | + } |
|
130 | 130 | /** |
131 | 131 | * sets the $where_sql for later use from client code |
132 | 132 | * @param string $where_sql |
133 | 133 | */ |
134 | - public function set_where_sql($where_sql) |
|
135 | - { |
|
136 | - $this->_where_sql = $where_sql; |
|
137 | - } |
|
138 | - public function get_where_sql() |
|
139 | - { |
|
140 | - return $this->_where_sql; |
|
141 | - } |
|
134 | + public function set_where_sql($where_sql) |
|
135 | + { |
|
136 | + $this->_where_sql = $where_sql; |
|
137 | + } |
|
138 | + public function get_where_sql() |
|
139 | + { |
|
140 | + return $this->_where_sql; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Gets the SQL for joining the main model to other models involves in the query, which was set earlier on |
145 | 145 | * the EE_Model_Query_info_Carrier by calling set_main_model_join_sql() |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function get_main_model_join_sql() |
|
149 | - { |
|
150 | - return $this->_main_join_sql; |
|
151 | - } |
|
148 | + public function get_main_model_join_sql() |
|
149 | + { |
|
150 | + return $this->_main_join_sql; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | /** |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * after the FROM and before the WHERE.) |
159 | 159 | * @param string $join_sql |
160 | 160 | */ |
161 | - public function set_main_model_join_sql($join_sql) |
|
162 | - { |
|
163 | - $this->_main_join_sql = $join_sql; |
|
164 | - } |
|
165 | - public function get_full_join_sql() |
|
166 | - { |
|
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
168 | - } |
|
161 | + public function set_main_model_join_sql($join_sql) |
|
162 | + { |
|
163 | + $this->_main_join_sql = $join_sql; |
|
164 | + } |
|
165 | + public function get_full_join_sql() |
|
166 | + { |
|
167 | + return $this->_main_join_sql . $this->_join_sql; |
|
168 | + } |
|
169 | 169 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function merge($other_model_query_info_carrier) |
97 | 97 | { |
98 | 98 | if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | 100 | $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
101 | 101 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
102 | 102 | } |
@@ -164,6 +164,6 @@ discard block |
||
164 | 164 | } |
165 | 165 | public function get_full_join_sql() |
166 | 166 | { |
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
167 | + return $this->_main_join_sql.$this->_join_sql; |
|
168 | 168 | } |
169 | 169 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * creates join statement FROM primary table |
55 | 55 | * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk |
56 | 56 | * |
57 | - * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery) |
|
57 | + * @param string $primary_table_alias_with_model_chain_prefix |
|
58 | 58 | * @return string of SQL |
59 | 59 | */ |
60 | 60 | public function get_join_sql($primary_table_alias_with_model_chain_prefix) |
@@ -78,6 +78,7 @@ discard block |
||
78 | 78 | * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns |
79 | 79 | * " LEFT JOIN primary_table AS Primary ON ...". |
80 | 80 | * This is useful if the secondary table is already included in the SQL, but the primary table is not yet. |
81 | + * @param string $secondary_table_alias_with_model_chain_prefix |
|
81 | 82 | * @return string |
82 | 83 | */ |
83 | 84 | public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix) |
@@ -7,118 +7,118 @@ |
||
7 | 7 | */ |
8 | 8 | class EE_Secondary_Table extends EE_Table_Base |
9 | 9 | { |
10 | - protected $_extra_join_conditions; |
|
10 | + protected $_extra_join_conditions; |
|
11 | 11 | |
12 | - /** |
|
13 | - * |
|
14 | - * @global type $wpdb |
|
15 | - * @param string $table_name with or without wpdb prefix |
|
16 | - * @param string $pk_column name of primary key column on THIS table |
|
17 | - * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key |
|
18 | - * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition |
|
19 | - * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
|
20 | - * or whether each site on a multisite install has a copy of this table |
|
21 | - */ |
|
22 | - public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false) |
|
23 | - { |
|
24 | - $this->_fk_on_table = $fk_column; |
|
25 | - $this->_extra_join_conditions = $extra_join_conditions; |
|
26 | - parent::__construct($table_name, $pk_column, $global); |
|
27 | - } |
|
28 | - public function get_fk_on_table() |
|
29 | - { |
|
30 | - return $this->_fk_on_table; |
|
31 | - } |
|
32 | - public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table) |
|
33 | - { |
|
34 | - $this->_table_to_join_with = $table; |
|
35 | - } |
|
36 | - /** |
|
37 | - * |
|
38 | - * @return string of sql like "Event.post_type = 'event'", which gets added to |
|
39 | - * the end of the join statement with the primary table |
|
40 | - */ |
|
41 | - public function get_extra_join_conditions() |
|
42 | - { |
|
43 | - return $this->_extra_join_conditions; |
|
44 | - } |
|
45 | - /** |
|
46 | - * |
|
47 | - * @return EE_Primary_Table |
|
48 | - */ |
|
49 | - public function get_table_to_join_with() |
|
50 | - { |
|
51 | - return $this->_table_to_join_with; |
|
52 | - } |
|
53 | - /** |
|
54 | - * creates join statement FROM primary table |
|
55 | - * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk |
|
56 | - * |
|
57 | - * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery) |
|
58 | - * @return string of SQL |
|
59 | - */ |
|
60 | - public function get_join_sql($primary_table_alias_with_model_chain_prefix) |
|
61 | - { |
|
12 | + /** |
|
13 | + * |
|
14 | + * @global type $wpdb |
|
15 | + * @param string $table_name with or without wpdb prefix |
|
16 | + * @param string $pk_column name of primary key column on THIS table |
|
17 | + * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key |
|
18 | + * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition |
|
19 | + * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
|
20 | + * or whether each site on a multisite install has a copy of this table |
|
21 | + */ |
|
22 | + public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false) |
|
23 | + { |
|
24 | + $this->_fk_on_table = $fk_column; |
|
25 | + $this->_extra_join_conditions = $extra_join_conditions; |
|
26 | + parent::__construct($table_name, $pk_column, $global); |
|
27 | + } |
|
28 | + public function get_fk_on_table() |
|
29 | + { |
|
30 | + return $this->_fk_on_table; |
|
31 | + } |
|
32 | + public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table) |
|
33 | + { |
|
34 | + $this->_table_to_join_with = $table; |
|
35 | + } |
|
36 | + /** |
|
37 | + * |
|
38 | + * @return string of sql like "Event.post_type = 'event'", which gets added to |
|
39 | + * the end of the join statement with the primary table |
|
40 | + */ |
|
41 | + public function get_extra_join_conditions() |
|
42 | + { |
|
43 | + return $this->_extra_join_conditions; |
|
44 | + } |
|
45 | + /** |
|
46 | + * |
|
47 | + * @return EE_Primary_Table |
|
48 | + */ |
|
49 | + public function get_table_to_join_with() |
|
50 | + { |
|
51 | + return $this->_table_to_join_with; |
|
52 | + } |
|
53 | + /** |
|
54 | + * creates join statement FROM primary table |
|
55 | + * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk |
|
56 | + * |
|
57 | + * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery) |
|
58 | + * @return string of SQL |
|
59 | + */ |
|
60 | + public function get_join_sql($primary_table_alias_with_model_chain_prefix) |
|
61 | + { |
|
62 | 62 | |
63 | - $table_name = $this->get_table_name(); |
|
64 | - $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias(); |
|
65 | - $other_table_pk = $this->get_table_to_join_with()->get_pk_column(); |
|
66 | - $fk = $this->get_fk_on_table(); |
|
67 | - $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk "; |
|
68 | - if ($this->get_extra_join_conditions()) { |
|
69 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
70 | - } |
|
71 | - return $join_sql; |
|
72 | - } |
|
63 | + $table_name = $this->get_table_name(); |
|
64 | + $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias(); |
|
65 | + $other_table_pk = $this->get_table_to_join_with()->get_pk_column(); |
|
66 | + $fk = $this->get_fk_on_table(); |
|
67 | + $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk "; |
|
68 | + if ($this->get_extra_join_conditions()) { |
|
69 | + $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
70 | + } |
|
71 | + return $join_sql; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * Produces join SQL like get_join_sql, except instead of joining the primary table to the |
|
77 | - * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of |
|
78 | - * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns |
|
79 | - * " LEFT JOIN primary_table AS Primary ON ...". |
|
80 | - * This is useful if the secondary table is already included in the SQL, but the primary table is not yet. |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix) |
|
84 | - { |
|
85 | - $primary_table_name =$this->get_table_to_join_with()->get_table_name(); |
|
86 | - $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias(); |
|
87 | - $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column(); |
|
88 | - $fk = $this->get_fk_on_table(); |
|
89 | - $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk "; |
|
90 | - if ($this->get_extra_join_conditions()) { |
|
91 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
92 | - } |
|
93 | - return $join_sql; |
|
94 | - } |
|
75 | + /** |
|
76 | + * Produces join SQL like get_join_sql, except instead of joining the primary table to the |
|
77 | + * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of |
|
78 | + * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns |
|
79 | + * " LEFT JOIN primary_table AS Primary ON ...". |
|
80 | + * This is useful if the secondary table is already included in the SQL, but the primary table is not yet. |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix) |
|
84 | + { |
|
85 | + $primary_table_name =$this->get_table_to_join_with()->get_table_name(); |
|
86 | + $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias(); |
|
87 | + $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column(); |
|
88 | + $fk = $this->get_fk_on_table(); |
|
89 | + $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk "; |
|
90 | + if ($this->get_extra_join_conditions()) { |
|
91 | + $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
92 | + } |
|
93 | + return $join_sql; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * This prepares the join on the other table using a select with a internal limit. |
|
98 | - * @param mixed (array|string) $limit limit |
|
99 | - * @return string SQL to return |
|
100 | - */ |
|
101 | - public function get_select_join_limit_join($limit) |
|
102 | - { |
|
103 | - // first get the select |
|
104 | - $select = $this->get_select_join_limit($limit); |
|
105 | - $join_sql = $this->get_join_sql($select); |
|
106 | - return $join_sql; |
|
107 | - } |
|
96 | + /** |
|
97 | + * This prepares the join on the other table using a select with a internal limit. |
|
98 | + * @param mixed (array|string) $limit limit |
|
99 | + * @return string SQL to return |
|
100 | + */ |
|
101 | + public function get_select_join_limit_join($limit) |
|
102 | + { |
|
103 | + // first get the select |
|
104 | + $select = $this->get_select_join_limit($limit); |
|
105 | + $join_sql = $this->get_join_sql($select); |
|
106 | + return $join_sql; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | 110 | |
111 | - public function get_fully_qualified_fk_column() |
|
112 | - { |
|
113 | - $table_alias = $this->get_table_alias(); |
|
114 | - $fk = $this->get_fk_on_table(); |
|
115 | - return $table_alias . '.' . $fk; |
|
116 | - } |
|
111 | + public function get_fully_qualified_fk_column() |
|
112 | + { |
|
113 | + $table_alias = $this->get_table_alias(); |
|
114 | + $fk = $this->get_fk_on_table(); |
|
115 | + return $table_alias . '.' . $fk; |
|
116 | + } |
|
117 | 117 | |
118 | - public function get_fully_qualified_pk_on_fk_table() |
|
119 | - { |
|
120 | - $table_alias = $this->get_table_to_join_with()->get_table_alias(); |
|
121 | - $pk = $this->get_table_to_join_with()->get_pk_column(); |
|
122 | - return $table_alias . '.' . $pk; |
|
123 | - } |
|
118 | + public function get_fully_qualified_pk_on_fk_table() |
|
119 | + { |
|
120 | + $table_alias = $this->get_table_to_join_with()->get_table_alias(); |
|
121 | + $pk = $this->get_table_to_join_with()->get_pk_column(); |
|
122 | + return $table_alias . '.' . $pk; |
|
123 | + } |
|
124 | 124 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | { |
62 | 62 | |
63 | 63 | $table_name = $this->get_table_name(); |
64 | - $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias(); |
|
64 | + $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix).$this->get_table_alias(); |
|
65 | 65 | $other_table_pk = $this->get_table_to_join_with()->get_pk_column(); |
66 | 66 | $fk = $this->get_fk_on_table(); |
67 | 67 | $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk "; |
68 | 68 | if ($this->get_extra_join_conditions()) { |
69 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
69 | + $join_sql .= "AND ".$this->get_extra_join_conditions(); |
|
70 | 70 | } |
71 | 71 | return $join_sql; |
72 | 72 | } |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix) |
84 | 84 | { |
85 | - $primary_table_name =$this->get_table_to_join_with()->get_table_name(); |
|
86 | - $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias(); |
|
87 | - $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column(); |
|
85 | + $primary_table_name = $this->get_table_to_join_with()->get_table_name(); |
|
86 | + $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix).$this->get_table_to_join_with()->get_table_alias(); |
|
87 | + $primary_table_pk = $this->get_table_to_join_with()->get_pk_column(); // $this->get_pk_column(); |
|
88 | 88 | $fk = $this->get_fk_on_table(); |
89 | 89 | $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk "; |
90 | 90 | if ($this->get_extra_join_conditions()) { |
91 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
91 | + $join_sql .= "AND ".$this->get_extra_join_conditions(); |
|
92 | 92 | } |
93 | 93 | return $join_sql; |
94 | 94 | } |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | { |
113 | 113 | $table_alias = $this->get_table_alias(); |
114 | 114 | $fk = $this->get_fk_on_table(); |
115 | - return $table_alias . '.' . $fk; |
|
115 | + return $table_alias.'.'.$fk; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function get_fully_qualified_pk_on_fk_table() |
119 | 119 | { |
120 | 120 | $table_alias = $this->get_table_to_join_with()->get_table_alias(); |
121 | 121 | $pk = $this->get_table_to_join_with()->get_pk_column(); |
122 | - return $table_alias . '.' . $pk; |
|
122 | + return $table_alias.'.'.$pk; |
|
123 | 123 | } |
124 | 124 | } |
@@ -1049,7 +1049,7 @@ |
||
1049 | 1049 | |
1050 | 1050 | /** |
1051 | 1051 | * @deprecated 4.9.0 |
1052 | - * @return array |
|
1052 | + * @return EE_messenger[] |
|
1053 | 1053 | */ |
1054 | 1054 | public function get_installed_messengers() |
1055 | 1055 | { |
@@ -84,20 +84,20 @@ discard block |
||
84 | 84 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
85 | 85 | foreach ($deprecated_filters as $deprecated_filter => $on) { |
86 | 86 | // was this filter called ? |
87 | - if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
87 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
88 | 88 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
89 | 89 | if (EE_Registry::instance()->CAP->current_user_can( |
90 | 90 | 'ee_read_ee', |
91 | 91 | 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
92 | 92 | ) && ! defined('DOING_AJAX')) { |
93 | 93 | EE_Error::doing_it_wrong( |
94 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
94 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
95 | 95 | sprintf( |
96 | 96 | __( |
97 | 97 | 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
98 | 98 | 'event_espresso' |
99 | 99 | ), |
100 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
100 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
101 | 101 | '<br />', |
102 | 102 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
103 | 103 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | ); |
107 | 107 | } |
108 | 108 | } else { |
109 | - unset($deprecated_filters[ $deprecated_filter ]); |
|
109 | + unset($deprecated_filters[$deprecated_filter]); |
|
110 | 110 | } |
111 | 111 | } |
112 | - if (! empty($deprecated_filters)) { |
|
112 | + if ( ! empty($deprecated_filters)) { |
|
113 | 113 | |
114 | 114 | if ($checkout->current_step->slug( |
115 | 115 | ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $submit_button_text = apply_filters( |
144 | 144 | 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
145 | 145 | $submit_button_text |
146 | - ) . $checkout->next_step->name(); |
|
146 | + ).$checkout->next_step->name(); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | 'event_espresso' |
328 | 328 | ); |
329 | 329 | EE_Error::doing_it_wrong( |
330 | - __CLASS__ . '::' . __FUNCTION__, |
|
330 | + __CLASS__.'::'.__FUNCTION__, |
|
331 | 331 | $msg, |
332 | 332 | '4.8.32.rc.000' |
333 | 333 | ); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | function ee_deprecated_update_attendee_registration_form_old($admin_page) |
355 | 355 | { |
356 | 356 | // check if the old hooks are in use. If not, do the default |
357 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
357 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
358 | 358 | || ! $admin_page instanceof EE_Admin_Page) { |
359 | 359 | return; |
360 | 360 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
363 | 363 | $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
364 | 364 | $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
365 | - if (! $REG_ID || ! $qstns) { |
|
365 | + if ( ! $REG_ID || ! $qstns) { |
|
366 | 366 | EE_Error::add_error( |
367 | 367 | __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
368 | 368 | __FILE__, |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | |
383 | 383 | foreach ($qstns as $QST_ID => $qstn) { |
384 | 384 | // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
385 | - if (! is_array($qstn)) { |
|
385 | + if ( ! is_array($qstn)) { |
|
386 | 386 | $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
387 | 387 | continue; |
388 | 388 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | ); |
400 | 400 | $answer = EEM_Answer::instance()->get_one($query_params); |
401 | 401 | // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
402 | - if (! $answer instanceof EE_Answer) { |
|
402 | + if ( ! $answer instanceof EE_Answer) { |
|
403 | 403 | $set_values = array( |
404 | 404 | 'QST_ID' => $QST_ID, |
405 | 405 | 'REG_ID' => $REG_ID, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) |
441 | 441 | { |
442 | 442 | // check if the old hooks are in use. If not, do the default |
443 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
443 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
444 | 444 | || ! $admin_page instanceof EE_Admin_Page) { |
445 | 445 | return $do_default_action; |
446 | 446 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | 'reg_questions_form_action' => 'edit_registration', |
473 | 473 | 'REG_ID' => $registration->ID(), |
474 | 474 | ); |
475 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
475 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
476 | 476 | echo EEH_Template::display_template($template_path, $template_args, true); |
477 | 477 | // indicate that we should not do the default admin page code |
478 | 478 | return false; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | public function _class_is_deprecated($method) |
591 | 591 | { |
592 | 592 | EE_Error::doing_it_wrong( |
593 | - 'EE_messages::' . $method, |
|
593 | + 'EE_messages::'.$method, |
|
594 | 594 | __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
595 | 595 | '4.9.0', |
596 | 596 | '4.10.0.p' |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $error = false; |
730 | 730 | // try to intelligently determine what method we'll call based on the incoming data. |
731 | 731 | // if generating and sending are different then generate and send immediately. |
732 | - if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
732 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
733 | 733 | // in the legacy system, when generating and sending were different, that means all the |
734 | 734 | // vars are already in the request object. So let's just use that. |
735 | 735 | try { |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'event_espresso' |
743 | 743 | ); |
744 | 744 | // add specific message for developers if WP_DEBUG in on |
745 | - $error_msg .= '||' . $e->getMessage(); |
|
745 | + $error_msg .= '||'.$e->getMessage(); |
|
746 | 746 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
747 | 747 | $error = true; |
748 | 748 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | } |
817 | 817 | } |
818 | 818 | // if no error then return the generated message(s). |
819 | - if (! $error && ! $send) { |
|
819 | + if ( ! $error && ! $send) { |
|
820 | 820 | $generated_queue = $processor->generate_queue(false); |
821 | 821 | // get message and return. |
822 | 822 | $generated_queue->get_message_repository()->rewind(); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | /** @type EE_Messages_Queue $queue */ |
876 | 876 | $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
877 | 877 | // make sure we have a proper message object |
878 | - if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
878 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
879 | 879 | $msg = EE_Message_Factory::create( |
880 | 880 | array( |
881 | 881 | 'MSG_messenger' => $messenger, |
@@ -887,11 +887,11 @@ discard block |
||
887 | 887 | } else { |
888 | 888 | $msg = $message; |
889 | 889 | } |
890 | - if (! $msg instanceof EE_Message) { |
|
890 | + if ( ! $msg instanceof EE_Message) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | // make sure any content in a content property (if not empty) is set on the MSG_content. |
894 | - if (! empty($msg->content)) { |
|
894 | + if ( ! empty($msg->content)) { |
|
895 | 895 | $msg->set('MSG_content', $msg->content); |
896 | 896 | } |
897 | 897 | $queue->add($msg); |
@@ -1130,8 +1130,8 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | add_filter( |
1132 | 1132 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
1133 | - function ($event_list_iframe_css) { |
|
1134 | - if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1133 | + function($event_list_iframe_css) { |
|
1134 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1135 | 1135 | return $event_list_iframe_css; |
1136 | 1136 | } |
1137 | 1137 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | ); |
1151 | 1151 | add_filter( |
1152 | 1152 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
1153 | - function ($event_list_iframe_js) { |
|
1154 | - if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1153 | + function($event_list_iframe_js) { |
|
1154 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1155 | 1155 | return $event_list_iframe_js; |
1156 | 1156 | } |
1157 | 1157 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | ); |
1171 | 1171 | add_action( |
1172 | 1172 | 'AHEE__EE_Capabilities__addCaps__complete', |
1173 | - function ($capabilities_map) { |
|
1174 | - if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1173 | + function($capabilities_map) { |
|
1174 | + if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1175 | 1175 | return; |
1176 | 1176 | } |
1177 | 1177 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | add_filter( |
1192 | 1192 | 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
1193 | - function ($existing_attendee, $registration, $attendee_data) { |
|
1194 | - if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1193 | + function($existing_attendee, $registration, $attendee_data) { |
|
1194 | + if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1195 | 1195 | return $existing_attendee; |
1196 | 1196 | } |
1197 | 1197 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | public function event_list_title($event_list_title = '') |
1276 | 1276 | { |
1277 | - if (! empty($this->title)) { |
|
1277 | + if ( ! empty($this->title)) { |
|
1278 | 1278 | return $this->title; |
1279 | 1279 | } |
1280 | 1280 | return $event_list_title; |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | foreach ($model_fields as $field) { |
1418 | 1418 | if ($label === EEH_Export::get_column_name_for_field($field)) { |
1419 | 1419 | // re-add the old field name |
1420 | - $new_label = $label . '[' . $field->get_name() . ']'; |
|
1420 | + $new_label = $label.'['.$field->get_name().']'; |
|
1421 | 1421 | break; |
1422 | 1422 | } |
1423 | 1423 | } |
@@ -39,31 +39,31 @@ discard block |
||
39 | 39 | * @param string $action_or_filter |
40 | 40 | */ |
41 | 41 | function deprecated_espresso_action_or_filter_doing_it_wrong( |
42 | - $deprecated_filter, |
|
43 | - $replacement, |
|
44 | - $replacement_location, |
|
45 | - $version_deprecated, |
|
46 | - $version_applies, |
|
47 | - $action_or_filter = 'action' |
|
42 | + $deprecated_filter, |
|
43 | + $replacement, |
|
44 | + $replacement_location, |
|
45 | + $version_deprecated, |
|
46 | + $version_applies, |
|
47 | + $action_or_filter = 'action' |
|
48 | 48 | ) { |
49 | - $action_or_filter = $action_or_filter === 'action' |
|
50 | - ? esc_html__('action', 'event_espresso') |
|
51 | - : esc_html__('filter', 'event_espresso'); |
|
52 | - EE_Error::doing_it_wrong( |
|
53 | - $deprecated_filter, |
|
54 | - sprintf( |
|
55 | - __( |
|
56 | - 'This %1$s is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - $action_or_filter, |
|
60 | - $replacement, |
|
61 | - $replacement_location, |
|
62 | - '<br />' |
|
63 | - ), |
|
64 | - $version_deprecated, |
|
65 | - $version_applies |
|
66 | - ); |
|
49 | + $action_or_filter = $action_or_filter === 'action' |
|
50 | + ? esc_html__('action', 'event_espresso') |
|
51 | + : esc_html__('filter', 'event_espresso'); |
|
52 | + EE_Error::doing_it_wrong( |
|
53 | + $deprecated_filter, |
|
54 | + sprintf( |
|
55 | + __( |
|
56 | + 'This %1$s is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + $action_or_filter, |
|
60 | + $replacement, |
|
61 | + $replacement_location, |
|
62 | + '<br />' |
|
63 | + ), |
|
64 | + $version_deprecated, |
|
65 | + $version_applies |
|
66 | + ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,90 +75,90 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) |
77 | 77 | { |
78 | - // list of old filters |
|
79 | - $deprecated_filters = array( |
|
80 | - 'update_registration_details' => true, |
|
81 | - 'process_payment' => true, |
|
82 | - 'finalize_registration' => true, |
|
83 | - 'and_proceed_to_payment' => true, |
|
84 | - 'proceed_to' => true, |
|
85 | - ); |
|
86 | - // loop thru and call doing_it_wrong() or remove any that aren't being used |
|
87 | - foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
88 | - // was this filter called ? |
|
89 | - if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
90 | - // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
|
91 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
92 | - 'ee_read_ee', |
|
93 | - 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
|
94 | - ) && ! defined('DOING_AJAX')) { |
|
95 | - EE_Error::doing_it_wrong( |
|
96 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
97 | - sprintf( |
|
98 | - __( |
|
99 | - 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
103 | - '<br />', |
|
104 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
105 | - '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
|
106 | - ), |
|
107 | - '4.6.10' |
|
108 | - ); |
|
109 | - } |
|
110 | - } else { |
|
111 | - unset($deprecated_filters[ $deprecated_filter ]); |
|
112 | - } |
|
113 | - } |
|
114 | - if (! empty($deprecated_filters)) { |
|
115 | - |
|
116 | - if ($checkout->current_step->slug( |
|
117 | - ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
118 | - $submit_button_text = apply_filters( |
|
119 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', |
|
120 | - $submit_button_text |
|
121 | - ); |
|
122 | - } elseif ($checkout->current_step->slug( |
|
123 | - ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
124 | - $submit_button_text = apply_filters( |
|
125 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', |
|
126 | - $submit_button_text |
|
127 | - ); |
|
128 | - } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug( |
|
129 | - ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
130 | - $submit_button_text = apply_filters( |
|
131 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', |
|
132 | - $submit_button_text |
|
133 | - ); |
|
134 | - } |
|
135 | - if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
136 | - if ($checkout->payment_required() && $checkout->next_step->slug( |
|
137 | - ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
138 | - $submit_button_text .= apply_filters( |
|
139 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', |
|
140 | - $submit_button_text |
|
141 | - ); |
|
142 | - } |
|
143 | - if ($checkout->next_step->slug( |
|
144 | - ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
145 | - $submit_button_text = apply_filters( |
|
146 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
|
147 | - $submit_button_text |
|
148 | - ) . $checkout->next_step->name(); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - } |
|
153 | - return $submit_button_text; |
|
78 | + // list of old filters |
|
79 | + $deprecated_filters = array( |
|
80 | + 'update_registration_details' => true, |
|
81 | + 'process_payment' => true, |
|
82 | + 'finalize_registration' => true, |
|
83 | + 'and_proceed_to_payment' => true, |
|
84 | + 'proceed_to' => true, |
|
85 | + ); |
|
86 | + // loop thru and call doing_it_wrong() or remove any that aren't being used |
|
87 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
88 | + // was this filter called ? |
|
89 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
90 | + // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
|
91 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
92 | + 'ee_read_ee', |
|
93 | + 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
|
94 | + ) && ! defined('DOING_AJAX')) { |
|
95 | + EE_Error::doing_it_wrong( |
|
96 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
97 | + sprintf( |
|
98 | + __( |
|
99 | + 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
103 | + '<br />', |
|
104 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
105 | + '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
|
106 | + ), |
|
107 | + '4.6.10' |
|
108 | + ); |
|
109 | + } |
|
110 | + } else { |
|
111 | + unset($deprecated_filters[ $deprecated_filter ]); |
|
112 | + } |
|
113 | + } |
|
114 | + if (! empty($deprecated_filters)) { |
|
115 | + |
|
116 | + if ($checkout->current_step->slug( |
|
117 | + ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
118 | + $submit_button_text = apply_filters( |
|
119 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', |
|
120 | + $submit_button_text |
|
121 | + ); |
|
122 | + } elseif ($checkout->current_step->slug( |
|
123 | + ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
124 | + $submit_button_text = apply_filters( |
|
125 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', |
|
126 | + $submit_button_text |
|
127 | + ); |
|
128 | + } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug( |
|
129 | + ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
130 | + $submit_button_text = apply_filters( |
|
131 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', |
|
132 | + $submit_button_text |
|
133 | + ); |
|
134 | + } |
|
135 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
136 | + if ($checkout->payment_required() && $checkout->next_step->slug( |
|
137 | + ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
138 | + $submit_button_text .= apply_filters( |
|
139 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', |
|
140 | + $submit_button_text |
|
141 | + ); |
|
142 | + } |
|
143 | + if ($checkout->next_step->slug( |
|
144 | + ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
145 | + $submit_button_text = apply_filters( |
|
146 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
|
147 | + $submit_button_text |
|
148 | + ) . $checkout->next_step->name(); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + } |
|
153 | + return $submit_button_text; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | 157 | add_filter( |
158 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
159 | - 'ee_deprecated__registration_checkout__button_text', |
|
160 | - 10, |
|
161 | - 2 |
|
158 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
159 | + 'ee_deprecated__registration_checkout__button_text', |
|
160 | + 10, |
|
161 | + 2 |
|
162 | 162 | ); |
163 | 163 | |
164 | 164 | |
@@ -170,54 +170,54 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) |
172 | 172 | { |
173 | - $action_ref = null; |
|
174 | - $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') |
|
175 | - ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
176 | - $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') |
|
177 | - ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
178 | - if ($action_ref) { |
|
179 | - |
|
180 | - EE_Error::doing_it_wrong( |
|
181 | - $action_ref, |
|
182 | - sprintf( |
|
183 | - __( |
|
184 | - 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', |
|
185 | - 'event_espresso' |
|
186 | - ), |
|
187 | - '<br />', |
|
188 | - '/core/business/EE_Transaction_Processor.class.php', |
|
189 | - 'AHEE__EE_Transaction_Processor__finalize', |
|
190 | - 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
|
191 | - 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', |
|
192 | - 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing' |
|
193 | - ), |
|
194 | - '4.6.0' |
|
195 | - ); |
|
196 | - switch ($action_ref) { |
|
197 | - case 'AHEE__EE_Transaction__finalize__new_transaction' : |
|
198 | - do_action( |
|
199 | - 'AHEE__EE_Transaction__finalize__new_transaction', |
|
200 | - $checkout->transaction, |
|
201 | - $checkout->admin_request |
|
202 | - ); |
|
203 | - break; |
|
204 | - case 'AHEE__EE_Transaction__finalize__all_transaction' : |
|
205 | - do_action( |
|
206 | - 'AHEE__EE_Transaction__finalize__new_transaction', |
|
207 | - $checkout->transaction, |
|
208 | - array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), |
|
209 | - $checkout->admin_request |
|
210 | - ); |
|
211 | - break; |
|
212 | - } |
|
213 | - } |
|
173 | + $action_ref = null; |
|
174 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') |
|
175 | + ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
176 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') |
|
177 | + ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
178 | + if ($action_ref) { |
|
179 | + |
|
180 | + EE_Error::doing_it_wrong( |
|
181 | + $action_ref, |
|
182 | + sprintf( |
|
183 | + __( |
|
184 | + 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', |
|
185 | + 'event_espresso' |
|
186 | + ), |
|
187 | + '<br />', |
|
188 | + '/core/business/EE_Transaction_Processor.class.php', |
|
189 | + 'AHEE__EE_Transaction_Processor__finalize', |
|
190 | + 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
|
191 | + 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', |
|
192 | + 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing' |
|
193 | + ), |
|
194 | + '4.6.0' |
|
195 | + ); |
|
196 | + switch ($action_ref) { |
|
197 | + case 'AHEE__EE_Transaction__finalize__new_transaction' : |
|
198 | + do_action( |
|
199 | + 'AHEE__EE_Transaction__finalize__new_transaction', |
|
200 | + $checkout->transaction, |
|
201 | + $checkout->admin_request |
|
202 | + ); |
|
203 | + break; |
|
204 | + case 'AHEE__EE_Transaction__finalize__all_transaction' : |
|
205 | + do_action( |
|
206 | + 'AHEE__EE_Transaction__finalize__new_transaction', |
|
207 | + $checkout->transaction, |
|
208 | + array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), |
|
209 | + $checkout->admin_request |
|
210 | + ); |
|
211 | + break; |
|
212 | + } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | add_action( |
217 | - 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
|
218 | - 'ee_deprecated_finalize_transaction', |
|
219 | - 10, |
|
220 | - 2 |
|
217 | + 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
|
218 | + 'ee_deprecated_finalize_transaction', |
|
219 | + 10, |
|
220 | + 2 |
|
221 | 221 | ); |
222 | 222 | /** |
223 | 223 | * ee_deprecated_finalize_registration |
@@ -226,35 +226,35 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function ee_deprecated_finalize_registration(EE_Registration $registration) |
228 | 228 | { |
229 | - $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') |
|
230 | - ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null; |
|
231 | - if ($action_ref) { |
|
232 | - EE_Error::doing_it_wrong( |
|
233 | - $action_ref, |
|
234 | - sprintf( |
|
235 | - __( |
|
236 | - 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', |
|
237 | - 'event_espresso' |
|
238 | - ), |
|
239 | - '<br />', |
|
240 | - '/core/business/EE_Registration_Processor.class.php', |
|
241 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications' |
|
242 | - ), |
|
243 | - '4.6.0' |
|
244 | - ); |
|
245 | - do_action( |
|
246 | - 'AHEE__EE_Registration__finalize__update_and_new_reg', |
|
247 | - $registration, |
|
248 | - (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) |
|
249 | - ); |
|
250 | - } |
|
229 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') |
|
230 | + ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null; |
|
231 | + if ($action_ref) { |
|
232 | + EE_Error::doing_it_wrong( |
|
233 | + $action_ref, |
|
234 | + sprintf( |
|
235 | + __( |
|
236 | + 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', |
|
237 | + 'event_espresso' |
|
238 | + ), |
|
239 | + '<br />', |
|
240 | + '/core/business/EE_Registration_Processor.class.php', |
|
241 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications' |
|
242 | + ), |
|
243 | + '4.6.0' |
|
244 | + ); |
|
245 | + do_action( |
|
246 | + 'AHEE__EE_Registration__finalize__update_and_new_reg', |
|
247 | + $registration, |
|
248 | + (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) |
|
249 | + ); |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | add_action( |
254 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
255 | - 'ee_deprecated_finalize_registration', |
|
256 | - 10, |
|
257 | - 1 |
|
254 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
255 | + 'ee_deprecated_finalize_registration', |
|
256 | + 10, |
|
257 | + 1 |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | |
@@ -264,44 +264,44 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function ee_deprecated_hooks() |
266 | 266 | { |
267 | - /** |
|
268 | - * @var $hooks array where keys are hook names, and their values are array{ |
|
269 | - * @type string $version when deprecated |
|
270 | - * @type string $alternative saying what to use instead |
|
271 | - * @type boolean $still_works whether or not the hook still works |
|
272 | - * } |
|
273 | - */ |
|
274 | - $hooks = array( |
|
275 | - 'AHEE__EE_System___do_setup_validations' => array( |
|
276 | - 'version' => '4.6.0', |
|
277 | - 'alternative' => __( |
|
278 | - 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', |
|
279 | - 'event_espresso' |
|
280 | - ), |
|
281 | - 'still_works' => false, |
|
282 | - ), |
|
283 | - ); |
|
284 | - foreach ($hooks as $name => $deprecation_info) { |
|
285 | - if (has_action($name)) { |
|
286 | - EE_Error::doing_it_wrong( |
|
287 | - $name, |
|
288 | - sprintf( |
|
289 | - __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
290 | - $deprecation_info['still_works'] ? __( |
|
291 | - 'It *may* work as an attempt to build in backwards compatibility.', |
|
292 | - 'event_espresso' |
|
293 | - ) : __('It has been completely removed.', 'event_espresso'), |
|
294 | - isset($deprecation_info['alternative']) |
|
295 | - ? $deprecation_info['alternative'] |
|
296 | - : __( |
|
297 | - 'Please read the current EE4 documentation further or contact Support.', |
|
298 | - 'event_espresso' |
|
299 | - ) |
|
300 | - ), |
|
301 | - isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
302 | - ); |
|
303 | - } |
|
304 | - } |
|
267 | + /** |
|
268 | + * @var $hooks array where keys are hook names, and their values are array{ |
|
269 | + * @type string $version when deprecated |
|
270 | + * @type string $alternative saying what to use instead |
|
271 | + * @type boolean $still_works whether or not the hook still works |
|
272 | + * } |
|
273 | + */ |
|
274 | + $hooks = array( |
|
275 | + 'AHEE__EE_System___do_setup_validations' => array( |
|
276 | + 'version' => '4.6.0', |
|
277 | + 'alternative' => __( |
|
278 | + 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', |
|
279 | + 'event_espresso' |
|
280 | + ), |
|
281 | + 'still_works' => false, |
|
282 | + ), |
|
283 | + ); |
|
284 | + foreach ($hooks as $name => $deprecation_info) { |
|
285 | + if (has_action($name)) { |
|
286 | + EE_Error::doing_it_wrong( |
|
287 | + $name, |
|
288 | + sprintf( |
|
289 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
290 | + $deprecation_info['still_works'] ? __( |
|
291 | + 'It *may* work as an attempt to build in backwards compatibility.', |
|
292 | + 'event_espresso' |
|
293 | + ) : __('It has been completely removed.', 'event_espresso'), |
|
294 | + isset($deprecation_info['alternative']) |
|
295 | + ? $deprecation_info['alternative'] |
|
296 | + : __( |
|
297 | + 'Please read the current EE4 documentation further or contact Support.', |
|
298 | + 'event_espresso' |
|
299 | + ) |
|
300 | + ), |
|
301 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
302 | + ); |
|
303 | + } |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
@@ -316,34 +316,34 @@ discard block |
||
316 | 316 | */ |
317 | 317 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
318 | 318 | { |
319 | - $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
320 | - || has_action( |
|
321 | - 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' |
|
322 | - ); |
|
323 | - if ($in_use) { |
|
324 | - $msg = __( |
|
325 | - 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
|
326 | - . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
|
327 | - . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end ' |
|
328 | - . 'to add other actions after a form submission has been received.', |
|
329 | - 'event_espresso' |
|
330 | - ); |
|
331 | - EE_Error::doing_it_wrong( |
|
332 | - __CLASS__ . '::' . __FUNCTION__, |
|
333 | - $msg, |
|
334 | - '4.8.32.rc.000' |
|
335 | - ); |
|
336 | - // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
|
337 | - if (is_admin() && ! defined('DOING_AJAX')) { |
|
338 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
339 | - } |
|
340 | - } |
|
341 | - return $in_use; |
|
319 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
320 | + || has_action( |
|
321 | + 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' |
|
322 | + ); |
|
323 | + if ($in_use) { |
|
324 | + $msg = __( |
|
325 | + 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
|
326 | + . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
|
327 | + . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end ' |
|
328 | + . 'to add other actions after a form submission has been received.', |
|
329 | + 'event_espresso' |
|
330 | + ); |
|
331 | + EE_Error::doing_it_wrong( |
|
332 | + __CLASS__ . '::' . __FUNCTION__, |
|
333 | + $msg, |
|
334 | + '4.8.32.rc.000' |
|
335 | + ); |
|
336 | + // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
|
337 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
338 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
339 | + } |
|
340 | + } |
|
341 | + return $in_use; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | add_action( |
345 | - 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', |
|
346 | - 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' |
|
345 | + 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', |
|
346 | + 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | /** |
@@ -355,77 +355,77 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function ee_deprecated_update_attendee_registration_form_old($admin_page) |
357 | 357 | { |
358 | - // check if the old hooks are in use. If not, do the default |
|
359 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
360 | - || ! $admin_page instanceof EE_Admin_Page) { |
|
361 | - return; |
|
362 | - } |
|
363 | - $req_data = $admin_page->get_request_data(); |
|
364 | - $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
|
365 | - $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
|
366 | - $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
367 | - if (! $REG_ID || ! $qstns) { |
|
368 | - EE_Error::add_error( |
|
369 | - __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
|
370 | - __FILE__, |
|
371 | - __FUNCTION__, |
|
372 | - __LINE__ |
|
373 | - ); |
|
374 | - } |
|
375 | - $success = true; |
|
376 | - |
|
377 | - // allow others to get in on this awesome fun :D |
|
378 | - do_action( |
|
379 | - 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', |
|
380 | - $REG_ID, |
|
381 | - $qstns |
|
382 | - ); |
|
383 | - // loop thru questions... FINALLY!!! |
|
384 | - |
|
385 | - foreach ($qstns as $QST_ID => $qstn) { |
|
386 | - // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
|
387 | - if (! is_array($qstn)) { |
|
388 | - $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
389 | - continue; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - foreach ($qstn as $ANS_ID => $ANS_value) { |
|
394 | - // get answer |
|
395 | - $query_params = array( |
|
396 | - 0 => array( |
|
397 | - 'ANS_ID' => $ANS_ID, |
|
398 | - 'REG_ID' => $REG_ID, |
|
399 | - 'QST_ID' => $QST_ID, |
|
400 | - ), |
|
401 | - ); |
|
402 | - $answer = EEM_Answer::instance()->get_one($query_params); |
|
403 | - // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
|
404 | - if (! $answer instanceof EE_Answer) { |
|
405 | - $set_values = array( |
|
406 | - 'QST_ID' => $QST_ID, |
|
407 | - 'REG_ID' => $REG_ID, |
|
408 | - 'ANS_value' => $qstn, |
|
409 | - ); |
|
410 | - $success = EEM_Answer::instance()->insert($set_values); |
|
411 | - continue 2; |
|
412 | - } |
|
413 | - |
|
414 | - $answer->set('ANS_value', $ANS_value); |
|
415 | - $success = $answer->save(); |
|
416 | - } |
|
417 | - } |
|
418 | - $what = __('Registration Form', 'event_espresso'); |
|
419 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
420 | - $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
421 | - exit; |
|
358 | + // check if the old hooks are in use. If not, do the default |
|
359 | + if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
360 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
361 | + return; |
|
362 | + } |
|
363 | + $req_data = $admin_page->get_request_data(); |
|
364 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
|
365 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
|
366 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
367 | + if (! $REG_ID || ! $qstns) { |
|
368 | + EE_Error::add_error( |
|
369 | + __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
|
370 | + __FILE__, |
|
371 | + __FUNCTION__, |
|
372 | + __LINE__ |
|
373 | + ); |
|
374 | + } |
|
375 | + $success = true; |
|
376 | + |
|
377 | + // allow others to get in on this awesome fun :D |
|
378 | + do_action( |
|
379 | + 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', |
|
380 | + $REG_ID, |
|
381 | + $qstns |
|
382 | + ); |
|
383 | + // loop thru questions... FINALLY!!! |
|
384 | + |
|
385 | + foreach ($qstns as $QST_ID => $qstn) { |
|
386 | + // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
|
387 | + if (! is_array($qstn)) { |
|
388 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
389 | + continue; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
394 | + // get answer |
|
395 | + $query_params = array( |
|
396 | + 0 => array( |
|
397 | + 'ANS_ID' => $ANS_ID, |
|
398 | + 'REG_ID' => $REG_ID, |
|
399 | + 'QST_ID' => $QST_ID, |
|
400 | + ), |
|
401 | + ); |
|
402 | + $answer = EEM_Answer::instance()->get_one($query_params); |
|
403 | + // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
|
404 | + if (! $answer instanceof EE_Answer) { |
|
405 | + $set_values = array( |
|
406 | + 'QST_ID' => $QST_ID, |
|
407 | + 'REG_ID' => $REG_ID, |
|
408 | + 'ANS_value' => $qstn, |
|
409 | + ); |
|
410 | + $success = EEM_Answer::instance()->insert($set_values); |
|
411 | + continue 2; |
|
412 | + } |
|
413 | + |
|
414 | + $answer->set('ANS_value', $ANS_value); |
|
415 | + $success = $answer->save(); |
|
416 | + } |
|
417 | + } |
|
418 | + $what = __('Registration Form', 'event_espresso'); |
|
419 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
420 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
421 | + exit; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | add_action( |
425 | - 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', |
|
426 | - 'ee_deprecated_update_attendee_registration_form_old', |
|
427 | - 10, |
|
428 | - 1 |
|
425 | + 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', |
|
426 | + 'ee_deprecated_update_attendee_registration_form_old', |
|
427 | + 10, |
|
428 | + 1 |
|
429 | 429 | ); |
430 | 430 | /** |
431 | 431 | * Render the registration admin page's custom questions area in the old fashion |
@@ -441,50 +441,50 @@ discard block |
||
441 | 441 | */ |
442 | 442 | function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) |
443 | 443 | { |
444 | - // check if the old hooks are in use. If not, do the default |
|
445 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
446 | - || ! $admin_page instanceof EE_Admin_Page) { |
|
447 | - return $do_default_action; |
|
448 | - } |
|
449 | - add_filter( |
|
450 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
451 | - array($admin_page, 'form_before_question_group'), |
|
452 | - 10, |
|
453 | - 1 |
|
454 | - ); |
|
455 | - add_filter( |
|
456 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
457 | - array($admin_page, 'form_after_question_group'), |
|
458 | - 10, |
|
459 | - 1 |
|
460 | - ); |
|
461 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
462 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
463 | - |
|
464 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( |
|
465 | - $registration, |
|
466 | - $registration->get( |
|
467 | - 'EVT_ID' |
|
468 | - ) |
|
469 | - ); |
|
470 | - |
|
471 | - EE_Registry::instance()->load_helper('Form_Fields'); |
|
472 | - $template_args = array( |
|
473 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
474 | - 'reg_questions_form_action' => 'edit_registration', |
|
475 | - 'REG_ID' => $registration->ID(), |
|
476 | - ); |
|
477 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
478 | - echo EEH_Template::display_template($template_path, $template_args, true); |
|
479 | - // indicate that we should not do the default admin page code |
|
480 | - return false; |
|
444 | + // check if the old hooks are in use. If not, do the default |
|
445 | + if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
446 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
447 | + return $do_default_action; |
|
448 | + } |
|
449 | + add_filter( |
|
450 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
451 | + array($admin_page, 'form_before_question_group'), |
|
452 | + 10, |
|
453 | + 1 |
|
454 | + ); |
|
455 | + add_filter( |
|
456 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
457 | + array($admin_page, 'form_after_question_group'), |
|
458 | + 10, |
|
459 | + 1 |
|
460 | + ); |
|
461 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
462 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
463 | + |
|
464 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( |
|
465 | + $registration, |
|
466 | + $registration->get( |
|
467 | + 'EVT_ID' |
|
468 | + ) |
|
469 | + ); |
|
470 | + |
|
471 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
472 | + $template_args = array( |
|
473 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
474 | + 'reg_questions_form_action' => 'edit_registration', |
|
475 | + 'REG_ID' => $registration->ID(), |
|
476 | + ); |
|
477 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
478 | + echo EEH_Template::display_template($template_path, $template_args, true); |
|
479 | + // indicate that we should not do the default admin page code |
|
480 | + return false; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | add_action( |
484 | - 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', |
|
485 | - 'ee_deprecated_reg_questions_meta_box_old', |
|
486 | - 10, |
|
487 | - 3 |
|
484 | + 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', |
|
485 | + 'ee_deprecated_reg_questions_meta_box_old', |
|
486 | + 10, |
|
487 | + 3 |
|
488 | 488 | ); |
489 | 489 | |
490 | 490 | |
@@ -501,42 +501,42 @@ discard block |
||
501 | 501 | class EE_Message_Template_Defaults extends EE_Base |
502 | 502 | { |
503 | 503 | |
504 | - /** |
|
505 | - * EE_Message_Template_Defaults constructor. |
|
506 | - * |
|
507 | - * @param EE_messages $messages |
|
508 | - * @param $messenger_name |
|
509 | - * @param $message_type_name |
|
510 | - * @param int $GRP_ID |
|
511 | - * @return EE_Messages_Template_Defaults |
|
512 | - */ |
|
513 | - public function __construct( |
|
514 | - EE_messages $messages, |
|
515 | - $messenger_name, |
|
516 | - $message_type_name, |
|
517 | - $GRP_ID = 0 |
|
518 | - ) { |
|
519 | - EE_Error::doing_it_wrong( |
|
520 | - __FUNCTION__, |
|
521 | - __( |
|
522 | - 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
523 | - 'event_espresso' |
|
524 | - ), |
|
525 | - '4.9.0' |
|
526 | - ); |
|
527 | - /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
528 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
529 | - $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
530 | - $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
531 | - return EE_Registry::instance()->load_lib( |
|
532 | - 'Messages_Template_Defaults', |
|
533 | - array( |
|
534 | - $GRP_ID, |
|
535 | - $messenger, |
|
536 | - $message_type, |
|
537 | - ) |
|
538 | - ); |
|
539 | - } |
|
504 | + /** |
|
505 | + * EE_Message_Template_Defaults constructor. |
|
506 | + * |
|
507 | + * @param EE_messages $messages |
|
508 | + * @param $messenger_name |
|
509 | + * @param $message_type_name |
|
510 | + * @param int $GRP_ID |
|
511 | + * @return EE_Messages_Template_Defaults |
|
512 | + */ |
|
513 | + public function __construct( |
|
514 | + EE_messages $messages, |
|
515 | + $messenger_name, |
|
516 | + $message_type_name, |
|
517 | + $GRP_ID = 0 |
|
518 | + ) { |
|
519 | + EE_Error::doing_it_wrong( |
|
520 | + __FUNCTION__, |
|
521 | + __( |
|
522 | + 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
523 | + 'event_espresso' |
|
524 | + ), |
|
525 | + '4.9.0' |
|
526 | + ); |
|
527 | + /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
528 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
529 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
530 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
531 | + return EE_Registry::instance()->load_lib( |
|
532 | + 'Messages_Template_Defaults', |
|
533 | + array( |
|
534 | + $GRP_ID, |
|
535 | + $messenger, |
|
536 | + $message_type, |
|
537 | + ) |
|
538 | + ); |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -554,525 +554,525 @@ discard block |
||
554 | 554 | class EE_messages |
555 | 555 | { |
556 | 556 | |
557 | - /** @type EE_messenger[] */ |
|
558 | - protected $_active_messengers = array(); |
|
559 | - |
|
560 | - /** @type array */ |
|
561 | - protected $_active_message_types = array(); |
|
562 | - |
|
563 | - /** @type EE_message_type[] */ |
|
564 | - protected $_installed_message_types = array(); |
|
565 | - |
|
566 | - /** @type EE_messenger */ |
|
567 | - protected $_messenger; |
|
568 | - |
|
569 | - /** @type EE_message_type */ |
|
570 | - protected $_message_type; |
|
571 | - |
|
572 | - /** @type array */ |
|
573 | - protected $_contexts = array(); |
|
574 | - |
|
575 | - /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
576 | - protected $_message_resource_manager; |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * EE_messages constructor. |
|
581 | - * |
|
582 | - * @deprecated 4.9.0 |
|
583 | - */ |
|
584 | - public function __construct() |
|
585 | - { |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * @param string $method |
|
591 | - */ |
|
592 | - public function _class_is_deprecated($method) |
|
593 | - { |
|
594 | - EE_Error::doing_it_wrong( |
|
595 | - 'EE_messages::' . $method, |
|
596 | - __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
597 | - '4.9.0', |
|
598 | - '4.10.0.p' |
|
599 | - ); |
|
600 | - // Please use EE_Message_Resource_Manager instead |
|
601 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * @deprecated 4.9.0 |
|
607 | - * @param string $messenger_name |
|
608 | - * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
609 | - */ |
|
610 | - public function ensure_messenger_is_active($messenger_name) |
|
611 | - { |
|
612 | - // EE_messages has been deprecated |
|
613 | - $this->_class_is_deprecated(__FUNCTION__); |
|
614 | - return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * @deprecated 4.9.0 |
|
620 | - * @param string $message_type message type name |
|
621 | - * @param $messenger |
|
622 | - * @return bool true if it got activated (or was active) and false if not. |
|
623 | - * @throws \EE_Error |
|
624 | - */ |
|
625 | - public function ensure_message_type_is_active($message_type, $messenger) |
|
626 | - { |
|
627 | - // EE_messages has been deprecated |
|
628 | - $this->_class_is_deprecated(__FUNCTION__); |
|
629 | - return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * @deprecated 4.9.0 |
|
635 | - * @param string $messenger_name |
|
636 | - * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
637 | - * If included we do NOT setup the default message types (assuming they |
|
638 | - * are already setup.) |
|
639 | - * @return boolean an array of generated templates or false if nothing generated/activated. |
|
640 | - */ |
|
641 | - public function activate_messenger($messenger_name, $mts_to_activate = array()) |
|
642 | - { |
|
643 | - // EE_messages has been deprecated |
|
644 | - $this->_class_is_deprecated(__FUNCTION__); |
|
645 | - return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
646 | - } |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * @deprecated 4.9.0 |
|
651 | - * @param EE_messenger $messenger messenger used in trigger |
|
652 | - * @param EE_message_type $message_type message type used in trigger |
|
653 | - * |
|
654 | - * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
655 | - */ |
|
656 | - public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
657 | - { |
|
658 | - // EE_messages has been deprecated |
|
659 | - $this->_class_is_deprecated(__FUNCTION__); |
|
660 | - return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * @deprecated 4.9.0 |
|
666 | - * @param string $messenger |
|
667 | - * @return EE_messenger | null |
|
668 | - */ |
|
669 | - public function get_messenger_if_active($messenger) |
|
670 | - { |
|
671 | - // EE_messages has been deprecated |
|
672 | - $this->_class_is_deprecated(__FUNCTION__); |
|
673 | - return $this->_message_resource_manager->get_active_messenger($messenger); |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - /** |
|
678 | - * @deprecated 4.9.0 |
|
679 | - * @param EE_Message $message |
|
680 | - * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
681 | - * available. |
|
682 | - * Eg. Valid Messenger and Message Type: |
|
683 | - * array( |
|
684 | - * 'messenger' => new EE_Email_messenger(), |
|
685 | - * 'message_type' => new EE_Registration_Approved_message_type() |
|
686 | - * ) |
|
687 | - * Valid Messenger and Invalid Message Type: |
|
688 | - * array( |
|
689 | - * 'messenger' => new EE_Email_messenger(), |
|
690 | - * 'message_type' => null |
|
691 | - * ) |
|
692 | - */ |
|
693 | - public function validate_for_use(EE_Message $message) |
|
694 | - { |
|
695 | - // EE_messages has been deprecated |
|
696 | - $this->_class_is_deprecated(__FUNCTION__); |
|
697 | - return array( |
|
698 | - 'messenger' => $message->messenger_object(), |
|
699 | - 'message_type' => $message->message_type_object(), |
|
700 | - ); |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * @deprecated 4.9.0 |
|
706 | - * @param string $type What type of message are we sending (corresponds to message types) |
|
707 | - * @param mixed $vars Data being sent for parsing in the message |
|
708 | - * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
709 | - * Otherwise we cycle through all active messengers. |
|
710 | - * @param string $generating_messenger if included then this messenger is used for generating the message |
|
711 | - * templates (but not for sending). |
|
712 | - * @param string $context If included then only a message type for a specific context will be |
|
713 | - * generated. |
|
714 | - * @param bool $send Default TRUE. If false, then this will just return the generated |
|
715 | - * EE_messages objects which might be used by the trigger to setup a batch |
|
716 | - * message (typically html messenger uses it). |
|
717 | - * @return bool |
|
718 | - */ |
|
719 | - public function send_message( |
|
720 | - $type, |
|
721 | - $vars, |
|
722 | - $sending_messenger = '', |
|
723 | - $generating_messenger = '', |
|
724 | - $context = '', |
|
725 | - $send = true |
|
726 | - ) { |
|
727 | - // EE_messages has been deprecated |
|
728 | - $this->_class_is_deprecated(__FUNCTION__); |
|
729 | - /** @type EE_Messages_Processor $processor */ |
|
730 | - $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
731 | - $error = false; |
|
732 | - // try to intelligently determine what method we'll call based on the incoming data. |
|
733 | - // if generating and sending are different then generate and send immediately. |
|
734 | - if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
735 | - // in the legacy system, when generating and sending were different, that means all the |
|
736 | - // vars are already in the request object. So let's just use that. |
|
737 | - try { |
|
738 | - /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
739 | - $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
740 | - $processor->generate_and_send_now($mtg); |
|
741 | - } catch (EE_Error $e) { |
|
742 | - $error_msg = __( |
|
743 | - 'Please note that a system message failed to send due to a technical issue.', |
|
744 | - 'event_espresso' |
|
745 | - ); |
|
746 | - // add specific message for developers if WP_DEBUG in on |
|
747 | - $error_msg .= '||' . $e->getMessage(); |
|
748 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
749 | - $error = true; |
|
750 | - } |
|
751 | - } else { |
|
752 | - $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
753 | - // let's find out if there were any errors and how many successfully were queued. |
|
754 | - $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
755 | - array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
756 | - ); |
|
757 | - $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
758 | - $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
759 | - $count_errors = $count_errors + $count_retry; |
|
760 | - if ($count_errors > 0) { |
|
761 | - $error = true; |
|
762 | - if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
763 | - $message = sprintf( |
|
764 | - __( |
|
765 | - 'There were %d errors and %d messages successfully queued for generation and sending', |
|
766 | - 'event_espresso' |
|
767 | - ), |
|
768 | - $count_errors, |
|
769 | - $count_queued |
|
770 | - ); |
|
771 | - } elseif ($count_errors > 1 && $count_queued === 1) { |
|
772 | - $message = sprintf( |
|
773 | - __( |
|
774 | - 'There were %d errors and %d message successfully queued for generation.', |
|
775 | - 'event_espresso' |
|
776 | - ), |
|
777 | - $count_errors, |
|
778 | - $count_queued |
|
779 | - ); |
|
780 | - } elseif ($count_errors === 1 && $count_queued > 1) { |
|
781 | - $message = sprintf( |
|
782 | - __( |
|
783 | - 'There was %d error and %d messages successfully queued for generation.', |
|
784 | - 'event_espresso' |
|
785 | - ), |
|
786 | - $count_errors, |
|
787 | - $count_queued |
|
788 | - ); |
|
789 | - } else { |
|
790 | - $message = sprintf( |
|
791 | - __( |
|
792 | - 'There was %d message that failed to be queued for generation.', |
|
793 | - 'event_espresso' |
|
794 | - ), |
|
795 | - $count_errors |
|
796 | - ); |
|
797 | - } |
|
798 | - EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
799 | - } else { |
|
800 | - if ($count_queued === 1) { |
|
801 | - $message = sprintf( |
|
802 | - __( |
|
803 | - '%d message successfully queued for generation.', |
|
804 | - 'event_espresso' |
|
805 | - ), |
|
806 | - $count_queued |
|
807 | - ); |
|
808 | - } else { |
|
809 | - $message = sprintf( |
|
810 | - __( |
|
811 | - '%d messages were successfully queued for generation.', |
|
812 | - 'event_espresso' |
|
813 | - ), |
|
814 | - $count_queued |
|
815 | - ); |
|
816 | - } |
|
817 | - EE_Error::add_success($message); |
|
818 | - } |
|
819 | - } |
|
820 | - // if no error then return the generated message(s). |
|
821 | - if (! $error && ! $send) { |
|
822 | - $generated_queue = $processor->generate_queue(false); |
|
823 | - // get message and return. |
|
824 | - $generated_queue->get_message_repository()->rewind(); |
|
825 | - $messages = array(); |
|
826 | - while ($generated_queue->get_message_repository()->valid()) { |
|
827 | - $message = $generated_queue->get_message_repository()->current(); |
|
828 | - if ($message instanceof EE_Message) { |
|
829 | - // set properties that might be expected by add-ons (backward compat) |
|
830 | - $message->content = $message->content(); |
|
831 | - $message->template_pack = $message->get_template_pack(); |
|
832 | - $message->template_variation = $message->get_template_pack_variation(); |
|
833 | - $messages[] = $message; |
|
834 | - } |
|
835 | - $generated_queue->get_message_repository()->next(); |
|
836 | - } |
|
837 | - return $messages; |
|
838 | - } |
|
839 | - return $error ? false |
|
840 | - : true; // yeah backwards eh? Really what we're returning is if there is a total success for all the messages or not. We'll modify this once we get message recording in place. |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * @deprecated 4.9.0 |
|
846 | - * @param string $type This should correspond with a valid message type |
|
847 | - * @param string $context This should correspond with a valid context for the message type |
|
848 | - * @param string $messenger This should correspond with a valid messenger. |
|
849 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
850 | - * preview |
|
851 | - * @return string The body of the message. |
|
852 | - */ |
|
853 | - public function preview_message($type, $context, $messenger, $send = false) |
|
854 | - { |
|
855 | - // EE_messages has been deprecated |
|
856 | - $this->_class_is_deprecated(__FUNCTION__); |
|
857 | - return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
858 | - } |
|
859 | - |
|
860 | - |
|
861 | - /** |
|
862 | - * @since 4.5.0 |
|
863 | - * @deprecated 4.9.0 Moved to EED_Messages Module |
|
864 | - * @param string $messenger a string matching a valid active messenger in the system |
|
865 | - * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
866 | - * required to send along the message type to the messenger because this is used for |
|
867 | - * determining what specific variations might be loaded for the generated message. |
|
868 | - * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
869 | - * |
|
870 | - * @return bool success or fail. |
|
871 | - */ |
|
872 | - public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
873 | - { |
|
874 | - // EE_messages has been deprecated |
|
875 | - $this->_class_is_deprecated(__FUNCTION__); |
|
876 | - // setup for sending to new method. |
|
877 | - /** @type EE_Messages_Queue $queue */ |
|
878 | - $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
879 | - // make sure we have a proper message object |
|
880 | - if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
881 | - $msg = EE_Message_Factory::create( |
|
882 | - array( |
|
883 | - 'MSG_messenger' => $messenger, |
|
884 | - 'MSG_message_type' => $message_type, |
|
885 | - 'MSG_content' => $message->content, |
|
886 | - 'MSG_subject' => $message->subject, |
|
887 | - ) |
|
888 | - ); |
|
889 | - } else { |
|
890 | - $msg = $message; |
|
891 | - } |
|
892 | - if (! $msg instanceof EE_Message) { |
|
893 | - return false; |
|
894 | - } |
|
895 | - // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
896 | - if (! empty($msg->content)) { |
|
897 | - $msg->set('MSG_content', $msg->content); |
|
898 | - } |
|
899 | - $queue->add($msg); |
|
900 | - return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
901 | - } |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * @deprecated 4.9.0 |
|
906 | - * @param $messenger |
|
907 | - * @param string $message_type message type that the templates are being created for |
|
908 | - * @param int $GRP_ID |
|
909 | - * @param bool $is_global |
|
910 | - * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
911 | - * returned. |
|
912 | - * @throws \EE_Error |
|
913 | - */ |
|
914 | - public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
915 | - { |
|
916 | - // EE_messages has been deprecated |
|
917 | - $this->_class_is_deprecated(__FUNCTION__); |
|
918 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
919 | - return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
920 | - } |
|
921 | - |
|
922 | - |
|
923 | - /** |
|
924 | - * @deprecated 4.9.0 |
|
925 | - * @param string $messenger_name name of EE_messenger |
|
926 | - * @param string $message_type_name name of EE_message_type |
|
927 | - * @return array |
|
928 | - */ |
|
929 | - public function get_fields($messenger_name, $message_type_name) |
|
930 | - { |
|
931 | - // EE_messages has been deprecated |
|
932 | - $this->_class_is_deprecated(__FUNCTION__); |
|
933 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
934 | - return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * @deprecated 4.9.0 |
|
940 | - * @access public |
|
941 | - * @param string $type we can indicate just returning installed message types |
|
942 | - * or messengers (or both) via this parameter. |
|
943 | - * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
944 | - * @return array multidimensional array of messenger and message_type objects |
|
945 | - * (messengers index, and message_type index); |
|
946 | - */ |
|
947 | - public function get_installed($type = 'all', $skip_cache = false) |
|
948 | - { |
|
949 | - // EE_messages has been deprecated |
|
950 | - $this->_class_is_deprecated(__FUNCTION__); |
|
951 | - if ($skip_cache) { |
|
952 | - $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
953 | - } |
|
954 | - switch ($type) { |
|
955 | - case 'messengers' : |
|
956 | - return array( |
|
957 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
958 | - ); |
|
959 | - break; |
|
960 | - case 'message_types' : |
|
961 | - return array( |
|
962 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
963 | - ); |
|
964 | - break; |
|
965 | - case 'all' : |
|
966 | - default : |
|
967 | - return array( |
|
968 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
969 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
970 | - ); |
|
971 | - break; |
|
972 | - } |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - /** |
|
977 | - * @deprecated 4.9.0 |
|
978 | - * @return \EE_messenger[] |
|
979 | - */ |
|
980 | - public function get_active_messengers() |
|
981 | - { |
|
982 | - // EE_messages has been deprecated |
|
983 | - $this->_class_is_deprecated(__FUNCTION__); |
|
984 | - return $this->_message_resource_manager->active_messengers(); |
|
985 | - } |
|
986 | - |
|
987 | - |
|
988 | - /** |
|
989 | - * @deprecated 4.9.0 |
|
990 | - * @return array array of message_type references (string) |
|
991 | - */ |
|
992 | - public function get_active_message_types() |
|
993 | - { |
|
994 | - // EE_messages has been deprecated |
|
995 | - $this->_class_is_deprecated(__FUNCTION__); |
|
996 | - return $this->_message_resource_manager->list_of_active_message_types(); |
|
997 | - } |
|
998 | - |
|
999 | - |
|
1000 | - /** |
|
1001 | - * @deprecated 4.9.0 |
|
1002 | - * @return EE_message_type[] |
|
1003 | - */ |
|
1004 | - public function get_active_message_type_objects() |
|
1005 | - { |
|
1006 | - // EE_messages has been deprecated |
|
1007 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1008 | - return $this->_message_resource_manager->get_active_message_type_objects(); |
|
1009 | - } |
|
1010 | - |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * @deprecated 4.9.0 |
|
1014 | - * @since 4.5.0 |
|
1015 | - * @param string $messenger The messenger being checked |
|
1016 | - * @return EE_message_type[] (or empty array if none present) |
|
1017 | - */ |
|
1018 | - public function get_active_message_types_per_messenger($messenger) |
|
1019 | - { |
|
1020 | - // EE_messages has been deprecated |
|
1021 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1022 | - return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1023 | - } |
|
1024 | - |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * @deprecated 4.9.0 |
|
1028 | - * @param string $messenger The string should correspond to the messenger (message types are |
|
1029 | - * @param string $message_type The string should correspond to a message type. |
|
1030 | - * @return EE_message_type|null |
|
1031 | - */ |
|
1032 | - public function get_active_message_type($messenger, $message_type) |
|
1033 | - { |
|
1034 | - // EE_messages has been deprecated |
|
1035 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1036 | - return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1037 | - } |
|
1038 | - |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * @deprecated 4.9.0 |
|
1042 | - * @return array|\EE_message_type[] |
|
1043 | - */ |
|
1044 | - public function get_installed_message_types() |
|
1045 | - { |
|
1046 | - // EE_messages has been deprecated |
|
1047 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1048 | - return $this->_message_resource_manager->installed_message_types(); |
|
1049 | - } |
|
1050 | - |
|
1051 | - |
|
1052 | - /** |
|
1053 | - * @deprecated 4.9.0 |
|
1054 | - * @return array |
|
1055 | - */ |
|
1056 | - public function get_installed_messengers() |
|
1057 | - { |
|
1058 | - // EE_messages has been deprecated |
|
1059 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1060 | - return $this->_message_resource_manager->installed_messengers(); |
|
1061 | - } |
|
1062 | - |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * @deprecated 4.9.0 |
|
1066 | - * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
1067 | - * message type. |
|
1068 | - * @return array |
|
1069 | - */ |
|
1070 | - public function get_all_contexts($slugs_only = true) |
|
1071 | - { |
|
1072 | - // EE_messages has been deprecated |
|
1073 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1074 | - return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1075 | - } |
|
557 | + /** @type EE_messenger[] */ |
|
558 | + protected $_active_messengers = array(); |
|
559 | + |
|
560 | + /** @type array */ |
|
561 | + protected $_active_message_types = array(); |
|
562 | + |
|
563 | + /** @type EE_message_type[] */ |
|
564 | + protected $_installed_message_types = array(); |
|
565 | + |
|
566 | + /** @type EE_messenger */ |
|
567 | + protected $_messenger; |
|
568 | + |
|
569 | + /** @type EE_message_type */ |
|
570 | + protected $_message_type; |
|
571 | + |
|
572 | + /** @type array */ |
|
573 | + protected $_contexts = array(); |
|
574 | + |
|
575 | + /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
576 | + protected $_message_resource_manager; |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * EE_messages constructor. |
|
581 | + * |
|
582 | + * @deprecated 4.9.0 |
|
583 | + */ |
|
584 | + public function __construct() |
|
585 | + { |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * @param string $method |
|
591 | + */ |
|
592 | + public function _class_is_deprecated($method) |
|
593 | + { |
|
594 | + EE_Error::doing_it_wrong( |
|
595 | + 'EE_messages::' . $method, |
|
596 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
597 | + '4.9.0', |
|
598 | + '4.10.0.p' |
|
599 | + ); |
|
600 | + // Please use EE_Message_Resource_Manager instead |
|
601 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + /** |
|
606 | + * @deprecated 4.9.0 |
|
607 | + * @param string $messenger_name |
|
608 | + * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
609 | + */ |
|
610 | + public function ensure_messenger_is_active($messenger_name) |
|
611 | + { |
|
612 | + // EE_messages has been deprecated |
|
613 | + $this->_class_is_deprecated(__FUNCTION__); |
|
614 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * @deprecated 4.9.0 |
|
620 | + * @param string $message_type message type name |
|
621 | + * @param $messenger |
|
622 | + * @return bool true if it got activated (or was active) and false if not. |
|
623 | + * @throws \EE_Error |
|
624 | + */ |
|
625 | + public function ensure_message_type_is_active($message_type, $messenger) |
|
626 | + { |
|
627 | + // EE_messages has been deprecated |
|
628 | + $this->_class_is_deprecated(__FUNCTION__); |
|
629 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * @deprecated 4.9.0 |
|
635 | + * @param string $messenger_name |
|
636 | + * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
637 | + * If included we do NOT setup the default message types (assuming they |
|
638 | + * are already setup.) |
|
639 | + * @return boolean an array of generated templates or false if nothing generated/activated. |
|
640 | + */ |
|
641 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) |
|
642 | + { |
|
643 | + // EE_messages has been deprecated |
|
644 | + $this->_class_is_deprecated(__FUNCTION__); |
|
645 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
646 | + } |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * @deprecated 4.9.0 |
|
651 | + * @param EE_messenger $messenger messenger used in trigger |
|
652 | + * @param EE_message_type $message_type message type used in trigger |
|
653 | + * |
|
654 | + * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
655 | + */ |
|
656 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
657 | + { |
|
658 | + // EE_messages has been deprecated |
|
659 | + $this->_class_is_deprecated(__FUNCTION__); |
|
660 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * @deprecated 4.9.0 |
|
666 | + * @param string $messenger |
|
667 | + * @return EE_messenger | null |
|
668 | + */ |
|
669 | + public function get_messenger_if_active($messenger) |
|
670 | + { |
|
671 | + // EE_messages has been deprecated |
|
672 | + $this->_class_is_deprecated(__FUNCTION__); |
|
673 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + /** |
|
678 | + * @deprecated 4.9.0 |
|
679 | + * @param EE_Message $message |
|
680 | + * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
681 | + * available. |
|
682 | + * Eg. Valid Messenger and Message Type: |
|
683 | + * array( |
|
684 | + * 'messenger' => new EE_Email_messenger(), |
|
685 | + * 'message_type' => new EE_Registration_Approved_message_type() |
|
686 | + * ) |
|
687 | + * Valid Messenger and Invalid Message Type: |
|
688 | + * array( |
|
689 | + * 'messenger' => new EE_Email_messenger(), |
|
690 | + * 'message_type' => null |
|
691 | + * ) |
|
692 | + */ |
|
693 | + public function validate_for_use(EE_Message $message) |
|
694 | + { |
|
695 | + // EE_messages has been deprecated |
|
696 | + $this->_class_is_deprecated(__FUNCTION__); |
|
697 | + return array( |
|
698 | + 'messenger' => $message->messenger_object(), |
|
699 | + 'message_type' => $message->message_type_object(), |
|
700 | + ); |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * @deprecated 4.9.0 |
|
706 | + * @param string $type What type of message are we sending (corresponds to message types) |
|
707 | + * @param mixed $vars Data being sent for parsing in the message |
|
708 | + * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
709 | + * Otherwise we cycle through all active messengers. |
|
710 | + * @param string $generating_messenger if included then this messenger is used for generating the message |
|
711 | + * templates (but not for sending). |
|
712 | + * @param string $context If included then only a message type for a specific context will be |
|
713 | + * generated. |
|
714 | + * @param bool $send Default TRUE. If false, then this will just return the generated |
|
715 | + * EE_messages objects which might be used by the trigger to setup a batch |
|
716 | + * message (typically html messenger uses it). |
|
717 | + * @return bool |
|
718 | + */ |
|
719 | + public function send_message( |
|
720 | + $type, |
|
721 | + $vars, |
|
722 | + $sending_messenger = '', |
|
723 | + $generating_messenger = '', |
|
724 | + $context = '', |
|
725 | + $send = true |
|
726 | + ) { |
|
727 | + // EE_messages has been deprecated |
|
728 | + $this->_class_is_deprecated(__FUNCTION__); |
|
729 | + /** @type EE_Messages_Processor $processor */ |
|
730 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
731 | + $error = false; |
|
732 | + // try to intelligently determine what method we'll call based on the incoming data. |
|
733 | + // if generating and sending are different then generate and send immediately. |
|
734 | + if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
735 | + // in the legacy system, when generating and sending were different, that means all the |
|
736 | + // vars are already in the request object. So let's just use that. |
|
737 | + try { |
|
738 | + /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
739 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
740 | + $processor->generate_and_send_now($mtg); |
|
741 | + } catch (EE_Error $e) { |
|
742 | + $error_msg = __( |
|
743 | + 'Please note that a system message failed to send due to a technical issue.', |
|
744 | + 'event_espresso' |
|
745 | + ); |
|
746 | + // add specific message for developers if WP_DEBUG in on |
|
747 | + $error_msg .= '||' . $e->getMessage(); |
|
748 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
749 | + $error = true; |
|
750 | + } |
|
751 | + } else { |
|
752 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
753 | + // let's find out if there were any errors and how many successfully were queued. |
|
754 | + $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
755 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
756 | + ); |
|
757 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
758 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
759 | + $count_errors = $count_errors + $count_retry; |
|
760 | + if ($count_errors > 0) { |
|
761 | + $error = true; |
|
762 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
763 | + $message = sprintf( |
|
764 | + __( |
|
765 | + 'There were %d errors and %d messages successfully queued for generation and sending', |
|
766 | + 'event_espresso' |
|
767 | + ), |
|
768 | + $count_errors, |
|
769 | + $count_queued |
|
770 | + ); |
|
771 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
772 | + $message = sprintf( |
|
773 | + __( |
|
774 | + 'There were %d errors and %d message successfully queued for generation.', |
|
775 | + 'event_espresso' |
|
776 | + ), |
|
777 | + $count_errors, |
|
778 | + $count_queued |
|
779 | + ); |
|
780 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
781 | + $message = sprintf( |
|
782 | + __( |
|
783 | + 'There was %d error and %d messages successfully queued for generation.', |
|
784 | + 'event_espresso' |
|
785 | + ), |
|
786 | + $count_errors, |
|
787 | + $count_queued |
|
788 | + ); |
|
789 | + } else { |
|
790 | + $message = sprintf( |
|
791 | + __( |
|
792 | + 'There was %d message that failed to be queued for generation.', |
|
793 | + 'event_espresso' |
|
794 | + ), |
|
795 | + $count_errors |
|
796 | + ); |
|
797 | + } |
|
798 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
799 | + } else { |
|
800 | + if ($count_queued === 1) { |
|
801 | + $message = sprintf( |
|
802 | + __( |
|
803 | + '%d message successfully queued for generation.', |
|
804 | + 'event_espresso' |
|
805 | + ), |
|
806 | + $count_queued |
|
807 | + ); |
|
808 | + } else { |
|
809 | + $message = sprintf( |
|
810 | + __( |
|
811 | + '%d messages were successfully queued for generation.', |
|
812 | + 'event_espresso' |
|
813 | + ), |
|
814 | + $count_queued |
|
815 | + ); |
|
816 | + } |
|
817 | + EE_Error::add_success($message); |
|
818 | + } |
|
819 | + } |
|
820 | + // if no error then return the generated message(s). |
|
821 | + if (! $error && ! $send) { |
|
822 | + $generated_queue = $processor->generate_queue(false); |
|
823 | + // get message and return. |
|
824 | + $generated_queue->get_message_repository()->rewind(); |
|
825 | + $messages = array(); |
|
826 | + while ($generated_queue->get_message_repository()->valid()) { |
|
827 | + $message = $generated_queue->get_message_repository()->current(); |
|
828 | + if ($message instanceof EE_Message) { |
|
829 | + // set properties that might be expected by add-ons (backward compat) |
|
830 | + $message->content = $message->content(); |
|
831 | + $message->template_pack = $message->get_template_pack(); |
|
832 | + $message->template_variation = $message->get_template_pack_variation(); |
|
833 | + $messages[] = $message; |
|
834 | + } |
|
835 | + $generated_queue->get_message_repository()->next(); |
|
836 | + } |
|
837 | + return $messages; |
|
838 | + } |
|
839 | + return $error ? false |
|
840 | + : true; // yeah backwards eh? Really what we're returning is if there is a total success for all the messages or not. We'll modify this once we get message recording in place. |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * @deprecated 4.9.0 |
|
846 | + * @param string $type This should correspond with a valid message type |
|
847 | + * @param string $context This should correspond with a valid context for the message type |
|
848 | + * @param string $messenger This should correspond with a valid messenger. |
|
849 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
850 | + * preview |
|
851 | + * @return string The body of the message. |
|
852 | + */ |
|
853 | + public function preview_message($type, $context, $messenger, $send = false) |
|
854 | + { |
|
855 | + // EE_messages has been deprecated |
|
856 | + $this->_class_is_deprecated(__FUNCTION__); |
|
857 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
858 | + } |
|
859 | + |
|
860 | + |
|
861 | + /** |
|
862 | + * @since 4.5.0 |
|
863 | + * @deprecated 4.9.0 Moved to EED_Messages Module |
|
864 | + * @param string $messenger a string matching a valid active messenger in the system |
|
865 | + * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
866 | + * required to send along the message type to the messenger because this is used for |
|
867 | + * determining what specific variations might be loaded for the generated message. |
|
868 | + * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
869 | + * |
|
870 | + * @return bool success or fail. |
|
871 | + */ |
|
872 | + public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
873 | + { |
|
874 | + // EE_messages has been deprecated |
|
875 | + $this->_class_is_deprecated(__FUNCTION__); |
|
876 | + // setup for sending to new method. |
|
877 | + /** @type EE_Messages_Queue $queue */ |
|
878 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
879 | + // make sure we have a proper message object |
|
880 | + if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
881 | + $msg = EE_Message_Factory::create( |
|
882 | + array( |
|
883 | + 'MSG_messenger' => $messenger, |
|
884 | + 'MSG_message_type' => $message_type, |
|
885 | + 'MSG_content' => $message->content, |
|
886 | + 'MSG_subject' => $message->subject, |
|
887 | + ) |
|
888 | + ); |
|
889 | + } else { |
|
890 | + $msg = $message; |
|
891 | + } |
|
892 | + if (! $msg instanceof EE_Message) { |
|
893 | + return false; |
|
894 | + } |
|
895 | + // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
896 | + if (! empty($msg->content)) { |
|
897 | + $msg->set('MSG_content', $msg->content); |
|
898 | + } |
|
899 | + $queue->add($msg); |
|
900 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
901 | + } |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * @deprecated 4.9.0 |
|
906 | + * @param $messenger |
|
907 | + * @param string $message_type message type that the templates are being created for |
|
908 | + * @param int $GRP_ID |
|
909 | + * @param bool $is_global |
|
910 | + * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
911 | + * returned. |
|
912 | + * @throws \EE_Error |
|
913 | + */ |
|
914 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
915 | + { |
|
916 | + // EE_messages has been deprecated |
|
917 | + $this->_class_is_deprecated(__FUNCTION__); |
|
918 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
919 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
920 | + } |
|
921 | + |
|
922 | + |
|
923 | + /** |
|
924 | + * @deprecated 4.9.0 |
|
925 | + * @param string $messenger_name name of EE_messenger |
|
926 | + * @param string $message_type_name name of EE_message_type |
|
927 | + * @return array |
|
928 | + */ |
|
929 | + public function get_fields($messenger_name, $message_type_name) |
|
930 | + { |
|
931 | + // EE_messages has been deprecated |
|
932 | + $this->_class_is_deprecated(__FUNCTION__); |
|
933 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
934 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * @deprecated 4.9.0 |
|
940 | + * @access public |
|
941 | + * @param string $type we can indicate just returning installed message types |
|
942 | + * or messengers (or both) via this parameter. |
|
943 | + * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
944 | + * @return array multidimensional array of messenger and message_type objects |
|
945 | + * (messengers index, and message_type index); |
|
946 | + */ |
|
947 | + public function get_installed($type = 'all', $skip_cache = false) |
|
948 | + { |
|
949 | + // EE_messages has been deprecated |
|
950 | + $this->_class_is_deprecated(__FUNCTION__); |
|
951 | + if ($skip_cache) { |
|
952 | + $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
953 | + } |
|
954 | + switch ($type) { |
|
955 | + case 'messengers' : |
|
956 | + return array( |
|
957 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
958 | + ); |
|
959 | + break; |
|
960 | + case 'message_types' : |
|
961 | + return array( |
|
962 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
963 | + ); |
|
964 | + break; |
|
965 | + case 'all' : |
|
966 | + default : |
|
967 | + return array( |
|
968 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
969 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
970 | + ); |
|
971 | + break; |
|
972 | + } |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + /** |
|
977 | + * @deprecated 4.9.0 |
|
978 | + * @return \EE_messenger[] |
|
979 | + */ |
|
980 | + public function get_active_messengers() |
|
981 | + { |
|
982 | + // EE_messages has been deprecated |
|
983 | + $this->_class_is_deprecated(__FUNCTION__); |
|
984 | + return $this->_message_resource_manager->active_messengers(); |
|
985 | + } |
|
986 | + |
|
987 | + |
|
988 | + /** |
|
989 | + * @deprecated 4.9.0 |
|
990 | + * @return array array of message_type references (string) |
|
991 | + */ |
|
992 | + public function get_active_message_types() |
|
993 | + { |
|
994 | + // EE_messages has been deprecated |
|
995 | + $this->_class_is_deprecated(__FUNCTION__); |
|
996 | + return $this->_message_resource_manager->list_of_active_message_types(); |
|
997 | + } |
|
998 | + |
|
999 | + |
|
1000 | + /** |
|
1001 | + * @deprecated 4.9.0 |
|
1002 | + * @return EE_message_type[] |
|
1003 | + */ |
|
1004 | + public function get_active_message_type_objects() |
|
1005 | + { |
|
1006 | + // EE_messages has been deprecated |
|
1007 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1008 | + return $this->_message_resource_manager->get_active_message_type_objects(); |
|
1009 | + } |
|
1010 | + |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * @deprecated 4.9.0 |
|
1014 | + * @since 4.5.0 |
|
1015 | + * @param string $messenger The messenger being checked |
|
1016 | + * @return EE_message_type[] (or empty array if none present) |
|
1017 | + */ |
|
1018 | + public function get_active_message_types_per_messenger($messenger) |
|
1019 | + { |
|
1020 | + // EE_messages has been deprecated |
|
1021 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1022 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1023 | + } |
|
1024 | + |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * @deprecated 4.9.0 |
|
1028 | + * @param string $messenger The string should correspond to the messenger (message types are |
|
1029 | + * @param string $message_type The string should correspond to a message type. |
|
1030 | + * @return EE_message_type|null |
|
1031 | + */ |
|
1032 | + public function get_active_message_type($messenger, $message_type) |
|
1033 | + { |
|
1034 | + // EE_messages has been deprecated |
|
1035 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1036 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1037 | + } |
|
1038 | + |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * @deprecated 4.9.0 |
|
1042 | + * @return array|\EE_message_type[] |
|
1043 | + */ |
|
1044 | + public function get_installed_message_types() |
|
1045 | + { |
|
1046 | + // EE_messages has been deprecated |
|
1047 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1048 | + return $this->_message_resource_manager->installed_message_types(); |
|
1049 | + } |
|
1050 | + |
|
1051 | + |
|
1052 | + /** |
|
1053 | + * @deprecated 4.9.0 |
|
1054 | + * @return array |
|
1055 | + */ |
|
1056 | + public function get_installed_messengers() |
|
1057 | + { |
|
1058 | + // EE_messages has been deprecated |
|
1059 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1060 | + return $this->_message_resource_manager->installed_messengers(); |
|
1061 | + } |
|
1062 | + |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * @deprecated 4.9.0 |
|
1066 | + * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
1067 | + * message type. |
|
1068 | + * @return array |
|
1069 | + */ |
|
1070 | + public function get_all_contexts($slugs_only = true) |
|
1071 | + { |
|
1072 | + // EE_messages has been deprecated |
|
1073 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1074 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1075 | + } |
|
1076 | 1076 | |
1077 | 1077 | |
1078 | 1078 | } |
@@ -1131,88 +1131,88 @@ discard block |
||
1131 | 1131 | |
1132 | 1132 | |
1133 | 1133 | add_filter( |
1134 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1135 | - function ($event_list_iframe_css) { |
|
1136 | - if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1137 | - return $event_list_iframe_css; |
|
1138 | - } |
|
1139 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1140 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1141 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1142 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1143 | - '4.9.14', |
|
1144 | - '5.0.0', |
|
1145 | - 'filter' |
|
1146 | - ); |
|
1147 | - return apply_filters( |
|
1148 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1149 | - $event_list_iframe_css |
|
1150 | - ); |
|
1151 | - } |
|
1134 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1135 | + function ($event_list_iframe_css) { |
|
1136 | + if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1137 | + return $event_list_iframe_css; |
|
1138 | + } |
|
1139 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1140 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1141 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1142 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1143 | + '4.9.14', |
|
1144 | + '5.0.0', |
|
1145 | + 'filter' |
|
1146 | + ); |
|
1147 | + return apply_filters( |
|
1148 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1149 | + $event_list_iframe_css |
|
1150 | + ); |
|
1151 | + } |
|
1152 | 1152 | ); |
1153 | 1153 | add_filter( |
1154 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1155 | - function ($event_list_iframe_js) { |
|
1156 | - if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1157 | - return $event_list_iframe_js; |
|
1158 | - } |
|
1159 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1160 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1161 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1162 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1163 | - '4.9.14', |
|
1164 | - '5.0.0', |
|
1165 | - 'filter' |
|
1166 | - ); |
|
1167 | - return apply_filters( |
|
1168 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1169 | - $event_list_iframe_js |
|
1170 | - ); |
|
1171 | - } |
|
1154 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1155 | + function ($event_list_iframe_js) { |
|
1156 | + if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1157 | + return $event_list_iframe_js; |
|
1158 | + } |
|
1159 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1160 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1161 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1162 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1163 | + '4.9.14', |
|
1164 | + '5.0.0', |
|
1165 | + 'filter' |
|
1166 | + ); |
|
1167 | + return apply_filters( |
|
1168 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1169 | + $event_list_iframe_js |
|
1170 | + ); |
|
1171 | + } |
|
1172 | 1172 | ); |
1173 | 1173 | add_action( |
1174 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
1175 | - function ($capabilities_map) { |
|
1176 | - if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1177 | - return; |
|
1178 | - } |
|
1179 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1180 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1181 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
1182 | - '\EE_Capabilities::addCaps()', |
|
1183 | - '4.9.42', |
|
1184 | - '5.0.0' |
|
1185 | - ); |
|
1186 | - do_action( |
|
1187 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1188 | - $capabilities_map |
|
1189 | - ); |
|
1190 | - } |
|
1174 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
1175 | + function ($capabilities_map) { |
|
1176 | + if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1177 | + return; |
|
1178 | + } |
|
1179 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1180 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1181 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
1182 | + '\EE_Capabilities::addCaps()', |
|
1183 | + '4.9.42', |
|
1184 | + '5.0.0' |
|
1185 | + ); |
|
1186 | + do_action( |
|
1187 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1188 | + $capabilities_map |
|
1189 | + ); |
|
1190 | + } |
|
1191 | 1191 | ); |
1192 | 1192 | |
1193 | 1193 | add_filter( |
1194 | - 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1195 | - function ($existing_attendee, $registration, $attendee_data) { |
|
1196 | - if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1197 | - return $existing_attendee; |
|
1198 | - } |
|
1199 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1200 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1201 | - 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1202 | - '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
1203 | - '4.9.34', |
|
1204 | - '5.0.0', |
|
1205 | - 'filter' |
|
1206 | - ); |
|
1207 | - return apply_filters( |
|
1208 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1209 | - $existing_attendee, |
|
1210 | - $registration, |
|
1211 | - $attendee_data |
|
1212 | - ); |
|
1213 | - }, |
|
1214 | - 10, |
|
1215 | - 3 |
|
1194 | + 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1195 | + function ($existing_attendee, $registration, $attendee_data) { |
|
1196 | + if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1197 | + return $existing_attendee; |
|
1198 | + } |
|
1199 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1200 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1201 | + 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1202 | + '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
1203 | + '4.9.34', |
|
1204 | + '5.0.0', |
|
1205 | + 'filter' |
|
1206 | + ); |
|
1207 | + return apply_filters( |
|
1208 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1209 | + $existing_attendee, |
|
1210 | + $registration, |
|
1211 | + $attendee_data |
|
1212 | + ); |
|
1213 | + }, |
|
1214 | + 10, |
|
1215 | + 3 |
|
1216 | 1216 | ); |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1223,88 +1223,88 @@ discard block |
||
1223 | 1223 | class EE_Event_List_Query extends WP_Query |
1224 | 1224 | { |
1225 | 1225 | |
1226 | - private $title; |
|
1227 | - |
|
1228 | - private $css_class; |
|
1229 | - |
|
1230 | - private $category_slug; |
|
1231 | - |
|
1232 | - /** |
|
1233 | - * EE_Event_List_Query constructor. |
|
1234 | - * |
|
1235 | - * @param array $args |
|
1236 | - */ |
|
1237 | - public function __construct($args = array()) |
|
1238 | - { |
|
1239 | - \EE_Error::doing_it_wrong( |
|
1240 | - __METHOD__, |
|
1241 | - __( |
|
1242 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1243 | - 'event_espresso' |
|
1244 | - ), |
|
1245 | - '4.9.27', |
|
1246 | - '5.0.0' |
|
1247 | - ); |
|
1248 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1249 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1250 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1251 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1252 | - // the current "page" we are viewing |
|
1253 | - $paged = max(1, get_query_var('paged')); |
|
1254 | - // Force these args |
|
1255 | - $args = array_merge( |
|
1256 | - $args, |
|
1257 | - array( |
|
1258 | - 'post_type' => 'espresso_events', |
|
1259 | - 'posts_per_page' => $limit, |
|
1260 | - 'update_post_term_cache' => false, |
|
1261 | - 'update_post_meta_cache' => false, |
|
1262 | - 'paged' => $paged, |
|
1263 | - 'offset' => ($paged - 1) * $limit, |
|
1264 | - ) |
|
1265 | - ); |
|
1266 | - // run the query |
|
1267 | - parent::__construct($args); |
|
1268 | - } |
|
1269 | - |
|
1270 | - |
|
1271 | - /** |
|
1272 | - * event_list_title |
|
1273 | - * |
|
1274 | - * @param string $event_list_title |
|
1275 | - * @return string |
|
1276 | - */ |
|
1277 | - public function event_list_title($event_list_title = '') |
|
1278 | - { |
|
1279 | - if (! empty($this->title)) { |
|
1280 | - return $this->title; |
|
1281 | - } |
|
1282 | - return $event_list_title; |
|
1283 | - } |
|
1284 | - |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * event_list_css |
|
1288 | - * |
|
1289 | - * @param string $event_list_css |
|
1290 | - * @return string |
|
1291 | - */ |
|
1292 | - public function event_list_css($event_list_css = '') |
|
1293 | - { |
|
1294 | - $event_list_css .= ! empty($event_list_css) |
|
1295 | - ? ' ' |
|
1296 | - : ''; |
|
1297 | - $event_list_css .= ! empty($this->css_class) |
|
1298 | - ? $this->css_class |
|
1299 | - : ''; |
|
1300 | - $event_list_css .= ! empty($event_list_css) |
|
1301 | - ? ' ' |
|
1302 | - : ''; |
|
1303 | - $event_list_css .= ! empty($this->category_slug) |
|
1304 | - ? $this->category_slug |
|
1305 | - : ''; |
|
1306 | - return $event_list_css; |
|
1307 | - } |
|
1226 | + private $title; |
|
1227 | + |
|
1228 | + private $css_class; |
|
1229 | + |
|
1230 | + private $category_slug; |
|
1231 | + |
|
1232 | + /** |
|
1233 | + * EE_Event_List_Query constructor. |
|
1234 | + * |
|
1235 | + * @param array $args |
|
1236 | + */ |
|
1237 | + public function __construct($args = array()) |
|
1238 | + { |
|
1239 | + \EE_Error::doing_it_wrong( |
|
1240 | + __METHOD__, |
|
1241 | + __( |
|
1242 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1243 | + 'event_espresso' |
|
1244 | + ), |
|
1245 | + '4.9.27', |
|
1246 | + '5.0.0' |
|
1247 | + ); |
|
1248 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1249 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1250 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1251 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1252 | + // the current "page" we are viewing |
|
1253 | + $paged = max(1, get_query_var('paged')); |
|
1254 | + // Force these args |
|
1255 | + $args = array_merge( |
|
1256 | + $args, |
|
1257 | + array( |
|
1258 | + 'post_type' => 'espresso_events', |
|
1259 | + 'posts_per_page' => $limit, |
|
1260 | + 'update_post_term_cache' => false, |
|
1261 | + 'update_post_meta_cache' => false, |
|
1262 | + 'paged' => $paged, |
|
1263 | + 'offset' => ($paged - 1) * $limit, |
|
1264 | + ) |
|
1265 | + ); |
|
1266 | + // run the query |
|
1267 | + parent::__construct($args); |
|
1268 | + } |
|
1269 | + |
|
1270 | + |
|
1271 | + /** |
|
1272 | + * event_list_title |
|
1273 | + * |
|
1274 | + * @param string $event_list_title |
|
1275 | + * @return string |
|
1276 | + */ |
|
1277 | + public function event_list_title($event_list_title = '') |
|
1278 | + { |
|
1279 | + if (! empty($this->title)) { |
|
1280 | + return $this->title; |
|
1281 | + } |
|
1282 | + return $event_list_title; |
|
1283 | + } |
|
1284 | + |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * event_list_css |
|
1288 | + * |
|
1289 | + * @param string $event_list_css |
|
1290 | + * @return string |
|
1291 | + */ |
|
1292 | + public function event_list_css($event_list_css = '') |
|
1293 | + { |
|
1294 | + $event_list_css .= ! empty($event_list_css) |
|
1295 | + ? ' ' |
|
1296 | + : ''; |
|
1297 | + $event_list_css .= ! empty($this->css_class) |
|
1298 | + ? $this->css_class |
|
1299 | + : ''; |
|
1300 | + $event_list_css .= ! empty($event_list_css) |
|
1301 | + ? ' ' |
|
1302 | + : ''; |
|
1303 | + $event_list_css .= ! empty($this->category_slug) |
|
1304 | + ? $this->category_slug |
|
1305 | + : ''; |
|
1306 | + return $event_list_css; |
|
1307 | + } |
|
1308 | 1308 | |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1321,75 +1321,75 @@ discard block |
||
1321 | 1321 | { |
1322 | 1322 | |
1323 | 1323 | |
1324 | - /** |
|
1325 | - * class constructor |
|
1326 | - * |
|
1327 | - * @deprecated 4.9.59.p |
|
1328 | - */ |
|
1329 | - public function __construct() |
|
1330 | - { |
|
1331 | - EE_Error::doing_it_wrong( |
|
1332 | - __METHOD__, |
|
1333 | - sprintf( |
|
1334 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1335 | - __CLASS__, |
|
1336 | - 'EventEspresso\core\services\licensing\LicenseServices' |
|
1337 | - ), |
|
1338 | - '4.9.59.p' |
|
1339 | - ); |
|
1340 | - } |
|
1341 | - |
|
1342 | - |
|
1343 | - /** |
|
1344 | - * The purpose of this function is to display information about Event Espresso data collection |
|
1345 | - * and a optin selection for extra data collecting by users. |
|
1346 | - * |
|
1347 | - * @param bool $extra |
|
1348 | - * @return string html. |
|
1349 | - * @deprecated 4.9.59.p |
|
1350 | - */ |
|
1351 | - public static function espresso_data_collection_optin_text($extra = true) |
|
1352 | - { |
|
1353 | - EE_Error::doing_it_wrong( |
|
1354 | - __METHOD__, |
|
1355 | - sprintf( |
|
1356 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1357 | - __METHOD__, |
|
1358 | - 'EventEspresso\core\domain\services\Stats::optinText' |
|
1359 | - ), |
|
1360 | - '4.9.59.p' |
|
1361 | - ); |
|
1362 | - Stats::optinText($extra); |
|
1363 | - } |
|
1364 | - |
|
1365 | - /** |
|
1366 | - * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
1367 | - * |
|
1368 | - * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
1369 | - * identify plugins. Defaults to core update |
|
1370 | - * @return boolean True if update available, false if not. |
|
1371 | - * @deprecated 4.9.59.p |
|
1372 | - */ |
|
1373 | - public static function is_update_available($basename = '') |
|
1374 | - { |
|
1375 | - EE_Error::doing_it_wrong( |
|
1376 | - __METHOD__, |
|
1377 | - sprintf( |
|
1378 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1379 | - __METHOD__, |
|
1380 | - 'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable' |
|
1381 | - ), |
|
1382 | - '4.9.59.p' |
|
1383 | - ); |
|
1384 | - return LicenseService::isUpdateAvailable($basename); |
|
1385 | - } |
|
1324 | + /** |
|
1325 | + * class constructor |
|
1326 | + * |
|
1327 | + * @deprecated 4.9.59.p |
|
1328 | + */ |
|
1329 | + public function __construct() |
|
1330 | + { |
|
1331 | + EE_Error::doing_it_wrong( |
|
1332 | + __METHOD__, |
|
1333 | + sprintf( |
|
1334 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1335 | + __CLASS__, |
|
1336 | + 'EventEspresso\core\services\licensing\LicenseServices' |
|
1337 | + ), |
|
1338 | + '4.9.59.p' |
|
1339 | + ); |
|
1340 | + } |
|
1341 | + |
|
1342 | + |
|
1343 | + /** |
|
1344 | + * The purpose of this function is to display information about Event Espresso data collection |
|
1345 | + * and a optin selection for extra data collecting by users. |
|
1346 | + * |
|
1347 | + * @param bool $extra |
|
1348 | + * @return string html. |
|
1349 | + * @deprecated 4.9.59.p |
|
1350 | + */ |
|
1351 | + public static function espresso_data_collection_optin_text($extra = true) |
|
1352 | + { |
|
1353 | + EE_Error::doing_it_wrong( |
|
1354 | + __METHOD__, |
|
1355 | + sprintf( |
|
1356 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1357 | + __METHOD__, |
|
1358 | + 'EventEspresso\core\domain\services\Stats::optinText' |
|
1359 | + ), |
|
1360 | + '4.9.59.p' |
|
1361 | + ); |
|
1362 | + Stats::optinText($extra); |
|
1363 | + } |
|
1364 | + |
|
1365 | + /** |
|
1366 | + * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
1367 | + * |
|
1368 | + * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
1369 | + * identify plugins. Defaults to core update |
|
1370 | + * @return boolean True if update available, false if not. |
|
1371 | + * @deprecated 4.9.59.p |
|
1372 | + */ |
|
1373 | + public static function is_update_available($basename = '') |
|
1374 | + { |
|
1375 | + EE_Error::doing_it_wrong( |
|
1376 | + __METHOD__, |
|
1377 | + sprintf( |
|
1378 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1379 | + __METHOD__, |
|
1380 | + 'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable' |
|
1381 | + ), |
|
1382 | + '4.9.59.p' |
|
1383 | + ); |
|
1384 | + return LicenseService::isUpdateAvailable($basename); |
|
1385 | + } |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | add_filter( |
1389 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
1390 | - 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
1391 | - 10, |
|
1392 | - 2 |
|
1389 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
1390 | + 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
1391 | + 10, |
|
1392 | + 2 |
|
1393 | 1393 | ); |
1394 | 1394 | /** |
1395 | 1395 | * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]"). |
@@ -1406,96 +1406,96 @@ discard block |
||
1406 | 1406 | */ |
1407 | 1407 | function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row) |
1408 | 1408 | { |
1409 | - // no need for all this if nobody is using the deprecated filter |
|
1410 | - if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
1411 | - EE_Error::doing_it_wrong( |
|
1412 | - __FUNCTION__, |
|
1413 | - sprintf( |
|
1414 | - // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
1415 | - _x( |
|
1416 | - 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
1417 | - 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
1418 | - 'event_espresso' |
|
1419 | - ), |
|
1420 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1421 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
1422 | - ), |
|
1423 | - '4.9.69.p', |
|
1424 | - '4.9.75.p' |
|
1425 | - ); |
|
1426 | - // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
1427 | - // first: what model fields might be used as column headers? (whose format we need to change) |
|
1428 | - $model_fields = array_merge( |
|
1429 | - EEM_Registration::instance()->field_settings(), |
|
1430 | - EEM_Attendee::instance()->field_settings() |
|
1431 | - ); |
|
1432 | - // create an array that uses the legacy column headers/labels. |
|
1433 | - $new_csv_row = array(); |
|
1434 | - foreach ($csv_row_data as $label => $value) { |
|
1435 | - $new_label = $label; |
|
1436 | - foreach ($model_fields as $field) { |
|
1437 | - if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
1438 | - // re-add the old field name |
|
1439 | - $new_label = $label . '[' . $field->get_name() . ']'; |
|
1440 | - break; |
|
1441 | - } |
|
1442 | - } |
|
1443 | - $new_csv_row[$new_label] = $value; |
|
1444 | - } |
|
1445 | - // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1446 | - // to create the old column names, because that's what's in the row temporarily |
|
1447 | - add_filter( |
|
1448 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1449 | - '__return_true', |
|
1450 | - 777 |
|
1451 | - ); |
|
1452 | - // now, those old filters can be run on this data. Have fun! |
|
1453 | - /** |
|
1454 | - * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1455 | - * |
|
1456 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
1457 | - * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1458 | - * Note: it has this name because originally that's where this filter resided, |
|
1459 | - * and we've left its name as-is for backward compatibility. |
|
1460 | - * Note when using: all rows in the CSV should have the same columns. |
|
1461 | - * |
|
1462 | - * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1463 | - * in this row |
|
1464 | - * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1465 | - */ |
|
1466 | - $updated_row = apply_filters( |
|
1467 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1468 | - $new_csv_row, |
|
1469 | - $reg_row |
|
1470 | - ); |
|
1471 | - |
|
1472 | - // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1473 | - remove_filter( |
|
1474 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1475 | - '__return_true', |
|
1476 | - 777 |
|
1477 | - ); |
|
1478 | - |
|
1479 | - // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1480 | - $updated_and_restored_row = array(); |
|
1481 | - foreach ($updated_row as $label => $value) { |
|
1482 | - $matches = array(); |
|
1483 | - if (preg_match( |
|
1484 | - '~([^\[]*)\[(.*)\]~', |
|
1485 | - $label, |
|
1486 | - $matches |
|
1487 | - ) |
|
1488 | - && isset( |
|
1489 | - $matches[0], |
|
1490 | - $matches[1], |
|
1491 | - $matches[2] |
|
1492 | - ) |
|
1493 | - ) { |
|
1494 | - $label = $matches[1]; |
|
1495 | - } |
|
1496 | - $updated_and_restored_row[$label] = $value; |
|
1497 | - } |
|
1498 | - $csv_row_data = $updated_and_restored_row; |
|
1499 | - } |
|
1500 | - return $csv_row_data; |
|
1409 | + // no need for all this if nobody is using the deprecated filter |
|
1410 | + if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
1411 | + EE_Error::doing_it_wrong( |
|
1412 | + __FUNCTION__, |
|
1413 | + sprintf( |
|
1414 | + // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
1415 | + _x( |
|
1416 | + 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
1417 | + 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
1418 | + 'event_espresso' |
|
1419 | + ), |
|
1420 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1421 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
1422 | + ), |
|
1423 | + '4.9.69.p', |
|
1424 | + '4.9.75.p' |
|
1425 | + ); |
|
1426 | + // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
1427 | + // first: what model fields might be used as column headers? (whose format we need to change) |
|
1428 | + $model_fields = array_merge( |
|
1429 | + EEM_Registration::instance()->field_settings(), |
|
1430 | + EEM_Attendee::instance()->field_settings() |
|
1431 | + ); |
|
1432 | + // create an array that uses the legacy column headers/labels. |
|
1433 | + $new_csv_row = array(); |
|
1434 | + foreach ($csv_row_data as $label => $value) { |
|
1435 | + $new_label = $label; |
|
1436 | + foreach ($model_fields as $field) { |
|
1437 | + if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
1438 | + // re-add the old field name |
|
1439 | + $new_label = $label . '[' . $field->get_name() . ']'; |
|
1440 | + break; |
|
1441 | + } |
|
1442 | + } |
|
1443 | + $new_csv_row[$new_label] = $value; |
|
1444 | + } |
|
1445 | + // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1446 | + // to create the old column names, because that's what's in the row temporarily |
|
1447 | + add_filter( |
|
1448 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1449 | + '__return_true', |
|
1450 | + 777 |
|
1451 | + ); |
|
1452 | + // now, those old filters can be run on this data. Have fun! |
|
1453 | + /** |
|
1454 | + * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1455 | + * |
|
1456 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
1457 | + * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1458 | + * Note: it has this name because originally that's where this filter resided, |
|
1459 | + * and we've left its name as-is for backward compatibility. |
|
1460 | + * Note when using: all rows in the CSV should have the same columns. |
|
1461 | + * |
|
1462 | + * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1463 | + * in this row |
|
1464 | + * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1465 | + */ |
|
1466 | + $updated_row = apply_filters( |
|
1467 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1468 | + $new_csv_row, |
|
1469 | + $reg_row |
|
1470 | + ); |
|
1471 | + |
|
1472 | + // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1473 | + remove_filter( |
|
1474 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1475 | + '__return_true', |
|
1476 | + 777 |
|
1477 | + ); |
|
1478 | + |
|
1479 | + // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1480 | + $updated_and_restored_row = array(); |
|
1481 | + foreach ($updated_row as $label => $value) { |
|
1482 | + $matches = array(); |
|
1483 | + if (preg_match( |
|
1484 | + '~([^\[]*)\[(.*)\]~', |
|
1485 | + $label, |
|
1486 | + $matches |
|
1487 | + ) |
|
1488 | + && isset( |
|
1489 | + $matches[0], |
|
1490 | + $matches[1], |
|
1491 | + $matches[2] |
|
1492 | + ) |
|
1493 | + ) { |
|
1494 | + $label = $matches[1]; |
|
1495 | + } |
|
1496 | + $updated_and_restored_row[$label] = $value; |
|
1497 | + } |
|
1498 | + $csv_row_data = $updated_and_restored_row; |
|
1499 | + } |
|
1500 | + return $csv_row_data; |
|
1501 | 1501 | } |
1502 | 1502 | \ No newline at end of file |