Completed
Branch fix/escaping-2 (5dcb9a)
by
unknown
13:02 queued 10:26
created
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             $JSON_response['success'] = $this->success();
123 123
         }
124 124
         // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
-        if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
125
+        if ( ! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126 126
             $JSON_response['success'] = null;
127 127
         }
128 128
         // set redirect_url, IF it exists
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         // and finally, add return_data array to main JSON response array, IF it contains anything
163 163
         // why did we add some of the above properties to the return data array?
164 164
         // because it is easier and cleaner in the Javascript to deal with this way
165
-        if (! empty($return_data)) {
165
+        if ( ! empty($return_data)) {
166 166
             $JSON_response['return_data'] = $return_data;
167 167
         }
168 168
         // filter final array
Please login to merge, or discard this patch.
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -15,403 +15,403 @@
 block discarded – undo
15 15
 class EE_SPCO_JSON_Response
16 16
 {
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    protected $_errors = '';
22
-
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $_unexpected_errors = '';
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $_attention = '';
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $_success = '';
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $_plz_select_method_of_payment = '';
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    protected $_redirect_url = '';
47
-
48
-    /**
49
-     * @var string
50
-     */
51
-    protected $_registration_time_limit = '';
52
-
53
-    /**
54
-     * @var string
55
-     */
56
-    protected $_redirect_form = '';
57
-
58
-    /**
59
-     * @var string
60
-     */
61
-    protected $_reg_step_html = '';
62
-
63
-    /**
64
-     * @var string
65
-     */
66
-    protected $_method_of_payment = '';
67
-
68
-    /**
69
-     * @var float
70
-     */
71
-    protected $_payment_amount;
72
-
73
-    /**
74
-     * @var array
75
-     */
76
-    protected $_return_data = array();
77
-
78
-
79
-    /**
80
-     * @var array
81
-     */
82
-    protected $_validation_rules = array();
83
-
84
-
85
-    /**
86
-     *    class constructor
87
-     */
88
-    public function __construct()
89
-    {
90
-    }
91
-
92
-
93
-    /**
94
-     *    __toString
95
-     *
96
-     *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
97
-     *        ie: $json_response = new EE_SPCO_JSON_Response();
98
-     *        echo $json_response;
99
-     *
100
-     * @access    public
101
-     * @return    string
102
-     */
103
-    public function __toString()
104
-    {
105
-        $JSON_response = array();
106
-        // grab notices
107
-        $notices = EE_Error::get_notices(false);
108
-        $this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
109
-        $this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
110
-        $this->set_success(isset($notices['success']) ? $notices['success'] : '');
111
-        // add notices to JSON response, but only if they exist
112
-        if ($this->attention()) {
113
-            $JSON_response['attention'] = $this->attention();
114
-        }
115
-        if ($this->errors()) {
116
-            $JSON_response['errors'] = $this->errors();
117
-        }
118
-        if ($this->unexpected_errors()) {
119
-            $JSON_response['unexpected_errors'] = $this->unexpected_errors();
120
-        }
121
-        if ($this->success()) {
122
-            $JSON_response['success'] = $this->success();
123
-        }
124
-        // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
-        if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126
-            $JSON_response['success'] = null;
127
-        }
128
-        // set redirect_url, IF it exists
129
-        if ($this->redirect_url()) {
130
-            $JSON_response['redirect_url'] = $this->redirect_url();
131
-        }
132
-        // set registration_time_limit, IF it exists
133
-        if ($this->registration_time_limit()) {
134
-            $JSON_response['registration_time_limit'] = $this->registration_time_limit();
135
-        }
136
-        // set payment_amount, IF it exists
137
-        if ($this->payment_amount() !== null) {
138
-            $JSON_response['payment_amount'] = $this->payment_amount();
139
-        }
140
-        // grab generic return data
141
-        $return_data = $this->return_data();
142
-        // add billing form validation rules
143
-        if ($this->validation_rules()) {
144
-            $return_data['validation_rules'] = $this->validation_rules();
145
-        }
146
-        // set reg_step_html, IF it exists
147
-        if ($this->reg_step_html()) {
148
-            $return_data['reg_step_html'] = $this->reg_step_html();
149
-        }
150
-        // set method of payment, IF it exists
151
-        if ($this->method_of_payment()) {
152
-            $return_data['method_of_payment'] = $this->method_of_payment();
153
-        }
154
-        // set "plz_select_method_of_payment" message, IF it exists
155
-        if ($this->plz_select_method_of_payment()) {
156
-            $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
157
-        }
158
-        // set redirect_form, IF it exists
159
-        if ($this->redirect_form()) {
160
-            $return_data['redirect_form'] = $this->redirect_form();
161
-        }
162
-        // and finally, add return_data array to main JSON response array, IF it contains anything
163
-        // why did we add some of the above properties to the return data array?
164
-        // because it is easier and cleaner in the Javascript to deal with this way
165
-        if (! empty($return_data)) {
166
-            $JSON_response['return_data'] = $return_data;
167
-        }
168
-        // filter final array
169
-        $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
170
-        // return encoded array
171
-        return (string) wp_json_encode($JSON_response);
172
-    }
173
-
174
-
175
-    /**
176
-     * @param string $attention
177
-     */
178
-    public function set_attention($attention)
179
-    {
180
-        $this->_attention = $attention;
181
-    }
182
-
183
-
184
-    /**
185
-     * @return string
186
-     */
187
-    public function attention()
188
-    {
189
-        return $this->_attention;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param string $errors
195
-     */
196
-    public function set_errors($errors)
197
-    {
198
-        $this->_errors = $errors;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function errors()
206
-    {
207
-        return $this->_errors;
208
-    }
209
-
210
-
211
-    /**
212
-     * @return string
213
-     */
214
-    public function unexpected_errors()
215
-    {
216
-        return $this->_unexpected_errors;
217
-    }
218
-
219
-
220
-    /**
221
-     * @param string $unexpected_errors
222
-     */
223
-    public function set_unexpected_errors($unexpected_errors)
224
-    {
225
-        $this->_unexpected_errors = $unexpected_errors;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param string $success
231
-     */
232
-    public function set_success($success)
233
-    {
234
-        $this->_success = $success;
235
-    }
236
-
237
-
238
-    /**
239
-     * @return string
240
-     */
241
-    public function success()
242
-    {
243
-        return $this->_success;
244
-    }
245
-
246
-
247
-    /**
248
-     * @param string $method_of_payment
249
-     */
250
-    public function set_method_of_payment($method_of_payment)
251
-    {
252
-        $this->_method_of_payment = $method_of_payment;
253
-    }
254
-
255
-
256
-    /**
257
-     * @return string
258
-     */
259
-    public function method_of_payment()
260
-    {
261
-        return $this->_method_of_payment;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return float
267
-     */
268
-    public function payment_amount()
269
-    {
270
-        return $this->_payment_amount;
271
-    }
272
-
273
-
274
-    /**
275
-     * @param float $payment_amount
276
-     * @throws EE_Error
277
-     */
278
-    public function set_payment_amount($payment_amount)
279
-    {
280
-        $this->_payment_amount = (float) $payment_amount;
281
-    }
282
-
283
-
284
-    /**
285
-     * @param string $next_step_html
286
-     */
287
-    public function set_reg_step_html($next_step_html)
288
-    {
289
-        $this->_reg_step_html = $next_step_html;
290
-    }
291
-
292
-
293
-    /**
294
-     * @return string
295
-     */
296
-    public function reg_step_html()
297
-    {
298
-        return $this->_reg_step_html;
299
-    }
300
-
301
-
302
-    /**
303
-     * @param string $redirect_form
304
-     */
305
-    public function set_redirect_form($redirect_form)
306
-    {
307
-        $this->_redirect_form = $redirect_form;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return string
313
-     */
314
-    public function redirect_form()
315
-    {
316
-        return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
317
-    }
318
-
319
-
320
-    /**
321
-     * @param string $plz_select_method_of_payment
322
-     */
323
-    public function set_plz_select_method_of_payment($plz_select_method_of_payment)
324
-    {
325
-        $this->_plz_select_method_of_payment = $plz_select_method_of_payment;
326
-    }
327
-
328
-
329
-    /**
330
-     * @return string
331
-     */
332
-    public function plz_select_method_of_payment()
333
-    {
334
-        return $this->_plz_select_method_of_payment;
335
-    }
336
-
337
-
338
-    /**
339
-     * @param string $redirect_url
340
-     */
341
-    public function set_redirect_url($redirect_url)
342
-    {
343
-        $this->_redirect_url = $redirect_url;
344
-    }
345
-
346
-
347
-    /**
348
-     * @return string
349
-     */
350
-    public function redirect_url()
351
-    {
352
-        return $this->_redirect_url;
353
-    }
354
-
355
-
356
-    /**
357
-     * @return string
358
-     */
359
-    public function registration_time_limit()
360
-    {
361
-        return $this->_registration_time_limit;
362
-    }
363
-
364
-
365
-    /**
366
-     * @param string $registration_time_limit
367
-     */
368
-    public function set_registration_time_limit($registration_time_limit)
369
-    {
370
-        $this->_registration_time_limit = $registration_time_limit;
371
-    }
372
-
373
-
374
-    /**
375
-     * @param array $return_data
376
-     */
377
-    public function set_return_data($return_data)
378
-    {
379
-        $this->_return_data = array_merge($this->_return_data, $return_data);
380
-    }
381
-
382
-
383
-    /**
384
-     * @return array
385
-     */
386
-    public function return_data()
387
-    {
388
-        return $this->_return_data;
389
-    }
390
-
391
-
392
-    /**
393
-     * @param array $validation_rules
394
-     */
395
-    public function add_validation_rules(array $validation_rules = array())
396
-    {
397
-        if (is_array($validation_rules) && ! empty($validation_rules)) {
398
-            $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
399
-        }
400
-    }
401
-
402
-
403
-    /**
404
-     * @return array | bool
405
-     */
406
-    public function validation_rules()
407
-    {
408
-        return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
409
-    }
410
-
411
-
412
-    public function echoAndExit()
413
-    {
414
-        echo $this; // already escaped
415
-        exit();
416
-    }
18
+	/**
19
+	 * @var string
20
+	 */
21
+	protected $_errors = '';
22
+
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $_unexpected_errors = '';
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $_attention = '';
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $_success = '';
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $_plz_select_method_of_payment = '';
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	protected $_redirect_url = '';
47
+
48
+	/**
49
+	 * @var string
50
+	 */
51
+	protected $_registration_time_limit = '';
52
+
53
+	/**
54
+	 * @var string
55
+	 */
56
+	protected $_redirect_form = '';
57
+
58
+	/**
59
+	 * @var string
60
+	 */
61
+	protected $_reg_step_html = '';
62
+
63
+	/**
64
+	 * @var string
65
+	 */
66
+	protected $_method_of_payment = '';
67
+
68
+	/**
69
+	 * @var float
70
+	 */
71
+	protected $_payment_amount;
72
+
73
+	/**
74
+	 * @var array
75
+	 */
76
+	protected $_return_data = array();
77
+
78
+
79
+	/**
80
+	 * @var array
81
+	 */
82
+	protected $_validation_rules = array();
83
+
84
+
85
+	/**
86
+	 *    class constructor
87
+	 */
88
+	public function __construct()
89
+	{
90
+	}
91
+
92
+
93
+	/**
94
+	 *    __toString
95
+	 *
96
+	 *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
97
+	 *        ie: $json_response = new EE_SPCO_JSON_Response();
98
+	 *        echo $json_response;
99
+	 *
100
+	 * @access    public
101
+	 * @return    string
102
+	 */
103
+	public function __toString()
104
+	{
105
+		$JSON_response = array();
106
+		// grab notices
107
+		$notices = EE_Error::get_notices(false);
108
+		$this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
109
+		$this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
110
+		$this->set_success(isset($notices['success']) ? $notices['success'] : '');
111
+		// add notices to JSON response, but only if they exist
112
+		if ($this->attention()) {
113
+			$JSON_response['attention'] = $this->attention();
114
+		}
115
+		if ($this->errors()) {
116
+			$JSON_response['errors'] = $this->errors();
117
+		}
118
+		if ($this->unexpected_errors()) {
119
+			$JSON_response['unexpected_errors'] = $this->unexpected_errors();
120
+		}
121
+		if ($this->success()) {
122
+			$JSON_response['success'] = $this->success();
123
+		}
124
+		// but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
+		if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126
+			$JSON_response['success'] = null;
127
+		}
128
+		// set redirect_url, IF it exists
129
+		if ($this->redirect_url()) {
130
+			$JSON_response['redirect_url'] = $this->redirect_url();
131
+		}
132
+		// set registration_time_limit, IF it exists
133
+		if ($this->registration_time_limit()) {
134
+			$JSON_response['registration_time_limit'] = $this->registration_time_limit();
135
+		}
136
+		// set payment_amount, IF it exists
137
+		if ($this->payment_amount() !== null) {
138
+			$JSON_response['payment_amount'] = $this->payment_amount();
139
+		}
140
+		// grab generic return data
141
+		$return_data = $this->return_data();
142
+		// add billing form validation rules
143
+		if ($this->validation_rules()) {
144
+			$return_data['validation_rules'] = $this->validation_rules();
145
+		}
146
+		// set reg_step_html, IF it exists
147
+		if ($this->reg_step_html()) {
148
+			$return_data['reg_step_html'] = $this->reg_step_html();
149
+		}
150
+		// set method of payment, IF it exists
151
+		if ($this->method_of_payment()) {
152
+			$return_data['method_of_payment'] = $this->method_of_payment();
153
+		}
154
+		// set "plz_select_method_of_payment" message, IF it exists
155
+		if ($this->plz_select_method_of_payment()) {
156
+			$return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
157
+		}
158
+		// set redirect_form, IF it exists
159
+		if ($this->redirect_form()) {
160
+			$return_data['redirect_form'] = $this->redirect_form();
161
+		}
162
+		// and finally, add return_data array to main JSON response array, IF it contains anything
163
+		// why did we add some of the above properties to the return data array?
164
+		// because it is easier and cleaner in the Javascript to deal with this way
165
+		if (! empty($return_data)) {
166
+			$JSON_response['return_data'] = $return_data;
167
+		}
168
+		// filter final array
169
+		$JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
170
+		// return encoded array
171
+		return (string) wp_json_encode($JSON_response);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param string $attention
177
+	 */
178
+	public function set_attention($attention)
179
+	{
180
+		$this->_attention = $attention;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @return string
186
+	 */
187
+	public function attention()
188
+	{
189
+		return $this->_attention;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param string $errors
195
+	 */
196
+	public function set_errors($errors)
197
+	{
198
+		$this->_errors = $errors;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function errors()
206
+	{
207
+		return $this->_errors;
208
+	}
209
+
210
+
211
+	/**
212
+	 * @return string
213
+	 */
214
+	public function unexpected_errors()
215
+	{
216
+		return $this->_unexpected_errors;
217
+	}
218
+
219
+
220
+	/**
221
+	 * @param string $unexpected_errors
222
+	 */
223
+	public function set_unexpected_errors($unexpected_errors)
224
+	{
225
+		$this->_unexpected_errors = $unexpected_errors;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param string $success
231
+	 */
232
+	public function set_success($success)
233
+	{
234
+		$this->_success = $success;
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return string
240
+	 */
241
+	public function success()
242
+	{
243
+		return $this->_success;
244
+	}
245
+
246
+
247
+	/**
248
+	 * @param string $method_of_payment
249
+	 */
250
+	public function set_method_of_payment($method_of_payment)
251
+	{
252
+		$this->_method_of_payment = $method_of_payment;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @return string
258
+	 */
259
+	public function method_of_payment()
260
+	{
261
+		return $this->_method_of_payment;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return float
267
+	 */
268
+	public function payment_amount()
269
+	{
270
+		return $this->_payment_amount;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @param float $payment_amount
276
+	 * @throws EE_Error
277
+	 */
278
+	public function set_payment_amount($payment_amount)
279
+	{
280
+		$this->_payment_amount = (float) $payment_amount;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param string $next_step_html
286
+	 */
287
+	public function set_reg_step_html($next_step_html)
288
+	{
289
+		$this->_reg_step_html = $next_step_html;
290
+	}
291
+
292
+
293
+	/**
294
+	 * @return string
295
+	 */
296
+	public function reg_step_html()
297
+	{
298
+		return $this->_reg_step_html;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @param string $redirect_form
304
+	 */
305
+	public function set_redirect_form($redirect_form)
306
+	{
307
+		$this->_redirect_form = $redirect_form;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return string
313
+	 */
314
+	public function redirect_form()
315
+	{
316
+		return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @param string $plz_select_method_of_payment
322
+	 */
323
+	public function set_plz_select_method_of_payment($plz_select_method_of_payment)
324
+	{
325
+		$this->_plz_select_method_of_payment = $plz_select_method_of_payment;
326
+	}
327
+
328
+
329
+	/**
330
+	 * @return string
331
+	 */
332
+	public function plz_select_method_of_payment()
333
+	{
334
+		return $this->_plz_select_method_of_payment;
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param string $redirect_url
340
+	 */
341
+	public function set_redirect_url($redirect_url)
342
+	{
343
+		$this->_redirect_url = $redirect_url;
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return string
349
+	 */
350
+	public function redirect_url()
351
+	{
352
+		return $this->_redirect_url;
353
+	}
354
+
355
+
356
+	/**
357
+	 * @return string
358
+	 */
359
+	public function registration_time_limit()
360
+	{
361
+		return $this->_registration_time_limit;
362
+	}
363
+
364
+
365
+	/**
366
+	 * @param string $registration_time_limit
367
+	 */
368
+	public function set_registration_time_limit($registration_time_limit)
369
+	{
370
+		$this->_registration_time_limit = $registration_time_limit;
371
+	}
372
+
373
+
374
+	/**
375
+	 * @param array $return_data
376
+	 */
377
+	public function set_return_data($return_data)
378
+	{
379
+		$this->_return_data = array_merge($this->_return_data, $return_data);
380
+	}
381
+
382
+
383
+	/**
384
+	 * @return array
385
+	 */
386
+	public function return_data()
387
+	{
388
+		return $this->_return_data;
389
+	}
390
+
391
+
392
+	/**
393
+	 * @param array $validation_rules
394
+	 */
395
+	public function add_validation_rules(array $validation_rules = array())
396
+	{
397
+		if (is_array($validation_rules) && ! empty($validation_rules)) {
398
+			$this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
399
+		}
400
+	}
401
+
402
+
403
+	/**
404
+	 * @return array | bool
405
+	 */
406
+	public function validation_rules()
407
+	{
408
+		return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
409
+	}
410
+
411
+
412
+	public function echoAndExit()
413
+	{
414
+		echo $this; // already escaped
415
+		exit();
416
+	}
417 417
 }
Please login to merge, or discard this patch.
admin_pages/messages/espresso_events_Messages_Hooks.class.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    public function __construct(EE_Admin_Page $admin_page)
20
-    {
21
-        parent::__construct($admin_page);
22
-    }
19
+	public function __construct(EE_Admin_Page $admin_page)
20
+	{
21
+		parent::__construct($admin_page);
22
+	}
23 23
 
24 24
 
25
-    protected function _set_hooks_properties()
26
-    {
27
-        $this->_name = 'messages';
28
-    }
25
+	protected function _set_hooks_properties()
26
+	{
27
+		$this->_name = 'messages';
28
+	}
29 29
 }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_List_Table.class.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
 class Extend_Events_Admin_List_Table extends Events_Admin_List_Table
13 13
 {
14 14
 
15
-    protected function _column_name_action_setup(EE_Event $item)
16
-    {
17
-        $export_query_args = array(
18
-            'action' => 'export_events',
19
-            'EVT_ID' => $item->ID(),
20
-        );
21
-        $export_event_link = EE_Admin_Page::add_query_args_and_nonce($export_query_args, EVENTS_ADMIN_URL);
15
+	protected function _column_name_action_setup(EE_Event $item)
16
+	{
17
+		$export_query_args = array(
18
+			'action' => 'export_events',
19
+			'EVT_ID' => $item->ID(),
20
+		);
21
+		$export_event_link = EE_Admin_Page::add_query_args_and_nonce($export_query_args, EVENTS_ADMIN_URL);
22 22
 
23
-        $actions = parent::_column_name_action_setup($item);
24
-        return $actions;
25
-    }
23
+		$actions = parent::_column_name_action_setup($item);
24
+		return $actions;
25
+	}
26 26
 }
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_EE_Registrations_List_Table.class.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
             'ee_read_checkins',
40 40
             'espresso_registrations_registration_checkins'
41 41
         )
42
-            ? '<a href="' . $check_in_url . '"'
43
-              . ' title="' . esc_attr__(
42
+            ? '<a href="'.$check_in_url.'"'
43
+              . ' title="'.esc_attr__(
44 44
                   'The Check-In List allows you to easily toggle check-in status for this event',
45 45
                   'event_espresso'
46 46
               )
47
-              . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>'
47
+              . '">'.esc_html__('View Check-ins', 'event_espresso').'</a>'
48 48
             : esc_html__('View Check-ins', 'event_espresso');
49 49
 
50 50
         return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions));
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
             // add a "View Registrations" link that filters list by event AND datetime
106 106
             $datetime_string .= $this->row_actions(
107 107
                 array(
108
-                    'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
108
+                    'event_datetime_filter' => '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
109 109
                         array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
110 110
                         REG_ADMIN_URL
111 111
                     )
112
-                                               . '" title="' . sprintf(
112
+                                               . '" title="'.sprintf(
113 113
                                                    esc_attr__(
114 114
                                                        'Filter this list to only show registrations for this datetime %s',
115 115
                                                        'event_espresso'
116 116
                                                    ),
117 117
                                                    $datetime->name()
118
-                                               ) . '">'
118
+                                               ).'">'
119 119
                                                . esc_html__('View Registrations', 'event_espresso')
120 120
                                                . '</a>',
121 121
                 )
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -13,117 +13,117 @@
 block discarded – undo
13 13
 class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table
14 14
 {
15 15
 
16
-    /**
17
-     * @param EE_Registration $item
18
-     * @return string
19
-     * @throws EE_Error
20
-     * @throws InvalidArgumentException
21
-     * @throws ReflectionException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     */
25
-    public function column__REG_date(EE_Registration $item)
26
-    {
27
-        $date_linked = parent::column__REG_date($item);
28
-        $actions = array();
29
-        // Build row actions
30
-        $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array(
31
-            'action'   => 'event_registrations',
32
-            'event_id' => $item->event_ID(),
33
-        ), REG_ADMIN_URL);
34
-        $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can(
35
-            'ee_read_registration',
36
-            'espresso_registrations_registration_checkins',
37
-            $item->ID()
38
-        ) && EE_Registry::instance()->CAP->current_user_can(
39
-            'ee_read_checkins',
40
-            'espresso_registrations_registration_checkins'
41
-        )
42
-            ? '<a href="' . $check_in_url . '"'
43
-              . ' title="' . esc_attr__(
44
-                  'The Check-In List allows you to easily toggle check-in status for this event',
45
-                  'event_espresso'
46
-              )
47
-              . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>'
48
-            : esc_html__('View Check-ins', 'event_espresso');
16
+	/**
17
+	 * @param EE_Registration $item
18
+	 * @return string
19
+	 * @throws EE_Error
20
+	 * @throws InvalidArgumentException
21
+	 * @throws ReflectionException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 */
25
+	public function column__REG_date(EE_Registration $item)
26
+	{
27
+		$date_linked = parent::column__REG_date($item);
28
+		$actions = array();
29
+		// Build row actions
30
+		$check_in_url = EE_Admin_Page::add_query_args_and_nonce(array(
31
+			'action'   => 'event_registrations',
32
+			'event_id' => $item->event_ID(),
33
+		), REG_ADMIN_URL);
34
+		$actions['check_in'] = EE_Registry::instance()->CAP->current_user_can(
35
+			'ee_read_registration',
36
+			'espresso_registrations_registration_checkins',
37
+			$item->ID()
38
+		) && EE_Registry::instance()->CAP->current_user_can(
39
+			'ee_read_checkins',
40
+			'espresso_registrations_registration_checkins'
41
+		)
42
+			? '<a href="' . $check_in_url . '"'
43
+			  . ' title="' . esc_attr__(
44
+				  'The Check-In List allows you to easily toggle check-in status for this event',
45
+				  'event_espresso'
46
+			  )
47
+			  . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>'
48
+			: esc_html__('View Check-ins', 'event_espresso');
49 49
 
50
-        return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions));
51
-    }
50
+		return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     *        column_default
56
-     *
57
-     * @param \EE_Registration $item
58
-     * @return string
59
-     * @throws EE_Error
60
-     * @throws InvalidArgumentException
61
-     * @throws InvalidDataTypeException
62
-     * @throws InvalidInterfaceException
63
-     * @throws ReflectionException
64
-     */
65
-    public function column_DTT_EVT_start(EE_Registration $item)
66
-    {
67
-        $remove_defaults = array('default_where_conditions' => 'none');
68
-        $ticket = $item->ticket();
69
-        $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array();
70
-        $EVT_ID = $item->event_ID();
71
-        $datetimes_for_display = array();
72
-        foreach ($datetimes as $datetime) {
73
-            $datetime_string = '';
74
-            if (
75
-                EE_Registry::instance()->CAP->current_user_can(
76
-                    'ee_read_checkin',
77
-                    'espresso_registrations_registration_checkins',
78
-                    $item->ID()
79
-                )
80
-            ) {
81
-                // open "a" tag and "href"
82
-                $datetime_string .= '<a href="';
83
-                // checkin URL
84
-                $datetime_string .= EE_Admin_Page::add_query_args_and_nonce(
85
-                    array(
86
-                        'action'   => 'event_registrations',
87
-                        'event_id' => $EVT_ID,
88
-                        'DTT_ID'   => $datetime->ID(),
89
-                    ),
90
-                    REG_ADMIN_URL
91
-                );
92
-                // close "href"
93
-                $datetime_string .= '"';
94
-                // open "title" tag
95
-                $datetime_string .= ' title="';
96
-                // link title text
97
-                $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso');
98
-                // close "title" tag and end of "a" tag opening
99
-                $datetime_string .= '">';
100
-                // link text
101
-                $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
102
-                // close "a" tag
103
-                $datetime_string .= '</a>';
104
-            } else {
105
-                $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
106
-            }
107
-            // add a "View Registrations" link that filters list by event AND datetime
108
-            $datetime_string .= $this->row_actions(
109
-                array(
110
-                    'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
111
-                        array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
112
-                        REG_ADMIN_URL
113
-                    )
114
-                                               . '" title="' . sprintf(
115
-                                                   esc_attr__(
116
-                                                       'Filter this list to only show registrations for this datetime %s',
117
-                                                       'event_espresso'
118
-                                                   ),
119
-                                                   $datetime->name()
120
-                                               ) . '">'
121
-                                               . esc_html__('View Registrations', 'event_espresso')
122
-                                               . '</a>',
123
-                )
124
-            );
125
-            $datetimes_for_display[] = $datetime_string;
126
-        }
127
-        return $this->generateDisplayForDateTimes($datetimes_for_display);
128
-    }
54
+	/**
55
+	 *        column_default
56
+	 *
57
+	 * @param \EE_Registration $item
58
+	 * @return string
59
+	 * @throws EE_Error
60
+	 * @throws InvalidArgumentException
61
+	 * @throws InvalidDataTypeException
62
+	 * @throws InvalidInterfaceException
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function column_DTT_EVT_start(EE_Registration $item)
66
+	{
67
+		$remove_defaults = array('default_where_conditions' => 'none');
68
+		$ticket = $item->ticket();
69
+		$datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array();
70
+		$EVT_ID = $item->event_ID();
71
+		$datetimes_for_display = array();
72
+		foreach ($datetimes as $datetime) {
73
+			$datetime_string = '';
74
+			if (
75
+				EE_Registry::instance()->CAP->current_user_can(
76
+					'ee_read_checkin',
77
+					'espresso_registrations_registration_checkins',
78
+					$item->ID()
79
+				)
80
+			) {
81
+				// open "a" tag and "href"
82
+				$datetime_string .= '<a href="';
83
+				// checkin URL
84
+				$datetime_string .= EE_Admin_Page::add_query_args_and_nonce(
85
+					array(
86
+						'action'   => 'event_registrations',
87
+						'event_id' => $EVT_ID,
88
+						'DTT_ID'   => $datetime->ID(),
89
+					),
90
+					REG_ADMIN_URL
91
+				);
92
+				// close "href"
93
+				$datetime_string .= '"';
94
+				// open "title" tag
95
+				$datetime_string .= ' title="';
96
+				// link title text
97
+				$datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso');
98
+				// close "title" tag and end of "a" tag opening
99
+				$datetime_string .= '">';
100
+				// link text
101
+				$datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
102
+				// close "a" tag
103
+				$datetime_string .= '</a>';
104
+			} else {
105
+				$datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start');
106
+			}
107
+			// add a "View Registrations" link that filters list by event AND datetime
108
+			$datetime_string .= $this->row_actions(
109
+				array(
110
+					'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
111
+						array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()),
112
+						REG_ADMIN_URL
113
+					)
114
+											   . '" title="' . sprintf(
115
+												   esc_attr__(
116
+													   'Filter this list to only show registrations for this datetime %s',
117
+													   'event_espresso'
118
+												   ),
119
+												   $datetime->name()
120
+											   ) . '">'
121
+											   . esc_html__('View Registrations', 'event_espresso')
122
+											   . '</a>',
123
+				)
124
+			);
125
+			$datetimes_for_display[] = $datetime_string;
126
+		}
127
+		return $this->generateDisplayForDateTimes($datetimes_for_display);
128
+	}
129 129
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Taxes.class.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -10,138 +10,138 @@
 block discarded – undo
10 10
 class EE_Taxes extends EE_Base
11 11
 {
12 12
 
13
-    /**
14
-     * This is used for when EE_Taxes is used statically by the admin
15
-     *
16
-     * @var array
17
-     */
18
-    private static $_subtotal = array();
13
+	/**
14
+	 * This is used for when EE_Taxes is used statically by the admin
15
+	 *
16
+	 * @var array
17
+	 */
18
+	private static $_subtotal = array();
19 19
 
20
-    /**
21
-     * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types)
22
-     *
23
-     * @var EE_Price[]
24
-     */
25
-    private static $_default_taxes = array();
20
+	/**
21
+	 * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types)
22
+	 *
23
+	 * @var EE_Price[]
24
+	 */
25
+	private static $_default_taxes = array();
26 26
 
27 27
 
28
-    /**
29
-     * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket
30
-     * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick
31
-     * calc of taxes for tickets listed in the event editor.
32
-     *
33
-     * @param  EE_Ticket $ticket incoming EE_Ticket
34
-     * @return float             total taxes to apply to ticket.
35
-     * @throws \EE_Error
36
-     */
37
-    public static function get_total_taxes_for_admin(EE_Ticket $ticket)
38
-    {
39
-        $tax = 0;
40
-        $total_tax = 0;
41
-        // This first checks to see if the given ticket is taxable.
42
-        if (! $ticket->get('TKT_taxable')) {
43
-            return $tax;
44
-        }
45
-        // get subtotal (notice we're only retrieving a subtotal if there isn't one given)
46
-        $subtotal = self::get_subtotal_for_admin($ticket);
47
-        // get taxes
48
-        $taxes = self::get_taxes_for_admin();
49
-        // apply taxes to subtotal
50
-        foreach ($taxes as $tax) {
51
-            // assuming taxes are not cumulative
52
-            $total_tax += $subtotal * $tax->get('PRC_amount') / 100;
53
-        }
54
-        return $total_tax;
55
-    }
28
+	/**
29
+	 * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket
30
+	 * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick
31
+	 * calc of taxes for tickets listed in the event editor.
32
+	 *
33
+	 * @param  EE_Ticket $ticket incoming EE_Ticket
34
+	 * @return float             total taxes to apply to ticket.
35
+	 * @throws \EE_Error
36
+	 */
37
+	public static function get_total_taxes_for_admin(EE_Ticket $ticket)
38
+	{
39
+		$tax = 0;
40
+		$total_tax = 0;
41
+		// This first checks to see if the given ticket is taxable.
42
+		if (! $ticket->get('TKT_taxable')) {
43
+			return $tax;
44
+		}
45
+		// get subtotal (notice we're only retrieving a subtotal if there isn't one given)
46
+		$subtotal = self::get_subtotal_for_admin($ticket);
47
+		// get taxes
48
+		$taxes = self::get_taxes_for_admin();
49
+		// apply taxes to subtotal
50
+		foreach ($taxes as $tax) {
51
+			// assuming taxes are not cumulative
52
+			$total_tax += $subtotal * $tax->get('PRC_amount') / 100;
53
+		}
54
+		return $total_tax;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Gets the total percentage of tax that should be applied to taxable line items
60
-     *
61
-     * @return float the percentage of tax that should be added to taxable items
62
-     * @throws \EE_Error
63
-     * eg 20 for %20 tax (NOT 0.20, which
64
-     */
65
-    public static function get_total_taxes_percentage()
66
-    {
67
-        $total_tax_percent = 0;
68
-        foreach (self::get_taxes_for_admin() as $tax_price) {
69
-            $total_tax_percent += $tax_price->get('PRC_amount');
70
-        }
71
-        return $total_tax_percent;
72
-    }
58
+	/**
59
+	 * Gets the total percentage of tax that should be applied to taxable line items
60
+	 *
61
+	 * @return float the percentage of tax that should be added to taxable items
62
+	 * @throws \EE_Error
63
+	 * eg 20 for %20 tax (NOT 0.20, which
64
+	 */
65
+	public static function get_total_taxes_percentage()
66
+	{
67
+		$total_tax_percent = 0;
68
+		foreach (self::get_taxes_for_admin() as $tax_price) {
69
+			$total_tax_percent += $tax_price->get('PRC_amount');
70
+		}
71
+		return $total_tax_percent;
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @param EE_Ticket $ticket
77
-     * @return float
78
-     * @throws \EE_Error
79
-     */
80
-    public static function get_subtotal_for_admin(EE_Ticket $ticket)
81
-    {
82
-        $TKT_ID = $ticket->ID();
83
-        return isset(self::$_subtotal[ $TKT_ID ])
84
-            ? self::$_subtotal[ $TKT_ID ]
85
-            : self::_get_subtotal_for_admin($ticket);
86
-    }
75
+	/**
76
+	 * @param EE_Ticket $ticket
77
+	 * @return float
78
+	 * @throws \EE_Error
79
+	 */
80
+	public static function get_subtotal_for_admin(EE_Ticket $ticket)
81
+	{
82
+		$TKT_ID = $ticket->ID();
83
+		return isset(self::$_subtotal[ $TKT_ID ])
84
+			? self::$_subtotal[ $TKT_ID ]
85
+			: self::_get_subtotal_for_admin($ticket);
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * simply take an incoming ticket and calculate the subtotal for the ticket
91
-     *
92
-     * @param  EE_Ticket $ticket
93
-     * @return float     subtotal calculated from all EE_Price[] on Ticket.
94
-     * @throws \EE_Error
95
-     */
96
-    private static function _get_subtotal_for_admin(EE_Ticket $ticket)
97
-    {
98
-        $subtotal = 0;
99
-        // get all prices
100
-        $prices = $ticket->get_many_related(
101
-            'Price',
102
-            array(
103
-                'default_where_conditions' => 'none',
104
-                'order_by'                 => array('PRC_order' => 'ASC'),
105
-            )
106
-        );
107
-        // let's loop through them (base price is always the first item)
108
-        foreach ($prices as $price) {
109
-            if ($price instanceof EE_Price) {
110
-                $price_type = $price->type_obj();
111
-                if ($price_type instanceof EE_Price_Type) {
112
-                    switch ($price->type_obj()->base_type()) {
113
-                        case 1: // base price
114
-                        case 3: // surcharges
115
-                            $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
116
-                                : $price->get('PRC_amount');
117
-                            break;
118
-                        case 2: // discounts
119
-                            $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
120
-                                : $price->get('PRC_amount');
121
-                            break;
122
-                    }
123
-                }
124
-            }
125
-        }
126
-        $TKT_ID = $ticket->ID();
127
-        self::$_subtotal = array($TKT_ID => $subtotal);
128
-        return $subtotal;
129
-    }
89
+	/**
90
+	 * simply take an incoming ticket and calculate the subtotal for the ticket
91
+	 *
92
+	 * @param  EE_Ticket $ticket
93
+	 * @return float     subtotal calculated from all EE_Price[] on Ticket.
94
+	 * @throws \EE_Error
95
+	 */
96
+	private static function _get_subtotal_for_admin(EE_Ticket $ticket)
97
+	{
98
+		$subtotal = 0;
99
+		// get all prices
100
+		$prices = $ticket->get_many_related(
101
+			'Price',
102
+			array(
103
+				'default_where_conditions' => 'none',
104
+				'order_by'                 => array('PRC_order' => 'ASC'),
105
+			)
106
+		);
107
+		// let's loop through them (base price is always the first item)
108
+		foreach ($prices as $price) {
109
+			if ($price instanceof EE_Price) {
110
+				$price_type = $price->type_obj();
111
+				if ($price_type instanceof EE_Price_Type) {
112
+					switch ($price->type_obj()->base_type()) {
113
+						case 1: // base price
114
+						case 3: // surcharges
115
+							$subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
116
+								: $price->get('PRC_amount');
117
+							break;
118
+						case 2: // discounts
119
+							$subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
120
+								: $price->get('PRC_amount');
121
+							break;
122
+					}
123
+				}
124
+			}
125
+		}
126
+		$TKT_ID = $ticket->ID();
127
+		self::$_subtotal = array($TKT_ID => $subtotal);
128
+		return $subtotal;
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * get all default prices that are a Tax price type (PRT_ID = 4) and return
134
-     *
135
-     * @return EE_Price[] EE_Price objects that have PRT_ID == 4
136
-     * @throws \EE_Error
137
-     */
138
-    public static function get_taxes_for_admin()
139
-    {
140
-        if (empty(self::$_default_taxes)) {
141
-            self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all(
142
-                array(array('Price_Type.PBT_ID' => 4))
143
-            );
144
-        }
145
-        return self::$_default_taxes;
146
-    }
132
+	/**
133
+	 * get all default prices that are a Tax price type (PRT_ID = 4) and return
134
+	 *
135
+	 * @return EE_Price[] EE_Price objects that have PRT_ID == 4
136
+	 * @throws \EE_Error
137
+	 */
138
+	public static function get_taxes_for_admin()
139
+	{
140
+		if (empty(self::$_default_taxes)) {
141
+			self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all(
142
+				array(array('Price_Type.PBT_ID' => 4))
143
+			);
144
+		}
145
+		return self::$_default_taxes;
146
+	}
147 147
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $tax = 0;
40 40
         $total_tax = 0;
41 41
         // This first checks to see if the given ticket is taxable.
42
-        if (! $ticket->get('TKT_taxable')) {
42
+        if ( ! $ticket->get('TKT_taxable')) {
43 43
             return $tax;
44 44
         }
45 45
         // get subtotal (notice we're only retrieving a subtotal if there isn't one given)
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     public static function get_subtotal_for_admin(EE_Ticket $ticket)
81 81
     {
82 82
         $TKT_ID = $ticket->ID();
83
-        return isset(self::$_subtotal[ $TKT_ID ])
84
-            ? self::$_subtotal[ $TKT_ID ]
83
+        return isset(self::$_subtotal[$TKT_ID])
84
+            ? self::$_subtotal[$TKT_ID]
85 85
             : self::_get_subtotal_for_admin($ticket);
86 86
     }
87 87
 
Please login to merge, or discard this patch.
core/db_classes/EE_Term_Taxonomy.class.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,80 +11,80 @@
 block discarded – undo
11 11
 class EE_Term_Taxonomy extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $props_n_values
16
-     * @return EE_Term_Taxonomy
17
-     */
18
-    public static function new_instance($props_n_values = array())
19
-    {
20
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
-        return $has_object ? $has_object : new self($props_n_values);
22
-    }
14
+	/**
15
+	 * @param array $props_n_values
16
+	 * @return EE_Term_Taxonomy
17
+	 */
18
+	public static function new_instance($props_n_values = array())
19
+	{
20
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
+		return $has_object ? $has_object : new self($props_n_values);
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * @param array $props_n_values
27
-     * @return EE_Term_Taxonomy
28
-     */
29
-    public static function new_instance_from_db($props_n_values = array())
30
-    {
31
-        return new self($props_n_values, true);
32
-    }
25
+	/**
26
+	 * @param array $props_n_values
27
+	 * @return EE_Term_Taxonomy
28
+	 */
29
+	public static function new_instance_from_db($props_n_values = array())
30
+	{
31
+		return new self($props_n_values, true);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Gets taxonomy
37
-     *
38
-     * @return string
39
-     */
40
-    public function taxonomy()
41
-    {
42
-        return $this->get('taxonomy');
43
-    }
35
+	/**
36
+	 * Gets taxonomy
37
+	 *
38
+	 * @return string
39
+	 */
40
+	public function taxonomy()
41
+	{
42
+		return $this->get('taxonomy');
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Sets taxonomy
48
-     *
49
-     * @param string $taxonomy
50
-     * @return boolean
51
-     */
52
-    public function set_taxonomy($taxonomy)
53
-    {
54
-        $this->set('taxonomy', $taxonomy);
55
-    }
46
+	/**
47
+	 * Sets taxonomy
48
+	 *
49
+	 * @param string $taxonomy
50
+	 * @return boolean
51
+	 */
52
+	public function set_taxonomy($taxonomy)
53
+	{
54
+		$this->set('taxonomy', $taxonomy);
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Gets term_count
60
-     *
61
-     * @return int
62
-     */
63
-    public function count()
64
-    {
65
-        return $this->get('term_count');
66
-    }
58
+	/**
59
+	 * Gets term_count
60
+	 *
61
+	 * @return int
62
+	 */
63
+	public function count()
64
+	{
65
+		return $this->get('term_count');
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Sets term_count
71
-     *
72
-     * @param int $term_count
73
-     * @return boolean
74
-     */
75
-    public function set_count($term_count)
76
-    {
77
-        $this->set('term_count', $term_count);
78
-    }
69
+	/**
70
+	 * Sets term_count
71
+	 *
72
+	 * @param int $term_count
73
+	 * @return boolean
74
+	 */
75
+	public function set_count($term_count)
76
+	{
77
+		$this->set('term_count', $term_count);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Gets the term for this term taxonomy
83
-     *
84
-     * @return EE_Term
85
-     */
86
-    public function term()
87
-    {
88
-        return $this->get_first_related('Term');
89
-    }
81
+	/**
82
+	 * Gets the term for this term taxonomy
83
+	 *
84
+	 * @return EE_Term
85
+	 */
86
+	public function term()
87
+	{
88
+		return $this->get_first_related('Term');
89
+	}
90 90
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template_Group.class.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function set_message_type($message_type = false)
50 50
     {
51
-        if (! $message_type) {
51
+        if ( ! $message_type) {
52 52
             throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53 53
         }
54 54
         $this->set('MTP_message_type', $message_type);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function set_messenger($messenger = false)
63 63
     {
64
-        if (! $messenger) {
64
+        if ( ! $messenger) {
65 65
             throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66 66
         }
67 67
         $this->set('MTP_messenger', $messenger);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function set_group_template_id($GRP_ID = false)
76 76
     {
77
-        if (! $GRP_ID) {
77
+        if ( ! $GRP_ID) {
78 78
             throw new EE_Error(
79 79
                 esc_html__(
80 80
                     'Missing required value for the message template group id',
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         }
291 291
         // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292 292
         foreach ($mtps as $mtp) {
293
-            $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
293
+            $mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
294 294
         }
295 295
         return $mtps_arr;
296 296
     }
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public function deactivate_context($context)
431 431
     {
432 432
         $this->validate_context($context);
433
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
433
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, false);
434 434
     }
435 435
 
436 436
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     public function activate_context($context)
446 446
     {
447 447
         $this->validate_context($context);
448
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
448
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true);
449 449
     }
450 450
 
451 451
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     {
466 466
         $this->validate_context($context);
467 467
         return filter_var(
468
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
468
+            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true, true),
469 469
             FILTER_VALIDATE_BOOLEAN
470 470
         );
471 471
     }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     public function validate_context($context)
482 482
     {
483 483
         $contexts = $this->contexts_config();
484
-        if (! isset($contexts[ $context ])) {
484
+        if ( ! isset($contexts[$context])) {
485 485
             throw new InvalidIdentifierException(
486 486
                 '',
487 487
                 '',
Please login to merge, or discard this patch.
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -13,487 +13,487 @@
 block discarded – undo
13 13
 class EE_Message_Template_Group extends EE_Soft_Delete_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
18
-     */
19
-    const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
20
-
21
-    /**
22
-     * @param array  $props_n_values
23
-     * @param string $timezone
24
-     * @return EE_Message_Template_Group|mixed
25
-     * @throws EE_Error
26
-     */
27
-    public static function new_instance($props_n_values = array(), $timezone = '')
28
-    {
29
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
30
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
31
-    }
32
-
33
-
34
-    /**
35
-     * @param array  $props_n_values
36
-     * @param string $timezone
37
-     * @return EE_Message_Template_Group
38
-     */
39
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
40
-    {
41
-        return new self($props_n_values, true, $timezone);
42
-    }
43
-
44
-
45
-    /**
46
-     * @param bool $message_type
47
-     * @throws EE_Error
48
-     */
49
-    public function set_message_type($message_type = false)
50
-    {
51
-        if (! $message_type) {
52
-            throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53
-        }
54
-        $this->set('MTP_message_type', $message_type);
55
-    }
56
-
57
-
58
-    /**
59
-     * @param bool $messenger
60
-     * @throws EE_Error
61
-     */
62
-    public function set_messenger($messenger = false)
63
-    {
64
-        if (! $messenger) {
65
-            throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66
-        }
67
-        $this->set('MTP_messenger', $messenger);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param bool $GRP_ID
73
-     * @throws EE_Error
74
-     */
75
-    public function set_group_template_id($GRP_ID = false)
76
-    {
77
-        if (! $GRP_ID) {
78
-            throw new EE_Error(
79
-                esc_html__(
80
-                    'Missing required value for the message template group id',
81
-                    'event_espresso'
82
-                )
83
-            );
84
-        }
85
-        $this->set('GRP_ID', $GRP_ID);
86
-    }
87
-
88
-
89
-    /**
90
-     * get Group ID
91
-     *
92
-     * @access public
93
-     * @return int
94
-     * @throws EE_Error
95
-     */
96
-    public function GRP_ID()
97
-    {
98
-        return $this->get('GRP_ID');
99
-    }
100
-
101
-
102
-    /**
103
-     * get User ID
104
-     *
105
-     * @access public
106
-     * @return int
107
-     * @throws EE_Error
108
-     */
109
-    public function user()
110
-    {
111
-        $user_id = $this->get('MTP_user_id');
112
-        return empty($user_id) ? get_current_user_id() : $user_id;
113
-    }
114
-
115
-
116
-    /**
117
-     * Wrapper for the user function() (preserve backward compat)
118
-     *
119
-     * @since  4.5.0
120
-     * @return int
121
-     * @throws EE_Error
122
-     */
123
-    public function wp_user()
124
-    {
125
-        return $this->user();
126
-    }
127
-
128
-
129
-    /**
130
-     * This simply returns a count of all related events to this message template group
131
-     *
132
-     * @return int
133
-     */
134
-    public function count_events()
135
-    {
136
-        return $this->count_related('Event');
137
-    }
138
-
139
-
140
-    /**
141
-     * returns the name saved in the db for this template
142
-     *
143
-     * @return string
144
-     * @throws EE_Error
145
-     */
146
-    public function name()
147
-    {
148
-        return $this->get('MTP_name');
149
-    }
150
-
151
-
152
-    /**
153
-     * Returns the description saved in the db for this template group
154
-     *
155
-     * @return string
156
-     * @throws EE_Error
157
-     */
158
-    public function description()
159
-    {
160
-        return $this->get('MTP_description');
161
-    }
162
-
163
-
164
-    /**
165
-     * returns all related EE_Message_Template objects
166
-     *
167
-     * @param  array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
168
-     * @return EE_Message_Template[]
169
-     * @throws EE_Error
170
-     */
171
-    public function message_templates($query_params = array())
172
-    {
173
-        return $this->get_many_related('Message_Template', $query_params);
174
-    }
175
-
176
-
177
-    /**
178
-     * get Message Messenger
179
-     *
180
-     * @access public
181
-     * @return string
182
-     * @throws EE_Error
183
-     */
184
-    public function messenger()
185
-    {
186
-        return $this->get('MTP_messenger');
187
-    }
188
-
189
-
190
-    /**
191
-     * get Message Messenger OBJECT
192
-     * If an attempt to get the corresponding messenger object fails, then we set this message
193
-     * template group to inactive, and save to db.  Then return null so client code can handle
194
-     * appropriately.
195
-     *
196
-     * @return EE_messenger
197
-     * @throws EE_Error
198
-     */
199
-    public function messenger_obj()
200
-    {
201
-        $messenger = $this->messenger();
202
-        try {
203
-            $messenger = EEH_MSG_Template::messenger_obj($messenger);
204
-        } catch (EE_Error $e) {
205
-            // if an exception was thrown then let's deactivate this message template group because it means there is no
206
-            // class for this messenger in this group.
207
-            $this->set('MTP_is_active', false);
208
-            $this->save();
209
-            return null;
210
-        }
211
-        return $messenger;
212
-    }
213
-
214
-
215
-    /**
216
-     * get Message Type
217
-     *
218
-     * @access public
219
-     * @return string
220
-     * @throws EE_Error
221
-     */
222
-    public function message_type()
223
-    {
224
-        return $this->get('MTP_message_type');
225
-    }
226
-
227
-
228
-    /**
229
-     * get Message type OBJECT
230
-     * If an attempt to get the corresponding message type object fails, then we set this message
231
-     * template group to inactive, and save to db.  Then return null so client code can handle
232
-     * appropriately.
233
-     *
234
-     * @throws EE_Error
235
-     * @return EE_message_type|false if exception thrown.
236
-     */
237
-    public function message_type_obj()
238
-    {
239
-        $message_type = $this->message_type();
240
-        try {
241
-            $message_type = EEH_MSG_Template::message_type_obj($message_type);
242
-        } catch (EE_Error $e) {
243
-            // if an exception was thrown then let's deactivate this message template group because it means there is no
244
-            // class for the message type in this group.
245
-            $this->set('MTP_is_active', false);
246
-            $this->save();
247
-            return null;
248
-        }
249
-        return $message_type;
250
-    }
251
-
252
-
253
-    /**
254
-     * @return array
255
-     * @throws EE_Error
256
-     */
257
-    public function contexts_config()
258
-    {
259
-        return $this->message_type_obj()->get_contexts();
260
-    }
261
-
262
-
263
-    /**
264
-     * This returns the context_label for contexts as set in the message type object
265
-     * Note this is an array with singular and plural keys
266
-     *
267
-     * @access public
268
-     * @return array labels for "context"
269
-     * @throws EE_Error
270
-     */
271
-    public function context_label()
272
-    {
273
-        $obj = $this->message_type_obj();
274
-        return $obj->get_context_label();
275
-    }
276
-
277
-
278
-    /**
279
-     * This returns an array of EE_Message_Template objects indexed by context and field.
280
-     *
281
-     * @return array ()
282
-     * @throws EE_Error
283
-     */
284
-    public function context_templates()
285
-    {
286
-        $mtps_arr = array();
287
-        $mtps = $this->get_many_related('Message_Template');
288
-        if (empty($mtps)) {
289
-            return array();
290
-        }
291
-        // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292
-        foreach ($mtps as $mtp) {
293
-            $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
294
-        }
295
-        return $mtps_arr;
296
-    }
297
-
298
-
299
-    /**
300
-     * this returns if the template group this template belongs to is global
301
-     *
302
-     * @return bool true if it is, false if it isn't
303
-     * @throws EE_Error
304
-     */
305
-    public function is_global()
306
-    {
307
-        return $this->get('MTP_is_global');
308
-    }
309
-
310
-
311
-    /**
312
-     * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
313
-     *
314
-     * @return bool true if it is, false if it isn't
315
-     * @throws EE_Error
316
-     */
317
-    public function is_active()
318
-    {
319
-        return $this->get('MTP_is_active');
320
-    }
321
-
322
-
323
-    /**
324
-     * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
325
-     * this template.
326
-     *
327
-     * @since 4.3.0
328
-     * @uses  EEH_MSG_Template::get_shortcodes()
329
-     * @param string $context what context we're going to return shortcodes for
330
-     * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
331
-     *                        to be returned.
332
-     * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
333
-     *                        unique shortcodes for all the given (or all) fields.
334
-     * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
335
-     *                        shortcodes found.
336
-     * @throws EE_Error
337
-     */
338
-    public function get_shortcodes($context, $fields = array(), $merged = false)
339
-    {
340
-        $messenger = $this->messenger();
341
-        $message_type = $this->message_type();
342
-        return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
343
-    }
344
-
345
-
346
-    /**
347
-     * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
348
-     * use the default template pack.
349
-     *
350
-     * @since 4.5.0
351
-     * @return string
352
-     * @throws EE_Error
353
-     */
354
-    public function get_template_pack_name()
355
-    {
356
-        return $this->get_extra_meta('MTP_template_pack', true, 'default');
357
-    }
358
-
359
-
360
-    /**
361
-     * This returns the specific template pack object referenced by the template pack name attached to this message
362
-     * template group.  If no template pack is assigned then the default template pack is retrieved.
363
-     *
364
-     * @since 4.5.0
365
-     * @return EE_Messages_Template_Pack
366
-     * @throws EE_Error
367
-     * @throws InvalidArgumentException
368
-     * @throws ReflectionException
369
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
370
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
371
-     */
372
-    public function get_template_pack()
373
-    {
374
-        $pack_name = $this->get_template_pack_name();
375
-        EE_Registry::instance()->load_helper('MSG_Template');
376
-        return EEH_MSG_Template::get_template_pack($pack_name);
377
-    }
378
-
379
-
380
-    /**
381
-     * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
382
-     * use the default template variation.
383
-     *
384
-     * @since 4.5.0
385
-     * @return string
386
-     * @throws EE_Error
387
-     */
388
-    public function get_template_pack_variation()
389
-    {
390
-        return $this->get_extra_meta('MTP_variation', true, 'default');
391
-    }
392
-
393
-
394
-    /**
395
-     * This just sets the template pack name attached to this message template group.
396
-     *
397
-     * @since 4.5.0
398
-     * @param string $template_pack_name What message template pack is assigned.
399
-     * @return int
400
-     * @throws EE_Error
401
-     */
402
-    public function set_template_pack_name($template_pack_name)
403
-    {
404
-        return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
405
-    }
406
-
407
-
408
-    /**
409
-     * This just sets the template pack variation attached to this message template group.
410
-     *
411
-     * @since 4.5.0
412
-     * @param string $variation What variation is being set on the message template group.
413
-     * @return int
414
-     * @throws EE_Error
415
-     */
416
-    public function set_template_pack_variation($variation)
417
-    {
418
-        return $this->update_extra_meta('MTP_variation', $variation);
419
-    }
420
-
421
-
422
-    /**
423
-     * Deactivates the given context.
424
-     *
425
-     * @param $context
426
-     * @return bool|int
427
-     * @throws EE_Error
428
-     * @throws InvalidIdentifierException
429
-     */
430
-    public function deactivate_context($context)
431
-    {
432
-        $this->validate_context($context);
433
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
434
-    }
435
-
436
-
437
-    /**
438
-     * Activates the given context.
439
-     *
440
-     * @param $context
441
-     * @return bool|int
442
-     * @throws EE_Error
443
-     * @throws InvalidIdentifierException
444
-     */
445
-    public function activate_context($context)
446
-    {
447
-        $this->validate_context($context);
448
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
449
-    }
450
-
451
-
452
-    /**
453
-     * Returns whether the context is active or not.
454
-     * Note, this will default to true if the extra meta record doesn't exist.
455
-     * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
456
-     * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
457
-     * whether a context is "active" or not.
458
-     *
459
-     * @param $context
460
-     * @return bool
461
-     * @throws EE_Error
462
-     * @throws InvalidIdentifierException
463
-     */
464
-    public function is_context_active($context)
465
-    {
466
-        $this->validate_context($context);
467
-        return filter_var(
468
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
469
-            FILTER_VALIDATE_BOOLEAN
470
-        );
471
-    }
472
-
473
-
474
-    /**
475
-     * Validates the incoming context to verify it matches a registered context for the related message type.
476
-     *
477
-     * @param string $context
478
-     * @throws EE_Error
479
-     * @throws InvalidIdentifierException
480
-     */
481
-    public function validate_context($context)
482
-    {
483
-        $contexts = $this->contexts_config();
484
-        if (! isset($contexts[ $context ])) {
485
-            throw new InvalidIdentifierException(
486
-                '',
487
-                '',
488
-                sprintf(
489
-                    esc_html__(
490
-                        'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
491
-                        'event_espresso'
492
-                    ),
493
-                    $context,
494
-                    implode(',', array_keys($contexts))
495
-                )
496
-            );
497
-        }
498
-    }
16
+	/**
17
+	 * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
18
+	 */
19
+	const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
20
+
21
+	/**
22
+	 * @param array  $props_n_values
23
+	 * @param string $timezone
24
+	 * @return EE_Message_Template_Group|mixed
25
+	 * @throws EE_Error
26
+	 */
27
+	public static function new_instance($props_n_values = array(), $timezone = '')
28
+	{
29
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
30
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
31
+	}
32
+
33
+
34
+	/**
35
+	 * @param array  $props_n_values
36
+	 * @param string $timezone
37
+	 * @return EE_Message_Template_Group
38
+	 */
39
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
40
+	{
41
+		return new self($props_n_values, true, $timezone);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @param bool $message_type
47
+	 * @throws EE_Error
48
+	 */
49
+	public function set_message_type($message_type = false)
50
+	{
51
+		if (! $message_type) {
52
+			throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53
+		}
54
+		$this->set('MTP_message_type', $message_type);
55
+	}
56
+
57
+
58
+	/**
59
+	 * @param bool $messenger
60
+	 * @throws EE_Error
61
+	 */
62
+	public function set_messenger($messenger = false)
63
+	{
64
+		if (! $messenger) {
65
+			throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66
+		}
67
+		$this->set('MTP_messenger', $messenger);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param bool $GRP_ID
73
+	 * @throws EE_Error
74
+	 */
75
+	public function set_group_template_id($GRP_ID = false)
76
+	{
77
+		if (! $GRP_ID) {
78
+			throw new EE_Error(
79
+				esc_html__(
80
+					'Missing required value for the message template group id',
81
+					'event_espresso'
82
+				)
83
+			);
84
+		}
85
+		$this->set('GRP_ID', $GRP_ID);
86
+	}
87
+
88
+
89
+	/**
90
+	 * get Group ID
91
+	 *
92
+	 * @access public
93
+	 * @return int
94
+	 * @throws EE_Error
95
+	 */
96
+	public function GRP_ID()
97
+	{
98
+		return $this->get('GRP_ID');
99
+	}
100
+
101
+
102
+	/**
103
+	 * get User ID
104
+	 *
105
+	 * @access public
106
+	 * @return int
107
+	 * @throws EE_Error
108
+	 */
109
+	public function user()
110
+	{
111
+		$user_id = $this->get('MTP_user_id');
112
+		return empty($user_id) ? get_current_user_id() : $user_id;
113
+	}
114
+
115
+
116
+	/**
117
+	 * Wrapper for the user function() (preserve backward compat)
118
+	 *
119
+	 * @since  4.5.0
120
+	 * @return int
121
+	 * @throws EE_Error
122
+	 */
123
+	public function wp_user()
124
+	{
125
+		return $this->user();
126
+	}
127
+
128
+
129
+	/**
130
+	 * This simply returns a count of all related events to this message template group
131
+	 *
132
+	 * @return int
133
+	 */
134
+	public function count_events()
135
+	{
136
+		return $this->count_related('Event');
137
+	}
138
+
139
+
140
+	/**
141
+	 * returns the name saved in the db for this template
142
+	 *
143
+	 * @return string
144
+	 * @throws EE_Error
145
+	 */
146
+	public function name()
147
+	{
148
+		return $this->get('MTP_name');
149
+	}
150
+
151
+
152
+	/**
153
+	 * Returns the description saved in the db for this template group
154
+	 *
155
+	 * @return string
156
+	 * @throws EE_Error
157
+	 */
158
+	public function description()
159
+	{
160
+		return $this->get('MTP_description');
161
+	}
162
+
163
+
164
+	/**
165
+	 * returns all related EE_Message_Template objects
166
+	 *
167
+	 * @param  array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
168
+	 * @return EE_Message_Template[]
169
+	 * @throws EE_Error
170
+	 */
171
+	public function message_templates($query_params = array())
172
+	{
173
+		return $this->get_many_related('Message_Template', $query_params);
174
+	}
175
+
176
+
177
+	/**
178
+	 * get Message Messenger
179
+	 *
180
+	 * @access public
181
+	 * @return string
182
+	 * @throws EE_Error
183
+	 */
184
+	public function messenger()
185
+	{
186
+		return $this->get('MTP_messenger');
187
+	}
188
+
189
+
190
+	/**
191
+	 * get Message Messenger OBJECT
192
+	 * If an attempt to get the corresponding messenger object fails, then we set this message
193
+	 * template group to inactive, and save to db.  Then return null so client code can handle
194
+	 * appropriately.
195
+	 *
196
+	 * @return EE_messenger
197
+	 * @throws EE_Error
198
+	 */
199
+	public function messenger_obj()
200
+	{
201
+		$messenger = $this->messenger();
202
+		try {
203
+			$messenger = EEH_MSG_Template::messenger_obj($messenger);
204
+		} catch (EE_Error $e) {
205
+			// if an exception was thrown then let's deactivate this message template group because it means there is no
206
+			// class for this messenger in this group.
207
+			$this->set('MTP_is_active', false);
208
+			$this->save();
209
+			return null;
210
+		}
211
+		return $messenger;
212
+	}
213
+
214
+
215
+	/**
216
+	 * get Message Type
217
+	 *
218
+	 * @access public
219
+	 * @return string
220
+	 * @throws EE_Error
221
+	 */
222
+	public function message_type()
223
+	{
224
+		return $this->get('MTP_message_type');
225
+	}
226
+
227
+
228
+	/**
229
+	 * get Message type OBJECT
230
+	 * If an attempt to get the corresponding message type object fails, then we set this message
231
+	 * template group to inactive, and save to db.  Then return null so client code can handle
232
+	 * appropriately.
233
+	 *
234
+	 * @throws EE_Error
235
+	 * @return EE_message_type|false if exception thrown.
236
+	 */
237
+	public function message_type_obj()
238
+	{
239
+		$message_type = $this->message_type();
240
+		try {
241
+			$message_type = EEH_MSG_Template::message_type_obj($message_type);
242
+		} catch (EE_Error $e) {
243
+			// if an exception was thrown then let's deactivate this message template group because it means there is no
244
+			// class for the message type in this group.
245
+			$this->set('MTP_is_active', false);
246
+			$this->save();
247
+			return null;
248
+		}
249
+		return $message_type;
250
+	}
251
+
252
+
253
+	/**
254
+	 * @return array
255
+	 * @throws EE_Error
256
+	 */
257
+	public function contexts_config()
258
+	{
259
+		return $this->message_type_obj()->get_contexts();
260
+	}
261
+
262
+
263
+	/**
264
+	 * This returns the context_label for contexts as set in the message type object
265
+	 * Note this is an array with singular and plural keys
266
+	 *
267
+	 * @access public
268
+	 * @return array labels for "context"
269
+	 * @throws EE_Error
270
+	 */
271
+	public function context_label()
272
+	{
273
+		$obj = $this->message_type_obj();
274
+		return $obj->get_context_label();
275
+	}
276
+
277
+
278
+	/**
279
+	 * This returns an array of EE_Message_Template objects indexed by context and field.
280
+	 *
281
+	 * @return array ()
282
+	 * @throws EE_Error
283
+	 */
284
+	public function context_templates()
285
+	{
286
+		$mtps_arr = array();
287
+		$mtps = $this->get_many_related('Message_Template');
288
+		if (empty($mtps)) {
289
+			return array();
290
+		}
291
+		// note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292
+		foreach ($mtps as $mtp) {
293
+			$mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
294
+		}
295
+		return $mtps_arr;
296
+	}
297
+
298
+
299
+	/**
300
+	 * this returns if the template group this template belongs to is global
301
+	 *
302
+	 * @return bool true if it is, false if it isn't
303
+	 * @throws EE_Error
304
+	 */
305
+	public function is_global()
306
+	{
307
+		return $this->get('MTP_is_global');
308
+	}
309
+
310
+
311
+	/**
312
+	 * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
313
+	 *
314
+	 * @return bool true if it is, false if it isn't
315
+	 * @throws EE_Error
316
+	 */
317
+	public function is_active()
318
+	{
319
+		return $this->get('MTP_is_active');
320
+	}
321
+
322
+
323
+	/**
324
+	 * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
325
+	 * this template.
326
+	 *
327
+	 * @since 4.3.0
328
+	 * @uses  EEH_MSG_Template::get_shortcodes()
329
+	 * @param string $context what context we're going to return shortcodes for
330
+	 * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
331
+	 *                        to be returned.
332
+	 * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
333
+	 *                        unique shortcodes for all the given (or all) fields.
334
+	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
335
+	 *                        shortcodes found.
336
+	 * @throws EE_Error
337
+	 */
338
+	public function get_shortcodes($context, $fields = array(), $merged = false)
339
+	{
340
+		$messenger = $this->messenger();
341
+		$message_type = $this->message_type();
342
+		return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
343
+	}
344
+
345
+
346
+	/**
347
+	 * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
348
+	 * use the default template pack.
349
+	 *
350
+	 * @since 4.5.0
351
+	 * @return string
352
+	 * @throws EE_Error
353
+	 */
354
+	public function get_template_pack_name()
355
+	{
356
+		return $this->get_extra_meta('MTP_template_pack', true, 'default');
357
+	}
358
+
359
+
360
+	/**
361
+	 * This returns the specific template pack object referenced by the template pack name attached to this message
362
+	 * template group.  If no template pack is assigned then the default template pack is retrieved.
363
+	 *
364
+	 * @since 4.5.0
365
+	 * @return EE_Messages_Template_Pack
366
+	 * @throws EE_Error
367
+	 * @throws InvalidArgumentException
368
+	 * @throws ReflectionException
369
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
370
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
371
+	 */
372
+	public function get_template_pack()
373
+	{
374
+		$pack_name = $this->get_template_pack_name();
375
+		EE_Registry::instance()->load_helper('MSG_Template');
376
+		return EEH_MSG_Template::get_template_pack($pack_name);
377
+	}
378
+
379
+
380
+	/**
381
+	 * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
382
+	 * use the default template variation.
383
+	 *
384
+	 * @since 4.5.0
385
+	 * @return string
386
+	 * @throws EE_Error
387
+	 */
388
+	public function get_template_pack_variation()
389
+	{
390
+		return $this->get_extra_meta('MTP_variation', true, 'default');
391
+	}
392
+
393
+
394
+	/**
395
+	 * This just sets the template pack name attached to this message template group.
396
+	 *
397
+	 * @since 4.5.0
398
+	 * @param string $template_pack_name What message template pack is assigned.
399
+	 * @return int
400
+	 * @throws EE_Error
401
+	 */
402
+	public function set_template_pack_name($template_pack_name)
403
+	{
404
+		return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
405
+	}
406
+
407
+
408
+	/**
409
+	 * This just sets the template pack variation attached to this message template group.
410
+	 *
411
+	 * @since 4.5.0
412
+	 * @param string $variation What variation is being set on the message template group.
413
+	 * @return int
414
+	 * @throws EE_Error
415
+	 */
416
+	public function set_template_pack_variation($variation)
417
+	{
418
+		return $this->update_extra_meta('MTP_variation', $variation);
419
+	}
420
+
421
+
422
+	/**
423
+	 * Deactivates the given context.
424
+	 *
425
+	 * @param $context
426
+	 * @return bool|int
427
+	 * @throws EE_Error
428
+	 * @throws InvalidIdentifierException
429
+	 */
430
+	public function deactivate_context($context)
431
+	{
432
+		$this->validate_context($context);
433
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
434
+	}
435
+
436
+
437
+	/**
438
+	 * Activates the given context.
439
+	 *
440
+	 * @param $context
441
+	 * @return bool|int
442
+	 * @throws EE_Error
443
+	 * @throws InvalidIdentifierException
444
+	 */
445
+	public function activate_context($context)
446
+	{
447
+		$this->validate_context($context);
448
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
449
+	}
450
+
451
+
452
+	/**
453
+	 * Returns whether the context is active or not.
454
+	 * Note, this will default to true if the extra meta record doesn't exist.
455
+	 * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
456
+	 * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
457
+	 * whether a context is "active" or not.
458
+	 *
459
+	 * @param $context
460
+	 * @return bool
461
+	 * @throws EE_Error
462
+	 * @throws InvalidIdentifierException
463
+	 */
464
+	public function is_context_active($context)
465
+	{
466
+		$this->validate_context($context);
467
+		return filter_var(
468
+			$this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
469
+			FILTER_VALIDATE_BOOLEAN
470
+		);
471
+	}
472
+
473
+
474
+	/**
475
+	 * Validates the incoming context to verify it matches a registered context for the related message type.
476
+	 *
477
+	 * @param string $context
478
+	 * @throws EE_Error
479
+	 * @throws InvalidIdentifierException
480
+	 */
481
+	public function validate_context($context)
482
+	{
483
+		$contexts = $this->contexts_config();
484
+		if (! isset($contexts[ $context ])) {
485
+			throw new InvalidIdentifierException(
486
+				'',
487
+				'',
488
+				sprintf(
489
+					esc_html__(
490
+						'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
491
+						'event_espresso'
492
+					),
493
+					$context,
494
+					implode(',', array_keys($contexts))
495
+				)
496
+			);
497
+		}
498
+	}
499 499
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket_Price.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
 class EE_Ticket_Price extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array  $props_n_values
16
-     * @param string $timezone
17
-     * @return EE_Ticket_Price|mixed
18
-     */
19
-    public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
20
-    {
21
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
22
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
23
-    }
14
+	/**
15
+	 * @param array  $props_n_values
16
+	 * @param string $timezone
17
+	 * @return EE_Ticket_Price|mixed
18
+	 */
19
+	public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
20
+	{
21
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
22
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * @param array  $props_n_values
28
-     * @param string $timezone
29
-     * @return EE_Ticket_Price
30
-     */
31
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
32
-    {
33
-        return new self($props_n_values, true, $timezone);
34
-    }
26
+	/**
27
+	 * @param array  $props_n_values
28
+	 * @param string $timezone
29
+	 * @return EE_Ticket_Price
30
+	 */
31
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
32
+	{
33
+		return new self($props_n_values, true, $timezone);
34
+	}
35 35
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket_Template.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
 class EE_Ticket_Template extends EE_Base_Class
13 13
 {
14 14
 
15
-    /**
16
-     * @param array  $props_n_values
17
-     * @param string $timezone
18
-     * @return EE_Ticket_Template|mixed
19
-     */
20
-    public static function new_instance($props_n_values = array(), $timezone = '')
21
-    {
22
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
-    }
15
+	/**
16
+	 * @param array  $props_n_values
17
+	 * @param string $timezone
18
+	 * @return EE_Ticket_Template|mixed
19
+	 */
20
+	public static function new_instance($props_n_values = array(), $timezone = '')
21
+	{
22
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * @param array  $props_n_values
29
-     * @param string $timezone
30
-     * @return EE_Ticket_Template
31
-     */
32
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
33
-    {
34
-        return new self($props_n_values, true, $timezone);
35
-    }
27
+	/**
28
+	 * @param array  $props_n_values
29
+	 * @param string $timezone
30
+	 * @return EE_Ticket_Template
31
+	 */
32
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
33
+	{
34
+		return new self($props_n_values, true, $timezone);
35
+	}
36 36
 }
Please login to merge, or discard this patch.