@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -12,869 +12,869 @@ discard block |
||
12 | 12 | class EE_Message extends EE_Base_Class implements EEI_Admin_Links |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @deprecated 4.9.0 Added for backward compat with add-on's |
|
17 | - * @type null |
|
18 | - */ |
|
19 | - public $template_pack; |
|
20 | - |
|
21 | - /** |
|
22 | - * @deprecated 4.9.0 Added for backward compat with add-on's |
|
23 | - * @type null |
|
24 | - */ |
|
25 | - public $template_variation; |
|
26 | - |
|
27 | - /** |
|
28 | - * @deprecated 4.9.0 Added for backward compat with add-on's |
|
29 | - * @type string |
|
30 | - */ |
|
31 | - public $content = ''; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @type EE_messenger $_messenger |
|
36 | - */ |
|
37 | - protected $_messenger = null; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_message_type $_message_type |
|
41 | - */ |
|
42 | - protected $_message_type = null; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @param array $props_n_values |
|
47 | - * @param string $timezone |
|
48 | - * @param array $date_formats incoming date formats in an array. First value is the date_format, second is time |
|
49 | - * format. |
|
50 | - * @return EE_Message |
|
51 | - */ |
|
52 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
53 | - { |
|
54 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
55 | - //if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db. |
|
56 | - if ( ! $has_object) { |
|
57 | - EE_Registry::instance()->load_helper('URL'); |
|
58 | - $props_n_values['MSG_token'] = EEH_URL::generate_unique_token(); |
|
59 | - } |
|
60 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @param array $props_n_values |
|
66 | - * @param string $timezone |
|
67 | - * @return EE_Message |
|
68 | - */ |
|
69 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
70 | - { |
|
71 | - return new self($props_n_values, true, $timezone); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * Gets MSG_token |
|
77 | - * |
|
78 | - * @return int |
|
79 | - */ |
|
80 | - public function MSG_token() |
|
81 | - { |
|
82 | - return $this->get('MSG_token'); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Sets MSG_token |
|
88 | - * |
|
89 | - * @param int $MSG_token |
|
90 | - */ |
|
91 | - public function set_MSG_token($MSG_token) |
|
92 | - { |
|
93 | - $this->set('MSG_token', $MSG_token); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Gets GRP_ID |
|
99 | - * |
|
100 | - * @return int |
|
101 | - */ |
|
102 | - public function GRP_ID() |
|
103 | - { |
|
104 | - return $this->get('GRP_ID'); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * Sets GRP_ID |
|
110 | - * |
|
111 | - * @param int $GRP_ID |
|
112 | - */ |
|
113 | - public function set_GRP_ID($GRP_ID) |
|
114 | - { |
|
115 | - $this->set('GRP_ID', $GRP_ID); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * Gets TXN_ID |
|
121 | - * |
|
122 | - * @return int |
|
123 | - */ |
|
124 | - public function TXN_ID() |
|
125 | - { |
|
126 | - return $this->get('TXN_ID'); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Sets TXN_ID |
|
132 | - * |
|
133 | - * @param int $TXN_ID |
|
134 | - */ |
|
135 | - public function set_TXN_ID($TXN_ID) |
|
136 | - { |
|
137 | - $this->set('TXN_ID', $TXN_ID); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Gets messenger |
|
143 | - * |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function messenger() |
|
147 | - { |
|
148 | - return $this->get('MSG_messenger'); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Sets messenger |
|
154 | - * |
|
155 | - * @param string $messenger |
|
156 | - */ |
|
157 | - public function set_messenger($messenger) |
|
158 | - { |
|
159 | - $this->set('MSG_messenger', $messenger); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * Returns corresponding messenger object for the set messenger on this message |
|
165 | - * |
|
166 | - * @return EE_messenger | null |
|
167 | - */ |
|
168 | - public function messenger_object() |
|
169 | - { |
|
170 | - return $this->_messenger; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Sets messenger |
|
176 | - * |
|
177 | - * @param EE_messenger $messenger |
|
178 | - */ |
|
179 | - public function set_messenger_object(EE_messenger $messenger) |
|
180 | - { |
|
181 | - $this->_messenger = $messenger; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * validates messenger |
|
187 | - * |
|
188 | - * @param bool $throw_exceptions |
|
189 | - * @return bool |
|
190 | - * @throws \EE_Error |
|
191 | - */ |
|
192 | - public function valid_messenger($throw_exceptions = false) |
|
193 | - { |
|
194 | - if ($this->_messenger instanceof EE_messenger) { |
|
195 | - return true; |
|
196 | - } |
|
197 | - if ($throw_exceptions) { |
|
198 | - throw new EE_Error( |
|
199 | - sprintf( |
|
200 | - __( |
|
201 | - 'The "%1$s" messenger set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.', |
|
202 | - 'event_espresso' |
|
203 | - ), |
|
204 | - $this->messenger() |
|
205 | - ) |
|
206 | - ); |
|
207 | - } |
|
208 | - return false; |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * This returns the set localized label for the messenger on this message. |
|
214 | - * Note, if unable to retrieve the EE_messenger object then will just return the messenger slug saved |
|
215 | - * with this message. |
|
216 | - * |
|
217 | - * @param bool $plural whether to return the plural label or not. |
|
218 | - * @return string |
|
219 | - */ |
|
220 | - public function messenger_label($plural = false) |
|
221 | - { |
|
222 | - $label_type = $plural ? 'plural' : 'singular'; |
|
223 | - $messenger = $this->messenger_object(); |
|
224 | - return $messenger instanceof EE_messenger ? $messenger->label[$label_type] : $this->messenger(); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Gets message_type |
|
230 | - * |
|
231 | - * @return string |
|
232 | - */ |
|
233 | - public function message_type() |
|
234 | - { |
|
235 | - return $this->get('MSG_message_type'); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * Sets message_type |
|
241 | - * |
|
242 | - * @param string $message_type |
|
243 | - */ |
|
244 | - public function set_message_type($message_type) |
|
245 | - { |
|
246 | - $this->set('MSG_message_type', $message_type); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * Returns the message type object for the set message type on this message |
|
252 | - * |
|
253 | - * @return EE_message_type | null |
|
254 | - */ |
|
255 | - public function message_type_object() |
|
256 | - { |
|
257 | - return $this->_message_type; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * Sets message_type |
|
263 | - * |
|
264 | - * @param EE_message_type $message_type |
|
265 | - * @param bool $set_priority This indicates whether to set the priority to whatever the priority is on |
|
266 | - * the message type or not. |
|
267 | - */ |
|
268 | - public function set_message_type_object(EE_message_type $message_type, $set_priority = false) |
|
269 | - { |
|
270 | - $this->_message_type = $message_type; |
|
271 | - if ($set_priority) { |
|
272 | - $this->set_priority($this->_message_type->get_priority()); |
|
273 | - } |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * validates message_type |
|
279 | - * |
|
280 | - * @param bool $throw_exceptions |
|
281 | - * @return bool |
|
282 | - * @throws \EE_Error |
|
283 | - */ |
|
284 | - public function valid_message_type($throw_exceptions = false) |
|
285 | - { |
|
286 | - if ($this->_message_type instanceof EE_message_type) { |
|
287 | - return true; |
|
288 | - } |
|
289 | - if ($throw_exceptions) { |
|
290 | - throw new EE_Error( |
|
291 | - sprintf( |
|
292 | - __( |
|
293 | - 'The %1$s message type set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.', |
|
294 | - 'event_espresso' |
|
295 | - ), |
|
296 | - $this->message_type() |
|
297 | - ) |
|
298 | - ); |
|
299 | - } |
|
300 | - return false; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * validates messenger and message_type (that they are valid EE_messenger and EE_message_type objects). |
|
306 | - * |
|
307 | - * @param bool $throw_exceptions |
|
308 | - * @return bool |
|
309 | - * @throws \EE_Error |
|
310 | - */ |
|
311 | - public function is_valid($throw_exceptions = false) |
|
312 | - { |
|
313 | - if ($this->valid_messenger($throw_exceptions) && $this->valid_message_type($throw_exceptions)) { |
|
314 | - return true; |
|
315 | - } |
|
316 | - return false; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * This validates whether the internal messenger and message type objects are valid for sending. |
|
322 | - * Three checks are done: |
|
323 | - * 1. There is a valid messenger object. |
|
324 | - * 2. There is a valid message type object. |
|
325 | - * 3. The message type object is active for the messenger. |
|
326 | - * |
|
327 | - * @throws EE_Error But only if $throw_exceptions is set to true. |
|
328 | - * @param bool $throw_exceptions |
|
329 | - * @return bool |
|
330 | - */ |
|
331 | - public function is_valid_for_sending_or_generation($throw_exceptions = false) |
|
332 | - { |
|
333 | - $valid = false; |
|
334 | - if ($this->is_valid($throw_exceptions)) { |
|
335 | - /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
336 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
337 | - $valid = $message_resource_manager->is_message_type_active_for_messenger($this->messenger(), |
|
338 | - $this->message_type()); |
|
339 | - if ( ! $valid && $throw_exceptions) { |
|
340 | - throw new EE_Error( |
|
341 | - sprintf( |
|
342 | - __('The %1$s message type is not a valid message type for the %2$s messenger so it will not be sent.', |
|
343 | - 'event_espresso'), |
|
344 | - $this->message_type(), |
|
345 | - $this->messenger() |
|
346 | - ) |
|
347 | - ); |
|
348 | - } |
|
349 | - } |
|
350 | - return $valid; |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * This returns the set localized label for the message type on this message. |
|
356 | - * Note, if unable to retrieve the EE_message_type object then will just return the message type slug saved |
|
357 | - * with this message. |
|
358 | - * |
|
359 | - * @param bool $plural whether to return the plural label or not. |
|
360 | - * @return string |
|
361 | - */ |
|
362 | - public function message_type_label($plural = false) |
|
363 | - { |
|
364 | - $label_type = $plural ? 'plural' : 'singular'; |
|
365 | - $message_type = $this->message_type_object(); |
|
366 | - return $message_type instanceof EE_message_type ? $message_type->label[$label_type] : str_replace( |
|
367 | - '_', |
|
368 | - ' ', |
|
369 | - $this->message_type() |
|
370 | - ); |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * Gets context |
|
376 | - * |
|
377 | - * @return string |
|
378 | - */ |
|
379 | - public function context() |
|
380 | - { |
|
381 | - return $this->get('MSG_context'); |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * This returns the corresponding localized label for the given context slug, if possible from installed message |
|
387 | - * types. Otherwise, this will just return the set context slug on this object. |
|
388 | - * |
|
389 | - * @return string |
|
390 | - */ |
|
391 | - public function context_label() |
|
392 | - { |
|
393 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
394 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
395 | - $contexts = $message_resource_manager->get_all_contexts(); |
|
396 | - return isset($contexts[$this->context()]) ? $contexts[$this->context()] : $this->context(); |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * Sets context |
|
402 | - * |
|
403 | - * @param string $context |
|
404 | - */ |
|
405 | - public function set_context($context) |
|
406 | - { |
|
407 | - $this->set('MSG_context', $context); |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * Gets recipient_ID |
|
413 | - * |
|
414 | - * @return int |
|
415 | - */ |
|
416 | - public function recipient_ID() |
|
417 | - { |
|
418 | - return $this->get('MSG_recipient_ID'); |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * Sets recipient_ID |
|
424 | - * |
|
425 | - * @param string $recipient_ID |
|
426 | - */ |
|
427 | - public function set_recipient_ID($recipient_ID) |
|
428 | - { |
|
429 | - $this->set('MSG_recipient_ID', $recipient_ID); |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * Gets recipient_type |
|
435 | - * |
|
436 | - * @return string |
|
437 | - */ |
|
438 | - public function recipient_type() |
|
439 | - { |
|
440 | - return $this->get('MSG_recipient_type'); |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * Return the related object matching the recipient type and ID. |
|
446 | - * |
|
447 | - * @return EE_Base_Class | null |
|
448 | - */ |
|
449 | - public function recipient_object() |
|
450 | - { |
|
451 | - if ( ! $this->recipient_type() || ! $this->recipient_ID()) { |
|
452 | - return null; |
|
453 | - } |
|
454 | - |
|
455 | - return $this->get_first_related($this->recipient_type()); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * Sets recipient_type |
|
461 | - * |
|
462 | - * @param string $recipient_type |
|
463 | - */ |
|
464 | - public function set_recipient_type($recipient_type) |
|
465 | - { |
|
466 | - $this->set('MSG_recipient_type', $recipient_type); |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * Gets content |
|
472 | - * |
|
473 | - * @return string |
|
474 | - */ |
|
475 | - public function content() |
|
476 | - { |
|
477 | - return $this->get('MSG_content'); |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * Sets content |
|
483 | - * |
|
484 | - * @param string $content |
|
485 | - */ |
|
486 | - public function set_content($content) |
|
487 | - { |
|
488 | - $this->set('MSG_content', $content); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * Gets subject |
|
494 | - * |
|
495 | - * @return string |
|
496 | - */ |
|
497 | - public function subject() |
|
498 | - { |
|
499 | - return $this->get('MSG_subject'); |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * Sets subject |
|
505 | - * |
|
506 | - * @param string $subject |
|
507 | - */ |
|
508 | - public function set_subject($subject) |
|
509 | - { |
|
510 | - $this->set('MSG_subject', $subject); |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * Gets to |
|
516 | - * |
|
517 | - * @return string |
|
518 | - */ |
|
519 | - public function to() |
|
520 | - { |
|
521 | - $to = $this->get('MSG_to'); |
|
522 | - return empty($to) ? __('No recipient', 'event_espresso') : $to; |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * Sets to |
|
528 | - * |
|
529 | - * @param string $to |
|
530 | - */ |
|
531 | - public function set_to($to) |
|
532 | - { |
|
533 | - $this->set('MSG_to', $to); |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * Gets from |
|
539 | - * |
|
540 | - * @return string |
|
541 | - */ |
|
542 | - public function from() |
|
543 | - { |
|
544 | - return $this->get('MSG_from'); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * Sets from |
|
550 | - * |
|
551 | - * @param string $from |
|
552 | - */ |
|
553 | - public function set_from($from) |
|
554 | - { |
|
555 | - $this->set('MSG_from', $from); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * Gets priority |
|
561 | - * |
|
562 | - * @return int |
|
563 | - */ |
|
564 | - public function priority() |
|
565 | - { |
|
566 | - return $this->get('MSG_priority'); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * Sets priority |
|
572 | - * Note. Send Now Messengers always override any priority that may be set on a Message. So |
|
573 | - * this method calls the send_now method to verify that. |
|
574 | - * |
|
575 | - * @param int $priority |
|
576 | - */ |
|
577 | - public function set_priority($priority) |
|
578 | - { |
|
579 | - $priority = $this->send_now() ? EEM_Message::priority_high : $priority; |
|
580 | - parent::set('MSG_priority', $priority); |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Overrides parent::set method so we can capture any sets for priority. |
|
586 | - * |
|
587 | - * @see parent::set() for phpdocs |
|
588 | - * @param string $field_name |
|
589 | - * @param mixed $field_value |
|
590 | - * @param bool $use_default |
|
591 | - * @throws EE_Error |
|
592 | - */ |
|
593 | - public function set($field_name, $field_value, $use_default = false) |
|
594 | - { |
|
595 | - if ($field_name === 'MSG_priority') { |
|
596 | - $this->set_priority($field_value); |
|
597 | - } |
|
598 | - parent::set($field_name, $field_value, $use_default); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * @return bool |
|
604 | - * @throws \EE_Error |
|
605 | - */ |
|
606 | - public function send_now() |
|
607 | - { |
|
608 | - $send_now = $this->valid_messenger() && $this->messenger_object()->send_now() ? EEM_Message::priority_high : $this->priority(); |
|
609 | - return $send_now === EEM_Message::priority_high ? true : false; |
|
610 | - } |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * Gets STS_ID |
|
615 | - * |
|
616 | - * @return string |
|
617 | - */ |
|
618 | - public function STS_ID() |
|
619 | - { |
|
620 | - return $this->get('STS_ID'); |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - /** |
|
625 | - * Sets STS_ID |
|
626 | - * |
|
627 | - * @param string $STS_ID |
|
628 | - */ |
|
629 | - public function set_STS_ID($STS_ID) |
|
630 | - { |
|
631 | - $this->set('STS_ID', $STS_ID); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * Gets created |
|
637 | - * |
|
638 | - * @return string |
|
639 | - */ |
|
640 | - public function created() |
|
641 | - { |
|
642 | - return $this->get('MSG_created'); |
|
643 | - } |
|
644 | - |
|
645 | - |
|
646 | - /** |
|
647 | - * Sets created |
|
648 | - * |
|
649 | - * @param string $created |
|
650 | - */ |
|
651 | - public function set_created($created) |
|
652 | - { |
|
653 | - $this->set('MSG_created', $created); |
|
654 | - } |
|
655 | - |
|
656 | - |
|
657 | - /** |
|
658 | - * Gets modified |
|
659 | - * |
|
660 | - * @return string |
|
661 | - */ |
|
662 | - public function modified() |
|
663 | - { |
|
664 | - return $this->get('MSG_modified'); |
|
665 | - } |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Sets modified |
|
670 | - * |
|
671 | - * @param string $modified |
|
672 | - */ |
|
673 | - public function set_modified($modified) |
|
674 | - { |
|
675 | - $this->set('MSG_modified', $modified); |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * Sets generation data for this message. |
|
681 | - * |
|
682 | - * @param mixed $data |
|
683 | - */ |
|
684 | - public function set_generation_data($data) |
|
685 | - { |
|
686 | - $this->set_field_or_extra_meta('MSG_generation_data', $data); |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * Returns any set generation data for this message. |
|
692 | - * |
|
693 | - * @return mixed|null |
|
694 | - */ |
|
695 | - public function get_generation_data() |
|
696 | - { |
|
697 | - return $this->get_field_or_extra_meta('MSG_generation_data'); |
|
698 | - } |
|
699 | - |
|
700 | - |
|
701 | - /** |
|
702 | - * Gets any error message. |
|
703 | - * |
|
704 | - * @return mixed|null |
|
705 | - */ |
|
706 | - public function error_message() |
|
707 | - { |
|
708 | - return $this->get_field_or_extra_meta('MSG_error'); |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * Sets an error message. |
|
714 | - * |
|
715 | - * @param $message |
|
716 | - * @return bool|int |
|
717 | - */ |
|
718 | - public function set_error_message($message) |
|
719 | - { |
|
720 | - return $this->set_field_or_extra_meta('MSG_error', $message); |
|
721 | - } |
|
722 | - |
|
723 | - |
|
724 | - /** |
|
725 | - * This retrieves the associated template pack with this message. |
|
726 | - * |
|
727 | - * @return EE_Messages_Template_Pack | null |
|
728 | - */ |
|
729 | - public function get_template_pack() |
|
730 | - { |
|
731 | - /** |
|
732 | - * This is deprecated functionality that will be removed eventually but included here now for backward compat. |
|
733 | - */ |
|
734 | - if ( ! empty($this->template_pack)) { |
|
735 | - return $this->template_pack; |
|
736 | - } |
|
737 | - /** @type EE_Message_Template_Group $grp */ |
|
738 | - $grp = $this->get_first_related('Message_Template_Group'); |
|
739 | - //if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
|
740 | - if ( ! $grp instanceof EE_Message_Template_Group) { |
|
741 | - $grp = EEM_Message_Template_Group::instance()->get_one( |
|
742 | - array( |
|
743 | - array( |
|
744 | - 'MTP_messenger' => $this->messenger(), |
|
745 | - 'MTP_message_type' => $this->message_type(), |
|
746 | - 'MTP_is_global' => true, |
|
747 | - ), |
|
748 | - ) |
|
749 | - ); |
|
750 | - } |
|
751 | - |
|
752 | - return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null; |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - /** |
|
757 | - * Retrieves the variation used for generating this message. |
|
758 | - * |
|
759 | - * @return string |
|
760 | - */ |
|
761 | - public function get_template_pack_variation() |
|
762 | - { |
|
763 | - /** |
|
764 | - * This is deprecated functionality that will be removed eventually but included here now for backward compat. |
|
765 | - */ |
|
766 | - if ( ! empty($this->template_variation)) { |
|
767 | - return $this->template_variation; |
|
768 | - } |
|
769 | - |
|
770 | - /** @type EE_Message_Template_Group $grp */ |
|
771 | - $grp = $this->get_first_related('Message_Template_Group'); |
|
772 | - |
|
773 | - //if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
|
774 | - if ( ! $grp instanceof EE_Message_Template_Group) { |
|
775 | - $grp = EEM_Message_Template_Group::instance()->get_one( |
|
776 | - array( |
|
777 | - array( |
|
778 | - 'MTP_messenger' => $this->messenger(), |
|
779 | - 'MTP_message_type' => $this->message_type(), |
|
780 | - 'MTP_is_global' => true, |
|
781 | - ), |
|
782 | - ) |
|
783 | - ); |
|
784 | - } |
|
785 | - |
|
786 | - return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : ''; |
|
787 | - } |
|
788 | - |
|
789 | - /** |
|
790 | - * Return the link to the admin details for the object. |
|
791 | - * |
|
792 | - * @return string |
|
793 | - */ |
|
794 | - public function get_admin_details_link() |
|
795 | - { |
|
796 | - EE_Registry::instance()->load_helper('URL'); |
|
797 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
798 | - switch ($this->STS_ID()) { |
|
799 | - case EEM_Message::status_failed : |
|
800 | - case EEM_Message::status_debug_only : |
|
801 | - return EEH_MSG_Template::generate_error_display_trigger($this); |
|
802 | - break; |
|
803 | - |
|
804 | - case EEM_Message::status_sent : |
|
805 | - return EEH_MSG_Template::generate_browser_trigger($this); |
|
806 | - break; |
|
807 | - |
|
808 | - default : |
|
809 | - return ''; |
|
810 | - } |
|
811 | - } |
|
812 | - |
|
813 | - /** |
|
814 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
815 | - * |
|
816 | - * @return string |
|
817 | - */ |
|
818 | - public function get_admin_edit_link() |
|
819 | - { |
|
820 | - return $this->get_admin_details_link(); |
|
821 | - } |
|
822 | - |
|
823 | - /** |
|
824 | - * Returns the link to a settings page for the object. |
|
825 | - * |
|
826 | - * @return string |
|
827 | - */ |
|
828 | - public function get_admin_settings_link() |
|
829 | - { |
|
830 | - EE_Registry::instance()->load_helper('URL'); |
|
831 | - return EEH_URL::add_query_args_and_nonce( |
|
832 | - array( |
|
833 | - 'page' => 'espresso_messages', |
|
834 | - 'action' => 'settings', |
|
835 | - ), |
|
836 | - admin_url('admin.php') |
|
837 | - ); |
|
838 | - } |
|
839 | - |
|
840 | - /** |
|
841 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
842 | - * |
|
843 | - * @return string |
|
844 | - */ |
|
845 | - public function get_admin_overview_link() |
|
846 | - { |
|
847 | - EE_Registry::instance()->load_helper('URL'); |
|
848 | - return EEH_URL::add_query_args_and_nonce( |
|
849 | - array( |
|
850 | - 'page' => 'espresso_messages', |
|
851 | - 'action' => 'default', |
|
852 | - ), |
|
853 | - admin_url('admin.php') |
|
854 | - ); |
|
855 | - } |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - * This sets the EEM_Message::status_messenger_executing class on the message and the appropriate error message for |
|
860 | - * it. |
|
861 | - * Note this also SAVES the current message object to the db because it adds an error message to accompany the status. |
|
862 | - * |
|
863 | - */ |
|
864 | - public function set_messenger_is_executing() |
|
865 | - { |
|
866 | - $this->set_STS_ID( EEM_Message::status_messenger_executing ); |
|
867 | - $this->set_error_message( |
|
868 | - esc_html__( |
|
869 | - 'A message with this status indicates that there was a problem that occurred while the message was being |
|
15 | + /** |
|
16 | + * @deprecated 4.9.0 Added for backward compat with add-on's |
|
17 | + * @type null |
|
18 | + */ |
|
19 | + public $template_pack; |
|
20 | + |
|
21 | + /** |
|
22 | + * @deprecated 4.9.0 Added for backward compat with add-on's |
|
23 | + * @type null |
|
24 | + */ |
|
25 | + public $template_variation; |
|
26 | + |
|
27 | + /** |
|
28 | + * @deprecated 4.9.0 Added for backward compat with add-on's |
|
29 | + * @type string |
|
30 | + */ |
|
31 | + public $content = ''; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @type EE_messenger $_messenger |
|
36 | + */ |
|
37 | + protected $_messenger = null; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_message_type $_message_type |
|
41 | + */ |
|
42 | + protected $_message_type = null; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @param array $props_n_values |
|
47 | + * @param string $timezone |
|
48 | + * @param array $date_formats incoming date formats in an array. First value is the date_format, second is time |
|
49 | + * format. |
|
50 | + * @return EE_Message |
|
51 | + */ |
|
52 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
53 | + { |
|
54 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
55 | + //if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db. |
|
56 | + if ( ! $has_object) { |
|
57 | + EE_Registry::instance()->load_helper('URL'); |
|
58 | + $props_n_values['MSG_token'] = EEH_URL::generate_unique_token(); |
|
59 | + } |
|
60 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @param array $props_n_values |
|
66 | + * @param string $timezone |
|
67 | + * @return EE_Message |
|
68 | + */ |
|
69 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
70 | + { |
|
71 | + return new self($props_n_values, true, $timezone); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * Gets MSG_token |
|
77 | + * |
|
78 | + * @return int |
|
79 | + */ |
|
80 | + public function MSG_token() |
|
81 | + { |
|
82 | + return $this->get('MSG_token'); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Sets MSG_token |
|
88 | + * |
|
89 | + * @param int $MSG_token |
|
90 | + */ |
|
91 | + public function set_MSG_token($MSG_token) |
|
92 | + { |
|
93 | + $this->set('MSG_token', $MSG_token); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Gets GRP_ID |
|
99 | + * |
|
100 | + * @return int |
|
101 | + */ |
|
102 | + public function GRP_ID() |
|
103 | + { |
|
104 | + return $this->get('GRP_ID'); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * Sets GRP_ID |
|
110 | + * |
|
111 | + * @param int $GRP_ID |
|
112 | + */ |
|
113 | + public function set_GRP_ID($GRP_ID) |
|
114 | + { |
|
115 | + $this->set('GRP_ID', $GRP_ID); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * Gets TXN_ID |
|
121 | + * |
|
122 | + * @return int |
|
123 | + */ |
|
124 | + public function TXN_ID() |
|
125 | + { |
|
126 | + return $this->get('TXN_ID'); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Sets TXN_ID |
|
132 | + * |
|
133 | + * @param int $TXN_ID |
|
134 | + */ |
|
135 | + public function set_TXN_ID($TXN_ID) |
|
136 | + { |
|
137 | + $this->set('TXN_ID', $TXN_ID); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Gets messenger |
|
143 | + * |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function messenger() |
|
147 | + { |
|
148 | + return $this->get('MSG_messenger'); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Sets messenger |
|
154 | + * |
|
155 | + * @param string $messenger |
|
156 | + */ |
|
157 | + public function set_messenger($messenger) |
|
158 | + { |
|
159 | + $this->set('MSG_messenger', $messenger); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * Returns corresponding messenger object for the set messenger on this message |
|
165 | + * |
|
166 | + * @return EE_messenger | null |
|
167 | + */ |
|
168 | + public function messenger_object() |
|
169 | + { |
|
170 | + return $this->_messenger; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Sets messenger |
|
176 | + * |
|
177 | + * @param EE_messenger $messenger |
|
178 | + */ |
|
179 | + public function set_messenger_object(EE_messenger $messenger) |
|
180 | + { |
|
181 | + $this->_messenger = $messenger; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * validates messenger |
|
187 | + * |
|
188 | + * @param bool $throw_exceptions |
|
189 | + * @return bool |
|
190 | + * @throws \EE_Error |
|
191 | + */ |
|
192 | + public function valid_messenger($throw_exceptions = false) |
|
193 | + { |
|
194 | + if ($this->_messenger instanceof EE_messenger) { |
|
195 | + return true; |
|
196 | + } |
|
197 | + if ($throw_exceptions) { |
|
198 | + throw new EE_Error( |
|
199 | + sprintf( |
|
200 | + __( |
|
201 | + 'The "%1$s" messenger set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.', |
|
202 | + 'event_espresso' |
|
203 | + ), |
|
204 | + $this->messenger() |
|
205 | + ) |
|
206 | + ); |
|
207 | + } |
|
208 | + return false; |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * This returns the set localized label for the messenger on this message. |
|
214 | + * Note, if unable to retrieve the EE_messenger object then will just return the messenger slug saved |
|
215 | + * with this message. |
|
216 | + * |
|
217 | + * @param bool $plural whether to return the plural label or not. |
|
218 | + * @return string |
|
219 | + */ |
|
220 | + public function messenger_label($plural = false) |
|
221 | + { |
|
222 | + $label_type = $plural ? 'plural' : 'singular'; |
|
223 | + $messenger = $this->messenger_object(); |
|
224 | + return $messenger instanceof EE_messenger ? $messenger->label[$label_type] : $this->messenger(); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Gets message_type |
|
230 | + * |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + public function message_type() |
|
234 | + { |
|
235 | + return $this->get('MSG_message_type'); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * Sets message_type |
|
241 | + * |
|
242 | + * @param string $message_type |
|
243 | + */ |
|
244 | + public function set_message_type($message_type) |
|
245 | + { |
|
246 | + $this->set('MSG_message_type', $message_type); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * Returns the message type object for the set message type on this message |
|
252 | + * |
|
253 | + * @return EE_message_type | null |
|
254 | + */ |
|
255 | + public function message_type_object() |
|
256 | + { |
|
257 | + return $this->_message_type; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * Sets message_type |
|
263 | + * |
|
264 | + * @param EE_message_type $message_type |
|
265 | + * @param bool $set_priority This indicates whether to set the priority to whatever the priority is on |
|
266 | + * the message type or not. |
|
267 | + */ |
|
268 | + public function set_message_type_object(EE_message_type $message_type, $set_priority = false) |
|
269 | + { |
|
270 | + $this->_message_type = $message_type; |
|
271 | + if ($set_priority) { |
|
272 | + $this->set_priority($this->_message_type->get_priority()); |
|
273 | + } |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * validates message_type |
|
279 | + * |
|
280 | + * @param bool $throw_exceptions |
|
281 | + * @return bool |
|
282 | + * @throws \EE_Error |
|
283 | + */ |
|
284 | + public function valid_message_type($throw_exceptions = false) |
|
285 | + { |
|
286 | + if ($this->_message_type instanceof EE_message_type) { |
|
287 | + return true; |
|
288 | + } |
|
289 | + if ($throw_exceptions) { |
|
290 | + throw new EE_Error( |
|
291 | + sprintf( |
|
292 | + __( |
|
293 | + 'The %1$s message type set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.', |
|
294 | + 'event_espresso' |
|
295 | + ), |
|
296 | + $this->message_type() |
|
297 | + ) |
|
298 | + ); |
|
299 | + } |
|
300 | + return false; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * validates messenger and message_type (that they are valid EE_messenger and EE_message_type objects). |
|
306 | + * |
|
307 | + * @param bool $throw_exceptions |
|
308 | + * @return bool |
|
309 | + * @throws \EE_Error |
|
310 | + */ |
|
311 | + public function is_valid($throw_exceptions = false) |
|
312 | + { |
|
313 | + if ($this->valid_messenger($throw_exceptions) && $this->valid_message_type($throw_exceptions)) { |
|
314 | + return true; |
|
315 | + } |
|
316 | + return false; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * This validates whether the internal messenger and message type objects are valid for sending. |
|
322 | + * Three checks are done: |
|
323 | + * 1. There is a valid messenger object. |
|
324 | + * 2. There is a valid message type object. |
|
325 | + * 3. The message type object is active for the messenger. |
|
326 | + * |
|
327 | + * @throws EE_Error But only if $throw_exceptions is set to true. |
|
328 | + * @param bool $throw_exceptions |
|
329 | + * @return bool |
|
330 | + */ |
|
331 | + public function is_valid_for_sending_or_generation($throw_exceptions = false) |
|
332 | + { |
|
333 | + $valid = false; |
|
334 | + if ($this->is_valid($throw_exceptions)) { |
|
335 | + /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
336 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
337 | + $valid = $message_resource_manager->is_message_type_active_for_messenger($this->messenger(), |
|
338 | + $this->message_type()); |
|
339 | + if ( ! $valid && $throw_exceptions) { |
|
340 | + throw new EE_Error( |
|
341 | + sprintf( |
|
342 | + __('The %1$s message type is not a valid message type for the %2$s messenger so it will not be sent.', |
|
343 | + 'event_espresso'), |
|
344 | + $this->message_type(), |
|
345 | + $this->messenger() |
|
346 | + ) |
|
347 | + ); |
|
348 | + } |
|
349 | + } |
|
350 | + return $valid; |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * This returns the set localized label for the message type on this message. |
|
356 | + * Note, if unable to retrieve the EE_message_type object then will just return the message type slug saved |
|
357 | + * with this message. |
|
358 | + * |
|
359 | + * @param bool $plural whether to return the plural label or not. |
|
360 | + * @return string |
|
361 | + */ |
|
362 | + public function message_type_label($plural = false) |
|
363 | + { |
|
364 | + $label_type = $plural ? 'plural' : 'singular'; |
|
365 | + $message_type = $this->message_type_object(); |
|
366 | + return $message_type instanceof EE_message_type ? $message_type->label[$label_type] : str_replace( |
|
367 | + '_', |
|
368 | + ' ', |
|
369 | + $this->message_type() |
|
370 | + ); |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * Gets context |
|
376 | + * |
|
377 | + * @return string |
|
378 | + */ |
|
379 | + public function context() |
|
380 | + { |
|
381 | + return $this->get('MSG_context'); |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * This returns the corresponding localized label for the given context slug, if possible from installed message |
|
387 | + * types. Otherwise, this will just return the set context slug on this object. |
|
388 | + * |
|
389 | + * @return string |
|
390 | + */ |
|
391 | + public function context_label() |
|
392 | + { |
|
393 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
394 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
395 | + $contexts = $message_resource_manager->get_all_contexts(); |
|
396 | + return isset($contexts[$this->context()]) ? $contexts[$this->context()] : $this->context(); |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * Sets context |
|
402 | + * |
|
403 | + * @param string $context |
|
404 | + */ |
|
405 | + public function set_context($context) |
|
406 | + { |
|
407 | + $this->set('MSG_context', $context); |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * Gets recipient_ID |
|
413 | + * |
|
414 | + * @return int |
|
415 | + */ |
|
416 | + public function recipient_ID() |
|
417 | + { |
|
418 | + return $this->get('MSG_recipient_ID'); |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * Sets recipient_ID |
|
424 | + * |
|
425 | + * @param string $recipient_ID |
|
426 | + */ |
|
427 | + public function set_recipient_ID($recipient_ID) |
|
428 | + { |
|
429 | + $this->set('MSG_recipient_ID', $recipient_ID); |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * Gets recipient_type |
|
435 | + * |
|
436 | + * @return string |
|
437 | + */ |
|
438 | + public function recipient_type() |
|
439 | + { |
|
440 | + return $this->get('MSG_recipient_type'); |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * Return the related object matching the recipient type and ID. |
|
446 | + * |
|
447 | + * @return EE_Base_Class | null |
|
448 | + */ |
|
449 | + public function recipient_object() |
|
450 | + { |
|
451 | + if ( ! $this->recipient_type() || ! $this->recipient_ID()) { |
|
452 | + return null; |
|
453 | + } |
|
454 | + |
|
455 | + return $this->get_first_related($this->recipient_type()); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * Sets recipient_type |
|
461 | + * |
|
462 | + * @param string $recipient_type |
|
463 | + */ |
|
464 | + public function set_recipient_type($recipient_type) |
|
465 | + { |
|
466 | + $this->set('MSG_recipient_type', $recipient_type); |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * Gets content |
|
472 | + * |
|
473 | + * @return string |
|
474 | + */ |
|
475 | + public function content() |
|
476 | + { |
|
477 | + return $this->get('MSG_content'); |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * Sets content |
|
483 | + * |
|
484 | + * @param string $content |
|
485 | + */ |
|
486 | + public function set_content($content) |
|
487 | + { |
|
488 | + $this->set('MSG_content', $content); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * Gets subject |
|
494 | + * |
|
495 | + * @return string |
|
496 | + */ |
|
497 | + public function subject() |
|
498 | + { |
|
499 | + return $this->get('MSG_subject'); |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * Sets subject |
|
505 | + * |
|
506 | + * @param string $subject |
|
507 | + */ |
|
508 | + public function set_subject($subject) |
|
509 | + { |
|
510 | + $this->set('MSG_subject', $subject); |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * Gets to |
|
516 | + * |
|
517 | + * @return string |
|
518 | + */ |
|
519 | + public function to() |
|
520 | + { |
|
521 | + $to = $this->get('MSG_to'); |
|
522 | + return empty($to) ? __('No recipient', 'event_espresso') : $to; |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * Sets to |
|
528 | + * |
|
529 | + * @param string $to |
|
530 | + */ |
|
531 | + public function set_to($to) |
|
532 | + { |
|
533 | + $this->set('MSG_to', $to); |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * Gets from |
|
539 | + * |
|
540 | + * @return string |
|
541 | + */ |
|
542 | + public function from() |
|
543 | + { |
|
544 | + return $this->get('MSG_from'); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * Sets from |
|
550 | + * |
|
551 | + * @param string $from |
|
552 | + */ |
|
553 | + public function set_from($from) |
|
554 | + { |
|
555 | + $this->set('MSG_from', $from); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * Gets priority |
|
561 | + * |
|
562 | + * @return int |
|
563 | + */ |
|
564 | + public function priority() |
|
565 | + { |
|
566 | + return $this->get('MSG_priority'); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * Sets priority |
|
572 | + * Note. Send Now Messengers always override any priority that may be set on a Message. So |
|
573 | + * this method calls the send_now method to verify that. |
|
574 | + * |
|
575 | + * @param int $priority |
|
576 | + */ |
|
577 | + public function set_priority($priority) |
|
578 | + { |
|
579 | + $priority = $this->send_now() ? EEM_Message::priority_high : $priority; |
|
580 | + parent::set('MSG_priority', $priority); |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Overrides parent::set method so we can capture any sets for priority. |
|
586 | + * |
|
587 | + * @see parent::set() for phpdocs |
|
588 | + * @param string $field_name |
|
589 | + * @param mixed $field_value |
|
590 | + * @param bool $use_default |
|
591 | + * @throws EE_Error |
|
592 | + */ |
|
593 | + public function set($field_name, $field_value, $use_default = false) |
|
594 | + { |
|
595 | + if ($field_name === 'MSG_priority') { |
|
596 | + $this->set_priority($field_value); |
|
597 | + } |
|
598 | + parent::set($field_name, $field_value, $use_default); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * @return bool |
|
604 | + * @throws \EE_Error |
|
605 | + */ |
|
606 | + public function send_now() |
|
607 | + { |
|
608 | + $send_now = $this->valid_messenger() && $this->messenger_object()->send_now() ? EEM_Message::priority_high : $this->priority(); |
|
609 | + return $send_now === EEM_Message::priority_high ? true : false; |
|
610 | + } |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * Gets STS_ID |
|
615 | + * |
|
616 | + * @return string |
|
617 | + */ |
|
618 | + public function STS_ID() |
|
619 | + { |
|
620 | + return $this->get('STS_ID'); |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + /** |
|
625 | + * Sets STS_ID |
|
626 | + * |
|
627 | + * @param string $STS_ID |
|
628 | + */ |
|
629 | + public function set_STS_ID($STS_ID) |
|
630 | + { |
|
631 | + $this->set('STS_ID', $STS_ID); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * Gets created |
|
637 | + * |
|
638 | + * @return string |
|
639 | + */ |
|
640 | + public function created() |
|
641 | + { |
|
642 | + return $this->get('MSG_created'); |
|
643 | + } |
|
644 | + |
|
645 | + |
|
646 | + /** |
|
647 | + * Sets created |
|
648 | + * |
|
649 | + * @param string $created |
|
650 | + */ |
|
651 | + public function set_created($created) |
|
652 | + { |
|
653 | + $this->set('MSG_created', $created); |
|
654 | + } |
|
655 | + |
|
656 | + |
|
657 | + /** |
|
658 | + * Gets modified |
|
659 | + * |
|
660 | + * @return string |
|
661 | + */ |
|
662 | + public function modified() |
|
663 | + { |
|
664 | + return $this->get('MSG_modified'); |
|
665 | + } |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Sets modified |
|
670 | + * |
|
671 | + * @param string $modified |
|
672 | + */ |
|
673 | + public function set_modified($modified) |
|
674 | + { |
|
675 | + $this->set('MSG_modified', $modified); |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * Sets generation data for this message. |
|
681 | + * |
|
682 | + * @param mixed $data |
|
683 | + */ |
|
684 | + public function set_generation_data($data) |
|
685 | + { |
|
686 | + $this->set_field_or_extra_meta('MSG_generation_data', $data); |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * Returns any set generation data for this message. |
|
692 | + * |
|
693 | + * @return mixed|null |
|
694 | + */ |
|
695 | + public function get_generation_data() |
|
696 | + { |
|
697 | + return $this->get_field_or_extra_meta('MSG_generation_data'); |
|
698 | + } |
|
699 | + |
|
700 | + |
|
701 | + /** |
|
702 | + * Gets any error message. |
|
703 | + * |
|
704 | + * @return mixed|null |
|
705 | + */ |
|
706 | + public function error_message() |
|
707 | + { |
|
708 | + return $this->get_field_or_extra_meta('MSG_error'); |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * Sets an error message. |
|
714 | + * |
|
715 | + * @param $message |
|
716 | + * @return bool|int |
|
717 | + */ |
|
718 | + public function set_error_message($message) |
|
719 | + { |
|
720 | + return $this->set_field_or_extra_meta('MSG_error', $message); |
|
721 | + } |
|
722 | + |
|
723 | + |
|
724 | + /** |
|
725 | + * This retrieves the associated template pack with this message. |
|
726 | + * |
|
727 | + * @return EE_Messages_Template_Pack | null |
|
728 | + */ |
|
729 | + public function get_template_pack() |
|
730 | + { |
|
731 | + /** |
|
732 | + * This is deprecated functionality that will be removed eventually but included here now for backward compat. |
|
733 | + */ |
|
734 | + if ( ! empty($this->template_pack)) { |
|
735 | + return $this->template_pack; |
|
736 | + } |
|
737 | + /** @type EE_Message_Template_Group $grp */ |
|
738 | + $grp = $this->get_first_related('Message_Template_Group'); |
|
739 | + //if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
|
740 | + if ( ! $grp instanceof EE_Message_Template_Group) { |
|
741 | + $grp = EEM_Message_Template_Group::instance()->get_one( |
|
742 | + array( |
|
743 | + array( |
|
744 | + 'MTP_messenger' => $this->messenger(), |
|
745 | + 'MTP_message_type' => $this->message_type(), |
|
746 | + 'MTP_is_global' => true, |
|
747 | + ), |
|
748 | + ) |
|
749 | + ); |
|
750 | + } |
|
751 | + |
|
752 | + return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null; |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + /** |
|
757 | + * Retrieves the variation used for generating this message. |
|
758 | + * |
|
759 | + * @return string |
|
760 | + */ |
|
761 | + public function get_template_pack_variation() |
|
762 | + { |
|
763 | + /** |
|
764 | + * This is deprecated functionality that will be removed eventually but included here now for backward compat. |
|
765 | + */ |
|
766 | + if ( ! empty($this->template_variation)) { |
|
767 | + return $this->template_variation; |
|
768 | + } |
|
769 | + |
|
770 | + /** @type EE_Message_Template_Group $grp */ |
|
771 | + $grp = $this->get_first_related('Message_Template_Group'); |
|
772 | + |
|
773 | + //if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
|
774 | + if ( ! $grp instanceof EE_Message_Template_Group) { |
|
775 | + $grp = EEM_Message_Template_Group::instance()->get_one( |
|
776 | + array( |
|
777 | + array( |
|
778 | + 'MTP_messenger' => $this->messenger(), |
|
779 | + 'MTP_message_type' => $this->message_type(), |
|
780 | + 'MTP_is_global' => true, |
|
781 | + ), |
|
782 | + ) |
|
783 | + ); |
|
784 | + } |
|
785 | + |
|
786 | + return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : ''; |
|
787 | + } |
|
788 | + |
|
789 | + /** |
|
790 | + * Return the link to the admin details for the object. |
|
791 | + * |
|
792 | + * @return string |
|
793 | + */ |
|
794 | + public function get_admin_details_link() |
|
795 | + { |
|
796 | + EE_Registry::instance()->load_helper('URL'); |
|
797 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
798 | + switch ($this->STS_ID()) { |
|
799 | + case EEM_Message::status_failed : |
|
800 | + case EEM_Message::status_debug_only : |
|
801 | + return EEH_MSG_Template::generate_error_display_trigger($this); |
|
802 | + break; |
|
803 | + |
|
804 | + case EEM_Message::status_sent : |
|
805 | + return EEH_MSG_Template::generate_browser_trigger($this); |
|
806 | + break; |
|
807 | + |
|
808 | + default : |
|
809 | + return ''; |
|
810 | + } |
|
811 | + } |
|
812 | + |
|
813 | + /** |
|
814 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
815 | + * |
|
816 | + * @return string |
|
817 | + */ |
|
818 | + public function get_admin_edit_link() |
|
819 | + { |
|
820 | + return $this->get_admin_details_link(); |
|
821 | + } |
|
822 | + |
|
823 | + /** |
|
824 | + * Returns the link to a settings page for the object. |
|
825 | + * |
|
826 | + * @return string |
|
827 | + */ |
|
828 | + public function get_admin_settings_link() |
|
829 | + { |
|
830 | + EE_Registry::instance()->load_helper('URL'); |
|
831 | + return EEH_URL::add_query_args_and_nonce( |
|
832 | + array( |
|
833 | + 'page' => 'espresso_messages', |
|
834 | + 'action' => 'settings', |
|
835 | + ), |
|
836 | + admin_url('admin.php') |
|
837 | + ); |
|
838 | + } |
|
839 | + |
|
840 | + /** |
|
841 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
842 | + * |
|
843 | + * @return string |
|
844 | + */ |
|
845 | + public function get_admin_overview_link() |
|
846 | + { |
|
847 | + EE_Registry::instance()->load_helper('URL'); |
|
848 | + return EEH_URL::add_query_args_and_nonce( |
|
849 | + array( |
|
850 | + 'page' => 'espresso_messages', |
|
851 | + 'action' => 'default', |
|
852 | + ), |
|
853 | + admin_url('admin.php') |
|
854 | + ); |
|
855 | + } |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + * This sets the EEM_Message::status_messenger_executing class on the message and the appropriate error message for |
|
860 | + * it. |
|
861 | + * Note this also SAVES the current message object to the db because it adds an error message to accompany the status. |
|
862 | + * |
|
863 | + */ |
|
864 | + public function set_messenger_is_executing() |
|
865 | + { |
|
866 | + $this->set_STS_ID( EEM_Message::status_messenger_executing ); |
|
867 | + $this->set_error_message( |
|
868 | + esc_html__( |
|
869 | + 'A message with this status indicates that there was a problem that occurred while the message was being |
|
870 | 870 | processed by the messenger. It is still possible that the message was sent successfully, but at some |
871 | 871 | point during the processing there was a failure. This usually is indicative of a timeout issue with PHP |
872 | 872 | or memory limits being reached. If you see this repeatedly you may want to consider upgrading the memory |
873 | 873 | available to PHP on your server.', |
874 | - 'event_espresso' |
|
875 | - ) |
|
876 | - ); |
|
877 | - } |
|
874 | + 'event_espresso' |
|
875 | + ) |
|
876 | + ); |
|
877 | + } |
|
878 | 878 | } |
879 | 879 | /* End of file EE_Message.class.php */ |
880 | 880 | /* Location: /core/db_classes/EE_Message.class.php */ |
881 | 881 | \ No newline at end of file |
@@ -13,72 +13,72 @@ |
||
13 | 13 | trait BaseCoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Core method for going to an Event Espresso Admin page. |
|
18 | - * @param string $page |
|
19 | - * @param string $action |
|
20 | - * @param string $additional_params |
|
21 | - */ |
|
22 | - public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | - { |
|
24 | - $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Core method for going to an Event Espresso Admin page. |
|
18 | + * @param string $page |
|
19 | + * @param string $action |
|
20 | + * @param string $additional_params |
|
21 | + */ |
|
22 | + public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | + { |
|
24 | + $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | - * @return \EventEspressoAcceptanceTester; |
|
31 | - */ |
|
32 | - protected function actor() |
|
33 | - { |
|
34 | - /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | - return $this; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | + * @return \EventEspressoAcceptanceTester; |
|
31 | + */ |
|
32 | + protected function actor() |
|
33 | + { |
|
34 | + /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | + return $this; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Use this to set the per page option for a list table page. |
|
41 | - * Assumes you are on a page that has this field exposed. |
|
42 | - * |
|
43 | - * @param int|string $per_page_value |
|
44 | - * @throws \Codeception\Exception\TestRuntimeException |
|
45 | - */ |
|
46 | - public function setPerPageOptionForScreen($per_page_value) |
|
47 | - { |
|
48 | - $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | - $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | - $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | - $this->actor()->wait(8); |
|
52 | - } |
|
39 | + /** |
|
40 | + * Use this to set the per page option for a list table page. |
|
41 | + * Assumes you are on a page that has this field exposed. |
|
42 | + * |
|
43 | + * @param int|string $per_page_value |
|
44 | + * @throws \Codeception\Exception\TestRuntimeException |
|
45 | + */ |
|
46 | + public function setPerPageOptionForScreen($per_page_value) |
|
47 | + { |
|
48 | + $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | + $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | + $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | + $this->actor()->wait(8); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Use this to append a given value to a wpEditor instance. |
|
58 | - * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | - * the value is added to the text area. |
|
60 | - * |
|
61 | - * @param $field_reference |
|
62 | - * @param $value |
|
63 | - * @throws \Codeception\Exception\ElementNotFound |
|
64 | - */ |
|
65 | - public function appendToWPEditorField($field_reference, $value) |
|
66 | - { |
|
67 | - $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | - $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | - } |
|
56 | + /** |
|
57 | + * Use this to append a given value to a wpEditor instance. |
|
58 | + * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | + * the value is added to the text area. |
|
60 | + * |
|
61 | + * @param $field_reference |
|
62 | + * @param $value |
|
63 | + * @throws \Codeception\Exception\ElementNotFound |
|
64 | + */ |
|
65 | + public function appendToWPEditorField($field_reference, $value) |
|
66 | + { |
|
67 | + $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | + $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Use to select and submit the given bulk action. |
|
74 | - * @param string $bulk_action_option |
|
75 | - */ |
|
76 | - public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | - { |
|
78 | - $this->actor()->selectOption( |
|
79 | - CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | - $bulk_action_option |
|
81 | - ); |
|
82 | - $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | - } |
|
72 | + /** |
|
73 | + * Use to select and submit the given bulk action. |
|
74 | + * @param string $bulk_action_option |
|
75 | + */ |
|
76 | + public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | + { |
|
78 | + $this->actor()->selectOption( |
|
79 | + CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | + $bulk_action_option |
|
81 | + ); |
|
82 | + $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | + } |
|
84 | 84 | } |
@@ -13,30 +13,30 @@ |
||
13 | 13 | trait RegistrationsAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * This will select all checkboxes on a registration list table for the given array of |
|
18 | - * registration ids. |
|
19 | - * Assumes the actor is on a list table page for registrations. |
|
20 | - * @param $registration_ids |
|
21 | - */ |
|
22 | - public function selectBulkActionCheckboxesForRegistrationIds(array $registration_ids) |
|
23 | - { |
|
24 | - foreach ($registration_ids as $registration_id) { |
|
25 | - $this->actor()->checkOption( |
|
26 | - RegistrationsAdminPage::listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
27 | - ); |
|
28 | - } |
|
29 | - } |
|
16 | + /** |
|
17 | + * This will select all checkboxes on a registration list table for the given array of |
|
18 | + * registration ids. |
|
19 | + * Assumes the actor is on a list table page for registrations. |
|
20 | + * @param $registration_ids |
|
21 | + */ |
|
22 | + public function selectBulkActionCheckboxesForRegistrationIds(array $registration_ids) |
|
23 | + { |
|
24 | + foreach ($registration_ids as $registration_id) { |
|
25 | + $this->actor()->checkOption( |
|
26 | + RegistrationsAdminPage::listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
27 | + ); |
|
28 | + } |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Navigates the actor to the default registration list table page. |
|
34 | - * @param string $additional_params |
|
35 | - */ |
|
36 | - public function amOnDefaultRegistrationsListTableAdminPage($additional_params = '') |
|
37 | - { |
|
38 | - $this->actor()->amOnAdminPage( |
|
39 | - RegistrationsAdminPage::registrationsDefaultAdminListTableUrl($additional_params) |
|
40 | - ); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Navigates the actor to the default registration list table page. |
|
34 | + * @param string $additional_params |
|
35 | + */ |
|
36 | + public function amOnDefaultRegistrationsListTableAdminPage($additional_params = '') |
|
37 | + { |
|
38 | + $this->actor()->amOnAdminPage( |
|
39 | + RegistrationsAdminPage::registrationsDefaultAdminListTableUrl($additional_params) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -13,70 +13,70 @@ |
||
13 | 13 | */ |
14 | 14 | trait Checkout |
15 | 15 | { |
16 | - /** |
|
17 | - * @param $value |
|
18 | - * @param int $attendee_number |
|
19 | - */ |
|
20 | - public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1) |
|
21 | - { |
|
22 | - $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
23 | - } |
|
16 | + /** |
|
17 | + * @param $value |
|
18 | + * @param int $attendee_number |
|
19 | + */ |
|
20 | + public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1) |
|
21 | + { |
|
22 | + $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param $value |
|
27 | - * @param int $attendee_number |
|
28 | - */ |
|
29 | - public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1) |
|
30 | - { |
|
31 | - $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param $value |
|
27 | + * @param int $attendee_number |
|
28 | + */ |
|
29 | + public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1) |
|
30 | + { |
|
31 | + $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $value |
|
36 | - * @param int $attendee_number |
|
37 | - */ |
|
38 | - public function fillOutEmailFieldForAttendee($value, $attendee_number = 1) |
|
39 | - { |
|
40 | - $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
41 | - } |
|
34 | + /** |
|
35 | + * @param $value |
|
36 | + * @param int $attendee_number |
|
37 | + */ |
|
38 | + public function fillOutEmailFieldForAttendee($value, $attendee_number = 1) |
|
39 | + { |
|
40 | + $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Clicks the next registration step button. |
|
46 | - */ |
|
47 | - public function goToNextRegistrationStep() |
|
48 | - { |
|
49 | - $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
50 | - } |
|
44 | + /** |
|
45 | + * Clicks the next registration step button. |
|
46 | + */ |
|
47 | + public function goToNextRegistrationStep() |
|
48 | + { |
|
49 | + $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Selects the payment option for the given payment method slug. |
|
55 | - * |
|
56 | - * @param string $payment_method_slug |
|
57 | - * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
58 | - * payment option select box is complete. Otherwise its up to calling code to |
|
59 | - * wait for whatever is needed after selecting the payment method. |
|
60 | - */ |
|
61 | - public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
62 | - { |
|
63 | - $this->actor()->selectOption( |
|
64 | - CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
65 | - $payment_method_slug |
|
66 | - ); |
|
67 | - if ($verify_selected) { |
|
68 | - $this->actor()->waitForText('Important information regarding your payment'); |
|
69 | - } |
|
70 | - } |
|
53 | + /** |
|
54 | + * Selects the payment option for the given payment method slug. |
|
55 | + * |
|
56 | + * @param string $payment_method_slug |
|
57 | + * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
58 | + * payment option select box is complete. Otherwise its up to calling code to |
|
59 | + * wait for whatever is needed after selecting the payment method. |
|
60 | + */ |
|
61 | + public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
62 | + { |
|
63 | + $this->actor()->selectOption( |
|
64 | + CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
65 | + $payment_method_slug |
|
66 | + ); |
|
67 | + if ($verify_selected) { |
|
68 | + $this->actor()->waitForText('Important information regarding your payment'); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * Submits the payment options step form. |
|
75 | - * Assumes the actor is in the context of the payment options SPCO step. |
|
76 | - */ |
|
77 | - public function submitPaymentOptionsRegistrationStepForm() |
|
78 | - { |
|
79 | - $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
80 | - } |
|
73 | + /** |
|
74 | + * Submits the payment options step form. |
|
75 | + * Assumes the actor is in the context of the payment options SPCO step. |
|
76 | + */ |
|
77 | + public function submitPaymentOptionsRegistrationStepForm() |
|
78 | + { |
|
79 | + $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -10,288 +10,288 @@ |
||
10 | 10 | */ |
11 | 11 | trait MessagesAdmin |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | - * a string. |
|
16 | - */ |
|
17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | - { |
|
19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | - * a string. |
|
25 | - */ |
|
26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | - { |
|
28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | - * a string. |
|
35 | - */ |
|
36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | - { |
|
38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Directs to message settings page |
|
44 | - */ |
|
45 | - public function amOnMessageSettingsPage() |
|
46 | - { |
|
47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | - { |
|
53 | - $this->actor()->dragAndDrop( |
|
54 | - MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | - MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | - * @param string $message_type_slug |
|
63 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | - */ |
|
65 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | - { |
|
67 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | - * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | - * |
|
75 | - * @param int $expected_occurence_count |
|
76 | - * @param string $text_to_check_for |
|
77 | - * @param string $field |
|
78 | - * @param string $message_type_label |
|
79 | - * @param string $message_status |
|
80 | - * @param string $messenger |
|
81 | - * @param string $context |
|
82 | - */ |
|
83 | - public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | - $expected_occurence_count, |
|
85 | - $text_to_check_for, |
|
86 | - $field, |
|
87 | - $message_type_label, |
|
88 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | - $messenger = 'Email', |
|
90 | - $context = 'Event Admin' |
|
91 | - ) { |
|
92 | - $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | - $field, |
|
94 | - $message_type_label, |
|
95 | - $message_status, |
|
96 | - $messenger, |
|
97 | - $context, |
|
98 | - $text_to_check_for, |
|
99 | - 0 |
|
100 | - )); |
|
101 | - $actual_count = count($elements); |
|
102 | - $this->actor()->assertEquals( |
|
103 | - $expected_occurence_count, |
|
104 | - $actual_count, |
|
105 | - sprintf( |
|
106 | - 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | - $expected_occurence_count, |
|
108 | - $text_to_check_for, |
|
109 | - $field, |
|
110 | - $actual_count |
|
111 | - ) |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | - * default (global) message template list table. |
|
119 | - * Also takes care of verifying the template was created. |
|
120 | - * @param string $message_type_label |
|
121 | - * @param string $messenger_label |
|
122 | - */ |
|
123 | - public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | - { |
|
125 | - $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | - $this->actor()->click( |
|
127 | - MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | - $message_type_label, |
|
129 | - $messenger_label |
|
130 | - ) |
|
131 | - ); |
|
132 | - $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This switches the context of the current messages template to the given reference. |
|
138 | - * @param string $context_reference This should be the visible label for the option. |
|
139 | - */ |
|
140 | - public function switchContextTo($context_reference) |
|
141 | - { |
|
142 | - $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | - $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
150 | - * toggling. |
|
151 | - * |
|
152 | - * @param string $context_string What context is being switched (used for the expected state text) |
|
153 | - * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
154 | - * (false) |
|
155 | - */ |
|
156 | - public function toggleContextState($context_string, $expected_state_is_active = true) |
|
157 | - { |
|
158 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
159 | - if ($expected_state_is_active) { |
|
160 | - $this->actor()->waitForText("The template for $context_string is currently active."); |
|
161 | - } else { |
|
162 | - $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Triggers saving the message template. |
|
169 | - * @param bool $and_close Use to indicate to click the Save and Close button. |
|
170 | - */ |
|
171 | - public function saveMessageTemplate($and_close = false) |
|
172 | - { |
|
173 | - if ($and_close) { |
|
174 | - $this->actor()->click('Save and Close'); |
|
175 | - } else { |
|
176 | - $this->actor()->click('Save'); |
|
177 | - } |
|
178 | - $this->actor()->waitForText('successfully updated'); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * This takes care of clicking the View Message icon for the given parameters. |
|
184 | - * Assumes you are already viewing the messages activity list table. |
|
185 | - * @param $message_type_label |
|
186 | - * @param $message_status |
|
187 | - * @param string $messenger |
|
188 | - * @param string $context |
|
189 | - * @param int $number_in_set |
|
190 | - */ |
|
191 | - public function viewMessageInMessagesListTableFor( |
|
192 | - $message_type_label, |
|
193 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
194 | - $messenger = 'Email', |
|
195 | - $context = 'Event Admin', |
|
196 | - $number_in_set = 1 |
|
197 | - ) { |
|
198 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
199 | - $message_type_label, |
|
200 | - $message_status, |
|
201 | - $messenger, |
|
202 | - $context, |
|
203 | - $number_in_set |
|
204 | - )); |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
210 | - * Assumes you are already viewing the messages activity list table. |
|
211 | - * @param $message_type_label |
|
212 | - * @param $message_status |
|
213 | - * @param string $messenger |
|
214 | - * @param string $context |
|
215 | - * @param int $number_in_set |
|
216 | - */ |
|
217 | - public function deleteMessageInMessagesListTableFor( |
|
218 | - $message_type_label, |
|
219 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
220 | - $messenger = 'Email', |
|
221 | - $context = 'Event Admin', |
|
222 | - $number_in_set = 1 |
|
223 | - ) { |
|
224 | - $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
225 | - $message_type_label, |
|
226 | - $message_status, |
|
227 | - $messenger, |
|
228 | - $context, |
|
229 | - $number_in_set |
|
230 | - ); |
|
231 | - $this->actor()->moveMouseOver( |
|
232 | - MessagesPage::messagesActivityListTableCellSelectorFor( |
|
233 | - 'to', |
|
234 | - $message_type_label, |
|
235 | - $message_status, |
|
236 | - $messenger, |
|
237 | - $context, |
|
238 | - '', |
|
239 | - $number_in_set |
|
240 | - ), |
|
241 | - 5, |
|
242 | - 5 |
|
243 | - ); |
|
244 | - $this->actor()->waitForElementVisible( |
|
245 | - $delete_action_selector |
|
246 | - ); |
|
247 | - $this->actor()->click( |
|
248 | - $delete_action_selector |
|
249 | - ); |
|
250 | - $this->actor()->waitForText('successfully deleted'); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
256 | - * list table, this will take care of validating the given text is in that window. |
|
257 | - * @param string $text_to_view |
|
258 | - */ |
|
259 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
260 | - { |
|
261 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
262 | - $this->actor()->switchToIframe('message-view-window'); |
|
263 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
264 | - $this->actor()->switchToIframe(); |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * This returns the value for the link at the given selector in the message modal. |
|
270 | - * @param string $selector (any selector string accepted by WebDriver) |
|
271 | - */ |
|
272 | - public function observeLinkAtInMessageModal($selector) |
|
273 | - { |
|
274 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
275 | - $this->actor()->switchToIframe('message-view-window'); |
|
276 | - return $this->actor()->observeLinkUrlAt($selector); |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
282 | - * list table, this will take care of validating the given text is NOT that window. |
|
283 | - * @param string $text_to_view |
|
284 | - */ |
|
285 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
286 | - { |
|
287 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - public function dismissMessageModal() |
|
292 | - { |
|
293 | - $this->actor()->click('#espresso-admin-page-overlay-dv'); |
|
294 | - //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
295 | - $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
296 | - } |
|
13 | + /** |
|
14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | + * a string. |
|
16 | + */ |
|
17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | + { |
|
19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | + * a string. |
|
25 | + */ |
|
26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | + { |
|
28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | + * a string. |
|
35 | + */ |
|
36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | + { |
|
38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Directs to message settings page |
|
44 | + */ |
|
45 | + public function amOnMessageSettingsPage() |
|
46 | + { |
|
47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | + { |
|
53 | + $this->actor()->dragAndDrop( |
|
54 | + MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | + MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | + * @param string $message_type_slug |
|
63 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | + */ |
|
65 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | + { |
|
67 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | + * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | + * |
|
75 | + * @param int $expected_occurence_count |
|
76 | + * @param string $text_to_check_for |
|
77 | + * @param string $field |
|
78 | + * @param string $message_type_label |
|
79 | + * @param string $message_status |
|
80 | + * @param string $messenger |
|
81 | + * @param string $context |
|
82 | + */ |
|
83 | + public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | + $expected_occurence_count, |
|
85 | + $text_to_check_for, |
|
86 | + $field, |
|
87 | + $message_type_label, |
|
88 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | + $messenger = 'Email', |
|
90 | + $context = 'Event Admin' |
|
91 | + ) { |
|
92 | + $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | + $field, |
|
94 | + $message_type_label, |
|
95 | + $message_status, |
|
96 | + $messenger, |
|
97 | + $context, |
|
98 | + $text_to_check_for, |
|
99 | + 0 |
|
100 | + )); |
|
101 | + $actual_count = count($elements); |
|
102 | + $this->actor()->assertEquals( |
|
103 | + $expected_occurence_count, |
|
104 | + $actual_count, |
|
105 | + sprintf( |
|
106 | + 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | + $expected_occurence_count, |
|
108 | + $text_to_check_for, |
|
109 | + $field, |
|
110 | + $actual_count |
|
111 | + ) |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | + * default (global) message template list table. |
|
119 | + * Also takes care of verifying the template was created. |
|
120 | + * @param string $message_type_label |
|
121 | + * @param string $messenger_label |
|
122 | + */ |
|
123 | + public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | + { |
|
125 | + $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | + $this->actor()->click( |
|
127 | + MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | + $message_type_label, |
|
129 | + $messenger_label |
|
130 | + ) |
|
131 | + ); |
|
132 | + $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This switches the context of the current messages template to the given reference. |
|
138 | + * @param string $context_reference This should be the visible label for the option. |
|
139 | + */ |
|
140 | + public function switchContextTo($context_reference) |
|
141 | + { |
|
142 | + $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | + $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
150 | + * toggling. |
|
151 | + * |
|
152 | + * @param string $context_string What context is being switched (used for the expected state text) |
|
153 | + * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
154 | + * (false) |
|
155 | + */ |
|
156 | + public function toggleContextState($context_string, $expected_state_is_active = true) |
|
157 | + { |
|
158 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
159 | + if ($expected_state_is_active) { |
|
160 | + $this->actor()->waitForText("The template for $context_string is currently active."); |
|
161 | + } else { |
|
162 | + $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Triggers saving the message template. |
|
169 | + * @param bool $and_close Use to indicate to click the Save and Close button. |
|
170 | + */ |
|
171 | + public function saveMessageTemplate($and_close = false) |
|
172 | + { |
|
173 | + if ($and_close) { |
|
174 | + $this->actor()->click('Save and Close'); |
|
175 | + } else { |
|
176 | + $this->actor()->click('Save'); |
|
177 | + } |
|
178 | + $this->actor()->waitForText('successfully updated'); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * This takes care of clicking the View Message icon for the given parameters. |
|
184 | + * Assumes you are already viewing the messages activity list table. |
|
185 | + * @param $message_type_label |
|
186 | + * @param $message_status |
|
187 | + * @param string $messenger |
|
188 | + * @param string $context |
|
189 | + * @param int $number_in_set |
|
190 | + */ |
|
191 | + public function viewMessageInMessagesListTableFor( |
|
192 | + $message_type_label, |
|
193 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
194 | + $messenger = 'Email', |
|
195 | + $context = 'Event Admin', |
|
196 | + $number_in_set = 1 |
|
197 | + ) { |
|
198 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
199 | + $message_type_label, |
|
200 | + $message_status, |
|
201 | + $messenger, |
|
202 | + $context, |
|
203 | + $number_in_set |
|
204 | + )); |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
210 | + * Assumes you are already viewing the messages activity list table. |
|
211 | + * @param $message_type_label |
|
212 | + * @param $message_status |
|
213 | + * @param string $messenger |
|
214 | + * @param string $context |
|
215 | + * @param int $number_in_set |
|
216 | + */ |
|
217 | + public function deleteMessageInMessagesListTableFor( |
|
218 | + $message_type_label, |
|
219 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
220 | + $messenger = 'Email', |
|
221 | + $context = 'Event Admin', |
|
222 | + $number_in_set = 1 |
|
223 | + ) { |
|
224 | + $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
225 | + $message_type_label, |
|
226 | + $message_status, |
|
227 | + $messenger, |
|
228 | + $context, |
|
229 | + $number_in_set |
|
230 | + ); |
|
231 | + $this->actor()->moveMouseOver( |
|
232 | + MessagesPage::messagesActivityListTableCellSelectorFor( |
|
233 | + 'to', |
|
234 | + $message_type_label, |
|
235 | + $message_status, |
|
236 | + $messenger, |
|
237 | + $context, |
|
238 | + '', |
|
239 | + $number_in_set |
|
240 | + ), |
|
241 | + 5, |
|
242 | + 5 |
|
243 | + ); |
|
244 | + $this->actor()->waitForElementVisible( |
|
245 | + $delete_action_selector |
|
246 | + ); |
|
247 | + $this->actor()->click( |
|
248 | + $delete_action_selector |
|
249 | + ); |
|
250 | + $this->actor()->waitForText('successfully deleted'); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
256 | + * list table, this will take care of validating the given text is in that window. |
|
257 | + * @param string $text_to_view |
|
258 | + */ |
|
259 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
260 | + { |
|
261 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
262 | + $this->actor()->switchToIframe('message-view-window'); |
|
263 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
264 | + $this->actor()->switchToIframe(); |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * This returns the value for the link at the given selector in the message modal. |
|
270 | + * @param string $selector (any selector string accepted by WebDriver) |
|
271 | + */ |
|
272 | + public function observeLinkAtInMessageModal($selector) |
|
273 | + { |
|
274 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
275 | + $this->actor()->switchToIframe('message-view-window'); |
|
276 | + return $this->actor()->observeLinkUrlAt($selector); |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
282 | + * list table, this will take care of validating the given text is NOT that window. |
|
283 | + * @param string $text_to_view |
|
284 | + */ |
|
285 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
286 | + { |
|
287 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + public function dismissMessageModal() |
|
292 | + { |
|
293 | + $this->actor()->click('#espresso-admin-page-overlay-dv'); |
|
294 | + //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
295 | + $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
296 | + } |
|
297 | 297 | } |
@@ -13,96 +13,96 @@ |
||
13 | 13 | class CoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - const URL_PREFIX = 'admin.php?page='; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * This is the selector for the next page button on list tables. |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * The selector for the search input submit button on list table pages |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Selector for the screen options dropdown. |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Selector for apply screen options settings. |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Selector for bulk action select field on list tables. |
|
59 | - */ |
|
60 | - const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-'; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Selector for applying a bulk action. |
|
65 | - */ |
|
66 | - const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the EE admin url for the given properties. |
|
71 | - * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
72 | - * with `amOnAdminPage` action. |
|
73 | - * |
|
74 | - * @param string $page |
|
75 | - * @param string $action |
|
76 | - * @param string $additional_params |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
80 | - { |
|
81 | - $url = self::URL_PREFIX . $page; |
|
82 | - $url .= $action ? '&action=' . $action : ''; |
|
83 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
84 | - return $url; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns the selector for the text tab switcher for a wp-editor instance. |
|
90 | - * @param $field_reference |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public static function wpEditorTextTabSelector($field_reference) |
|
94 | - { |
|
95 | - return '#content-' . $field_reference . '-content-html'; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
101 | - * @param $field_reference |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public static function wpEditorTextAreaSelector($field_reference) |
|
105 | - { |
|
106 | - return '#content-' . $field_reference . '-content'; |
|
107 | - } |
|
16 | + /** |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + const URL_PREFIX = 'admin.php?page='; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * This is the selector for the next page button on list tables. |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * The selector for the search input submit button on list table pages |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Selector for the screen options dropdown. |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Selector for apply screen options settings. |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Selector for bulk action select field on list tables. |
|
59 | + */ |
|
60 | + const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-'; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Selector for applying a bulk action. |
|
65 | + */ |
|
66 | + const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the EE admin url for the given properties. |
|
71 | + * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
72 | + * with `amOnAdminPage` action. |
|
73 | + * |
|
74 | + * @param string $page |
|
75 | + * @param string $action |
|
76 | + * @param string $additional_params |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
80 | + { |
|
81 | + $url = self::URL_PREFIX . $page; |
|
82 | + $url .= $action ? '&action=' . $action : ''; |
|
83 | + $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
84 | + return $url; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns the selector for the text tab switcher for a wp-editor instance. |
|
90 | + * @param $field_reference |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public static function wpEditorTextTabSelector($field_reference) |
|
94 | + { |
|
95 | + return '#content-' . $field_reference . '-content-html'; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
101 | + * @param $field_reference |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public static function wpEditorTextAreaSelector($field_reference) |
|
105 | + { |
|
106 | + return '#content-' . $field_reference . '-content'; |
|
107 | + } |
|
108 | 108 | } |
@@ -11,43 +11,43 @@ |
||
11 | 11 | */ |
12 | 12 | class RegistrationsAdmin extends CoreAdmin |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $additional_params |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public static function registrationsDefaultAdminListTableUrl($additional_params = '') |
|
38 | - { |
|
39 | - return self::adminUrl('espresso_registrations', 'default', $additional_params); |
|
40 | - } |
|
33 | + /** |
|
34 | + * @param string $additional_params |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public static function registrationsDefaultAdminListTableUrl($additional_params = '') |
|
38 | + { |
|
39 | + return self::adminUrl('espresso_registrations', 'default', $additional_params); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Given a registration id, this will return the selector for all the checkbox for that id. |
|
45 | - * Assumes the view is a Registration list table. |
|
46 | - * @param int $registration_id |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public static function listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
50 | - { |
|
51 | - return "//input[@name='_REG_ID[]' and @value='{$registration_id}']"; |
|
52 | - } |
|
43 | + /** |
|
44 | + * Given a registration id, this will return the selector for all the checkbox for that id. |
|
45 | + * Assumes the view is a Registration list table. |
|
46 | + * @param int $registration_id |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public static function listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
50 | + { |
|
51 | + return "//input[@name='_REG_ID[]' and @value='{$registration_id}']"; |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | \ No newline at end of file |
@@ -14,267 +14,267 @@ |
||
14 | 14 | class EventsAdmin extends CoreAdmin |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Selector for the Add new Event button in the admin. |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Selector for the Event Title field in the event editor |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | - |
|
30 | - /** |
|
31 | - * Selector for the publish submit button in the event editor. |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * Selector for the save button in the event editor |
|
39 | - */ |
|
40 | - const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post"; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
47 | - |
|
48 | - /** |
|
49 | - * Selector for the view link after publishing an event. |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a"; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Selector for the ID of the event in the event editor |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * Selector for the search input on the event list table page. |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $additional_params |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public static function defaultEventsListTableUrl($additional_params = '') |
|
76 | - { |
|
77 | - return self::adminUrl('espresso_events', 'default', $additional_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * The selector for the DTTname field for the given row in the event editor. |
|
83 | - * @param int $row_number |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
87 | - { |
|
88 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
94 | - * @param int $row_number |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
98 | - { |
|
99 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
105 | - * |
|
106 | - * @param string $field_name |
|
107 | - * @param int $row_number |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
111 | - { |
|
112 | - return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * The selector for the TKT_name field for the given display row in the event editor. |
|
118 | - * @param int $row_number |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
122 | - { |
|
123 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * Selector for the TKT_base_price field for the given display row in the event editor. |
|
129 | - * @param int $row_number |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
133 | - { |
|
134 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Selector for the TKT_qty field for the given display row in the event editor. |
|
140 | - * @param int $row_number |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public static function eventEditorTicketQuantityFieldSelector($row_number = 1) |
|
144 | - { |
|
145 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Selector for the advanced details toggle for the ticket for the given display row in the event editor. |
|
151 | - * @param int $row_number |
|
152 | - * @return string |
|
153 | - */ |
|
154 | - public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
155 | - { |
|
156 | - return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * Selector for the subtotal amount for the given display row of the ticket in the event editor. |
|
162 | - * @param int $row_number |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
166 | - { |
|
167 | - return "//span[@id='price-total-amount-$row_number']"; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Selector for the Total element for the given display row of the ticket in the event editor. |
|
173 | - * @param int $row_number |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
177 | - { |
|
178 | - return "//span[@id='price-total-amount-$row_number']"; |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Selector for the taxable selector for the ticket for the given display row in the event editor. |
|
184 | - * @param int $row_number |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
188 | - { |
|
189 | - return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
195 | - * given ticket (row) and the given tax id (PRC_ID). |
|
196 | - * |
|
197 | - * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
198 | - * setup on a fresh install. |
|
199 | - * @param int $row_number What row representing the ticket you want the locator for. |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
203 | - { |
|
204 | - return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
210 | - * @param $field_name |
|
211 | - * @param int $row_number |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
215 | - { |
|
216 | - return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
222 | - * @param string $event_title |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
226 | - { |
|
227 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * Locator for for the ID column in the event list table for a given event title. |
|
233 | - * @param string $event_title |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public static function eventListTableEventIdSelectorForTitle($event_title) |
|
237 | - { |
|
238 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
239 | - . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * Locator for the view link in the row of an event list table for the given event title. |
|
245 | - * @param string $event_title |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
249 | - { |
|
250 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
251 | - . "//ancestor::td//span[@class='view']/a"; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
257 | - * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
258 | - * @return string |
|
259 | - */ |
|
260 | - public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
261 | - { |
|
262 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
263 | - . "//a[@rel='ee-tab-$messenger_slug']"; |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * Locator for the select input within the notifications metabox. |
|
269 | - * Note, this assumes the tab content for the related messenger is already visible. |
|
270 | - * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
274 | - { |
|
275 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
276 | - . "//table[@class='messages-custom-template-switcher']" |
|
277 | - . "//tr/td[contains(.,'Registration Approved')]" |
|
278 | - . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
279 | - } |
|
17 | + /** |
|
18 | + * Selector for the Add new Event button in the admin. |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Selector for the Event Title field in the event editor |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | + |
|
30 | + /** |
|
31 | + * Selector for the publish submit button in the event editor. |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * Selector for the save button in the event editor |
|
39 | + */ |
|
40 | + const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post"; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
47 | + |
|
48 | + /** |
|
49 | + * Selector for the view link after publishing an event. |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a"; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Selector for the ID of the event in the event editor |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * Selector for the search input on the event list table page. |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $additional_params |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public static function defaultEventsListTableUrl($additional_params = '') |
|
76 | + { |
|
77 | + return self::adminUrl('espresso_events', 'default', $additional_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * The selector for the DTTname field for the given row in the event editor. |
|
83 | + * @param int $row_number |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
87 | + { |
|
88 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
94 | + * @param int $row_number |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
98 | + { |
|
99 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
105 | + * |
|
106 | + * @param string $field_name |
|
107 | + * @param int $row_number |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
111 | + { |
|
112 | + return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * The selector for the TKT_name field for the given display row in the event editor. |
|
118 | + * @param int $row_number |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
122 | + { |
|
123 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * Selector for the TKT_base_price field for the given display row in the event editor. |
|
129 | + * @param int $row_number |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
133 | + { |
|
134 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Selector for the TKT_qty field for the given display row in the event editor. |
|
140 | + * @param int $row_number |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public static function eventEditorTicketQuantityFieldSelector($row_number = 1) |
|
144 | + { |
|
145 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Selector for the advanced details toggle for the ticket for the given display row in the event editor. |
|
151 | + * @param int $row_number |
|
152 | + * @return string |
|
153 | + */ |
|
154 | + public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
155 | + { |
|
156 | + return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * Selector for the subtotal amount for the given display row of the ticket in the event editor. |
|
162 | + * @param int $row_number |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
166 | + { |
|
167 | + return "//span[@id='price-total-amount-$row_number']"; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Selector for the Total element for the given display row of the ticket in the event editor. |
|
173 | + * @param int $row_number |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
177 | + { |
|
178 | + return "//span[@id='price-total-amount-$row_number']"; |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Selector for the taxable selector for the ticket for the given display row in the event editor. |
|
184 | + * @param int $row_number |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
188 | + { |
|
189 | + return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
195 | + * given ticket (row) and the given tax id (PRC_ID). |
|
196 | + * |
|
197 | + * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
198 | + * setup on a fresh install. |
|
199 | + * @param int $row_number What row representing the ticket you want the locator for. |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
203 | + { |
|
204 | + return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
210 | + * @param $field_name |
|
211 | + * @param int $row_number |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
215 | + { |
|
216 | + return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
222 | + * @param string $event_title |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
226 | + { |
|
227 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * Locator for for the ID column in the event list table for a given event title. |
|
233 | + * @param string $event_title |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public static function eventListTableEventIdSelectorForTitle($event_title) |
|
237 | + { |
|
238 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
239 | + . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * Locator for the view link in the row of an event list table for the given event title. |
|
245 | + * @param string $event_title |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
249 | + { |
|
250 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
251 | + . "//ancestor::td//span[@class='view']/a"; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
257 | + * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
258 | + * @return string |
|
259 | + */ |
|
260 | + public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
261 | + { |
|
262 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
263 | + . "//a[@rel='ee-tab-$messenger_slug']"; |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * Locator for the select input within the notifications metabox. |
|
269 | + * Note, this assumes the tab content for the related messenger is already visible. |
|
270 | + * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
274 | + { |
|
275 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
276 | + . "//table[@class='messages-custom-template-switcher']" |
|
277 | + . "//tr/td[contains(.,'Registration Approved')]" |
|
278 | + . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
279 | + } |
|
280 | 280 | } |
@@ -13,62 +13,62 @@ |
||
13 | 13 | class Checkout |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * The class selector for the next step button in the checkout. |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
16 | + /** |
|
17 | + * The class selector for the next step button in the checkout. |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
21 | 21 | |
22 | 22 | |
23 | - const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
23 | + const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param int $attendee_number |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
31 | - { |
|
32 | - return self::fieldSelectorForAttendeeNumber('fname', $attendee_number); |
|
33 | - } |
|
26 | + /** |
|
27 | + * @param int $attendee_number |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
31 | + { |
|
32 | + return self::fieldSelectorForAttendeeNumber('fname', $attendee_number); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param int $attendee_number |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
41 | - { |
|
42 | - return self::fieldSelectorForAttendeeNumber('lname', $attendee_number); |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param int $attendee_number |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
41 | + { |
|
42 | + return self::fieldSelectorForAttendeeNumber('lname', $attendee_number); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param int $attendee_number |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
51 | - { |
|
52 | - return self::fieldSelectorForAttendeeNumber('email', $attendee_number); |
|
53 | - } |
|
46 | + /** |
|
47 | + * @param int $attendee_number |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
51 | + { |
|
52 | + return self::fieldSelectorForAttendeeNumber('email', $attendee_number); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param $field_name |
|
57 | - * @param int $attendee_number |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1) |
|
61 | - { |
|
62 | - return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
63 | - } |
|
55 | + /** |
|
56 | + * @param $field_name |
|
57 | + * @param int $attendee_number |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1) |
|
61 | + { |
|
62 | + return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param string $payment_method_slug Slug for the payment method. |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
71 | - { |
|
72 | - return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
73 | - } |
|
66 | + /** |
|
67 | + * @param string $payment_method_slug Slug for the payment method. |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
71 | + { |
|
72 | + return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
73 | + } |
|
74 | 74 | } |