@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function __construct() { |
44 | 44 | // construct request stack and run middleware apps as soon as all WP plugins are loaded |
45 | - add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 ); |
|
45 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
46 | 46 | // set framework for the rest of EE to hook into when loading |
47 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 ); |
|
48 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 ); |
|
49 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 ); |
|
50 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
51 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 ); |
|
47 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
48 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
49 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
50 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
51 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | new EE_Load_Espresso_Core() |
66 | 66 | ); |
67 | 67 | $this->_request_stack->handle_request( |
68 | - new EE_Request( $_GET, $_POST, $_COOKIE ), |
|
68 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
69 | 69 | new EE_Response() |
70 | 70 | ); |
71 | 71 | $this->_request_stack->handle_response(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function load_autoloader() { |
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' ); |
|
81 | + espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php'); |
|
82 | 82 | EEH_Autoloader::instance(); |
83 | 83 | } |
84 | 84 | |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function set_autoloaders_for_required_files() { |
91 | 91 | // load interfaces |
92 | - espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' ); |
|
93 | - espresso_load_required( 'InterminableInterface', EE_CORE . 'interfaces' . DS . 'InterminableInterface.php' ); |
|
94 | - espresso_load_required( 'ResettableInterface', EE_CORE . 'interfaces' . DS . 'ResettableInterface.php' ); |
|
92 | + espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php'); |
|
93 | + espresso_load_required('InterminableInterface', EE_CORE.'interfaces'.DS.'InterminableInterface.php'); |
|
94 | + espresso_load_required('ResettableInterface', EE_CORE.'interfaces'.DS.'ResettableInterface.php'); |
|
95 | 95 | // load helpers |
96 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
96 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
97 | 97 | // load request stack |
98 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS ); |
|
98 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
99 | 99 | // load middleware |
100 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS ); |
|
100 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | // load middleware onto stack : FILO (First In Last Out) |
121 | - foreach ( (array)$stack_apps as $stack_app ) { |
|
121 | + foreach ((array) $stack_apps as $stack_app) { |
|
122 | 122 | //$request_stack_builder->push( $stack_app ); |
123 | - $request_stack_builder->unshift( $stack_app ); |
|
123 | + $request_stack_builder->unshift($stack_app); |
|
124 | 124 | } |
125 | 125 | return apply_filters( |
126 | 126 | 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * no other logic should be performed at this point |
138 | 138 | */ |
139 | 139 | public static function load_espresso_addons() { |
140 | - do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' ); |
|
140 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * we can determine if anything needs activating or upgrading |
150 | 150 | */ |
151 | 151 | public static function detect_activations_or_upgrades() { |
152 | - do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' ); |
|
152 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * we can load and set all of the system configurations |
162 | 162 | */ |
163 | 163 | public static function load_core_configuration() { |
164 | - do_action( 'AHEE__EE_Bootstrap__load_core_configuration' ); |
|
164 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * so that they are ready to be used throughout the system |
174 | 174 | */ |
175 | 175 | public static function register_shortcodes_modules_and_widgets() { |
176 | - do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' ); |
|
176 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * so let the fun begin... |
186 | 186 | */ |
187 | 187 | public static function brew_espresso() { |
188 | - do_action( 'AHEE__EE_Bootstrap__brew_espresso' ); |
|
188 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php use EventEspresso\core\interfaces\InterminableInterface; |
|
1 | +<?php |
|
2 | 2 | |
3 | 3 | defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
4 | 4 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use ReflectionException; |
8 | 8 | |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -25,53 +25,53 @@ discard block |
||
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param Exception $exception |
|
30 | - * @throws Exception |
|
31 | - */ |
|
32 | - public function __construct(Exception $exception) |
|
33 | - { |
|
34 | - if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
35 | - $this->displayException($exception); |
|
36 | - } else { |
|
37 | - throw $exception; |
|
38 | - } |
|
39 | - } |
|
28 | + /** |
|
29 | + * @param Exception $exception |
|
30 | + * @throws Exception |
|
31 | + */ |
|
32 | + public function __construct(Exception $exception) |
|
33 | + { |
|
34 | + if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
35 | + $this->displayException($exception); |
|
36 | + } else { |
|
37 | + throw $exception; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @access protected |
|
45 | - * @param Exception $exception |
|
46 | - * @throws ReflectionException |
|
47 | - */ |
|
48 | - protected function displayException(Exception $exception) |
|
49 | - { |
|
50 | - $error_code = ''; |
|
51 | - $trace_details = ''; |
|
52 | - $time = time(); |
|
53 | - $trace = $exception->getTrace(); |
|
54 | - // get separate user and developer messages if they exist |
|
55 | - $msg = explode('||', $exception->getMessage()); |
|
56 | - $user_msg = $msg[0]; |
|
57 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
58 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
59 | - // start gathering output |
|
60 | - $output = $this->exceptionStyles(); |
|
61 | - $output .= ' |
|
43 | + /** |
|
44 | + * @access protected |
|
45 | + * @param Exception $exception |
|
46 | + * @throws ReflectionException |
|
47 | + */ |
|
48 | + protected function displayException(Exception $exception) |
|
49 | + { |
|
50 | + $error_code = ''; |
|
51 | + $trace_details = ''; |
|
52 | + $time = time(); |
|
53 | + $trace = $exception->getTrace(); |
|
54 | + // get separate user and developer messages if they exist |
|
55 | + $msg = explode('||', $exception->getMessage()); |
|
56 | + $user_msg = $msg[0]; |
|
57 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
58 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
59 | + // start gathering output |
|
60 | + $output = $this->exceptionStyles(); |
|
61 | + $output .= ' |
|
62 | 62 | <div id="ee-error-message" class="error">'; |
63 | - if (! WP_DEBUG) { |
|
64 | - $output .= ' |
|
63 | + if (! WP_DEBUG) { |
|
64 | + $output .= ' |
|
65 | 65 | <p>'; |
66 | - } |
|
67 | - // process trace info |
|
68 | - if (empty($trace)) { |
|
69 | - $trace_details .= __( |
|
70 | - 'Sorry, but no trace information was available for this exception.', |
|
71 | - 'event_espresso' |
|
72 | - ); |
|
73 | - } else { |
|
74 | - $trace_details .= ' |
|
66 | + } |
|
67 | + // process trace info |
|
68 | + if (empty($trace)) { |
|
69 | + $trace_details .= __( |
|
70 | + 'Sorry, but no trace information was available for this exception.', |
|
71 | + 'event_espresso' |
|
72 | + ); |
|
73 | + } else { |
|
74 | + $trace_details .= ' |
|
75 | 75 | <div id="ee-trace-details"> |
76 | 76 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
77 | 77 | <tr> |
@@ -79,255 +79,255 @@ discard block |
||
79 | 79 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
80 | 80 | <th scope="col" align="left" style="width:40%;">File</th> |
81 | 81 | <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )', |
82 | - 'event_espresso') . '</th> |
|
82 | + 'event_espresso') . '</th> |
|
83 | 83 | </tr>'; |
84 | - $last_on_stack = count($trace) - 1; |
|
85 | - // reverse array so that stack is in proper chronological order |
|
86 | - $sorted_trace = array_reverse($trace); |
|
87 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
88 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
89 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
90 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
91 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
92 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
93 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
94 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
95 | - $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
96 | - if (empty($file) && ! empty($class)) { |
|
97 | - $a = new ReflectionClass($class); |
|
98 | - $file = $a->getFileName(); |
|
99 | - if (empty($line) && ! empty($function)) { |
|
100 | - $b = new \ReflectionMethod($class, $function); |
|
101 | - $line = $b->getStartLine(); |
|
102 | - } |
|
103 | - } |
|
104 | - if ($nmbr === $last_on_stack) { |
|
105 | - $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | - $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | - $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | - } |
|
109 | - $file = \EEH_File::standardise_directory_separators($file); |
|
110 | - $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | - $line = ! empty($line) ? $line : ' '; |
|
112 | - $file = ! empty($file) ? $file : ' '; |
|
113 | - $class_display = ! empty($class) ? $class : ''; |
|
114 | - $type = ! empty($type) ? $type : ''; |
|
115 | - $function = ! empty($function) ? $function : ''; |
|
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | - $trace_details .= ' |
|
84 | + $last_on_stack = count($trace) - 1; |
|
85 | + // reverse array so that stack is in proper chronological order |
|
86 | + $sorted_trace = array_reverse($trace); |
|
87 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
88 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
89 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
90 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
91 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
92 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
93 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
94 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
95 | + $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
96 | + if (empty($file) && ! empty($class)) { |
|
97 | + $a = new ReflectionClass($class); |
|
98 | + $file = $a->getFileName(); |
|
99 | + if (empty($line) && ! empty($function)) { |
|
100 | + $b = new \ReflectionMethod($class, $function); |
|
101 | + $line = $b->getStartLine(); |
|
102 | + } |
|
103 | + } |
|
104 | + if ($nmbr === $last_on_stack) { |
|
105 | + $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | + $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | + $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | + } |
|
109 | + $file = \EEH_File::standardise_directory_separators($file); |
|
110 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | + $line = ! empty($line) ? $line : ' '; |
|
112 | + $file = ! empty($file) ? $file : ' '; |
|
113 | + $class_display = ! empty($class) ? $class : ''; |
|
114 | + $type = ! empty($type) ? $type : ''; |
|
115 | + $function = ! empty($function) ? $function : ''; |
|
116 | + $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | + $trace_details .= ' |
|
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
120 | - . $zebra |
|
121 | - . '">' |
|
122 | - . $nmbr |
|
123 | - . '</td> |
|
120 | + . $zebra |
|
121 | + . '">' |
|
122 | + . $nmbr |
|
123 | + . '</td> |
|
124 | 124 | <td align="right" valign="top" class="' |
125 | - . $zebra |
|
126 | - . '">' |
|
127 | - . $line |
|
128 | - . '</td> |
|
125 | + . $zebra |
|
126 | + . '">' |
|
127 | + . $line |
|
128 | + . '</td> |
|
129 | 129 | <td align="left" valign="top" class="' |
130 | - . $zebra |
|
131 | - . '">' |
|
132 | - . $file |
|
133 | - . '</td> |
|
130 | + . $zebra |
|
131 | + . '">' |
|
132 | + . $file |
|
133 | + . '</td> |
|
134 | 134 | <td align="left" valign="top" class="' |
135 | - . $zebra |
|
136 | - . '">' |
|
137 | - . $class_display |
|
138 | - . $type |
|
139 | - . $function |
|
140 | - . $args |
|
141 | - . '</td> |
|
135 | + . $zebra |
|
136 | + . '">' |
|
137 | + . $class_display |
|
138 | + . $type |
|
139 | + . $function |
|
140 | + . $args |
|
141 | + . '</td> |
|
142 | 142 | </tr>'; |
143 | - } |
|
144 | - $trace_details .= ' |
|
143 | + } |
|
144 | + $trace_details .= ' |
|
145 | 145 | </table> |
146 | 146 | </div>'; |
147 | - } |
|
148 | - $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | - // add generic non-identifying messages for non-privileged users |
|
150 | - if (! WP_DEBUG) { |
|
151 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | - . trim($msg) |
|
153 | - . '</span> <sup>' |
|
154 | - . $code |
|
155 | - . '</sup><br />'; |
|
156 | - } else { |
|
157 | - // or helpful developer messages if debugging is on |
|
158 | - $output .= ' |
|
147 | + } |
|
148 | + $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | + // add generic non-identifying messages for non-privileged users |
|
150 | + if (! WP_DEBUG) { |
|
151 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | + . trim($msg) |
|
153 | + . '</span> <sup>' |
|
154 | + . $code |
|
155 | + . '</sup><br />'; |
|
156 | + } else { |
|
157 | + // or helpful developer messages if debugging is on |
|
158 | + $output .= ' |
|
159 | 159 | <div class="ee-error-dev-msg-dv"> |
160 | 160 | <p class="ee-error-dev-msg-pg"> |
161 | 161 | ' |
162 | - . sprintf( |
|
163 | - __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | - '<strong class="ee-error-dev-msg-str">', |
|
165 | - get_class($exception), |
|
166 | - '</strong> <span>', |
|
167 | - $code . '</span>' |
|
168 | - ) |
|
169 | - . '<br /> |
|
162 | + . sprintf( |
|
163 | + __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | + '<strong class="ee-error-dev-msg-str">', |
|
165 | + get_class($exception), |
|
166 | + '</strong> <span>', |
|
167 | + $code . '</span>' |
|
168 | + ) |
|
169 | + . '<br /> |
|
170 | 170 | <span class="big-text">"' |
171 | - . trim($msg) |
|
172 | - . '"</span><br/> |
|
171 | + . trim($msg) |
|
172 | + . '"</span><br/> |
|
173 | 173 | <a id="display-ee-error-trace-1' |
174 | - . $time |
|
175 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | - . $time |
|
177 | - . '"> |
|
174 | + . $time |
|
175 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | + . $time |
|
177 | + . '"> |
|
178 | 178 | ' |
179 | - . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | - . ' |
|
179 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | + . ' |
|
181 | 181 | </a><br /> |
182 | 182 | ' |
183 | - . $exception->getFile() |
|
184 | - . sprintf( |
|
185 | - __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | - ' <span class="small-text lt-grey-text">', |
|
187 | - $exception->getLine(), |
|
188 | - '</span>' |
|
189 | - ) |
|
190 | - . ' |
|
183 | + . $exception->getFile() |
|
184 | + . sprintf( |
|
185 | + __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | + ' <span class="small-text lt-grey-text">', |
|
187 | + $exception->getLine(), |
|
188 | + '</span>' |
|
189 | + ) |
|
190 | + . ' |
|
191 | 191 | </p> |
192 | 192 | <div id="ee-error-trace-1' |
193 | - . $time |
|
194 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
193 | + . $time |
|
194 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
195 | 195 | ' |
196 | - . $trace_details; |
|
197 | - if (! empty($class)) { |
|
198 | - $output .= ' |
|
196 | + . $trace_details; |
|
197 | + if (! empty($class)) { |
|
198 | + $output .= ' |
|
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | 201 | <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
202 | - $a = new ReflectionClass($class); |
|
203 | - $output .= ' |
|
202 | + $a = new ReflectionClass($class); |
|
203 | + $output .= ' |
|
204 | 204 | <pre>' . $a . '</pre> |
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | - } |
|
208 | - $output .= ' |
|
207 | + } |
|
208 | + $output .= ' |
|
209 | 209 | </div> |
210 | 210 | </div> |
211 | 211 | <br />'; |
212 | - } |
|
213 | - // remove last linebreak |
|
214 | - $output = substr($output, 0, -6); |
|
215 | - if (! WP_DEBUG) { |
|
216 | - $output .= ' |
|
212 | + } |
|
213 | + // remove last linebreak |
|
214 | + $output = substr($output, 0, -6); |
|
215 | + if (! WP_DEBUG) { |
|
216 | + $output .= ' |
|
217 | 217 | </p>'; |
218 | - } |
|
219 | - $output .= ' |
|
218 | + } |
|
219 | + $output .= ' |
|
220 | 220 | </div>'; |
221 | - $output .= $this->printScripts(true); |
|
222 | - if (defined('DOING_AJAX')) { |
|
223 | - echo wp_json_encode(array('error' => $output)); |
|
224 | - exit(); |
|
225 | - } |
|
226 | - echo $output; |
|
227 | - } |
|
221 | + $output .= $this->printScripts(true); |
|
222 | + if (defined('DOING_AJAX')) { |
|
223 | + echo wp_json_encode(array('error' => $output)); |
|
224 | + exit(); |
|
225 | + } |
|
226 | + echo $output; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | 230 | |
231 | - /** |
|
232 | - * generate string from exception trace args |
|
233 | - * |
|
234 | - * @param array $arguments |
|
235 | - * @param int $indent |
|
236 | - * @param bool $array |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | - { |
|
241 | - $args = array(); |
|
242 | - $args_count = count($arguments); |
|
243 | - if ($args_count > 2) { |
|
244 | - $indent++; |
|
245 | - $args[] = '<br />'; |
|
246 | - } |
|
247 | - $x = 0; |
|
248 | - foreach ($arguments as $arg) { |
|
249 | - $x++; |
|
250 | - for ($i = 0; $i < $indent; $i++) { |
|
251 | - $args[] = ' '; |
|
252 | - } |
|
253 | - if (is_string($arg)) { |
|
254 | - if (! $array && strlen($arg) > 75) { |
|
255 | - $args[] = '<br />'; |
|
256 | - for ($i = 0; $i <= $indent; $i++) { |
|
257 | - $args[] = ' '; |
|
258 | - } |
|
259 | - $args[] = "'" . $arg . "'<br />"; |
|
260 | - } else { |
|
261 | - $args[] = " '" . $arg . "'"; |
|
262 | - } |
|
263 | - } elseif (is_array($arg)) { |
|
264 | - $arg_count = count($arg); |
|
265 | - if ($arg_count > 2) { |
|
266 | - $indent++; |
|
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | - $indent--; |
|
269 | - } else if ($arg_count === 0) { |
|
270 | - $args[] = ' array()'; |
|
271 | - } else { |
|
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | - } |
|
274 | - } elseif ($arg === null) { |
|
275 | - $args[] = ' null'; |
|
276 | - } elseif (is_bool($arg)) { |
|
277 | - $args[] = $arg ? ' true' : ' false'; |
|
278 | - } elseif (is_object($arg)) { |
|
279 | - $args[] = get_class($arg); |
|
280 | - } elseif (is_resource($arg)) { |
|
281 | - $args[] = get_resource_type($arg); |
|
282 | - } else { |
|
283 | - $args[] = $arg; |
|
284 | - } |
|
285 | - if ($x === $args_count) { |
|
286 | - if ($args_count > 2) { |
|
287 | - $args[] = '<br />'; |
|
288 | - $indent--; |
|
289 | - for ($i = 1; $i < $indent; $i++) { |
|
290 | - $args[] = ' '; |
|
291 | - } |
|
292 | - } |
|
293 | - } else { |
|
294 | - $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | - } |
|
296 | - } |
|
297 | - return implode('', $args); |
|
298 | - } |
|
231 | + /** |
|
232 | + * generate string from exception trace args |
|
233 | + * |
|
234 | + * @param array $arguments |
|
235 | + * @param int $indent |
|
236 | + * @param bool $array |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | + { |
|
241 | + $args = array(); |
|
242 | + $args_count = count($arguments); |
|
243 | + if ($args_count > 2) { |
|
244 | + $indent++; |
|
245 | + $args[] = '<br />'; |
|
246 | + } |
|
247 | + $x = 0; |
|
248 | + foreach ($arguments as $arg) { |
|
249 | + $x++; |
|
250 | + for ($i = 0; $i < $indent; $i++) { |
|
251 | + $args[] = ' '; |
|
252 | + } |
|
253 | + if (is_string($arg)) { |
|
254 | + if (! $array && strlen($arg) > 75) { |
|
255 | + $args[] = '<br />'; |
|
256 | + for ($i = 0; $i <= $indent; $i++) { |
|
257 | + $args[] = ' '; |
|
258 | + } |
|
259 | + $args[] = "'" . $arg . "'<br />"; |
|
260 | + } else { |
|
261 | + $args[] = " '" . $arg . "'"; |
|
262 | + } |
|
263 | + } elseif (is_array($arg)) { |
|
264 | + $arg_count = count($arg); |
|
265 | + if ($arg_count > 2) { |
|
266 | + $indent++; |
|
267 | + $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | + $indent--; |
|
269 | + } else if ($arg_count === 0) { |
|
270 | + $args[] = ' array()'; |
|
271 | + } else { |
|
272 | + $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | + } |
|
274 | + } elseif ($arg === null) { |
|
275 | + $args[] = ' null'; |
|
276 | + } elseif (is_bool($arg)) { |
|
277 | + $args[] = $arg ? ' true' : ' false'; |
|
278 | + } elseif (is_object($arg)) { |
|
279 | + $args[] = get_class($arg); |
|
280 | + } elseif (is_resource($arg)) { |
|
281 | + $args[] = get_resource_type($arg); |
|
282 | + } else { |
|
283 | + $args[] = $arg; |
|
284 | + } |
|
285 | + if ($x === $args_count) { |
|
286 | + if ($args_count > 2) { |
|
287 | + $args[] = '<br />'; |
|
288 | + $indent--; |
|
289 | + for ($i = 1; $i < $indent; $i++) { |
|
290 | + $args[] = ' '; |
|
291 | + } |
|
292 | + } |
|
293 | + } else { |
|
294 | + $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | + } |
|
296 | + } |
|
297 | + return implode('', $args); |
|
298 | + } |
|
299 | 299 | |
300 | 300 | |
301 | 301 | |
302 | - /** |
|
303 | - * create error code from filepath, function name, |
|
304 | - * and line number where exception or error was thrown |
|
305 | - * |
|
306 | - * @access protected |
|
307 | - * @param string $file |
|
308 | - * @param string $func |
|
309 | - * @param string $line |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - protected function generate_error_code($file = '', $func = '', $line = '') |
|
313 | - { |
|
314 | - $file_bits = explode('.', basename($file)); |
|
315 | - $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
316 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
318 | - return $error_code; |
|
319 | - } |
|
302 | + /** |
|
303 | + * create error code from filepath, function name, |
|
304 | + * and line number where exception or error was thrown |
|
305 | + * |
|
306 | + * @access protected |
|
307 | + * @param string $file |
|
308 | + * @param string $func |
|
309 | + * @param string $line |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + protected function generate_error_code($file = '', $func = '', $line = '') |
|
313 | + { |
|
314 | + $file_bits = explode('.', basename($file)); |
|
315 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
316 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
318 | + return $error_code; |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - /** |
|
324 | - * _exception_styles |
|
325 | - * |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - private function exceptionStyles() |
|
329 | - { |
|
330 | - return ' |
|
323 | + /** |
|
324 | + * _exception_styles |
|
325 | + * |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + private function exceptionStyles() |
|
329 | + { |
|
330 | + return ' |
|
331 | 331 | <style type="text/css"> |
332 | 332 | #ee-error-message { |
333 | 333 | max-width:90% !important; |
@@ -384,30 +384,30 @@ discard block |
||
384 | 384 | color: #999; |
385 | 385 | } |
386 | 386 | </style>'; |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | 389 | |
390 | 390 | |
391 | - /** |
|
392 | - * _print_scripts |
|
393 | - * |
|
394 | - * @param bool $force_print |
|
395 | - * @return string |
|
396 | - */ |
|
397 | - private function printScripts($force_print = false) |
|
398 | - { |
|
399 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
401 | - return ''; |
|
402 | - } |
|
403 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
404 | - wp_enqueue_style('espresso_default'); |
|
405 | - wp_enqueue_style('espresso_custom_css'); |
|
406 | - wp_enqueue_script( 'ee_error_js' ); |
|
391 | + /** |
|
392 | + * _print_scripts |
|
393 | + * |
|
394 | + * @param bool $force_print |
|
395 | + * @return string |
|
396 | + */ |
|
397 | + private function printScripts($force_print = false) |
|
398 | + { |
|
399 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
401 | + return ''; |
|
402 | + } |
|
403 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
404 | + wp_enqueue_style('espresso_default'); |
|
405 | + wp_enqueue_style('espresso_custom_css'); |
|
406 | + wp_enqueue_script( 'ee_error_js' ); |
|
407 | 407 | wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
408 | - } |
|
409 | - } else { |
|
410 | - return ' |
|
408 | + } |
|
409 | + } else { |
|
410 | + return ' |
|
411 | 411 | <script> |
412 | 412 | /* <![CDATA[ */ |
413 | 413 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
418 | 418 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
419 | 419 | '; |
420 | - } |
|
421 | - return ''; |
|
422 | - } |
|
420 | + } |
|
421 | + return ''; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | |
425 | 425 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use ReflectionClass; |
7 | 7 | use ReflectionException; |
8 | 8 | |
9 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('No direct script access allowed'); |
11 | 11 | } |
12 | 12 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $output = $this->exceptionStyles(); |
61 | 61 | $output .= ' |
62 | 62 | <div id="ee-error-message" class="error">'; |
63 | - if (! WP_DEBUG) { |
|
63 | + if ( ! WP_DEBUG) { |
|
64 | 64 | $output .= ' |
65 | 65 | <p>'; |
66 | 66 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | <th scope="col" align="right" style="width:2.5%;">#</th> |
79 | 79 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
80 | 80 | <th scope="col" align="left" style="width:40%;">File</th> |
81 | - <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )', |
|
82 | - 'event_espresso') . '</th> |
|
81 | + <th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__('Method( arguments )', |
|
82 | + 'event_espresso').'</th> |
|
83 | 83 | </tr>'; |
84 | 84 | $last_on_stack = count($trace) - 1; |
85 | 85 | // reverse array so that stack is in proper chronological order |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $type = isset($trace['type']) ? $trace['type'] : ''; |
91 | 91 | $function = isset($trace['function']) ? $trace['function'] : ''; |
92 | 92 | $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
93 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
93 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
94 | 94 | $line = isset($trace['line']) ? $trace['line'] : ''; |
95 | 95 | $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
96 | 96 | if (empty($file) && ! empty($class)) { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $class_display = ! empty($class) ? $class : ''; |
114 | 114 | $type = ! empty($type) ? $type : ''; |
115 | 115 | $function = ! empty($function) ? $function : ''; |
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
116 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
117 | 117 | $trace_details .= ' |
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $code = $exception->getCode() ? $exception->getCode() : $error_code; |
149 | 149 | // add generic non-identifying messages for non-privileged users |
150 | - if (! WP_DEBUG) { |
|
150 | + if ( ! WP_DEBUG) { |
|
151 | 151 | $output .= '<span class="ee-error-user-msg-spn">' |
152 | 152 | . trim($msg) |
153 | 153 | . '</span> <sup>' |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | '<strong class="ee-error-dev-msg-str">', |
165 | 165 | get_class($exception), |
166 | 166 | '</strong> <span>', |
167 | - $code . '</span>' |
|
167 | + $code.'</span>' |
|
168 | 168 | ) |
169 | 169 | . '<br /> |
170 | 170 | <span class="big-text">"' |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
195 | 195 | ' |
196 | 196 | . $trace_details; |
197 | - if (! empty($class)) { |
|
197 | + if ( ! empty($class)) { |
|
198 | 198 | $output .= ' |
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | - <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
|
201 | + <h3>' . __('Class Details', 'event_espresso').'</h3>'; |
|
202 | 202 | $a = new ReflectionClass($class); |
203 | 203 | $output .= ' |
204 | - <pre>' . $a . '</pre> |
|
204 | + <pre>' . $a.'</pre> |
|
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | // remove last linebreak |
214 | 214 | $output = substr($output, 0, -6); |
215 | - if (! WP_DEBUG) { |
|
215 | + if ( ! WP_DEBUG) { |
|
216 | 216 | $output .= ' |
217 | 217 | </p>'; |
218 | 218 | } |
@@ -251,25 +251,25 @@ discard block |
||
251 | 251 | $args[] = ' '; |
252 | 252 | } |
253 | 253 | if (is_string($arg)) { |
254 | - if (! $array && strlen($arg) > 75) { |
|
254 | + if ( ! $array && strlen($arg) > 75) { |
|
255 | 255 | $args[] = '<br />'; |
256 | 256 | for ($i = 0; $i <= $indent; $i++) { |
257 | 257 | $args[] = ' '; |
258 | 258 | } |
259 | - $args[] = "'" . $arg . "'<br />"; |
|
259 | + $args[] = "'".$arg."'<br />"; |
|
260 | 260 | } else { |
261 | - $args[] = " '" . $arg . "'"; |
|
261 | + $args[] = " '".$arg."'"; |
|
262 | 262 | } |
263 | 263 | } elseif (is_array($arg)) { |
264 | 264 | $arg_count = count($arg); |
265 | 265 | if ($arg_count > 2) { |
266 | 266 | $indent++; |
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
267 | + $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')'; |
|
268 | 268 | $indent--; |
269 | 269 | } else if ($arg_count === 0) { |
270 | 270 | $args[] = ' array()'; |
271 | 271 | } else { |
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
272 | + $args[] = ' array( '.$this->_convert_args_to_string($arg).' )'; |
|
273 | 273 | } |
274 | 274 | } elseif ($arg === null) { |
275 | 275 | $args[] = ' null'; |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | { |
314 | 314 | $file_bits = explode('.', basename($file)); |
315 | 315 | $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
316 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
316 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
317 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
318 | 318 | return $error_code; |
319 | 319 | } |
320 | 320 | |
@@ -396,26 +396,26 @@ discard block |
||
396 | 396 | */ |
397 | 397 | private function printScripts($force_print = false) |
398 | 398 | { |
399 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
399 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | 400 | if (wp_script_is('ee_error_js', 'enqueued')) { |
401 | 401 | return ''; |
402 | 402 | } |
403 | 403 | if (wp_script_is('ee_error_js', 'registered')) { |
404 | 404 | wp_enqueue_style('espresso_default'); |
405 | 405 | wp_enqueue_style('espresso_custom_css'); |
406 | - wp_enqueue_script( 'ee_error_js' ); |
|
407 | - wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
|
406 | + wp_enqueue_script('ee_error_js'); |
|
407 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
408 | 408 | } |
409 | 409 | } else { |
410 | 410 | return ' |
411 | 411 | <script> |
412 | 412 | /* <![CDATA[ */ |
413 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
413 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
414 | 414 | /* ]]> */ |
415 | 415 | </script> |
416 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
417 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
418 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
416 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
417 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
418 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
419 | 419 | '; |
420 | 420 | } |
421 | 421 | return ''; |
@@ -151,7 +151,7 @@ |
||
151 | 151 | * This provides a count of events using this custom template |
152 | 152 | * |
153 | 153 | * @param EE_Message_Template_Group $item message_template group data |
154 | - * @return string column output |
|
154 | + * @return integer column output |
|
155 | 155 | */ |
156 | 156 | public function column_events($item) |
157 | 157 | { |
@@ -12,246 +12,246 @@ |
||
12 | 12 | class Custom_Messages_Template_List_Table extends Messages_Template_List_Table |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Setup initial data. |
|
17 | - */ |
|
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | - $this->_per_page, |
|
22 | - $this->_view, |
|
23 | - false, |
|
24 | - false, |
|
25 | - false |
|
26 | - ); |
|
27 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | - $this->_per_page, |
|
29 | - $this->_view, |
|
30 | - true, |
|
31 | - true, |
|
32 | - false |
|
33 | - ); |
|
34 | - } |
|
15 | + /** |
|
16 | + * Setup initial data. |
|
17 | + */ |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | + $this->_per_page, |
|
22 | + $this->_view, |
|
23 | + false, |
|
24 | + false, |
|
25 | + false |
|
26 | + ); |
|
27 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | + $this->_per_page, |
|
29 | + $this->_view, |
|
30 | + true, |
|
31 | + true, |
|
32 | + false |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Set initial properties |
|
39 | - */ |
|
40 | - protected function _set_properties() |
|
41 | - { |
|
42 | - parent::_set_properties(); |
|
43 | - $this->_wp_list_args = array( |
|
44 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | - 'ajax' => true, //for now, |
|
47 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | - ); |
|
37 | + /** |
|
38 | + * Set initial properties |
|
39 | + */ |
|
40 | + protected function _set_properties() |
|
41 | + { |
|
42 | + parent::_set_properties(); |
|
43 | + $this->_wp_list_args = array( |
|
44 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | + 'ajax' => true, //for now, |
|
47 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | + ); |
|
49 | 49 | |
50 | - $this->_columns = array_merge( |
|
51 | - array( |
|
52 | - 'cb' => '<input type="checkbox" />', |
|
53 | - 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | - ), |
|
55 | - $this->_columns, |
|
56 | - array( |
|
57 | - 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | - 'actions' => '' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
50 | + $this->_columns = array_merge( |
|
51 | + array( |
|
52 | + 'cb' => '<input type="checkbox" />', |
|
53 | + 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | + ), |
|
55 | + $this->_columns, |
|
56 | + array( |
|
57 | + 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | + 'actions' => '' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Custom message for when there are no items found. |
|
66 | - * |
|
67 | - * @since 4.3.0 |
|
68 | - */ |
|
69 | - public function no_items() |
|
70 | - { |
|
71 | - if ($this->_view !== 'trashed') { |
|
72 | - printf( |
|
73 | - esc_html__( |
|
74 | - '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - '<strong>', |
|
78 | - '</strong>' |
|
79 | - ); |
|
80 | - } else { |
|
81 | - parent::no_items(); |
|
82 | - } |
|
83 | - } |
|
64 | + /** |
|
65 | + * Custom message for when there are no items found. |
|
66 | + * |
|
67 | + * @since 4.3.0 |
|
68 | + */ |
|
69 | + public function no_items() |
|
70 | + { |
|
71 | + if ($this->_view !== 'trashed') { |
|
72 | + printf( |
|
73 | + esc_html__( |
|
74 | + '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + '<strong>', |
|
78 | + '</strong>' |
|
79 | + ); |
|
80 | + } else { |
|
81 | + parent::no_items(); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param EE_Message_Template_Group $item |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function column_cb($item) |
|
91 | - { |
|
92 | - return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | - } |
|
86 | + /** |
|
87 | + * @param EE_Message_Template_Group $item |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function column_cb($item) |
|
91 | + { |
|
92 | + return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @param EE_Message_Template_Group $item |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function column_name($item) |
|
101 | - { |
|
102 | - return '<p>' . $item->name() . '</p>'; |
|
103 | - } |
|
96 | + /** |
|
97 | + * @param EE_Message_Template_Group $item |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function column_name($item) |
|
101 | + { |
|
102 | + return '<p>' . $item->name() . '</p>'; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @param EE_Message_Template_Group $item |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function column_actions($item) |
|
111 | - { |
|
112 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | - 'ee_edit_messages', |
|
114 | - 'espresso_messages_add_new_message_template' |
|
115 | - )) { |
|
116 | - $create_args = array( |
|
117 | - 'GRP_ID' => $item->ID(), |
|
118 | - 'messenger' => $item->messenger(), |
|
119 | - 'message_type' => $item->message_type(), |
|
120 | - 'action' => 'add_new_message_template', |
|
121 | - ); |
|
122 | - $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | - return sprintf( |
|
124 | - '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | - $create_link, |
|
126 | - esc_html__('Create Custom', 'event_espresso') |
|
127 | - ); |
|
128 | - } |
|
129 | - return ''; |
|
130 | - } |
|
106 | + /** |
|
107 | + * @param EE_Message_Template_Group $item |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function column_actions($item) |
|
111 | + { |
|
112 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | + 'ee_edit_messages', |
|
114 | + 'espresso_messages_add_new_message_template' |
|
115 | + )) { |
|
116 | + $create_args = array( |
|
117 | + 'GRP_ID' => $item->ID(), |
|
118 | + 'messenger' => $item->messenger(), |
|
119 | + 'message_type' => $item->message_type(), |
|
120 | + 'action' => 'add_new_message_template', |
|
121 | + ); |
|
122 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | + return sprintf( |
|
124 | + '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | + $create_link, |
|
126 | + esc_html__('Create Custom', 'event_espresso') |
|
127 | + ); |
|
128 | + } |
|
129 | + return ''; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Set the view counts on the _views property |
|
134 | - */ |
|
135 | - protected function _add_view_counts() |
|
136 | - { |
|
137 | - foreach ($this->_views as $view => $args) { |
|
138 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | - $this->_per_page, |
|
140 | - $view, |
|
141 | - true, |
|
142 | - true, |
|
143 | - false |
|
144 | - ); |
|
145 | - } |
|
146 | - } |
|
132 | + /** |
|
133 | + * Set the view counts on the _views property |
|
134 | + */ |
|
135 | + protected function _add_view_counts() |
|
136 | + { |
|
137 | + foreach ($this->_views as $view => $args) { |
|
138 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | + $this->_per_page, |
|
140 | + $view, |
|
141 | + true, |
|
142 | + true, |
|
143 | + false |
|
144 | + ); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | - /** |
|
150 | - * column_events |
|
151 | - * This provides a count of events using this custom template |
|
152 | - * |
|
153 | - * @param EE_Message_Template_Group $item message_template group data |
|
154 | - * @return string column output |
|
155 | - */ |
|
156 | - public function column_events($item) |
|
157 | - { |
|
158 | - return $item->count_events(); |
|
159 | - } |
|
149 | + /** |
|
150 | + * column_events |
|
151 | + * This provides a count of events using this custom template |
|
152 | + * |
|
153 | + * @param EE_Message_Template_Group $item message_template group data |
|
154 | + * @return string column output |
|
155 | + */ |
|
156 | + public function column_events($item) |
|
157 | + { |
|
158 | + return $item->count_events(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Add additional actions for custom message template list view. |
|
164 | - * @param EE_Message_Template_Group $item |
|
165 | - * @return array |
|
166 | - * @throws EE_Error |
|
167 | - */ |
|
168 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | - { |
|
170 | - $actions = parent::_get_actions_for_messenger_column($item); |
|
162 | + /** |
|
163 | + * Add additional actions for custom message template list view. |
|
164 | + * @param EE_Message_Template_Group $item |
|
165 | + * @return array |
|
166 | + * @throws EE_Error |
|
167 | + */ |
|
168 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | + { |
|
170 | + $actions = parent::_get_actions_for_messenger_column($item); |
|
171 | 171 | |
172 | - //add additional actions for trash/restore etc. |
|
173 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | - 'id' => $item->GRP_ID(), |
|
175 | - 'noheader' => true, |
|
176 | - ), EE_MSG_ADMIN_URL); |
|
177 | - // restore link |
|
178 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | - 'id' => $item->GRP_ID(), |
|
180 | - 'noheader' => true, |
|
181 | - ), EE_MSG_ADMIN_URL); |
|
182 | - // delete price link |
|
183 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | - 'id' => $item->GRP_ID(), |
|
185 | - 'noheader' => true, |
|
186 | - ), EE_MSG_ADMIN_URL); |
|
172 | + //add additional actions for trash/restore etc. |
|
173 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | + 'id' => $item->GRP_ID(), |
|
175 | + 'noheader' => true, |
|
176 | + ), EE_MSG_ADMIN_URL); |
|
177 | + // restore link |
|
178 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | + 'id' => $item->GRP_ID(), |
|
180 | + 'noheader' => true, |
|
181 | + ), EE_MSG_ADMIN_URL); |
|
182 | + // delete price link |
|
183 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | + 'id' => $item->GRP_ID(), |
|
185 | + 'noheader' => true, |
|
186 | + ), EE_MSG_ADMIN_URL); |
|
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
189 | - && EE_Registry::instance()->CAP->current_user_can( |
|
190 | - 'ee_delete_message', |
|
191 | - 'espresso_messages_trash_message_template', |
|
192 | - $item->ID() |
|
193 | - ) |
|
194 | - ) { |
|
195 | - $actions['trash'] = '<a href="' |
|
196 | - . $trash_lnk_url |
|
197 | - . '" title="' |
|
198 | - . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | - . '">' |
|
200 | - . esc_html__('Move to Trash', 'event_espresso') |
|
201 | - . '</a>'; |
|
202 | - } else { |
|
203 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | - 'ee_delete_message', |
|
205 | - 'espresso_messages_restore_message_template', |
|
206 | - $item->ID() |
|
207 | - )) { |
|
208 | - $actions['restore'] = '<a href="' |
|
209 | - . $restore_lnk_url |
|
210 | - . '" title="' |
|
211 | - . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | - . '">' |
|
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | - } |
|
188 | + if (! $item->get('MTP_deleted') |
|
189 | + && EE_Registry::instance()->CAP->current_user_can( |
|
190 | + 'ee_delete_message', |
|
191 | + 'espresso_messages_trash_message_template', |
|
192 | + $item->ID() |
|
193 | + ) |
|
194 | + ) { |
|
195 | + $actions['trash'] = '<a href="' |
|
196 | + . $trash_lnk_url |
|
197 | + . '" title="' |
|
198 | + . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | + . '">' |
|
200 | + . esc_html__('Move to Trash', 'event_espresso') |
|
201 | + . '</a>'; |
|
202 | + } else { |
|
203 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | + 'ee_delete_message', |
|
205 | + 'espresso_messages_restore_message_template', |
|
206 | + $item->ID() |
|
207 | + )) { |
|
208 | + $actions['restore'] = '<a href="' |
|
209 | + . $restore_lnk_url |
|
210 | + . '" title="' |
|
211 | + . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | + . '">' |
|
213 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | + } |
|
215 | 215 | |
216 | - if ($this->_view === 'trashed' |
|
217 | - && EE_Registry::instance()->CAP->current_user_can( |
|
218 | - 'ee_delete_message', |
|
219 | - 'espresso_messages_delete_message_template', |
|
220 | - $item->ID() |
|
221 | - )) { |
|
222 | - $actions['delete'] = '<a href="' |
|
223 | - . $delete_lnk_url |
|
224 | - . '" title="' |
|
225 | - . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | - . '">' |
|
227 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | - . '</a>'; |
|
229 | - } |
|
230 | - } |
|
231 | - return $actions; |
|
232 | - } |
|
216 | + if ($this->_view === 'trashed' |
|
217 | + && EE_Registry::instance()->CAP->current_user_can( |
|
218 | + 'ee_delete_message', |
|
219 | + 'espresso_messages_delete_message_template', |
|
220 | + $item->ID() |
|
221 | + )) { |
|
222 | + $actions['delete'] = '<a href="' |
|
223 | + . $delete_lnk_url |
|
224 | + . '" title="' |
|
225 | + . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | + . '">' |
|
227 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | + . '</a>'; |
|
229 | + } |
|
230 | + } |
|
231 | + return $actions; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * Generate dropdown filter select input for messengers |
|
237 | - * @param bool $global |
|
238 | - * @return string |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - protected function _get_messengers_dropdown_filter($global = true) |
|
242 | - { |
|
243 | - return parent::_get_messengers_dropdown_filter(false); |
|
244 | - } |
|
235 | + /** |
|
236 | + * Generate dropdown filter select input for messengers |
|
237 | + * @param bool $global |
|
238 | + * @return string |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + protected function _get_messengers_dropdown_filter($global = true) |
|
242 | + { |
|
243 | + return parent::_get_messengers_dropdown_filter(false); |
|
244 | + } |
|
245 | 245 | |
246 | 246 | |
247 | - /** |
|
248 | - * Generate dropdown filter select input for message types |
|
249 | - * @param bool $global |
|
250 | - * @return string |
|
251 | - * @throws EE_Error |
|
252 | - */ |
|
253 | - protected function _get_message_types_dropdown_filter($global = true) |
|
254 | - { |
|
255 | - return parent::_get_message_types_dropdown_filter(false); |
|
256 | - } |
|
247 | + /** |
|
248 | + * Generate dropdown filter select input for message types |
|
249 | + * @param bool $global |
|
250 | + * @return string |
|
251 | + * @throws EE_Error |
|
252 | + */ |
|
253 | + protected function _get_message_types_dropdown_filter($global = true) |
|
254 | + { |
|
255 | + return parent::_get_message_types_dropdown_filter(false); |
|
256 | + } |
|
257 | 257 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | protected function _setup_data() |
19 | 19 | { |
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | 21 | $this->_per_page, |
22 | 22 | $this->_view, |
23 | 23 | false, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function column_name($item) |
101 | 101 | { |
102 | - return '<p>' . $item->name() . '</p>'; |
|
102 | + return '<p>'.$item->name().'</p>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'noheader' => true, |
186 | 186 | ), EE_MSG_ADMIN_URL); |
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
188 | + if ( ! $item->get('MTP_deleted') |
|
189 | 189 | && EE_Registry::instance()->CAP->current_user_can( |
190 | 190 | 'ee_delete_message', |
191 | 191 | 'espresso_messages_trash_message_template', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | . '" title="' |
211 | 211 | . esc_attr__('Restore Message Template', 'event_espresso') |
212 | 212 | . '">' |
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
213 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($this->_view === 'trashed' |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function _setup_data() |
29 | 29 | { |
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | 31 | $this->_per_page, |
32 | 32 | $this->_view, |
33 | 33 | false |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'ajax' => true, //for now, |
53 | 53 | 'screen' => $this->get_admin_page()->get_current_screen()->id, |
54 | 54 | ); |
55 | - $this->_columns = array( |
|
55 | + $this->_columns = array( |
|
56 | 56 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
57 | 57 | 'message_type' => esc_html__('Message Type', 'event_espresso'), |
58 | 58 | 'messenger' => esc_html__('Messenger', 'event_espresso'), |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $message_type = $item->message_type_obj(); |
81 | 81 | $messenger = $item->messenger_obj(); |
82 | 82 | |
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
83 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | 84 | echo ''; |
85 | 85 | return; |
86 | 86 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function column_description($item) |
158 | 158 | { |
159 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
159 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $edit_url = ''; |
270 | 270 | // edit link but only if item isn't trashed. |
271 | - if (! $item->get('MTP_deleted') |
|
271 | + if ( ! $item->get('MTP_deleted') |
|
272 | 272 | && EE_Registry::instance()->CAP->current_user_can( |
273 | 273 | 'ee_edit_message', |
274 | 274 | 'espresso_messages_edit_message_template', |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | protected function _get_context_links(EE_Message_Template_Group $item) |
296 | 296 | { |
297 | 297 | //first check if we even show the context links or not. |
298 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
298 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
299 | 299 | 'ee_edit_message', |
300 | 300 | 'espresso_messages_edit_message_template', |
301 | 301 | $item->ID() |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | && $context_templates[$context]['to'] instanceof EE_Message_Template |
315 | 315 | ? $context_templates[$context]['to']->get('MTP_content') |
316 | 316 | : null; |
317 | - $inactive = empty($mtp_to) |
|
317 | + $inactive = empty($mtp_to) |
|
318 | 318 | && ! empty($context_templates[$context]['to']) |
319 | 319 | ? ' class="mtp-inactive"' |
320 | 320 | : ''; |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | 'id' => $item->GRP_ID(), |
325 | 325 | 'context' => $context, |
326 | 326 | ), EE_MSG_ADMIN_URL); |
327 | - $ctxt[] = '<a' . $inactive |
|
328 | - . ' href="' . $edit_link . '"' |
|
329 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
330 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
327 | + $ctxt[] = '<a'.$inactive |
|
328 | + . ' href="'.$edit_link.'"' |
|
329 | + . ' class="'.$item->message_type().'-'.$context.'-edit-link"' |
|
330 | + . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">' |
|
331 | 331 | . $context_title |
332 | 332 | . '</a>'; |
333 | 333 | } |
334 | 334 | |
335 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
335 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $ctxt); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | { |
347 | 347 | $edit_url = $this->_get_edit_url($item); |
348 | 348 | return $edit_url |
349 | - ? '<a href="' . $edit_url . '"' |
|
350 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
349 | + ? '<a href="'.$edit_url.'"' |
|
350 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
351 | 351 | . ucwords($item->messenger_obj()->label['singular']) |
352 | 352 | . '</a>' |
353 | 353 | : ucwords($item->messenger_obj()->label['singular']); |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | $actions = array(); |
366 | 366 | if ($edit_url = $this->_get_edit_url($item)) { |
367 | 367 | $actions = array( |
368 | - 'edit' => '<a href="' . $edit_url . '"' |
|
369 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
370 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
368 | + 'edit' => '<a href="'.$edit_url.'"' |
|
369 | + . ' class="'.$item->message_type().'-edit-link"' |
|
370 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
371 | 371 | . esc_html__('Edit', 'event_espresso') |
372 | 372 | . '</a>' |
373 | 373 | ); |
@@ -13,370 +13,370 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @return Messages_Admin_Page |
|
18 | - */ |
|
19 | - public function get_admin_page() |
|
20 | - { |
|
21 | - return $this->_admin_page; |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Setup data object |
|
27 | - */ |
|
28 | - protected function _setup_data() |
|
29 | - { |
|
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | - $this->_per_page, |
|
32 | - $this->_view, |
|
33 | - false |
|
34 | - ); |
|
35 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | - $this->_per_page, |
|
37 | - $this->_view, |
|
38 | - true, |
|
39 | - true |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Set internal properties |
|
46 | - */ |
|
47 | - protected function _set_properties() |
|
48 | - { |
|
49 | - $this->_wp_list_args = array( |
|
50 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | - 'ajax' => true, //for now, |
|
53 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | - ); |
|
55 | - $this->_columns = array( |
|
56 | - //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | - 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | - 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | - 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | - ); |
|
61 | - |
|
62 | - $this->_sortable_columns = array( |
|
63 | - 'messenger' => array('MTP_messenger' => true), |
|
64 | - ); |
|
65 | - |
|
66 | - $this->_hidden_columns = array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | - * message_type or messenger object before generating the row. |
|
73 | - * |
|
74 | - * @param EE_Message_Template_Group $item |
|
75 | - * @return string |
|
76 | - * @throws EE_Error |
|
77 | - */ |
|
78 | - public function single_row($item) |
|
79 | - { |
|
80 | - $message_type = $item->message_type_obj(); |
|
81 | - $messenger = $item->messenger_obj(); |
|
82 | - |
|
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | - echo ''; |
|
85 | - return; |
|
86 | - } |
|
87 | - |
|
88 | - parent::single_row($item); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - protected function _get_table_filters() |
|
97 | - { |
|
98 | - $filters = array(); |
|
99 | - |
|
100 | - //get select inputs |
|
101 | - $select_inputs = array( |
|
102 | - $this->_get_messengers_dropdown_filter(), |
|
103 | - $this->_get_message_types_dropdown_filter(), |
|
104 | - ); |
|
105 | - |
|
106 | - //set filters to select inputs if they aren't empty |
|
107 | - foreach ($select_inputs as $select_input) { |
|
108 | - if ($select_input) { |
|
109 | - $filters[] = $select_input; |
|
110 | - } |
|
111 | - } |
|
112 | - return $filters; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * We're just removing the search box for message templates, not needed. |
|
117 | - * |
|
118 | - * @param string $text |
|
119 | - * @param string $input_id |
|
120 | - * @return string ; |
|
121 | - */ |
|
122 | - public function search_box($text, $input_id) |
|
123 | - { |
|
124 | - return ''; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Add counts to the _views property |
|
130 | - */ |
|
131 | - protected function _add_view_counts() |
|
132 | - { |
|
133 | - foreach ($this->_views as $view => $args) { |
|
134 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | - $this->_per_page, |
|
136 | - $view, |
|
137 | - true, |
|
138 | - true |
|
139 | - ); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param EE_Message_Template_Group $item |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function column_cb($item) |
|
149 | - { |
|
150 | - return ''; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @param EE_Message_Template_Group $item |
|
156 | - * @return string |
|
157 | - * @throws EE_Error |
|
158 | - */ |
|
159 | - public function column_description($item) |
|
160 | - { |
|
161 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param EE_Message_Template_Group $item |
|
167 | - * @return string |
|
168 | - * @throws EE_Error |
|
169 | - */ |
|
170 | - public function column_messenger($item) |
|
171 | - { |
|
172 | - //Return the name contents |
|
173 | - return sprintf( |
|
174 | - '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
175 | - /* $1%s */ |
|
176 | - $this->_get_name_link_for_messenger($item), |
|
177 | - /* $2%s */ |
|
178 | - $item->GRP_ID(), |
|
179 | - /* %4$s */ |
|
180 | - $this->_get_context_links($item), |
|
181 | - /* $3%s */ |
|
182 | - $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * column_message_type |
|
188 | - * |
|
189 | - * @param EE_Message_Template_Group $item message info for the row |
|
190 | - * @return string message_type name |
|
191 | - * @throws EE_Error |
|
192 | - */ |
|
193 | - public function column_message_type($item) |
|
194 | - { |
|
195 | - return ucwords($item->message_type_obj()->label['singular']); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Generate dropdown filter select input for messengers |
|
201 | - * |
|
202 | - * @param bool $global |
|
203 | - * @return string |
|
204 | - * @throws EE_Error |
|
205 | - */ |
|
206 | - protected function _get_messengers_dropdown_filter($global = true) |
|
207 | - { |
|
208 | - $messenger_options = array(); |
|
209 | - $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
210 | - array( |
|
211 | - array( |
|
212 | - 'MTP_is_active' => true, |
|
213 | - 'MTP_is_global' => $global, |
|
214 | - ), |
|
215 | - 'group_by' => 'MTP_messenger', |
|
216 | - ) |
|
217 | - ); |
|
218 | - |
|
219 | - foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
220 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
221 | - $messenger = $active_message_template_group->messenger_obj(); |
|
222 | - $messenger_label = $messenger instanceof EE_messenger |
|
223 | - ? $messenger->label['singular'] |
|
224 | - : $active_message_template_group->messenger(); |
|
225 | - $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
226 | - } |
|
227 | - } |
|
228 | - return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * Generate dropdown filter select input for message types |
|
234 | - * |
|
235 | - * @param bool $global |
|
236 | - * @return string |
|
237 | - * @throws EE_Error |
|
238 | - */ |
|
239 | - protected function _get_message_types_dropdown_filter($global = true) |
|
240 | - { |
|
241 | - $message_type_options = array(); |
|
242 | - $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
243 | - array( |
|
244 | - array( |
|
245 | - 'MTP_is_active' => true, |
|
246 | - 'MTP_is_global' => true, |
|
247 | - ), |
|
248 | - 'group_by' => 'MTP_message_type', |
|
249 | - ) |
|
250 | - ); |
|
251 | - |
|
252 | - foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
253 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
254 | - $message_type = $active_message_template_group->message_type_obj(); |
|
255 | - $message_type_label = $message_type instanceof EE_message_type |
|
256 | - ? $message_type->label['singular'] |
|
257 | - : $active_message_template_group->message_type(); |
|
258 | - $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
259 | - } |
|
260 | - } |
|
261 | - return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * Return the edit url for the message template group. |
|
267 | - * @param EE_Message_Template_Group $item |
|
268 | - * @return string |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - protected function _get_edit_url(EE_Message_Template_Group $item) |
|
272 | - { |
|
273 | - $edit_url = ''; |
|
274 | - // edit link but only if item isn't trashed. |
|
275 | - if (! $item->get('MTP_deleted') |
|
276 | - && EE_Registry::instance()->CAP->current_user_can( |
|
277 | - 'ee_edit_message', |
|
278 | - 'espresso_messages_edit_message_template', |
|
279 | - $item->ID() |
|
280 | - )) { |
|
281 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
282 | - array( |
|
283 | - 'action' => 'edit_message_template', |
|
284 | - 'id' => $item->GRP_ID(), |
|
285 | - ), |
|
286 | - EE_MSG_ADMIN_URL |
|
287 | - ); |
|
288 | - } |
|
289 | - return $edit_url; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Get the context link string for the messenger column. |
|
295 | - * @param EE_Message_Template_Group $item |
|
296 | - * @return string |
|
297 | - * @throws EE_Error |
|
298 | - */ |
|
299 | - protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | - { |
|
301 | - //first check if we even show the context links or not. |
|
302 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | - 'ee_edit_message', |
|
304 | - 'espresso_messages_edit_message_template', |
|
305 | - $item->ID() |
|
306 | - ) |
|
307 | - || $item->get('MTP_deleted') |
|
308 | - ) { |
|
309 | - return ''; |
|
310 | - } |
|
311 | - //we want to display the contexts in here so we need to set them up |
|
312 | - $c_label = $item->context_label(); |
|
313 | - $c_configs = $item->contexts_config(); |
|
314 | - $ctxt = array(); |
|
315 | - $context_templates = $item->context_templates(); |
|
316 | - foreach ($context_templates as $context => $template_fields) { |
|
317 | - $mtp_to = ! empty($context_templates[$context]['to']) |
|
318 | - && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
319 | - ? $context_templates[$context]['to']->get('MTP_content') |
|
320 | - : null; |
|
321 | - $inactive = empty($mtp_to) |
|
322 | - && ! empty($context_templates[$context]['to']) |
|
323 | - ? ' class="mtp-inactive"' |
|
324 | - : ''; |
|
325 | - $context_title = ucwords($c_configs[$context]['label']); |
|
326 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
327 | - 'action' => 'edit_message_template', |
|
328 | - 'id' => $item->GRP_ID(), |
|
329 | - 'context' => $context, |
|
330 | - ), EE_MSG_ADMIN_URL); |
|
331 | - $ctxt[] = '<a' . $inactive |
|
332 | - . ' href="' . $edit_link . '"' |
|
333 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
334 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
335 | - . $context_title |
|
336 | - . '</a>'; |
|
337 | - } |
|
338 | - |
|
339 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
345 | - * @param EE_Message_Template_Group $item |
|
346 | - * @return string |
|
347 | - * @throws EE_Error |
|
348 | - */ |
|
349 | - protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
350 | - { |
|
351 | - $edit_url = $this->_get_edit_url($item); |
|
352 | - return $edit_url |
|
353 | - ? '<a href="' . $edit_url . '"' |
|
354 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
355 | - . ucwords($item->messenger_obj()->label['singular']) |
|
356 | - . '</a>' |
|
357 | - : ucwords($item->messenger_obj()->label['singular']); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Return the actions array for the messenger column. |
|
363 | - * @param EE_Message_Template_Group $item |
|
364 | - * @return array |
|
365 | - * @throws EE_Error |
|
366 | - */ |
|
367 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
368 | - { |
|
369 | - $actions = array(); |
|
370 | - if ($edit_url = $this->_get_edit_url($item)) { |
|
371 | - $actions = array( |
|
372 | - 'edit' => '<a href="' . $edit_url . '"' |
|
373 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
374 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
375 | - . esc_html__('Edit', 'event_espresso') |
|
376 | - . '</a>' |
|
377 | - ); |
|
378 | - } |
|
379 | - return $actions; |
|
380 | - } |
|
16 | + /** |
|
17 | + * @return Messages_Admin_Page |
|
18 | + */ |
|
19 | + public function get_admin_page() |
|
20 | + { |
|
21 | + return $this->_admin_page; |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Setup data object |
|
27 | + */ |
|
28 | + protected function _setup_data() |
|
29 | + { |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | + $this->_per_page, |
|
32 | + $this->_view, |
|
33 | + false |
|
34 | + ); |
|
35 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | + $this->_per_page, |
|
37 | + $this->_view, |
|
38 | + true, |
|
39 | + true |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Set internal properties |
|
46 | + */ |
|
47 | + protected function _set_properties() |
|
48 | + { |
|
49 | + $this->_wp_list_args = array( |
|
50 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | + 'ajax' => true, //for now, |
|
53 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | + ); |
|
55 | + $this->_columns = array( |
|
56 | + //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | + 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | + 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | + 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | + ); |
|
61 | + |
|
62 | + $this->_sortable_columns = array( |
|
63 | + 'messenger' => array('MTP_messenger' => true), |
|
64 | + ); |
|
65 | + |
|
66 | + $this->_hidden_columns = array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | + * message_type or messenger object before generating the row. |
|
73 | + * |
|
74 | + * @param EE_Message_Template_Group $item |
|
75 | + * @return string |
|
76 | + * @throws EE_Error |
|
77 | + */ |
|
78 | + public function single_row($item) |
|
79 | + { |
|
80 | + $message_type = $item->message_type_obj(); |
|
81 | + $messenger = $item->messenger_obj(); |
|
82 | + |
|
83 | + if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | + echo ''; |
|
85 | + return; |
|
86 | + } |
|
87 | + |
|
88 | + parent::single_row($item); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + protected function _get_table_filters() |
|
97 | + { |
|
98 | + $filters = array(); |
|
99 | + |
|
100 | + //get select inputs |
|
101 | + $select_inputs = array( |
|
102 | + $this->_get_messengers_dropdown_filter(), |
|
103 | + $this->_get_message_types_dropdown_filter(), |
|
104 | + ); |
|
105 | + |
|
106 | + //set filters to select inputs if they aren't empty |
|
107 | + foreach ($select_inputs as $select_input) { |
|
108 | + if ($select_input) { |
|
109 | + $filters[] = $select_input; |
|
110 | + } |
|
111 | + } |
|
112 | + return $filters; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * We're just removing the search box for message templates, not needed. |
|
117 | + * |
|
118 | + * @param string $text |
|
119 | + * @param string $input_id |
|
120 | + * @return string ; |
|
121 | + */ |
|
122 | + public function search_box($text, $input_id) |
|
123 | + { |
|
124 | + return ''; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Add counts to the _views property |
|
130 | + */ |
|
131 | + protected function _add_view_counts() |
|
132 | + { |
|
133 | + foreach ($this->_views as $view => $args) { |
|
134 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | + $this->_per_page, |
|
136 | + $view, |
|
137 | + true, |
|
138 | + true |
|
139 | + ); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param EE_Message_Template_Group $item |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function column_cb($item) |
|
149 | + { |
|
150 | + return ''; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @param EE_Message_Template_Group $item |
|
156 | + * @return string |
|
157 | + * @throws EE_Error |
|
158 | + */ |
|
159 | + public function column_description($item) |
|
160 | + { |
|
161 | + return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param EE_Message_Template_Group $item |
|
167 | + * @return string |
|
168 | + * @throws EE_Error |
|
169 | + */ |
|
170 | + public function column_messenger($item) |
|
171 | + { |
|
172 | + //Return the name contents |
|
173 | + return sprintf( |
|
174 | + '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
175 | + /* $1%s */ |
|
176 | + $this->_get_name_link_for_messenger($item), |
|
177 | + /* $2%s */ |
|
178 | + $item->GRP_ID(), |
|
179 | + /* %4$s */ |
|
180 | + $this->_get_context_links($item), |
|
181 | + /* $3%s */ |
|
182 | + $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * column_message_type |
|
188 | + * |
|
189 | + * @param EE_Message_Template_Group $item message info for the row |
|
190 | + * @return string message_type name |
|
191 | + * @throws EE_Error |
|
192 | + */ |
|
193 | + public function column_message_type($item) |
|
194 | + { |
|
195 | + return ucwords($item->message_type_obj()->label['singular']); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Generate dropdown filter select input for messengers |
|
201 | + * |
|
202 | + * @param bool $global |
|
203 | + * @return string |
|
204 | + * @throws EE_Error |
|
205 | + */ |
|
206 | + protected function _get_messengers_dropdown_filter($global = true) |
|
207 | + { |
|
208 | + $messenger_options = array(); |
|
209 | + $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
210 | + array( |
|
211 | + array( |
|
212 | + 'MTP_is_active' => true, |
|
213 | + 'MTP_is_global' => $global, |
|
214 | + ), |
|
215 | + 'group_by' => 'MTP_messenger', |
|
216 | + ) |
|
217 | + ); |
|
218 | + |
|
219 | + foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
220 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
221 | + $messenger = $active_message_template_group->messenger_obj(); |
|
222 | + $messenger_label = $messenger instanceof EE_messenger |
|
223 | + ? $messenger->label['singular'] |
|
224 | + : $active_message_template_group->messenger(); |
|
225 | + $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
226 | + } |
|
227 | + } |
|
228 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Generate dropdown filter select input for message types |
|
234 | + * |
|
235 | + * @param bool $global |
|
236 | + * @return string |
|
237 | + * @throws EE_Error |
|
238 | + */ |
|
239 | + protected function _get_message_types_dropdown_filter($global = true) |
|
240 | + { |
|
241 | + $message_type_options = array(); |
|
242 | + $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
243 | + array( |
|
244 | + array( |
|
245 | + 'MTP_is_active' => true, |
|
246 | + 'MTP_is_global' => true, |
|
247 | + ), |
|
248 | + 'group_by' => 'MTP_message_type', |
|
249 | + ) |
|
250 | + ); |
|
251 | + |
|
252 | + foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
253 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
254 | + $message_type = $active_message_template_group->message_type_obj(); |
|
255 | + $message_type_label = $message_type instanceof EE_message_type |
|
256 | + ? $message_type->label['singular'] |
|
257 | + : $active_message_template_group->message_type(); |
|
258 | + $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
259 | + } |
|
260 | + } |
|
261 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * Return the edit url for the message template group. |
|
267 | + * @param EE_Message_Template_Group $item |
|
268 | + * @return string |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + protected function _get_edit_url(EE_Message_Template_Group $item) |
|
272 | + { |
|
273 | + $edit_url = ''; |
|
274 | + // edit link but only if item isn't trashed. |
|
275 | + if (! $item->get('MTP_deleted') |
|
276 | + && EE_Registry::instance()->CAP->current_user_can( |
|
277 | + 'ee_edit_message', |
|
278 | + 'espresso_messages_edit_message_template', |
|
279 | + $item->ID() |
|
280 | + )) { |
|
281 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
282 | + array( |
|
283 | + 'action' => 'edit_message_template', |
|
284 | + 'id' => $item->GRP_ID(), |
|
285 | + ), |
|
286 | + EE_MSG_ADMIN_URL |
|
287 | + ); |
|
288 | + } |
|
289 | + return $edit_url; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Get the context link string for the messenger column. |
|
295 | + * @param EE_Message_Template_Group $item |
|
296 | + * @return string |
|
297 | + * @throws EE_Error |
|
298 | + */ |
|
299 | + protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | + { |
|
301 | + //first check if we even show the context links or not. |
|
302 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | + 'ee_edit_message', |
|
304 | + 'espresso_messages_edit_message_template', |
|
305 | + $item->ID() |
|
306 | + ) |
|
307 | + || $item->get('MTP_deleted') |
|
308 | + ) { |
|
309 | + return ''; |
|
310 | + } |
|
311 | + //we want to display the contexts in here so we need to set them up |
|
312 | + $c_label = $item->context_label(); |
|
313 | + $c_configs = $item->contexts_config(); |
|
314 | + $ctxt = array(); |
|
315 | + $context_templates = $item->context_templates(); |
|
316 | + foreach ($context_templates as $context => $template_fields) { |
|
317 | + $mtp_to = ! empty($context_templates[$context]['to']) |
|
318 | + && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
319 | + ? $context_templates[$context]['to']->get('MTP_content') |
|
320 | + : null; |
|
321 | + $inactive = empty($mtp_to) |
|
322 | + && ! empty($context_templates[$context]['to']) |
|
323 | + ? ' class="mtp-inactive"' |
|
324 | + : ''; |
|
325 | + $context_title = ucwords($c_configs[$context]['label']); |
|
326 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
327 | + 'action' => 'edit_message_template', |
|
328 | + 'id' => $item->GRP_ID(), |
|
329 | + 'context' => $context, |
|
330 | + ), EE_MSG_ADMIN_URL); |
|
331 | + $ctxt[] = '<a' . $inactive |
|
332 | + . ' href="' . $edit_link . '"' |
|
333 | + . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
334 | + . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
335 | + . $context_title |
|
336 | + . '</a>'; |
|
337 | + } |
|
338 | + |
|
339 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
345 | + * @param EE_Message_Template_Group $item |
|
346 | + * @return string |
|
347 | + * @throws EE_Error |
|
348 | + */ |
|
349 | + protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
350 | + { |
|
351 | + $edit_url = $this->_get_edit_url($item); |
|
352 | + return $edit_url |
|
353 | + ? '<a href="' . $edit_url . '"' |
|
354 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
355 | + . ucwords($item->messenger_obj()->label['singular']) |
|
356 | + . '</a>' |
|
357 | + : ucwords($item->messenger_obj()->label['singular']); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Return the actions array for the messenger column. |
|
363 | + * @param EE_Message_Template_Group $item |
|
364 | + * @return array |
|
365 | + * @throws EE_Error |
|
366 | + */ |
|
367 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
368 | + { |
|
369 | + $actions = array(); |
|
370 | + if ($edit_url = $this->_get_edit_url($item)) { |
|
371 | + $actions = array( |
|
372 | + 'edit' => '<a href="' . $edit_url . '"' |
|
373 | + . ' class="' . $item->message_type() . '-edit-link"' |
|
374 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
375 | + . esc_html__('Edit', 'event_espresso') |
|
376 | + . '</a>' |
|
377 | + ); |
|
378 | + } |
|
379 | + return $actions; |
|
380 | + } |
|
381 | 381 | } |
382 | 382 |
@@ -19,206 +19,206 @@ |
||
19 | 19 | class EventListQuery extends WP_Query |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var string $title |
|
24 | - */ |
|
25 | - private $title; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var integer $limit |
|
29 | - */ |
|
30 | - private $limit = 10; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string $css_class |
|
34 | - */ |
|
35 | - private $css_class; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var boolean $show_expired |
|
39 | - */ |
|
40 | - private $show_expired = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $month |
|
44 | - */ |
|
45 | - private $month; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $category_slug |
|
49 | - */ |
|
50 | - private $category_slug; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $order_by |
|
54 | - */ |
|
55 | - private $order_by; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $sort |
|
59 | - */ |
|
60 | - private $sort; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var boolean $show_title |
|
64 | - */ |
|
65 | - private $show_title = true; |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * EE_Event_List_Query Constructor * |
|
71 | - * |
|
72 | - * @param array $args |
|
73 | - */ |
|
74 | - public function __construct($args = array()) |
|
75 | - { |
|
76 | - $args = $this->parseArgs((array)$args); |
|
77 | - $this->setupEventQueryHelper(); |
|
78 | - $this->setupFilters(); |
|
79 | - $args = $this->getQueryArgs($args); |
|
80 | - // run the query |
|
81 | - parent::__construct($args); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param array $args |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - private function parseArgs(array $args) |
|
91 | - { |
|
92 | - // incoming args could be a mix of WP query args + EE shortcode args |
|
93 | - foreach ($args as $property => $value) { |
|
94 | - // if the arg is a property of this class, then it's an EE shortcode arg |
|
95 | - if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) { |
|
96 | - // set the property value |
|
97 | - $this->{$property} = $value; |
|
98 | - // then remove it from the array of args that will later be passed to WP_Query() |
|
99 | - unset($args[$property]); |
|
100 | - } |
|
101 | - } |
|
102 | - return $args; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - private function setupEventQueryHelper() |
|
108 | - { |
|
109 | - //add query filters |
|
110 | - EEH_Event_Query::add_query_filters(); |
|
111 | - // set params that will get used by the filters |
|
112 | - EEH_Event_Query::set_query_params( |
|
113 | - $this->month, |
|
114 | - $this->category_slug, |
|
115 | - $this->show_expired, |
|
116 | - $this->order_by, |
|
117 | - $this->sort |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - private function setupFilters() |
|
124 | - { |
|
125 | - // first off, let's remove any filters from previous queries |
|
126 | - remove_filter( |
|
127 | - 'FHEE__archive_espresso_events_template__show_header', |
|
128 | - array($this, 'show_event_list_title') |
|
129 | - ); |
|
130 | - remove_filter( |
|
131 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
132 | - array($this, 'event_list_title') |
|
133 | - ); |
|
134 | - remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
135 | - // Event List Title ? |
|
136 | - add_filter( |
|
137 | - 'FHEE__archive_espresso_events_template__show_header', |
|
138 | - array($this, 'show_event_list_title') |
|
139 | - ); |
|
140 | - add_filter( |
|
141 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
142 | - array($this, 'event_list_title'), |
|
143 | - 10, |
|
144 | - 1 |
|
145 | - ); |
|
146 | - // add the css class |
|
147 | - add_filter( |
|
148 | - 'FHEE__content_espresso_events__event_class', |
|
149 | - array($this, 'event_list_css'), |
|
150 | - 10, |
|
151 | - 1 |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - |
|
157 | - private function getQueryArgs(array $args) |
|
158 | - { |
|
159 | - // the current "page" we are viewing |
|
160 | - $paged = max(1, get_query_var('paged')); |
|
161 | - // Force these args |
|
162 | - return array_merge( |
|
163 | - $args, |
|
164 | - array( |
|
165 | - 'post_type' => 'espresso_events', |
|
166 | - 'posts_per_page' => $this->limit, |
|
167 | - 'update_post_term_cache' => false, |
|
168 | - 'update_post_meta_cache' => false, |
|
169 | - 'paged' => $paged, |
|
170 | - 'offset' => ($paged - 1) * $this->limit, |
|
171 | - ) |
|
172 | - ); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * show_event_list_title |
|
179 | - * |
|
180 | - * @return boolean |
|
181 | - */ |
|
182 | - public function show_event_list_title() |
|
183 | - { |
|
184 | - return filter_var( |
|
185 | - $this->show_title, |
|
186 | - FILTER_VALIDATE_BOOLEAN |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
194 | - * |
|
195 | - * @param string $event_list_title |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - public function event_list_title($event_list_title = '') |
|
199 | - { |
|
200 | - if ( ! empty($this->title)) { |
|
201 | - return $this->title; |
|
202 | - } |
|
203 | - return $event_list_title; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * callback for FHEE__content_espresso_events__event_class filter |
|
210 | - * |
|
211 | - * @param string $event_list_css |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public function event_list_css($event_list_css = '') |
|
215 | - { |
|
216 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
217 | - $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
218 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
219 | - $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
220 | - return $event_list_css; |
|
221 | - } |
|
22 | + /** |
|
23 | + * @var string $title |
|
24 | + */ |
|
25 | + private $title; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var integer $limit |
|
29 | + */ |
|
30 | + private $limit = 10; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string $css_class |
|
34 | + */ |
|
35 | + private $css_class; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var boolean $show_expired |
|
39 | + */ |
|
40 | + private $show_expired = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $month |
|
44 | + */ |
|
45 | + private $month; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $category_slug |
|
49 | + */ |
|
50 | + private $category_slug; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $order_by |
|
54 | + */ |
|
55 | + private $order_by; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $sort |
|
59 | + */ |
|
60 | + private $sort; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var boolean $show_title |
|
64 | + */ |
|
65 | + private $show_title = true; |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * EE_Event_List_Query Constructor * |
|
71 | + * |
|
72 | + * @param array $args |
|
73 | + */ |
|
74 | + public function __construct($args = array()) |
|
75 | + { |
|
76 | + $args = $this->parseArgs((array)$args); |
|
77 | + $this->setupEventQueryHelper(); |
|
78 | + $this->setupFilters(); |
|
79 | + $args = $this->getQueryArgs($args); |
|
80 | + // run the query |
|
81 | + parent::__construct($args); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param array $args |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + private function parseArgs(array $args) |
|
91 | + { |
|
92 | + // incoming args could be a mix of WP query args + EE shortcode args |
|
93 | + foreach ($args as $property => $value) { |
|
94 | + // if the arg is a property of this class, then it's an EE shortcode arg |
|
95 | + if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) { |
|
96 | + // set the property value |
|
97 | + $this->{$property} = $value; |
|
98 | + // then remove it from the array of args that will later be passed to WP_Query() |
|
99 | + unset($args[$property]); |
|
100 | + } |
|
101 | + } |
|
102 | + return $args; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + private function setupEventQueryHelper() |
|
108 | + { |
|
109 | + //add query filters |
|
110 | + EEH_Event_Query::add_query_filters(); |
|
111 | + // set params that will get used by the filters |
|
112 | + EEH_Event_Query::set_query_params( |
|
113 | + $this->month, |
|
114 | + $this->category_slug, |
|
115 | + $this->show_expired, |
|
116 | + $this->order_by, |
|
117 | + $this->sort |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + private function setupFilters() |
|
124 | + { |
|
125 | + // first off, let's remove any filters from previous queries |
|
126 | + remove_filter( |
|
127 | + 'FHEE__archive_espresso_events_template__show_header', |
|
128 | + array($this, 'show_event_list_title') |
|
129 | + ); |
|
130 | + remove_filter( |
|
131 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
132 | + array($this, 'event_list_title') |
|
133 | + ); |
|
134 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
135 | + // Event List Title ? |
|
136 | + add_filter( |
|
137 | + 'FHEE__archive_espresso_events_template__show_header', |
|
138 | + array($this, 'show_event_list_title') |
|
139 | + ); |
|
140 | + add_filter( |
|
141 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
142 | + array($this, 'event_list_title'), |
|
143 | + 10, |
|
144 | + 1 |
|
145 | + ); |
|
146 | + // add the css class |
|
147 | + add_filter( |
|
148 | + 'FHEE__content_espresso_events__event_class', |
|
149 | + array($this, 'event_list_css'), |
|
150 | + 10, |
|
151 | + 1 |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + |
|
157 | + private function getQueryArgs(array $args) |
|
158 | + { |
|
159 | + // the current "page" we are viewing |
|
160 | + $paged = max(1, get_query_var('paged')); |
|
161 | + // Force these args |
|
162 | + return array_merge( |
|
163 | + $args, |
|
164 | + array( |
|
165 | + 'post_type' => 'espresso_events', |
|
166 | + 'posts_per_page' => $this->limit, |
|
167 | + 'update_post_term_cache' => false, |
|
168 | + 'update_post_meta_cache' => false, |
|
169 | + 'paged' => $paged, |
|
170 | + 'offset' => ($paged - 1) * $this->limit, |
|
171 | + ) |
|
172 | + ); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * show_event_list_title |
|
179 | + * |
|
180 | + * @return boolean |
|
181 | + */ |
|
182 | + public function show_event_list_title() |
|
183 | + { |
|
184 | + return filter_var( |
|
185 | + $this->show_title, |
|
186 | + FILTER_VALIDATE_BOOLEAN |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
194 | + * |
|
195 | + * @param string $event_list_title |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + public function event_list_title($event_list_title = '') |
|
199 | + { |
|
200 | + if ( ! empty($this->title)) { |
|
201 | + return $this->title; |
|
202 | + } |
|
203 | + return $event_list_title; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * callback for FHEE__content_espresso_events__event_class filter |
|
210 | + * |
|
211 | + * @param string $event_list_css |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public function event_list_css($event_list_css = '') |
|
215 | + { |
|
216 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
217 | + $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
218 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
219 | + $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
220 | + return $event_list_css; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | // End of file EventListQuery.php |
@@ -14,132 +14,132 @@ |
||
14 | 14 | class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * opening div tag for a form |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function layout_form_begin() |
|
23 | - { |
|
24 | - return EEH_HTML::div( |
|
25 | - '', |
|
26 | - $this->_form_section->html_id(), |
|
27 | - $this->_form_section->html_class(), |
|
28 | - $this->_form_section->html_style() |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Lays out the row for the input, including label and errors |
|
36 | - * |
|
37 | - * @param EE_Form_Input_Base $input |
|
38 | - * @return string |
|
39 | - * @throws \EE_Error |
|
40 | - */ |
|
41 | - public function layout_input($input) |
|
42 | - { |
|
43 | - $html = ''; |
|
44 | - // set something unique for the id |
|
45 | - $html_id = (string)$input->html_id() !== '' |
|
46 | - ? (string)$input->html_id() |
|
47 | - : spl_object_hash($input); |
|
48 | - // and add a generic class |
|
49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
50 | - if ($input instanceof EE_Hidden_Input) { |
|
51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
52 | - } else if ($input instanceof EE_Submit_Input) { |
|
53 | - $html .= EEH_HTML::div( |
|
54 | - $input->get_html_for_input(), |
|
55 | - $html_id . '-submit-dv', |
|
56 | - $html_class |
|
57 | - ); |
|
58 | - } else if ($input instanceof EE_Select_Input) { |
|
59 | - $html .= EEH_HTML::div( |
|
60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | - $html_id . '-input-dv', |
|
65 | - $html_class |
|
66 | - ); |
|
67 | - } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
68 | - $html .= EEH_HTML::div( |
|
69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | - $html_id . '-input-dv', |
|
74 | - $html_class |
|
75 | - ); |
|
76 | - } else { |
|
77 | - $html .= EEH_HTML::div( |
|
78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | - $html_id . '-input-dv', |
|
83 | - $html_class |
|
84 | - ); |
|
85 | - } |
|
86 | - return $html; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * |
|
93 | - * _display_label_for_option_type_question |
|
94 | - * Gets the HTML for the 'label', which is just text for this (because labels |
|
95 | - * should be for each input) |
|
96 | - * |
|
97 | - * @param EE_Form_Input_With_Options_Base $input |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
101 | - { |
|
102 | - if ($input->display_html_label_text() !== '') { |
|
103 | - return EEH_HTML::div( |
|
104 | - $input->required() |
|
105 | - ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
106 | - : $input->html_label_text(), |
|
107 | - $input->html_label_id(), |
|
108 | - $input->required() |
|
109 | - ? 'ee-required-label ' . $input->html_label_class() |
|
110 | - : $input->html_label_class(), |
|
111 | - $input->html_label_style(), |
|
112 | - $input->html_other_attributes() |
|
113 | - ); |
|
114 | - } |
|
115 | - return ''; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * Lays out a row for the subsection |
|
122 | - * |
|
123 | - * @param EE_Form_Section_Proper $form_section |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - public function layout_subsection($form_section) |
|
127 | - { |
|
128 | - // d( $form_section ); |
|
129 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * closing div tag for a form |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function layout_form_end() |
|
140 | - { |
|
141 | - return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
142 | - } |
|
17 | + /** |
|
18 | + * opening div tag for a form |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function layout_form_begin() |
|
23 | + { |
|
24 | + return EEH_HTML::div( |
|
25 | + '', |
|
26 | + $this->_form_section->html_id(), |
|
27 | + $this->_form_section->html_class(), |
|
28 | + $this->_form_section->html_style() |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Lays out the row for the input, including label and errors |
|
36 | + * |
|
37 | + * @param EE_Form_Input_Base $input |
|
38 | + * @return string |
|
39 | + * @throws \EE_Error |
|
40 | + */ |
|
41 | + public function layout_input($input) |
|
42 | + { |
|
43 | + $html = ''; |
|
44 | + // set something unique for the id |
|
45 | + $html_id = (string)$input->html_id() !== '' |
|
46 | + ? (string)$input->html_id() |
|
47 | + : spl_object_hash($input); |
|
48 | + // and add a generic class |
|
49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
50 | + if ($input instanceof EE_Hidden_Input) { |
|
51 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
52 | + } else if ($input instanceof EE_Submit_Input) { |
|
53 | + $html .= EEH_HTML::div( |
|
54 | + $input->get_html_for_input(), |
|
55 | + $html_id . '-submit-dv', |
|
56 | + $html_class |
|
57 | + ); |
|
58 | + } else if ($input instanceof EE_Select_Input) { |
|
59 | + $html .= EEH_HTML::div( |
|
60 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | + $html_id . '-input-dv', |
|
65 | + $html_class |
|
66 | + ); |
|
67 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
68 | + $html .= EEH_HTML::div( |
|
69 | + EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | + $html_id . '-input-dv', |
|
74 | + $html_class |
|
75 | + ); |
|
76 | + } else { |
|
77 | + $html .= EEH_HTML::div( |
|
78 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | + $html_id . '-input-dv', |
|
83 | + $html_class |
|
84 | + ); |
|
85 | + } |
|
86 | + return $html; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * |
|
93 | + * _display_label_for_option_type_question |
|
94 | + * Gets the HTML for the 'label', which is just text for this (because labels |
|
95 | + * should be for each input) |
|
96 | + * |
|
97 | + * @param EE_Form_Input_With_Options_Base $input |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
101 | + { |
|
102 | + if ($input->display_html_label_text() !== '') { |
|
103 | + return EEH_HTML::div( |
|
104 | + $input->required() |
|
105 | + ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
106 | + : $input->html_label_text(), |
|
107 | + $input->html_label_id(), |
|
108 | + $input->required() |
|
109 | + ? 'ee-required-label ' . $input->html_label_class() |
|
110 | + : $input->html_label_class(), |
|
111 | + $input->html_label_style(), |
|
112 | + $input->html_other_attributes() |
|
113 | + ); |
|
114 | + } |
|
115 | + return ''; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * Lays out a row for the subsection |
|
122 | + * |
|
123 | + * @param EE_Form_Section_Proper $form_section |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + public function layout_subsection($form_section) |
|
127 | + { |
|
128 | + // d( $form_section ); |
|
129 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * closing div tag for a form |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function layout_form_end() |
|
140 | + { |
|
141 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | 145 |
@@ -42,44 +42,44 @@ discard block |
||
42 | 42 | { |
43 | 43 | $html = ''; |
44 | 44 | // set something unique for the id |
45 | - $html_id = (string)$input->html_id() !== '' |
|
46 | - ? (string)$input->html_id() |
|
45 | + $html_id = (string) $input->html_id() !== '' |
|
46 | + ? (string) $input->html_id() |
|
47 | 47 | : spl_object_hash($input); |
48 | 48 | // and add a generic class |
49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv'; |
|
50 | 50 | if ($input instanceof EE_Hidden_Input) { |
51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
51 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
52 | 52 | } else if ($input instanceof EE_Submit_Input) { |
53 | 53 | $html .= EEH_HTML::div( |
54 | 54 | $input->get_html_for_input(), |
55 | - $html_id . '-submit-dv', |
|
55 | + $html_id.'-submit-dv', |
|
56 | 56 | $html_class |
57 | 57 | ); |
58 | 58 | } else if ($input instanceof EE_Select_Input) { |
59 | 59 | $html .= EEH_HTML::div( |
60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | - $html_id . '-input-dv', |
|
60 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
61 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
62 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
63 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
64 | + $html_id.'-input-dv', |
|
65 | 65 | $html_class |
66 | 66 | ); |
67 | 67 | } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
68 | 68 | $html .= EEH_HTML::div( |
69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | - $html_id . '-input-dv', |
|
69 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
70 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
71 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
72 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
73 | + $html_id.'-input-dv', |
|
74 | 74 | $html_class |
75 | 75 | ); |
76 | 76 | } else { |
77 | 77 | $html .= EEH_HTML::div( |
78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | - $html_id . '-input-dv', |
|
78 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
79 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
80 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
81 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
82 | + $html_id.'-input-dv', |
|
83 | 83 | $html_class |
84 | 84 | ); |
85 | 85 | } |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | if ($input->display_html_label_text() !== '') { |
103 | 103 | return EEH_HTML::div( |
104 | 104 | $input->required() |
105 | - ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
105 | + ? $input->html_label_text().EEH_HTML::span('*', '', 'ee-asterisk') |
|
106 | 106 | : $input->html_label_text(), |
107 | 107 | $input->html_label_id(), |
108 | 108 | $input->required() |
109 | - ? 'ee-required-label ' . $input->html_label_class() |
|
109 | + ? 'ee-required-label '.$input->html_label_class() |
|
110 | 110 | : $input->html_label_class(), |
111 | 111 | $input->html_label_style(), |
112 | 112 | $input->html_other_attributes() |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function layout_subsection($form_section) |
127 | 127 | { |
128 | 128 | // d( $form_section ); |
129 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
129 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 |
@@ -1047,11 +1047,11 @@ discard block |
||
1047 | 1047 | 'filter' |
1048 | 1048 | ); |
1049 | 1049 | return apply_filters( |
1050 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1051 | - $existing_attendee, $registration, $attendee_data |
|
1052 | - ); |
|
1050 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1051 | + $existing_attendee, $registration, $attendee_data |
|
1052 | + ); |
|
1053 | 1053 | }, |
1054 | - 10,3 |
|
1054 | + 10,3 |
|
1055 | 1055 | ); |
1056 | 1056 | |
1057 | 1057 | |
@@ -1064,88 +1064,88 @@ discard block |
||
1064 | 1064 | class EE_Event_List_Query extends WP_Query |
1065 | 1065 | { |
1066 | 1066 | |
1067 | - private $title; |
|
1068 | - |
|
1069 | - private $css_class; |
|
1070 | - |
|
1071 | - private $category_slug; |
|
1072 | - |
|
1073 | - /** |
|
1074 | - * EE_Event_List_Query constructor. |
|
1075 | - * |
|
1076 | - * @param array $args |
|
1077 | - */ |
|
1078 | - public function __construct($args = array()) |
|
1079 | - { |
|
1080 | - \EE_Error::doing_it_wrong( |
|
1081 | - __METHOD__, |
|
1082 | - __( |
|
1083 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1084 | - 'event_espresso' |
|
1085 | - ), |
|
1086 | - '4.9.27', |
|
1087 | - '5.0.0' |
|
1088 | - ); |
|
1089 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1090 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1091 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1092 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1093 | - // the current "page" we are viewing |
|
1094 | - $paged = max(1, get_query_var('paged')); |
|
1095 | - // Force these args |
|
1096 | - $args = array_merge( |
|
1097 | - $args, array( |
|
1098 | - 'post_type' => 'espresso_events', |
|
1099 | - 'posts_per_page' => $limit, |
|
1100 | - 'update_post_term_cache' => false, |
|
1101 | - 'update_post_meta_cache' => false, |
|
1102 | - 'paged' => $paged, |
|
1103 | - 'offset' => ($paged - 1) * $limit |
|
1104 | - ) |
|
1105 | - ); |
|
1106 | - // run the query |
|
1107 | - parent::__construct($args); |
|
1108 | - } |
|
1109 | - |
|
1110 | - |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * event_list_title |
|
1114 | - * |
|
1115 | - * @param string $event_list_title |
|
1116 | - * @return string |
|
1117 | - */ |
|
1118 | - public function event_list_title($event_list_title = '') |
|
1119 | - { |
|
1120 | - if (! empty($this->title)) { |
|
1121 | - return $this->title; |
|
1122 | - } |
|
1123 | - return $event_list_title; |
|
1124 | - } |
|
1125 | - |
|
1126 | - |
|
1127 | - |
|
1128 | - /** |
|
1129 | - * event_list_css |
|
1130 | - * |
|
1131 | - * @param string $event_list_css |
|
1132 | - * @return string |
|
1133 | - */ |
|
1134 | - public function event_list_css($event_list_css = '') |
|
1135 | - { |
|
1136 | - $event_list_css .= ! empty($event_list_css) |
|
1137 | - ? ' ' |
|
1138 | - : ''; |
|
1139 | - $event_list_css .= ! empty($this->css_class) |
|
1140 | - ? $this->css_class |
|
1141 | - : ''; |
|
1142 | - $event_list_css .= ! empty($event_list_css) |
|
1143 | - ? ' ' |
|
1144 | - : ''; |
|
1145 | - $event_list_css .= ! empty($this->category_slug) |
|
1146 | - ? $this->category_slug |
|
1147 | - : ''; |
|
1148 | - return $event_list_css; |
|
1149 | - } |
|
1067 | + private $title; |
|
1068 | + |
|
1069 | + private $css_class; |
|
1070 | + |
|
1071 | + private $category_slug; |
|
1072 | + |
|
1073 | + /** |
|
1074 | + * EE_Event_List_Query constructor. |
|
1075 | + * |
|
1076 | + * @param array $args |
|
1077 | + */ |
|
1078 | + public function __construct($args = array()) |
|
1079 | + { |
|
1080 | + \EE_Error::doing_it_wrong( |
|
1081 | + __METHOD__, |
|
1082 | + __( |
|
1083 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1084 | + 'event_espresso' |
|
1085 | + ), |
|
1086 | + '4.9.27', |
|
1087 | + '5.0.0' |
|
1088 | + ); |
|
1089 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1090 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1091 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1092 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1093 | + // the current "page" we are viewing |
|
1094 | + $paged = max(1, get_query_var('paged')); |
|
1095 | + // Force these args |
|
1096 | + $args = array_merge( |
|
1097 | + $args, array( |
|
1098 | + 'post_type' => 'espresso_events', |
|
1099 | + 'posts_per_page' => $limit, |
|
1100 | + 'update_post_term_cache' => false, |
|
1101 | + 'update_post_meta_cache' => false, |
|
1102 | + 'paged' => $paged, |
|
1103 | + 'offset' => ($paged - 1) * $limit |
|
1104 | + ) |
|
1105 | + ); |
|
1106 | + // run the query |
|
1107 | + parent::__construct($args); |
|
1108 | + } |
|
1109 | + |
|
1110 | + |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * event_list_title |
|
1114 | + * |
|
1115 | + * @param string $event_list_title |
|
1116 | + * @return string |
|
1117 | + */ |
|
1118 | + public function event_list_title($event_list_title = '') |
|
1119 | + { |
|
1120 | + if (! empty($this->title)) { |
|
1121 | + return $this->title; |
|
1122 | + } |
|
1123 | + return $event_list_title; |
|
1124 | + } |
|
1125 | + |
|
1126 | + |
|
1127 | + |
|
1128 | + /** |
|
1129 | + * event_list_css |
|
1130 | + * |
|
1131 | + * @param string $event_list_css |
|
1132 | + * @return string |
|
1133 | + */ |
|
1134 | + public function event_list_css($event_list_css = '') |
|
1135 | + { |
|
1136 | + $event_list_css .= ! empty($event_list_css) |
|
1137 | + ? ' ' |
|
1138 | + : ''; |
|
1139 | + $event_list_css .= ! empty($this->css_class) |
|
1140 | + ? $this->css_class |
|
1141 | + : ''; |
|
1142 | + $event_list_css .= ! empty($event_list_css) |
|
1143 | + ? ' ' |
|
1144 | + : ''; |
|
1145 | + $event_list_css .= ! empty($this->category_slug) |
|
1146 | + ? $this->category_slug |
|
1147 | + : ''; |
|
1148 | + return $event_list_css; |
|
1149 | + } |
|
1150 | 1150 | |
1151 | 1151 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $action_or_filter = 'action' |
44 | 44 | ) { |
45 | 45 | $action_or_filter = $action_or_filter === 'action' |
46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
46 | + ? esc_html__('action', 'event_espresso') |
|
47 | + : esc_html__('filter', 'event_espresso'); |
|
48 | 48 | EE_Error::doing_it_wrong( |
49 | 49 | $deprecated_filter, |
50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param \EE_Checkout $checkout |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
72 | 72 | // list of old filters |
73 | 73 | $deprecated_filters = array( |
74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | 'proceed_to' => true, |
79 | 79 | ); |
80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
82 | 82 | // was this filter called ? |
83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
86 | 86 | EE_Error::doing_it_wrong( |
87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
88 | 88 | sprintf( |
89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
91 | 91 | '<br />', |
92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ); |
97 | 97 | } |
98 | 98 | } else { |
99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
99 | + unset($deprecated_filters[$deprecated_filter]); |
|
100 | 100 | } |
101 | 101 | } |
102 | - if ( ! empty( $deprecated_filters )) { |
|
103 | - |
|
104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
102 | + if ( ! empty($deprecated_filters)) { |
|
103 | + |
|
104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
110 | 110 | } |
111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
114 | 114 | } |
115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return $submit_button_text; |
122 | 122 | |
123 | 123 | } |
124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | * @param \EE_Checkout $checkout |
133 | 133 | * @param boolean $status_updates |
134 | 134 | */ |
135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
136 | 136 | $action_ref = NULL; |
137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
139 | - if ( $action_ref ) { |
|
137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
139 | + if ($action_ref) { |
|
140 | 140 | |
141 | 141 | EE_Error::doing_it_wrong( |
142 | 142 | $action_ref, |
143 | 143 | sprintf( |
144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
145 | 145 | '<br />', |
146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
151 | 151 | ), |
152 | 152 | '4.6.0' |
153 | 153 | ); |
154 | - switch ( $action_ref ) { |
|
154 | + switch ($action_ref) { |
|
155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
157 | 157 | break; |
158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
160 | 160 | break; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
165 | 165 | /** |
166 | 166 | * ee_deprecated_finalize_registration |
167 | 167 | * |
168 | 168 | * @param EE_Registration $registration |
169 | 169 | */ |
170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
172 | - if ( $action_ref ) { |
|
170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
172 | + if ($action_ref) { |
|
173 | 173 | EE_Error::doing_it_wrong( |
174 | 174 | $action_ref, |
175 | 175 | sprintf( |
176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
177 | 177 | '<br />', |
178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
180 | 180 | ), |
181 | 181 | '4.6.0' |
182 | 182 | ); |
183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
184 | 184 | } |
185 | 185 | } |
186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
193 | 193 | */ |
194 | -function ee_deprecated_hooks(){ |
|
194 | +function ee_deprecated_hooks() { |
|
195 | 195 | /** |
196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | $hooks = array( |
203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
204 | 204 | 'version' => '4.6.0', |
205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
206 | 206 | 'still_works' => FALSE |
207 | 207 | ) |
208 | 208 | ); |
209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
210 | - if( has_action( $name ) ){ |
|
209 | + foreach ($hooks as $name => $deprecation_info) { |
|
210 | + if (has_action($name)) { |
|
211 | 211 | EE_Error::doing_it_wrong( |
212 | 212 | $name, |
213 | 213 | sprintf( |
214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
217 | 217 | ), |
218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
219 | 219 | ); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
224 | 224 | |
225 | 225 | |
226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @return boolean |
232 | 232 | */ |
233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
236 | - if( $in_use ) { |
|
234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
236 | + if ($in_use) { |
|
237 | 237 | $msg = __( |
238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | 'event_espresso' ) |
243 | 243 | ; |
244 | 244 | EE_Error::doing_it_wrong( |
245 | - __CLASS__ . '::' . __FUNCTION__, |
|
245 | + __CLASS__.'::'.__FUNCTION__, |
|
246 | 246 | $msg, |
247 | 247 | '4.8.32.rc.000' |
248 | 248 | ); |
249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | return $in_use; |
255 | 255 | } |
256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
262 | 262 | * @param EE_Admin_Page $admin_page |
263 | 263 | * @return void |
264 | 264 | */ |
265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
266 | 266 | //check if the old hooks are in use. If not, do the default |
267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | $req_data = $admin_page->get_request_data(); |
272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
275 | - if ( ! $REG_ID || ! $qstns ) { |
|
276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
275 | + if ( ! $REG_ID || ! $qstns) { |
|
276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
277 | 277 | } |
278 | 278 | $success = TRUE; |
279 | 279 | |
280 | 280 | // allow others to get in on this awesome fun :D |
281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
282 | 282 | // loop thru questions... FINALLY!!! |
283 | 283 | |
284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
286 | - if ( !is_array($qstn) ) { |
|
287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
286 | + if ( ! is_array($qstn)) { |
|
287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | |
292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
293 | 293 | //get answer |
294 | 294 | $query_params = array( |
295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ); |
301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
303 | - if ( ! $answer instanceof EE_Answer ) { |
|
303 | + if ( ! $answer instanceof EE_Answer) { |
|
304 | 304 | $set_values = array( |
305 | 305 | 'QST_ID' => $QST_ID, |
306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | } |
316 | 316 | } |
317 | 317 | $what = __('Registration Form', 'event_espresso'); |
318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
320 | 320 | exit; |
321 | 321 | } |
322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
323 | 323 | /** |
324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
332 | 332 | * @return bool |
333 | 333 | * @throws \EE_Error |
334 | 334 | */ |
335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
336 | 336 | //check if the old hooks are in use. If not, do the default |
337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
339 | 339 | return $do_default_action; |
340 | 340 | } |
341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
345 | 345 | |
346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
347 | 347 | |
348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
349 | 349 | $template_args = array( |
350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
352 | 352 | 'REG_ID' => $registration->ID() |
353 | 353 | ); |
354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
356 | 356 | //indicate that we should not do the default admin page code |
357 | 357 | return false; |
358 | 358 | } |
359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | '4.9.0' |
398 | 398 | ); |
399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
403 | 403 | return EE_Registry::instance()->load_lib( |
404 | 404 | 'Messages_Template_Defaults', |
405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | /** |
465 | 465 | * @param string $method |
466 | 466 | */ |
467 | - public function _class_is_deprecated( $method ) { |
|
467 | + public function _class_is_deprecated($method) { |
|
468 | 468 | EE_Error::doing_it_wrong( |
469 | - 'EE_messages::' . $method, |
|
470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
469 | + 'EE_messages::'.$method, |
|
470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
471 | 471 | '4.9.0', |
472 | 472 | '4.10.0.p' |
473 | 473 | ); |
474 | 474 | // Please use EE_Message_Resource_Manager instead |
475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | * @param string $messenger_name |
483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
484 | 484 | */ |
485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
485 | + public function ensure_messenger_is_active($messenger_name) { |
|
486 | 486 | // EE_messages has been deprecated |
487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
498 | 498 | * @throws \EE_Error |
499 | 499 | */ |
500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
501 | 501 | // EE_messages has been deprecated |
502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | * they are already setup.) |
514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
515 | 515 | */ |
516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
517 | 517 | // EE_messages has been deprecated |
518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
530 | 530 | */ |
531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
532 | 532 | // EE_messages has been deprecated |
533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | * @param string $messenger |
542 | 542 | * @return EE_messenger | null |
543 | 543 | */ |
544 | - public function get_messenger_if_active( $messenger ) { |
|
544 | + public function get_messenger_if_active($messenger) { |
|
545 | 545 | // EE_messages has been deprecated |
546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | * 'message_type' => null |
566 | 566 | * ) |
567 | 567 | */ |
568 | - public function validate_for_use( EE_Message $message ) { |
|
568 | + public function validate_for_use(EE_Message $message) { |
|
569 | 569 | // EE_messages has been deprecated |
570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
571 | 571 | return array( |
572 | 572 | 'messenger' => $message->messenger_object(), |
573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
595 | 595 | $send = true |
596 | 596 | ) { |
597 | 597 | // EE_messages has been deprecated |
598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
599 | 599 | /** @type EE_Messages_Processor $processor */ |
600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
601 | 601 | $error = false; |
602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
603 | 603 | //if generating and sending are different then generate and send immediately. |
604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
606 | 606 | //vars are already in the request object. So let's just use that. |
607 | 607 | try { |
608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
610 | - $processor->generate_and_send_now( $mtg ); |
|
611 | - } catch ( EE_Error $e ) { |
|
609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
610 | + $processor->generate_and_send_now($mtg); |
|
611 | + } catch (EE_Error $e) { |
|
612 | 612 | $error_msg = __( |
613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
614 | 614 | 'event_espresso' |
615 | 615 | ); |
616 | 616 | // add specific message for developers if WP_DEBUG in on |
617 | - $error_msg .= '||' . $e->getMessage(); |
|
618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
617 | + $error_msg .= '||'.$e->getMessage(); |
|
618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
619 | 619 | $error = true; |
620 | 620 | } |
621 | 621 | } else { |
622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
626 | 626 | ); |
627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
629 | 629 | $count_errors = $count_errors + $count_retry; |
630 | - if ( $count_errors > 0 ) { |
|
630 | + if ($count_errors > 0) { |
|
631 | 631 | $error = true; |
632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
633 | 633 | $message = sprintf( |
634 | 634 | __( |
635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | $count_errors, |
639 | 639 | $count_queued |
640 | 640 | ); |
641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
642 | 642 | $message = sprintf( |
643 | 643 | __( |
644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $count_errors, |
648 | 648 | $count_queued |
649 | 649 | ); |
650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
651 | 651 | $message = sprintf( |
652 | 652 | __( |
653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
665 | 665 | $count_errors |
666 | 666 | ); |
667 | 667 | } |
668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
669 | 669 | } else { |
670 | - if ( $count_queued === 1 ) { |
|
670 | + if ($count_queued === 1) { |
|
671 | 671 | $message = sprintf( |
672 | 672 | __( |
673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
684 | 684 | $count_queued |
685 | 685 | ); |
686 | 686 | } |
687 | - EE_Error::add_success( $message ); |
|
687 | + EE_Error::add_success($message); |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | //if no error then return the generated message(s). |
691 | - if ( ! $error && ! $send ) { |
|
692 | - $generated_queue = $processor->generate_queue( false ); |
|
691 | + if ( ! $error && ! $send) { |
|
692 | + $generated_queue = $processor->generate_queue(false); |
|
693 | 693 | //get message and return. |
694 | 694 | $generated_queue->get_message_repository()->rewind(); |
695 | 695 | $messages = array(); |
696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
698 | - if ( $message instanceof EE_Message ) { |
|
698 | + if ($message instanceof EE_Message) { |
|
699 | 699 | //set properties that might be expected by add-ons (backward compat) |
700 | 700 | $message->content = $message->content(); |
701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
721 | 721 | * @return string The body of the message. |
722 | 722 | */ |
723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
724 | 724 | // EE_messages has been deprecated |
725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return bool success or fail. |
739 | 739 | */ |
740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
741 | 741 | // EE_messages has been deprecated |
742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
743 | 743 | //setup for sending to new method. |
744 | 744 | /** @type EE_Messages_Queue $queue */ |
745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
746 | 746 | //make sure we have a proper message object |
747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
748 | 748 | $msg = EE_Message_Factory::create( |
749 | 749 | array( |
750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | } else { |
757 | 757 | $msg = $message; |
758 | 758 | } |
759 | - if ( ! $msg instanceof EE_Message ) { |
|
759 | + if ( ! $msg instanceof EE_Message) { |
|
760 | 760 | return false; |
761 | 761 | } |
762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
763 | - if ( ! empty( $msg->content ) ) { |
|
764 | - $msg->set( 'MSG_content', $msg->content ); |
|
763 | + if ( ! empty($msg->content)) { |
|
764 | + $msg->set('MSG_content', $msg->content); |
|
765 | 765 | } |
766 | - $queue->add( $msg ); |
|
767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
766 | + $queue->add($msg); |
|
767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
779 | 779 | * @throws \EE_Error |
780 | 780 | */ |
781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
782 | 782 | // EE_messages has been deprecated |
783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | * @param string $message_type_name name of EE_message_type |
794 | 794 | * @return array |
795 | 795 | */ |
796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
796 | + public function get_fields($messenger_name, $message_type_name) { |
|
797 | 797 | // EE_messages has been deprecated |
798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
811 | 811 | * @return array multidimensional array of messenger and message_type objects |
812 | 812 | * (messengers index, and message_type index); |
813 | 813 | */ |
814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
815 | 815 | // EE_messages has been deprecated |
816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
817 | - if ( $skip_cache ) { |
|
816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
817 | + if ($skip_cache) { |
|
818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
819 | 819 | } |
820 | - switch ( $type ) { |
|
820 | + switch ($type) { |
|
821 | 821 | case 'messengers' : |
822 | 822 | return array( |
823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | */ |
847 | 847 | public function get_active_messengers() { |
848 | 848 | // EE_messages has been deprecated |
849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
850 | 850 | return $this->_message_resource_manager->active_messengers(); |
851 | 851 | } |
852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | public function get_active_message_types() { |
860 | 860 | // EE_messages has been deprecated |
861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
863 | 863 | } |
864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | */ |
871 | 871 | public function get_active_message_type_objects() { |
872 | 872 | // EE_messages has been deprecated |
873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
875 | 875 | } |
876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
882 | 882 | * @param string $messenger The messenger being checked |
883 | 883 | * @return EE_message_type[] (or empty array if none present) |
884 | 884 | */ |
885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
885 | + public function get_active_message_types_per_messenger($messenger) { |
|
886 | 886 | // EE_messages has been deprecated |
887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
896 | 896 | * @param string $message_type The string should correspond to a message type. |
897 | 897 | * @return EE_message_type|null |
898 | 898 | */ |
899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
899 | + public function get_active_message_type($messenger, $message_type) { |
|
900 | 900 | // EE_messages has been deprecated |
901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | */ |
911 | 911 | public function get_installed_message_types() { |
912 | 912 | // EE_messages has been deprecated |
913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
915 | 915 | } |
916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | */ |
923 | 923 | public function get_installed_messengers() { |
924 | 924 | // EE_messages has been deprecated |
925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
927 | 927 | } |
928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
934 | 934 | * @return array |
935 | 935 | */ |
936 | - public function get_all_contexts( $slugs_only = true ) { |
|
936 | + public function get_all_contexts($slugs_only = true) { |
|
937 | 937 | // EE_messages has been deprecated |
938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | add_filter( |
996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
997 | 997 | function($event_list_iframe_css) { |
998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
999 | 999 | return $event_list_iframe_css; |
1000 | 1000 | } |
1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | add_filter( |
1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
1017 | 1017 | function($event_list_iframe_js) { |
1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1019 | 1019 | return $event_list_iframe_js; |
1020 | 1020 | } |
1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | add_filter( |
1036 | 1036 | 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
1037 | 1037 | function($existing_attendee, $registration, $attendee_data) { |
1038 | - if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) { |
|
1038 | + if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1039 | 1039 | return $existing_attendee; |
1040 | 1040 | } |
1041 | 1041 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $existing_attendee, $registration, $attendee_data |
1052 | 1052 | ); |
1053 | 1053 | }, |
1054 | - 10,3 |
|
1054 | + 10, 3 |
|
1055 | 1055 | ); |
1056 | 1056 | |
1057 | 1057 | |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | */ |
1118 | 1118 | public function event_list_title($event_list_title = '') |
1119 | 1119 | { |
1120 | - if (! empty($this->title)) { |
|
1120 | + if ( ! empty($this->title)) { |
|
1121 | 1121 | return $this->title; |
1122 | 1122 | } |
1123 | 1123 | return $event_list_title; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('No direct script access allowed'); |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -15,1690 +15,1690 @@ discard block |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Used to reference when a registration has never been checked in. |
|
20 | - * |
|
21 | - * @type int |
|
22 | - */ |
|
23 | - const checkin_status_never = 2; |
|
24 | - |
|
25 | - /** |
|
26 | - * Used to reference when a registration has been checked in. |
|
27 | - * |
|
28 | - * @type int |
|
29 | - */ |
|
30 | - const checkin_status_in = 1; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Used to reference when a registration has been checked out. |
|
35 | - * |
|
36 | - * @type int |
|
37 | - */ |
|
38 | - const checkin_status_out = 0; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * extra meta key for tracking reg status os trashed registrations |
|
43 | - * |
|
44 | - * @type string |
|
45 | - */ |
|
46 | - const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * extra meta key for tracking if registration has reserved ticket |
|
51 | - * |
|
52 | - * @type string |
|
53 | - */ |
|
54 | - const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @param array $props_n_values incoming values |
|
59 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | - * used.) |
|
61 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | - * date_format and the second value is the time format |
|
63 | - * @return EE_Registration |
|
64 | - */ |
|
65 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | - { |
|
67 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
68 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param array $props_n_values incoming values from the database |
|
74 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
75 | - * the website will be used. |
|
76 | - * @return EE_Registration |
|
77 | - */ |
|
78 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
79 | - { |
|
80 | - return new self($props_n_values, true, $timezone); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Set Event ID |
|
86 | - * |
|
87 | - * @param int $EVT_ID Event ID |
|
88 | - */ |
|
89 | - public function set_event($EVT_ID = 0) |
|
90 | - { |
|
91 | - $this->set('EVT_ID', $EVT_ID); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
97 | - * be routed to internal methods |
|
98 | - * |
|
99 | - * @param string $field_name |
|
100 | - * @param mixed $field_value |
|
101 | - * @param bool $use_default |
|
102 | - * @throws \EE_Error |
|
103 | - * @throws \RuntimeException |
|
104 | - */ |
|
105 | - public function set($field_name, $field_value, $use_default = false) |
|
106 | - { |
|
107 | - switch ($field_name) { |
|
108 | - case 'REG_code' : |
|
109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
110 | - $this->set_reg_code($field_value, $use_default); |
|
111 | - } |
|
112 | - break; |
|
113 | - case 'STS_ID' : |
|
114 | - $this->set_status($field_value, $use_default); |
|
115 | - break; |
|
116 | - default : |
|
117 | - parent::set($field_name, $field_value, $use_default); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Set Status ID |
|
124 | - * updates the registration status and ALSO... |
|
125 | - * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
126 | - * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
127 | - * |
|
128 | - * @param string $new_STS_ID |
|
129 | - * @param boolean $use_default |
|
130 | - * @return bool |
|
131 | - * @throws \RuntimeException |
|
132 | - * @throws \EE_Error |
|
133 | - */ |
|
134 | - public function set_status($new_STS_ID = null, $use_default = false) |
|
135 | - { |
|
136 | - // get current REG_Status |
|
137 | - $old_STS_ID = $this->status_ID(); |
|
138 | - // if status has changed |
|
139 | - if ( |
|
140 | - $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
141 | - && ! empty($old_STS_ID) // and that old status is actually set |
|
142 | - && ! empty($new_STS_ID) // as well as the new status |
|
143 | - && $this->ID() // ensure registration is in the db |
|
144 | - ) { |
|
145 | - // TO approved |
|
146 | - if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
147 | - // reserve a space by incrementing ticket and datetime sold values |
|
148 | - $this->_reserve_registration_space(); |
|
149 | - do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
150 | - // OR FROM approved |
|
151 | - } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
152 | - // release a space by decrementing ticket and datetime sold values |
|
153 | - $this->_release_registration_space(); |
|
154 | - do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
155 | - } |
|
156 | - // update status |
|
157 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
158 | - $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
159 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
160 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
161 | - $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
162 | - $this->transaction()->update_status_based_on_total_paid(true); |
|
163 | - do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID); |
|
164 | - return true; |
|
165 | - } |
|
166 | - //even though the old value matches the new value, it's still good to |
|
167 | - //allow the parent set method to have a say |
|
168 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
169 | - return true; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * update REGs and TXN when cancelled or declined registrations involved |
|
175 | - * |
|
176 | - * @param string $new_STS_ID |
|
177 | - * @param string $old_STS_ID |
|
178 | - * @throws \EE_Error |
|
179 | - */ |
|
180 | - private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
181 | - { |
|
182 | - // these reg statuses should not be considered in any calculations involving monies owing |
|
183 | - $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
184 | - // true if registration has been cancelled or declined |
|
185 | - if ( |
|
186 | - in_array($new_STS_ID, $closed_reg_statuses, true) |
|
187 | - && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
188 | - ) { |
|
189 | - /** @type EE_Registration_Processor $registration_processor */ |
|
190 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
191 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
192 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
193 | - // cancelled or declined registration |
|
194 | - $registration_processor->update_registration_after_being_canceled_or_declined( |
|
195 | - $this, |
|
196 | - $closed_reg_statuses |
|
197 | - ); |
|
198 | - $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
199 | - $this, |
|
200 | - $closed_reg_statuses, |
|
201 | - false |
|
202 | - ); |
|
203 | - do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
204 | - return; |
|
205 | - } |
|
206 | - // true if reinstating cancelled or declined registration |
|
207 | - if ( |
|
208 | - in_array($old_STS_ID, $closed_reg_statuses, true) |
|
209 | - && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
210 | - ) { |
|
211 | - /** @type EE_Registration_Processor $registration_processor */ |
|
212 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
213 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
214 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
215 | - // reinstating cancelled or declined registration |
|
216 | - $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
217 | - $this, |
|
218 | - $closed_reg_statuses |
|
219 | - ); |
|
220 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
221 | - $this, |
|
222 | - $closed_reg_statuses, |
|
223 | - false |
|
224 | - ); |
|
225 | - do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * get Status ID |
|
232 | - */ |
|
233 | - public function status_ID() |
|
234 | - { |
|
235 | - return $this->get('STS_ID'); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * increments this registration's related ticket sold and corresponding datetime sold values |
|
241 | - * |
|
242 | - * @return void |
|
243 | - * @throws \EE_Error |
|
244 | - */ |
|
245 | - private function _reserve_registration_space() |
|
246 | - { |
|
247 | - // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
248 | - // so stop tracking that this reg has a ticket reserved |
|
249 | - $this->release_reserved_ticket(); |
|
250 | - $ticket = $this->ticket(); |
|
251 | - $ticket->increase_sold(); |
|
252 | - $ticket->save(); |
|
253 | - // possibly set event status to sold out |
|
254 | - $this->event()->perform_sold_out_status_check(); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Gets the ticket this registration is for |
|
260 | - * |
|
261 | - * @param boolean $include_archived whether to include archived tickets or not. |
|
262 | - * @return EE_Ticket|EE_Base_Class |
|
263 | - * @throws \EE_Error |
|
264 | - */ |
|
265 | - public function ticket($include_archived = true) |
|
266 | - { |
|
267 | - $query_params = array(); |
|
268 | - if ($include_archived) { |
|
269 | - $query_params['default_where_conditions'] = 'none'; |
|
270 | - } |
|
271 | - return $this->get_first_related('Ticket', $query_params); |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Gets the event this registration is for |
|
277 | - * |
|
278 | - * @return EE_Event |
|
279 | - */ |
|
280 | - public function event() |
|
281 | - { |
|
282 | - $event = $this->get_first_related('Event'); |
|
283 | - if (! $event instanceof \EE_Event) { |
|
284 | - throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
285 | - } |
|
286 | - return $event; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
292 | - * with the author of the event this registration is for. |
|
293 | - * |
|
294 | - * @since 4.5.0 |
|
295 | - * @return int |
|
296 | - */ |
|
297 | - public function wp_user() |
|
298 | - { |
|
299 | - $event = $this->event(); |
|
300 | - if ($event instanceof EE_Event) { |
|
301 | - return $event->wp_user(); |
|
302 | - } |
|
303 | - return 0; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
309 | - * |
|
310 | - * @return void |
|
311 | - * @throws \EE_Error |
|
312 | - */ |
|
313 | - private function _release_registration_space() |
|
314 | - { |
|
315 | - $ticket = $this->ticket(); |
|
316 | - $ticket->decrease_sold(); |
|
317 | - $ticket->save(); |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * tracks this registration's ticket reservation in extra meta |
|
323 | - * and can increment related ticket reserved and corresponding datetime reserved values |
|
324 | - * |
|
325 | - * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
326 | - * @return void |
|
327 | - * @throws \EE_Error |
|
328 | - */ |
|
329 | - public function reserve_ticket($update_ticket = false) |
|
330 | - { |
|
331 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
332 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
333 | - // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
334 | - if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
335 | - $ticket = $this->ticket(); |
|
336 | - $ticket->increase_reserved(); |
|
337 | - $ticket->save(); |
|
338 | - } |
|
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * stops tracking this registration's ticket reservation in extra meta |
|
345 | - * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
346 | - * |
|
347 | - * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
348 | - * @return void |
|
349 | - * @throws \EE_Error |
|
350 | - */ |
|
351 | - public function release_reserved_ticket($update_ticket = false) |
|
352 | - { |
|
353 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
354 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
355 | - // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
356 | - if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
357 | - $ticket = $this->ticket(); |
|
358 | - $ticket->decrease_reserved(); |
|
359 | - $ticket->save(); |
|
360 | - } |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * Set Attendee ID |
|
367 | - * |
|
368 | - * @param int $ATT_ID Attendee ID |
|
369 | - */ |
|
370 | - public function set_attendee_id($ATT_ID = 0) |
|
371 | - { |
|
372 | - $this->set('ATT_ID', $ATT_ID); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Set Transaction ID |
|
378 | - * |
|
379 | - * @param int $TXN_ID Transaction ID |
|
380 | - */ |
|
381 | - public function set_transaction_id($TXN_ID = 0) |
|
382 | - { |
|
383 | - $this->set('TXN_ID', $TXN_ID); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * Set Session |
|
389 | - * |
|
390 | - * @param string $REG_session PHP Session ID |
|
391 | - */ |
|
392 | - public function set_session($REG_session = '') |
|
393 | - { |
|
394 | - $this->set('REG_session', $REG_session); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * Set Registration URL Link |
|
400 | - * |
|
401 | - * @param string $REG_url_link Registration URL Link |
|
402 | - */ |
|
403 | - public function set_reg_url_link($REG_url_link = '') |
|
404 | - { |
|
405 | - $this->set('REG_url_link', $REG_url_link); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * Set Attendee Counter |
|
411 | - * |
|
412 | - * @param int $REG_count Primary Attendee |
|
413 | - */ |
|
414 | - public function set_count($REG_count = 1) |
|
415 | - { |
|
416 | - $this->set('REG_count', $REG_count); |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * Set Group Size |
|
422 | - * |
|
423 | - * @param boolean $REG_group_size Group Registration |
|
424 | - */ |
|
425 | - public function set_group_size($REG_group_size = false) |
|
426 | - { |
|
427 | - $this->set('REG_group_size', $REG_group_size); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
433 | - * EEM_Registration::status_id_not_approved |
|
434 | - * |
|
435 | - * @return boolean |
|
436 | - */ |
|
437 | - public function is_not_approved() |
|
438 | - { |
|
439 | - return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
445 | - * EEM_Registration::status_id_pending_payment |
|
446 | - * |
|
447 | - * @return boolean |
|
448 | - */ |
|
449 | - public function is_pending_payment() |
|
450 | - { |
|
451 | - return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
457 | - * |
|
458 | - * @return boolean |
|
459 | - */ |
|
460 | - public function is_approved() |
|
461 | - { |
|
462 | - return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
468 | - * |
|
469 | - * @return boolean |
|
470 | - */ |
|
471 | - public function is_cancelled() |
|
472 | - { |
|
473 | - return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
474 | - } |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
479 | - * |
|
480 | - * @return boolean |
|
481 | - */ |
|
482 | - public function is_declined() |
|
483 | - { |
|
484 | - return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
490 | - * EEM_Registration::status_id_incomplete |
|
491 | - * |
|
492 | - * @return boolean |
|
493 | - */ |
|
494 | - public function is_incomplete() |
|
495 | - { |
|
496 | - return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * Set Registration Date |
|
502 | - * |
|
503 | - * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
504 | - * Date |
|
505 | - */ |
|
506 | - public function set_reg_date($REG_date = false) |
|
507 | - { |
|
508 | - $this->set('REG_date', $REG_date); |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * Set final price owing for this registration after all ticket/price modifications |
|
514 | - * |
|
515 | - * @access public |
|
516 | - * @param float $REG_final_price |
|
517 | - */ |
|
518 | - public function set_final_price($REG_final_price = 0.00) |
|
519 | - { |
|
520 | - $this->set('REG_final_price', $REG_final_price); |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - /** |
|
525 | - * Set amount paid towards this registration's final price |
|
526 | - * |
|
527 | - * @access public |
|
528 | - * @param float $REG_paid |
|
529 | - */ |
|
530 | - public function set_paid($REG_paid = 0.00) |
|
531 | - { |
|
532 | - $this->set('REG_paid', $REG_paid); |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * Attendee Is Going |
|
538 | - * |
|
539 | - * @param boolean $REG_att_is_going Attendee Is Going |
|
540 | - */ |
|
541 | - public function set_att_is_going($REG_att_is_going = false) |
|
542 | - { |
|
543 | - $this->set('REG_att_is_going', $REG_att_is_going); |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * Gets the related attendee |
|
549 | - * |
|
550 | - * @return EE_Attendee |
|
551 | - */ |
|
552 | - public function attendee() |
|
553 | - { |
|
554 | - return $this->get_first_related('Attendee'); |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * get Event ID |
|
560 | - */ |
|
561 | - public function event_ID() |
|
562 | - { |
|
563 | - return $this->get('EVT_ID'); |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - /** |
|
568 | - * get Event ID |
|
569 | - */ |
|
570 | - public function event_name() |
|
571 | - { |
|
572 | - $event = $this->event_obj(); |
|
573 | - if ($event) { |
|
574 | - return $event->name(); |
|
575 | - } else { |
|
576 | - return null; |
|
577 | - } |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * Fetches the event this registration is for |
|
583 | - * |
|
584 | - * @return EE_Event |
|
585 | - */ |
|
586 | - public function event_obj() |
|
587 | - { |
|
588 | - return $this->get_first_related('Event'); |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * get Attendee ID |
|
594 | - */ |
|
595 | - public function attendee_ID() |
|
596 | - { |
|
597 | - return $this->get('ATT_ID'); |
|
598 | - } |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * get PHP Session ID |
|
603 | - */ |
|
604 | - public function session_ID() |
|
605 | - { |
|
606 | - return $this->get('REG_session'); |
|
607 | - } |
|
608 | - |
|
609 | - |
|
610 | - /** |
|
611 | - * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
612 | - * |
|
613 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
614 | - * @return string |
|
615 | - */ |
|
616 | - public function receipt_url($messenger = 'html') |
|
617 | - { |
|
618 | - |
|
619 | - /** |
|
620 | - * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
621 | - * |
|
622 | - * @since 4.5.0 |
|
623 | - */ |
|
624 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
625 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
626 | - |
|
627 | - if ($has_custom) { |
|
628 | - return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
629 | - } |
|
630 | - return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
631 | - } |
|
632 | - |
|
633 | - |
|
634 | - /** |
|
635 | - * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
636 | - * |
|
637 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
638 | - * @return string |
|
639 | - */ |
|
640 | - public function invoice_url($messenger = 'html') |
|
641 | - { |
|
642 | - /** |
|
643 | - * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
644 | - * |
|
645 | - * @since 4.5.0 |
|
646 | - */ |
|
647 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
648 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
649 | - |
|
650 | - if ($has_custom) { |
|
651 | - if ($messenger == 'html') { |
|
652 | - return $this->invoice_url('launch'); |
|
653 | - } |
|
654 | - $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
655 | - |
|
656 | - $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
657 | - if ($messenger == 'html') { |
|
658 | - $query_args['html'] = true; |
|
659 | - } |
|
660 | - return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
661 | - } |
|
662 | - return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
663 | - } |
|
664 | - |
|
665 | - |
|
666 | - /** |
|
667 | - * get Registration URL Link |
|
668 | - * |
|
669 | - * @access public |
|
670 | - * @return string |
|
671 | - * @throws \EE_Error |
|
672 | - */ |
|
673 | - public function reg_url_link() |
|
674 | - { |
|
675 | - return (string)$this->get('REG_url_link'); |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * Echoes out invoice_url() |
|
681 | - * |
|
682 | - * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
683 | - * @return void |
|
684 | - */ |
|
685 | - public function e_invoice_url($type = 'launch') |
|
686 | - { |
|
687 | - echo $this->invoice_url($type); |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * Echoes out payment_overview_url |
|
693 | - */ |
|
694 | - public function e_payment_overview_url() |
|
695 | - { |
|
696 | - echo $this->payment_overview_url(); |
|
697 | - } |
|
698 | - |
|
699 | - |
|
700 | - /** |
|
701 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
702 | - * a query parameter |
|
703 | - * |
|
704 | - * @return string |
|
705 | - */ |
|
706 | - public function payment_overview_url() |
|
707 | - { |
|
708 | - return add_query_arg(array( |
|
709 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
710 | - 'step' => 'payment_options', |
|
711 | - 'revisit' => true, |
|
712 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
713 | - } |
|
714 | - |
|
715 | - |
|
716 | - /** |
|
717 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
718 | - * a query parameter |
|
719 | - * |
|
720 | - * @return string |
|
721 | - */ |
|
722 | - public function edit_attendee_information_url() |
|
723 | - { |
|
724 | - return add_query_arg(array( |
|
725 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
726 | - 'step' => 'attendee_information', |
|
727 | - 'revisit' => true, |
|
728 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
729 | - } |
|
730 | - |
|
731 | - |
|
732 | - /** |
|
733 | - * Simply generates and returns the appropriate admin_url link to edit this registration |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public function get_admin_edit_url() |
|
738 | - { |
|
739 | - return EEH_URL::add_query_args_and_nonce(array( |
|
740 | - 'page' => 'espresso_registrations', |
|
741 | - 'action' => 'view_registration', |
|
742 | - '_REG_ID' => $this->ID(), |
|
743 | - ), admin_url('admin.php')); |
|
744 | - } |
|
745 | - |
|
746 | - |
|
747 | - /** |
|
748 | - * is_primary_registrant? |
|
749 | - */ |
|
750 | - public function is_primary_registrant() |
|
751 | - { |
|
752 | - return $this->get('REG_count') == 1 ? true : false; |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - /** |
|
757 | - * This returns the primary registration object for this registration group (which may be this object). |
|
758 | - * |
|
759 | - * @return EE_Registration |
|
760 | - */ |
|
761 | - public function get_primary_registration() |
|
762 | - { |
|
763 | - if ($this->is_primary_registrant()) { |
|
764 | - return $this; |
|
765 | - } |
|
766 | - |
|
767 | - //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
768 | - $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
769 | - array( |
|
770 | - 'TXN_ID' => $this->transaction_ID(), |
|
771 | - 'REG_count' => 1, |
|
772 | - ), |
|
773 | - )); |
|
774 | - return $primary_registrant; |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - /** |
|
779 | - * get Attendee Number |
|
780 | - * |
|
781 | - * @access public |
|
782 | - */ |
|
783 | - public function count() |
|
784 | - { |
|
785 | - return $this->get('REG_count'); |
|
786 | - } |
|
787 | - |
|
788 | - |
|
789 | - /** |
|
790 | - * get Group Size |
|
791 | - */ |
|
792 | - public function group_size() |
|
793 | - { |
|
794 | - return $this->get('REG_group_size'); |
|
795 | - } |
|
796 | - |
|
797 | - |
|
798 | - /** |
|
799 | - * get Registration Date |
|
800 | - */ |
|
801 | - public function date() |
|
802 | - { |
|
803 | - return $this->get('REG_date'); |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - /** |
|
808 | - * gets a pretty date |
|
809 | - * |
|
810 | - * @param string $date_format |
|
811 | - * @param string $time_format |
|
812 | - * @return string |
|
813 | - */ |
|
814 | - public function pretty_date($date_format = null, $time_format = null) |
|
815 | - { |
|
816 | - return $this->get_datetime('REG_date', $date_format, $time_format); |
|
817 | - } |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * final_price |
|
822 | - * the registration's share of the transaction total, so that the |
|
823 | - * sum of all the transaction's REG_final_prices equal the transaction's total |
|
824 | - * |
|
825 | - * @return float |
|
826 | - */ |
|
827 | - public function final_price() |
|
828 | - { |
|
829 | - return $this->get('REG_final_price'); |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - /** |
|
834 | - * pretty_final_price |
|
835 | - * final price as formatted string, with correct decimal places and currency symbol |
|
836 | - * |
|
837 | - * @return string |
|
838 | - */ |
|
839 | - public function pretty_final_price() |
|
840 | - { |
|
841 | - return $this->get_pretty('REG_final_price'); |
|
842 | - } |
|
843 | - |
|
844 | - |
|
845 | - /** |
|
846 | - * get paid (yeah) |
|
847 | - * |
|
848 | - * @return float |
|
849 | - */ |
|
850 | - public function paid() |
|
851 | - { |
|
852 | - return $this->get('REG_paid'); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * pretty_paid |
|
858 | - * |
|
859 | - * @return float |
|
860 | - */ |
|
861 | - public function pretty_paid() |
|
862 | - { |
|
863 | - return $this->get_pretty('REG_paid'); |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - /** |
|
868 | - * owes_monies_and_can_pay |
|
869 | - * whether or not this registration has monies owing and it's' status allows payment |
|
870 | - * |
|
871 | - * @param array $requires_payment |
|
872 | - * @return bool |
|
873 | - */ |
|
874 | - public function owes_monies_and_can_pay($requires_payment = array()) |
|
875 | - { |
|
876 | - // these reg statuses require payment (if event is not free) |
|
877 | - $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
878 | - if ( |
|
879 | - in_array($this->status_ID(), $requires_payment) && |
|
880 | - $this->final_price() != 0 && |
|
881 | - $this->final_price() != $this->paid() |
|
882 | - ) { |
|
883 | - return true; |
|
884 | - } else { |
|
885 | - return false; |
|
886 | - } |
|
887 | - } |
|
888 | - |
|
889 | - |
|
890 | - /** |
|
891 | - * Prints out the return value of $this->pretty_status() |
|
892 | - * |
|
893 | - * @param bool $show_icons |
|
894 | - * @return void |
|
895 | - */ |
|
896 | - public function e_pretty_status($show_icons = false) |
|
897 | - { |
|
898 | - echo $this->pretty_status($show_icons); |
|
899 | - } |
|
900 | - |
|
901 | - |
|
902 | - /** |
|
903 | - * Returns a nice version of the status for displaying to customers |
|
904 | - * |
|
905 | - * @param bool $show_icons |
|
906 | - * @return string |
|
907 | - */ |
|
908 | - public function pretty_status($show_icons = false) |
|
909 | - { |
|
910 | - $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
911 | - false, 'sentence'); |
|
912 | - $icon = ''; |
|
913 | - switch ($this->status_ID()) { |
|
914 | - case EEM_Registration::status_id_approved: |
|
915 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
916 | - break; |
|
917 | - case EEM_Registration::status_id_pending_payment: |
|
918 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
919 | - break; |
|
920 | - case EEM_Registration::status_id_not_approved: |
|
921 | - $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
922 | - break; |
|
923 | - case EEM_Registration::status_id_cancelled: |
|
924 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
925 | - break; |
|
926 | - case EEM_Registration::status_id_incomplete: |
|
927 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
928 | - break; |
|
929 | - case EEM_Registration::status_id_declined: |
|
930 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
931 | - break; |
|
932 | - case EEM_Registration::status_id_wait_list: |
|
933 | - $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
934 | - break; |
|
935 | - } |
|
936 | - return $icon . $status[$this->status_ID()]; |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - /** |
|
941 | - * get Attendee Is Going |
|
942 | - */ |
|
943 | - public function att_is_going() |
|
944 | - { |
|
945 | - return $this->get('REG_att_is_going'); |
|
946 | - } |
|
947 | - |
|
948 | - |
|
949 | - /** |
|
950 | - * Gets related answers |
|
951 | - * |
|
952 | - * @param array $query_params like EEM_Base::get_all |
|
953 | - * @return EE_Answer[] |
|
954 | - */ |
|
955 | - public function answers($query_params = null) |
|
956 | - { |
|
957 | - return $this->get_many_related('Answer', $query_params); |
|
958 | - } |
|
959 | - |
|
960 | - |
|
961 | - /** |
|
962 | - * Gets the registration's answer value to the specified question |
|
963 | - * (either the question's ID or a question object) |
|
964 | - * |
|
965 | - * @param EE_Question|int $question |
|
966 | - * @param bool $pretty_value |
|
967 | - * @return array|string if pretty_value= true, the result will always be a string |
|
968 | - * (because the answer might be an array of answer values, so passing pretty_value=true |
|
969 | - * will convert it into some kind of string) |
|
970 | - */ |
|
971 | - public function answer_value_to_question($question, $pretty_value = true) |
|
972 | - { |
|
973 | - $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
974 | - return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
975 | - } |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * question_groups |
|
980 | - * returns an array of EE_Question_Group objects for this registration |
|
981 | - * |
|
982 | - * @return EE_Question_Group[] |
|
983 | - */ |
|
984 | - public function question_groups() |
|
985 | - { |
|
986 | - $question_groups = array(); |
|
987 | - if ($this->event() instanceof EE_Event) { |
|
988 | - $question_groups = $this->event()->question_groups( |
|
989 | - array( |
|
990 | - array( |
|
991 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
992 | - ), |
|
993 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
994 | - ) |
|
995 | - ); |
|
996 | - } |
|
997 | - return $question_groups; |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * count_question_groups |
|
1003 | - * returns a count of the number of EE_Question_Group objects for this registration |
|
1004 | - * |
|
1005 | - * @return int |
|
1006 | - */ |
|
1007 | - public function count_question_groups() |
|
1008 | - { |
|
1009 | - $qg_count = 0; |
|
1010 | - if ($this->event() instanceof EE_Event) { |
|
1011 | - $qg_count = $this->event()->count_related( |
|
1012 | - 'Question_Group', |
|
1013 | - array( |
|
1014 | - array( |
|
1015 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
1016 | - ), |
|
1017 | - ) |
|
1018 | - ); |
|
1019 | - } |
|
1020 | - return $qg_count; |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * Returns the registration date in the 'standard' string format |
|
1026 | - * (function may be improved in the future to allow for different formats and timezones) |
|
1027 | - * |
|
1028 | - * @return string |
|
1029 | - */ |
|
1030 | - public function reg_date() |
|
1031 | - { |
|
1032 | - return $this->get_datetime('REG_date'); |
|
1033 | - } |
|
1034 | - |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
1038 | - * the ticket this registration purchased, or the datetime they have registered |
|
1039 | - * to attend) |
|
1040 | - * |
|
1041 | - * @return EE_Datetime_Ticket |
|
1042 | - */ |
|
1043 | - public function datetime_ticket() |
|
1044 | - { |
|
1045 | - return $this->get_first_related('Datetime_Ticket'); |
|
1046 | - } |
|
1047 | - |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * Sets the registration's datetime_ticket. |
|
1051 | - * |
|
1052 | - * @param EE_Datetime_Ticket $datetime_ticket |
|
1053 | - * @return EE_Datetime_Ticket |
|
1054 | - */ |
|
1055 | - public function set_datetime_ticket($datetime_ticket) |
|
1056 | - { |
|
1057 | - return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
1058 | - } |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * Gets deleted |
|
1062 | - * |
|
1063 | - * @return boolean |
|
1064 | - */ |
|
1065 | - public function deleted() |
|
1066 | - { |
|
1067 | - return $this->get('REG_deleted'); |
|
1068 | - } |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * Sets deleted |
|
1072 | - * |
|
1073 | - * @param boolean $deleted |
|
1074 | - * @return boolean |
|
1075 | - */ |
|
1076 | - public function set_deleted($deleted) |
|
1077 | - { |
|
1078 | - if ($deleted) { |
|
1079 | - $this->delete(); |
|
1080 | - } else { |
|
1081 | - $this->restore(); |
|
1082 | - } |
|
1083 | - } |
|
1084 | - |
|
1085 | - |
|
1086 | - /** |
|
1087 | - * Get the status object of this object |
|
1088 | - * |
|
1089 | - * @return EE_Status |
|
1090 | - */ |
|
1091 | - public function status_obj() |
|
1092 | - { |
|
1093 | - return $this->get_first_related('Status'); |
|
1094 | - } |
|
1095 | - |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Returns the number of times this registration has checked into any of the datetimes |
|
1099 | - * its available for |
|
1100 | - * |
|
1101 | - * @return int |
|
1102 | - */ |
|
1103 | - public function count_checkins() |
|
1104 | - { |
|
1105 | - return $this->get_model()->count_related($this, 'Checkin'); |
|
1106 | - } |
|
1107 | - |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
1111 | - * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
1112 | - * |
|
1113 | - * @return int |
|
1114 | - */ |
|
1115 | - public function count_checkins_not_checkedout() |
|
1116 | - { |
|
1117 | - return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
1118 | - } |
|
1119 | - |
|
1120 | - |
|
1121 | - /** |
|
1122 | - * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
1123 | - * |
|
1124 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1125 | - * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
1126 | - * consider registration status as well as datetime access. |
|
1127 | - * @return bool |
|
1128 | - */ |
|
1129 | - public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
1130 | - { |
|
1131 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1132 | - |
|
1133 | - //first check registration status |
|
1134 | - if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1135 | - return false; |
|
1136 | - } |
|
1137 | - //is there a datetime ticket that matches this dtt_ID? |
|
1138 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1139 | - array( |
|
1140 | - 'TKT_ID' => $this->get('TKT_ID'), |
|
1141 | - 'DTT_ID' => $DTT_ID, |
|
1142 | - ), |
|
1143 | - ))) |
|
1144 | - ) { |
|
1145 | - return false; |
|
1146 | - } |
|
1147 | - |
|
1148 | - //final check is against TKT_uses |
|
1149 | - return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1150 | - } |
|
1151 | - |
|
1152 | - |
|
1153 | - /** |
|
1154 | - * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
1155 | - * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
1156 | - * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
1157 | - * then return false. Otherwise return true. |
|
1158 | - * |
|
1159 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1160 | - * @return bool true means can checkin. false means cannot checkin. |
|
1161 | - */ |
|
1162 | - public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
1163 | - { |
|
1164 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1165 | - |
|
1166 | - if (! $DTT_ID) { |
|
1167 | - return false; |
|
1168 | - } |
|
1169 | - |
|
1170 | - $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
1171 | - |
|
1172 | - // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
1173 | - // or not. |
|
1174 | - if (! $max_uses || $max_uses === EE_INF) { |
|
1175 | - return true; |
|
1176 | - } |
|
1177 | - |
|
1178 | - //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
1179 | - //go ahead and toggle. |
|
1180 | - if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1181 | - return true; |
|
1182 | - } |
|
1183 | - |
|
1184 | - //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
1185 | - //disallows further check-ins. |
|
1186 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
1187 | - array( |
|
1188 | - 'REG_ID' => $this->ID(), |
|
1189 | - 'CHK_in' => true, |
|
1190 | - ), |
|
1191 | - ), 'DTT_ID', true); |
|
1192 | - // checkins have already reached their max number of uses |
|
1193 | - // so registrant can NOT checkin |
|
1194 | - if ($count_unique_dtt_checkins >= $max_uses) { |
|
1195 | - EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
1196 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1197 | - return false; |
|
1198 | - } |
|
1199 | - return true; |
|
1200 | - } |
|
1201 | - |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * toggle Check-in status for this registration |
|
1205 | - * Check-ins are toggled in the following order: |
|
1206 | - * never checked in -> checked in |
|
1207 | - * checked in -> checked out |
|
1208 | - * checked out -> checked in |
|
1209 | - * |
|
1210 | - * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1211 | - * If not included or null, then it is assumed latest datetime is being toggled. |
|
1212 | - * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1213 | - * can be checked in or not. Otherwise this forces change in checkin status. |
|
1214 | - * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1215 | - * @throws EE_Error |
|
1216 | - */ |
|
1217 | - public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
1218 | - { |
|
1219 | - if (empty($DTT_ID)) { |
|
1220 | - $datetime = $this->get_latest_related_datetime(); |
|
1221 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
1222 | - // verify the registration can checkin for the given DTT_ID |
|
1223 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
1224 | - EE_Error::add_error( |
|
1225 | - sprintf( |
|
1226 | - __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
1227 | - 'event_espresso'), |
|
1228 | - $this->ID(), |
|
1229 | - $DTT_ID |
|
1230 | - ), |
|
1231 | - __FILE__, __FUNCTION__, __LINE__ |
|
1232 | - ); |
|
1233 | - return false; |
|
1234 | - } |
|
1235 | - $status_paths = array( |
|
1236 | - EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
1237 | - EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
1238 | - EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
1239 | - ); |
|
1240 | - //start by getting the current status so we know what status we'll be changing to. |
|
1241 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
1242 | - $status_to = $status_paths[$cur_status]; |
|
1243 | - // database only records true for checked IN or false for checked OUT |
|
1244 | - // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
1245 | - $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
1246 | - // add relation - note Check-ins are always creating new rows |
|
1247 | - // because we are keeping track of Check-ins over time. |
|
1248 | - // Eventually we'll probably want to show a list table |
|
1249 | - // for the individual Check-ins so that they can be managed. |
|
1250 | - $checkin = EE_Checkin::new_instance(array( |
|
1251 | - 'REG_ID' => $this->ID(), |
|
1252 | - 'DTT_ID' => $DTT_ID, |
|
1253 | - 'CHK_in' => $new_status, |
|
1254 | - )); |
|
1255 | - // if the record could not be saved then return false |
|
1256 | - if ($checkin->save() === 0) { |
|
1257 | - if (WP_DEBUG) { |
|
1258 | - global $wpdb; |
|
1259 | - $error = sprintf( |
|
1260 | - __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
1261 | - 'event_espresso'), |
|
1262 | - '<br />', |
|
1263 | - $wpdb->last_error |
|
1264 | - ); |
|
1265 | - } else { |
|
1266 | - $error = __('Registration check in update failed because of an unknown database error', |
|
1267 | - 'event_espresso'); |
|
1268 | - } |
|
1269 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1270 | - return false; |
|
1271 | - } |
|
1272 | - return $status_to; |
|
1273 | - } |
|
1274 | - |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1278 | - * "Latest" is defined by the `DTT_EVT_start` column. |
|
1279 | - * |
|
1280 | - * @return EE_Datetime|null |
|
1281 | - * @throws \EE_Error |
|
1282 | - */ |
|
1283 | - public function get_latest_related_datetime() |
|
1284 | - { |
|
1285 | - return EEM_Datetime::instance()->get_one( |
|
1286 | - array( |
|
1287 | - array( |
|
1288 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1289 | - ), |
|
1290 | - 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
1291 | - ) |
|
1292 | - ); |
|
1293 | - } |
|
1294 | - |
|
1295 | - |
|
1296 | - /** |
|
1297 | - * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1298 | - * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1299 | - * |
|
1300 | - * @throws \EE_Error |
|
1301 | - */ |
|
1302 | - public function get_earliest_related_datetime() |
|
1303 | - { |
|
1304 | - return EEM_Datetime::instance()->get_one( |
|
1305 | - array( |
|
1306 | - array( |
|
1307 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1308 | - ), |
|
1309 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
1310 | - ) |
|
1311 | - ); |
|
1312 | - } |
|
1313 | - |
|
1314 | - |
|
1315 | - /** |
|
1316 | - * This method simply returns the check-in status for this registration and the given datetime. |
|
1317 | - * If neither the datetime nor the checkin values are provided as arguments, |
|
1318 | - * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1319 | - * |
|
1320 | - * @param int $DTT_ID The ID of the datetime we're checking against |
|
1321 | - * (if empty we'll get the primary datetime for |
|
1322 | - * this registration (via event) and use it's ID); |
|
1323 | - * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1324 | - * @return int Integer representing Check-in status. |
|
1325 | - * @throws \EE_Error |
|
1326 | - */ |
|
1327 | - public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
1328 | - { |
|
1329 | - $checkin_query_params = array( |
|
1330 | - 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
1331 | - ); |
|
1332 | - |
|
1333 | - if ($DTT_ID > 0) { |
|
1334 | - $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1335 | - } |
|
1336 | - |
|
1337 | - //get checkin object (if exists) |
|
1338 | - $checkin = $checkin instanceof EE_Checkin |
|
1339 | - ? $checkin |
|
1340 | - : $this->get_first_related('Checkin', $checkin_query_params); |
|
1341 | - if ($checkin instanceof EE_Checkin) { |
|
1342 | - if ($checkin->get('CHK_in')) { |
|
1343 | - return EE_Registration::checkin_status_in; //checked in |
|
1344 | - } |
|
1345 | - return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
1346 | - } |
|
1347 | - return EE_Registration::checkin_status_never; //never been checked in |
|
1348 | - } |
|
1349 | - |
|
1350 | - |
|
1351 | - /** |
|
1352 | - * This method returns a localized message for the toggled Check-in message. |
|
1353 | - * |
|
1354 | - * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
1355 | - * then it is assumed Check-in for primary datetime was toggled. |
|
1356 | - * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
1357 | - * message can be customized with the attendee name. |
|
1358 | - * @return string internationalized message |
|
1359 | - */ |
|
1360 | - public function get_checkin_msg($DTT_ID, $error = false) |
|
1361 | - { |
|
1362 | - //let's get the attendee first so we can include the name of the attendee |
|
1363 | - $attendee = $this->get_first_related('Attendee'); |
|
1364 | - if ($attendee instanceof EE_Attendee) { |
|
1365 | - if ($error) { |
|
1366 | - return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1367 | - } |
|
1368 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1369 | - //what is the status message going to be? |
|
1370 | - switch ($cur_status) { |
|
1371 | - case EE_Registration::checkin_status_never : |
|
1372 | - return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
1373 | - $attendee->full_name()); |
|
1374 | - break; |
|
1375 | - case EE_Registration::checkin_status_in : |
|
1376 | - return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1377 | - break; |
|
1378 | - case EE_Registration::checkin_status_out : |
|
1379 | - return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1380 | - break; |
|
1381 | - } |
|
1382 | - } |
|
1383 | - return __("The check-in status could not be determined.", "event_espresso"); |
|
1384 | - } |
|
1385 | - |
|
1386 | - |
|
1387 | - /** |
|
1388 | - * Returns the related EE_Transaction to this registration |
|
1389 | - * |
|
1390 | - * @return EE_Transaction |
|
1391 | - */ |
|
1392 | - public function transaction() |
|
1393 | - { |
|
1394 | - $transaction = $this->get_first_related('Transaction'); |
|
1395 | - if (! $transaction instanceof \EE_Transaction) { |
|
1396 | - throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
1397 | - } |
|
1398 | - return $transaction; |
|
1399 | - } |
|
1400 | - |
|
1401 | - |
|
1402 | - /** |
|
1403 | - * get Registration Code |
|
1404 | - */ |
|
1405 | - public function reg_code() |
|
1406 | - { |
|
1407 | - return $this->get('REG_code'); |
|
1408 | - } |
|
1409 | - |
|
1410 | - |
|
1411 | - /** |
|
1412 | - * get Transaction ID |
|
1413 | - */ |
|
1414 | - public function transaction_ID() |
|
1415 | - { |
|
1416 | - return $this->get('TXN_ID'); |
|
1417 | - } |
|
1418 | - |
|
1419 | - |
|
1420 | - /** |
|
1421 | - * @return int |
|
1422 | - */ |
|
1423 | - public function ticket_ID() |
|
1424 | - { |
|
1425 | - return $this->get('TKT_ID'); |
|
1426 | - } |
|
1427 | - |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * Set Registration Code |
|
1431 | - * |
|
1432 | - * @access public |
|
1433 | - * @param string $REG_code Registration Code |
|
1434 | - * @param boolean $use_default |
|
1435 | - */ |
|
1436 | - public function set_reg_code($REG_code, $use_default = false) |
|
1437 | - { |
|
1438 | - if (empty($REG_code)) { |
|
1439 | - EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1440 | - return; |
|
1441 | - } |
|
1442 | - if (! $this->reg_code()) { |
|
1443 | - parent::set('REG_code', $REG_code, $use_default); |
|
1444 | - } else { |
|
1445 | - EE_Error::doing_it_wrong( |
|
1446 | - __CLASS__ . '::' . __FUNCTION__, |
|
1447 | - __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1448 | - '4.6.0' |
|
1449 | - ); |
|
1450 | - } |
|
1451 | - } |
|
1452 | - |
|
1453 | - |
|
1454 | - /** |
|
1455 | - * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
1456 | - * Note, if you want to just get all registrations in the same transaction (group), use: |
|
1457 | - * $registration->transaction()->registrations(); |
|
1458 | - * |
|
1459 | - * @since 4.5.0 |
|
1460 | - * @return EE_Registration[] or empty array if this isn't a group registration. |
|
1461 | - */ |
|
1462 | - public function get_all_other_registrations_in_group() |
|
1463 | - { |
|
1464 | - if ($this->group_size() < 2) { |
|
1465 | - return array(); |
|
1466 | - } |
|
1467 | - |
|
1468 | - $query[0] = array( |
|
1469 | - 'TXN_ID' => $this->transaction_ID(), |
|
1470 | - 'REG_ID' => array('!=', $this->ID()), |
|
1471 | - 'TKT_ID' => $this->ticket_ID(), |
|
1472 | - ); |
|
1473 | - |
|
1474 | - $registrations = $this->get_model()->get_all($query); |
|
1475 | - return $registrations; |
|
1476 | - } |
|
1477 | - |
|
1478 | - /** |
|
1479 | - * Return the link to the admin details for the object. |
|
1480 | - * |
|
1481 | - * @return string |
|
1482 | - */ |
|
1483 | - public function get_admin_details_link() |
|
1484 | - { |
|
1485 | - EE_Registry::instance()->load_helper('URL'); |
|
1486 | - return EEH_URL::add_query_args_and_nonce( |
|
1487 | - array( |
|
1488 | - 'page' => 'espresso_registrations', |
|
1489 | - 'action' => 'view_registration', |
|
1490 | - '_REG_ID' => $this->ID(), |
|
1491 | - ), |
|
1492 | - admin_url('admin.php') |
|
1493 | - ); |
|
1494 | - } |
|
1495 | - |
|
1496 | - /** |
|
1497 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
1498 | - * |
|
1499 | - * @return string |
|
1500 | - */ |
|
1501 | - public function get_admin_edit_link() |
|
1502 | - { |
|
1503 | - return $this->get_admin_details_link(); |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * Returns the link to a settings page for the object. |
|
1508 | - * |
|
1509 | - * @return string |
|
1510 | - */ |
|
1511 | - public function get_admin_settings_link() |
|
1512 | - { |
|
1513 | - return $this->get_admin_details_link(); |
|
1514 | - } |
|
1515 | - |
|
1516 | - /** |
|
1517 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
1518 | - * |
|
1519 | - * @return string |
|
1520 | - */ |
|
1521 | - public function get_admin_overview_link() |
|
1522 | - { |
|
1523 | - EE_Registry::instance()->load_helper('URL'); |
|
1524 | - return EEH_URL::add_query_args_and_nonce( |
|
1525 | - array( |
|
1526 | - 'page' => 'espresso_registrations', |
|
1527 | - ), |
|
1528 | - admin_url('admin.php') |
|
1529 | - ); |
|
1530 | - } |
|
1531 | - |
|
1532 | - |
|
1533 | - /** |
|
1534 | - * @param array $query_params |
|
1535 | - * @return \EE_Registration[] |
|
1536 | - * @throws \EE_Error |
|
1537 | - */ |
|
1538 | - public function payments($query_params = array()) |
|
1539 | - { |
|
1540 | - return $this->get_many_related('Payment', $query_params); |
|
1541 | - } |
|
1542 | - |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * @param array $query_params |
|
1546 | - * @return \EE_Registration_Payment[] |
|
1547 | - * @throws \EE_Error |
|
1548 | - */ |
|
1549 | - public function registration_payments($query_params = array()) |
|
1550 | - { |
|
1551 | - return $this->get_many_related('Registration_Payment', $query_params); |
|
1552 | - } |
|
1553 | - |
|
1554 | - |
|
1555 | - /** |
|
1556 | - * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
1557 | - * Note: if there are no payments on the registration there will be no payment method returned. |
|
1558 | - * |
|
1559 | - * @return EE_Payment_Method|null |
|
1560 | - */ |
|
1561 | - public function payment_method() |
|
1562 | - { |
|
1563 | - return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1564 | - } |
|
1565 | - |
|
1566 | - |
|
1567 | - /** |
|
1568 | - * @return \EE_Line_Item |
|
1569 | - * @throws EntityNotFoundException |
|
1570 | - * @throws \EE_Error |
|
1571 | - */ |
|
1572 | - public function ticket_line_item() |
|
1573 | - { |
|
1574 | - $ticket = $this->ticket(); |
|
1575 | - $transaction = $this->transaction(); |
|
1576 | - $line_item = null; |
|
1577 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
1578 | - $transaction->total_line_item(), |
|
1579 | - 'Ticket', |
|
1580 | - array($ticket->ID()) |
|
1581 | - ); |
|
1582 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
1583 | - if ( |
|
1584 | - $ticket_line_item instanceof \EE_Line_Item |
|
1585 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
1586 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
1587 | - ) { |
|
1588 | - $line_item = $ticket_line_item; |
|
1589 | - break; |
|
1590 | - } |
|
1591 | - } |
|
1592 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1593 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
1594 | - } |
|
1595 | - return $line_item; |
|
1596 | - } |
|
1597 | - |
|
1598 | - |
|
1599 | - /** |
|
1600 | - * Soft Deletes this model object. |
|
1601 | - * |
|
1602 | - * @return boolean | int |
|
1603 | - * @throws \RuntimeException |
|
1604 | - * @throws \EE_Error |
|
1605 | - */ |
|
1606 | - public function delete() |
|
1607 | - { |
|
1608 | - if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1609 | - $this->set_status(EEM_Registration::status_id_cancelled); |
|
1610 | - } |
|
1611 | - return parent::delete(); |
|
1612 | - } |
|
1613 | - |
|
1614 | - |
|
1615 | - /** |
|
1616 | - * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
1617 | - * |
|
1618 | - * @throws \EE_Error |
|
1619 | - * @throws \RuntimeException |
|
1620 | - */ |
|
1621 | - public function restore() |
|
1622 | - { |
|
1623 | - $previous_status = $this->get_extra_meta( |
|
1624 | - EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
1625 | - true, |
|
1626 | - EEM_Registration::status_id_cancelled |
|
1627 | - ); |
|
1628 | - if ($previous_status) { |
|
1629 | - $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
1630 | - $this->set_status($previous_status); |
|
1631 | - } |
|
1632 | - return parent::restore(); |
|
1633 | - } |
|
1634 | - |
|
1635 | - |
|
1636 | - |
|
1637 | - /*************************** DEPRECATED ***************************/ |
|
1638 | - |
|
1639 | - |
|
1640 | - /** |
|
1641 | - * @deprecated |
|
1642 | - * @since 4.7.0 |
|
1643 | - * @access public |
|
1644 | - */ |
|
1645 | - public function price_paid() |
|
1646 | - { |
|
1647 | - EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
1648 | - __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
1649 | - '4.7.0'); |
|
1650 | - return $this->final_price(); |
|
1651 | - } |
|
1652 | - |
|
1653 | - |
|
1654 | - /** |
|
1655 | - * @deprecated |
|
1656 | - * @since 4.7.0 |
|
1657 | - * @access public |
|
1658 | - * @param float $REG_final_price |
|
1659 | - */ |
|
1660 | - public function set_price_paid($REG_final_price = 0.00) |
|
1661 | - { |
|
1662 | - EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
1663 | - __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
1664 | - '4.7.0'); |
|
1665 | - $this->set_final_price($REG_final_price); |
|
1666 | - } |
|
1667 | - |
|
1668 | - |
|
1669 | - /** |
|
1670 | - * @deprecated |
|
1671 | - * @since 4.7.0 |
|
1672 | - * @return string |
|
1673 | - */ |
|
1674 | - public function pretty_price_paid() |
|
1675 | - { |
|
1676 | - EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
1677 | - __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
1678 | - 'event_espresso'), '4.7.0'); |
|
1679 | - return $this->pretty_final_price(); |
|
1680 | - } |
|
1681 | - |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * Gets the primary datetime related to this registration via the related Event to this registration |
|
1685 | - * |
|
1686 | - * @deprecated 4.9.17 |
|
1687 | - * @return EE_Datetime |
|
1688 | - */ |
|
1689 | - public function get_related_primary_datetime() |
|
1690 | - { |
|
1691 | - EE_Error::doing_it_wrong( |
|
1692 | - __METHOD__, |
|
1693 | - esc_html__( |
|
1694 | - 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1695 | - 'event_espresso' |
|
1696 | - ), |
|
1697 | - '4.9.17', |
|
1698 | - '5.0.0' |
|
1699 | - ); |
|
1700 | - return $this->event()->primary_datetime(); |
|
1701 | - } |
|
18 | + /** |
|
19 | + * Used to reference when a registration has never been checked in. |
|
20 | + * |
|
21 | + * @type int |
|
22 | + */ |
|
23 | + const checkin_status_never = 2; |
|
24 | + |
|
25 | + /** |
|
26 | + * Used to reference when a registration has been checked in. |
|
27 | + * |
|
28 | + * @type int |
|
29 | + */ |
|
30 | + const checkin_status_in = 1; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Used to reference when a registration has been checked out. |
|
35 | + * |
|
36 | + * @type int |
|
37 | + */ |
|
38 | + const checkin_status_out = 0; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * extra meta key for tracking reg status os trashed registrations |
|
43 | + * |
|
44 | + * @type string |
|
45 | + */ |
|
46 | + const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * extra meta key for tracking if registration has reserved ticket |
|
51 | + * |
|
52 | + * @type string |
|
53 | + */ |
|
54 | + const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @param array $props_n_values incoming values |
|
59 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | + * used.) |
|
61 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | + * date_format and the second value is the time format |
|
63 | + * @return EE_Registration |
|
64 | + */ |
|
65 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | + { |
|
67 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
68 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param array $props_n_values incoming values from the database |
|
74 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
75 | + * the website will be used. |
|
76 | + * @return EE_Registration |
|
77 | + */ |
|
78 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
79 | + { |
|
80 | + return new self($props_n_values, true, $timezone); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Set Event ID |
|
86 | + * |
|
87 | + * @param int $EVT_ID Event ID |
|
88 | + */ |
|
89 | + public function set_event($EVT_ID = 0) |
|
90 | + { |
|
91 | + $this->set('EVT_ID', $EVT_ID); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
97 | + * be routed to internal methods |
|
98 | + * |
|
99 | + * @param string $field_name |
|
100 | + * @param mixed $field_value |
|
101 | + * @param bool $use_default |
|
102 | + * @throws \EE_Error |
|
103 | + * @throws \RuntimeException |
|
104 | + */ |
|
105 | + public function set($field_name, $field_value, $use_default = false) |
|
106 | + { |
|
107 | + switch ($field_name) { |
|
108 | + case 'REG_code' : |
|
109 | + if (! empty($field_value) && $this->reg_code() === null) { |
|
110 | + $this->set_reg_code($field_value, $use_default); |
|
111 | + } |
|
112 | + break; |
|
113 | + case 'STS_ID' : |
|
114 | + $this->set_status($field_value, $use_default); |
|
115 | + break; |
|
116 | + default : |
|
117 | + parent::set($field_name, $field_value, $use_default); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Set Status ID |
|
124 | + * updates the registration status and ALSO... |
|
125 | + * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
126 | + * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
127 | + * |
|
128 | + * @param string $new_STS_ID |
|
129 | + * @param boolean $use_default |
|
130 | + * @return bool |
|
131 | + * @throws \RuntimeException |
|
132 | + * @throws \EE_Error |
|
133 | + */ |
|
134 | + public function set_status($new_STS_ID = null, $use_default = false) |
|
135 | + { |
|
136 | + // get current REG_Status |
|
137 | + $old_STS_ID = $this->status_ID(); |
|
138 | + // if status has changed |
|
139 | + if ( |
|
140 | + $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
141 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
142 | + && ! empty($new_STS_ID) // as well as the new status |
|
143 | + && $this->ID() // ensure registration is in the db |
|
144 | + ) { |
|
145 | + // TO approved |
|
146 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
147 | + // reserve a space by incrementing ticket and datetime sold values |
|
148 | + $this->_reserve_registration_space(); |
|
149 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
150 | + // OR FROM approved |
|
151 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
152 | + // release a space by decrementing ticket and datetime sold values |
|
153 | + $this->_release_registration_space(); |
|
154 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
155 | + } |
|
156 | + // update status |
|
157 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
158 | + $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
159 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
160 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
161 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
162 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
163 | + do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID); |
|
164 | + return true; |
|
165 | + } |
|
166 | + //even though the old value matches the new value, it's still good to |
|
167 | + //allow the parent set method to have a say |
|
168 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
169 | + return true; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * update REGs and TXN when cancelled or declined registrations involved |
|
175 | + * |
|
176 | + * @param string $new_STS_ID |
|
177 | + * @param string $old_STS_ID |
|
178 | + * @throws \EE_Error |
|
179 | + */ |
|
180 | + private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
181 | + { |
|
182 | + // these reg statuses should not be considered in any calculations involving monies owing |
|
183 | + $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
184 | + // true if registration has been cancelled or declined |
|
185 | + if ( |
|
186 | + in_array($new_STS_ID, $closed_reg_statuses, true) |
|
187 | + && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
188 | + ) { |
|
189 | + /** @type EE_Registration_Processor $registration_processor */ |
|
190 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
191 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
192 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
193 | + // cancelled or declined registration |
|
194 | + $registration_processor->update_registration_after_being_canceled_or_declined( |
|
195 | + $this, |
|
196 | + $closed_reg_statuses |
|
197 | + ); |
|
198 | + $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
199 | + $this, |
|
200 | + $closed_reg_statuses, |
|
201 | + false |
|
202 | + ); |
|
203 | + do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
204 | + return; |
|
205 | + } |
|
206 | + // true if reinstating cancelled or declined registration |
|
207 | + if ( |
|
208 | + in_array($old_STS_ID, $closed_reg_statuses, true) |
|
209 | + && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
210 | + ) { |
|
211 | + /** @type EE_Registration_Processor $registration_processor */ |
|
212 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
213 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
214 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
215 | + // reinstating cancelled or declined registration |
|
216 | + $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
217 | + $this, |
|
218 | + $closed_reg_statuses |
|
219 | + ); |
|
220 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
221 | + $this, |
|
222 | + $closed_reg_statuses, |
|
223 | + false |
|
224 | + ); |
|
225 | + do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * get Status ID |
|
232 | + */ |
|
233 | + public function status_ID() |
|
234 | + { |
|
235 | + return $this->get('STS_ID'); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * increments this registration's related ticket sold and corresponding datetime sold values |
|
241 | + * |
|
242 | + * @return void |
|
243 | + * @throws \EE_Error |
|
244 | + */ |
|
245 | + private function _reserve_registration_space() |
|
246 | + { |
|
247 | + // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
248 | + // so stop tracking that this reg has a ticket reserved |
|
249 | + $this->release_reserved_ticket(); |
|
250 | + $ticket = $this->ticket(); |
|
251 | + $ticket->increase_sold(); |
|
252 | + $ticket->save(); |
|
253 | + // possibly set event status to sold out |
|
254 | + $this->event()->perform_sold_out_status_check(); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Gets the ticket this registration is for |
|
260 | + * |
|
261 | + * @param boolean $include_archived whether to include archived tickets or not. |
|
262 | + * @return EE_Ticket|EE_Base_Class |
|
263 | + * @throws \EE_Error |
|
264 | + */ |
|
265 | + public function ticket($include_archived = true) |
|
266 | + { |
|
267 | + $query_params = array(); |
|
268 | + if ($include_archived) { |
|
269 | + $query_params['default_where_conditions'] = 'none'; |
|
270 | + } |
|
271 | + return $this->get_first_related('Ticket', $query_params); |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Gets the event this registration is for |
|
277 | + * |
|
278 | + * @return EE_Event |
|
279 | + */ |
|
280 | + public function event() |
|
281 | + { |
|
282 | + $event = $this->get_first_related('Event'); |
|
283 | + if (! $event instanceof \EE_Event) { |
|
284 | + throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
285 | + } |
|
286 | + return $event; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
292 | + * with the author of the event this registration is for. |
|
293 | + * |
|
294 | + * @since 4.5.0 |
|
295 | + * @return int |
|
296 | + */ |
|
297 | + public function wp_user() |
|
298 | + { |
|
299 | + $event = $this->event(); |
|
300 | + if ($event instanceof EE_Event) { |
|
301 | + return $event->wp_user(); |
|
302 | + } |
|
303 | + return 0; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
309 | + * |
|
310 | + * @return void |
|
311 | + * @throws \EE_Error |
|
312 | + */ |
|
313 | + private function _release_registration_space() |
|
314 | + { |
|
315 | + $ticket = $this->ticket(); |
|
316 | + $ticket->decrease_sold(); |
|
317 | + $ticket->save(); |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * tracks this registration's ticket reservation in extra meta |
|
323 | + * and can increment related ticket reserved and corresponding datetime reserved values |
|
324 | + * |
|
325 | + * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
326 | + * @return void |
|
327 | + * @throws \EE_Error |
|
328 | + */ |
|
329 | + public function reserve_ticket($update_ticket = false) |
|
330 | + { |
|
331 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
332 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
333 | + // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
334 | + if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
335 | + $ticket = $this->ticket(); |
|
336 | + $ticket->increase_reserved(); |
|
337 | + $ticket->save(); |
|
338 | + } |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * stops tracking this registration's ticket reservation in extra meta |
|
345 | + * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
346 | + * |
|
347 | + * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
348 | + * @return void |
|
349 | + * @throws \EE_Error |
|
350 | + */ |
|
351 | + public function release_reserved_ticket($update_ticket = false) |
|
352 | + { |
|
353 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
354 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
355 | + // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
356 | + if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
357 | + $ticket = $this->ticket(); |
|
358 | + $ticket->decrease_reserved(); |
|
359 | + $ticket->save(); |
|
360 | + } |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * Set Attendee ID |
|
367 | + * |
|
368 | + * @param int $ATT_ID Attendee ID |
|
369 | + */ |
|
370 | + public function set_attendee_id($ATT_ID = 0) |
|
371 | + { |
|
372 | + $this->set('ATT_ID', $ATT_ID); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Set Transaction ID |
|
378 | + * |
|
379 | + * @param int $TXN_ID Transaction ID |
|
380 | + */ |
|
381 | + public function set_transaction_id($TXN_ID = 0) |
|
382 | + { |
|
383 | + $this->set('TXN_ID', $TXN_ID); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * Set Session |
|
389 | + * |
|
390 | + * @param string $REG_session PHP Session ID |
|
391 | + */ |
|
392 | + public function set_session($REG_session = '') |
|
393 | + { |
|
394 | + $this->set('REG_session', $REG_session); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * Set Registration URL Link |
|
400 | + * |
|
401 | + * @param string $REG_url_link Registration URL Link |
|
402 | + */ |
|
403 | + public function set_reg_url_link($REG_url_link = '') |
|
404 | + { |
|
405 | + $this->set('REG_url_link', $REG_url_link); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * Set Attendee Counter |
|
411 | + * |
|
412 | + * @param int $REG_count Primary Attendee |
|
413 | + */ |
|
414 | + public function set_count($REG_count = 1) |
|
415 | + { |
|
416 | + $this->set('REG_count', $REG_count); |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * Set Group Size |
|
422 | + * |
|
423 | + * @param boolean $REG_group_size Group Registration |
|
424 | + */ |
|
425 | + public function set_group_size($REG_group_size = false) |
|
426 | + { |
|
427 | + $this->set('REG_group_size', $REG_group_size); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
433 | + * EEM_Registration::status_id_not_approved |
|
434 | + * |
|
435 | + * @return boolean |
|
436 | + */ |
|
437 | + public function is_not_approved() |
|
438 | + { |
|
439 | + return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
445 | + * EEM_Registration::status_id_pending_payment |
|
446 | + * |
|
447 | + * @return boolean |
|
448 | + */ |
|
449 | + public function is_pending_payment() |
|
450 | + { |
|
451 | + return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
457 | + * |
|
458 | + * @return boolean |
|
459 | + */ |
|
460 | + public function is_approved() |
|
461 | + { |
|
462 | + return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
468 | + * |
|
469 | + * @return boolean |
|
470 | + */ |
|
471 | + public function is_cancelled() |
|
472 | + { |
|
473 | + return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
474 | + } |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
479 | + * |
|
480 | + * @return boolean |
|
481 | + */ |
|
482 | + public function is_declined() |
|
483 | + { |
|
484 | + return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
490 | + * EEM_Registration::status_id_incomplete |
|
491 | + * |
|
492 | + * @return boolean |
|
493 | + */ |
|
494 | + public function is_incomplete() |
|
495 | + { |
|
496 | + return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * Set Registration Date |
|
502 | + * |
|
503 | + * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
504 | + * Date |
|
505 | + */ |
|
506 | + public function set_reg_date($REG_date = false) |
|
507 | + { |
|
508 | + $this->set('REG_date', $REG_date); |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * Set final price owing for this registration after all ticket/price modifications |
|
514 | + * |
|
515 | + * @access public |
|
516 | + * @param float $REG_final_price |
|
517 | + */ |
|
518 | + public function set_final_price($REG_final_price = 0.00) |
|
519 | + { |
|
520 | + $this->set('REG_final_price', $REG_final_price); |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * Set amount paid towards this registration's final price |
|
526 | + * |
|
527 | + * @access public |
|
528 | + * @param float $REG_paid |
|
529 | + */ |
|
530 | + public function set_paid($REG_paid = 0.00) |
|
531 | + { |
|
532 | + $this->set('REG_paid', $REG_paid); |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * Attendee Is Going |
|
538 | + * |
|
539 | + * @param boolean $REG_att_is_going Attendee Is Going |
|
540 | + */ |
|
541 | + public function set_att_is_going($REG_att_is_going = false) |
|
542 | + { |
|
543 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * Gets the related attendee |
|
549 | + * |
|
550 | + * @return EE_Attendee |
|
551 | + */ |
|
552 | + public function attendee() |
|
553 | + { |
|
554 | + return $this->get_first_related('Attendee'); |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * get Event ID |
|
560 | + */ |
|
561 | + public function event_ID() |
|
562 | + { |
|
563 | + return $this->get('EVT_ID'); |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + /** |
|
568 | + * get Event ID |
|
569 | + */ |
|
570 | + public function event_name() |
|
571 | + { |
|
572 | + $event = $this->event_obj(); |
|
573 | + if ($event) { |
|
574 | + return $event->name(); |
|
575 | + } else { |
|
576 | + return null; |
|
577 | + } |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * Fetches the event this registration is for |
|
583 | + * |
|
584 | + * @return EE_Event |
|
585 | + */ |
|
586 | + public function event_obj() |
|
587 | + { |
|
588 | + return $this->get_first_related('Event'); |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * get Attendee ID |
|
594 | + */ |
|
595 | + public function attendee_ID() |
|
596 | + { |
|
597 | + return $this->get('ATT_ID'); |
|
598 | + } |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * get PHP Session ID |
|
603 | + */ |
|
604 | + public function session_ID() |
|
605 | + { |
|
606 | + return $this->get('REG_session'); |
|
607 | + } |
|
608 | + |
|
609 | + |
|
610 | + /** |
|
611 | + * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
612 | + * |
|
613 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
614 | + * @return string |
|
615 | + */ |
|
616 | + public function receipt_url($messenger = 'html') |
|
617 | + { |
|
618 | + |
|
619 | + /** |
|
620 | + * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
621 | + * |
|
622 | + * @since 4.5.0 |
|
623 | + */ |
|
624 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
625 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
626 | + |
|
627 | + if ($has_custom) { |
|
628 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
629 | + } |
|
630 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
631 | + } |
|
632 | + |
|
633 | + |
|
634 | + /** |
|
635 | + * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
636 | + * |
|
637 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
638 | + * @return string |
|
639 | + */ |
|
640 | + public function invoice_url($messenger = 'html') |
|
641 | + { |
|
642 | + /** |
|
643 | + * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
644 | + * |
|
645 | + * @since 4.5.0 |
|
646 | + */ |
|
647 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
648 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
649 | + |
|
650 | + if ($has_custom) { |
|
651 | + if ($messenger == 'html') { |
|
652 | + return $this->invoice_url('launch'); |
|
653 | + } |
|
654 | + $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
655 | + |
|
656 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
657 | + if ($messenger == 'html') { |
|
658 | + $query_args['html'] = true; |
|
659 | + } |
|
660 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
661 | + } |
|
662 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
663 | + } |
|
664 | + |
|
665 | + |
|
666 | + /** |
|
667 | + * get Registration URL Link |
|
668 | + * |
|
669 | + * @access public |
|
670 | + * @return string |
|
671 | + * @throws \EE_Error |
|
672 | + */ |
|
673 | + public function reg_url_link() |
|
674 | + { |
|
675 | + return (string)$this->get('REG_url_link'); |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * Echoes out invoice_url() |
|
681 | + * |
|
682 | + * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
683 | + * @return void |
|
684 | + */ |
|
685 | + public function e_invoice_url($type = 'launch') |
|
686 | + { |
|
687 | + echo $this->invoice_url($type); |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * Echoes out payment_overview_url |
|
693 | + */ |
|
694 | + public function e_payment_overview_url() |
|
695 | + { |
|
696 | + echo $this->payment_overview_url(); |
|
697 | + } |
|
698 | + |
|
699 | + |
|
700 | + /** |
|
701 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
702 | + * a query parameter |
|
703 | + * |
|
704 | + * @return string |
|
705 | + */ |
|
706 | + public function payment_overview_url() |
|
707 | + { |
|
708 | + return add_query_arg(array( |
|
709 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
710 | + 'step' => 'payment_options', |
|
711 | + 'revisit' => true, |
|
712 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
713 | + } |
|
714 | + |
|
715 | + |
|
716 | + /** |
|
717 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
718 | + * a query parameter |
|
719 | + * |
|
720 | + * @return string |
|
721 | + */ |
|
722 | + public function edit_attendee_information_url() |
|
723 | + { |
|
724 | + return add_query_arg(array( |
|
725 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
726 | + 'step' => 'attendee_information', |
|
727 | + 'revisit' => true, |
|
728 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
729 | + } |
|
730 | + |
|
731 | + |
|
732 | + /** |
|
733 | + * Simply generates and returns the appropriate admin_url link to edit this registration |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public function get_admin_edit_url() |
|
738 | + { |
|
739 | + return EEH_URL::add_query_args_and_nonce(array( |
|
740 | + 'page' => 'espresso_registrations', |
|
741 | + 'action' => 'view_registration', |
|
742 | + '_REG_ID' => $this->ID(), |
|
743 | + ), admin_url('admin.php')); |
|
744 | + } |
|
745 | + |
|
746 | + |
|
747 | + /** |
|
748 | + * is_primary_registrant? |
|
749 | + */ |
|
750 | + public function is_primary_registrant() |
|
751 | + { |
|
752 | + return $this->get('REG_count') == 1 ? true : false; |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + /** |
|
757 | + * This returns the primary registration object for this registration group (which may be this object). |
|
758 | + * |
|
759 | + * @return EE_Registration |
|
760 | + */ |
|
761 | + public function get_primary_registration() |
|
762 | + { |
|
763 | + if ($this->is_primary_registrant()) { |
|
764 | + return $this; |
|
765 | + } |
|
766 | + |
|
767 | + //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
768 | + $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
769 | + array( |
|
770 | + 'TXN_ID' => $this->transaction_ID(), |
|
771 | + 'REG_count' => 1, |
|
772 | + ), |
|
773 | + )); |
|
774 | + return $primary_registrant; |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + /** |
|
779 | + * get Attendee Number |
|
780 | + * |
|
781 | + * @access public |
|
782 | + */ |
|
783 | + public function count() |
|
784 | + { |
|
785 | + return $this->get('REG_count'); |
|
786 | + } |
|
787 | + |
|
788 | + |
|
789 | + /** |
|
790 | + * get Group Size |
|
791 | + */ |
|
792 | + public function group_size() |
|
793 | + { |
|
794 | + return $this->get('REG_group_size'); |
|
795 | + } |
|
796 | + |
|
797 | + |
|
798 | + /** |
|
799 | + * get Registration Date |
|
800 | + */ |
|
801 | + public function date() |
|
802 | + { |
|
803 | + return $this->get('REG_date'); |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + /** |
|
808 | + * gets a pretty date |
|
809 | + * |
|
810 | + * @param string $date_format |
|
811 | + * @param string $time_format |
|
812 | + * @return string |
|
813 | + */ |
|
814 | + public function pretty_date($date_format = null, $time_format = null) |
|
815 | + { |
|
816 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
817 | + } |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * final_price |
|
822 | + * the registration's share of the transaction total, so that the |
|
823 | + * sum of all the transaction's REG_final_prices equal the transaction's total |
|
824 | + * |
|
825 | + * @return float |
|
826 | + */ |
|
827 | + public function final_price() |
|
828 | + { |
|
829 | + return $this->get('REG_final_price'); |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + /** |
|
834 | + * pretty_final_price |
|
835 | + * final price as formatted string, with correct decimal places and currency symbol |
|
836 | + * |
|
837 | + * @return string |
|
838 | + */ |
|
839 | + public function pretty_final_price() |
|
840 | + { |
|
841 | + return $this->get_pretty('REG_final_price'); |
|
842 | + } |
|
843 | + |
|
844 | + |
|
845 | + /** |
|
846 | + * get paid (yeah) |
|
847 | + * |
|
848 | + * @return float |
|
849 | + */ |
|
850 | + public function paid() |
|
851 | + { |
|
852 | + return $this->get('REG_paid'); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * pretty_paid |
|
858 | + * |
|
859 | + * @return float |
|
860 | + */ |
|
861 | + public function pretty_paid() |
|
862 | + { |
|
863 | + return $this->get_pretty('REG_paid'); |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + /** |
|
868 | + * owes_monies_and_can_pay |
|
869 | + * whether or not this registration has monies owing and it's' status allows payment |
|
870 | + * |
|
871 | + * @param array $requires_payment |
|
872 | + * @return bool |
|
873 | + */ |
|
874 | + public function owes_monies_and_can_pay($requires_payment = array()) |
|
875 | + { |
|
876 | + // these reg statuses require payment (if event is not free) |
|
877 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
878 | + if ( |
|
879 | + in_array($this->status_ID(), $requires_payment) && |
|
880 | + $this->final_price() != 0 && |
|
881 | + $this->final_price() != $this->paid() |
|
882 | + ) { |
|
883 | + return true; |
|
884 | + } else { |
|
885 | + return false; |
|
886 | + } |
|
887 | + } |
|
888 | + |
|
889 | + |
|
890 | + /** |
|
891 | + * Prints out the return value of $this->pretty_status() |
|
892 | + * |
|
893 | + * @param bool $show_icons |
|
894 | + * @return void |
|
895 | + */ |
|
896 | + public function e_pretty_status($show_icons = false) |
|
897 | + { |
|
898 | + echo $this->pretty_status($show_icons); |
|
899 | + } |
|
900 | + |
|
901 | + |
|
902 | + /** |
|
903 | + * Returns a nice version of the status for displaying to customers |
|
904 | + * |
|
905 | + * @param bool $show_icons |
|
906 | + * @return string |
|
907 | + */ |
|
908 | + public function pretty_status($show_icons = false) |
|
909 | + { |
|
910 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
911 | + false, 'sentence'); |
|
912 | + $icon = ''; |
|
913 | + switch ($this->status_ID()) { |
|
914 | + case EEM_Registration::status_id_approved: |
|
915 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
916 | + break; |
|
917 | + case EEM_Registration::status_id_pending_payment: |
|
918 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
919 | + break; |
|
920 | + case EEM_Registration::status_id_not_approved: |
|
921 | + $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
922 | + break; |
|
923 | + case EEM_Registration::status_id_cancelled: |
|
924 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
925 | + break; |
|
926 | + case EEM_Registration::status_id_incomplete: |
|
927 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
928 | + break; |
|
929 | + case EEM_Registration::status_id_declined: |
|
930 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
931 | + break; |
|
932 | + case EEM_Registration::status_id_wait_list: |
|
933 | + $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
934 | + break; |
|
935 | + } |
|
936 | + return $icon . $status[$this->status_ID()]; |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + /** |
|
941 | + * get Attendee Is Going |
|
942 | + */ |
|
943 | + public function att_is_going() |
|
944 | + { |
|
945 | + return $this->get('REG_att_is_going'); |
|
946 | + } |
|
947 | + |
|
948 | + |
|
949 | + /** |
|
950 | + * Gets related answers |
|
951 | + * |
|
952 | + * @param array $query_params like EEM_Base::get_all |
|
953 | + * @return EE_Answer[] |
|
954 | + */ |
|
955 | + public function answers($query_params = null) |
|
956 | + { |
|
957 | + return $this->get_many_related('Answer', $query_params); |
|
958 | + } |
|
959 | + |
|
960 | + |
|
961 | + /** |
|
962 | + * Gets the registration's answer value to the specified question |
|
963 | + * (either the question's ID or a question object) |
|
964 | + * |
|
965 | + * @param EE_Question|int $question |
|
966 | + * @param bool $pretty_value |
|
967 | + * @return array|string if pretty_value= true, the result will always be a string |
|
968 | + * (because the answer might be an array of answer values, so passing pretty_value=true |
|
969 | + * will convert it into some kind of string) |
|
970 | + */ |
|
971 | + public function answer_value_to_question($question, $pretty_value = true) |
|
972 | + { |
|
973 | + $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
974 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
975 | + } |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * question_groups |
|
980 | + * returns an array of EE_Question_Group objects for this registration |
|
981 | + * |
|
982 | + * @return EE_Question_Group[] |
|
983 | + */ |
|
984 | + public function question_groups() |
|
985 | + { |
|
986 | + $question_groups = array(); |
|
987 | + if ($this->event() instanceof EE_Event) { |
|
988 | + $question_groups = $this->event()->question_groups( |
|
989 | + array( |
|
990 | + array( |
|
991 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
992 | + ), |
|
993 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
994 | + ) |
|
995 | + ); |
|
996 | + } |
|
997 | + return $question_groups; |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * count_question_groups |
|
1003 | + * returns a count of the number of EE_Question_Group objects for this registration |
|
1004 | + * |
|
1005 | + * @return int |
|
1006 | + */ |
|
1007 | + public function count_question_groups() |
|
1008 | + { |
|
1009 | + $qg_count = 0; |
|
1010 | + if ($this->event() instanceof EE_Event) { |
|
1011 | + $qg_count = $this->event()->count_related( |
|
1012 | + 'Question_Group', |
|
1013 | + array( |
|
1014 | + array( |
|
1015 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
1016 | + ), |
|
1017 | + ) |
|
1018 | + ); |
|
1019 | + } |
|
1020 | + return $qg_count; |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * Returns the registration date in the 'standard' string format |
|
1026 | + * (function may be improved in the future to allow for different formats and timezones) |
|
1027 | + * |
|
1028 | + * @return string |
|
1029 | + */ |
|
1030 | + public function reg_date() |
|
1031 | + { |
|
1032 | + return $this->get_datetime('REG_date'); |
|
1033 | + } |
|
1034 | + |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
1038 | + * the ticket this registration purchased, or the datetime they have registered |
|
1039 | + * to attend) |
|
1040 | + * |
|
1041 | + * @return EE_Datetime_Ticket |
|
1042 | + */ |
|
1043 | + public function datetime_ticket() |
|
1044 | + { |
|
1045 | + return $this->get_first_related('Datetime_Ticket'); |
|
1046 | + } |
|
1047 | + |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * Sets the registration's datetime_ticket. |
|
1051 | + * |
|
1052 | + * @param EE_Datetime_Ticket $datetime_ticket |
|
1053 | + * @return EE_Datetime_Ticket |
|
1054 | + */ |
|
1055 | + public function set_datetime_ticket($datetime_ticket) |
|
1056 | + { |
|
1057 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
1058 | + } |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * Gets deleted |
|
1062 | + * |
|
1063 | + * @return boolean |
|
1064 | + */ |
|
1065 | + public function deleted() |
|
1066 | + { |
|
1067 | + return $this->get('REG_deleted'); |
|
1068 | + } |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * Sets deleted |
|
1072 | + * |
|
1073 | + * @param boolean $deleted |
|
1074 | + * @return boolean |
|
1075 | + */ |
|
1076 | + public function set_deleted($deleted) |
|
1077 | + { |
|
1078 | + if ($deleted) { |
|
1079 | + $this->delete(); |
|
1080 | + } else { |
|
1081 | + $this->restore(); |
|
1082 | + } |
|
1083 | + } |
|
1084 | + |
|
1085 | + |
|
1086 | + /** |
|
1087 | + * Get the status object of this object |
|
1088 | + * |
|
1089 | + * @return EE_Status |
|
1090 | + */ |
|
1091 | + public function status_obj() |
|
1092 | + { |
|
1093 | + return $this->get_first_related('Status'); |
|
1094 | + } |
|
1095 | + |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * Returns the number of times this registration has checked into any of the datetimes |
|
1099 | + * its available for |
|
1100 | + * |
|
1101 | + * @return int |
|
1102 | + */ |
|
1103 | + public function count_checkins() |
|
1104 | + { |
|
1105 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
1106 | + } |
|
1107 | + |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
1111 | + * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
1112 | + * |
|
1113 | + * @return int |
|
1114 | + */ |
|
1115 | + public function count_checkins_not_checkedout() |
|
1116 | + { |
|
1117 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
1118 | + } |
|
1119 | + |
|
1120 | + |
|
1121 | + /** |
|
1122 | + * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
1123 | + * |
|
1124 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1125 | + * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
1126 | + * consider registration status as well as datetime access. |
|
1127 | + * @return bool |
|
1128 | + */ |
|
1129 | + public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
1130 | + { |
|
1131 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1132 | + |
|
1133 | + //first check registration status |
|
1134 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1135 | + return false; |
|
1136 | + } |
|
1137 | + //is there a datetime ticket that matches this dtt_ID? |
|
1138 | + if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
1139 | + array( |
|
1140 | + 'TKT_ID' => $this->get('TKT_ID'), |
|
1141 | + 'DTT_ID' => $DTT_ID, |
|
1142 | + ), |
|
1143 | + ))) |
|
1144 | + ) { |
|
1145 | + return false; |
|
1146 | + } |
|
1147 | + |
|
1148 | + //final check is against TKT_uses |
|
1149 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1150 | + } |
|
1151 | + |
|
1152 | + |
|
1153 | + /** |
|
1154 | + * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
1155 | + * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
1156 | + * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
1157 | + * then return false. Otherwise return true. |
|
1158 | + * |
|
1159 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
1160 | + * @return bool true means can checkin. false means cannot checkin. |
|
1161 | + */ |
|
1162 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
1163 | + { |
|
1164 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1165 | + |
|
1166 | + if (! $DTT_ID) { |
|
1167 | + return false; |
|
1168 | + } |
|
1169 | + |
|
1170 | + $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
1171 | + |
|
1172 | + // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
1173 | + // or not. |
|
1174 | + if (! $max_uses || $max_uses === EE_INF) { |
|
1175 | + return true; |
|
1176 | + } |
|
1177 | + |
|
1178 | + //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
1179 | + //go ahead and toggle. |
|
1180 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1181 | + return true; |
|
1182 | + } |
|
1183 | + |
|
1184 | + //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
1185 | + //disallows further check-ins. |
|
1186 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
1187 | + array( |
|
1188 | + 'REG_ID' => $this->ID(), |
|
1189 | + 'CHK_in' => true, |
|
1190 | + ), |
|
1191 | + ), 'DTT_ID', true); |
|
1192 | + // checkins have already reached their max number of uses |
|
1193 | + // so registrant can NOT checkin |
|
1194 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1195 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
1196 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1197 | + return false; |
|
1198 | + } |
|
1199 | + return true; |
|
1200 | + } |
|
1201 | + |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * toggle Check-in status for this registration |
|
1205 | + * Check-ins are toggled in the following order: |
|
1206 | + * never checked in -> checked in |
|
1207 | + * checked in -> checked out |
|
1208 | + * checked out -> checked in |
|
1209 | + * |
|
1210 | + * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1211 | + * If not included or null, then it is assumed latest datetime is being toggled. |
|
1212 | + * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1213 | + * can be checked in or not. Otherwise this forces change in checkin status. |
|
1214 | + * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1215 | + * @throws EE_Error |
|
1216 | + */ |
|
1217 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
1218 | + { |
|
1219 | + if (empty($DTT_ID)) { |
|
1220 | + $datetime = $this->get_latest_related_datetime(); |
|
1221 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
1222 | + // verify the registration can checkin for the given DTT_ID |
|
1223 | + } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
1224 | + EE_Error::add_error( |
|
1225 | + sprintf( |
|
1226 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
1227 | + 'event_espresso'), |
|
1228 | + $this->ID(), |
|
1229 | + $DTT_ID |
|
1230 | + ), |
|
1231 | + __FILE__, __FUNCTION__, __LINE__ |
|
1232 | + ); |
|
1233 | + return false; |
|
1234 | + } |
|
1235 | + $status_paths = array( |
|
1236 | + EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
1237 | + EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
1238 | + EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
1239 | + ); |
|
1240 | + //start by getting the current status so we know what status we'll be changing to. |
|
1241 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
1242 | + $status_to = $status_paths[$cur_status]; |
|
1243 | + // database only records true for checked IN or false for checked OUT |
|
1244 | + // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
1245 | + $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
1246 | + // add relation - note Check-ins are always creating new rows |
|
1247 | + // because we are keeping track of Check-ins over time. |
|
1248 | + // Eventually we'll probably want to show a list table |
|
1249 | + // for the individual Check-ins so that they can be managed. |
|
1250 | + $checkin = EE_Checkin::new_instance(array( |
|
1251 | + 'REG_ID' => $this->ID(), |
|
1252 | + 'DTT_ID' => $DTT_ID, |
|
1253 | + 'CHK_in' => $new_status, |
|
1254 | + )); |
|
1255 | + // if the record could not be saved then return false |
|
1256 | + if ($checkin->save() === 0) { |
|
1257 | + if (WP_DEBUG) { |
|
1258 | + global $wpdb; |
|
1259 | + $error = sprintf( |
|
1260 | + __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
1261 | + 'event_espresso'), |
|
1262 | + '<br />', |
|
1263 | + $wpdb->last_error |
|
1264 | + ); |
|
1265 | + } else { |
|
1266 | + $error = __('Registration check in update failed because of an unknown database error', |
|
1267 | + 'event_espresso'); |
|
1268 | + } |
|
1269 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1270 | + return false; |
|
1271 | + } |
|
1272 | + return $status_to; |
|
1273 | + } |
|
1274 | + |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1278 | + * "Latest" is defined by the `DTT_EVT_start` column. |
|
1279 | + * |
|
1280 | + * @return EE_Datetime|null |
|
1281 | + * @throws \EE_Error |
|
1282 | + */ |
|
1283 | + public function get_latest_related_datetime() |
|
1284 | + { |
|
1285 | + return EEM_Datetime::instance()->get_one( |
|
1286 | + array( |
|
1287 | + array( |
|
1288 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1289 | + ), |
|
1290 | + 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
1291 | + ) |
|
1292 | + ); |
|
1293 | + } |
|
1294 | + |
|
1295 | + |
|
1296 | + /** |
|
1297 | + * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1298 | + * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1299 | + * |
|
1300 | + * @throws \EE_Error |
|
1301 | + */ |
|
1302 | + public function get_earliest_related_datetime() |
|
1303 | + { |
|
1304 | + return EEM_Datetime::instance()->get_one( |
|
1305 | + array( |
|
1306 | + array( |
|
1307 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
1308 | + ), |
|
1309 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
1310 | + ) |
|
1311 | + ); |
|
1312 | + } |
|
1313 | + |
|
1314 | + |
|
1315 | + /** |
|
1316 | + * This method simply returns the check-in status for this registration and the given datetime. |
|
1317 | + * If neither the datetime nor the checkin values are provided as arguments, |
|
1318 | + * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1319 | + * |
|
1320 | + * @param int $DTT_ID The ID of the datetime we're checking against |
|
1321 | + * (if empty we'll get the primary datetime for |
|
1322 | + * this registration (via event) and use it's ID); |
|
1323 | + * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1324 | + * @return int Integer representing Check-in status. |
|
1325 | + * @throws \EE_Error |
|
1326 | + */ |
|
1327 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
1328 | + { |
|
1329 | + $checkin_query_params = array( |
|
1330 | + 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
1331 | + ); |
|
1332 | + |
|
1333 | + if ($DTT_ID > 0) { |
|
1334 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1335 | + } |
|
1336 | + |
|
1337 | + //get checkin object (if exists) |
|
1338 | + $checkin = $checkin instanceof EE_Checkin |
|
1339 | + ? $checkin |
|
1340 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
1341 | + if ($checkin instanceof EE_Checkin) { |
|
1342 | + if ($checkin->get('CHK_in')) { |
|
1343 | + return EE_Registration::checkin_status_in; //checked in |
|
1344 | + } |
|
1345 | + return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
1346 | + } |
|
1347 | + return EE_Registration::checkin_status_never; //never been checked in |
|
1348 | + } |
|
1349 | + |
|
1350 | + |
|
1351 | + /** |
|
1352 | + * This method returns a localized message for the toggled Check-in message. |
|
1353 | + * |
|
1354 | + * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
1355 | + * then it is assumed Check-in for primary datetime was toggled. |
|
1356 | + * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
1357 | + * message can be customized with the attendee name. |
|
1358 | + * @return string internationalized message |
|
1359 | + */ |
|
1360 | + public function get_checkin_msg($DTT_ID, $error = false) |
|
1361 | + { |
|
1362 | + //let's get the attendee first so we can include the name of the attendee |
|
1363 | + $attendee = $this->get_first_related('Attendee'); |
|
1364 | + if ($attendee instanceof EE_Attendee) { |
|
1365 | + if ($error) { |
|
1366 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1367 | + } |
|
1368 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1369 | + //what is the status message going to be? |
|
1370 | + switch ($cur_status) { |
|
1371 | + case EE_Registration::checkin_status_never : |
|
1372 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
1373 | + $attendee->full_name()); |
|
1374 | + break; |
|
1375 | + case EE_Registration::checkin_status_in : |
|
1376 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1377 | + break; |
|
1378 | + case EE_Registration::checkin_status_out : |
|
1379 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1380 | + break; |
|
1381 | + } |
|
1382 | + } |
|
1383 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1384 | + } |
|
1385 | + |
|
1386 | + |
|
1387 | + /** |
|
1388 | + * Returns the related EE_Transaction to this registration |
|
1389 | + * |
|
1390 | + * @return EE_Transaction |
|
1391 | + */ |
|
1392 | + public function transaction() |
|
1393 | + { |
|
1394 | + $transaction = $this->get_first_related('Transaction'); |
|
1395 | + if (! $transaction instanceof \EE_Transaction) { |
|
1396 | + throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
1397 | + } |
|
1398 | + return $transaction; |
|
1399 | + } |
|
1400 | + |
|
1401 | + |
|
1402 | + /** |
|
1403 | + * get Registration Code |
|
1404 | + */ |
|
1405 | + public function reg_code() |
|
1406 | + { |
|
1407 | + return $this->get('REG_code'); |
|
1408 | + } |
|
1409 | + |
|
1410 | + |
|
1411 | + /** |
|
1412 | + * get Transaction ID |
|
1413 | + */ |
|
1414 | + public function transaction_ID() |
|
1415 | + { |
|
1416 | + return $this->get('TXN_ID'); |
|
1417 | + } |
|
1418 | + |
|
1419 | + |
|
1420 | + /** |
|
1421 | + * @return int |
|
1422 | + */ |
|
1423 | + public function ticket_ID() |
|
1424 | + { |
|
1425 | + return $this->get('TKT_ID'); |
|
1426 | + } |
|
1427 | + |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * Set Registration Code |
|
1431 | + * |
|
1432 | + * @access public |
|
1433 | + * @param string $REG_code Registration Code |
|
1434 | + * @param boolean $use_default |
|
1435 | + */ |
|
1436 | + public function set_reg_code($REG_code, $use_default = false) |
|
1437 | + { |
|
1438 | + if (empty($REG_code)) { |
|
1439 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1440 | + return; |
|
1441 | + } |
|
1442 | + if (! $this->reg_code()) { |
|
1443 | + parent::set('REG_code', $REG_code, $use_default); |
|
1444 | + } else { |
|
1445 | + EE_Error::doing_it_wrong( |
|
1446 | + __CLASS__ . '::' . __FUNCTION__, |
|
1447 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1448 | + '4.6.0' |
|
1449 | + ); |
|
1450 | + } |
|
1451 | + } |
|
1452 | + |
|
1453 | + |
|
1454 | + /** |
|
1455 | + * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
1456 | + * Note, if you want to just get all registrations in the same transaction (group), use: |
|
1457 | + * $registration->transaction()->registrations(); |
|
1458 | + * |
|
1459 | + * @since 4.5.0 |
|
1460 | + * @return EE_Registration[] or empty array if this isn't a group registration. |
|
1461 | + */ |
|
1462 | + public function get_all_other_registrations_in_group() |
|
1463 | + { |
|
1464 | + if ($this->group_size() < 2) { |
|
1465 | + return array(); |
|
1466 | + } |
|
1467 | + |
|
1468 | + $query[0] = array( |
|
1469 | + 'TXN_ID' => $this->transaction_ID(), |
|
1470 | + 'REG_ID' => array('!=', $this->ID()), |
|
1471 | + 'TKT_ID' => $this->ticket_ID(), |
|
1472 | + ); |
|
1473 | + |
|
1474 | + $registrations = $this->get_model()->get_all($query); |
|
1475 | + return $registrations; |
|
1476 | + } |
|
1477 | + |
|
1478 | + /** |
|
1479 | + * Return the link to the admin details for the object. |
|
1480 | + * |
|
1481 | + * @return string |
|
1482 | + */ |
|
1483 | + public function get_admin_details_link() |
|
1484 | + { |
|
1485 | + EE_Registry::instance()->load_helper('URL'); |
|
1486 | + return EEH_URL::add_query_args_and_nonce( |
|
1487 | + array( |
|
1488 | + 'page' => 'espresso_registrations', |
|
1489 | + 'action' => 'view_registration', |
|
1490 | + '_REG_ID' => $this->ID(), |
|
1491 | + ), |
|
1492 | + admin_url('admin.php') |
|
1493 | + ); |
|
1494 | + } |
|
1495 | + |
|
1496 | + /** |
|
1497 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
1498 | + * |
|
1499 | + * @return string |
|
1500 | + */ |
|
1501 | + public function get_admin_edit_link() |
|
1502 | + { |
|
1503 | + return $this->get_admin_details_link(); |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * Returns the link to a settings page for the object. |
|
1508 | + * |
|
1509 | + * @return string |
|
1510 | + */ |
|
1511 | + public function get_admin_settings_link() |
|
1512 | + { |
|
1513 | + return $this->get_admin_details_link(); |
|
1514 | + } |
|
1515 | + |
|
1516 | + /** |
|
1517 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
1518 | + * |
|
1519 | + * @return string |
|
1520 | + */ |
|
1521 | + public function get_admin_overview_link() |
|
1522 | + { |
|
1523 | + EE_Registry::instance()->load_helper('URL'); |
|
1524 | + return EEH_URL::add_query_args_and_nonce( |
|
1525 | + array( |
|
1526 | + 'page' => 'espresso_registrations', |
|
1527 | + ), |
|
1528 | + admin_url('admin.php') |
|
1529 | + ); |
|
1530 | + } |
|
1531 | + |
|
1532 | + |
|
1533 | + /** |
|
1534 | + * @param array $query_params |
|
1535 | + * @return \EE_Registration[] |
|
1536 | + * @throws \EE_Error |
|
1537 | + */ |
|
1538 | + public function payments($query_params = array()) |
|
1539 | + { |
|
1540 | + return $this->get_many_related('Payment', $query_params); |
|
1541 | + } |
|
1542 | + |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * @param array $query_params |
|
1546 | + * @return \EE_Registration_Payment[] |
|
1547 | + * @throws \EE_Error |
|
1548 | + */ |
|
1549 | + public function registration_payments($query_params = array()) |
|
1550 | + { |
|
1551 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1552 | + } |
|
1553 | + |
|
1554 | + |
|
1555 | + /** |
|
1556 | + * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
1557 | + * Note: if there are no payments on the registration there will be no payment method returned. |
|
1558 | + * |
|
1559 | + * @return EE_Payment_Method|null |
|
1560 | + */ |
|
1561 | + public function payment_method() |
|
1562 | + { |
|
1563 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1564 | + } |
|
1565 | + |
|
1566 | + |
|
1567 | + /** |
|
1568 | + * @return \EE_Line_Item |
|
1569 | + * @throws EntityNotFoundException |
|
1570 | + * @throws \EE_Error |
|
1571 | + */ |
|
1572 | + public function ticket_line_item() |
|
1573 | + { |
|
1574 | + $ticket = $this->ticket(); |
|
1575 | + $transaction = $this->transaction(); |
|
1576 | + $line_item = null; |
|
1577 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
1578 | + $transaction->total_line_item(), |
|
1579 | + 'Ticket', |
|
1580 | + array($ticket->ID()) |
|
1581 | + ); |
|
1582 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
1583 | + if ( |
|
1584 | + $ticket_line_item instanceof \EE_Line_Item |
|
1585 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
1586 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
1587 | + ) { |
|
1588 | + $line_item = $ticket_line_item; |
|
1589 | + break; |
|
1590 | + } |
|
1591 | + } |
|
1592 | + if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
1593 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
1594 | + } |
|
1595 | + return $line_item; |
|
1596 | + } |
|
1597 | + |
|
1598 | + |
|
1599 | + /** |
|
1600 | + * Soft Deletes this model object. |
|
1601 | + * |
|
1602 | + * @return boolean | int |
|
1603 | + * @throws \RuntimeException |
|
1604 | + * @throws \EE_Error |
|
1605 | + */ |
|
1606 | + public function delete() |
|
1607 | + { |
|
1608 | + if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1609 | + $this->set_status(EEM_Registration::status_id_cancelled); |
|
1610 | + } |
|
1611 | + return parent::delete(); |
|
1612 | + } |
|
1613 | + |
|
1614 | + |
|
1615 | + /** |
|
1616 | + * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
1617 | + * |
|
1618 | + * @throws \EE_Error |
|
1619 | + * @throws \RuntimeException |
|
1620 | + */ |
|
1621 | + public function restore() |
|
1622 | + { |
|
1623 | + $previous_status = $this->get_extra_meta( |
|
1624 | + EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
1625 | + true, |
|
1626 | + EEM_Registration::status_id_cancelled |
|
1627 | + ); |
|
1628 | + if ($previous_status) { |
|
1629 | + $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
1630 | + $this->set_status($previous_status); |
|
1631 | + } |
|
1632 | + return parent::restore(); |
|
1633 | + } |
|
1634 | + |
|
1635 | + |
|
1636 | + |
|
1637 | + /*************************** DEPRECATED ***************************/ |
|
1638 | + |
|
1639 | + |
|
1640 | + /** |
|
1641 | + * @deprecated |
|
1642 | + * @since 4.7.0 |
|
1643 | + * @access public |
|
1644 | + */ |
|
1645 | + public function price_paid() |
|
1646 | + { |
|
1647 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
1648 | + __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
1649 | + '4.7.0'); |
|
1650 | + return $this->final_price(); |
|
1651 | + } |
|
1652 | + |
|
1653 | + |
|
1654 | + /** |
|
1655 | + * @deprecated |
|
1656 | + * @since 4.7.0 |
|
1657 | + * @access public |
|
1658 | + * @param float $REG_final_price |
|
1659 | + */ |
|
1660 | + public function set_price_paid($REG_final_price = 0.00) |
|
1661 | + { |
|
1662 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
1663 | + __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
1664 | + '4.7.0'); |
|
1665 | + $this->set_final_price($REG_final_price); |
|
1666 | + } |
|
1667 | + |
|
1668 | + |
|
1669 | + /** |
|
1670 | + * @deprecated |
|
1671 | + * @since 4.7.0 |
|
1672 | + * @return string |
|
1673 | + */ |
|
1674 | + public function pretty_price_paid() |
|
1675 | + { |
|
1676 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
1677 | + __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
1678 | + 'event_espresso'), '4.7.0'); |
|
1679 | + return $this->pretty_final_price(); |
|
1680 | + } |
|
1681 | + |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * Gets the primary datetime related to this registration via the related Event to this registration |
|
1685 | + * |
|
1686 | + * @deprecated 4.9.17 |
|
1687 | + * @return EE_Datetime |
|
1688 | + */ |
|
1689 | + public function get_related_primary_datetime() |
|
1690 | + { |
|
1691 | + EE_Error::doing_it_wrong( |
|
1692 | + __METHOD__, |
|
1693 | + esc_html__( |
|
1694 | + 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1695 | + 'event_espresso' |
|
1696 | + ), |
|
1697 | + '4.9.17', |
|
1698 | + '5.0.0' |
|
1699 | + ); |
|
1700 | + return $this->event()->primary_datetime(); |
|
1701 | + } |
|
1702 | 1702 | |
1703 | 1703 | |
1704 | 1704 | } |