Completed
Branch models-cleanup/main (0d2dda)
by
unknown
09:34
created
core/db_models/EEM_Extra_Join.model.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -23,32 +23,32 @@
 block discarded – undo
23 23
  */
24 24
 class EEM_Extra_Join extends EEM_Base
25 25
 {
26
-    // private instance of the Extra Join object
27
-    protected static $_instance = null;
26
+	// private instance of the Extra Join object
27
+	protected static $_instance = null;
28 28
 
29
-    public function __construct($timezone = '')
30
-    {
31
-        $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models);
32
-        $this->_tables = array(
33
-            'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'),
34
-        );
35
-        $this->_fields = array(
36
-            'Extra_Join' => array(
37
-                'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')),
38
-                'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join),
39
-                'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join),
40
-                'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join),
41
-                'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join),
29
+	public function __construct($timezone = '')
30
+	{
31
+		$models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models);
32
+		$this->_tables = array(
33
+			'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'),
34
+		);
35
+		$this->_fields = array(
36
+			'Extra_Join' => array(
37
+				'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')),
38
+				'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join),
39
+				'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join),
40
+				'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join),
41
+				'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join),
42 42
 
43
-            )
44
-        );
45
-        // this model is weird in that it has two foreign key columns which can point to any model/table.
46
-        // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other
47
-        // model linked to is alphabetically greater than event (eg venue).
48
-        // but if the model linked to is alphabetically lower (eg attendee),
49
-        // the foreign key to the event will be in "EXJ_second_model_ID"
50
-        // so normal usage of foreign keys is weird. So don't define any
51
-        // relations to other models because they won't work properly with this model
52
-        parent::__construct($timezone);
53
-    }
43
+			)
44
+		);
45
+		// this model is weird in that it has two foreign key columns which can point to any model/table.
46
+		// eg a foreign key to event will be in "EXJ_first_model_ID", provided the other
47
+		// model linked to is alphabetically greater than event (eg venue).
48
+		// but if the model linked to is alphabetically lower (eg attendee),
49
+		// the foreign key to the event will be in "EXJ_second_model_ID"
50
+		// so normal usage of foreign keys is weird. So don't define any
51
+		// relations to other models because they won't work properly with this model
52
+		parent::__construct($timezone);
53
+	}
54 54
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group_Question.model.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 class EEM_Question_Group_Question extends EEM_Base
15 15
 {
16 16
 
17
-    // private instance of the Attendee object
18
-    protected static $_instance = null;
17
+	// private instance of the Attendee object
18
+	protected static $_instance = null;
19 19
 
20 20
 
21
-    protected function __construct($timezone = '')
22
-    {
23
-        $this->singular_item    = esc_html__('Question Group to Question Link', 'event_espresso');
24
-        $this->plural_item      = esc_html__('Question Group to Question Links', 'event_espresso');
25
-        $this->_tables          = [
26
-            'Question_Group_Question' => new EE_Primary_Table('esp_question_group_question', 'QGQ_ID'),
27
-        ];
28
-        $this->_fields          = [
29
-            'Question_Group_Question' => [
30
-                'QGQ_ID'    => new EE_Primary_Key_Int_Field(
31
-                    'QGQ_ID',
32
-                    esc_html__('Question Group to Question Link ID', 'event_espresso')
33
-                ),
34
-                'QSG_ID'    => new EE_Foreign_Key_Int_Field(
35
-                    'QSG_ID',
36
-                    esc_html__('Question Group ID', 'event_espresso'),
37
-                    false,
38
-                    0,
39
-                    'Question_Group'
40
-                ),
41
-                'QST_ID'    => new EE_Foreign_Key_Int_Field(
42
-                    'QST_ID',
43
-                    esc_html__('Question Id', 'event_espresso'),
44
-                    false,
45
-                    0,
46
-                    'Question'
47
-                ),
48
-                'QGQ_order' => new EE_Integer_Field(
49
-                    'QGQ_order',
50
-                    esc_html__('Question Group Question Order', 'event_espresso'),
51
-                    false,
52
-                    0
53
-                ),
54
-            ],
55
-        ];
56
-        $this->_model_relations = [
57
-            'Question_Group' => new EE_Belongs_To_Relation(),
58
-            'Question'       => new EE_Belongs_To_Relation(),
59
-        ];
21
+	protected function __construct($timezone = '')
22
+	{
23
+		$this->singular_item    = esc_html__('Question Group to Question Link', 'event_espresso');
24
+		$this->plural_item      = esc_html__('Question Group to Question Links', 'event_espresso');
25
+		$this->_tables          = [
26
+			'Question_Group_Question' => new EE_Primary_Table('esp_question_group_question', 'QGQ_ID'),
27
+		];
28
+		$this->_fields          = [
29
+			'Question_Group_Question' => [
30
+				'QGQ_ID'    => new EE_Primary_Key_Int_Field(
31
+					'QGQ_ID',
32
+					esc_html__('Question Group to Question Link ID', 'event_espresso')
33
+				),
34
+				'QSG_ID'    => new EE_Foreign_Key_Int_Field(
35
+					'QSG_ID',
36
+					esc_html__('Question Group ID', 'event_espresso'),
37
+					false,
38
+					0,
39
+					'Question_Group'
40
+				),
41
+				'QST_ID'    => new EE_Foreign_Key_Int_Field(
42
+					'QST_ID',
43
+					esc_html__('Question Id', 'event_espresso'),
44
+					false,
45
+					0,
46
+					'Question'
47
+				),
48
+				'QGQ_order' => new EE_Integer_Field(
49
+					'QGQ_order',
50
+					esc_html__('Question Group Question Order', 'event_espresso'),
51
+					false,
52
+					0
53
+				),
54
+			],
55
+		];
56
+		$this->_model_relations = [
57
+			'Question_Group' => new EE_Belongs_To_Relation(),
58
+			'Question'       => new EE_Belongs_To_Relation(),
59
+		];
60 60
 
61
-        $this->_model_chain_to_wp_user = 'Question_Group';
61
+		$this->_model_chain_to_wp_user = 'Question_Group';
62 62
 
63
-        // this model is generally available for reading
64
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
65
-            new EE_Restriction_Generator_Public();
66
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
67
-            new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
69
-            new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
70
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
71
-            new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
63
+		// this model is generally available for reading
64
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
65
+			new EE_Restriction_Generator_Public();
66
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
67
+			new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
68
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
69
+			new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
70
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
71
+			new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system');
72 72
 
73
-        // use the caps for question groups
74
-        $this->_caps_slug = 'question_groups';
75
-        parent::__construct($timezone);
76
-    }
73
+		// use the caps for question groups
74
+		$this->_caps_slug = 'question_groups';
75
+		parent::__construct($timezone);
76
+	}
77 77
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Status.model.php 1 patch
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -11,292 +11,292 @@
 block discarded – undo
11 11
 class EEM_Status extends EEM_Base
12 12
 {
13 13
 
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18
-    /**
19
-     * @return EEM_Status
20
-     */
21
-    protected function __construct($timezone = '')
22
-    {
23
-        $this->singular_item    = __('Status', 'event_espresso');
24
-        $this->plural_item      = __('Stati', 'event_espresso');
25
-        $this->_tables          = array(
26
-            'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'),
27
-        );
28
-        $this->_fields          = array(
29
-            'StatusTable' => array(
30
-                'STS_ID'       => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')),
31
-                'STS_code'     => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''),
32
-                'STS_type'     => new EE_Enum_Text_Field(
33
-                    'STS_type',
34
-                    __("Type", "event_espresso"),
35
-                    false,
36
-                    'event',
37
-                    array(
38
-                        'event'        => __("Event", "event_espresso"),// deprecated
39
-                        'registration' => __("Registration", "event_espresso"),
40
-                        'transaction'  => __("Transaction", "event_espresso"),
41
-                        'payment'      => __("Payment", "event_espresso"),
42
-                        'email'        => __("Email", "event_espresso"),
43
-                        'message'      => __("Message", "event_espresso"),
44
-                    )
45
-                ),
46
-                'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false, false),
47
-                'STS_desc'     => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''),
48
-                'STS_open'     => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false),
49
-            ),
50
-        );
51
-        $this->_model_relations = array(
52
-            'Registration' => new EE_Has_Many_Relation(),
53
-            'Transaction'  => new EE_Has_Many_Relation(),
54
-            'Payment'      => new EE_Has_Many_Relation(),
55
-        );
56
-        // this model is generally available for reading
57
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
18
+	/**
19
+	 * @return EEM_Status
20
+	 */
21
+	protected function __construct($timezone = '')
22
+	{
23
+		$this->singular_item    = __('Status', 'event_espresso');
24
+		$this->plural_item      = __('Stati', 'event_espresso');
25
+		$this->_tables          = array(
26
+			'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'),
27
+		);
28
+		$this->_fields          = array(
29
+			'StatusTable' => array(
30
+				'STS_ID'       => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')),
31
+				'STS_code'     => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''),
32
+				'STS_type'     => new EE_Enum_Text_Field(
33
+					'STS_type',
34
+					__("Type", "event_espresso"),
35
+					false,
36
+					'event',
37
+					array(
38
+						'event'        => __("Event", "event_espresso"),// deprecated
39
+						'registration' => __("Registration", "event_espresso"),
40
+						'transaction'  => __("Transaction", "event_espresso"),
41
+						'payment'      => __("Payment", "event_espresso"),
42
+						'email'        => __("Email", "event_espresso"),
43
+						'message'      => __("Message", "event_espresso"),
44
+					)
45
+				),
46
+				'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false, false),
47
+				'STS_desc'     => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''),
48
+				'STS_open'     => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false),
49
+			),
50
+		);
51
+		$this->_model_relations = array(
52
+			'Registration' => new EE_Has_Many_Relation(),
53
+			'Transaction'  => new EE_Has_Many_Relation(),
54
+			'Payment'      => new EE_Has_Many_Relation(),
55
+		);
56
+		// this model is generally available for reading
57
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
58 58
 
59
-        parent::__construct($timezone);
60
-    }
59
+		parent::__construct($timezone);
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * This method provides the localized singular or plural string for a given status id
65
-     *
66
-     * @param  array   $statuses This should be an array of statuses in the format array( $status_id, $status_code ).
67
-     *                           That way if there isn't a translation in the index we'll return the default code.
68
-     * @param  boolean $plural   Whether to return plural string or not. Note, nearly all of the plural strings are the
69
-     *                           same as the singular (in English), however, this may NOT be the case with other
70
-     *                           languages
71
-     * @param  string  $schema   This can be either 'upper', 'lower', or 'sentence'.  Basically indicates how we want
72
-     *                           the status string returned ( UPPER, lower, Sentence)
73
-     * @throws EE_Error
74
-     * @return array             an array of translated strings for the incoming status id.
75
-     */
76
-    public function localized_status($statuses, $plural = false, $schema = 'upper')
77
-    {
78
-        // note these are all in lower case because ucwords() on upper case will NOT convert.
79
-        $translation_array = array(
80
-            EEM_Registration::status_id_pending_payment => array(
81
-                __('pending payment', 'event_espresso'), // singular
82
-                __('pending payments', 'event_espresso') // plural
83
-            ),
84
-            EEM_Registration::status_id_approved        => array(
85
-                __('approved', 'event_espresso'), // singular
86
-                __('approved', 'event_espresso') // plural
87
-            ),
88
-            EEM_Registration::status_id_not_approved    => array(
89
-                __('not approved', 'event_espresso'),
90
-                __('not approved', 'event_espresso'),
91
-            ),
92
-            EEM_Registration::status_id_cancelled       => array(
93
-                __('cancelled', 'event_espresso'),
94
-                __('cancelled', 'event_espresso'),
95
-            ),
96
-            EEM_Registration::status_id_incomplete      => array(
97
-                __('incomplete', 'event_espresso'),
98
-                __('incomplete', 'event_espresso'),
99
-            ),
100
-            EEM_Registration::status_id_declined        => array(
101
-                __('declined', 'event_espresso'),
102
-                __('declined', 'event_espresso'),
103
-            ),
104
-            EEM_Registration::status_id_wait_list       => array(
105
-                __('wait list', 'event_espresso'),
106
-                __('wait list', 'event_espresso'),
107
-            ),
108
-            EEM_Transaction::overpaid_status_code       => array(
109
-                __('overpaid', 'event_espresso'),
110
-                __('overpaid', 'event_espresso'),
111
-            ),
112
-            EEM_Transaction::complete_status_code       => array(
113
-                __('complete', 'event_espresso'),
114
-                __('complete', 'event_espresso'),
115
-            ),
116
-            EEM_Transaction::incomplete_status_code     => array(
117
-                __('incomplete', 'event_espresso'),
118
-                __('incomplete', 'event_espresso'),
119
-            ),
120
-            EEM_Transaction::failed_status_code         => array(
121
-                __('failed', 'event_espresso'),
122
-                __('failed', 'event_espresso'),
123
-            ),
124
-            EEM_Transaction::abandoned_status_code      => array(
125
-                __('abandoned', 'event_espresso'),
126
-                __('abandoned', 'event_espresso'),
127
-            ),
128
-            EEM_Payment::status_id_approved             => array(
129
-                __('accepted', 'event_espresso'),
130
-                __('accepted', 'event_espresso'),
131
-            ),
132
-            EEM_Payment::status_id_pending              => array(
133
-                __('pending', 'event_espresso'),
134
-                __('pending', 'event_espresso'),
135
-            ),
136
-            EEM_Payment::status_id_cancelled            => array(
137
-                __('cancelled', 'event_espresso'),
138
-                __('cancelled', 'event_espresso'),
139
-            ),
140
-            EEM_Payment::status_id_declined             => array(
141
-                __('declined', 'event_espresso'),
142
-                __('declined', 'event_espresso'),
143
-            ),
144
-            EEM_Payment::status_id_failed               => array(
145
-                __('failed', 'event_espresso'),
146
-                __('failed', 'event_espresso'),
147
-            ),
148
-            // following statuses are NOT part of the EEM_Status but to keep things centralized we include in here.
149
-            EEM_Event::sold_out                         => array(
150
-                __('sold out', 'event_espresso'),
151
-                __('sold out', 'event_espresso'),
152
-            ),
153
-            EEM_Event::postponed                        => array(
154
-                __('postponed', 'event_espresso'),
155
-                __('Postponed', 'event_espresso'),
156
-            ),
157
-            EEM_Event::cancelled                        => array(
158
-                __('cancelled', 'event_espresso'),
159
-                __('cancelled', 'event_espresso'),
160
-            ),
161
-            EE_Ticket::archived                         => array(
162
-                __('archived', 'event_espresso'),
163
-                __('archived', 'event_espresso'),
164
-            ),
165
-            EE_Ticket::expired                          => array(
166
-                __('expired', 'event_espresso'),
167
-                __('expired', 'event_espresso'),
168
-            ),
169
-            EE_Ticket::sold_out                         => array(
170
-                __('sold out', 'event_espresso'),
171
-                __('sold out', 'event_espresso'),
172
-            ),
173
-            EE_Ticket::pending                          => array(
174
-                __('upcoming', 'event_espresso'),
175
-                __('upcoming', 'event_espresso'),
176
-            ),
177
-            EE_Ticket::onsale                           => array(
178
-                __('on sale', 'event_espresso'),
179
-                __('on sale', 'event_espresso'),
180
-            ),
181
-            EE_Datetime::cancelled                      => array(
182
-                __('cancelled', 'event_espresso'),
183
-                __('cancelled', 'event_espresso'),
184
-            ),
185
-            EE_Datetime::sold_out                       => array(
186
-                __('sold out', 'event_espresso'),
187
-                __('sold out', 'event_espresso'),
188
-            ),
189
-            EE_Datetime::expired                        => array(
190
-                __('expired', 'event_espresso'),
191
-                __('expired', 'event_espresso'),
192
-            ),
193
-            EE_Datetime::inactive                       => array(
194
-                __('inactive', 'event_espresso'),
195
-                __('inactive', 'event_espresso'),
196
-            ),
197
-            EE_Datetime::upcoming                       => array(
198
-                __('upcoming', 'event_espresso'),
199
-                __('upcoming', 'event_espresso'),
200
-            ),
201
-            EE_Datetime::active                         => array(
202
-                __('active', 'event_espresso'),
203
-                __('active', 'event_espresso'),
204
-            ),
205
-            EE_Datetime::postponed                      => array(
206
-                __('postponed', 'event_espresso'),
207
-                __('postponed', 'event_espresso'),
208
-            ),
209
-            // messages related
210
-            EEM_Message::status_sent                    => array(
211
-                __('sent', 'event_espresso'),
212
-                __('sent', 'event_espresso'),
213
-            ),
214
-            EEM_Message::status_idle                    => array(
215
-                __('queued for sending', 'event_espresso'),
216
-                __('queued for sending', 'event_espresso'),
217
-            ),
218
-            EEM_Message::status_failed                  => array(
219
-                __('failed', 'event_espresso'),
220
-                __('failed', 'event_espresso'),
221
-            ),
222
-            EEM_Message::status_debug_only              => array(
223
-                __('debug only', 'event_espresso'),
224
-                __('debug only', 'event_espresso'),
225
-            ),
226
-            EEM_Message::status_messenger_executing     => array(
227
-                __('messenger is executing', 'event_espresso'),
228
-                __('messenger is executing', 'event_espresso'),
229
-            ),
230
-            EEM_Message::status_resend                  => array(
231
-                __('queued for resending', 'event_espresso'),
232
-                __('queued for resending', 'event_espresso'),
233
-            ),
234
-            EEM_Message::status_incomplete              => array(
235
-                __('queued for generating', 'event_espresso'),
236
-                __('queued for generating', 'event_espresso'),
237
-            ),
238
-            EEM_Message::status_retry                   => array(
239
-                __('failed sending, can be retried', 'event_espresso'),
240
-                __('failed sending, can be retried', 'event_espresso'),
241
-            ),
242
-            EEM_CPT_Base::post_status_publish           => array(
243
-                __('published', 'event_espresso'),
244
-                __('published', 'event_espresso'),
245
-            ),
246
-            EEM_CPT_Base::post_status_future            => array(
247
-                __('scheduled', 'event_espresso'),
248
-                __('scheduled', 'event_espresso'),
249
-            ),
250
-            EEM_CPT_Base::post_status_draft             => array(
251
-                __('draft', 'event_espresso'),
252
-                __('draft', 'event_espresso'),
253
-            ),
254
-            EEM_CPT_Base::post_status_pending           => array(
255
-                __('pending', 'event_espresso'),
256
-                __('pending', 'event_espresso'),
257
-            ),
258
-            EEM_CPT_Base::post_status_private           => array(
259
-                __('private', 'event_espresso'),
260
-                __('private', 'event_espresso'),
261
-            ),
262
-            EEM_CPT_Base::post_status_trashed           => array(
263
-                __('trashed', 'event_espresso'),
264
-                __('trashed', 'event_espresso'),
265
-            ),
266
-        );
63
+	/**
64
+	 * This method provides the localized singular or plural string for a given status id
65
+	 *
66
+	 * @param  array   $statuses This should be an array of statuses in the format array( $status_id, $status_code ).
67
+	 *                           That way if there isn't a translation in the index we'll return the default code.
68
+	 * @param  boolean $plural   Whether to return plural string or not. Note, nearly all of the plural strings are the
69
+	 *                           same as the singular (in English), however, this may NOT be the case with other
70
+	 *                           languages
71
+	 * @param  string  $schema   This can be either 'upper', 'lower', or 'sentence'.  Basically indicates how we want
72
+	 *                           the status string returned ( UPPER, lower, Sentence)
73
+	 * @throws EE_Error
74
+	 * @return array             an array of translated strings for the incoming status id.
75
+	 */
76
+	public function localized_status($statuses, $plural = false, $schema = 'upper')
77
+	{
78
+		// note these are all in lower case because ucwords() on upper case will NOT convert.
79
+		$translation_array = array(
80
+			EEM_Registration::status_id_pending_payment => array(
81
+				__('pending payment', 'event_espresso'), // singular
82
+				__('pending payments', 'event_espresso') // plural
83
+			),
84
+			EEM_Registration::status_id_approved        => array(
85
+				__('approved', 'event_espresso'), // singular
86
+				__('approved', 'event_espresso') // plural
87
+			),
88
+			EEM_Registration::status_id_not_approved    => array(
89
+				__('not approved', 'event_espresso'),
90
+				__('not approved', 'event_espresso'),
91
+			),
92
+			EEM_Registration::status_id_cancelled       => array(
93
+				__('cancelled', 'event_espresso'),
94
+				__('cancelled', 'event_espresso'),
95
+			),
96
+			EEM_Registration::status_id_incomplete      => array(
97
+				__('incomplete', 'event_espresso'),
98
+				__('incomplete', 'event_espresso'),
99
+			),
100
+			EEM_Registration::status_id_declined        => array(
101
+				__('declined', 'event_espresso'),
102
+				__('declined', 'event_espresso'),
103
+			),
104
+			EEM_Registration::status_id_wait_list       => array(
105
+				__('wait list', 'event_espresso'),
106
+				__('wait list', 'event_espresso'),
107
+			),
108
+			EEM_Transaction::overpaid_status_code       => array(
109
+				__('overpaid', 'event_espresso'),
110
+				__('overpaid', 'event_espresso'),
111
+			),
112
+			EEM_Transaction::complete_status_code       => array(
113
+				__('complete', 'event_espresso'),
114
+				__('complete', 'event_espresso'),
115
+			),
116
+			EEM_Transaction::incomplete_status_code     => array(
117
+				__('incomplete', 'event_espresso'),
118
+				__('incomplete', 'event_espresso'),
119
+			),
120
+			EEM_Transaction::failed_status_code         => array(
121
+				__('failed', 'event_espresso'),
122
+				__('failed', 'event_espresso'),
123
+			),
124
+			EEM_Transaction::abandoned_status_code      => array(
125
+				__('abandoned', 'event_espresso'),
126
+				__('abandoned', 'event_espresso'),
127
+			),
128
+			EEM_Payment::status_id_approved             => array(
129
+				__('accepted', 'event_espresso'),
130
+				__('accepted', 'event_espresso'),
131
+			),
132
+			EEM_Payment::status_id_pending              => array(
133
+				__('pending', 'event_espresso'),
134
+				__('pending', 'event_espresso'),
135
+			),
136
+			EEM_Payment::status_id_cancelled            => array(
137
+				__('cancelled', 'event_espresso'),
138
+				__('cancelled', 'event_espresso'),
139
+			),
140
+			EEM_Payment::status_id_declined             => array(
141
+				__('declined', 'event_espresso'),
142
+				__('declined', 'event_espresso'),
143
+			),
144
+			EEM_Payment::status_id_failed               => array(
145
+				__('failed', 'event_espresso'),
146
+				__('failed', 'event_espresso'),
147
+			),
148
+			// following statuses are NOT part of the EEM_Status but to keep things centralized we include in here.
149
+			EEM_Event::sold_out                         => array(
150
+				__('sold out', 'event_espresso'),
151
+				__('sold out', 'event_espresso'),
152
+			),
153
+			EEM_Event::postponed                        => array(
154
+				__('postponed', 'event_espresso'),
155
+				__('Postponed', 'event_espresso'),
156
+			),
157
+			EEM_Event::cancelled                        => array(
158
+				__('cancelled', 'event_espresso'),
159
+				__('cancelled', 'event_espresso'),
160
+			),
161
+			EE_Ticket::archived                         => array(
162
+				__('archived', 'event_espresso'),
163
+				__('archived', 'event_espresso'),
164
+			),
165
+			EE_Ticket::expired                          => array(
166
+				__('expired', 'event_espresso'),
167
+				__('expired', 'event_espresso'),
168
+			),
169
+			EE_Ticket::sold_out                         => array(
170
+				__('sold out', 'event_espresso'),
171
+				__('sold out', 'event_espresso'),
172
+			),
173
+			EE_Ticket::pending                          => array(
174
+				__('upcoming', 'event_espresso'),
175
+				__('upcoming', 'event_espresso'),
176
+			),
177
+			EE_Ticket::onsale                           => array(
178
+				__('on sale', 'event_espresso'),
179
+				__('on sale', 'event_espresso'),
180
+			),
181
+			EE_Datetime::cancelled                      => array(
182
+				__('cancelled', 'event_espresso'),
183
+				__('cancelled', 'event_espresso'),
184
+			),
185
+			EE_Datetime::sold_out                       => array(
186
+				__('sold out', 'event_espresso'),
187
+				__('sold out', 'event_espresso'),
188
+			),
189
+			EE_Datetime::expired                        => array(
190
+				__('expired', 'event_espresso'),
191
+				__('expired', 'event_espresso'),
192
+			),
193
+			EE_Datetime::inactive                       => array(
194
+				__('inactive', 'event_espresso'),
195
+				__('inactive', 'event_espresso'),
196
+			),
197
+			EE_Datetime::upcoming                       => array(
198
+				__('upcoming', 'event_espresso'),
199
+				__('upcoming', 'event_espresso'),
200
+			),
201
+			EE_Datetime::active                         => array(
202
+				__('active', 'event_espresso'),
203
+				__('active', 'event_espresso'),
204
+			),
205
+			EE_Datetime::postponed                      => array(
206
+				__('postponed', 'event_espresso'),
207
+				__('postponed', 'event_espresso'),
208
+			),
209
+			// messages related
210
+			EEM_Message::status_sent                    => array(
211
+				__('sent', 'event_espresso'),
212
+				__('sent', 'event_espresso'),
213
+			),
214
+			EEM_Message::status_idle                    => array(
215
+				__('queued for sending', 'event_espresso'),
216
+				__('queued for sending', 'event_espresso'),
217
+			),
218
+			EEM_Message::status_failed                  => array(
219
+				__('failed', 'event_espresso'),
220
+				__('failed', 'event_espresso'),
221
+			),
222
+			EEM_Message::status_debug_only              => array(
223
+				__('debug only', 'event_espresso'),
224
+				__('debug only', 'event_espresso'),
225
+			),
226
+			EEM_Message::status_messenger_executing     => array(
227
+				__('messenger is executing', 'event_espresso'),
228
+				__('messenger is executing', 'event_espresso'),
229
+			),
230
+			EEM_Message::status_resend                  => array(
231
+				__('queued for resending', 'event_espresso'),
232
+				__('queued for resending', 'event_espresso'),
233
+			),
234
+			EEM_Message::status_incomplete              => array(
235
+				__('queued for generating', 'event_espresso'),
236
+				__('queued for generating', 'event_espresso'),
237
+			),
238
+			EEM_Message::status_retry                   => array(
239
+				__('failed sending, can be retried', 'event_espresso'),
240
+				__('failed sending, can be retried', 'event_espresso'),
241
+			),
242
+			EEM_CPT_Base::post_status_publish           => array(
243
+				__('published', 'event_espresso'),
244
+				__('published', 'event_espresso'),
245
+			),
246
+			EEM_CPT_Base::post_status_future            => array(
247
+				__('scheduled', 'event_espresso'),
248
+				__('scheduled', 'event_espresso'),
249
+			),
250
+			EEM_CPT_Base::post_status_draft             => array(
251
+				__('draft', 'event_espresso'),
252
+				__('draft', 'event_espresso'),
253
+			),
254
+			EEM_CPT_Base::post_status_pending           => array(
255
+				__('pending', 'event_espresso'),
256
+				__('pending', 'event_espresso'),
257
+			),
258
+			EEM_CPT_Base::post_status_private           => array(
259
+				__('private', 'event_espresso'),
260
+				__('private', 'event_espresso'),
261
+			),
262
+			EEM_CPT_Base::post_status_trashed           => array(
263
+				__('trashed', 'event_espresso'),
264
+				__('trashed', 'event_espresso'),
265
+			),
266
+		);
267 267
 
268
-        $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
268
+		$translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array);
269 269
 
270
-        if (! is_array($statuses)) {
271
-            throw new EE_Error(__(
272
-                'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code',
273
-                'event_espresso'
274
-            ));
275
-        }
270
+		if (! is_array($statuses)) {
271
+			throw new EE_Error(__(
272
+				'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code',
273
+				'event_espresso'
274
+			));
275
+		}
276 276
 
277
-        $translation = array();
277
+		$translation = array();
278 278
 
279
-        foreach ($statuses as $id => $code) {
280
-            if (isset($translation_array[ $id ])) {
281
-                $translation[ $id ] = $plural ? $translation_array[ $id ][1] : $translation_array[ $id ][0];
282
-            } else {
283
-                $translation[ $id ] = $code;
284
-            }
279
+		foreach ($statuses as $id => $code) {
280
+			if (isset($translation_array[ $id ])) {
281
+				$translation[ $id ] = $plural ? $translation_array[ $id ][1] : $translation_array[ $id ][0];
282
+			} else {
283
+				$translation[ $id ] = $code;
284
+			}
285 285
 
286
-            // schema
287
-            switch ($schema) {
288
-                case 'lower':
289
-                    $translation[ $id ] = strtolower($translation[ $id ]); // even though these start in lower case, this will catch any statuses added via filter.
290
-                    break;
291
-                case 'sentence':
292
-                    $translation[ $id ] = ucwords($translation[ $id ]);
293
-                    break;
294
-                case 'upper':
295
-                    $translation[ $id ] = strtoupper($translation[ $id ]);
296
-                    break;
297
-            }
298
-        }
286
+			// schema
287
+			switch ($schema) {
288
+				case 'lower':
289
+					$translation[ $id ] = strtolower($translation[ $id ]); // even though these start in lower case, this will catch any statuses added via filter.
290
+					break;
291
+				case 'sentence':
292
+					$translation[ $id ] = ucwords($translation[ $id ]);
293
+					break;
294
+				case 'upper':
295
+					$translation[ $id ] = strtoupper($translation[ $id ]);
296
+					break;
297
+			}
298
+		}
299 299
 
300
-        return $translation;
301
-    }
300
+		return $translation;
301
+	}
302 302
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Price_Type.model.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -12,108 +12,108 @@  discard block
 block discarded – undo
12 12
 class EEM_Price_Type extends EEM_Soft_Delete_Base
13 13
 {
14 14
 
15
-    // private instance of the Price Type object
16
-    protected static $_instance = null;
17
-    // An array of the price type objects
18
-    public $type = null;
19
-
20
-    /**
21
-    *   Price Base types
22
-    *
23
-    *   @access private
24
-    *   @var int
25
-    */
26
-    public $base_types = null;
27
-
28
-    /**
29
-     * return an array of Base types. Keys are INTs which are used in the database,
30
-     * values are text-representations of the base type.
31
-     * @return array
32
-     */
33
-    public function get_base_types()
34
-    {
35
-        return $this->base_types;
36
-    }
37
-
38
-    /**
39
-     * Gets the name of the base
40
-     * @param type $base_type_int
41
-     * @return type
42
-     */
43
-    public function get_base_type_name($base_type_int)
44
-    {
45
-        return $this->base_types[ $base_type_int ];
46
-    }
47
-
48
-    /**
49
-     * constants for price base types. In the DB, we decided to store the price base type
50
-     * as an integer. So, to avoid just having magic numbers everwhere (eg, querying for
51
-     * all price types with PBT_ID = 2), we define these constants, to make code more understandable.
52
-     * So, as an example, to query for all price types that are a tax, we'd do
53
-     * EEM_PRice_Type::instance()->get_all(array(array('PBT_ID'=>EEM_Price_Type::base_type_tax)))
54
-     * instead of
55
-     * EEM_Price_Type::instance()->get_all(array(array('PBT_ID'=>2)))
56
-     * Although the 2nd is shorter, it's much less obvious what it's doing. Also, should these magic IDs ever
57
-     * change, we can continue to use the constant, by simply change its value.
58
-     */
59
-    const base_type_base_price = 1;
60
-    const base_type_discount = 2;
61
-    const base_type_surcharge = 3;
62
-    const base_type_tax = 4;
63
-    /**
64
-     *      private constructor to prevent direct creation
65
-     *      @Constructor
66
-     *      @access protected
67
-     *      @return void
68
-     */
69
-    protected function __construct($timezone = '')
70
-    {
71
-        $this->base_types = array(
72
-            EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'),
73
-            EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'),
74
-            EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'),
75
-            EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') );
76
-        $this->singular_item = __('Price Type', 'event_espresso');
77
-        $this->plural_item = __('Price Types', 'event_espresso');
78
-
79
-        $this->_tables = array(
80
-            'Price_Type' => new EE_Primary_Table('esp_price_type', 'PRT_ID')
81
-        );
82
-        $this->_fields = array(
83
-            'Price_Type' => array(
84
-                'PRT_ID' => new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')),
85
-                'PRT_name' => new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''),
86
-                'PBT_ID' => new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types),
87
-                'PRT_is_percent' => new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false),
88
-                'PRT_order' => new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0),
89
-                'PRT_deleted' => new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false),
90
-                'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), false),
91
-            )
92
-        );
93
-        $this->_model_relations = array(
94
-            'Price' => new EE_Has_Many_Relation(),
95
-            'WP_User' => new EE_Belongs_To_Relation(),
96
-        );
97
-        // this model is generally available for reading
98
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
99
-        // all price types are "default" in terms of capability names
100
-        $this->_caps_slug = 'default_price_types';
101
-        parent::__construct($timezone);
102
-    }
103
-
104
-
105
-
106
-
107
-    /**
108
-     *      instantiate a new price type object with blank/empty properties
109
-     *
110
-     *      @access     public
111
-     *      @return     mixed       array on success, FALSE on fail
112
-     */
113
-    public function get_new_price_type()
114
-    {
115
-        return EE_Price_Type::new_instance();
116
-    }
15
+	// private instance of the Price Type object
16
+	protected static $_instance = null;
17
+	// An array of the price type objects
18
+	public $type = null;
19
+
20
+	/**
21
+	 *   Price Base types
22
+	 *
23
+	 *   @access private
24
+	 *   @var int
25
+	 */
26
+	public $base_types = null;
27
+
28
+	/**
29
+	 * return an array of Base types. Keys are INTs which are used in the database,
30
+	 * values are text-representations of the base type.
31
+	 * @return array
32
+	 */
33
+	public function get_base_types()
34
+	{
35
+		return $this->base_types;
36
+	}
37
+
38
+	/**
39
+	 * Gets the name of the base
40
+	 * @param type $base_type_int
41
+	 * @return type
42
+	 */
43
+	public function get_base_type_name($base_type_int)
44
+	{
45
+		return $this->base_types[ $base_type_int ];
46
+	}
47
+
48
+	/**
49
+	 * constants for price base types. In the DB, we decided to store the price base type
50
+	 * as an integer. So, to avoid just having magic numbers everwhere (eg, querying for
51
+	 * all price types with PBT_ID = 2), we define these constants, to make code more understandable.
52
+	 * So, as an example, to query for all price types that are a tax, we'd do
53
+	 * EEM_PRice_Type::instance()->get_all(array(array('PBT_ID'=>EEM_Price_Type::base_type_tax)))
54
+	 * instead of
55
+	 * EEM_Price_Type::instance()->get_all(array(array('PBT_ID'=>2)))
56
+	 * Although the 2nd is shorter, it's much less obvious what it's doing. Also, should these magic IDs ever
57
+	 * change, we can continue to use the constant, by simply change its value.
58
+	 */
59
+	const base_type_base_price = 1;
60
+	const base_type_discount = 2;
61
+	const base_type_surcharge = 3;
62
+	const base_type_tax = 4;
63
+	/**
64
+	 *      private constructor to prevent direct creation
65
+	 *      @Constructor
66
+	 *      @access protected
67
+	 *      @return void
68
+	 */
69
+	protected function __construct($timezone = '')
70
+	{
71
+		$this->base_types = array(
72
+			EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'),
73
+			EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'),
74
+			EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'),
75
+			EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') );
76
+		$this->singular_item = __('Price Type', 'event_espresso');
77
+		$this->plural_item = __('Price Types', 'event_espresso');
78
+
79
+		$this->_tables = array(
80
+			'Price_Type' => new EE_Primary_Table('esp_price_type', 'PRT_ID')
81
+		);
82
+		$this->_fields = array(
83
+			'Price_Type' => array(
84
+				'PRT_ID' => new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')),
85
+				'PRT_name' => new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''),
86
+				'PBT_ID' => new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types),
87
+				'PRT_is_percent' => new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false),
88
+				'PRT_order' => new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0),
89
+				'PRT_deleted' => new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false),
90
+				'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), false),
91
+			)
92
+		);
93
+		$this->_model_relations = array(
94
+			'Price' => new EE_Has_Many_Relation(),
95
+			'WP_User' => new EE_Belongs_To_Relation(),
96
+		);
97
+		// this model is generally available for reading
98
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
99
+		// all price types are "default" in terms of capability names
100
+		$this->_caps_slug = 'default_price_types';
101
+		parent::__construct($timezone);
102
+	}
103
+
104
+
105
+
106
+
107
+	/**
108
+	 *      instantiate a new price type object with blank/empty properties
109
+	 *
110
+	 *      @access     public
111
+	 *      @return     mixed       array on success, FALSE on fail
112
+	 */
113
+	public function get_new_price_type()
114
+	{
115
+		return EE_Price_Type::new_instance();
116
+	}
117 117
 
118 118
 
119 119
 
@@ -132,33 +132,33 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @param type $query_params
134 134
  * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
135
-     * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
136
-     * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
135
+ * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
136
+ * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
137 137
  * @return boolean
138 138
  */
139
-    public function delete_permanently($query_params = array(), $allow_blocking = true)
140
-    {
139
+	public function delete_permanently($query_params = array(), $allow_blocking = true)
140
+	{
141 141
 
142
-        $would_be_deleted_price_types = $this->get_all_deleted_and_undeleted($query_params);
143
-        $would_be_deleted_price_type_ids = array_keys($would_be_deleted_price_types);
142
+		$would_be_deleted_price_types = $this->get_all_deleted_and_undeleted($query_params);
143
+		$would_be_deleted_price_type_ids = array_keys($would_be_deleted_price_types);
144 144
 
145
-        $ID = $query_params[0][ $this->get_primary_key_field()->get_name() ];
145
+		$ID = $query_params[0][ $this->get_primary_key_field()->get_name() ];
146 146
 
147
-        // check if any prices use this price type
148
-        $prc_query_params = array(array('PRT_ID' => array('IN',$would_be_deleted_price_type_ids)));
149
-        if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) {
150
-            $prices_names_and_ids = array();
151
-            foreach ($prices as $price) {
152
-                /* @var $price EE_Price */
153
-                $prices_names_and_ids[] = $price->name() . "(" . $price->ID() . ")";
154
-            }
155
-            $msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type.  If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids));
156
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
157
-            return false;
158
-        }
147
+		// check if any prices use this price type
148
+		$prc_query_params = array(array('PRT_ID' => array('IN',$would_be_deleted_price_type_ids)));
149
+		if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) {
150
+			$prices_names_and_ids = array();
151
+			foreach ($prices as $price) {
152
+				/* @var $price EE_Price */
153
+				$prices_names_and_ids[] = $price->name() . "(" . $price->ID() . ")";
154
+			}
155
+			$msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type.  If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids));
156
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
157
+			return false;
158
+		}
159 159
 
160 160
 
161 161
 
162
-        return parent::delete_permanently($query_params);
163
-    }
162
+		return parent::delete_permanently($query_params);
163
+	}
164 164
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 1 patch
Indentation   +752 added lines, -752 removed lines patch added patch discarded remove patch
@@ -16,757 +16,757 @@
 block discarded – undo
16 16
 class EE_Datetime_Field extends EE_Model_Field_Base
17 17
 {
18 18
 
19
-    /**
20
-     * The pattern we're looking for is if only the characters 0-9 are found and there are only
21
-     * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
22
-     *
23
-     * @type string unix_timestamp_regex
24
-     */
25
-    const unix_timestamp_regex = '/[0-9]{10,}/';
26
-
27
-    /**
28
-     * @type string mysql_timestamp_format
29
-     */
30
-    const mysql_timestamp_format = 'Y-m-d H:i:s';
31
-
32
-    /**
33
-     * @type string mysql_date_format
34
-     */
35
-    const mysql_date_format = 'Y-m-d';
36
-
37
-    /**
38
-     * @type string mysql_time_format
39
-     */
40
-    const mysql_time_format = 'H:i:s';
41
-
42
-    /**
43
-     * Const for using in the default value. If the field's default is set to this,
44
-     * then we will return the time of calling `get_default_value()`, not
45
-     * just the current time at construction
46
-     */
47
-    const now = 'now';
48
-
49
-    /**
50
-     * The following properties hold the default formats for date and time.
51
-     * Defaults are set via the constructor and can be overridden on class instantiation.
52
-     * However they can also be overridden later by the set_format() method
53
-     * (and corresponding set_date_format, set_time_format methods);
54
-     */
55
-    /**
56
-     * @type string $_date_format
57
-     */
58
-    protected $_date_format = '';
59
-
60
-    /**
61
-     * @type string $_time_format
62
-     */
63
-    protected $_time_format = '';
64
-
65
-    /**
66
-     * @type string $_pretty_date_format
67
-     */
68
-    protected $_pretty_date_format = '';
69
-
70
-    /**
71
-     * @type string $_pretty_time_format
72
-     */
73
-    protected $_pretty_time_format = '';
74
-
75
-    /**
76
-     * @type DateTimeZone $_DateTimeZone
77
-     */
78
-    protected $_DateTimeZone;
79
-
80
-    /**
81
-     * @type DateTimeZone $_UTC_DateTimeZone
82
-     */
83
-    protected $_UTC_DateTimeZone;
84
-
85
-    /**
86
-     * @type DateTimeZone $_blog_DateTimeZone
87
-     */
88
-    protected $_blog_DateTimeZone;
89
-
90
-
91
-    /**
92
-     * This property holds how we want the output returned when getting a datetime string.  It is set for the
93
-     * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
94
-     * and time returned via getters.
95
-     *
96
-     * @var mixed (null|string)
97
-     */
98
-    protected $_date_time_output;
99
-
100
-
101
-    /**
102
-     * timezone string
103
-     * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
104
-     * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
105
-     * coming out of the object to be in.  Default timezone is the current WP timezone option setting
106
-     *
107
-     * @var string
108
-     */
109
-    protected $_timezone_string;
110
-
111
-
112
-    /**
113
-     * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
114
-     * offsets for comparison purposes).
115
-     *
116
-     * @var int
117
-     */
118
-    protected $_blog_offset;
119
-
120
-
121
-
122
-    /**
123
-     * @param string $table_column
124
-     * @param string $nice_name
125
-     * @param bool   $nullable
126
-     * @param string $default_value
127
-     * @param string $timezone_string
128
-     * @param string $date_format
129
-     * @param string $time_format
130
-     * @param string $pretty_date_format
131
-     * @param string $pretty_time_format
132
-     * @throws EE_Error
133
-     * @throws InvalidArgumentException
134
-     */
135
-    public function __construct(
136
-        $table_column,
137
-        $nice_name,
138
-        $nullable,
139
-        $default_value,
140
-        $timezone_string = '',
141
-        $date_format = '',
142
-        $time_format = '',
143
-        $pretty_date_format = '',
144
-        $pretty_time_format = ''
145
-    ) {
146
-
147
-        $this->_date_format        = ! empty($date_format) ? $date_format : get_option('date_format');
148
-        $this->_time_format        = ! empty($time_format) ? $time_format : get_option('time_format');
149
-        $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
150
-        $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
151
-
152
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
153
-        $this->set_timezone($timezone_string);
154
-        $this->setSchemaFormat('date-time');
155
-    }
156
-
157
-
158
-    /**
159
-     * @return DateTimeZone
160
-     * @throws \EE_Error
161
-     */
162
-    public function get_UTC_DateTimeZone()
163
-    {
164
-        return $this->_UTC_DateTimeZone instanceof DateTimeZone
165
-            ? $this->_UTC_DateTimeZone
166
-            : $this->_create_timezone_object_from_timezone_string('UTC');
167
-    }
168
-
169
-
170
-    /**
171
-     * @return DateTimeZone
172
-     * @throws \EE_Error
173
-     */
174
-    public function get_blog_DateTimeZone()
175
-    {
176
-        return $this->_blog_DateTimeZone instanceof DateTimeZone
177
-            ? $this->_blog_DateTimeZone
178
-            : $this->_create_timezone_object_from_timezone_string('');
179
-    }
180
-
181
-
182
-    /**
183
-     * this prepares any incoming date data and make sure its converted to a utc unix timestamp
184
-     *
185
-     * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix
186
-     *                                                              timestamp
187
-     * @return DateTime
188
-     */
189
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
190
-    {
191
-        return $this->_get_date_object($value_inputted_for_field_on_model_object);
192
-    }
193
-
194
-
195
-    /**
196
-     * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
197
-     * getters need to know whether we're just returning the date or the time or both.  By default we return both.
198
-     *
199
-     * @param bool $pretty If we're returning the pretty formats or standard format string.
200
-     * @return string    The final assembled format string.
201
-     */
202
-    protected function _get_date_time_output($pretty = false)
203
-    {
204
-
205
-        switch ($this->_date_time_output) {
206
-            case 'time':
207
-                return $pretty ? $this->_pretty_time_format : $this->_time_format;
208
-                break;
209
-
210
-            case 'date':
211
-                return $pretty ? $this->_pretty_date_format : $this->_date_format;
212
-                break;
213
-
214
-            default:
215
-                return $pretty
216
-                    ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format
217
-                    : $this->_date_format . ' ' . $this->_time_format;
218
-        }
219
-    }
220
-
221
-
222
-    /**
223
-     * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
224
-     * returned (using the format properties)
225
-     *
226
-     * @param string $what acceptable values are 'time' or 'date'.
227
-     *                     Any other value will be set but will always result
228
-     *                     in both 'date' and 'time' being returned.
229
-     * @return void
230
-     */
231
-    public function set_date_time_output($what = null)
232
-    {
233
-        $this->_date_time_output = $what;
234
-    }
235
-
236
-
237
-    /**
238
-     * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
239
-     * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
240
-     * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
241
-     * We also set some other properties in this method.
242
-     *
243
-     * @param string $timezone_string A valid timezone string as described by @link
244
-     *                                http://www.php.net/manual/en/timezones.php
245
-     * @return void
246
-     * @throws InvalidArgumentException
247
-     * @throws InvalidDataTypeException
248
-     * @throws InvalidInterfaceException
249
-     */
250
-    public function set_timezone($timezone_string)
251
-    {
252
-        if (empty($timezone_string) && ! empty($this->_timezone_string)) {
253
-            // leave the timezone AS-IS if we already have one and
254
-            // the function arg didn't provide one
255
-            return;
256
-        }
257
-        $timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
258
-        $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
259
-        $this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
260
-    }
261
-
262
-
263
-    /**
264
-     * _create_timezone_object_from_timezone_name
265
-     *
266
-     * @access protected
267
-     * @param string $timezone_string
268
-     * @return \DateTimeZone
269
-     * @throws InvalidArgumentException
270
-     * @throws InvalidDataTypeException
271
-     * @throws InvalidInterfaceException
272
-     */
273
-    protected function _create_timezone_object_from_timezone_string($timezone_string = '')
274
-    {
275
-        return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
276
-    }
277
-
278
-
279
-    /**
280
-     * This just returns whatever is set for the current timezone.
281
-     *
282
-     * @access public
283
-     * @return string timezone string
284
-     */
285
-    public function get_timezone()
286
-    {
287
-        return $this->_timezone_string;
288
-    }
289
-
290
-
291
-    /**
292
-     * set the $_date_format property
293
-     *
294
-     * @access public
295
-     * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
296
-     * @param bool   $pretty Whether to set pretty format or not.
297
-     * @return void
298
-     */
299
-    public function set_date_format($format, $pretty = false)
300
-    {
301
-        if ($pretty) {
302
-            $this->_pretty_date_format = $format;
303
-        } else {
304
-            $this->_date_format = $format;
305
-        }
306
-    }
307
-
308
-
309
-    /**
310
-     * return the $_date_format property value.
311
-     *
312
-     * @param bool $pretty Whether to get pretty format or not.
313
-     * @return string
314
-     */
315
-    public function get_date_format($pretty = false)
316
-    {
317
-        return $pretty ? $this->_pretty_date_format : $this->_date_format;
318
-    }
319
-
320
-
321
-    /**
322
-     * set the $_time_format property
323
-     *
324
-     * @access public
325
-     * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
326
-     * @param bool   $pretty Whether to set pretty format or not.
327
-     * @return void
328
-     */
329
-    public function set_time_format($format, $pretty = false)
330
-    {
331
-        if ($pretty) {
332
-            $this->_pretty_time_format = $format;
333
-        } else {
334
-            $this->_time_format = $format;
335
-        }
336
-    }
337
-
338
-
339
-    /**
340
-     * return the $_time_format property value.
341
-     *
342
-     * @param bool $pretty Whether to get pretty format or not.
343
-     * @return string
344
-     */
345
-    public function get_time_format($pretty = false)
346
-    {
347
-        return $pretty ? $this->_pretty_time_format : $this->_time_format;
348
-    }
349
-
350
-
351
-    /**
352
-     * set the $_pretty_date_format property
353
-     *
354
-     * @access public
355
-     * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
356
-     * @return void
357
-     */
358
-    public function set_pretty_date_format($format)
359
-    {
360
-        $this->_pretty_date_format = $format;
361
-    }
362
-
363
-
364
-    /**
365
-     * set the $_pretty_time_format property
366
-     *
367
-     * @access public
368
-     * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
369
-     * @return void
370
-     */
371
-    public function set_pretty_time_format($format)
372
-    {
373
-        $this->_pretty_time_format = $format;
374
-    }
375
-
376
-
377
-    /**
378
-     * Only sets the time portion of the datetime.
379
-     *
380
-     * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
381
-     * @param DateTime        $current            current DateTime object for the datetime field
382
-     * @return DateTime
383
-     */
384
-    public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current)
385
-    {
386
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
387
-        // Otherwise parse the string.
388
-        if ($time_to_set_string instanceof DateTime) {
389
-            $parsed = array(
390
-                'hour'   => $time_to_set_string->format('H'),
391
-                'minute' => $time_to_set_string->format('i'),
392
-                'second' => $time_to_set_string->format('s'),
393
-            );
394
-        } else {
395
-            // parse incoming string
396
-            $parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
397
-        }
398
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
399
-        return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
400
-    }
401
-
402
-
403
-    /**
404
-     * Only sets the date portion of the datetime.
405
-     *
406
-     * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
407
-     * @param DateTime        $current            current DateTime object for the datetime field
408
-     * @return DateTime
409
-     */
410
-    public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current)
411
-    {
412
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
413
-        // Otherwise parse the string.
414
-        if ($date_to_set_string instanceof DateTime) {
415
-            $parsed = array(
416
-                'year'  => $date_to_set_string->format('Y'),
417
-                'month' => $date_to_set_string->format('m'),
418
-                'day'   => $date_to_set_string->format('d'),
419
-            );
420
-        } else {
421
-            // parse incoming string
422
-            $parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
423
-        }
424
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
425
-        return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
426
-    }
427
-
428
-
429
-    /**
430
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
431
-     * datetime gets to this stage it should ALREADY be in UTC time
432
-     *
433
-     * @param  DateTime $DateTime
434
-     * @return string formatted date time for given timezone
435
-     * @throws \EE_Error
436
-     */
437
-    public function prepare_for_get($DateTime)
438
-    {
439
-        return $this->_prepare_for_display($DateTime);
440
-    }
441
-
442
-
443
-    /**
444
-     * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
445
-     * from the set wp timezone.  If so, then it returns the datetime string formatted via
446
-     * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
447
-     * abbreviation to the date_string.
448
-     *
449
-     * @param mixed $DateTime
450
-     * @param null  $schema
451
-     * @return string
452
-     * @throws \EE_Error
453
-     */
454
-    public function prepare_for_pretty_echoing($DateTime, $schema = null)
455
-    {
456
-        return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
457
-    }
458
-
459
-
460
-    /**
461
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
462
-     * timezone).
463
-     *
464
-     * @param DateTime    $DateTime
465
-     * @param bool|string $schema
466
-     * @return string
467
-     * @throws \EE_Error
468
-     */
469
-    protected function _prepare_for_display($DateTime, $schema = false)
470
-    {
471
-        if (! $DateTime instanceof DateTime) {
472
-            if ($this->_nullable) {
473
-                return '';
474
-            } else {
475
-                if (WP_DEBUG) {
476
-                    throw new EE_Error(
477
-                        sprintf(
478
-                            __(
479
-                                'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
480
-                                'event_espresso'
481
-                            ),
482
-                            $this->_nicename
483
-                        )
484
-                    );
485
-                } else {
486
-                    $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now);
487
-                    EE_Error::add_error(
488
-                        sprintf(
489
-                            __(
490
-                                'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
491
-                                'event_espresso'
492
-                            ),
493
-                            $this->_nicename
494
-                        )
495
-                    );
496
-                }
497
-            }
498
-        }
499
-        $format_string = $this->_get_date_time_output($schema);
500
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
501
-        if ($schema) {
502
-            if ($this->_display_timezone()) {
503
-                // must be explicit because schema could equal true.
504
-                if ($schema === 'no_html') {
505
-                    $timezone_string = ' (' . $DateTime->format('T') . ')';
506
-                } else {
507
-                    $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
508
-                }
509
-            } else {
510
-                $timezone_string = '';
511
-            }
512
-
513
-            return $DateTime->format($format_string) . $timezone_string;
514
-        }
515
-        return $DateTime->format($format_string);
516
-    }
517
-
518
-
519
-    /**
520
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
521
-     * timezone).
522
-     *
523
-     * @param  mixed $datetime_value u
524
-     * @return string mysql timestamp in UTC
525
-     * @throws \EE_Error
526
-     */
527
-    public function prepare_for_use_in_db($datetime_value)
528
-    {
529
-        // we allow an empty value or DateTime object, but nothing else.
530
-        if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
531
-            throw new EE_Error(
532
-                sprintf(
533
-                    __(
534
-                        'The incoming value being prepared for setting in the database must either be empty or a php 
19
+	/**
20
+	 * The pattern we're looking for is if only the characters 0-9 are found and there are only
21
+	 * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
22
+	 *
23
+	 * @type string unix_timestamp_regex
24
+	 */
25
+	const unix_timestamp_regex = '/[0-9]{10,}/';
26
+
27
+	/**
28
+	 * @type string mysql_timestamp_format
29
+	 */
30
+	const mysql_timestamp_format = 'Y-m-d H:i:s';
31
+
32
+	/**
33
+	 * @type string mysql_date_format
34
+	 */
35
+	const mysql_date_format = 'Y-m-d';
36
+
37
+	/**
38
+	 * @type string mysql_time_format
39
+	 */
40
+	const mysql_time_format = 'H:i:s';
41
+
42
+	/**
43
+	 * Const for using in the default value. If the field's default is set to this,
44
+	 * then we will return the time of calling `get_default_value()`, not
45
+	 * just the current time at construction
46
+	 */
47
+	const now = 'now';
48
+
49
+	/**
50
+	 * The following properties hold the default formats for date and time.
51
+	 * Defaults are set via the constructor and can be overridden on class instantiation.
52
+	 * However they can also be overridden later by the set_format() method
53
+	 * (and corresponding set_date_format, set_time_format methods);
54
+	 */
55
+	/**
56
+	 * @type string $_date_format
57
+	 */
58
+	protected $_date_format = '';
59
+
60
+	/**
61
+	 * @type string $_time_format
62
+	 */
63
+	protected $_time_format = '';
64
+
65
+	/**
66
+	 * @type string $_pretty_date_format
67
+	 */
68
+	protected $_pretty_date_format = '';
69
+
70
+	/**
71
+	 * @type string $_pretty_time_format
72
+	 */
73
+	protected $_pretty_time_format = '';
74
+
75
+	/**
76
+	 * @type DateTimeZone $_DateTimeZone
77
+	 */
78
+	protected $_DateTimeZone;
79
+
80
+	/**
81
+	 * @type DateTimeZone $_UTC_DateTimeZone
82
+	 */
83
+	protected $_UTC_DateTimeZone;
84
+
85
+	/**
86
+	 * @type DateTimeZone $_blog_DateTimeZone
87
+	 */
88
+	protected $_blog_DateTimeZone;
89
+
90
+
91
+	/**
92
+	 * This property holds how we want the output returned when getting a datetime string.  It is set for the
93
+	 * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
94
+	 * and time returned via getters.
95
+	 *
96
+	 * @var mixed (null|string)
97
+	 */
98
+	protected $_date_time_output;
99
+
100
+
101
+	/**
102
+	 * timezone string
103
+	 * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
104
+	 * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
105
+	 * coming out of the object to be in.  Default timezone is the current WP timezone option setting
106
+	 *
107
+	 * @var string
108
+	 */
109
+	protected $_timezone_string;
110
+
111
+
112
+	/**
113
+	 * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
114
+	 * offsets for comparison purposes).
115
+	 *
116
+	 * @var int
117
+	 */
118
+	protected $_blog_offset;
119
+
120
+
121
+
122
+	/**
123
+	 * @param string $table_column
124
+	 * @param string $nice_name
125
+	 * @param bool   $nullable
126
+	 * @param string $default_value
127
+	 * @param string $timezone_string
128
+	 * @param string $date_format
129
+	 * @param string $time_format
130
+	 * @param string $pretty_date_format
131
+	 * @param string $pretty_time_format
132
+	 * @throws EE_Error
133
+	 * @throws InvalidArgumentException
134
+	 */
135
+	public function __construct(
136
+		$table_column,
137
+		$nice_name,
138
+		$nullable,
139
+		$default_value,
140
+		$timezone_string = '',
141
+		$date_format = '',
142
+		$time_format = '',
143
+		$pretty_date_format = '',
144
+		$pretty_time_format = ''
145
+	) {
146
+
147
+		$this->_date_format        = ! empty($date_format) ? $date_format : get_option('date_format');
148
+		$this->_time_format        = ! empty($time_format) ? $time_format : get_option('time_format');
149
+		$this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
150
+		$this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
151
+
152
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
153
+		$this->set_timezone($timezone_string);
154
+		$this->setSchemaFormat('date-time');
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return DateTimeZone
160
+	 * @throws \EE_Error
161
+	 */
162
+	public function get_UTC_DateTimeZone()
163
+	{
164
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone
165
+			? $this->_UTC_DateTimeZone
166
+			: $this->_create_timezone_object_from_timezone_string('UTC');
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return DateTimeZone
172
+	 * @throws \EE_Error
173
+	 */
174
+	public function get_blog_DateTimeZone()
175
+	{
176
+		return $this->_blog_DateTimeZone instanceof DateTimeZone
177
+			? $this->_blog_DateTimeZone
178
+			: $this->_create_timezone_object_from_timezone_string('');
179
+	}
180
+
181
+
182
+	/**
183
+	 * this prepares any incoming date data and make sure its converted to a utc unix timestamp
184
+	 *
185
+	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix
186
+	 *                                                              timestamp
187
+	 * @return DateTime
188
+	 */
189
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
190
+	{
191
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
192
+	}
193
+
194
+
195
+	/**
196
+	 * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
197
+	 * getters need to know whether we're just returning the date or the time or both.  By default we return both.
198
+	 *
199
+	 * @param bool $pretty If we're returning the pretty formats or standard format string.
200
+	 * @return string    The final assembled format string.
201
+	 */
202
+	protected function _get_date_time_output($pretty = false)
203
+	{
204
+
205
+		switch ($this->_date_time_output) {
206
+			case 'time':
207
+				return $pretty ? $this->_pretty_time_format : $this->_time_format;
208
+				break;
209
+
210
+			case 'date':
211
+				return $pretty ? $this->_pretty_date_format : $this->_date_format;
212
+				break;
213
+
214
+			default:
215
+				return $pretty
216
+					? $this->_pretty_date_format . ' ' . $this->_pretty_time_format
217
+					: $this->_date_format . ' ' . $this->_time_format;
218
+		}
219
+	}
220
+
221
+
222
+	/**
223
+	 * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
224
+	 * returned (using the format properties)
225
+	 *
226
+	 * @param string $what acceptable values are 'time' or 'date'.
227
+	 *                     Any other value will be set but will always result
228
+	 *                     in both 'date' and 'time' being returned.
229
+	 * @return void
230
+	 */
231
+	public function set_date_time_output($what = null)
232
+	{
233
+		$this->_date_time_output = $what;
234
+	}
235
+
236
+
237
+	/**
238
+	 * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
239
+	 * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
240
+	 * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
241
+	 * We also set some other properties in this method.
242
+	 *
243
+	 * @param string $timezone_string A valid timezone string as described by @link
244
+	 *                                http://www.php.net/manual/en/timezones.php
245
+	 * @return void
246
+	 * @throws InvalidArgumentException
247
+	 * @throws InvalidDataTypeException
248
+	 * @throws InvalidInterfaceException
249
+	 */
250
+	public function set_timezone($timezone_string)
251
+	{
252
+		if (empty($timezone_string) && ! empty($this->_timezone_string)) {
253
+			// leave the timezone AS-IS if we already have one and
254
+			// the function arg didn't provide one
255
+			return;
256
+		}
257
+		$timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
258
+		$this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
259
+		$this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
260
+	}
261
+
262
+
263
+	/**
264
+	 * _create_timezone_object_from_timezone_name
265
+	 *
266
+	 * @access protected
267
+	 * @param string $timezone_string
268
+	 * @return \DateTimeZone
269
+	 * @throws InvalidArgumentException
270
+	 * @throws InvalidDataTypeException
271
+	 * @throws InvalidInterfaceException
272
+	 */
273
+	protected function _create_timezone_object_from_timezone_string($timezone_string = '')
274
+	{
275
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
276
+	}
277
+
278
+
279
+	/**
280
+	 * This just returns whatever is set for the current timezone.
281
+	 *
282
+	 * @access public
283
+	 * @return string timezone string
284
+	 */
285
+	public function get_timezone()
286
+	{
287
+		return $this->_timezone_string;
288
+	}
289
+
290
+
291
+	/**
292
+	 * set the $_date_format property
293
+	 *
294
+	 * @access public
295
+	 * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
296
+	 * @param bool   $pretty Whether to set pretty format or not.
297
+	 * @return void
298
+	 */
299
+	public function set_date_format($format, $pretty = false)
300
+	{
301
+		if ($pretty) {
302
+			$this->_pretty_date_format = $format;
303
+		} else {
304
+			$this->_date_format = $format;
305
+		}
306
+	}
307
+
308
+
309
+	/**
310
+	 * return the $_date_format property value.
311
+	 *
312
+	 * @param bool $pretty Whether to get pretty format or not.
313
+	 * @return string
314
+	 */
315
+	public function get_date_format($pretty = false)
316
+	{
317
+		return $pretty ? $this->_pretty_date_format : $this->_date_format;
318
+	}
319
+
320
+
321
+	/**
322
+	 * set the $_time_format property
323
+	 *
324
+	 * @access public
325
+	 * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
326
+	 * @param bool   $pretty Whether to set pretty format or not.
327
+	 * @return void
328
+	 */
329
+	public function set_time_format($format, $pretty = false)
330
+	{
331
+		if ($pretty) {
332
+			$this->_pretty_time_format = $format;
333
+		} else {
334
+			$this->_time_format = $format;
335
+		}
336
+	}
337
+
338
+
339
+	/**
340
+	 * return the $_time_format property value.
341
+	 *
342
+	 * @param bool $pretty Whether to get pretty format or not.
343
+	 * @return string
344
+	 */
345
+	public function get_time_format($pretty = false)
346
+	{
347
+		return $pretty ? $this->_pretty_time_format : $this->_time_format;
348
+	}
349
+
350
+
351
+	/**
352
+	 * set the $_pretty_date_format property
353
+	 *
354
+	 * @access public
355
+	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
356
+	 * @return void
357
+	 */
358
+	public function set_pretty_date_format($format)
359
+	{
360
+		$this->_pretty_date_format = $format;
361
+	}
362
+
363
+
364
+	/**
365
+	 * set the $_pretty_time_format property
366
+	 *
367
+	 * @access public
368
+	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
369
+	 * @return void
370
+	 */
371
+	public function set_pretty_time_format($format)
372
+	{
373
+		$this->_pretty_time_format = $format;
374
+	}
375
+
376
+
377
+	/**
378
+	 * Only sets the time portion of the datetime.
379
+	 *
380
+	 * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
381
+	 * @param DateTime        $current            current DateTime object for the datetime field
382
+	 * @return DateTime
383
+	 */
384
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current)
385
+	{
386
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
387
+		// Otherwise parse the string.
388
+		if ($time_to_set_string instanceof DateTime) {
389
+			$parsed = array(
390
+				'hour'   => $time_to_set_string->format('H'),
391
+				'minute' => $time_to_set_string->format('i'),
392
+				'second' => $time_to_set_string->format('s'),
393
+			);
394
+		} else {
395
+			// parse incoming string
396
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
397
+		}
398
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
399
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
400
+	}
401
+
402
+
403
+	/**
404
+	 * Only sets the date portion of the datetime.
405
+	 *
406
+	 * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
407
+	 * @param DateTime        $current            current DateTime object for the datetime field
408
+	 * @return DateTime
409
+	 */
410
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current)
411
+	{
412
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
413
+		// Otherwise parse the string.
414
+		if ($date_to_set_string instanceof DateTime) {
415
+			$parsed = array(
416
+				'year'  => $date_to_set_string->format('Y'),
417
+				'month' => $date_to_set_string->format('m'),
418
+				'day'   => $date_to_set_string->format('d'),
419
+			);
420
+		} else {
421
+			// parse incoming string
422
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
423
+		}
424
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
425
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
426
+	}
427
+
428
+
429
+	/**
430
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
431
+	 * datetime gets to this stage it should ALREADY be in UTC time
432
+	 *
433
+	 * @param  DateTime $DateTime
434
+	 * @return string formatted date time for given timezone
435
+	 * @throws \EE_Error
436
+	 */
437
+	public function prepare_for_get($DateTime)
438
+	{
439
+		return $this->_prepare_for_display($DateTime);
440
+	}
441
+
442
+
443
+	/**
444
+	 * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
445
+	 * from the set wp timezone.  If so, then it returns the datetime string formatted via
446
+	 * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
447
+	 * abbreviation to the date_string.
448
+	 *
449
+	 * @param mixed $DateTime
450
+	 * @param null  $schema
451
+	 * @return string
452
+	 * @throws \EE_Error
453
+	 */
454
+	public function prepare_for_pretty_echoing($DateTime, $schema = null)
455
+	{
456
+		return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
457
+	}
458
+
459
+
460
+	/**
461
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
462
+	 * timezone).
463
+	 *
464
+	 * @param DateTime    $DateTime
465
+	 * @param bool|string $schema
466
+	 * @return string
467
+	 * @throws \EE_Error
468
+	 */
469
+	protected function _prepare_for_display($DateTime, $schema = false)
470
+	{
471
+		if (! $DateTime instanceof DateTime) {
472
+			if ($this->_nullable) {
473
+				return '';
474
+			} else {
475
+				if (WP_DEBUG) {
476
+					throw new EE_Error(
477
+						sprintf(
478
+							__(
479
+								'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
480
+								'event_espresso'
481
+							),
482
+							$this->_nicename
483
+						)
484
+					);
485
+				} else {
486
+					$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now);
487
+					EE_Error::add_error(
488
+						sprintf(
489
+							__(
490
+								'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
491
+								'event_espresso'
492
+							),
493
+							$this->_nicename
494
+						)
495
+					);
496
+				}
497
+			}
498
+		}
499
+		$format_string = $this->_get_date_time_output($schema);
500
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
501
+		if ($schema) {
502
+			if ($this->_display_timezone()) {
503
+				// must be explicit because schema could equal true.
504
+				if ($schema === 'no_html') {
505
+					$timezone_string = ' (' . $DateTime->format('T') . ')';
506
+				} else {
507
+					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
508
+				}
509
+			} else {
510
+				$timezone_string = '';
511
+			}
512
+
513
+			return $DateTime->format($format_string) . $timezone_string;
514
+		}
515
+		return $DateTime->format($format_string);
516
+	}
517
+
518
+
519
+	/**
520
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
521
+	 * timezone).
522
+	 *
523
+	 * @param  mixed $datetime_value u
524
+	 * @return string mysql timestamp in UTC
525
+	 * @throws \EE_Error
526
+	 */
527
+	public function prepare_for_use_in_db($datetime_value)
528
+	{
529
+		// we allow an empty value or DateTime object, but nothing else.
530
+		if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
531
+			throw new EE_Error(
532
+				sprintf(
533
+					__(
534
+						'The incoming value being prepared for setting in the database must either be empty or a php 
535 535
             		    DateTime object, instead of: %1$s %2$s',
536
-                        'event_espresso'
537
-                    ),
538
-                    '<br />',
539
-                    print_r($datetime_value, true)
540
-                )
541
-            );
542
-        }
543
-
544
-        if ($datetime_value instanceof DateTime) {
545
-            if (! $datetime_value instanceof DbSafeDateTime) {
546
-                $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
547
-            }
548
-            EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
549
-            return $datetime_value->format(
550
-                EE_Datetime_Field::mysql_timestamp_format
551
-            );
552
-        }
553
-
554
-        // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
555
-        return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
556
-    }
557
-
558
-
559
-    /**
560
-     * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
561
-     * allowed)
562
-     *
563
-     * @param string $datetime_string mysql timestamp in UTC
564
-     * @return  mixed null | DateTime
565
-     * @throws \EE_Error
566
-     */
567
-    public function prepare_for_set_from_db($datetime_string)
568
-    {
569
-        // if $datetime_value is empty, and ! $this->_nullable, just use time()
570
-        if (empty($datetime_string) && $this->_nullable) {
571
-            return null;
572
-        }
573
-        // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
574
-        if (empty($datetime_string)) {
575
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
576
-        } else {
577
-            $DateTime = DbSafeDateTime::createFromFormat(
578
-                EE_Datetime_Field::mysql_timestamp_format,
579
-                $datetime_string,
580
-                $this->get_UTC_DateTimeZone()
581
-            );
582
-        }
583
-
584
-        if (! $DateTime instanceof DbSafeDateTime) {
585
-            // if still no datetime object, then let's just use now
586
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
587
-        }
588
-        // THEN apply the field's set DateTimeZone
589
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
590
-        return $DateTime;
591
-    }
592
-
593
-
594
-    /**
595
-     * All this method does is determine if we're going to display the timezone string or not on any output.
596
-     * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
597
-     * If so, then true.
598
-     *
599
-     * @return bool true for yes false for no
600
-     * @throws \EE_Error
601
-     */
602
-    protected function _display_timezone()
603
-    {
604
-
605
-        // first let's do a comparison of timezone strings.
606
-        // If they match then we can get out without any further calculations
607
-        $blog_string = get_option('timezone_string');
608
-        if ($blog_string === $this->_timezone_string) {
609
-            return false;
610
-        }
611
-        // now we need to calc the offset for the timezone string so we can compare with the blog offset.
612
-        $this_offset = $this->get_timezone_offset($this->_DateTimeZone);
613
-        $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
614
-        // now compare
615
-        return $blog_offset !== $this_offset;
616
-    }
617
-
618
-
619
-    /**
620
-     * This method returns a php DateTime object for setting on the EE_Base_Class model.
621
-     * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
622
-     * with.
623
-     *
624
-     * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
625
-     *                                                    in the format that is set on the date_field (or DateTime
626
-     *                                                    object)!
627
-     * @return DateTime
628
-     */
629
-    protected function _get_date_object($date_string)
630
-    {
631
-        // first if this is an empty date_string and nullable is allowed, just return null.
632
-        if ($this->_nullable && empty($date_string)) {
633
-            return null;
634
-        }
635
-
636
-        // if incoming date
637
-        if ($date_string instanceof DateTime) {
638
-            EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
639
-            return $date_string;
640
-        }
641
-        // if empty date_string and made it here.
642
-        // Return a datetime object for now in the given timezone.
643
-        if (empty($date_string)) {
644
-            return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
645
-        }
646
-        // if $date_string is matches something that looks like a Unix timestamp let's just use it.
647
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
648
-            try {
649
-                // This is operating under the assumption that the incoming Unix timestamp
650
-                // is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
651
-                $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
652
-                $DateTime->setTimestamp($date_string);
653
-
654
-                return $DateTime;
655
-            } catch (Exception $e) {
656
-                // should be rare, but if things got fooled then let's just continue
657
-            }
658
-        }
659
-        // not a unix timestamp.  So we will use the set format on this object and set timezone to
660
-        // create the DateTime object.
661
-        $format = $this->_date_format . ' ' . $this->_time_format;
662
-        try {
663
-            $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
664
-            if (! $DateTime instanceof DbSafeDateTime) {
665
-                throw new EE_Error(
666
-                    sprintf(
667
-                        __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
668
-                        $date_string,
669
-                        $format
670
-                    )
671
-                );
672
-            }
673
-        } catch (Exception $e) {
674
-            // if we made it here then likely then something went really wrong.
675
-            // Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
676
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
677
-        }
678
-
679
-        return $DateTime;
680
-    }
681
-
682
-
683
-
684
-    /**
685
-     * get_timezone_transitions
686
-     *
687
-     * @param \DateTimeZone $DateTimeZone
688
-     * @param int           $time
689
-     * @param bool          $first_only
690
-     * @return mixed
691
-     */
692
-    public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true)
693
-    {
694
-        return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
695
-    }
696
-
697
-
698
-
699
-    /**
700
-     * get_timezone_offset
701
-     *
702
-     * @param \DateTimeZone $DateTimeZone
703
-     * @param int           $time
704
-     * @return mixed
705
-     * @throws \DomainException
706
-     */
707
-    public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
708
-    {
709
-        return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
710
-    }
711
-
712
-
713
-    /**
714
-     * This will take an incoming timezone string and return the abbreviation for that timezone
715
-     *
716
-     * @param  string $timezone_string
717
-     * @return string           abbreviation
718
-     * @throws \EE_Error
719
-     */
720
-    public function get_timezone_abbrev($timezone_string)
721
-    {
722
-        $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
723
-        $dateTime        = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string));
724
-
725
-        return $dateTime->format('T');
726
-    }
727
-
728
-    /**
729
-     * Overrides the parent to allow for having a dynamic "now" value
730
-     *
731
-     * @return mixed
732
-     */
733
-    public function get_default_value()
734
-    {
735
-        if ($this->_default_value === EE_Datetime_Field::now) {
736
-            return time();
737
-        } else {
738
-            return parent::get_default_value();
739
-        }
740
-    }
741
-
742
-    /**
743
-     * Gets the default datetime object from the field's default time
744
-     * @since 4.9.66.p
745
-     * @return DbSafeDateTime|null
746
-     * @throws InvalidArgumentException
747
-     * @throws InvalidDataTypeException
748
-     * @throws InvalidInterfaceException
749
-     */
750
-    public function getDefaultDateTimeObj()
751
-    {
752
-        $default_raw = $this->get_default_value();
753
-        if ($default_raw instanceof DateTime) {
754
-            return $default_raw;
755
-        } elseif (is_null($default_raw)) {
756
-            return $default_raw;
757
-        } else {
758
-            return new DbSafeDateTime(
759
-                $this->get_default_value(),
760
-                EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone())
761
-            );
762
-        }
763
-    }
764
-
765
-    public function getSchemaDescription()
766
-    {
767
-        return sprintf(
768
-            esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
769
-            $this->get_nicename()
770
-        );
771
-    }
536
+						'event_espresso'
537
+					),
538
+					'<br />',
539
+					print_r($datetime_value, true)
540
+				)
541
+			);
542
+		}
543
+
544
+		if ($datetime_value instanceof DateTime) {
545
+			if (! $datetime_value instanceof DbSafeDateTime) {
546
+				$datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
547
+			}
548
+			EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
549
+			return $datetime_value->format(
550
+				EE_Datetime_Field::mysql_timestamp_format
551
+			);
552
+		}
553
+
554
+		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
555
+		return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
556
+	}
557
+
558
+
559
+	/**
560
+	 * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
561
+	 * allowed)
562
+	 *
563
+	 * @param string $datetime_string mysql timestamp in UTC
564
+	 * @return  mixed null | DateTime
565
+	 * @throws \EE_Error
566
+	 */
567
+	public function prepare_for_set_from_db($datetime_string)
568
+	{
569
+		// if $datetime_value is empty, and ! $this->_nullable, just use time()
570
+		if (empty($datetime_string) && $this->_nullable) {
571
+			return null;
572
+		}
573
+		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
574
+		if (empty($datetime_string)) {
575
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
576
+		} else {
577
+			$DateTime = DbSafeDateTime::createFromFormat(
578
+				EE_Datetime_Field::mysql_timestamp_format,
579
+				$datetime_string,
580
+				$this->get_UTC_DateTimeZone()
581
+			);
582
+		}
583
+
584
+		if (! $DateTime instanceof DbSafeDateTime) {
585
+			// if still no datetime object, then let's just use now
586
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
587
+		}
588
+		// THEN apply the field's set DateTimeZone
589
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
590
+		return $DateTime;
591
+	}
592
+
593
+
594
+	/**
595
+	 * All this method does is determine if we're going to display the timezone string or not on any output.
596
+	 * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
597
+	 * If so, then true.
598
+	 *
599
+	 * @return bool true for yes false for no
600
+	 * @throws \EE_Error
601
+	 */
602
+	protected function _display_timezone()
603
+	{
604
+
605
+		// first let's do a comparison of timezone strings.
606
+		// If they match then we can get out without any further calculations
607
+		$blog_string = get_option('timezone_string');
608
+		if ($blog_string === $this->_timezone_string) {
609
+			return false;
610
+		}
611
+		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
612
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
613
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
614
+		// now compare
615
+		return $blog_offset !== $this_offset;
616
+	}
617
+
618
+
619
+	/**
620
+	 * This method returns a php DateTime object for setting on the EE_Base_Class model.
621
+	 * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
622
+	 * with.
623
+	 *
624
+	 * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
625
+	 *                                                    in the format that is set on the date_field (or DateTime
626
+	 *                                                    object)!
627
+	 * @return DateTime
628
+	 */
629
+	protected function _get_date_object($date_string)
630
+	{
631
+		// first if this is an empty date_string and nullable is allowed, just return null.
632
+		if ($this->_nullable && empty($date_string)) {
633
+			return null;
634
+		}
635
+
636
+		// if incoming date
637
+		if ($date_string instanceof DateTime) {
638
+			EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
639
+			return $date_string;
640
+		}
641
+		// if empty date_string and made it here.
642
+		// Return a datetime object for now in the given timezone.
643
+		if (empty($date_string)) {
644
+			return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
645
+		}
646
+		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
647
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
648
+			try {
649
+				// This is operating under the assumption that the incoming Unix timestamp
650
+				// is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
651
+				$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
652
+				$DateTime->setTimestamp($date_string);
653
+
654
+				return $DateTime;
655
+			} catch (Exception $e) {
656
+				// should be rare, but if things got fooled then let's just continue
657
+			}
658
+		}
659
+		// not a unix timestamp.  So we will use the set format on this object and set timezone to
660
+		// create the DateTime object.
661
+		$format = $this->_date_format . ' ' . $this->_time_format;
662
+		try {
663
+			$DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
664
+			if (! $DateTime instanceof DbSafeDateTime) {
665
+				throw new EE_Error(
666
+					sprintf(
667
+						__('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
668
+						$date_string,
669
+						$format
670
+					)
671
+				);
672
+			}
673
+		} catch (Exception $e) {
674
+			// if we made it here then likely then something went really wrong.
675
+			// Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
676
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
677
+		}
678
+
679
+		return $DateTime;
680
+	}
681
+
682
+
683
+
684
+	/**
685
+	 * get_timezone_transitions
686
+	 *
687
+	 * @param \DateTimeZone $DateTimeZone
688
+	 * @param int           $time
689
+	 * @param bool          $first_only
690
+	 * @return mixed
691
+	 */
692
+	public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true)
693
+	{
694
+		return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
695
+	}
696
+
697
+
698
+
699
+	/**
700
+	 * get_timezone_offset
701
+	 *
702
+	 * @param \DateTimeZone $DateTimeZone
703
+	 * @param int           $time
704
+	 * @return mixed
705
+	 * @throws \DomainException
706
+	 */
707
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
708
+	{
709
+		return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
710
+	}
711
+
712
+
713
+	/**
714
+	 * This will take an incoming timezone string and return the abbreviation for that timezone
715
+	 *
716
+	 * @param  string $timezone_string
717
+	 * @return string           abbreviation
718
+	 * @throws \EE_Error
719
+	 */
720
+	public function get_timezone_abbrev($timezone_string)
721
+	{
722
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
723
+		$dateTime        = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string));
724
+
725
+		return $dateTime->format('T');
726
+	}
727
+
728
+	/**
729
+	 * Overrides the parent to allow for having a dynamic "now" value
730
+	 *
731
+	 * @return mixed
732
+	 */
733
+	public function get_default_value()
734
+	{
735
+		if ($this->_default_value === EE_Datetime_Field::now) {
736
+			return time();
737
+		} else {
738
+			return parent::get_default_value();
739
+		}
740
+	}
741
+
742
+	/**
743
+	 * Gets the default datetime object from the field's default time
744
+	 * @since 4.9.66.p
745
+	 * @return DbSafeDateTime|null
746
+	 * @throws InvalidArgumentException
747
+	 * @throws InvalidDataTypeException
748
+	 * @throws InvalidInterfaceException
749
+	 */
750
+	public function getDefaultDateTimeObj()
751
+	{
752
+		$default_raw = $this->get_default_value();
753
+		if ($default_raw instanceof DateTime) {
754
+			return $default_raw;
755
+		} elseif (is_null($default_raw)) {
756
+			return $default_raw;
757
+		} else {
758
+			return new DbSafeDateTime(
759
+				$this->get_default_value(),
760
+				EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone())
761
+			);
762
+		}
763
+	}
764
+
765
+	public function getSchemaDescription()
766
+	{
767
+		return sprintf(
768
+			esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
769
+			$this->get_nicename()
770
+		);
771
+	}
772 772
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Term_Taxonomy.model.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -11,128 +11,128 @@
 block discarded – undo
11 11
 class EEM_Term_Taxonomy extends EEM_Base
12 12
 {
13 13
 
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18 18
 
19
-    protected function __construct($timezone = '')
20
-    {
21
-        $this->singular_item = __('Term Taxonomy', 'event_espresso');
22
-        $this->plural_item = __('Term Taxonomy', 'event_espresso');
23
-        $this->_tables = array(
24
-            'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
25
-        );
26
-        $this->_fields = array(
27
-            'Term_Taxonomy' => array(
28
-                'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
29
-                    'term_taxonomy_id',
30
-                    __('Term-Taxonomy ID', 'event_espresso')
31
-                ),
32
-                'term_id'          => new EE_Foreign_Key_Int_Field(
33
-                    'term_id',
34
-                    __("Term Id", "event_espresso"),
35
-                    false,
36
-                    0,
37
-                    'Term'
38
-                ),
39
-                'taxonomy'         => new EE_Plain_Text_Field(
40
-                    'taxonomy',
41
-                    __('Taxonomy Name', 'event_espresso'),
42
-                    false,
43
-                    'category'
44
-                ),
45
-                'description'      => new EE_Post_Content_Field(
46
-                    'description',
47
-                    __("Description of Term", "event_espresso"),
48
-                    false,
49
-                    ''
50
-                ),
51
-                'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
52
-                'term_count'       => new EE_Integer_Field(
53
-                    'count',
54
-                    __("Count of Objects attached", 'event_espresso'),
55
-                    false,
56
-                    0
57
-                ),
58
-            ),
59
-        );
60
-        $this->_model_relations = array(
61
-            'Term_Relationship' => new EE_Has_Many_Relation(),
62
-            'Term'              => new EE_Belongs_To_Relation(),
63
-        );
64
-        $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
65
-        foreach ($cpt_models as $model_name) {
66
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
67
-        }
68
-        $this->_wp_core_model = true;
69
-        $this->_indexes = array(
70
-            'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
71
-        );
72
-        $path_to_tax_model = '';
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
74
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
75
-            $path_to_tax_model
76
-        );
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
78
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
79
-        // add cap restrictions for editing relating to the "ee_edit_*"
80
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
81
-            array(
82
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
83
-            )
84
-        );
85
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
86
-            array(
87
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
88
-            )
89
-        );
90
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
91
-            array(
92
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
93
-            )
94
-        );
95
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
96
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
97
-            array(
98
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
99
-            )
100
-        );
101
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
102
-            array(
103
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
104
-            )
105
-        );
106
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
107
-            array(
108
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
109
-            )
110
-        );
111
-        parent::__construct($timezone);
112
-        add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
113
-    }
19
+	protected function __construct($timezone = '')
20
+	{
21
+		$this->singular_item = __('Term Taxonomy', 'event_espresso');
22
+		$this->plural_item = __('Term Taxonomy', 'event_espresso');
23
+		$this->_tables = array(
24
+			'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
25
+		);
26
+		$this->_fields = array(
27
+			'Term_Taxonomy' => array(
28
+				'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
29
+					'term_taxonomy_id',
30
+					__('Term-Taxonomy ID', 'event_espresso')
31
+				),
32
+				'term_id'          => new EE_Foreign_Key_Int_Field(
33
+					'term_id',
34
+					__("Term Id", "event_espresso"),
35
+					false,
36
+					0,
37
+					'Term'
38
+				),
39
+				'taxonomy'         => new EE_Plain_Text_Field(
40
+					'taxonomy',
41
+					__('Taxonomy Name', 'event_espresso'),
42
+					false,
43
+					'category'
44
+				),
45
+				'description'      => new EE_Post_Content_Field(
46
+					'description',
47
+					__("Description of Term", "event_espresso"),
48
+					false,
49
+					''
50
+				),
51
+				'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
52
+				'term_count'       => new EE_Integer_Field(
53
+					'count',
54
+					__("Count of Objects attached", 'event_espresso'),
55
+					false,
56
+					0
57
+				),
58
+			),
59
+		);
60
+		$this->_model_relations = array(
61
+			'Term_Relationship' => new EE_Has_Many_Relation(),
62
+			'Term'              => new EE_Belongs_To_Relation(),
63
+		);
64
+		$cpt_models = array_keys(EE_Registry::instance()->cpt_models());
65
+		foreach ($cpt_models as $model_name) {
66
+			$this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
67
+		}
68
+		$this->_wp_core_model = true;
69
+		$this->_indexes = array(
70
+			'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
71
+		);
72
+		$path_to_tax_model = '';
73
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
74
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
75
+			$path_to_tax_model
76
+		);
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
78
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
79
+		// add cap restrictions for editing relating to the "ee_edit_*"
80
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
81
+			array(
82
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
83
+			)
84
+		);
85
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
86
+			array(
87
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
88
+			)
89
+		);
90
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
91
+			array(
92
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
93
+			)
94
+		);
95
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
96
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
97
+			array(
98
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
99
+			)
100
+		);
101
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
102
+			array(
103
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
104
+			)
105
+		);
106
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
107
+			array(
108
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
109
+			)
110
+		);
111
+		parent::__construct($timezone);
112
+		add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
113
+	}
114 114
 
115 115
 
116 116
 
117
-    /**
118
-     * Makes sure that during REST API queries, we only return term-taxonomies
119
-     * for term taxonomies which should be shown in the rest api
120
-     *
121
-     * @param array    $model_query_params
122
-     * @param array    $querystring_query_params
123
-     * @param EEM_Base $model
124
-     * @return array
125
-     */
126
-    public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
127
-    {
128
-        if ($model === EEM_Term_Taxonomy::instance()) {
129
-            $taxonomies = get_taxonomies(array('show_in_rest' => true));
130
-            if (! empty($taxonomies)) {
131
-                $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
132
-            }
133
-        }
134
-        return $model_query_params;
135
-    }
117
+	/**
118
+	 * Makes sure that during REST API queries, we only return term-taxonomies
119
+	 * for term taxonomies which should be shown in the rest api
120
+	 *
121
+	 * @param array    $model_query_params
122
+	 * @param array    $querystring_query_params
123
+	 * @param EEM_Base $model
124
+	 * @return array
125
+	 */
126
+	public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
127
+	{
128
+		if ($model === EEM_Term_Taxonomy::instance()) {
129
+			$taxonomies = get_taxonomies(array('show_in_rest' => true));
130
+			if (! empty($taxonomies)) {
131
+				$model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
132
+			}
133
+		}
134
+		return $model_query_params;
135
+	}
136 136
 }
137 137
 // End of file EEM_Term_Taxonomy.model.php
138 138
 // Location: /includes/models/EEM_Term_Taxonomy.model.php
Please login to merge, or discard this patch.
core/db_models/EEM_Venue.model.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -11,189 +11,189 @@
 block discarded – undo
11 11
 class EEM_Venue extends EEM_CPT_Base
12 12
 {
13 13
 
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18 18
 
19
-    protected function __construct($timezone = '')
20
-    {
21
-        $this->singular_item = __('Venue', 'event_espresso');
22
-        $this->plural_item = __('Venues', 'event_espresso');
23
-        $this->_tables = array(
24
-            'Venue_CPT'  => new EE_Primary_Table('posts', 'ID'),
25
-            'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'),
26
-        );
27
-        $this->_fields = array(
28
-            'Venue_CPT'  => array(
29
-                'VNU_ID'         => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")),
30
-                'VNU_name'       => new EE_Plain_Text_Field(
31
-                    'post_title',
32
-                    __("Venue Name", "event_espresso"),
33
-                    false,
34
-                    ''
35
-                ),
36
-                'VNU_desc'       => new EE_Post_Content_Field(
37
-                    'post_content',
38
-                    __("Venue Description", "event_espresso"),
39
-                    false,
40
-                    ''
41
-                ),
42
-                'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''),
43
-                'VNU_created'    => new EE_Datetime_Field(
44
-                    'post_date',
45
-                    __("Date Venue Created", "event_espresso"),
46
-                    false,
47
-                    EE_Datetime_Field::now
48
-                ),
49
-                'VNU_short_desc' => new EE_Plain_Text_Field(
50
-                    'post_excerpt',
51
-                    __("Short Description of Venue", "event_espresso"),
52
-                    true,
53
-                    ''
54
-                ),
55
-                'VNU_modified'   => new EE_Datetime_Field(
56
-                    'post_modified',
57
-                    __("Venue Modified Date", "event_espresso"),
58
-                    false,
59
-                    EE_Datetime_Field::now
60
-                ),
61
-                'VNU_wp_user'    => new EE_WP_User_Field(
62
-                    'post_author',
63
-                    __("Venue Creator ID", "event_espresso"),
64
-                    false
65
-                ),
66
-                'parent'         => new EE_Integer_Field(
67
-                    'post_parent',
68
-                    __("Venue Parent ID", "event_espresso"),
69
-                    false,
70
-                    0
71
-                ),
72
-                'VNU_order'      => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1),
73
-                'post_type'      => new EE_WP_Post_Type_Field('espresso_venues'),
74
-                'password' => new EE_Password_Field(
75
-                    'post_password',
76
-                    __('Password', 'event_espresso'),
77
-                    false,
78
-                    '',
79
-                    array(
80
-                        'VNU_desc',
81
-                        'VNU_short_desc',
82
-                        'VNU_address',
83
-                        'VNU_address2',
84
-                        'VNU_city',
85
-                        'STA_ID',
86
-                        'CNT_ISO',
87
-                        'VNU_zip',
88
-                        'VNU_phone',
89
-                        'VNU_capacity',
90
-                        'VNU_url',
91
-                        'VNU_virtual_phone',
92
-                        'VNU_virtual_url',
93
-                        'VNU_google_map_link',
94
-                        'VNU_enable_for_gmap',
95
-                    )
96
-                )
97
-            ),
98
-            'Venue_Meta' => array(
99
-                'VNUM_ID'             => new EE_DB_Only_Int_Field(
100
-                    'VNUM_ID',
101
-                    __("ID of Venue Meta Row", "event_espresso"),
102
-                    false
103
-                ),
104
-                'VNU_ID_fk'           => new EE_DB_Only_Int_Field(
105
-                    'VNU_ID',
106
-                    __("Foreign Key to Venue Post ", "event_espresso"),
107
-                    false
108
-                ),
109
-                'VNU_address'         => new EE_Plain_Text_Field(
110
-                    'VNU_address',
111
-                    __("Venue Address line 1", "event_espresso"),
112
-                    true,
113
-                    ''
114
-                ),
115
-                'VNU_address2'        => new EE_Plain_Text_Field(
116
-                    'VNU_address2',
117
-                    __("Venue Address line 2", "event_espresso"),
118
-                    true,
119
-                    ''
120
-                ),
121
-                'VNU_city'            => new EE_Plain_Text_Field(
122
-                    'VNU_city',
123
-                    __("Venue City", "event_espresso"),
124
-                    true,
125
-                    ''
126
-                ),
127
-                'STA_ID'              => new EE_Foreign_Key_Int_Field(
128
-                    'STA_ID',
129
-                    __("State ID", "event_espresso"),
130
-                    true,
131
-                    null,
132
-                    'State'
133
-                ),
134
-                'CNT_ISO'             => new EE_Foreign_Key_String_Field(
135
-                    'CNT_ISO',
136
-                    __("Country Code", "event_espresso"),
137
-                    true,
138
-                    null,
139
-                    'Country'
140
-                ),
141
-                'VNU_zip'             => new EE_Plain_Text_Field(
142
-                    'VNU_zip',
143
-                    __("Venue Zip/Postal Code", "event_espresso"),
144
-                    true
145
-                ),
146
-                'VNU_phone'           => new EE_Plain_Text_Field(
147
-                    'VNU_phone',
148
-                    __("Venue Phone", "event_espresso"),
149
-                    true
150
-                ),
151
-                'VNU_capacity'        => new EE_Infinite_Integer_Field(
152
-                    'VNU_capacity',
153
-                    __("Venue Capacity", "event_espresso"),
154
-                    true,
155
-                    EE_INF
156
-                ),
157
-                'VNU_url'             => new EE_Plain_Text_Field(
158
-                    'VNU_url',
159
-                    __('Venue Website', 'event_espresso'),
160
-                    true
161
-                ),
162
-                'VNU_virtual_phone'   => new EE_Plain_Text_Field(
163
-                    'VNU_virtual_phone',
164
-                    __('Call in Number', 'event_espresso'),
165
-                    true
166
-                ),
167
-                'VNU_virtual_url'     => new EE_Plain_Text_Field(
168
-                    'VNU_virtual_url',
169
-                    __('Virtual URL', 'event_espresso'),
170
-                    true
171
-                ),
172
-                'VNU_google_map_link' => new EE_Plain_Text_Field(
173
-                    'VNU_google_map_link',
174
-                    __('Google Map Link', 'event_espresso'),
175
-                    true
176
-                ),
177
-                'VNU_enable_for_gmap' => new EE_Boolean_Field(
178
-                    'VNU_enable_for_gmap',
179
-                    __('Show Google Map?', 'event_espresso'),
180
-                    false,
181
-                    false
182
-                ),
183
-            ),
184
-        );
185
-        $this->_model_relations = array(
186
-            'Event'             => new EE_HABTM_Relation('Event_Venue'),
187
-            'State'             => new EE_Belongs_To_Relation(),
188
-            'Country'           => new EE_Belongs_To_Relation(),
189
-            'Event_Venue'       => new EE_Has_Many_Relation(),
190
-            'WP_User'           => new EE_Belongs_To_Relation(),
191
-            'Term_Relationship' => new EE_Has_Many_Relation(),
192
-            'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
193
-        );
194
-        // this model is generally available for reading
195
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
196
-        $this->model_chain_to_password = '';
197
-        parent::__construct($timezone);
198
-    }
19
+	protected function __construct($timezone = '')
20
+	{
21
+		$this->singular_item = __('Venue', 'event_espresso');
22
+		$this->plural_item = __('Venues', 'event_espresso');
23
+		$this->_tables = array(
24
+			'Venue_CPT'  => new EE_Primary_Table('posts', 'ID'),
25
+			'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'),
26
+		);
27
+		$this->_fields = array(
28
+			'Venue_CPT'  => array(
29
+				'VNU_ID'         => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")),
30
+				'VNU_name'       => new EE_Plain_Text_Field(
31
+					'post_title',
32
+					__("Venue Name", "event_espresso"),
33
+					false,
34
+					''
35
+				),
36
+				'VNU_desc'       => new EE_Post_Content_Field(
37
+					'post_content',
38
+					__("Venue Description", "event_espresso"),
39
+					false,
40
+					''
41
+				),
42
+				'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''),
43
+				'VNU_created'    => new EE_Datetime_Field(
44
+					'post_date',
45
+					__("Date Venue Created", "event_espresso"),
46
+					false,
47
+					EE_Datetime_Field::now
48
+				),
49
+				'VNU_short_desc' => new EE_Plain_Text_Field(
50
+					'post_excerpt',
51
+					__("Short Description of Venue", "event_espresso"),
52
+					true,
53
+					''
54
+				),
55
+				'VNU_modified'   => new EE_Datetime_Field(
56
+					'post_modified',
57
+					__("Venue Modified Date", "event_espresso"),
58
+					false,
59
+					EE_Datetime_Field::now
60
+				),
61
+				'VNU_wp_user'    => new EE_WP_User_Field(
62
+					'post_author',
63
+					__("Venue Creator ID", "event_espresso"),
64
+					false
65
+				),
66
+				'parent'         => new EE_Integer_Field(
67
+					'post_parent',
68
+					__("Venue Parent ID", "event_espresso"),
69
+					false,
70
+					0
71
+				),
72
+				'VNU_order'      => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1),
73
+				'post_type'      => new EE_WP_Post_Type_Field('espresso_venues'),
74
+				'password' => new EE_Password_Field(
75
+					'post_password',
76
+					__('Password', 'event_espresso'),
77
+					false,
78
+					'',
79
+					array(
80
+						'VNU_desc',
81
+						'VNU_short_desc',
82
+						'VNU_address',
83
+						'VNU_address2',
84
+						'VNU_city',
85
+						'STA_ID',
86
+						'CNT_ISO',
87
+						'VNU_zip',
88
+						'VNU_phone',
89
+						'VNU_capacity',
90
+						'VNU_url',
91
+						'VNU_virtual_phone',
92
+						'VNU_virtual_url',
93
+						'VNU_google_map_link',
94
+						'VNU_enable_for_gmap',
95
+					)
96
+				)
97
+			),
98
+			'Venue_Meta' => array(
99
+				'VNUM_ID'             => new EE_DB_Only_Int_Field(
100
+					'VNUM_ID',
101
+					__("ID of Venue Meta Row", "event_espresso"),
102
+					false
103
+				),
104
+				'VNU_ID_fk'           => new EE_DB_Only_Int_Field(
105
+					'VNU_ID',
106
+					__("Foreign Key to Venue Post ", "event_espresso"),
107
+					false
108
+				),
109
+				'VNU_address'         => new EE_Plain_Text_Field(
110
+					'VNU_address',
111
+					__("Venue Address line 1", "event_espresso"),
112
+					true,
113
+					''
114
+				),
115
+				'VNU_address2'        => new EE_Plain_Text_Field(
116
+					'VNU_address2',
117
+					__("Venue Address line 2", "event_espresso"),
118
+					true,
119
+					''
120
+				),
121
+				'VNU_city'            => new EE_Plain_Text_Field(
122
+					'VNU_city',
123
+					__("Venue City", "event_espresso"),
124
+					true,
125
+					''
126
+				),
127
+				'STA_ID'              => new EE_Foreign_Key_Int_Field(
128
+					'STA_ID',
129
+					__("State ID", "event_espresso"),
130
+					true,
131
+					null,
132
+					'State'
133
+				),
134
+				'CNT_ISO'             => new EE_Foreign_Key_String_Field(
135
+					'CNT_ISO',
136
+					__("Country Code", "event_espresso"),
137
+					true,
138
+					null,
139
+					'Country'
140
+				),
141
+				'VNU_zip'             => new EE_Plain_Text_Field(
142
+					'VNU_zip',
143
+					__("Venue Zip/Postal Code", "event_espresso"),
144
+					true
145
+				),
146
+				'VNU_phone'           => new EE_Plain_Text_Field(
147
+					'VNU_phone',
148
+					__("Venue Phone", "event_espresso"),
149
+					true
150
+				),
151
+				'VNU_capacity'        => new EE_Infinite_Integer_Field(
152
+					'VNU_capacity',
153
+					__("Venue Capacity", "event_espresso"),
154
+					true,
155
+					EE_INF
156
+				),
157
+				'VNU_url'             => new EE_Plain_Text_Field(
158
+					'VNU_url',
159
+					__('Venue Website', 'event_espresso'),
160
+					true
161
+				),
162
+				'VNU_virtual_phone'   => new EE_Plain_Text_Field(
163
+					'VNU_virtual_phone',
164
+					__('Call in Number', 'event_espresso'),
165
+					true
166
+				),
167
+				'VNU_virtual_url'     => new EE_Plain_Text_Field(
168
+					'VNU_virtual_url',
169
+					__('Virtual URL', 'event_espresso'),
170
+					true
171
+				),
172
+				'VNU_google_map_link' => new EE_Plain_Text_Field(
173
+					'VNU_google_map_link',
174
+					__('Google Map Link', 'event_espresso'),
175
+					true
176
+				),
177
+				'VNU_enable_for_gmap' => new EE_Boolean_Field(
178
+					'VNU_enable_for_gmap',
179
+					__('Show Google Map?', 'event_espresso'),
180
+					false,
181
+					false
182
+				),
183
+			),
184
+		);
185
+		$this->_model_relations = array(
186
+			'Event'             => new EE_HABTM_Relation('Event_Venue'),
187
+			'State'             => new EE_Belongs_To_Relation(),
188
+			'Country'           => new EE_Belongs_To_Relation(),
189
+			'Event_Venue'       => new EE_Has_Many_Relation(),
190
+			'WP_User'           => new EE_Belongs_To_Relation(),
191
+			'Term_Relationship' => new EE_Has_Many_Relation(),
192
+			'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
193
+		);
194
+		// this model is generally available for reading
195
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
196
+		$this->model_chain_to_password = '';
197
+		parent::__construct($timezone);
198
+	}
199 199
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -11,68 +11,68 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency extends EEM_Base
13 13
 {
14
-        // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+		// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = '')
18
-    {
19
-        $this->singular_item = __('Currency', 'event_espresso');
20
-        $this->plural_item = __('Currencies', 'event_espresso');
21
-        $this->_tables = array(
22
-            'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
-        );
24
-        $this->_fields = array(
25
-            'Currency' => array(
26
-                'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
-                'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
-                'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
-                'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
-                'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
-                'CUR_active' => new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
-            ));
33
-        $this->_model_relations = array(
34
-            'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
17
+	protected function __construct($timezone = '')
18
+	{
19
+		$this->singular_item = __('Currency', 'event_espresso');
20
+		$this->plural_item = __('Currencies', 'event_espresso');
21
+		$this->_tables = array(
22
+			'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
+		);
24
+		$this->_fields = array(
25
+			'Currency' => array(
26
+				'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
+				'CUR_active' => new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
+			));
33
+		$this->_model_relations = array(
34
+			'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38 38
 
39
-        parent::__construct($timezone);
40
-    }
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
-     * (may be overridden)
45
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
-     * @return EE_Currency[]
47
-     */
48
-    public function get_all_active($query_params = array())
49
-    {
50
-        $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
-        }
54
-        return $this->get_all($query_params);
55
-    }
56
-    /**
57
-     * Gets all the currencies which can be used by that payment method type
58
-     * @param EE_PMT_Base $payment_method_type
59
-     * @return EE_Currency[]
60
-     */
61
-    public function get_all_currencies_usable_by($payment_method_type)
62
-    {
63
-        if (
64
-            $payment_method_type instanceof EE_PMT_Base &&
65
-                $payment_method_type->get_gateway()
66
-        ) {
67
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
-        } else {
69
-            $currencies_supported = EE_Gateway::all_currencies_supported;
70
-        }
71
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
-            $currencies = $this->get_all_active();
73
-        } else {
74
-            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
-        }
76
-        return $currencies;
77
-    }
42
+	/**
43
+	 * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
+	 * (may be overridden)
45
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
+	 * @return EE_Currency[]
47
+	 */
48
+	public function get_all_active($query_params = array())
49
+	{
50
+		$query_params[0]['CUR_active'] = true;
51
+		if (! isset($query_params['order_by'])) {
52
+			$query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
+		}
54
+		return $this->get_all($query_params);
55
+	}
56
+	/**
57
+	 * Gets all the currencies which can be used by that payment method type
58
+	 * @param EE_PMT_Base $payment_method_type
59
+	 * @return EE_Currency[]
60
+	 */
61
+	public function get_all_currencies_usable_by($payment_method_type)
62
+	{
63
+		if (
64
+			$payment_method_type instanceof EE_PMT_Base &&
65
+				$payment_method_type->get_gateway()
66
+		) {
67
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
+		} else {
69
+			$currencies_supported = EE_Gateway::all_currencies_supported;
70
+		}
71
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
+			$currencies = $this->get_all_active();
73
+		} else {
74
+			$currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
+		}
76
+		return $currencies;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Answer.model.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -10,144 +10,144 @@
 block discarded – undo
10 10
 class EEM_Answer extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * private instance of the EEM_Answer object
15
-     * @type EEM_Answer
16
-     */
17
-    protected static $_instance = null;
13
+	/**
14
+	 * private instance of the EEM_Answer object
15
+	 * @type EEM_Answer
16
+	 */
17
+	protected static $_instance = null;
18 18
 
19
-    /**
20
-     * Mapping from system question ids to attendee field names
21
-     * @type array
22
-     * @deprecated since version 4.8.8
23
-     */
24
-    protected $_question_id_to_att_field_map = array(
25
-        EEM_Attendee::fname_question_id => 'ATT_fname',
26
-        EEM_Attendee::lname_question_id => 'ATT_lname',
27
-        EEM_Attendee::email_question_id => 'ATT_email',
28
-        EEM_Attendee::address_question_id => 'ATT_address',
29
-        EEM_Attendee::address2_question_id => 'ATT_address2',
30
-        EEM_Attendee::city_question_id => 'ATT_city',
31
-        EEM_Attendee::state_question_id => 'STA_ID',
32
-        EEM_Attendee::country_question_id => 'CNT_ISO',
33
-        EEM_Attendee::zip_question_id => 'ATT_zip',
34
-        EEM_Attendee::phone_question_id => 'ATT_phone'
35
-    );
19
+	/**
20
+	 * Mapping from system question ids to attendee field names
21
+	 * @type array
22
+	 * @deprecated since version 4.8.8
23
+	 */
24
+	protected $_question_id_to_att_field_map = array(
25
+		EEM_Attendee::fname_question_id => 'ATT_fname',
26
+		EEM_Attendee::lname_question_id => 'ATT_lname',
27
+		EEM_Attendee::email_question_id => 'ATT_email',
28
+		EEM_Attendee::address_question_id => 'ATT_address',
29
+		EEM_Attendee::address2_question_id => 'ATT_address2',
30
+		EEM_Attendee::city_question_id => 'ATT_city',
31
+		EEM_Attendee::state_question_id => 'STA_ID',
32
+		EEM_Attendee::country_question_id => 'CNT_ISO',
33
+		EEM_Attendee::zip_question_id => 'ATT_zip',
34
+		EEM_Attendee::phone_question_id => 'ATT_phone'
35
+	);
36 36
 
37 37
 
38
-    /**
39
-     *  constructor
40
-     *
41
-     * @param string $timezone
42
-     * @throws EE_Error
43
-     */
44
-    protected function __construct($timezone = '')
45
-    {
46
-        $this->singular_item = __('Answer', 'event_espresso');
47
-        $this->plural_item = __('Answers', 'event_espresso');
48
-        $this->_tables = array(
49
-            'Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID')
50
-        );
51
-        $this->_fields = array(
52
-            'Answer' => array(
53
-                'ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
54
-                'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
55
-                'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
56
-                'ANS_value' => new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
57
-            ));
58
-        $this->_model_relations = array(
59
-            'Registration' => new EE_Belongs_To_Relation(),
60
-            'Question' => new EE_Belongs_To_Relation()
61
-        );
62
-        $this->_model_chain_to_wp_user = 'Registration.Event';
63
-        $this->_caps_slug = 'registrations';
64
-        parent::__construct($timezone);
65
-    }
38
+	/**
39
+	 *  constructor
40
+	 *
41
+	 * @param string $timezone
42
+	 * @throws EE_Error
43
+	 */
44
+	protected function __construct($timezone = '')
45
+	{
46
+		$this->singular_item = __('Answer', 'event_espresso');
47
+		$this->plural_item = __('Answers', 'event_espresso');
48
+		$this->_tables = array(
49
+			'Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID')
50
+		);
51
+		$this->_fields = array(
52
+			'Answer' => array(
53
+				'ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
54
+				'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
55
+				'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
56
+				'ANS_value' => new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
57
+			));
58
+		$this->_model_relations = array(
59
+			'Registration' => new EE_Belongs_To_Relation(),
60
+			'Question' => new EE_Belongs_To_Relation()
61
+		);
62
+		$this->_model_chain_to_wp_user = 'Registration.Event';
63
+		$this->_caps_slug = 'registrations';
64
+		parent::__construct($timezone);
65
+	}
66 66
 
67 67
 
68 68
 
69
-    /**
70
-     * Gets the string answer to the question for this registration (it could either be stored
71
-     * on the attendee or in the answer table. This function finds its value regardless)
72
-     * @param EE_Registration $registration
73
-     * @param int $question_id
74
-     * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
75
-     * @return string
76
-     */
77
-    public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
78
-    {
79
-        $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
80
-        if ($value === null) {
81
-            $answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
82
-            if ($answer_obj instanceof EE_Answer) {
83
-                if ($pretty_answer) {
84
-                    $value = $answer_obj->pretty_value();
85
-                } else {
86
-                    $value = $answer_obj->value();
87
-                }
88
-            }
89
-        }
90
-        return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
91
-    }
69
+	/**
70
+	 * Gets the string answer to the question for this registration (it could either be stored
71
+	 * on the attendee or in the answer table. This function finds its value regardless)
72
+	 * @param EE_Registration $registration
73
+	 * @param int $question_id
74
+	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
75
+	 * @return string
76
+	 */
77
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
78
+	{
79
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
80
+		if ($value === null) {
81
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
82
+			if ($answer_obj instanceof EE_Answer) {
83
+				if ($pretty_answer) {
84
+					$value = $answer_obj->pretty_value();
85
+				} else {
86
+					$value = $answer_obj->value();
87
+				}
88
+			}
89
+		}
90
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
91
+	}
92 92
 
93 93
 
94 94
 
95
-    /**
96
-     * Gets the EE_Answer object for the question for this registration (if it exists)
97
-     * @param EE_Registration $registration
98
-     * @param int $question_id
99
-     * @return EE_Answer
100
-     */
101
-    public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
102
-    {
103
-        $answer_obj = $this->get_one(array( array( 'QST_ID' => $question_id, 'REG_ID' => $registration->ID() )));
104
-        return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
105
-    }
95
+	/**
96
+	 * Gets the EE_Answer object for the question for this registration (if it exists)
97
+	 * @param EE_Registration $registration
98
+	 * @param int $question_id
99
+	 * @return EE_Answer
100
+	 */
101
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
102
+	{
103
+		$answer_obj = $this->get_one(array( array( 'QST_ID' => $question_id, 'REG_ID' => $registration->ID() )));
104
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
105
+	}
106 106
 
107 107
 
108 108
 
109
-    /**
110
-     * Gets the string answer to the question for this registration's attendee
111
-     * @param EE_Registration $registration
112
-     * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
113
-     *  Passing in the QST_system value is more efficient
114
-     * @param boolean $pretty_answer
115
-     * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
116
-     * a question corresponding to an attendee field, returns null)
117
-     */
118
-    public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
119
-    {
120
-        $field_name = null;
121
-        $value = null;
122
-                // backward compat: we still want to find the question's ID
123
-        if (is_numeric($question_system_id)) {
124
-            // find this question's QST_system value
125
-            $question_id = $question_system_id;
126
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
127
-        } else {
128
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
129
-        }
130
-        // only bother checking if the registration has an attendee
131
-        if ($registration->attendee() instanceof EE_Attendee) {
132
-            $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
133
-            if ($field_name) {
134
-                if ($pretty_answer) {
135
-                    if ($field_name === 'STA_ID') {
136
-                        $state = $registration->attendee()->state_obj();
137
-                        $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
138
-                    } elseif ($field_name === 'CNT_ISO') {
139
-                        $country = $registration->attendee()->country_obj();
140
-                        $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
141
-                    } else {
142
-                        $value = $registration->attendee()->get_pretty($field_name);
143
-                    }
144
-                    // if field name is blank, leave the value as null too
145
-                } else {
146
-                    $value = $registration->attendee()->get($field_name);
147
-                }
148
-            }
149
-            // if no field was found, leave value blank
150
-        }
151
-        return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
152
-    }
109
+	/**
110
+	 * Gets the string answer to the question for this registration's attendee
111
+	 * @param EE_Registration $registration
112
+	 * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
113
+	 *  Passing in the QST_system value is more efficient
114
+	 * @param boolean $pretty_answer
115
+	 * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
116
+	 * a question corresponding to an attendee field, returns null)
117
+	 */
118
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
119
+	{
120
+		$field_name = null;
121
+		$value = null;
122
+				// backward compat: we still want to find the question's ID
123
+		if (is_numeric($question_system_id)) {
124
+			// find this question's QST_system value
125
+			$question_id = $question_system_id;
126
+			$question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
127
+		} else {
128
+			$question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
129
+		}
130
+		// only bother checking if the registration has an attendee
131
+		if ($registration->attendee() instanceof EE_Attendee) {
132
+			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
133
+			if ($field_name) {
134
+				if ($pretty_answer) {
135
+					if ($field_name === 'STA_ID') {
136
+						$state = $registration->attendee()->state_obj();
137
+						$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
138
+					} elseif ($field_name === 'CNT_ISO') {
139
+						$country = $registration->attendee()->country_obj();
140
+						$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
141
+					} else {
142
+						$value = $registration->attendee()->get_pretty($field_name);
143
+					}
144
+					// if field name is blank, leave the value as null too
145
+				} else {
146
+					$value = $registration->attendee()->get($field_name);
147
+				}
148
+			}
149
+			// if no field was found, leave value blank
150
+		}
151
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
152
+	}
153 153
 }
Please login to merge, or discard this patch.