@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once( EE_CLASSES . 'EE_Question.class.php'); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once(EE_CLASSES.'EE_Question.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Question extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -107,49 +107,49 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param null $timezone |
109 | 109 | */ |
110 | - protected function __construct( $timezone = NULL ) { |
|
111 | - $this->singular_item = __('Question','event_espresso'); |
|
112 | - $this->plural_item = __('Questions','event_espresso'); |
|
113 | - $this->_allowed_question_types=apply_filters( |
|
110 | + protected function __construct($timezone = NULL) { |
|
111 | + $this->singular_item = __('Question', 'event_espresso'); |
|
112 | + $this->plural_item = __('Questions', 'event_espresso'); |
|
113 | + $this->_allowed_question_types = apply_filters( |
|
114 | 114 | 'FHEE__EEM_Question__construct__allowed_question_types', |
115 | 115 | array( |
116 | - EEM_Question::QST_type_text =>__('Text','event_espresso'), |
|
117 | - EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'), |
|
118 | - EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'), |
|
119 | - EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'), |
|
120 | - EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'), |
|
121 | - EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'), |
|
122 | - EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'), |
|
123 | - EEM_Question::QST_type_date =>__('Date Picker','event_espresso'), |
|
124 | - EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ), |
|
125 | - EEM_Question::QST_type_email => __( 'Email', 'event_espresso' ), |
|
126 | - EEM_Question::QST_type_us_phone => __( 'USA - Format Phone', 'event_espresso' ), |
|
127 | - EEM_Question::QST_type_decimal => __( 'Number', 'event_espresso' ), |
|
128 | - EEM_Question::QST_type_int => __( 'Whole Number', 'event_espresso' ), |
|
129 | - EEM_Question::QST_type_url => __( 'URL', 'event_espresso' ), |
|
130 | - EEM_Question::QST_type_year => __( 'Year', 'event_espresso' ), |
|
131 | - EEM_Question::QST_type_multi_select => __( 'Multi Select', 'event_espresso' ) |
|
116 | + EEM_Question::QST_type_text =>__('Text', 'event_espresso'), |
|
117 | + EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'), |
|
118 | + EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'), |
|
119 | + EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'), |
|
120 | + EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'), |
|
121 | + EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'), |
|
122 | + EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'), |
|
123 | + EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'), |
|
124 | + EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'), |
|
125 | + EEM_Question::QST_type_email => __('Email', 'event_espresso'), |
|
126 | + EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'), |
|
127 | + EEM_Question::QST_type_decimal => __('Number', 'event_espresso'), |
|
128 | + EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'), |
|
129 | + EEM_Question::QST_type_url => __('URL', 'event_espresso'), |
|
130 | + EEM_Question::QST_type_year => __('Year', 'event_espresso'), |
|
131 | + EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso') |
|
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | $this->_question_descriptions = apply_filters( |
135 | 135 | 'FHEE__EEM_Question__construct__allowed_question_types', |
136 | 136 | array( |
137 | - EEM_Question::QST_type_text => __( 'A single line text input field', 'event_espresso' ), |
|
138 | - EEM_Question::QST_type_textarea => __( 'A multi line text input field', 'event_espresso' ), |
|
139 | - EEM_Question::QST_type_checkbox => __( 'Allows multiple preset options to be selected', 'event_espresso' ), |
|
140 | - EEM_Question::QST_type_radio => __( 'Allows a single preset option to be selected', 'event_espresso' ), |
|
141 | - EEM_Question::QST_type_dropdown => __( 'A dropdown that allows a single selection', 'event_espresso' ), |
|
142 | - EEM_Question::QST_type_state => __( 'A dropdown that lists states/provinces', 'event_espresso' ), |
|
143 | - EEM_Question::QST_type_country => __( 'A dropdown that lists countries', 'event_espresso' ), |
|
144 | - EEM_Question::QST_type_date => __( 'A popup calendar that allows date selections', 'event_espresso' ), |
|
145 | - EEM_Question::QST_type_html_textarea => __( 'A multi line text input field that allows HTML', 'event_espresso' ), |
|
146 | - EEM_Question::QST_type_email => __( 'A text field that must contain a valid Email address', 'event_espresso' ), |
|
147 | - EEM_Question::QST_type_us_phone => __( 'A text field that must contain a valid US phone number', 'event_espresso' ), |
|
148 | - EEM_Question::QST_type_decimal => __( 'A text field that allows number values with decimals', 'event_espresso' ), |
|
149 | - EEM_Question::QST_type_int => __( 'A text field that only allows whole numbers (no decimals)', 'event_espresso' ), |
|
150 | - EEM_Question::QST_type_url => __( 'A text field that must contain a valid URL', 'event_espresso' ), |
|
151 | - EEM_Question::QST_type_year => __( 'A dropdown that lists the last 100 years', 'event_espresso' ), |
|
152 | - EEM_Question::QST_type_multi_select => __( 'A dropdown that allows multiple selections', 'event_espresso' ) |
|
137 | + EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'), |
|
138 | + EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'), |
|
139 | + EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'), |
|
140 | + EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'), |
|
141 | + EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'), |
|
142 | + EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'), |
|
143 | + EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'), |
|
144 | + EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'), |
|
145 | + EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'), |
|
146 | + EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'), |
|
147 | + EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'), |
|
148 | + EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'), |
|
149 | + EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'), |
|
150 | + EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'), |
|
151 | + EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'), |
|
152 | + EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso') |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | $this->_question_type_categories = apply_filters( |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | ); |
178 | 178 | |
179 | 179 | $this->_tables = array( |
180 | - 'Question'=>new EE_Primary_Table('esp_question','QST_ID') |
|
180 | + 'Question'=>new EE_Primary_Table('esp_question', 'QST_ID') |
|
181 | 181 | ); |
182 | 182 | $this->_fields = array( |
183 | 183 | 'Question'=>array( |
184 | - 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')), |
|
185 | - 'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''), |
|
186 | - 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''), |
|
187 | - 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ), |
|
188 | - 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types), |
|
189 | - 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false), |
|
190 | - 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''), |
|
191 | - 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0), |
|
192 | - 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false), |
|
193 | - 'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso' ), false, EE_INF ), |
|
194 | - 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ), |
|
195 | - 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false) |
|
184 | + 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')), |
|
185 | + 'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''), |
|
186 | + 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''), |
|
187 | + 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL), |
|
188 | + 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types), |
|
189 | + 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false), |
|
190 | + 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''), |
|
191 | + 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0), |
|
192 | + 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false), |
|
193 | + 'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF), |
|
194 | + 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false), |
|
195 | + 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false) |
|
196 | 196 | ) |
197 | 197 | ); |
198 | 198 | $this->_model_relations = array( |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | 'Question_Group_Question'=>new EE_Has_Many_Relation() |
205 | 205 | ); |
206 | 206 | //this model is generally available for reading |
207 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
208 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
209 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
210 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
211 | - parent::__construct( $timezone ); |
|
207 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
208 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
209 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
210 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
211 | + parent::__construct($timezone); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * but they can be extended |
217 | 217 | * @return string[] |
218 | 218 | */ |
219 | - public function allowed_question_types(){ |
|
219 | + public function allowed_question_types() { |
|
220 | 220 | return $this->_allowed_question_types; |
221 | 221 | } |
222 | 222 | /** |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | * @param string $question_type one of EEM_Question::allowed_question_types( |
225 | 225 | * @return string[] like EEM_Question::allowed_question_types() |
226 | 226 | */ |
227 | - public function question_types_in_same_category( $question_type ) { |
|
228 | - $question_types = array( $question_type ); |
|
229 | - foreach( $this->_question_type_categories as $category => $question_types_in_category ) { |
|
230 | - if( in_array( $question_type, $question_types_in_category ) ) { |
|
227 | + public function question_types_in_same_category($question_type) { |
|
228 | + $question_types = array($question_type); |
|
229 | + foreach ($this->_question_type_categories as $category => $question_types_in_category) { |
|
230 | + if (in_array($question_type, $question_types_in_category)) { |
|
231 | 231 | $question_types = $question_types_in_category; |
232 | 232 | break; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) ); |
|
236 | + return array_intersect_key($this->allowed_question_types(), array_flip($question_types)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | * @param string $category one of the top-level keys of EEM_Question::question_type_categories() |
243 | 243 | * @return boolean |
244 | 244 | */ |
245 | - public function question_type_is_in_category( $question_type, $category ) { |
|
246 | - if( ! isset( $this->_question_type_categories[ $category ] ) ) { |
|
245 | + public function question_type_is_in_category($question_type, $category) { |
|
246 | + if ( ! isset($this->_question_type_categories[$category])) { |
|
247 | 247 | return false; |
248 | 248 | } |
249 | - return in_array( $question_type, $this->_question_type_categories[ $category ] ); |
|
249 | + return in_array($question_type, $this->_question_type_categories[$category]); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param string $system_question_group_id QSG_system |
264 | 264 | * @return array of system question names (QST_system) |
265 | 265 | */ |
266 | - public function allowed_system_questions_in_system_question_group( $system_question_group_id ) { |
|
266 | + public function allowed_system_questions_in_system_question_group($system_question_group_id) { |
|
267 | 267 | $question_system_ids = array(); |
268 | - switch( $system_question_group_id ) { |
|
268 | + switch ($system_question_group_id) { |
|
269 | 269 | case EEM_Question_Group::system_personal: |
270 | 270 | $question_system_ids = array( |
271 | 271 | EEM_Attendee::system_question_fname, |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | ); |
287 | 287 | break; |
288 | 288 | } |
289 | - return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id ); |
|
289 | + return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | * @param string $system_question_group_id QSG_system |
296 | 296 | * @return array of system question names (QST_system) |
297 | 297 | */ |
298 | - public function required_system_questions_in_system_question_group( $system_question_group_id ) { |
|
298 | + public function required_system_questions_in_system_question_group($system_question_group_id) { |
|
299 | 299 | $question_system_ids = null; |
300 | - switch( $system_question_group_id ) { |
|
300 | + switch ($system_question_group_id) { |
|
301 | 301 | case EEM_Question_Group::system_personal: |
302 | - $question_system_ids = array( |
|
302 | + $question_system_ids = array( |
|
303 | 303 | EEM_Attendee::system_question_fname, |
304 | 304 | EEM_Attendee::system_question_email, |
305 | 305 | ); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | default: |
308 | 308 | $question_system_ids = array(); |
309 | 309 | } |
310 | - return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id ); |
|
310 | + return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param $QST_system |
319 | 319 | * @return int of QST_ID for the question that corresponds to that QST_system |
320 | 320 | */ |
321 | - public function get_Question_ID_from_system_string( $QST_system ){ |
|
322 | - return $this->get_var( array( array( 'QST_system' => $QST_system ) ) ); |
|
321 | + public function get_Question_ID_from_system_string($QST_system) { |
|
322 | + return $this->get_var(array(array('QST_system' => $QST_system))); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function get_latest_question_order() { |
333 | 333 | $columns_to_select = array( |
334 | - 'max_order' => array("MAX(QST_order)","%d") |
|
334 | + 'max_order' => array("MAX(QST_order)", "%d") |
|
335 | 335 | ); |
336 | - $max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select ); |
|
336 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
337 | 337 | return $max[0]['max_order']; |
338 | 338 | } |
339 | 339 | |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | * @param string $system_question_value |
364 | 364 | * @return int|float |
365 | 365 | */ |
366 | - public function absolute_max_for_system_question( $system_question_value ) { |
|
366 | + public function absolute_max_for_system_question($system_question_value) { |
|
367 | 367 | $maxes = $this->system_question_maxes(); |
368 | - if( isset( $maxes[ $system_question_value ] ) ) { |
|
369 | - return $maxes[ $system_question_value ]; |
|
368 | + if (isset($maxes[$system_question_value])) { |
|
369 | + return $maxes[$system_question_value]; |
|
370 | 370 | } else { |
371 | 371 | return EE_INF; |
372 | 372 | } |
@@ -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 | /** |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | * |
25 | 25 | * ------------------------------------------------------------------------ |
26 | 26 | */ |
27 | -class EE_Year_Input extends EE_Select_Input{ |
|
27 | +class EE_Year_Input extends EE_Select_Input { |
|
28 | 28 | |
29 | - function __construct( $input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0 ){ |
|
30 | - if($four_digit_year){ |
|
29 | + function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) { |
|
30 | + if ($four_digit_year) { |
|
31 | 31 | $current_year_int = intval(date('Y')); |
32 | - }else{ |
|
32 | + } else { |
|
33 | 33 | $current_year_int = intval(date('y')); |
34 | 34 | } |
35 | 35 | $answer_options = array(); |
36 | - for( $start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++){ |
|
36 | + for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
37 | 37 | $answer_options[$start] = $start; |
38 | 38 | } |
39 | - parent::__construct( $answer_options, $input_settings ); |
|
39 | + parent::__construct($answer_options, $input_settings); |
|
40 | 40 | } |
41 | 41 | } |
@@ -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 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - public function __construct( $routing = TRUE ) { |
|
62 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
63 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
64 | - $this->_question_model= EEM_Question::instance(); |
|
65 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
66 | - parent::__construct( $routing ); |
|
61 | + public function __construct($routing = TRUE) { |
|
62 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
63 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
64 | + $this->_question_model = EEM_Question::instance(); |
|
65 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
66 | + parent::__construct($routing); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | protected function _set_page_routes() { |
100 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
100 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
101 | 101 | $this->_page_routes = array( |
102 | 102 | 'default' => array( |
103 | 103 | 'func' => '_questions_overview_list_table', |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | 'update_question' => array( |
120 | 120 | 'func' => '_insert_or_update_question', |
121 | - 'args' => array('new_question' => FALSE ), |
|
121 | + 'args' => array('new_question' => FALSE), |
|
122 | 122 | 'capability' => 'ee_edit_question', |
123 | 123 | 'obj_id' => $qst_id, |
124 | 124 | 'noheader' => TRUE, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
154 | 154 | ) |
155 | 155 | ), |
156 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
156 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
157 | 157 | 'require_nonce' => FALSE, |
158 | 158 | 'qtips' => array( |
159 | 159 | 'EE_Registration_Form_Tips' |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | 'filename' => 'registration_form_question_groups' |
173 | 173 | ), |
174 | 174 | ), |
175 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
175 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
176 | 176 | 'require_nonce' => FALSE |
177 | 177 | ), |
178 | 178 | |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | 'label' => __('Edit Question', 'event_espresso'), |
182 | 182 | 'order' => 15, |
183 | 183 | 'persistent' => FALSE, |
184 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
184 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
185 | 185 | ), |
186 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
186 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
187 | 187 | 'help_tabs' => array( |
188 | 188 | 'registration_form_edit_question_group_help_tab' => array( |
189 | 189 | 'title' => __('Edit Question', 'event_espresso'), |
190 | 190 | 'filename' => 'registration_form_edit_question' |
191 | 191 | ), |
192 | 192 | ), |
193 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
193 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
194 | 194 | 'require_nonce' => FALSE |
195 | 195 | ), |
196 | 196 | ); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | //none of the below group are currently used for Event Categories |
219 | 219 | protected function _add_feature_pointers() {} |
220 | 220 | public function load_scripts_styles() { |
221 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
221 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
222 | 222 | wp_enqueue_style('espresso_registration'); |
223 | 223 | } |
224 | 224 | public function admin_init() {} |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | |
235 | 235 | public function load_scripts_styles_add_question() { |
236 | 236 | $this->load_scripts_styles_forms(); |
237 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
238 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
237 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
238 | + wp_enqueue_script('espresso_registration_form_single'); |
|
239 | 239 | } |
240 | 240 | public function load_scripts_styles_edit_question() { |
241 | 241 | $this->load_scripts_styles_forms(); |
242 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
243 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
242 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
243 | + wp_enqueue_script('espresso_registration_form_single'); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
247 | 247 | |
248 | 248 | |
249 | 249 | public function recaptcha_info_help_tab() { |
250 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
250 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
251 | 251 | EEH_Template::display_template($template, array()); |
252 | 252 | } |
253 | 253 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | |
282 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
282 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
283 | 283 | $this->_views['trash'] = array( |
284 | 284 | 'slug' => 'trash', |
285 | 285 | 'label' => __('Trash', 'event_espresso'), |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function _questions_groups_preview() { |
299 | 299 | $this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso'); |
300 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />'; |
|
301 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
302 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
300 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />'; |
|
301 | + $this->_template_args['preview_text'] = '<strong>'.__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
302 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -310,58 +310,58 @@ discard block |
||
310 | 310 | * @param \EEM_Base $model |
311 | 311 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
312 | 312 | */ |
313 | - protected function _set_column_values_for(EEM_Base $model){ |
|
314 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
315 | - $set_column_values=array(); |
|
313 | + protected function _set_column_values_for(EEM_Base $model) { |
|
314 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
315 | + $set_column_values = array(); |
|
316 | 316 | |
317 | 317 | //some initial checks for proper values. |
318 | 318 | //if QST_admin_only, then no matter what QST_required is we disable. |
319 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
319 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
320 | 320 | $this->_req_data['QST_required'] = 0; |
321 | 321 | } |
322 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
322 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
323 | 323 | // basically if QSG_identifier is empty or not set |
324 | - if ( $fieldName == 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
325 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
326 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid(); |
|
324 | + if ($fieldName == 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
325 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
326 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid(); |
|
327 | 327 | // dd($set_column_values); |
328 | 328 | } |
329 | 329 | //if the admin label is blank, use a slug version of the question text |
330 | - else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
331 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
332 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
330 | + else if ($fieldName == 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
331 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
332 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | - else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
336 | + else if ($fieldName == 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
337 | 337 | $set_column_values[$fieldName] = 0; |
338 | 338 | } |
339 | 339 | |
340 | - else if ( $fieldName == 'QST_max' ) { |
|
340 | + else if ($fieldName == 'QST_max') { |
|
341 | 341 | $qst_system = EEM_Question::instance()->get_var( |
342 | 342 | array( |
343 | 343 | array( |
344 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
344 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
345 | 345 | ) |
346 | 346 | ), |
347 | 347 | 'QST_system' ); |
348 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
349 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
350 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
351 | - $set_column_values[ $fieldName ] = $max_max; |
|
348 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
349 | + if (empty($this->_req_data['QST_max']) || |
|
350 | + $this->_req_data['QST_max'] > $max_max) { |
|
351 | + $set_column_values[$fieldName] = $max_max; |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | 356 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
357 | - if( |
|
358 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
359 | - isset($this->_req_data[$fieldName] ) ){ |
|
360 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
357 | + if ( |
|
358 | + ! isset($set_column_values[$fieldName]) && |
|
359 | + isset($this->_req_data[$fieldName]) ) { |
|
360 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | } |
364 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
364 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -379,30 +379,30 @@ discard block |
||
379 | 379 | /** |
380 | 380 | * @param string $action |
381 | 381 | */ |
382 | - protected function _edit_question( $action= 'add' ) { |
|
383 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
384 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
382 | + protected function _edit_question($action = 'add') { |
|
383 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
384 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
385 | 385 | |
386 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
386 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
387 | 387 | // add PRC_ID to title if editing |
388 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
389 | - if($ID){ |
|
390 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
391 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
388 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
389 | + if ($ID) { |
|
390 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
391 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
392 | 392 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
393 | - }else{ |
|
394 | - $question= EE_Question::new_instance(); |
|
393 | + } else { |
|
394 | + $question = EE_Question::new_instance(); |
|
395 | 395 | $question->set_order_to_latest(); |
396 | 396 | $this->_set_add_edit_form_tags('insert_question'); |
397 | 397 | } |
398 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
399 | - $this->_template_args['QST_ID']=$ID; |
|
400 | - $this->_template_args['question']=$question; |
|
401 | - $this->_template_args['question_types']= $question_types; |
|
402 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
398 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
399 | + $this->_template_args['QST_ID'] = $ID; |
|
400 | + $this->_template_args['question'] = $question; |
|
401 | + $this->_template_args['question_types'] = $question_types; |
|
402 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
403 | 403 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
404 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
405 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
404 | + $this->_set_publish_post_box_vars('id', $ID); |
|
405 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
406 | 406 | |
407 | 407 | // the details template wrapper |
408 | 408 | $this->display_admin_page_with_sidebar(); |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | EE_Registry::instance()->load_helper('HTML'); |
418 | 418 | $descriptions = ''; |
419 | 419 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
420 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
420 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
421 | 421 | $descriptions .= EEH_HTML::p( |
422 | 422 | $question_type_description, |
423 | - 'question_type_description-' . $type, |
|
423 | + 'question_type_description-'.$type, |
|
424 | 424 | 'question_type_description description', |
425 | 425 | 'display:none;' |
426 | 426 | ); |
@@ -434,58 +434,58 @@ discard block |
||
434 | 434 | * @param bool|true $new_question |
435 | 435 | * @throws \EE_Error |
436 | 436 | */ |
437 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
438 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
439 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
440 | - if($new_question){ |
|
441 | - $ID=$this->_question_model->insert($set_column_values); |
|
437 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
438 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
439 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
440 | + if ($new_question) { |
|
441 | + $ID = $this->_question_model->insert($set_column_values); |
|
442 | 442 | $success = $ID ? true : false; |
443 | 443 | $action_desc = 'added'; |
444 | - }else{ |
|
445 | - $ID=absint($this->_req_data['QST_ID']); |
|
446 | - $pk=$this->_question_model->primary_key_name(); |
|
447 | - $wheres=array($pk=>$ID); |
|
444 | + } else { |
|
445 | + $ID = absint($this->_req_data['QST_ID']); |
|
446 | + $pk = $this->_question_model->primary_key_name(); |
|
447 | + $wheres = array($pk=>$ID); |
|
448 | 448 | unset($set_column_values[$pk]); |
449 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
450 | - $action_desc='updated'; |
|
449 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
450 | + $action_desc = 'updated'; |
|
451 | 451 | } |
452 | 452 | |
453 | - if ($ID){ |
|
453 | + if ($ID) { |
|
454 | 454 | //save the related options |
455 | 455 | //trash removed options, save old ones |
456 | 456 | //get list of all options |
457 | 457 | /** @type EE_Question $question */ |
458 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
459 | - $options=$question->options(); |
|
460 | - if(! empty($options)){ |
|
461 | - foreach($options as $option_ID=>$option){ |
|
462 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
463 | - if($option_req_index!==FALSE){ |
|
458 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
459 | + $options = $question->options(); |
|
460 | + if ( ! empty($options)) { |
|
461 | + foreach ($options as $option_ID=>$option) { |
|
462 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
463 | + if ($option_req_index !== FALSE) { |
|
464 | 464 | $option->save($this->_req_data['question_options'][$option_req_index]); |
465 | - }else{ |
|
465 | + } else { |
|
466 | 466 | //not found, remove it |
467 | 467 | $option->delete(); |
468 | 468 | } |
469 | 469 | } |
470 | 470 | } |
471 | 471 | //save new related options |
472 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
473 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
474 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
475 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
472 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
473 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
474 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
475 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
476 | 476 | } |
477 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
477 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
478 | 478 | $new_option->save(); |
479 | 479 | } |
480 | 480 | } |
481 | 481 | } |
482 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
483 | - if ( $success !== FALSE ) { |
|
484 | - $msg = $new_question ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
485 | - EE_Error::add_success( $msg ); |
|
482 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
483 | + if ($success !== FALSE) { |
|
484 | + $msg = $new_question ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
485 | + EE_Error::add_success($msg); |
|
486 | 486 | } |
487 | 487 | |
488 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
488 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | * @param int $ID of the question option to find |
499 | 499 | * @return int index in question_options array if successful, FALSE if unsuccessful |
500 | 500 | */ |
501 | - protected function _get_option_req_data_index($ID){ |
|
502 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
503 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
504 | - if(array_key_exists('QSO_ID',$option_data) && intval($option_data['QSO_ID'])==$ID){ |
|
501 | + protected function _get_option_req_data_index($ID) { |
|
502 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
503 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
504 | + if (array_key_exists('QSO_ID', $option_data) && intval($option_data['QSO_ID']) == $ID) { |
|
505 | 505 | return $num; |
506 | 506 | } |
507 | 507 | } |
@@ -523,25 +523,25 @@ discard block |
||
523 | 523 | * @param int $current_page |
524 | 524 | * @return array lik EEM_Base::get_all's $query_params parameter |
525 | 525 | */ |
526 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
526 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
527 | 527 | $query_params = array(); |
528 | - $offset=($current_page-1)*$per_page; |
|
529 | - $query_params['limit']=array($offset,$per_page); |
|
530 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
528 | + $offset = ($current_page - 1) * $per_page; |
|
529 | + $query_params['limit'] = array($offset, $per_page); |
|
530 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
531 | 531 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
532 | 532 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
533 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
534 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
535 | - if(! empty($search_string)){ |
|
536 | - if($model instanceof EEM_Question_Group){ |
|
537 | - $query_params[0]=array( |
|
533 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
534 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
535 | + if ( ! empty($search_string)) { |
|
536 | + if ($model instanceof EEM_Question_Group) { |
|
537 | + $query_params[0] = array( |
|
538 | 538 | 'OR'=>array( |
539 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
540 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
539 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
540 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
541 | 541 | ); |
542 | - }else{ |
|
543 | - $query_params[0]=array( |
|
544 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
542 | + } else { |
|
543 | + $query_params[0] = array( |
|
544 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
545 | 545 | ); |
546 | 546 | } |
547 | 547 | } |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | * @param bool|false $count |
590 | 590 | * @return \EE_Soft_Delete_Base_Class[]|int |
591 | 591 | */ |
592 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
592 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
593 | 593 | $QST = EEM_Question::instance(); |
594 | 594 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
595 | - if ($count){ |
|
596 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
595 | + if ($count) { |
|
596 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
597 | 597 | $results = $QST->count($where); |
598 | - }else{ |
|
598 | + } else { |
|
599 | 599 | $results = $QST->get_all($query_params); |
600 | 600 | } |
601 | 601 | return $results; |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | * @param bool|false $count |
611 | 611 | * @return \EE_Soft_Delete_Base_Class[]|int |
612 | 612 | */ |
613 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
614 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
615 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
616 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
613 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
614 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
615 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
616 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
617 | 617 | return $questions; |
618 | 618 | } |
619 | 619 | |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | * @param bool|false $count |
626 | 626 | * @return \EE_Soft_Delete_Base_Class[] |
627 | 627 | */ |
628 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
628 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
629 | 629 | /** @type EEM_Question_Group $questionGroupModel */ |
630 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
631 | - $query_params=$this->get_query_params( $questionGroupModel, $per_page, $current_page ); |
|
632 | - $questionGroups=$questionGroupModel->get_all($query_params);//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
630 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
631 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
632 | + $questionGroups = $questionGroupModel->get_all($query_params); //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
633 | 633 | return $questionGroups; |
634 | 634 | } |
635 | 635 | |
@@ -646,36 +646,36 @@ discard block |
||
646 | 646 | |
647 | 647 | $this->_template_args['values'] = $this->_yes_no_values; |
648 | 648 | |
649 | - $this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
650 | - $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': ''; |
|
649 | + $this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
650 | + $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : ''; |
|
651 | 651 | |
652 | - $this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : ''; |
|
653 | - $this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : ''; |
|
654 | - $this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500; |
|
652 | + $this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : ''; |
|
653 | + $this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : ''; |
|
654 | + $this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500; |
|
655 | 655 | |
656 | 656 | $this->_template_args['recaptcha_theme_options'] = array( |
657 | - array('id' => 'red','text'=> __('Red', 'event_espresso')), |
|
658 | - array('id' => 'white','text'=> __('White', 'event_espresso')), |
|
659 | - array('id' => 'blackglass','text'=> __('Blackglass', 'event_espresso')), |
|
660 | - array('id' => 'clean','text'=> __('Clean', 'event_espresso')) |
|
657 | + array('id' => 'red', 'text'=> __('Red', 'event_espresso')), |
|
658 | + array('id' => 'white', 'text'=> __('White', 'event_espresso')), |
|
659 | + array('id' => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')), |
|
660 | + array('id' => 'clean', 'text'=> __('Clean', 'event_espresso')) |
|
661 | 661 | ); |
662 | - $this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean'; |
|
662 | + $this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean'; |
|
663 | 663 | |
664 | 664 | $this->_template_args['recaptcha_language_options'] = array( |
665 | - array('id' => 'en','text'=> __('English', 'event_espresso')), |
|
666 | - array('id' => 'es','text'=> __('Spanish', 'event_espresso')), |
|
667 | - array('id' => 'nl','text'=> __('Dutch', 'event_espresso')), |
|
668 | - array('id' => 'fr','text'=> __('French', 'event_espresso')), |
|
669 | - array('id' => 'de','text'=> __('German', 'event_espresso')), |
|
670 | - array('id' => 'pt','text'=> __('Portuguese', 'event_espresso')), |
|
671 | - array('id' => 'ru','text'=> __('Russian', 'event_espresso')), |
|
672 | - array('id' => 'tr','text'=> __('Turkish', 'event_espresso')) |
|
665 | + array('id' => 'en', 'text'=> __('English', 'event_espresso')), |
|
666 | + array('id' => 'es', 'text'=> __('Spanish', 'event_espresso')), |
|
667 | + array('id' => 'nl', 'text'=> __('Dutch', 'event_espresso')), |
|
668 | + array('id' => 'fr', 'text'=> __('French', 'event_espresso')), |
|
669 | + array('id' => 'de', 'text'=> __('German', 'event_espresso')), |
|
670 | + array('id' => 'pt', 'text'=> __('Portuguese', 'event_espresso')), |
|
671 | + array('id' => 'ru', 'text'=> __('Russian', 'event_espresso')), |
|
672 | + array('id' => 'tr', 'text'=> __('Turkish', 'event_espresso')) |
|
673 | 673 | ); |
674 | - $this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
674 | + $this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
675 | 675 | |
676 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
677 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
678 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE ); |
|
676 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
677 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
678 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE); |
|
679 | 679 | $this->display_admin_page_with_sidebar(); |
680 | 680 | } |
681 | 681 |