Completed
Branch FET-10416-autoload-b4-bootstra... (42a01c)
by
unknown
13:17
created
strategies/display/EE_Text_Input_Display_Strategy.strategy.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * Gets the html "type" attribute's value
35 35
 	 * @return string
36 36
 	 */
37
-    public function get_type(){
37
+	public function get_type(){
38 38
 		if (
39 39
 			$this->_type === 'email'
40 40
 			&& ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false )
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return string of html to display the field
52 52
 	 */
53
-    public function display(){
53
+	public function display(){
54 54
 		$input = '<input type="'. $this->get_type() .'"';
55 55
 		$input .= ' name="' . $this->_input->html_name() . '"';
56 56
 		$input .= ' id="' . $this->_input->html_id() . '"';
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since               	4.6
12 12
  *
13 13
  */
14
-class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base{
14
+class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base {
15 15
 	/**
16 16
 	 * The html "type" attribute value. default is "text"
17 17
 	 * @var string
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @param string $type
25 25
 	 */
26
-	public function __construct( $type = 'text' ) {
26
+	public function __construct($type = 'text') {
27 27
 		$this->_type = $type;
28 28
 		parent::__construct();
29 29
 	}
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 	 * Gets the html "type" attribute's value
35 35
 	 * @return string
36 36
 	 */
37
-    public function get_type(){
37
+    public function get_type() {
38 38
 		if (
39 39
 			$this->_type === 'email'
40
-			&& ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false )
40
+			&& ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false)
41 41
 		) {
42 42
 			return 'text';
43 43
 		}
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return string of html to display the field
52 52
 	 */
53
-    public function display(){
54
-		$input = '<input type="'. $this->get_type() .'"';
55
-		$input .= ' name="' . $this->_input->html_name() . '"';
56
-		$input .= ' id="' . $this->_input->html_id() . '"';
57
-		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
58
-		$input .= ' class="' . $class . '"';
53
+    public function display() {
54
+		$input = '<input type="'.$this->get_type().'"';
55
+		$input .= ' name="'.$this->_input->html_name().'"';
56
+		$input .= ' id="'.$this->_input->html_id().'"';
57
+		$class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class();
58
+		$input .= ' class="'.$class.'"';
59 59
 		// add html5 required
60 60
 		$input .= $this->_input->required() ? ' required' : '';
61
-		$input .= ' value="' . $this->_input->raw_value_in_form() . '"';
62
-		$input .= ' style="' . $this->_input->html_style() . '"';
61
+		$input .= ' value="'.$this->_input->raw_value_in_form().'"';
62
+		$input .= ' style="'.$this->_input->html_style().'"';
63 63
 		$input .= $this->_input->other_html_attributes();
64 64
 		$input .= '/>';
65 65
 		return $input;
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Integer_Input.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,37 +15,37 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * @param array $input_settings
20
-     */
21
-    public function __construct($input_settings = array())
22
-    {
23
-        $this->_set_display_strategy(
24
-            new EE_Number_Input_Display_Strategy(
25
-                isset($input_settings['min_value'])
26
-                    ? $input_settings['min_value']
27
-                    : null,
28
-                isset($input_settings['max_value'])
29
-                    ? $input_settings['max_value']
30
-                    : null
31
-            )
32
-        );
33
-        $this->_set_normalization_strategy(
34
-            new EE_Int_Normalization(
35
-                isset($input_settings['validation_error_message'])
36
-                    ? $input_settings['validation_error_message']
37
-                    : null
38
-            )
39
-        );
40
-        $this->_add_validation_strategy(
41
-            new EE_Int_Validation_Strategy(
42
-                isset($input_settings['validation_error_message'])
43
-                    ? $input_settings['validation_error_message']
44
-                    : null
45
-            )
46
-        );
47
-        parent::__construct($input_settings);
48
-    }
18
+	/**
19
+	 * @param array $input_settings
20
+	 */
21
+	public function __construct($input_settings = array())
22
+	{
23
+		$this->_set_display_strategy(
24
+			new EE_Number_Input_Display_Strategy(
25
+				isset($input_settings['min_value'])
26
+					? $input_settings['min_value']
27
+					: null,
28
+				isset($input_settings['max_value'])
29
+					? $input_settings['max_value']
30
+					: null
31
+			)
32
+		);
33
+		$this->_set_normalization_strategy(
34
+			new EE_Int_Normalization(
35
+				isset($input_settings['validation_error_message'])
36
+					? $input_settings['validation_error_message']
37
+					: null
38
+			)
39
+		);
40
+		$this->_add_validation_strategy(
41
+			new EE_Int_Validation_Strategy(
42
+				isset($input_settings['validation_error_message'])
43
+					? $input_settings['validation_error_message']
44
+					: null
45
+			)
46
+		);
47
+		parent::__construct($input_settings);
48
+	}
49 49
 
50 50
 }
51 51
 // End of file EE_Integer_Input.php
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Float_Input.input.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,6 +16,6 @@
 block discarded – undo
16 16
 		$this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) );
17 17
 		$this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) );
18 18
 		parent::__construct($input_settings);
19
-        $this->_other_html_attributes .= ' step="any"';
19
+		$this->_other_html_attributes .= ' step="any"';
20 20
 	}
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
  * @subpackage
7 7
  * @author				Mike Nelson
8 8
  */
9
-class EE_Float_Input extends EE_Form_Input_Base{
9
+class EE_Float_Input extends EE_Form_Input_Base {
10 10
 
11 11
 	/**
12 12
 	 * @param array $input_settings
13 13
 	 */
14
-	function __construct($input_settings = array()){
14
+	function __construct($input_settings = array()) {
15 15
 		$this->_set_display_strategy(new EE_Number_Input_Display_Strategy());
16
-		$this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) );
17
-		$this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) );
16
+		$this->_set_normalization_strategy(new EE_Float_Normalization(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL));
17
+		$this->_add_validation_strategy(new EE_Float_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL));
18 18
 		parent::__construct($input_settings);
19 19
         $this->_other_html_attributes .= ' step="any"';
20 20
 	}
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Display_Strategy_Base.strategy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected function _append_chars($string = '', $chars = '-')
63 63
     {
64
-        return $this->_remove_chars($string, $chars) . $chars;
64
+        return $this->_remove_chars($string, $chars).$chars;
65 65
     }
66 66
 
67 67
 
Please login to merge, or discard this patch.
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,229 +16,229 @@  discard block
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var string $_tag
21
-     */
22
-    protected $_tag = '';
19
+	/**
20
+	 * @var string $_tag
21
+	 */
22
+	protected $_tag = '';
23 23
 
24 24
 
25 25
 
26 26
 
27 27
 
28
-    /**
29
-     * returns HTML and javascript related to the displaying of this input
30
-     *
31
-     * @return string
32
-     */
33
-    abstract public function display();
28
+	/**
29
+	 * returns HTML and javascript related to the displaying of this input
30
+	 *
31
+	 * @return string
32
+	 */
33
+	abstract public function display();
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars
39
-     * is already there
40
-     *
41
-     * @param string $string - the string being processed
42
-     * @param string $chars  - exact string of characters to remove
43
-     * @return string
44
-     */
45
-    protected function _remove_chars($string = '', $chars = '-')
46
-    {
47
-        $char_length = strlen($chars) * -1;
48
-        // if last three characters of string is  " - ", then remove it
49
-        return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string;
50
-    }
37
+	/**
38
+	 * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars
39
+	 * is already there
40
+	 *
41
+	 * @param string $string - the string being processed
42
+	 * @param string $chars  - exact string of characters to remove
43
+	 * @return string
44
+	 */
45
+	protected function _remove_chars($string = '', $chars = '-')
46
+	{
47
+		$char_length = strlen($chars) * -1;
48
+		// if last three characters of string is  " - ", then remove it
49
+		return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string;
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not
56
-     * already there
57
-     *
58
-     * @param string $string - the string being processed
59
-     * @param string $chars  - exact string of characters to be added to end of string
60
-     * @return string
61
-     */
62
-    protected function _append_chars($string = '', $chars = '-')
63
-    {
64
-        return $this->_remove_chars($string, $chars) . $chars;
65
-    }
54
+	/**
55
+	 * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not
56
+	 * already there
57
+	 *
58
+	 * @param string $string - the string being processed
59
+	 * @param string $chars  - exact string of characters to be added to end of string
60
+	 * @return string
61
+	 */
62
+	protected function _append_chars($string = '', $chars = '-')
63
+	{
64
+		return $this->_remove_chars($string, $chars) . $chars;
65
+	}
66 66
 
67 67
 
68
-
69
-    /**
70
-     * Gets the HTML IDs of all the inputs
71
-     *
72
-     * @param bool $add_pound_sign
73
-     * @return array
74
-     */
75
-    public function get_html_input_ids($add_pound_sign = false)
76
-    {
77
-        return array($this->get_input()->html_id($add_pound_sign));
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * Adds js variables for localization to the $other_js_data. These should be put
84
-     * in each form's "other_data" javascript object.
85
-     *
86
-     * @param array $other_js_data
87
-     * @return array
88
-     */
89
-    public function get_other_js_data($other_js_data = array())
90
-    {
91
-        return $other_js_data;
92
-    }
93
-
94
-
95
-
96
-    /**
97
-     * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
98
-     * This should be called during wp_enqueue_scripts
99
-     */
100
-    public function enqueue_js()
101
-    {
102
-    }
103
-
104
-
105
-
106
-    /**
107
-     * returns string like: '<tag'
108
-     *
109
-     * @param string $tag
110
-     * @return string
111
-     */
112
-    protected function _opening_tag($tag)
113
-    {
114
-        $this->_tag = $tag;
115
-        return "<{$this->_tag}";
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     * returns string like: '</tag>
122
-     *
123
-     * @return string
124
-     */
125
-    protected function _closing_tag()
126
-    {
127
-        return "</{$this->_tag}>";
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * returns string like: '/>'
134
-     *
135
-     * @return string
136
-     */
137
-    protected function _close_tag()
138
-    {
139
-        return '/>';
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * returns an array of standard HTML attributes that get added to nearly all inputs,
146
-     * where string keys represent named attributes like id, class, etc
147
-     * and numeric keys represent single attributes like 'required'.
148
-     * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use
149
-     * it.
150
-     *
151
-     * @return array
152
-     */
153
-    protected function _standard_attributes_array()
154
-    {
155
-        return array(
156
-            'name'  => $this->_input->html_name(),
157
-            'id'    => $this->_input->html_id(),
158
-            'class' => $this->_input->html_class(true),
159
-            0       => array('required', $this->_input->required()),
160
-            1       => $this->_input->other_html_attributes(),
161
-            'style' => $this->_input->html_style(),
162
-        );
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * sets the attributes using the incoming array
169
-     * and returns a string of all attributes rendered as valid HTML
170
-     *
171
-     * @param array $attributes
172
-     * @return string
173
-     */
174
-    protected function _attributes_string($attributes = array())
175
-    {
176
-        $attributes = apply_filters(
177
-            'FHEE__EE_Display_Strategy_Base__attributes_string__attributes',
178
-            $attributes,
179
-            $this,
180
-            $this->_input
181
-        );
182
-        $attributes_string = '';
183
-        foreach ($attributes as $attribute => $value) {
184
-            if (is_numeric($attribute)) {
185
-                $add = true;
186
-                if (is_array($value)) {
187
-                    $attribute = isset($value[0]) ? $value[0] : '';
188
-                    $add = isset($value[1]) ? $value[1] : false;
189
-                } else {
190
-                    $attribute = $value;
191
-                }
192
-                $attributes_string .= $this->_single_attribute($attribute, $add);
193
-            } else {
194
-                $attributes_string .= $this->_attribute($attribute, $value);
195
-            }
196
-        }
197
-        return $attributes_string;
198
-    }
199
-
200
-
201
-
202
-    /**
203
-     * returns string like: ' attribute="value"'
204
-     * returns an empty string if $value is null
205
-     *
206
-     * @param string $attribute
207
-     * @param string $value
208
-     * @return string
209
-     */
210
-    protected function _attribute($attribute, $value = '')
211
-    {
212
-        return $value !== null ? " {$attribute}=\"{$value}\"" : '';
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * returns string like: ' data-attribute="value"'
219
-     * returns an empty string if $value is null
220
-     *
221
-     * @param string $attribute
222
-     * @param string $value
223
-     * @return string
224
-     */
225
-    protected function _data_attribute($attribute, $value = '')
226
-    {
227
-        return $value !== null ? " data-{$attribute}=\"{$value}\"" : '';
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * returns string like: ' attribute' if $add is true
234
-     *
235
-     * @param string  $attribute
236
-     * @param boolean $add
237
-     * @return string
238
-     */
239
-    protected function _single_attribute($attribute, $add = true)
240
-    {
241
-        return $add ? " {$attribute}" : '';
242
-    }
68
+
69
+	/**
70
+	 * Gets the HTML IDs of all the inputs
71
+	 *
72
+	 * @param bool $add_pound_sign
73
+	 * @return array
74
+	 */
75
+	public function get_html_input_ids($add_pound_sign = false)
76
+	{
77
+		return array($this->get_input()->html_id($add_pound_sign));
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * Adds js variables for localization to the $other_js_data. These should be put
84
+	 * in each form's "other_data" javascript object.
85
+	 *
86
+	 * @param array $other_js_data
87
+	 * @return array
88
+	 */
89
+	public function get_other_js_data($other_js_data = array())
90
+	{
91
+		return $other_js_data;
92
+	}
93
+
94
+
95
+
96
+	/**
97
+	 * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
98
+	 * This should be called during wp_enqueue_scripts
99
+	 */
100
+	public function enqueue_js()
101
+	{
102
+	}
103
+
104
+
105
+
106
+	/**
107
+	 * returns string like: '<tag'
108
+	 *
109
+	 * @param string $tag
110
+	 * @return string
111
+	 */
112
+	protected function _opening_tag($tag)
113
+	{
114
+		$this->_tag = $tag;
115
+		return "<{$this->_tag}";
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 * returns string like: '</tag>
122
+	 *
123
+	 * @return string
124
+	 */
125
+	protected function _closing_tag()
126
+	{
127
+		return "</{$this->_tag}>";
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * returns string like: '/>'
134
+	 *
135
+	 * @return string
136
+	 */
137
+	protected function _close_tag()
138
+	{
139
+		return '/>';
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * returns an array of standard HTML attributes that get added to nearly all inputs,
146
+	 * where string keys represent named attributes like id, class, etc
147
+	 * and numeric keys represent single attributes like 'required'.
148
+	 * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use
149
+	 * it.
150
+	 *
151
+	 * @return array
152
+	 */
153
+	protected function _standard_attributes_array()
154
+	{
155
+		return array(
156
+			'name'  => $this->_input->html_name(),
157
+			'id'    => $this->_input->html_id(),
158
+			'class' => $this->_input->html_class(true),
159
+			0       => array('required', $this->_input->required()),
160
+			1       => $this->_input->other_html_attributes(),
161
+			'style' => $this->_input->html_style(),
162
+		);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * sets the attributes using the incoming array
169
+	 * and returns a string of all attributes rendered as valid HTML
170
+	 *
171
+	 * @param array $attributes
172
+	 * @return string
173
+	 */
174
+	protected function _attributes_string($attributes = array())
175
+	{
176
+		$attributes = apply_filters(
177
+			'FHEE__EE_Display_Strategy_Base__attributes_string__attributes',
178
+			$attributes,
179
+			$this,
180
+			$this->_input
181
+		);
182
+		$attributes_string = '';
183
+		foreach ($attributes as $attribute => $value) {
184
+			if (is_numeric($attribute)) {
185
+				$add = true;
186
+				if (is_array($value)) {
187
+					$attribute = isset($value[0]) ? $value[0] : '';
188
+					$add = isset($value[1]) ? $value[1] : false;
189
+				} else {
190
+					$attribute = $value;
191
+				}
192
+				$attributes_string .= $this->_single_attribute($attribute, $add);
193
+			} else {
194
+				$attributes_string .= $this->_attribute($attribute, $value);
195
+			}
196
+		}
197
+		return $attributes_string;
198
+	}
199
+
200
+
201
+
202
+	/**
203
+	 * returns string like: ' attribute="value"'
204
+	 * returns an empty string if $value is null
205
+	 *
206
+	 * @param string $attribute
207
+	 * @param string $value
208
+	 * @return string
209
+	 */
210
+	protected function _attribute($attribute, $value = '')
211
+	{
212
+		return $value !== null ? " {$attribute}=\"{$value}\"" : '';
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * returns string like: ' data-attribute="value"'
219
+	 * returns an empty string if $value is null
220
+	 *
221
+	 * @param string $attribute
222
+	 * @param string $value
223
+	 * @return string
224
+	 */
225
+	protected function _data_attribute($attribute, $value = '')
226
+	{
227
+		return $value !== null ? " data-{$attribute}=\"{$value}\"" : '';
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * returns string like: ' attribute' if $add is true
234
+	 *
235
+	 * @param string  $attribute
236
+	 * @param boolean $add
237
+	 * @return string
238
+	 */
239
+	protected function _single_attribute($attribute, $add = true)
240
+	{
241
+		return $add ? " {$attribute}" : '';
242
+	}
243 243
 
244 244
 }
245 245
\ No newline at end of file
Please login to merge, or discard this patch.
libraries/form_sections/strategies/EE_Form_Input_Strategy_Base.strategy.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,40 +9,40 @@
 block discarded – undo
9 9
 abstract class EE_Form_Input_Strategy_Base
10 10
 {
11 11
 
12
-    /**
13
-     * Form Input to display
14
-     *
15
-     * @var EE_Form_Input_Base
16
-     */
17
-    protected $_input;
12
+	/**
13
+	 * Form Input to display
14
+	 *
15
+	 * @var EE_Form_Input_Base
16
+	 */
17
+	protected $_input;
18 18
 
19 19
 
20 20
 
21
-    public function __construct()
22
-    {
23
-    }
21
+	public function __construct()
22
+	{
23
+	}
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * The form input on which this strategy is to perform
29
-     *
30
-     * @param EE_Form_Input_Base $form_input
31
-     */
32
-    public function _construct_finalize(EE_Form_Input_Base $form_input)
33
-    {
34
-        $this->_input = $form_input;
35
-    }
27
+	/**
28
+	 * The form input on which this strategy is to perform
29
+	 *
30
+	 * @param EE_Form_Input_Base $form_input
31
+	 */
32
+	public function _construct_finalize(EE_Form_Input_Base $form_input)
33
+	{
34
+		$this->_input = $form_input;
35
+	}
36 36
 
37 37
 
38 38
 
39
-    /**
40
-     * Gets this strategy's input
41
-     *
42
-     * @return EE_Form_Input_Base
43
-     */
44
-    public function get_input()
45
-    {
46
-        return $this->_input;
47
-    }
39
+	/**
40
+	 * Gets this strategy's input
41
+	 *
42
+	 * @return EE_Form_Input_Base
43
+	 */
44
+	public function get_input()
45
+	{
46
+		return $this->_input;
47
+	}
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_classes/EE_Question.class.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	 *                             		    date_format and the second value is the time format
38 38
 	 * @return EE_Question
39 39
 	 */
40
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
41
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
42
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
40
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
41
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
42
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
43 43
 	}
44 44
 
45 45
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 *                          		the website will be used.
51 51
 	 * @return EE_Question
52 52
 	 */
53
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
54
-		return new self( $props_n_values, TRUE, $timezone );
53
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
54
+		return new self($props_n_values, TRUE, $timezone);
55 55
 	}
56 56
 
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @access        public
63 63
 	 * @param string $QST_display_text
64 64
 	 */
65
-	public function set_display_text( $QST_display_text = '' ) {
66
-		$this->set( 'QST_display_text', $QST_display_text );
65
+	public function set_display_text($QST_display_text = '') {
66
+		$this->set('QST_display_text', $QST_display_text);
67 67
 	}
68 68
 
69 69
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @access        public
75 75
 	 * @param        string $QST_admin_label
76 76
 	 */
77
-	public function set_admin_label( $QST_admin_label = '' ) {
78
-		$this->set( 'QST_admin_label', $QST_admin_label );
77
+	public function set_admin_label($QST_admin_label = '') {
78
+		$this->set('QST_admin_label', $QST_admin_label);
79 79
 	}
80 80
 
81 81
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @access        public
87 87
 	 * @param        mixed $QST_system
88 88
 	 */
89
-	public function set_system_ID( $QST_system = '' ) {
90
-		$this->set( 'QST_system', $QST_system );
89
+	public function set_system_ID($QST_system = '') {
90
+		$this->set('QST_system', $QST_system);
91 91
 	}
92 92
 
93 93
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @access        public
99 99
 	 * @param        string $QST_type
100 100
 	 */
101
-	public function set_question_type( $QST_type = '' ) {
102
-		$this->set( 'QST_type', $QST_type );
101
+	public function set_question_type($QST_type = '') {
102
+		$this->set('QST_type', $QST_type);
103 103
 	}
104 104
 
105 105
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @access        public
111 111
 	 * @param        bool $QST_required
112 112
 	 */
113
-	public function set_required( $QST_required = FALSE ) {
114
-		$this->set( 'QST_required', $QST_required );
113
+	public function set_required($QST_required = FALSE) {
114
+		$this->set('QST_required', $QST_required);
115 115
 	}
116 116
 
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @access        public
123 123
 	 * @param        string $QST_required_text
124 124
 	 */
125
-	public function set_required_text( $QST_required_text = '' ) {
126
-		$this->set( 'QST_required_text', $QST_required_text );
125
+	public function set_required_text($QST_required_text = '') {
126
+		$this->set('QST_required_text', $QST_required_text);
127 127
 	}
128 128
 
129 129
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @access        public
135 135
 	 * @param        int $QST_order
136 136
 	 */
137
-	public function set_order( $QST_order = 0 ) {
138
-		$this->set( 'QST_order', $QST_order );
137
+	public function set_order($QST_order = 0) {
138
+		$this->set('QST_order', $QST_order);
139 139
 	}
140 140
 
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @access        public
147 147
 	 * @param        bool $QST_admin_only
148 148
 	 */
149
-	public function set_admin_only( $QST_admin_only = FALSE ) {
150
-		$this->set( 'QST_admin_only', $QST_admin_only );
149
+	public function set_admin_only($QST_admin_only = FALSE) {
150
+		$this->set('QST_admin_only', $QST_admin_only);
151 151
 	}
152 152
 
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @access        public
159 159
 	 * @param        int $QST_wp_user
160 160
 	 */
161
-	public function set_wp_user( $QST_wp_user = 1 ) {
162
-		$this->set( 'QST_wp_user', $QST_wp_user );
161
+	public function set_wp_user($QST_wp_user = 1) {
162
+		$this->set('QST_wp_user', $QST_wp_user);
163 163
 	}
164 164
 
165 165
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param 	bool $QST_deleted
177 177
 	 */
178
-	public function set_deleted( $QST_deleted = FALSE ) {
179
-		$this->set( 'QST_deleted', $QST_deleted );
178
+	public function set_deleted($QST_deleted = FALSE) {
179
+		$this->set('QST_deleted', $QST_deleted);
180 180
 	}
181 181
 
182 182
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function display_text() {
190
-		return $this->get( 'QST_display_text' );
190
+		return $this->get('QST_display_text');
191 191
 	}
192 192
 
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string
199 199
 	 */
200 200
 	public function admin_label() {
201
-		return $this->get( 'QST_admin_label' );
201
+		return $this->get('QST_admin_label');
202 202
 	}
203 203
 
204 204
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function system_ID() {
212
-		return $this->get( 'QST_system' );
212
+		return $this->get('QST_system');
213 213
 	}
214 214
 
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function required() {
223
-		return $this->get( 'QST_required' );
223
+		return $this->get('QST_required');
224 224
 	}
225 225
 
226 226
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function required_text() {
235
-		return $this->get( 'QST_required_text' );
235
+		return $this->get('QST_required_text');
236 236
 	}
237 237
 
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function type() {
246
-		return $this->get( 'QST_type' );
246
+		return $this->get('QST_type');
247 247
 	}
248 248
 
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @return int
256 256
 	 */
257 257
 	public function order() {
258
-		return $this->get( 'QST_order' );
258
+		return $this->get('QST_order');
259 259
 	}
260 260
 
261 261
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return boolean
268 268
 	 */
269 269
 	public function admin_only() {
270
-		return $this->get( 'QST_admin_only' );
270
+		return $this->get('QST_admin_only');
271 271
 	}
272 272
 
273 273
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return int
279 279
 	 */
280 280
 	public function wp_user() {
281
-		return $this->get( 'QST_wp_user' );
281
+		return $this->get('QST_wp_user');
282 282
 	}
283 283
 
284 284
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return boolean
290 290
 	 */
291 291
 	public function deleted() {
292
-		return $this->get( 'QST_deleted' );
292
+		return $this->get('QST_deleted');
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return EE_Answer[]
300 300
 	 */
301 301
 	public function answers() {
302
-		return $this->get_many_related( 'Answer' );
302
+		return $this->get_many_related('Answer');
303 303
 	}
304 304
 
305 305
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return boolean true = has answers, false = no answers.
310 310
 	 */
311 311
 	public function has_answers() {
312
-		return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE;
312
+		return $this->count_related('Answer') > 0 ? TRUE : FALSE;
313 313
 	}
314 314
 
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return EE_Question_Group[]
320 320
 	 */
321 321
 	public function question_groups() {
322
-		return $this->get_many_related( 'Question_Group' );
322
+		return $this->get_many_related('Question_Group');
323 323
 	}
324 324
 
325 325
 
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
 	 *                                                       whether it was trashed or not.
334 334
 	 * @return EE_Question_Option[]
335 335
 	 */
336
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
337
-		if ( ! $this->ID() ) {
336
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
337
+		if ( ! $this->ID()) {
338 338
 			return array();
339 339
 		}
340 340
 		$query_params = array();
341
-		if ( $selected_value_to_always_include ) {
342
-			if ( is_array( $selected_value_to_always_include ) ) {
343
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include );
341
+		if ($selected_value_to_always_include) {
342
+			if (is_array($selected_value_to_always_include)) {
343
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
344 344
 			} else {
345
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include;
345
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
346 346
 			}
347 347
 		}
348
-		if ( $notDeletedOptionsOnly ) {
349
-			$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE;
348
+		if ($notDeletedOptionsOnly) {
349
+			$query_params[0]['OR*options-query']['QSO_deleted'] = FALSE;
350 350
 		}
351 351
 		//order by QSO_order
352
-		$query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' );
353
-		return $this->get_many_related( 'Question_Option', $query_params );
352
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
353
+		return $this->get_many_related('Question_Option', $query_params);
354 354
 	}
355 355
 
356 356
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return \EE_Question_Option[]
361 361
 	 */
362 362
 	public function temp_options() {
363
-		return $this->_model_relations[ 'Question_Option' ];
363
+		return $this->_model_relations['Question_Option'];
364 364
 	}
365 365
 
366 366
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param EE_Question_Option $option
372 372
 	 * @return boolean success
373 373
 	 */
374
-	public function add_option( EE_Question_Option $option ) {
375
-		return $this->_add_relation_to( $option, 'Question_Option' );
374
+	public function add_option(EE_Question_Option $option) {
375
+		return $this->_add_relation_to($option, 'Question_Option');
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param EE_Question_Option $option
383 383
 	 * @return boolean success
384 384
 	 */
385
-	public function add_temp_option( EE_Question_Option $option ) {
386
-		$this->_model_relations[ 'Question_Option' ][ ] = $option;
385
+	public function add_temp_option(EE_Question_Option $option) {
386
+		$this->_model_relations['Question_Option'][] = $option;
387 387
 		return TRUE;
388 388
 	}
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param EE_Question_Option $option
395 395
 	 * @return boolean success
396 396
 	 */
397
-	public function remove_option( EE_Question_Option $option ) {
398
-		return $this->_remove_relation_to( $option, 'Question_Option' );
397
+	public function remove_option(EE_Question_Option $option) {
398
+		return $this->_remove_relation_to($option, 'Question_Option');
399 399
 	}
400 400
 
401 401
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @return bool
405 405
 	 */
406 406
 	public function is_system_question() {
407
-		$system_ID = $this->get( 'QST_system' );
408
-		return ! empty( $system_ID ) ? TRUE : FALSE;
407
+		$system_ID = $this->get('QST_system');
408
+		return ! empty($system_ID) ? TRUE : FALSE;
409 409
 	}
410 410
 
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	public function set_order_to_latest() {
420 420
 		$latest_order = $this->get_model()->get_latest_question_order();
421
-		$latest_order ++;
422
-		$this->set( 'QST_order', $latest_order );
421
+		$latest_order++;
422
+		$this->set('QST_order', $latest_order);
423 423
 	}
424 424
 
425 425
 
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 	 * Duplicates this question and its question options
439 439
 	 * @return \EE_Question
440 440
 	 */
441
-	public function duplicate( $options = array() ) {
441
+	public function duplicate($options = array()) {
442 442
 		$new_question = clone $this;
443
-		$new_question->set( 'QST_ID', null );
444
-		$new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) );
445
-		$new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) );
446
-		$new_question->set_system_ID( null );
447
-		$new_question->set_wp_user( get_current_user_id() );
443
+		$new_question->set('QST_ID', null);
444
+		$new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
445
+		$new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
446
+		$new_question->set_system_ID(null);
447
+		$new_question->set_wp_user(get_current_user_id());
448 448
                 //if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
-                $new_question->set_deleted( false );
449
+                $new_question->set_deleted(false);
450 450
 		$success = $new_question->save();
451
-		if( $success ) {
451
+		if ($success) {
452 452
 			//we don't totally want to duplicate the question options, because we want them to be for the NEW question
453
-			foreach( $this->options() as $question_option ) {
454
-				$question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) );
453
+			foreach ($this->options() as $question_option) {
454
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
455 455
 			}
456 456
 			return $new_question;
457 457
 		} else {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @return int|float
465 465
 	 */
466 466
 	public function max() {
467
-		return $this->get( 'QST_max' );
467
+		return $this->get('QST_max');
468 468
 	}
469 469
 
470 470
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param int|float $new_max
473 473
 	 * @return void
474 474
 	 */
475
-	public function set_max( $new_max ) {
476
-		$this->set( 'QST_max', $new_max );
475
+	public function set_max($new_max) {
476
+		$this->set('QST_max', $new_max);
477 477
 	}
478 478
 
479 479
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param array $input_constructor_args
486 486
 	 * @return EE_Form_Input_Base
487 487
 	 */
488
-	public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) {
488
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) {
489 489
 		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
490 490
 
491 491
 		$input_constructor_args = array_merge(
@@ -496,29 +496,29 @@  discard block
 block discarded – undo
496 496
 				),
497 497
 				$input_constructor_args
498 498
 			);
499
-		if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) {
500
-			$answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() );
499
+		if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
500
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
501 501
 		}
502 502
 		// has this question been answered ?
503
-		if ( $answer instanceof EE_Answer
503
+		if ($answer instanceof EE_Answer
504 504
              && $answer->value() !== ''
505 505
         ) {
506 506
 			//answer gets htmlspecialchars called on it, undo that please
507 507
 			//because the form input's display strategy may call esc_attr too
508 508
 			//which also does html special characters
509 509
 			$values_with_html_special_chars = $answer->value();
510
-			if( is_array( $values_with_html_special_chars ) ) {
511
-				$default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars );
510
+			if (is_array($values_with_html_special_chars)) {
511
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
512 512
 			} else {
513
-				$default_value = htmlspecialchars_decode( $values_with_html_special_chars );
513
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
514 514
 			}
515 515
 			$input_constructor_args['default'] = $default_value;
516 516
 		}
517
-		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() );
518
-		if( EEM_Question::instance()->question_type_is_in_category(  $this->type(), 'text' ) ) {
519
-			$input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy(
517
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
518
+		if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) {
519
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
520 520
 				null,
521
-				min( $max_max_for_question, $this->max() )
521
+				min($max_max_for_question, $this->max())
522 522
 			);
523 523
 		}
524 524
 		$input_constructor_args = apply_filters(
@@ -530,22 +530,22 @@  discard block
 block discarded – undo
530 530
 		);
531 531
 
532 532
 		$result = null;
533
-		switch ( $this->type() ) {
533
+		switch ($this->type()) {
534 534
 			// Text
535 535
 			case EEM_Question::QST_type_text :
536
-				$result = new EE_Text_Input( $input_constructor_args );
536
+				$result = new EE_Text_Input($input_constructor_args);
537 537
 				break;
538 538
 			// Textarea
539 539
 			case EEM_Question::QST_type_textarea :
540
-				$result = new EE_Text_Area_Input( $input_constructor_args );
540
+				$result = new EE_Text_Area_Input($input_constructor_args);
541 541
 				break;
542 542
 			// Radio Buttons
543 543
 			case EEM_Question::QST_type_radio :
544
-				$result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args );
544
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
545 545
 				break;
546 546
 			// Dropdown
547 547
 			case EEM_Question::QST_type_dropdown :
548
-				$result = new EE_Select_Input( $this->options(), $input_constructor_args );
548
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
549 549
 				break;
550 550
 			// State Dropdown
551 551
 			case EEM_Question::QST_type_state :
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 					$registration,
557 557
 					$answer
558 558
 				);				
559
-				$result = new EE_State_Select_Input( $state_options, $input_constructor_args );
559
+				$result = new EE_State_Select_Input($state_options, $input_constructor_args);
560 560
 				break;
561 561
 			// Country Dropdown
562 562
 			case EEM_Question::QST_type_country :
@@ -567,47 +567,47 @@  discard block
 block discarded – undo
567 567
 					$registration,
568 568
 					$answer
569 569
 				);
570
-				$result = new EE_Country_Select_Input( $country_options, $input_constructor_args );
570
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
571 571
 				break;
572 572
 			// Checkboxes
573 573
 			case EEM_Question::QST_type_checkbox :
574
-				$result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args );
574
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
575 575
 				break;
576 576
 			// Date
577 577
 			case EEM_Question::QST_type_date :
578
-				$result = new EE_Datepicker_Input( $input_constructor_args );
578
+				$result = new EE_Datepicker_Input($input_constructor_args);
579 579
 				break;
580 580
 			case EEM_Question::QST_type_html_textarea :
581
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy();
582
-				$result =  new EE_Text_Area_Input( $input_constructor_args );
583
-				$result->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' );
581
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
582
+				$result = new EE_Text_Area_Input($input_constructor_args);
583
+				$result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
584 584
 				break;
585 585
 			case EEM_Question::QST_type_email :
586
-				$result = new EE_Email_Input( $input_constructor_args );
586
+				$result = new EE_Email_Input($input_constructor_args);
587 587
 				break;
588 588
 			case EEM_Question::QST_type_us_phone :
589
-				$result = new EE_Phone_Input( $input_constructor_args );
589
+				$result = new EE_Phone_Input($input_constructor_args);
590 590
 				break;
591 591
 			case EEM_Question::QST_type_int :
592
-				$result = new EE_Integer_Input( $input_constructor_args );
592
+				$result = new EE_Integer_Input($input_constructor_args);
593 593
 				break;
594 594
 			case EEM_Question::QST_type_decimal :
595
-				$result = new EE_Float_Input( $input_constructor_args );
595
+				$result = new EE_Float_Input($input_constructor_args);
596 596
 				break;
597 597
 			case EEM_Question::QST_type_url :
598
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_URL_Validation_Strategy();
599
-				$result = new EE_Text_Input( $input_constructor_args );
598
+				$input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy();
599
+				$result = new EE_Text_Input($input_constructor_args);
600 600
 				break;
601 601
 			case EEM_Question::QST_type_year :
602 602
 				$result = new EE_Year_Input(
603 603
 						$input_constructor_args,
604
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this ),
605
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this ),
606
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this )
604
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this),
605
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this),
606
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this)
607 607
 						);
608 608
 				break;
609 609
 			case EEM_Question::QST_type_multi_select :
610
-				$result = new EE_Select_Multiple_Input( $this->options(), $input_constructor_args );
610
+				$result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
611 611
 				break;
612 612
 			// fallback
613 613
 			default :
@@ -618,12 +618,12 @@  discard block
 block discarded – undo
618 618
 					$this,
619 619
 					$input_constructor_args
620 620
 				);
621
-				if( ! $default_input ){
622
-					$default_input = new EE_Text_Input( $input_constructor_args );
621
+				if ( ! $default_input) {
622
+					$default_input = new EE_Text_Input($input_constructor_args);
623 623
 				}
624 624
 				$result = $default_input;
625 625
 		}
626
-		return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer );
626
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
627 627
 	}
628 628
 
629 629
 
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4
-require_once(EE_MODELS . 'EEM_CPT_Base.model.php');
4
+require_once(EE_MODELS.'EEM_CPT_Base.model.php');
5 5
 
6 6
 
7 7
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public static function instance($timezone = null)
60 60
     {
61 61
         // check if instance of EEM_Event already exists
62
-        if (! self::$_instance instanceof EEM_Event) {
62
+        if ( ! self::$_instance instanceof EEM_Event) {
63 63
             // instantiate Espresso_model
64 64
             self::$_instance = new self($timezone);
65 65
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function get_all_event_question_groups($EVT_ID = 0)
251 251
     {
252
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
252
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
253 253
             EE_Error::add_error(
254 254
                 esc_html__(
255 255
                     'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
280 280
     {
281
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
281
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
282 282
             EE_Error::add_error(
283 283
                 esc_html__(
284 284
                     'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
312 312
     {
313
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
313
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
314 314
             EE_Error::add_error(
315 315
                 esc_html__(
316 316
                     'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         $questions = array();
715 715
         // get all question groups for event
716 716
         $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
717
-        if (! empty($qgs)) {
717
+        if ( ! empty($qgs)) {
718 718
             foreach ($qgs as $qg) {
719 719
                 $qsts = $qg->questions();
720 720
                 $questions[$qg->ID()] = $qg->model_field_array();
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
                     $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
733 733
                     $qst_name = $qstn_id = $qst->ID();
734 734
                     $ans_id = $answer->ID();
735
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
735
+                    $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
736 736
                     $input_name = '';
737 737
                     $input_id = sanitize_key($qst->display_text());
738 738
                     $input_class = '';
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
                     $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'
741 741
                                                                                            . $input_name
742 742
                                                                                            . $qst_name;
743
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id;
743
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
744 744
                     $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
745 745
                     $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
746 746
                     $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@
 block discarded – undo
217 217
 
218 218
     /**
219 219
      * Used to override the default for the additional limit field.
220
-     * @param $additional_limit
220
+     * @param integer $additional_limit
221 221
      */
222 222
     public static function set_default_additional_limit($additional_limit)
223 223
     {
Please login to merge, or discard this patch.
Indentation   +788 added lines, -788 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 require_once(EE_MODELS . 'EEM_CPT_Base.model.php');
5 5
 
@@ -16,793 +16,793 @@  discard block
 block discarded – undo
16 16
 class EEM_Event extends EEM_CPT_Base
17 17
 {
18 18
 
19
-    /**
20
-     * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
21
-     * event
22
-     */
23
-    const sold_out = 'sold_out';
24
-
25
-    /**
26
-     * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
27
-     * date)
28
-     */
29
-    const postponed = 'postponed';
30
-
31
-    /**
32
-     * constant used by status(), indicating that the event will no longer occur
33
-     */
34
-    const cancelled = 'cancelled';
35
-
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected static $_default_reg_status;
41
-
42
-
43
-    /**
44
-     * This is the default for the additional limit field.
45
-     * @var int
46
-     */
47
-    protected static $_default_additional_limit = 10;
48
-
49
-
50
-    /**
51
-     * private instance of the Event object
52
-     *
53
-     * @var EEM_Event
54
-     */
55
-    protected static $_instance;
56
-
57
-
58
-
59
-    /**
60
-     *  This function is a singleton method used to instantiate the EEM_Event object
61
-     *
62
-     * @param string $timezone
63
-     * @return EEM_Event
64
-     * @throws \EE_Error
65
-     */
66
-    public static function instance($timezone = null)
67
-    {
68
-        // check if instance of EEM_Event already exists
69
-        if (! self::$_instance instanceof EEM_Event) {
70
-            // instantiate Espresso_model
71
-            self::$_instance = new self($timezone);
72
-        }
73
-        //we might have a timezone set, let set_timezone decide what to do with it
74
-        self::$_instance->set_timezone($timezone);
75
-        // EEM_Event object
76
-        return self::$_instance;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * Adds a relationship to Term_Taxonomy for each CPT_Base
83
-     *
84
-     * @param string $timezone
85
-     * @throws \EE_Error
86
-     */
87
-    protected function __construct($timezone = null)
88
-    {
89
-        EE_Registry::instance()->load_model('Registration');
90
-        $this->singular_item = esc_html__('Event', 'event_espresso');
91
-        $this->plural_item = esc_html__('Events', 'event_espresso');
92
-        // to remove Cancelled events from the frontend, copy the following filter to your functions.php file
93
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
94
-        // to remove Postponed events from the frontend, copy the following filter to your functions.php file
95
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
96
-        // to remove Sold Out events from the frontend, copy the following filter to your functions.php file
97
-        //	add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
98
-        $this->_custom_stati = apply_filters(
99
-            'AFEE__EEM_Event__construct___custom_stati',
100
-            array(
101
-                EEM_Event::cancelled => array(
102
-                    'label'  => esc_html__('Cancelled', 'event_espresso'),
103
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
104
-                ),
105
-                EEM_Event::postponed => array(
106
-                    'label'  => esc_html__('Postponed', 'event_espresso'),
107
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
108
-                ),
109
-                EEM_Event::sold_out  => array(
110
-                    'label'  => esc_html__('Sold Out', 'event_espresso'),
111
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
112
-                ),
113
-            )
114
-        );
115
-        self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
116
-            : self::$_default_reg_status;
117
-        $this->_tables = array(
118
-            'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
119
-            'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
120
-        );
121
-        $this->_fields = array(
122
-            'Event_CPT'  => array(
123
-                'EVT_ID'         => new EE_Primary_Key_Int_Field('ID',
124
-                    esc_html__('Post ID for Event', 'event_espresso')),
125
-                'EVT_name'       => new EE_Plain_Text_Field('post_title', esc_html__('Event Name', 'event_espresso'),
126
-                    false,
127
-                    ''),
128
-                'EVT_desc'       => new EE_Post_Content_Field('post_content',
129
-                    esc_html__('Event Description', 'event_espresso'),
130
-                    false, ''),
131
-                'EVT_slug'       => new EE_Slug_Field('post_name', esc_html__('Event Slug', 'event_espresso'), false,
132
-                    ''),
133
-                'EVT_created'    => new EE_Datetime_Field('post_date',
134
-                    esc_html__('Date/Time Event Created', 'event_espresso'),
135
-                    false, EE_Datetime_Field::now),
136
-                'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt',
137
-                    esc_html__('Event Short Description', 'event_espresso'), false, ''),
138
-                'EVT_modified'   => new EE_Datetime_Field('post_modified',
139
-                    esc_html__('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now),
140
-                'EVT_wp_user'    => new EE_WP_User_Field('post_author',
141
-                    esc_html__('Event Creator ID', 'event_espresso'),
142
-                    false),
143
-                'parent'         => new EE_Integer_Field('post_parent', esc_html__('Event Parent ID', 'event_espresso'),
144
-                    false,
145
-                    0),
146
-                'EVT_order'      => new EE_Integer_Field('menu_order', esc_html__('Event Menu Order', 'event_espresso'),
147
-                    false,
148
-                    1),
149
-                'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
150
-                // EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
151
-                'status'         => new EE_WP_Post_Status_Field('post_status',
152
-                    esc_html__('Event Status', 'event_espresso'),
153
-                    false, 'draft', $this->_custom_stati),
154
-            ),
155
-            'Event_Meta' => array(
156
-                'EVTM_ID'                         => new EE_DB_Only_Float_Field('EVTM_ID',
157
-                    esc_html__('Event Meta Row ID', 'event_espresso'), false),
158
-                'EVT_ID_fk'                       => new EE_DB_Only_Int_Field('EVT_ID',
159
-                    esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'), false),
160
-                'EVT_display_desc'                => new EE_Boolean_Field('EVT_display_desc',
161
-                    esc_html__('Display Description Flag', 'event_espresso'), false, 1),
162
-                'EVT_display_ticket_selector'     => new EE_Boolean_Field('EVT_display_ticket_selector',
163
-                    esc_html__('Display Ticket Selector Flag', 'event_espresso'), false, 1),
164
-                'EVT_visible_on'                  => new EE_Datetime_Field('EVT_visible_on',
165
-                    esc_html__('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now),
166
-                'EVT_additional_limit'            => new EE_Integer_Field(
167
-                    'EVT_additional_limit',
168
-                    esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
169
-                    true,
170
-                    self::$_default_additional_limit
171
-                ),
172
-                'EVT_default_registration_status' => new EE_Enum_Text_Field(
173
-                    'EVT_default_registration_status',
174
-                    esc_html__('Default Registration Status on this Event', 'event_espresso'), false,
175
-                    EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
176
-                ),
177
-                'EVT_member_only'                 => new EE_Boolean_Field('EVT_member_only',
178
-                    esc_html__('Member-Only Event Flag', 'event_espresso'), false, false),
179
-                'EVT_phone'                       => new EE_Plain_Text_Field('EVT_phone',
180
-                    esc_html__('Event Phone Number', 'event_espresso'), false),
181
-                'EVT_allow_overflow'              => new EE_Boolean_Field('EVT_allow_overflow',
182
-                    esc_html__('Allow Overflow on Event', 'event_espresso'), false, false),
183
-                'EVT_timezone_string'             => new EE_Plain_Text_Field('EVT_timezone_string',
184
-                    esc_html__('Timezone (name) for Event times', 'event_espresso'), false),
185
-                'EVT_external_URL'                => new EE_Plain_Text_Field('EVT_external_URL',
186
-                    esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'), true),
187
-                'EVT_donations'                   => new EE_Boolean_Field('EVT_donations',
188
-                    esc_html__('Accept Donations?', 'event_espresso'), false, false),
189
-            ),
190
-        );
191
-        $this->_model_relations = array(
192
-            'Registration'           => new EE_Has_Many_Relation(),
193
-            'Datetime'               => new EE_Has_Many_Relation(),
194
-            'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
195
-            'Venue'                  => new EE_HABTM_Relation('Event_Venue'),
196
-            'Term_Relationship'      => new EE_Has_Many_Relation(),
197
-            'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
198
-            'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
199
-            'Attendee'               => new EE_HABTM_Relation('Registration'),
200
-            'WP_User'                => new EE_Belongs_To_Relation(),
201
-        );
202
-        //this model is generally available for reading
203
-        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
204
-        parent::__construct($timezone);
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * @param string $default_reg_status
211
-     */
212
-    public static function set_default_reg_status($default_reg_status)
213
-    {
214
-        self::$_default_reg_status = $default_reg_status;
215
-        // if EEM_Event has already been instantiated,
216
-        // then we need to reset the `EVT_default_reg_status` field to use the new default.
217
-        if (self::$_instance instanceof EEM_Event) {
218
-            $default_reg_status = new EE_Enum_Text_Field(
219
-                'EVT_default_registration_status',
220
-                esc_html__('Default Registration Status on this Event', 'event_espresso'),
221
-                false,
222
-                $default_reg_status,
223
-                EEM_Registration::reg_status_array()
224
-            );
225
-            $default_reg_status->_construct_finalize(
226
-                'Event_Meta',
227
-                'EVT_default_registration_status',
228
-                'EEM_Event'
229
-            );
230
-            self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
231
-        }
232
-    }
233
-
234
-
235
-    /**
236
-     * Used to override the default for the additional limit field.
237
-     * @param $additional_limit
238
-     */
239
-    public static function set_default_additional_limit($additional_limit)
240
-    {
241
-        self::$_default_additional_limit = (int) $additional_limit;
242
-        if (self::$_instance instanceof EEM_Event) {
243
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
244
-                'EVT_additional_limit',
245
-                __('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
246
-                true,
247
-                self::$_default_additional_limit
248
-            );
249
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
250
-                'Event_Meta',
251
-                'EVT_additional_limit',
252
-                'EEM_Event'
253
-            );
254
-        }
255
-    }
256
-
257
-
258
-    /**
259
-     * Return what is currently set as the default additional limit for the event.
260
-     * @return int
261
-     */
262
-    public static function get_default_additional_limit()
263
-    {
264
-        return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
265
-    }
266
-
267
-
268
-    /**
269
-     * get_question_groups
270
-     *
271
-     * @return array
272
-     * @throws \EE_Error
273
-     */
274
-    public function get_all_question_groups()
275
-    {
276
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
277
-            array(
278
-                array('QSG_deleted' => false),
279
-                'order_by' => array('QSG_order' => 'ASC'),
280
-            )
281
-        );
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * get_question_groups
288
-     *
289
-     * @param int $EVT_ID
290
-     * @return array|bool
291
-     * @throws \EE_Error
292
-     */
293
-    public function get_all_event_question_groups($EVT_ID = 0)
294
-    {
295
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
296
-            EE_Error::add_error(
297
-                esc_html__(
298
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
299
-                    'event_espresso'
300
-                ),
301
-                __FILE__, __FUNCTION__, __LINE__
302
-            );
303
-            return false;
304
-        }
305
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
306
-            array(
307
-                array('EVT_ID' => $EVT_ID),
308
-            )
309
-        );
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * get_question_groups
316
-     *
317
-     * @param int     $EVT_ID
318
-     * @param boolean $for_primary_attendee
319
-     * @return array|bool
320
-     * @throws \EE_Error
321
-     */
322
-    public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
323
-    {
324
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
325
-            EE_Error::add_error(
326
-                esc_html__(
327
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
328
-                    'event_espresso'
329
-                ),
330
-                __FILE__, __FUNCTION__, __LINE__
331
-            );
332
-            return false;
333
-        }
334
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
335
-            array(
336
-                array(
337
-                    'EVT_ID'      => $EVT_ID,
338
-                    'EQG_primary' => $for_primary_attendee,
339
-                ),
340
-            )
341
-        );
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * get_question_groups
348
-     *
349
-     * @param int             $EVT_ID
350
-     * @param EE_Registration $registration
351
-     * @return array|bool
352
-     * @throws \EE_Error
353
-     */
354
-    public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
355
-    {
356
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
357
-            EE_Error::add_error(
358
-                esc_html__(
359
-                    'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
360
-                    'event_espresso'
361
-                ),
362
-                __FILE__, __FUNCTION__, __LINE__
363
-            );
364
-            return false;
365
-        }
366
-        $where_params = array(
367
-            'Event_Question_Group.EVT_ID'      => $EVT_ID,
368
-            'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
369
-            'QSG_deleted'                      => false,
370
-        );
371
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
372
-            array(
373
-                $where_params,
374
-                'order_by' => array('QSG_order' => 'ASC'),
375
-            )
376
-        );
377
-    }
378
-
379
-
380
-
381
-    /**
382
-     * get_question_target_db_column
383
-     *
384
-     * @param string $QSG_IDs csv list of $QSG IDs
385
-     * @return array|bool
386
-     * @throws \EE_Error
387
-     */
388
-    public function get_questions_in_groups($QSG_IDs = '')
389
-    {
390
-        if (empty($QSG_IDs)) {
391
-            EE_Error::add_error(
392
-                esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
393
-                __FILE__, __FUNCTION__, __LINE__
394
-            );
395
-            return false;
396
-        }
397
-        return EE_Registry::instance()->load_model('Question')->get_all(
398
-            array(
399
-                array(
400
-                    'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
401
-                    'QST_deleted'           => false,
402
-                    'QST_admin_only'        => is_admin(),
403
-                ),
404
-                'order_by' => 'QST_order',
405
-            )
406
-        );
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * get_options_for_question
413
-     *
414
-     * @param string $QST_IDs csv list of $QST IDs
415
-     * @return array|bool
416
-     * @throws \EE_Error
417
-     */
418
-    public function get_options_for_question($QST_IDs)
419
-    {
420
-        if (empty($QST_IDs)) {
421
-            EE_Error::add_error(
422
-                esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
423
-                __FILE__, __FUNCTION__, __LINE__
424
-            );
425
-            return false;
426
-        }
427
-        return EE_Registry::instance()->load_model('Question_Option')->get_all(
428
-            array(
429
-                array(
430
-                    'Question.QST_ID' => array('IN', $QST_IDs),
431
-                    'QSO_deleted'     => false,
432
-                ),
433
-                'order_by' => 'QSO_ID',
434
-            )
435
-        );
436
-    }
437
-
438
-
439
-
440
-
441
-
442
-
443
-
444
-    /**
445
-     * Gets all events that are published
446
-     * and have event start time earlier than now and an event end time later than now
447
-     *
448
-     * @param  array $query_params An array of query params to further filter on
449
-     *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
450
-     * @param bool   $count        whether to return the count or not (default FALSE)
451
-     * @return EE_Event[]|int
452
-     * @throws \EE_Error
453
-     */
454
-    public function get_active_events($query_params, $count = false)
455
-    {
456
-        if (array_key_exists(0, $query_params)) {
457
-            $where_params = $query_params[0];
458
-            unset($query_params[0]);
459
-        } else {
460
-            $where_params = array();
461
-        }
462
-        // if we have count make sure we don't include group by
463
-        if ($count && isset($query_params['group_by'])) {
464
-            unset($query_params['group_by']);
465
-        }
466
-        // let's add specific query_params for active_events
467
-        // keep in mind this will override any sent status in the query AND any date queries.
468
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
469
-        //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
470
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
471
-            $where_params['Datetime.DTT_EVT_start******'] = array(
472
-                '<',
473
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
474
-            );
475
-        } else {
476
-            $where_params['Datetime.DTT_EVT_start'] = array(
477
-                '<',
478
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
479
-            );
480
-        }
481
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
482
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
483
-                '>',
484
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
485
-            );
486
-        } else {
487
-            $where_params['Datetime.DTT_EVT_end'] = array(
488
-                '>',
489
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
490
-            );
491
-        }
492
-        $query_params[0] = $where_params;
493
-        // don't use $query_params with count()
494
-        // because we don't want to include additional query clauses like "GROUP BY"
495
-        return $count
496
-            ? $this->count(array($where_params), 'EVT_ID', true)
497
-            : $this->get_all($query_params);
498
-    }
499
-
500
-
501
-
502
-    /**
503
-     * get all events that are published and have an event start time later than now
504
-     *
505
-     * @param  array $query_params An array of query params to further filter on
506
-     *                             (Note that status and DTT_EVT_start will be overridden)
507
-     * @param bool   $count        whether to return the count or not (default FALSE)
508
-     * @return EE_Event[]|int
509
-     * @throws \EE_Error
510
-     */
511
-    public function get_upcoming_events($query_params, $count = false)
512
-    {
513
-        if (array_key_exists(0, $query_params)) {
514
-            $where_params = $query_params[0];
515
-            unset($query_params[0]);
516
-        } else {
517
-            $where_params = array();
518
-        }
519
-        // if we have count make sure we don't include group by
520
-        if ($count && isset($query_params['group_by'])) {
521
-            unset($query_params['group_by']);
522
-        }
523
-        // let's add specific query_params for active_events
524
-        // keep in mind this will override any sent status in the query AND any date queries.
525
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
526
-        // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
527
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
528
-            $where_params['Datetime.DTT_EVT_start*****'] = array(
529
-                '>',
530
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
531
-            );
532
-        } else {
533
-            $where_params['Datetime.DTT_EVT_start'] = array(
534
-                '>',
535
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
536
-            );
537
-        }
538
-        $query_params[0] = $where_params;
539
-        // don't use $query_params with count()
540
-        // because we don't want to include additional query clauses like "GROUP BY"
541
-        return $count
542
-            ? $this->count(array($where_params), 'EVT_ID', true)
543
-            : $this->get_all($query_params);
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * Gets all events that are published
550
-     * and have an event end time later than now
551
-     *
552
-     * @param  array $query_params An array of query params to further filter on
553
-     *                             (note that status and DTT_EVT_end will be overridden)
554
-     * @param bool   $count        whether to return the count or not (default FALSE)
555
-     * @return EE_Event[]|int
556
-     * @throws \EE_Error
557
-     */
558
-    public function get_active_and_upcoming_events($query_params, $count = false)
559
-    {
560
-        if (array_key_exists(0, $query_params)) {
561
-            $where_params = $query_params[0];
562
-            unset($query_params[0]);
563
-        } else {
564
-            $where_params = array();
565
-        }
566
-        // if we have count make sure we don't include group by
567
-        if ($count && isset($query_params['group_by'])) {
568
-            unset($query_params['group_by']);
569
-        }
570
-        // let's add specific query_params for active_events
571
-        // keep in mind this will override any sent status in the query AND any date queries.
572
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
573
-        // add where params for DTT_EVT_end
574
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
575
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
576
-                '>',
577
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
578
-            );
579
-        } else {
580
-            $where_params['Datetime.DTT_EVT_end'] = array(
581
-                '>',
582
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
-            );
584
-        }
585
-        $query_params[0] = $where_params;
586
-        // don't use $query_params with count()
587
-        // because we don't want to include additional query clauses like "GROUP BY"
588
-        return $count
589
-            ? $this->count(array($where_params), 'EVT_ID', true)
590
-            : $this->get_all($query_params);
591
-    }
592
-
593
-
594
-
595
-    /**
596
-     * This only returns events that are expired.
597
-     * They may still be published but all their datetimes have expired.
598
-     *
599
-     * @param  array $query_params An array of query params to further filter on
600
-     *                             (note that status and DTT_EVT_end will be overridden)
601
-     * @param bool   $count        whether to return the count or not (default FALSE)
602
-     * @return EE_Event[]|int
603
-     * @throws \EE_Error
604
-     */
605
-    public function get_expired_events($query_params, $count = false)
606
-    {
607
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
608
-        // if we have count make sure we don't include group by
609
-        if ($count && isset($query_params['group_by'])) {
610
-            unset($query_params['group_by']);
611
-        }
612
-        // let's add specific query_params for active_events
613
-        // keep in mind this will override any sent status in the query AND any date queries.
614
-        if (isset($where_params['status'])) {
615
-            unset($where_params['status']);
616
-        }
617
-        $exclude_query = $query_params;
618
-        if (isset($exclude_query[0])) {
619
-            unset($exclude_query[0]);
620
-        }
621
-        $exclude_query[0] = array(
622
-            'Datetime.DTT_EVT_end' => array(
623
-                '>',
624
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
625
-            ),
626
-        );
627
-        // first get all events that have datetimes where its not expired.
628
-        $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
629
-        $event_ids = array_keys($event_ids);
630
-        // if we have any additional query_params, let's add them to the 'AND' condition
631
-        $and_condition = array(
632
-            'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
633
-            'EVT_ID'               => array('NOT IN', $event_ids),
634
-        );
635
-        if (isset($where_params['OR'])) {
636
-            $and_condition['OR'] = $where_params['OR'];
637
-            unset($where_params['OR']);
638
-        }
639
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
640
-            $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
641
-            unset($where_params['Datetime.DTT_EVT_end']);
642
-        }
643
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
644
-            $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
645
-            unset($where_params['Datetime.DTT_EVT_start']);
646
-        }
647
-        // merge remaining $where params with the and conditions.
648
-        $where_params['AND'] = array_merge($and_condition, $where_params);
649
-        $query_params[0] = $where_params;
650
-        // don't use $query_params with count()
651
-        // because we don't want to include additional query clauses like "GROUP BY"
652
-        return $count
653
-            ? $this->count(array($where_params), 'EVT_ID', true)
654
-            : $this->get_all($query_params);
655
-    }
656
-
657
-
658
-
659
-    /**
660
-     * This basically just returns the events that do not have the publish status.
661
-     *
662
-     * @param  array   $query_params An array of query params to further filter on
663
-     *                               (note that status will be overwritten)
664
-     * @param  boolean $count        whether to return the count or not (default FALSE)
665
-     * @return EE_Event[]|int
666
-     * @throws \EE_Error
667
-     */
668
-    public function get_inactive_events($query_params, $count = false)
669
-    {
670
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
671
-        // let's add in specific query_params for inactive events.
672
-        if (isset($where_params['status'])) {
673
-            unset($where_params['status']);
674
-        }
675
-        // if we have count make sure we don't include group by
676
-        if ($count && isset($query_params['group_by'])) {
677
-            unset($query_params['group_by']);
678
-        }
679
-        // if we have any additional query_params, let's add them to the 'AND' condition
680
-        $where_params['AND']['status'] = array('!=', 'publish');
681
-        if (isset($where_params['OR'])) {
682
-            $where_params['AND']['OR'] = $where_params['OR'];
683
-            unset($where_params['OR']);
684
-        }
685
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
686
-            $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
687
-            unset($where_params['Datetime.DTT_EVT_end']);
688
-        }
689
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
690
-            $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
691
-            unset($where_params['Datetime.DTT_EVT_start']);
692
-        }
693
-        $query_params[0] = $where_params;
694
-        // don't use $query_params with count()
695
-        // because we don't want to include additional query clauses like "GROUP BY"
696
-        return $count
697
-            ? $this->count(array($where_params), 'EVT_ID', true)
698
-            : $this->get_all($query_params);
699
-    }
700
-
701
-
702
-
703
-    /**
704
-     * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
705
-     * because we don't want to override any existing global default prices but instead insert NEW prices that get
706
-     * attached to the event. See parent for param descriptions
707
-     *
708
-     * @param        $id_or_obj
709
-     * @param        $other_model_id_or_obj
710
-     * @param string $relationName
711
-     * @param array  $where_query
712
-     * @return EE_Base_Class
713
-     * @throws EE_Error
714
-     */
715
-    public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
716
-    {
717
-        if ($relationName === 'Price') {
718
-            //let's get the PRC object for the given ID to make sure that we aren't dealing with a default
719
-            $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
720
-            //if EVT_ID = 0, then this is a default
721
-            if ((int) $prc_chk->get('EVT_ID') === 0) {
722
-                //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
723
-                $prc_chk->set('PRC_ID', 0);
724
-            }
725
-            //run parent
726
-            return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
727
-        }
728
-        //otherwise carry on as normal
729
-        return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
730
-    }
731
-
732
-
733
-
734
-    /******************** DEPRECATED METHODS ********************/
735
-
736
-
737
-
738
-    /**
739
-     * _get_question_target_db_column
740
-     *
741
-     * @deprecated as of 4.8.32.rc.001. Instead consider using
742
-     *             EE_Registration_Custom_Questions_Form located in
743
-     *             admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
744
-     * @access     public
745
-     * @param    EE_Registration $registration (so existing answers for registration are included)
746
-     * @param    int             $EVT_ID       so all question groups are included for event (not just answers from
747
-     *                                         registration).
748
-     * @throws EE_Error
749
-     * @return    array
750
-     */
751
-    public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
752
-    {
753
-        if (empty($EVT_ID)) {
754
-            throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
755
-                'event_espresso'));
756
-        }
757
-        $questions = array();
758
-        // get all question groups for event
759
-        $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
760
-        if (! empty($qgs)) {
761
-            foreach ($qgs as $qg) {
762
-                $qsts = $qg->questions();
763
-                $questions[$qg->ID()] = $qg->model_field_array();
764
-                $questions[$qg->ID()]['QSG_questions'] = array();
765
-                foreach ($qsts as $qst) {
766
-                    if ($qst->is_system_question()) {
767
-                        continue;
768
-                    }
769
-                    $answer = EEM_Answer::instance()->get_one(array(
770
-                        array(
771
-                            'QST_ID' => $qst->ID(),
772
-                            'REG_ID' => $registration->ID(),
773
-                        ),
774
-                    ));
775
-                    $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
776
-                    $qst_name = $qstn_id = $qst->ID();
777
-                    $ans_id = $answer->ID();
778
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
779
-                    $input_name = '';
780
-                    $input_id = sanitize_key($qst->display_text());
781
-                    $input_class = '';
782
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
783
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'
784
-                                                                                           . $input_name
785
-                                                                                           . $qst_name;
786
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id;
787
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
788
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
789
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
790
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
791
-                    //leave responses as-is, don't convert stuff into html entities please!
792
-                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
793
-                    if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
794
-                        $QSOs = $qst->options(true, $answer->value());
795
-                        if (is_array($QSOs)) {
796
-                            foreach ($QSOs as $QSO_ID => $QSO) {
797
-                                $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
798
-                            }
799
-                        }
800
-                    }
801
-                }
802
-            }
803
-        }
804
-        return $questions;
805
-    }
19
+	/**
20
+	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
21
+	 * event
22
+	 */
23
+	const sold_out = 'sold_out';
24
+
25
+	/**
26
+	 * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
27
+	 * date)
28
+	 */
29
+	const postponed = 'postponed';
30
+
31
+	/**
32
+	 * constant used by status(), indicating that the event will no longer occur
33
+	 */
34
+	const cancelled = 'cancelled';
35
+
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected static $_default_reg_status;
41
+
42
+
43
+	/**
44
+	 * This is the default for the additional limit field.
45
+	 * @var int
46
+	 */
47
+	protected static $_default_additional_limit = 10;
48
+
49
+
50
+	/**
51
+	 * private instance of the Event object
52
+	 *
53
+	 * @var EEM_Event
54
+	 */
55
+	protected static $_instance;
56
+
57
+
58
+
59
+	/**
60
+	 *  This function is a singleton method used to instantiate the EEM_Event object
61
+	 *
62
+	 * @param string $timezone
63
+	 * @return EEM_Event
64
+	 * @throws \EE_Error
65
+	 */
66
+	public static function instance($timezone = null)
67
+	{
68
+		// check if instance of EEM_Event already exists
69
+		if (! self::$_instance instanceof EEM_Event) {
70
+			// instantiate Espresso_model
71
+			self::$_instance = new self($timezone);
72
+		}
73
+		//we might have a timezone set, let set_timezone decide what to do with it
74
+		self::$_instance->set_timezone($timezone);
75
+		// EEM_Event object
76
+		return self::$_instance;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * Adds a relationship to Term_Taxonomy for each CPT_Base
83
+	 *
84
+	 * @param string $timezone
85
+	 * @throws \EE_Error
86
+	 */
87
+	protected function __construct($timezone = null)
88
+	{
89
+		EE_Registry::instance()->load_model('Registration');
90
+		$this->singular_item = esc_html__('Event', 'event_espresso');
91
+		$this->plural_item = esc_html__('Events', 'event_espresso');
92
+		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
93
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
94
+		// to remove Postponed events from the frontend, copy the following filter to your functions.php file
95
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
96
+		// to remove Sold Out events from the frontend, copy the following filter to your functions.php file
97
+		//	add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
98
+		$this->_custom_stati = apply_filters(
99
+			'AFEE__EEM_Event__construct___custom_stati',
100
+			array(
101
+				EEM_Event::cancelled => array(
102
+					'label'  => esc_html__('Cancelled', 'event_espresso'),
103
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
104
+				),
105
+				EEM_Event::postponed => array(
106
+					'label'  => esc_html__('Postponed', 'event_espresso'),
107
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
108
+				),
109
+				EEM_Event::sold_out  => array(
110
+					'label'  => esc_html__('Sold Out', 'event_espresso'),
111
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
112
+				),
113
+			)
114
+		);
115
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
116
+			: self::$_default_reg_status;
117
+		$this->_tables = array(
118
+			'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
119
+			'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
120
+		);
121
+		$this->_fields = array(
122
+			'Event_CPT'  => array(
123
+				'EVT_ID'         => new EE_Primary_Key_Int_Field('ID',
124
+					esc_html__('Post ID for Event', 'event_espresso')),
125
+				'EVT_name'       => new EE_Plain_Text_Field('post_title', esc_html__('Event Name', 'event_espresso'),
126
+					false,
127
+					''),
128
+				'EVT_desc'       => new EE_Post_Content_Field('post_content',
129
+					esc_html__('Event Description', 'event_espresso'),
130
+					false, ''),
131
+				'EVT_slug'       => new EE_Slug_Field('post_name', esc_html__('Event Slug', 'event_espresso'), false,
132
+					''),
133
+				'EVT_created'    => new EE_Datetime_Field('post_date',
134
+					esc_html__('Date/Time Event Created', 'event_espresso'),
135
+					false, EE_Datetime_Field::now),
136
+				'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt',
137
+					esc_html__('Event Short Description', 'event_espresso'), false, ''),
138
+				'EVT_modified'   => new EE_Datetime_Field('post_modified',
139
+					esc_html__('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now),
140
+				'EVT_wp_user'    => new EE_WP_User_Field('post_author',
141
+					esc_html__('Event Creator ID', 'event_espresso'),
142
+					false),
143
+				'parent'         => new EE_Integer_Field('post_parent', esc_html__('Event Parent ID', 'event_espresso'),
144
+					false,
145
+					0),
146
+				'EVT_order'      => new EE_Integer_Field('menu_order', esc_html__('Event Menu Order', 'event_espresso'),
147
+					false,
148
+					1),
149
+				'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
150
+				// EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
151
+				'status'         => new EE_WP_Post_Status_Field('post_status',
152
+					esc_html__('Event Status', 'event_espresso'),
153
+					false, 'draft', $this->_custom_stati),
154
+			),
155
+			'Event_Meta' => array(
156
+				'EVTM_ID'                         => new EE_DB_Only_Float_Field('EVTM_ID',
157
+					esc_html__('Event Meta Row ID', 'event_espresso'), false),
158
+				'EVT_ID_fk'                       => new EE_DB_Only_Int_Field('EVT_ID',
159
+					esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'), false),
160
+				'EVT_display_desc'                => new EE_Boolean_Field('EVT_display_desc',
161
+					esc_html__('Display Description Flag', 'event_espresso'), false, 1),
162
+				'EVT_display_ticket_selector'     => new EE_Boolean_Field('EVT_display_ticket_selector',
163
+					esc_html__('Display Ticket Selector Flag', 'event_espresso'), false, 1),
164
+				'EVT_visible_on'                  => new EE_Datetime_Field('EVT_visible_on',
165
+					esc_html__('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now),
166
+				'EVT_additional_limit'            => new EE_Integer_Field(
167
+					'EVT_additional_limit',
168
+					esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
169
+					true,
170
+					self::$_default_additional_limit
171
+				),
172
+				'EVT_default_registration_status' => new EE_Enum_Text_Field(
173
+					'EVT_default_registration_status',
174
+					esc_html__('Default Registration Status on this Event', 'event_espresso'), false,
175
+					EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
176
+				),
177
+				'EVT_member_only'                 => new EE_Boolean_Field('EVT_member_only',
178
+					esc_html__('Member-Only Event Flag', 'event_espresso'), false, false),
179
+				'EVT_phone'                       => new EE_Plain_Text_Field('EVT_phone',
180
+					esc_html__('Event Phone Number', 'event_espresso'), false),
181
+				'EVT_allow_overflow'              => new EE_Boolean_Field('EVT_allow_overflow',
182
+					esc_html__('Allow Overflow on Event', 'event_espresso'), false, false),
183
+				'EVT_timezone_string'             => new EE_Plain_Text_Field('EVT_timezone_string',
184
+					esc_html__('Timezone (name) for Event times', 'event_espresso'), false),
185
+				'EVT_external_URL'                => new EE_Plain_Text_Field('EVT_external_URL',
186
+					esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'), true),
187
+				'EVT_donations'                   => new EE_Boolean_Field('EVT_donations',
188
+					esc_html__('Accept Donations?', 'event_espresso'), false, false),
189
+			),
190
+		);
191
+		$this->_model_relations = array(
192
+			'Registration'           => new EE_Has_Many_Relation(),
193
+			'Datetime'               => new EE_Has_Many_Relation(),
194
+			'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
195
+			'Venue'                  => new EE_HABTM_Relation('Event_Venue'),
196
+			'Term_Relationship'      => new EE_Has_Many_Relation(),
197
+			'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
198
+			'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
199
+			'Attendee'               => new EE_HABTM_Relation('Registration'),
200
+			'WP_User'                => new EE_Belongs_To_Relation(),
201
+		);
202
+		//this model is generally available for reading
203
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
204
+		parent::__construct($timezone);
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * @param string $default_reg_status
211
+	 */
212
+	public static function set_default_reg_status($default_reg_status)
213
+	{
214
+		self::$_default_reg_status = $default_reg_status;
215
+		// if EEM_Event has already been instantiated,
216
+		// then we need to reset the `EVT_default_reg_status` field to use the new default.
217
+		if (self::$_instance instanceof EEM_Event) {
218
+			$default_reg_status = new EE_Enum_Text_Field(
219
+				'EVT_default_registration_status',
220
+				esc_html__('Default Registration Status on this Event', 'event_espresso'),
221
+				false,
222
+				$default_reg_status,
223
+				EEM_Registration::reg_status_array()
224
+			);
225
+			$default_reg_status->_construct_finalize(
226
+				'Event_Meta',
227
+				'EVT_default_registration_status',
228
+				'EEM_Event'
229
+			);
230
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
231
+		}
232
+	}
233
+
234
+
235
+	/**
236
+	 * Used to override the default for the additional limit field.
237
+	 * @param $additional_limit
238
+	 */
239
+	public static function set_default_additional_limit($additional_limit)
240
+	{
241
+		self::$_default_additional_limit = (int) $additional_limit;
242
+		if (self::$_instance instanceof EEM_Event) {
243
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
244
+				'EVT_additional_limit',
245
+				__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
246
+				true,
247
+				self::$_default_additional_limit
248
+			);
249
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
250
+				'Event_Meta',
251
+				'EVT_additional_limit',
252
+				'EEM_Event'
253
+			);
254
+		}
255
+	}
256
+
257
+
258
+	/**
259
+	 * Return what is currently set as the default additional limit for the event.
260
+	 * @return int
261
+	 */
262
+	public static function get_default_additional_limit()
263
+	{
264
+		return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
265
+	}
266
+
267
+
268
+	/**
269
+	 * get_question_groups
270
+	 *
271
+	 * @return array
272
+	 * @throws \EE_Error
273
+	 */
274
+	public function get_all_question_groups()
275
+	{
276
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
277
+			array(
278
+				array('QSG_deleted' => false),
279
+				'order_by' => array('QSG_order' => 'ASC'),
280
+			)
281
+		);
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * get_question_groups
288
+	 *
289
+	 * @param int $EVT_ID
290
+	 * @return array|bool
291
+	 * @throws \EE_Error
292
+	 */
293
+	public function get_all_event_question_groups($EVT_ID = 0)
294
+	{
295
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
296
+			EE_Error::add_error(
297
+				esc_html__(
298
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
299
+					'event_espresso'
300
+				),
301
+				__FILE__, __FUNCTION__, __LINE__
302
+			);
303
+			return false;
304
+		}
305
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
306
+			array(
307
+				array('EVT_ID' => $EVT_ID),
308
+			)
309
+		);
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * get_question_groups
316
+	 *
317
+	 * @param int     $EVT_ID
318
+	 * @param boolean $for_primary_attendee
319
+	 * @return array|bool
320
+	 * @throws \EE_Error
321
+	 */
322
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
323
+	{
324
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
325
+			EE_Error::add_error(
326
+				esc_html__(
327
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
328
+					'event_espresso'
329
+				),
330
+				__FILE__, __FUNCTION__, __LINE__
331
+			);
332
+			return false;
333
+		}
334
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
335
+			array(
336
+				array(
337
+					'EVT_ID'      => $EVT_ID,
338
+					'EQG_primary' => $for_primary_attendee,
339
+				),
340
+			)
341
+		);
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * get_question_groups
348
+	 *
349
+	 * @param int             $EVT_ID
350
+	 * @param EE_Registration $registration
351
+	 * @return array|bool
352
+	 * @throws \EE_Error
353
+	 */
354
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
355
+	{
356
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
357
+			EE_Error::add_error(
358
+				esc_html__(
359
+					'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
360
+					'event_espresso'
361
+				),
362
+				__FILE__, __FUNCTION__, __LINE__
363
+			);
364
+			return false;
365
+		}
366
+		$where_params = array(
367
+			'Event_Question_Group.EVT_ID'      => $EVT_ID,
368
+			'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
369
+			'QSG_deleted'                      => false,
370
+		);
371
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
372
+			array(
373
+				$where_params,
374
+				'order_by' => array('QSG_order' => 'ASC'),
375
+			)
376
+		);
377
+	}
378
+
379
+
380
+
381
+	/**
382
+	 * get_question_target_db_column
383
+	 *
384
+	 * @param string $QSG_IDs csv list of $QSG IDs
385
+	 * @return array|bool
386
+	 * @throws \EE_Error
387
+	 */
388
+	public function get_questions_in_groups($QSG_IDs = '')
389
+	{
390
+		if (empty($QSG_IDs)) {
391
+			EE_Error::add_error(
392
+				esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
393
+				__FILE__, __FUNCTION__, __LINE__
394
+			);
395
+			return false;
396
+		}
397
+		return EE_Registry::instance()->load_model('Question')->get_all(
398
+			array(
399
+				array(
400
+					'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
401
+					'QST_deleted'           => false,
402
+					'QST_admin_only'        => is_admin(),
403
+				),
404
+				'order_by' => 'QST_order',
405
+			)
406
+		);
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * get_options_for_question
413
+	 *
414
+	 * @param string $QST_IDs csv list of $QST IDs
415
+	 * @return array|bool
416
+	 * @throws \EE_Error
417
+	 */
418
+	public function get_options_for_question($QST_IDs)
419
+	{
420
+		if (empty($QST_IDs)) {
421
+			EE_Error::add_error(
422
+				esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
423
+				__FILE__, __FUNCTION__, __LINE__
424
+			);
425
+			return false;
426
+		}
427
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(
428
+			array(
429
+				array(
430
+					'Question.QST_ID' => array('IN', $QST_IDs),
431
+					'QSO_deleted'     => false,
432
+				),
433
+				'order_by' => 'QSO_ID',
434
+			)
435
+		);
436
+	}
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+	/**
445
+	 * Gets all events that are published
446
+	 * and have event start time earlier than now and an event end time later than now
447
+	 *
448
+	 * @param  array $query_params An array of query params to further filter on
449
+	 *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
450
+	 * @param bool   $count        whether to return the count or not (default FALSE)
451
+	 * @return EE_Event[]|int
452
+	 * @throws \EE_Error
453
+	 */
454
+	public function get_active_events($query_params, $count = false)
455
+	{
456
+		if (array_key_exists(0, $query_params)) {
457
+			$where_params = $query_params[0];
458
+			unset($query_params[0]);
459
+		} else {
460
+			$where_params = array();
461
+		}
462
+		// if we have count make sure we don't include group by
463
+		if ($count && isset($query_params['group_by'])) {
464
+			unset($query_params['group_by']);
465
+		}
466
+		// let's add specific query_params for active_events
467
+		// keep in mind this will override any sent status in the query AND any date queries.
468
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
469
+		//if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
470
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
471
+			$where_params['Datetime.DTT_EVT_start******'] = array(
472
+				'<',
473
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
474
+			);
475
+		} else {
476
+			$where_params['Datetime.DTT_EVT_start'] = array(
477
+				'<',
478
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
479
+			);
480
+		}
481
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
482
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
483
+				'>',
484
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
485
+			);
486
+		} else {
487
+			$where_params['Datetime.DTT_EVT_end'] = array(
488
+				'>',
489
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
490
+			);
491
+		}
492
+		$query_params[0] = $where_params;
493
+		// don't use $query_params with count()
494
+		// because we don't want to include additional query clauses like "GROUP BY"
495
+		return $count
496
+			? $this->count(array($where_params), 'EVT_ID', true)
497
+			: $this->get_all($query_params);
498
+	}
499
+
500
+
501
+
502
+	/**
503
+	 * get all events that are published and have an event start time later than now
504
+	 *
505
+	 * @param  array $query_params An array of query params to further filter on
506
+	 *                             (Note that status and DTT_EVT_start will be overridden)
507
+	 * @param bool   $count        whether to return the count or not (default FALSE)
508
+	 * @return EE_Event[]|int
509
+	 * @throws \EE_Error
510
+	 */
511
+	public function get_upcoming_events($query_params, $count = false)
512
+	{
513
+		if (array_key_exists(0, $query_params)) {
514
+			$where_params = $query_params[0];
515
+			unset($query_params[0]);
516
+		} else {
517
+			$where_params = array();
518
+		}
519
+		// if we have count make sure we don't include group by
520
+		if ($count && isset($query_params['group_by'])) {
521
+			unset($query_params['group_by']);
522
+		}
523
+		// let's add specific query_params for active_events
524
+		// keep in mind this will override any sent status in the query AND any date queries.
525
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
526
+		// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
527
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
528
+			$where_params['Datetime.DTT_EVT_start*****'] = array(
529
+				'>',
530
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
531
+			);
532
+		} else {
533
+			$where_params['Datetime.DTT_EVT_start'] = array(
534
+				'>',
535
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
536
+			);
537
+		}
538
+		$query_params[0] = $where_params;
539
+		// don't use $query_params with count()
540
+		// because we don't want to include additional query clauses like "GROUP BY"
541
+		return $count
542
+			? $this->count(array($where_params), 'EVT_ID', true)
543
+			: $this->get_all($query_params);
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * Gets all events that are published
550
+	 * and have an event end time later than now
551
+	 *
552
+	 * @param  array $query_params An array of query params to further filter on
553
+	 *                             (note that status and DTT_EVT_end will be overridden)
554
+	 * @param bool   $count        whether to return the count or not (default FALSE)
555
+	 * @return EE_Event[]|int
556
+	 * @throws \EE_Error
557
+	 */
558
+	public function get_active_and_upcoming_events($query_params, $count = false)
559
+	{
560
+		if (array_key_exists(0, $query_params)) {
561
+			$where_params = $query_params[0];
562
+			unset($query_params[0]);
563
+		} else {
564
+			$where_params = array();
565
+		}
566
+		// if we have count make sure we don't include group by
567
+		if ($count && isset($query_params['group_by'])) {
568
+			unset($query_params['group_by']);
569
+		}
570
+		// let's add specific query_params for active_events
571
+		// keep in mind this will override any sent status in the query AND any date queries.
572
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
573
+		// add where params for DTT_EVT_end
574
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
575
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
576
+				'>',
577
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
578
+			);
579
+		} else {
580
+			$where_params['Datetime.DTT_EVT_end'] = array(
581
+				'>',
582
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
+			);
584
+		}
585
+		$query_params[0] = $where_params;
586
+		// don't use $query_params with count()
587
+		// because we don't want to include additional query clauses like "GROUP BY"
588
+		return $count
589
+			? $this->count(array($where_params), 'EVT_ID', true)
590
+			: $this->get_all($query_params);
591
+	}
592
+
593
+
594
+
595
+	/**
596
+	 * This only returns events that are expired.
597
+	 * They may still be published but all their datetimes have expired.
598
+	 *
599
+	 * @param  array $query_params An array of query params to further filter on
600
+	 *                             (note that status and DTT_EVT_end will be overridden)
601
+	 * @param bool   $count        whether to return the count or not (default FALSE)
602
+	 * @return EE_Event[]|int
603
+	 * @throws \EE_Error
604
+	 */
605
+	public function get_expired_events($query_params, $count = false)
606
+	{
607
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
608
+		// if we have count make sure we don't include group by
609
+		if ($count && isset($query_params['group_by'])) {
610
+			unset($query_params['group_by']);
611
+		}
612
+		// let's add specific query_params for active_events
613
+		// keep in mind this will override any sent status in the query AND any date queries.
614
+		if (isset($where_params['status'])) {
615
+			unset($where_params['status']);
616
+		}
617
+		$exclude_query = $query_params;
618
+		if (isset($exclude_query[0])) {
619
+			unset($exclude_query[0]);
620
+		}
621
+		$exclude_query[0] = array(
622
+			'Datetime.DTT_EVT_end' => array(
623
+				'>',
624
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
625
+			),
626
+		);
627
+		// first get all events that have datetimes where its not expired.
628
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
629
+		$event_ids = array_keys($event_ids);
630
+		// if we have any additional query_params, let's add them to the 'AND' condition
631
+		$and_condition = array(
632
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
633
+			'EVT_ID'               => array('NOT IN', $event_ids),
634
+		);
635
+		if (isset($where_params['OR'])) {
636
+			$and_condition['OR'] = $where_params['OR'];
637
+			unset($where_params['OR']);
638
+		}
639
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
640
+			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
641
+			unset($where_params['Datetime.DTT_EVT_end']);
642
+		}
643
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
644
+			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
645
+			unset($where_params['Datetime.DTT_EVT_start']);
646
+		}
647
+		// merge remaining $where params with the and conditions.
648
+		$where_params['AND'] = array_merge($and_condition, $where_params);
649
+		$query_params[0] = $where_params;
650
+		// don't use $query_params with count()
651
+		// because we don't want to include additional query clauses like "GROUP BY"
652
+		return $count
653
+			? $this->count(array($where_params), 'EVT_ID', true)
654
+			: $this->get_all($query_params);
655
+	}
656
+
657
+
658
+
659
+	/**
660
+	 * This basically just returns the events that do not have the publish status.
661
+	 *
662
+	 * @param  array   $query_params An array of query params to further filter on
663
+	 *                               (note that status will be overwritten)
664
+	 * @param  boolean $count        whether to return the count or not (default FALSE)
665
+	 * @return EE_Event[]|int
666
+	 * @throws \EE_Error
667
+	 */
668
+	public function get_inactive_events($query_params, $count = false)
669
+	{
670
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
671
+		// let's add in specific query_params for inactive events.
672
+		if (isset($where_params['status'])) {
673
+			unset($where_params['status']);
674
+		}
675
+		// if we have count make sure we don't include group by
676
+		if ($count && isset($query_params['group_by'])) {
677
+			unset($query_params['group_by']);
678
+		}
679
+		// if we have any additional query_params, let's add them to the 'AND' condition
680
+		$where_params['AND']['status'] = array('!=', 'publish');
681
+		if (isset($where_params['OR'])) {
682
+			$where_params['AND']['OR'] = $where_params['OR'];
683
+			unset($where_params['OR']);
684
+		}
685
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
686
+			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
687
+			unset($where_params['Datetime.DTT_EVT_end']);
688
+		}
689
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
690
+			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
691
+			unset($where_params['Datetime.DTT_EVT_start']);
692
+		}
693
+		$query_params[0] = $where_params;
694
+		// don't use $query_params with count()
695
+		// because we don't want to include additional query clauses like "GROUP BY"
696
+		return $count
697
+			? $this->count(array($where_params), 'EVT_ID', true)
698
+			: $this->get_all($query_params);
699
+	}
700
+
701
+
702
+
703
+	/**
704
+	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
705
+	 * because we don't want to override any existing global default prices but instead insert NEW prices that get
706
+	 * attached to the event. See parent for param descriptions
707
+	 *
708
+	 * @param        $id_or_obj
709
+	 * @param        $other_model_id_or_obj
710
+	 * @param string $relationName
711
+	 * @param array  $where_query
712
+	 * @return EE_Base_Class
713
+	 * @throws EE_Error
714
+	 */
715
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
716
+	{
717
+		if ($relationName === 'Price') {
718
+			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
719
+			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
720
+			//if EVT_ID = 0, then this is a default
721
+			if ((int) $prc_chk->get('EVT_ID') === 0) {
722
+				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
723
+				$prc_chk->set('PRC_ID', 0);
724
+			}
725
+			//run parent
726
+			return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
727
+		}
728
+		//otherwise carry on as normal
729
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
730
+	}
731
+
732
+
733
+
734
+	/******************** DEPRECATED METHODS ********************/
735
+
736
+
737
+
738
+	/**
739
+	 * _get_question_target_db_column
740
+	 *
741
+	 * @deprecated as of 4.8.32.rc.001. Instead consider using
742
+	 *             EE_Registration_Custom_Questions_Form located in
743
+	 *             admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
744
+	 * @access     public
745
+	 * @param    EE_Registration $registration (so existing answers for registration are included)
746
+	 * @param    int             $EVT_ID       so all question groups are included for event (not just answers from
747
+	 *                                         registration).
748
+	 * @throws EE_Error
749
+	 * @return    array
750
+	 */
751
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
752
+	{
753
+		if (empty($EVT_ID)) {
754
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
755
+				'event_espresso'));
756
+		}
757
+		$questions = array();
758
+		// get all question groups for event
759
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
760
+		if (! empty($qgs)) {
761
+			foreach ($qgs as $qg) {
762
+				$qsts = $qg->questions();
763
+				$questions[$qg->ID()] = $qg->model_field_array();
764
+				$questions[$qg->ID()]['QSG_questions'] = array();
765
+				foreach ($qsts as $qst) {
766
+					if ($qst->is_system_question()) {
767
+						continue;
768
+					}
769
+					$answer = EEM_Answer::instance()->get_one(array(
770
+						array(
771
+							'QST_ID' => $qst->ID(),
772
+							'REG_ID' => $registration->ID(),
773
+						),
774
+					));
775
+					$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
776
+					$qst_name = $qstn_id = $qst->ID();
777
+					$ans_id = $answer->ID();
778
+					$qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
779
+					$input_name = '';
780
+					$input_id = sanitize_key($qst->display_text());
781
+					$input_class = '';
782
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
783
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'
784
+																						   . $input_name
785
+																						   . $qst_name;
786
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id;
787
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
788
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
789
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
790
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
791
+					//leave responses as-is, don't convert stuff into html entities please!
792
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
793
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
794
+						$QSOs = $qst->options(true, $answer->value());
795
+						if (is_array($QSOs)) {
796
+							foreach ($QSOs as $QSO_ID => $QSO) {
797
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
798
+							}
799
+						}
800
+					}
801
+				}
802
+			}
803
+		}
804
+		return $questions;
805
+	}
806 806
 
807 807
 
808 808
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -462,29 +462,29 @@  discard block
 block discarded – undo
462 462
 
463 463
 
464 464
 
465
-    /**
466
-     * Gets all payments which have not been approved
467
-     * @return \EEI_Payment[]
468
-     * @throws EE_Error if a model is misconfigured somehow
469
-     */
465
+	/**
466
+	 * Gets all payments which have not been approved
467
+	 * @return \EEI_Payment[]
468
+	 * @throws EE_Error if a model is misconfigured somehow
469
+	 */
470 470
 	public function pending_payments()
471
-    {
472
-        return $this->get_many_related(
473
-            'Payment',
474
-            array(
475
-                array(
476
-                    'STS_ID' => EEM_Payment::status_id_pending
477
-                ),
478
-                'order_by' => array(
479
-                    'PAY_timestamp' => 'DESC'
480
-                )
481
-            )
482
-        );
483
-    }
484
-
485
-
486
-
487
-    /**
471
+	{
472
+		return $this->get_many_related(
473
+			'Payment',
474
+			array(
475
+				array(
476
+					'STS_ID' => EEM_Payment::status_id_pending
477
+				),
478
+				'order_by' => array(
479
+					'PAY_timestamp' => 'DESC'
480
+				)
481
+			)
482
+		);
483
+	}
484
+
485
+
486
+
487
+	/**
488 488
 	 * echoes $this->pretty_status()
489 489
 	 *
490 490
 	 * @param bool $show_icons
@@ -645,20 +645,20 @@  discard block
 block discarded – undo
645 645
 	 * @throws \EE_Error
646 646
 	 */
647 647
 	public function primary_registration() {
648
-        $registrations = (array) $this->get_many_related(
649
-            'Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))
650
-        );
651
-        foreach ($registrations as $registration) {
652
-            // valid registration that is NOT cancelled or declined ?
653
-            if(
654
-                $registration instanceof EE_Registration
655
-                && ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true)
656
-            ) {
657
-                return $registration;
658
-            }
659
-        }
660
-        // nothing valid found, so just return first thing from array of results
661
-        return reset($registrations);
648
+		$registrations = (array) $this->get_many_related(
649
+			'Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))
650
+		);
651
+		foreach ($registrations as $registration) {
652
+			// valid registration that is NOT cancelled or declined ?
653
+			if(
654
+				$registration instanceof EE_Registration
655
+				&& ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true)
656
+			) {
657
+				return $registration;
658
+			}
659
+		}
660
+		// nothing valid found, so just return first thing from array of results
661
+		return reset($registrations);
662 662
 	}
663 663
 
664 664
 
Please login to merge, or discard this patch.
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Transaction class
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 	 * @return EE_Transaction
35 35
 	 * @throws \EE_Error
36 36
 	 */
37
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
38
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
37
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
38
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
39 39
 		$txn = $has_object
40 40
 			? $has_object
41
-			: new self( $props_n_values, false, $timezone, $date_formats );
42
-		if ( ! $has_object ) {
43
-			$txn->set_old_txn_status( $txn->status_ID() );
41
+			: new self($props_n_values, false, $timezone, $date_formats);
42
+		if ( ! $has_object) {
43
+			$txn->set_old_txn_status($txn->status_ID());
44 44
 		}
45 45
 		return $txn;
46 46
 	}
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @return EE_Transaction
55 55
 	 * @throws \EE_Error
56 56
 	 */
57
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
58
-		$txn = new self( $props_n_values, TRUE, $timezone );
59
-		$txn->set_old_txn_status( $txn->status_ID() );
57
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
58
+		$txn = new self($props_n_values, TRUE, $timezone);
59
+		$txn->set_old_txn_status($txn->status_ID());
60 60
 		return $txn;
61 61
 	}
62 62
 
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function lock() {
75 75
 		// attempt to set lock, but if that fails...
76
-		if ( ! $this->add_extra_meta( 'lock', time(), true )  ) {
76
+		if ( ! $this->add_extra_meta('lock', time(), true)) {
77 77
 			// then attempt to remove the lock in case it is expired
78
-			if ( $this->_remove_expired_lock() ) {
78
+			if ($this->_remove_expired_lock()) {
79 79
 				// if removal was successful, then try setting lock again
80 80
 				$this->lock();
81 81
 			} else {
82 82
 				// but if the lock can not be removed, then throw an exception
83 83
 				throw new EE_Error(
84 84
 					sprintf(
85
-						__( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ),
85
+						__('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'),
86 86
 						$this->ID()
87 87
 					)
88 88
 				);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @throws \EE_Error
102 102
 	 */
103 103
 	public function unlock() {
104
-		return $this->delete_extra_meta( 'lock' );
104
+		return $this->delete_extra_meta('lock');
105 105
 	}
106 106
 
107 107
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function is_locked() {
124 124
 		// if TXN is not locked, then return false immediately
125
-		if ( ! $this->_get_lock() ) {
125
+		if ( ! $this->_get_lock()) {
126 126
 			return false;
127 127
 		}
128 128
 		// if not, then let's try and remove the lock in case it's expired...
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @throws \EE_Error
144 144
 	 */
145 145
 	protected function _get_lock() {
146
-		return (int)$this->get_extra_meta( 'lock', true, 0 );
146
+		return (int) $this->get_extra_meta('lock', true, 0);
147 147
 	}
148 148
 
149 149
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	protected function _remove_expired_lock() {
160 160
 		$locked = $this->_get_lock();
161
-		if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) {
161
+		if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) {
162 162
 			return $this->unlock();
163 163
 		}
164 164
 		return 0;
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param        float $total total value of transaction
174 174
 	 * @throws \EE_Error
175 175
 	 */
176
-	public function set_total( $total = 0.00 ) {
177
-		$this->set( 'TXN_total', (float)$total );
176
+	public function set_total($total = 0.00) {
177
+		$this->set('TXN_total', (float) $total);
178 178
 	}
179 179
 
180 180
 
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
187 187
 	 * @throws \EE_Error
188 188
 	 */
189
-	public function set_paid( $total_paid = 0.00 ) {
190
-		$this->set( 'TXN_paid', (float)$total_paid );
189
+	public function set_paid($total_paid = 0.00) {
190
+		$this->set('TXN_paid', (float) $total_paid);
191 191
 	}
192 192
 
193 193
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
200 200
 	 * @throws \EE_Error
201 201
 	 */
202
-	public function set_status( $status = '' ) {
203
-		$this->set( 'STS_ID', $status );
202
+	public function set_status($status = '') {
203
+		$this->set('STS_ID', $status);
204 204
 	}
205 205
 
206 206
 
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 * @param        string $hash_salt required for some payment gateways
213 213
 	 * @throws \EE_Error
214 214
 	 */
215
-	public function set_hash_salt( $hash_salt = '' ) {
216
-		$this->set( 'TXN_hash_salt', $hash_salt );
215
+	public function set_hash_salt($hash_salt = '') {
216
+		$this->set('TXN_hash_salt', $hash_salt);
217 217
 	}
218 218
 
219 219
 
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param array $txn_reg_steps
225 225
 	 * @throws \EE_Error
226 226
 	 */
227
-	public function set_reg_steps( array $txn_reg_steps ) {
228
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
227
+	public function set_reg_steps(array $txn_reg_steps) {
228
+		$this->set('TXN_reg_steps', $txn_reg_steps);
229 229
 	}
230 230
 
231 231
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @throws \EE_Error
238 238
 	 */
239 239
 	public function reg_steps() {
240
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
241
-		return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array();
240
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
241
+		return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array();
242 242
 	}
243 243
 
244 244
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @throws \EE_Error
249 249
 	 */
250 250
 	public function pretty_total() {
251
-		return $this->get_pretty( 'TXN_total' );
251
+		return $this->get_pretty('TXN_total');
252 252
 	}
253 253
 
254 254
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @throws \EE_Error
261 261
 	 */
262 262
 	public function pretty_paid() {
263
-		return $this->get_pretty( 'TXN_paid' );
263
+		return $this->get_pretty('TXN_paid');
264 264
 	}
265 265
 
266 266
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @throws \EE_Error
274 274
 	 */
275 275
 	public function remaining() {
276
-		return (float)( $this->total() - $this->paid() );
276
+		return (float) ($this->total() - $this->paid());
277 277
 	}
278 278
 
279 279
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @throws \EE_Error
287 287
 	 */
288 288
 	public function total() {
289
-		return (float)$this->get( 'TXN_total' );
289
+		return (float) $this->get('TXN_total');
290 290
 	}
291 291
 
292 292
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @throws \EE_Error
300 300
 	 */
301 301
 	public function paid() {
302
-		return (float)$this->get( 'TXN_paid' );
302
+		return (float) $this->get('TXN_paid');
303 303
 	}
304 304
 
305 305
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @throws \EE_Error
312 312
 	 */
313 313
 	public function get_cart_session() {
314
-		$session_data = (array)$this->get( 'TXN_session_data' );
315
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart
316
-			? $session_data[ 'cart' ]
314
+		$session_data = (array) $this->get('TXN_session_data');
315
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart
316
+			? $session_data['cart']
317 317
 			: null;
318 318
 	}
319 319
 
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 * @throws \EE_Error
327 327
 	 */
328 328
 	public function session_data() {
329
-		$session_data = $this->get( 'TXN_session_data' );
330
-		if ( empty( $session_data ) ) {
329
+		$session_data = $this->get('TXN_session_data');
330
+		if (empty($session_data)) {
331 331
 			$session_data = array(
332 332
 				'id'            => null,
333 333
 				'user_id'       => null,
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 	 * @param        EE_Session|array $session_data
351 351
 	 * @throws \EE_Error
352 352
 	 */
353
-	public function set_txn_session_data( $session_data ) {
354
-		if ( $session_data instanceof EE_Session ) {
355
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
353
+	public function set_txn_session_data($session_data) {
354
+		if ($session_data instanceof EE_Session) {
355
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
356 356
 		} else {
357
-			$this->set( 'TXN_session_data', $session_data );
357
+			$this->set('TXN_session_data', $session_data);
358 358
 		}
359 359
 	}
360 360
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * @throws \EE_Error
368 368
 	 */
369 369
 	public function hash_salt_() {
370
-		return $this->get( 'TXN_hash_salt' );
370
+		return $this->get('TXN_hash_salt');
371 371
 	}
372 372
 
373 373
 
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
 	 * @return    string | int
388 388
 	 * @throws \EE_Error
389 389
 	 */
390
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
391
-		if ( $format ) {
392
-			return $this->get_pretty( 'TXN_timestamp' );
393
-		} else if ( $gmt ) {
394
-			return $this->get_raw( 'TXN_timestamp' );
390
+	public function datetime($format = FALSE, $gmt = FALSE) {
391
+		if ($format) {
392
+			return $this->get_pretty('TXN_timestamp');
393
+		} else if ($gmt) {
394
+			return $this->get_raw('TXN_timestamp');
395 395
 		} else {
396
-			return $this->get( 'TXN_timestamp' );
396
+			return $this->get('TXN_timestamp');
397 397
 		}
398 398
 	}
399 399
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * @return EE_Registration[]
408 408
 	 * @throws \EE_Error
409 409
 	 */
410
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
411
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) )
410
+	public function registrations($query_params = array(), $get_cached = FALSE) {
411
+		$query_params = (empty($query_params) || ! is_array($query_params))
412 412
 			? array(
413 413
 				'order_by' => array(
414 414
 					'Event.EVT_name' => 'ASC',
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			)
419 419
 			: $query_params;
420 420
 		$query_params = $get_cached ? array() : $query_params;
421
-		return $this->get_many_related( 'Registration', $query_params );
421
+		return $this->get_many_related('Registration', $query_params);
422 422
 	}
423 423
 
424 424
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	 * @throws \EE_Error
432 432
 	 */
433 433
 	public function attendees() {
434
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
434
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
435 435
 	}
436 436
 
437 437
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 * @return EE_Payment[]
444 444
 	 * @throws \EE_Error
445 445
 	 */
446
-	public function payments( $query_params = array() ) {
447
-		return $this->get_many_related( 'Payment', $query_params );
446
+	public function payments($query_params = array()) {
447
+		return $this->get_many_related('Payment', $query_params);
448 448
 	}
449 449
 
450 450
 
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @throws \EE_Error
457 457
 	 */
458 458
 	public function approved_payments() {
459
-		EE_Registry::instance()->load_model( 'Payment' );
460
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
459
+		EE_Registry::instance()->load_model('Payment');
460
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
461 461
 	}
462 462
 
463 463
 
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @return string
492 492
 	 * @throws \EE_Error
493 493
 	 */
494
-	public function e_pretty_status( $show_icons = FALSE ) {
495
-		echo $this->pretty_status( $show_icons );
494
+	public function e_pretty_status($show_icons = FALSE) {
495
+		echo $this->pretty_status($show_icons);
496 496
 	}
497 497
 
498 498
 
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
 	 * @return string
505 505
 	 * @throws \EE_Error
506 506
 	 */
507
-	public function pretty_status( $show_icons = FALSE ) {
508
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
507
+	public function pretty_status($show_icons = FALSE) {
508
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
509 509
 		$icon = '';
510
-		switch ( $this->status_ID() ) {
510
+		switch ($this->status_ID()) {
511 511
 			case EEM_Transaction::complete_status_code:
512 512
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
513 513
 				break;
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
525 525
 				break;
526 526
 		}
527
-		return $icon . $status[ $this->status_ID() ];
527
+		return $icon.$status[$this->status_ID()];
528 528
 	}
529 529
 
530 530
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 * @throws \EE_Error
537 537
 	 */
538 538
 	public function status_ID() {
539
-		return $this->get( 'STS_ID' );
539
+		return $this->get('STS_ID');
540 540
 	}
541 541
 
542 542
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 * @throws \EE_Error
549 549
 	 */
550 550
 	public function is_free() {
551
-		return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' );
551
+		return EEH_Money::compare_floats($this->get('TXN_total'), 0, '==');
552 552
 	}
553 553
 
554 554
 
@@ -628,12 +628,12 @@  discard block
 block discarded – undo
628 628
 	 * @return string
629 629
 	 * @throws \EE_Error
630 630
 	 */
631
-	public function invoice_url( $type = 'html' ) {
631
+	public function invoice_url($type = 'html') {
632 632
 		$REG = $this->primary_registration();
633
-		if ( ! $REG instanceof EE_Registration ) {
633
+		if ( ! $REG instanceof EE_Registration) {
634 634
 			return '';
635 635
 		}
636
-		return $REG->invoice_url( $type );
636
+		return $REG->invoice_url($type);
637 637
 	}
638 638
 
639 639
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         );
651 651
         foreach ($registrations as $registration) {
652 652
             // valid registration that is NOT cancelled or declined ?
653
-            if(
653
+            if (
654 654
                 $registration instanceof EE_Registration
655 655
                 && ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true)
656 656
             ) {
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
 	 * @return string
671 671
 	 * @throws \EE_Error
672 672
 	 */
673
-	public function receipt_url( $type = 'html' ) {
673
+	public function receipt_url($type = 'html') {
674 674
 		$REG = $this->primary_registration();
675
-		if ( ! $REG instanceof EE_Registration ) {
675
+		if ( ! $REG instanceof EE_Registration) {
676 676
 			return '';
677 677
 		}
678
-		return $REG->receipt_url( $type );
678
+		return $REG->receipt_url($type);
679 679
 	}
680 680
 
681 681
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	 * @throws \EE_Error
701 701
 	 */
702 702
 	public function gateway_response_on_transaction() {
703
-		$payment = $this->get_first_related( 'Payment' );
703
+		$payment = $this->get_first_related('Payment');
704 704
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
705 705
 	}
706 706
 
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	 * @throws \EE_Error
714 714
 	 */
715 715
 	public function status_obj() {
716
-		return $this->get_first_related( 'Status' );
716
+		return $this->get_first_related('Status');
717 717
 	}
718 718
 
719 719
 
@@ -725,8 +725,8 @@  discard block
 block discarded – undo
725 725
 	 * @return EE_Extra_Meta
726 726
 	 * @throws \EE_Error
727 727
 	 */
728
-	public function extra_meta( $query_params = array() ) {
729
-		return $this->get_many_related( 'Extra_Meta', $query_params );
728
+	public function extra_meta($query_params = array()) {
729
+		return $this->get_many_related('Extra_Meta', $query_params);
730 730
 	}
731 731
 
732 732
 
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 	 * @return EE_Base_Class the relation was added to
739 739
 	 * @throws \EE_Error
740 740
 	 */
741
-	public function add_registration( EE_Registration $registration ) {
742
-		return $this->_add_relation_to( $registration, 'Registration' );
741
+	public function add_registration(EE_Registration $registration) {
742
+		return $this->_add_relation_to($registration, 'Registration');
743 743
 	}
744 744
 
745 745
 
@@ -752,8 +752,8 @@  discard block
 block discarded – undo
752 752
 	 * @return EE_Base_Class that was removed from being related
753 753
 	 * @throws \EE_Error
754 754
 	 */
755
-	public function remove_registration_with_id( $registration_or_id ) {
756
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
755
+	public function remove_registration_with_id($registration_or_id) {
756
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
757 757
 	}
758 758
 
759 759
 
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 	 * @throws \EE_Error
766 766
 	 */
767 767
 	public function items_purchased() {
768
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
768
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
769 769
 	}
770 770
 
771 771
 
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	 * @return EE_Base_Class the relation was added to
778 778
 	 * @throws \EE_Error
779 779
 	 */
780
-	public function add_line_item( EE_Line_Item $line_item ) {
781
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
780
+	public function add_line_item(EE_Line_Item $line_item) {
781
+		return $this->_add_relation_to($line_item, 'Line_Item');
782 782
 	}
783 783
 
784 784
 
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 	 * @return EE_Line_Item[]
791 791
 	 * @throws \EE_Error
792 792
 	 */
793
-	public function line_items( $query_params = array() ) {
794
-		return $this->get_many_related( 'Line_Item', $query_params );
793
+	public function line_items($query_params = array()) {
794
+		return $this->get_many_related('Line_Item', $query_params);
795 795
 	}
796 796
 
797 797
 
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	 * @throws \EE_Error
804 804
 	 */
805 805
 	public function tax_items() {
806
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
806
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
807 807
 	}
808 808
 
809 809
 
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
 	 * @return \EE_Line_Item
817 817
 	 * @throws \EE_Error
818 818
 	 */
819
-	public function total_line_item( $create_if_not_found = true ) {
820
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
821
-		if( ! $item && $create_if_not_found ){
822
-			$item = EEH_Line_Item::create_total_line_item( $this );
819
+	public function total_line_item($create_if_not_found = true) {
820
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
821
+		if ( ! $item && $create_if_not_found) {
822
+			$item = EEH_Line_Item::create_total_line_item($this);
823 823
 		}
824 824
 		return $item;
825 825
 	}
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
 	 */
836 836
 	public function tax_total() {
837 837
 		$tax_line_item = $this->tax_total_line_item();
838
-		if ( $tax_line_item ) {
839
-			return (float)$tax_line_item->total();
838
+		if ($tax_line_item) {
839
+			return (float) $tax_line_item->total();
840 840
 		} else {
841
-			return (float)0;
841
+			return (float) 0;
842 842
 		}
843 843
 	}
844 844
 
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 	 * @throws \EE_Error
852 852
 	 */
853 853
 	public function tax_total_line_item() {
854
-		return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() );
854
+		return EEH_Line_Item::get_taxes_subtotal($this->total_line_item());
855 855
 	}
856 856
 
857 857
 
@@ -862,20 +862,20 @@  discard block
 block discarded – undo
862 862
 	 * @return EE_Form_Section_Proper
863 863
 	 * @throws \EE_Error
864 864
 	 */
865
-	public function billing_info(){
865
+	public function billing_info() {
866 866
 		$payment_method = $this->payment_method();
867
-		if ( !$payment_method){
867
+		if ( ! $payment_method) {
868 868
 			EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
869 869
 			return false;
870 870
 		}
871 871
 		$primary_reg = $this->primary_registration();
872
-		if ( ! $primary_reg ) {
873
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
872
+		if ( ! $primary_reg) {
873
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
874 874
 			return FALSE;
875 875
 		}
876 876
 		$attendee = $primary_reg->attendee();
877
-		if ( ! $attendee ) {
878
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
877
+		if ( ! $attendee) {
878
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
879 879
 			return FALSE;
880 880
 		}
881 881
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -916,15 +916,15 @@  discard block
 block discarded – undo
916 916
 	 * @return EE_Payment_Method
917 917
 	 * @throws \EE_Error
918 918
 	 */
919
-	public function payment_method(){
919
+	public function payment_method() {
920 920
 		$pm = $this->get_first_related('Payment_Method');
921
-		if( $pm instanceof EE_Payment_Method ){
921
+		if ($pm instanceof EE_Payment_Method) {
922 922
 			return $pm;
923
-		}else{
923
+		} else {
924 924
 			$last_payment = $this->last_payment();
925
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
925
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
926 926
 				return $last_payment->payment_method();
927
-			}else{
927
+			} else {
928 928
 				return NULL;
929 929
 			}
930 930
 		}
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 	 * @throws \EE_Error
940 940
 	 */
941 941
 	public function last_payment() {
942
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
942
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
943 943
 	}
944 944
 
945 945
 
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 	 * @return EE_Line_Item[]
951 951
 	 * @throws \EE_Error
952 952
 	 */
953
-	public function non_ticket_line_items(){
954
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
953
+	public function non_ticket_line_items() {
954
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
955 955
 	}
956 956
 
957 957
 
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 	public function update_based_on_payments()
1000 1000
 	{
1001 1001
 		EE_Error::doing_it_wrong(
1002
-			__CLASS__ . '::' . __FUNCTION__,
1002
+			__CLASS__.'::'.__FUNCTION__,
1003 1003
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
1004 1004
 				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
1005 1005
 			'4.6.0'
@@ -1023,9 +1023,9 @@  discard block
 block discarded – undo
1023 1023
 	/**
1024 1024
 	 * @param string $old_txn_status
1025 1025
 	 */
1026
-	public function set_old_txn_status( $old_txn_status ) {
1026
+	public function set_old_txn_status($old_txn_status) {
1027 1027
 		// only set the first time
1028
-		if ( $this->_old_txn_status === null ) {
1028
+		if ($this->_old_txn_status === null) {
1029 1029
 			$this->_old_txn_status = $old_txn_status;
1030 1030
 		}
1031 1031
 	}
@@ -1054,17 +1054,17 @@  discard block
 block discarded – undo
1054 1054
 	 * @param bool           $check_all
1055 1055
 	 * @return boolean | int
1056 1056
 	 */
1057
-	private function _reg_steps_completed( $reg_step_slug = '', $check_all = true ) {
1057
+	private function _reg_steps_completed($reg_step_slug = '', $check_all = true) {
1058 1058
 		$reg_steps = $this->reg_steps();
1059
-		if ( ! is_array( $reg_steps ) || empty( $reg_steps ) ) {
1059
+		if ( ! is_array($reg_steps) || empty($reg_steps)) {
1060 1060
 			return false;
1061 1061
 		}
1062 1062
 		// loop thru reg steps array)
1063
-		foreach ( $reg_steps as $slug => $reg_step_completed ) {
1063
+		foreach ($reg_steps as $slug => $reg_step_completed) {
1064 1064
 			// if NOT checking ALL steps (only checking one step)
1065
-			if ( ! $check_all ) {
1065
+			if ( ! $check_all) {
1066 1066
 				// and this is the one
1067
-				if ( $slug === $reg_step_slug ) {
1067
+				if ($slug === $reg_step_slug) {
1068 1068
 					return $reg_step_completed;
1069 1069
 				} else {
1070 1070
 					// skip to next reg step in loop
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 				}
1073 1073
 			}
1074 1074
 			// $check_all must be true, else we would never have gotten to this point
1075
-			if ( $slug === $reg_step_slug ) {
1075
+			if ($slug === $reg_step_slug) {
1076 1076
 				// if we reach this point, then we are testing either:
1077 1077
 				// all_reg_steps_completed_except() or
1078 1078
 				// all_reg_steps_completed_except_final_step(),
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 				// ie: "is everything completed except the final step?"
1082 1082
 				// "that is correct... the final step is not completed, but all others are."
1083 1083
 				return $reg_step_completed !== true ? true : false;
1084
-			} else if ( $reg_step_completed !== true ) {
1084
+			} else if ($reg_step_completed !== true) {
1085 1085
 				// if any reg step is NOT completed, then ALL steps are not completed
1086 1086
 				return false;
1087 1087
 			}
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 	 * @param string         $exception
1116 1116
 	 * @return boolean
1117 1117
 	 */
1118
-	public function all_reg_steps_completed_except( $exception = '' ) {
1119
-		return $this->_reg_steps_completed( $exception );
1118
+	public function all_reg_steps_completed_except($exception = '') {
1119
+		return $this->_reg_steps_completed($exception);
1120 1120
 	}
1121 1121
 
1122 1122
 
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	 * @return boolean
1132 1132
 	 */
1133 1133
 	public function all_reg_steps_completed_except_final_step() {
1134
-		return $this->_reg_steps_completed( 'finalize_registration' );
1134
+		return $this->_reg_steps_completed('finalize_registration');
1135 1135
 	}
1136 1136
 
1137 1137
 
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param string         $reg_step_slug
1147 1147
 	 * @return boolean | int
1148 1148
 	 */
1149
-	public function reg_step_completed( $reg_step_slug ) {
1150
-		return $this->_reg_steps_completed( $reg_step_slug, false );
1149
+	public function reg_step_completed($reg_step_slug) {
1150
+		return $this->_reg_steps_completed($reg_step_slug, false);
1151 1151
 	}
1152 1152
 
1153 1153
 
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 	 * @return boolean | int
1163 1163
 	 */
1164 1164
 	public function final_reg_step_completed() {
1165
-		return $this->_reg_steps_completed( 'finalize_registration', false );
1165
+		return $this->_reg_steps_completed('finalize_registration', false);
1166 1166
 	}
1167 1167
 
1168 1168
 
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 	 * @return boolean
1177 1177
 	 * @throws \EE_Error
1178 1178
 	 */
1179
-	public function set_reg_step_initiated( $reg_step_slug ) {
1180
-		return $this->_set_reg_step_completed_status( $reg_step_slug, time() );
1179
+	public function set_reg_step_initiated($reg_step_slug) {
1180
+		return $this->_set_reg_step_completed_status($reg_step_slug, time());
1181 1181
 	}
1182 1182
 
1183 1183
 
@@ -1191,8 +1191,8 @@  discard block
 block discarded – undo
1191 1191
 	 * @return boolean
1192 1192
 	 * @throws \EE_Error
1193 1193
 	 */
1194
-	public function set_reg_step_completed( $reg_step_slug ) {
1195
-		return $this->_set_reg_step_completed_status( $reg_step_slug, true );
1194
+	public function set_reg_step_completed($reg_step_slug) {
1195
+		return $this->_set_reg_step_completed_status($reg_step_slug, true);
1196 1196
 	}
1197 1197
 
1198 1198
 
@@ -1206,8 +1206,8 @@  discard block
 block discarded – undo
1206 1206
 	 * @return boolean
1207 1207
 	 * @throws \EE_Error
1208 1208
 	 */
1209
-	public function set_reg_step_not_completed( $reg_step_slug ) {
1210
-		return $this->_set_reg_step_completed_status( $reg_step_slug, false );
1209
+	public function set_reg_step_not_completed($reg_step_slug) {
1210
+		return $this->_set_reg_step_completed_status($reg_step_slug, false);
1211 1211
 	}
1212 1212
 
1213 1213
 
@@ -1222,37 +1222,37 @@  discard block
 block discarded – undo
1222 1222
 	 * @return boolean
1223 1223
 	 * @throws \EE_Error
1224 1224
 	 */
1225
-	private function _set_reg_step_completed_status( $reg_step_slug, $status ) {
1225
+	private function _set_reg_step_completed_status($reg_step_slug, $status) {
1226 1226
 		// validate status
1227
-		$status = is_bool( $status ) || is_int( $status ) ? $status : false;
1227
+		$status = is_bool($status) || is_int($status) ? $status : false;
1228 1228
 		// get reg steps array
1229 1229
 		$txn_reg_steps = $this->reg_steps();
1230 1230
 		// if reg step does NOT exist
1231
-		if ( ! isset( $txn_reg_steps[ $reg_step_slug ] ) ) {
1231
+		if ( ! isset($txn_reg_steps[$reg_step_slug])) {
1232 1232
 			return false;
1233 1233
 		}
1234 1234
 		// if  we're trying to complete a step that is already completed
1235
-		if ( $txn_reg_steps[ $reg_step_slug ] === true ) {
1235
+		if ($txn_reg_steps[$reg_step_slug] === true) {
1236 1236
 			return true;
1237 1237
 		}
1238 1238
 		// if  we're trying to complete a step that hasn't even started
1239
-		if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) {
1239
+		if ($status === true && $txn_reg_steps[$reg_step_slug] === false) {
1240 1240
 			return false;
1241 1241
 		}
1242 1242
 		// if current status value matches the incoming value (no change)
1243 1243
 		// type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890
1244
-		if ( (int) $txn_reg_steps[ $reg_step_slug ] === (int) $status ) {
1244
+		if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) {
1245 1245
 			// this will happen in cases where multiple AJAX requests occur during the same step
1246 1246
 			return true;
1247 1247
 		}
1248 1248
 		// if we're trying to set a start time, but it has already been set...
1249
-		if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] ) ) {
1249
+		if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) {
1250 1250
 			// skip the update below, but don't return FALSE so that errors won't be displayed
1251 1251
 			return true;
1252 1252
 		}
1253 1253
 		// update completed status
1254
-		$txn_reg_steps[ $reg_step_slug ] = $status;
1255
-		$this->set_reg_steps( $txn_reg_steps );
1254
+		$txn_reg_steps[$reg_step_slug] = $status;
1255
+		$this->set_reg_steps($txn_reg_steps);
1256 1256
 		$this->save();
1257 1257
 		return true;
1258 1258
 	}
@@ -1268,11 +1268,11 @@  discard block
 block discarded – undo
1268 1268
 	 * @param string          $reg_step_slug
1269 1269
 	 * @return void
1270 1270
 	 */
1271
-	public function remove_reg_step( $reg_step_slug ) {
1271
+	public function remove_reg_step($reg_step_slug) {
1272 1272
 		// get reg steps array
1273 1273
 		$txn_reg_steps = $this->reg_steps();
1274
-		unset( $txn_reg_steps[ $reg_step_slug ] );
1275
-		$this->set_reg_steps( $txn_reg_steps );
1274
+		unset($txn_reg_steps[$reg_step_slug]);
1275
+		$this->set_reg_steps($txn_reg_steps);
1276 1276
 	}
1277 1277
 
1278 1278
 
@@ -1286,11 +1286,11 @@  discard block
 block discarded – undo
1286 1286
 	 * @param bool $save
1287 1287
 	 * @return bool
1288 1288
 	 */
1289
-	public function toggle_failed_transaction_status( $save = true ) {
1289
+	public function toggle_failed_transaction_status($save = true) {
1290 1290
 		// if TXN status is still set as "failed"...
1291
-		if ( $this->status_ID() === EEM_Transaction::failed_status_code ) {
1292
-			$this->set_status( EEM_Transaction::abandoned_status_code );
1293
-			if ( $save ) {
1291
+		if ($this->status_ID() === EEM_Transaction::failed_status_code) {
1292
+			$this->set_status(EEM_Transaction::abandoned_status_code);
1293
+			if ($save) {
1294 1294
 				$this->save();
1295 1295
 			}
1296 1296
 			return true;
@@ -1319,10 +1319,10 @@  discard block
 block discarded – undo
1319 1319
 				$this->primary_registration() instanceof EE_Registration
1320 1320
 				&& $this->primary_registration()->attendee() instanceof EE_Attendee
1321 1321
 			) {
1322
-				$this->set_status( EEM_Transaction::incomplete_status_code );
1322
+				$this->set_status(EEM_Transaction::incomplete_status_code);
1323 1323
 			} else {
1324 1324
 				// no contact record? yer abandoned!
1325
-				$this->set_status( EEM_Transaction::abandoned_status_code );
1325
+				$this->set_status(EEM_Transaction::abandoned_status_code);
1326 1326
 			}
1327 1327
 			return true;
1328 1328
 		}
@@ -1336,16 +1336,16 @@  discard block
 block discarded – undo
1336 1336
 	 * updates the TXN status based on the amount paid
1337 1337
 	 */
1338 1338
 	public function verify_abandoned_transaction_status() {
1339
-		if ( $this->status_ID() !== EEM_Transaction::abandoned_status_code ) {
1339
+		if ($this->status_ID() !== EEM_Transaction::abandoned_status_code) {
1340 1340
 			return;
1341 1341
 		}
1342
-		$payments = $this->get_many_related( 'Payment' );
1343
-		if ( ! empty( $payments ) ) {
1344
-			foreach ( $payments as $payment ) {
1345
-				if ( $payment instanceof EE_Payment ) {
1342
+		$payments = $this->get_many_related('Payment');
1343
+		if ( ! empty($payments)) {
1344
+			foreach ($payments as $payment) {
1345
+				if ($payment instanceof EE_Payment) {
1346 1346
 					// kk this TXN should NOT be abandoned
1347 1347
 					$this->update_status_based_on_total_paid();
1348
-					if ( is_admin() && ! ( defined('DOING_AJAX') && DOING_AJAX ) ) {
1348
+					if (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) {
1349 1349
 						EE_Error::add_attention(
1350 1350
 							sprintf(
1351 1351
 								esc_html__(
@@ -1361,8 +1361,8 @@  discard block
 block discarded – undo
1361 1361
 					$finalized = $this->final_reg_step_completed();
1362 1362
 					// if the 'finalize_registration' step has been initiated (has a timestamp)
1363 1363
 					// but has not yet been fully completed (TRUE)
1364
-					if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) {
1365
-						$this->set_reg_step_completed( 'finalize_registration' );
1364
+					if (is_int($finalized) && $finalized !== false && $finalized !== true) {
1365
+						$this->set_reg_step_completed('finalize_registration');
1366 1366
 						$this->save();
1367 1367
 					}
1368 1368
 				}
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class EED_Ticket_Selector extends  EED_Module {
24 24
 
25
-    /**
26
-     * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
-     */
28
-    private static $ticket_selector;
25
+	/**
26
+	 * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
+	 */
28
+	private static $ticket_selector;
29 29
 
30
-    /**
31
-     * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
-     */
33
-    private static $iframe_embed_button;
30
+	/**
31
+	 * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
+	 */
33
+	private static $iframe_embed_button;
34 34
 
35 35
 
36 36
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 		// routing
62 62
 		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63 63
 		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
64
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
64
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
+		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66 66
 		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
-        EED_Ticket_Selector::loadIframeAssets();
70
-    }
67
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
+		EED_Ticket_Selector::loadIframeAssets();
70
+	}
71 71
 
72 72
 
73 73
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 			10
87 87
 		);
88 88
 
89
-        /**
90
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
-         * registrations work.
92
-         */
89
+		/**
90
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
+		 * registrations work.
92
+		 */
93 93
 		add_action(
94
-		    'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
-            array('EED_Ticket_Selector', 'set_definitions'),
96
-            10
97
-        );
98
-    }
94
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
+			array('EED_Ticket_Selector', 'set_definitions'),
96
+			10
97
+		);
98
+	}
99 99
 
100 100
 
101 101
 
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
 
112 112
 		//if config is not set, initialize
113 113
 		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
114
-            \EED_Ticket_Selector::instance()->set_config();
115
-            \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
114
+			\EED_Ticket_Selector::instance()->set_config();
115
+			\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
117 117
 	}
118 118
 
119 119
 
120 120
 
121 121
 	/**
122
-     * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
-     */
124
-    public static function ticketSelector()
125
-    {
126
-        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
-        }
129
-        return EED_Ticket_Selector::$ticket_selector;
130
-    }
122
+	 * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
+	 */
124
+	public static function ticketSelector()
125
+	{
126
+		if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
+		}
129
+		return EED_Ticket_Selector::$ticket_selector;
130
+	}
131 131
 
132 132
 
133 133
 	/**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 
183
-    /**
184
-     *    creates buttons for selecting number of attendees for an event
185
-     *
186
-     * @access    public
187
-     * @param    WP_Post|int $event
188
-     * @param    bool        $view_details
189
-     * @return    string
190
-     * @throws \EE_Error
191
-     */
183
+	/**
184
+	 *    creates buttons for selecting number of attendees for an event
185
+	 *
186
+	 * @access    public
187
+	 * @param    WP_Post|int $event
188
+	 * @param    bool        $view_details
189
+	 * @return    string
190
+	 * @throws \EE_Error
191
+	 */
192 192
 	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193 193
 		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
194 194
 	}
@@ -209,244 +209,244 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 
212
-    /**
213
-     * cancel_ticket_selections
214
-     *
215
-     * @access        public
216
-     * @return        string
217
-     */
218
-    public static function cancel_ticket_selections()
219
-    {
220
-        $form = new ProcessTicketSelector();
221
-        return $form->cancelTicketSelections();
222
-    }
212
+	/**
213
+	 * cancel_ticket_selections
214
+	 *
215
+	 * @access        public
216
+	 * @return        string
217
+	 */
218
+	public static function cancel_ticket_selections()
219
+	{
220
+		$form = new ProcessTicketSelector();
221
+		return $form->cancelTicketSelections();
222
+	}
223 223
 
224 224
 
225 225
 
226 226
 	/**
227
-	* @return void
228
-	*/
227
+	 * @return void
228
+	 */
229 229
 	public static function translate_js_strings() {
230
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
-            'please select a datetime', 'event_espresso'
232
-        );
233
-    }
230
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
+			'please select a datetime', 'event_espresso'
232
+		);
233
+	}
234 234
 
235 235
 
236 236
 
237 237
 	/**
238
-	* 	load js
239
-	*
240
-	* 	@access 		public
241
-	* 	@return 		void
242
-	*/
238
+	 * 	load js
239
+	 *
240
+	 * 	@access 		public
241
+	 * 	@return 		void
242
+	 */
243 243
 	public static function load_tckt_slctr_assets() {
244 244
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
245
-            // add some style
246
-            wp_register_style(
247
-                'ticket_selector', 
248
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
249
-                array(),
250
-                EVENT_ESPRESSO_VERSION
251
-            );
252
-            wp_enqueue_style('ticket_selector');
253
-            // make it dance
254
-            wp_register_script(
255
-                'ticket_selector', 
256
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', 
257
-                array('espresso_core'), 
258
-                EVENT_ESPRESSO_VERSION, 
259
-                TRUE
260
-            );
245
+			// add some style
246
+			wp_register_style(
247
+				'ticket_selector', 
248
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
249
+				array(),
250
+				EVENT_ESPRESSO_VERSION
251
+			);
252
+			wp_enqueue_style('ticket_selector');
253
+			// make it dance
254
+			wp_register_script(
255
+				'ticket_selector', 
256
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', 
257
+				array('espresso_core'), 
258
+				EVENT_ESPRESSO_VERSION, 
259
+				TRUE
260
+			);
261 261
 			wp_enqueue_script('ticket_selector');
262
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
263
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
264
-        }
262
+			require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
263
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
264
+		}
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 * @return void
271
+	 */
272
+	public static function loadIframeAssets()
273
+	{
274
+		// for event lists
275
+		add_filter(
276
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
277
+			array('EED_Ticket_Selector', 'iframeCss')
278
+		);
279
+		add_filter(
280
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
281
+			array('EED_Ticket_Selector', 'iframeJs')
282
+		);
283
+		// for ticket selectors
284
+		add_filter(
285
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
286
+			array('EED_Ticket_Selector', 'iframeCss')
287
+		);
288
+		add_filter(
289
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
290
+			array('EED_Ticket_Selector', 'iframeJs')
291
+		);
292
+	}
293
+
294
+
295
+
296
+	/**
297
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
298
+	 *
299
+	 * @param array $iframe_css
300
+	 * @return array
301
+	 */
302
+	public static function iframeCss(array $iframe_css)
303
+	{
304
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
305
+		return $iframe_css;
265 306
 	}
266 307
 
267 308
 
268 309
 
269
-    /**
270
-     * @return void
271
-     */
272
-    public static function loadIframeAssets()
273
-    {
274
-        // for event lists
275
-        add_filter(
276
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
277
-            array('EED_Ticket_Selector', 'iframeCss')
278
-        );
279
-        add_filter(
280
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
281
-            array('EED_Ticket_Selector', 'iframeJs')
282
-        );
283
-        // for ticket selectors
284
-        add_filter(
285
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
286
-            array('EED_Ticket_Selector', 'iframeCss')
287
-        );
288
-        add_filter(
289
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
290
-            array('EED_Ticket_Selector', 'iframeJs')
291
-        );
292
-    }
293
-
294
-
295
-
296
-    /**
297
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
298
-     *
299
-     * @param array $iframe_css
300
-     * @return array
301
-     */
302
-    public static function iframeCss(array $iframe_css)
303
-    {
304
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
305
-        return $iframe_css;
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
312
-     *
313
-     * @param array $iframe_js
314
-     * @return array
315
-     */
316
-    public static function iframeJs(array $iframe_js)
317
-    {
318
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
319
-        return $iframe_js;
320
-    }
310
+	/**
311
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
312
+	 *
313
+	 * @param array $iframe_js
314
+	 * @return array
315
+	 */
316
+	public static function iframeJs(array $iframe_js)
317
+	{
318
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
319
+		return $iframe_js;
320
+	}
321 321
 
322 322
 
323 323
 	/****************************** DEPRECATED ******************************/
324 324
 
325 325
 
326 326
 
327
-    /**
328
-     * @deprecated
329
-     * @return string
330
-     * @throws \EE_Error
331
-     */
332
-    public static function display_view_details_btn()
333
-    {
334
-        // todo add doing_it_wrong() notice during next major version
335
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
336
-    }
337
-
338
-
339
-
340
-    /**
341
-     * @deprecated
342
-     * @return string
343
-     * @throws \EE_Error
344
-     */
345
-    public static function display_ticket_selector_submit()
346
-    {
347
-        // todo add doing_it_wrong() notice during next major version
348
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
349
-    }
350
-
351
-
352
-
353
-    /**
354
-     * @deprecated
355
-     * @param string $permalink_string
356
-     * @param int    $id
357
-     * @param string $new_title
358
-     * @param string $new_slug
359
-     * @return string
360
-     */
361
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
362
-    {
363
-        // todo add doing_it_wrong() notice during next major version
364
-        if (
365
-        	\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
366
-        	&& \EE_Registry::instance()->REQ->get('action') === 'edit'
367
-        ) {
368
-            $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
369
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
370
-        }
371
-        return '';
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * @deprecated
378
-     * @param int    $ID
379
-     * @param string $external_url
380
-     * @return string
381
-     */
382
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
383
-    {
384
-        // todo add doing_it_wrong() notice during next major version
385
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     * @deprecated
392
-     * @return string
393
-     */
394
-    public static function ticket_selector_form_close()
395
-    {
396
-        // todo add doing_it_wrong() notice during next major version
397
-        return EED_Ticket_Selector::ticketSelector()->formClose();
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     * @deprecated
404
-     * @return string
405
-     */
406
-    public static function no_tkt_slctr_end_dv()
407
-    {
408
-        // todo add doing_it_wrong() notice during next major version
409
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * @deprecated 4.9.13
416
-     * @return string
417
-     */
418
-    public static function tkt_slctr_end_dv()
419
-    {
420
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
-    }
422
-
423
-
424
-
425
-    /**
426
-     * @deprecated
427
-     * @return string
428
-     */
429
-    public static function clear_tkt_slctr()
430
-    {
431
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
-    }
433
-
434
-
435
-
436
-    /**
437
-     * @deprecated
438
-     */
439
-    public static function load_tckt_slctr_assets_admin()
440
-    {
441
-        // todo add doing_it_wrong() notice during next major version
442
-	    if (
443
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
444
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
445
-	    ) {
446
-		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
447
-            $iframe_embed_button->embedButtonAssets();
448
-        }
449
-    }
327
+	/**
328
+	 * @deprecated
329
+	 * @return string
330
+	 * @throws \EE_Error
331
+	 */
332
+	public static function display_view_details_btn()
333
+	{
334
+		// todo add doing_it_wrong() notice during next major version
335
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
336
+	}
337
+
338
+
339
+
340
+	/**
341
+	 * @deprecated
342
+	 * @return string
343
+	 * @throws \EE_Error
344
+	 */
345
+	public static function display_ticket_selector_submit()
346
+	{
347
+		// todo add doing_it_wrong() notice during next major version
348
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
349
+	}
350
+
351
+
352
+
353
+	/**
354
+	 * @deprecated
355
+	 * @param string $permalink_string
356
+	 * @param int    $id
357
+	 * @param string $new_title
358
+	 * @param string $new_slug
359
+	 * @return string
360
+	 */
361
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
362
+	{
363
+		// todo add doing_it_wrong() notice during next major version
364
+		if (
365
+			\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
366
+			&& \EE_Registry::instance()->REQ->get('action') === 'edit'
367
+		) {
368
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
369
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
370
+		}
371
+		return '';
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * @deprecated
378
+	 * @param int    $ID
379
+	 * @param string $external_url
380
+	 * @return string
381
+	 */
382
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
383
+	{
384
+		// todo add doing_it_wrong() notice during next major version
385
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 * @deprecated
392
+	 * @return string
393
+	 */
394
+	public static function ticket_selector_form_close()
395
+	{
396
+		// todo add doing_it_wrong() notice during next major version
397
+		return EED_Ticket_Selector::ticketSelector()->formClose();
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 * @deprecated
404
+	 * @return string
405
+	 */
406
+	public static function no_tkt_slctr_end_dv()
407
+	{
408
+		// todo add doing_it_wrong() notice during next major version
409
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * @deprecated 4.9.13
416
+	 * @return string
417
+	 */
418
+	public static function tkt_slctr_end_dv()
419
+	{
420
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
+	}
422
+
423
+
424
+
425
+	/**
426
+	 * @deprecated
427
+	 * @return string
428
+	 */
429
+	public static function clear_tkt_slctr()
430
+	{
431
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
+	}
433
+
434
+
435
+
436
+	/**
437
+	 * @deprecated
438
+	 */
439
+	public static function load_tckt_slctr_assets_admin()
440
+	{
441
+		// todo add doing_it_wrong() notice during next major version
442
+		if (
443
+			\EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
444
+			&& \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
445
+		) {
446
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
447
+			$iframe_embed_button->embedButtonAssets();
448
+		}
449
+	}
450 450
 
451 451
 
452 452
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\modules\ticket_selector\TicketSelectorIframe;
4 4
 use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Ticket_Selector
39 39
 	 */
40 40
 	public static function instance() {
41
-		return parent::get_instance( __CLASS__ );
41
+		return parent::get_instance(__CLASS__);
42 42
 	}
43 43
 
44 44
 
45 45
 
46
-	protected function set_config(){
47
-		$this->set_config_section( 'template_settings' );
48
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
49
-		$this->set_config_name( 'EED_Ticket_Selector' );
46
+	protected function set_config() {
47
+		$this->set_config_section('template_settings');
48
+		$this->set_config_class('EE_Ticket_Selector_Config');
49
+		$this->set_config_name('EED_Ticket_Selector');
50 50
 	}
51 51
 
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// routing
62
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
62
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
63
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
64 64
         EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
65
+        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
66
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
67
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
68
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
69 69
         EED_Ticket_Selector::loadIframeAssets();
70 70
     }
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		// to load assets for "espresso_events" page on the "edit" route (action)
83 83
 		add_action(
84 84
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
85
-			array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ),
85
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
86 86
 			10
87 87
 		);
88 88
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *  @return 	void
107 107
 	 */
108 108
 	public static function set_definitions() {
109
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
110
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
109
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
110
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
111 111
 
112 112
 		//if config is not set, initialize
113
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
113
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
114 114
             \EED_Ticket_Selector::instance()->set_config();
115 115
             \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * 	@param	WP $WP
138 138
 	 * 	@return void
139 139
 	 */
140
-	public function run( $WP ) {}
140
+	public function run($WP) {}
141 141
 
142 142
 
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton
146 146
 	 */
147 147
 	public static function getIframeEmbedButton() {
148
-		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) {
148
+		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
149 149
 			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
150 150
 		}
151 151
 		return self::$iframe_embed_button;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
      * @return    string
190 190
      * @throws \EE_Error
191 191
      */
192
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193
-		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
192
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
193
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
194 194
 	}
195 195
 
196 196
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	* 	@return 		void
242 242
 	*/
243 243
 	public static function load_tckt_slctr_assets() {
244
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
244
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
245 245
             // add some style
246 246
             wp_register_style(
247 247
                 'ticket_selector', 
248
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
248
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css',
249 249
                 array(),
250 250
                 EVENT_ESPRESSO_VERSION
251 251
             );
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
             // make it dance
254 254
             wp_register_script(
255 255
                 'ticket_selector', 
256
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', 
256
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', 
257 257
                 array('espresso_core'), 
258 258
                 EVENT_ESPRESSO_VERSION, 
259 259
                 TRUE
260 260
             );
261 261
 			wp_enqueue_script('ticket_selector');
262
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
262
+            require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
263 263
             \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
264 264
         }
265 265
 	}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      */
302 302
     public static function iframeCss(array $iframe_css)
303 303
     {
304
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
304
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
305 305
         return $iframe_css;
306 306
     }
307 307
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public static function iframeJs(array $iframe_js)
317 317
     {
318
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
318
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
319 319
         return $iframe_js;
320 320
     }
321 321
 
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
     {
441 441
         // todo add doing_it_wrong() notice during next major version
442 442
 	    if (
443
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
444
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
443
+		    \EE_Registry::instance()->REQ->get('page') === 'espresso_events'
444
+		    && \EE_Registry::instance()->REQ->get('action') === 'edit'
445 445
 	    ) {
446 446
 		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
447 447
             $iframe_embed_button->embedButtonAssets();
Please login to merge, or discard this patch.