@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Add_New_State |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | * @return void |
28 | 28 | */ |
29 | 29 | public static function set_hooks() { |
30 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
31 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'translate_js_strings' ), 0 ); |
|
32 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'wp_enqueue_scripts' ), 10 ); |
|
33 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
34 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
35 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
36 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
37 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
38 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
39 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
30 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
31 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
32 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
33 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
34 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
35 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
36 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
37 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
38 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
39 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | public static function set_hooks_admin() { |
49 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
50 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
51 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
52 | - add_action( 'wp_ajax_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
53 | - add_action( 'wp_ajax_nopriv_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
54 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
55 | - add_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
56 | - add_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
57 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
58 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
59 | - add_filter( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
|
60 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
61 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
49 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
50 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
51 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
52 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
53 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
54 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
55 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
56 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
57 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
58 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
59 | + add_filter('FHEE__Single_Page_Checkout___check_form_submission__request_params', array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
60 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
61 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | public static function set_definitions() { |
73 | - define( 'ANS_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
74 | - define( 'ANS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
73 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
74 | + define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param \WP $WP |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public function run( $WP ) { |
|
86 | + public function run($WP) { |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function wp_enqueue_scripts() { |
114 | - if ( apply_filters( 'EED_Single_Page_Checkout__SPCO_active', false ) ) { |
|
115 | - wp_register_script( 'add_new_state', ANS_ASSETS_URL . 'add_new_state.js', array( 'espresso_core', 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, true ); |
|
116 | - wp_enqueue_script( 'add_new_state' ); |
|
114 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
115 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
116 | + wp_enqueue_script('add_new_state'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,30 +127,30 @@ discard block |
||
127 | 127 | * @return string |
128 | 128 | */ |
129 | 129 | // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
130 | - public static function display_add_new_state_micro_form( EE_Form_Section_Proper $question_group_reg_form ){ |
|
130 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) { |
|
131 | 131 | // only add the 'new_state_micro_form' when displaying reg forms, |
132 | 132 | // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
133 | - $action = EE_Registry::instance()->REQ->get( 'action', '' ); |
|
134 | - if ( $action === 'process_reg_step' || $action === 'update_reg_step' ) { |
|
133 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
134 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
135 | 135 | return $question_group_reg_form; |
136 | 136 | } |
137 | 137 | // is the "state" question in this form section? |
138 | - $input = $question_group_reg_form->get_subsection( 'state' ); |
|
138 | + $input = $question_group_reg_form->get_subsection('state'); |
|
139 | 139 | // we're only doing this for state select inputs |
140 | - if ( $input instanceof EE_State_Select_Input ) { |
|
140 | + if ($input instanceof EE_State_Select_Input) { |
|
141 | 141 | // load helpers |
142 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
142 | + EE_Registry::instance()->load_helper('HTML'); |
|
143 | 143 | // grab any set values from the request |
144 | - $country_name = str_replace( 'state', 'new_state_country', $input->html_name() ); |
|
145 | - $state_name = str_replace( 'state', 'new_state_name', $input->html_name() ); |
|
146 | - $abbrv_name = str_replace( 'state', 'new_state_abbrv', $input->html_name() ); |
|
147 | - $new_state_submit_id = str_replace( 'state', 'new_state', $input->html_id() ); |
|
144 | + $country_name = str_replace('state', 'new_state_country', $input->html_name()); |
|
145 | + $state_name = str_replace('state', 'new_state_name', $input->html_name()); |
|
146 | + $abbrv_name = str_replace('state', 'new_state_abbrv', $input->html_name()); |
|
147 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
148 | 148 | $country_options = array(); |
149 | 149 | $countries = EEM_Country::instance()->get_all_countries(); |
150 | - if ( ! empty( $countries )) { |
|
151 | - foreach( $countries as $country ){ |
|
152 | - if ( $country instanceof EE_Country ) { |
|
153 | - $country_options[ $country->ID() ] = $country->name(); |
|
150 | + if ( ! empty($countries)) { |
|
151 | + foreach ($countries as $country) { |
|
152 | + if ($country instanceof EE_Country) { |
|
153 | + $country_options[$country->ID()] = $country->name(); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | // add hidden input to indicate that a new state is being added |
164 | 164 | 'add_new_state' => new EE_Hidden_Input( |
165 | 165 | array( |
166 | - 'html_name' => str_replace( 'state', 'add_new_state', $input->html_name() ), |
|
167 | - 'html_id' => str_replace( 'state', 'add_new_state', $input->html_id() ), |
|
166 | + 'html_name' => str_replace('state', 'add_new_state', $input->html_name()), |
|
167 | + 'html_id' => str_replace('state', 'add_new_state', $input->html_id()), |
|
168 | 168 | 'default' => 0 |
169 | 169 | ) |
170 | 170 | ), |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | '', |
177 | 177 | __('click here to add a new state/province', 'event_espresso'), |
178 | 178 | '', |
179 | - 'display-' . $input->html_id(), |
|
179 | + 'display-'.$input->html_id(), |
|
180 | 180 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
181 | 181 | '', |
182 | - 'rel="' . $input->html_id() . '"' |
|
182 | + 'rel="'.$input->html_id().'"' |
|
183 | 183 | ) |
184 | 184 | ) |
185 | 185 | ), |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | 'add_new_state_micro_form' =>new EE_Form_Section_HTML( |
188 | 188 | apply_filters( |
189 | 189 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
190 | - EEH_HTML::div( '', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;' ) . |
|
191 | - EEH_HTML::h6( __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) . |
|
192 | - EEH_HTML::ul() . |
|
193 | - EEH_HTML::li( __('first select the Country that your State/Province belongs to', 'event_espresso') ) . |
|
194 | - EEH_HTML::li( __('enter the name of your State/Province', 'event_espresso') ) . |
|
195 | - EEH_HTML::li( __('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso') ) . |
|
196 | - EEH_HTML::li( __('click the ADD button', 'event_espresso') ) . |
|
190 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', 'display: none;'). |
|
191 | + EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')). |
|
192 | + EEH_HTML::ul(). |
|
193 | + EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')). |
|
194 | + EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')). |
|
195 | + EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')). |
|
196 | + EEH_HTML::li(__('click the ADD button', 'event_espresso')). |
|
197 | 197 | EEH_HTML::ulx() |
198 | 198 | ) |
199 | 199 | ), |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | $country_options, |
203 | 203 | array( |
204 | 204 | 'html_name' => $country_name, |
205 | - 'html_id' => str_replace( 'state', 'new_state_country', $input->html_id() ), |
|
206 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
205 | + 'html_id' => str_replace('state', 'new_state_country', $input->html_id()), |
|
206 | + 'html_class' => $input->html_class().' new-state-country', |
|
207 | 207 | 'html_label_text' => __('New State/Province Country', 'event_espresso'), |
208 | - 'default' => EE_Registry::instance()->REQ->get( $country_name, '' ), |
|
208 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
209 | 209 | 'required' => false |
210 | 210 | ) |
211 | 211 | ), |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | 'new_state_name' => new EE_Text_Input( |
214 | 214 | array( |
215 | 215 | 'html_name' => $state_name, |
216 | - 'html_id' => str_replace( 'state', 'new_state_name', $input->html_id() ), |
|
217 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
216 | + 'html_id' => str_replace('state', 'new_state_name', $input->html_id()), |
|
217 | + 'html_class' => $input->html_class().' new-state-state', |
|
218 | 218 | 'html_label_text' => __('New State/Province Name', 'event_espresso'), |
219 | - 'default' => EE_Registry::instance()->REQ->get( $state_name, '' ), |
|
219 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
220 | 220 | 'required' => false |
221 | 221 | ) |
222 | 222 | ), |
223 | - 'spacer' => new EE_Form_Section_HTML( EEH_HTML::br() ), |
|
223 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
224 | 224 | // NEW STATE NAME |
225 | 225 | 'new_state_abbrv' => new EE_Text_Input( |
226 | 226 | array( |
227 | 227 | 'html_name' => $abbrv_name, |
228 | - 'html_id' => str_replace( 'state', 'new_state_abbrv', $input->html_id() ), |
|
229 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
228 | + 'html_id' => str_replace('state', 'new_state_abbrv', $input->html_id()), |
|
229 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
230 | 230 | 'html_label_text' => __('New State/Province Abbreviation', 'event_espresso'), |
231 | 231 | 'html_other_attributes' => 'size="24"', |
232 | - 'default' => EE_Registry::instance()->REQ->get( $abbrv_name, '' ), |
|
232 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
233 | 233 | 'required' => false |
234 | 234 | ) |
235 | 235 | ), |
@@ -237,26 +237,26 @@ discard block |
||
237 | 237 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
238 | 238 | apply_filters( |
239 | 239 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
240 | - EEH_HTML::nbsp(3) . |
|
241 | - EEH_HTML::link( '', __('ADD', 'event_espresso'), '', 'submit-' . $new_state_submit_id, 'ee-form-add-new-state-submit button button-secondary', '', 'rel="' . $new_state_submit_id . '"' ) |
|
240 | + EEH_HTML::nbsp(3). |
|
241 | + EEH_HTML::link('', __('ADD', 'event_espresso'), '', 'submit-'.$new_state_submit_id, 'ee-form-add-new-state-submit button button-secondary', '', 'rel="'.$new_state_submit_id.'"') |
|
242 | 242 | ) |
243 | 243 | ), |
244 | 244 | // extra info |
245 | 245 | 'add_new_state_extra' => new EE_Form_Section_HTML( |
246 | 246 | apply_filters( |
247 | 247 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
248 | - EEH_HTML::br(2) . |
|
249 | - EEH_HTML::div( '', '', 'small-text' ) . |
|
250 | - EEH_HTML::strong( __('Don\'t know your State/Province Abbreviation?', 'event_espresso') ) . |
|
251 | - EEH_HTML::br() . |
|
248 | + EEH_HTML::br(2). |
|
249 | + EEH_HTML::div('', '', 'small-text'). |
|
250 | + EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')). |
|
251 | + EEH_HTML::br(). |
|
252 | 252 | sprintf( |
253 | 253 | __('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'), |
254 | - EEH_HTML::link( 'http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk' ) |
|
255 | - ) . |
|
256 | - EEH_HTML::divx() . |
|
257 | - EEH_HTML::br() . |
|
258 | - EEH_HTML::link( '', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'rel="' . $input->html_id() . '"' ) . |
|
259 | - EEH_HTML::divx() . |
|
254 | + EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk') |
|
255 | + ). |
|
256 | + EEH_HTML::divx(). |
|
257 | + EEH_HTML::br(). |
|
258 | + EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'rel="'.$input->html_id().'"'). |
|
259 | + EEH_HTML::divx(). |
|
260 | 260 | EEH_HTML::br() |
261 | 261 | ) |
262 | 262 | ) |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ); |
267 | - $question_group_reg_form->add_subsections( array( 'new_state_micro_form' => $new_state_micro_form ), 'state', false ); |
|
267 | + $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false); |
|
268 | 268 | } |
269 | 269 | return $question_group_reg_form; |
270 | 270 | } |
@@ -281,41 +281,41 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public static function add_new_state() { |
283 | 283 | $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
284 | - if ( $REQ->is_set( 'add_new_state' ) && $REQ->get( 'add_new_state' ) == 1 ) { |
|
284 | + if ($REQ->is_set('add_new_state') && $REQ->get('add_new_state') == 1) { |
|
285 | 285 | EE_Registry::instance()->load_model('State'); |
286 | 286 | // grab country ISO code, new state name, and new state abbreviation |
287 | - $state_country = $REQ->is_set( 'new_state_country' ) ? sanitize_text_field( $REQ->get( 'new_state_country' )) : FALSE; |
|
288 | - $state_name = $REQ->is_set( 'new_state_name' ) ? sanitize_text_field( $REQ->get( 'new_state_name' )) : FALSE; |
|
289 | - $state_abbr = $REQ->is_set( 'new_state_abbrv' ) ? sanitize_text_field( $REQ->get( 'new_state_abbrv' )) : FALSE; |
|
287 | + $state_country = $REQ->is_set('new_state_country') ? sanitize_text_field($REQ->get('new_state_country')) : FALSE; |
|
288 | + $state_name = $REQ->is_set('new_state_name') ? sanitize_text_field($REQ->get('new_state_name')) : FALSE; |
|
289 | + $state_abbr = $REQ->is_set('new_state_abbrv') ? sanitize_text_field($REQ->get('new_state_abbrv')) : FALSE; |
|
290 | 290 | |
291 | 291 | //echo '<h4>$state_country : ' . $state_country . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
292 | 292 | //echo '<h4>$state_name : ' . $state_name . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
293 | 293 | //echo '<h4>$state_abbr : ' . $state_abbr . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
294 | 294 | |
295 | - if ( $state_country && $state_name && $state_abbr ) { |
|
296 | - $new_state = EED_Add_New_State::save_new_state_to_db( array( |
|
297 | - 'CNT_ISO'=> strtoupper( $state_country ), |
|
298 | - 'STA_abbrev' => strtoupper( $state_abbr ), |
|
299 | - 'STA_name' => ucwords( $state_name ), |
|
295 | + if ($state_country && $state_name && $state_abbr) { |
|
296 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
297 | + 'CNT_ISO'=> strtoupper($state_country), |
|
298 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
299 | + 'STA_name' => ucwords($state_name), |
|
300 | 300 | 'STA_active' => FALSE |
301 | 301 | )); |
302 | 302 | |
303 | - if ( $new_state instanceof EE_State ) { |
|
303 | + if ($new_state instanceof EE_State) { |
|
304 | 304 | // clean house |
305 | - EE_Registry::instance()->REQ->un_set( 'add_new_state' ); |
|
306 | - EE_Registry::instance()->REQ->un_set( 'new_state_country' ); |
|
307 | - EE_Registry::instance()->REQ->un_set( 'new_state_name' ); |
|
308 | - EE_Registry::instance()->REQ->un_set( 'new_state_abbrv' ); |
|
305 | + EE_Registry::instance()->REQ->un_set('add_new_state'); |
|
306 | + EE_Registry::instance()->REQ->un_set('new_state_country'); |
|
307 | + EE_Registry::instance()->REQ->un_set('new_state_name'); |
|
308 | + EE_Registry::instance()->REQ->un_set('new_state_abbrv'); |
|
309 | 309 | |
310 | 310 | // get any existing new states |
311 | 311 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
312 | 312 | 'new_states' |
313 | 313 | ); |
314 | - $new_states[ $new_state->ID() ] = $new_state; |
|
315 | - EE_Registry::instance()->SSN->set_session_data( array( 'new_states' => $new_states )); |
|
314 | + $new_states[$new_state->ID()] = $new_state; |
|
315 | + EE_Registry::instance()->SSN->set_session_data(array('new_states' => $new_states)); |
|
316 | 316 | |
317 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
318 | - echo json_encode( array( |
|
317 | + if (EE_Registry::instance()->REQ->ajax) { |
|
318 | + echo json_encode(array( |
|
319 | 319 | 'success' => TRUE, |
320 | 320 | 'id' => $new_state->ID(), |
321 | 321 | 'name' => $new_state->name(), |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | } else { |
333 | - $error = __( 'A new State/Province could not be added because invalid or missing data was received.', 'event_espresso' ); |
|
334 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
335 | - echo json_encode( array( 'error' => $error )); |
|
333 | + $error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso'); |
|
334 | + if (EE_Registry::instance()->REQ->ajax) { |
|
335 | + echo json_encode(array('error' => $error)); |
|
336 | 336 | exit(); |
337 | 337 | } else { |
338 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
338 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | } |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | * @param array $request_params |
354 | 354 | * @return array |
355 | 355 | */ |
356 | - public static function filter_checkout_request_params ( $request_params ) { |
|
357 | - foreach ( $request_params as $form_section ) { |
|
358 | - if ( is_array( $form_section )) { |
|
359 | - EED_Add_New_State::unset_new_state_request_params( $form_section ); |
|
360 | - EED_Add_New_State::filter_checkout_request_params( $form_section ); |
|
356 | + public static function filter_checkout_request_params($request_params) { |
|
357 | + foreach ($request_params as $form_section) { |
|
358 | + if (is_array($form_section)) { |
|
359 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
360 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | return $request_params; |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | * @param array $request_params |
373 | 373 | * @return boolean |
374 | 374 | */ |
375 | - public static function unset_new_state_request_params ( $request_params ) { |
|
376 | - unset( $request_params[ 'new_state_micro_form' ] ); |
|
377 | - unset( $request_params[ 'add_new_state' ] ); |
|
378 | - unset( $request_params[ 'new_state_country' ] ); |
|
379 | - unset( $request_params[ 'new_state_name' ] ); |
|
380 | - unset( $request_params[ 'new_state_abbrv' ] ); |
|
375 | + public static function unset_new_state_request_params($request_params) { |
|
376 | + unset($request_params['new_state_micro_form']); |
|
377 | + unset($request_params['add_new_state']); |
|
378 | + unset($request_params['new_state_country']); |
|
379 | + unset($request_params['new_state_name']); |
|
380 | + unset($request_params['new_state_abbrv']); |
|
381 | 381 | return $request_params; |
382 | 382 | } |
383 | 383 | |
@@ -390,25 +390,25 @@ discard block |
||
390 | 390 | * @param array $props_n_values |
391 | 391 | * @return boolean |
392 | 392 | */ |
393 | - public static function save_new_state_to_db ( $props_n_values = array() ) { |
|
393 | + public static function save_new_state_to_db($props_n_values = array()) { |
|
394 | 394 | // EEH_Debug_Tools::printr( $props_n_values, '$props_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
395 | - $existing_state = EEM_State::instance()->get_all( array( $props_n_values, 'limit' => 1 )); |
|
396 | - if ( ! empty( $existing_state )) { |
|
397 | - return array_pop( $existing_state ); |
|
395 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
396 | + if ( ! empty($existing_state)) { |
|
397 | + return array_pop($existing_state); |
|
398 | 398 | } |
399 | - $new_state = EE_State::new_instance( $props_n_values ); |
|
400 | - if ( $new_state instanceof EE_State ) { |
|
399 | + $new_state = EE_State::new_instance($props_n_values); |
|
400 | + if ($new_state instanceof EE_State) { |
|
401 | 401 | // if not non-ajax admin |
402 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
402 | + $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(); |
|
403 | 403 | $new_state_notice = sprintf( |
404 | - __( 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso' ), |
|
405 | - '<b>' . $new_state->name() . '</b>', |
|
406 | - '<b>' . $new_state->abbrev() . '</b>', |
|
407 | - '<b>' . $new_state->country()->name() . '</b>', |
|
408 | - '<a href="' . add_query_arg( array( 'page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso() ), admin_url( 'admin.php' )) . '">' . __( 'Event Espresso - General Settings > Countries Tab', 'event_espresso' ) . '</a>', |
|
404 | + __('A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso'), |
|
405 | + '<b>'.$new_state->name().'</b>', |
|
406 | + '<b>'.$new_state->abbrev().'</b>', |
|
407 | + '<b>'.$new_state->country()->name().'</b>', |
|
408 | + '<a href="'.add_query_arg(array('page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso()), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab', 'event_espresso').'</a>', |
|
409 | 409 | '<br />' |
410 | 410 | ); |
411 | - EE_Error::add_persistent_admin_notice( $new_state_key, $new_state_notice ); |
|
411 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
412 | 412 | $new_state->save(); |
413 | 413 | EEM_State::instance()->reset_cached_states(); |
414 | 414 | return $new_state; |
@@ -427,22 +427,22 @@ discard block |
||
427 | 427 | * @param array $cols_n_values |
428 | 428 | * @return boolean |
429 | 429 | */ |
430 | - public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) { |
|
431 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE; |
|
432 | - if ( ! $CNT_ISO ) { |
|
433 | - EE_Error::add_error( __( 'An invalid or missing Country ISO Code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
430 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) { |
|
431 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : FALSE; |
|
432 | + if ( ! $CNT_ISO) { |
|
433 | + EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
434 | 434 | } |
435 | - $STA_abbrev = is_array( $cols_n_values ) && isset( $cols_n_values['STA_abbrev'] ) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
436 | - if ( ! $STA_abbrev && ! empty( $STA_ID )) { |
|
437 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
438 | - if ( $state instanceof EE_State ) { |
|
435 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
436 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
437 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
438 | + if ($state instanceof EE_State) { |
|
439 | 439 | $STA_abbrev = $state->abbrev(); |
440 | 440 | } |
441 | 441 | } |
442 | - if ( ! $STA_abbrev ) { |
|
443 | - EE_Error::add_error( __( 'An invalid or missing State Abbreviation was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
442 | + if ( ! $STA_abbrev) { |
|
443 | + EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
444 | 444 | } |
445 | - EE_Error::dismiss_persistent_admin_notice( $CNT_ISO . '-' . $STA_abbrev, TRUE, TRUE ); |
|
445 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, TRUE, TRUE); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param $answer |
459 | 459 | * @return bool |
460 | 460 | */ |
461 | - public static function inject_new_reg_state_into_options( $state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
462 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state ) { |
|
461 | + public static function inject_new_reg_state_into_options($state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
462 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state) { |
|
463 | 463 | $STA_ID = $answer->value(); |
464 | - if ( ! empty( $STA_ID ) ) { |
|
465 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
466 | - if ( $state instanceof EE_State ) { |
|
464 | + if ( ! empty($STA_ID)) { |
|
465 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
466 | + if ($state instanceof EE_State) { |
|
467 | 467 | $country = $state->country(); |
468 | - if ( $country instanceof EE_Country ) { |
|
469 | - if ( ! isset( $state_options[ $country->name() ] )) { |
|
470 | - $state_options[ $country->name() ] = array(); |
|
468 | + if ($country instanceof EE_Country) { |
|
469 | + if ( ! isset($state_options[$country->name()])) { |
|
470 | + $state_options[$country->name()] = array(); |
|
471 | 471 | } |
472 | - if ( ! isset( $state_options[ $country->name() ][ $STA_ID ] )) { |
|
473 | - $state_options[ $country->name() ][ $STA_ID ] = $state->name(); |
|
472 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
473 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | * @param $answer |
493 | 493 | * @return bool |
494 | 494 | */ |
495 | - public static function inject_new_reg_country_into_options( $country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
496 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country ) { |
|
495 | + public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
496 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) { |
|
497 | 497 | $CNT_ISO = $answer->value(); |
498 | - if ( ! empty( $CNT_ISO ) ) { |
|
499 | - $country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO ); |
|
500 | - if ( $country instanceof EE_Country ) { |
|
501 | - if ( ! isset( $country_options[ $CNT_ISO ] ) ) { |
|
502 | - $country_options[ $CNT_ISO ] = $country->name(); |
|
498 | + if ( ! empty($CNT_ISO)) { |
|
499 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
500 | + if ($country instanceof EE_Country) { |
|
501 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
502 | + $country_options[$CNT_ISO] = $country->name(); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | } |
@@ -516,17 +516,17 @@ discard block |
||
516 | 516 | * @param EE_State[] $state_options |
517 | 517 | * @return boolean |
518 | 518 | */ |
519 | - public static function state_options( $state_options = array() ) { |
|
519 | + public static function state_options($state_options = array()) { |
|
520 | 520 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
521 | 521 | 'new_states' |
522 | 522 | ); |
523 | - if ( is_array( $new_states ) && ! empty( $new_states )) { |
|
524 | - foreach ( $new_states as $new_state ) { |
|
523 | + if (is_array($new_states) && ! empty($new_states)) { |
|
524 | + foreach ($new_states as $new_state) { |
|
525 | 525 | if ( |
526 | 526 | $new_state instanceof EE_State |
527 | 527 | && $new_state->country() instanceof EE_Country |
528 | 528 | ) { |
529 | - $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name(); |
|
529 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | * @param EE_Country[] $country_options |
543 | 543 | * @return boolean |
544 | 544 | */ |
545 | - public static function country_options( $country_options = array() ) { |
|
545 | + public static function country_options($country_options = array()) { |
|
546 | 546 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
547 | 547 | 'new_states' |
548 | 548 | ); |
549 | - if ( is_array( $new_states ) && ! empty( $new_states )) { |
|
550 | - foreach ( $new_states as $new_state ) { |
|
549 | + if (is_array($new_states) && ! empty($new_states)) { |
|
550 | + foreach ($new_states as $new_state) { |
|
551 | 551 | if ( |
552 | 552 | $new_state instanceof EE_State |
553 | 553 | && $new_state->country() instanceof EE_Country |
554 | 554 | ) { |
555 | - $country_options[ $new_state->country()->ID() ] = $new_state->country()->name(); |
|
555 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | } |
@@ -22,7 +22,6 @@ |
||
22 | 22 | /** |
23 | 23 | * Removes the checkin and checkout endpoints from the index for requests |
24 | 24 | * to api versions lowers than 4.8.33 |
25 | - * @param array $routes_on_this_version |
|
26 | 25 | * @param EventEspresso\core\libraries\rest_api\controllers\Base $controller |
27 | 26 | * @return array like $routes_on_this_version |
28 | 27 | */ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | //is for lower than 4.8.33 |
14 | 14 | add_filter( |
15 | 15 | 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
16 | - array( $this, 'remove_response_headers' ), |
|
16 | + array($this, 'remove_response_headers'), |
|
17 | 17 | 10, |
18 | 18 | 3 |
19 | 19 | ); |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @param EventEspresso\core\libraries\rest_api\controllers\Base $controller |
27 | 27 | * @return array like $routes_on_this_version |
28 | 28 | */ |
29 | - public function remove_response_headers( $response_headers, $controller, $requested_version ) { |
|
30 | - if( $controller instanceof Base |
|
31 | - && $this->applies_to_version( $requested_version ) ) { |
|
29 | + public function remove_response_headers($response_headers, $controller, $requested_version) { |
|
30 | + if ($controller instanceof Base |
|
31 | + && $this->applies_to_version($requested_version)) { |
|
32 | 32 | return array(); |
33 | 33 | } |
34 | 34 | return $response_headers; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table { |
33 | 33 | |
34 | - public function __construct( $admin_page ) { |
|
34 | + public function __construct($admin_page) { |
|
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
37 | 37 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _setup_data() { |
42 | - $this->_data = $this->_admin_page->get_categories( $this->_per_page, $this->_current_page); |
|
43 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( array( array( 'taxonomy' => 'espresso_event_categories' ) ) ); |
|
42 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
43 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count(array(array('taxonomy' => 'espresso_event_categories'))); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | protected function _set_properties() { |
51 | 51 | $this->_wp_list_args = array( |
52 | - 'singular' => __('event category', 'event_espresso' ), |
|
53 | - 'plural' => __('event categories', 'event_espresso' ), |
|
52 | + 'singular' => __('event category', 'event_espresso'), |
|
53 | + 'plural' => __('event categories', 'event_espresso'), |
|
54 | 54 | 'ajax' => TRUE, //for now, |
55 | 55 | 'screen' => $this->_admin_page->get_current_screen()->id |
56 | 56 | ); |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | $this->_sortable_columns = array( |
67 | - 'id' => array( 'Term.term_id' => true ), |
|
68 | - 'name' => array( 'Term.slug' => false ), |
|
69 | - 'count' => array( 'term_count' => false ) |
|
67 | + 'id' => array('Term.term_id' => true), |
|
68 | + 'name' => array('Term.slug' => false), |
|
69 | + 'count' => array('term_count' => false) |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $this->_primary_column = 'id'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | public function column_cb($item) { |
101 | - return sprintf( '<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id') ); |
|
101 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function column_id($item) { |
109 | 109 | $content = $item->get('term_id'); |
110 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get('name') . '</span>'; |
|
110 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get('name').'</span>'; |
|
111 | 111 | return $content; |
112 | 112 | } |
113 | 113 | |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | 'EVT_CAT_ID' => $item->get('term_id') |
128 | 128 | ); |
129 | 129 | |
130 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
131 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce( $delete_query_args, EVENTS_ADMIN_URL ); |
|
130 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
131 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
132 | 132 | |
133 | 133 | $actions = array( |
134 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Category', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>' |
|
134 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Category', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | |
138 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__('Delete Category', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>'; |
|
138 | + $actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__('Delete Category', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
139 | 139 | |
140 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get('name') . '</a></strong>'; |
|
140 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get('name').'</a></strong>'; |
|
141 | 141 | $content .= $this->row_actions($actions); |
142 | 142 | return $content; |
143 | 143 | } |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | public function column_shortcode($item) { |
149 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
149 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
150 | 150 | return $content; |
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - public function column_count( $item ) { |
|
156 | + public function column_count($item) { |
|
157 | 157 | $e_args = array( |
158 | 158 | 'action' => 'default', |
159 | 159 | 'EVT_CAT' => $item->get_first_related('Term')->ID() |
160 | 160 | ); |
161 | - $e_link = EE_Admin_Page::add_query_args_and_nonce( $e_args, EVENTS_ADMIN_URL ); |
|
162 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
161 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
162 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
163 | 163 | return $content; |
164 | 164 | } |
165 | 165 | } |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{ |
12 | 12 | |
13 | 13 | /** |
14 | - * @param null $validation_error_message |
|
15 | - */ |
|
14 | + * @param null $validation_error_message |
|
15 | + */ |
|
16 | 16 | public function __construct( $validation_error_message = NULL ) { |
17 | 17 | if( ! $validation_error_message ){ |
18 | 18 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * @return array |
|
42 | - */ |
|
41 | + * @return array |
|
42 | + */ |
|
43 | 43 | function get_jquery_validation_rule_array(){ |
44 | 44 | return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) ); |
45 | 45 | } |
@@ -8,16 +8,16 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{ |
|
11 | +class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param null $validation_error_message |
15 | 15 | */ |
16 | - public function __construct( $validation_error_message = NULL ) { |
|
17 | - if( ! $validation_error_message ){ |
|
16 | + public function __construct($validation_error_message = NULL) { |
|
17 | + if ( ! $validation_error_message) { |
|
18 | 18 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
19 | 19 | } |
20 | - parent::__construct( $validation_error_message ); |
|
20 | + parent::__construct($validation_error_message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @return bool |
30 | 30 | * @throws \EE_Validation_Error |
31 | 31 | */ |
32 | - function validate( $normalized_value ) { |
|
33 | - if( $normalized_value && ! $this->_validate_email( $normalized_value ) ){ |
|
34 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
32 | + function validate($normalized_value) { |
|
33 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
34 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - function get_jquery_validation_rule_array(){ |
|
44 | - return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) ); |
|
43 | + function get_jquery_validation_rule_array() { |
|
44 | + return array('email'=>true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | * @return bool of whether the email is valid or not |
55 | 55 | * @throws \EE_Validation_Error |
56 | 56 | */ |
57 | - private function _validate_email( $email ) { |
|
58 | - if ( ! preg_match( '/^.+\@\S+\.\S+$/', $email ) ) { |
|
57 | + private function _validate_email($email) { |
|
58 | + if ( ! preg_match('/^.+\@\S+\.\S+$/', $email)) { |
|
59 | 59 | // email not in correct {string}@{string}.{string} format |
60 | 60 | return false; |
61 | 61 | } else { |
62 | - $atIndex = strrpos( $email, "@" ); |
|
63 | - $domain = substr( $email, $atIndex + 1 ); |
|
64 | - $local = substr( $email, 0, $atIndex ); |
|
65 | - $localLen = strlen( $local ); |
|
66 | - $domainLen = strlen( $domain ); |
|
67 | - if ( $localLen < 1 || $localLen > 64 ) { |
|
62 | + $atIndex = strrpos($email, "@"); |
|
63 | + $domain = substr($email, $atIndex + 1); |
|
64 | + $local = substr($email, 0, $atIndex); |
|
65 | + $localLen = strlen($local); |
|
66 | + $domainLen = strlen($domain); |
|
67 | + if ($localLen < 1 || $localLen > 64) { |
|
68 | 68 | // local part length exceeded |
69 | 69 | return false; |
70 | - } else if ( $domainLen < 1 || $domainLen > 255 ) { |
|
70 | + } else if ($domainLen < 1 || $domainLen > 255) { |
|
71 | 71 | // domain part length exceeded |
72 | 72 | return false; |
73 | - } else if ( $local[ 0 ] == '.' || $local[ $localLen - 1 ] == '.' ) { |
|
73 | + } else if ($local[0] == '.' || $local[$localLen - 1] == '.') { |
|
74 | 74 | // local part starts or ends with '.' |
75 | 75 | return false; |
76 | - } else if ( preg_match( '/\\.\\./', $local ) ) { |
|
76 | + } else if (preg_match('/\\.\\./', $local)) { |
|
77 | 77 | // local part has two consecutive dots |
78 | 78 | return false; |
79 | - } else if ( preg_match( '/\\.\\./', $domain ) ) { |
|
79 | + } else if (preg_match('/\\.\\./', $domain)) { |
|
80 | 80 | // domain part has two consecutive dots |
81 | 81 | return false; |
82 | 82 | } else if ( |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | ) |
88 | 88 | ) { |
89 | 89 | return false; |
90 | - } else if ( apply_filters( 'FHEE__EE_Email_Validation_Strategy___validate_email__perform_dns_checks', false ) ) { |
|
91 | - if ( ! checkdnsrr( $domain, "MX" ) ) { |
|
90 | + } else if (apply_filters('FHEE__EE_Email_Validation_Strategy___validate_email__perform_dns_checks', false)) { |
|
91 | + if ( ! checkdnsrr($domain, "MX")) { |
|
92 | 92 | // domain not found in MX records |
93 | 93 | throw new EE_Validation_Error( |
94 | 94 | __( |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'event_espresso' |
97 | 97 | ) |
98 | 98 | ); |
99 | - } else if ( ! checkdnsrr( $domain, "A" ) ) { |
|
99 | + } else if ( ! checkdnsrr($domain, "A")) { |
|
100 | 100 | // domain not found in A records |
101 | 101 | throw new EE_Validation_Error( |
102 | 102 | __( |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.6 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base{ |
|
14 | +class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base { |
|
15 | 15 | /** |
16 | 16 | * The html "type" attribute value. default is "text" |
17 | 17 | * @var string |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @param string $type |
25 | 25 | */ |
26 | - function __construct( $type = 'text' ) { |
|
26 | + function __construct($type = 'text') { |
|
27 | 27 | $this->_type = $type; |
28 | 28 | parent::__construct(); |
29 | 29 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * Gets the html "type" attribute's value |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - function get_type(){ |
|
37 | + function get_type() { |
|
38 | 38 | if ( |
39 | 39 | $this->_type == 'email' |
40 | - && ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false ) |
|
40 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
41 | 41 | ) { |
42 | 42 | return 'text'; |
43 | 43 | } |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string of html to display the field |
52 | 52 | */ |
53 | - function display(){ |
|
54 | - $input = '<input type="'. $this->get_type() .'"'; |
|
55 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
56 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
57 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
58 | - $input .= ' class="' . $class . '"'; |
|
53 | + function display() { |
|
54 | + $input = '<input type="'.$this->get_type().'"'; |
|
55 | + $input .= ' name="'.$this->_input->html_name().'"'; |
|
56 | + $input .= ' id="'.$this->_input->html_id().'"'; |
|
57 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
58 | + $input .= ' class="'.$class.'"'; |
|
59 | 59 | // add html5 required |
60 | 60 | $input .= $this->_input->required() ? ' required' : ''; |
61 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
62 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
61 | + $input .= ' value="'.$this->_input->raw_value_in_form().'"'; |
|
62 | + $input .= ' style="'.$this->_input->html_style().'"'; |
|
63 | 63 | $input .= $this->_input->html_other_attributes(); |
64 | 64 | $input .= '/>'; |
65 | 65 | return $input; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,37 +1415,37 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = reset( $times ); |
|
1430 | + $first_datetime = reset($times); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime instanceof EE_Datetime |
|
1433 | - && $first_datetime->ID() !== 0 ) { |
|
1432 | + if ($first_datetime instanceof EE_Datetime |
|
1433 | + && $first_datetime->ID() !== 0) { |
|
1434 | 1434 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1435 | 1435 | $template_args['time'] = $first_datetime; |
1436 | 1436 | $related_tickets = $first_datetime->tickets( |
1437 | 1437 | array( |
1438 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1438 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1439 | 1439 | 'default_where_conditions' => 'none' |
1440 | 1440 | ) |
1441 | 1441 | ); |
1442 | 1442 | |
1443 | - if ( !empty($related_tickets) ) { |
|
1443 | + if ( ! empty($related_tickets)) { |
|
1444 | 1444 | $template_args['total_ticket_rows'] = count($related_tickets); |
1445 | 1445 | $row = 0; |
1446 | - foreach ( $related_tickets as $ticket ) { |
|
1446 | + foreach ($related_tickets as $ticket) { |
|
1447 | 1447 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1448 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1448 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1449 | 1449 | |
1450 | 1450 | $row++; |
1451 | 1451 | } |
@@ -1453,13 +1453,13 @@ discard block |
||
1453 | 1453 | $template_args['total_ticket_rows'] = 1; |
1454 | 1454 | /** @type EE_Ticket $ticket */ |
1455 | 1455 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1456 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1456 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1457 | 1457 | } |
1458 | 1458 | } else { |
1459 | 1459 | $template_args['time'] = $times[0]; |
1460 | 1460 | /** @type EE_Ticket $ticket */ |
1461 | 1461 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1462 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1462 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1463 | 1463 | // NOTE: we're just sending the first default row |
1464 | 1464 | // (decaf can't manage default tickets so this should be sufficient); |
1465 | 1465 | } |
@@ -1468,8 +1468,8 @@ discard block |
||
1468 | 1468 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1469 | 1469 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1470 | 1470 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1471 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1472 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1471 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1472 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1473 | 1473 | EEH_Template::display_template($template, $template_args); |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1484,21 +1484,21 @@ discard block |
||
1484 | 1484 | * @param int $row |
1485 | 1485 | * @return string generated html for the ticket row. |
1486 | 1486 | */ |
1487 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1487 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1488 | 1488 | $template_args = array( |
1489 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1490 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1489 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1490 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1491 | 1491 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1492 | 1492 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1493 | 1493 | 'TKT_name' => $ticket->get('TKT_name'), |
1494 | 1494 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1495 | 1495 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1496 | 1496 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1497 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1497 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1498 | 1498 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1499 | 1499 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1500 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1500 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1502 | 1502 | ); |
1503 | 1503 | |
1504 | 1504 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1514,23 +1514,23 @@ discard block |
||
1514 | 1514 | |
1515 | 1515 | //make sure we have default start and end dates if skeleton |
1516 | 1516 | //handle rows that should NOT be empty |
1517 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1517 | + if (empty($template_args['TKT_start_date'])) { |
|
1518 | 1518 | //if empty then the start date will be now. |
1519 | 1519 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1520 | 1520 | } |
1521 | 1521 | |
1522 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1522 | + if (empty($template_args['TKT_end_date'])) { |
|
1523 | 1523 | //get the earliest datetime (if present); |
1524 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1524 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1525 | 1525 | |
1526 | - if ( !empty( $earliest_dtt ) ) |
|
1526 | + if ( ! empty($earliest_dtt)) |
|
1527 | 1527 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1528 | 1528 | else |
1529 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1529 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $template_args = array_merge( $template_args, $price_args ); |
|
1533 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1532 | + $template_args = array_merge($template_args, $price_args); |
|
1533 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1534 | 1534 | return EEH_Template::display_template($template, $template_args, TRUE); |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1559,8 +1559,8 @@ discard block |
||
1559 | 1559 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1560 | 1560 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1561 | 1561 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1562 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1563 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1562 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1563 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1564 | 1564 | EEH_Template::display_template($templatepath, $template_args); |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1588,21 +1588,21 @@ discard block |
||
1588 | 1588 | $EEME = $this->_event_model(); |
1589 | 1589 | |
1590 | 1590 | $offset = ($current_page - 1) * $per_page; |
1591 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1591 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1592 | 1592 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1593 | 1593 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1594 | 1594 | |
1595 | 1595 | if (isset($this->_req_data['month_range'])) { |
1596 | 1596 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1597 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1597 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | $where = array(); |
1602 | 1602 | |
1603 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1603 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1604 | 1604 | //determine what post_status our condition will have for the query. |
1605 | - switch ( $status ) { |
|
1605 | + switch ($status) { |
|
1606 | 1606 | case 'month' : |
1607 | 1607 | case 'today' : |
1608 | 1608 | case NULL : |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | break; |
1611 | 1611 | |
1612 | 1612 | case 'draft' : |
1613 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1613 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1614 | 1614 | break; |
1615 | 1615 | |
1616 | 1616 | default : |
@@ -1618,43 +1618,43 @@ discard block |
||
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | //categories? |
1621 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1621 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1622 | 1622 | |
1623 | - if ( !empty ( $category ) ) { |
|
1623 | + if ( ! empty ($category)) { |
|
1624 | 1624 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1625 | 1625 | $where['Term_Taxonomy.term_id'] = $category; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | //date where conditions |
1629 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1629 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1630 | 1630 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1631 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1632 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1633 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1634 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1631 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1632 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1633 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1634 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1635 | 1635 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1636 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1637 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1638 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1639 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1640 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1641 | - $now = date( 'Y-m-01' ); |
|
1642 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1643 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1644 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1645 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1636 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1637 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1638 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1639 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1640 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1641 | + $now = date('Y-m-01'); |
|
1642 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1643 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1644 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1645 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | |
1649 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1650 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1649 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1650 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1651 | 1651 | } else { |
1652 | - if ( ! isset( $where['status'] ) ) { |
|
1653 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1652 | + if ( ! isset($where['status'])) { |
|
1653 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1654 | 1654 | $where['OR'] = array( |
1655 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1655 | + 'status*restrict_private' => array('!=', 'private'), |
|
1656 | 1656 | 'AND' => array( |
1657 | - 'status*inclusive' => array( '=', 'private' ), |
|
1657 | + 'status*inclusive' => array('=', 'private'), |
|
1658 | 1658 | 'EVT_wp_user' => get_current_user_id() |
1659 | 1659 | ) |
1660 | 1660 | ); |
@@ -1662,16 +1662,16 @@ discard block |
||
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | |
1665 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1666 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1665 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1666 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1667 | 1667 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1668 | 1668 | } |
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | |
1672 | 1672 | //search query handling |
1673 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1674 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1673 | + if (isset($this->_req_data['s'])) { |
|
1674 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1675 | 1675 | $where['OR'] = array( |
1676 | 1676 | 'EVT_name' => array('LIKE', $search_string), |
1677 | 1677 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1680,32 +1680,32 @@ discard block |
||
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
1683 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1684 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1683 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1684 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1685 | 1685 | |
1686 | 1686 | |
1687 | 1687 | //let's first check if we have special requests coming in. |
1688 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1689 | - switch ( $this->_req_data['active_status'] ) { |
|
1688 | + if (isset($this->_req_data['active_status'])) { |
|
1689 | + switch ($this->_req_data['active_status']) { |
|
1690 | 1690 | case 'upcoming' : |
1691 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1691 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1692 | 1692 | break; |
1693 | 1693 | |
1694 | 1694 | case 'expired' : |
1695 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1695 | + return $EEME->get_expired_events($query_params, $count); |
|
1696 | 1696 | break; |
1697 | 1697 | |
1698 | 1698 | case 'active' : |
1699 | - return $EEME->get_active_events( $query_params, $count ); |
|
1699 | + return $EEME->get_active_events($query_params, $count); |
|
1700 | 1700 | break; |
1701 | 1701 | |
1702 | 1702 | case 'inactive' : |
1703 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1703 | + return $EEME->get_inactive_events($query_params, $count); |
|
1704 | 1704 | break; |
1705 | 1705 | } |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1708 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1709 | 1709 | |
1710 | 1710 | return $events; |
1711 | 1711 | } |
@@ -1714,23 +1714,23 @@ discard block |
||
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | //handling for WordPress CPT actions (trash, restore, delete) |
1717 | - public function trash_cpt_item( $post_id ) { |
|
1717 | + public function trash_cpt_item($post_id) { |
|
1718 | 1718 | $this->_req_data['EVT_ID'] = $post_id; |
1719 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1719 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | |
1723 | 1723 | |
1724 | 1724 | |
1725 | - public function restore_cpt_item( $post_id ) { |
|
1725 | + public function restore_cpt_item($post_id) { |
|
1726 | 1726 | $this->_req_data['EVT_ID'] = $post_id; |
1727 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1727 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | |
1731 | - public function delete_cpt_item( $post_id ) { |
|
1731 | + public function delete_cpt_item($post_id) { |
|
1732 | 1732 | $this->_req_data['EVT_ID'] = $post_id; |
1733 | - $this->_delete_event( FALSE ); |
|
1733 | + $this->_delete_event(FALSE); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | * @param string $event_status |
1743 | 1743 | * @return void |
1744 | 1744 | */ |
1745 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1745 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1746 | 1746 | //determine the event id and set to array. |
1747 | 1747 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1748 | 1748 | // loop thru events |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | // clean status |
1751 | 1751 | $event_status = sanitize_key($event_status); |
1752 | 1752 | // grab status |
1753 | - if (!empty($event_status)) { |
|
1753 | + if ( ! empty($event_status)) { |
|
1754 | 1754 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1755 | 1755 | } else { |
1756 | 1756 | $success = FALSE; |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | } |
1765 | 1765 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1766 | 1766 | |
1767 | - if ( $redirect_after ) |
|
1767 | + if ($redirect_after) |
|
1768 | 1768 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1769 | 1769 | } |
1770 | 1770 | |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | // clean status |
1780 | 1780 | $event_status = sanitize_key($event_status); |
1781 | 1781 | // grab status |
1782 | - if (!empty($event_status)) { |
|
1782 | + if ( ! empty($event_status)) { |
|
1783 | 1783 | $success = TRUE; |
1784 | 1784 | //determine the event id and set to array. |
1785 | 1785 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1814,15 +1814,15 @@ discard block |
||
1814 | 1814 | * @param string $event_status |
1815 | 1815 | * @return bool |
1816 | 1816 | */ |
1817 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1817 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1818 | 1818 | // grab event id |
1819 | - if (!$EVT_ID) { |
|
1819 | + if ( ! $EVT_ID) { |
|
1820 | 1820 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1821 | 1821 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1822 | 1822 | return FALSE; |
1823 | 1823 | } |
1824 | 1824 | |
1825 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1825 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1826 | 1826 | |
1827 | 1827 | // clean status |
1828 | 1828 | $event_status = sanitize_key($event_status); |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | $hook = FALSE; |
1849 | 1849 | } |
1850 | 1850 | //use class to change status |
1851 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1851 | + $this->_cpt_model_obj->set_status($event_status); |
|
1852 | 1852 | $success = $this->_cpt_model_obj->save(); |
1853 | 1853 | |
1854 | 1854 | if ($success === FALSE) { |
@@ -1870,15 +1870,15 @@ discard block |
||
1870 | 1870 | * @access protected |
1871 | 1871 | * @param bool $redirect_after |
1872 | 1872 | */ |
1873 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1873 | + protected function _delete_event($redirect_after = TRUE) { |
|
1874 | 1874 | //determine the event id and set to array. |
1875 | 1875 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1876 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1876 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1877 | 1877 | |
1878 | 1878 | |
1879 | 1879 | // loop thru events |
1880 | 1880 | if ($EVT_ID) { |
1881 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1881 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1882 | 1882 | // get list of events with no prices |
1883 | 1883 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1884 | 1884 | // remove this event from the list of events with no prices |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - if ( $redirect_after ) |
|
1895 | + if ($redirect_after) |
|
1896 | 1896 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1910,12 +1910,12 @@ discard block |
||
1910 | 1910 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1911 | 1911 | // loop thru events |
1912 | 1912 | foreach ($EVT_IDs as $EVT_ID) { |
1913 | - $EVT_ID = absint( $EVT_ID ); |
|
1914 | - if ( $EVT_ID ) { |
|
1915 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1913 | + $EVT_ID = absint($EVT_ID); |
|
1914 | + if ($EVT_ID) { |
|
1915 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1916 | 1916 | $success = $results !== FALSE ? $success : FALSE; |
1917 | 1917 | // remove this event from the list of events with no prices |
1918 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1918 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1919 | 1919 | } else { |
1920 | 1920 | $success = FALSE; |
1921 | 1921 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1935,21 +1935,21 @@ discard block |
||
1935 | 1935 | * @param int $EVT_ID |
1936 | 1936 | * @return bool |
1937 | 1937 | */ |
1938 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1938 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1939 | 1939 | // grab event id |
1940 | - if ( ! $EVT_ID ) { |
|
1940 | + if ( ! $EVT_ID) { |
|
1941 | 1941 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1942 | 1942 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1943 | 1943 | return FALSE; |
1944 | 1944 | } |
1945 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1945 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1946 | 1946 | |
1947 | 1947 | //need to delete related tickets and prices first. |
1948 | 1948 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1949 | - foreach ( $datetimes as $datetime ) { |
|
1949 | + foreach ($datetimes as $datetime) { |
|
1950 | 1950 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1951 | 1951 | $tickets = $datetime->get_many_related('Ticket'); |
1952 | - foreach ( $tickets as $ticket ) { |
|
1952 | + foreach ($tickets as $ticket) { |
|
1953 | 1953 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1954 | 1954 | $ticket->delete_related_permanently('Price'); |
1955 | 1955 | $ticket->delete_permanently(); |
@@ -1959,14 +1959,14 @@ discard block |
||
1959 | 1959 | |
1960 | 1960 | //what about related venues or terms? |
1961 | 1961 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1962 | - foreach ( $venues as $venue ) { |
|
1962 | + foreach ($venues as $venue) { |
|
1963 | 1963 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1964 | 1964 | } |
1965 | 1965 | |
1966 | 1966 | //any attached question groups? |
1967 | 1967 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1968 | - if ( !empty( $question_groups ) ) { |
|
1969 | - foreach ( $question_groups as $question_group ) { |
|
1968 | + if ( ! empty($question_groups)) { |
|
1969 | + foreach ($question_groups as $question_group) { |
|
1970 | 1970 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1971 | 1971 | } |
1972 | 1972 | } |
@@ -1975,12 +1975,12 @@ discard block |
||
1975 | 1975 | |
1976 | 1976 | |
1977 | 1977 | //Message Template Groups |
1978 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1978 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1979 | 1979 | |
1980 | 1980 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1981 | 1981 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1982 | 1982 | |
1983 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1983 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1984 | 1984 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1985 | 1985 | } |
1986 | 1986 | |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1995 | 1995 | return FALSE; |
1996 | 1996 | } |
1997 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
1997 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
1998 | 1998 | return TRUE; |
1999 | 1999 | } |
2000 | 2000 | |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | */ |
2012 | 2012 | public function total_events() { |
2013 | 2013 | |
2014 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2014 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2015 | 2015 | return $count; |
2016 | 2016 | } |
2017 | 2017 | |
@@ -2026,10 +2026,10 @@ discard block |
||
2026 | 2026 | */ |
2027 | 2027 | public function total_events_draft() { |
2028 | 2028 | $where = array( |
2029 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2029 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2030 | 2030 | ); |
2031 | 2031 | |
2032 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2032 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2033 | 2033 | return $count; |
2034 | 2034 | } |
2035 | 2035 | |
@@ -2048,7 +2048,7 @@ discard block |
||
2048 | 2048 | 'status' => 'trash' |
2049 | 2049 | ); |
2050 | 2050 | |
2051 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2051 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2052 | 2052 | return $count; |
2053 | 2053 | } |
2054 | 2054 | |
@@ -2076,11 +2076,11 @@ discard block |
||
2076 | 2076 | // translated |
2077 | 2077 | TRUE |
2078 | 2078 | ); |
2079 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2079 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2080 | 2080 | |
2081 | 2081 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2082 | 2082 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2083 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2083 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2084 | 2084 | $this->display_admin_page_with_sidebar(); |
2085 | 2085 | } |
2086 | 2086 | |
@@ -2106,9 +2106,9 @@ discard block |
||
2106 | 2106 | |
2107 | 2107 | protected function _template_settings() { |
2108 | 2108 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2109 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2110 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2111 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2109 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2110 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2111 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2112 | 2112 | } |
2113 | 2113 | |
2114 | 2114 | |
@@ -2121,22 +2121,22 @@ discard block |
||
2121 | 2121 | * @return void |
2122 | 2122 | */ |
2123 | 2123 | private function _set_category_object() { |
2124 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2124 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2125 | 2125 | return; //already have the category object so get out. |
2126 | 2126 | |
2127 | 2127 | //set default category object |
2128 | 2128 | $this->_set_empty_category_object(); |
2129 | 2129 | |
2130 | 2130 | //only set if we've got an id |
2131 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2131 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2132 | 2132 | return; |
2133 | 2133 | } |
2134 | 2134 | |
2135 | 2135 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2136 | 2136 | |
2137 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2137 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2138 | 2138 | |
2139 | - if ( !empty( $term ) ) { |
|
2139 | + if ( ! empty($term)) { |
|
2140 | 2140 | $this->_category->category_name = $term->name; |
2141 | 2141 | $this->_category->category_identifier = $term->slug; |
2142 | 2142 | $this->_category->category_desc = $term->description; |
@@ -2150,13 +2150,13 @@ discard block |
||
2150 | 2150 | |
2151 | 2151 | private function _set_empty_category_object() { |
2152 | 2152 | $this->_category = new stdClass(); |
2153 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2153 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2154 | 2154 | $this->_category->id = $this->_category->parent = 0; |
2155 | 2155 | } |
2156 | 2156 | |
2157 | 2157 | |
2158 | 2158 | protected function _category_list_table() { |
2159 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2159 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2160 | 2160 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2161 | 2161 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2162 | 2162 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2166,22 +2166,22 @@ discard block |
||
2166 | 2166 | protected function _category_details($view) { |
2167 | 2167 | |
2168 | 2168 | //load formatter helper |
2169 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2169 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2170 | 2170 | //load field generator helper |
2171 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2171 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2172 | 2172 | |
2173 | 2173 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2174 | 2174 | $this->_set_add_edit_form_tags($route); |
2175 | 2175 | |
2176 | 2176 | $this->_set_category_object(); |
2177 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2177 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2178 | 2178 | |
2179 | 2179 | $delete_action = 'delete_category'; |
2180 | 2180 | |
2181 | 2181 | //custom redirect |
2182 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2182 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2183 | 2183 | |
2184 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2184 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2185 | 2185 | |
2186 | 2186 | //take care of contents |
2187 | 2187 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2195,25 +2195,25 @@ discard block |
||
2195 | 2195 | 'type' => 'wp_editor', |
2196 | 2196 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2197 | 2197 | 'class' => 'my_editor_custom', |
2198 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2198 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2199 | 2199 | ); |
2200 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2200 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2201 | 2201 | |
2202 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2202 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2203 | 2203 | |
2204 | 2204 | //setup category select for term parents. |
2205 | 2205 | $category_select_values[] = array( |
2206 | 2206 | 'text' => __('No Parent', 'event_espresso'), |
2207 | 2207 | 'id' => 0 |
2208 | 2208 | ); |
2209 | - foreach ( $all_terms as $term ) { |
|
2209 | + foreach ($all_terms as $term) { |
|
2210 | 2210 | $category_select_values[] = array( |
2211 | 2211 | 'text' => $term->name, |
2212 | 2212 | 'id' => $term->term_id |
2213 | 2213 | ); |
2214 | 2214 | } |
2215 | 2215 | |
2216 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2216 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2217 | 2217 | |
2218 | 2218 | $template_args = array( |
2219 | 2219 | 'category' => $this->_category, |
@@ -2223,15 +2223,15 @@ discard block |
||
2223 | 2223 | 'disable' => '', |
2224 | 2224 | 'disabled_message' => FALSE |
2225 | 2225 | ); |
2226 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2227 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2226 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2227 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | |
2231 | 2231 | protected function _delete_categories() { |
2232 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2232 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2233 | 2233 | |
2234 | - foreach ( $cat_ids as $cat_id ) { |
|
2234 | + foreach ($cat_ids as $cat_id) { |
|
2235 | 2235 | $this->_delete_category($cat_id); |
2236 | 2236 | } |
2237 | 2237 | |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $query_args = array( |
2240 | 2240 | 'action' => 'category_list' |
2241 | 2241 | ); |
2242 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2242 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2243 | 2243 | |
2244 | 2244 | } |
2245 | 2245 | |
@@ -2249,61 +2249,61 @@ discard block |
||
2249 | 2249 | |
2250 | 2250 | protected function _delete_category($cat_id) { |
2251 | 2251 | global $wpdb; |
2252 | - $cat_id = absint( $cat_id ); |
|
2253 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2252 | + $cat_id = absint($cat_id); |
|
2253 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | |
2257 | 2257 | |
2258 | 2258 | protected function _insert_or_update_category($new_category) { |
2259 | 2259 | |
2260 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2260 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2261 | 2261 | $success = 0; //we already have a success message so lets not send another. |
2262 | 2262 | |
2263 | - if ( $cat_id ) { |
|
2263 | + if ($cat_id) { |
|
2264 | 2264 | $query_args = array( |
2265 | 2265 | 'action' => 'edit_category', |
2266 | 2266 | 'EVT_CAT_ID' => $cat_id |
2267 | 2267 | ); |
2268 | 2268 | } else { |
2269 | - $query_args = array( 'action' => 'add_category' ); |
|
2269 | + $query_args = array('action' => 'add_category'); |
|
2270 | 2270 | } |
2271 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2271 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2272 | 2272 | |
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | |
2276 | 2276 | |
2277 | - private function _insert_category( $update = FALSE ) { |
|
2277 | + private function _insert_category($update = FALSE) { |
|
2278 | 2278 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2279 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2280 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2281 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2279 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2280 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2281 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2282 | 2282 | |
2283 | - if ( empty( $category_name ) ) { |
|
2284 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2285 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2283 | + if (empty($category_name)) { |
|
2284 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2285 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2286 | 2286 | return false; |
2287 | 2287 | } |
2288 | 2288 | |
2289 | - $term_args=array( |
|
2289 | + $term_args = array( |
|
2290 | 2290 | 'name'=>$category_name, |
2291 | 2291 | 'description'=>$category_desc, |
2292 | 2292 | 'parent'=>$category_parent |
2293 | 2293 | ); |
2294 | 2294 | //was the category_identifier input disabled? |
2295 | - if(isset($this->_req_data['category_identifier'])){ |
|
2295 | + if (isset($this->_req_data['category_identifier'])) { |
|
2296 | 2296 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2297 | 2297 | } |
2298 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2298 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2299 | 2299 | |
2300 | - if ( !is_array( $insert_ids ) ) { |
|
2301 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2302 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2300 | + if ( ! is_array($insert_ids)) { |
|
2301 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2302 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2303 | 2303 | } else { |
2304 | 2304 | $cat_id = $insert_ids['term_id']; |
2305 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2306 | - EE_Error::add_success( $msg ); |
|
2305 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2306 | + EE_Error::add_success($msg); |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | return $cat_id; |
@@ -2312,32 +2312,32 @@ discard block |
||
2312 | 2312 | |
2313 | 2313 | |
2314 | 2314 | |
2315 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2315 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2316 | 2316 | global $wpdb; |
2317 | 2317 | |
2318 | 2318 | //testing term stuff |
2319 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2320 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2321 | - $limit = ($current_page-1)*$per_page; |
|
2319 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2320 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2321 | + $limit = ($current_page - 1) * $per_page; |
|
2322 | 2322 | |
2323 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2323 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2324 | 2324 | |
2325 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2326 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2325 | + if (isset($this->_req_data['s'])) { |
|
2326 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2327 | 2327 | $where['OR'] = array( |
2328 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2329 | - 'description' => array( 'LIKE', $sstr ) |
|
2328 | + 'Term.name' => array('LIKE', $sstr), |
|
2329 | + 'description' => array('LIKE', $sstr) |
|
2330 | 2330 | ); |
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | $query_params = array( |
2334 | - $where , |
|
2335 | - 'order_by' => array( $orderby => $order ), |
|
2336 | - 'limit' => $limit . ',' . $per_page, |
|
2334 | + $where, |
|
2335 | + 'order_by' => array($orderby => $order), |
|
2336 | + 'limit' => $limit.','.$per_page, |
|
2337 | 2337 | 'force_join' => array('Term') |
2338 | 2338 | ); |
2339 | 2339 | |
2340 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2340 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2341 | 2341 | |
2342 | 2342 | return $categories; |
2343 | 2343 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | ){ |
240 | 240 | if( $relation instanceof \EE_Belongs_To_Relation ) { |
241 | 241 | $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
244 | 244 | } |
245 | 245 | return new \WP_Error( |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | if( $relation instanceof \EE_Belongs_To_Relation ){ |
293 | 293 | return array_shift( $nice_results ); |
294 | - }else{ |
|
294 | + } else{ |
|
295 | 295 | return $nice_results; |
296 | 296 | } |
297 | 297 | } |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
406 | 406 | if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
407 | 407 | unset( $result[ $field_name ] ); |
408 | - }elseif( |
|
408 | + } elseif( |
|
409 | 409 | $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
410 | 410 | ){ |
411 | 411 | $result[ $field_name ] = array( |
412 | 412 | 'raw' => $field_obj->prepare_for_get( $field_value ), |
413 | 413 | 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
414 | 414 | ); |
415 | - }elseif( |
|
415 | + } elseif( |
|
416 | 416 | $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
417 | 417 | ){ |
418 | 418 | $result[ $field_name ] = array( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public static function get_related_entity_name( $relation_name, $relation_obj ){ |
596 | 596 | if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
597 | 597 | return strtolower( $relation_name ); |
598 | - }else{ |
|
598 | + } else{ |
|
599 | 599 | return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
600 | 600 | } |
601 | 601 | } |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
666 | 666 | if( in_array( $context, $valid_contexts ) ){ |
667 | 667 | return $context; |
668 | - }else{ |
|
668 | + } else{ |
|
669 | 669 | return \EEM_Base::caps_read; |
670 | 670 | } |
671 | 671 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | $order_by = $query_parameters[ 'order_by' ]; |
691 | 691 | } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
692 | 692 | $order_by = $query_parameters[ 'orderby' ]; |
693 | - }else{ |
|
693 | + } else{ |
|
694 | 694 | $order_by = null; |
695 | 695 | } |
696 | 696 | if( $order_by !== null ){ |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $group_by = $query_parameters[ 'group_by' ]; |
701 | 701 | } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
702 | 702 | $group_by = $query_parameters[ 'groupby' ]; |
703 | - }else{ |
|
703 | + } else{ |
|
704 | 704 | $group_by = null; |
705 | 705 | } |
706 | 706 | if( $group_by !== null ){ |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
724 | 724 | if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
725 | 725 | $limit_array = explode(',', (string)$query_parameters['limit']); |
726 | - }else { |
|
726 | + } else { |
|
727 | 727 | $limit_array = $query_parameters[ 'limit' ]; |
728 | 728 | } |
729 | 729 | $sanitized_limit = array(); |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | $sanitized_limit[] = intval( $limit_part ); |
740 | 740 | } |
741 | 741 | $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
742 | - }else{ |
|
742 | + } else{ |
|
743 | 743 | $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
744 | 744 | } |
745 | 745 | if( isset( $query_parameters[ 'caps' ] ) ) { |
746 | 746 | $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
747 | - }else{ |
|
747 | + } else{ |
|
748 | 748 | $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
749 | 749 | } |
750 | 750 | return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | foreach( $query_params as $key => $value ) { |
765 | 765 | if( is_array( $value ) ) { |
766 | 766 | $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
767 | - }else{ |
|
767 | + } else{ |
|
768 | 768 | $model_ready_query_params[ $key ] = $value; |
769 | 769 | } |
770 | 770 | } |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | //found the model name at the exact start |
817 | 817 | $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
818 | 818 | $extracted_fields_to_include[] = $field_sans_model_name; |
819 | - }elseif( $field_to_include == $model_name ){ |
|
819 | + } elseif( $field_to_include == $model_name ){ |
|
820 | 820 | $extracted_fields_to_include[] = '*'; |
821 | 821 | } |
822 | 822 | } |
823 | - }else{ |
|
823 | + } else{ |
|
824 | 824 | //look for ones with no period |
825 | 825 | foreach( $includes as $field_to_include ) { |
826 | 826 | $field_to_include = trim( $field_to_include ); |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() { |
35 | 35 | parent::__construct(); |
36 | - \EE_Registry::instance()->load_helper( 'Inflector' ); |
|
36 | + \EE_Registry::instance()->load_helper('Inflector'); |
|
37 | 37 | $this->_fields_calculator = new Calculated_Model_Fields(); |
38 | 38 | } |
39 | 39 | |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | * @param \WP_REST_Request $request |
43 | 43 | * @return \WP_REST_Response|\WP_Error |
44 | 44 | */ |
45 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
45 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
46 | 46 | $controller = new Read(); |
47 | - try{ |
|
47 | + try { |
|
48 | 48 | $matches = $controller->parse_route( |
49 | 49 | $request->get_route(), |
50 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
51 | - array( 'version', 'model' ) |
|
50 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
51 | + array('version', 'model') |
|
52 | 52 | ); |
53 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
54 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
55 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
53 | + $controller->set_requested_version($matches['version']); |
|
54 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
55 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
56 | 56 | return $controller->send_response( |
57 | 57 | new \WP_Error( |
58 | 58 | 'endpoint_parsing_error', |
59 | 59 | sprintf( |
60 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
60 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
61 | 61 | $model_name_singular |
62 | 62 | ) |
63 | 63 | ) |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | } |
66 | 66 | return $controller->send_response( |
67 | 67 | $controller->get_entities_from_model( |
68 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
68 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
69 | 69 | $request |
70 | 70 | ) |
71 | 71 | ); |
72 | - } catch( \Exception $e ) { |
|
73 | - return $controller->send_response( $e ); |
|
72 | + } catch (\Exception $e) { |
|
73 | + return $controller->send_response($e); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -80,21 +80,21 @@ discard block |
||
80 | 80 | * @param \WP_Rest_Request $request |
81 | 81 | * @return \WP_REST_Response|\WP_Error |
82 | 82 | */ |
83 | - public static function handle_request_get_one( \WP_Rest_Request $request ) { |
|
83 | + public static function handle_request_get_one(\WP_Rest_Request $request) { |
|
84 | 84 | $controller = new Read(); |
85 | - try{ |
|
85 | + try { |
|
86 | 86 | $matches = $controller->parse_route( |
87 | 87 | $request->get_route(), |
88 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
89 | - array( 'version', 'model', 'id' ) ); |
|
90 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
91 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
92 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
88 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
89 | + array('version', 'model', 'id') ); |
|
90 | + $controller->set_requested_version($matches['version']); |
|
91 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
92 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
93 | 93 | return $controller->send_response( |
94 | 94 | new \WP_Error( |
95 | 95 | 'endpoint_parsing_error', |
96 | 96 | sprintf( |
97 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
97 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
98 | 98 | $model_name_singular |
99 | 99 | ) |
100 | 100 | ) |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | } |
103 | 103 | return $controller->send_response( |
104 | 104 | $controller->get_entity_from_model( |
105 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
105 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
106 | 106 | $request |
107 | 107 | ) |
108 | 108 | ); |
109 | - } catch( \Exception $e ) { |
|
110 | - return $controller->send_response( $e ); |
|
109 | + } catch (\Exception $e) { |
|
110 | + return $controller->send_response($e); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -119,40 +119,40 @@ discard block |
||
119 | 119 | * @param \WP_REST_Request $request |
120 | 120 | * @return \WP_REST_Response|\WP_Error |
121 | 121 | */ |
122 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
122 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
123 | 123 | $controller = new Read(); |
124 | - try{ |
|
124 | + try { |
|
125 | 125 | $matches = $controller->parse_route( |
126 | 126 | $request->get_route(), |
127 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
128 | - array( 'version', 'model', 'id', 'related_model' ) |
|
127 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
128 | + array('version', 'model', 'id', 'related_model') |
|
129 | 129 | ); |
130 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
131 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
132 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
130 | + $controller->set_requested_version($matches['version']); |
|
131 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
132 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
133 | 133 | return $controller->send_response( |
134 | 134 | new \WP_Error( |
135 | 135 | 'endpoint_parsing_error', |
136 | 136 | sprintf( |
137 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
137 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
138 | 138 | $main_model_name_singular |
139 | 139 | ) |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | } |
143 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
143 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
144 | 144 | //assume the related model name is plural and try to find the model's name |
145 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
146 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
145 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
146 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
147 | 147 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
148 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
148 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
149 | 149 | } |
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | return $controller->send_response( |
152 | 152 | new \WP_Error( |
153 | 153 | 'endpoint_parsing_error', |
154 | 154 | sprintf( |
155 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
155 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
156 | 156 | $related_model_name_singular |
157 | 157 | ) |
158 | 158 | ) |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | |
162 | 162 | return $controller->send_response( |
163 | 163 | $controller->get_entities_from_relation( |
164 | - $request->get_param( 'id' ), |
|
165 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
164 | + $request->get_param('id'), |
|
165 | + $main_model->related_settings_for($related_model_name_singular), |
|
166 | 166 | $request |
167 | 167 | ) |
168 | 168 | ); |
169 | - } catch( \Exception $e ) { |
|
170 | - return $controller->send_response( $e ); |
|
169 | + } catch (\Exception $e) { |
|
170 | + return $controller->send_response($e); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | * @param \WP_REST_Request $request |
181 | 181 | * @return array |
182 | 182 | */ |
183 | - public function get_entities_from_model( $model, $request) { |
|
184 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
185 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
186 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
183 | + public function get_entities_from_model($model, $request) { |
|
184 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
185 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
186 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
187 | 187 | return new \WP_Error( |
188 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
188 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
189 | 189 | sprintf( |
190 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
190 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
191 | 191 | $model_name_plural, |
192 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
192 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
193 | 193 | ), |
194 | - array( 'status' => 403 ) |
|
194 | + array('status' => 403) |
|
195 | 195 | ); |
196 | 196 | } |
197 | 197 | |
198 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
198 | + $this->_set_headers_from_query_params($model, $query_params); |
|
199 | 199 | /** @type array $results */ |
200 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
200 | + $results = $model->get_all_wpdb_results($query_params); |
|
201 | 201 | $nice_results = array( ); |
202 | - foreach ( $results as $result ) { |
|
203 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
202 | + foreach ($results as $result) { |
|
203 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
204 | 204 | $model, |
205 | 205 | $result, |
206 | 206 | $request |
@@ -221,62 +221,62 @@ discard block |
||
221 | 221 | * @param \WP_REST_Request $request |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
225 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
224 | + public function get_entities_from_relation($id, $relation, $request) { |
|
225 | + $context = $this->validate_context($request->get_param('caps')); |
|
226 | 226 | $model = $relation->get_this_model(); |
227 | 227 | $related_model = $relation->get_other_model(); |
228 | 228 | //check if they can access the 1st model object |
229 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
230 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
229 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
230 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
231 | 231 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
232 | 232 | } |
233 | 233 | $restricted_query_params = $query_params; |
234 | - $restricted_query_params[ 'caps' ] = $context; |
|
235 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
236 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
234 | + $restricted_query_params['caps'] = $context; |
|
235 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
236 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
237 | 237 | |
238 | - if( |
|
238 | + if ( |
|
239 | 239 | ! ( |
240 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
241 | - && $model->exists( $restricted_query_params ) |
|
240 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
241 | + && $model->exists($restricted_query_params) |
|
242 | 242 | ) |
243 | - ){ |
|
244 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
245 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
246 | - }else{ |
|
247 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
243 | + ) { |
|
244 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
245 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
246 | + } else { |
|
247 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
248 | 248 | } |
249 | 249 | return new \WP_Error( |
250 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
250 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
251 | 251 | sprintf( |
252 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
252 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
253 | 253 | $related_model_name_maybe_plural, |
254 | 254 | $relation->get_this_model()->get_this_model_name(), |
255 | 255 | implode( |
256 | 256 | ',', |
257 | 257 | array_keys( |
258 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
258 | + Capabilities::get_missing_permissions($related_model, $context) |
|
259 | 259 | ) |
260 | 260 | ) |
261 | 261 | ), |
262 | - array( 'status' => 403 ) |
|
262 | + array('status' => 403) |
|
263 | 263 | ); |
264 | 264 | } |
265 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
266 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
267 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
268 | - $query_params[ 'caps' ] = $context; |
|
269 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
265 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
266 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
267 | + $query_params['default_where_conditions'] = 'none'; |
|
268 | + $query_params['caps'] = $context; |
|
269 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
270 | 270 | /** @type array $results */ |
271 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
271 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
272 | 272 | $nice_results = array(); |
273 | - foreach( $results as $result ) { |
|
273 | + foreach ($results as $result) { |
|
274 | 274 | $nice_result = $this->create_entity_from_wpdb_result( |
275 | 275 | $relation->get_other_model(), |
276 | 276 | $result, |
277 | 277 | $request |
278 | 278 | ); |
279 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
279 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
280 | 280 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
281 | 281 | //if there are conflicts we prefer the properties from the main model |
282 | 282 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -284,18 +284,18 @@ discard block |
||
284 | 284 | $result, |
285 | 285 | $request |
286 | 286 | ); |
287 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
287 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
288 | 288 | //but keep the meta stuff from the main model |
289 | - if( isset( $nice_result['meta'] ) ){ |
|
289 | + if (isset($nice_result['meta'])) { |
|
290 | 290 | $joined_result['meta'] = $nice_result['meta']; |
291 | 291 | } |
292 | 292 | $nice_result = $joined_result; |
293 | 293 | } |
294 | 294 | $nice_results[] = $nice_result; |
295 | 295 | } |
296 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
297 | - return array_shift( $nice_results ); |
|
298 | - }else{ |
|
296 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
297 | + return array_shift($nice_results); |
|
298 | + } else { |
|
299 | 299 | return $nice_results; |
300 | 300 | } |
301 | 301 | } |
@@ -307,32 +307,32 @@ discard block |
||
307 | 307 | * @param array $query_params |
308 | 308 | * @return void |
309 | 309 | */ |
310 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
311 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
312 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
310 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
311 | + $this->_set_debug_info('model query params', $query_params); |
|
312 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
313 | 313 | //normally the limit to a 2-part array, where the 2nd item is the limit |
314 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
315 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
314 | + if ( ! isset($query_params['limit'])) { |
|
315 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
316 | 316 | } |
317 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
318 | - $limit_parts = $query_params[ 'limit' ]; |
|
317 | + if (is_array($query_params['limit'])) { |
|
318 | + $limit_parts = $query_params['limit']; |
|
319 | 319 | } else { |
320 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
321 | - if( count( $limit_parts ) == 1 ){ |
|
322 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
320 | + $limit_parts = explode(',', $query_params['limit']); |
|
321 | + if (count($limit_parts) == 1) { |
|
322 | + $limit_parts = array(0, $limit_parts[0]); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | //remove the group by and having parts of the query, as those will |
326 | 326 | //make the sql query return an array of values, instead of just a single value |
327 | - unset( $query_params[ 'group_by' ] ); |
|
328 | - unset( $query_params[ 'having' ] ); |
|
329 | - unset( $query_params[ 'limit' ] ); |
|
330 | - $count = $model->count( $query_params, null, true ); |
|
331 | - |
|
332 | - $pages = $count / $limit_parts[ 1 ]; |
|
333 | - $this->_set_response_header( 'Total', $count, false ); |
|
334 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
335 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
327 | + unset($query_params['group_by']); |
|
328 | + unset($query_params['having']); |
|
329 | + unset($query_params['limit']); |
|
330 | + $count = $model->count($query_params, null, true); |
|
331 | + |
|
332 | + $pages = $count / $limit_parts[1]; |
|
333 | + $this->_set_response_header('Total', $count, false); |
|
334 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
335 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -345,47 +345,47 @@ discard block |
||
345 | 345 | * @param string $deprecated no longer used |
346 | 346 | * @return array ready for being converted into json for sending to client |
347 | 347 | */ |
348 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
349 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
348 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
349 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
350 | 350 | //ok so this was called in the old style, where the 3rd arg was |
351 | 351 | //$include, and the 4th arg was $context |
352 | 352 | //now setup the request just to avoid fatal errors, although we won't be able |
353 | 353 | //to truly make use of it because it's kinda devoid of info |
354 | 354 | $rest_request = new \WP_REST_Request(); |
355 | - $rest_request->set_param( 'include', $rest_request ); |
|
356 | - $rest_request->set_param( 'caps', $deprecated ); |
|
355 | + $rest_request->set_param('include', $rest_request); |
|
356 | + $rest_request->set_param('caps', $deprecated); |
|
357 | 357 | } |
358 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
359 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
358 | + if ($rest_request->get_param('caps') == null) { |
|
359 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
360 | 360 | } |
361 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
362 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
363 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
364 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
365 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
361 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
362 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
363 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
364 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
365 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
366 | 366 | $entity_array = apply_filters( |
367 | 367 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
368 | 368 | $entity_array, |
369 | 369 | $model, |
370 | - $rest_request->get_param( 'caps' ), |
|
370 | + $rest_request->get_param('caps'), |
|
371 | 371 | $rest_request, |
372 | 372 | $this |
373 | 373 | ); |
374 | 374 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
375 | 375 | $entity_array, |
376 | 376 | $model, |
377 | - $rest_request->get_param( 'caps' ), |
|
377 | + $rest_request->get_param('caps'), |
|
378 | 378 | $this->get_model_version_info() |
379 | 379 | ); |
380 | 380 | $this->_set_debug_info( |
381 | 381 | 'inaccessible fields', |
382 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
382 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
383 | 383 | ); |
384 | 384 | return apply_filters( |
385 | 385 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
386 | 386 | $result_without_inaccessible_fields, |
387 | 387 | $model, |
388 | - $rest_request->get_param( 'caps' ) |
|
388 | + $rest_request->get_param('caps') |
|
389 | 389 | ); |
390 | 390 | } |
391 | 391 | |
@@ -397,38 +397,38 @@ discard block |
||
397 | 397 | * @param array $db_row |
398 | 398 | * @return array entity mostly ready for converting to JSON and sending in the response |
399 | 399 | */ |
400 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
401 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
402 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
403 | - foreach( $result as $field_name => $raw_field_value ) { |
|
400 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
401 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
402 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
403 | + foreach ($result as $field_name => $raw_field_value) { |
|
404 | 404 | $field_obj = $model->field_settings_for($field_name); |
405 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
406 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
407 | - unset( $result[ $field_name ] ); |
|
408 | - }elseif( |
|
409 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
410 | - ){ |
|
411 | - $result[ $field_name ] = array( |
|
412 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
413 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
405 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
406 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
407 | + unset($result[$field_name]); |
|
408 | + }elseif ( |
|
409 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
410 | + ) { |
|
411 | + $result[$field_name] = array( |
|
412 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
413 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
414 | 414 | ); |
415 | - }elseif( |
|
416 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
417 | - ){ |
|
418 | - $result[ $field_name ] = array( |
|
419 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
420 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
415 | + }elseif ( |
|
416 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
417 | + ) { |
|
418 | + $result[$field_name] = array( |
|
419 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
420 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
421 | 421 | ); |
422 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
423 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
422 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
423 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
424 | 424 | $field_obj, |
425 | 425 | $field_value, |
426 | 426 | $this->get_model_version_info()->requested_version() |
427 | 427 | ); |
428 | 428 | } else { |
429 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
429 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | 430 | $field_obj, |
431 | - $field_obj->prepare_for_get( $field_value ), |
|
431 | + $field_obj->prepare_for_get($field_value), |
|
432 | 432 | $this->get_model_version_info()->requested_version() |
433 | 433 | ); |
434 | 434 | } |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | * @param array $entity_array |
444 | 444 | * @return array modified entity |
445 | 445 | */ |
446 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
447 | - if( $model instanceof \EEM_CPT_Base ) { |
|
448 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
446 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
447 | + if ($model instanceof \EEM_CPT_Base) { |
|
448 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
449 | 449 | } |
450 | 450 | return $entity_array; |
451 | 451 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | * @param array $entity_array |
460 | 460 | * @return array the _links item in the entity |
461 | 461 | */ |
462 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
462 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
463 | 463 | //add basic links |
464 | 464 | $links = array( |
465 | 465 | 'self' => array( |
466 | 466 | array( |
467 | 467 | 'href' => $this->get_versioned_link_to( |
468 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
468 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
469 | 469 | ) |
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'collection' => array( |
473 | 473 | array( |
474 | 474 | 'href' => $this->get_versioned_link_to( |
475 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
475 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
476 | 476 | ) |
477 | 477 | ) |
478 | 478 | ), |
@@ -480,24 +480,24 @@ discard block |
||
480 | 480 | |
481 | 481 | //add link to the wp core endpoint, if wp api is active |
482 | 482 | global $wp_rest_server; |
483 | - if( $model instanceof \EEM_CPT_Base && |
|
483 | + if ($model instanceof \EEM_CPT_Base && |
|
484 | 484 | $wp_rest_server instanceof \WP_REST_Server && |
485 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
486 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
485 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
486 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
487 | 487 | array( |
488 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
488 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
489 | 489 | 'single' => true |
490 | 490 | ) |
491 | 491 | ); |
492 | 492 | } |
493 | 493 | |
494 | 494 | //add links to related models |
495 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
496 | - $related_model_part = $this->get_related_entity_name( $relation_name, $relation_obj ); |
|
497 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
495 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
496 | + $related_model_part = $this->get_related_entity_name($relation_name, $relation_obj); |
|
497 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
498 | 498 | array( |
499 | 499 | 'href' => $this->get_versioned_link_to( |
500 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
500 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
501 | 501 | ), |
502 | 502 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
503 | 503 | ) |
@@ -513,50 +513,50 @@ discard block |
||
513 | 513 | * @param array $entity_array |
514 | 514 | * @return array the modified entity |
515 | 515 | */ |
516 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
517 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
518 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
516 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
517 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
518 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
519 | 519 | //if they passed in * or didn't specify any includes, return everything |
520 | - if( ! in_array( '*', $includes_for_this_model ) |
|
521 | - && ! empty( $includes_for_this_model ) ) { |
|
522 | - if( $model->has_primary_key_field() ) { |
|
520 | + if ( ! in_array('*', $includes_for_this_model) |
|
521 | + && ! empty($includes_for_this_model)) { |
|
522 | + if ($model->has_primary_key_field()) { |
|
523 | 523 | //always include the primary key. ya just gotta know that at least |
524 | 524 | $includes_for_this_model[] = $model->primary_key_name(); |
525 | 525 | } |
526 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
526 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
527 | 527 | $includes_for_this_model[] = '_calculated_fields'; |
528 | 528 | } |
529 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
529 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
530 | 530 | } |
531 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
532 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
531 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
532 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
533 | 533 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
534 | - $rest_request->get_param( 'include' ), |
|
534 | + $rest_request->get_param('include'), |
|
535 | 535 | $relation_name |
536 | 536 | ); |
537 | 537 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
538 | - $rest_request->get_param( 'calculate' ), |
|
538 | + $rest_request->get_param('calculate'), |
|
539 | 539 | $relation_name |
540 | 540 | ); |
541 | 541 | //did they specify they wanted to include a related model, or |
542 | 542 | //specific fields from a related model? |
543 | 543 | //or did they specify to calculate a field from a related model? |
544 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
544 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
545 | 545 | //if so, we should include at least some part of the related model |
546 | 546 | $pretend_related_request = new \WP_REST_Request(); |
547 | 547 | $pretend_related_request->set_query_params( |
548 | 548 | array( |
549 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
549 | + 'caps' => $rest_request->get_param('caps'), |
|
550 | 550 | 'include' => $related_fields_to_include, |
551 | 551 | 'calculate' => $related_fields_to_calculate, |
552 | 552 | ) |
553 | 553 | ); |
554 | 554 | $related_results = $this->get_entities_from_relation( |
555 | - $entity_array[ $model->primary_key_name() ], |
|
555 | + $entity_array[$model->primary_key_name()], |
|
556 | 556 | $relation_obj, |
557 | 557 | $pretend_related_request |
558 | 558 | ); |
559 | - $entity_array[ $this->get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error ? null : $related_results; |
|
559 | + $entity_array[$this->get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error ? null : $related_results; |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | return $entity_array; |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | * @param array $arr |
569 | 569 | * @return array |
570 | 570 | */ |
571 | - private function _remove_model_names_from_array( $arr ) { |
|
572 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
571 | + private function _remove_model_names_from_array($arr) { |
|
572 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
573 | 573 | } |
574 | 574 | /** |
575 | 575 | * Gets the calculated fields for the response |
@@ -579,16 +579,16 @@ discard block |
||
579 | 579 | * @param \WP_REST_Request $rest_request |
580 | 580 | * @return array the _calculations item in the entity |
581 | 581 | */ |
582 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
582 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
583 | 583 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
584 | - $rest_request->get_param( 'calculate' ), |
|
584 | + $rest_request->get_param('calculate'), |
|
585 | 585 | '' |
586 | 586 | ); |
587 | 587 | //note: setting calculate=* doesn't do anything |
588 | 588 | $calculated_fields_to_return = array(); |
589 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
590 | - try{ |
|
591 | - $calculated_fields_to_return[ $field_to_calculate ] = Model_Data_Translator::prepare_field_value_for_json( |
|
589 | + foreach ($calculated_fields as $field_to_calculate) { |
|
590 | + try { |
|
591 | + $calculated_fields_to_return[$field_to_calculate] = Model_Data_Translator::prepare_field_value_for_json( |
|
592 | 592 | null, |
593 | 593 | $this->_fields_calculator->retrieve_calculated_field_value( |
594 | 594 | $model, |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | ), |
600 | 600 | $this->get_model_version_info()->requested_version() |
601 | 601 | ); |
602 | - } catch( Rest_Exception $e ) { |
|
602 | + } catch (Rest_Exception $e) { |
|
603 | 603 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
604 | 604 | $this->_set_response_header( |
605 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
605 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
606 | 606 | $e->getMessage(), |
607 | 607 | true |
608 | 608 | ); |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
617 | 617 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
618 | 618 | */ |
619 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
619 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
620 | 620 | return rest_url( |
621 | 621 | \EED_Core_Rest_Api::ee_api_namespace |
622 | 622 | . $this->get_model_version_info()->requested_version() |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | * @param \EE_Model_Relation_Base $relation_obj |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
636 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
637 | - return strtolower( $relation_name ); |
|
638 | - }else{ |
|
639 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
635 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
636 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
637 | + return strtolower($relation_name); |
|
638 | + } else { |
|
639 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
@@ -649,43 +649,43 @@ discard block |
||
649 | 649 | * @param \WP_REST_Request $request |
650 | 650 | * @return array |
651 | 651 | */ |
652 | - public function get_entity_from_model( $model, $request ) { |
|
653 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
654 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
652 | + public function get_entity_from_model($model, $request) { |
|
653 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
654 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
655 | 655 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
656 | 656 | } |
657 | 657 | $restricted_query_params = $query_params; |
658 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
659 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
660 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
661 | - if ( ! empty ( $model_rows ) ) { |
|
658 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
659 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
660 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
661 | + if ( ! empty ($model_rows)) { |
|
662 | 662 | return $this->create_entity_from_wpdb_result( |
663 | 663 | $model, |
664 | - array_shift( $model_rows ), |
|
664 | + array_shift($model_rows), |
|
665 | 665 | $request ); |
666 | 666 | } else { |
667 | 667 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
668 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
669 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
670 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
668 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
669 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
670 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
671 | 671 | //you got shafted- it existed but we didn't want to tell you! |
672 | 672 | return new \WP_Error( |
673 | 673 | 'rest_user_cannot_read', |
674 | 674 | sprintf( |
675 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
676 | - strtolower( $model->get_this_model_name() ), |
|
675 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
676 | + strtolower($model->get_this_model_name()), |
|
677 | 677 | Capabilities::get_missing_permissions_string( |
678 | 678 | $model, |
679 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
679 | + $this->validate_context($request->get_param('caps')) ) |
|
680 | 680 | ), |
681 | - array( 'status' => 403 ) |
|
681 | + array('status' => 403) |
|
682 | 682 | ); |
683 | 683 | } else { |
684 | 684 | //it's not you. It just doesn't exist |
685 | 685 | return new \WP_Error( |
686 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
687 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
688 | - array( 'status' => 404 ) |
|
686 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
687 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
688 | + array('status' => 404) |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | } |
@@ -698,14 +698,14 @@ discard block |
||
698 | 698 | * @param string $context |
699 | 699 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
700 | 700 | */ |
701 | - public function validate_context( $context ) { |
|
702 | - if( ! $context ) { |
|
701 | + public function validate_context($context) { |
|
702 | + if ( ! $context) { |
|
703 | 703 | $context = \EEM_Base::caps_read; |
704 | 704 | } |
705 | 705 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
706 | - if( in_array( $context, $valid_contexts ) ){ |
|
706 | + if (in_array($context, $valid_contexts)) { |
|
707 | 707 | return $context; |
708 | - }else{ |
|
708 | + } else { |
|
709 | 709 | return \EEM_Base::caps_read; |
710 | 710 | } |
711 | 711 | } |
@@ -724,77 +724,77 @@ discard block |
||
724 | 724 | * that absolutely no results should be returned |
725 | 725 | * @throws \EE_Error |
726 | 726 | */ |
727 | - public function create_model_query_params( $model, $query_parameters ) { |
|
727 | + public function create_model_query_params($model, $query_parameters) { |
|
728 | 728 | $model_query_params = array( ); |
729 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
730 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
731 | - $query_parameters[ 'where' ], |
|
729 | + if (isset($query_parameters['where'])) { |
|
730 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
731 | + $query_parameters['where'], |
|
732 | 732 | $model, |
733 | 733 | $this->get_model_version_info()->requested_version() |
734 | 734 | ); |
735 | 735 | } |
736 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
737 | - $order_by = $query_parameters[ 'order_by' ]; |
|
738 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
739 | - $order_by = $query_parameters[ 'orderby' ]; |
|
740 | - }else{ |
|
736 | + if (isset($query_parameters['order_by'])) { |
|
737 | + $order_by = $query_parameters['order_by']; |
|
738 | + } elseif (isset($query_parameters['orderby'])) { |
|
739 | + $order_by = $query_parameters['orderby']; |
|
740 | + } else { |
|
741 | 741 | $order_by = null; |
742 | 742 | } |
743 | - if( $order_by !== null ){ |
|
744 | - $model_query_params[ 'order_by' ] = $order_by; |
|
743 | + if ($order_by !== null) { |
|
744 | + $model_query_params['order_by'] = $order_by; |
|
745 | 745 | } |
746 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
747 | - $group_by = $query_parameters[ 'group_by' ]; |
|
748 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
749 | - $group_by = $query_parameters[ 'groupby' ]; |
|
750 | - }else{ |
|
746 | + if (isset($query_parameters['group_by'])) { |
|
747 | + $group_by = $query_parameters['group_by']; |
|
748 | + } elseif (isset($query_parameters['groupby'])) { |
|
749 | + $group_by = $query_parameters['groupby']; |
|
750 | + } else { |
|
751 | 751 | $group_by = null; |
752 | 752 | } |
753 | - if( $group_by !== null ){ |
|
754 | - $model_query_params[ 'group_by' ] = $group_by; |
|
753 | + if ($group_by !== null) { |
|
754 | + $model_query_params['group_by'] = $group_by; |
|
755 | 755 | } |
756 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
757 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
758 | - $query_parameters[ 'having' ], |
|
756 | + if (isset($query_parameters['having'])) { |
|
757 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
758 | + $query_parameters['having'], |
|
759 | 759 | $model, |
760 | 760 | $this->get_model_version_info()->requested_version() |
761 | 761 | ); |
762 | 762 | } |
763 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
764 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
763 | + if (isset($query_parameters['order'])) { |
|
764 | + $model_query_params['order'] = $query_parameters['order']; |
|
765 | 765 | } |
766 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
767 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
766 | + if (isset($query_parameters['mine'])) { |
|
767 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
768 | 768 | } |
769 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
769 | + if (isset($query_parameters['limit'])) { |
|
770 | 770 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
771 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
772 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
773 | - }else { |
|
774 | - $limit_array = $query_parameters[ 'limit' ]; |
|
771 | + if ( ! is_array($query_parameters['limit'])) { |
|
772 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
773 | + } else { |
|
774 | + $limit_array = $query_parameters['limit']; |
|
775 | 775 | } |
776 | 776 | $sanitized_limit = array(); |
777 | - foreach( $limit_array as $key => $limit_part ) { |
|
778 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
777 | + foreach ($limit_array as $key => $limit_part) { |
|
778 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
779 | 779 | throw new \EE_Error( |
780 | 780 | sprintf( |
781 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
782 | - json_encode( $query_parameters[ 'limit' ] ) |
|
781 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
782 | + json_encode($query_parameters['limit']) |
|
783 | 783 | ) |
784 | 784 | ); |
785 | 785 | } |
786 | - $sanitized_limit[] = intval( $limit_part ); |
|
786 | + $sanitized_limit[] = intval($limit_part); |
|
787 | 787 | } |
788 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
789 | - }else{ |
|
790 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
788 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
789 | + } else { |
|
790 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
791 | 791 | } |
792 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
793 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
794 | - }else{ |
|
795 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
792 | + if (isset($query_parameters['caps'])) { |
|
793 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
794 | + } else { |
|
795 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
796 | 796 | } |
797 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
797 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
807 | 807 | * @return array |
808 | 808 | */ |
809 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
809 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
810 | 810 | $model_ready_query_params = array(); |
811 | - foreach( $query_params as $key => $value ) { |
|
812 | - if( is_array( $value ) ) { |
|
813 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
814 | - }else{ |
|
815 | - $model_ready_query_params[ $key ] = $value; |
|
811 | + foreach ($query_params as $key => $value) { |
|
812 | + if (is_array($value)) { |
|
813 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
814 | + } else { |
|
815 | + $model_ready_query_params[$key] = $value; |
|
816 | 816 | } |
817 | 817 | } |
818 | 818 | return $model_ready_query_params; |
@@ -826,13 +826,13 @@ discard block |
||
826 | 826 | * @param $query_params |
827 | 827 | * @return array |
828 | 828 | */ |
829 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
829 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
830 | 830 | $model_ready_query_params = array(); |
831 | - foreach( $query_params as $key => $value ) { |
|
832 | - if( is_array( $value ) ) { |
|
833 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
831 | + foreach ($query_params as $key => $value) { |
|
832 | + if (is_array($value)) { |
|
833 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
834 | 834 | } else { |
835 | - $model_ready_query_params[ $key ] = $value; |
|
835 | + $model_ready_query_params[$key] = $value; |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 | return $model_ready_query_params; |
@@ -847,33 +847,33 @@ discard block |
||
847 | 847 | * we only return strings starting with that and a period; if no prefix was specified |
848 | 848 | * we return all items containing NO periods |
849 | 849 | */ |
850 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
851 | - if( is_string( $string_to_explode ) ) { |
|
852 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
853 | - } else if( is_array( $string_to_explode ) ) { |
|
850 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
851 | + if (is_string($string_to_explode)) { |
|
852 | + $exploded_contents = explode(',', $string_to_explode); |
|
853 | + } else if (is_array($string_to_explode)) { |
|
854 | 854 | $exploded_contents = $string_to_explode; |
855 | 855 | } else { |
856 | 856 | $exploded_contents = array(); |
857 | 857 | } |
858 | 858 | //if the string was empty, we want an empty array |
859 | - $exploded_contents = array_filter( $exploded_contents ); |
|
859 | + $exploded_contents = array_filter($exploded_contents); |
|
860 | 860 | $contents_with_prefix = array(); |
861 | - foreach( $exploded_contents as $item ) { |
|
862 | - $item = trim( $item ); |
|
861 | + foreach ($exploded_contents as $item) { |
|
862 | + $item = trim($item); |
|
863 | 863 | //if no prefix was provided, so we look for items with no "." in them |
864 | - if( ! $prefix ) { |
|
864 | + if ( ! $prefix) { |
|
865 | 865 | //does this item have a period? |
866 | - if( strpos( $item, '.' ) === false ) { |
|
866 | + if (strpos($item, '.') === false) { |
|
867 | 867 | //if not, then its what we're looking for |
868 | 868 | $contents_with_prefix[] = $item; |
869 | 869 | } |
870 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
870 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
871 | 871 | //this item has the prefix and a period, grab it |
872 | 872 | $contents_with_prefix[] = substr( |
873 | 873 | $item, |
874 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
874 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
875 | 875 | ); |
876 | - } else if( $item === $prefix ) { |
|
876 | + } else if ($item === $prefix) { |
|
877 | 877 | //this item is JUST the prefix |
878 | 878 | //so let's grab everything after, which is a blank string |
879 | 879 | $contents_with_prefix[] = ''; |
@@ -896,33 +896,33 @@ discard block |
||
896 | 896 | * the fields for that model, with the model's name removed from each. |
897 | 897 | * If $include_string was blank or '*' returns an empty array |
898 | 898 | */ |
899 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
900 | - if( is_array( $include_string ) ) { |
|
901 | - $include_string = implode( ',', $include_string ); |
|
899 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
900 | + if (is_array($include_string)) { |
|
901 | + $include_string = implode(',', $include_string); |
|
902 | 902 | } |
903 | - if( $include_string === '*' || $include_string === '' ) { |
|
903 | + if ($include_string === '*' || $include_string === '') { |
|
904 | 904 | return array(); |
905 | 905 | } |
906 | - $includes = explode( ',', $include_string ); |
|
906 | + $includes = explode(',', $include_string); |
|
907 | 907 | $extracted_fields_to_include = array(); |
908 | - if( $model_name ){ |
|
909 | - foreach( $includes as $field_to_include ) { |
|
910 | - $field_to_include = trim( $field_to_include ); |
|
911 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
908 | + if ($model_name) { |
|
909 | + foreach ($includes as $field_to_include) { |
|
910 | + $field_to_include = trim($field_to_include); |
|
911 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
912 | 912 | //found the model name at the exact start |
913 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
913 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
914 | 914 | $extracted_fields_to_include[] = $field_sans_model_name; |
915 | - }elseif( $field_to_include == $model_name ){ |
|
915 | + }elseif ($field_to_include == $model_name) { |
|
916 | 916 | $extracted_fields_to_include[] = '*'; |
917 | 917 | } |
918 | 918 | } |
919 | - }else{ |
|
919 | + } else { |
|
920 | 920 | //look for ones with no period |
921 | - foreach( $includes as $field_to_include ) { |
|
922 | - $field_to_include = trim( $field_to_include ); |
|
921 | + foreach ($includes as $field_to_include) { |
|
922 | + $field_to_include = trim($field_to_include); |
|
923 | 923 | if ( |
924 | - strpos( $field_to_include, '.' ) === false |
|
925 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
924 | + strpos($field_to_include, '.') === false |
|
925 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
926 | 926 | ) { |
927 | 927 | $extracted_fields_to_include[] = $field_to_include; |
928 | 928 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected $_cached_fields_on_models = array(); |
89 | 89 | |
90 | 90 | |
91 | - public function __construct( $requested_version ) { |
|
91 | + public function __construct($requested_version) { |
|
92 | 92 | $this->_requested_version = $requested_version; |
93 | 93 | $this->_model_changes = array( |
94 | 94 | '4.8.29' => array( |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | 'table_column' => 'N/A', |
111 | 111 | 'always_available' => true, |
112 | 112 | ); |
113 | - foreach( $this->_resource_changes as $version => $model_classnames ) { |
|
114 | - foreach( $model_classnames as $model_classname => $extra_fields ) { |
|
115 | - foreach( $extra_fields as $fieldname => $field_data ) { |
|
116 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ 'name' ] = $fieldname; |
|
117 | - foreach( $defaults as $attribute => $default_value ) { |
|
118 | - if( ! isset( $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] ) ) { |
|
119 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] = $default_value; |
|
113 | + foreach ($this->_resource_changes as $version => $model_classnames) { |
|
114 | + foreach ($model_classnames as $model_classname => $extra_fields) { |
|
115 | + foreach ($extra_fields as $fieldname => $field_data) { |
|
116 | + $this->_resource_changes[$model_classname][$fieldname]['name'] = $fieldname; |
|
117 | + foreach ($defaults as $attribute => $default_value) { |
|
118 | + if ( ! isset($this->_resource_changes[$model_classname][$fieldname][$attribute])) { |
|
119 | + $this->_resource_changes[$model_classname][$fieldname][$attribute] = $default_value; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | * @return array |
133 | 133 | */ |
134 | 134 | public function model_changes_between_requested_version_and_current() { |
135 | - if( $this->_cached_model_changes_between_requested_version_and_current === null ) { |
|
135 | + if ($this->_cached_model_changes_between_requested_version_and_current === null) { |
|
136 | 136 | $model_changes = array(); |
137 | - foreach( $this->model_changes() as $version => $models_changed_in_version ) { |
|
138 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
139 | - $model_changes[ $version ] = $models_changed_in_version; |
|
137 | + foreach ($this->model_changes() as $version => $models_changed_in_version) { |
|
138 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
139 | + $model_changes[$version] = $models_changed_in_version; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | $this->_cached_model_changes_between_requested_version_and_current = $model_changes; |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | */ |
154 | 154 | public function resource_changes_between_requested_version_and_current() { |
155 | - if( $this->_cached_resource_changes_between_requested_version_and_current === null ) { |
|
155 | + if ($this->_cached_resource_changes_between_requested_version_and_current === null) { |
|
156 | 156 | $resource_changes = array(); |
157 | - foreach( $this->resource_changes() as $version => $model_classnames ) { |
|
158 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
159 | - $resource_changes[ $version ] = $model_classnames; |
|
157 | + foreach ($this->resource_changes() as $version => $model_classnames) { |
|
158 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
159 | + $resource_changes[$version] = $model_classnames; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | $this->_cached_resource_changes_between_requested_version_and_current = $resource_changes; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * If a request was sent to 'wp-json/ee/v4.7/events' this would be '4.7' |
169 | 169 | * @return string like '4.6' |
170 | 170 | */ |
171 | - public function requested_version(){ |
|
171 | + public function requested_version() { |
|
172 | 172 | return $this->_requested_version; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * If a version is missing then we don't know anything about what changes it introduced from the previous version |
183 | 183 | * @return array |
184 | 184 | */ |
185 | - public function model_changes(){ |
|
185 | + public function model_changes() { |
|
186 | 186 | return $this->_model_changes; |
187 | 187 | } |
188 | 188 | |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @return array keys are model names, values are their classname |
194 | 194 | */ |
195 | 195 | public function models_for_requested_version() { |
196 | - if( $this->_cached_models_for_requested_version === null ) { |
|
196 | + if ($this->_cached_models_for_requested_version === null) { |
|
197 | 197 | $all_models_in_current_version = \EE_Registry::instance()->non_abstract_db_models; |
198 | - foreach( $this->model_changes_between_requested_version_and_current() as $version => $models_changed ) { |
|
199 | - foreach( $models_changed as $model_name => $new_indicator_or_fields_added ) { |
|
200 | - if( $new_indicator_or_fields_added === Model_Version_Info::model_added ) { |
|
201 | - unset( $all_models_in_current_version[ $model_name ] ); |
|
198 | + foreach ($this->model_changes_between_requested_version_and_current() as $version => $models_changed) { |
|
199 | + foreach ($models_changed as $model_name => $new_indicator_or_fields_added) { |
|
200 | + if ($new_indicator_or_fields_added === Model_Version_Info::model_added) { |
|
201 | + unset($all_models_in_current_version[$model_name]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * @param string $model_name eg 'Event' |
218 | 218 | * @return boolean |
219 | 219 | */ |
220 | - public function is_model_name_in_this_version( $model_name ) { |
|
220 | + public function is_model_name_in_this_version($model_name) { |
|
221 | 221 | $model_names = $this->models_for_requested_version(); |
222 | - if( isset( $model_names[ $model_name ] ) ) { |
|
222 | + if (isset($model_names[$model_name])) { |
|
223 | 223 | return true; |
224 | - }else{ |
|
224 | + } else { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | * @return \EEM_Base |
237 | 237 | * @throws \EE_Error |
238 | 238 | */ |
239 | - public function load_model( $model_name ) { |
|
240 | - if( $this->is_model_name_in_this_version( $model_name ) ) { |
|
241 | - return \EE_Registry::instance()->load_model( $model_name ); |
|
242 | - }else{ |
|
239 | + public function load_model($model_name) { |
|
240 | + if ($this->is_model_name_in_this_version($model_name)) { |
|
241 | + return \EE_Registry::instance()->load_model($model_name); |
|
242 | + } else { |
|
243 | 243 | throw new \EE_Error( |
244 | 244 | sprintf( |
245 | 245 | __( |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | * @param \EEM_Base $model |
262 | 262 | * @return array|\EE_Model_Field_Base[] |
263 | 263 | */ |
264 | - public function fields_on_model_in_this_version( $model ) { |
|
265 | - if( ! isset( $this->_cached_fields_on_models[ $model->get_this_model_name() ] ) ) { |
|
264 | + public function fields_on_model_in_this_version($model) { |
|
265 | + if ( ! isset($this->_cached_fields_on_models[$model->get_this_model_name()])) { |
|
266 | 266 | //get all model changes between the requested version and current core version |
267 | 267 | $changes = $this->model_changes_between_requested_version_and_current(); |
268 | 268 | //fetch all fields currently on this model |
269 | 269 | $current_fields = $model->field_settings(); |
270 | 270 | //remove all fields that have been added since |
271 | - foreach( $changes as $version => $changes_in_version ) { |
|
272 | - if( |
|
273 | - isset( $changes_in_version[ $model->get_this_model_name() ] ) |
|
274 | - && $changes_in_version[ $model->get_this_model_name() ] !== Model_Version_Info::model_added |
|
271 | + foreach ($changes as $version => $changes_in_version) { |
|
272 | + if ( |
|
273 | + isset($changes_in_version[$model->get_this_model_name()]) |
|
274 | + && $changes_in_version[$model->get_this_model_name()] !== Model_Version_Info::model_added |
|
275 | 275 | ) { |
276 | 276 | $current_fields = array_diff_key( |
277 | 277 | $current_fields, |
278 | - array_flip( $changes_in_version[ $model->get_this_model_name() ] ) |
|
278 | + array_flip($changes_in_version[$model->get_this_model_name()]) |
|
279 | 279 | ); |
280 | 280 | } |
281 | 281 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @param array $classnames |
294 | 294 | * @return boolean |
295 | 295 | */ |
296 | - public function is_subclass_of_one( $object, $classnames ) { |
|
297 | - foreach( $classnames as $classname ) { |
|
298 | - if( is_a( $object, $classname ) ) { |
|
296 | + public function is_subclass_of_one($object, $classnames) { |
|
297 | + foreach ($classnames as $classname) { |
|
298 | + if (is_a($object, $classname)) { |
|
299 | 299 | return true; |
300 | 300 | } |
301 | 301 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * Returns the list of model field classes that that the API basically ignores |
307 | 307 | * @return array |
308 | 308 | */ |
309 | - public function fields_ignored(){ |
|
309 | + public function fields_ignored() { |
|
310 | 310 | return apply_filters( |
311 | 311 | 'FHEE__Controller_Model_Read_fields_ignored', |
312 | - array( 'EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field' ) |
|
312 | + array('EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field') |
|
313 | 313 | ); |
314 | 314 | } |
315 | 315 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param EE_Model_Field_Base |
319 | 319 | * @return boolean |
320 | 320 | */ |
321 | - public function field_is_ignored( $field_obj ){ |
|
322 | - return $this->is_subclass_of_one( $field_obj, $this->fields_ignored() ); |
|
321 | + public function field_is_ignored($field_obj) { |
|
322 | + return $this->is_subclass_of_one($field_obj, $this->fields_ignored()); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | public function fields_that_have_rendered_format() { |
331 | 331 | return apply_filters( |
332 | 332 | 'FHEE__Controller_Model_Read__fields_raw', |
333 | - array( 'EE_Post_Content_Field', 'EE_Full_HTML_Field' ) |
|
333 | + array('EE_Post_Content_Field', 'EE_Full_HTML_Field') |
|
334 | 334 | ); |
335 | 335 | } |
336 | 336 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Model_Field_Base |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - public function field_has_rendered_format( $field_obj ){ |
|
343 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_rendered_format() ); |
|
342 | + public function field_has_rendered_format($field_obj) { |
|
343 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_rendered_format()); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function fields_that_have_pretty_format() { |
353 | 353 | return apply_filters( |
354 | 354 | 'FHEE__Controller_Model_Read__fields_pretty', |
355 | - array( 'EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field' ) |
|
355 | + array('EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field') |
|
356 | 356 | ); |
357 | 357 | } |
358 | 358 | |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * @param EE_Model_Field_Base |
362 | 362 | * @return boolean |
363 | 363 | */ |
364 | - public function field_has_pretty_format( $field_obj ){ |
|
365 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_pretty_format() ); |
|
364 | + public function field_has_pretty_format($field_obj) { |
|
365 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_pretty_format()); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | * @param \EEM_Base $model |
380 | 380 | * @return array |
381 | 381 | */ |
382 | - public function extra_resource_properties_for_model( $model ) { |
|
382 | + public function extra_resource_properties_for_model($model) { |
|
383 | 383 | $extra_properties = array(); |
384 | - foreach( $this->resource_changes_between_requested_version_and_current() as $version => $model_classnames ) { |
|
385 | - foreach( $model_classnames as $model_classname => $properties_added_in_this_version ) { |
|
386 | - if( is_subclass_of( $model, $model_classname ) ) { |
|
387 | - $extra_properties = array_merge( $extra_properties, $properties_added_in_this_version ); |
|
384 | + foreach ($this->resource_changes_between_requested_version_and_current() as $version => $model_classnames) { |
|
385 | + foreach ($model_classnames as $model_classname => $properties_added_in_this_version) { |
|
386 | + if (is_subclass_of($model, $model_classname)) { |
|
387 | + $extra_properties = array_merge($extra_properties, $properties_added_in_this_version); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param \EEM_Base $model |
398 | 398 | * @return \EE_Model_Relation_Base[] |
399 | 399 | */ |
400 | - public function relation_settings( \EEM_Base $model ) { |
|
400 | + public function relation_settings(\EEM_Base $model) { |
|
401 | 401 | $relations = array(); |
402 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
403 | - if( $this->is_model_name_in_this_version( $relation_name ) ) { |
|
404 | - $relations[ $relation_name ] = $relation_obj; |
|
402 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
403 | + if ($this->is_model_name_in_this_version($relation_name)) { |
|
404 | + $relations[$relation_name] = $relation_obj; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | //filter the results, but use the old filter name |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | protected $_reports_template_data = array(); |
38 | 38 | |
39 | 39 | |
40 | - public function __construct( $routing = TRUE ) { |
|
41 | - parent::__construct( $routing ); |
|
42 | - define( 'REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
43 | - define( 'REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
44 | - define( 'REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
40 | + public function __construct($routing = TRUE) { |
|
41 | + parent::__construct($routing); |
|
42 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
43 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
44 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | protected function _extend_page_config() { |
49 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
50 | 50 | |
51 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
52 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
53 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
51 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
52 | + $att_id = ! empty($this->_req_data['ATT_ID']) ? ! is_array($this->_req_data['ATT_ID']) : 0; |
|
53 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
54 | 54 | |
55 | 55 | $new_page_routes = array( |
56 | 56 | 'reports' => array( |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | |
92 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
92 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
93 | 93 | |
94 | 94 | $new_page_config = array( |
95 | 95 | 'reports' => array( |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | 'filename' => 'registrations_event_checkin_other' |
135 | 135 | ) |
136 | 136 | ), |
137 | - 'help_tour' => array( 'Event_Checkin_Help_Tour' ), |
|
138 | - 'qtips' => array('Registration_List_Table_Tips' ), |
|
137 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
138 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
139 | 139 | 'list_table' => 'EE_Event_Registrations_List_Table', |
140 | 140 | 'metaboxes' => array(), |
141 | 141 | 'require_nonce' => FALSE |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | // var_dump($this->_req_data); |
157 | 157 | // exit(); |
158 | 158 | |
159 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
159 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
160 | 160 | $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
161 | 161 | $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
162 | 162 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | protected function _ajax_hooks() { |
167 | 167 | parent::_ajax_hooks(); |
168 | - add_action('wp_ajax_get_newsletter_form_content', array( $this, 'get_newsletter_form_content') ); |
|
168 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -175,20 +175,20 @@ discard block |
||
175 | 175 | |
176 | 176 | //if newsletter message type is active then let's add filter and load js for it. |
177 | 177 | EE_Registry::instance()->load_helper('MSG_Template'); |
178 | - if ( EEH_MSG_Template::is_mt_active('newsletter') ) { |
|
178 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
179 | 179 | //enqueue newsletter js |
180 | - wp_enqueue_script( 'ee-newsletter-trigger', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', array( 'ee-dialog'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
181 | - wp_enqueue_style( 'ee-newsletter-trigger-css', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION ); |
|
180 | + wp_enqueue_script('ee-newsletter-trigger', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, TRUE); |
|
181 | + wp_enqueue_style('ee-newsletter-trigger-css', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION); |
|
182 | 182 | //hook in buttons for newsletter message type trigger. |
183 | - add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array( $this, 'add_newsletter_action_buttons'), 10 ); |
|
183 | + add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array($this, 'add_newsletter_action_buttons'), 10); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | 189 | public function load_scripts_styles_reports() { |
190 | - wp_register_script( 'ee-reg-reports-js', REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', array( 'google-charts' ), EVENT_ESPRESSO_VERSION, true ); |
|
191 | - wp_enqueue_script( 'ee-reg-reports-js' ); |
|
190 | + wp_register_script('ee-reg-reports-js', REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', array('google-charts'), EVENT_ESPRESSO_VERSION, true); |
|
191 | + wp_enqueue_script('ee-reg-reports-js'); |
|
192 | 192 | $this->_registration_reports_js_setup(); |
193 | 193 | } |
194 | 194 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'slug' => 'all', |
221 | 221 | 'label' => __('All', 'event_espresso'), |
222 | 222 | 'count' => 0, |
223 | - 'bulk_action' => !isset( $this->_req_data['event_id'] ) ? array() : array( |
|
223 | + 'bulk_action' => ! isset($this->_req_data['event_id']) ? array() : array( |
|
224 | 224 | 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
225 | 225 | //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
226 | 226 | ) |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | 'slug' => 'all', |
239 | 239 | 'label' => __('All', 'event_espresso'), |
240 | 240 | 'count' => 0, |
241 | - 'bulk_action' => array( 'delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso') ) |
|
241 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')) |
|
242 | 242 | ), |
243 | 243 | ); |
244 | 244 | } |
@@ -254,20 +254,20 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function get_newsletter_form_content() { |
256 | 256 | //do a nonce check cause we're not coming in from an normal route here. |
257 | - $nonce = isset( $this->_req_data['get_newsletter_form_content_nonce'] ) ? sanitize_text_field( $this->_req_data['get_newsletter_form_content_nonce'] ) : ''; |
|
257 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field($this->_req_data['get_newsletter_form_content_nonce']) : ''; |
|
258 | 258 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
259 | 259 | |
260 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
260 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
261 | 261 | //let's get the mtp for the incoming MTP_ ID |
262 | - if ( !isset( $this->_req_data['GRP_ID'] ) ) { |
|
263 | - EE_Error::add_error( __('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
262 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
263 | + EE_Error::add_error(__('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
264 | 264 | $this->_template_args['success'] = FALSE; |
265 | 265 | $this->_template_args['error'] = TRUE; |
266 | 266 | $this->_return_json(); |
267 | 267 | } |
268 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['GRP_ID'] ); |
|
269 | - if ( ! $MTPG instanceof EE_Message_Template_Group ) { |
|
270 | - EE_Error::add_error( sprintf( __('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
268 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
269 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
270 | + EE_Error::add_error(sprintf(__('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID']), __FILE__, __FUNCTION__, __LINE__); |
|
271 | 271 | $this->_template_args['success'] = FALSE; |
272 | 272 | $this->_template_args['error'] = TRUE; |
273 | 273 | $this->_return_json(); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | $MTPs = $MTPG->context_templates(); |
277 | 277 | $MTPs = $MTPs['attendee']; |
278 | 278 | $template_fields = array(); |
279 | - foreach ( $MTPs as $MTP ) { |
|
279 | + foreach ($MTPs as $MTP) { |
|
280 | 280 | $field = $MTP->get('MTP_template_field'); |
281 | - if ( $field == 'content' ) { |
|
281 | + if ($field == 'content') { |
|
282 | 282 | $content = $MTP->get('MTP_content'); |
283 | - if ( !empty( $content['newsletter_content'] ) ) { |
|
283 | + if ( ! empty($content['newsletter_content'])) { |
|
284 | 284 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
285 | 285 | } |
286 | 286 | continue; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $this->_template_args['data'] = array( |
294 | 294 | 'batch_message_from' => isset($template_fields['from']) ? $template_fields['from'] : '', |
295 | 295 | 'batch_message_subject' => isset($template_fields['subject']) ? $template_fields['subject'] : '', |
296 | - 'batch_message_content' => isset( $template_fields['newsletter_content'] ) ? $template_fields['newsletter_content'] : '' |
|
296 | + 'batch_message_content' => isset($template_fields['newsletter_content']) ? $template_fields['newsletter_content'] : '' |
|
297 | 297 | ); |
298 | 298 | $this->_return_json(); |
299 | 299 | } |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | * @param EE_Admin_List_Table $list_table |
310 | 310 | * @return string html string for extra buttons |
311 | 311 | */ |
312 | - public function add_newsletter_action_buttons( EE_Admin_List_Table $list_table ) { |
|
313 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_newsletter_selected_send' ) ) { |
|
312 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) { |
|
313 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_newsletter_selected_send')) { |
|
314 | 314 | return ''; |
315 | 315 | } |
316 | 316 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | 'event_registrations', |
320 | 320 | 'default' |
321 | 321 | ); |
322 | - if ( $this->_current_page == 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to ) ) { |
|
323 | - if ( ( $this->_req_action == 'event_registrations' && empty( $this->_req_data['event_id'] ) ) || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ) ) { |
|
322 | + if ($this->_current_page == 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
323 | + if (($this->_req_action == 'event_registrations' && empty($this->_req_data['event_id'])) || (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash')) { |
|
324 | 324 | echo ''; |
325 | 325 | } else { |
326 | - $button_text = sprintf( __('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>' ); |
|
327 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' . $button_text . '</button>'; |
|
328 | - add_action('admin_footer', array( $this, 'newsletter_send_form_skeleton') ); |
|
326 | + $button_text = sprintf(__('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>'); |
|
327 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'.$button_text.'</button>'; |
|
328 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
@@ -337,38 +337,38 @@ discard block |
||
337 | 337 | $list_table = $this->_list_table_object; |
338 | 338 | $codes = array(); |
339 | 339 | //need to templates for the newsletter message type for the template selector. |
340 | - $values[] = array( 'text' => __('Select Template to Use', 'event_espresso'), 'id' => 0 ); |
|
341 | - $mtps = EEM_Message_Template_Group::instance()->get_all( array( array( 'MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email' ) ) ); |
|
342 | - foreach ( $mtps as $mtp ) { |
|
340 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
341 | + $mtps = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))); |
|
342 | + foreach ($mtps as $mtp) { |
|
343 | 343 | $name = $mtp->name(); |
344 | 344 | $values[] = array( |
345 | - 'text' => empty( $name ) ? __('Global', 'event_espresso') : $name, |
|
345 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
346 | 346 | 'id' => $mtp->ID() |
347 | 347 | ); |
348 | 348 | } |
349 | 349 | |
350 | 350 | //need to get a list of shortcodes that are available for the newsletter message type. |
351 | 351 | EE_Registry::instance()->load_helper('MSG_Template'); |
352 | - $shortcodes = EEH_MSG_Template::get_shortcodes( 'newsletter', 'email', array(), 'attendee', FALSE ); |
|
353 | - foreach ( $shortcodes as $field => $shortcode_array ) { |
|
354 | - $codes[$field] = implode(', ', array_keys($shortcode_array ) ); |
|
352 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', FALSE); |
|
353 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
354 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | $shortcodes = $codes; |
358 | 358 | |
359 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
359 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
360 | 360 | $form_template_args = array( |
361 | 361 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
362 | 362 | 'form_route' => 'newsletter_selected_send', |
363 | 363 | 'form_nonce_name' => 'newsletter_selected_send_nonce', |
364 | - 'form_nonce' => wp_create_nonce( 'newsletter_selected_send_nonce' ), |
|
364 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
365 | 365 | 'redirect_back_to' => $this->_req_action, |
366 | - 'ajax_nonce' => wp_create_nonce( 'get_newsletter_form_content_nonce'), |
|
367 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values ), |
|
366 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
367 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
368 | 368 | 'shortcodes' => $shortcodes, |
369 | 369 | 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration' |
370 | 370 | ); |
371 | - EEH_Template::display_template( $form_template, $form_template_args ); |
|
371 | + EEH_Template::display_template($form_template, $form_template_args); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -383,35 +383,35 @@ discard block |
||
383 | 383 | protected function _newsletter_selected_send() { |
384 | 384 | $success = TRUE; |
385 | 385 | //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
386 | - if ( empty( $this->_req_data['newsletter_mtp_selected'] ) ) { |
|
387 | - EE_Error::add_error( __('In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
386 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
387 | + EE_Error::add_error(__('In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
388 | 388 | $success = FALSE; |
389 | 389 | } |
390 | 390 | |
391 | - if ( $success ) { |
|
391 | + if ($success) { |
|
392 | 392 | //update Message template in case there are any changes |
393 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['newsletter_mtp_selected'] ); |
|
393 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['newsletter_mtp_selected']); |
|
394 | 394 | $MTPs = $MTPG instanceof EE_Message_Template_Group ? $MTPG->context_templates() : array(); |
395 | - if ( empty( $MTPs ) ) { |
|
396 | - EE_Error::add_error( __('Unable to retrieve message template fields from the db. Messages not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
395 | + if (empty($MTPs)) { |
|
396 | + EE_Error::add_error(__('Unable to retrieve message template fields from the db. Messages not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
397 | 397 | $success = FALSE; |
398 | 398 | } |
399 | 399 | |
400 | 400 | //let's just update the specific fields |
401 | - foreach ( $MTPs['attendee'] as $MTP ) { |
|
401 | + foreach ($MTPs['attendee'] as $MTP) { |
|
402 | 402 | $field = $MTP->get('MTP_template_field'); |
403 | 403 | $content = $MTP->get('MTP_content'); |
404 | 404 | $new_content = $content; |
405 | - switch( $field ) { |
|
405 | + switch ($field) { |
|
406 | 406 | case 'from' : |
407 | - $new_content = !empty( $this->_req_data['batch_message']['from'] ) ? $this->_req_data['batch_message']['from'] : $content; |
|
407 | + $new_content = ! empty($this->_req_data['batch_message']['from']) ? $this->_req_data['batch_message']['from'] : $content; |
|
408 | 408 | break; |
409 | 409 | case 'subject' : |
410 | - $new_content = !empty( $this->_req_data['batch_message']['subject'] ) ? $this->_req_data['batch_message']['subject'] : $content; |
|
410 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) ? $this->_req_data['batch_message']['subject'] : $content; |
|
411 | 411 | break; |
412 | 412 | case 'content' : |
413 | 413 | $new_content = $content; |
414 | - $new_content['newsletter_content'] = !empty( $this->_req_data['batch_message']['content'] ) ? $this->_req_data['batch_message']['content'] : $content['newsletter_content']; |
|
414 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) ? $this->_req_data['batch_message']['content'] : $content['newsletter_content']; |
|
415 | 415 | break; |
416 | 416 | default : |
417 | 417 | continue; |
@@ -422,20 +422,20 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
425 | - $id_type = !empty( $this->_req_data['batch_message']['id_type'] ) ? $this->_req_data['batch_message']['id_type'] : 'registration'; |
|
425 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) ? $this->_req_data['batch_message']['id_type'] : 'registration'; |
|
426 | 426 | |
427 | 427 | //id_type will affect how we assemble the ids. |
428 | - $ids = !empty( $this->_req_data['batch_message']['ids'] ) ? json_decode( stripslashes($this->_req_data['batch_message']['ids']) ) : array(); |
|
428 | + $ids = ! empty($this->_req_data['batch_message']['ids']) ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) : array(); |
|
429 | 429 | |
430 | - $contacts = $id_type == 'registration' ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids( $ids ) : EEM_Attendee::instance()->get_all( array( array( 'ATT_ID' => array('in', $ids ) ) ) ); |
|
430 | + $contacts = $id_type == 'registration' ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
431 | 431 | |
432 | 432 | //we do _action because ALL triggers are handled in EED_Messages. |
433 | - do_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', $contacts, $MTPG->ID() ); |
|
433 | + do_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', $contacts, $MTPG->ID()); |
|
434 | 434 | } |
435 | 435 | $query_args = array( |
436 | - 'action' => !empty( $this->_req_data['redirect_back_to'] ) ? $this->_req_data['redirect_back_to'] : 'default' |
|
436 | + 'action' => ! empty($this->_req_data['redirect_back_to']) ? $this->_req_data['redirect_back_to'] : 'default' |
|
437 | 437 | ); |
438 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
438 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return void |
458 | 458 | */ |
459 | 459 | protected function _registration_reports() { |
460 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
461 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_reports_template_data, true ); |
|
460 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
461 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_reports_template_data, true); |
|
462 | 462 | // the final template wrapper |
463 | 463 | $this->display_admin_page_with_no_sidebar(); |
464 | 464 | |
@@ -471,29 +471,29 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - private function _registrations_per_day_report( $period = '-1 month' ) { |
|
474 | + private function _registrations_per_day_report($period = '-1 month') { |
|
475 | 475 | $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
476 | 476 | |
477 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report( $period ); |
|
478 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
477 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
478 | + EE_Registry::instance()->load_helper('Template'); |
|
479 | 479 | |
480 | 480 | $results = (array) $results; |
481 | 481 | $regs = array(); |
482 | 482 | $subtitle = ''; |
483 | 483 | |
484 | - if( $results ) { |
|
484 | + if ($results) { |
|
485 | 485 | $column_titles = array(); |
486 | 486 | $tracker = 0; |
487 | - foreach ( $results as $result ) { |
|
487 | + foreach ($results as $result) { |
|
488 | 488 | $report_column_values = array(); |
489 | - foreach( $result as $property_name => $property_value ) { |
|
489 | + foreach ($result as $property_name => $property_value) { |
|
490 | 490 | $property_value = $property_name == 'Registration_REG_date' ? $property_value : (int) $property_value; |
491 | 491 | $report_column_values[] = $property_value; |
492 | - if ( $tracker === 0 ) { |
|
493 | - if ( $property_name == 'Registration_REG_date' ) { |
|
494 | - $column_titles[] = __( 'Date (only days with registrations are shown)', 'event_espresso' ); |
|
492 | + if ($tracker === 0) { |
|
493 | + if ($property_name == 'Registration_REG_date') { |
|
494 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
495 | 495 | } else { |
496 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
496 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
@@ -502,37 +502,37 @@ discard block |
||
502 | 502 | } |
503 | 503 | |
504 | 504 | //make sure the column_titles is pushed to the beginning of the array |
505 | - array_unshift( $regs, $column_titles ); |
|
505 | + array_unshift($regs, $column_titles); |
|
506 | 506 | //setup the date range. |
507 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
508 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
509 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
510 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
507 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
508 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
509 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
510 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
511 | 511 | $subtitle = sprintf( |
512 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
513 | - $beginning_date->format( 'Y-m-d' ), |
|
514 | - $ending_date->format( 'Y-m-d' ) |
|
512 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
513 | + $beginning_date->format('Y-m-d'), |
|
514 | + $ending_date->format('Y-m-d') |
|
515 | 515 | ); |
516 | 516 | } |
517 | 517 | |
518 | - $report_title = __( 'Total Registrations per Day', 'event_espresso' ); |
|
518 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
519 | 519 | |
520 | 520 | $report_params = array( |
521 | 521 | 'title' => $report_title, |
522 | 522 | 'subtitle' => $subtitle, |
523 | 523 | 'id' => $report_ID, |
524 | 524 | 'regs' => $regs, |
525 | - 'noResults' => empty( $regs ), |
|
525 | + 'noResults' => empty($regs), |
|
526 | 526 | 'noRegsMsg' => sprintf( |
527 | 527 | __( |
528 | 528 | '%sThere are currently no registration records in the last month for this report.%s', |
529 | 529 | 'event_espresso' |
530 | 530 | ), |
531 | - '<h2>' . $report_title . '</h2><p>', |
|
531 | + '<h2>'.$report_title.'</h2><p>', |
|
532 | 532 | '</p>' |
533 | 533 | ), |
534 | 534 | ); |
535 | - wp_localize_script( 'ee-reg-reports-js', 'regPerDay', $report_params ); |
|
535 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
536 | 536 | |
537 | 537 | return $report_ID; |
538 | 538 | } |
@@ -544,30 +544,30 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return string |
546 | 546 | */ |
547 | - private function _registrations_per_event_report( $period = '-1 month' ) { |
|
547 | + private function _registrations_per_event_report($period = '-1 month') { |
|
548 | 548 | |
549 | 549 | $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
550 | 550 | |
551 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report( $period ); |
|
552 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
551 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
552 | + EE_Registry::instance()->load_helper('Template'); |
|
553 | 553 | |
554 | 554 | $results = (array) $results; |
555 | 555 | $regs = array(); |
556 | 556 | $subtitle = ''; |
557 | 557 | |
558 | - if ( $results ) { |
|
558 | + if ($results) { |
|
559 | 559 | $column_titles = array(); |
560 | 560 | $tracker = 0; |
561 | - foreach ( $results as $result ) { |
|
561 | + foreach ($results as $result) { |
|
562 | 562 | $report_column_values = array(); |
563 | - foreach( $result as $property_name => $property_value ) { |
|
564 | - $property_value = $property_name == 'Registration_Event' ? wp_trim_words( $property_value, 4, '...' ) : (int) $property_value; |
|
563 | + foreach ($result as $property_name => $property_value) { |
|
564 | + $property_value = $property_name == 'Registration_Event' ? wp_trim_words($property_value, 4, '...') : (int) $property_value; |
|
565 | 565 | $report_column_values[] = $property_value; |
566 | - if ( $tracker === 0 ) { |
|
567 | - if ( $property_name == 'Registration_Event' ) { |
|
568 | - $column_titles[] = __( 'Event', 'event_espresso' ); |
|
566 | + if ($tracker === 0) { |
|
567 | + if ($property_name == 'Registration_Event') { |
|
568 | + $column_titles[] = __('Event', 'event_espresso'); |
|
569 | 569 | } else { |
570 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
570 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | } |
@@ -576,38 +576,38 @@ discard block |
||
576 | 576 | } |
577 | 577 | |
578 | 578 | //make sure the column_titles is pushed to the beginning of the array |
579 | - array_unshift( $regs, $column_titles ); |
|
579 | + array_unshift($regs, $column_titles); |
|
580 | 580 | |
581 | 581 | //setup the date range. |
582 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
583 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
584 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
585 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
582 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
583 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
584 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
585 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
586 | 586 | $subtitle = sprintf( |
587 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
588 | - $beginning_date->format( 'Y-m-d' ), |
|
589 | - $ending_date->format( 'Y-m-d' ) |
|
587 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
588 | + $beginning_date->format('Y-m-d'), |
|
589 | + $ending_date->format('Y-m-d') |
|
590 | 590 | ); |
591 | 591 | } |
592 | 592 | |
593 | - $report_title = __( 'Total Registrations per Event', 'event_espresso' ); |
|
593 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
594 | 594 | |
595 | 595 | $report_params = array( |
596 | 596 | 'title' => $report_title, |
597 | 597 | 'subtitle' => $subtitle, |
598 | 598 | 'id' => $report_ID, |
599 | 599 | 'regs' => $regs, |
600 | - 'noResults' => empty( $regs ), |
|
600 | + 'noResults' => empty($regs), |
|
601 | 601 | 'noRegsMsg' => sprintf( |
602 | 602 | __( |
603 | 603 | '%sThere are currently no registration records in the last month for this report.%s', |
604 | 604 | 'event_espresso' |
605 | 605 | ), |
606 | - '<h2>' . $report_title . '</h2><p>', |
|
606 | + '<h2>'.$report_title.'</h2><p>', |
|
607 | 607 | '</p>' |
608 | 608 | ), |
609 | 609 | ); |
610 | - wp_localize_script( 'ee-reg-reports-js', 'regPerEvent', $report_params ); |
|
610 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
611 | 611 | |
612 | 612 | return $report_ID; |
613 | 613 | } |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | * @return void |
622 | 622 | */ |
623 | 623 | protected function _registration_checkin_list_table() { |
624 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
625 | - $reg_id = isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : null; |
|
624 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
625 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
626 | 626 | $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
627 | 627 | $this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $reg->event_ID()), 'add-new-h2'); |
628 | 628 | |
@@ -636,15 +636,15 @@ discard block |
||
636 | 636 | 'desc' => __('This indicates the attendee has been checked out', 'event_espresso') |
637 | 637 | ) |
638 | 638 | ); |
639 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
639 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
640 | 640 | |
641 | 641 | |
642 | - $dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
643 | - $go_back_url = !empty( $reg_id ) ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id ), $this->_admin_base_url ) : ''; |
|
642 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
643 | + $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id), $this->_admin_base_url) : ''; |
|
644 | 644 | |
645 | - $this->_template_args['before_list_table'] = !empty( $reg_id ) && !empty( $dtt_id ) ? '<h2>' . sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">' . EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name() . '</span>', '<span id="checkin-dtt"><a href="' . $go_back_url . '">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time() . ' - ' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time() . '</a></span>', '<span id="checkin-event-name">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name') . '</span>' ) . '</h2>' : ''; |
|
646 | - $this->_template_args['list_table_hidden_fields'] = !empty( $reg_id ) ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
647 | - $this->_template_args['list_table_hidden_fields'] .= !empty( $dtt_id ) ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
645 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) ? '<h2>'.sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">'.EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name().'</span>', '<span id="checkin-dtt"><a href="'.$go_back_url.'">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time().' - '.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time().'</a></span>', '<span id="checkin-event-name">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name').'</span>').'</h2>' : ''; |
|
646 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : ''; |
|
647 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
648 | 648 | |
649 | 649 | $this->display_admin_list_table_page_with_no_sidebar(); |
650 | 650 | } |
@@ -657,24 +657,24 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function toggle_checkin_status() { |
659 | 659 | //first make sure we have the necessary data |
660 | - if ( !isset( $this->_req_data['_regid'] ) ) { |
|
661 | - EE_Error::add_error( __('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
660 | + if ( ! isset($this->_req_data['_regid'])) { |
|
661 | + EE_Error::add_error(__('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
662 | 662 | $this->_template_args['success'] = FALSE; |
663 | 663 | $this->_template_args['error'] = TRUE; |
664 | 664 | $this->_return_json(); |
665 | 665 | }; |
666 | 666 | |
667 | 667 | //do a nonce check cause we're not coming in from an normal route here. |
668 | - $nonce = isset( $this->_req_data['checkinnonce'] ) ? sanitize_text_field( $this->_req_data['checkinnonce'] ) : ''; |
|
668 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) : ''; |
|
669 | 669 | $nonce_ref = 'checkin_nonce'; |
670 | 670 | |
671 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
671 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
672 | 672 | |
673 | 673 | //beautiful! Made it this far so let's get the status. |
674 | 674 | $new_status = $this->_toggle_checkin_status(); |
675 | 675 | |
676 | 676 | //setup new class to return via ajax |
677 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' . $new_status; |
|
677 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'.$new_status; |
|
678 | 678 | $this->_template_args['success'] = TRUE; |
679 | 679 | $this->_return_json(); |
680 | 680 | } |
@@ -694,32 +694,32 @@ discard block |
||
694 | 694 | //first let's get the query args out of the way for the redirect |
695 | 695 | $query_args = array( |
696 | 696 | 'action' => 'event_registrations', |
697 | - 'event_id' => isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : NULL, |
|
698 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL |
|
697 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : NULL, |
|
698 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL |
|
699 | 699 | ); |
700 | 700 | $new_status = FALSE; |
701 | 701 | |
702 | 702 | // bulk action check in toggle |
703 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
703 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
704 | 704 | // cycle thru checkboxes |
705 | - while ( list( $REG_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
706 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
705 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
706 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
707 | 707 | $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
708 | 708 | } |
709 | 709 | |
710 | - } elseif ( isset( $this->_req_data['_regid'] ) ) { |
|
710 | + } elseif (isset($this->_req_data['_regid'])) { |
|
711 | 711 | //coming from ajax request |
712 | - $DTT_ID = isset( $this->_req_data['dttid'] ) ? $this->_req_data['dttid'] : NULL; |
|
712 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : NULL; |
|
713 | 713 | $query_args['DTT_ID'] = $DTT_ID; |
714 | 714 | $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
715 | 715 | } else { |
716 | - EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
716 | + EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
717 | 717 | } |
718 | 718 | |
719 | - if ( defined('DOING_AJAX' ) ) |
|
719 | + if (defined('DOING_AJAX')) |
|
720 | 720 | return $new_status; |
721 | 721 | |
722 | - $this->_redirect_after_action( FALSE,'', '', $query_args, TRUE ); |
|
722 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
723 | 723 | |
724 | 724 | } |
725 | 725 | |
@@ -735,11 +735,11 @@ discard block |
||
735 | 735 | */ |
736 | 736 | private function _toggle_checkin($REG_ID, $DTT_ID) { |
737 | 737 | $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
738 | - $new_status = $REG->toggle_checkin_status( $DTT_ID ); |
|
739 | - if ( $new_status !== FALSE ) { |
|
740 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID) ); |
|
738 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
739 | + if ($new_status !== FALSE) { |
|
740 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
741 | 741 | } else { |
742 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__ ); |
|
742 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__); |
|
743 | 743 | $new_status = FALSE; |
744 | 744 | } |
745 | 745 | return $new_status; |
@@ -755,28 +755,28 @@ discard block |
||
755 | 755 | protected function _delete_checkin_rows() { |
756 | 756 | $query_args = array( |
757 | 757 | 'action' => 'registration_checkins', |
758 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
759 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0 |
|
758 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
759 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0 |
|
760 | 760 | ); |
761 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
762 | - while ( list( $CHK_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
761 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
762 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
763 | 763 | $errors = 0; |
764 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID ) ) { |
|
764 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
765 | 765 | $errors++; |
766 | 766 | } |
767 | 767 | } |
768 | 768 | } else { |
769 | - EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
770 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
769 | + EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
770 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
771 | 771 | } |
772 | 772 | |
773 | - if ( $errors > 0 ) { |
|
774 | - EE_Error::add_error( sprintf( __('There were %d records that did not delete successfully', 'event_espresso'), $errors ), __FILE__, __FUNCTION__, __LINE__ ); |
|
773 | + if ($errors > 0) { |
|
774 | + EE_Error::add_error(sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), __FILE__, __FUNCTION__, __LINE__); |
|
775 | 775 | } else { |
776 | - EE_Error::add_success( __('Records were successfully deleted', 'event_espresso') ); |
|
776 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
777 | 777 | } |
778 | 778 | |
779 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
779 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | |
@@ -788,20 +788,20 @@ discard block |
||
788 | 788 | protected function _delete_checkin_row() { |
789 | 789 | $query_args = array( |
790 | 790 | 'action' => 'registration_checkins', |
791 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
792 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0 |
|
791 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
792 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0 |
|
793 | 793 | ); |
794 | 794 | |
795 | - if ( !empty( $this->_req_data['CHK_ID'] ) ) { |
|
796 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'] ) ) { |
|
797 | - EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
795 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
796 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
797 | + EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
798 | 798 | } else { |
799 | - EE_Error::add_success( __('Check-In record successfully deleted', 'event_espresso') ); |
|
799 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
800 | 800 | } |
801 | 801 | } else { |
802 | - EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | + EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
803 | 803 | } |
804 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
804 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -814,8 +814,8 @@ discard block |
||
814 | 814 | * @return void |
815 | 815 | */ |
816 | 816 | protected function _event_registrations_list_table() { |
817 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
818 | - $this->_admin_page_title .= isset( $this->_req_data['event_id'] ) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : ''; |
|
817 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
818 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : ''; |
|
819 | 819 | |
820 | 820 | $legend_items = array( |
821 | 821 | 'star-icon' => array( |
@@ -839,31 +839,31 @@ discard block |
||
839 | 839 | 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso') |
840 | 840 | ), |
841 | 841 | 'approved_status' => array( |
842 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
843 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
842 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
843 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
844 | 844 | ), |
845 | 845 | 'cancelled_status' => array( |
846 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
847 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
846 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
847 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
848 | 848 | ), |
849 | 849 | 'declined_status' => array( |
850 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
851 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
850 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
851 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
852 | 852 | ), |
853 | 853 | 'not_approved' => array( |
854 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
855 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
854 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
855 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
856 | 856 | ), |
857 | 857 | 'pending_status' => array( |
858 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
859 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
858 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
859 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
860 | 860 | )/**/ |
861 | 861 | ); |
862 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
862 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
863 | 863 | |
864 | - $event_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
865 | - $this->_template_args['before_list_table'] = !empty( $event_id ) ? '<h2>' . sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') ) . '</h2>' : ''; |
|
866 | - $this->_template_args['list_table_hidden_fields'] = !empty( $event_id ) ? '<input type="hidden" name="event_id" value="' . $event_id . '">' : ''; |
|
864 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
865 | + $this->_template_args['before_list_table'] = ! empty($event_id) ? '<h2>'.sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')).'</h2>' : ''; |
|
866 | + $this->_template_args['list_table_hidden_fields'] = ! empty($event_id) ? '<input type="hidden" name="event_id" value="'.$event_id.'">' : ''; |
|
867 | 867 | |
868 | 868 | $this->display_admin_list_table_page_with_no_sidebar(); |
869 | 869 | } |
@@ -877,15 +877,15 @@ discard block |
||
877 | 877 | * @access public |
878 | 878 | * @return array |
879 | 879 | */ |
880 | - public function get_event_attendees( $per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '' ) { |
|
880 | + public function get_event_attendees($per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '') { |
|
881 | 881 | |
882 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
883 | - require_once(EE_MODELS . 'EEM_Attendee.model.php'); |
|
882 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
883 | + require_once(EE_MODELS.'EEM_Attendee.model.php'); |
|
884 | 884 | //$ATT_MDL = EEM_Attendee::instance(); |
885 | 885 | |
886 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
887 | - $CAT_ID = isset($this->_req_data['category_id']) ? absint( $this->_req_data['category_id'] ) : FALSE; |
|
888 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
886 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
887 | + $CAT_ID = isset($this->_req_data['category_id']) ? absint($this->_req_data['category_id']) : FALSE; |
|
888 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
889 | 889 | |
890 | 890 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
891 | 891 | |
@@ -898,94 +898,94 @@ discard block |
||
898 | 898 | // $orderby = 'reg.REG_final_price'; |
899 | 899 | } |
900 | 900 | |
901 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
901 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
902 | 902 | |
903 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
904 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
903 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
904 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
905 | 905 | |
906 | 906 | |
907 | - $offset = ($current_page-1)*$per_page; |
|
908 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
909 | - $query_params = array(array('Event.status'=>array('IN', array_keys(EEM_Event::instance()->get_status_array())))); |
|
910 | - if ($EVT_ID){ |
|
911 | - $query_params[0]['EVT_ID']=$EVT_ID; |
|
907 | + $offset = ($current_page - 1) * $per_page; |
|
908 | + $limit = $count ? NULL : array($offset, $per_page); |
|
909 | + $query_params = array(array('Event.status'=>array('IN', array_keys(EEM_Event::instance()->get_status_array())))); |
|
910 | + if ($EVT_ID) { |
|
911 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
912 | 912 | } |
913 | - if($CAT_ID){ |
|
913 | + if ($CAT_ID) { |
|
914 | 914 | throw new EE_Error("You specified a Category Id for this query. Thats odd because we are now using terms and taxonomies. So did you mean the term taxonomy id o rthe term id?"); |
915 | 915 | } |
916 | 916 | |
917 | 917 | //if DTT is included we do multiple datetimes. |
918 | - if ( $DTT_ID ) { |
|
918 | + if ($DTT_ID) { |
|
919 | 919 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
920 | 920 | } |
921 | 921 | |
922 | 922 | //make sure we only have default where on the current regs |
923 | 923 | $query_params['default_where_conditions'] = 'this_model_only'; |
924 | 924 | |
925 | - $status_ids_array = apply_filters( 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) ); |
|
925 | + $status_ids_array = apply_filters('FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)); |
|
926 | 926 | |
927 | - $query_params[0]['STS_ID']= array('IN', $status_ids_array ); |
|
927 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
928 | 928 | |
929 | - if($trash){ |
|
930 | - $query_params[0]['Attendee.status']= EEM_CPT_Base::post_status_trashed; |
|
929 | + if ($trash) { |
|
930 | + $query_params[0]['Attendee.status'] = EEM_CPT_Base::post_status_trashed; |
|
931 | 931 | } |
932 | 932 | |
933 | - if ( isset( $this->_req_data['s'] ) ) { |
|
934 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
933 | + if (isset($this->_req_data['s'])) { |
|
934 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
935 | 935 | $query_params[0]['OR'] = array( |
936 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
937 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
938 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
939 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
940 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
941 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
942 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
943 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
944 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
945 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
946 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
947 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
948 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
949 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
950 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
951 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ) |
|
936 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
937 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
938 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
939 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
940 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
941 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
942 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
943 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
944 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
945 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
946 | + 'REG_final_price' => array('LIKE', $sstr), |
|
947 | + 'REG_code' => array('LIKE', $sstr), |
|
948 | + 'REG_count' => array('LIKE', $sstr), |
|
949 | + 'REG_group_size' => array('LIKE', $sstr), |
|
950 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
951 | + 'Ticket.TKT_description' => array('LIKE', $sstr) |
|
952 | 952 | ); |
953 | 953 | } |
954 | 954 | |
955 | 955 | $query_params['order_by'][$orderby] = $sort; |
956 | 956 | $query_params['limit'] = $limit; |
957 | - $query_params['force_join'] = array('Attendee');//force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
958 | - if($count){ |
|
959 | - $registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only' )); |
|
960 | - }else{ |
|
957 | + $query_params['force_join'] = array('Attendee'); //force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
958 | + if ($count) { |
|
959 | + $registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only')); |
|
960 | + } else { |
|
961 | 961 | $registrations = EEM_Registration::instance()->get_all($query_params); |
962 | 962 | |
963 | 963 | |
964 | 964 | // $registrations = EEM_Registration::instance(); |
965 | 965 | // $all_attendees = EEM_Attendee::instance()->get_event_attendees( $EVT_ID, $CAT_ID, $reg_status, $trash, $orderby, $sort, $limit, $output ); |
966 | - if ( isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration ) { |
|
966 | + if (isset($registrations[0]) && $registrations[0] instanceof EE_Registration) { |
|
967 | 967 | //EEH_Debug_Tools::printr( $all_attendees[0], '$all_attendees[0] <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
968 | 968 | // name |
969 | 969 | $first_registration = $registrations[0]; |
970 | 970 | $event_obj = $first_registration->event_obj(); |
971 | - if($event_obj){ |
|
971 | + if ($event_obj) { |
|
972 | 972 | $event_name = $first_registration->event_obj()->name(); |
973 | - $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?';//$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
973 | + $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?'; //$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
974 | 974 | // edit event link |
975 | - if ( $event_name != '' ) { |
|
976 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
977 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
978 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
975 | + if ($event_name != '') { |
|
976 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
977 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
978 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
979 | 979 | } |
980 | 980 | |
981 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
982 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
981 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
982 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
983 | 983 | |
984 | 984 | $this->_template_args['before_admin_page_content'] = ' |
985 | 985 | <div id="admin-page-header"> |
986 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
987 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
988 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
986 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
987 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
988 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
989 | 989 | </div> |
990 | 990 | '; |
991 | 991 | } |