Completed
Branch ADMIN-REFRESH (794602)
by
unknown
05:30 queued 03:17
created
core/db_classes/EE_Question.class.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
337 337
     {
338
-        if (! $this->ID()) {
338
+        if ( ! $this->ID()) {
339 339
             return array();
340 340
         }
341 341
         $query_params = array();
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             ),
510 510
             $input_constructor_args
511 511
         );
512
-        if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
512
+        if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
513 513
             $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
514 514
         }
515 515
         // has this question been answered ?
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
                     $this,
648 648
                     $input_constructor_args
649 649
                 );
650
-                if (! $default_input) {
650
+                if ( ! $default_input) {
651 651
                     $default_input = new EE_Text_Input($input_constructor_args);
652 652
                 }
653 653
                 $result = $default_input;
Please login to merge, or discard this patch.
Indentation   +664 added lines, -664 removed lines patch added patch discarded remove patch
@@ -14,668 +14,668 @@
 block discarded – undo
14 14
 class EE_Question extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param array  $props_n_values          incoming values
20
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
21
-     *                                        used.)
22
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
23
-     *                                        date_format and the second value is the time format
24
-     * @return EE_Question
25
-     */
26
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
27
-    {
28
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
29
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
30
-    }
31
-
32
-
33
-    /**
34
-     * @param array  $props_n_values  incoming values from the database
35
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
36
-     *                                the website will be used.
37
-     * @return EE_Question
38
-     */
39
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
40
-    {
41
-        return new self($props_n_values, true, $timezone);
42
-    }
43
-
44
-
45
-    /**
46
-     *        Set    Question display text
47
-     *
48
-     * @access        public
49
-     * @param string $QST_display_text
50
-     */
51
-    public function set_display_text($QST_display_text = '')
52
-    {
53
-        $this->set('QST_display_text', $QST_display_text);
54
-    }
55
-
56
-
57
-    /**
58
-     *        Set    Question admin text
59
-     *
60
-     * @access        public
61
-     * @param        string $QST_admin_label
62
-     */
63
-    public function set_admin_label($QST_admin_label = '')
64
-    {
65
-        $this->set('QST_admin_label', $QST_admin_label);
66
-    }
67
-
68
-
69
-    /**
70
-     *        Set    system name
71
-     *
72
-     * @access        public
73
-     * @param        mixed $QST_system
74
-     */
75
-    public function set_system_ID($QST_system = '')
76
-    {
77
-        $this->set('QST_system', $QST_system);
78
-    }
79
-
80
-
81
-    /**
82
-     *        Set    question's type
83
-     *
84
-     * @access        public
85
-     * @param        string $QST_type
86
-     */
87
-    public function set_question_type($QST_type = '')
88
-    {
89
-        $this->set('QST_type', $QST_type);
90
-    }
91
-
92
-
93
-    /**
94
-     *        Sets whether this question must be answered when presented in a form
95
-     *
96
-     * @access        public
97
-     * @param        bool $QST_required
98
-     */
99
-    public function set_required($QST_required = false)
100
-    {
101
-        $this->set('QST_required', $QST_required);
102
-    }
103
-
104
-
105
-    /**
106
-     *        Set    Question display text
107
-     *
108
-     * @access        public
109
-     * @param        string $QST_required_text
110
-     */
111
-    public function set_required_text($QST_required_text = '')
112
-    {
113
-        $this->set('QST_required_text', $QST_required_text);
114
-    }
115
-
116
-
117
-    /**
118
-     *        Sets the order of this question when placed in a sequence of questions
119
-     *
120
-     * @access        public
121
-     * @param        int $QST_order
122
-     */
123
-    public function set_order($QST_order = 0)
124
-    {
125
-        $this->set('QST_order', $QST_order);
126
-    }
127
-
128
-
129
-    /**
130
-     *        Sets whether the question is admin-only
131
-     *
132
-     * @access        public
133
-     * @param        bool $QST_admin_only
134
-     */
135
-    public function set_admin_only($QST_admin_only = false)
136
-    {
137
-        $this->set('QST_admin_only', $QST_admin_only);
138
-    }
139
-
140
-
141
-    /**
142
-     *        Sets the wordpress user ID on the question
143
-     *
144
-     * @access        public
145
-     * @param        int $QST_wp_user
146
-     */
147
-    public function set_wp_user($QST_wp_user = 1)
148
-    {
149
-        $this->set('QST_wp_user', $QST_wp_user);
150
-    }
151
-
152
-
153
-    /**
154
-     *        Sets whether the question has been deleted
155
-     *        (we use this boolean instead of actually
156
-     *        deleting it because when users delete this question
157
-     *        they really want to remove the question from future
158
-     *        forms, BUT keep their old answers which depend
159
-     *        on this record actually existing.
160
-     *
161
-     * @access        public
162
-     * @param    bool $QST_deleted
163
-     */
164
-    public function set_deleted($QST_deleted = false)
165
-    {
166
-        $this->set('QST_deleted', $QST_deleted);
167
-    }
168
-
169
-
170
-    /**
171
-     * returns the text for displaying the question to users
172
-     *
173
-     * @access public
174
-     * @return string
175
-     */
176
-    public function display_text()
177
-    {
178
-        return $this->get('QST_display_text');
179
-    }
180
-
181
-
182
-    /**
183
-     * returns the text for the administrative label
184
-     *
185
-     * @access public
186
-     * @return string
187
-     */
188
-    public function admin_label()
189
-    {
190
-        return $this->get('QST_admin_label');
191
-    }
192
-
193
-
194
-    /**
195
-     * returns the attendee column name for this question
196
-     *
197
-     * @access public
198
-     * @return string
199
-     */
200
-    public function system_ID()
201
-    {
202
-        return $this->get('QST_system');
203
-    }
204
-
205
-
206
-    /**
207
-     * returns either a string of 'text', 'textfield', etc.
208
-     *
209
-     * @access public
210
-     * @return boolean
211
-     */
212
-    public function required()
213
-    {
214
-        return $this->get('QST_required');
215
-    }
216
-
217
-
218
-    /**
219
-     * returns the text which should be displayed when a user
220
-     * doesn't answer this question in a form
221
-     *
222
-     * @access public
223
-     * @return string
224
-     */
225
-    public function required_text()
226
-    {
227
-        return $this->get('QST_required_text');
228
-    }
229
-
230
-
231
-    /**
232
-     * returns the type of this question
233
-     *
234
-     * @access public
235
-     * @return string
236
-     */
237
-    public function type()
238
-    {
239
-        return $this->get('QST_type');
240
-    }
241
-
242
-
243
-    /**
244
-     * returns an integer showing where this question should
245
-     * be placed in a sequence of questions
246
-     *
247
-     * @access public
248
-     * @return int
249
-     */
250
-    public function order()
251
-    {
252
-        return $this->get('QST_order');
253
-    }
254
-
255
-
256
-    /**
257
-     * returns whether this question should only appears to admins,
258
-     * or to everyone
259
-     *
260
-     * @access public
261
-     * @return boolean
262
-     */
263
-    public function admin_only()
264
-    {
265
-        return $this->get('QST_admin_only');
266
-    }
267
-
268
-
269
-    /**
270
-     * returns the id the wordpress user who created this question
271
-     *
272
-     * @access public
273
-     * @return int
274
-     */
275
-    public function wp_user()
276
-    {
277
-        return $this->get('QST_wp_user');
278
-    }
279
-
280
-
281
-    /**
282
-     * returns whether this question has been marked as 'deleted'
283
-     *
284
-     * @access public
285
-     * @return boolean
286
-     */
287
-    public function deleted()
288
-    {
289
-        return $this->get('QST_deleted');
290
-    }
291
-
292
-
293
-    /**
294
-     * Gets an array of related EE_Answer  to this EE_Question
295
-     *
296
-     * @return EE_Answer[]
297
-     */
298
-    public function answers()
299
-    {
300
-        return $this->get_many_related('Answer');
301
-    }
302
-
303
-
304
-    /**
305
-     * Boolean check for if there are answers on this question in th db
306
-     *
307
-     * @return boolean true = has answers, false = no answers.
308
-     */
309
-    public function has_answers()
310
-    {
311
-        return $this->count_related('Answer') > 0 ? true : false;
312
-    }
313
-
314
-
315
-    /**
316
-     * gets an array of EE_Question_Group which relate to this question
317
-     *
318
-     * @return EE_Question_Group[]
319
-     */
320
-    public function question_groups()
321
-    {
322
-        return $this->get_many_related('Question_Group');
323
-    }
324
-
325
-
326
-    /**
327
-     * Returns all the options for this question. By default, it returns only the not-yet-deleted ones.
328
-     *
329
-     * @param boolean      $notDeletedOptionsOnly            1
330
-     *                                                       whether to return ALL options, or only the ones which have
331
-     *                                                       not yet been deleleted
332
-     * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
333
-     *                                                       we want to usually only show non-deleted options AND the
334
-     *                                                       value that was selected for the answer, whether it was
335
-     *                                                       trashed or not.
336
-     * @return EE_Question_Option[]
337
-     */
338
-    public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
339
-    {
340
-        if (! $this->ID()) {
341
-            return array();
342
-        }
343
-        $query_params = array();
344
-        if ($selected_value_to_always_include) {
345
-            if (is_array($selected_value_to_always_include)) {
346
-                $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
347
-            } else {
348
-                $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
349
-            }
350
-        }
351
-        if ($notDeletedOptionsOnly) {
352
-            $query_params[0]['OR*options-query']['QSO_deleted'] = false;
353
-        }
354
-        // order by QSO_order
355
-        $query_params['order_by'] = array('QSO_order' => 'ASC');
356
-        return $this->get_many_related('Question_Option', $query_params);
357
-    }
358
-
359
-
360
-    /**
361
-     * returns an array of EE_Question_Options which relate to this question
362
-     *
363
-     * @return \EE_Question_Option[]
364
-     */
365
-    public function temp_options()
366
-    {
367
-        return $this->_model_relations['Question_Option'];
368
-    }
369
-
370
-
371
-    /**
372
-     * Adds an option for this question. Note: if the option were previously associated with a different
373
-     * Question, that relationship will be overwritten.
374
-     *
375
-     * @param EE_Question_Option $option
376
-     * @return boolean success
377
-     */
378
-    public function add_option(EE_Question_Option $option)
379
-    {
380
-        return $this->_add_relation_to($option, 'Question_Option');
381
-    }
382
-
383
-
384
-    /**
385
-     * Adds an option directly to this question without saving to the db
386
-     *
387
-     * @param EE_Question_Option $option
388
-     * @return boolean success
389
-     */
390
-    public function add_temp_option(EE_Question_Option $option)
391
-    {
392
-        $this->_model_relations['Question_Option'][] = $option;
393
-        return true;
394
-    }
395
-
396
-
397
-    /**
398
-     * Marks the option as deleted.
399
-     *
400
-     * @param EE_Question_Option $option
401
-     * @return boolean success
402
-     */
403
-    public function remove_option(EE_Question_Option $option)
404
-    {
405
-        return $this->_remove_relation_to($option, 'Question_Option');
406
-    }
407
-
408
-
409
-    /**
410
-     * @return bool
411
-     */
412
-    public function is_system_question()
413
-    {
414
-        $system_ID = $this->get('QST_system');
415
-        return ! empty($system_ID) ? true : false;
416
-    }
417
-
418
-
419
-    /**
420
-     * The purpose of this method is set the question order this question order to be the max out of all questions
421
-     *
422
-     * @access public
423
-     * @return void
424
-     */
425
-    public function set_order_to_latest()
426
-    {
427
-        $latest_order = $this->get_model()->get_latest_question_order();
428
-        $latest_order++;
429
-        $this->set('QST_order', $latest_order);
430
-    }
431
-
432
-
433
-    /**
434
-     * Retrieves the list of allowed question types from the model.
435
-     *
436
-     * @return string[]
437
-     */
438
-    private function _allowed_question_types()
439
-    {
440
-        $questionModel = $this->get_model();
441
-        /* @var $questionModel EEM_Question */
442
-        return $questionModel->allowed_question_types();
443
-    }
444
-
445
-    /**
446
-     * Duplicates this question and its question options
447
-     *
448
-     * @return \EE_Question
449
-     */
450
-    public function duplicate($options = array())
451
-    {
452
-        $new_question = clone $this;
453
-        $new_question->set('QST_ID', null);
454
-        $new_question->set_display_text(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
455
-        $new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
456
-        $new_question->set_system_ID(null);
457
-        $new_question->set_wp_user(get_current_user_id());
458
-        // if we're duplicating a trashed question, assume we don't want the new one to be trashed
459
-        $new_question->set_deleted(false);
460
-        $success = $new_question->save();
461
-        if ($success) {
462
-            // we don't totally want to duplicate the question options, because we want them to be for the NEW question
463
-            foreach ($this->options() as $question_option) {
464
-                $question_option->duplicate(array('QST_ID' => $new_question->ID()));
465
-            }
466
-            return $new_question;
467
-        } else {
468
-            return null;
469
-        }
470
-    }
471
-
472
-    /**
473
-     * Returns the question's maximum allowed response size
474
-     *
475
-     * @return int|float
476
-     */
477
-    public function max()
478
-    {
479
-        return $this->get('QST_max');
480
-    }
481
-
482
-    /**
483
-     * Sets the question's maximum allowed response size
484
-     *
485
-     * @param int|float $new_max
486
-     * @return void
487
-     */
488
-    public function set_max($new_max)
489
-    {
490
-        $this->set('QST_max', $new_max);
491
-    }
492
-
493
-
494
-    /**
495
-     * Creates a form input from this question which can be used in HTML forms
496
-     *
497
-     * @param EE_Registration $registration
498
-     * @param EE_Answer       $answer
499
-     * @param array           $input_constructor_args
500
-     * @return EE_Form_Input_Base
501
-     */
502
-    public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array())
503
-    {
504
-        $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
505
-
506
-        $input_constructor_args = array_merge(
507
-            array(
508
-                'required'                          => $this->required() ? true : false,
509
-                'html_label_text'                   => $this->display_text(),
510
-                'required_validation_error_message' => $this->required_text(),
511
-            ),
512
-            $input_constructor_args
513
-        );
514
-        if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
515
-            $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
516
-        }
517
-        // has this question been answered ?
518
-        if (
519
-            $answer instanceof EE_Answer
520
-            && $answer->value() !== ''
521
-        ) {
522
-            // answer gets htmlspecialchars called on it, undo that please
523
-            // because the form input's display strategy may call esc_attr too
524
-            // which also does html special characters
525
-            $values_with_html_special_chars = $answer->value();
526
-            if (is_array($values_with_html_special_chars)) {
527
-                $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
528
-            } else {
529
-                $default_value = htmlspecialchars_decode($values_with_html_special_chars);
530
-            }
531
-            $input_constructor_args['default'] = $default_value;
532
-        }
533
-        $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
534
-        if (
535
-            in_array(
536
-                $this->type(),
537
-                EEM_Question::instance()->questionTypesWithMaxLength(),
538
-                true
539
-            )
540
-        ) {
541
-            $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
542
-                null,
543
-                min($max_max_for_question, $this->max())
544
-            );
545
-        }
546
-        $input_constructor_args = apply_filters(
547
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
548
-            $input_constructor_args,
549
-            $registration,
550
-            $this,
551
-            $answer
552
-        );
553
-
554
-        $result = null;
555
-        switch ($this->type()) {
556
-            // Text
557
-            case EEM_Question::QST_type_text:
558
-                $result = new EE_Text_Input($input_constructor_args);
559
-                break;
560
-            // Textarea
561
-            case EEM_Question::QST_type_textarea:
562
-                $result = new EE_Text_Area_Input($input_constructor_args);
563
-                break;
564
-            // Radio Buttons
565
-            case EEM_Question::QST_type_radio:
566
-                $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
567
-                break;
568
-            // Dropdown
569
-            case EEM_Question::QST_type_dropdown:
570
-                $result = new EE_Select_Input($this->options(), $input_constructor_args);
571
-                break;
572
-            // State Dropdown
573
-            case EEM_Question::QST_type_state:
574
-                $state_options = apply_filters(
575
-                    'FHEE__EE_Question__generate_form_input__state_options',
576
-                    null,
577
-                    $this,
578
-                    $registration,
579
-                    $answer
580
-                );
581
-                $result = new EE_State_Select_Input($state_options, $input_constructor_args);
582
-                break;
583
-            // Country Dropdown
584
-            case EEM_Question::QST_type_country:
585
-                $country_options = apply_filters(
586
-                    'FHEE__EE_Question__generate_form_input__country_options',
587
-                    null,
588
-                    $this,
589
-                    $registration,
590
-                    $answer
591
-                );
592
-                $result = new EE_Country_Select_Input($country_options, $input_constructor_args);
593
-                break;
594
-            // Checkboxes
595
-            case EEM_Question::QST_type_checkbox:
596
-                $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
597
-                break;
598
-            // Date
599
-            case EEM_Question::QST_type_date:
600
-                $result = new EE_Datepicker_Input($input_constructor_args);
601
-                break;
602
-            case EEM_Question::QST_type_html_textarea:
603
-                $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
604
-                $result = new EE_Text_Area_Input($input_constructor_args);
605
-                $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
606
-                break;
607
-            case EEM_Question::QST_type_email:
608
-                    $result = new EE_Email_Input($input_constructor_args);
609
-                break;
610
-            // Email confirm
611
-            case EEM_Question::QST_type_email_confirm:
612
-                $result = new EE_Email_Confirm_Input($input_constructor_args);
613
-                break;
614
-            case EEM_Question::QST_type_us_phone:
615
-                $result = new EE_Phone_Input($input_constructor_args);
616
-                break;
617
-            case EEM_Question::QST_type_int:
618
-                $result = new EE_Integer_Input($input_constructor_args);
619
-                break;
620
-            case EEM_Question::QST_type_decimal:
621
-                $result = new EE_Float_Input($input_constructor_args);
622
-                break;
623
-            case EEM_Question::QST_type_url:
624
-                $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy');
625
-                $result = new EE_Text_Input($input_constructor_args);
626
-                break;
627
-            case EEM_Question::QST_type_year:
628
-                $result = new EE_Year_Input(
629
-                    $input_constructor_args,
630
-                    apply_filters(
631
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
632
-                        true,
633
-                        $this
634
-                    ),
635
-                    apply_filters(
636
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
637
-                        100,
638
-                        $this
639
-                    ),
640
-                    apply_filters(
641
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
642
-                        100,
643
-                        $this
644
-                    )
645
-                );
646
-                break;
647
-            case EEM_Question::QST_type_multi_select:
648
-                $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
649
-                break;
650
-            // fallback
651
-            default:
652
-                $default_input = apply_filters(
653
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default',
654
-                    null,
655
-                    $this->type(),
656
-                    $this,
657
-                    $input_constructor_args
658
-                );
659
-                if (! $default_input) {
660
-                    $default_input = new EE_Text_Input($input_constructor_args);
661
-                }
662
-                $result = $default_input;
663
-        }
664
-        return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
665
-    }
666
-
667
-
668
-    /**
669
-     * Returns whether or not this question type should have question option entries
670
-     *
671
-     * @return bool
672
-     */
673
-    public function should_have_question_options()
674
-    {
675
-        return in_array(
676
-            $this->type(),
677
-            $this->_model->question_types_with_options(),
678
-            true
679
-        );
680
-    }
17
+	/**
18
+	 *
19
+	 * @param array  $props_n_values          incoming values
20
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
21
+	 *                                        used.)
22
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
23
+	 *                                        date_format and the second value is the time format
24
+	 * @return EE_Question
25
+	 */
26
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
27
+	{
28
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
29
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
30
+	}
31
+
32
+
33
+	/**
34
+	 * @param array  $props_n_values  incoming values from the database
35
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
36
+	 *                                the website will be used.
37
+	 * @return EE_Question
38
+	 */
39
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
40
+	{
41
+		return new self($props_n_values, true, $timezone);
42
+	}
43
+
44
+
45
+	/**
46
+	 *        Set    Question display text
47
+	 *
48
+	 * @access        public
49
+	 * @param string $QST_display_text
50
+	 */
51
+	public function set_display_text($QST_display_text = '')
52
+	{
53
+		$this->set('QST_display_text', $QST_display_text);
54
+	}
55
+
56
+
57
+	/**
58
+	 *        Set    Question admin text
59
+	 *
60
+	 * @access        public
61
+	 * @param        string $QST_admin_label
62
+	 */
63
+	public function set_admin_label($QST_admin_label = '')
64
+	{
65
+		$this->set('QST_admin_label', $QST_admin_label);
66
+	}
67
+
68
+
69
+	/**
70
+	 *        Set    system name
71
+	 *
72
+	 * @access        public
73
+	 * @param        mixed $QST_system
74
+	 */
75
+	public function set_system_ID($QST_system = '')
76
+	{
77
+		$this->set('QST_system', $QST_system);
78
+	}
79
+
80
+
81
+	/**
82
+	 *        Set    question's type
83
+	 *
84
+	 * @access        public
85
+	 * @param        string $QST_type
86
+	 */
87
+	public function set_question_type($QST_type = '')
88
+	{
89
+		$this->set('QST_type', $QST_type);
90
+	}
91
+
92
+
93
+	/**
94
+	 *        Sets whether this question must be answered when presented in a form
95
+	 *
96
+	 * @access        public
97
+	 * @param        bool $QST_required
98
+	 */
99
+	public function set_required($QST_required = false)
100
+	{
101
+		$this->set('QST_required', $QST_required);
102
+	}
103
+
104
+
105
+	/**
106
+	 *        Set    Question display text
107
+	 *
108
+	 * @access        public
109
+	 * @param        string $QST_required_text
110
+	 */
111
+	public function set_required_text($QST_required_text = '')
112
+	{
113
+		$this->set('QST_required_text', $QST_required_text);
114
+	}
115
+
116
+
117
+	/**
118
+	 *        Sets the order of this question when placed in a sequence of questions
119
+	 *
120
+	 * @access        public
121
+	 * @param        int $QST_order
122
+	 */
123
+	public function set_order($QST_order = 0)
124
+	{
125
+		$this->set('QST_order', $QST_order);
126
+	}
127
+
128
+
129
+	/**
130
+	 *        Sets whether the question is admin-only
131
+	 *
132
+	 * @access        public
133
+	 * @param        bool $QST_admin_only
134
+	 */
135
+	public function set_admin_only($QST_admin_only = false)
136
+	{
137
+		$this->set('QST_admin_only', $QST_admin_only);
138
+	}
139
+
140
+
141
+	/**
142
+	 *        Sets the wordpress user ID on the question
143
+	 *
144
+	 * @access        public
145
+	 * @param        int $QST_wp_user
146
+	 */
147
+	public function set_wp_user($QST_wp_user = 1)
148
+	{
149
+		$this->set('QST_wp_user', $QST_wp_user);
150
+	}
151
+
152
+
153
+	/**
154
+	 *        Sets whether the question has been deleted
155
+	 *        (we use this boolean instead of actually
156
+	 *        deleting it because when users delete this question
157
+	 *        they really want to remove the question from future
158
+	 *        forms, BUT keep their old answers which depend
159
+	 *        on this record actually existing.
160
+	 *
161
+	 * @access        public
162
+	 * @param    bool $QST_deleted
163
+	 */
164
+	public function set_deleted($QST_deleted = false)
165
+	{
166
+		$this->set('QST_deleted', $QST_deleted);
167
+	}
168
+
169
+
170
+	/**
171
+	 * returns the text for displaying the question to users
172
+	 *
173
+	 * @access public
174
+	 * @return string
175
+	 */
176
+	public function display_text()
177
+	{
178
+		return $this->get('QST_display_text');
179
+	}
180
+
181
+
182
+	/**
183
+	 * returns the text for the administrative label
184
+	 *
185
+	 * @access public
186
+	 * @return string
187
+	 */
188
+	public function admin_label()
189
+	{
190
+		return $this->get('QST_admin_label');
191
+	}
192
+
193
+
194
+	/**
195
+	 * returns the attendee column name for this question
196
+	 *
197
+	 * @access public
198
+	 * @return string
199
+	 */
200
+	public function system_ID()
201
+	{
202
+		return $this->get('QST_system');
203
+	}
204
+
205
+
206
+	/**
207
+	 * returns either a string of 'text', 'textfield', etc.
208
+	 *
209
+	 * @access public
210
+	 * @return boolean
211
+	 */
212
+	public function required()
213
+	{
214
+		return $this->get('QST_required');
215
+	}
216
+
217
+
218
+	/**
219
+	 * returns the text which should be displayed when a user
220
+	 * doesn't answer this question in a form
221
+	 *
222
+	 * @access public
223
+	 * @return string
224
+	 */
225
+	public function required_text()
226
+	{
227
+		return $this->get('QST_required_text');
228
+	}
229
+
230
+
231
+	/**
232
+	 * returns the type of this question
233
+	 *
234
+	 * @access public
235
+	 * @return string
236
+	 */
237
+	public function type()
238
+	{
239
+		return $this->get('QST_type');
240
+	}
241
+
242
+
243
+	/**
244
+	 * returns an integer showing where this question should
245
+	 * be placed in a sequence of questions
246
+	 *
247
+	 * @access public
248
+	 * @return int
249
+	 */
250
+	public function order()
251
+	{
252
+		return $this->get('QST_order');
253
+	}
254
+
255
+
256
+	/**
257
+	 * returns whether this question should only appears to admins,
258
+	 * or to everyone
259
+	 *
260
+	 * @access public
261
+	 * @return boolean
262
+	 */
263
+	public function admin_only()
264
+	{
265
+		return $this->get('QST_admin_only');
266
+	}
267
+
268
+
269
+	/**
270
+	 * returns the id the wordpress user who created this question
271
+	 *
272
+	 * @access public
273
+	 * @return int
274
+	 */
275
+	public function wp_user()
276
+	{
277
+		return $this->get('QST_wp_user');
278
+	}
279
+
280
+
281
+	/**
282
+	 * returns whether this question has been marked as 'deleted'
283
+	 *
284
+	 * @access public
285
+	 * @return boolean
286
+	 */
287
+	public function deleted()
288
+	{
289
+		return $this->get('QST_deleted');
290
+	}
291
+
292
+
293
+	/**
294
+	 * Gets an array of related EE_Answer  to this EE_Question
295
+	 *
296
+	 * @return EE_Answer[]
297
+	 */
298
+	public function answers()
299
+	{
300
+		return $this->get_many_related('Answer');
301
+	}
302
+
303
+
304
+	/**
305
+	 * Boolean check for if there are answers on this question in th db
306
+	 *
307
+	 * @return boolean true = has answers, false = no answers.
308
+	 */
309
+	public function has_answers()
310
+	{
311
+		return $this->count_related('Answer') > 0 ? true : false;
312
+	}
313
+
314
+
315
+	/**
316
+	 * gets an array of EE_Question_Group which relate to this question
317
+	 *
318
+	 * @return EE_Question_Group[]
319
+	 */
320
+	public function question_groups()
321
+	{
322
+		return $this->get_many_related('Question_Group');
323
+	}
324
+
325
+
326
+	/**
327
+	 * Returns all the options for this question. By default, it returns only the not-yet-deleted ones.
328
+	 *
329
+	 * @param boolean      $notDeletedOptionsOnly            1
330
+	 *                                                       whether to return ALL options, or only the ones which have
331
+	 *                                                       not yet been deleleted
332
+	 * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
333
+	 *                                                       we want to usually only show non-deleted options AND the
334
+	 *                                                       value that was selected for the answer, whether it was
335
+	 *                                                       trashed or not.
336
+	 * @return EE_Question_Option[]
337
+	 */
338
+	public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
339
+	{
340
+		if (! $this->ID()) {
341
+			return array();
342
+		}
343
+		$query_params = array();
344
+		if ($selected_value_to_always_include) {
345
+			if (is_array($selected_value_to_always_include)) {
346
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
347
+			} else {
348
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
349
+			}
350
+		}
351
+		if ($notDeletedOptionsOnly) {
352
+			$query_params[0]['OR*options-query']['QSO_deleted'] = false;
353
+		}
354
+		// order by QSO_order
355
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
356
+		return $this->get_many_related('Question_Option', $query_params);
357
+	}
358
+
359
+
360
+	/**
361
+	 * returns an array of EE_Question_Options which relate to this question
362
+	 *
363
+	 * @return \EE_Question_Option[]
364
+	 */
365
+	public function temp_options()
366
+	{
367
+		return $this->_model_relations['Question_Option'];
368
+	}
369
+
370
+
371
+	/**
372
+	 * Adds an option for this question. Note: if the option were previously associated with a different
373
+	 * Question, that relationship will be overwritten.
374
+	 *
375
+	 * @param EE_Question_Option $option
376
+	 * @return boolean success
377
+	 */
378
+	public function add_option(EE_Question_Option $option)
379
+	{
380
+		return $this->_add_relation_to($option, 'Question_Option');
381
+	}
382
+
383
+
384
+	/**
385
+	 * Adds an option directly to this question without saving to the db
386
+	 *
387
+	 * @param EE_Question_Option $option
388
+	 * @return boolean success
389
+	 */
390
+	public function add_temp_option(EE_Question_Option $option)
391
+	{
392
+		$this->_model_relations['Question_Option'][] = $option;
393
+		return true;
394
+	}
395
+
396
+
397
+	/**
398
+	 * Marks the option as deleted.
399
+	 *
400
+	 * @param EE_Question_Option $option
401
+	 * @return boolean success
402
+	 */
403
+	public function remove_option(EE_Question_Option $option)
404
+	{
405
+		return $this->_remove_relation_to($option, 'Question_Option');
406
+	}
407
+
408
+
409
+	/**
410
+	 * @return bool
411
+	 */
412
+	public function is_system_question()
413
+	{
414
+		$system_ID = $this->get('QST_system');
415
+		return ! empty($system_ID) ? true : false;
416
+	}
417
+
418
+
419
+	/**
420
+	 * The purpose of this method is set the question order this question order to be the max out of all questions
421
+	 *
422
+	 * @access public
423
+	 * @return void
424
+	 */
425
+	public function set_order_to_latest()
426
+	{
427
+		$latest_order = $this->get_model()->get_latest_question_order();
428
+		$latest_order++;
429
+		$this->set('QST_order', $latest_order);
430
+	}
431
+
432
+
433
+	/**
434
+	 * Retrieves the list of allowed question types from the model.
435
+	 *
436
+	 * @return string[]
437
+	 */
438
+	private function _allowed_question_types()
439
+	{
440
+		$questionModel = $this->get_model();
441
+		/* @var $questionModel EEM_Question */
442
+		return $questionModel->allowed_question_types();
443
+	}
444
+
445
+	/**
446
+	 * Duplicates this question and its question options
447
+	 *
448
+	 * @return \EE_Question
449
+	 */
450
+	public function duplicate($options = array())
451
+	{
452
+		$new_question = clone $this;
453
+		$new_question->set('QST_ID', null);
454
+		$new_question->set_display_text(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
455
+		$new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
456
+		$new_question->set_system_ID(null);
457
+		$new_question->set_wp_user(get_current_user_id());
458
+		// if we're duplicating a trashed question, assume we don't want the new one to be trashed
459
+		$new_question->set_deleted(false);
460
+		$success = $new_question->save();
461
+		if ($success) {
462
+			// we don't totally want to duplicate the question options, because we want them to be for the NEW question
463
+			foreach ($this->options() as $question_option) {
464
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
465
+			}
466
+			return $new_question;
467
+		} else {
468
+			return null;
469
+		}
470
+	}
471
+
472
+	/**
473
+	 * Returns the question's maximum allowed response size
474
+	 *
475
+	 * @return int|float
476
+	 */
477
+	public function max()
478
+	{
479
+		return $this->get('QST_max');
480
+	}
481
+
482
+	/**
483
+	 * Sets the question's maximum allowed response size
484
+	 *
485
+	 * @param int|float $new_max
486
+	 * @return void
487
+	 */
488
+	public function set_max($new_max)
489
+	{
490
+		$this->set('QST_max', $new_max);
491
+	}
492
+
493
+
494
+	/**
495
+	 * Creates a form input from this question which can be used in HTML forms
496
+	 *
497
+	 * @param EE_Registration $registration
498
+	 * @param EE_Answer       $answer
499
+	 * @param array           $input_constructor_args
500
+	 * @return EE_Form_Input_Base
501
+	 */
502
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array())
503
+	{
504
+		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
505
+
506
+		$input_constructor_args = array_merge(
507
+			array(
508
+				'required'                          => $this->required() ? true : false,
509
+				'html_label_text'                   => $this->display_text(),
510
+				'required_validation_error_message' => $this->required_text(),
511
+			),
512
+			$input_constructor_args
513
+		);
514
+		if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
515
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
516
+		}
517
+		// has this question been answered ?
518
+		if (
519
+			$answer instanceof EE_Answer
520
+			&& $answer->value() !== ''
521
+		) {
522
+			// answer gets htmlspecialchars called on it, undo that please
523
+			// because the form input's display strategy may call esc_attr too
524
+			// which also does html special characters
525
+			$values_with_html_special_chars = $answer->value();
526
+			if (is_array($values_with_html_special_chars)) {
527
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
528
+			} else {
529
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
530
+			}
531
+			$input_constructor_args['default'] = $default_value;
532
+		}
533
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
534
+		if (
535
+			in_array(
536
+				$this->type(),
537
+				EEM_Question::instance()->questionTypesWithMaxLength(),
538
+				true
539
+			)
540
+		) {
541
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
542
+				null,
543
+				min($max_max_for_question, $this->max())
544
+			);
545
+		}
546
+		$input_constructor_args = apply_filters(
547
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
548
+			$input_constructor_args,
549
+			$registration,
550
+			$this,
551
+			$answer
552
+		);
553
+
554
+		$result = null;
555
+		switch ($this->type()) {
556
+			// Text
557
+			case EEM_Question::QST_type_text:
558
+				$result = new EE_Text_Input($input_constructor_args);
559
+				break;
560
+			// Textarea
561
+			case EEM_Question::QST_type_textarea:
562
+				$result = new EE_Text_Area_Input($input_constructor_args);
563
+				break;
564
+			// Radio Buttons
565
+			case EEM_Question::QST_type_radio:
566
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
567
+				break;
568
+			// Dropdown
569
+			case EEM_Question::QST_type_dropdown:
570
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
571
+				break;
572
+			// State Dropdown
573
+			case EEM_Question::QST_type_state:
574
+				$state_options = apply_filters(
575
+					'FHEE__EE_Question__generate_form_input__state_options',
576
+					null,
577
+					$this,
578
+					$registration,
579
+					$answer
580
+				);
581
+				$result = new EE_State_Select_Input($state_options, $input_constructor_args);
582
+				break;
583
+			// Country Dropdown
584
+			case EEM_Question::QST_type_country:
585
+				$country_options = apply_filters(
586
+					'FHEE__EE_Question__generate_form_input__country_options',
587
+					null,
588
+					$this,
589
+					$registration,
590
+					$answer
591
+				);
592
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
593
+				break;
594
+			// Checkboxes
595
+			case EEM_Question::QST_type_checkbox:
596
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
597
+				break;
598
+			// Date
599
+			case EEM_Question::QST_type_date:
600
+				$result = new EE_Datepicker_Input($input_constructor_args);
601
+				break;
602
+			case EEM_Question::QST_type_html_textarea:
603
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
604
+				$result = new EE_Text_Area_Input($input_constructor_args);
605
+				$result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
606
+				break;
607
+			case EEM_Question::QST_type_email:
608
+					$result = new EE_Email_Input($input_constructor_args);
609
+				break;
610
+			// Email confirm
611
+			case EEM_Question::QST_type_email_confirm:
612
+				$result = new EE_Email_Confirm_Input($input_constructor_args);
613
+				break;
614
+			case EEM_Question::QST_type_us_phone:
615
+				$result = new EE_Phone_Input($input_constructor_args);
616
+				break;
617
+			case EEM_Question::QST_type_int:
618
+				$result = new EE_Integer_Input($input_constructor_args);
619
+				break;
620
+			case EEM_Question::QST_type_decimal:
621
+				$result = new EE_Float_Input($input_constructor_args);
622
+				break;
623
+			case EEM_Question::QST_type_url:
624
+				$input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy');
625
+				$result = new EE_Text_Input($input_constructor_args);
626
+				break;
627
+			case EEM_Question::QST_type_year:
628
+				$result = new EE_Year_Input(
629
+					$input_constructor_args,
630
+					apply_filters(
631
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
632
+						true,
633
+						$this
634
+					),
635
+					apply_filters(
636
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
637
+						100,
638
+						$this
639
+					),
640
+					apply_filters(
641
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
642
+						100,
643
+						$this
644
+					)
645
+				);
646
+				break;
647
+			case EEM_Question::QST_type_multi_select:
648
+				$result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
649
+				break;
650
+			// fallback
651
+			default:
652
+				$default_input = apply_filters(
653
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default',
654
+					null,
655
+					$this->type(),
656
+					$this,
657
+					$input_constructor_args
658
+				);
659
+				if (! $default_input) {
660
+					$default_input = new EE_Text_Input($input_constructor_args);
661
+				}
662
+				$result = $default_input;
663
+		}
664
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
665
+	}
666
+
667
+
668
+	/**
669
+	 * Returns whether or not this question type should have question option entries
670
+	 *
671
+	 * @return bool
672
+	 */
673
+	public function should_have_question_options()
674
+	{
675
+		return in_array(
676
+			$this->type(),
677
+			$this->_model->question_types_with_options(),
678
+			true
679
+		);
680
+	}
681 681
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Term_Relationship.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -10,23 +10,23 @@
 block discarded – undo
10 10
 class EE_Term_Relationship extends EE_Base_Class
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $props_n_values
15
-     * @return EE_Term_Relationship
16
-     */
17
-    public static function new_instance($props_n_values = array())
18
-    {
19
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
20
-        return $has_object ? $has_object : new self($props_n_values);
21
-    }
13
+	/**
14
+	 * @param array $props_n_values
15
+	 * @return EE_Term_Relationship
16
+	 */
17
+	public static function new_instance($props_n_values = array())
18
+	{
19
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
20
+		return $has_object ? $has_object : new self($props_n_values);
21
+	}
22 22
 
23 23
 
24
-    /**
25
-     * @param array $props_n_values
26
-     * @return EE_Term_Relationship
27
-     */
28
-    public static function new_instance_from_db($props_n_values = array())
29
-    {
30
-        return new self($props_n_values, true);
31
-    }
24
+	/**
25
+	 * @param array $props_n_values
26
+	 * @return EE_Term_Relationship
27
+	 */
28
+	public static function new_instance_from_db($props_n_values = array())
29
+	{
30
+		return new self($props_n_values, true);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Answer.class.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -10,144 +10,144 @@
 block discarded – undo
10 10
 class EE_Answer extends EE_Base_Class
11 11
 {
12 12
 
13
-    /**
14
-     *
15
-     * @param array $props_n_values
16
-     * @return EE_Answer
17
-     */
18
-    public static function new_instance($props_n_values = array())
19
-    {
20
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
-        return $has_object ? $has_object : new self($props_n_values);
22
-    }
23
-
24
-
25
-    /**
26
-     *
27
-     * @param array $props_n_values
28
-     * @return EE_Answer
29
-     */
30
-    public static function new_instance_from_db($props_n_values = array())
31
-    {
32
-        return new self($props_n_values, true);
33
-    }
34
-
35
-
36
-    /**
37
-     *    Set Question ID
38
-     *
39
-     * @access        public
40
-     * @param int $QST_ID
41
-     */
42
-    public function set_question($QST_ID = 0)
43
-    {
44
-        $this->set('QST_ID', $QST_ID);
45
-    }
46
-
47
-
48
-    /**
49
-     *    Set Registration ID
50
-     *
51
-     * @access        public
52
-     * @param int $REG_ID
53
-     */
54
-    public function set_registration($REG_ID = 0)
55
-    {
56
-        $this->set('REG_ID', $REG_ID);
57
-    }
58
-
59
-
60
-    /**
61
-     *    Set Answer value
62
-     *
63
-     * @access        public
64
-     * @param mixed $ANS_value
65
-     */
66
-    public function set_value($ANS_value = '')
67
-    {
68
-        $this->set('ANS_value', $ANS_value);
69
-    }
70
-
71
-
72
-    /**
73
-     *    get Attendee First Name
74
-     *
75
-     * @access        public
76
-     * @return        int
77
-     */
78
-    public function registration_ID()
79
-    {
80
-        return $this->get('REG_ID');
81
-    }
82
-
83
-
84
-    /**
85
-     *    get Attendee Last Name
86
-     *
87
-     * @access        public
88
-     * @return        int
89
-     */
90
-    public function question_ID()
91
-    {
92
-        return $this->get('QST_ID');
93
-    }
94
-
95
-
96
-    /**
97
-     *    get Attendee Address
98
-     *
99
-     * @access        public
100
-     * @return        string
101
-     */
102
-    public function value()
103
-    {
104
-        return $this->get('ANS_value');
105
-    }
106
-
107
-
108
-    /**
109
-     * Gets a pretty form of the value (mostly applies to answers that have multiple answers)
110
-     *
111
-     * @param null $schema
112
-     * @return string
113
-     */
114
-    public function pretty_value($schema = null)
115
-    {
116
-        return $this->get_pretty('ANS_value', $schema);
117
-    }
118
-
119
-
120
-    /**
121
-     * Echoes out a pretty value (even for multi-choice options)
122
-     *
123
-     * @param string $schema
124
-     */
125
-    public function e_value($schema = null)
126
-    {
127
-        $this->e('ANS_value', $schema);
128
-    }
129
-
130
-
131
-    /**
132
-     * Gets the related EE_Question to this EE_Answer
133
-     *
134
-     * @return EE_Question
135
-     */
136
-    public function question()
137
-    {
138
-        return $this->get_first_related('Question');
139
-    }
140
-
141
-
142
-    /**
143
-     * Gets the related EE_Registration to this EE_Answer
144
-     *
145
-     * @return EE_Registration
146
-     */
147
-    public function registration()
148
-    {
149
-        return $this->get_first_related('Registration');
150
-    }
13
+	/**
14
+	 *
15
+	 * @param array $props_n_values
16
+	 * @return EE_Answer
17
+	 */
18
+	public static function new_instance($props_n_values = array())
19
+	{
20
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
+		return $has_object ? $has_object : new self($props_n_values);
22
+	}
23
+
24
+
25
+	/**
26
+	 *
27
+	 * @param array $props_n_values
28
+	 * @return EE_Answer
29
+	 */
30
+	public static function new_instance_from_db($props_n_values = array())
31
+	{
32
+		return new self($props_n_values, true);
33
+	}
34
+
35
+
36
+	/**
37
+	 *    Set Question ID
38
+	 *
39
+	 * @access        public
40
+	 * @param int $QST_ID
41
+	 */
42
+	public function set_question($QST_ID = 0)
43
+	{
44
+		$this->set('QST_ID', $QST_ID);
45
+	}
46
+
47
+
48
+	/**
49
+	 *    Set Registration ID
50
+	 *
51
+	 * @access        public
52
+	 * @param int $REG_ID
53
+	 */
54
+	public function set_registration($REG_ID = 0)
55
+	{
56
+		$this->set('REG_ID', $REG_ID);
57
+	}
58
+
59
+
60
+	/**
61
+	 *    Set Answer value
62
+	 *
63
+	 * @access        public
64
+	 * @param mixed $ANS_value
65
+	 */
66
+	public function set_value($ANS_value = '')
67
+	{
68
+		$this->set('ANS_value', $ANS_value);
69
+	}
70
+
71
+
72
+	/**
73
+	 *    get Attendee First Name
74
+	 *
75
+	 * @access        public
76
+	 * @return        int
77
+	 */
78
+	public function registration_ID()
79
+	{
80
+		return $this->get('REG_ID');
81
+	}
82
+
83
+
84
+	/**
85
+	 *    get Attendee Last Name
86
+	 *
87
+	 * @access        public
88
+	 * @return        int
89
+	 */
90
+	public function question_ID()
91
+	{
92
+		return $this->get('QST_ID');
93
+	}
94
+
95
+
96
+	/**
97
+	 *    get Attendee Address
98
+	 *
99
+	 * @access        public
100
+	 * @return        string
101
+	 */
102
+	public function value()
103
+	{
104
+		return $this->get('ANS_value');
105
+	}
106
+
107
+
108
+	/**
109
+	 * Gets a pretty form of the value (mostly applies to answers that have multiple answers)
110
+	 *
111
+	 * @param null $schema
112
+	 * @return string
113
+	 */
114
+	public function pretty_value($schema = null)
115
+	{
116
+		return $this->get_pretty('ANS_value', $schema);
117
+	}
118
+
119
+
120
+	/**
121
+	 * Echoes out a pretty value (even for multi-choice options)
122
+	 *
123
+	 * @param string $schema
124
+	 */
125
+	public function e_value($schema = null)
126
+	{
127
+		$this->e('ANS_value', $schema);
128
+	}
129
+
130
+
131
+	/**
132
+	 * Gets the related EE_Question to this EE_Answer
133
+	 *
134
+	 * @return EE_Question
135
+	 */
136
+	public function question()
137
+	{
138
+		return $this->get_first_related('Question');
139
+	}
140
+
141
+
142
+	/**
143
+	 * Gets the related EE_Registration to this EE_Answer
144
+	 *
145
+	 * @return EE_Registration
146
+	 */
147
+	public function registration()
148
+	{
149
+		return $this->get_first_related('Registration');
150
+	}
151 151
 }
152 152
 
153 153
 /* End of file EE_Answer.class.php */
Please login to merge, or discard this patch.
core/db_classes/EE_Extra_Join.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
 class EE_Extra_Join extends EE_Base_Class
13 13
 {
14 14
 
15
-    /**
16
-     * @param array $props_n_values
17
-     * @param null  $timezone
18
-     * @return EE_Extra_Join|mixed
19
-     */
20
-    public static function new_instance($props_n_values = array(), $timezone = null)
21
-    {
22
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
-    }
15
+	/**
16
+	 * @param array $props_n_values
17
+	 * @param null  $timezone
18
+	 * @return EE_Extra_Join|mixed
19
+	 */
20
+	public static function new_instance($props_n_values = array(), $timezone = null)
21
+	{
22
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * @param array $props_n_values
29
-     * @param null  $timezone
30
-     * @return EE_Extra_Join
31
-     */
32
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
-    {
34
-        return new self($props_n_values, true, $timezone);
35
-    }
27
+	/**
28
+	 * @param array $props_n_values
29
+	 * @param null  $timezone
30
+	 * @return EE_Extra_Join
31
+	 */
32
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
+	{
34
+		return new self($props_n_values, true, $timezone);
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Currency_Payment_Method.class.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -14,40 +14,40 @@
 block discarded – undo
14 14
 class EE_Currency_Payment_Method extends EE_Base_Class
15 15
 {
16 16
 
17
-    /** Currency to Payment Method Link ID @var CPM_ID */
18
-    protected $_CPM_ID = null;
19
-    /** Currency Code @var CUR_code */
20
-    protected $_CUR_code = null;
21
-    /** Payment Method ID @var PMD_ID */
22
-    protected $_PMD_ID = null;
23
-    protected $_Payment_Method;
24
-    protected $_Currency;
17
+	/** Currency to Payment Method Link ID @var CPM_ID */
18
+	protected $_CPM_ID = null;
19
+	/** Currency Code @var CUR_code */
20
+	protected $_CUR_code = null;
21
+	/** Payment Method ID @var PMD_ID */
22
+	protected $_PMD_ID = null;
23
+	protected $_Payment_Method;
24
+	protected $_Currency;
25 25
 
26 26
 
27
-    /**
28
-     *
29
-     * @param array  $props_n_values          incoming values
30
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
31
-     *                                        used.)
32
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
33
-     *                                        date_format and the second value is the time format
34
-     * @return EE_Attendee
35
-     */
36
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
37
-    {
38
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
39
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
40
-    }
27
+	/**
28
+	 *
29
+	 * @param array  $props_n_values          incoming values
30
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
31
+	 *                                        used.)
32
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
33
+	 *                                        date_format and the second value is the time format
34
+	 * @return EE_Attendee
35
+	 */
36
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
37
+	{
38
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
39
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @param array  $props_n_values  incoming values from the database
45
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
46
-     *                                the website will be used.
47
-     * @return EE_Attendee
48
-     */
49
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
50
-    {
51
-        return new self($props_n_values, true, $timezone);
52
-    }
43
+	/**
44
+	 * @param array  $props_n_values  incoming values from the database
45
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
46
+	 *                                the website will be used.
47
+	 * @return EE_Attendee
48
+	 */
49
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
50
+	{
51
+		return new self($props_n_values, true, $timezone);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Group.class.php 1 patch
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -12,280 +12,280 @@
 block discarded – undo
12 12
 class EE_Question_Group extends EE_Soft_Delete_Base_Class
13 13
 {
14 14
 
15
-    /**
16
-     * @param array $props_n_values
17
-     * @return EE_Question_Group|mixed
18
-     */
19
-    public static function new_instance($props_n_values = array())
20
-    {
21
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
22
-        return $has_object ? $has_object : new self($props_n_values);
23
-    }
24
-
25
-
26
-    /**
27
-     * @param array $props_n_values
28
-     * @return EE_Question_Group
29
-     */
30
-    public static function new_instance_from_db($props_n_values = array())
31
-    {
32
-        return new self($props_n_values, true);
33
-    }
34
-
35
-
36
-    /**
37
-     * gets the question group's name
38
-     *
39
-     * @access public
40
-     * @param bool $pretty
41
-     * @return string
42
-     */
43
-    public function name($pretty = false)
44
-    {
45
-        return $pretty ? $this->get_pretty('QSG_name') : $this->get('QSG_name');
46
-    }
47
-
48
-
49
-    /**
50
-     * Gets the question group's internal name
51
-     *
52
-     * @access public
53
-     * @return string
54
-     */
55
-    public function identifier()
56
-    {
57
-        return $this->get('QSG_identifier');
58
-    }
59
-
60
-
61
-    /**
62
-     * Gets the question group's description
63
-     *
64
-     * @access public
65
-     * @param bool $pretty
66
-     * @return string
67
-     */
68
-    public function desc($pretty = false)
69
-    {
70
-        return $pretty ? $this->get_pretty('QSG_desc') : $this->get('QSG_desc');
71
-    }
72
-
73
-
74
-    /**
75
-     * Gets the question group's order number in a sequence
76
-     * of other question groups
77
-     *
78
-     * @access public
79
-     * @return int
80
-     */
81
-    public function order()
82
-    {
83
-        return $this->get('QSG_order');
84
-    }
85
-
86
-
87
-    /**
88
-     * Returns whether to show the group's name on the frontend
89
-     *
90
-     * @access public
91
-     * @return boolean
92
-     */
93
-    public function show_group_name()
94
-    {
95
-        return $this->get('QSG_show_group_name');
96
-    }
97
-
98
-
99
-    /**
100
-     * Returns whether to show the group's description
101
-     * on the frontend
102
-     *
103
-     * @access public
104
-     * @return boolean
105
-     */
106
-    public function show_group_desc()
107
-    {
108
-        return $this->get('QSG_show_group_desc');
109
-    }
110
-
111
-
112
-    /**
113
-     * Returns whether this is a 'system group' (meaning
114
-     * a question group integral to the system, whose questions
115
-     * relate to the attendee table)
116
-     *
117
-     * @access public
118
-     * @return int
119
-     */
120
-    public function system_group()
121
-    {
122
-        return $this->get('QSG_system');
123
-    }
124
-
125
-
126
-    /**
127
-     * get the author of the question group.
128
-     *
129
-     * @since 4.5.0
130
-     *
131
-     * @return int
132
-     */
133
-    public function wp_user()
134
-    {
135
-        return $this->get('QSG_wp_user');
136
-    }
137
-
138
-
139
-    /**
140
-     * Returns whether this question group has
141
-     * been deleted
142
-     *
143
-     * @access public
144
-     * @return boolean
145
-     */
146
-    public function deleted()
147
-    {
148
-        return $this->get('QST_deleted');
149
-    }
150
-
151
-
152
-    /**
153
-     * Gets an array of questions with questions IN the group at the start of the array and questions NOT in the group
154
-     * at the end of the array.  Questions in the group are ordered by Question_Group_Question.QGQ_order and questions
155
-     * NOT in the group are ordered by Question.QGQ_order
156
-     *
157
-     * @return EE_Question[]
158
-     */
159
-    public function questions_in_and_not_in_group()
160
-    {
161
-        $questions_in_group = $this->questions();
162
-        $exclude_question_ids = ! empty($questions_in_group) ? array_keys($questions_in_group) : array();
163
-        $questions_not_in_group = $this->questions_not_in_group($exclude_question_ids);
164
-        return $questions_in_group + $questions_not_in_group;
165
-    }
166
-
167
-
168
-    /**
169
-     * Gets all the questions which are part of this question group (ordered Question_Group_Question.QGQ_order)
170
-     *
171
-     * @param array $query_params
172
-     * @return EE_Question[]
173
-     */
174
-    public function questions($query_params = array())
175
-    {
176
-        $query_params = ! empty($query_params) ? $query_params
177
-            : array('order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'));
178
-        return $this->ID() ? $this->get_many_related('Question', $query_params) : array();
179
-    }
180
-
181
-
182
-    /**
183
-     * Gets all the questions which are NOT part of this question group.
184
-     *
185
-     * @param  mixed $question_IDS_in_group if empty array then all questions returned.  if FALSE then we first get
186
-     *                                      questions in this group and exclude them from questions get all. IF empty
187
-     *                                      array then we just return all questions.
188
-     * @return EE_Question[]
189
-     */
190
-    public function questions_not_in_group($question_IDS_in_group = false)
191
-    {
192
-        if ($question_IDS_in_group === false) {
193
-            $questions = $this->questions();
194
-            $question_IDS_in_group = ! empty($questions) ? array_keys($questions) : array();
195
-        }
196
-        $_where = ! empty($question_IDS_in_group) ? array('QST_ID' => array('not_in', $question_IDS_in_group))
197
-            : array();
198
-
199
-        return EEM_Question::instance()->get_all(array($_where, 'order_by' => array('QST_ID' => 'ASC')));
200
-    }
201
-
202
-
203
-    /**
204
-     * Gets all events which are related to this question group
205
-     *
206
-     * @return EE_Event[]
207
-     */
208
-    public function events()
209
-    {
210
-        return $this->get_many_related('Event');
211
-    }
212
-
213
-
214
-    /**
215
-     * Adds the question to this question group
216
-     *
217
-     * @param EE_Question || int $question object or ID
218
-     * @return boolean if successful
219
-     */
220
-    public function add_question($questionObjectOrID)
221
-    {
222
-        return $this->_add_relation_to($questionObjectOrID, 'Question');
223
-    }
224
-
225
-
226
-    /**
227
-     * Removes the question from this question group
228
-     *
229
-     * @param EE_Question || int $question object or ID
230
-     * @return boolean of success
231
-     */
232
-    public function remove_question($questionObjectOrID)
233
-    {
234
-        return $this->_remove_relation_to($questionObjectOrID, 'Question');
235
-    }
236
-
237
-
238
-    /**
239
-     * @param $questionObjectOrID
240
-     * @param $qst_order
241
-     * @return int
242
-     */
243
-    public function update_question_order($questionObjectOrID, $qst_order)
244
-    {
245
-        $qst_ID = $questionObjectOrID instanceof EE_Question ? $questionObjectOrID->ID() : (int) $questionObjectOrID;
246
-        return EEM_Question_Group_Question::instance()->update(
247
-            array('QGQ_order' => $qst_order),
248
-            array(
249
-                array(
250
-                    'QST_ID' => $qst_ID,
251
-                    'QSG_ID' => $this->ID(),
252
-                ),
253
-            )
254
-        );
255
-    }
256
-
257
-
258
-    /**
259
-     * Basically this is method just returns whether the question group has any questions with answers.  This is used
260
-     * by the admin currently to determine whether we should display the ui for deleting permanently or not b/c
261
-     * question groups with questions that have answers should not be possible to delete permanently
262
-     *
263
-     * @return boolean true if has questions with answers, false if not.
264
-     */
265
-    public function has_questions_with_answers()
266
-    {
267
-        $has_answers = false;
268
-        $questions = $this->get_many_related('Question');
269
-        foreach ($questions as $question) {
270
-            if ($question->count_related('Answer') > 0) {
271
-                $has_answers = true;
272
-            }
273
-        }
274
-        return $has_answers;
275
-    }
276
-
277
-
278
-    /**
279
-     * The purpose of this method is set the question group order for this question group to be the max out of all
280
-     * question groups
281
-     *
282
-     * @access public
283
-     * @return void
284
-     */
285
-    public function set_order_to_latest()
286
-    {
287
-        $latest_order = $this->get_model()->get_latest_question_group_order();
288
-        $latest_order++;
289
-        $this->set('QSG_order', $latest_order);
290
-    }
15
+	/**
16
+	 * @param array $props_n_values
17
+	 * @return EE_Question_Group|mixed
18
+	 */
19
+	public static function new_instance($props_n_values = array())
20
+	{
21
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
22
+		return $has_object ? $has_object : new self($props_n_values);
23
+	}
24
+
25
+
26
+	/**
27
+	 * @param array $props_n_values
28
+	 * @return EE_Question_Group
29
+	 */
30
+	public static function new_instance_from_db($props_n_values = array())
31
+	{
32
+		return new self($props_n_values, true);
33
+	}
34
+
35
+
36
+	/**
37
+	 * gets the question group's name
38
+	 *
39
+	 * @access public
40
+	 * @param bool $pretty
41
+	 * @return string
42
+	 */
43
+	public function name($pretty = false)
44
+	{
45
+		return $pretty ? $this->get_pretty('QSG_name') : $this->get('QSG_name');
46
+	}
47
+
48
+
49
+	/**
50
+	 * Gets the question group's internal name
51
+	 *
52
+	 * @access public
53
+	 * @return string
54
+	 */
55
+	public function identifier()
56
+	{
57
+		return $this->get('QSG_identifier');
58
+	}
59
+
60
+
61
+	/**
62
+	 * Gets the question group's description
63
+	 *
64
+	 * @access public
65
+	 * @param bool $pretty
66
+	 * @return string
67
+	 */
68
+	public function desc($pretty = false)
69
+	{
70
+		return $pretty ? $this->get_pretty('QSG_desc') : $this->get('QSG_desc');
71
+	}
72
+
73
+
74
+	/**
75
+	 * Gets the question group's order number in a sequence
76
+	 * of other question groups
77
+	 *
78
+	 * @access public
79
+	 * @return int
80
+	 */
81
+	public function order()
82
+	{
83
+		return $this->get('QSG_order');
84
+	}
85
+
86
+
87
+	/**
88
+	 * Returns whether to show the group's name on the frontend
89
+	 *
90
+	 * @access public
91
+	 * @return boolean
92
+	 */
93
+	public function show_group_name()
94
+	{
95
+		return $this->get('QSG_show_group_name');
96
+	}
97
+
98
+
99
+	/**
100
+	 * Returns whether to show the group's description
101
+	 * on the frontend
102
+	 *
103
+	 * @access public
104
+	 * @return boolean
105
+	 */
106
+	public function show_group_desc()
107
+	{
108
+		return $this->get('QSG_show_group_desc');
109
+	}
110
+
111
+
112
+	/**
113
+	 * Returns whether this is a 'system group' (meaning
114
+	 * a question group integral to the system, whose questions
115
+	 * relate to the attendee table)
116
+	 *
117
+	 * @access public
118
+	 * @return int
119
+	 */
120
+	public function system_group()
121
+	{
122
+		return $this->get('QSG_system');
123
+	}
124
+
125
+
126
+	/**
127
+	 * get the author of the question group.
128
+	 *
129
+	 * @since 4.5.0
130
+	 *
131
+	 * @return int
132
+	 */
133
+	public function wp_user()
134
+	{
135
+		return $this->get('QSG_wp_user');
136
+	}
137
+
138
+
139
+	/**
140
+	 * Returns whether this question group has
141
+	 * been deleted
142
+	 *
143
+	 * @access public
144
+	 * @return boolean
145
+	 */
146
+	public function deleted()
147
+	{
148
+		return $this->get('QST_deleted');
149
+	}
150
+
151
+
152
+	/**
153
+	 * Gets an array of questions with questions IN the group at the start of the array and questions NOT in the group
154
+	 * at the end of the array.  Questions in the group are ordered by Question_Group_Question.QGQ_order and questions
155
+	 * NOT in the group are ordered by Question.QGQ_order
156
+	 *
157
+	 * @return EE_Question[]
158
+	 */
159
+	public function questions_in_and_not_in_group()
160
+	{
161
+		$questions_in_group = $this->questions();
162
+		$exclude_question_ids = ! empty($questions_in_group) ? array_keys($questions_in_group) : array();
163
+		$questions_not_in_group = $this->questions_not_in_group($exclude_question_ids);
164
+		return $questions_in_group + $questions_not_in_group;
165
+	}
166
+
167
+
168
+	/**
169
+	 * Gets all the questions which are part of this question group (ordered Question_Group_Question.QGQ_order)
170
+	 *
171
+	 * @param array $query_params
172
+	 * @return EE_Question[]
173
+	 */
174
+	public function questions($query_params = array())
175
+	{
176
+		$query_params = ! empty($query_params) ? $query_params
177
+			: array('order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'));
178
+		return $this->ID() ? $this->get_many_related('Question', $query_params) : array();
179
+	}
180
+
181
+
182
+	/**
183
+	 * Gets all the questions which are NOT part of this question group.
184
+	 *
185
+	 * @param  mixed $question_IDS_in_group if empty array then all questions returned.  if FALSE then we first get
186
+	 *                                      questions in this group and exclude them from questions get all. IF empty
187
+	 *                                      array then we just return all questions.
188
+	 * @return EE_Question[]
189
+	 */
190
+	public function questions_not_in_group($question_IDS_in_group = false)
191
+	{
192
+		if ($question_IDS_in_group === false) {
193
+			$questions = $this->questions();
194
+			$question_IDS_in_group = ! empty($questions) ? array_keys($questions) : array();
195
+		}
196
+		$_where = ! empty($question_IDS_in_group) ? array('QST_ID' => array('not_in', $question_IDS_in_group))
197
+			: array();
198
+
199
+		return EEM_Question::instance()->get_all(array($_where, 'order_by' => array('QST_ID' => 'ASC')));
200
+	}
201
+
202
+
203
+	/**
204
+	 * Gets all events which are related to this question group
205
+	 *
206
+	 * @return EE_Event[]
207
+	 */
208
+	public function events()
209
+	{
210
+		return $this->get_many_related('Event');
211
+	}
212
+
213
+
214
+	/**
215
+	 * Adds the question to this question group
216
+	 *
217
+	 * @param EE_Question || int $question object or ID
218
+	 * @return boolean if successful
219
+	 */
220
+	public function add_question($questionObjectOrID)
221
+	{
222
+		return $this->_add_relation_to($questionObjectOrID, 'Question');
223
+	}
224
+
225
+
226
+	/**
227
+	 * Removes the question from this question group
228
+	 *
229
+	 * @param EE_Question || int $question object or ID
230
+	 * @return boolean of success
231
+	 */
232
+	public function remove_question($questionObjectOrID)
233
+	{
234
+		return $this->_remove_relation_to($questionObjectOrID, 'Question');
235
+	}
236
+
237
+
238
+	/**
239
+	 * @param $questionObjectOrID
240
+	 * @param $qst_order
241
+	 * @return int
242
+	 */
243
+	public function update_question_order($questionObjectOrID, $qst_order)
244
+	{
245
+		$qst_ID = $questionObjectOrID instanceof EE_Question ? $questionObjectOrID->ID() : (int) $questionObjectOrID;
246
+		return EEM_Question_Group_Question::instance()->update(
247
+			array('QGQ_order' => $qst_order),
248
+			array(
249
+				array(
250
+					'QST_ID' => $qst_ID,
251
+					'QSG_ID' => $this->ID(),
252
+				),
253
+			)
254
+		);
255
+	}
256
+
257
+
258
+	/**
259
+	 * Basically this is method just returns whether the question group has any questions with answers.  This is used
260
+	 * by the admin currently to determine whether we should display the ui for deleting permanently or not b/c
261
+	 * question groups with questions that have answers should not be possible to delete permanently
262
+	 *
263
+	 * @return boolean true if has questions with answers, false if not.
264
+	 */
265
+	public function has_questions_with_answers()
266
+	{
267
+		$has_answers = false;
268
+		$questions = $this->get_many_related('Question');
269
+		foreach ($questions as $question) {
270
+			if ($question->count_related('Answer') > 0) {
271
+				$has_answers = true;
272
+			}
273
+		}
274
+		return $has_answers;
275
+	}
276
+
277
+
278
+	/**
279
+	 * The purpose of this method is set the question group order for this question group to be the max out of all
280
+	 * question groups
281
+	 *
282
+	 * @access public
283
+	 * @return void
284
+	 */
285
+	public function set_order_to_latest()
286
+	{
287
+		$latest_order = $this->get_model()->get_latest_question_group_order();
288
+		$latest_order++;
289
+		$this->set('QSG_order', $latest_order);
290
+	}
291 291
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Checkin.class.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -11,86 +11,86 @@
 block discarded – undo
11 11
 {
12 12
 
13 13
 
14
-    /**
15
-     * Used to reference when a registration has been checked out.
16
-     *
17
-     * @type int
18
-     */
19
-    const status_checked_out = 0;
20
-
21
-    /**
22
-     * Used to reference when a registration has been checked in.
23
-     *
24
-     * @type int
25
-     */
26
-    const status_checked_in = 1;
27
-
28
-    /**
29
-     * Used to reference when a registration has never been checked in.
30
-     *
31
-     * @type int
32
-     */
33
-    const status_checked_never = 2;
34
-
35
-
36
-    /**
37
-     *
38
-     * @param array  $props_n_values    incoming values
39
-     * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
40
-     * @param array  $date_formats      incoming date_formats in an array
41
-     *                                  where the first value is the date_format
42
-     *                                  and the second value is the time format
43
-     * @return EE_Checkin
44
-     * @throws EE_Error
45
-     */
46
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
47
-    {
48
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
49
-        return $has_object
50
-            ? $has_object
51
-            : new self($props_n_values, false, $timezone, $date_formats);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param array  $props_n_values  incoming values from the database
57
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
58
-     *                                the website will be used.
59
-     * @return EE_Checkin
60
-     * @throws EE_Error
61
-     */
62
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
63
-    {
64
-        return new self($props_n_values, true, $timezone);
65
-    }
66
-
67
-
68
-    public function ID()
69
-    {
70
-        return $this->get('CHK_ID');
71
-    }
72
-
73
-
74
-    public function registration_id()
75
-    {
76
-        return $this->get('REG_ID');
77
-    }
78
-
79
-
80
-    public function datetime_id()
81
-    {
82
-        return $this->get('DTT_ID');
83
-    }
84
-
85
-
86
-    public function status()
87
-    {
88
-        return $this->get('CHK_in');
89
-    }
90
-
91
-
92
-    public function timestamp()
93
-    {
94
-        return $this->get('CHK_timestamp');
95
-    }
14
+	/**
15
+	 * Used to reference when a registration has been checked out.
16
+	 *
17
+	 * @type int
18
+	 */
19
+	const status_checked_out = 0;
20
+
21
+	/**
22
+	 * Used to reference when a registration has been checked in.
23
+	 *
24
+	 * @type int
25
+	 */
26
+	const status_checked_in = 1;
27
+
28
+	/**
29
+	 * Used to reference when a registration has never been checked in.
30
+	 *
31
+	 * @type int
32
+	 */
33
+	const status_checked_never = 2;
34
+
35
+
36
+	/**
37
+	 *
38
+	 * @param array  $props_n_values    incoming values
39
+	 * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
40
+	 * @param array  $date_formats      incoming date_formats in an array
41
+	 *                                  where the first value is the date_format
42
+	 *                                  and the second value is the time format
43
+	 * @return EE_Checkin
44
+	 * @throws EE_Error
45
+	 */
46
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
47
+	{
48
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
49
+		return $has_object
50
+			? $has_object
51
+			: new self($props_n_values, false, $timezone, $date_formats);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param array  $props_n_values  incoming values from the database
57
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
58
+	 *                                the website will be used.
59
+	 * @return EE_Checkin
60
+	 * @throws EE_Error
61
+	 */
62
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
63
+	{
64
+		return new self($props_n_values, true, $timezone);
65
+	}
66
+
67
+
68
+	public function ID()
69
+	{
70
+		return $this->get('CHK_ID');
71
+	}
72
+
73
+
74
+	public function registration_id()
75
+	{
76
+		return $this->get('REG_ID');
77
+	}
78
+
79
+
80
+	public function datetime_id()
81
+	{
82
+		return $this->get('DTT_ID');
83
+	}
84
+
85
+
86
+	public function status()
87
+	{
88
+		return $this->get('CHK_in');
89
+	}
90
+
91
+
92
+	public function timestamp()
93
+	{
94
+		return $this->get('CHK_timestamp');
95
+	}
96 96
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Venue.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 class EE_Event_Venue extends EE_Base_Class
7 7
 {
8 8
 
9
-    /**
10
-     * @param array $props_n_values
11
-     * @return EE_Event_Venue|mixed
12
-     */
13
-    public static function new_instance($props_n_values = array())
14
-    {
15
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
-        return $has_object ? $has_object : new self($props_n_values);
17
-    }
9
+	/**
10
+	 * @param array $props_n_values
11
+	 * @return EE_Event_Venue|mixed
12
+	 */
13
+	public static function new_instance($props_n_values = array())
14
+	{
15
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
+		return $has_object ? $has_object : new self($props_n_values);
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * @param array $props_n_values
22
-     * @return EE_Event_Venue
23
-     */
24
-    public static function new_instance_from_db($props_n_values = array())
25
-    {
26
-        return new self($props_n_values, true);
27
-    }
20
+	/**
21
+	 * @param array $props_n_values
22
+	 * @return EE_Event_Venue
23
+	 */
24
+	public static function new_instance_from_db($props_n_values = array())
25
+	{
26
+		return new self($props_n_values, true);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Soft_Delete_Base_Class.class.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Overrides parent _delete() so that we do soft deletes.
17
-     *
18
-     * @return bool|int
19
-     */
20
-    protected function _delete()
21
-    {
22
-        return $this->delete_or_restore();
23
-    }
15
+	/**
16
+	 * Overrides parent _delete() so that we do soft deletes.
17
+	 *
18
+	 * @return bool|int
19
+	 */
20
+	protected function _delete()
21
+	{
22
+		return $this->delete_or_restore();
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Deletes or restores this object.
28
-     *
29
-     * @param bool $delete true=>delete, false=>restore
30
-     * @return bool|int
31
-     */
32
-    public function delete_or_restore($delete = true)
33
-    {
34
-        /**
35
-         * Called just before trashing (soft delete) or restoring a trashed item.
36
-         *
37
-         * @param EE_Base_Class $model_object about to be trashed or restored
38
-         * @param bool          $delete       true the item is being trashed, false the item is being restored.
39
-         */
40
-        do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete);
41
-        $model = $this->get_model();
42
-        $result = $model->delete_or_restore_by_ID($delete, $this->ID());
43
-        /**
44
-         * Called just after trashing (soft delete) or restoring a trashed item.
45
-         *
46
-         * @param EE_Base_Class $model_object that was just trashed or restored.
47
-         * @param bool          $delete       true the item is being trashed, false the item is being restored.
48
-         * @param bool|int      $result
49
-         */
50
-        do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result);
51
-        return $result;
52
-    }
26
+	/**
27
+	 * Deletes or restores this object.
28
+	 *
29
+	 * @param bool $delete true=>delete, false=>restore
30
+	 * @return bool|int
31
+	 */
32
+	public function delete_or_restore($delete = true)
33
+	{
34
+		/**
35
+		 * Called just before trashing (soft delete) or restoring a trashed item.
36
+		 *
37
+		 * @param EE_Base_Class $model_object about to be trashed or restored
38
+		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
39
+		 */
40
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete);
41
+		$model = $this->get_model();
42
+		$result = $model->delete_or_restore_by_ID($delete, $this->ID());
43
+		/**
44
+		 * Called just after trashing (soft delete) or restoring a trashed item.
45
+		 *
46
+		 * @param EE_Base_Class $model_object that was just trashed or restored.
47
+		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
48
+		 * @param bool|int      $result
49
+		 */
50
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result);
51
+		return $result;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Performs a restoration (un-deletes) this object
57
-     *
58
-     * @return bool|int
59
-     */
60
-    public function restore()
61
-    {
62
-        return $this->delete_or_restore(false);
63
-    }
55
+	/**
56
+	 * Performs a restoration (un-deletes) this object
57
+	 *
58
+	 * @return bool|int
59
+	 */
60
+	public function restore()
61
+	{
62
+		return $this->delete_or_restore(false);
63
+	}
64 64
 }
Please login to merge, or discard this patch.