Completed
Branch new-admin-design (7f58b2)
by
unknown
02:54
created
core/db_models/EEM_Event_Venue.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
         );
33 33
         // this model is generally available for reading
34 34
         $path_to_event = 'Event';
35
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
35
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
39 39
         $this->model_chain_to_password = $path_to_event;
40 40
         parent::__construct($timezone);
41 41
     }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,36 +8,36 @@
 block discarded – undo
8 8
  */
9 9
 class EEM_Event_Venue extends EEM_Base
10 10
 {
11
-    // private instance of the Attendee object
12
-    protected static $_instance = null;
11
+	// private instance of the Attendee object
12
+	protected static $_instance = null;
13 13
 
14
-    protected function __construct($timezone = null)
15
-    {
16
-        $this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso');
17
-        $this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso');
18
-        $this->_tables = array(
19
-            'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID')
20
-        );
21
-        $this->_fields = array(
22
-            'Event_Venue' => array(
23
-                'EVV_ID' => new EE_Primary_Key_Int_Field('EVV_ID', esc_html__('Event to Venue Link ID', 'event_espresso')),
24
-                'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'),
25
-                'VNU_ID' => new EE_Foreign_Key_Int_Field('VNU_ID', esc_html__('Venue ID', 'event_espresso'), false, 0, 'Venue'),
26
-                'EVV_primary' => new EE_Boolean_Field('EVV_primary', esc_html__("Flag indicating venue is primary one for event", "event_espresso"), false, true)
14
+	protected function __construct($timezone = null)
15
+	{
16
+		$this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso');
17
+		$this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso');
18
+		$this->_tables = array(
19
+			'Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID')
20
+		);
21
+		$this->_fields = array(
22
+			'Event_Venue' => array(
23
+				'EVV_ID' => new EE_Primary_Key_Int_Field('EVV_ID', esc_html__('Event to Venue Link ID', 'event_espresso')),
24
+				'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'),
25
+				'VNU_ID' => new EE_Foreign_Key_Int_Field('VNU_ID', esc_html__('Venue ID', 'event_espresso'), false, 0, 'Venue'),
26
+				'EVV_primary' => new EE_Boolean_Field('EVV_primary', esc_html__("Flag indicating venue is primary one for event", "event_espresso"), false, true)
27 27
 
28
-            )
29
-        );
30
-        $this->_model_relations = array(
31
-            'Event' => new EE_Belongs_To_Relation(),
32
-            'Venue' => new EE_Belongs_To_Relation()
33
-        );
34
-        // this model is generally available for reading
35
-        $path_to_event = 'Event';
36
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
39
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
40
-        $this->model_chain_to_password = $path_to_event;
41
-        parent::__construct($timezone);
42
-    }
28
+			)
29
+		);
30
+		$this->_model_relations = array(
31
+			'Event' => new EE_Belongs_To_Relation(),
32
+			'Venue' => new EE_Belongs_To_Relation()
33
+		);
34
+		// this model is generally available for reading
35
+		$path_to_event = 'Event';
36
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
39
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
40
+		$this->model_chain_to_password = $path_to_event;
41
+		parent::__construct($timezone);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Password_Field.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -12,45 +12,45 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Password_Field extends EE_Text_Field_Base
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $protected_fields;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $protected_fields;
19 19
 
20
-    /**
21
-     * EE_Password_Field constructor.
22
-     * @param $table_column
23
-     * @param $nicename
24
-     * @param $nullable
25
-     * @param null $default_value
26
-     * @param array $protected_fields
27
-     */
28
-    public function __construct($table_column, $nicename, $nullable, $default_value = null, $protected_fields = array())
29
-    {
30
-        $this->protected_fields = $protected_fields;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
20
+	/**
21
+	 * EE_Password_Field constructor.
22
+	 * @param $table_column
23
+	 * @param $nicename
24
+	 * @param $nullable
25
+	 * @param null $default_value
26
+	 * @param array $protected_fields
27
+	 */
28
+	public function __construct($table_column, $nicename, $nullable, $default_value = null, $protected_fields = array())
29
+	{
30
+		$this->protected_fields = $protected_fields;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34
-    /**
35
-     * Returns the names of the fields on this model that this password field should protect
36
-     * @since 4.9.74.p
37
-     * @return array
38
-     */
39
-    public function protectedFields()
40
-    {
41
-        return $this->protected_fields;
42
-    }
34
+	/**
35
+	 * Returns the names of the fields on this model that this password field should protect
36
+	 * @since 4.9.74.p
37
+	 * @return array
38
+	 */
39
+	public function protectedFields()
40
+	{
41
+		return $this->protected_fields;
42
+	}
43 43
 
44
-    /**
45
-     * Returns whether or not the specified field is protected by this model
46
-     * @since 4.9.74.p
47
-     * @param $field_name
48
-     * @return bool
49
-     */
50
-    public function fieldIsProtected($field_name)
51
-    {
52
-        return in_array($field_name, $this->protectedFields(), true);
53
-    }
44
+	/**
45
+	 * Returns whether or not the specified field is protected by this model
46
+	 * @since 4.9.74.p
47
+	 * @param $field_name
48
+	 * @return bool
49
+	 */
50
+	public function fieldIsProtected($field_name)
51
+	{
52
+		return in_array($field_name, $this->protectedFields(), true);
53
+	}
54 54
 }
55 55
 // End of file EE_Password_Field.php
56 56
 // Location: ${NAMESPACE}/EE_Password_Field.php
Please login to merge, or discard this patch.
core/domain/services/admin/ajax/EventEditorHeartbeat.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,52 +16,52 @@
 block discarded – undo
16 16
 class EventEditorHeartbeat
17 17
 {
18 18
 
19
-    /**
20
-     * @var Domain $domain
21
-     */
22
-    protected $domain;
19
+	/**
20
+	 * @var Domain $domain
21
+	 */
22
+	protected $domain;
23 23
 
24
-    /**
25
-     * @var EE_Environment_Config $environment
26
-     */
27
-    protected $environment;
24
+	/**
25
+	 * @var EE_Environment_Config $environment
26
+	 */
27
+	protected $environment;
28 28
 
29 29
 
30
-    /**
31
-     * EventEditorHeartbeat constructor.
32
-     *
33
-     * @param Domain                $domain
34
-     * @param EE_Environment_Config $environment
35
-     */
36
-    public function __construct(Domain $domain, EE_Environment_Config $environment)
37
-    {
38
-        $this->domain = $domain;
39
-        $this->environment = $environment;
40
-        if ($this->domain->isCaffeinated()) {
41
-            add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2);
42
-        }
43
-    }
30
+	/**
31
+	 * EventEditorHeartbeat constructor.
32
+	 *
33
+	 * @param Domain                $domain
34
+	 * @param EE_Environment_Config $environment
35
+	 */
36
+	public function __construct(Domain $domain, EE_Environment_Config $environment)
37
+	{
38
+		$this->domain = $domain;
39
+		$this->environment = $environment;
40
+		if ($this->domain->isCaffeinated()) {
41
+			add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2);
42
+		}
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
48
-     * accordingly.
49
-     *
50
-     * @param array $response The existing heartbeat response array.
51
-     * @param array $data     The incoming data package.
52
-     * @return array  possibly appended response.
53
-     */
54
-    public function heartbeatResponse($response, $data)
55
-    {
56
-        /**
57
-         * check whether count of tickets is approaching the potential
58
-         * limits for the server.
59
-         */
60
-        if (! empty($data['input_count'])) {
61
-            $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check(
62
-                $data['input_count']
63
-            );
64
-        }
65
-        return $response;
66
-    }
46
+	/**
47
+	 * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
48
+	 * accordingly.
49
+	 *
50
+	 * @param array $response The existing heartbeat response array.
51
+	 * @param array $data     The incoming data package.
52
+	 * @return array  possibly appended response.
53
+	 */
54
+	public function heartbeatResponse($response, $data)
55
+	{
56
+		/**
57
+		 * check whether count of tickets is approaching the potential
58
+		 * limits for the server.
59
+		 */
60
+		if (! empty($data['input_count'])) {
61
+			$response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check(
62
+				$data['input_count']
63
+			);
64
+		}
65
+		return $response;
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
          * check whether count of tickets is approaching the potential
58 58
          * limits for the server.
59 59
          */
60
-        if (! empty($data['input_count'])) {
60
+        if ( ! empty($data['input_count'])) {
61 61
             $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check(
62 62
                 $data['input_count']
63 63
             );
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/forms/SettingsForm.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -19,53 +19,53 @@
 block discarded – undo
19 19
  */
20 20
 class SettingsForm extends PayPalSettingsForm
21 21
 {
22
-    /**
23
-     * SettingsForm constructor.
24
-     *
25
-     * @param array $options_array
26
-     * @param string $help_tab_link
27
-     * @throws InvalidDataTypeException
28
-     * @throws InvalidInterfaceException
29
-     * @throws InvalidArgumentException
30
-     */
31
-    public function __construct(array $options_array = array(), $help_tab_link = '')
32
-    {
33
-        $options_array = array_replace_recursive(
34
-            array(
35
-                'extra_meta_inputs' => array(
36
-                    'request_shipping_addr' => new EE_Yes_No_Input(
37
-                        array(
38
-                            'html_label_text' => sprintf(
39
-                                esc_html__('Request Shipping Address %s', 'event_espresso'),
40
-                                $help_tab_link
41
-                            ),
42
-                            'html_help_text'  => esc_html__(
43
-                            // @codingStandardsIgnoreStart
44
-                                'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.',
45
-                                // @codingStandardsIgnoreEnd
46
-                                'event_espresso'
47
-                            ),
48
-                            'required'        => true,
49
-                            'default'         => false,
50
-                        )
51
-                    ),
52
-                    'image_url' => new EE_Admin_File_Uploader_Input(
53
-                        array(
54
-                            'html_label_text' => sprintf(
55
-                                esc_html__('Image URL %s', 'event_espresso'),
56
-                                $help_tab_link
57
-                            ),
58
-                            'html_help_text'  => esc_html__(
59
-                                'Used for your business/personal logo on the PayPal page',
60
-                                'event_espresso'
61
-                            ),
62
-                            'required'        => false,
63
-                        )
64
-                    ),
65
-                )
66
-            ),
67
-            $options_array
68
-        );
69
-        parent::__construct($options_array, $help_tab_link);
70
-    }
22
+	/**
23
+	 * SettingsForm constructor.
24
+	 *
25
+	 * @param array $options_array
26
+	 * @param string $help_tab_link
27
+	 * @throws InvalidDataTypeException
28
+	 * @throws InvalidInterfaceException
29
+	 * @throws InvalidArgumentException
30
+	 */
31
+	public function __construct(array $options_array = array(), $help_tab_link = '')
32
+	{
33
+		$options_array = array_replace_recursive(
34
+			array(
35
+				'extra_meta_inputs' => array(
36
+					'request_shipping_addr' => new EE_Yes_No_Input(
37
+						array(
38
+							'html_label_text' => sprintf(
39
+								esc_html__('Request Shipping Address %s', 'event_espresso'),
40
+								$help_tab_link
41
+							),
42
+							'html_help_text'  => esc_html__(
43
+							// @codingStandardsIgnoreStart
44
+								'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.',
45
+								// @codingStandardsIgnoreEnd
46
+								'event_espresso'
47
+							),
48
+							'required'        => true,
49
+							'default'         => false,
50
+						)
51
+					),
52
+					'image_url' => new EE_Admin_File_Uploader_Input(
53
+						array(
54
+							'html_label_text' => sprintf(
55
+								esc_html__('Image URL %s', 'event_espresso'),
56
+								$help_tab_link
57
+							),
58
+							'html_help_text'  => esc_html__(
59
+								'Used for your business/personal logo on the PayPal page',
60
+								'event_espresso'
61
+							),
62
+							'required'        => false,
63
+						)
64
+					),
65
+				)
66
+			),
67
+			$options_array
68
+		);
69
+		parent::__construct($options_array, $help_tab_link);
70
+	}
71 71
 }
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks_Extend.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 : [];
135 135
             $EQGids = array_keys($EQGs);
136 136
 
137
-            if (! empty($QSGs)) {
137
+            if ( ! empty($QSGs)) {
138 138
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
139 139
                 foreach ($QSGs as $QSG) {
140 140
                     $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
                     );
148 148
 
149 149
                     $html .= '
150
-					<p id="event-question-group-' . $QSG->ID() . '">
151
-						<input value="' . $QSG->ID() . '"'
152
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
153
-						<a href="' . $edit_link . '" title="'
150
+					<p id="event-question-group-' . $QSG->ID().'">
151
+						<input value="' . $QSG->ID().'"'
152
+                             . ' type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' />
153
+						<a href="' . $edit_link.'" title="'
154 154
                              . sprintf(
155 155
                                  esc_attr__('Edit %s Group', 'event_espresso'),
156 156
                                  $QSG->get('QSG_name')
157 157
                              )
158
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
158
+                             . '" target="_blank">'.$QSG->get('QSG_name').'</a>
159 159
 					</p>';
160 160
                     if ($QSG->ID() === 2) {
161 161
                         $html .= '
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $current_qgs = array_keys($current_qgs); // we just want the ids
200 200
 
201 201
         // now let's get the groups selected in the editor and update (IF we have data)
202
-        if (! empty($question_groups)) {
202
+        if ( ! empty($question_groups)) {
203 203
             foreach ($question_groups as $qgid) {
204 204
                 // add to event
205 205
                 if ($qgid) {
Please login to merge, or discard this patch.
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -16,214 +16,214 @@
 block discarded – undo
16 16
 class espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks
17 17
 {
18 18
 
19
-    /**
20
-     * extending the properties set in espresso_events_Registration_From_Hooks
21
-     *
22
-     * @access protected
23
-     * @return void
24
-     */
25
-    protected function _extend_properties()
26
-    {
27
-        if (
28
-            $this->_adminpage_obj->adminConfig()->useAdvancedEditor()
29
-            && $this->_adminpage_obj->feature()->allowed('use_reg_form_builder')
30
-        ) {
31
-            return;
32
-        }
33
-        $this->_metaboxes = array_merge(
34
-            $this->_metaboxes,
35
-            array(
36
-                1 => array(
37
-                    'page_route' => array('create_new', 'edit'),
38
-                    'func'       => 'additional_questions',
39
-                    'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
40
-                    'priority'   => 'default',
41
-                    'context'    => 'side',
42
-                ),
43
-            )
44
-        );
45
-        $this->_scripts_styles = array(
46
-            'registers' => array(
47
-                'extended-event-editor' => array(
48
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
49
-                                 . 'registration_form/assets/event-editor-question-groups.js',
50
-                    'depends' => array('jquery'),
51
-                ),
52
-            ),
53
-            'enqueues'  => array(
54
-                'extended-event-editor' => array('edit', 'create_new'),
55
-            ),
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * @param Callable[] $callbacks
62
-     * @return array
63
-     */
64
-    public function modify_callbacks($callbacks)
65
-    {
66
-        $callbacks = parent::modify_callbacks($callbacks);
67
-        $callbacks[] = array($this, 'additional_question_group_update');
68
-        return $callbacks;
69
-    }
70
-
71
-
72
-    /**
73
-     * Call back hooked into revision restores.
74
-     *
75
-     * @param $post_id
76
-     * @param $revision_id
77
-     * @return EE_Base_Class|void
78
-     * @throws EE_Error
79
-     * @throws InvalidArgumentException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     * @throws ReflectionException
83
-     */
84
-    public function restore_revision($post_id, $revision_id)
85
-    {
86
-        $post_evt = parent::restore_revision($post_id, $revision_id);
87
-
88
-        // restore revision for additional questions
89
-        $post_evt->restore_revision(
90
-            $revision_id,
91
-            ['Question_Group'],
92
-            [
93
-                'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
94
-            ]
95
-        );
96
-    }
97
-
98
-
99
-    /**
100
-     * @param $post_id
101
-     * @param $post
102
-     * @throws EE_Error
103
-     * @throws InvalidArgumentException
104
-     * @throws InvalidDataTypeException
105
-     * @throws InvalidInterfaceException
106
-     */
107
-    public function additional_questions($post_id, $post)
108
-    {
109
-        $this->_event = $this->_adminpage_obj->get_event_object();
110
-        $event_id = $this->_event->ID();
111
-        ?>
19
+	/**
20
+	 * extending the properties set in espresso_events_Registration_From_Hooks
21
+	 *
22
+	 * @access protected
23
+	 * @return void
24
+	 */
25
+	protected function _extend_properties()
26
+	{
27
+		if (
28
+			$this->_adminpage_obj->adminConfig()->useAdvancedEditor()
29
+			&& $this->_adminpage_obj->feature()->allowed('use_reg_form_builder')
30
+		) {
31
+			return;
32
+		}
33
+		$this->_metaboxes = array_merge(
34
+			$this->_metaboxes,
35
+			array(
36
+				1 => array(
37
+					'page_route' => array('create_new', 'edit'),
38
+					'func'       => 'additional_questions',
39
+					'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
40
+					'priority'   => 'default',
41
+					'context'    => 'side',
42
+				),
43
+			)
44
+		);
45
+		$this->_scripts_styles = array(
46
+			'registers' => array(
47
+				'extended-event-editor' => array(
48
+					'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
49
+								 . 'registration_form/assets/event-editor-question-groups.js',
50
+					'depends' => array('jquery'),
51
+				),
52
+			),
53
+			'enqueues'  => array(
54
+				'extended-event-editor' => array('edit', 'create_new'),
55
+			),
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @param Callable[] $callbacks
62
+	 * @return array
63
+	 */
64
+	public function modify_callbacks($callbacks)
65
+	{
66
+		$callbacks = parent::modify_callbacks($callbacks);
67
+		$callbacks[] = array($this, 'additional_question_group_update');
68
+		return $callbacks;
69
+	}
70
+
71
+
72
+	/**
73
+	 * Call back hooked into revision restores.
74
+	 *
75
+	 * @param $post_id
76
+	 * @param $revision_id
77
+	 * @return EE_Base_Class|void
78
+	 * @throws EE_Error
79
+	 * @throws InvalidArgumentException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 * @throws ReflectionException
83
+	 */
84
+	public function restore_revision($post_id, $revision_id)
85
+	{
86
+		$post_evt = parent::restore_revision($post_id, $revision_id);
87
+
88
+		// restore revision for additional questions
89
+		$post_evt->restore_revision(
90
+			$revision_id,
91
+			['Question_Group'],
92
+			[
93
+				'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
94
+			]
95
+		);
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param $post_id
101
+	 * @param $post
102
+	 * @throws EE_Error
103
+	 * @throws InvalidArgumentException
104
+	 * @throws InvalidDataTypeException
105
+	 * @throws InvalidInterfaceException
106
+	 */
107
+	public function additional_questions($post_id, $post)
108
+	{
109
+		$this->_event = $this->_adminpage_obj->get_event_object();
110
+		$event_id = $this->_event->ID();
111
+		?>
112 112
         <div class="inside">
113 113
             <p><strong>
114 114
                     <?php esc_html_e('Question Groups', 'event_espresso'); ?>
115 115
                 </strong><br/>
116 116
                 <?php
117
-                printf(
118
-                    esc_html__(
119
-                        'Add a pre-populated %1$sgroup of questions%2$s to your event.',
120
-                        'event_espresso'
121
-                    ),
122
-                    '<a href="admin.php?page=espresso_registration_form" target="_blank">',
123
-                    '</a>'
124
-                );
125
-                ?>
117
+				printf(
118
+					esc_html__(
119
+						'Add a pre-populated %1$sgroup of questions%2$s to your event.',
120
+						'event_espresso'
121
+					),
122
+					'<a href="admin.php?page=espresso_registration_form" target="_blank">',
123
+					'</a>'
124
+				);
125
+				?>
126 126
             </p>
127 127
             <?php
128 128
 
129
-            $qsg_where['QSG_deleted'] = false;
130
-            $query_params = apply_filters(
131
-                'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
132
-                array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
133
-            );
134
-            $QSGs = EEM_Question_Group::instance()->get_all($query_params);
135
-            $EQGs = ! empty($event_id)
136
-                ? $this->_event->get_many_related(
137
-                    'Question_Group',
138
-                    [['Event_Question_Group.EQG_additional' => true]]
139
-                )
140
-                : [];
141
-            $EQGids = array_keys($EQGs);
142
-
143
-            if (! empty($QSGs)) {
144
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
145
-                foreach ($QSGs as $QSG) {
146
-                    $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
147
-                    $edit_link = EE_Admin_Page::add_query_args_and_nonce(
148
-                        array(
149
-                            'action' => 'edit_question_group',
150
-                            'QSG_ID' => $QSG->ID(),
151
-                        ),
152
-                        EE_FORMS_ADMIN_URL
153
-                    );
154
-
155
-                    $html .= '
129
+			$qsg_where['QSG_deleted'] = false;
130
+			$query_params = apply_filters(
131
+				'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
132
+				array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
133
+			);
134
+			$QSGs = EEM_Question_Group::instance()->get_all($query_params);
135
+			$EQGs = ! empty($event_id)
136
+				? $this->_event->get_many_related(
137
+					'Question_Group',
138
+					[['Event_Question_Group.EQG_additional' => true]]
139
+				)
140
+				: [];
141
+			$EQGids = array_keys($EQGs);
142
+
143
+			if (! empty($QSGs)) {
144
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
145
+				foreach ($QSGs as $QSG) {
146
+					$checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
147
+					$edit_link = EE_Admin_Page::add_query_args_and_nonce(
148
+						array(
149
+							'action' => 'edit_question_group',
150
+							'QSG_ID' => $QSG->ID(),
151
+						),
152
+						EE_FORMS_ADMIN_URL
153
+					);
154
+
155
+					$html .= '
156 156
 					<p id="event-question-group-' . $QSG->ID() . '">
157 157
 						<input value="' . $QSG->ID() . '"'
158
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
158
+							 . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
159 159
 						<a href="' . $edit_link . '" title="'
160
-                             . sprintf(
161
-                                 esc_attr__('Edit %s Group', 'event_espresso'),
162
-                                 $QSG->get('QSG_name')
163
-                             )
164
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
160
+							 . sprintf(
161
+								 esc_attr__('Edit %s Group', 'event_espresso'),
162
+								 $QSG->get('QSG_name')
163
+							 )
164
+							 . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
165 165
 					</p>';
166
-                    if ($QSG->ID() === 2) {
167
-                        $html .= '
166
+					if ($QSG->ID() === 2) {
167
+						$html .= '
168 168
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">'
169
-                                 . esc_html__(
170
-                                     'The Personal Information question group is required whenever the Address Information question group is activated.',
171
-                                     'event_espresso'
172
-                                 )
173
-                                 . '</p>';
174
-                    }
175
-                }
176
-                $html .= count($QSGs) > 10 ? '</div>' : '';
177
-
178
-                echo $html;
179
-            } else {
180
-                esc_html_e(
181
-                    'There seems to be a problem with your questions. Please contact [email protected]',
182
-                    'event_espresso'
183
-                );
184
-            }
185
-            do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
186
-            ?>
169
+								 . esc_html__(
170
+									 'The Personal Information question group is required whenever the Address Information question group is activated.',
171
+									 'event_espresso'
172
+								 )
173
+								 . '</p>';
174
+					}
175
+				}
176
+				$html .= count($QSGs) > 10 ? '</div>' : '';
177
+
178
+				echo $html;
179
+			} else {
180
+				esc_html_e(
181
+					'There seems to be a problem with your questions. Please contact [email protected]',
182
+					'event_espresso'
183
+				);
184
+			}
185
+			do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
186
+			?>
187 187
         </div>
188 188
         <?php
189
-    }
190
-
191
-
192
-    public function additional_question_group_update($evtobj, $data)
193
-    {
194
-        $question_groups = ! empty($data['add_attendee_question_groups'])
195
-            ? (array) $data['add_attendee_question_groups']
196
-            : [];
197
-        $added_qgs = array_keys($question_groups);
198
-        $success = [];
199
-
200
-        // let's get all current question groups associated with this event.
201
-        $current_qgs = $evtobj->get_many_related(
202
-            'Question_Group',
203
-            [['Event_Question_Group.EQG_additional' => true]]
204
-        );
205
-        $current_qgs = array_keys($current_qgs); // we just want the ids
206
-
207
-        // now let's get the groups selected in the editor and update (IF we have data)
208
-        if (! empty($question_groups)) {
209
-            foreach ($question_groups as $qgid) {
210
-                // add to event
211
-                if ($qgid) {
212
-                    $qg = $evtobj->add_question_group($qgid, false);
213
-                }
214
-                $success[] = ! empty($qg) ? 1 : 0;
215
-            }
216
-        }
217
-
218
-        // wait a minute... are there question groups missing in the saved groups that ARE with the current event?
219
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
220
-
221
-        foreach ($removed_qgs as $qgid) {
222
-            $qg = $evtobj->remove_question_group($qgid, false);
223
-            $success[] = ! empty($qg) ? 1 : 0;
224
-        }
225
-
226
-
227
-        return in_array(0, $success, true) ? false : true;
228
-    }
189
+	}
190
+
191
+
192
+	public function additional_question_group_update($evtobj, $data)
193
+	{
194
+		$question_groups = ! empty($data['add_attendee_question_groups'])
195
+			? (array) $data['add_attendee_question_groups']
196
+			: [];
197
+		$added_qgs = array_keys($question_groups);
198
+		$success = [];
199
+
200
+		// let's get all current question groups associated with this event.
201
+		$current_qgs = $evtobj->get_many_related(
202
+			'Question_Group',
203
+			[['Event_Question_Group.EQG_additional' => true]]
204
+		);
205
+		$current_qgs = array_keys($current_qgs); // we just want the ids
206
+
207
+		// now let's get the groups selected in the editor and update (IF we have data)
208
+		if (! empty($question_groups)) {
209
+			foreach ($question_groups as $qgid) {
210
+				// add to event
211
+				if ($qgid) {
212
+					$qg = $evtobj->add_question_group($qgid, false);
213
+				}
214
+				$success[] = ! empty($qg) ? 1 : 0;
215
+			}
216
+		}
217
+
218
+		// wait a minute... are there question groups missing in the saved groups that ARE with the current event?
219
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
220
+
221
+		foreach ($removed_qgs as $qgid) {
222
+			$qg = $evtobj->remove_question_group($qgid, false);
223
+			$success[] = ! empty($qg) ? 1 : 0;
224
+		}
225
+
226
+
227
+		return in_array(0, $success, true) ? false : true;
228
+	}
229 229
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Event.model.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             'WP_User'                => new EE_Belongs_To_Relation(),
279 279
         );
280 280
         // this model is generally available for reading
281
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
281
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
282 282
         $this->model_chain_to_password = '';
283 283
         parent::__construct($timezone);
284 284
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function get_all_event_question_groups($EVT_ID = 0)
373 373
     {
374
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
374
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
375 375
             EE_Error::add_error(
376 376
                 esc_html__(
377 377
                     'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
407 407
     {
408
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
408
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
409 409
             EE_Error::add_error(
410 410
                 esc_html__(
411 411
                     // @codingStandardsIgnoreStart
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
450 450
     {
451
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
451
+        if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
452 452
             EE_Error::add_error(
453 453
                 esc_html__(
454 454
                     'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
@@ -861,11 +861,11 @@  discard block
 block discarded – undo
861 861
         $questions = array();
862 862
         // get all question groups for event
863 863
         $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
864
-        if (! empty($qgs)) {
864
+        if ( ! empty($qgs)) {
865 865
             foreach ($qgs as $qg) {
866 866
                 $qsts = $qg->questions();
867
-                $questions[ $qg->ID() ] = $qg->model_field_array();
868
-                $questions[ $qg->ID() ]['QSG_questions'] = array();
867
+                $questions[$qg->ID()] = $qg->model_field_array();
868
+                $questions[$qg->ID()]['QSG_questions'] = array();
869 869
                 foreach ($qsts as $qst) {
870 870
                     if ($qst->is_system_question()) {
871 871
                         continue;
@@ -879,26 +879,26 @@  discard block
 block discarded – undo
879 879
                     $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
880 880
                     $qst_name = $qstn_id = $qst->ID();
881 881
                     $ans_id = $answer->ID();
882
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
882
+                    $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
883 883
                     $input_name = '';
884 884
                     $input_id = sanitize_key($qst->display_text());
885 885
                     $input_class = '';
886
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
887
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
886
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
887
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'
888 888
                                                                                            . $input_name
889 889
                                                                                            . $qst_name;
890
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
891
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
892
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
893
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
894
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
890
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
891
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
892
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
893
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
894
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
895 895
                     // leave responses as-is, don't convert stuff into html entities please!
896
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
896
+                    $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
897 897
                     if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
898 898
                         $QSOs = $qst->options(true, $answer->value());
899 899
                         if (is_array($QSOs)) {
900 900
                             foreach ($QSOs as $QSO_ID => $QSO) {
901
-                                $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
901
+                                $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
902 902
                             }
903 903
                         }
904 904
                     }
Please login to merge, or discard this patch.
Indentation   +963 added lines, -963 removed lines patch added patch discarded remove patch
@@ -14,967 +14,967 @@
 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
-                    esc_html__('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
-                'VNU_ID' => new EE_Foreign_Key_Int_Field(
199
-                    'VNU_ID',
200
-                    __('Venue ID', 'event_espresso'),
201
-                    false,
202
-                    0,
203
-                    'Venue'
204
-                ),
205
-                'EVT_display_desc'                => new EE_Boolean_Field(
206
-                    'EVT_display_desc',
207
-                    esc_html__('Display Description Flag', 'event_espresso'),
208
-                    false,
209
-                    true
210
-                ),
211
-                'EVT_display_ticket_selector'     => new EE_Boolean_Field(
212
-                    'EVT_display_ticket_selector',
213
-                    esc_html__('Display Ticket Selector Flag', 'event_espresso'),
214
-                    false,
215
-                    true
216
-                ),
217
-                'EVT_visible_on'                  => new EE_Datetime_Field(
218
-                    'EVT_visible_on',
219
-                    esc_html__('Event Visible Date', 'event_espresso'),
220
-                    true,
221
-                    EE_Datetime_Field::now
222
-                ),
223
-                'EVT_additional_limit'            => new EE_Integer_Field(
224
-                    'EVT_additional_limit',
225
-                    esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
226
-                    true,
227
-                    self::$_default_additional_limit
228
-                ),
229
-                'EVT_default_registration_status' => new EE_Enum_Text_Field(
230
-                    'EVT_default_registration_status',
231
-                    esc_html__('Default Registration Status on this Event', 'event_espresso'),
232
-                    false,
233
-                    EEM_Event::$_default_reg_status,
234
-                    EEM_Registration::reg_status_array()
235
-                ),
236
-                'EVT_member_only'                 => new EE_Boolean_Field(
237
-                    'EVT_member_only',
238
-                    esc_html__('Member-Only Event Flag', 'event_espresso'),
239
-                    false,
240
-                    false
241
-                ),
242
-                'EVT_phone'                       => new EE_Plain_Text_Field(
243
-                    'EVT_phone',
244
-                    esc_html__('Event Phone Number', 'event_espresso'),
245
-                    false,
246
-                    ''
247
-                ),
248
-                'EVT_allow_overflow'              => new EE_Boolean_Field(
249
-                    'EVT_allow_overflow',
250
-                    esc_html__('Allow Overflow on Event', 'event_espresso'),
251
-                    false,
252
-                    false
253
-                ),
254
-                'EVT_timezone_string'             => new EE_Plain_Text_Field(
255
-                    'EVT_timezone_string',
256
-                    esc_html__('Timezone (name) for Event times', 'event_espresso'),
257
-                    false,
258
-                    ''
259
-                ),
260
-                'EVT_external_URL'                => new EE_Plain_Text_Field(
261
-                    'EVT_external_URL',
262
-                    esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
263
-                    true
264
-                ),
265
-                'EVT_donations'                   => new EE_Boolean_Field(
266
-                    'EVT_donations',
267
-                    esc_html__('Accept Donations?', 'event_espresso'),
268
-                    false,
269
-                    false
270
-                ),
271
-                'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
272
-                    'FSC_UUID',
273
-                    esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
274
-                    true,
275
-                    null,
276
-                    'Form_Section',
277
-                    false
278
-                ),
279
-            ),
280
-        );
281
-        $this->_model_relations = array(
282
-            'Attendee'               => new EE_HABTM_Relation('Registration'),
283
-            'Datetime'               => new EE_Has_Many_Relation(),
284
-            'Event_Question_Group'   => new EE_Has_Many_Relation(),
285
-            'Form_Section'           => new EE_Belongs_To_Relation(),
286
-            'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
287
-            'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
288
-            'Registration'           => new EE_Has_Many_Relation(),
289
-            'Term_Relationship'      => new EE_Has_Many_Relation(),
290
-            'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
291
-            'Venue'                  => new EE_Belongs_To_Relation(),
292
-            'WP_User'                => new EE_Belongs_To_Relation(),
293
-        );
294
-        // this model is generally available for reading
295
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
296
-        $this->model_chain_to_password = '';
297
-        parent::__construct($timezone);
298
-    }
299
-
300
-
301
-    /**
302
-     * @param string $default_reg_status
303
-     * @throws EE_Error
304
-     * @throws EE_Error
305
-     */
306
-    public static function set_default_reg_status($default_reg_status)
307
-    {
308
-        self::$_default_reg_status = $default_reg_status;
309
-        // if EEM_Event has already been instantiated,
310
-        // then we need to reset the `EVT_default_reg_status` field to use the new default.
311
-        if (self::$_instance instanceof EEM_Event) {
312
-            $default_reg_status = new EE_Enum_Text_Field(
313
-                'EVT_default_registration_status',
314
-                esc_html__('Default Registration Status on this Event', 'event_espresso'),
315
-                false,
316
-                $default_reg_status,
317
-                EEM_Registration::reg_status_array()
318
-            );
319
-            $default_reg_status->_construct_finalize(
320
-                'Event_Meta',
321
-                'EVT_default_registration_status',
322
-                'EEM_Event'
323
-            );
324
-            self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
325
-        }
326
-    }
327
-
328
-
329
-    /**
330
-     * Used to override the default for the additional limit field.
331
-     * @param $additional_limit
332
-     */
333
-    public static function set_default_additional_limit($additional_limit)
334
-    {
335
-        self::$_default_additional_limit = (int) $additional_limit;
336
-        if (self::$_instance instanceof EEM_Event) {
337
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
338
-                'EVT_additional_limit',
339
-                esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
340
-                true,
341
-                self::$_default_additional_limit
342
-            );
343
-            self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
344
-                'Event_Meta',
345
-                'EVT_additional_limit',
346
-                'EEM_Event'
347
-            );
348
-        }
349
-    }
350
-
351
-
352
-    /**
353
-     * Return what is currently set as the default additional limit for the event.
354
-     * @return int
355
-     */
356
-    public static function get_default_additional_limit()
357
-    {
358
-        return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
359
-    }
360
-
361
-
362
-    /**
363
-     * get_question_groups
364
-     *
365
-     * @return array
366
-     * @throws EE_Error
367
-     * @throws ReflectionException
368
-     */
369
-    public function get_all_question_groups()
370
-    {
371
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
372
-            array(
373
-                array('QSG_deleted' => false),
374
-                'order_by' => array('QSG_order' => 'ASC'),
375
-            )
376
-        );
377
-    }
378
-
379
-
380
-    /**
381
-     * get_question_groups
382
-     *
383
-     * @param int $EVT_ID
384
-     * @return array|bool
385
-     * @throws EE_Error
386
-     * @throws ReflectionException
387
-     */
388
-    public function get_all_event_question_groups($EVT_ID = 0)
389
-    {
390
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
391
-            EE_Error::add_error(
392
-                esc_html__(
393
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
394
-                    'event_espresso'
395
-                ),
396
-                __FILE__,
397
-                __FUNCTION__,
398
-                __LINE__
399
-            );
400
-            return false;
401
-        }
402
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
403
-            array(
404
-                array('EVT_ID' => $EVT_ID),
405
-            )
406
-        );
407
-    }
408
-
409
-
410
-    /**
411
-     * get_question_groups
412
-     *
413
-     * @param int $EVT_ID
414
-     * @param boolean $for_primary_attendee
415
-     * @return array|bool
416
-     * @throws EE_Error
417
-     * @throws InvalidArgumentException
418
-     * @throws ReflectionException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidInterfaceException
421
-     */
422
-    public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
423
-    {
424
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
425
-            EE_Error::add_error(
426
-                esc_html__(
427
-                    // @codingStandardsIgnoreStart
428
-                    'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
429
-                    // @codingStandardsIgnoreEnd
430
-                    'event_espresso'
431
-                ),
432
-                __FILE__,
433
-                __FUNCTION__,
434
-                __LINE__
435
-            );
436
-            return false;
437
-        }
438
-        $query_params = [
439
-            [
440
-                'EVT_ID' => $EVT_ID,
441
-                EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
442
-            ]
443
-        ];
444
-        if ($for_primary_attendee) {
445
-            $query_params[0]['EQG_primary'] = true;
446
-        } else {
447
-            $query_params[0]['EQG_additional'] = true;
448
-        }
449
-        return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
450
-    }
451
-
452
-
453
-    /**
454
-     * get_question_groups
455
-     *
456
-     * @param int $EVT_ID
457
-     * @param EE_Registration $registration
458
-     * @return array|bool
459
-     * @throws EE_Error
460
-     * @throws InvalidArgumentException
461
-     * @throws InvalidDataTypeException
462
-     * @throws InvalidInterfaceException
463
-     * @throws ReflectionException
464
-     */
465
-    public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
466
-    {
467
-        if (! isset($EVT_ID) || ! absint($EVT_ID)) {
468
-            EE_Error::add_error(
469
-                esc_html__(
470
-                    'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
471
-                    'event_espresso'
472
-                ),
473
-                __FILE__,
474
-                __FUNCTION__,
475
-                __LINE__
476
-            );
477
-            return false;
478
-        }
479
-        return EE_Registry::instance()->load_model('Question_Group')->get_all(
480
-            [
481
-                [
482
-                    'Event_Question_Group.EVT_ID'      => $EVT_ID,
483
-                    'Event_Question_Group.'
484
-                        . EEM_Event_Question_Group::instance()->fieldNameForContext(
485
-                            $registration->is_primary_registrant()
486
-                        ) => true
487
-                ],
488
-                'order_by' => ['QSG_order' => 'ASC'],
489
-            ]
490
-        );
491
-    }
492
-
493
-
494
-    /**
495
-     * get_question_target_db_column
496
-     *
497
-     * @param string $QSG_IDs csv list of $QSG IDs
498
-     * @return array|bool
499
-     * @throws EE_Error
500
-     * @throws ReflectionException
501
-     */
502
-    public function get_questions_in_groups($QSG_IDs = '')
503
-    {
504
-        if (empty($QSG_IDs)) {
505
-            EE_Error::add_error(
506
-                esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
507
-                __FILE__,
508
-                __FUNCTION__,
509
-                __LINE__
510
-            );
511
-            return false;
512
-        }
513
-        return EE_Registry::instance()->load_model('Question')->get_all(
514
-            array(
515
-                array(
516
-                    'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
517
-                    'QST_deleted'           => false,
518
-                    'QST_admin_only'        => is_admin(),
519
-                ),
520
-                'order_by' => 'QST_order',
521
-            )
522
-        );
523
-    }
524
-
525
-
526
-    /**
527
-     * get_options_for_question
528
-     *
529
-     * @param string $QST_IDs csv list of $QST IDs
530
-     * @return array|bool
531
-     * @throws EE_Error
532
-     * @throws ReflectionException
533
-     */
534
-    public function get_options_for_question($QST_IDs)
535
-    {
536
-        if (empty($QST_IDs)) {
537
-            EE_Error::add_error(
538
-                esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
539
-                __FILE__,
540
-                __FUNCTION__,
541
-                __LINE__
542
-            );
543
-            return false;
544
-        }
545
-        return EE_Registry::instance()->load_model('Question_Option')->get_all(
546
-            array(
547
-                array(
548
-                    'Question.QST_ID' => array('IN', $QST_IDs),
549
-                    'QSO_deleted'     => false,
550
-                ),
551
-                'order_by' => 'QSO_ID',
552
-            )
553
-        );
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets all events that are published
559
-     * and have event start time earlier than now and an event end time later than now
560
-     *
561
-     * @param array $query_params  An array of query params to further filter on
562
-     *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
563
-     * @param bool  $count         whether to return the count or not (default FALSE)
564
-     * @return EE_Event[]|int
565
-     * @throws EE_Error
566
-     * @throws ReflectionException
567
-     */
568
-    public function get_active_events($query_params, $count = false)
569
-    {
570
-        if (array_key_exists(0, $query_params)) {
571
-            $where_params = $query_params[0];
572
-            unset($query_params[0]);
573
-        } else {
574
-            $where_params = array();
575
-        }
576
-        // if we have count make sure we don't include group by
577
-        if ($count && isset($query_params['group_by'])) {
578
-            unset($query_params['group_by']);
579
-        }
580
-        // let's add specific query_params for active_events
581
-        // keep in mind this will override any sent status in the query AND any date queries.
582
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
583
-        // if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
584
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
585
-            $where_params['Datetime.DTT_EVT_start******'] = array(
586
-                '<',
587
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
588
-            );
589
-        } else {
590
-            $where_params['Datetime.DTT_EVT_start'] = array(
591
-                '<',
592
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
593
-            );
594
-        }
595
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
596
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
597
-                '>',
598
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
599
-            );
600
-        } else {
601
-            $where_params['Datetime.DTT_EVT_end'] = array(
602
-                '>',
603
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
604
-            );
605
-        }
606
-        $query_params[0] = $where_params;
607
-        // don't use $query_params with count()
608
-        // because we don't want to include additional query clauses like "GROUP BY"
609
-        return $count
610
-            ? $this->count(array($where_params), 'EVT_ID', true)
611
-            : $this->get_all($query_params);
612
-    }
613
-
614
-
615
-    /**
616
-     * get all events that are published and have an event start time later than now
617
-     *
618
-     * @param array $query_params  An array of query params to further filter on
619
-     *                             (Note that status and DTT_EVT_start will be overridden)
620
-     * @param bool  $count         whether to return the count or not (default FALSE)
621
-     * @return EE_Event[]|int
622
-     * @throws EE_Error
623
-     * @throws ReflectionException
624
-     */
625
-    public function get_upcoming_events($query_params, $count = false)
626
-    {
627
-        if (array_key_exists(0, $query_params)) {
628
-            $where_params = $query_params[0];
629
-            unset($query_params[0]);
630
-        } else {
631
-            $where_params = array();
632
-        }
633
-        // if we have count make sure we don't include group by
634
-        if ($count && isset($query_params['group_by'])) {
635
-            unset($query_params['group_by']);
636
-        }
637
-        // let's add specific query_params for active_events
638
-        // keep in mind this will override any sent status in the query AND any date queries.
639
-        // we need to pull events with a status of publish and sold_out
640
-        $event_status = array('publish', EEM_Event::sold_out);
641
-        // check if the user can read private events and if so add the 'private status to the were params'
642
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
643
-            $event_status[] = 'private';
644
-        }
645
-        $where_params['status'] = array('IN', $event_status);
646
-        // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
647
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
648
-            $where_params['Datetime.DTT_EVT_start*****'] = array(
649
-                '>',
650
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
651
-            );
652
-        } else {
653
-            $where_params['Datetime.DTT_EVT_start'] = array(
654
-                '>',
655
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
656
-            );
657
-        }
658
-        $query_params[0] = $where_params;
659
-        // don't use $query_params with count()
660
-        // because we don't want to include additional query clauses like "GROUP BY"
661
-        return $count
662
-            ? $this->count(array($where_params), 'EVT_ID', true)
663
-            : $this->get_all($query_params);
664
-    }
665
-
666
-
667
-    /**
668
-     * Gets all events that are published
669
-     * and have an event end time later than now
670
-     *
671
-     * @param array $query_params  An array of query params to further filter on
672
-     *                             (note that status and DTT_EVT_end will be overridden)
673
-     * @param bool  $count         whether to return the count or not (default FALSE)
674
-     * @return EE_Event[]|int
675
-     * @throws EE_Error
676
-     * @throws ReflectionException
677
-     */
678
-    public function get_active_and_upcoming_events($query_params, $count = false)
679
-    {
680
-        if (array_key_exists(0, $query_params)) {
681
-            $where_params = $query_params[0];
682
-            unset($query_params[0]);
683
-        } else {
684
-            $where_params = array();
685
-        }
686
-        // if we have count make sure we don't include group by
687
-        if ($count && isset($query_params['group_by'])) {
688
-            unset($query_params['group_by']);
689
-        }
690
-        // let's add specific query_params for active_events
691
-        // keep in mind this will override any sent status in the query AND any date queries.
692
-        $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
693
-        // add where params for DTT_EVT_end
694
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
695
-            $where_params['Datetime.DTT_EVT_end*****'] = array(
696
-                '>',
697
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
698
-            );
699
-        } else {
700
-            $where_params['Datetime.DTT_EVT_end'] = array(
701
-                '>',
702
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
703
-            );
704
-        }
705
-        $query_params[0] = $where_params;
706
-        // don't use $query_params with count()
707
-        // because we don't want to include additional query clauses like "GROUP BY"
708
-        return $count
709
-            ? $this->count(array($where_params), 'EVT_ID', true)
710
-            : $this->get_all($query_params);
711
-    }
712
-
713
-
714
-    /**
715
-     * This only returns events that are expired.
716
-     * They may still be published but all their datetimes have expired.
717
-     *
718
-     * @param array $query_params  An array of query params to further filter on
719
-     *                             (note that status and DTT_EVT_end will be overridden)
720
-     * @param bool  $count         whether to return the count or not (default FALSE)
721
-     * @return EE_Event[]|int
722
-     * @throws EE_Error
723
-     * @throws ReflectionException
724
-     */
725
-    public function get_expired_events($query_params, $count = false)
726
-    {
727
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
728
-        // if we have count make sure we don't include group by
729
-        if ($count && isset($query_params['group_by'])) {
730
-            unset($query_params['group_by']);
731
-        }
732
-        // let's add specific query_params for active_events
733
-        // keep in mind this will override any sent status in the query AND any date queries.
734
-        if (isset($where_params['status'])) {
735
-            unset($where_params['status']);
736
-        }
737
-        $exclude_query = $query_params;
738
-        if (isset($exclude_query[0])) {
739
-            unset($exclude_query[0]);
740
-        }
741
-        $exclude_query[0] = array(
742
-            'Datetime.DTT_EVT_end' => array(
743
-                '>',
744
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
745
-            ),
746
-        );
747
-        // first get all events that have datetimes where its not expired.
748
-        $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
749
-        $event_ids = array_keys($event_ids);
750
-        // if we have any additional query_params, let's add them to the 'AND' condition
751
-        $and_condition = array(
752
-            'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
753
-            'EVT_ID'               => array('NOT IN', $event_ids),
754
-        );
755
-        if (isset($where_params['OR'])) {
756
-            $and_condition['OR'] = $where_params['OR'];
757
-            unset($where_params['OR']);
758
-        }
759
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
760
-            $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
761
-            unset($where_params['Datetime.DTT_EVT_end']);
762
-        }
763
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
764
-            $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
765
-            unset($where_params['Datetime.DTT_EVT_start']);
766
-        }
767
-        // merge remaining $where params with the and conditions.
768
-        $where_params['AND'] = array_merge($and_condition, $where_params);
769
-        $query_params[0] = $where_params;
770
-        // don't use $query_params with count()
771
-        // because we don't want to include additional query clauses like "GROUP BY"
772
-        return $count
773
-            ? $this->count(array($where_params), 'EVT_ID', true)
774
-            : $this->get_all($query_params);
775
-    }
776
-
777
-
778
-
779
-    /**
780
-     * This basically just returns the events that do not have the publish status.
781
-     *
782
-     * @param  array   $query_params An array of query params to further filter on
783
-     *                               (note that status will be overwritten)
784
-     * @param  boolean $count        whether to return the count or not (default FALSE)
785
-     * @return EE_Event[]|int
786
-     * @throws EE_Error
787
-     */
788
-    public function get_inactive_events($query_params, $count = false)
789
-    {
790
-        $where_params = isset($query_params[0]) ? $query_params[0] : array();
791
-        // let's add in specific query_params for inactive events.
792
-        if (isset($where_params['status'])) {
793
-            unset($where_params['status']);
794
-        }
795
-        // if we have count make sure we don't include group by
796
-        if ($count && isset($query_params['group_by'])) {
797
-            unset($query_params['group_by']);
798
-        }
799
-        // if we have any additional query_params, let's add them to the 'AND' condition
800
-        $where_params['AND']['status'] = array('!=', 'publish');
801
-        if (isset($where_params['OR'])) {
802
-            $where_params['AND']['OR'] = $where_params['OR'];
803
-            unset($where_params['OR']);
804
-        }
805
-        if (isset($where_params['Datetime.DTT_EVT_end'])) {
806
-            $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
807
-            unset($where_params['Datetime.DTT_EVT_end']);
808
-        }
809
-        if (isset($where_params['Datetime.DTT_EVT_start'])) {
810
-            $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
811
-            unset($where_params['Datetime.DTT_EVT_start']);
812
-        }
813
-        $query_params[0] = $where_params;
814
-        // don't use $query_params with count()
815
-        // because we don't want to include additional query clauses like "GROUP BY"
816
-        return $count
817
-            ? $this->count(array($where_params), 'EVT_ID', true)
818
-            : $this->get_all($query_params);
819
-    }
820
-
821
-
822
-    /**
823
-     * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
824
-     * because we don't want to override any existing global default prices but instead insert NEW prices that get
825
-     * attached to the event. See parent for param descriptions
826
-     *
827
-     * @param        $id_or_obj
828
-     * @param        $other_model_id_or_obj
829
-     * @param string $relationName
830
-     * @param array  $where_query
831
-     * @return EE_Base_Class
832
-     * @throws EE_Error
833
-     * @throws ReflectionException
834
-     */
835
-    public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
836
-    {
837
-        if ($relationName === 'Price') {
838
-            // let's get the PRC object for the given ID to make sure that we aren't dealing with a default
839
-            $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
840
-            // if EVT_ID = 0, then this is a default
841
-            if ((int) $prc_chk->get('EVT_ID') === 0) {
842
-                // let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
843
-                $prc_chk->set('PRC_ID', 0);
844
-            }
845
-            // run parent
846
-            return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
847
-        }
848
-        // otherwise carry on as normal
849
-        return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
850
-    }
851
-
852
-
853
-
854
-    /******************** DEPRECATED METHODS ********************/
855
-
856
-
857
-    /**
858
-     * _get_question_target_db_column
859
-     *
860
-     * @param EE_Registration $registration    (so existing answers for registration are included)
861
-     * @param int             $EVT_ID          so all question groups are included for event (not just answers from
862
-     *                                         registration).
863
-     * @return    array
864
-     * @throws ReflectionException
865
-     * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
866
-     *                                         EE_Registration_Custom_Questions_Form located in
867
-     *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
868
-     * @access     public
869
-     */
870
-    public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
871
-    {
872
-        if (empty($EVT_ID)) {
873
-            throw new EE_Error(esc_html__(
874
-                'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
875
-                'event_espresso'
876
-            ));
877
-        }
878
-        $questions = array();
879
-        // get all question groups for event
880
-        $qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
881
-        if (! empty($qgs)) {
882
-            foreach ($qgs as $qg) {
883
-                $qsts = $qg->questions();
884
-                $questions[ $qg->ID() ] = $qg->model_field_array();
885
-                $questions[ $qg->ID() ]['QSG_questions'] = array();
886
-                foreach ($qsts as $qst) {
887
-                    if ($qst->is_system_question()) {
888
-                        continue;
889
-                    }
890
-                    $answer = EEM_Answer::instance()->get_one(array(
891
-                        array(
892
-                            'QST_ID' => $qst->ID(),
893
-                            'REG_ID' => $registration->ID(),
894
-                        ),
895
-                    ));
896
-                    $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
897
-                    $qst_name = $qstn_id = $qst->ID();
898
-                    $ans_id = $answer->ID();
899
-                    $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
900
-                    $input_name = '';
901
-                    $input_id = sanitize_key($qst->display_text());
902
-                    $input_class = '';
903
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
904
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
905
-                                                                                           . $input_name
906
-                                                                                           . $qst_name;
907
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
908
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
909
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
910
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
911
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
912
-                    // leave responses as-is, don't convert stuff into html entities please!
913
-                    $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
914
-                    if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
915
-                        $QSOs = $qst->options(true, $answer->value());
916
-                        if (is_array($QSOs)) {
917
-                            foreach ($QSOs as $QSO_ID => $QSO) {
918
-                                $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
919
-                            }
920
-                        }
921
-                    }
922
-                }
923
-            }
924
-        }
925
-        return $questions;
926
-    }
927
-
928
-
929
-    /**
930
-     * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
931
-     *                             or an stdClass where each property is the name of a column,
932
-     * @return EE_Base_Class
933
-     * @throws EE_Error
934
-     */
935
-    public function instantiate_class_from_array_or_object($cols_n_values)
936
-    {
937
-        $classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
938
-        if ($classInstance instanceof EE_Event) {
939
-            // events have their timezone defined in the DB, so use it immediately
940
-            $this->set_timezone($classInstance->get_timezone());
941
-        }
942
-        return $classInstance;
943
-    }
944
-
945
-
946
-    /**
947
-     * Deletes the model objects that meet the query params. Note: this method is overridden
948
-     * in EEM_Soft_Delete_Base so that soft-deleted model objects are instead only flagged
949
-     * as archived, not actually deleted
950
-     *
951
-     * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
952
-     * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
953
-     *                                that blocks it (ie, there' sno other data that depends on this data); if false,
954
-     *                                deletes regardless of other objects which may depend on it. Its generally
955
-     *                                advisable to always leave this as TRUE, otherwise you could easily corrupt your
956
-     *                                DB
957
-     * @return int                    number of rows deleted
958
-     * @throws EE_Error
959
-     */
960
-    public function delete_permanently($query_params, $allow_blocking = true)
961
-    {
962
-        $deleted = parent::delete_permanently($query_params, $allow_blocking);
963
-        if ($deleted) {
964
-            // get list of events with no prices
965
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', []);
966
-            $where = isset($query_params[0]) ? $query_params[0] : [];
967
-            $where_event = isset($where['EVT_ID']) ? $where['EVT_ID'] : ['', ''];
968
-            $where_event_ids = isset($where_event[1]) ? $where_event[1] : '';
969
-            $event_ids = is_string($where_event_ids)
970
-                ? explode(',', $where_event_ids)
971
-                : (array) $where_event_ids;
972
-            array_walk($event_ids, 'trim');
973
-            $event_ids = array_filter($event_ids);
974
-            // remove events from list of events with no prices
975
-            $espresso_no_ticket_prices = array_diff($espresso_no_ticket_prices, $event_ids);
976
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
977
-        }
978
-        return $deleted;
979
-    }
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
+					esc_html__('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
+				'VNU_ID' => new EE_Foreign_Key_Int_Field(
199
+					'VNU_ID',
200
+					__('Venue ID', 'event_espresso'),
201
+					false,
202
+					0,
203
+					'Venue'
204
+				),
205
+				'EVT_display_desc'                => new EE_Boolean_Field(
206
+					'EVT_display_desc',
207
+					esc_html__('Display Description Flag', 'event_espresso'),
208
+					false,
209
+					true
210
+				),
211
+				'EVT_display_ticket_selector'     => new EE_Boolean_Field(
212
+					'EVT_display_ticket_selector',
213
+					esc_html__('Display Ticket Selector Flag', 'event_espresso'),
214
+					false,
215
+					true
216
+				),
217
+				'EVT_visible_on'                  => new EE_Datetime_Field(
218
+					'EVT_visible_on',
219
+					esc_html__('Event Visible Date', 'event_espresso'),
220
+					true,
221
+					EE_Datetime_Field::now
222
+				),
223
+				'EVT_additional_limit'            => new EE_Integer_Field(
224
+					'EVT_additional_limit',
225
+					esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
226
+					true,
227
+					self::$_default_additional_limit
228
+				),
229
+				'EVT_default_registration_status' => new EE_Enum_Text_Field(
230
+					'EVT_default_registration_status',
231
+					esc_html__('Default Registration Status on this Event', 'event_espresso'),
232
+					false,
233
+					EEM_Event::$_default_reg_status,
234
+					EEM_Registration::reg_status_array()
235
+				),
236
+				'EVT_member_only'                 => new EE_Boolean_Field(
237
+					'EVT_member_only',
238
+					esc_html__('Member-Only Event Flag', 'event_espresso'),
239
+					false,
240
+					false
241
+				),
242
+				'EVT_phone'                       => new EE_Plain_Text_Field(
243
+					'EVT_phone',
244
+					esc_html__('Event Phone Number', 'event_espresso'),
245
+					false,
246
+					''
247
+				),
248
+				'EVT_allow_overflow'              => new EE_Boolean_Field(
249
+					'EVT_allow_overflow',
250
+					esc_html__('Allow Overflow on Event', 'event_espresso'),
251
+					false,
252
+					false
253
+				),
254
+				'EVT_timezone_string'             => new EE_Plain_Text_Field(
255
+					'EVT_timezone_string',
256
+					esc_html__('Timezone (name) for Event times', 'event_espresso'),
257
+					false,
258
+					''
259
+				),
260
+				'EVT_external_URL'                => new EE_Plain_Text_Field(
261
+					'EVT_external_URL',
262
+					esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'),
263
+					true
264
+				),
265
+				'EVT_donations'                   => new EE_Boolean_Field(
266
+					'EVT_donations',
267
+					esc_html__('Accept Donations?', 'event_espresso'),
268
+					false,
269
+					false
270
+				),
271
+				'FSC_UUID'                        => new EE_Foreign_Key_String_Field(
272
+					'FSC_UUID',
273
+					esc_html__('Registration Form UUID (universally unique identifier)', 'event_espresso'),
274
+					true,
275
+					null,
276
+					'Form_Section',
277
+					false
278
+				),
279
+			),
280
+		);
281
+		$this->_model_relations = array(
282
+			'Attendee'               => new EE_HABTM_Relation('Registration'),
283
+			'Datetime'               => new EE_Has_Many_Relation(),
284
+			'Event_Question_Group'   => new EE_Has_Many_Relation(),
285
+			'Form_Section'           => new EE_Belongs_To_Relation(),
286
+			'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'),
287
+			'Question_Group'         => new EE_HABTM_Relation('Event_Question_Group'),
288
+			'Registration'           => new EE_Has_Many_Relation(),
289
+			'Term_Relationship'      => new EE_Has_Many_Relation(),
290
+			'Term_Taxonomy'          => new EE_HABTM_Relation('Term_Relationship'),
291
+			'Venue'                  => new EE_Belongs_To_Relation(),
292
+			'WP_User'                => new EE_Belongs_To_Relation(),
293
+		);
294
+		// this model is generally available for reading
295
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
296
+		$this->model_chain_to_password = '';
297
+		parent::__construct($timezone);
298
+	}
299
+
300
+
301
+	/**
302
+	 * @param string $default_reg_status
303
+	 * @throws EE_Error
304
+	 * @throws EE_Error
305
+	 */
306
+	public static function set_default_reg_status($default_reg_status)
307
+	{
308
+		self::$_default_reg_status = $default_reg_status;
309
+		// if EEM_Event has already been instantiated,
310
+		// then we need to reset the `EVT_default_reg_status` field to use the new default.
311
+		if (self::$_instance instanceof EEM_Event) {
312
+			$default_reg_status = new EE_Enum_Text_Field(
313
+				'EVT_default_registration_status',
314
+				esc_html__('Default Registration Status on this Event', 'event_espresso'),
315
+				false,
316
+				$default_reg_status,
317
+				EEM_Registration::reg_status_array()
318
+			);
319
+			$default_reg_status->_construct_finalize(
320
+				'Event_Meta',
321
+				'EVT_default_registration_status',
322
+				'EEM_Event'
323
+			);
324
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status;
325
+		}
326
+	}
327
+
328
+
329
+	/**
330
+	 * Used to override the default for the additional limit field.
331
+	 * @param $additional_limit
332
+	 */
333
+	public static function set_default_additional_limit($additional_limit)
334
+	{
335
+		self::$_default_additional_limit = (int) $additional_limit;
336
+		if (self::$_instance instanceof EEM_Event) {
337
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field(
338
+				'EVT_additional_limit',
339
+				esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'),
340
+				true,
341
+				self::$_default_additional_limit
342
+			);
343
+			self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize(
344
+				'Event_Meta',
345
+				'EVT_additional_limit',
346
+				'EEM_Event'
347
+			);
348
+		}
349
+	}
350
+
351
+
352
+	/**
353
+	 * Return what is currently set as the default additional limit for the event.
354
+	 * @return int
355
+	 */
356
+	public static function get_default_additional_limit()
357
+	{
358
+		return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit);
359
+	}
360
+
361
+
362
+	/**
363
+	 * get_question_groups
364
+	 *
365
+	 * @return array
366
+	 * @throws EE_Error
367
+	 * @throws ReflectionException
368
+	 */
369
+	public function get_all_question_groups()
370
+	{
371
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
372
+			array(
373
+				array('QSG_deleted' => false),
374
+				'order_by' => array('QSG_order' => 'ASC'),
375
+			)
376
+		);
377
+	}
378
+
379
+
380
+	/**
381
+	 * get_question_groups
382
+	 *
383
+	 * @param int $EVT_ID
384
+	 * @return array|bool
385
+	 * @throws EE_Error
386
+	 * @throws ReflectionException
387
+	 */
388
+	public function get_all_event_question_groups($EVT_ID = 0)
389
+	{
390
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
391
+			EE_Error::add_error(
392
+				esc_html__(
393
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
394
+					'event_espresso'
395
+				),
396
+				__FILE__,
397
+				__FUNCTION__,
398
+				__LINE__
399
+			);
400
+			return false;
401
+		}
402
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(
403
+			array(
404
+				array('EVT_ID' => $EVT_ID),
405
+			)
406
+		);
407
+	}
408
+
409
+
410
+	/**
411
+	 * get_question_groups
412
+	 *
413
+	 * @param int $EVT_ID
414
+	 * @param boolean $for_primary_attendee
415
+	 * @return array|bool
416
+	 * @throws EE_Error
417
+	 * @throws InvalidArgumentException
418
+	 * @throws ReflectionException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidInterfaceException
421
+	 */
422
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true)
423
+	{
424
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
425
+			EE_Error::add_error(
426
+				esc_html__(
427
+					// @codingStandardsIgnoreStart
428
+					'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.',
429
+					// @codingStandardsIgnoreEnd
430
+					'event_espresso'
431
+				),
432
+				__FILE__,
433
+				__FUNCTION__,
434
+				__LINE__
435
+			);
436
+			return false;
437
+		}
438
+		$query_params = [
439
+			[
440
+				'EVT_ID' => $EVT_ID,
441
+				EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary_attendee) => true
442
+			]
443
+		];
444
+		if ($for_primary_attendee) {
445
+			$query_params[0]['EQG_primary'] = true;
446
+		} else {
447
+			$query_params[0]['EQG_additional'] = true;
448
+		}
449
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all($query_params);
450
+	}
451
+
452
+
453
+	/**
454
+	 * get_question_groups
455
+	 *
456
+	 * @param int $EVT_ID
457
+	 * @param EE_Registration $registration
458
+	 * @return array|bool
459
+	 * @throws EE_Error
460
+	 * @throws InvalidArgumentException
461
+	 * @throws InvalidDataTypeException
462
+	 * @throws InvalidInterfaceException
463
+	 * @throws ReflectionException
464
+	 */
465
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration)
466
+	{
467
+		if (! isset($EVT_ID) || ! absint($EVT_ID)) {
468
+			EE_Error::add_error(
469
+				esc_html__(
470
+					'An error occurred. No Question Groups could be retrieved because an Event ID was not received.',
471
+					'event_espresso'
472
+				),
473
+				__FILE__,
474
+				__FUNCTION__,
475
+				__LINE__
476
+			);
477
+			return false;
478
+		}
479
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(
480
+			[
481
+				[
482
+					'Event_Question_Group.EVT_ID'      => $EVT_ID,
483
+					'Event_Question_Group.'
484
+						. EEM_Event_Question_Group::instance()->fieldNameForContext(
485
+							$registration->is_primary_registrant()
486
+						) => true
487
+				],
488
+				'order_by' => ['QSG_order' => 'ASC'],
489
+			]
490
+		);
491
+	}
492
+
493
+
494
+	/**
495
+	 * get_question_target_db_column
496
+	 *
497
+	 * @param string $QSG_IDs csv list of $QSG IDs
498
+	 * @return array|bool
499
+	 * @throws EE_Error
500
+	 * @throws ReflectionException
501
+	 */
502
+	public function get_questions_in_groups($QSG_IDs = '')
503
+	{
504
+		if (empty($QSG_IDs)) {
505
+			EE_Error::add_error(
506
+				esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'),
507
+				__FILE__,
508
+				__FUNCTION__,
509
+				__LINE__
510
+			);
511
+			return false;
512
+		}
513
+		return EE_Registry::instance()->load_model('Question')->get_all(
514
+			array(
515
+				array(
516
+					'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
517
+					'QST_deleted'           => false,
518
+					'QST_admin_only'        => is_admin(),
519
+				),
520
+				'order_by' => 'QST_order',
521
+			)
522
+		);
523
+	}
524
+
525
+
526
+	/**
527
+	 * get_options_for_question
528
+	 *
529
+	 * @param string $QST_IDs csv list of $QST IDs
530
+	 * @return array|bool
531
+	 * @throws EE_Error
532
+	 * @throws ReflectionException
533
+	 */
534
+	public function get_options_for_question($QST_IDs)
535
+	{
536
+		if (empty($QST_IDs)) {
537
+			EE_Error::add_error(
538
+				esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'),
539
+				__FILE__,
540
+				__FUNCTION__,
541
+				__LINE__
542
+			);
543
+			return false;
544
+		}
545
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(
546
+			array(
547
+				array(
548
+					'Question.QST_ID' => array('IN', $QST_IDs),
549
+					'QSO_deleted'     => false,
550
+				),
551
+				'order_by' => 'QSO_ID',
552
+			)
553
+		);
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets all events that are published
559
+	 * and have event start time earlier than now and an event end time later than now
560
+	 *
561
+	 * @param array $query_params  An array of query params to further filter on
562
+	 *                             (note that status and DTT_EVT_start and DTT_EVT_end will be overridden)
563
+	 * @param bool  $count         whether to return the count or not (default FALSE)
564
+	 * @return EE_Event[]|int
565
+	 * @throws EE_Error
566
+	 * @throws ReflectionException
567
+	 */
568
+	public function get_active_events($query_params, $count = false)
569
+	{
570
+		if (array_key_exists(0, $query_params)) {
571
+			$where_params = $query_params[0];
572
+			unset($query_params[0]);
573
+		} else {
574
+			$where_params = array();
575
+		}
576
+		// if we have count make sure we don't include group by
577
+		if ($count && isset($query_params['group_by'])) {
578
+			unset($query_params['group_by']);
579
+		}
580
+		// let's add specific query_params for active_events
581
+		// keep in mind this will override any sent status in the query AND any date queries.
582
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
583
+		// if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
584
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
585
+			$where_params['Datetime.DTT_EVT_start******'] = array(
586
+				'<',
587
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
588
+			);
589
+		} else {
590
+			$where_params['Datetime.DTT_EVT_start'] = array(
591
+				'<',
592
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
593
+			);
594
+		}
595
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
596
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
597
+				'>',
598
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
599
+			);
600
+		} else {
601
+			$where_params['Datetime.DTT_EVT_end'] = array(
602
+				'>',
603
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
604
+			);
605
+		}
606
+		$query_params[0] = $where_params;
607
+		// don't use $query_params with count()
608
+		// because we don't want to include additional query clauses like "GROUP BY"
609
+		return $count
610
+			? $this->count(array($where_params), 'EVT_ID', true)
611
+			: $this->get_all($query_params);
612
+	}
613
+
614
+
615
+	/**
616
+	 * get all events that are published and have an event start time later than now
617
+	 *
618
+	 * @param array $query_params  An array of query params to further filter on
619
+	 *                             (Note that status and DTT_EVT_start will be overridden)
620
+	 * @param bool  $count         whether to return the count or not (default FALSE)
621
+	 * @return EE_Event[]|int
622
+	 * @throws EE_Error
623
+	 * @throws ReflectionException
624
+	 */
625
+	public function get_upcoming_events($query_params, $count = false)
626
+	{
627
+		if (array_key_exists(0, $query_params)) {
628
+			$where_params = $query_params[0];
629
+			unset($query_params[0]);
630
+		} else {
631
+			$where_params = array();
632
+		}
633
+		// if we have count make sure we don't include group by
634
+		if ($count && isset($query_params['group_by'])) {
635
+			unset($query_params['group_by']);
636
+		}
637
+		// let's add specific query_params for active_events
638
+		// keep in mind this will override any sent status in the query AND any date queries.
639
+		// we need to pull events with a status of publish and sold_out
640
+		$event_status = array('publish', EEM_Event::sold_out);
641
+		// check if the user can read private events and if so add the 'private status to the were params'
642
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_upcoming_events')) {
643
+			$event_status[] = 'private';
644
+		}
645
+		$where_params['status'] = array('IN', $event_status);
646
+		// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
647
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
648
+			$where_params['Datetime.DTT_EVT_start*****'] = array(
649
+				'>',
650
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
651
+			);
652
+		} else {
653
+			$where_params['Datetime.DTT_EVT_start'] = array(
654
+				'>',
655
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
656
+			);
657
+		}
658
+		$query_params[0] = $where_params;
659
+		// don't use $query_params with count()
660
+		// because we don't want to include additional query clauses like "GROUP BY"
661
+		return $count
662
+			? $this->count(array($where_params), 'EVT_ID', true)
663
+			: $this->get_all($query_params);
664
+	}
665
+
666
+
667
+	/**
668
+	 * Gets all events that are published
669
+	 * and have an event end time later than now
670
+	 *
671
+	 * @param array $query_params  An array of query params to further filter on
672
+	 *                             (note that status and DTT_EVT_end will be overridden)
673
+	 * @param bool  $count         whether to return the count or not (default FALSE)
674
+	 * @return EE_Event[]|int
675
+	 * @throws EE_Error
676
+	 * @throws ReflectionException
677
+	 */
678
+	public function get_active_and_upcoming_events($query_params, $count = false)
679
+	{
680
+		if (array_key_exists(0, $query_params)) {
681
+			$where_params = $query_params[0];
682
+			unset($query_params[0]);
683
+		} else {
684
+			$where_params = array();
685
+		}
686
+		// if we have count make sure we don't include group by
687
+		if ($count && isset($query_params['group_by'])) {
688
+			unset($query_params['group_by']);
689
+		}
690
+		// let's add specific query_params for active_events
691
+		// keep in mind this will override any sent status in the query AND any date queries.
692
+		$where_params['status'] = array('IN', array('publish', EEM_Event::sold_out));
693
+		// add where params for DTT_EVT_end
694
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
695
+			$where_params['Datetime.DTT_EVT_end*****'] = array(
696
+				'>',
697
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
698
+			);
699
+		} else {
700
+			$where_params['Datetime.DTT_EVT_end'] = array(
701
+				'>',
702
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
703
+			);
704
+		}
705
+		$query_params[0] = $where_params;
706
+		// don't use $query_params with count()
707
+		// because we don't want to include additional query clauses like "GROUP BY"
708
+		return $count
709
+			? $this->count(array($where_params), 'EVT_ID', true)
710
+			: $this->get_all($query_params);
711
+	}
712
+
713
+
714
+	/**
715
+	 * This only returns events that are expired.
716
+	 * They may still be published but all their datetimes have expired.
717
+	 *
718
+	 * @param array $query_params  An array of query params to further filter on
719
+	 *                             (note that status and DTT_EVT_end will be overridden)
720
+	 * @param bool  $count         whether to return the count or not (default FALSE)
721
+	 * @return EE_Event[]|int
722
+	 * @throws EE_Error
723
+	 * @throws ReflectionException
724
+	 */
725
+	public function get_expired_events($query_params, $count = false)
726
+	{
727
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
728
+		// if we have count make sure we don't include group by
729
+		if ($count && isset($query_params['group_by'])) {
730
+			unset($query_params['group_by']);
731
+		}
732
+		// let's add specific query_params for active_events
733
+		// keep in mind this will override any sent status in the query AND any date queries.
734
+		if (isset($where_params['status'])) {
735
+			unset($where_params['status']);
736
+		}
737
+		$exclude_query = $query_params;
738
+		if (isset($exclude_query[0])) {
739
+			unset($exclude_query[0]);
740
+		}
741
+		$exclude_query[0] = array(
742
+			'Datetime.DTT_EVT_end' => array(
743
+				'>',
744
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
745
+			),
746
+		);
747
+		// first get all events that have datetimes where its not expired.
748
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
749
+		$event_ids = array_keys($event_ids);
750
+		// if we have any additional query_params, let's add them to the 'AND' condition
751
+		$and_condition = array(
752
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
753
+			'EVT_ID'               => array('NOT IN', $event_ids),
754
+		);
755
+		if (isset($where_params['OR'])) {
756
+			$and_condition['OR'] = $where_params['OR'];
757
+			unset($where_params['OR']);
758
+		}
759
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
760
+			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
761
+			unset($where_params['Datetime.DTT_EVT_end']);
762
+		}
763
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
764
+			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
765
+			unset($where_params['Datetime.DTT_EVT_start']);
766
+		}
767
+		// merge remaining $where params with the and conditions.
768
+		$where_params['AND'] = array_merge($and_condition, $where_params);
769
+		$query_params[0] = $where_params;
770
+		// don't use $query_params with count()
771
+		// because we don't want to include additional query clauses like "GROUP BY"
772
+		return $count
773
+			? $this->count(array($where_params), 'EVT_ID', true)
774
+			: $this->get_all($query_params);
775
+	}
776
+
777
+
778
+
779
+	/**
780
+	 * This basically just returns the events that do not have the publish status.
781
+	 *
782
+	 * @param  array   $query_params An array of query params to further filter on
783
+	 *                               (note that status will be overwritten)
784
+	 * @param  boolean $count        whether to return the count or not (default FALSE)
785
+	 * @return EE_Event[]|int
786
+	 * @throws EE_Error
787
+	 */
788
+	public function get_inactive_events($query_params, $count = false)
789
+	{
790
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
791
+		// let's add in specific query_params for inactive events.
792
+		if (isset($where_params['status'])) {
793
+			unset($where_params['status']);
794
+		}
795
+		// if we have count make sure we don't include group by
796
+		if ($count && isset($query_params['group_by'])) {
797
+			unset($query_params['group_by']);
798
+		}
799
+		// if we have any additional query_params, let's add them to the 'AND' condition
800
+		$where_params['AND']['status'] = array('!=', 'publish');
801
+		if (isset($where_params['OR'])) {
802
+			$where_params['AND']['OR'] = $where_params['OR'];
803
+			unset($where_params['OR']);
804
+		}
805
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
806
+			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
807
+			unset($where_params['Datetime.DTT_EVT_end']);
808
+		}
809
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
810
+			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
811
+			unset($where_params['Datetime.DTT_EVT_start']);
812
+		}
813
+		$query_params[0] = $where_params;
814
+		// don't use $query_params with count()
815
+		// because we don't want to include additional query clauses like "GROUP BY"
816
+		return $count
817
+			? $this->count(array($where_params), 'EVT_ID', true)
818
+			: $this->get_all($query_params);
819
+	}
820
+
821
+
822
+	/**
823
+	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships
824
+	 * because we don't want to override any existing global default prices but instead insert NEW prices that get
825
+	 * attached to the event. See parent for param descriptions
826
+	 *
827
+	 * @param        $id_or_obj
828
+	 * @param        $other_model_id_or_obj
829
+	 * @param string $relationName
830
+	 * @param array  $where_query
831
+	 * @return EE_Base_Class
832
+	 * @throws EE_Error
833
+	 * @throws ReflectionException
834
+	 */
835
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
836
+	{
837
+		if ($relationName === 'Price') {
838
+			// let's get the PRC object for the given ID to make sure that we aren't dealing with a default
839
+			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
840
+			// if EVT_ID = 0, then this is a default
841
+			if ((int) $prc_chk->get('EVT_ID') === 0) {
842
+				// let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
843
+				$prc_chk->set('PRC_ID', 0);
844
+			}
845
+			// run parent
846
+			return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
847
+		}
848
+		// otherwise carry on as normal
849
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
850
+	}
851
+
852
+
853
+
854
+	/******************** DEPRECATED METHODS ********************/
855
+
856
+
857
+	/**
858
+	 * _get_question_target_db_column
859
+	 *
860
+	 * @param EE_Registration $registration    (so existing answers for registration are included)
861
+	 * @param int             $EVT_ID          so all question groups are included for event (not just answers from
862
+	 *                                         registration).
863
+	 * @return    array
864
+	 * @throws ReflectionException
865
+	 * @throws EE_Error*@deprecated as of 4.8.32.rc.001. Instead consider using
866
+	 *                                         EE_Registration_Custom_Questions_Form located in
867
+	 *                                         admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php
868
+	 * @access     public
869
+	 */
870
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0)
871
+	{
872
+		if (empty($EVT_ID)) {
873
+			throw new EE_Error(esc_html__(
874
+				'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.',
875
+				'event_espresso'
876
+			));
877
+		}
878
+		$questions = array();
879
+		// get all question groups for event
880
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
881
+		if (! empty($qgs)) {
882
+			foreach ($qgs as $qg) {
883
+				$qsts = $qg->questions();
884
+				$questions[ $qg->ID() ] = $qg->model_field_array();
885
+				$questions[ $qg->ID() ]['QSG_questions'] = array();
886
+				foreach ($qsts as $qst) {
887
+					if ($qst->is_system_question()) {
888
+						continue;
889
+					}
890
+					$answer = EEM_Answer::instance()->get_one(array(
891
+						array(
892
+							'QST_ID' => $qst->ID(),
893
+							'REG_ID' => $registration->ID(),
894
+						),
895
+					));
896
+					$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
897
+					$qst_name = $qstn_id = $qst->ID();
898
+					$ans_id = $answer->ID();
899
+					$qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
900
+					$input_name = '';
901
+					$input_id = sanitize_key($qst->display_text());
902
+					$input_class = '';
903
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ] = $qst->model_field_array();
904
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn'
905
+																						   . $input_name
906
+																						   . $qst_name;
907
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
908
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
909
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
910
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
911
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
912
+					// leave responses as-is, don't convert stuff into html entities please!
913
+					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['htmlentities'] = false;
914
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
915
+						$QSOs = $qst->options(true, $answer->value());
916
+						if (is_array($QSOs)) {
917
+							foreach ($QSOs as $QSO_ID => $QSO) {
918
+								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
919
+							}
920
+						}
921
+					}
922
+				}
923
+			}
924
+		}
925
+		return $questions;
926
+	}
927
+
928
+
929
+	/**
930
+	 * @param mixed $cols_n_values either an array of where each key is the name of a field, and the value is its value
931
+	 *                             or an stdClass where each property is the name of a column,
932
+	 * @return EE_Base_Class
933
+	 * @throws EE_Error
934
+	 */
935
+	public function instantiate_class_from_array_or_object($cols_n_values)
936
+	{
937
+		$classInstance = parent::instantiate_class_from_array_or_object($cols_n_values);
938
+		if ($classInstance instanceof EE_Event) {
939
+			// events have their timezone defined in the DB, so use it immediately
940
+			$this->set_timezone($classInstance->get_timezone());
941
+		}
942
+		return $classInstance;
943
+	}
944
+
945
+
946
+	/**
947
+	 * Deletes the model objects that meet the query params. Note: this method is overridden
948
+	 * in EEM_Soft_Delete_Base so that soft-deleted model objects are instead only flagged
949
+	 * as archived, not actually deleted
950
+	 *
951
+	 * @param array   $query_params   @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
952
+	 * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
953
+	 *                                that blocks it (ie, there' sno other data that depends on this data); if false,
954
+	 *                                deletes regardless of other objects which may depend on it. Its generally
955
+	 *                                advisable to always leave this as TRUE, otherwise you could easily corrupt your
956
+	 *                                DB
957
+	 * @return int                    number of rows deleted
958
+	 * @throws EE_Error
959
+	 */
960
+	public function delete_permanently($query_params, $allow_blocking = true)
961
+	{
962
+		$deleted = parent::delete_permanently($query_params, $allow_blocking);
963
+		if ($deleted) {
964
+			// get list of events with no prices
965
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', []);
966
+			$where = isset($query_params[0]) ? $query_params[0] : [];
967
+			$where_event = isset($where['EVT_ID']) ? $where['EVT_ID'] : ['', ''];
968
+			$where_event_ids = isset($where_event[1]) ? $where_event[1] : '';
969
+			$event_ids = is_string($where_event_ids)
970
+				? explode(',', $where_event_ids)
971
+				: (array) $where_event_ids;
972
+			array_walk($event_ids, 'trim');
973
+			$event_ids = array_filter($event_ids);
974
+			// remove events from list of events with no prices
975
+			$espresso_no_ticket_prices = array_diff($espresso_no_ticket_prices, $event_ids);
976
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
977
+		}
978
+		return $deleted;
979
+	}
980 980
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Line_Item.model.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
         );
325 325
         $query = $wpdb->prepare(
326 326
             'DELETE li
327
-				FROM ' . $this->table() . ' li
328
-				LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID
327
+				FROM ' . $this->table().' li
328
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
329 329
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
330 330
             // use GMT time because that's what TXN_timestamps are in
331 331
             date('Y-m-d H:i:s', time() - $time_to_leave_alone)
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
      */
599 599
     public function getTicketLineItemsForExpiredCarts($timestamp = 0)
600 600
     {
601
-        if (! absint($timestamp)) {
601
+        if ( ! absint($timestamp)) {
602 602
             /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
603 603
             $session_lifespan = LoaderFactory::getLoader()->getShared(
604 604
                 'EventEspresso\core\domain\values\session\SessionLifespan'
Please login to merge, or discard this patch.
Indentation   +609 added lines, -609 removed lines patch added patch discarded remove patch
@@ -28,616 +28,616 @@
 block discarded – undo
28 28
 class EEM_Line_Item extends EEM_Base
29 29
 {
30 30
 
31
-    /**
32
-     * Tax sub-total is just the total of all the taxes, which should be children
33
-     * of this line item. There should only ever be one tax sub-total, and it should
34
-     * be a direct child of. Its quantity and LIN_unit_price = 1.
35
-     */
36
-    const type_tax_sub_total = 'tax-sub-total';
37
-
38
-    /**
39
-     * Tax line items indicate a tax applied to all the taxable line items.
40
-     * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
41
-     * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
42
-     */
43
-    const type_tax = 'tax';
44
-
45
-    /**
46
-     * Indicating individual items purchased, or discounts or surcharges.
47
-     * The sum of all the regular line items  plus the tax items should equal the grand total.
48
-     * Possible children are sub-line-items and cancellations.
49
-     * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children
50
-     * LIN_totals. Its LIN_percent = 0.
51
-     * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1).
52
-     * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1.
53
-     */
54
-    const type_line_item = 'line-item';
55
-
56
-    /**
57
-     * Line item indicating all the factors that make a single line item.
58
-     * Sub-line items should have NO children line items.
59
-     * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's
60
-     * contribution towards the price of ONE of their parent items, and its LIN_total should be
61
-     *  = LIN_quantity * LIN_unit_price. Its LIN_percent = 0.
62
-     * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should
63
-     * = LIN_percent / 100 * sum of lower-priority sibling line items..
64
-     */
65
-    const type_sub_line_item = 'sub-item';
66
-
67
-    /**
68
-     * SubTax line items indicate a tax that is only applied to the pre-tax total of their parent line item.
69
-     * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
70
-     * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
71
-     */
72
-    const type_sub_tax = 'sub-tax';
73
-
74
-    /**
75
-     * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal).
76
-     * Direct children should be event subtotals.
77
-     * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals.
78
-     */
79
-    const type_sub_total = 'sub-total';
80
-
81
-    /**
82
-     * Line item for the grand total of an order.
83
-     * Its direct children should be tax subtotals and (pre-tax) subtotals,
84
-     * and possibly a regular line item indicating a transaction-wide discount/surcharge.
85
-     * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount.
86
-     */
87
-    const type_total = 'total';
88
-
89
-    /**
90
-     * When a line item is cancelled, a sub-line-item of type 'cancellation'
91
-     * should be created, indicating the quantity that were cancelled
92
-     * (because a line item could have a quantity of 1, and its cancellation item
93
-     * could be for 3, indicating that originally 4 were purchased, but 3 have been
94
-     * cancelled, and only one remains).
95
-     * When items are refunded, a cancellation line item should be made, which points
96
-     * to teh payment model object which actually refunded the payment.
97
-     * Cancellations should NOT have any children line items; the should NOT affect
98
-     * any calculations, and are only meant as a record that cancellations have occurred.
99
-     * Their LIN_percent should be 0.
100
-     */
101
-    const type_cancellation = 'cancellation';
102
-
103
-    // various line item object types
104
-    const OBJ_TYPE_EVENT = 'Event';
105
-
106
-    const OBJ_TYPE_PRICE = 'Price';
107
-
108
-    const OBJ_TYPE_PROMOTION = 'Promotion';
109
-
110
-    const OBJ_TYPE_TICKET = 'Ticket';
111
-
112
-    const OBJ_TYPE_TRANSACTION = 'Transaction';
113
-
114
-    /**
115
-     * @var EEM_Line_Item $_instance
116
-     */
117
-    protected static $_instance;
118
-
119
-
120
-    /**
121
-     * private constructor to prevent direct creation
122
-     *
123
-     * @Constructor
124
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
125
-     *                         (and any incoming timezone data that gets saved).
126
-     *                         Note this just sends the timezone info to the date time model field objects.
127
-     *                         Default is NULL
128
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
129
-     * @throws EE_Error
130
-     * @throws InvalidArgumentException
131
-     */
132
-    protected function __construct($timezone)
133
-    {
134
-        $this->singular_item = esc_html__('Line Item', 'event_espresso');
135
-        $this->plural_item = esc_html__('Line Items', 'event_espresso');
136
-
137
-        $this->_tables = array(
138
-            'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'),
139
-        );
140
-        $line_items_can_be_for = apply_filters(
141
-            'FHEE__EEM_Line_Item__line_items_can_be_for',
142
-            array('Ticket', 'Price', 'Event')
143
-        );
144
-        $this->_fields = array(
145
-            'Line_Item' => array(
146
-                'LIN_ID'         => new EE_Primary_Key_Int_Field(
147
-                    'LIN_ID',
148
-                    esc_html__('ID', 'event_espresso')
149
-                ),
150
-                'LIN_code'       => new EE_Slug_Field(
151
-                    'LIN_code',
152
-                    esc_html__('Code for index into Cart', 'event_espresso'),
153
-                    true
154
-                ),
155
-                'TXN_ID'         => new EE_Foreign_Key_Int_Field(
156
-                    'TXN_ID',
157
-                    esc_html__('Transaction ID', 'event_espresso'),
158
-                    true,
159
-                    null,
160
-                    'Transaction'
161
-                ),
162
-                'LIN_name'       => new EE_Full_HTML_Field(
163
-                    'LIN_name',
164
-                    esc_html__('Line Item Name', 'event_espresso'),
165
-                    false,
166
-                    ''
167
-                ),
168
-                'LIN_desc'       => new EE_Full_HTML_Field(
169
-                    'LIN_desc',
170
-                    esc_html__('Line Item Description', 'event_espresso'),
171
-                    true
172
-                ),
173
-                'LIN_unit_price' => new EE_Money_Field(
174
-                    'LIN_unit_price',
175
-                    esc_html__('Unit Price', 'event_espresso'),
176
-                    false,
177
-                    0
178
-                ),
179
-                'LIN_percent'    => new EE_Float_Field(
180
-                    'LIN_percent',
181
-                    esc_html__('Percent', 'event_espresso'),
182
-                    false,
183
-                    0
184
-                ),
185
-                'LIN_is_taxable' => new EE_Boolean_Field(
186
-                    'LIN_is_taxable',
187
-                    esc_html__('Taxable', 'event_espresso'),
188
-                    false,
189
-                    false
190
-                ),
191
-                'LIN_order'      => new EE_Integer_Field(
192
-                    'LIN_order',
193
-                    esc_html__('Order of Application towards total of parent', 'event_espresso'),
194
-                    false,
195
-                    1
196
-                ),
197
-                'LIN_total'      => new EE_Money_Field(
198
-                    'LIN_total',
199
-                    esc_html__('Total (unit price x quantity) after taxes', 'event_espresso'),
200
-                    false,
201
-                    0
202
-                ),
203
-                'LIN_pretax'      => new EE_Money_Field(
204
-                    'LIN_pretax',
205
-                    esc_html__('Total (unit price x quantity) before taxes', 'event_espresso'),
206
-                    false,
207
-                    0
208
-                ),
209
-                'LIN_quantity'   => new EE_Integer_Field(
210
-                    'LIN_quantity',
211
-                    esc_html__('Quantity', 'event_espresso'),
212
-                    true,
213
-                    1
214
-                ),
215
-                'LIN_parent'     => new EE_Integer_Field(
216
-                    'LIN_parent',
217
-                    esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'),
218
-                    true,
219
-                    null
220
-                ),
221
-                'LIN_type'       => new EE_Enum_Text_Field(
222
-                    'LIN_type',
223
-                    esc_html__('Type', 'event_espresso'),
224
-                    false,
225
-                    'line-item',
226
-                    array(
227
-                        self::type_line_item     => esc_html__('Line Item', 'event_espresso'),
228
-                        self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'),
229
-                        self::type_sub_tax       => esc_html__('Sub-Tax', 'event_espresso'),
230
-                        self::type_sub_total     => esc_html__('Subtotal', 'event_espresso'),
231
-                        self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'),
232
-                        self::type_tax           => esc_html__('Tax', 'event_espresso'),
233
-                        self::type_total         => esc_html__('Total', 'event_espresso'),
234
-                        self::type_cancellation  => esc_html__('Cancellation', 'event_espresso'),
235
-                    )
236
-                ),
237
-                'OBJ_ID'         => new EE_Foreign_Key_Int_Field(
238
-                    'OBJ_ID',
239
-                    esc_html__('ID of Item purchased.', 'event_espresso'),
240
-                    true,
241
-                    null,
242
-                    $line_items_can_be_for
243
-                ),
244
-                'OBJ_type'       => new EE_Any_Foreign_Model_Name_Field(
245
-                    'OBJ_type',
246
-                    esc_html__('Model Name this Line Item is for', 'event_espresso'),
247
-                    true,
248
-                    null,
249
-                    $line_items_can_be_for
250
-                ),
251
-                'LIN_timestamp'  => new EE_Datetime_Field(
252
-                    'LIN_timestamp',
253
-                    esc_html__('When the line item was created', 'event_espresso'),
254
-                    false,
255
-                    EE_Datetime_Field::now,
256
-                    $timezone
257
-                ),
258
-            ),
259
-        );
260
-        $this->_model_relations = array(
261
-            'Transaction' => new EE_Belongs_To_Relation(),
262
-            'Ticket'      => new EE_Belongs_To_Any_Relation(),
263
-            'Price'       => new EE_Belongs_To_Any_Relation(),
264
-            'Event'       => new EE_Belongs_To_Any_Relation(),
265
-        );
266
-        $this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
267
-        $this->_caps_slug = 'transactions';
268
-        parent::__construct($timezone);
269
-    }
270
-
271
-
272
-    /**
273
-     * Gets all the line items for this transaction of the given type
274
-     *
275
-     * @param string             $line_item_type like one of EEM_Line_Item::type_*
276
-     * @param EE_Transaction|int $transaction
277
-     * @return EE_Base_Class[]|EE_Line_Item[]
278
-     * @throws EE_Error
279
-     * @throws InvalidArgumentException
280
-     * @throws InvalidDataTypeException
281
-     * @throws InvalidInterfaceException
282
-     */
283
-    public function get_all_of_type_for_transaction($line_item_type, $transaction)
284
-    {
285
-        $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
286
-        return $this->get_all(array(
287
-            array(
288
-                'LIN_type' => $line_item_type,
289
-                'TXN_ID'   => $transaction,
290
-            ),
291
-        ));
292
-    }
293
-
294
-
295
-    /**
296
-     * Gets all line items unrelated to tickets that are normal line items
297
-     * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category)
298
-     *
299
-     * @param EE_Transaction|int $transaction
300
-     * @return EE_Base_Class[]|EE_Line_Item[]
301
-     * @throws EE_Error
302
-     * @throws InvalidArgumentException
303
-     * @throws InvalidDataTypeException
304
-     * @throws InvalidInterfaceException
305
-     */
306
-    public function get_all_non_ticket_line_items_for_transaction($transaction)
307
-    {
308
-        $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
309
-        return $this->get_all(array(
310
-            array(
311
-                'LIN_type' => self::type_line_item,
312
-                'TXN_ID'   => $transaction,
313
-                'OR'       => array(
314
-                    'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET),
315
-                    'OBJ_type*null'      => array('IS_NULL'),
316
-                ),
317
-            ),
318
-        ));
319
-    }
320
-
321
-
322
-    /**
323
-     * Deletes line items with no transaction who have passed the transaction cutoff time.
324
-     * This needs to be very efficient
325
-     * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when
326
-     * deleting and joining tables like this.
327
-     *
328
-     * @return int count of how many deleted
329
-     * @throws EE_Error
330
-     * @throws InvalidArgumentException
331
-     * @throws InvalidDataTypeException
332
-     * @throws InvalidInterfaceException
333
-     */
334
-    public function delete_line_items_with_no_transaction()
335
-    {
336
-        /** @type WPDB $wpdb */
337
-        global $wpdb;
338
-        $time_to_leave_alone = apply_filters(
339
-            'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone',
340
-            WEEK_IN_SECONDS
341
-        );
342
-        $query = $wpdb->prepare(
343
-            'DELETE li
31
+	/**
32
+	 * Tax sub-total is just the total of all the taxes, which should be children
33
+	 * of this line item. There should only ever be one tax sub-total, and it should
34
+	 * be a direct child of. Its quantity and LIN_unit_price = 1.
35
+	 */
36
+	const type_tax_sub_total = 'tax-sub-total';
37
+
38
+	/**
39
+	 * Tax line items indicate a tax applied to all the taxable line items.
40
+	 * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
41
+	 * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
42
+	 */
43
+	const type_tax = 'tax';
44
+
45
+	/**
46
+	 * Indicating individual items purchased, or discounts or surcharges.
47
+	 * The sum of all the regular line items  plus the tax items should equal the grand total.
48
+	 * Possible children are sub-line-items and cancellations.
49
+	 * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children
50
+	 * LIN_totals. Its LIN_percent = 0.
51
+	 * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1).
52
+	 * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1.
53
+	 */
54
+	const type_line_item = 'line-item';
55
+
56
+	/**
57
+	 * Line item indicating all the factors that make a single line item.
58
+	 * Sub-line items should have NO children line items.
59
+	 * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's
60
+	 * contribution towards the price of ONE of their parent items, and its LIN_total should be
61
+	 *  = LIN_quantity * LIN_unit_price. Its LIN_percent = 0.
62
+	 * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should
63
+	 * = LIN_percent / 100 * sum of lower-priority sibling line items..
64
+	 */
65
+	const type_sub_line_item = 'sub-item';
66
+
67
+	/**
68
+	 * SubTax line items indicate a tax that is only applied to the pre-tax total of their parent line item.
69
+	 * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal
70
+	 * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1.
71
+	 */
72
+	const type_sub_tax = 'sub-tax';
73
+
74
+	/**
75
+	 * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal).
76
+	 * Direct children should be event subtotals.
77
+	 * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals.
78
+	 */
79
+	const type_sub_total = 'sub-total';
80
+
81
+	/**
82
+	 * Line item for the grand total of an order.
83
+	 * Its direct children should be tax subtotals and (pre-tax) subtotals,
84
+	 * and possibly a regular line item indicating a transaction-wide discount/surcharge.
85
+	 * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount.
86
+	 */
87
+	const type_total = 'total';
88
+
89
+	/**
90
+	 * When a line item is cancelled, a sub-line-item of type 'cancellation'
91
+	 * should be created, indicating the quantity that were cancelled
92
+	 * (because a line item could have a quantity of 1, and its cancellation item
93
+	 * could be for 3, indicating that originally 4 were purchased, but 3 have been
94
+	 * cancelled, and only one remains).
95
+	 * When items are refunded, a cancellation line item should be made, which points
96
+	 * to teh payment model object which actually refunded the payment.
97
+	 * Cancellations should NOT have any children line items; the should NOT affect
98
+	 * any calculations, and are only meant as a record that cancellations have occurred.
99
+	 * Their LIN_percent should be 0.
100
+	 */
101
+	const type_cancellation = 'cancellation';
102
+
103
+	// various line item object types
104
+	const OBJ_TYPE_EVENT = 'Event';
105
+
106
+	const OBJ_TYPE_PRICE = 'Price';
107
+
108
+	const OBJ_TYPE_PROMOTION = 'Promotion';
109
+
110
+	const OBJ_TYPE_TICKET = 'Ticket';
111
+
112
+	const OBJ_TYPE_TRANSACTION = 'Transaction';
113
+
114
+	/**
115
+	 * @var EEM_Line_Item $_instance
116
+	 */
117
+	protected static $_instance;
118
+
119
+
120
+	/**
121
+	 * private constructor to prevent direct creation
122
+	 *
123
+	 * @Constructor
124
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
125
+	 *                         (and any incoming timezone data that gets saved).
126
+	 *                         Note this just sends the timezone info to the date time model field objects.
127
+	 *                         Default is NULL
128
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
129
+	 * @throws EE_Error
130
+	 * @throws InvalidArgumentException
131
+	 */
132
+	protected function __construct($timezone)
133
+	{
134
+		$this->singular_item = esc_html__('Line Item', 'event_espresso');
135
+		$this->plural_item = esc_html__('Line Items', 'event_espresso');
136
+
137
+		$this->_tables = array(
138
+			'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'),
139
+		);
140
+		$line_items_can_be_for = apply_filters(
141
+			'FHEE__EEM_Line_Item__line_items_can_be_for',
142
+			array('Ticket', 'Price', 'Event')
143
+		);
144
+		$this->_fields = array(
145
+			'Line_Item' => array(
146
+				'LIN_ID'         => new EE_Primary_Key_Int_Field(
147
+					'LIN_ID',
148
+					esc_html__('ID', 'event_espresso')
149
+				),
150
+				'LIN_code'       => new EE_Slug_Field(
151
+					'LIN_code',
152
+					esc_html__('Code for index into Cart', 'event_espresso'),
153
+					true
154
+				),
155
+				'TXN_ID'         => new EE_Foreign_Key_Int_Field(
156
+					'TXN_ID',
157
+					esc_html__('Transaction ID', 'event_espresso'),
158
+					true,
159
+					null,
160
+					'Transaction'
161
+				),
162
+				'LIN_name'       => new EE_Full_HTML_Field(
163
+					'LIN_name',
164
+					esc_html__('Line Item Name', 'event_espresso'),
165
+					false,
166
+					''
167
+				),
168
+				'LIN_desc'       => new EE_Full_HTML_Field(
169
+					'LIN_desc',
170
+					esc_html__('Line Item Description', 'event_espresso'),
171
+					true
172
+				),
173
+				'LIN_unit_price' => new EE_Money_Field(
174
+					'LIN_unit_price',
175
+					esc_html__('Unit Price', 'event_espresso'),
176
+					false,
177
+					0
178
+				),
179
+				'LIN_percent'    => new EE_Float_Field(
180
+					'LIN_percent',
181
+					esc_html__('Percent', 'event_espresso'),
182
+					false,
183
+					0
184
+				),
185
+				'LIN_is_taxable' => new EE_Boolean_Field(
186
+					'LIN_is_taxable',
187
+					esc_html__('Taxable', 'event_espresso'),
188
+					false,
189
+					false
190
+				),
191
+				'LIN_order'      => new EE_Integer_Field(
192
+					'LIN_order',
193
+					esc_html__('Order of Application towards total of parent', 'event_espresso'),
194
+					false,
195
+					1
196
+				),
197
+				'LIN_total'      => new EE_Money_Field(
198
+					'LIN_total',
199
+					esc_html__('Total (unit price x quantity) after taxes', 'event_espresso'),
200
+					false,
201
+					0
202
+				),
203
+				'LIN_pretax'      => new EE_Money_Field(
204
+					'LIN_pretax',
205
+					esc_html__('Total (unit price x quantity) before taxes', 'event_espresso'),
206
+					false,
207
+					0
208
+				),
209
+				'LIN_quantity'   => new EE_Integer_Field(
210
+					'LIN_quantity',
211
+					esc_html__('Quantity', 'event_espresso'),
212
+					true,
213
+					1
214
+				),
215
+				'LIN_parent'     => new EE_Integer_Field(
216
+					'LIN_parent',
217
+					esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'),
218
+					true,
219
+					null
220
+				),
221
+				'LIN_type'       => new EE_Enum_Text_Field(
222
+					'LIN_type',
223
+					esc_html__('Type', 'event_espresso'),
224
+					false,
225
+					'line-item',
226
+					array(
227
+						self::type_line_item     => esc_html__('Line Item', 'event_espresso'),
228
+						self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'),
229
+						self::type_sub_tax       => esc_html__('Sub-Tax', 'event_espresso'),
230
+						self::type_sub_total     => esc_html__('Subtotal', 'event_espresso'),
231
+						self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'),
232
+						self::type_tax           => esc_html__('Tax', 'event_espresso'),
233
+						self::type_total         => esc_html__('Total', 'event_espresso'),
234
+						self::type_cancellation  => esc_html__('Cancellation', 'event_espresso'),
235
+					)
236
+				),
237
+				'OBJ_ID'         => new EE_Foreign_Key_Int_Field(
238
+					'OBJ_ID',
239
+					esc_html__('ID of Item purchased.', 'event_espresso'),
240
+					true,
241
+					null,
242
+					$line_items_can_be_for
243
+				),
244
+				'OBJ_type'       => new EE_Any_Foreign_Model_Name_Field(
245
+					'OBJ_type',
246
+					esc_html__('Model Name this Line Item is for', 'event_espresso'),
247
+					true,
248
+					null,
249
+					$line_items_can_be_for
250
+				),
251
+				'LIN_timestamp'  => new EE_Datetime_Field(
252
+					'LIN_timestamp',
253
+					esc_html__('When the line item was created', 'event_espresso'),
254
+					false,
255
+					EE_Datetime_Field::now,
256
+					$timezone
257
+				),
258
+			),
259
+		);
260
+		$this->_model_relations = array(
261
+			'Transaction' => new EE_Belongs_To_Relation(),
262
+			'Ticket'      => new EE_Belongs_To_Any_Relation(),
263
+			'Price'       => new EE_Belongs_To_Any_Relation(),
264
+			'Event'       => new EE_Belongs_To_Any_Relation(),
265
+		);
266
+		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
267
+		$this->_caps_slug = 'transactions';
268
+		parent::__construct($timezone);
269
+	}
270
+
271
+
272
+	/**
273
+	 * Gets all the line items for this transaction of the given type
274
+	 *
275
+	 * @param string             $line_item_type like one of EEM_Line_Item::type_*
276
+	 * @param EE_Transaction|int $transaction
277
+	 * @return EE_Base_Class[]|EE_Line_Item[]
278
+	 * @throws EE_Error
279
+	 * @throws InvalidArgumentException
280
+	 * @throws InvalidDataTypeException
281
+	 * @throws InvalidInterfaceException
282
+	 */
283
+	public function get_all_of_type_for_transaction($line_item_type, $transaction)
284
+	{
285
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
286
+		return $this->get_all(array(
287
+			array(
288
+				'LIN_type' => $line_item_type,
289
+				'TXN_ID'   => $transaction,
290
+			),
291
+		));
292
+	}
293
+
294
+
295
+	/**
296
+	 * Gets all line items unrelated to tickets that are normal line items
297
+	 * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category)
298
+	 *
299
+	 * @param EE_Transaction|int $transaction
300
+	 * @return EE_Base_Class[]|EE_Line_Item[]
301
+	 * @throws EE_Error
302
+	 * @throws InvalidArgumentException
303
+	 * @throws InvalidDataTypeException
304
+	 * @throws InvalidInterfaceException
305
+	 */
306
+	public function get_all_non_ticket_line_items_for_transaction($transaction)
307
+	{
308
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
309
+		return $this->get_all(array(
310
+			array(
311
+				'LIN_type' => self::type_line_item,
312
+				'TXN_ID'   => $transaction,
313
+				'OR'       => array(
314
+					'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET),
315
+					'OBJ_type*null'      => array('IS_NULL'),
316
+				),
317
+			),
318
+		));
319
+	}
320
+
321
+
322
+	/**
323
+	 * Deletes line items with no transaction who have passed the transaction cutoff time.
324
+	 * This needs to be very efficient
325
+	 * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when
326
+	 * deleting and joining tables like this.
327
+	 *
328
+	 * @return int count of how many deleted
329
+	 * @throws EE_Error
330
+	 * @throws InvalidArgumentException
331
+	 * @throws InvalidDataTypeException
332
+	 * @throws InvalidInterfaceException
333
+	 */
334
+	public function delete_line_items_with_no_transaction()
335
+	{
336
+		/** @type WPDB $wpdb */
337
+		global $wpdb;
338
+		$time_to_leave_alone = apply_filters(
339
+			'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone',
340
+			WEEK_IN_SECONDS
341
+		);
342
+		$query = $wpdb->prepare(
343
+			'DELETE li
344 344
 				FROM ' . $this->table() . ' li
345 345
 				LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID
346 346
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
347
-            // use GMT time because that's what TXN_timestamps are in
348
-            date('Y-m-d H:i:s', time() - $time_to_leave_alone)
349
-        );
350
-        return $wpdb->query($query);
351
-    }
352
-
353
-
354
-    /**
355
-     * get_line_item_for_transaction_object
356
-     * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket
357
-     *
358
-     * @param int           $TXN_ID
359
-     * @param EE_Base_Class $object
360
-     * @return EE_Base_Class[]|EE_Line_Item[]
361
-     * @throws EE_Error
362
-     * @throws InvalidArgumentException
363
-     * @throws InvalidDataTypeException
364
-     * @throws InvalidInterfaceException
365
-     * @throws ReflectionException
366
-     */
367
-    public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object)
368
-    {
369
-        return $this->get_all(array(
370
-            array(
371
-                'TXN_ID'   => $TXN_ID,
372
-                'OBJ_type' => str_replace('EE_', '', get_class($object)),
373
-                'OBJ_ID'   => $object->ID(),
374
-            ),
375
-        ));
376
-    }
377
-
378
-
379
-    /**
380
-     * get_object_line_items_for_transaction
381
-     * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs
382
-     *
383
-     * @param int    $TXN_ID
384
-     * @param string $OBJ_type
385
-     * @param array  $OBJ_IDs
386
-     * @return EE_Base_Class[]|EE_Line_Item[]
387
-     * @throws EE_Error
388
-     */
389
-    public function get_object_line_items_for_transaction(
390
-        $TXN_ID,
391
-        $OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT,
392
-        $OBJ_IDs = array()
393
-    ) {
394
-        $query_params = array(
395
-            'OBJ_type' => $OBJ_type,
396
-            // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
397
-            'OBJ_ID'   => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs,
398
-        );
399
-        if ($TXN_ID) {
400
-            $query_params['TXN_ID'] = $TXN_ID;
401
-        }
402
-        return $this->get_all(array($query_params));
403
-    }
404
-
405
-
406
-    /**
407
-     * get_all_ticket_line_items_for_transaction
408
-     *
409
-     * @param EE_Transaction $transaction
410
-     * @return EE_Base_Class[]|EE_Line_Item[]
411
-     * @throws EE_Error
412
-     * @throws InvalidArgumentException
413
-     * @throws InvalidDataTypeException
414
-     * @throws InvalidInterfaceException
415
-     * @throws ReflectionException
416
-     */
417
-    public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction)
418
-    {
419
-        return $this->get_all(array(
420
-            array(
421
-                'TXN_ID'   => $transaction->ID(),
422
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
423
-            ),
424
-        ));
425
-    }
426
-
427
-
428
-    /**
429
-     * get_ticket_line_item_for_transaction
430
-     *
431
-     * @param int $TXN_ID
432
-     * @param int $TKT_ID
433
-     * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
434
-     * @throws EE_Error
435
-     * @throws InvalidArgumentException
436
-     * @throws InvalidDataTypeException
437
-     * @throws InvalidInterfaceException
438
-     */
439
-    public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID)
440
-    {
441
-        return $this->get_one(array(
442
-            array(
443
-                'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
444
-                'OBJ_ID'   => $TKT_ID,
445
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
446
-            ),
447
-        ));
448
-    }
449
-
450
-
451
-    /**
452
-     * get_existing_promotion_line_item
453
-     * searches the cart for existing line items for the specified promotion
454
-     *
455
-     * @since 1.0.0
456
-     * @param EE_Line_Item $parent_line_item
457
-     * @param EE_Promotion $promotion
458
-     * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
459
-     * @throws EE_Error
460
-     * @throws InvalidArgumentException
461
-     * @throws InvalidDataTypeException
462
-     * @throws InvalidInterfaceException
463
-     * @throws ReflectionException
464
-     */
465
-    public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion)
466
-    {
467
-        return $this->get_one(array(
468
-            array(
469
-                'TXN_ID'     => $parent_line_item->TXN_ID(),
470
-                'LIN_parent' => $parent_line_item->ID(),
471
-                'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
472
-                'OBJ_ID'     => $promotion->ID(),
473
-            ),
474
-        ));
475
-    }
476
-
477
-
478
-    /**
479
-     * get_all_promotion_line_items
480
-     * searches the cart for any and all existing promotion line items
481
-     *
482
-     * @since   1.0.0
483
-     * @param EE_Line_Item $parent_line_item
484
-     * @return EE_Base_Class[]|EE_Line_Item[]
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws InvalidDataTypeException
488
-     * @throws InvalidInterfaceException
489
-     * @throws ReflectionException
490
-     */
491
-    public function get_all_promotion_line_items(EE_Line_Item $parent_line_item)
492
-    {
493
-        return $this->get_all(array(
494
-            array(
495
-                'TXN_ID'     => $parent_line_item->TXN_ID(),
496
-                'LIN_parent' => $parent_line_item->ID(),
497
-                'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
498
-            ),
499
-        ));
500
-    }
501
-
502
-
503
-    /**
504
-     * Gets the registration's corresponding line item.
505
-     * Note: basically does NOT support having multiple line items for a single ticket,
506
-     * which would happen if some of the registrations had a price modifier while others didn't.
507
-     * In order to support that, we'd probably need a LIN_ID on registrations or something.
508
-     *
509
-     * @param EE_Registration $registration
510
-     * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL
511
-     * @throws EE_Error
512
-     */
513
-    public function get_line_item_for_registration(EE_Registration $registration)
514
-    {
515
-        return $this->get_one($this->line_item_for_registration_query_params($registration));
516
-    }
517
-
518
-
519
-    /**
520
-     * Gets the query params used to retrieve a specific line item for the given registration
521
-     *
522
-     * @param EE_Registration $registration
523
-     * @param array           $original_query_params any extra query params you'd like to be merged with
524
-     * @return array @see
525
-     *      https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
526
-     * @throws EE_Error
527
-     */
528
-    public function line_item_for_registration_query_params(
529
-        EE_Registration $registration,
530
-        $original_query_params = array()
531
-    ) {
532
-        return array_replace_recursive($original_query_params, array(
533
-            array(
534
-                'OBJ_ID'   => $registration->ticket_ID(),
535
-                'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
536
-                'TXN_ID'   => $registration->transaction_ID(),
537
-            ),
538
-        ));
539
-    }
540
-
541
-
542
-    /**
543
-     * @return EE_Base_Class[]|EE_Line_Item[]
544
-     * @throws InvalidInterfaceException
545
-     * @throws InvalidDataTypeException
546
-     * @throws EE_Error
547
-     * @throws InvalidArgumentException
548
-     */
549
-    public function get_total_line_items_with_no_transaction()
550
-    {
551
-        return $this->get_total_line_items_for_carts();
552
-    }
553
-
554
-
555
-    /**
556
-     * @return EE_Base_Class[]|EE_Line_Item[]
557
-     * @throws InvalidInterfaceException
558
-     * @throws InvalidDataTypeException
559
-     * @throws EE_Error
560
-     * @throws InvalidArgumentException
561
-     */
562
-    public function get_total_line_items_for_active_carts()
563
-    {
564
-        return $this->get_total_line_items_for_carts(false);
565
-    }
566
-
567
-
568
-    /**
569
-     * @return EE_Base_Class[]|EE_Line_Item[]
570
-     * @throws InvalidInterfaceException
571
-     * @throws InvalidDataTypeException
572
-     * @throws EE_Error
573
-     * @throws InvalidArgumentException
574
-     */
575
-    public function get_total_line_items_for_expired_carts()
576
-    {
577
-        return $this->get_total_line_items_for_carts(true);
578
-    }
579
-
580
-
581
-    /**
582
-     * Returns an array of grand total line items where the TXN_ID is 0.
583
-     * If $expired is set to true, then only line items for expired sessions will be returned.
584
-     * If $expired is set to false, then only line items for active sessions will be returned.
585
-     *
586
-     * @param null $expired
587
-     * @return EE_Base_Class[]|EE_Line_Item[]
588
-     * @throws EE_Error
589
-     * @throws InvalidArgumentException
590
-     * @throws InvalidDataTypeException
591
-     * @throws InvalidInterfaceException
592
-     */
593
-    private function get_total_line_items_for_carts($expired = null)
594
-    {
595
-        $where_params = array(
596
-            'TXN_ID'   => 0,
597
-            'LIN_type' => 'total',
598
-        );
599
-        if ($expired !== null) {
600
-            /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
601
-            $session_lifespan = LoaderFactory::getLoader()->getShared(
602
-                'EventEspresso\core\domain\values\session\SessionLifespan'
603
-            );
604
-            $where_params['LIN_timestamp'] = array(
605
-                $expired ? '<=' : '>',
606
-                $session_lifespan->expiration(),
607
-            );
608
-        }
609
-        return $this->get_all(array($where_params));
610
-    }
611
-
612
-
613
-    /**
614
-     * Returns an array of ticket total line items where the TXN_ID is 0
615
-     * AND the timestamp is older than the session lifespan.
616
-     *
617
-     * @param int $timestamp
618
-     * @return EE_Base_Class[]|EE_Line_Item[]
619
-     * @throws EE_Error
620
-     * @throws InvalidArgumentException
621
-     * @throws InvalidDataTypeException
622
-     * @throws InvalidInterfaceException
623
-     */
624
-    public function getTicketLineItemsForExpiredCarts($timestamp = 0)
625
-    {
626
-        if (! absint($timestamp)) {
627
-            /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
628
-            $session_lifespan = LoaderFactory::getLoader()->getShared(
629
-                'EventEspresso\core\domain\values\session\SessionLifespan'
630
-            );
631
-            $timestamp = $session_lifespan->expiration();
632
-        }
633
-        return $this->get_all(
634
-            array(
635
-                array(
636
-                    'TXN_ID'        => 0,
637
-                    'OBJ_type'      => EEM_Line_Item::OBJ_TYPE_TICKET,
638
-                    'LIN_timestamp' => array('<=', $timestamp),
639
-                ),
640
-            )
641
-        );
642
-    }
347
+			// use GMT time because that's what TXN_timestamps are in
348
+			date('Y-m-d H:i:s', time() - $time_to_leave_alone)
349
+		);
350
+		return $wpdb->query($query);
351
+	}
352
+
353
+
354
+	/**
355
+	 * get_line_item_for_transaction_object
356
+	 * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket
357
+	 *
358
+	 * @param int           $TXN_ID
359
+	 * @param EE_Base_Class $object
360
+	 * @return EE_Base_Class[]|EE_Line_Item[]
361
+	 * @throws EE_Error
362
+	 * @throws InvalidArgumentException
363
+	 * @throws InvalidDataTypeException
364
+	 * @throws InvalidInterfaceException
365
+	 * @throws ReflectionException
366
+	 */
367
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object)
368
+	{
369
+		return $this->get_all(array(
370
+			array(
371
+				'TXN_ID'   => $TXN_ID,
372
+				'OBJ_type' => str_replace('EE_', '', get_class($object)),
373
+				'OBJ_ID'   => $object->ID(),
374
+			),
375
+		));
376
+	}
377
+
378
+
379
+	/**
380
+	 * get_object_line_items_for_transaction
381
+	 * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs
382
+	 *
383
+	 * @param int    $TXN_ID
384
+	 * @param string $OBJ_type
385
+	 * @param array  $OBJ_IDs
386
+	 * @return EE_Base_Class[]|EE_Line_Item[]
387
+	 * @throws EE_Error
388
+	 */
389
+	public function get_object_line_items_for_transaction(
390
+		$TXN_ID,
391
+		$OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT,
392
+		$OBJ_IDs = array()
393
+	) {
394
+		$query_params = array(
395
+			'OBJ_type' => $OBJ_type,
396
+			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
397
+			'OBJ_ID'   => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs,
398
+		);
399
+		if ($TXN_ID) {
400
+			$query_params['TXN_ID'] = $TXN_ID;
401
+		}
402
+		return $this->get_all(array($query_params));
403
+	}
404
+
405
+
406
+	/**
407
+	 * get_all_ticket_line_items_for_transaction
408
+	 *
409
+	 * @param EE_Transaction $transaction
410
+	 * @return EE_Base_Class[]|EE_Line_Item[]
411
+	 * @throws EE_Error
412
+	 * @throws InvalidArgumentException
413
+	 * @throws InvalidDataTypeException
414
+	 * @throws InvalidInterfaceException
415
+	 * @throws ReflectionException
416
+	 */
417
+	public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction)
418
+	{
419
+		return $this->get_all(array(
420
+			array(
421
+				'TXN_ID'   => $transaction->ID(),
422
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
423
+			),
424
+		));
425
+	}
426
+
427
+
428
+	/**
429
+	 * get_ticket_line_item_for_transaction
430
+	 *
431
+	 * @param int $TXN_ID
432
+	 * @param int $TKT_ID
433
+	 * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
434
+	 * @throws EE_Error
435
+	 * @throws InvalidArgumentException
436
+	 * @throws InvalidDataTypeException
437
+	 * @throws InvalidInterfaceException
438
+	 */
439
+	public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID)
440
+	{
441
+		return $this->get_one(array(
442
+			array(
443
+				'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
444
+				'OBJ_ID'   => $TKT_ID,
445
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
446
+			),
447
+		));
448
+	}
449
+
450
+
451
+	/**
452
+	 * get_existing_promotion_line_item
453
+	 * searches the cart for existing line items for the specified promotion
454
+	 *
455
+	 * @since 1.0.0
456
+	 * @param EE_Line_Item $parent_line_item
457
+	 * @param EE_Promotion $promotion
458
+	 * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
459
+	 * @throws EE_Error
460
+	 * @throws InvalidArgumentException
461
+	 * @throws InvalidDataTypeException
462
+	 * @throws InvalidInterfaceException
463
+	 * @throws ReflectionException
464
+	 */
465
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion)
466
+	{
467
+		return $this->get_one(array(
468
+			array(
469
+				'TXN_ID'     => $parent_line_item->TXN_ID(),
470
+				'LIN_parent' => $parent_line_item->ID(),
471
+				'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
472
+				'OBJ_ID'     => $promotion->ID(),
473
+			),
474
+		));
475
+	}
476
+
477
+
478
+	/**
479
+	 * get_all_promotion_line_items
480
+	 * searches the cart for any and all existing promotion line items
481
+	 *
482
+	 * @since   1.0.0
483
+	 * @param EE_Line_Item $parent_line_item
484
+	 * @return EE_Base_Class[]|EE_Line_Item[]
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws InvalidDataTypeException
488
+	 * @throws InvalidInterfaceException
489
+	 * @throws ReflectionException
490
+	 */
491
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item)
492
+	{
493
+		return $this->get_all(array(
494
+			array(
495
+				'TXN_ID'     => $parent_line_item->TXN_ID(),
496
+				'LIN_parent' => $parent_line_item->ID(),
497
+				'OBJ_type'   => EEM_Line_Item::OBJ_TYPE_PROMOTION,
498
+			),
499
+		));
500
+	}
501
+
502
+
503
+	/**
504
+	 * Gets the registration's corresponding line item.
505
+	 * Note: basically does NOT support having multiple line items for a single ticket,
506
+	 * which would happen if some of the registrations had a price modifier while others didn't.
507
+	 * In order to support that, we'd probably need a LIN_ID on registrations or something.
508
+	 *
509
+	 * @param EE_Registration $registration
510
+	 * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL
511
+	 * @throws EE_Error
512
+	 */
513
+	public function get_line_item_for_registration(EE_Registration $registration)
514
+	{
515
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
516
+	}
517
+
518
+
519
+	/**
520
+	 * Gets the query params used to retrieve a specific line item for the given registration
521
+	 *
522
+	 * @param EE_Registration $registration
523
+	 * @param array           $original_query_params any extra query params you'd like to be merged with
524
+	 * @return array @see
525
+	 *      https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
526
+	 * @throws EE_Error
527
+	 */
528
+	public function line_item_for_registration_query_params(
529
+		EE_Registration $registration,
530
+		$original_query_params = array()
531
+	) {
532
+		return array_replace_recursive($original_query_params, array(
533
+			array(
534
+				'OBJ_ID'   => $registration->ticket_ID(),
535
+				'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET,
536
+				'TXN_ID'   => $registration->transaction_ID(),
537
+			),
538
+		));
539
+	}
540
+
541
+
542
+	/**
543
+	 * @return EE_Base_Class[]|EE_Line_Item[]
544
+	 * @throws InvalidInterfaceException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws EE_Error
547
+	 * @throws InvalidArgumentException
548
+	 */
549
+	public function get_total_line_items_with_no_transaction()
550
+	{
551
+		return $this->get_total_line_items_for_carts();
552
+	}
553
+
554
+
555
+	/**
556
+	 * @return EE_Base_Class[]|EE_Line_Item[]
557
+	 * @throws InvalidInterfaceException
558
+	 * @throws InvalidDataTypeException
559
+	 * @throws EE_Error
560
+	 * @throws InvalidArgumentException
561
+	 */
562
+	public function get_total_line_items_for_active_carts()
563
+	{
564
+		return $this->get_total_line_items_for_carts(false);
565
+	}
566
+
567
+
568
+	/**
569
+	 * @return EE_Base_Class[]|EE_Line_Item[]
570
+	 * @throws InvalidInterfaceException
571
+	 * @throws InvalidDataTypeException
572
+	 * @throws EE_Error
573
+	 * @throws InvalidArgumentException
574
+	 */
575
+	public function get_total_line_items_for_expired_carts()
576
+	{
577
+		return $this->get_total_line_items_for_carts(true);
578
+	}
579
+
580
+
581
+	/**
582
+	 * Returns an array of grand total line items where the TXN_ID is 0.
583
+	 * If $expired is set to true, then only line items for expired sessions will be returned.
584
+	 * If $expired is set to false, then only line items for active sessions will be returned.
585
+	 *
586
+	 * @param null $expired
587
+	 * @return EE_Base_Class[]|EE_Line_Item[]
588
+	 * @throws EE_Error
589
+	 * @throws InvalidArgumentException
590
+	 * @throws InvalidDataTypeException
591
+	 * @throws InvalidInterfaceException
592
+	 */
593
+	private function get_total_line_items_for_carts($expired = null)
594
+	{
595
+		$where_params = array(
596
+			'TXN_ID'   => 0,
597
+			'LIN_type' => 'total',
598
+		);
599
+		if ($expired !== null) {
600
+			/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
601
+			$session_lifespan = LoaderFactory::getLoader()->getShared(
602
+				'EventEspresso\core\domain\values\session\SessionLifespan'
603
+			);
604
+			$where_params['LIN_timestamp'] = array(
605
+				$expired ? '<=' : '>',
606
+				$session_lifespan->expiration(),
607
+			);
608
+		}
609
+		return $this->get_all(array($where_params));
610
+	}
611
+
612
+
613
+	/**
614
+	 * Returns an array of ticket total line items where the TXN_ID is 0
615
+	 * AND the timestamp is older than the session lifespan.
616
+	 *
617
+	 * @param int $timestamp
618
+	 * @return EE_Base_Class[]|EE_Line_Item[]
619
+	 * @throws EE_Error
620
+	 * @throws InvalidArgumentException
621
+	 * @throws InvalidDataTypeException
622
+	 * @throws InvalidInterfaceException
623
+	 */
624
+	public function getTicketLineItemsForExpiredCarts($timestamp = 0)
625
+	{
626
+		if (! absint($timestamp)) {
627
+			/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
628
+			$session_lifespan = LoaderFactory::getLoader()->getShared(
629
+				'EventEspresso\core\domain\values\session\SessionLifespan'
630
+			);
631
+			$timestamp = $session_lifespan->expiration();
632
+		}
633
+		return $this->get_all(
634
+			array(
635
+				array(
636
+					'TXN_ID'        => 0,
637
+					'OBJ_type'      => EEM_Line_Item::OBJ_TYPE_TICKET,
638
+					'LIN_timestamp' => array('<=', $timestamp),
639
+				),
640
+			)
641
+		);
642
+	}
643 643
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Admin_File_Uploader_Input.input.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,27 +14,27 @@
 block discarded – undo
14 14
 class EE_Admin_File_Uploader_Input extends EE_Form_Input_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param array $input_settings
19
-     * @throws InvalidArgumentException
20
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
21
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
22
-     */
23
-    public function __construct($input_settings = array())
24
-    {
25
-        $this->_set_display_strategy(new EE_Admin_File_Uploader_Display_Strategy());
26
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
27
-        $this->_add_validation_strategy(
28
-            LoaderFactory::getLoader()->getNew(
29
-                'EE_URL_Validation_Strategy',
30
-                array(
31
-                    isset($input_settings['validation_error_message'])
32
-                        ? $input_settings['validation_error_message']
33
-                        : null,
34
-                    false
35
-                )
36
-            )
37
-        );
38
-        parent::__construct($input_settings);
39
-    }
17
+	/**
18
+	 * @param array $input_settings
19
+	 * @throws InvalidArgumentException
20
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
21
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
22
+	 */
23
+	public function __construct($input_settings = array())
24
+	{
25
+		$this->_set_display_strategy(new EE_Admin_File_Uploader_Display_Strategy());
26
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
27
+		$this->_add_validation_strategy(
28
+			LoaderFactory::getLoader()->getNew(
29
+				'EE_URL_Validation_Strategy',
30
+				array(
31
+					isset($input_settings['validation_error_message'])
32
+						? $input_settings['validation_error_message']
33
+						: null,
34
+					false
35
+				)
36
+			)
37
+		);
38
+		parent::__construct($input_settings);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
support/templates/support_admin_details_additional_information.template.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <div class="padding">
2 2
     <p><?php
3
-        printf(
4
-            esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'),
5
-            '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">',
6
-            '</a>'
7
-        ); ?></p>
3
+		printf(
4
+			esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'),
5
+			'<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">',
6
+			'</a>'
7
+		); ?></p>
8 8
 </div>
9 9
\ No newline at end of file
Please login to merge, or discard this patch.