@@ -11,578 +11,578 @@ |
||
11 | 11 | class EE_Payment_Method extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Payment Method type object, which has all the info about this type of payment method, |
|
16 | - * including functions for processing payments, to get settings forms, etc. |
|
17 | - * |
|
18 | - * @var EE_PMT_Base |
|
19 | - */ |
|
20 | - protected $_type_obj; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * @param array $props_n_values |
|
25 | - * @return EE_Payment_Method |
|
26 | - * @throws \EE_Error |
|
27 | - */ |
|
28 | - public static function new_instance($props_n_values = array()) |
|
29 | - { |
|
30 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
31 | - return $has_object ? $has_object : new self($props_n_values, false); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @param array $props_n_values |
|
37 | - * @return EE_Payment_Method |
|
38 | - * @throws \EE_Error |
|
39 | - */ |
|
40 | - public static function new_instance_from_db($props_n_values = array()) |
|
41 | - { |
|
42 | - return new self($props_n_values, true); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname. |
|
49 | - * Otherwise returns a normal EE_Payment_Method |
|
50 | - * |
|
51 | - * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically |
|
52 | - * the classname minus 'EEPM_') |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - // private static function _payment_method_type($props_n_values) |
|
56 | - // { |
|
57 | - // EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
58 | - // $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null; |
|
59 | - // if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) { |
|
60 | - // return 'EEPM_' . $type_string; |
|
61 | - // } else { |
|
62 | - // return __CLASS__; |
|
63 | - // } |
|
64 | - // } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc) |
|
69 | - * |
|
70 | - * @return boolean |
|
71 | - */ |
|
72 | - public function active() |
|
73 | - { |
|
74 | - return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope()); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Sets this PM as active by making it usable within the CART scope. Offline gateways |
|
80 | - * are also usable from the admin-scope as well. DOES NOT SAVE it |
|
81 | - * |
|
82 | - * @throws \EE_Error |
|
83 | - */ |
|
84 | - public function set_active() |
|
85 | - { |
|
86 | - $default_scopes = array(EEM_Payment_Method::scope_cart); |
|
87 | - if ($this->type_obj() && |
|
88 | - $this->type_obj()->payment_occurs() === EE_PMT_Base::offline) { |
|
89 | - $default_scopes[] = EEM_Payment_Method::scope_admin; |
|
90 | - } |
|
91 | - $this->set_scope($default_scopes); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it. |
|
97 | - */ |
|
98 | - public function deactivate() |
|
99 | - { |
|
100 | - $this->set_scope(array()); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Gets button_url |
|
106 | - * |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function button_url() |
|
110 | - { |
|
111 | - return $this->get('PMD_button_url'); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Sets button_url |
|
117 | - * |
|
118 | - * @param string $button_url |
|
119 | - */ |
|
120 | - public function set_button_url($button_url) |
|
121 | - { |
|
122 | - $this->set('PMD_button_url', $button_url); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Gets debug_mode |
|
128 | - * |
|
129 | - * @return boolean |
|
130 | - */ |
|
131 | - public function debug_mode() |
|
132 | - { |
|
133 | - return $this->get('PMD_debug_mode'); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Sets debug_mode |
|
139 | - * |
|
140 | - * @param boolean $debug_mode |
|
141 | - */ |
|
142 | - public function set_debug_mode($debug_mode) |
|
143 | - { |
|
144 | - $this->set('PMD_debug_mode', $debug_mode); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Gets description |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function description() |
|
154 | - { |
|
155 | - return $this->get('PMD_desc'); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * Sets description |
|
161 | - * |
|
162 | - * @param string $description |
|
163 | - */ |
|
164 | - public function set_description($description) |
|
165 | - { |
|
166 | - $this->set('PMD_desc', $description); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * Gets name |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function name() |
|
176 | - { |
|
177 | - return $this->get('PMD_name'); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * Sets name |
|
183 | - * |
|
184 | - * @param string $name |
|
185 | - */ |
|
186 | - public function set_name($name) |
|
187 | - { |
|
188 | - $this->set('PMD_name', $name); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * Gets open_by_default |
|
194 | - * |
|
195 | - * @return boolean |
|
196 | - */ |
|
197 | - public function open_by_default() |
|
198 | - { |
|
199 | - return $this->get('PMD_open_by_default'); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Sets open_by_default |
|
205 | - * |
|
206 | - * @param boolean $open_by_default |
|
207 | - */ |
|
208 | - public function set_open_by_default($open_by_default) |
|
209 | - { |
|
210 | - $this->set('PMD_open_by_default', $open_by_default); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Gets order |
|
216 | - * |
|
217 | - * @return int |
|
218 | - */ |
|
219 | - public function order() |
|
220 | - { |
|
221 | - return $this->get('PMD_order'); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * Sets order |
|
227 | - * |
|
228 | - * @param int $order |
|
229 | - */ |
|
230 | - public function set_order($order) |
|
231 | - { |
|
232 | - $this->set('PMD_order', $order); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * Gets slug |
|
238 | - * |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - public function slug() |
|
242 | - { |
|
243 | - return $this->get('PMD_slug'); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Sets slug |
|
249 | - * |
|
250 | - * @param string $slug |
|
251 | - */ |
|
252 | - public function set_slug($slug) |
|
253 | - { |
|
254 | - $this->set('PMD_slug', $slug); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Gets type |
|
260 | - * |
|
261 | - * @return string |
|
262 | - */ |
|
263 | - public function type() |
|
264 | - { |
|
265 | - return $this->get('PMD_type'); |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * Sets type |
|
271 | - * |
|
272 | - * @param string $type |
|
273 | - */ |
|
274 | - public function set_type($type) |
|
275 | - { |
|
276 | - $this->set('PMD_type', $type); |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * Gets wp_user |
|
282 | - * |
|
283 | - * @return int |
|
284 | - */ |
|
285 | - public function wp_user() |
|
286 | - { |
|
287 | - return $this->get('PMD_wp_user'); |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Sets wp_user |
|
293 | - * |
|
294 | - * @param int $wp_user_id |
|
295 | - */ |
|
296 | - public function set_wp_user($wp_user_id) |
|
297 | - { |
|
298 | - $this->set('PMD_wp_user', $wp_user_id); |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Overrides parent so when PMD_type is changed we refresh the _type_obj |
|
303 | - * |
|
304 | - * @param string $field_name |
|
305 | - * @param mixed $field_value |
|
306 | - * @param boolean $use_default |
|
307 | - */ |
|
308 | - public function set($field_name, $field_value, $use_default = false) |
|
309 | - { |
|
310 | - if ($field_name === 'PMD_type') { |
|
311 | - // the type has probably changed, so forget about its old type object |
|
312 | - $this->_type_obj = null; |
|
313 | - } |
|
314 | - parent::set($field_name, $field_value, $use_default); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * Gets admin_name |
|
320 | - * |
|
321 | - * @return string |
|
322 | - */ |
|
323 | - public function admin_name() |
|
324 | - { |
|
325 | - return $this->get('PMD_admin_name'); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * Sets admin_name |
|
331 | - * |
|
332 | - * @param string $admin_name |
|
333 | - */ |
|
334 | - public function set_admin_name($admin_name) |
|
335 | - { |
|
336 | - $this->set('PMD_admin_name', $admin_name); |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * Gets admin_desc |
|
342 | - * |
|
343 | - * @return string |
|
344 | - */ |
|
345 | - public function admin_desc() |
|
346 | - { |
|
347 | - return $this->get('PMD_admin_desc'); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * Sets admin_desc |
|
353 | - * |
|
354 | - * @param string $admin_desc |
|
355 | - */ |
|
356 | - public function set_admin_desc($admin_desc) |
|
357 | - { |
|
358 | - $this->set('PMD_admin_desc', $admin_desc); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * Gets scope |
|
364 | - * |
|
365 | - * @return array |
|
366 | - */ |
|
367 | - public function scope() |
|
368 | - { |
|
369 | - return $this->get('PMD_scope'); |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * Sets scope |
|
375 | - * |
|
376 | - * @param array $scope |
|
377 | - */ |
|
378 | - public function set_scope($scope) |
|
379 | - { |
|
380 | - $this->set('PMD_scope', $scope); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * Gets the payment method type for this payment method instance |
|
386 | - * |
|
387 | - * @return EE_PMT_Base |
|
388 | - * @throws EE_Error |
|
389 | - */ |
|
390 | - public function type_obj() |
|
391 | - { |
|
392 | - if (! $this->_type_obj) { |
|
393 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
394 | - if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) { |
|
395 | - $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type()); |
|
396 | - if (! class_exists($class_name)) { |
|
397 | - throw new EE_Error( |
|
398 | - sprintf( |
|
399 | - __( |
|
400 | - 'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', |
|
401 | - 'event_espresso' |
|
402 | - ), |
|
403 | - $class_name, |
|
404 | - '<br />', |
|
405 | - '<a href="' . admin_url('plugins.php') . '">', |
|
406 | - '</a>' |
|
407 | - ) |
|
408 | - ); |
|
409 | - } |
|
410 | - $r = new ReflectionClass($class_name); |
|
411 | - $this->_type_obj = $r->newInstanceArgs(array($this)); |
|
412 | - } else { |
|
413 | - throw new EE_Error( |
|
414 | - sprintf( |
|
415 | - __( |
|
416 | - 'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', |
|
417 | - 'event_espresso' |
|
418 | - ), |
|
419 | - $this->type(), |
|
420 | - implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names()) |
|
421 | - ) |
|
422 | - ); |
|
423 | - } |
|
424 | - } |
|
425 | - return $this->_type_obj; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix) |
|
431 | - * and the extra meta. Mostly used for passing off ot gateways. * |
|
432 | - * |
|
433 | - * @return array |
|
434 | - */ |
|
435 | - public function settings_array() |
|
436 | - { |
|
437 | - $fields = $this->model_field_array(); |
|
438 | - $extra_meta = $this->all_extra_meta_array(); |
|
439 | - // remove the model's prefix from the fields |
|
440 | - $combined_settings_array = array(); |
|
441 | - foreach ($fields as $key => $value) { |
|
442 | - if (strpos($key, 'PMD_') === 0) { |
|
443 | - $key_sans_model_prefix = str_replace('PMD_', '', $key); |
|
444 | - $combined_settings_array [ $key_sans_model_prefix ] = $value; |
|
445 | - } |
|
446 | - } |
|
447 | - $combined_settings_array = array_merge($extra_meta, $combined_settings_array); |
|
448 | - return $combined_settings_array; |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Gets the HTML for displaying the payment method on a page. |
|
454 | - * |
|
455 | - * @param string $url |
|
456 | - * @param string $css_class |
|
457 | - * @return string of HTML for displaying the button |
|
458 | - * @throws \EE_Error |
|
459 | - */ |
|
460 | - public function button_html($url = '', $css_class = '') |
|
461 | - { |
|
462 | - $payment_occurs = $this->type_obj()->payment_occurs(); |
|
463 | - return ' |
|
14 | + /** |
|
15 | + * Payment Method type object, which has all the info about this type of payment method, |
|
16 | + * including functions for processing payments, to get settings forms, etc. |
|
17 | + * |
|
18 | + * @var EE_PMT_Base |
|
19 | + */ |
|
20 | + protected $_type_obj; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * @param array $props_n_values |
|
25 | + * @return EE_Payment_Method |
|
26 | + * @throws \EE_Error |
|
27 | + */ |
|
28 | + public static function new_instance($props_n_values = array()) |
|
29 | + { |
|
30 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
31 | + return $has_object ? $has_object : new self($props_n_values, false); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @param array $props_n_values |
|
37 | + * @return EE_Payment_Method |
|
38 | + * @throws \EE_Error |
|
39 | + */ |
|
40 | + public static function new_instance_from_db($props_n_values = array()) |
|
41 | + { |
|
42 | + return new self($props_n_values, true); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname. |
|
49 | + * Otherwise returns a normal EE_Payment_Method |
|
50 | + * |
|
51 | + * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically |
|
52 | + * the classname minus 'EEPM_') |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + // private static function _payment_method_type($props_n_values) |
|
56 | + // { |
|
57 | + // EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
58 | + // $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null; |
|
59 | + // if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) { |
|
60 | + // return 'EEPM_' . $type_string; |
|
61 | + // } else { |
|
62 | + // return __CLASS__; |
|
63 | + // } |
|
64 | + // } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc) |
|
69 | + * |
|
70 | + * @return boolean |
|
71 | + */ |
|
72 | + public function active() |
|
73 | + { |
|
74 | + return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope()); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Sets this PM as active by making it usable within the CART scope. Offline gateways |
|
80 | + * are also usable from the admin-scope as well. DOES NOT SAVE it |
|
81 | + * |
|
82 | + * @throws \EE_Error |
|
83 | + */ |
|
84 | + public function set_active() |
|
85 | + { |
|
86 | + $default_scopes = array(EEM_Payment_Method::scope_cart); |
|
87 | + if ($this->type_obj() && |
|
88 | + $this->type_obj()->payment_occurs() === EE_PMT_Base::offline) { |
|
89 | + $default_scopes[] = EEM_Payment_Method::scope_admin; |
|
90 | + } |
|
91 | + $this->set_scope($default_scopes); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it. |
|
97 | + */ |
|
98 | + public function deactivate() |
|
99 | + { |
|
100 | + $this->set_scope(array()); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Gets button_url |
|
106 | + * |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function button_url() |
|
110 | + { |
|
111 | + return $this->get('PMD_button_url'); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Sets button_url |
|
117 | + * |
|
118 | + * @param string $button_url |
|
119 | + */ |
|
120 | + public function set_button_url($button_url) |
|
121 | + { |
|
122 | + $this->set('PMD_button_url', $button_url); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Gets debug_mode |
|
128 | + * |
|
129 | + * @return boolean |
|
130 | + */ |
|
131 | + public function debug_mode() |
|
132 | + { |
|
133 | + return $this->get('PMD_debug_mode'); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Sets debug_mode |
|
139 | + * |
|
140 | + * @param boolean $debug_mode |
|
141 | + */ |
|
142 | + public function set_debug_mode($debug_mode) |
|
143 | + { |
|
144 | + $this->set('PMD_debug_mode', $debug_mode); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Gets description |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function description() |
|
154 | + { |
|
155 | + return $this->get('PMD_desc'); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * Sets description |
|
161 | + * |
|
162 | + * @param string $description |
|
163 | + */ |
|
164 | + public function set_description($description) |
|
165 | + { |
|
166 | + $this->set('PMD_desc', $description); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * Gets name |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function name() |
|
176 | + { |
|
177 | + return $this->get('PMD_name'); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * Sets name |
|
183 | + * |
|
184 | + * @param string $name |
|
185 | + */ |
|
186 | + public function set_name($name) |
|
187 | + { |
|
188 | + $this->set('PMD_name', $name); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * Gets open_by_default |
|
194 | + * |
|
195 | + * @return boolean |
|
196 | + */ |
|
197 | + public function open_by_default() |
|
198 | + { |
|
199 | + return $this->get('PMD_open_by_default'); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Sets open_by_default |
|
205 | + * |
|
206 | + * @param boolean $open_by_default |
|
207 | + */ |
|
208 | + public function set_open_by_default($open_by_default) |
|
209 | + { |
|
210 | + $this->set('PMD_open_by_default', $open_by_default); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Gets order |
|
216 | + * |
|
217 | + * @return int |
|
218 | + */ |
|
219 | + public function order() |
|
220 | + { |
|
221 | + return $this->get('PMD_order'); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * Sets order |
|
227 | + * |
|
228 | + * @param int $order |
|
229 | + */ |
|
230 | + public function set_order($order) |
|
231 | + { |
|
232 | + $this->set('PMD_order', $order); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * Gets slug |
|
238 | + * |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + public function slug() |
|
242 | + { |
|
243 | + return $this->get('PMD_slug'); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Sets slug |
|
249 | + * |
|
250 | + * @param string $slug |
|
251 | + */ |
|
252 | + public function set_slug($slug) |
|
253 | + { |
|
254 | + $this->set('PMD_slug', $slug); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Gets type |
|
260 | + * |
|
261 | + * @return string |
|
262 | + */ |
|
263 | + public function type() |
|
264 | + { |
|
265 | + return $this->get('PMD_type'); |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * Sets type |
|
271 | + * |
|
272 | + * @param string $type |
|
273 | + */ |
|
274 | + public function set_type($type) |
|
275 | + { |
|
276 | + $this->set('PMD_type', $type); |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * Gets wp_user |
|
282 | + * |
|
283 | + * @return int |
|
284 | + */ |
|
285 | + public function wp_user() |
|
286 | + { |
|
287 | + return $this->get('PMD_wp_user'); |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Sets wp_user |
|
293 | + * |
|
294 | + * @param int $wp_user_id |
|
295 | + */ |
|
296 | + public function set_wp_user($wp_user_id) |
|
297 | + { |
|
298 | + $this->set('PMD_wp_user', $wp_user_id); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Overrides parent so when PMD_type is changed we refresh the _type_obj |
|
303 | + * |
|
304 | + * @param string $field_name |
|
305 | + * @param mixed $field_value |
|
306 | + * @param boolean $use_default |
|
307 | + */ |
|
308 | + public function set($field_name, $field_value, $use_default = false) |
|
309 | + { |
|
310 | + if ($field_name === 'PMD_type') { |
|
311 | + // the type has probably changed, so forget about its old type object |
|
312 | + $this->_type_obj = null; |
|
313 | + } |
|
314 | + parent::set($field_name, $field_value, $use_default); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * Gets admin_name |
|
320 | + * |
|
321 | + * @return string |
|
322 | + */ |
|
323 | + public function admin_name() |
|
324 | + { |
|
325 | + return $this->get('PMD_admin_name'); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * Sets admin_name |
|
331 | + * |
|
332 | + * @param string $admin_name |
|
333 | + */ |
|
334 | + public function set_admin_name($admin_name) |
|
335 | + { |
|
336 | + $this->set('PMD_admin_name', $admin_name); |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * Gets admin_desc |
|
342 | + * |
|
343 | + * @return string |
|
344 | + */ |
|
345 | + public function admin_desc() |
|
346 | + { |
|
347 | + return $this->get('PMD_admin_desc'); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * Sets admin_desc |
|
353 | + * |
|
354 | + * @param string $admin_desc |
|
355 | + */ |
|
356 | + public function set_admin_desc($admin_desc) |
|
357 | + { |
|
358 | + $this->set('PMD_admin_desc', $admin_desc); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * Gets scope |
|
364 | + * |
|
365 | + * @return array |
|
366 | + */ |
|
367 | + public function scope() |
|
368 | + { |
|
369 | + return $this->get('PMD_scope'); |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * Sets scope |
|
375 | + * |
|
376 | + * @param array $scope |
|
377 | + */ |
|
378 | + public function set_scope($scope) |
|
379 | + { |
|
380 | + $this->set('PMD_scope', $scope); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * Gets the payment method type for this payment method instance |
|
386 | + * |
|
387 | + * @return EE_PMT_Base |
|
388 | + * @throws EE_Error |
|
389 | + */ |
|
390 | + public function type_obj() |
|
391 | + { |
|
392 | + if (! $this->_type_obj) { |
|
393 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
394 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) { |
|
395 | + $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type()); |
|
396 | + if (! class_exists($class_name)) { |
|
397 | + throw new EE_Error( |
|
398 | + sprintf( |
|
399 | + __( |
|
400 | + 'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', |
|
401 | + 'event_espresso' |
|
402 | + ), |
|
403 | + $class_name, |
|
404 | + '<br />', |
|
405 | + '<a href="' . admin_url('plugins.php') . '">', |
|
406 | + '</a>' |
|
407 | + ) |
|
408 | + ); |
|
409 | + } |
|
410 | + $r = new ReflectionClass($class_name); |
|
411 | + $this->_type_obj = $r->newInstanceArgs(array($this)); |
|
412 | + } else { |
|
413 | + throw new EE_Error( |
|
414 | + sprintf( |
|
415 | + __( |
|
416 | + 'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', |
|
417 | + 'event_espresso' |
|
418 | + ), |
|
419 | + $this->type(), |
|
420 | + implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names()) |
|
421 | + ) |
|
422 | + ); |
|
423 | + } |
|
424 | + } |
|
425 | + return $this->_type_obj; |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix) |
|
431 | + * and the extra meta. Mostly used for passing off ot gateways. * |
|
432 | + * |
|
433 | + * @return array |
|
434 | + */ |
|
435 | + public function settings_array() |
|
436 | + { |
|
437 | + $fields = $this->model_field_array(); |
|
438 | + $extra_meta = $this->all_extra_meta_array(); |
|
439 | + // remove the model's prefix from the fields |
|
440 | + $combined_settings_array = array(); |
|
441 | + foreach ($fields as $key => $value) { |
|
442 | + if (strpos($key, 'PMD_') === 0) { |
|
443 | + $key_sans_model_prefix = str_replace('PMD_', '', $key); |
|
444 | + $combined_settings_array [ $key_sans_model_prefix ] = $value; |
|
445 | + } |
|
446 | + } |
|
447 | + $combined_settings_array = array_merge($extra_meta, $combined_settings_array); |
|
448 | + return $combined_settings_array; |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Gets the HTML for displaying the payment method on a page. |
|
454 | + * |
|
455 | + * @param string $url |
|
456 | + * @param string $css_class |
|
457 | + * @return string of HTML for displaying the button |
|
458 | + * @throws \EE_Error |
|
459 | + */ |
|
460 | + public function button_html($url = '', $css_class = '') |
|
461 | + { |
|
462 | + $payment_occurs = $this->type_obj()->payment_occurs(); |
|
463 | + return ' |
|
464 | 464 | <div id="' |
465 | - . $this->slug() |
|
466 | - . '-payment-option-dv" class="' |
|
467 | - . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '"> |
|
465 | + . $this->slug() |
|
466 | + . '-payment-option-dv" class="' |
|
467 | + . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '"> |
|
468 | 468 | <a id="payment-gateway-button-' . $this->slug() |
469 | - . '" class="reg-page-payment-option-lnk" rel="' |
|
470 | - . $this->slug() . '" href="' . $url . '" > |
|
469 | + . '" class="reg-page-payment-option-lnk" rel="' |
|
470 | + . $this->slug() . '" href="' . $url . '" > |
|
471 | 471 | <img src="' . $this->button_url() . '" alt="' . sprintf( |
472 | - esc_attr__('Pay using %s', 'event_espresso'), |
|
473 | - $this->get_pretty('PMD_name', 'form_input') |
|
474 | - ) . '" /> |
|
472 | + esc_attr__('Pay using %s', 'event_espresso'), |
|
473 | + $this->get_pretty('PMD_name', 'form_input') |
|
474 | + ) . '" /> |
|
475 | 475 | </a> |
476 | 476 | </div> |
477 | 477 | '; |
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * Gets all the currencies which are an option for this payment method |
|
483 | - * (as defined by the gateway and the currently active currencies) |
|
484 | - * |
|
485 | - * @return EE_Currency[] |
|
486 | - * @throws \EE_Error |
|
487 | - */ |
|
488 | - public function get_all_usable_currencies() |
|
489 | - { |
|
490 | - return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj()); |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * Reports whether or not this payment method can be used for this payment method |
|
496 | - * |
|
497 | - * @param string $currency_code currency ID (code) |
|
498 | - * @return boolean |
|
499 | - * @throws \EE_Error |
|
500 | - */ |
|
501 | - public function usable_for_currency($currency_code) |
|
502 | - { |
|
503 | - foreach ($this->get_all_usable_currencies() as $currency_obj) { |
|
504 | - if ($currency_obj->ID() === $currency_code) { |
|
505 | - return true; |
|
506 | - } |
|
507 | - } |
|
508 | - return false; |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway |
|
514 | - * |
|
515 | - * @return bool |
|
516 | - * @throws \EE_Error |
|
517 | - */ |
|
518 | - public function is_on_site() |
|
519 | - { |
|
520 | - return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite; |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - /** |
|
525 | - * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway |
|
526 | - * |
|
527 | - * @return bool |
|
528 | - * @throws \EE_Error |
|
529 | - */ |
|
530 | - public function is_off_site() |
|
531 | - { |
|
532 | - return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite; |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * Returns TRUE if this payment method does not utilize a gateway |
|
538 | - * |
|
539 | - * @return bool |
|
540 | - * @throws \EE_Error |
|
541 | - */ |
|
542 | - public function is_off_line() |
|
543 | - { |
|
544 | - return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline; |
|
545 | - } |
|
546 | - |
|
547 | - /** |
|
548 | - * Overrides default __sleep so the object type is NOT cached. |
|
549 | - * This way we can rely on the normal EE_Payment_Method::type_obj() logic |
|
550 | - * to load the required classes, and don't need them at the time of unserialization |
|
551 | - * |
|
552 | - * @return array |
|
553 | - */ |
|
554 | - public function __sleep() |
|
555 | - { |
|
556 | - $properties = get_object_vars($this); |
|
557 | - unset($properties['_type_obj']); |
|
558 | - return array_keys($properties); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Overrides parent to add some logging for when payment methods get deactivated |
|
564 | - * |
|
565 | - * @param array $set_cols_n_values |
|
566 | - * @return int @see EE_Base_Class::save() |
|
567 | - * @throws \EE_Error |
|
568 | - */ |
|
569 | - public function save($set_cols_n_values = array()) |
|
570 | - { |
|
571 | - $results = parent::save($set_cols_n_values); |
|
572 | - if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) { |
|
573 | - EE_Log::instance()->log( |
|
574 | - __FILE__, |
|
575 | - __FUNCTION__, |
|
576 | - sprintf( |
|
577 | - __('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'), |
|
578 | - $this->name(), |
|
579 | - serialize($this->get_original('PMD_scope')), |
|
580 | - serialize($this->get('PMD_scope')), |
|
581 | - EE_Registry::instance()->REQ->get_current_page_permalink() |
|
582 | - ), |
|
583 | - 'payment_method_change' |
|
584 | - ); |
|
585 | - } |
|
586 | - return $results; |
|
587 | - } |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * Gets all the currencies which are an option for this payment method |
|
483 | + * (as defined by the gateway and the currently active currencies) |
|
484 | + * |
|
485 | + * @return EE_Currency[] |
|
486 | + * @throws \EE_Error |
|
487 | + */ |
|
488 | + public function get_all_usable_currencies() |
|
489 | + { |
|
490 | + return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj()); |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * Reports whether or not this payment method can be used for this payment method |
|
496 | + * |
|
497 | + * @param string $currency_code currency ID (code) |
|
498 | + * @return boolean |
|
499 | + * @throws \EE_Error |
|
500 | + */ |
|
501 | + public function usable_for_currency($currency_code) |
|
502 | + { |
|
503 | + foreach ($this->get_all_usable_currencies() as $currency_obj) { |
|
504 | + if ($currency_obj->ID() === $currency_code) { |
|
505 | + return true; |
|
506 | + } |
|
507 | + } |
|
508 | + return false; |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway |
|
514 | + * |
|
515 | + * @return bool |
|
516 | + * @throws \EE_Error |
|
517 | + */ |
|
518 | + public function is_on_site() |
|
519 | + { |
|
520 | + return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite; |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway |
|
526 | + * |
|
527 | + * @return bool |
|
528 | + * @throws \EE_Error |
|
529 | + */ |
|
530 | + public function is_off_site() |
|
531 | + { |
|
532 | + return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite; |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * Returns TRUE if this payment method does not utilize a gateway |
|
538 | + * |
|
539 | + * @return bool |
|
540 | + * @throws \EE_Error |
|
541 | + */ |
|
542 | + public function is_off_line() |
|
543 | + { |
|
544 | + return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline; |
|
545 | + } |
|
546 | + |
|
547 | + /** |
|
548 | + * Overrides default __sleep so the object type is NOT cached. |
|
549 | + * This way we can rely on the normal EE_Payment_Method::type_obj() logic |
|
550 | + * to load the required classes, and don't need them at the time of unserialization |
|
551 | + * |
|
552 | + * @return array |
|
553 | + */ |
|
554 | + public function __sleep() |
|
555 | + { |
|
556 | + $properties = get_object_vars($this); |
|
557 | + unset($properties['_type_obj']); |
|
558 | + return array_keys($properties); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Overrides parent to add some logging for when payment methods get deactivated |
|
564 | + * |
|
565 | + * @param array $set_cols_n_values |
|
566 | + * @return int @see EE_Base_Class::save() |
|
567 | + * @throws \EE_Error |
|
568 | + */ |
|
569 | + public function save($set_cols_n_values = array()) |
|
570 | + { |
|
571 | + $results = parent::save($set_cols_n_values); |
|
572 | + if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) { |
|
573 | + EE_Log::instance()->log( |
|
574 | + __FILE__, |
|
575 | + __FUNCTION__, |
|
576 | + sprintf( |
|
577 | + __('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'), |
|
578 | + $this->name(), |
|
579 | + serialize($this->get_original('PMD_scope')), |
|
580 | + serialize($this->get('PMD_scope')), |
|
581 | + EE_Registry::instance()->REQ->get_current_page_permalink() |
|
582 | + ), |
|
583 | + 'payment_method_change' |
|
584 | + ); |
|
585 | + } |
|
586 | + return $results; |
|
587 | + } |
|
588 | 588 | } |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function type_obj() |
391 | 391 | { |
392 | - if (! $this->_type_obj) { |
|
392 | + if ( ! $this->_type_obj) { |
|
393 | 393 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
394 | 394 | if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) { |
395 | 395 | $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type()); |
396 | - if (! class_exists($class_name)) { |
|
396 | + if ( ! class_exists($class_name)) { |
|
397 | 397 | throw new EE_Error( |
398 | 398 | sprintf( |
399 | 399 | __( |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | ), |
403 | 403 | $class_name, |
404 | 404 | '<br />', |
405 | - '<a href="' . admin_url('plugins.php') . '">', |
|
405 | + '<a href="'.admin_url('plugins.php').'">', |
|
406 | 406 | '</a>' |
407 | 407 | ) |
408 | 408 | ); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | foreach ($fields as $key => $value) { |
442 | 442 | if (strpos($key, 'PMD_') === 0) { |
443 | 443 | $key_sans_model_prefix = str_replace('PMD_', '', $key); |
444 | - $combined_settings_array [ $key_sans_model_prefix ] = $value; |
|
444 | + $combined_settings_array [$key_sans_model_prefix] = $value; |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | $combined_settings_array = array_merge($extra_meta, $combined_settings_array); |
@@ -464,14 +464,14 @@ discard block |
||
464 | 464 | <div id="' |
465 | 465 | . $this->slug() |
466 | 466 | . '-payment-option-dv" class="' |
467 | - . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '"> |
|
467 | + . $payment_occurs.'-payment-gateway reg-page-payment-option-dv'.$css_class.'"> |
|
468 | 468 | <a id="payment-gateway-button-' . $this->slug() |
469 | 469 | . '" class="reg-page-payment-option-lnk" rel="' |
470 | - . $this->slug() . '" href="' . $url . '" > |
|
471 | - <img src="' . $this->button_url() . '" alt="' . sprintf( |
|
470 | + . $this->slug().'" href="'.$url.'" > |
|
471 | + <img src="' . $this->button_url().'" alt="'.sprintf( |
|
472 | 472 | esc_attr__('Pay using %s', 'event_espresso'), |
473 | 473 | $this->get_pretty('PMD_name', 'form_input') |
474 | - ) . '" /> |
|
474 | + ).'" /> |
|
475 | 475 | </a> |
476 | 476 | </div> |
477 | 477 | '; |
@@ -6,23 +6,23 @@ |
||
6 | 6 | class EE_Event_Venue extends EE_Base_Class |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * @param array $props_n_values |
|
11 | - * @return EE_Event_Venue|mixed |
|
12 | - */ |
|
13 | - public static function new_instance($props_n_values = array()) |
|
14 | - { |
|
15 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | - return $has_object ? $has_object : new self($props_n_values); |
|
17 | - } |
|
9 | + /** |
|
10 | + * @param array $props_n_values |
|
11 | + * @return EE_Event_Venue|mixed |
|
12 | + */ |
|
13 | + public static function new_instance($props_n_values = array()) |
|
14 | + { |
|
15 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | + return $has_object ? $has_object : new self($props_n_values); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $props_n_values |
|
22 | - * @return EE_Event_Venue |
|
23 | - */ |
|
24 | - public static function new_instance_from_db($props_n_values = array()) |
|
25 | - { |
|
26 | - return new self($props_n_values, true); |
|
27 | - } |
|
20 | + /** |
|
21 | + * @param array $props_n_values |
|
22 | + * @return EE_Event_Venue |
|
23 | + */ |
|
24 | + public static function new_instance_from_db($props_n_values = array()) |
|
25 | + { |
|
26 | + return new self($props_n_values, true); |
|
27 | + } |
|
28 | 28 | } |
@@ -12,53 +12,53 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * Overrides parent _delete() so that we do soft deletes. |
|
17 | - * |
|
18 | - * @return bool|int |
|
19 | - */ |
|
20 | - protected function _delete() |
|
21 | - { |
|
22 | - return $this->delete_or_restore(); |
|
23 | - } |
|
15 | + /** |
|
16 | + * Overrides parent _delete() so that we do soft deletes. |
|
17 | + * |
|
18 | + * @return bool|int |
|
19 | + */ |
|
20 | + protected function _delete() |
|
21 | + { |
|
22 | + return $this->delete_or_restore(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Deletes or restores this object. |
|
28 | - * |
|
29 | - * @param bool $delete true=>delete, false=>restore |
|
30 | - * @return bool|int |
|
31 | - */ |
|
32 | - public function delete_or_restore($delete = true) |
|
33 | - { |
|
34 | - /** |
|
35 | - * Called just before trashing (soft delete) or restoring a trashed item. |
|
36 | - * |
|
37 | - * @param EE_Base_Class $model_object about to be trashed or restored |
|
38 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
39 | - */ |
|
40 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
41 | - $model = $this->get_model(); |
|
42 | - $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
43 | - /** |
|
44 | - * Called just after trashing (soft delete) or restoring a trashed item. |
|
45 | - * |
|
46 | - * @param EE_Base_Class $model_object that was just trashed or restored. |
|
47 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
48 | - * @param bool|int $result |
|
49 | - */ |
|
50 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
51 | - return $result; |
|
52 | - } |
|
26 | + /** |
|
27 | + * Deletes or restores this object. |
|
28 | + * |
|
29 | + * @param bool $delete true=>delete, false=>restore |
|
30 | + * @return bool|int |
|
31 | + */ |
|
32 | + public function delete_or_restore($delete = true) |
|
33 | + { |
|
34 | + /** |
|
35 | + * Called just before trashing (soft delete) or restoring a trashed item. |
|
36 | + * |
|
37 | + * @param EE_Base_Class $model_object about to be trashed or restored |
|
38 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
39 | + */ |
|
40 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
41 | + $model = $this->get_model(); |
|
42 | + $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
43 | + /** |
|
44 | + * Called just after trashing (soft delete) or restoring a trashed item. |
|
45 | + * |
|
46 | + * @param EE_Base_Class $model_object that was just trashed or restored. |
|
47 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
48 | + * @param bool|int $result |
|
49 | + */ |
|
50 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
51 | + return $result; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Performs a restoration (un-deletes) this object |
|
57 | - * |
|
58 | - * @return bool|int |
|
59 | - */ |
|
60 | - public function restore() |
|
61 | - { |
|
62 | - return $this->delete_or_restore(false); |
|
63 | - } |
|
55 | + /** |
|
56 | + * Performs a restoration (un-deletes) this object |
|
57 | + * |
|
58 | + * @return bool|int |
|
59 | + */ |
|
60 | + public function restore() |
|
61 | + { |
|
62 | + return $this->delete_or_restore(false); |
|
63 | + } |
|
64 | 64 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | class EE_Event_Question_Group extends EE_Base_Class |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * @param array $props_n_values |
|
11 | - * @return EE_Event_Question_Group|mixed |
|
12 | - */ |
|
13 | - public static function new_instance($props_n_values = array()) |
|
14 | - { |
|
15 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | - return $has_object ? $has_object : new self($props_n_values); |
|
17 | - } |
|
9 | + /** |
|
10 | + * @param array $props_n_values |
|
11 | + * @return EE_Event_Question_Group|mixed |
|
12 | + */ |
|
13 | + public static function new_instance($props_n_values = array()) |
|
14 | + { |
|
15 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | + return $has_object ? $has_object : new self($props_n_values); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $props_n_values |
|
22 | - * @return EE_Event_Question_Group |
|
23 | - */ |
|
24 | - public static function new_instance_from_db($props_n_values = array()) |
|
25 | - { |
|
26 | - return new self($props_n_values, true); |
|
27 | - } |
|
20 | + /** |
|
21 | + * @param array $props_n_values |
|
22 | + * @return EE_Event_Question_Group |
|
23 | + */ |
|
24 | + public static function new_instance_from_db($props_n_values = array()) |
|
25 | + { |
|
26 | + return new self($props_n_values, true); |
|
27 | + } |
|
28 | 28 | } |
@@ -14,98 +14,98 @@ |
||
14 | 14 | class EE_Registration_Payment extends EE_Base_Class |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * |
|
19 | - * @param array $props_n_values |
|
20 | - * @param string $timezone |
|
21 | - * @return EE_Registration_Payment |
|
22 | - */ |
|
23 | - public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
24 | - { |
|
25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @param array $props_n_values |
|
32 | - * @param string $timezone |
|
33 | - * @return EE_Registration_Payment |
|
34 | - */ |
|
35 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
36 | - { |
|
37 | - return new self($props_n_values, true, $timezone); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * registration_ID |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @return int |
|
46 | - */ |
|
47 | - public function registration_ID() |
|
48 | - { |
|
49 | - return $this->get('REG_ID'); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * payment_ID |
|
55 | - * |
|
56 | - * @access public |
|
57 | - * @return int |
|
58 | - */ |
|
59 | - public function payment_ID() |
|
60 | - { |
|
61 | - return $this->get('PAY_ID'); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * amount |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @return float |
|
70 | - */ |
|
71 | - public function amount() |
|
72 | - { |
|
73 | - return $this->get('RPY_amount'); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * amount |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @param float $amount |
|
82 | - */ |
|
83 | - public function set_amount($amount = 0.000) |
|
84 | - { |
|
85 | - $this->set('RPY_amount', $amount); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * registration |
|
91 | - * |
|
92 | - * @access public |
|
93 | - * @return \EE_Registration |
|
94 | - */ |
|
95 | - public function registration() |
|
96 | - { |
|
97 | - return $this->get_first_related('Registration'); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * payment |
|
103 | - * |
|
104 | - * @access public |
|
105 | - * @return \EE_Payment |
|
106 | - */ |
|
107 | - public function payment() |
|
108 | - { |
|
109 | - return $this->get_first_related('Payment'); |
|
110 | - } |
|
17 | + /** |
|
18 | + * |
|
19 | + * @param array $props_n_values |
|
20 | + * @param string $timezone |
|
21 | + * @return EE_Registration_Payment |
|
22 | + */ |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
24 | + { |
|
25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @param array $props_n_values |
|
32 | + * @param string $timezone |
|
33 | + * @return EE_Registration_Payment |
|
34 | + */ |
|
35 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
36 | + { |
|
37 | + return new self($props_n_values, true, $timezone); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * registration_ID |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @return int |
|
46 | + */ |
|
47 | + public function registration_ID() |
|
48 | + { |
|
49 | + return $this->get('REG_ID'); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * payment_ID |
|
55 | + * |
|
56 | + * @access public |
|
57 | + * @return int |
|
58 | + */ |
|
59 | + public function payment_ID() |
|
60 | + { |
|
61 | + return $this->get('PAY_ID'); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * amount |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @return float |
|
70 | + */ |
|
71 | + public function amount() |
|
72 | + { |
|
73 | + return $this->get('RPY_amount'); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * amount |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @param float $amount |
|
82 | + */ |
|
83 | + public function set_amount($amount = 0.000) |
|
84 | + { |
|
85 | + $this->set('RPY_amount', $amount); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * registration |
|
91 | + * |
|
92 | + * @access public |
|
93 | + * @return \EE_Registration |
|
94 | + */ |
|
95 | + public function registration() |
|
96 | + { |
|
97 | + return $this->get_first_related('Registration'); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * payment |
|
103 | + * |
|
104 | + * @access public |
|
105 | + * @return \EE_Payment |
|
106 | + */ |
|
107 | + public function payment() |
|
108 | + { |
|
109 | + return $this->get_first_related('Payment'); |
|
110 | + } |
|
111 | 111 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | class EE_Question_Group_Question extends EE_Base_Class |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * @param array $props_n_values |
|
11 | - * @return EE_Question_Group_Question|mixed |
|
12 | - */ |
|
13 | - public static function new_instance($props_n_values = array()) |
|
14 | - { |
|
15 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | - return $has_object ? $has_object : new self($props_n_values); |
|
17 | - } |
|
9 | + /** |
|
10 | + * @param array $props_n_values |
|
11 | + * @return EE_Question_Group_Question|mixed |
|
12 | + */ |
|
13 | + public static function new_instance($props_n_values = array()) |
|
14 | + { |
|
15 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
16 | + return $has_object ? $has_object : new self($props_n_values); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $props_n_values |
|
22 | - * @return EE_Question_Group_Question |
|
23 | - */ |
|
24 | - public static function new_instance_from_db($props_n_values = array()) |
|
25 | - { |
|
26 | - return new self($props_n_values, true); |
|
27 | - } |
|
20 | + /** |
|
21 | + * @param array $props_n_values |
|
22 | + * @return EE_Question_Group_Question |
|
23 | + */ |
|
24 | + public static function new_instance_from_db($props_n_values = array()) |
|
25 | + { |
|
26 | + return new self($props_n_values, true); |
|
27 | + } |
|
28 | 28 | } |
@@ -11,104 +11,104 @@ |
||
11 | 11 | class EE_State extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values |
|
16 | - * @return EE_State|mixed |
|
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 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @param array $props_n_values |
|
27 | - * @return EE_State |
|
28 | - */ |
|
29 | - public static function new_instance_from_db($props_n_values = array()) |
|
30 | - { |
|
31 | - return new self($props_n_values, true); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function country_iso() |
|
39 | - { |
|
40 | - return $this->get('CNT_ISO'); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function abbrev() |
|
48 | - { |
|
49 | - return $this->get('STA_abbrev'); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return bool |
|
55 | - */ |
|
56 | - public function active() |
|
57 | - { |
|
58 | - return $this->get('STA_active'); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function name() |
|
66 | - { |
|
67 | - return $this->get('STA_name'); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return EE_Country |
|
73 | - */ |
|
74 | - public function country() |
|
75 | - { |
|
76 | - return $this->get_first_related('Country'); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param $iso |
|
82 | - */ |
|
83 | - public function set_country_iso($iso) |
|
84 | - { |
|
85 | - $this->set('CNT_ISO', $iso); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @param $abbrev |
|
91 | - */ |
|
92 | - public function set_abbrev($abbrev) |
|
93 | - { |
|
94 | - $this->set('STA_abbrev', $abbrev); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @param $active |
|
100 | - */ |
|
101 | - public function set_active($active) |
|
102 | - { |
|
103 | - $this->set('STA_active', $active); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param $name |
|
109 | - */ |
|
110 | - public function set_name($name) |
|
111 | - { |
|
112 | - $this->set('STA_name', $name); |
|
113 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values |
|
16 | + * @return EE_State|mixed |
|
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 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @param array $props_n_values |
|
27 | + * @return EE_State |
|
28 | + */ |
|
29 | + public static function new_instance_from_db($props_n_values = array()) |
|
30 | + { |
|
31 | + return new self($props_n_values, true); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function country_iso() |
|
39 | + { |
|
40 | + return $this->get('CNT_ISO'); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function abbrev() |
|
48 | + { |
|
49 | + return $this->get('STA_abbrev'); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | + public function active() |
|
57 | + { |
|
58 | + return $this->get('STA_active'); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function name() |
|
66 | + { |
|
67 | + return $this->get('STA_name'); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return EE_Country |
|
73 | + */ |
|
74 | + public function country() |
|
75 | + { |
|
76 | + return $this->get_first_related('Country'); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param $iso |
|
82 | + */ |
|
83 | + public function set_country_iso($iso) |
|
84 | + { |
|
85 | + $this->set('CNT_ISO', $iso); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @param $abbrev |
|
91 | + */ |
|
92 | + public function set_abbrev($abbrev) |
|
93 | + { |
|
94 | + $this->set('STA_abbrev', $abbrev); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @param $active |
|
100 | + */ |
|
101 | + public function set_active($active) |
|
102 | + { |
|
103 | + $this->set('STA_active', $active); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param $name |
|
109 | + */ |
|
110 | + public function set_name($name) |
|
111 | + { |
|
112 | + $this->set('STA_name', $name); |
|
113 | + } |
|
114 | 114 | } |
@@ -12,25 +12,25 @@ |
||
12 | 12 | class EE_Event_Message_Template extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @param null $timezone |
|
18 | - * @return EE_Event_Message_Template|mixed |
|
19 | - */ |
|
20 | - public static function new_instance($props_n_values = array(), $timezone = null) |
|
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 null $timezone |
|
18 | + * @return EE_Event_Message_Template|mixed |
|
19 | + */ |
|
20 | + public static function new_instance($props_n_values = array(), $timezone = null) |
|
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 null $timezone |
|
30 | - * @return EE_Event_Message_Template |
|
31 | - */ |
|
32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
33 | - { |
|
34 | - return new self($props_n_values, true, $timezone); |
|
35 | - } |
|
27 | + /** |
|
28 | + * @param array $props_n_values |
|
29 | + * @param null $timezone |
|
30 | + * @return EE_Event_Message_Template |
|
31 | + */ |
|
32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
33 | + { |
|
34 | + return new self($props_n_values, true, $timezone); |
|
35 | + } |
|
36 | 36 | } |
@@ -11,217 +11,217 @@ |
||
11 | 11 | class EE_Change_Log extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values incoming values |
|
16 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | - * used.) |
|
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | - * date_format and the second value is the time format |
|
20 | - * @return EE_Change_Log |
|
21 | - * @throws EE_Error |
|
22 | - */ |
|
23 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
24 | - { |
|
25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @param array $props_n_values incoming values from the database |
|
32 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
33 | - * the website will be used. |
|
34 | - * @return EE_Change_Log |
|
35 | - */ |
|
36 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
37 | - { |
|
38 | - return new self($props_n_values, true, $timezone); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Gets message |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - * @throws EE_Error |
|
46 | - */ |
|
47 | - public function message() |
|
48 | - { |
|
49 | - return $this->get('LOG_message'); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Sets message |
|
54 | - * |
|
55 | - * @param mixed $message |
|
56 | - * @throws EE_Error |
|
57 | - */ |
|
58 | - public function set_message($message) |
|
59 | - { |
|
60 | - $this->set('LOG_message', $message); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets time |
|
65 | - * |
|
66 | - * @return string |
|
67 | - * @throws EE_Error |
|
68 | - */ |
|
69 | - public function time() |
|
70 | - { |
|
71 | - return $this->get('LOG_time'); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Sets time |
|
76 | - * |
|
77 | - * @param string $time |
|
78 | - * @throws EE_Error |
|
79 | - */ |
|
80 | - public function set_time($time) |
|
81 | - { |
|
82 | - $this->set('LOG_time', $time); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Gets log_type |
|
87 | - * |
|
88 | - * @return string |
|
89 | - * @throws EE_Error |
|
90 | - */ |
|
91 | - public function log_type() |
|
92 | - { |
|
93 | - return $this->get('LOG_type'); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Return the localized log type label. |
|
99 | - * |
|
100 | - * @return string |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - public function log_type_label() |
|
104 | - { |
|
105 | - return EEM_Change_Log::get_pretty_label_for_type($this->log_type()); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Sets log_type |
|
110 | - * |
|
111 | - * @param string $log_type |
|
112 | - * @throws EE_Error |
|
113 | - */ |
|
114 | - public function set_log_type($log_type) |
|
115 | - { |
|
116 | - $this->set('LOG_type', $log_type); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Gets type of the model object related to this log |
|
121 | - * |
|
122 | - * @return string |
|
123 | - * @throws EE_Error |
|
124 | - */ |
|
125 | - public function OBJ_type() |
|
126 | - { |
|
127 | - return $this->get('OBJ_type'); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Sets type |
|
132 | - * |
|
133 | - * @param string $type |
|
134 | - * @throws EE_Error |
|
135 | - */ |
|
136 | - public function set_OBJ_type($type) |
|
137 | - { |
|
138 | - $this->set('OBJ_type', $type); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Gets OBJ_ID (the ID of the item related to this log) |
|
143 | - * |
|
144 | - * @return mixed |
|
145 | - * @throws EE_Error |
|
146 | - */ |
|
147 | - public function OBJ_ID() |
|
148 | - { |
|
149 | - return $this->get('OBJ_ID'); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Sets OBJ_ID |
|
154 | - * |
|
155 | - * @param mixed $OBJ_ID |
|
156 | - * @throws EE_Error |
|
157 | - */ |
|
158 | - public function set_OBJ_ID($OBJ_ID) |
|
159 | - { |
|
160 | - $this->set('OBJ_ID', $OBJ_ID); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Gets wp_user |
|
165 | - * |
|
166 | - * @return int |
|
167 | - * @throws EE_Error |
|
168 | - */ |
|
169 | - public function wp_user() |
|
170 | - { |
|
171 | - return $this->get('LOG_wp_user'); |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Sets wp_user |
|
176 | - * |
|
177 | - * @param int $wp_user_id |
|
178 | - * @throws EE_Error |
|
179 | - */ |
|
180 | - public function set_wp_user($wp_user_id) |
|
181 | - { |
|
182 | - $this->set('LOG_wp_user', $wp_user_id); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Gets the model object attached to this log |
|
187 | - * |
|
188 | - * @return EE_Base_Class |
|
189 | - * @throws EE_Error |
|
190 | - */ |
|
191 | - public function object() |
|
192 | - { |
|
193 | - $model_name_of_related_obj = $this->OBJ_type(); |
|
194 | - $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
|
195 | - if (! $is_model_name) { |
|
196 | - return null; |
|
197 | - } else { |
|
198 | - return $this->get_first_related($model_name_of_related_obj); |
|
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using |
|
204 | - * _add_relation_to because you don't have to specify what type of model you're |
|
205 | - * associating it with |
|
206 | - * |
|
207 | - * @param EE_Base_Class $object |
|
208 | - * @param boolean $save |
|
209 | - * @return bool if $save=true, NULL is $save=false |
|
210 | - * @throws EE_Error |
|
211 | - */ |
|
212 | - public function set_object($object, $save = true) |
|
213 | - { |
|
214 | - if ($object instanceof EE_Base_Class) { |
|
215 | - $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
|
216 | - $this->set_OBJ_ID($object->ID()); |
|
217 | - } else { |
|
218 | - $this->set_OBJ_type(null); |
|
219 | - $this->set_OBJ_ID(null); |
|
220 | - } |
|
221 | - if ($save) { |
|
222 | - return $this->save(); |
|
223 | - } else { |
|
224 | - return null; |
|
225 | - } |
|
226 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values incoming values |
|
16 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | + * used.) |
|
18 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | + * date_format and the second value is the time format |
|
20 | + * @return EE_Change_Log |
|
21 | + * @throws EE_Error |
|
22 | + */ |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
24 | + { |
|
25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @param array $props_n_values incoming values from the database |
|
32 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
33 | + * the website will be used. |
|
34 | + * @return EE_Change_Log |
|
35 | + */ |
|
36 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
37 | + { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Gets message |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + * @throws EE_Error |
|
46 | + */ |
|
47 | + public function message() |
|
48 | + { |
|
49 | + return $this->get('LOG_message'); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Sets message |
|
54 | + * |
|
55 | + * @param mixed $message |
|
56 | + * @throws EE_Error |
|
57 | + */ |
|
58 | + public function set_message($message) |
|
59 | + { |
|
60 | + $this->set('LOG_message', $message); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets time |
|
65 | + * |
|
66 | + * @return string |
|
67 | + * @throws EE_Error |
|
68 | + */ |
|
69 | + public function time() |
|
70 | + { |
|
71 | + return $this->get('LOG_time'); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Sets time |
|
76 | + * |
|
77 | + * @param string $time |
|
78 | + * @throws EE_Error |
|
79 | + */ |
|
80 | + public function set_time($time) |
|
81 | + { |
|
82 | + $this->set('LOG_time', $time); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Gets log_type |
|
87 | + * |
|
88 | + * @return string |
|
89 | + * @throws EE_Error |
|
90 | + */ |
|
91 | + public function log_type() |
|
92 | + { |
|
93 | + return $this->get('LOG_type'); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Return the localized log type label. |
|
99 | + * |
|
100 | + * @return string |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + public function log_type_label() |
|
104 | + { |
|
105 | + return EEM_Change_Log::get_pretty_label_for_type($this->log_type()); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Sets log_type |
|
110 | + * |
|
111 | + * @param string $log_type |
|
112 | + * @throws EE_Error |
|
113 | + */ |
|
114 | + public function set_log_type($log_type) |
|
115 | + { |
|
116 | + $this->set('LOG_type', $log_type); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Gets type of the model object related to this log |
|
121 | + * |
|
122 | + * @return string |
|
123 | + * @throws EE_Error |
|
124 | + */ |
|
125 | + public function OBJ_type() |
|
126 | + { |
|
127 | + return $this->get('OBJ_type'); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Sets type |
|
132 | + * |
|
133 | + * @param string $type |
|
134 | + * @throws EE_Error |
|
135 | + */ |
|
136 | + public function set_OBJ_type($type) |
|
137 | + { |
|
138 | + $this->set('OBJ_type', $type); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Gets OBJ_ID (the ID of the item related to this log) |
|
143 | + * |
|
144 | + * @return mixed |
|
145 | + * @throws EE_Error |
|
146 | + */ |
|
147 | + public function OBJ_ID() |
|
148 | + { |
|
149 | + return $this->get('OBJ_ID'); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Sets OBJ_ID |
|
154 | + * |
|
155 | + * @param mixed $OBJ_ID |
|
156 | + * @throws EE_Error |
|
157 | + */ |
|
158 | + public function set_OBJ_ID($OBJ_ID) |
|
159 | + { |
|
160 | + $this->set('OBJ_ID', $OBJ_ID); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Gets wp_user |
|
165 | + * |
|
166 | + * @return int |
|
167 | + * @throws EE_Error |
|
168 | + */ |
|
169 | + public function wp_user() |
|
170 | + { |
|
171 | + return $this->get('LOG_wp_user'); |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Sets wp_user |
|
176 | + * |
|
177 | + * @param int $wp_user_id |
|
178 | + * @throws EE_Error |
|
179 | + */ |
|
180 | + public function set_wp_user($wp_user_id) |
|
181 | + { |
|
182 | + $this->set('LOG_wp_user', $wp_user_id); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Gets the model object attached to this log |
|
187 | + * |
|
188 | + * @return EE_Base_Class |
|
189 | + * @throws EE_Error |
|
190 | + */ |
|
191 | + public function object() |
|
192 | + { |
|
193 | + $model_name_of_related_obj = $this->OBJ_type(); |
|
194 | + $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
|
195 | + if (! $is_model_name) { |
|
196 | + return null; |
|
197 | + } else { |
|
198 | + return $this->get_first_related($model_name_of_related_obj); |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using |
|
204 | + * _add_relation_to because you don't have to specify what type of model you're |
|
205 | + * associating it with |
|
206 | + * |
|
207 | + * @param EE_Base_Class $object |
|
208 | + * @param boolean $save |
|
209 | + * @return bool if $save=true, NULL is $save=false |
|
210 | + * @throws EE_Error |
|
211 | + */ |
|
212 | + public function set_object($object, $save = true) |
|
213 | + { |
|
214 | + if ($object instanceof EE_Base_Class) { |
|
215 | + $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
|
216 | + $this->set_OBJ_ID($object->ID()); |
|
217 | + } else { |
|
218 | + $this->set_OBJ_type(null); |
|
219 | + $this->set_OBJ_ID(null); |
|
220 | + } |
|
221 | + if ($save) { |
|
222 | + return $this->save(); |
|
223 | + } else { |
|
224 | + return null; |
|
225 | + } |
|
226 | + } |
|
227 | 227 | } |
@@ -192,7 +192,7 @@ |
||
192 | 192 | { |
193 | 193 | $model_name_of_related_obj = $this->OBJ_type(); |
194 | 194 | $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
195 | - if (! $is_model_name) { |
|
195 | + if ( ! $is_model_name) { |
|
196 | 196 | return null; |
197 | 197 | } else { |
198 | 198 | return $this->get_first_related($model_name_of_related_obj); |