1
|
|
|
<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
2
|
|
|
exit( 'No direct script access allowed' ); |
3
|
|
|
} |
4
|
|
|
/** |
5
|
|
|
* EE_Message class |
6
|
|
|
* |
7
|
|
|
* @package Event Espresso |
8
|
|
|
* @subpackage db classes |
9
|
|
|
* @author Darren Ethier |
10
|
|
|
*/ |
11
|
|
|
class EE_Message extends EE_Base_Class implements EEI_Admin_Links { |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @deprecated 4.9.0 Added for backward compat with add-on's |
15
|
|
|
* @type null |
16
|
|
|
*/ |
17
|
|
|
public $template_pack; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @deprecated 4.9.0 Added for backward compat with add-on's |
21
|
|
|
* @type null |
22
|
|
|
*/ |
23
|
|
|
public $template_variation; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @deprecated 4.9.0 Added for backward compat with add-on's |
27
|
|
|
* @type string |
28
|
|
|
*/ |
29
|
|
|
public $content = ''; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @type EE_Messenger $_messenger |
34
|
|
|
*/ |
35
|
|
|
protected $_messenger = null; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @type EE_Message_Type $_message_type |
39
|
|
|
*/ |
40
|
|
|
protected $_message_type = null; |
41
|
|
|
|
42
|
|
|
|
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 format. |
49
|
|
|
* @return EE_Message |
50
|
|
|
*/ |
51
|
|
|
public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
52
|
|
|
$has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
|
|
|
53
|
|
|
//if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db. |
54
|
|
|
if ( ! $has_object ) { |
55
|
|
|
EE_Registry::instance()->load_helper( 'URL' ); |
56
|
|
|
$props_n_values['MSG_token'] = EEH_URL::generate_unique_token(); |
57
|
|
|
} |
58
|
|
|
return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
59
|
|
|
} |
60
|
|
|
|
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
|
|
|
return new self( $props_n_values, true, $timezone ); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Gets MSG_token |
77
|
|
|
* |
78
|
|
|
* @return int |
79
|
|
|
*/ |
80
|
|
|
public function MSG_token() { |
81
|
|
|
return $this->get( 'MSG_token' ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Sets MSG_token |
88
|
|
|
* |
89
|
|
|
* @param int $MSG_token |
90
|
|
|
*/ |
91
|
|
|
public function set_MSG_token( $MSG_token) { |
92
|
|
|
$this->set( 'MSG_token', $MSG_token ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Gets GRP_ID |
100
|
|
|
* |
101
|
|
|
* @return int |
102
|
|
|
*/ |
103
|
|
|
public function GRP_ID() { |
104
|
|
|
return $this->get( 'GRP_ID' ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Sets GRP_ID |
111
|
|
|
* |
112
|
|
|
* @param int $GRP_ID |
113
|
|
|
*/ |
114
|
|
|
public function set_GRP_ID( $GRP_ID ) { |
115
|
|
|
$this->set( 'GRP_ID', $GRP_ID ); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
|
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Gets TXN_ID |
123
|
|
|
* |
124
|
|
|
* @return int |
125
|
|
|
*/ |
126
|
|
|
public function TXN_ID() { |
127
|
|
|
return $this->get( 'TXN_ID' ); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Sets TXN_ID |
134
|
|
|
* |
135
|
|
|
* @param int $TXN_ID |
136
|
|
|
*/ |
137
|
|
|
public function set_TXN_ID( $TXN_ID) { |
138
|
|
|
$this->set( 'TXN_ID', $TXN_ID ); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
|
142
|
|
|
|
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Gets messenger |
146
|
|
|
* |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function messenger() { |
150
|
|
|
return $this->get( 'MSG_messenger' ); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Sets messenger |
157
|
|
|
* |
158
|
|
|
* @param string $messenger |
159
|
|
|
*/ |
160
|
|
|
public function set_messenger( $messenger ) { |
161
|
|
|
$this->set( 'MSG_messenger', $messenger ); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Returns corresponding messenger object for the set messenger on this message |
168
|
|
|
* |
169
|
|
|
* @return EE_Messenger | null |
170
|
|
|
*/ |
171
|
|
|
public function messenger_object() { |
172
|
|
|
return $this->_messenger; |
173
|
|
|
//EE_Registry::instance()->load_helper( 'MSG_Template' ); |
174
|
|
|
//return EEH_MSG_Template::messenger_obj( $this->messenger() ); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Sets messenger |
181
|
|
|
* |
182
|
|
|
* @param EE_Messenger $messenger |
183
|
|
|
*/ |
184
|
|
|
public function set_messenger_object( EE_Messenger $messenger ) { |
185
|
|
|
$this->_messenger = $messenger; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
|
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* validates messenger |
192
|
|
|
* |
193
|
|
|
* @param bool $throw_exceptions |
194
|
|
|
* @return bool |
195
|
|
|
* @throws \EE_Error |
196
|
|
|
*/ |
197
|
|
|
public function valid_messenger( $throw_exceptions = false ) { |
198
|
|
|
if ( $this->_messenger instanceof EE_Messenger ) { |
199
|
|
|
return true; |
200
|
|
|
} |
201
|
|
|
if ( $throw_exceptions ) { |
202
|
|
|
throw new EE_Error( |
203
|
|
|
sprintf( |
204
|
|
|
__( |
205
|
|
|
'The "%1$s" messenger set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.', |
206
|
|
|
'event_espresso' |
207
|
|
|
), |
208
|
|
|
$this->messenger() |
209
|
|
|
) |
210
|
|
|
); |
211
|
|
|
} |
212
|
|
|
return false; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
|
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* This returns the set localized label for the messenger on this message. |
219
|
|
|
* Note, if unable to retrieve the EE_Messenger object then will just return the messenger slug saved |
220
|
|
|
* with this message. |
221
|
|
|
* |
222
|
|
|
* @param bool $plural whether to return the plural label or not. |
223
|
|
|
* @return string |
224
|
|
|
*/ |
225
|
|
|
public function messenger_label( $plural = false ) { |
226
|
|
|
$label_type = $plural ? 'plural' : 'singular'; |
227
|
|
|
$messenger = $this->messenger_object(); |
228
|
|
|
return $messenger instanceof EE_Messenger ? $messenger->label[ $label_type ] : $this->messenger(); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
|
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Gets message_type |
235
|
|
|
* |
236
|
|
|
* @return string |
237
|
|
|
*/ |
238
|
|
|
public function message_type() { |
239
|
|
|
return $this->get( 'MSG_message_type' ); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
|
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Sets message_type |
246
|
|
|
* |
247
|
|
|
* @param string $message_type |
248
|
|
|
*/ |
249
|
|
|
public function set_message_type( $message_type ) { |
250
|
|
|
$this->set( 'MSG_message_type', $message_type ); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
|
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Returns the message type object for the set message type on this message |
257
|
|
|
* |
258
|
|
|
* @return EE_message_type | null |
259
|
|
|
*/ |
260
|
|
|
public function message_type_object() { |
261
|
|
|
return $this->_message_type; |
262
|
|
|
//EE_Registry::instance()->load_helper( 'MSG_Template' ); |
263
|
|
|
//return EEH_MSG_Template::message_type_obj( $this->message_type() ); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
|
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Sets message_type |
270
|
|
|
* |
271
|
|
|
* @param EE_Message_Type $message_type |
272
|
|
|
*/ |
273
|
|
|
public function set_message_type_object( EE_Message_Type $message_type ) { |
274
|
|
|
$this->_message_type = $message_type; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
|
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* validates message_type |
281
|
|
|
* |
282
|
|
|
* @param bool $throw_exceptions |
283
|
|
|
* @return bool |
284
|
|
|
* @throws \EE_Error |
285
|
|
|
*/ |
286
|
|
|
public function valid_message_type( $throw_exceptions = false ) { |
287
|
|
|
if ( $this->_message_type instanceof EE_Message_Type ) { |
288
|
|
|
return true; |
289
|
|
|
} |
290
|
|
|
if ( $throw_exceptions ) { |
291
|
|
|
throw new EE_Error( |
292
|
|
|
sprintf( |
293
|
|
|
__( |
294
|
|
|
'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.', |
295
|
|
|
'event_espresso' |
296
|
|
|
), |
297
|
|
|
$this->message_type() |
298
|
|
|
) |
299
|
|
|
); |
300
|
|
|
} |
301
|
|
|
return false; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
|
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* This returns the set localized label for the message type on this message. |
308
|
|
|
* Note, if unable to retrieve the EE_message_type object then will just return the message type slug saved |
309
|
|
|
* with this message. |
310
|
|
|
* |
311
|
|
|
* @param bool $plural whether to return the plural label or not. |
312
|
|
|
* @return string |
313
|
|
|
*/ |
314
|
|
|
public function message_type_label( $plural = false ) { |
315
|
|
|
$label_type = $plural ? 'plural' : 'singular'; |
316
|
|
|
$message_type = $this->message_type_object(); |
317
|
|
|
return $message_type instanceof EE_message_type ? $message_type->label[ $label_type ] : $this->message_type(); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
|
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Gets context |
324
|
|
|
* |
325
|
|
|
* @return string |
326
|
|
|
*/ |
327
|
|
|
public function context() { |
328
|
|
|
return $this->get( 'MSG_context' ); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
|
332
|
|
|
|
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* This returns the corresponding localized label for the given context slug, if possible from installed message types. |
336
|
|
|
* Otherwise, this will just return the set context slug on this object. |
337
|
|
|
* |
338
|
|
|
* @return string |
339
|
|
|
*/ |
340
|
|
|
public function context_label() { |
341
|
|
|
/** @type EE_Messages $messages_controller */ |
342
|
|
|
$messages_controller = EE_Registry::instance()->load_lib( 'messages' ); |
343
|
|
|
$contexts = $messages_controller->get_all_contexts(); |
344
|
|
|
return isset( $contexts[ $this->context() ] ) ? $contexts[ $this->context() ] : $this->context(); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
|
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Sets context |
351
|
|
|
* |
352
|
|
|
* @param string $context |
353
|
|
|
*/ |
354
|
|
|
public function set_context( $context ) { |
355
|
|
|
$this->set( 'MSG_context', $context ); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
|
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Gets recipient_ID |
362
|
|
|
* |
363
|
|
|
* @return int |
364
|
|
|
*/ |
365
|
|
|
public function recipient_ID() { |
366
|
|
|
return $this->get( 'MSG_recipient_ID' ); |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
|
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Sets recipient_ID |
373
|
|
|
* |
374
|
|
|
* @param string $recipient_ID |
375
|
|
|
*/ |
376
|
|
|
public function set_recipient_ID( $recipient_ID ) { |
377
|
|
|
$this->set( 'MSG_recipient_ID', $recipient_ID ); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
|
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Gets recipient_type |
384
|
|
|
* |
385
|
|
|
* @return string |
386
|
|
|
*/ |
387
|
|
|
public function recipient_type() { |
388
|
|
|
return $this->get( 'MSG_recipient_type' ); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
|
392
|
|
|
|
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* Return the related object matching the recipient type and ID. |
396
|
|
|
* |
397
|
|
|
* @return EE_Base_Class | null |
398
|
|
|
*/ |
399
|
|
|
public function recipient_object() { |
400
|
|
|
if ( ! $this->recipient_type() || ! $this->recipient_ID() ) { |
401
|
|
|
return null; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
return $this->get_first_related( $this->recipient_type() ); |
|
|
|
|
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
|
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Sets recipient_type |
411
|
|
|
* |
412
|
|
|
* @param string $recipient_type |
413
|
|
|
*/ |
414
|
|
|
public function set_recipient_type( $recipient_type ) { |
415
|
|
|
$this->set( 'MSG_recipient_type', $recipient_type ); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
|
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Gets content |
422
|
|
|
* |
423
|
|
|
* @return string |
424
|
|
|
*/ |
425
|
|
|
public function content() { |
426
|
|
|
return $this->get( 'MSG_content' ); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
|
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* Sets content |
433
|
|
|
* |
434
|
|
|
* @param string $content |
435
|
|
|
*/ |
436
|
|
|
public function set_content( $content ) { |
437
|
|
|
$this->set( 'MSG_content', $content ); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
|
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Gets subject |
444
|
|
|
* |
445
|
|
|
* @return string |
446
|
|
|
*/ |
447
|
|
|
public function subject() { |
448
|
|
|
return $this->get( 'MSG_subject' ); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
|
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Sets subject |
455
|
|
|
* |
456
|
|
|
* @param string $subject |
457
|
|
|
*/ |
458
|
|
|
public function set_subject( $subject ) { |
459
|
|
|
$this->set( 'MSG_subject', $subject ); |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
|
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Gets to |
466
|
|
|
* |
467
|
|
|
* @return string |
468
|
|
|
*/ |
469
|
|
|
public function to() { |
470
|
|
|
$to = $this->get( 'MSG_to' ); |
471
|
|
|
return empty( $to ) ? __( 'No recipient', 'event_espresso' ) : $to; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
|
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Sets to |
478
|
|
|
* |
479
|
|
|
* @param string $to |
480
|
|
|
*/ |
481
|
|
|
public function set_to( $to ) { |
482
|
|
|
$this->set( 'MSG_to', $to ); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
|
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Gets from |
489
|
|
|
* |
490
|
|
|
* @return string |
491
|
|
|
*/ |
492
|
|
|
public function from() { |
493
|
|
|
return $this->get( 'MSG_from' ); |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
|
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* Sets from |
500
|
|
|
* |
501
|
|
|
* @param string $from |
502
|
|
|
*/ |
503
|
|
|
public function set_from( $from ) { |
504
|
|
|
$this->set( 'MSG_from', $from ); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
|
508
|
|
|
|
509
|
|
|
|
510
|
|
|
|
511
|
|
|
/** |
512
|
|
|
* Gets priority |
513
|
|
|
* |
514
|
|
|
* @return int |
515
|
|
|
*/ |
516
|
|
|
public function priority() { |
517
|
|
|
return $this->get( 'MSG_priority' ); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
|
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Sets priority |
524
|
|
|
* |
525
|
|
|
* @param int $priority |
526
|
|
|
*/ |
527
|
|
|
public function set_priority( $priority ) { |
528
|
|
|
$this->set( 'MSG_priority', $priority ); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
|
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* Gets STS_ID |
535
|
|
|
* |
536
|
|
|
* @return string |
537
|
|
|
*/ |
538
|
|
|
public function STS_ID() { |
539
|
|
|
return $this->get( 'STS_ID' ); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
|
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Sets STS_ID |
546
|
|
|
* |
547
|
|
|
* @param string $STS_ID |
548
|
|
|
*/ |
549
|
|
|
public function set_STS_ID( $STS_ID ) { |
550
|
|
|
$this->set( 'STS_ID', $STS_ID ); |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
|
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* Gets created |
557
|
|
|
* |
558
|
|
|
* @return string |
559
|
|
|
*/ |
560
|
|
|
public function created() { |
561
|
|
|
return $this->get( 'MSG_created' ); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
|
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Sets created |
568
|
|
|
* |
569
|
|
|
* @param string $created |
570
|
|
|
*/ |
571
|
|
|
public function set_created( $created ) { |
572
|
|
|
$this->set( 'MSG_created', $created ); |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
|
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Gets modified |
579
|
|
|
* |
580
|
|
|
* @return string |
581
|
|
|
*/ |
582
|
|
|
public function modified() { |
583
|
|
|
return $this->get( 'MSG_modified' ); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
|
587
|
|
|
|
588
|
|
|
/** |
589
|
|
|
* Sets modified |
590
|
|
|
* |
591
|
|
|
* @param string $modified |
592
|
|
|
*/ |
593
|
|
|
public function set_modified( $modified ) { |
594
|
|
|
$this->set( 'MSG_modified', $modified ); |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
|
598
|
|
|
|
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Sets generation data for this message. |
602
|
|
|
* @param mixed $data |
603
|
|
|
*/ |
604
|
|
|
public function set_generation_data( $data ) { |
605
|
|
|
$this->set_field_or_extra_meta( 'MSG_generation_data', $data ); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
|
609
|
|
|
|
610
|
|
|
|
611
|
|
|
|
612
|
|
|
/** |
613
|
|
|
* Returns any set generation data for this message. |
614
|
|
|
* @return mixed|null |
615
|
|
|
*/ |
616
|
|
|
public function get_generation_data() { |
617
|
|
|
return $this->get_field_or_extra_meta( 'MSG_generation_data' ); |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
|
621
|
|
|
|
622
|
|
|
|
623
|
|
|
/** |
624
|
|
|
* Gets any error message. |
625
|
|
|
* @return mixed|null |
626
|
|
|
*/ |
627
|
|
|
public function error_message() { |
628
|
|
|
return $this->get_field_or_extra_meta( 'MSG_error' ); |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
|
632
|
|
|
/** |
633
|
|
|
* Sets an error message. |
634
|
|
|
* @param $message |
635
|
|
|
* @return bool|int |
636
|
|
|
*/ |
637
|
|
|
public function set_error_message( $message ) { |
638
|
|
|
return $this->set_field_or_extra_meta( 'MSG_error', $message ); |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
|
642
|
|
|
|
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* This retrieves the associated template pack with this message. |
646
|
|
|
* @return EE_Messages_Template_Pack | null |
647
|
|
|
*/ |
648
|
|
View Code Duplication |
public function get_template_pack() { |
|
|
|
|
649
|
|
|
/** |
650
|
|
|
* This is deprecated functionality that will be removed eventually but included here now for backward compat. |
651
|
|
|
*/ |
652
|
|
|
if ( ! empty( $this->template_pack ) ) { |
|
|
|
|
653
|
|
|
return $this->template_pack; |
|
|
|
|
654
|
|
|
} |
655
|
|
|
/** @type EE_Message_Template_Group $grp */ |
656
|
|
|
$grp = $this->get_first_related( 'Message_Template_Group' ); |
657
|
|
|
//if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
658
|
|
|
if ( ! $grp instanceof EE_Message_Template_Group ) { |
659
|
|
|
$grp = EEM_Message_Template_Group::instance()->get_one( array( array( |
660
|
|
|
'MTP_messenger' => $this->messenger(), |
661
|
|
|
'MTP_message_type' => $this->message_type(), |
662
|
|
|
'MTP_is_global' => true |
663
|
|
|
) ) ); |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
|
670
|
|
|
|
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* Retrieves the variation used for generating this message. |
674
|
|
|
* @return string |
675
|
|
|
*/ |
676
|
|
View Code Duplication |
public function get_template_pack_variation() { |
|
|
|
|
677
|
|
|
/** |
678
|
|
|
* This is deprecated functionality that will be removed eventually but included here now for backward compat. |
679
|
|
|
*/ |
680
|
|
|
if ( ! empty( $this->template_variation ) ) { |
|
|
|
|
681
|
|
|
return $this->template_variation; |
|
|
|
|
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
/** @type EE_Message_Template_Group $grp */ |
685
|
|
|
$grp = $this->get_first_related( 'Message_Template_Group' ); |
686
|
|
|
|
687
|
|
|
//if no group then let's try to get the first related group by internal messenger and message type (will use global grp). |
688
|
|
|
if ( ! $grp instanceof EE_Message_Template_Group ) { |
689
|
|
|
$grp = EEM_Message_Template_Group::instance()->get_one( array( array( |
690
|
|
|
'MTP_messenger' => $this->messenger(), |
691
|
|
|
'MTP_message_type' => $this->message_type(), |
692
|
|
|
'MTP_is_global' => true |
693
|
|
|
) ) ); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : ''; |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
/** |
700
|
|
|
* Return the link to the admin details for the object. |
701
|
|
|
* @return string |
702
|
|
|
*/ |
703
|
|
|
public function get_admin_details_link() { |
704
|
|
|
EE_Registry::instance()->load_helper( 'URL' ); |
705
|
|
|
EE_Registry::instance()->load_helper( 'MSG_Template' ); |
706
|
|
|
switch ( $this->STS_ID() ) { |
707
|
|
|
case EEM_Message::status_failed : |
708
|
|
|
return EEH_MSG_Template::generate_error_display_trigger( $this ); |
709
|
|
|
break; |
|
|
|
|
710
|
|
|
|
711
|
|
|
case EEM_Message::status_sent : |
712
|
|
|
return EEH_MSG_Template::generate_browser_trigger( $this ); |
713
|
|
|
break; |
|
|
|
|
714
|
|
|
|
715
|
|
|
default : |
716
|
|
|
return ''; |
717
|
|
|
} |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
/** |
721
|
|
|
* Returns the link to the editor for the object. Sometimes this is the same as the details. |
722
|
|
|
* @return string |
723
|
|
|
*/ |
724
|
|
|
public function get_admin_edit_link() { |
725
|
|
|
return $this->get_admin_details_link(); |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
/** |
729
|
|
|
* Returns the link to a settings page for the object. |
730
|
|
|
* @return string |
731
|
|
|
*/ |
732
|
|
View Code Duplication |
public function get_admin_settings_link() { |
|
|
|
|
733
|
|
|
EE_Registry::instance()->load_helper( 'URL' ); |
734
|
|
|
return EEH_URL::add_query_args_and_nonce( |
735
|
|
|
array( |
736
|
|
|
'page' => 'espresso_messages', |
737
|
|
|
'action' => 'settings', |
738
|
|
|
), |
739
|
|
|
admin_url( 'admin.php' ) |
740
|
|
|
); |
741
|
|
|
} |
742
|
|
|
|
743
|
|
|
/** |
744
|
|
|
* Returns the link to the "overview" for the object (typically the "list table" view). |
745
|
|
|
* @return string |
746
|
|
|
*/ |
747
|
|
View Code Duplication |
public function get_admin_overview_link() { |
|
|
|
|
748
|
|
|
EE_Registry::instance()->load_helper( 'URL' ); |
749
|
|
|
return EEH_URL::add_query_args_and_nonce( |
750
|
|
|
array( |
751
|
|
|
'page' => 'espresso_messages', |
752
|
|
|
'action' => 'default', |
753
|
|
|
), |
754
|
|
|
admin_url( 'admin.php' ) |
755
|
|
|
); |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
|
759
|
|
|
} |
760
|
|
|
/* End of file EE_Message.class.php */ |
761
|
|
|
/* Location: /core/db_classes/EE_Message.class.php */ |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.