Completed
Branch FET/reg-form-builder/main (a2f871)
by
unknown
15:30 queued 13:14
created
core/db_models/EEM_Form_Section.model.php 2 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -21,237 +21,237 @@
 block discarded – undo
21 21
  */
22 22
 class EEM_Form_Section extends EEM_Form_Element
23 23
 {
24
-    public const APPLIES_TO_ALL         = 'all';
24
+	public const APPLIES_TO_ALL         = 'all';
25 25
 
26
-    public const APPLIES_TO_PRIMARY     = 'primary';
26
+	public const APPLIES_TO_PRIMARY     = 'primary';
27 27
 
28
-    public const APPLIES_TO_PURCHASER   = 'purchaser';
28
+	public const APPLIES_TO_PURCHASER   = 'purchaser';
29 29
 
30
-    public const APPLIES_TO_REGISTRANTS = 'registrants';
30
+	public const APPLIES_TO_REGISTRANTS = 'registrants';
31 31
 
32
-    /**
33
-     * @var EEM_Form_Section
34
-     */
35
-    protected static $_instance;
32
+	/**
33
+	 * @var EEM_Form_Section
34
+	 */
35
+	protected static $_instance;
36 36
 
37
-    /**
38
-     * @var RequestInterface
39
-     */
40
-    private $request;
37
+	/**
38
+	 * @var RequestInterface
39
+	 */
40
+	private $request;
41 41
 
42
-    /**
43
-     * @var array
44
-     */
45
-    private $valid_applies_to_options;
42
+	/**
43
+	 * @var array
44
+	 */
45
+	private $valid_applies_to_options;
46 46
 
47 47
 
48
-    protected function __construct(Element $element, $timezone = null)
49
-    {
50
-        $this->valid_applies_to_options = apply_filters(
51
-            'FHEE__EEM_Form_Section__valid_applies_to_options',
52
-            [
53
-                EEM_Form_Section::APPLIES_TO_ALL         => esc_html__('All Registrants', 'event_espresso'),
54
-                EEM_Form_Section::APPLIES_TO_PRIMARY     => esc_html__('Primary Registrant Only', 'event_espresso'),
55
-                EEM_Form_Section::APPLIES_TO_PURCHASER   => esc_html__('Purchasing Agent', 'event_espresso'),
56
-                EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'),
57
-            ]
58
-        );
48
+	protected function __construct(Element $element, $timezone = null)
49
+	{
50
+		$this->valid_applies_to_options = apply_filters(
51
+			'FHEE__EEM_Form_Section__valid_applies_to_options',
52
+			[
53
+				EEM_Form_Section::APPLIES_TO_ALL         => esc_html__('All Registrants', 'event_espresso'),
54
+				EEM_Form_Section::APPLIES_TO_PRIMARY     => esc_html__('Primary Registrant Only', 'event_espresso'),
55
+				EEM_Form_Section::APPLIES_TO_PURCHASER   => esc_html__('Purchasing Agent', 'event_espresso'),
56
+				EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'),
57
+			]
58
+		);
59 59
 
60
-        $this->singular_item = esc_html__('Form Section', 'event_espresso');
61
-        $this->plural_item   = esc_html__('Form Sections', 'event_espresso');
60
+		$this->singular_item = esc_html__('Form Section', 'event_espresso');
61
+		$this->plural_item   = esc_html__('Form Sections', 'event_espresso');
62 62
 
63
-        $this->_tables          = [
64
-            'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'),
65
-        ];
66
-        $this->_fields          = [
67
-            'Form_Section' => [
68
-                'FSC_UUID'      => new EE_Primary_Key_String_Field(
69
-                    'FSC_UUID',
70
-                    esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso')
71
-                ),
72
-                'FSC_adminLabel' => new EE_Plain_Text_Field(
73
-                    'FSC_adminLabel',
74
-                    esc_html__(
75
-                        'Form Section label displayed in the admin to help differentiate it from others.',
76
-                        'event_espresso'
77
-                    ),
78
-                    true,
79
-                    null
80
-                ),
81
-                'FSC_appliesTo' => new EE_Enum_Text_Field(
82
-                    'FSC_appliesTo',
83
-                    esc_html(
84
-                        sprintf(
85
-                            /* translators: 1 class name */
86
-                            __(
87
-                                'Form user type that this form section should be presented to. Values correspond to the %s constants.',
88
-                                'event_espresso'
89
-                            ),
90
-                            'EEM_Form_Section::APPLIES_TO_*'
91
-                        )
92
-                    ),
93
-                    false,
94
-                    EEM_Form_Section::APPLIES_TO_ALL,
95
-                    $this->valid_applies_to_options
96
-                ),
97
-                'FSC_belongsTo' => new EE_Plain_Text_Field(
98
-                    'FSC_belongsTo',
99
-                    esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'),
100
-                    true,
101
-                    null
102
-                ),
103
-                'FSC_htmlClass' => new EE_Plain_Text_Field(
104
-                    'FSC_htmlClass',
105
-                    esc_html__('HTML classes to be applied to this form section\'s container.', 'event_espresso'),
106
-                    true,
107
-                    null
108
-                ),
109
-                'FSC_order'     => new EE_Integer_Field(
110
-                    'FSC_order',
111
-                    esc_html__('Order in which form section appears in a form.', 'event_espresso'),
112
-                    false,
113
-                    0
114
-                ),
115
-                'FSC_publicLabel' => new EE_Plain_Text_Field(
116
-                    'FSC_publicLabel',
117
-                    esc_html__('Form Section label displayed on public forms as a heading.', 'event_espresso'),
118
-                    true,
119
-                    null
120
-                ),
121
-                'FSC_showLabel' => new EE_Boolean_Field(
122
-                    'FSC_showLabel',
123
-                    esc_html__(
124
-                        'Whether or not to display the Form Section name (Public Label) on public forms.',
125
-                        'event_espresso'
126
-                    ),
127
-                    false,
128
-                    true
129
-                ),
130
-                'FSC_status'    => new EE_Enum_Text_Field(
131
-                    'FSC_status',
132
-                    esc_html(
133
-                        sprintf(
134
-                            /* translators: 1 class name */
135
-                            __(
136
-                                'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %s constants.',
137
-                                'event_espresso'
138
-                            ),
139
-                            'EEM_Form_Section::STATUS_TO_'
140
-                        )
141
-                    ),
142
-                    false,
143
-                    Element::STATUS_ACTIVE,
144
-                    $element->validStatusOptions()
145
-                ),
146
-                'FSC_wpUser'    => new EE_WP_User_Field(
147
-                    'FSC_wpUser',
148
-                    esc_html__('ID of the WP User that created this form section.', 'event_espresso'),
149
-                    false
150
-                ),
151
-            ],
152
-        ];
153
-        $this->_model_relations = [
154
-            'Form_Input' => new EE_Has_Many_Relation(),
155
-            'Form_Submission' => new EE_Has_Many_Relation(),
156
-            'WP_User'    => new EE_Belongs_To_Relation(),
157
-        ];
158
-        // this model is generally available for reading
159
-        $restrictions                              = [];
160
-        $restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
161
-        $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
162
-        $restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
163
-        $restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
164
-        $this->_cap_restriction_generators         = $restrictions;
165
-        parent::__construct($element, $timezone);
166
-        $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
167
-    }
63
+		$this->_tables          = [
64
+			'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'),
65
+		];
66
+		$this->_fields          = [
67
+			'Form_Section' => [
68
+				'FSC_UUID'      => new EE_Primary_Key_String_Field(
69
+					'FSC_UUID',
70
+					esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso')
71
+				),
72
+				'FSC_adminLabel' => new EE_Plain_Text_Field(
73
+					'FSC_adminLabel',
74
+					esc_html__(
75
+						'Form Section label displayed in the admin to help differentiate it from others.',
76
+						'event_espresso'
77
+					),
78
+					true,
79
+					null
80
+				),
81
+				'FSC_appliesTo' => new EE_Enum_Text_Field(
82
+					'FSC_appliesTo',
83
+					esc_html(
84
+						sprintf(
85
+							/* translators: 1 class name */
86
+							__(
87
+								'Form user type that this form section should be presented to. Values correspond to the %s constants.',
88
+								'event_espresso'
89
+							),
90
+							'EEM_Form_Section::APPLIES_TO_*'
91
+						)
92
+					),
93
+					false,
94
+					EEM_Form_Section::APPLIES_TO_ALL,
95
+					$this->valid_applies_to_options
96
+				),
97
+				'FSC_belongsTo' => new EE_Plain_Text_Field(
98
+					'FSC_belongsTo',
99
+					esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'),
100
+					true,
101
+					null
102
+				),
103
+				'FSC_htmlClass' => new EE_Plain_Text_Field(
104
+					'FSC_htmlClass',
105
+					esc_html__('HTML classes to be applied to this form section\'s container.', 'event_espresso'),
106
+					true,
107
+					null
108
+				),
109
+				'FSC_order'     => new EE_Integer_Field(
110
+					'FSC_order',
111
+					esc_html__('Order in which form section appears in a form.', 'event_espresso'),
112
+					false,
113
+					0
114
+				),
115
+				'FSC_publicLabel' => new EE_Plain_Text_Field(
116
+					'FSC_publicLabel',
117
+					esc_html__('Form Section label displayed on public forms as a heading.', 'event_espresso'),
118
+					true,
119
+					null
120
+				),
121
+				'FSC_showLabel' => new EE_Boolean_Field(
122
+					'FSC_showLabel',
123
+					esc_html__(
124
+						'Whether or not to display the Form Section name (Public Label) on public forms.',
125
+						'event_espresso'
126
+					),
127
+					false,
128
+					true
129
+				),
130
+				'FSC_status'    => new EE_Enum_Text_Field(
131
+					'FSC_status',
132
+					esc_html(
133
+						sprintf(
134
+							/* translators: 1 class name */
135
+							__(
136
+								'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %s constants.',
137
+								'event_espresso'
138
+							),
139
+							'EEM_Form_Section::STATUS_TO_'
140
+						)
141
+					),
142
+					false,
143
+					Element::STATUS_ACTIVE,
144
+					$element->validStatusOptions()
145
+				),
146
+				'FSC_wpUser'    => new EE_WP_User_Field(
147
+					'FSC_wpUser',
148
+					esc_html__('ID of the WP User that created this form section.', 'event_espresso'),
149
+					false
150
+				),
151
+			],
152
+		];
153
+		$this->_model_relations = [
154
+			'Form_Input' => new EE_Has_Many_Relation(),
155
+			'Form_Submission' => new EE_Has_Many_Relation(),
156
+			'WP_User'    => new EE_Belongs_To_Relation(),
157
+		];
158
+		// this model is generally available for reading
159
+		$restrictions                              = [];
160
+		$restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
161
+		$restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
162
+		$restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
163
+		$restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
164
+		$this->_cap_restriction_generators         = $restrictions;
165
+		parent::__construct($element, $timezone);
166
+		$this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
167
+	}
168 168
 
169 169
 
170
-    /**
171
-     * @param array $query_params
172
-     * @return array
173
-     */
174
-    private function addDefaultWhereConditions(array $query_params): array
175
-    {
176
-        // might need to add a way to identify GQL requests for admin domains
177
-        $admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
178
-        $query_params['default_where_conditions'] = $admin_request
179
-            ? EEM_Base::default_where_conditions_none
180
-            : EEM_Base::default_where_conditions_all;
181
-        return $query_params;
182
-    }
170
+	/**
171
+	 * @param array $query_params
172
+	 * @return array
173
+	 */
174
+	private function addDefaultWhereConditions(array $query_params): array
175
+	{
176
+		// might need to add a way to identify GQL requests for admin domains
177
+		$admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
178
+		$query_params['default_where_conditions'] = $admin_request
179
+			? EEM_Base::default_where_conditions_none
180
+			: EEM_Base::default_where_conditions_all;
181
+		return $query_params;
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * form sections should always be sorted in ascending order via the FSC_order field
187
-     *
188
-     * @param array $query_params
189
-     * @return array
190
-     */
191
-    private function addOrderByQueryParams(array $query_params): array
192
-    {
193
-        $query_params['order_by'] = ['FSC_order' => 'ASC'];
194
-        return $query_params;
195
-    }
185
+	/**
186
+	 * form sections should always be sorted in ascending order via the FSC_order field
187
+	 *
188
+	 * @param array $query_params
189
+	 * @return array
190
+	 */
191
+	private function addOrderByQueryParams(array $query_params): array
192
+	{
193
+		$query_params['order_by'] = ['FSC_order' => 'ASC'];
194
+		return $query_params;
195
+	}
196 196
 
197 197
 
198
-    /**
199
-     * returns an array of Form Sections for the specified parent Form Section
200
-     *
201
-     * @param string $FSC_UUID
202
-     * @return EE_Form_Section[]
203
-     * @throws EE_Error
204
-     */
205
-    public function getChildFormSections(string $FSC_UUID): array
206
-    {
207
-        return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]);
208
-    }
198
+	/**
199
+	 * returns an array of Form Sections for the specified parent Form Section
200
+	 *
201
+	 * @param string $FSC_UUID
202
+	 * @return EE_Form_Section[]
203
+	 * @throws EE_Error
204
+	 */
205
+	public function getChildFormSections(string $FSC_UUID): array
206
+	{
207
+		return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]);
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     * @return EE_Form_Section[]
213
-     * @throws EE_Error
214
-     */
215
-    private function getFormSections(array $where_params): array
216
-    {
217
-        $query_params = $this->addDefaultWhereConditions([$where_params]);
218
-        $query_params = $this->addOrderByQueryParams($query_params);
219
-        return $this->get_all($query_params);
220
-    }
211
+	/**
212
+	 * @return EE_Form_Section[]
213
+	 * @throws EE_Error
214
+	 */
215
+	private function getFormSections(array $where_params): array
216
+	{
217
+		$query_params = $this->addDefaultWhereConditions([$where_params]);
218
+		$query_params = $this->addOrderByQueryParams($query_params);
219
+		return $this->get_all($query_params);
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * returns an array of Form Sections for the specified Event
225
-     *
226
-     * @param EE_Event $event
227
-     * @return EE_Form_Section[]
228
-     * @throws EE_Error
229
-     * @throws ReflectionException
230
-     */
231
-    public function getFormSectionsForEvent(EE_Event $event): array
232
-    {
233
-        $FSC_UUID = $event->registrationFormUuid();
234
-        return ! empty($FSC_UUID)
235
-            ? $this->getFormSections(
236
-                [
237
-                    'OR' => [
238
-                        'FSC_UUID'      => $FSC_UUID, // top level form
239
-                        'FSC_belongsTo' => $FSC_UUID, // child form sections
240
-                    ]
241
-                ]
242
-            )
243
-            : [];
244
-    }
223
+	/**
224
+	 * returns an array of Form Sections for the specified Event
225
+	 *
226
+	 * @param EE_Event $event
227
+	 * @return EE_Form_Section[]
228
+	 * @throws EE_Error
229
+	 * @throws ReflectionException
230
+	 */
231
+	public function getFormSectionsForEvent(EE_Event $event): array
232
+	{
233
+		$FSC_UUID = $event->registrationFormUuid();
234
+		return ! empty($FSC_UUID)
235
+			? $this->getFormSections(
236
+				[
237
+					'OR' => [
238
+						'FSC_UUID'      => $FSC_UUID, // top level form
239
+						'FSC_belongsTo' => $FSC_UUID, // child form sections
240
+					]
241
+				]
242
+			)
243
+			: [];
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * @param bool $constants_only
249
-     * @return array
250
-     */
251
-    public function validAppliesToOptions(bool $constants_only = false): array
252
-    {
253
-        return $constants_only
254
-            ? array_keys($this->valid_applies_to_options)
255
-            : $this->valid_applies_to_options;
256
-    }
247
+	/**
248
+	 * @param bool $constants_only
249
+	 * @return array
250
+	 */
251
+	public function validAppliesToOptions(bool $constants_only = false): array
252
+	{
253
+		return $constants_only
254
+			? array_keys($this->valid_applies_to_options)
255
+			: $this->valid_applies_to_options;
256
+	}
257 257
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -157,10 +157,10 @@
 block discarded – undo
157 157
         ];
158 158
         // this model is generally available for reading
159 159
         $restrictions                              = [];
160
-        $restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
161
-        $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
162
-        $restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
163
-        $restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
160
+        $restrictions[EEM_Base::caps_read]       = new EE_Restriction_Generator_Public();
161
+        $restrictions[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
162
+        $restrictions[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
163
+        $restrictions[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
164 164
         $this->_cap_restriction_generators         = $restrictions;
165 165
         parent::__construct($element, $timezone);
166 166
         $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
Please login to merge, or discard this patch.
core/db_models/fields/EE_JSON_Field.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,76 +5,76 @@
 block discarded – undo
5 5
 class EE_JSON_Field extends EE_Model_Field_Base
6 6
 {
7 7
 
8
-    /**
9
-     * @var JsonDataHandler
10
-     */
11
-    private $json_data_handler;
8
+	/**
9
+	 * @var JsonDataHandler
10
+	 */
11
+	private $json_data_handler;
12 12
 
13 13
 
14
-    /**
15
-     * @param string $table_column
16
-     * @param string $nicename
17
-     * @param bool   $nullable
18
-     * @param null   $default_value
19
-     */
20
-    public function __construct(
21
-        $table_column,
22
-        $nicename,
23
-        $nullable,
24
-        $default_value = null
25
-    ) {
26
-        $this->json_data_handler = new JsonDataHandler();
27
-        $this->json_data_handler->configure(
28
-            JsonDataHandler::DATA_TYPE_OBJECT
29
-        );
30
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
31
-    }
14
+	/**
15
+	 * @param string $table_column
16
+	 * @param string $nicename
17
+	 * @param bool   $nullable
18
+	 * @param null   $default_value
19
+	 */
20
+	public function __construct(
21
+		$table_column,
22
+		$nicename,
23
+		$nullable,
24
+		$default_value = null
25
+	) {
26
+		$this->json_data_handler = new JsonDataHandler();
27
+		$this->json_data_handler->configure(
28
+			JsonDataHandler::DATA_TYPE_OBJECT
29
+		);
30
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
31
+	}
32 32
 
33 33
 
34
-    // /**
35
-    //  * When get() is called on a model object (eg EE_Event), before returning its value,
36
-    //  * call this function on it, allowing us to customize the returned value based on
37
-    //  * the field's type. Eg, we may want to unserialize it, strip tags, etc. By default,
38
-    //  * we simply return it.
39
-    //  *
40
-    //  * @param mixed $value_of_field_on_model_object
41
-    //  * @return mixed
42
-    //  */
43
-    // public function prepare_for_get($value_of_field_on_model_object)
44
-    // {
45
-    //     // return $this->json_data_handler->decodeJson($value_of_field_on_model_object);
46
-    //     return $value_of_field_on_model_object;
47
-    // }
34
+	// /**
35
+	//  * When get() is called on a model object (eg EE_Event), before returning its value,
36
+	//  * call this function on it, allowing us to customize the returned value based on
37
+	//  * the field's type. Eg, we may want to unserialize it, strip tags, etc. By default,
38
+	//  * we simply return it.
39
+	//  *
40
+	//  * @param mixed $value_of_field_on_model_object
41
+	//  * @return mixed
42
+	//  */
43
+	// public function prepare_for_get($value_of_field_on_model_object)
44
+	// {
45
+	//     // return $this->json_data_handler->decodeJson($value_of_field_on_model_object);
46
+	//     return $value_of_field_on_model_object;
47
+	// }
48 48
 
49 49
 
50
-    /**
51
-     * When creating a brand-new model object, or setting a particular value for one of its fields, this function
52
-     * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc.
53
-     * By default, we do nothing.
54
-     *
55
-     * If the model field is going to perform any validation on the input, this is where it should be done
56
-     * (once the value is on the model object, it may be used in other ways besides putting it into the DB
57
-     * so it's best to validate it right away).
58
-     *
59
-     * @param mixed $value_inputted_for_field_on_model_object
60
-     * @return false|string
61
-     */
62
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
63
-    {
64
-        return $this->json_data_handler->encodeData($value_inputted_for_field_on_model_object);
65
-    }
50
+	/**
51
+	 * When creating a brand-new model object, or setting a particular value for one of its fields, this function
52
+	 * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc.
53
+	 * By default, we do nothing.
54
+	 *
55
+	 * If the model field is going to perform any validation on the input, this is where it should be done
56
+	 * (once the value is on the model object, it may be used in other ways besides putting it into the DB
57
+	 * so it's best to validate it right away).
58
+	 *
59
+	 * @param mixed $value_inputted_for_field_on_model_object
60
+	 * @return false|string
61
+	 */
62
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
63
+	{
64
+		return $this->json_data_handler->encodeData($value_inputted_for_field_on_model_object);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * When inserting or updating a field on a model object, run this function on each
70
-     * value to prepare it for insertion into the db. Generally this converts
71
-     * the validated input on the model object into the format used in the DB.
72
-     *
73
-     * @param mixed $value_of_field_on_model_object
74
-     * @return false|string
75
-     */
76
-    public function prepare_for_use_in_db($value_of_field_on_model_object)
77
-    {
78
-        return $this->json_data_handler->encodeData($value_of_field_on_model_object);
79
-    }
68
+	/**
69
+	 * When inserting or updating a field on a model object, run this function on each
70
+	 * value to prepare it for insertion into the db. Generally this converts
71
+	 * the validated input on the model object into the format used in the DB.
72
+	 *
73
+	 * @param mixed $value_of_field_on_model_object
74
+	 * @return false|string
75
+	 */
76
+	public function prepare_for_use_in_db($value_of_field_on_model_object)
77
+	{
78
+		return $this->json_data_handler->encodeData($value_of_field_on_model_object);
79
+	}
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/EEM_Form_Input.model.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -34,282 +34,282 @@
 block discarded – undo
34 34
 class EEM_Form_Input extends EEM_Form_Element
35 35
 {
36 36
 
37
-    /**
38
-     * @var EEM_Form_Input
39
-     */
40
-    protected static $_instance;
37
+	/**
38
+	 * @var EEM_Form_Input
39
+	 */
40
+	protected static $_instance;
41 41
 
42
-    /**
43
-     * @var RequestInterface
44
-     */
45
-    private $request;
42
+	/**
43
+	 * @var RequestInterface
44
+	 */
45
+	private $request;
46 46
 
47
-    /**
48
-     * @var InputTypes
49
-     */
50
-    private $input_types;
47
+	/**
48
+	 * @var InputTypes
49
+	 */
50
+	private $input_types;
51 51
 
52 52
 
53
-    protected function __construct(Element $element, InputTypes $input_types, $timezone = null)
54
-    {
55
-        $this->input_types = $input_types;
56
-        $this->singular_item = esc_html__('Form Input', 'event_espresso');
57
-        $this->plural_item   = esc_html__('Form Inputs', 'event_espresso');
53
+	protected function __construct(Element $element, InputTypes $input_types, $timezone = null)
54
+	{
55
+		$this->input_types = $input_types;
56
+		$this->singular_item = esc_html__('Form Input', 'event_espresso');
57
+		$this->plural_item   = esc_html__('Form Inputs', 'event_espresso');
58 58
 
59
-        $this->_tables          = [
60
-            'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_UUID'),
61
-        ];
62
-        $this->_fields          = [
63
-            'Form_Input' => [
64
-                'FIN_UUID'      => new EE_Primary_Key_String_Field(
65
-                    'FIN_UUID',
66
-                    esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso')
67
-                ),
68
-                'FSC_UUID' => new EE_Foreign_Key_String_Field(
69
-                    'FSC_UUID',
70
-                    esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
71
-                    false,
72
-                    null,
73
-                    ['Form_Section']
74
-                ),
75
-                'FIN_adminLabel' => new EE_Plain_Text_Field(
76
-                    'FIN_adminLabel',
77
-                    esc_html__(
78
-                        'Input label displayed in the admin to help differentiate input from others.',
79
-                        'event_espresso'
80
-                    ),
81
-                    true,
82
-                    null
83
-                ),
84
-                'FIN_adminOnly' => new EE_Boolean_Field(
85
-                    'FIN_adminOnly',
86
-                    esc_html__(
87
-                        'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
88
-                        'event_espresso'
89
-                    ),
90
-                    false,
91
-                    false
92
-                ),
93
-                'FIN_helpClass' => new EE_Plain_Text_Field(
94
-                    'FIN_helpClass',
95
-                    esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'),
96
-                    true,
97
-                    null
98
-                ),
99
-                'FIN_helpText' => new EE_Plain_Text_Field(
100
-                    'FIN_helpText',
101
-                    esc_html__(
102
-                        'Additional text displayed alongside a form input to assist users with completing the form.',
103
-                        'event_espresso'
104
-                    ),
105
-                    true,
106
-                    null
107
-                ),
108
-                'FIN_htmlClass' => new EE_Plain_Text_Field(
109
-                    'FIN_htmlClass',
110
-                    esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'),
111
-                    true,
112
-                    null
113
-                ),
114
-                'FIN_mapsTo'     => new EE_Plain_Text_Field(
115
-                    'FIN_mapsTo',
116
-                    esc_html__(
117
-                        'Model and Fields name that this input maps to; ex: Attendee.email',
118
-                        'event_espresso'
119
-                    ),
120
-                    true,
121
-                    null
122
-                ),
123
-                'FIN_max'     => new EE_Integer_Field(
124
-                    'FIN_max',
125
-                    esc_html__(
126
-                        'Maximum numeric value or maximum characters allowed for form input answer.',
127
-                        'event_espresso'
128
-                    ),
129
-                    false,
130
-                    EE_INF
131
-                ),
132
-                'FIN_min'     => new EE_Integer_Field(
133
-                    'FIN_min',
134
-                    esc_html__(
135
-                        'Minimum numeric value or minimum characters allowed for form input answer.',
136
-                        'event_espresso'
137
-                    ),
138
-                    true,
139
-                    null
140
-                ),
141
-                'FIN_options'     => new EE_JSON_Field(
142
-                    'FIN_options',
143
-                    esc_html__(
144
-                        'JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.',
145
-                        'event_espresso'
146
-                    ),
147
-                    true,
148
-                    null
149
-                ),
150
-                'FIN_order'     => new EE_Integer_Field(
151
-                    'FIN_order',
152
-                    esc_html__('Order in which form input appears in a form.', 'event_espresso'),
153
-                    false,
154
-                    0
155
-                ),
156
-                'FIN_placeholder' => new EE_Plain_Text_Field(
157
-                    'FIN_placeholder',
158
-                    esc_html__(
159
-                        'Example text displayed within an input to assist users with completing the form.',
160
-                        'event_espresso'
161
-                    ),
162
-                    true,
163
-                    null
164
-                ),
165
-                'FIN_publicLabel' => new EE_Plain_Text_Field(
166
-                    'FIN_publicLabel',
167
-                    esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'),
168
-                    true,
169
-                    null
170
-                ),
171
-                'FIN_required' => new EE_Boolean_Field(
172
-                    'FIN_required',
173
-                    esc_html__(
174
-                        'Whether or not the input must be supplied with a value in order to complete the form.',
175
-                        'event_espresso'
176
-                    ),
177
-                    false,
178
-                    false
179
-                ),
180
-                'FIN_requiredText' => new EE_Plain_Text_Field(
181
-                    'FIN_requiredText',
182
-                    esc_html__(
183
-                        'Custom validation text displayed alongside a required form input to assist users with completing the form.',
184
-                        'event_espresso'
185
-                    ),
186
-                    true,
187
-                    null
188
-                ),
189
-                'FIN_status'    => new EE_Enum_Text_Field(
190
-                    'FIN_status',
191
-                    esc_html(
192
-                        sprintf(
193
-                            /* translators: 1 class name */
194
-                            __(
195
-                                'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the %s constants.',
196
-                                'event_espresso'
197
-                            ),
198
-                            'EEM_Form_Input::STATUS_*'
199
-                        )
200
-                    ),
201
-                    false,
202
-                    Element::STATUS_ACTIVE,
203
-                    $element->validStatusOptions()
204
-                ),
205
-                'FIN_type'    => new EE_Enum_Text_Field(
206
-                    'FIN_type',
207
-                    esc_html(
208
-                        sprintf(
209
-                            /* translators: 1 class name */
210
-                            __(
211
-                                'Form input type. Values correspond to the %s constants.',
212
-                                'event_espresso'
213
-                            ),
214
-                            'EventEspresso\core\domain\entities\form\Input::TYPE_*'
215
-                        )
216
-                    ),
217
-                    false,
218
-                    Text::TYPE_TEXT,
219
-                    $this->validTypeOptions()
220
-                ),
221
-                'FIN_wpUser'    => new EE_WP_User_Field(
222
-                    'FIN_wpUser',
223
-                    esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
224
-                    false
225
-                ),
226
-            ],
227
-        ];
59
+		$this->_tables          = [
60
+			'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_UUID'),
61
+		];
62
+		$this->_fields          = [
63
+			'Form_Input' => [
64
+				'FIN_UUID'      => new EE_Primary_Key_String_Field(
65
+					'FIN_UUID',
66
+					esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso')
67
+				),
68
+				'FSC_UUID' => new EE_Foreign_Key_String_Field(
69
+					'FSC_UUID',
70
+					esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
71
+					false,
72
+					null,
73
+					['Form_Section']
74
+				),
75
+				'FIN_adminLabel' => new EE_Plain_Text_Field(
76
+					'FIN_adminLabel',
77
+					esc_html__(
78
+						'Input label displayed in the admin to help differentiate input from others.',
79
+						'event_espresso'
80
+					),
81
+					true,
82
+					null
83
+				),
84
+				'FIN_adminOnly' => new EE_Boolean_Field(
85
+					'FIN_adminOnly',
86
+					esc_html__(
87
+						'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
88
+						'event_espresso'
89
+					),
90
+					false,
91
+					false
92
+				),
93
+				'FIN_helpClass' => new EE_Plain_Text_Field(
94
+					'FIN_helpClass',
95
+					esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'),
96
+					true,
97
+					null
98
+				),
99
+				'FIN_helpText' => new EE_Plain_Text_Field(
100
+					'FIN_helpText',
101
+					esc_html__(
102
+						'Additional text displayed alongside a form input to assist users with completing the form.',
103
+						'event_espresso'
104
+					),
105
+					true,
106
+					null
107
+				),
108
+				'FIN_htmlClass' => new EE_Plain_Text_Field(
109
+					'FIN_htmlClass',
110
+					esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'),
111
+					true,
112
+					null
113
+				),
114
+				'FIN_mapsTo'     => new EE_Plain_Text_Field(
115
+					'FIN_mapsTo',
116
+					esc_html__(
117
+						'Model and Fields name that this input maps to; ex: Attendee.email',
118
+						'event_espresso'
119
+					),
120
+					true,
121
+					null
122
+				),
123
+				'FIN_max'     => new EE_Integer_Field(
124
+					'FIN_max',
125
+					esc_html__(
126
+						'Maximum numeric value or maximum characters allowed for form input answer.',
127
+						'event_espresso'
128
+					),
129
+					false,
130
+					EE_INF
131
+				),
132
+				'FIN_min'     => new EE_Integer_Field(
133
+					'FIN_min',
134
+					esc_html__(
135
+						'Minimum numeric value or minimum characters allowed for form input answer.',
136
+						'event_espresso'
137
+					),
138
+					true,
139
+					null
140
+				),
141
+				'FIN_options'     => new EE_JSON_Field(
142
+					'FIN_options',
143
+					esc_html__(
144
+						'JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.',
145
+						'event_espresso'
146
+					),
147
+					true,
148
+					null
149
+				),
150
+				'FIN_order'     => new EE_Integer_Field(
151
+					'FIN_order',
152
+					esc_html__('Order in which form input appears in a form.', 'event_espresso'),
153
+					false,
154
+					0
155
+				),
156
+				'FIN_placeholder' => new EE_Plain_Text_Field(
157
+					'FIN_placeholder',
158
+					esc_html__(
159
+						'Example text displayed within an input to assist users with completing the form.',
160
+						'event_espresso'
161
+					),
162
+					true,
163
+					null
164
+				),
165
+				'FIN_publicLabel' => new EE_Plain_Text_Field(
166
+					'FIN_publicLabel',
167
+					esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'),
168
+					true,
169
+					null
170
+				),
171
+				'FIN_required' => new EE_Boolean_Field(
172
+					'FIN_required',
173
+					esc_html__(
174
+						'Whether or not the input must be supplied with a value in order to complete the form.',
175
+						'event_espresso'
176
+					),
177
+					false,
178
+					false
179
+				),
180
+				'FIN_requiredText' => new EE_Plain_Text_Field(
181
+					'FIN_requiredText',
182
+					esc_html__(
183
+						'Custom validation text displayed alongside a required form input to assist users with completing the form.',
184
+						'event_espresso'
185
+					),
186
+					true,
187
+					null
188
+				),
189
+				'FIN_status'    => new EE_Enum_Text_Field(
190
+					'FIN_status',
191
+					esc_html(
192
+						sprintf(
193
+							/* translators: 1 class name */
194
+							__(
195
+								'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the %s constants.',
196
+								'event_espresso'
197
+							),
198
+							'EEM_Form_Input::STATUS_*'
199
+						)
200
+					),
201
+					false,
202
+					Element::STATUS_ACTIVE,
203
+					$element->validStatusOptions()
204
+				),
205
+				'FIN_type'    => new EE_Enum_Text_Field(
206
+					'FIN_type',
207
+					esc_html(
208
+						sprintf(
209
+							/* translators: 1 class name */
210
+							__(
211
+								'Form input type. Values correspond to the %s constants.',
212
+								'event_espresso'
213
+							),
214
+							'EventEspresso\core\domain\entities\form\Input::TYPE_*'
215
+						)
216
+					),
217
+					false,
218
+					Text::TYPE_TEXT,
219
+					$this->validTypeOptions()
220
+				),
221
+				'FIN_wpUser'    => new EE_WP_User_Field(
222
+					'FIN_wpUser',
223
+					esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
224
+					false
225
+				),
226
+			],
227
+		];
228 228
 
229
-        $this->_model_relations = [
230
-            'Form_Section' => new EE_Belongs_To_Relation(),
231
-            'WP_User'      => new EE_Belongs_To_Relation(),
232
-        ];
233
-        // this model is generally available for reading
234
-        $this->_cap_restriction_generators = [
235
-            EEM_Base::caps_read       => new EE_Restriction_Generator_Public(),
236
-            EEM_Base::caps_read_admin => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
237
-            EEM_Base::caps_edit       => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
238
-            EEM_Base::caps_delete     => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
239
-        ];
240
-        parent::__construct($element, $timezone);
241
-        $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
242
-    }
229
+		$this->_model_relations = [
230
+			'Form_Section' => new EE_Belongs_To_Relation(),
231
+			'WP_User'      => new EE_Belongs_To_Relation(),
232
+		];
233
+		// this model is generally available for reading
234
+		$this->_cap_restriction_generators = [
235
+			EEM_Base::caps_read       => new EE_Restriction_Generator_Public(),
236
+			EEM_Base::caps_read_admin => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
237
+			EEM_Base::caps_edit       => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
238
+			EEM_Base::caps_delete     => new EE_Restriction_Generator_Reg_Form('FIN_applies_to'),
239
+		];
240
+		parent::__construct($element, $timezone);
241
+		$this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
242
+	}
243 243
 
244 244
 
245
-    /**
246
-     * @param array $query_params
247
-     * @return array
248
-     */
249
-    private function addDefaultWhereConditions(array $query_params): array
250
-    {
251
-        // might need to add a way to identify GQL requests for admin domains
252
-        $admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
253
-        $query_params['default_where_conditions'] = $admin_request
254
-            ? EEM_Base::default_where_conditions_none
255
-            : EEM_Base::default_where_conditions_all;
256
-        return $query_params;
257
-    }
245
+	/**
246
+	 * @param array $query_params
247
+	 * @return array
248
+	 */
249
+	private function addDefaultWhereConditions(array $query_params): array
250
+	{
251
+		// might need to add a way to identify GQL requests for admin domains
252
+		$admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
253
+		$query_params['default_where_conditions'] = $admin_request
254
+			? EEM_Base::default_where_conditions_none
255
+			: EEM_Base::default_where_conditions_all;
256
+		return $query_params;
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * form inputs should always be sorted in ascending order via the FIN_order field
262
-     *
263
-     * @param array $query_params
264
-     * @return array
265
-     */
266
-    private function addOrderByQueryParams(array $query_params): array
267
-    {
268
-        $query_params['order_by'] = ['FIN_order' => 'ASC'];
269
-        return $query_params;
270
-    }
260
+	/**
261
+	 * form inputs should always be sorted in ascending order via the FIN_order field
262
+	 *
263
+	 * @param array $query_params
264
+	 * @return array
265
+	 */
266
+	private function addOrderByQueryParams(array $query_params): array
267
+	{
268
+		$query_params['order_by'] = ['FIN_order' => 'ASC'];
269
+		return $query_params;
270
+	}
271 271
 
272 272
 
273
-    /**
274
-     * @param EE_Form_Section $form_section
275
-     * @param EE_Form_Input[] $all_form_inputs
276
-     * @return EE_Form_Input[]
277
-     * @throws EE_Error
278
-     * @throws ReflectionException
279
-     */
280
-    public function filterFormInputsForFormSection(EE_Form_Section $form_section, array $all_form_inputs): array
281
-    {
282
-        return array_filter($all_form_inputs, $form_section->formInputFilter());
283
-    }
273
+	/**
274
+	 * @param EE_Form_Section $form_section
275
+	 * @param EE_Form_Input[] $all_form_inputs
276
+	 * @return EE_Form_Input[]
277
+	 * @throws EE_Error
278
+	 * @throws ReflectionException
279
+	 */
280
+	public function filterFormInputsForFormSection(EE_Form_Section $form_section, array $all_form_inputs): array
281
+	{
282
+		return array_filter($all_form_inputs, $form_section->formInputFilter());
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * @param EE_Form_Section[] $form_sections
288
-     * @return EE_Form_Input[]
289
-     * @throws EE_Error
290
-     * @throws ReflectionException
291
-     */
292
-    public function getAllFormInputsForFormSections(array $form_sections): array
293
-    {
294
-        $FSC_UUIDs = [];
295
-        foreach ($form_sections as $form_section) {
296
-            if ($form_section instanceof EE_Form_Section) {
297
-                $FSC_UUIDs[] = $form_section->UUID();
298
-            }
299
-        }
300
-        $where_params = ['FSC_UUID' => ['IN', $FSC_UUIDs]];
301
-        $query_params = $this->addDefaultWhereConditions([$where_params]);
302
-        $query_params = $this->addOrderByQueryParams($query_params);
303
-        return $this->get_all($query_params);
304
-    }
286
+	/**
287
+	 * @param EE_Form_Section[] $form_sections
288
+	 * @return EE_Form_Input[]
289
+	 * @throws EE_Error
290
+	 * @throws ReflectionException
291
+	 */
292
+	public function getAllFormInputsForFormSections(array $form_sections): array
293
+	{
294
+		$FSC_UUIDs = [];
295
+		foreach ($form_sections as $form_section) {
296
+			if ($form_section instanceof EE_Form_Section) {
297
+				$FSC_UUIDs[] = $form_section->UUID();
298
+			}
299
+		}
300
+		$where_params = ['FSC_UUID' => ['IN', $FSC_UUIDs]];
301
+		$query_params = $this->addDefaultWhereConditions([$where_params]);
302
+		$query_params = $this->addOrderByQueryParams($query_params);
303
+		return $this->get_all($query_params);
304
+	}
305 305
 
306 306
 
307
-    /**
308
-     * @param bool $constants_only
309
-     * @return array
310
-     */
311
-    public function validTypeOptions(bool $constants_only = false): array
312
-    {
313
-        return $this->input_types->validTypeOptions($constants_only);
314
-    }
307
+	/**
308
+	 * @param bool $constants_only
309
+	 * @return array
310
+	 */
311
+	public function validTypeOptions(bool $constants_only = false): array
312
+	{
313
+		return $this->input_types->validTypeOptions($constants_only);
314
+	}
315 315
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 1 patch
Indentation   +919 added lines, -919 removed lines patch added patch discarded remove patch
@@ -14,923 +14,923 @@
 block discarded – undo
14 14
 class EEM_Event extends EEM_CPT_Base
15 15
 {
16 16
 
17
-    /**
18
-     * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
19
-     * event
20
-     */
21
-    const sold_out = 'sold_out';
22
-
23
-    /**
24
-     * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
25
-     * date)
26
-     */
27
-    const postponed = 'postponed';
28
-
29
-    /**
30
-     * constant used by status(), indicating that the event will no longer occur
31
-     */
32
-    const cancelled = 'cancelled';
33
-
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    protected static $_default_reg_status;
39
-
40
-
41
-    /**
42
-     * This is the default for the additional limit field.
43
-     * @var int
44
-     */
45
-    protected static $_default_additional_limit = 10;
46
-
47
-
48
-    /**
49
-     * private instance of the Event object
50
-     *
51
-     * @var EEM_Event
52
-     */
53
-    protected static $_instance;
54
-
55
-
56
-    /**
57
-     * Adds a relationship to Term_Taxonomy for each CPT_Base
58
-     *
59
-     * @param string $timezone
60
-     * @throws EE_Error
61
-     * @throws ReflectionException
62
-     */
63
-    protected function __construct($timezone = null)
64
-    {
65
-        EE_Registry::instance()->load_model('Registration');
66
-        $this->singular_item = esc_html__('Event', 'event_espresso');
67
-        $this->plural_item = esc_html__('Events', 'event_espresso');
68
-        // to remove Cancelled events from the frontend, copy the following filter to your functions.php file
69
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
70
-        // to remove Postponed events from the frontend, copy the following filter to your functions.php file
71
-        // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
72
-        // to remove Sold Out events from the frontend, copy the following filter to your functions.php file
73
-        //  add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
74
-        $this->_custom_stati = apply_filters(
75
-            'AFEE__EEM_Event__construct___custom_stati',
76
-            array(
77
-                EEM_Event::cancelled => array(
78
-                    'label'  => esc_html__('Cancelled', 'event_espresso'),
79
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
80
-                ),
81
-                EEM_Event::postponed => array(
82
-                    'label'  => esc_html__('Postponed', 'event_espresso'),
83
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
84
-                ),
85
-                EEM_Event::sold_out  => array(
86
-                    'label'  => esc_html__('Sold Out', 'event_espresso'),
87
-                    'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
88
-                ),
89
-            )
90
-        );
91
-        self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
92
-            : self::$_default_reg_status;
93
-        $this->_tables = array(
94
-            'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
95
-            'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
96
-        );
97
-        $this->_fields = array(
98
-            'Event_CPT'  => array(
99
-                'EVT_ID'         => new EE_Primary_Key_Int_Field(
100
-                    'ID',
101
-                    esc_html__('Post ID for Event', 'event_espresso')
102
-                ),
103
-                'EVT_name'       => new EE_Plain_Text_Field(
104
-                    'post_title',
105
-                    esc_html__('Event Name', 'event_espresso'),
106
-                    false,
107
-                    ''
108
-                ),
109
-                'EVT_desc'       => new EE_Post_Content_Field(
110
-                    'post_content',
111
-                    esc_html__('Event Description', 'event_espresso'),
112
-                    false,
113
-                    ''
114
-                ),
115
-                'EVT_slug'       => new EE_Slug_Field(
116
-                    'post_name',
117
-                    esc_html__('Event Slug', 'event_espresso'),
118
-                    false,
119
-                    ''
120
-                ),
121
-                'EVT_created'    => new EE_Datetime_Field(
122
-                    'post_date',
123
-                    esc_html__('Date/Time Event Created', 'event_espresso'),
124
-                    false,
125
-                    EE_Datetime_Field::now
126
-                ),
127
-                'EVT_short_desc' => new EE_Simple_HTML_Field(
128
-                    'post_excerpt',
129
-                    esc_html__('Event Short Description', 'event_espresso'),
130
-                    false,
131
-                    ''
132
-                ),
133
-                'EVT_modified'   => new EE_Datetime_Field(
134
-                    'post_modified',
135
-                    esc_html__('Date/Time Event Modified', 'event_espresso'),
136
-                    false,
137
-                    EE_Datetime_Field::now
138
-                ),
139
-                'EVT_wp_user'    => new EE_WP_User_Field(
140
-                    'post_author',
141
-                    esc_html__('Event Creator ID', 'event_espresso'),
142
-                    false
143
-                ),
144
-                'parent'         => new EE_Integer_Field(
145
-                    'post_parent',
146
-                    esc_html__('Event Parent ID', 'event_espresso'),
147
-                    false,
148
-                    0
149
-                ),
150
-                'EVT_order'      => new EE_Integer_Field(
151
-                    'menu_order',
152
-                    esc_html__('Event Menu Order', 'event_espresso'),
153
-                    false,
154
-                    1
155
-                ),
156
-                'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
157
-                // EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
158
-                'status'         => new EE_WP_Post_Status_Field(
159
-                    'post_status',
160
-                    esc_html__('Event Status', 'event_espresso'),
161
-                    false,
162
-                    'draft',
163
-                    $this->_custom_stati
164
-                ),
165
-                'password' => new EE_Password_Field(
166
-                    'post_password',
167
-                    __('Password', 'event_espresso'),
168
-                    false,
169
-                    '',
170
-                    array(
171
-                        'EVT_desc',
172
-                        'EVT_short_desc',
173
-                        'EVT_display_desc',
174
-                        'EVT_display_ticket_selector',
175
-                        'EVT_visible_on',
176
-                        'EVT_additional_limit',
177
-                        'EVT_default_registration_status',
178
-                        'EVT_member_only',
179
-                        'EVT_phone',
180
-                        'EVT_allow_overflow',
181
-                        'EVT_timezone_string',
182
-                        'EVT_external_URL',
183
-                        'EVT_donations'
184
-                    )
185
-                )
186
-            ),
187
-            'Event_Meta' => array(
188
-                'EVTM_ID'                         => new EE_DB_Only_Float_Field(
189
-                    'EVTM_ID',
190
-                    esc_html__('Event Meta Row ID', 'event_espresso'),
191
-                    false
192
-                ),
193
-                'EVT_ID_fk'                       => new EE_DB_Only_Int_Field(
194
-                    'EVT_ID',
195
-                    esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'),
196
-                    false
197
-                ),
198
-                'EVT_display_desc'                => new EE_Boolean_Field(
199
-                    'EVT_display_desc',
200
-                    esc_html__('Display Description Flag', 'event_espresso'),
201
-                    false,
202
-                    true
203
-                ),
204
-                'EVT_display_ticket_selector'     => new EE_Boolean_Field(
205
-                    'EVT_display_ticket_selector',
206
-                    esc_html__('Display Ticket Selector Flag', 'event_espresso'),
207
-                    false,
208
-                    true
209
-                ),
210
-                'EVT_visible_on'                  => new EE_Datetime_Field(
211
-                    'EVT_visible_on',
212
-                    esc_html__('Event Visible Date', 'event_espresso'),
213
-                    true,
214
-                    EE_Datetime_Field::now
215
-                ),
216
-                'EVT_additional_limit'            => new EE_Integer_Field(
217
-                    'EVT_additional_limit',
218
-                    esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
219
-                    true,
220
-                    self::$_default_additional_limit
221
-                ),
222
-                'EVT_default_registration_status' => new EE_Enum_Text_Field(
223
-                    'EVT_default_registration_status',
224
-                    esc_html__('Default Registration Status on this Event', 'event_espresso'),
225
-                    false,
226
-                    EEM_Event::$_default_reg_status,
227
-                    EEM_Registration::reg_status_array()
228
-                ),
229
-                'EVT_member_only'                 => new EE_Boolean_Field(
230
-                    'EVT_member_only',
231
-                    esc_html__('Member-Only Event Flag', 'event_espresso'),
232
-                    false,
233
-                    false
234
-                ),
235
-                'EVT_phone'                       => new EE_Plain_Text_Field(
236
-                    'EVT_phone',
237
-                    esc_html__('Event Phone Number', 'event_espresso'),
238
-                    false,
239
-                    ''
240
-                ),
241
-                'EVT_allow_overflow'              => new EE_Boolean_Field(
242
-                    'EVT_allow_overflow',
243
-                    esc_html__('Allow Overflow on Event', 'event_espresso'),
244
-                    false,
245
-                    false
246
-                ),
247
-                'EVT_timezone_string'             => new EE_Plain_Text_Field(
248
-                    'EVT_timezone_string',
249
-                    esc_html__('Timezone (name) for Event times', 'event_espresso'),
250
-                    false,
251
-                    ''
252
-                ),
253
-                'EVT_external_URL'                => new EE_Plain_Text_Field(
254
-                    'EVT_external_URL',
255
-                    esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
256
-                    true
257
-                ),
258
-                'EVT_donations'                   => new EE_Boolean_Field(
259
-                    'EVT_donations',
260
-                    esc_html__('Accept Donations?', 'event_espresso'),
261
-                    false,
262
-                    false
263
-                ),
264
-                'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
265
-                    'FSC_UUID',
266
-                    esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
267
-                    true,
268
-                    null,
269
-                    'Form_Section'
270
-                ),
271
-            ),
272
-        );
273
-        $this->_model_relations = array(
274
-            'Attendee'               => new EE_HABTM_Relation('Registration'),
275
-            'Datetime'               => new EE_Has_Many_Relation(),
276
-            'Event_Question_Group'   => new EE_Has_Many_Relation(),
277
-            'Form_Section'           => new EE_Belongs_To_Relation(),
278
-            'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
279
-            'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
280
-            'Registration'           => new EE_Has_Many_Relation(),
281
-            'Term_Relationship'      => new EE_Has_Many_Relation(),
282
-            'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
283
-            'Venue'                  => new EE_HABTM_Relation('Event_Venue'),
284
-            'WP_User'                => new EE_Belongs_To_Relation(),
285
-        );
286
-        // this model is generally available for reading
287
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
288
-        $this->model_chain_to_password = '';
289
-        parent::__construct($timezone);
290
-    }
291
-
292
-
293
-    /**
294
-     * @param string $default_reg_status
295
-     * @throws EE_Error
296
-     * @throws EE_Error
297
-     */
298
-    public static function set_default_reg_status($default_reg_status)
299
-    {
300
-        self::$_default_reg_status = $default_reg_status;
301
-        // if EEM_Event has already been instantiated,
302
-        // then we need to reset the `EVT_default_reg_status` field to use the new default.
303
-        if (self::$_instance instanceof EEM_Event) {
304
-            $default_reg_status = new EE_Enum_Text_Field(
305
-                'EVT_default_registration_status',
306
-                esc_html__('Default Registration Status on this Event', 'event_espresso'),
307
-                false,
308
-                $default_reg_status,
309
-                EEM_Registration::reg_status_array()
310
-            );
311
-            $default_reg_status->_construct_finalize(
312
-                'Event_Meta',
313
-                'EVT_default_registration_status',
314
-                'EEM_Event'
315
-            );
316
-            self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
317
-        }
318
-    }
319
-
320
-
321
-    /**
322
-     * Used to override the default for the additional limit field.
323
-     * @param $additional_limit
324
-     */
325
-    public static function set_default_additional_limit($additional_limit)
326
-    {
327
-        self::$_default_additional_limit = (int) $additional_limit;
328
-        if (self::$_instance instanceof EEM_Event) {
329
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
330
-                'EVT_additional_limit',
331
-                __('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
332
-                true,
333
-                self::$_default_additional_limit
334
-            );
335
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
336
-                'Event_Meta',
337
-                'EVT_additional_limit',
338
-                'EEM_Event'
339
-            );
340
-        }
341
-    }
342
-
343
-
344
-    /**
345
-     * Return what is currently set as the default additional limit for the event.
346
-     * @return int
347
-     */
348
-    public static function get_default_additional_limit()
349
-    {
350
-        return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
351
-    }
352
-
353
-
354
-    /**
355
-     * get_question_groups
356
-     *
357
-     * @return array
358
-     * @throws EE_Error
359
-     * @throws ReflectionException
360
-     */
361
-    public function get_all_question_groups()
362
-    {
363
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
364
-            array(
365
-                array('QSG_deleted' => false),
366
-                'order_by' => array('QSG_order' => 'ASC'),
367
-            )
368
-        );
369
-    }
370
-
371
-
372
-    /**
373
-     * get_question_groups
374
-     *
375
-     * @param int $EVT_ID
376
-     * @return array|bool
377
-     * @throws EE_Error
378
-     * @throws ReflectionException
379
-     */
380
-    public function get_all_event_question_groups($EVT_ID = 0)
381
-    {
382
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
383
-            EE_Error::add_error(
384
-                esc_html__(
385
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
386
-                    'event_espresso'
387
-                ),
388
-                __FILE__,
389
-                __FUNCTION__,
390
-                __LINE__
391
-            );
392
-            return false;
393
-        }
394
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
395
-            array(
396
-                array('EVT_ID' => $EVT_ID),
397
-            )
398
-        );
399
-    }
400
-
401
-
402
-    /**
403
-     * get_question_groups
404
-     *
405
-     * @param int $EVT_ID
406
-     * @param boolean $for_primary_attendee
407
-     * @return array|bool
408
-     * @throws EE_Error
409
-     * @throws InvalidArgumentException
410
-     * @throws ReflectionException
411
-     * @throws InvalidDataTypeException
412
-     * @throws InvalidInterfaceException
413
-     */
414
-    public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
415
-    {
416
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
417
-            EE_Error::add_error(
418
-                esc_html__(
419
-                    // @codingStandardsIgnoreStart
420
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
421
-                    // @codingStandardsIgnoreEnd
422
-                    'event_espresso'
423
-                ),
424
-                __FILE__,
425
-                __FUNCTION__,
426
-                __LINE__
427
-            );
428
-            return false;
429
-        }
430
-        $query_params = [
431
-            [
432
-                'EVT_ID' => $EVT_ID,
433
-                EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
434
-            ]
435
-        ];
436
-        if ($for_primary_attendee) {
437
-            $query_params[0]['EQG_primary'] = true;
438
-        } else {
439
-            $query_params[0]['EQG_additional'] = true;
440
-        }
441
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
442
-    }
443
-
444
-
445
-    /**
446
-     * get_question_groups
447
-     *
448
-     * @param int $EVT_ID
449
-     * @param EE_Registration $registration
450
-     * @return array|bool
451
-     * @throws EE_Error
452
-     * @throws InvalidArgumentException
453
-     * @throws InvalidDataTypeException
454
-     * @throws InvalidInterfaceException
455
-     * @throws ReflectionException
456
-     */
457
-    public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
458
-    {
459
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
460
-            EE_Error::add_error(
461
-                esc_html__(
462
-                    'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
463
-                    'event_espresso'
464
-                ),
465
-                __FILE__,
466
-                __FUNCTION__,
467
-                __LINE__
468
-            );
469
-            return false;
470
-        }
471
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
472
-            [
473
-                [
474
-                    'Event_Question_Group.EVT_ID'      => $EVT_ID,
475
-                    'Event_Question_Group.'
476
-                        . EEM_Event_Question_Group::instance()->fieldNameForContext(
477
-                            $registration->is_primary_registrant()
478
-                        ) => true
479
-                ],
480
-                'order_by' => ['QSG_order' => 'ASC'],
481
-            ]
482
-        );
483
-    }
484
-
485
-
486
-    /**
487
-     * get_question_target_db_column
488
-     *
489
-     * @param string $QSG_IDs csv list of $QSG IDs
490
-     * @return array|bool
491
-     * @throws EE_Error
492
-     * @throws ReflectionException
493
-     */
494
-    public function get_questions_in_groups($QSG_IDs = '')
495
-    {
496
-        if (empty($QSG_IDs)) {
497
-            EE_Error::add_error(
498
-                esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
499
-                __FILE__,
500
-                __FUNCTION__,
501
-                __LINE__
502
-            );
503
-            return false;
504
-        }
505
-        return EE_Registry::instance()->load_model('Question')->get_all(
506
-            array(
507
-                array(
508
-                    'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
509
-                    'QST_deleted'           => false,
510
-                    'QST_admin_only'        => is_admin(),
511
-                ),
512
-                'order_by' => 'QST_order',
513
-            )
514
-        );
515
-    }
516
-
517
-
518
-    /**
519
-     * get_options_for_question
520
-     *
521
-     * @param string $QST_IDs csv list of $QST IDs
522
-     * @return array|bool
523
-     * @throws EE_Error
524
-     * @throws ReflectionException
525
-     */
526
-    public function get_options_for_question($QST_IDs)
527
-    {
528
-        if (empty($QST_IDs)) {
529
-            EE_Error::add_error(
530
-                esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
531
-                __FILE__,
532
-                __FUNCTION__,
533
-                __LINE__
534
-            );
535
-            return false;
536
-        }
537
-        return EE_Registry::instance()->load_model('Question_Option')->get_all(
538
-            array(
539
-                array(
540
-                    'Question.QST_ID' => array('IN', $QST_IDs),
541
-                    'QSO_deleted'     => false,
542
-                ),
543
-                'order_by' => 'QSO_ID',
544
-            )
545
-        );
546
-    }
547
-
548
-
549
-    /**
550
-     * Gets all events that are published
551
-     * and have event start time earlier than now and an event end time later than now
552
-     *
553
-     * @param array $query_params  An array of query params to further filter on
554
-     *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
555
-     * @param bool  $count         whether to return the count or not (default FALSE)
556
-     * @return EE_Event[]|int
557
-     * @throws EE_Error
558
-     * @throws ReflectionException
559
-     */
560
-    public function get_active_events($query_params, $count = false)
561
-    {
562
-        if (array_key_exists(0, $query_params)) {
563
-            $where_params = $query_params[0];
564
-            unset($query_params[0]);
565
-        } else {
566
-            $where_params = array();
567
-        }
568
-        // if we have count make sure we don't include group by
569
-        if ($count && isset($query_params['group_by'])) {
570
-            unset($query_params['group_by']);
571
-        }
572
-        // let's add specific query_params for active_events
573
-        // keep in mind this will override any sent status in the query AND any date queries.
574
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
575
-        // if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
576
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
577
-            $where_params['Datetime.DTT_EVT_start******'] = array(
578
-                '<',
579
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
580
-            );
581
-        } else {
582
-            $where_params['Datetime.DTT_EVT_start'] = array(
583
-                '<',
584
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
585
-            );
586
-        }
587
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
588
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
589
-                '>',
590
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
591
-            );
592
-        } else {
593
-            $where_params['Datetime.DTT_EVT_end'] = array(
594
-                '>',
595
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
596
-            );
597
-        }
598
-        $query_params[0] = $where_params;
599
-        // don't use $query_params with count()
600
-        // because we don't want to include additional query clauses like "GROUP BY"
601
-        return $count
602
-            ? $this->count(array($where_params), 'EVT_ID', true)
603
-            : $this->get_all($query_params);
604
-    }
605
-
606
-
607
-    /**
608
-     * get all events that are published and have an event start time later than now
609
-     *
610
-     * @param array $query_params  An array of query params to further filter on
611
-     *                             (Note that status and DTT_EVT_start will be overridden)
612
-     * @param bool  $count         whether to return the count or not (default FALSE)
613
-     * @return EE_Event[]|int
614
-     * @throws EE_Error
615
-     * @throws ReflectionException
616
-     */
617
-    public function get_upcoming_events($query_params, $count = false)
618
-    {
619
-        if (array_key_exists(0, $query_params)) {
620
-            $where_params = $query_params[0];
621
-            unset($query_params[0]);
622
-        } else {
623
-            $where_params = array();
624
-        }
625
-        // if we have count make sure we don't include group by
626
-        if ($count && isset($query_params['group_by'])) {
627
-            unset($query_params['group_by']);
628
-        }
629
-        // let's add specific query_params for active_events
630
-        // keep in mind this will override any sent status in the query AND any date queries.
631
-        // we need to pull events with a status of publish and sold_out
632
-        $event_status = array('publish', EEM_Event::sold_out);
633
-        // check if the user can read private events and if so add the 'private status to the were params'
634
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
635
-            $event_status[] = 'private';
636
-        }
637
-        $where_params['status'] = array('IN', $event_status);
638
-        // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
639
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
640
-            $where_params['Datetime.DTT_EVT_start*****'] = array(
641
-                '>',
642
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
643
-            );
644
-        } else {
645
-            $where_params['Datetime.DTT_EVT_start'] = array(
646
-                '>',
647
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
648
-            );
649
-        }
650
-        $query_params[0] = $where_params;
651
-        // don't use $query_params with count()
652
-        // because we don't want to include additional query clauses like "GROUP BY"
653
-        return $count
654
-            ? $this->count(array($where_params), 'EVT_ID', true)
655
-            : $this->get_all($query_params);
656
-    }
657
-
658
-
659
-    /**
660
-     * Gets all events that are published
661
-     * and have an event end time later than now
662
-     *
663
-     * @param array $query_params  An array of query params to further filter on
664
-     *                             (note that status and DTT_EVT_end will be overridden)
665
-     * @param bool  $count         whether to return the count or not (default FALSE)
666
-     * @return EE_Event[]|int
667
-     * @throws EE_Error
668
-     * @throws ReflectionException
669
-     */
670
-    public function get_active_and_upcoming_events($query_params, $count = false)
671
-    {
672
-        if (array_key_exists(0, $query_params)) {
673
-            $where_params = $query_params[0];
674
-            unset($query_params[0]);
675
-        } else {
676
-            $where_params = array();
677
-        }
678
-        // if we have count make sure we don't include group by
679
-        if ($count && isset($query_params['group_by'])) {
680
-            unset($query_params['group_by']);
681
-        }
682
-        // let's add specific query_params for active_events
683
-        // keep in mind this will override any sent status in the query AND any date queries.
684
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
685
-        // add where params for DTT_EVT_end
686
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
687
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
688
-                '>',
689
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
690
-            );
691
-        } else {
692
-            $where_params['Datetime.DTT_EVT_end'] = array(
693
-                '>',
694
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
695
-            );
696
-        }
697
-        $query_params[0] = $where_params;
698
-        // don't use $query_params with count()
699
-        // because we don't want to include additional query clauses like "GROUP BY"
700
-        return $count
701
-            ? $this->count(array($where_params), 'EVT_ID', true)
702
-            : $this->get_all($query_params);
703
-    }
704
-
705
-
706
-    /**
707
-     * This only returns events that are expired.
708
-     * They may still be published but all their datetimes have expired.
709
-     *
710
-     * @param array $query_params  An array of query params to further filter on
711
-     *                             (note that status and DTT_EVT_end will be overridden)
712
-     * @param bool  $count         whether to return the count or not (default FALSE)
713
-     * @return EE_Event[]|int
714
-     * @throws EE_Error
715
-     * @throws ReflectionException
716
-     */
717
-    public function get_expired_events($query_params, $count = false)
718
-    {
719
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
720
-        // if we have count make sure we don't include group by
721
-        if ($count && isset($query_params['group_by'])) {
722
-            unset($query_params['group_by']);
723
-        }
724
-        // let's add specific query_params for active_events
725
-        // keep in mind this will override any sent status in the query AND any date queries.
726
-        if (isset($where_params['status'])) {
727
-            unset($where_params['status']);
728
-        }
729
-        $exclude_query = $query_params;
730
-        if (isset($exclude_query[0])) {
731
-            unset($exclude_query[0]);
732
-        }
733
-        $exclude_query[0] = array(
734
-            'Datetime.DTT_EVT_end' => array(
735
-                '>',
736
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
737
-            ),
738
-        );
739
-        // first get all events that have datetimes where its not expired.
740
-        $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
741
-        $event_ids = array_keys($event_ids);
742
-        // if we have any additional query_params, let's add them to the 'AND' condition
743
-        $and_condition = array(
744
-            'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
745
-            'EVT_ID'               => array('NOT IN', $event_ids),
746
-        );
747
-        if (isset($where_params['OR'])) {
748
-            $and_condition['OR'] = $where_params['OR'];
749
-            unset($where_params['OR']);
750
-        }
751
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
752
-            $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
753
-            unset($where_params['Datetime.DTT_EVT_end']);
754
-        }
755
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
756
-            $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
757
-            unset($where_params['Datetime.DTT_EVT_start']);
758
-        }
759
-        // merge remaining $where params with the and conditions.
760
-        $where_params['AND'] = array_merge($and_condition, $where_params);
761
-        $query_params[0] = $where_params;
762
-        // don't use $query_params with count()
763
-        // because we don't want to include additional query clauses like "GROUP BY"
764
-        return $count
765
-            ? $this->count(array($where_params), 'EVT_ID', true)
766
-            : $this->get_all($query_params);
767
-    }
768
-
769
-
770
-
771
-    /**
772
-     * This basically just returns the events that do not have the publish status.
773
-     *
774
-     * @param  array   $query_params An array of query params to further filter on
775
-     *                               (note that status will be overwritten)
776
-     * @param  boolean $count        whether to return the count or not (default FALSE)
777
-     * @return EE_Event[]|int
778
-     * @throws EE_Error
779
-     */
780
-    public function get_inactive_events($query_params, $count = false)
781
-    {
782
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
783
-        // let's add in specific query_params for inactive events.
784
-        if (isset($where_params['status'])) {
785
-            unset($where_params['status']);
786
-        }
787
-        // if we have count make sure we don't include group by
788
-        if ($count && isset($query_params['group_by'])) {
789
-            unset($query_params['group_by']);
790
-        }
791
-        // if we have any additional query_params, let's add them to the 'AND' condition
792
-        $where_params['AND']['status'] = array('!=', 'publish');
793
-        if (isset($where_params['OR'])) {
794
-            $where_params['AND']['OR'] = $where_params['OR'];
795
-            unset($where_params['OR']);
796
-        }
797
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
798
-            $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
799
-            unset($where_params['Datetime.DTT_EVT_end']);
800
-        }
801
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
802
-            $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
803
-            unset($where_params['Datetime.DTT_EVT_start']);
804
-        }
805
-        $query_params[0] = $where_params;
806
-        // don't use $query_params with count()
807
-        // because we don't want to include additional query clauses like "GROUP BY"
808
-        return $count
809
-            ? $this->count(array($where_params), 'EVT_ID', true)
810
-            : $this->get_all($query_params);
811
-    }
812
-
813
-
814
-    /**
815
-     * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
816
-     * because we don't want to override any existing global default prices but instead insert NEW prices that get
817
-     * attached to the event. See parent for param descriptions
818
-     *
819
-     * @param        $id_or_obj
820
-     * @param        $other_model_id_or_obj
821
-     * @param string $relationName
822
-     * @param array  $where_query
823
-     * @return EE_Base_Class
824
-     * @throws EE_Error
825
-     * @throws ReflectionException
826
-     */
827
-    public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
828
-    {
829
-        if ($relationName === 'Price') {
830
-            // let's get the PRC object for the given ID to make sure that we aren't dealing with a default
831
-            $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
832
-            // if EVT_ID = 0, then this is a default
833
-            if ((int) $prc_chk->get('EVT_ID') === 0) {
834
-                // let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
835
-                $prc_chk->set('PRC_ID', 0);
836
-            }
837
-            // run parent
838
-            return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
839
-        }
840
-        // otherwise carry on as normal
841
-        return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
842
-    }
843
-
844
-
845
-
846
-    /******************** DEPRECATED METHODS ********************/
847
-
848
-
849
-    /**
850
-     * _get_question_target_db_column
851
-     *
852
-     * @param EE_Registration $registration    (so existing answers for registration are included)
853
-     * @param int             $EVT_ID          so all question groups are included for event (not just answers from
854
-     *                                         registration).
855
-     * @return    array
856
-     * @throws ReflectionException
857
-     * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
858
-     *                                         EE_Registration_Custom_Questions_Form located in
859
-     *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
860
-     * @access     public
861
-     */
862
-    public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
863
-    {
864
-        if (empty($EVT_ID)) {
865
-            throw new EE_Error(__(
866
-                'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
867
-                'event_espresso'
868
-            ));
869
-        }
870
-        $questions = array();
871
-        // get all question groups for event
872
-        $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
873
-        if (! empty($qgs)) {
874
-            foreach ($qgs as $qg) {
875
-                $qsts = $qg->questions();
876
-                $questions[ $qg->ID() ] = $qg->model_field_array();
877
-                $questions[ $qg->ID() ]['QSG_questions'] = array();
878
-                foreach ($qsts as $qst) {
879
-                    if ($qst->is_system_question()) {
880
-                        continue;
881
-                    }
882
-                    $answer = EEM_Answer::instance()->get_one(array(
883
-                        array(
884
-                            'QST_ID' => $qst->ID(),
885
-                            'REG_ID' => $registration->ID(),
886
-                        ),
887
-                    ));
888
-                    $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
889
-                    $qst_name = $qstn_id = $qst->ID();
890
-                    $ans_id = $answer->ID();
891
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
892
-                    $input_name = '';
893
-                    $input_id = sanitize_key($qst->display_text());
894
-                    $input_class = '';
895
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
896
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
897
-                                                                                           . $input_name
898
-                                                                                           . $qst_name;
899
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
900
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
901
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
902
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
903
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
904
-                    // leave responses as-is, don't convert stuff into html entities please!
905
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
906
-                    if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
907
-                        $QSOs = $qst->options(true, $answer->value());
908
-                        if (is_array($QSOs)) {
909
-                            foreach ($QSOs as $QSO_ID => $QSO) {
910
-                                $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
911
-                            }
912
-                        }
913
-                    }
914
-                }
915
-            }
916
-        }
917
-        return $questions;
918
-    }
919
-
920
-
921
-    /**
922
-     * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
923
-     *                             or an stdClass where each property is the name of a column,
924
-     * @return EE_Base_Class
925
-     * @throws EE_Error
926
-     */
927
-    public function instantiate_class_from_array_or_object($cols_n_values)
928
-    {
929
-        $classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
930
-        if ($classInstance instanceof EE_Event) {
931
-            // events have their timezone defined in the DB, so use it immediately
932
-            $this->set_timezone($classInstance->get_timezone());
933
-        }
934
-        return $classInstance;
935
-    }
17
+	/**
18
+	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the
19
+	 * event
20
+	 */
21
+	const sold_out = 'sold_out';
22
+
23
+	/**
24
+	 * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later
25
+	 * date)
26
+	 */
27
+	const postponed = 'postponed';
28
+
29
+	/**
30
+	 * constant used by status(), indicating that the event will no longer occur
31
+	 */
32
+	const cancelled = 'cancelled';
33
+
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	protected static $_default_reg_status;
39
+
40
+
41
+	/**
42
+	 * This is the default for the additional limit field.
43
+	 * @var int
44
+	 */
45
+	protected static $_default_additional_limit = 10;
46
+
47
+
48
+	/**
49
+	 * private instance of the Event object
50
+	 *
51
+	 * @var EEM_Event
52
+	 */
53
+	protected static $_instance;
54
+
55
+
56
+	/**
57
+	 * Adds a relationship to Term_Taxonomy for each CPT_Base
58
+	 *
59
+	 * @param string $timezone
60
+	 * @throws EE_Error
61
+	 * @throws ReflectionException
62
+	 */
63
+	protected function __construct($timezone = null)
64
+	{
65
+		EE_Registry::instance()->load_model('Registration');
66
+		$this->singular_item = esc_html__('Event', 'event_espresso');
67
+		$this->plural_item = esc_html__('Events', 'event_espresso');
68
+		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
69
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
70
+		// to remove Postponed events from the frontend, copy the following filter to your functions.php file
71
+		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' );
72
+		// to remove Sold Out events from the frontend, copy the following filter to your functions.php file
73
+		//  add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' );
74
+		$this->_custom_stati = apply_filters(
75
+			'AFEE__EEM_Event__construct___custom_stati',
76
+			array(
77
+				EEM_Event::cancelled => array(
78
+					'label'  => esc_html__('Cancelled', 'event_espresso'),
79
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true),
80
+				),
81
+				EEM_Event::postponed => array(
82
+					'label'  => esc_html__('Postponed', 'event_espresso'),
83
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true),
84
+				),
85
+				EEM_Event::sold_out  => array(
86
+					'label'  => esc_html__('Sold Out', 'event_espresso'),
87
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true),
88
+				),
89
+			)
90
+		);
91
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment
92
+			: self::$_default_reg_status;
93
+		$this->_tables = array(
94
+			'Event_CPT'  => new EE_Primary_Table('posts', 'ID'),
95
+			'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'),
96
+		);
97
+		$this->_fields = array(
98
+			'Event_CPT'  => array(
99
+				'EVT_ID'         => new EE_Primary_Key_Int_Field(
100
+					'ID',
101
+					esc_html__('Post ID for Event', 'event_espresso')
102
+				),
103
+				'EVT_name'       => new EE_Plain_Text_Field(
104
+					'post_title',
105
+					esc_html__('Event Name', 'event_espresso'),
106
+					false,
107
+					''
108
+				),
109
+				'EVT_desc'       => new EE_Post_Content_Field(
110
+					'post_content',
111
+					esc_html__('Event Description', 'event_espresso'),
112
+					false,
113
+					''
114
+				),
115
+				'EVT_slug'       => new EE_Slug_Field(
116
+					'post_name',
117
+					esc_html__('Event Slug', 'event_espresso'),
118
+					false,
119
+					''
120
+				),
121
+				'EVT_created'    => new EE_Datetime_Field(
122
+					'post_date',
123
+					esc_html__('Date/Time Event Created', 'event_espresso'),
124
+					false,
125
+					EE_Datetime_Field::now
126
+				),
127
+				'EVT_short_desc' => new EE_Simple_HTML_Field(
128
+					'post_excerpt',
129
+					esc_html__('Event Short Description', 'event_espresso'),
130
+					false,
131
+					''
132
+				),
133
+				'EVT_modified'   => new EE_Datetime_Field(
134
+					'post_modified',
135
+					esc_html__('Date/Time Event Modified', 'event_espresso'),
136
+					false,
137
+					EE_Datetime_Field::now
138
+				),
139
+				'EVT_wp_user'    => new EE_WP_User_Field(
140
+					'post_author',
141
+					esc_html__('Event Creator ID', 'event_espresso'),
142
+					false
143
+				),
144
+				'parent'         => new EE_Integer_Field(
145
+					'post_parent',
146
+					esc_html__('Event Parent ID', 'event_espresso'),
147
+					false,
148
+					0
149
+				),
150
+				'EVT_order'      => new EE_Integer_Field(
151
+					'menu_order',
152
+					esc_html__('Event Menu Order', 'event_espresso'),
153
+					false,
154
+					1
155
+				),
156
+				'post_type'      => new EE_WP_Post_Type_Field('espresso_events'),
157
+				// EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
158
+				'status'         => new EE_WP_Post_Status_Field(
159
+					'post_status',
160
+					esc_html__('Event Status', 'event_espresso'),
161
+					false,
162
+					'draft',
163
+					$this->_custom_stati
164
+				),
165
+				'password' => new EE_Password_Field(
166
+					'post_password',
167
+					__('Password', 'event_espresso'),
168
+					false,
169
+					'',
170
+					array(
171
+						'EVT_desc',
172
+						'EVT_short_desc',
173
+						'EVT_display_desc',
174
+						'EVT_display_ticket_selector',
175
+						'EVT_visible_on',
176
+						'EVT_additional_limit',
177
+						'EVT_default_registration_status',
178
+						'EVT_member_only',
179
+						'EVT_phone',
180
+						'EVT_allow_overflow',
181
+						'EVT_timezone_string',
182
+						'EVT_external_URL',
183
+						'EVT_donations'
184
+					)
185
+				)
186
+			),
187
+			'Event_Meta' => array(
188
+				'EVTM_ID'                         => new EE_DB_Only_Float_Field(
189
+					'EVTM_ID',
190
+					esc_html__('Event Meta Row ID', 'event_espresso'),
191
+					false
192
+				),
193
+				'EVT_ID_fk'                       => new EE_DB_Only_Int_Field(
194
+					'EVT_ID',
195
+					esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'),
196
+					false
197
+				),
198
+				'EVT_display_desc'                => new EE_Boolean_Field(
199
+					'EVT_display_desc',
200
+					esc_html__('Display Description Flag', 'event_espresso'),
201
+					false,
202
+					true
203
+				),
204
+				'EVT_display_ticket_selector'     => new EE_Boolean_Field(
205
+					'EVT_display_ticket_selector',
206
+					esc_html__('Display Ticket Selector Flag', 'event_espresso'),
207
+					false,
208
+					true
209
+				),
210
+				'EVT_visible_on'                  => new EE_Datetime_Field(
211
+					'EVT_visible_on',
212
+					esc_html__('Event Visible Date', 'event_espresso'),
213
+					true,
214
+					EE_Datetime_Field::now
215
+				),
216
+				'EVT_additional_limit'            => new EE_Integer_Field(
217
+					'EVT_additional_limit',
218
+					esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
219
+					true,
220
+					self::$_default_additional_limit
221
+				),
222
+				'EVT_default_registration_status' => new EE_Enum_Text_Field(
223
+					'EVT_default_registration_status',
224
+					esc_html__('Default Registration Status on this Event', 'event_espresso'),
225
+					false,
226
+					EEM_Event::$_default_reg_status,
227
+					EEM_Registration::reg_status_array()
228
+				),
229
+				'EVT_member_only'                 => new EE_Boolean_Field(
230
+					'EVT_member_only',
231
+					esc_html__('Member-Only Event Flag', 'event_espresso'),
232
+					false,
233
+					false
234
+				),
235
+				'EVT_phone'                       => new EE_Plain_Text_Field(
236
+					'EVT_phone',
237
+					esc_html__('Event Phone Number', 'event_espresso'),
238
+					false,
239
+					''
240
+				),
241
+				'EVT_allow_overflow'              => new EE_Boolean_Field(
242
+					'EVT_allow_overflow',
243
+					esc_html__('Allow Overflow on Event', 'event_espresso'),
244
+					false,
245
+					false
246
+				),
247
+				'EVT_timezone_string'             => new EE_Plain_Text_Field(
248
+					'EVT_timezone_string',
249
+					esc_html__('Timezone (name) for Event times', 'event_espresso'),
250
+					false,
251
+					''
252
+				),
253
+				'EVT_external_URL'                => new EE_Plain_Text_Field(
254
+					'EVT_external_URL',
255
+					esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
256
+					true
257
+				),
258
+				'EVT_donations'                   => new EE_Boolean_Field(
259
+					'EVT_donations',
260
+					esc_html__('Accept Donations?', 'event_espresso'),
261
+					false,
262
+					false
263
+				),
264
+				'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
265
+					'FSC_UUID',
266
+					esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
267
+					true,
268
+					null,
269
+					'Form_Section'
270
+				),
271
+			),
272
+		);
273
+		$this->_model_relations = array(
274
+			'Attendee'               => new EE_HABTM_Relation('Registration'),
275
+			'Datetime'               => new EE_Has_Many_Relation(),
276
+			'Event_Question_Group'   => new EE_Has_Many_Relation(),
277
+			'Form_Section'           => new EE_Belongs_To_Relation(),
278
+			'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
279
+			'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
280
+			'Registration'           => new EE_Has_Many_Relation(),
281
+			'Term_Relationship'      => new EE_Has_Many_Relation(),
282
+			'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
283
+			'Venue'                  => new EE_HABTM_Relation('Event_Venue'),
284
+			'WP_User'                => new EE_Belongs_To_Relation(),
285
+		);
286
+		// this model is generally available for reading
287
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
288
+		$this->model_chain_to_password = '';
289
+		parent::__construct($timezone);
290
+	}
291
+
292
+
293
+	/**
294
+	 * @param string $default_reg_status
295
+	 * @throws EE_Error
296
+	 * @throws EE_Error
297
+	 */
298
+	public static function set_default_reg_status($default_reg_status)
299
+	{
300
+		self::$_default_reg_status = $default_reg_status;
301
+		// if EEM_Event has already been instantiated,
302
+		// then we need to reset the `EVT_default_reg_status` field to use the new default.
303
+		if (self::$_instance instanceof EEM_Event) {
304
+			$default_reg_status = new EE_Enum_Text_Field(
305
+				'EVT_default_registration_status',
306
+				esc_html__('Default Registration Status on this Event', 'event_espresso'),
307
+				false,
308
+				$default_reg_status,
309
+				EEM_Registration::reg_status_array()
310
+			);
311
+			$default_reg_status->_construct_finalize(
312
+				'Event_Meta',
313
+				'EVT_default_registration_status',
314
+				'EEM_Event'
315
+			);
316
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
317
+		}
318
+	}
319
+
320
+
321
+	/**
322
+	 * Used to override the default for the additional limit field.
323
+	 * @param $additional_limit
324
+	 */
325
+	public static function set_default_additional_limit($additional_limit)
326
+	{
327
+		self::$_default_additional_limit = (int) $additional_limit;
328
+		if (self::$_instance instanceof EEM_Event) {
329
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
330
+				'EVT_additional_limit',
331
+				__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
332
+				true,
333
+				self::$_default_additional_limit
334
+			);
335
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
336
+				'Event_Meta',
337
+				'EVT_additional_limit',
338
+				'EEM_Event'
339
+			);
340
+		}
341
+	}
342
+
343
+
344
+	/**
345
+	 * Return what is currently set as the default additional limit for the event.
346
+	 * @return int
347
+	 */
348
+	public static function get_default_additional_limit()
349
+	{
350
+		return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
351
+	}
352
+
353
+
354
+	/**
355
+	 * get_question_groups
356
+	 *
357
+	 * @return array
358
+	 * @throws EE_Error
359
+	 * @throws ReflectionException
360
+	 */
361
+	public function get_all_question_groups()
362
+	{
363
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
364
+			array(
365
+				array('QSG_deleted' => false),
366
+				'order_by' => array('QSG_order' => 'ASC'),
367
+			)
368
+		);
369
+	}
370
+
371
+
372
+	/**
373
+	 * get_question_groups
374
+	 *
375
+	 * @param int $EVT_ID
376
+	 * @return array|bool
377
+	 * @throws EE_Error
378
+	 * @throws ReflectionException
379
+	 */
380
+	public function get_all_event_question_groups($EVT_ID = 0)
381
+	{
382
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
383
+			EE_Error::add_error(
384
+				esc_html__(
385
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
386
+					'event_espresso'
387
+				),
388
+				__FILE__,
389
+				__FUNCTION__,
390
+				__LINE__
391
+			);
392
+			return false;
393
+		}
394
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
395
+			array(
396
+				array('EVT_ID' => $EVT_ID),
397
+			)
398
+		);
399
+	}
400
+
401
+
402
+	/**
403
+	 * get_question_groups
404
+	 *
405
+	 * @param int $EVT_ID
406
+	 * @param boolean $for_primary_attendee
407
+	 * @return array|bool
408
+	 * @throws EE_Error
409
+	 * @throws InvalidArgumentException
410
+	 * @throws ReflectionException
411
+	 * @throws InvalidDataTypeException
412
+	 * @throws InvalidInterfaceException
413
+	 */
414
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
415
+	{
416
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
417
+			EE_Error::add_error(
418
+				esc_html__(
419
+					// @codingStandardsIgnoreStart
420
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
421
+					// @codingStandardsIgnoreEnd
422
+					'event_espresso'
423
+				),
424
+				__FILE__,
425
+				__FUNCTION__,
426
+				__LINE__
427
+			);
428
+			return false;
429
+		}
430
+		$query_params = [
431
+			[
432
+				'EVT_ID' => $EVT_ID,
433
+				EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
434
+			]
435
+		];
436
+		if ($for_primary_attendee) {
437
+			$query_params[0]['EQG_primary'] = true;
438
+		} else {
439
+			$query_params[0]['EQG_additional'] = true;
440
+		}
441
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
442
+	}
443
+
444
+
445
+	/**
446
+	 * get_question_groups
447
+	 *
448
+	 * @param int $EVT_ID
449
+	 * @param EE_Registration $registration
450
+	 * @return array|bool
451
+	 * @throws EE_Error
452
+	 * @throws InvalidArgumentException
453
+	 * @throws InvalidDataTypeException
454
+	 * @throws InvalidInterfaceException
455
+	 * @throws ReflectionException
456
+	 */
457
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
458
+	{
459
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
460
+			EE_Error::add_error(
461
+				esc_html__(
462
+					'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
463
+					'event_espresso'
464
+				),
465
+				__FILE__,
466
+				__FUNCTION__,
467
+				__LINE__
468
+			);
469
+			return false;
470
+		}
471
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
472
+			[
473
+				[
474
+					'Event_Question_Group.EVT_ID'      => $EVT_ID,
475
+					'Event_Question_Group.'
476
+						. EEM_Event_Question_Group::instance()->fieldNameForContext(
477
+							$registration->is_primary_registrant()
478
+						) => true
479
+				],
480
+				'order_by' => ['QSG_order' => 'ASC'],
481
+			]
482
+		);
483
+	}
484
+
485
+
486
+	/**
487
+	 * get_question_target_db_column
488
+	 *
489
+	 * @param string $QSG_IDs csv list of $QSG IDs
490
+	 * @return array|bool
491
+	 * @throws EE_Error
492
+	 * @throws ReflectionException
493
+	 */
494
+	public function get_questions_in_groups($QSG_IDs = '')
495
+	{
496
+		if (empty($QSG_IDs)) {
497
+			EE_Error::add_error(
498
+				esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
499
+				__FILE__,
500
+				__FUNCTION__,
501
+				__LINE__
502
+			);
503
+			return false;
504
+		}
505
+		return EE_Registry::instance()->load_model('Question')->get_all(
506
+			array(
507
+				array(
508
+					'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
509
+					'QST_deleted'           => false,
510
+					'QST_admin_only'        => is_admin(),
511
+				),
512
+				'order_by' => 'QST_order',
513
+			)
514
+		);
515
+	}
516
+
517
+
518
+	/**
519
+	 * get_options_for_question
520
+	 *
521
+	 * @param string $QST_IDs csv list of $QST IDs
522
+	 * @return array|bool
523
+	 * @throws EE_Error
524
+	 * @throws ReflectionException
525
+	 */
526
+	public function get_options_for_question($QST_IDs)
527
+	{
528
+		if (empty($QST_IDs)) {
529
+			EE_Error::add_error(
530
+				esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
531
+				__FILE__,
532
+				__FUNCTION__,
533
+				__LINE__
534
+			);
535
+			return false;
536
+		}
537
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(
538
+			array(
539
+				array(
540
+					'Question.QST_ID' => array('IN', $QST_IDs),
541
+					'QSO_deleted'     => false,
542
+				),
543
+				'order_by' => 'QSO_ID',
544
+			)
545
+		);
546
+	}
547
+
548
+
549
+	/**
550
+	 * Gets all events that are published
551
+	 * and have event start time earlier than now and an event end time later than now
552
+	 *
553
+	 * @param array $query_params  An array of query params to further filter on
554
+	 *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
555
+	 * @param bool  $count         whether to return the count or not (default FALSE)
556
+	 * @return EE_Event[]|int
557
+	 * @throws EE_Error
558
+	 * @throws ReflectionException
559
+	 */
560
+	public function get_active_events($query_params, $count = false)
561
+	{
562
+		if (array_key_exists(0, $query_params)) {
563
+			$where_params = $query_params[0];
564
+			unset($query_params[0]);
565
+		} else {
566
+			$where_params = array();
567
+		}
568
+		// if we have count make sure we don't include group by
569
+		if ($count && isset($query_params['group_by'])) {
570
+			unset($query_params['group_by']);
571
+		}
572
+		// let's add specific query_params for active_events
573
+		// keep in mind this will override any sent status in the query AND any date queries.
574
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
575
+		// if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
576
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
577
+			$where_params['Datetime.DTT_EVT_start******'] = array(
578
+				'<',
579
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
580
+			);
581
+		} else {
582
+			$where_params['Datetime.DTT_EVT_start'] = array(
583
+				'<',
584
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
585
+			);
586
+		}
587
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
588
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
589
+				'>',
590
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
591
+			);
592
+		} else {
593
+			$where_params['Datetime.DTT_EVT_end'] = array(
594
+				'>',
595
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
596
+			);
597
+		}
598
+		$query_params[0] = $where_params;
599
+		// don't use $query_params with count()
600
+		// because we don't want to include additional query clauses like "GROUP BY"
601
+		return $count
602
+			? $this->count(array($where_params), 'EVT_ID', true)
603
+			: $this->get_all($query_params);
604
+	}
605
+
606
+
607
+	/**
608
+	 * get all events that are published and have an event start time later than now
609
+	 *
610
+	 * @param array $query_params  An array of query params to further filter on
611
+	 *                             (Note that status and DTT_EVT_start will be overridden)
612
+	 * @param bool  $count         whether to return the count or not (default FALSE)
613
+	 * @return EE_Event[]|int
614
+	 * @throws EE_Error
615
+	 * @throws ReflectionException
616
+	 */
617
+	public function get_upcoming_events($query_params, $count = false)
618
+	{
619
+		if (array_key_exists(0, $query_params)) {
620
+			$where_params = $query_params[0];
621
+			unset($query_params[0]);
622
+		} else {
623
+			$where_params = array();
624
+		}
625
+		// if we have count make sure we don't include group by
626
+		if ($count && isset($query_params['group_by'])) {
627
+			unset($query_params['group_by']);
628
+		}
629
+		// let's add specific query_params for active_events
630
+		// keep in mind this will override any sent status in the query AND any date queries.
631
+		// we need to pull events with a status of publish and sold_out
632
+		$event_status = array('publish', EEM_Event::sold_out);
633
+		// check if the user can read private events and if so add the 'private status to the were params'
634
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
635
+			$event_status[] = 'private';
636
+		}
637
+		$where_params['status'] = array('IN', $event_status);
638
+		// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
639
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
640
+			$where_params['Datetime.DTT_EVT_start*****'] = array(
641
+				'>',
642
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
643
+			);
644
+		} else {
645
+			$where_params['Datetime.DTT_EVT_start'] = array(
646
+				'>',
647
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
648
+			);
649
+		}
650
+		$query_params[0] = $where_params;
651
+		// don't use $query_params with count()
652
+		// because we don't want to include additional query clauses like "GROUP BY"
653
+		return $count
654
+			? $this->count(array($where_params), 'EVT_ID', true)
655
+			: $this->get_all($query_params);
656
+	}
657
+
658
+
659
+	/**
660
+	 * Gets all events that are published
661
+	 * and have an event end time later than now
662
+	 *
663
+	 * @param array $query_params  An array of query params to further filter on
664
+	 *                             (note that status and DTT_EVT_end will be overridden)
665
+	 * @param bool  $count         whether to return the count or not (default FALSE)
666
+	 * @return EE_Event[]|int
667
+	 * @throws EE_Error
668
+	 * @throws ReflectionException
669
+	 */
670
+	public function get_active_and_upcoming_events($query_params, $count = false)
671
+	{
672
+		if (array_key_exists(0, $query_params)) {
673
+			$where_params = $query_params[0];
674
+			unset($query_params[0]);
675
+		} else {
676
+			$where_params = array();
677
+		}
678
+		// if we have count make sure we don't include group by
679
+		if ($count && isset($query_params['group_by'])) {
680
+			unset($query_params['group_by']);
681
+		}
682
+		// let's add specific query_params for active_events
683
+		// keep in mind this will override any sent status in the query AND any date queries.
684
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
685
+		// add where params for DTT_EVT_end
686
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
687
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
688
+				'>',
689
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
690
+			);
691
+		} else {
692
+			$where_params['Datetime.DTT_EVT_end'] = array(
693
+				'>',
694
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
695
+			);
696
+		}
697
+		$query_params[0] = $where_params;
698
+		// don't use $query_params with count()
699
+		// because we don't want to include additional query clauses like "GROUP BY"
700
+		return $count
701
+			? $this->count(array($where_params), 'EVT_ID', true)
702
+			: $this->get_all($query_params);
703
+	}
704
+
705
+
706
+	/**
707
+	 * This only returns events that are expired.
708
+	 * They may still be published but all their datetimes have expired.
709
+	 *
710
+	 * @param array $query_params  An array of query params to further filter on
711
+	 *                             (note that status and DTT_EVT_end will be overridden)
712
+	 * @param bool  $count         whether to return the count or not (default FALSE)
713
+	 * @return EE_Event[]|int
714
+	 * @throws EE_Error
715
+	 * @throws ReflectionException
716
+	 */
717
+	public function get_expired_events($query_params, $count = false)
718
+	{
719
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
720
+		// if we have count make sure we don't include group by
721
+		if ($count && isset($query_params['group_by'])) {
722
+			unset($query_params['group_by']);
723
+		}
724
+		// let's add specific query_params for active_events
725
+		// keep in mind this will override any sent status in the query AND any date queries.
726
+		if (isset($where_params['status'])) {
727
+			unset($where_params['status']);
728
+		}
729
+		$exclude_query = $query_params;
730
+		if (isset($exclude_query[0])) {
731
+			unset($exclude_query[0]);
732
+		}
733
+		$exclude_query[0] = array(
734
+			'Datetime.DTT_EVT_end' => array(
735
+				'>',
736
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
737
+			),
738
+		);
739
+		// first get all events that have datetimes where its not expired.
740
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
741
+		$event_ids = array_keys($event_ids);
742
+		// if we have any additional query_params, let's add them to the 'AND' condition
743
+		$and_condition = array(
744
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
745
+			'EVT_ID'               => array('NOT IN', $event_ids),
746
+		);
747
+		if (isset($where_params['OR'])) {
748
+			$and_condition['OR'] = $where_params['OR'];
749
+			unset($where_params['OR']);
750
+		}
751
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
752
+			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
753
+			unset($where_params['Datetime.DTT_EVT_end']);
754
+		}
755
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
756
+			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
757
+			unset($where_params['Datetime.DTT_EVT_start']);
758
+		}
759
+		// merge remaining $where params with the and conditions.
760
+		$where_params['AND'] = array_merge($and_condition, $where_params);
761
+		$query_params[0] = $where_params;
762
+		// don't use $query_params with count()
763
+		// because we don't want to include additional query clauses like "GROUP BY"
764
+		return $count
765
+			? $this->count(array($where_params), 'EVT_ID', true)
766
+			: $this->get_all($query_params);
767
+	}
768
+
769
+
770
+
771
+	/**
772
+	 * This basically just returns the events that do not have the publish status.
773
+	 *
774
+	 * @param  array   $query_params An array of query params to further filter on
775
+	 *                               (note that status will be overwritten)
776
+	 * @param  boolean $count        whether to return the count or not (default FALSE)
777
+	 * @return EE_Event[]|int
778
+	 * @throws EE_Error
779
+	 */
780
+	public function get_inactive_events($query_params, $count = false)
781
+	{
782
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
783
+		// let's add in specific query_params for inactive events.
784
+		if (isset($where_params['status'])) {
785
+			unset($where_params['status']);
786
+		}
787
+		// if we have count make sure we don't include group by
788
+		if ($count && isset($query_params['group_by'])) {
789
+			unset($query_params['group_by']);
790
+		}
791
+		// if we have any additional query_params, let's add them to the 'AND' condition
792
+		$where_params['AND']['status'] = array('!=', 'publish');
793
+		if (isset($where_params['OR'])) {
794
+			$where_params['AND']['OR'] = $where_params['OR'];
795
+			unset($where_params['OR']);
796
+		}
797
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
798
+			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
799
+			unset($where_params['Datetime.DTT_EVT_end']);
800
+		}
801
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
802
+			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
803
+			unset($where_params['Datetime.DTT_EVT_start']);
804
+		}
805
+		$query_params[0] = $where_params;
806
+		// don't use $query_params with count()
807
+		// because we don't want to include additional query clauses like "GROUP BY"
808
+		return $count
809
+			? $this->count(array($where_params), 'EVT_ID', true)
810
+			: $this->get_all($query_params);
811
+	}
812
+
813
+
814
+	/**
815
+	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
816
+	 * because we don't want to override any existing global default prices but instead insert NEW prices that get
817
+	 * attached to the event. See parent for param descriptions
818
+	 *
819
+	 * @param        $id_or_obj
820
+	 * @param        $other_model_id_or_obj
821
+	 * @param string $relationName
822
+	 * @param array  $where_query
823
+	 * @return EE_Base_Class
824
+	 * @throws EE_Error
825
+	 * @throws ReflectionException
826
+	 */
827
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
828
+	{
829
+		if ($relationName === 'Price') {
830
+			// let's get the PRC object for the given ID to make sure that we aren't dealing with a default
831
+			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
832
+			// if EVT_ID = 0, then this is a default
833
+			if ((int) $prc_chk->get('EVT_ID') === 0) {
834
+				// let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
835
+				$prc_chk->set('PRC_ID', 0);
836
+			}
837
+			// run parent
838
+			return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
839
+		}
840
+		// otherwise carry on as normal
841
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
842
+	}
843
+
844
+
845
+
846
+	/******************** DEPRECATED METHODS ********************/
847
+
848
+
849
+	/**
850
+	 * _get_question_target_db_column
851
+	 *
852
+	 * @param EE_Registration $registration    (so existing answers for registration are included)
853
+	 * @param int             $EVT_ID          so all question groups are included for event (not just answers from
854
+	 *                                         registration).
855
+	 * @return    array
856
+	 * @throws ReflectionException
857
+	 * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
858
+	 *                                         EE_Registration_Custom_Questions_Form located in
859
+	 *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
860
+	 * @access     public
861
+	 */
862
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
863
+	{
864
+		if (empty($EVT_ID)) {
865
+			throw new EE_Error(__(
866
+				'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
867
+				'event_espresso'
868
+			));
869
+		}
870
+		$questions = array();
871
+		// get all question groups for event
872
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
873
+		if (! empty($qgs)) {
874
+			foreach ($qgs as $qg) {
875
+				$qsts = $qg->questions();
876
+				$questions[ $qg->ID() ] = $qg->model_field_array();
877
+				$questions[ $qg->ID() ]['QSG_questions'] = array();
878
+				foreach ($qsts as $qst) {
879
+					if ($qst->is_system_question()) {
880
+						continue;
881
+					}
882
+					$answer = EEM_Answer::instance()->get_one(array(
883
+						array(
884
+							'QST_ID' => $qst->ID(),
885
+							'REG_ID' => $registration->ID(),
886
+						),
887
+					));
888
+					$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
889
+					$qst_name = $qstn_id = $qst->ID();
890
+					$ans_id = $answer->ID();
891
+					$qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
892
+					$input_name = '';
893
+					$input_id = sanitize_key($qst->display_text());
894
+					$input_class = '';
895
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
896
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
897
+																						   . $input_name
898
+																						   . $qst_name;
899
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
900
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
901
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
902
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
903
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
904
+					// leave responses as-is, don't convert stuff into html entities please!
905
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
906
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
907
+						$QSOs = $qst->options(true, $answer->value());
908
+						if (is_array($QSOs)) {
909
+							foreach ($QSOs as $QSO_ID => $QSO) {
910
+								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
911
+							}
912
+						}
913
+					}
914
+				}
915
+			}
916
+		}
917
+		return $questions;
918
+	}
919
+
920
+
921
+	/**
922
+	 * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
923
+	 *                             or an stdClass where each property is the name of a column,
924
+	 * @return EE_Base_Class
925
+	 * @throws EE_Error
926
+	 */
927
+	public function instantiate_class_from_array_or_object($cols_n_values)
928
+	{
929
+		$classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
930
+		if ($classInstance instanceof EE_Event) {
931
+			// events have their timezone defined in the DB, so use it immediately
932
+			$this->set_timezone($classInstance->get_timezone());
933
+		}
934
+		return $classInstance;
935
+	}
936 936
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/AttendeesConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class AttendeesConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * AttendeesConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * AttendeesConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'AttendeesConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/TicketsConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class TicketsConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * TicketsConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'TicketsConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * TicketsConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'TicketsConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/DatetimesConnectionOrderbyInput.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 class DatetimesConnectionOrderbyInput extends InputBase
18 18
 {
19 19
 
20
-    /**
21
-     * DatetimesConnectionOrderbyInput constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput');
26
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * DatetimesConnectionOrderbyInput constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'DatetimesConnectionOrderbyInput');
26
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return GraphQLFieldInterface[]
33
-     */
34
-    protected function getFields(): array
35
-    {
36
-        return [
37
-            new GraphQLField(
38
-                'field',
39
-                ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum']
40
-            ),
41
-            new GraphQLField(
42
-                'order',
43
-                'OrderEnum'
44
-            ),
45
-        ];
46
-    }
31
+	/**
32
+	 * @return GraphQLFieldInterface[]
33
+	 */
34
+	protected function getFields(): array
35
+	{
36
+		return [
37
+			new GraphQLField(
38
+				'field',
39
+				['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum']
40
+			),
41
+			new GraphQLField(
42
+				'order',
43
+				'OrderEnum'
44
+			),
45
+		];
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketUpdate.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,68 +15,68 @@
 block discarded – undo
15 15
 class TicketUpdate extends EntityMutator
16 16
 {
17 17
 
18
-    /**
19
-     * Defines the mutation data modification closure.
20
-     *
21
-     * @param EEM_Ticket $model
22
-     * @param Ticket     $type
23
-     * @return callable
24
-     */
25
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
26
-    {
27
-        /**
28
-         * Updates an entity.
29
-         *
30
-         * @param array       $input   The input for the mutation
31
-         * @param AppContext  $context The AppContext passed down to all resolvers
32
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
-         * @return array
34
-         * @throws EE_Error
35
-         * @throws ReflectionException
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Ticket $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
18
+	/**
19
+	 * Defines the mutation data modification closure.
20
+	 *
21
+	 * @param EEM_Ticket $model
22
+	 * @param Ticket     $type
23
+	 * @return callable
24
+	 */
25
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
26
+	{
27
+		/**
28
+		 * Updates an entity.
29
+		 *
30
+		 * @param array       $input   The input for the mutation
31
+		 * @param AppContext  $context The AppContext passed down to all resolvers
32
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
33
+		 * @return array
34
+		 * @throws EE_Error
35
+		 * @throws ReflectionException
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Ticket $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                $datetimes = [];
43
-                $prices = null;
42
+				$datetimes = [];
43
+				$prices = null;
44 44
 
45
-                $args = TicketMutation::prepareFields($input);
45
+				$args = TicketMutation::prepareFields($input);
46 46
 
47
-                if (isset($args['datetimes'])) {
48
-                    $datetimes = $args['datetimes'];
49
-                    unset($args['datetimes']);
50
-                }
51
-                if (array_key_exists('prices', $args)) {
52
-                    $prices = $args['prices'];
53
-                    unset($args['prices']);
54
-                }
47
+				if (isset($args['datetimes'])) {
48
+					$datetimes = $args['datetimes'];
49
+					unset($args['datetimes']);
50
+				}
51
+				if (array_key_exists('prices', $args)) {
52
+					$prices = $args['prices'];
53
+					unset($args['prices']);
54
+				}
55 55
 
56
-                $entity->save($args);
56
+				$entity->save($args);
57 57
 
58
-                if (! empty($datetimes)) {
59
-                    TicketMutation::setRelatedDatetimes($entity, $datetimes);
60
-                }
61
-                // if prices array is passed.
62
-                if (is_array($prices)) {
63
-                    TicketMutation::setRelatedPrices($entity, $prices);
64
-                }
58
+				if (! empty($datetimes)) {
59
+					TicketMutation::setRelatedDatetimes($entity, $datetimes);
60
+				}
61
+				// if prices array is passed.
62
+				if (is_array($prices)) {
63
+					TicketMutation::setRelatedPrices($entity, $prices);
64
+				}
65 65
 
66
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
67
-            } catch (Exception $exception) {
68
-                EntityMutator::handleExceptions(
69
-                    $exception,
70
-                    esc_html__(
71
-                        'The ticket could not be deleted because of the following error(s)',
72
-                        'event_espresso'
73
-                    )
74
-                );
75
-            }
66
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
67
+			} catch (Exception $exception) {
68
+				EntityMutator::handleExceptions(
69
+					$exception,
70
+					esc_html__(
71
+						'The ticket could not be deleted because of the following error(s)',
72
+						'event_espresso'
73
+					)
74
+				);
75
+			}
76 76
 
77
-            return [
78
-                'id' => $entity->ID(),
79
-            ];
80
-        };
81
-    }
77
+			return [
78
+				'id' => $entity->ID(),
79
+			];
80
+		};
81
+	}
82 82
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
          * @throws EE_Error
35 35
          * @throws ReflectionException
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Ticket $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
                 $entity->save($args);
57 57
 
58
-                if (! empty($datetimes)) {
58
+                if ( ! empty($datetimes)) {
59 59
                     TicketMutation::setRelatedDatetimes($entity, $datetimes);
60 60
                 }
61 61
                 // if prices array is passed.
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeBulkUpdate.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 class DatetimeBulkUpdate extends EntityMutator
9 9
 {
10 10
 
11
-    /**
12
-     * Defines the mutation data modification closure.
13
-     *
14
-     * @param EEM_Datetime $model
15
-     * @param Datetime     $type
16
-     * @return callable
17
-     */
18
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
-    {
20
-        $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
-        $bulkMutator = new BulkEntityMutator($entityMutator);
22
-        return array($bulkMutator, 'updateEntities');
23
-    }
11
+	/**
12
+	 * Defines the mutation data modification closure.
13
+	 *
14
+	 * @param EEM_Datetime $model
15
+	 * @param Datetime     $type
16
+	 * @return callable
17
+	 */
18
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
+	{
20
+		$entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
+		$bulkMutator = new BulkEntityMutator($entityMutator);
22
+		return array($bulkMutator, 'updateEntities');
23
+	}
24 24
 }
Please login to merge, or discard this patch.