Completed
Branch FET-Wait-List (44abc2)
by
unknown
98:41 queued 88:15
created
messages/message_type/newsletter/EE_Newsletter_message_type.class.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -157,9 +157,9 @@
 block discarded – undo
157 157
 			$aee = array_merge( $this->_default_addressee_data, $aee );
158 158
 
159 159
 			//make sure txn is set
160
-            if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) {
161
-                $aee['txn'] = $aee['reg_obj']->transaction();
162
-            }
160
+			if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) {
161
+				$aee['txn'] = $aee['reg_obj']->transaction();
162
+			}
163 163
 
164 164
 			$addressee[] = new EE_Messages_Addressee( $aee );
165 165
 		}
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 
23 23
 	public function __construct() {
24 24
 		$this->name = 'newsletter';
25
-		$this->description = __( 'Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso' );
25
+		$this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso');
26 26
 		$this->label = array(
27
-			'singular' => __( 'batch', 'event_espresso' ),
28
-			'plural' => __( 'batches', 'event_espresso' )
27
+			'singular' => __('batch', 'event_espresso'),
28
+			'plural' => __('batches', 'event_espresso')
29 29
 			);
30 30
 		$this->_master_templates = array(
31 31
 			'email' => 'registration',
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 
52
-	protected function _get_data_for_context( $context, EE_Registration $registration, $id ) {
52
+	protected function _get_data_for_context($context, EE_Registration $registration, $id) {
53 53
 		//newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects.
54
-		return array( $registration );
54
+		return array($registration);
55 55
 	}
56 56
 
57 57
 
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 
65 65
 	protected function _set_contexts() {
66 66
 		$this->_context_label = array(
67
-			'label' => __( 'recipient', 'event_espresso' ),
68
-			'plural' => __( 'recipients', 'event_espresso' ),
69
-			'description' => __( 'Recipient\'s are who will receive the message.', 'event_espresso' )
67
+			'label' => __('recipient', 'event_espresso'),
68
+			'plural' => __('recipients', 'event_espresso'),
69
+			'description' => __('Recipient\'s are who will receive the message.', 'event_espresso')
70 70
 			);
71 71
 
72 72
 		$this->_contexts = array(
73 73
 			'attendee' => array(
74
-				'label' => __( 'Registrant', 'event_espresso' ),
75
-				'description' => __( 'This template goes to selected registrants.', 'event_espresso' )
74
+				'label' => __('Registrant', 'event_espresso'),
75
+				'description' => __('This template goes to selected registrants.', 'event_espresso')
76 76
 				)
77 77
 			);
78 78
 	}
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 			'newsletter',
99 99
 			);
100 100
 
101
-		foreach ( $this->_valid_shortcodes as $context => $shortcodes ) {
102
-			foreach ( $shortcodes as $key => $shortcode ) {
103
-				if ( ! in_array( $shortcode, $included_shortcodes ) ) {
104
-					unset( $this->_valid_shortcodes[ $context ][ $key ] );
101
+		foreach ($this->_valid_shortcodes as $context => $shortcodes) {
102
+			foreach ($shortcodes as $key => $shortcode) {
103
+				if ( ! in_array($shortcode, $included_shortcodes)) {
104
+					unset($this->_valid_shortcodes[$context][$key]);
105 105
 				}
106 106
 			}
107
-			$this->_valid_shortcodes[ $context ][] = 'newsletter';
107
+			$this->_valid_shortcodes[$context][] = 'newsletter';
108 108
 		}
109 109
 
110 110
 	}
@@ -118,50 +118,50 @@  discard block
 block discarded – undo
118 118
 		$addressee = array();
119 119
 
120 120
 		//looping through registrations
121
-		foreach ( $this->_data->registrations as $reg_id => $details ) {
121
+		foreach ($this->_data->registrations as $reg_id => $details) {
122 122
 			//set $attendee array to blank on each loop
123 123
 			$aee = array();
124 124
 
125 125
 			//need to get the attendee from this registration.
126
-			$attendee = isset( $details['att_obj'] ) && $details['att_obj'] instanceof EE_Attendee
126
+			$attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee
127 127
 				? $details['att_obj']
128 128
 				: null;
129 129
 
130
-			if ( ! $attendee instanceof EE_Attendee ) {
130
+			if ( ! $attendee instanceof EE_Attendee) {
131 131
 				continue;
132 132
 			}
133 133
 
134 134
 			//set $aee from attendee object
135 135
 			$aee['att_obj'] = $attendee;
136
-			$aee['reg_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['reg_objs'] )
137
-				? $this->_data->attendees[ $attendee->ID() ]['reg_objs']
136
+			$aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs'])
137
+				? $this->_data->attendees[$attendee->ID()]['reg_objs']
138 138
 				: array();
139 139
 			$aee['attendee_email'] = $attendee->email();
140
-			$aee['tkt_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] )
141
-				? $this->_data->attendees[ $attendee->ID() ]['tkt_objs']
140
+			$aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs'])
141
+				? $this->_data->attendees[$attendee->ID()]['tkt_objs']
142 142
 				: array();
143 143
 
144
-			if ( isset( $this->_data->attendees[ $attendee->ID() ]['evt_objs'] ) ) {
145
-				$aee['evt_objs'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs'];
146
-				$aee['events'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs'];
144
+			if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) {
145
+				$aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
146
+				$aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
147 147
 			} else {
148 148
 				$aee['evt_objs'] = $aee['events'] = array();
149 149
 			}
150 150
 
151
-			$aee['reg_obj'] = isset( $details['reg_obj'] )
151
+			$aee['reg_obj'] = isset($details['reg_obj'])
152 152
 				? $details['reg_obj']
153 153
 				: null;
154 154
 			$aee['attendees'] = $this->_data->attendees;
155 155
 
156 156
 			//merge in the primary attendee data
157
-			$aee = array_merge( $this->_default_addressee_data, $aee );
157
+			$aee = array_merge($this->_default_addressee_data, $aee);
158 158
 
159 159
 			//make sure txn is set
160 160
             if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) {
161 161
                 $aee['txn'] = $aee['reg_obj']->transaction();
162 162
             }
163 163
 
164
-			$addressee[] = new EE_Messages_Addressee( $aee );
164
+			$addressee[] = new EE_Messages_Addressee($aee);
165 165
 		}
166 166
 		return $addressee;
167 167
 	}
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks.class.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,62 +26,62 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    protected $_event;
29
+	protected $_event;
30 30
 
31 31
 
32
-    public function __construct(EE_Admin_Page $admin_page)
33
-    {
34
-        parent::__construct($admin_page);
35
-    }
32
+	public function __construct(EE_Admin_Page $admin_page)
33
+	{
34
+		parent::__construct($admin_page);
35
+	}
36 36
 
37 37
 
38
-    protected function _set_hooks_properties()
39
-    {
38
+	protected function _set_hooks_properties()
39
+	{
40 40
 
41
-        $this->_name      = 'registration_form';
42
-        $this->_metaboxes = array(
43
-            0 => array(
44
-                'page_route' => array('edit', 'create_new'),
45
-                'func'       => 'primary_questions',
46
-                'label'      => __('Questions for Primary Registrant', 'event_espresso'),
47
-                'priority'   => 'default',
48
-                'context'    => 'side',
49
-            ),
50
-        );
41
+		$this->_name      = 'registration_form';
42
+		$this->_metaboxes = array(
43
+			0 => array(
44
+				'page_route' => array('edit', 'create_new'),
45
+				'func'       => 'primary_questions',
46
+				'label'      => __('Questions for Primary Registrant', 'event_espresso'),
47
+				'priority'   => 'default',
48
+				'context'    => 'side',
49
+			),
50
+		);
51 51
 
52
-        //hook into the handler for saving question groups
53
-        add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
54
-            array($this, 'modify_callbacks'), 10);
52
+		//hook into the handler for saving question groups
53
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
54
+			array($this, 'modify_callbacks'), 10);
55 55
 
56
-        //hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already restricted by page)
57
-        add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2);
58
-    }
56
+		//hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already restricted by page)
57
+		add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2);
58
+	}
59 59
 
60 60
 
61
-    public function modify_callbacks($callbacks)
62
-    {
63
-        //now let's add the question group callback
64
-        $callbacks[] = array($this, 'primary_question_group_update');
65
-        return $callbacks;
66
-    }
61
+	public function modify_callbacks($callbacks)
62
+	{
63
+		//now let's add the question group callback
64
+		$callbacks[] = array($this, 'primary_question_group_update');
65
+		return $callbacks;
66
+	}
67 67
 
68 68
 
69
-    public function restore_revision($post_id, $revision_id)
70
-    {
71
-        $EVT_MDL  = EE_Registry::instance()->load_model('Event');
72
-        $post_evt = $EVT_MDL->get_one_by_ID($post_id);
73
-        //restore revision for primary questions
74
-        $post_evt->restore_revision($revision_id, array('Question_Group'),
75
-            array('Question_Group' => array('Event_Question_Group.EQG_primary' => 1)));
76
-        return $post_evt; //for any caffeinated functionality extending.
77
-    }
69
+	public function restore_revision($post_id, $revision_id)
70
+	{
71
+		$EVT_MDL  = EE_Registry::instance()->load_model('Event');
72
+		$post_evt = $EVT_MDL->get_one_by_ID($post_id);
73
+		//restore revision for primary questions
74
+		$post_evt->restore_revision($revision_id, array('Question_Group'),
75
+			array('Question_Group' => array('Event_Question_Group.EQG_primary' => 1)));
76
+		return $post_evt; //for any caffeinated functionality extending.
77
+	}
78 78
 
79 79
 
80
-    public function primary_questions($post_id, $post)
81
-    {
82
-        $this->_event = $this->_adminpage_obj->get_event_object();
83
-        $event_id     = $this->_event->ID();
84
-        ?>
80
+	public function primary_questions($post_id, $post)
81
+	{
82
+		$this->_event = $this->_adminpage_obj->get_event_object();
83
+		$event_id     = $this->_event->ID();
84
+		?>
85 85
         <div class="inside">
86 86
             <p><strong>
87 87
                     <?php _e('Question Groups', 'event_espresso'); ?>
@@ -91,86 +91,86 @@  discard block
 block discarded – undo
91 91
                     <?php _e('group of questions', 'event_espresso'); ?>
92 92
                 </a>
93 93
                 <?php _e('to your event. The personal information group is required for all events.',
94
-                    'event_espresso'); ?>
94
+					'event_espresso'); ?>
95 95
             </p>
96 96
             <?php
97 97
 
98
-            $qsg_where['QSG_deleted'] = false;
99
-            $query_params             = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'));
100
-            $QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
101
-            $EQGs                     = ! empty($event_id) ? $this->_event->get_many_related('Question_Group',
102
-                array(array('Event_Question_Group.EQG_primary' => 1))) : array();
103
-            $EQGids                   = array_keys($EQGs);
104
-
105
-            //EEH_Debug_Tools::printr( $QSGs, '$QSGs  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
106
-
107
-            if (! empty($QSGs)) {
108
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
109
-                foreach ($QSGs as $QSG) {
110
-
111
-                    $checked         = (in_array($QSG->ID(),
112
-                            $EQGids) || $QSG->get('QSG_system') == 1) ? ' checked="checked"' : '';
113
-                    $visibility      = $QSG->get('QSG_system') == 1 ? ' style="visibility:hidden"' : '';
114
-                    $edit_query_args = $this->_adminpage_obj->is_caf() ? array(
115
-                        'action' => 'edit_question_group',
116
-                        'QSG_ID' => $QSG->ID(),
117
-                    ) : array('action' => 'question_groups');
118
-                    $edit_link       = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args,
119
-                        EE_FORMS_ADMIN_URL);
120
-
121
-                    $html .= '
98
+			$qsg_where['QSG_deleted'] = false;
99
+			$query_params             = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'));
100
+			$QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
101
+			$EQGs                     = ! empty($event_id) ? $this->_event->get_many_related('Question_Group',
102
+				array(array('Event_Question_Group.EQG_primary' => 1))) : array();
103
+			$EQGids                   = array_keys($EQGs);
104
+
105
+			//EEH_Debug_Tools::printr( $QSGs, '$QSGs  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
106
+
107
+			if (! empty($QSGs)) {
108
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
109
+				foreach ($QSGs as $QSG) {
110
+
111
+					$checked         = (in_array($QSG->ID(),
112
+							$EQGids) || $QSG->get('QSG_system') == 1) ? ' checked="checked"' : '';
113
+					$visibility      = $QSG->get('QSG_system') == 1 ? ' style="visibility:hidden"' : '';
114
+					$edit_query_args = $this->_adminpage_obj->is_caf() ? array(
115
+						'action' => 'edit_question_group',
116
+						'QSG_ID' => $QSG->ID(),
117
+					) : array('action' => 'question_groups');
118
+					$edit_link       = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args,
119
+						EE_FORMS_ADMIN_URL);
120
+
121
+					$html .= '
122 122
 					<p id="event-question-group-' . $QSG->ID() . '">
123 123
 						<input value="' . $QSG->ID() . '" type="checkbox"' . $visibility . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' />
124 124
 						<a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
-                            $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
125
+							$QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
126 126
 					</p>';
127
-                }
128
-                $html .= count($QSGs) > 10 ? '</div>' : '';
129
-
130
-                echo $html;
131
-            } else {
132
-                echo __('There seems to be a problem with your questions. Please contact [email protected]',
133
-                    'event_espresso');
134
-            }
135
-            do_action('AHEE_event_editor_questions_notice');
136
-            ?>
127
+				}
128
+				$html .= count($QSGs) > 10 ? '</div>' : '';
129
+
130
+				echo $html;
131
+			} else {
132
+				echo __('There seems to be a problem with your questions. Please contact [email protected]',
133
+					'event_espresso');
134
+			}
135
+			do_action('AHEE_event_editor_questions_notice');
136
+			?>
137 137
         </div>
138 138
         <?php
139
-    }
139
+	}
140 140
 
141 141
 
142
-    public function primary_question_group_update($evtobj, $data)
143
-    {
144
-        $question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array();
145
-        $added_qgs       = array_keys($question_groups);
146
-        $success         = array();
142
+	public function primary_question_group_update($evtobj, $data)
143
+	{
144
+		$question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array();
145
+		$added_qgs       = array_keys($question_groups);
146
+		$success         = array();
147 147
 
148
-        //let's get all current question groups associated with this event.
149
-        $current_qgs = $evtobj->get_many_related('Question_Group',
150
-            array(array('Event_Question_Group.EQG_primary' => 1)));
151
-        $current_qgs = array_keys($current_qgs); //we just want the ids
148
+		//let's get all current question groups associated with this event.
149
+		$current_qgs = $evtobj->get_many_related('Question_Group',
150
+			array(array('Event_Question_Group.EQG_primary' => 1)));
151
+		$current_qgs = array_keys($current_qgs); //we just want the ids
152 152
 
153
-        //now let's get the groups selected in the editor and update (IF we have data)
154
-        if (! empty($question_groups)) {
155
-            foreach ($question_groups as $id => $val) {
156
-                //add to event
157
-                if ($val) {
158
-                    $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 1));
159
-                }
160
-                $success[] = ! empty($qg) ? 1 : 0;
161
-            }
162
-        }
153
+		//now let's get the groups selected in the editor and update (IF we have data)
154
+		if (! empty($question_groups)) {
155
+			foreach ($question_groups as $id => $val) {
156
+				//add to event
157
+				if ($val) {
158
+					$qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 1));
159
+				}
160
+				$success[] = ! empty($qg) ? 1 : 0;
161
+			}
162
+		}
163 163
 
164
-        //wait a minute... are there question groups missing in the saved groups that ARE with the current event?
165
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
164
+		//wait a minute... are there question groups missing in the saved groups that ARE with the current event?
165
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
166 166
 
167
-        foreach ($removed_qgs as $qgid) {
168
-            $qg        = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 1));
169
-            $success[] = ! empty($qg) ? 1 : 0;
170
-        }
167
+		foreach ($removed_qgs as $qgid) {
168
+			$qg        = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 1));
169
+			$success[] = ! empty($qg) ? 1 : 0;
170
+		}
171 171
 
172 172
 
173
-        return in_array(0, $success) ? false : true;
173
+		return in_array(0, $success) ? false : true;
174 174
 
175
-    }
175
+	}
176 176
 } //end espresso_events_Registration_Form_Hooks
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
             //EEH_Debug_Tools::printr( $QSGs, '$QSGs  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
106 106
 
107
-            if (! empty($QSGs)) {
107
+            if ( ! empty($QSGs)) {
108 108
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
109 109
                 foreach ($QSGs as $QSG) {
110 110
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
                         'action' => 'edit_question_group',
116 116
                         'QSG_ID' => $QSG->ID(),
117 117
                     ) : array('action' => 'question_groups');
118
-                    $edit_link       = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args,
118
+                    $edit_link = $this->_adminpage_obj->add_query_args_and_nonce($edit_query_args,
119 119
                         EE_FORMS_ADMIN_URL);
120 120
 
121 121
                     $html .= '
122
-					<p id="event-question-group-' . $QSG->ID() . '">
123
-						<input value="' . $QSG->ID() . '" type="checkbox"' . $visibility . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' />
124
-						<a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
-                            $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
122
+					<p id="event-question-group-' . $QSG->ID().'">
123
+						<input value="' . $QSG->ID().'" type="checkbox"'.$visibility.' name="question_groups['.$QSG->ID().']"'.$checked.' />
124
+						<a href="' . $edit_link.'" title="'.sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
+                            $QSG->get('QSG_name')).'" target="_blank">'.$QSG->get('QSG_name').'</a>
126 126
 					</p>';
127 127
                 }
128 128
                 $html .= count($QSGs) > 10 ? '</div>' : '';
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
     public function primary_question_group_update($evtobj, $data)
143 143
     {
144
-        $question_groups = ! empty($data['question_groups']) ? (array)$data['question_groups'] : array();
144
+        $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array();
145 145
         $added_qgs       = array_keys($question_groups);
146 146
         $success         = array();
147 147
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $current_qgs = array_keys($current_qgs); //we just want the ids
152 152
 
153 153
         //now let's get the groups selected in the editor and update (IF we have data)
154
-        if (! empty($question_groups)) {
154
+        if ( ! empty($question_groups)) {
155 155
             foreach ($question_groups as $id => $val) {
156 156
                 //add to event
157 157
                 if ($val) {
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks_Extend.class.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,69 +26,69 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    public function __construct(EE_Admin_Page $admin_page)
30
-    {
31
-        parent::__construct($admin_page);
32
-    }
33
-
34
-
35
-    /**
36
-     * extending the properties set in espresso_events_Registration_From_Hooks
37
-     *
38
-     * @access protected
39
-     * @return void
40
-     */
41
-    protected function _extend_properties()
42
-    {
43
-        $this->_metaboxes      = array_merge(
44
-            $this->_metaboxes,
45
-            array(
46
-                1 => array(
47
-                    'page_route' => array('create_new', 'edit'),
48
-                    'func'       => 'additional_questions',
49
-                    'label'      => __('Questions for Additional Registrants', 'event_espresso'),
50
-                    'priority'   => 'default',
51
-                    'context'    => 'side',
52
-                ),
53
-            )
54
-        );
55
-        $this->_scripts_styles = array(
56
-            'registers' => array(
57
-                'extended-event-editor' => array(
58
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
59
-                    'depends' => array('jquery'),
60
-                ),
61
-            ),
62
-            'enqueues'  => array(
63
-                'extended-event-editor' => array('edit', 'create_new'),
64
-            ),
65
-        );
66
-    }
67
-
68
-
69
-    public function modify_callbacks($callbacks)
70
-    {
71
-        $callbacks   = parent::modify_callbacks($callbacks);
72
-        $callbacks[] = array($this, 'additional_question_group_update');
73
-        return $callbacks;
74
-    }
75
-
76
-
77
-    public function restore_revision($post_id, $revision_id)
78
-    {
79
-        $post_evt = parent::restore_revision($post_id, $revision_id);
80
-
81
-        //restore revision for additional questions
82
-        $post_evt->restore_revision($revision_id, array('Question_Group'),
83
-            array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0)));
84
-    }
85
-
86
-
87
-    public function additional_questions($post_id, $post)
88
-    {
89
-        $this->_event = $this->_adminpage_obj->get_event_object();
90
-        $event_id     = $this->_event->ID();
91
-        ?>
29
+	public function __construct(EE_Admin_Page $admin_page)
30
+	{
31
+		parent::__construct($admin_page);
32
+	}
33
+
34
+
35
+	/**
36
+	 * extending the properties set in espresso_events_Registration_From_Hooks
37
+	 *
38
+	 * @access protected
39
+	 * @return void
40
+	 */
41
+	protected function _extend_properties()
42
+	{
43
+		$this->_metaboxes      = array_merge(
44
+			$this->_metaboxes,
45
+			array(
46
+				1 => array(
47
+					'page_route' => array('create_new', 'edit'),
48
+					'func'       => 'additional_questions',
49
+					'label'      => __('Questions for Additional Registrants', 'event_espresso'),
50
+					'priority'   => 'default',
51
+					'context'    => 'side',
52
+				),
53
+			)
54
+		);
55
+		$this->_scripts_styles = array(
56
+			'registers' => array(
57
+				'extended-event-editor' => array(
58
+					'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
59
+					'depends' => array('jquery'),
60
+				),
61
+			),
62
+			'enqueues'  => array(
63
+				'extended-event-editor' => array('edit', 'create_new'),
64
+			),
65
+		);
66
+	}
67
+
68
+
69
+	public function modify_callbacks($callbacks)
70
+	{
71
+		$callbacks   = parent::modify_callbacks($callbacks);
72
+		$callbacks[] = array($this, 'additional_question_group_update');
73
+		return $callbacks;
74
+	}
75
+
76
+
77
+	public function restore_revision($post_id, $revision_id)
78
+	{
79
+		$post_evt = parent::restore_revision($post_id, $revision_id);
80
+
81
+		//restore revision for additional questions
82
+		$post_evt->restore_revision($revision_id, array('Question_Group'),
83
+			array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0)));
84
+	}
85
+
86
+
87
+	public function additional_questions($post_id, $post)
88
+	{
89
+		$this->_event = $this->_adminpage_obj->get_event_object();
90
+		$event_id     = $this->_event->ID();
91
+		?>
92 92
         <div class="inside">
93 93
             <p><strong>
94 94
                     <?php _e('Question Groups', 'event_espresso'); ?>
@@ -101,83 +101,83 @@  discard block
 block discarded – undo
101 101
             </p>
102 102
             <?php
103 103
 
104
-            $qsg_where['QSG_deleted'] = false;
105
-            $query_params             = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'));
106
-            $QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
107
-            $EQGs                     = ! empty($event_id) ? $this->_event->get_many_related('Question_Group',
108
-                array(array('Event_Question_Group.EQG_primary' => 0))) : array();
109
-            $EQGids                   = array_keys($EQGs);
104
+			$qsg_where['QSG_deleted'] = false;
105
+			$query_params             = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'));
106
+			$QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
107
+			$EQGs                     = ! empty($event_id) ? $this->_event->get_many_related('Question_Group',
108
+				array(array('Event_Question_Group.EQG_primary' => 0))) : array();
109
+			$EQGids                   = array_keys($EQGs);
110 110
 
111
-            if (! empty($QSGs)) {
112
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
113
-                foreach ($QSGs as $QSG) {
111
+			if (! empty($QSGs)) {
112
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
113
+				foreach ($QSGs as $QSG) {
114 114
 
115
-                    $checked   = in_array($QSG->ID(), $EQGids) ? ' checked="checked" ' : '';
116
-                    $edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array(
117
-                        'action' => 'edit_question_group',
118
-                        'QSG_ID' => $QSG->ID(),
119
-                    ), EE_FORMS_ADMIN_URL);
115
+					$checked   = in_array($QSG->ID(), $EQGids) ? ' checked="checked" ' : '';
116
+					$edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array(
117
+						'action' => 'edit_question_group',
118
+						'QSG_ID' => $QSG->ID(),
119
+					), EE_FORMS_ADMIN_URL);
120 120
 
121
-                    $html .= '
121
+					$html .= '
122 122
 					<p id="event-question-group-' . $QSG->ID() . '">
123 123
 						<input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
124 124
 						<a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
-                            $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
125
+							$QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
126 126
 					</p>';
127
-                    if ($QSG->ID() === 2) {
128
-                        $html .= '
127
+					if ($QSG->ID() === 2) {
128
+						$html .= '
129 129
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">
130 130
 					    ' . esc_html__('The Personal Information question group is required whenever the Address Information question group is activated.',
131
-                                'event_espresso') . '
131
+								'event_espresso') . '
132 132
 					</p>';
133
-                    }
134
-                }
135
-                $html .= count($QSGs) > 10 ? '</div>' : '';
136
-
137
-                echo $html;
138
-
139
-            } else {
140
-                echo __('There seems to be a problem with your questions. Please contact [email protected]',
141
-                    'event_espresso');
142
-            }
143
-            do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
144
-            ?>
133
+					}
134
+				}
135
+				$html .= count($QSGs) > 10 ? '</div>' : '';
136
+
137
+				echo $html;
138
+
139
+			} else {
140
+				echo __('There seems to be a problem with your questions. Please contact [email protected]',
141
+					'event_espresso');
142
+			}
143
+			do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
144
+			?>
145 145
         </div>
146 146
         <?php
147
-    }
148
-
149
-
150
-    public function additional_question_group_update($evtobj, $data)
151
-    {
152
-        $question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array();
153
-        $added_qgs       = array_keys($question_groups);
154
-        $success         = array();
155
-
156
-        //let's get all current question groups associated with this event.
157
-        $current_qgs = $evtobj->get_many_related('Question_Group',
158
-            array(array('Event_Question_Group.EQG_primary' => 0)));
159
-        $current_qgs = array_keys($current_qgs); //we just want the ids
160
-
161
-        //now let's get the groups selected in the editor and update (IF we have data)
162
-        if (! empty($question_groups)) {
163
-            foreach ($question_groups as $id => $val) {
164
-                //add to event
165
-                if ($val) {
166
-                    $qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 0));
167
-                }
168
-                $success[] = ! empty($qg) ? 1 : 0;
169
-            }
170
-        }
171
-
172
-        //wait a minute... are there question groups missing in the saved groups that ARE with the current event?
173
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
174
-
175
-        foreach ($removed_qgs as $qgid) {
176
-            $qg        = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 0));
177
-            $success[] = ! empty($qg) ? 1 : 0;
178
-        }
179
-
180
-
181
-        return in_array(0, $success) ? false : true;
182
-    }
147
+	}
148
+
149
+
150
+	public function additional_question_group_update($evtobj, $data)
151
+	{
152
+		$question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array();
153
+		$added_qgs       = array_keys($question_groups);
154
+		$success         = array();
155
+
156
+		//let's get all current question groups associated with this event.
157
+		$current_qgs = $evtobj->get_many_related('Question_Group',
158
+			array(array('Event_Question_Group.EQG_primary' => 0)));
159
+		$current_qgs = array_keys($current_qgs); //we just want the ids
160
+
161
+		//now let's get the groups selected in the editor and update (IF we have data)
162
+		if (! empty($question_groups)) {
163
+			foreach ($question_groups as $id => $val) {
164
+				//add to event
165
+				if ($val) {
166
+					$qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 0));
167
+				}
168
+				$success[] = ! empty($qg) ? 1 : 0;
169
+			}
170
+		}
171
+
172
+		//wait a minute... are there question groups missing in the saved groups that ARE with the current event?
173
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
174
+
175
+		foreach ($removed_qgs as $qgid) {
176
+			$qg        = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 0));
177
+			$success[] = ! empty($qg) ? 1 : 0;
178
+		}
179
+
180
+
181
+		return in_array(0, $success) ? false : true;
182
+	}
183 183
 } //end class espresso_events_Registration_Form_Hooks_Extend
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     protected function _extend_properties()
42 42
     {
43
-        $this->_metaboxes      = array_merge(
43
+        $this->_metaboxes = array_merge(
44 44
             $this->_metaboxes,
45 45
             array(
46 46
                 1 => array(
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $this->_scripts_styles = array(
56 56
             'registers' => array(
57 57
                 'extended-event-editor' => array(
58
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
58
+                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/event-editor-question-groups.js',
59 59
                     'depends' => array('jquery'),
60 60
                 ),
61 61
             ),
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 array(array('Event_Question_Group.EQG_primary' => 0))) : array();
109 109
             $EQGids                   = array_keys($EQGs);
110 110
 
111
-            if (! empty($QSGs)) {
111
+            if ( ! empty($QSGs)) {
112 112
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
113 113
                 foreach ($QSGs as $QSG) {
114 114
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
                     ), EE_FORMS_ADMIN_URL);
120 120
 
121 121
                     $html .= '
122
-					<p id="event-question-group-' . $QSG->ID() . '">
123
-						<input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
124
-						<a href="' . $edit_link . '" title="' . sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
-                            $QSG->get('QSG_name')) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
122
+					<p id="event-question-group-' . $QSG->ID().'">
123
+						<input value="' . $QSG->ID().'" type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' />
124
+						<a href="' . $edit_link.'" title="'.sprintf(esc_attr__('Edit %s Group', 'event_espresso'),
125
+                            $QSG->get('QSG_name')).'" target="_blank">'.$QSG->get('QSG_name').'</a>
126 126
 					</p>';
127 127
                     if ($QSG->ID() === 2) {
128 128
                         $html .= '
129 129
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">
130 130
 					    ' . esc_html__('The Personal Information question group is required whenever the Address Information question group is activated.',
131
-                                'event_espresso') . '
131
+                                'event_espresso').'
132 132
 					</p>';
133 133
                     }
134 134
                 }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function additional_question_group_update($evtobj, $data)
151 151
     {
152
-        $question_groups = ! empty($data['add_attendee_question_groups']) ? (array)$data['add_attendee_question_groups'] : array();
152
+        $question_groups = ! empty($data['add_attendee_question_groups']) ? (array) $data['add_attendee_question_groups'] : array();
153 153
         $added_qgs       = array_keys($question_groups);
154 154
         $success         = array();
155 155
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $current_qgs = array_keys($current_qgs); //we just want the ids
160 160
 
161 161
         //now let's get the groups selected in the editor and update (IF we have data)
162
-        if (! empty($question_groups)) {
162
+        if ( ! empty($question_groups)) {
163 163
             foreach ($question_groups as $id => $val) {
164 164
                 //add to event
165 165
                 if ($val) {
Please login to merge, or discard this patch.
modules/ticket_selector/DisplayTicketSelector.php 1 patch
Indentation   +715 added lines, -715 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use WP_Post;
18 18
 
19 19
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-    exit( 'No direct script access allowed' );
20
+	exit( 'No direct script access allowed' );
21 21
 }
22 22
 
23 23
 
@@ -34,723 +34,723 @@  discard block
 block discarded – undo
34 34
 class DisplayTicketSelector
35 35
 {
36 36
 
37
-    /**
38
-     * event that ticket selector is being generated for
39
-     *
40
-     * @access protected
41
-     * @var EE_Event $event
42
-     */
43
-    protected $event;
44
-
45
-    /**
46
-     * Used to flag when the ticket selector is being called from an external iframe.
47
-     *
48
-     * @var bool $iframe
49
-     */
50
-    protected $iframe = false;
51
-
52
-    /**
53
-     * max attendees that can register for event at one time
54
-     *
55
-     * @var int $max_attendees
56
-     */
57
-    private $max_attendees = EE_INF;
58
-
59
-    /**
60
-     *@var string $date_format
61
-     */
62
-    private $date_format;
63
-
64
-    /**
65
-     *@var string $time_format
66
-     */
67
-    private $time_format;
68
-
69
-    /**
70
-     *@var boolean $display_full_ui
71
-     */
72
-    private $display_full_ui;
73
-
74
-
75
-
76
-    /**
77
-     * DisplayTicketSelector constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        $this->date_format = apply_filters(
82
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
83
-            get_option('date_format')
84
-        );
85
-        $this->time_format = apply_filters(
86
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
87
-            get_option('time_format')
88
-        );
89
-    }
90
-
91
-
92
-    /**
93
-     * @return bool
94
-     */
95
-    public function isIframe()
96
-    {
97
-        return $this->iframe;
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @param boolean $iframe
104
-     */
105
-    public function setIframe( $iframe = true )
106
-    {
107
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
108
-    }
109
-
110
-
111
-    /**
112
-     * finds and sets the \EE_Event object for use throughout class
113
-     *
114
-     * @param mixed $event
115
-     * @return bool
116
-     * @throws EE_Error
117
-     */
118
-    protected function setEvent( $event = null )
119
-    {
120
-        if ( $event === null ) {
121
-            global $post;
122
-            $event = $post;
123
-        }
124
-        if ( $event instanceof EE_Event ) {
125
-            $this->event = $event;
126
-        } elseif ( $event instanceof WP_Post ) {
127
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
128
-                $this->event = $event->EE_Event;
129
-            } elseif ( $event->post_type === 'espresso_events' ) {
130
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
131
-                $this->event = $event->EE_Event;
132
-            }
133
-        } else {
134
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
135
-            $dev_msg = $user_msg . __(
136
-                    'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
137
-                    'event_espresso'
138
-                );
139
-            EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
140
-            return false;
141
-        }
142
-        return true;
143
-    }
144
-
145
-
146
-
147
-    /**
148
-     * @return int
149
-     */
150
-    public function getMaxAttendees()
151
-    {
152
-        return $this->max_attendees;
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * @param int $max_attendees
159
-     */
160
-    public function setMaxAttendees($max_attendees)
161
-    {
162
-        $this->max_attendees = absint(
163
-            apply_filters(
164
-                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
165
-                $max_attendees
166
-            )
167
-        );
168
-    }
169
-
170
-
171
-
172
-    /**
173
-     * Returns whether or not the full ticket selector should be shown or not.
174
-     * Currently, it displays on the frontend (including ajax requests) but not the backend
175
-     * @return bool
176
-     */
177
-    private function display_full_ui()
178
-    {
179
-        if ($this->display_full_ui === null) {
180
-            $this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX);
181
-        }
182
-        return $this->display_full_ui;
183
-    }
184
-
185
-
186
-    /**
187
-     * creates buttons for selecting number of attendees for an event
188
-     *
189
-     * @param WP_Post|int $event
190
-     * @param bool         $view_details
191
-     * @return string
192
-     * @throws EE_Error
193
-     */
194
-    public function display( $event = null, $view_details = false )
195
-    {
196
-        // reset filter for displaying submit button
197
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
198
-        // poke and prod incoming event till it tells us what it is
199
-        if ( ! $this->setEvent( $event ) ) {
200
-            return false;
201
-        }
202
-        // begin gathering template arguments by getting event status
203
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
204
-        if (
205
-            $this->activeEventAndShowTicketSelector(
206
-                $event,
207
-                $template_args['event_status'],
208
-                $view_details
209
-            )
210
-        ) {
211
-            return ! is_single() ? $this->displayViewDetailsButton() : '';
212
-        }
213
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
214
-        $this->setMaxAttendees($this->event->additional_limit());
215
-        if ($this->getMaxAttendees() < 1) {
216
-            return $this->ticketSalesClosedMessage();
217
-        }
218
-        // is the event expired ?
219
-        $template_args['event_is_expired'] = $this->event->is_expired();
220
-        if ( $template_args[ 'event_is_expired' ] ) {
221
-            return $this->expiredEventMessage();
222
-        }
223
-        // get all tickets for this event ordered by the datetime
224
-        $tickets = $this->getTickets();
225
-        if (count($tickets) < 1) {
226
-            return $this->noTicketAvailableMessage();
227
-        }
228
-        if (EED_Events_Archive::is_iframe()){
229
-            $this->setIframe();
230
-        }
231
-        // redirecting to another site for registration ??
232
-        $external_url = (string) $this->event->external_url();
233
-        // if redirecting to another site for registration, then we don't load the TS
234
-        $ticket_selector = $external_url
235
-            ? $this->externalEventRegistration()
236
-            : $this->loadTicketSelector($tickets,$template_args);
237
-        // now set up the form (but not for the admin)
238
-        $ticket_selector = $this->display_full_ui()
239
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
240
-            : $ticket_selector;
241
-        // submit button and form close tag
242
-        $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
243
-        return $ticket_selector;
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * displayTicketSelector
250
-     * examines the event properties and determines whether a Ticket Selector should be displayed
251
-     *
252
-     * @param WP_Post|int $event
253
-     * @param string       $_event_active_status
254
-     * @param bool         $view_details
255
-     * @return bool
256
-     * @throws EE_Error
257
-     */
258
-    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
259
-    {
260
-        $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
261
-        return $this->display_full_ui()
262
-               && (
263
-                   ! $this->event->display_ticket_selector()
264
-                   || $view_details
265
-                   || post_password_required($event_post)
266
-                   || (
267
-                       $_event_active_status !== EE_Datetime::active
268
-                       && $_event_active_status !== EE_Datetime::upcoming
269
-                       && $_event_active_status !== EE_Datetime::sold_out
270
-                       && ! (
271
-                           $_event_active_status === EE_Datetime::inactive
272
-                           && is_user_logged_in()
273
-                       )
274
-                   )
275
-               );
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * noTicketAvailableMessage
282
-     * notice displayed if event is expired
283
-     *
284
-     * @return string
285
-     * @throws EE_Error
286
-     */
287
-    protected function expiredEventMessage()
288
-    {
289
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
290
-            'We\'re sorry, but all tickets sales have ended because the event is expired.',
291
-            'event_espresso'
292
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
293
-    }
294
-
295
-
296
-
297
-    /**
298
-     * noTicketAvailableMessage
299
-     * notice displayed if event has no more tickets available
300
-     *
301
-     * @return string
302
-     * @throws EE_Error
303
-     */
304
-    protected function noTicketAvailableMessage()
305
-    {
306
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
307
-        if (current_user_can('edit_post', $this->event->ID())) {
308
-            $no_ticket_available_msg .= sprintf(
309
-                esc_html__(
310
-                    '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
311
-                    'event_espresso'
312
-                ),
313
-                '<div class="ee-attention" style="text-align: left;"><b>',
314
-                '</b><br />',
315
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
316
-                '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
317
-            );
318
-        }
319
-        return '
37
+	/**
38
+	 * event that ticket selector is being generated for
39
+	 *
40
+	 * @access protected
41
+	 * @var EE_Event $event
42
+	 */
43
+	protected $event;
44
+
45
+	/**
46
+	 * Used to flag when the ticket selector is being called from an external iframe.
47
+	 *
48
+	 * @var bool $iframe
49
+	 */
50
+	protected $iframe = false;
51
+
52
+	/**
53
+	 * max attendees that can register for event at one time
54
+	 *
55
+	 * @var int $max_attendees
56
+	 */
57
+	private $max_attendees = EE_INF;
58
+
59
+	/**
60
+	 *@var string $date_format
61
+	 */
62
+	private $date_format;
63
+
64
+	/**
65
+	 *@var string $time_format
66
+	 */
67
+	private $time_format;
68
+
69
+	/**
70
+	 *@var boolean $display_full_ui
71
+	 */
72
+	private $display_full_ui;
73
+
74
+
75
+
76
+	/**
77
+	 * DisplayTicketSelector constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		$this->date_format = apply_filters(
82
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
83
+			get_option('date_format')
84
+		);
85
+		$this->time_format = apply_filters(
86
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
87
+			get_option('time_format')
88
+		);
89
+	}
90
+
91
+
92
+	/**
93
+	 * @return bool
94
+	 */
95
+	public function isIframe()
96
+	{
97
+		return $this->iframe;
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @param boolean $iframe
104
+	 */
105
+	public function setIframe( $iframe = true )
106
+	{
107
+		$this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
108
+	}
109
+
110
+
111
+	/**
112
+	 * finds and sets the \EE_Event object for use throughout class
113
+	 *
114
+	 * @param mixed $event
115
+	 * @return bool
116
+	 * @throws EE_Error
117
+	 */
118
+	protected function setEvent( $event = null )
119
+	{
120
+		if ( $event === null ) {
121
+			global $post;
122
+			$event = $post;
123
+		}
124
+		if ( $event instanceof EE_Event ) {
125
+			$this->event = $event;
126
+		} elseif ( $event instanceof WP_Post ) {
127
+			if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
128
+				$this->event = $event->EE_Event;
129
+			} elseif ( $event->post_type === 'espresso_events' ) {
130
+				$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
131
+				$this->event = $event->EE_Event;
132
+			}
133
+		} else {
134
+			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
135
+			$dev_msg = $user_msg . __(
136
+					'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
137
+					'event_espresso'
138
+				);
139
+			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
140
+			return false;
141
+		}
142
+		return true;
143
+	}
144
+
145
+
146
+
147
+	/**
148
+	 * @return int
149
+	 */
150
+	public function getMaxAttendees()
151
+	{
152
+		return $this->max_attendees;
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * @param int $max_attendees
159
+	 */
160
+	public function setMaxAttendees($max_attendees)
161
+	{
162
+		$this->max_attendees = absint(
163
+			apply_filters(
164
+				'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
165
+				$max_attendees
166
+			)
167
+		);
168
+	}
169
+
170
+
171
+
172
+	/**
173
+	 * Returns whether or not the full ticket selector should be shown or not.
174
+	 * Currently, it displays on the frontend (including ajax requests) but not the backend
175
+	 * @return bool
176
+	 */
177
+	private function display_full_ui()
178
+	{
179
+		if ($this->display_full_ui === null) {
180
+			$this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX);
181
+		}
182
+		return $this->display_full_ui;
183
+	}
184
+
185
+
186
+	/**
187
+	 * creates buttons for selecting number of attendees for an event
188
+	 *
189
+	 * @param WP_Post|int $event
190
+	 * @param bool         $view_details
191
+	 * @return string
192
+	 * @throws EE_Error
193
+	 */
194
+	public function display( $event = null, $view_details = false )
195
+	{
196
+		// reset filter for displaying submit button
197
+		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
198
+		// poke and prod incoming event till it tells us what it is
199
+		if ( ! $this->setEvent( $event ) ) {
200
+			return false;
201
+		}
202
+		// begin gathering template arguments by getting event status
203
+		$template_args = array( 'event_status' => $this->event->get_active_status() );
204
+		if (
205
+			$this->activeEventAndShowTicketSelector(
206
+				$event,
207
+				$template_args['event_status'],
208
+				$view_details
209
+			)
210
+		) {
211
+			return ! is_single() ? $this->displayViewDetailsButton() : '';
212
+		}
213
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
214
+		$this->setMaxAttendees($this->event->additional_limit());
215
+		if ($this->getMaxAttendees() < 1) {
216
+			return $this->ticketSalesClosedMessage();
217
+		}
218
+		// is the event expired ?
219
+		$template_args['event_is_expired'] = $this->event->is_expired();
220
+		if ( $template_args[ 'event_is_expired' ] ) {
221
+			return $this->expiredEventMessage();
222
+		}
223
+		// get all tickets for this event ordered by the datetime
224
+		$tickets = $this->getTickets();
225
+		if (count($tickets) < 1) {
226
+			return $this->noTicketAvailableMessage();
227
+		}
228
+		if (EED_Events_Archive::is_iframe()){
229
+			$this->setIframe();
230
+		}
231
+		// redirecting to another site for registration ??
232
+		$external_url = (string) $this->event->external_url();
233
+		// if redirecting to another site for registration, then we don't load the TS
234
+		$ticket_selector = $external_url
235
+			? $this->externalEventRegistration()
236
+			: $this->loadTicketSelector($tickets,$template_args);
237
+		// now set up the form (but not for the admin)
238
+		$ticket_selector = $this->display_full_ui()
239
+			? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
240
+			: $ticket_selector;
241
+		// submit button and form close tag
242
+		$ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
243
+		return $ticket_selector;
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * displayTicketSelector
250
+	 * examines the event properties and determines whether a Ticket Selector should be displayed
251
+	 *
252
+	 * @param WP_Post|int $event
253
+	 * @param string       $_event_active_status
254
+	 * @param bool         $view_details
255
+	 * @return bool
256
+	 * @throws EE_Error
257
+	 */
258
+	protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
259
+	{
260
+		$event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
261
+		return $this->display_full_ui()
262
+			   && (
263
+				   ! $this->event->display_ticket_selector()
264
+				   || $view_details
265
+				   || post_password_required($event_post)
266
+				   || (
267
+					   $_event_active_status !== EE_Datetime::active
268
+					   && $_event_active_status !== EE_Datetime::upcoming
269
+					   && $_event_active_status !== EE_Datetime::sold_out
270
+					   && ! (
271
+						   $_event_active_status === EE_Datetime::inactive
272
+						   && is_user_logged_in()
273
+					   )
274
+				   )
275
+			   );
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * noTicketAvailableMessage
282
+	 * notice displayed if event is expired
283
+	 *
284
+	 * @return string
285
+	 * @throws EE_Error
286
+	 */
287
+	protected function expiredEventMessage()
288
+	{
289
+		return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
290
+			'We\'re sorry, but all tickets sales have ended because the event is expired.',
291
+			'event_espresso'
292
+		) . '</span></div><!-- .ee-event-expired-notice -->';
293
+	}
294
+
295
+
296
+
297
+	/**
298
+	 * noTicketAvailableMessage
299
+	 * notice displayed if event has no more tickets available
300
+	 *
301
+	 * @return string
302
+	 * @throws EE_Error
303
+	 */
304
+	protected function noTicketAvailableMessage()
305
+	{
306
+		$no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
307
+		if (current_user_can('edit_post', $this->event->ID())) {
308
+			$no_ticket_available_msg .= sprintf(
309
+				esc_html__(
310
+					'%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
311
+					'event_espresso'
312
+				),
313
+				'<div class="ee-attention" style="text-align: left;"><b>',
314
+				'</b><br />',
315
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
316
+				'</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
317
+			);
318
+		}
319
+		return '
320 320
             <div class="ee-event-expired-notice">
321 321
                 <span class="important-notice">' . $no_ticket_available_msg . '</span>
322 322
             </div><!-- .ee-event-expired-notice -->';
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * ticketSalesClosed
329
-     * notice displayed if event ticket sales are turned off
330
-     *
331
-     * @return string
332
-     * @throws EE_Error
333
-     */
334
-    protected function ticketSalesClosedMessage()
335
-    {
336
-        $sales_closed_msg = esc_html__(
337
-            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
338
-            'event_espresso'
339
-        );
340
-        if (current_user_can('edit_post', $this->event->ID())) {
341
-            $sales_closed_msg .= sprintf(
342
-                esc_html__(
343
-                    '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
344
-                    'event_espresso'
345
-                ),
346
-                '<div class="ee-attention" style="text-align: left;"><b>',
347
-                '</b><br />',
348
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
349
-                '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
350
-            );
351
-        }
352
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
353
-    }
354
-
355
-
356
-
357
-    /**
358
-     * getTickets
359
-     *
360
-     * @return \EE_Base_Class[]|\EE_Ticket[]
361
-     * @throws EE_Error
362
-     */
363
-    protected function getTickets()
364
-    {
365
-        $ticket_query_args = array(
366
-            array('Datetime.EVT_ID' => $this->event->ID()),
367
-            'order_by' => array(
368
-                'TKT_order'              => 'ASC',
369
-                'TKT_required'           => 'DESC',
370
-                'TKT_start_date'         => 'ASC',
371
-                'TKT_end_date'           => 'ASC',
372
-                'Datetime.DTT_EVT_start' => 'DESC',
373
-            ),
374
-        );
375
-        if (
376
-            ! (
377
-                EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
378
-                && EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets
379
-            )
380
-        ) {
381
-            //use the correct applicable time query depending on what version of core is being run.
382
-            $current_time = method_exists('EEM_Datetime', 'current_time_for_query')
383
-                ? time()
384
-                : current_time('timestamp');
385
-            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
386
-        }
387
-        return EEM_Ticket::instance()->get_all($ticket_query_args);
388
-    }
389
-
390
-
391
-
392
-    /**
393
-     * loadTicketSelector
394
-     * begins to assemble template arguments
395
-     * and decides whether to load a "simple" ticket selector, or the standard
396
-     *
397
-     * @param \EE_Ticket[] $tickets
398
-     * @param array $template_args
399
-     * @return string
400
-     * @throws EE_Error
401
-     */
402
-    protected function loadTicketSelector(array $tickets, array $template_args)
403
-    {
404
-        $template_args['event'] = $this->event;
405
-        $template_args['EVT_ID'] = $this->event->ID();
406
-        $template_args['event_is_expired'] = $this->event->is_expired();
407
-        $template_args['max_atndz'] = $this->getMaxAttendees();
408
-        $template_args['date_format'] = $this->date_format;
409
-        $template_args['time_format'] = $this->time_format;
410
-        /**
411
-         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
412
-         *
413
-         * @since 4.9.13
414
-         * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
415
-         * @param int $EVT_ID The Event ID
416
-         */
417
-        $template_args['anchor_id'] = apply_filters(
418
-            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
419
-            '#tkt-slctr-tbl-' . $this->event->ID(),
420
-            $this->event->ID()
421
-        );
422
-        $template_args['tickets'] = $tickets;
423
-        $template_args['ticket_count'] = count($tickets);
424
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
425
-        return $ticket_selector instanceof TicketSelectorSimple
426
-            ? $ticket_selector
427
-            : new TicketSelectorStandard(
428
-                $this->event,
429
-                $tickets,
430
-                $this->getMaxAttendees(),
431
-                $template_args,
432
-                $this->date_format,
433
-                $this->time_format
434
-            );
435
-    }
436
-
437
-
438
-
439
-    /**
440
-     * simpleTicketSelector
441
-     * there's one ticket, and max attendees is set to one,
442
-     * so if the event is free, then this is a "simple" ticket selector
443
-     * a.k.a. "Dude Where's my Ticket Selector?"
444
-     *
445
-     * @param \EE_Ticket[] $tickets
446
-     * @param array  $template_args
447
-     * @return string
448
-     * @throws EE_Error
449
-     */
450
-    protected function simpleTicketSelector($tickets, array $template_args)
451
-    {
452
-        // if there is only ONE ticket with a max qty of ONE
453
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
454
-            return '';
455
-        }
456
-        /** @var \EE_Ticket $ticket */
457
-        $ticket = reset($tickets);
458
-        // if the ticket is free... then not much need for the ticket selector
459
-        if (
460
-            apply_filters(
461
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
462
-                $ticket->is_free(),
463
-                $this->event->ID()
464
-            )
465
-        ) {
466
-            return new TicketSelectorSimple(
467
-                $this->event,
468
-                $ticket,
469
-                $this->getMaxAttendees(),
470
-                $template_args
471
-            );
472
-        }
473
-        return '';
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * externalEventRegistration
480
-     *
481
-     * @return string
482
-     */
483
-    public function externalEventRegistration()
484
-    {
485
-        // if not we still need to trigger the display of the submit button
486
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
487
-        //display notice to admin that registration is external
488
-        return $this->display_full_ui()
489
-            ? esc_html__(
490
-                'Registration is at an external URL for this event.',
491
-                'event_espresso'
492
-            )
493
-            : '';
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * formOpen
500
-     *
501
-     * @param        int    $ID
502
-     * @param        string $external_url
503
-     * @return        string
504
-     */
505
-    public function formOpen( $ID = 0, $external_url = '' )
506
-    {
507
-        // if redirecting, we don't need any anything else
508
-        if ( $external_url ) {
509
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
510
-            // open link in new window ?
511
-            $html .= apply_filters(
512
-                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
513
-                EED_Events_Archive::is_iframe()
514
-            )
515
-                ? ' target="_blank"'
516
-                : '';
517
-            $html .= '>';
518
-            $query_args = EEH_URL::get_query_string( $external_url );
519
-            foreach ( (array)$query_args as $query_arg => $value ) {
520
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
521
-            }
522
-            return $html;
523
-        }
524
-        // if there is no submit button, then don't start building a form
525
-        // because the "View Details" button will build its own form
526
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
527
-            return '';
528
-        }
529
-        $checkout_url = EEH_Event_View::event_link_url( $ID );
530
-        if ( ! $checkout_url ) {
531
-            EE_Error::add_error(
532
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
533
-                __FILE__,
534
-                __FUNCTION__,
535
-                __LINE__
536
-            );
537
-        }
538
-        // set no cache headers and constants
539
-        EE_System::do_not_cache();
540
-        $extra_params = $this->iframe ? ' target="_blank"' : '';
541
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
542
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
543
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
544
-        return $html;
545
-    }
546
-
547
-
548
-
549
-    /**
550
-     * displaySubmitButton
551
-     *
552
-     * @param  string $external_url
553
-     * @return string
554
-     * @throws EE_Error
555
-     */
556
-    public function displaySubmitButton($external_url = '')
557
-    {
558
-        $html = '';
559
-        if ($this->display_full_ui()) {
560
-            // standard TS displayed with submit button, ie: "Register Now"
561
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562
-                $html .= $this->displayRegisterNowButton();
563
-                $html .= empty($external_url)
564
-                    ? $this->ticketSelectorEndDiv()
565
-                    : $this->clearTicketSelector();
566
-                $html .= '<br/>' . $this->formClose();
567
-            } elseif ($this->getMaxAttendees() === 1) {
568
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
569
-                if ($this->event->is_sold_out()) {
570
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
571
-                    $html .= apply_filters(
572
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
573
-                        sprintf(
574
-                            __(
575
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
576
-                                'event_espresso'
577
-                            ),
578
-                            '<p class="no-ticket-selector-msg clear-float">',
579
-                            $this->event->name(),
580
-                            '</p>',
581
-                            '<br />'
582
-                        ),
583
-                        $this->event
584
-                    );
585
-                    if (
586
-                        apply_filters(
587
-                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
588
-                            false,
589
-                            $this->event
590
-                        )
591
-                    ) {
592
-                        $html .= $this->displayRegisterNowButton();
593
-                    }
594
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
595
-                    $html .=  $this->ticketSelectorEndDiv();
596
-                } elseif (
597
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
598
-                    && ! is_single()
599
-                ) {
600
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
601
-                    // but no tickets are available, so display event's "View Details" button.
602
-                    // it is being viewed via somewhere other than a single post
603
-                    $html .= $this->displayViewDetailsButton(true);
604
-                } else {
605
-                    $html .= $this->ticketSelectorEndDiv();
606
-                }
607
-            } elseif (is_archive()) {
608
-                // event list, no tickets available so display event's "View Details" button
609
-                $html .= $this->ticketSelectorEndDiv();
610
-                $html .= $this->displayViewDetailsButton();
611
-            } else {
612
-                if (
613
-                    apply_filters(
614
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
615
-                        false,
616
-                        $this->event
617
-                    )
618
-                ) {
619
-                    $html .= $this->displayRegisterNowButton();
620
-                }
621
-                // no submit or view details button, and no additional content
622
-                $html .= $this->ticketSelectorEndDiv();
623
-            }
624
-            if ( ! $this->iframe && ! is_archive()) {
625
-                $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
626
-            }
627
-        }
628
-	    return apply_filters(
629
-		    'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html',
630
-		    $html,
631
-		    $this->event,
632
-            $this
633
-	    );
634
-    }
635
-
636
-
637
-
638
-    /**
639
-     * @return string
640
-     * @throws EE_Error
641
-     */
642
-    public function displayRegisterNowButton()
643
-    {
644
-        $btn_text = apply_filters(
645
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
646
-            __('Register Now', 'event_espresso'),
647
-            $this->event
648
-        );
649
-        $external_url = $this->event->external_url();
650
-        $html = EEH_HTML::div(
651
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
652
-        );
653
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
654
-        $html .= ' class="ticket-selector-submit-btn ';
655
-        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
656
-        $html .= ' type="submit" value="' . $btn_text . '" />';
657
-        $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
658
-        $html .= apply_filters(
659
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
660
-            '',
661
-            $this->event
662
-        );
663
-        return $html;
664
-    }
665
-
666
-
667
-    /**
668
-     * displayViewDetailsButton
669
-     *
670
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
671
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
672
-     *                    either because they are sold out, expired, or not yet on sale.
673
-     *                    In this case, we need to close the form BEFORE adding any closing divs
674
-     * @return string
675
-     * @throws EE_Error
676
-     */
677
-    public function displayViewDetailsButton( $DWMTS = false )
678
-    {
679
-        if ( ! $this->event->get_permalink() ) {
680
-            EE_Error::add_error(
681
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
682
-                __FILE__, __FUNCTION__, __LINE__
683
-            );
684
-        }
685
-        $view_details_btn = '<form method="POST" action="';
686
-        $view_details_btn .= apply_filters(
687
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
688
-            $this->event->get_permalink(),
689
-            $this->event
690
-        );
691
-        $view_details_btn .= '"';
692
-        // open link in new window ?
693
-        $view_details_btn .= apply_filters(
694
-            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
695
-            EED_Events_Archive::is_iframe()
696
-        )
697
-            ? ' target="_blank"'
698
-            : '';
699
-        $view_details_btn .='>';
700
-        $btn_text = apply_filters(
701
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
702
-            esc_html__('View Details', 'event_espresso'),
703
-            $this->event
704
-        );
705
-        $view_details_btn .= '<input id="ticket-selector-submit-'
706
-                             . $this->event->ID()
707
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
708
-                             . $btn_text
709
-                             . '" />';
710
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
711
-        if ($DWMTS) {
712
-            $view_details_btn .= $this->formClose();
713
-            $view_details_btn .= $this->ticketSelectorEndDiv();
714
-            $view_details_btn .= '<br/>';
715
-        } else {
716
-            $view_details_btn .= $this->clearTicketSelector();
717
-            $view_details_btn .= '<br/>';
718
-            $view_details_btn .= $this->formClose();
719
-        }
720
-        return $view_details_btn;
721
-    }
722
-
723
-
724
-
725
-    /**
726
-     * @return string
727
-     */
728
-    public function ticketSelectorEndDiv()
729
-    {
730
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
731
-    }
732
-
733
-
734
-
735
-    /**
736
-     * @return string
737
-     */
738
-    public function clearTicketSelector()
739
-    {
740
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
741
-        return '<div class="clear"></div><!-- clearTicketSelector -->';
742
-    }
743
-
744
-
745
-
746
-    /**
747
-     * @access        public
748
-     * @return        string
749
-     */
750
-    public function formClose()
751
-    {
752
-        return '</form>';
753
-    }
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * ticketSalesClosed
329
+	 * notice displayed if event ticket sales are turned off
330
+	 *
331
+	 * @return string
332
+	 * @throws EE_Error
333
+	 */
334
+	protected function ticketSalesClosedMessage()
335
+	{
336
+		$sales_closed_msg = esc_html__(
337
+			'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
338
+			'event_espresso'
339
+		);
340
+		if (current_user_can('edit_post', $this->event->ID())) {
341
+			$sales_closed_msg .= sprintf(
342
+				esc_html__(
343
+					'%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
344
+					'event_espresso'
345
+				),
346
+				'<div class="ee-attention" style="text-align: left;"><b>',
347
+				'</b><br />',
348
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
349
+				'</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
350
+			);
351
+		}
352
+		return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
353
+	}
354
+
355
+
356
+
357
+	/**
358
+	 * getTickets
359
+	 *
360
+	 * @return \EE_Base_Class[]|\EE_Ticket[]
361
+	 * @throws EE_Error
362
+	 */
363
+	protected function getTickets()
364
+	{
365
+		$ticket_query_args = array(
366
+			array('Datetime.EVT_ID' => $this->event->ID()),
367
+			'order_by' => array(
368
+				'TKT_order'              => 'ASC',
369
+				'TKT_required'           => 'DESC',
370
+				'TKT_start_date'         => 'ASC',
371
+				'TKT_end_date'           => 'ASC',
372
+				'Datetime.DTT_EVT_start' => 'DESC',
373
+			),
374
+		);
375
+		if (
376
+			! (
377
+				EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
378
+				&& EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets
379
+			)
380
+		) {
381
+			//use the correct applicable time query depending on what version of core is being run.
382
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query')
383
+				? time()
384
+				: current_time('timestamp');
385
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
386
+		}
387
+		return EEM_Ticket::instance()->get_all($ticket_query_args);
388
+	}
389
+
390
+
391
+
392
+	/**
393
+	 * loadTicketSelector
394
+	 * begins to assemble template arguments
395
+	 * and decides whether to load a "simple" ticket selector, or the standard
396
+	 *
397
+	 * @param \EE_Ticket[] $tickets
398
+	 * @param array $template_args
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 */
402
+	protected function loadTicketSelector(array $tickets, array $template_args)
403
+	{
404
+		$template_args['event'] = $this->event;
405
+		$template_args['EVT_ID'] = $this->event->ID();
406
+		$template_args['event_is_expired'] = $this->event->is_expired();
407
+		$template_args['max_atndz'] = $this->getMaxAttendees();
408
+		$template_args['date_format'] = $this->date_format;
409
+		$template_args['time_format'] = $this->time_format;
410
+		/**
411
+		 * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
412
+		 *
413
+		 * @since 4.9.13
414
+		 * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
415
+		 * @param int $EVT_ID The Event ID
416
+		 */
417
+		$template_args['anchor_id'] = apply_filters(
418
+			'FHEE__EE_Ticket_Selector__redirect_anchor_id',
419
+			'#tkt-slctr-tbl-' . $this->event->ID(),
420
+			$this->event->ID()
421
+		);
422
+		$template_args['tickets'] = $tickets;
423
+		$template_args['ticket_count'] = count($tickets);
424
+		$ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
425
+		return $ticket_selector instanceof TicketSelectorSimple
426
+			? $ticket_selector
427
+			: new TicketSelectorStandard(
428
+				$this->event,
429
+				$tickets,
430
+				$this->getMaxAttendees(),
431
+				$template_args,
432
+				$this->date_format,
433
+				$this->time_format
434
+			);
435
+	}
436
+
437
+
438
+
439
+	/**
440
+	 * simpleTicketSelector
441
+	 * there's one ticket, and max attendees is set to one,
442
+	 * so if the event is free, then this is a "simple" ticket selector
443
+	 * a.k.a. "Dude Where's my Ticket Selector?"
444
+	 *
445
+	 * @param \EE_Ticket[] $tickets
446
+	 * @param array  $template_args
447
+	 * @return string
448
+	 * @throws EE_Error
449
+	 */
450
+	protected function simpleTicketSelector($tickets, array $template_args)
451
+	{
452
+		// if there is only ONE ticket with a max qty of ONE
453
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
454
+			return '';
455
+		}
456
+		/** @var \EE_Ticket $ticket */
457
+		$ticket = reset($tickets);
458
+		// if the ticket is free... then not much need for the ticket selector
459
+		if (
460
+			apply_filters(
461
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
462
+				$ticket->is_free(),
463
+				$this->event->ID()
464
+			)
465
+		) {
466
+			return new TicketSelectorSimple(
467
+				$this->event,
468
+				$ticket,
469
+				$this->getMaxAttendees(),
470
+				$template_args
471
+			);
472
+		}
473
+		return '';
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * externalEventRegistration
480
+	 *
481
+	 * @return string
482
+	 */
483
+	public function externalEventRegistration()
484
+	{
485
+		// if not we still need to trigger the display of the submit button
486
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
487
+		//display notice to admin that registration is external
488
+		return $this->display_full_ui()
489
+			? esc_html__(
490
+				'Registration is at an external URL for this event.',
491
+				'event_espresso'
492
+			)
493
+			: '';
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * formOpen
500
+	 *
501
+	 * @param        int    $ID
502
+	 * @param        string $external_url
503
+	 * @return        string
504
+	 */
505
+	public function formOpen( $ID = 0, $external_url = '' )
506
+	{
507
+		// if redirecting, we don't need any anything else
508
+		if ( $external_url ) {
509
+			$html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
510
+			// open link in new window ?
511
+			$html .= apply_filters(
512
+				'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
513
+				EED_Events_Archive::is_iframe()
514
+			)
515
+				? ' target="_blank"'
516
+				: '';
517
+			$html .= '>';
518
+			$query_args = EEH_URL::get_query_string( $external_url );
519
+			foreach ( (array)$query_args as $query_arg => $value ) {
520
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
521
+			}
522
+			return $html;
523
+		}
524
+		// if there is no submit button, then don't start building a form
525
+		// because the "View Details" button will build its own form
526
+		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
527
+			return '';
528
+		}
529
+		$checkout_url = EEH_Event_View::event_link_url( $ID );
530
+		if ( ! $checkout_url ) {
531
+			EE_Error::add_error(
532
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
533
+				__FILE__,
534
+				__FUNCTION__,
535
+				__LINE__
536
+			);
537
+		}
538
+		// set no cache headers and constants
539
+		EE_System::do_not_cache();
540
+		$extra_params = $this->iframe ? ' target="_blank"' : '';
541
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
542
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
543
+		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
544
+		return $html;
545
+	}
546
+
547
+
548
+
549
+	/**
550
+	 * displaySubmitButton
551
+	 *
552
+	 * @param  string $external_url
553
+	 * @return string
554
+	 * @throws EE_Error
555
+	 */
556
+	public function displaySubmitButton($external_url = '')
557
+	{
558
+		$html = '';
559
+		if ($this->display_full_ui()) {
560
+			// standard TS displayed with submit button, ie: "Register Now"
561
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562
+				$html .= $this->displayRegisterNowButton();
563
+				$html .= empty($external_url)
564
+					? $this->ticketSelectorEndDiv()
565
+					: $this->clearTicketSelector();
566
+				$html .= '<br/>' . $this->formClose();
567
+			} elseif ($this->getMaxAttendees() === 1) {
568
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
569
+				if ($this->event->is_sold_out()) {
570
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
571
+					$html .= apply_filters(
572
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
573
+						sprintf(
574
+							__(
575
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
576
+								'event_espresso'
577
+							),
578
+							'<p class="no-ticket-selector-msg clear-float">',
579
+							$this->event->name(),
580
+							'</p>',
581
+							'<br />'
582
+						),
583
+						$this->event
584
+					);
585
+					if (
586
+						apply_filters(
587
+							'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
588
+							false,
589
+							$this->event
590
+						)
591
+					) {
592
+						$html .= $this->displayRegisterNowButton();
593
+					}
594
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
595
+					$html .=  $this->ticketSelectorEndDiv();
596
+				} elseif (
597
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
598
+					&& ! is_single()
599
+				) {
600
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
601
+					// but no tickets are available, so display event's "View Details" button.
602
+					// it is being viewed via somewhere other than a single post
603
+					$html .= $this->displayViewDetailsButton(true);
604
+				} else {
605
+					$html .= $this->ticketSelectorEndDiv();
606
+				}
607
+			} elseif (is_archive()) {
608
+				// event list, no tickets available so display event's "View Details" button
609
+				$html .= $this->ticketSelectorEndDiv();
610
+				$html .= $this->displayViewDetailsButton();
611
+			} else {
612
+				if (
613
+					apply_filters(
614
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
615
+						false,
616
+						$this->event
617
+					)
618
+				) {
619
+					$html .= $this->displayRegisterNowButton();
620
+				}
621
+				// no submit or view details button, and no additional content
622
+				$html .= $this->ticketSelectorEndDiv();
623
+			}
624
+			if ( ! $this->iframe && ! is_archive()) {
625
+				$html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
626
+			}
627
+		}
628
+		return apply_filters(
629
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html',
630
+			$html,
631
+			$this->event,
632
+			$this
633
+		);
634
+	}
635
+
636
+
637
+
638
+	/**
639
+	 * @return string
640
+	 * @throws EE_Error
641
+	 */
642
+	public function displayRegisterNowButton()
643
+	{
644
+		$btn_text = apply_filters(
645
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
646
+			__('Register Now', 'event_espresso'),
647
+			$this->event
648
+		);
649
+		$external_url = $this->event->external_url();
650
+		$html = EEH_HTML::div(
651
+			'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
652
+		);
653
+		$html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
654
+		$html .= ' class="ticket-selector-submit-btn ';
655
+		$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
656
+		$html .= ' type="submit" value="' . $btn_text . '" />';
657
+		$html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
658
+		$html .= apply_filters(
659
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
660
+			'',
661
+			$this->event
662
+		);
663
+		return $html;
664
+	}
665
+
666
+
667
+	/**
668
+	 * displayViewDetailsButton
669
+	 *
670
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
671
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
672
+	 *                    either because they are sold out, expired, or not yet on sale.
673
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
674
+	 * @return string
675
+	 * @throws EE_Error
676
+	 */
677
+	public function displayViewDetailsButton( $DWMTS = false )
678
+	{
679
+		if ( ! $this->event->get_permalink() ) {
680
+			EE_Error::add_error(
681
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
682
+				__FILE__, __FUNCTION__, __LINE__
683
+			);
684
+		}
685
+		$view_details_btn = '<form method="POST" action="';
686
+		$view_details_btn .= apply_filters(
687
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
688
+			$this->event->get_permalink(),
689
+			$this->event
690
+		);
691
+		$view_details_btn .= '"';
692
+		// open link in new window ?
693
+		$view_details_btn .= apply_filters(
694
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
695
+			EED_Events_Archive::is_iframe()
696
+		)
697
+			? ' target="_blank"'
698
+			: '';
699
+		$view_details_btn .='>';
700
+		$btn_text = apply_filters(
701
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
702
+			esc_html__('View Details', 'event_espresso'),
703
+			$this->event
704
+		);
705
+		$view_details_btn .= '<input id="ticket-selector-submit-'
706
+							 . $this->event->ID()
707
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
708
+							 . $btn_text
709
+							 . '" />';
710
+		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
711
+		if ($DWMTS) {
712
+			$view_details_btn .= $this->formClose();
713
+			$view_details_btn .= $this->ticketSelectorEndDiv();
714
+			$view_details_btn .= '<br/>';
715
+		} else {
716
+			$view_details_btn .= $this->clearTicketSelector();
717
+			$view_details_btn .= '<br/>';
718
+			$view_details_btn .= $this->formClose();
719
+		}
720
+		return $view_details_btn;
721
+	}
722
+
723
+
724
+
725
+	/**
726
+	 * @return string
727
+	 */
728
+	public function ticketSelectorEndDiv()
729
+	{
730
+		return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
731
+	}
732
+
733
+
734
+
735
+	/**
736
+	 * @return string
737
+	 */
738
+	public function clearTicketSelector()
739
+	{
740
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
741
+		return '<div class="clear"></div><!-- clearTicketSelector -->';
742
+	}
743
+
744
+
745
+
746
+	/**
747
+	 * @access        public
748
+	 * @return        string
749
+	 */
750
+	public function formClose()
751
+	{
752
+		return '</form>';
753
+	}
754 754
 
755 755
 
756 756
 
Please login to merge, or discard this patch.
core/libraries/messages/data_class/EE_Messages_incoming_data.core.php 2 patches
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -27,511 +27,511 @@  discard block
 block discarded – undo
27 27
 {
28 28
 
29 29
 
30
-    /**
31
-     * user id for logged in user when data collected
32
-     *
33
-     * @var string $user_id
34
-     */
35
-    public $user_id;
36
-
37
-    /**
38
-     * IP Address of browser used
39
-     *
40
-     * @var string $ip_address
41
-     */
42
-    public $ip_address;
43
-
44
-    /**
45
-     * browser
46
-     *
47
-     * @var string $user_agent
48
-     */
49
-    public $user_agent;
50
-
51
-    /**
52
-     * Unix timestamp
53
-     *
54
-     * @var string $init_access
55
-     */
56
-    public $init_access;
57
-
58
-    /**
59
-     * Unix timestamp
60
-     *
61
-     * @var string $last_access
62
-     */
63
-    public $last_access;
64
-
65
-    /**
66
-     * The registrations details from the cart
67
-     *
68
-     * @var array $reg_info
69
-     */
70
-    public $reg_info;
71
-
72
-    /**
73
-     * Some data handlers can set what reg status all the registrations are filtered by.
74
-     * The status should match a EEM_Registration status constant.
75
-     *
76
-     * @var string $filtered_reg_status
77
-     */
78
-    public $filtered_reg_status;
79
-
80
-    /**
81
-     * will hold an array of events assembled from $reg_info
82
-     *
83
-     * @var EE_Event[] $events
84
-     */
85
-    public $events;
86
-
87
-    /**
88
-     * holds an array of datetimes assembled from the incoming data.
89
-     *
90
-     * @var EE_Datetime[] $datetimes
91
-     */
92
-    public $datetimes;
93
-
94
-    /**
95
-     * holds an array of tickets assembled from the incoming data.
96
-     *
97
-     * @var EE_Ticket[] $tickets
98
-     */
99
-    public $tickets;
100
-
101
-    /**
102
-     * holds an array with a key of parent line item and values are an array of children of that line item.
103
-     *
104
-     * @since 4.5.0
105
-     * @var EE_Line_Item[] $line_items_with_children
106
-     */
107
-    public $line_items_with_children;
108
-
109
-    /**
110
-     * will hold an array of attendees assembled from the $reg_info
111
-     *
112
-     * @var EE_Attendee[] $attendees
113
-     */
114
-    public $attendees;
115
-
116
-    /**
117
-     * will hold an array of cached registration objects and info assembled from reg_info
118
-     *
119
-     * @var array $registrations
120
-     */
121
-    public $registrations;
122
-
123
-    /**
124
-     * will hold an array of answers assembled from the $reg_info
125
-     *
126
-     * @var EE_Answer[] $answers
127
-     */
128
-    public $answers;
129
-
130
-    /**
131
-     * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
132
-     *
133
-     * @var EE_Question[] $questions
134
-     */
135
-    public $questions;
136
-
137
-    /**
138
-     * Will hold billing data assembled from $billing_info (if present)
139
-     *
140
-     * @var mixed (array|null) $billing
141
-     */
142
-    public $billing;
143
-
144
-    /**
145
-     * The total amount of tax for the transaction
146
-     *
147
-     * @var float $taxes
148
-     */
149
-    public $taxes;
150
-
151
-    /**
152
-     * Holds the line items related to taxes
153
-     *
154
-     * @since 4.5.0
155
-     * @var EE_Line_Item[] $tax_line_items
156
-     */
157
-    public $tax_line_items;
158
-
159
-    /**
160
-     * Hold the line items which aren't taxes and don't relate
161
-     * to tickets. So: promotions and miscellaneous charges
162
-     *
163
-     * @since 4.5
164
-     * @var EE_Line_Item[] $additional_line_items
165
-     */
166
-    public $additional_line_items;
167
-
168
-    /**
169
-     * Holds the grand total EE_Line_Item
170
-     *
171
-     * @var EE_Line_Item $grand_total_line_item
172
-     */
173
-    public $grand_total_line_item;
174
-
175
-    /**
176
-     * holds the grand total price object
177
-     *
178
-     * @var object $grand_total_price_object
179
-     */
180
-    public $grand_total_price_object;
181
-
182
-    /**
183
-     * total number of tickets
184
-     *
185
-     * @var int $total_ticket_count
186
-     */
187
-    public $total_ticket_count;
188
-
189
-    /**
190
-     * Will hold the final transaction object (EE_Transaction)
191
-     *
192
-     * @var EE_Transaction $txn
193
-     */
194
-    public $txn;
195
-
196
-    /**
197
-     * Holds the payments related to a transaction
198
-     *
199
-     * @since 4.5.0
200
-     * @var EE_Payment[] $payments
201
-     */
202
-    public $payments;
203
-
204
-    /**
205
-     * Holds the first related payment related for a transaction
206
-     *
207
-     * @since 4.5.0
208
-     * @var EE_Payment $payment
209
-     */
210
-    public $payment;
211
-
212
-    /**
213
-     * Will hold the label for the txn status
214
-     *
215
-     * @var string $txn_status
216
-     */
217
-    public $txn_status;
218
-
219
-    /**
220
-     * Will hold the final registration object (EE_Registration)
221
-     *
222
-     * @var EE_Registration[] $reg_objs
223
-     */
224
-    public $reg_objs;
225
-
226
-    /**
227
-     * Will hold an array of primary attendee data (if present)
228
-     *
229
-     * @var array $primary_attendee_data
230
-     */
231
-    public $primary_attendee_data;
232
-
233
-    /**
234
-     * This is just an internal object used for passing around the incoming data.
235
-     *
236
-     * @var object $_data
237
-     */
238
-    protected $_data;
239
-
240
-    /**
241
-     * This is just an internal object used for passing around the incoming data.
242
-     *
243
-     * @var object $incoming_data
244
-     */
245
-    public $incoming_data;
246
-
247
-    /**
248
-     * hold objects that might be created
249
-     *
250
-     * @type EE_Registration $reg_obj
251
-     */
252
-    public $reg_obj;
253
-
254
-
255
-    /**
256
-     * constructor
257
-     *
258
-     * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
259
-     *                    data object.  But here parent will be generic because we don't know what's coming in.
260
-     */
261
-    public function __construct($data)
262
-    {
263
-        $this->_data = $data;
264
-        $this->_setup_data();
265
-    }
266
-
267
-
268
-    /**
269
-     * Every child class has to setup the data object !
270
-     *
271
-     * @return void
272
-     */
273
-    abstract protected function _setup_data();
274
-
275
-
276
-    /**
277
-     * Returns database safe representation of the data later used to when instantiating this object.
278
-     *
279
-     * @param mixed $data The incoming data to be prepped.
280
-     * @return mixed   The prepped data for db
281
-     */
282
-    static public function convert_data_for_persistent_storage($data)
283
-    {
284
-        return $data;
285
-    }
286
-
287
-
288
-    /**
289
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
290
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
291
-     *
292
-     * @param $data
293
-     * @return mixed
294
-     */
295
-    static public function convert_data_from_persistent_storage($data)
296
-    {
297
-        return $data;
298
-    }
299
-
300
-
301
-    /**
302
-     * only purpose is to return the data
303
-     *
304
-     * @access public
305
-     * @return object the formatted data object!
306
-     */
307
-    public function data()
308
-    {
309
-        return $this->_data;
310
-    }
311
-
312
-
313
-    /**
314
-     * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
315
-     * is that $this->reg_objs be set.
316
-     *
317
-     * @throws \EE_Error
318
-     */
319
-    protected function _assemble_data()
320
-    {
321
-        //verify that reg_objs is set
322
-        if (
323
-            ! is_array($this->reg_objs)
324
-            && ! reset($this->reg_objs) instanceof EE_Registration
325
-        ) {
326
-            throw new EE_Error(
327
-                __(
328
-                    'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
329
-                    'event_espresso'
330
-                )
331
-            );
332
-        }
333
-
334
-        //get all attendee and events associated with the registrations in this transaction
335
-        $events             = $event_setup = $evtcache = $tickets = $datetimes = array();
336
-        $answers            = $questions = $attendees = $line_items = $registrations = array();
337
-        $total_ticket_count = 0;
338
-
339
-        if (! empty($this->reg_objs)) {
340
-            $event_attendee_count = array();
341
-            foreach ($this->reg_objs as $reg) {
342
-
343
-                if (
344
-                $this->_skip_registration_for_processing($reg)
345
-                ) {
346
-                    continue;
347
-                }
348
-
349
-                $evt_id = $reg->event_ID();
350
-                /** @type EE_Ticket $ticket */
351
-                $ticket          = $reg->get_first_related('Ticket');
352
-                $relateddatetime = $ticket->datetimes();
353
-                $total_ticket_count++;
354
-                $tickets[$ticket->ID()]['ticket']                        = $ticket;
355
-                $tickets[$ticket->ID()]['count']                         = is_array($tickets[$ticket->ID()])
356
-                                                                           && isset($tickets[$ticket->ID()]['count'])
357
-                    ? $tickets[$ticket->ID()]['count'] + 1
358
-                    : 1;
359
-                $tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee();
360
-                $tickets[$ticket->ID()]['dtt_objs']                      = $relateddatetime;
361
-                $tickets[$ticket->ID()]['reg_objs'][$reg->ID()]          = $reg;
362
-                $event                                                   = $reg->event();
363
-                $tickets[$ticket->ID()]['EE_Event']                      = $event;
364
-                $evtcache[$evt_id]                                       = $event;
365
-                $eventsetup[$evt_id]['reg_objs'][$reg->ID()]             = $reg;
366
-                $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()]          = $ticket;
367
-                $eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()]    = $reg->attendee();
368
-                $event_attendee_count[$evt_id]                           = isset($event_attendee_count[$evt_id])
369
-                    ? $event_attendee_count[$evt_id] + 1
370
-                    : 0;
371
-                $attendees[$reg->attendee_ID()]['line_ref'][]            = $evt_id;
372
-                $attendees[$reg->attendee_ID()]['att_obj']               = $reg->attendee();
373
-                $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()]  = $reg;
374
-                //$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
375
-                $attendees[$reg->attendee_ID()]['attendee_email']          = $reg->attendee() instanceof EE_Attendee
376
-                    ? $reg->attendee()->email()
377
-                    : '';
378
-                $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket;
379
-                $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id]       = $event;
380
-
381
-                //registrations
382
-                $registrations[$reg->ID()]['tkt_obj'] = $ticket;
383
-                $registrations[$reg->ID()]['evt_obj'] = $event;
384
-                $registrations[$reg->ID()]['reg_obj'] = $reg;
385
-                $registrations[$reg->ID()]['att_obj'] = $reg->attendee();
386
-
387
-                //set up answer objects
388
-                $rel_ans = $reg->get_many_related('Answer');
389
-                foreach ($rel_ans as $ansid => $answer) {
390
-                    if (! isset($questions[$ansid])) {
391
-                        $questions[$ansid] = $answer->get_first_related('Question');
392
-                    }
393
-                    $answers[$ansid]                               = $answer;
394
-                    $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer;
395
-                }
396
-
397
-                foreach ($relateddatetime as $dtt_id => $datetime) {
398
-                    $eventsetup[$evt_id]['dtt_objs'][$dtt_id]       = $datetime;
399
-                    $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime;
400
-
401
-                    if (isset($datetimes[$dtt_id])) {
402
-                        continue; //already have this info in the datetimes array.
403
-                    }
404
-
405
-                    $datetimes[$dtt_id]['tkt_objs'][]           = $ticket;
406
-                    $datetimes[$dtt_id]['datetime']             = $datetime;
407
-                    $datetimes[$dtt_id]['evt_objs'][$evt_id]    = $event;
408
-                    $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg;
409
-                }
410
-            }
411
-
412
-            //let's loop through the unique event=>reg items and setup data on them
413
-
414
-            if (! empty($eventsetup)) {
415
-                foreach ($eventsetup as $evt_id => $items) {
416
-                    if ($this->txn instanceof EE_Transaction) {
417
-                        $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
418
-                            array(
419
-                                array(
420
-                                    'Ticket.Datetime.EVT_ID' => $evt_id,
421
-                                    'TXN_ID'                 => $this->txn->ID(),
422
-                                ),
423
-                                'default_where_conditions' => 'none',
424
-                            )
425
-                        );
426
-                    } else {
427
-                        $ticket_line_items_for_event = array();
428
-                    }
429
-                    $events[$evt_id] = array(
430
-                        'ID'              => $evt_id,
431
-                        'event'           => $evtcache[$evt_id],
432
-                        'name'            => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '',
433
-                        'total_attendees' => $event_attendee_count[$evt_id],
434
-                        'reg_objs'        => $items['reg_objs'],
435
-                        'tkt_objs'        => $items['tkt_objs'],
436
-                        'att_objs'        => $items['att_objs'],
437
-                        'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
438
-                        'line_items'      => $ticket_line_items_for_event,
439
-                    );
440
-
441
-                    //make sure the tickets have the line items setup for them.
442
-                    foreach ($ticket_line_items_for_event as $line_id => $line_item) {
443
-                        if ($line_item instanceof EE_Line_Item) {
444
-                            $tickets[$line_item->ticket()->ID()]['line_item']      = $line_item;
445
-                            $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children();
446
-                            $line_items[$line_item->ID()]['children']              = $line_item->children();
447
-                            $line_items[$line_item->ID()]['EE_Ticket']             = $line_item->ticket();
448
-                        }
449
-                    }
450
-                }
451
-            }
452
-
453
-            $this->grand_total_line_item = $this->txn instanceof EE_Transaction
454
-                ? $this->txn->total_line_item()
455
-                : null;
456
-        }
457
-
458
-        //lets set the attendees and events properties
459
-        $this->attendees                = $attendees;
460
-        $this->events                   = $events;
461
-        $this->tickets                  = $tickets;
462
-        $this->line_items_with_children = $line_items;
463
-        $this->datetimes                = $datetimes;
464
-        $this->questions                = $questions;
465
-        $this->answers                  = $answers;
466
-        $this->total_ticket_count       = $total_ticket_count;
467
-        $this->registrations            = $registrations;
468
-
469
-        if ($this->txn instanceof EE_Transaction) {
470
-            $this->tax_line_items        = $this->txn->tax_items();
471
-            $this->additional_line_items = $this->txn->non_ticket_line_items();
472
-            $this->payments              = $this->txn->payments();
473
-
474
-            //setup primary registration if we have a single transaction object to work with
475
-
476
-            //let's get just the primary_attendee_data!  First we get the primary registration object.
477
-            $primary_reg = $this->txn->primary_registration();
478
-            // verify
479
-            if ($primary_reg instanceof EE_Registration) {
480
-
481
-                // get attendee object
482
-                if ($primary_reg->attendee() instanceof EE_Attendee) {
483
-
484
-                    //now we can setup the primary_attendee_data array
485
-                    $this->primary_attendee_data = array(
486
-                        'registration_id' => $primary_reg->ID(),
487
-                        'att_obj'         => $primary_reg->attendee(),
488
-                        'reg_obj'         => $primary_reg,
489
-                        'primary_att_obj' => $primary_reg->attendee(),
490
-                        'primary_reg_obj' => $primary_reg,
491
-                    );
492
-
493
-                } else {
494
-                    EE_Error::add_error(
495
-                        __(
496
-                            'Incoming data does not have a valid Attendee object for the primary registrant.',
497
-                            'event_espresso'
498
-                        ),
499
-                        __FILE__,
500
-                        __FUNCTION__,
501
-                        __LINE__
502
-                    );
503
-                }
504
-            } else {
505
-                EE_Error::add_error(
506
-                    __(
507
-                        'Incoming data does not have a valid Registration object for the primary registrant.',
508
-                        'event_espresso'
509
-                    ),
510
-                    __FILE__,
511
-                    __FUNCTION__,
512
-                    __LINE__
513
-                );
514
-            }
515
-        }
516
-    }
517
-
518
-    /**
519
-     * This simply considers whether the given registration should be processed or not based on comparison with the
520
-     * filtered_reg_status property.
521
-     *
522
-     * @param EE_Registration $registration
523
-     * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
524
-     *               processing
525
-     */
526
-    protected function _skip_registration_for_processing(EE_Registration $registration)
527
-    {
528
-        if (empty($this->filtered_reg_status)) {
529
-            return false;
530
-        }
531
-
532
-        //if we made it here then we just compare the filtered_reg_status with the registration status and return that
533
-        return $this->filtered_reg_status !== $registration->status_ID();
534
-    }
30
+	/**
31
+	 * user id for logged in user when data collected
32
+	 *
33
+	 * @var string $user_id
34
+	 */
35
+	public $user_id;
36
+
37
+	/**
38
+	 * IP Address of browser used
39
+	 *
40
+	 * @var string $ip_address
41
+	 */
42
+	public $ip_address;
43
+
44
+	/**
45
+	 * browser
46
+	 *
47
+	 * @var string $user_agent
48
+	 */
49
+	public $user_agent;
50
+
51
+	/**
52
+	 * Unix timestamp
53
+	 *
54
+	 * @var string $init_access
55
+	 */
56
+	public $init_access;
57
+
58
+	/**
59
+	 * Unix timestamp
60
+	 *
61
+	 * @var string $last_access
62
+	 */
63
+	public $last_access;
64
+
65
+	/**
66
+	 * The registrations details from the cart
67
+	 *
68
+	 * @var array $reg_info
69
+	 */
70
+	public $reg_info;
71
+
72
+	/**
73
+	 * Some data handlers can set what reg status all the registrations are filtered by.
74
+	 * The status should match a EEM_Registration status constant.
75
+	 *
76
+	 * @var string $filtered_reg_status
77
+	 */
78
+	public $filtered_reg_status;
79
+
80
+	/**
81
+	 * will hold an array of events assembled from $reg_info
82
+	 *
83
+	 * @var EE_Event[] $events
84
+	 */
85
+	public $events;
86
+
87
+	/**
88
+	 * holds an array of datetimes assembled from the incoming data.
89
+	 *
90
+	 * @var EE_Datetime[] $datetimes
91
+	 */
92
+	public $datetimes;
93
+
94
+	/**
95
+	 * holds an array of tickets assembled from the incoming data.
96
+	 *
97
+	 * @var EE_Ticket[] $tickets
98
+	 */
99
+	public $tickets;
100
+
101
+	/**
102
+	 * holds an array with a key of parent line item and values are an array of children of that line item.
103
+	 *
104
+	 * @since 4.5.0
105
+	 * @var EE_Line_Item[] $line_items_with_children
106
+	 */
107
+	public $line_items_with_children;
108
+
109
+	/**
110
+	 * will hold an array of attendees assembled from the $reg_info
111
+	 *
112
+	 * @var EE_Attendee[] $attendees
113
+	 */
114
+	public $attendees;
115
+
116
+	/**
117
+	 * will hold an array of cached registration objects and info assembled from reg_info
118
+	 *
119
+	 * @var array $registrations
120
+	 */
121
+	public $registrations;
122
+
123
+	/**
124
+	 * will hold an array of answers assembled from the $reg_info
125
+	 *
126
+	 * @var EE_Answer[] $answers
127
+	 */
128
+	public $answers;
129
+
130
+	/**
131
+	 * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
132
+	 *
133
+	 * @var EE_Question[] $questions
134
+	 */
135
+	public $questions;
136
+
137
+	/**
138
+	 * Will hold billing data assembled from $billing_info (if present)
139
+	 *
140
+	 * @var mixed (array|null) $billing
141
+	 */
142
+	public $billing;
143
+
144
+	/**
145
+	 * The total amount of tax for the transaction
146
+	 *
147
+	 * @var float $taxes
148
+	 */
149
+	public $taxes;
150
+
151
+	/**
152
+	 * Holds the line items related to taxes
153
+	 *
154
+	 * @since 4.5.0
155
+	 * @var EE_Line_Item[] $tax_line_items
156
+	 */
157
+	public $tax_line_items;
158
+
159
+	/**
160
+	 * Hold the line items which aren't taxes and don't relate
161
+	 * to tickets. So: promotions and miscellaneous charges
162
+	 *
163
+	 * @since 4.5
164
+	 * @var EE_Line_Item[] $additional_line_items
165
+	 */
166
+	public $additional_line_items;
167
+
168
+	/**
169
+	 * Holds the grand total EE_Line_Item
170
+	 *
171
+	 * @var EE_Line_Item $grand_total_line_item
172
+	 */
173
+	public $grand_total_line_item;
174
+
175
+	/**
176
+	 * holds the grand total price object
177
+	 *
178
+	 * @var object $grand_total_price_object
179
+	 */
180
+	public $grand_total_price_object;
181
+
182
+	/**
183
+	 * total number of tickets
184
+	 *
185
+	 * @var int $total_ticket_count
186
+	 */
187
+	public $total_ticket_count;
188
+
189
+	/**
190
+	 * Will hold the final transaction object (EE_Transaction)
191
+	 *
192
+	 * @var EE_Transaction $txn
193
+	 */
194
+	public $txn;
195
+
196
+	/**
197
+	 * Holds the payments related to a transaction
198
+	 *
199
+	 * @since 4.5.0
200
+	 * @var EE_Payment[] $payments
201
+	 */
202
+	public $payments;
203
+
204
+	/**
205
+	 * Holds the first related payment related for a transaction
206
+	 *
207
+	 * @since 4.5.0
208
+	 * @var EE_Payment $payment
209
+	 */
210
+	public $payment;
211
+
212
+	/**
213
+	 * Will hold the label for the txn status
214
+	 *
215
+	 * @var string $txn_status
216
+	 */
217
+	public $txn_status;
218
+
219
+	/**
220
+	 * Will hold the final registration object (EE_Registration)
221
+	 *
222
+	 * @var EE_Registration[] $reg_objs
223
+	 */
224
+	public $reg_objs;
225
+
226
+	/**
227
+	 * Will hold an array of primary attendee data (if present)
228
+	 *
229
+	 * @var array $primary_attendee_data
230
+	 */
231
+	public $primary_attendee_data;
232
+
233
+	/**
234
+	 * This is just an internal object used for passing around the incoming data.
235
+	 *
236
+	 * @var object $_data
237
+	 */
238
+	protected $_data;
239
+
240
+	/**
241
+	 * This is just an internal object used for passing around the incoming data.
242
+	 *
243
+	 * @var object $incoming_data
244
+	 */
245
+	public $incoming_data;
246
+
247
+	/**
248
+	 * hold objects that might be created
249
+	 *
250
+	 * @type EE_Registration $reg_obj
251
+	 */
252
+	public $reg_obj;
253
+
254
+
255
+	/**
256
+	 * constructor
257
+	 *
258
+	 * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
259
+	 *                    data object.  But here parent will be generic because we don't know what's coming in.
260
+	 */
261
+	public function __construct($data)
262
+	{
263
+		$this->_data = $data;
264
+		$this->_setup_data();
265
+	}
266
+
267
+
268
+	/**
269
+	 * Every child class has to setup the data object !
270
+	 *
271
+	 * @return void
272
+	 */
273
+	abstract protected function _setup_data();
274
+
275
+
276
+	/**
277
+	 * Returns database safe representation of the data later used to when instantiating this object.
278
+	 *
279
+	 * @param mixed $data The incoming data to be prepped.
280
+	 * @return mixed   The prepped data for db
281
+	 */
282
+	static public function convert_data_for_persistent_storage($data)
283
+	{
284
+		return $data;
285
+	}
286
+
287
+
288
+	/**
289
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
290
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
291
+	 *
292
+	 * @param $data
293
+	 * @return mixed
294
+	 */
295
+	static public function convert_data_from_persistent_storage($data)
296
+	{
297
+		return $data;
298
+	}
299
+
300
+
301
+	/**
302
+	 * only purpose is to return the data
303
+	 *
304
+	 * @access public
305
+	 * @return object the formatted data object!
306
+	 */
307
+	public function data()
308
+	{
309
+		return $this->_data;
310
+	}
311
+
312
+
313
+	/**
314
+	 * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
315
+	 * is that $this->reg_objs be set.
316
+	 *
317
+	 * @throws \EE_Error
318
+	 */
319
+	protected function _assemble_data()
320
+	{
321
+		//verify that reg_objs is set
322
+		if (
323
+			! is_array($this->reg_objs)
324
+			&& ! reset($this->reg_objs) instanceof EE_Registration
325
+		) {
326
+			throw new EE_Error(
327
+				__(
328
+					'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
329
+					'event_espresso'
330
+				)
331
+			);
332
+		}
333
+
334
+		//get all attendee and events associated with the registrations in this transaction
335
+		$events             = $event_setup = $evtcache = $tickets = $datetimes = array();
336
+		$answers            = $questions = $attendees = $line_items = $registrations = array();
337
+		$total_ticket_count = 0;
338
+
339
+		if (! empty($this->reg_objs)) {
340
+			$event_attendee_count = array();
341
+			foreach ($this->reg_objs as $reg) {
342
+
343
+				if (
344
+				$this->_skip_registration_for_processing($reg)
345
+				) {
346
+					continue;
347
+				}
348
+
349
+				$evt_id = $reg->event_ID();
350
+				/** @type EE_Ticket $ticket */
351
+				$ticket          = $reg->get_first_related('Ticket');
352
+				$relateddatetime = $ticket->datetimes();
353
+				$total_ticket_count++;
354
+				$tickets[$ticket->ID()]['ticket']                        = $ticket;
355
+				$tickets[$ticket->ID()]['count']                         = is_array($tickets[$ticket->ID()])
356
+																		   && isset($tickets[$ticket->ID()]['count'])
357
+					? $tickets[$ticket->ID()]['count'] + 1
358
+					: 1;
359
+				$tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee();
360
+				$tickets[$ticket->ID()]['dtt_objs']                      = $relateddatetime;
361
+				$tickets[$ticket->ID()]['reg_objs'][$reg->ID()]          = $reg;
362
+				$event                                                   = $reg->event();
363
+				$tickets[$ticket->ID()]['EE_Event']                      = $event;
364
+				$evtcache[$evt_id]                                       = $event;
365
+				$eventsetup[$evt_id]['reg_objs'][$reg->ID()]             = $reg;
366
+				$eventsetup[$evt_id]['tkt_objs'][$ticket->ID()]          = $ticket;
367
+				$eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()]    = $reg->attendee();
368
+				$event_attendee_count[$evt_id]                           = isset($event_attendee_count[$evt_id])
369
+					? $event_attendee_count[$evt_id] + 1
370
+					: 0;
371
+				$attendees[$reg->attendee_ID()]['line_ref'][]            = $evt_id;
372
+				$attendees[$reg->attendee_ID()]['att_obj']               = $reg->attendee();
373
+				$attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()]  = $reg;
374
+				//$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
375
+				$attendees[$reg->attendee_ID()]['attendee_email']          = $reg->attendee() instanceof EE_Attendee
376
+					? $reg->attendee()->email()
377
+					: '';
378
+				$attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket;
379
+				$attendees[$reg->attendee_ID()]['evt_objs'][$evt_id]       = $event;
380
+
381
+				//registrations
382
+				$registrations[$reg->ID()]['tkt_obj'] = $ticket;
383
+				$registrations[$reg->ID()]['evt_obj'] = $event;
384
+				$registrations[$reg->ID()]['reg_obj'] = $reg;
385
+				$registrations[$reg->ID()]['att_obj'] = $reg->attendee();
386
+
387
+				//set up answer objects
388
+				$rel_ans = $reg->get_many_related('Answer');
389
+				foreach ($rel_ans as $ansid => $answer) {
390
+					if (! isset($questions[$ansid])) {
391
+						$questions[$ansid] = $answer->get_first_related('Question');
392
+					}
393
+					$answers[$ansid]                               = $answer;
394
+					$registrations[$reg->ID()]['ans_objs'][$ansid] = $answer;
395
+				}
396
+
397
+				foreach ($relateddatetime as $dtt_id => $datetime) {
398
+					$eventsetup[$evt_id]['dtt_objs'][$dtt_id]       = $datetime;
399
+					$registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime;
400
+
401
+					if (isset($datetimes[$dtt_id])) {
402
+						continue; //already have this info in the datetimes array.
403
+					}
404
+
405
+					$datetimes[$dtt_id]['tkt_objs'][]           = $ticket;
406
+					$datetimes[$dtt_id]['datetime']             = $datetime;
407
+					$datetimes[$dtt_id]['evt_objs'][$evt_id]    = $event;
408
+					$datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg;
409
+				}
410
+			}
411
+
412
+			//let's loop through the unique event=>reg items and setup data on them
413
+
414
+			if (! empty($eventsetup)) {
415
+				foreach ($eventsetup as $evt_id => $items) {
416
+					if ($this->txn instanceof EE_Transaction) {
417
+						$ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
418
+							array(
419
+								array(
420
+									'Ticket.Datetime.EVT_ID' => $evt_id,
421
+									'TXN_ID'                 => $this->txn->ID(),
422
+								),
423
+								'default_where_conditions' => 'none',
424
+							)
425
+						);
426
+					} else {
427
+						$ticket_line_items_for_event = array();
428
+					}
429
+					$events[$evt_id] = array(
430
+						'ID'              => $evt_id,
431
+						'event'           => $evtcache[$evt_id],
432
+						'name'            => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '',
433
+						'total_attendees' => $event_attendee_count[$evt_id],
434
+						'reg_objs'        => $items['reg_objs'],
435
+						'tkt_objs'        => $items['tkt_objs'],
436
+						'att_objs'        => $items['att_objs'],
437
+						'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
438
+						'line_items'      => $ticket_line_items_for_event,
439
+					);
440
+
441
+					//make sure the tickets have the line items setup for them.
442
+					foreach ($ticket_line_items_for_event as $line_id => $line_item) {
443
+						if ($line_item instanceof EE_Line_Item) {
444
+							$tickets[$line_item->ticket()->ID()]['line_item']      = $line_item;
445
+							$tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children();
446
+							$line_items[$line_item->ID()]['children']              = $line_item->children();
447
+							$line_items[$line_item->ID()]['EE_Ticket']             = $line_item->ticket();
448
+						}
449
+					}
450
+				}
451
+			}
452
+
453
+			$this->grand_total_line_item = $this->txn instanceof EE_Transaction
454
+				? $this->txn->total_line_item()
455
+				: null;
456
+		}
457
+
458
+		//lets set the attendees and events properties
459
+		$this->attendees                = $attendees;
460
+		$this->events                   = $events;
461
+		$this->tickets                  = $tickets;
462
+		$this->line_items_with_children = $line_items;
463
+		$this->datetimes                = $datetimes;
464
+		$this->questions                = $questions;
465
+		$this->answers                  = $answers;
466
+		$this->total_ticket_count       = $total_ticket_count;
467
+		$this->registrations            = $registrations;
468
+
469
+		if ($this->txn instanceof EE_Transaction) {
470
+			$this->tax_line_items        = $this->txn->tax_items();
471
+			$this->additional_line_items = $this->txn->non_ticket_line_items();
472
+			$this->payments              = $this->txn->payments();
473
+
474
+			//setup primary registration if we have a single transaction object to work with
475
+
476
+			//let's get just the primary_attendee_data!  First we get the primary registration object.
477
+			$primary_reg = $this->txn->primary_registration();
478
+			// verify
479
+			if ($primary_reg instanceof EE_Registration) {
480
+
481
+				// get attendee object
482
+				if ($primary_reg->attendee() instanceof EE_Attendee) {
483
+
484
+					//now we can setup the primary_attendee_data array
485
+					$this->primary_attendee_data = array(
486
+						'registration_id' => $primary_reg->ID(),
487
+						'att_obj'         => $primary_reg->attendee(),
488
+						'reg_obj'         => $primary_reg,
489
+						'primary_att_obj' => $primary_reg->attendee(),
490
+						'primary_reg_obj' => $primary_reg,
491
+					);
492
+
493
+				} else {
494
+					EE_Error::add_error(
495
+						__(
496
+							'Incoming data does not have a valid Attendee object for the primary registrant.',
497
+							'event_espresso'
498
+						),
499
+						__FILE__,
500
+						__FUNCTION__,
501
+						__LINE__
502
+					);
503
+				}
504
+			} else {
505
+				EE_Error::add_error(
506
+					__(
507
+						'Incoming data does not have a valid Registration object for the primary registrant.',
508
+						'event_espresso'
509
+					),
510
+					__FILE__,
511
+					__FUNCTION__,
512
+					__LINE__
513
+				);
514
+			}
515
+		}
516
+	}
517
+
518
+	/**
519
+	 * This simply considers whether the given registration should be processed or not based on comparison with the
520
+	 * filtered_reg_status property.
521
+	 *
522
+	 * @param EE_Registration $registration
523
+	 * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
524
+	 *               processing
525
+	 */
526
+	protected function _skip_registration_for_processing(EE_Registration $registration)
527
+	{
528
+		if (empty($this->filtered_reg_status)) {
529
+			return false;
530
+		}
531
+
532
+		//if we made it here then we just compare the filtered_reg_status with the registration status and return that
533
+		return $this->filtered_reg_status !== $registration->status_ID();
534
+	}
535 535
 
536 536
 
537 537
 } //end EE_Messages_incoming_data class
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('NO direct script access allowed');
5 5
 }
6 6
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $answers            = $questions = $attendees = $line_items = $registrations = array();
337 337
         $total_ticket_count = 0;
338 338
 
339
-        if (! empty($this->reg_objs)) {
339
+        if ( ! empty($this->reg_objs)) {
340 340
             $event_attendee_count = array();
341 341
             foreach ($this->reg_objs as $reg) {
342 342
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                 //set up answer objects
388 388
                 $rel_ans = $reg->get_many_related('Answer');
389 389
                 foreach ($rel_ans as $ansid => $answer) {
390
-                    if (! isset($questions[$ansid])) {
390
+                    if ( ! isset($questions[$ansid])) {
391 391
                         $questions[$ansid] = $answer->get_first_related('Question');
392 392
                     }
393 393
                     $answers[$ansid]                               = $answer;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 
412 412
             //let's loop through the unique event=>reg items and setup data on them
413 413
 
414
-            if (! empty($eventsetup)) {
414
+            if ( ! empty($eventsetup)) {
415 415
                 foreach ($eventsetup as $evt_id => $items) {
416 416
                     if ($this->txn instanceof EE_Transaction) {
417 417
                         $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.040');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.040');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.