1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
13 | class EEM_Attendee extends EEM_CPT_Base { |
||
14 | |||
15 | // private instance of the Attendee object |
||
16 | protected static $_instance = NULL; |
||
17 | |||
18 | /** |
||
19 | * QST_system for questions are strings not ints now, |
||
20 | * so these constants are deprecated. |
||
21 | * Please instead use the EEM_Attendee::system_question_* constants |
||
22 | * @deprecated |
||
23 | */ |
||
24 | const fname_question_id=1; |
||
25 | |||
26 | /** |
||
27 | * @deprecated |
||
28 | */ |
||
29 | const lname_question_id=2; |
||
30 | |||
31 | |||
32 | /** |
||
33 | * @deprecated |
||
34 | */ |
||
35 | const email_question_id=3; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @deprecated |
||
40 | */ |
||
41 | const address_question_id=4; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * @deprecated |
||
46 | */ |
||
47 | const address2_question_id=5; |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @deprecated |
||
52 | */ |
||
53 | const city_question_id=6; |
||
54 | |||
55 | |||
56 | /** |
||
57 | * @deprecated |
||
58 | */ |
||
59 | const state_question_id=7; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * @deprecated |
||
64 | */ |
||
65 | const country_question_id=8; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * @deprecated |
||
70 | */ |
||
71 | const zip_question_id=9; |
||
72 | |||
73 | |||
74 | /** |
||
75 | * @deprecated |
||
76 | */ |
||
77 | const phone_question_id=10; |
||
78 | |||
79 | /** |
||
80 | * When looking for questions that correspond to attendee fields, |
||
81 | * look for the question with this QST_system value. |
||
82 | * These replace the old constants like EEM_Attendee::*_question_id |
||
83 | */ |
||
84 | const system_question_fname = 'fname'; |
||
85 | const system_question_lname = 'lname'; |
||
86 | const system_question_email = 'email'; |
||
87 | const system_question_address = 'address'; |
||
88 | const system_question_address2 = 'address2'; |
||
89 | const system_question_city = 'city'; |
||
90 | const system_question_state = 'state'; |
||
91 | const system_question_country = 'country'; |
||
92 | const system_question_zip = 'zip'; |
||
93 | const system_question_phone = 'phone'; |
||
94 | |||
95 | /** |
||
96 | * Keys are all the EEM_Attendee::system_question_* constants, which are |
||
97 | * also all the values of QST_system in the questions table, and values |
||
98 | * are their corresponding Attendee field names |
||
99 | * @var array |
||
100 | */ |
||
101 | protected $_system_question_to_attendee_field_name = array( |
||
102 | EEM_Attendee::system_question_fname => 'ATT_fname', |
||
103 | EEM_Attendee::system_question_lname => 'ATT_lname', |
||
104 | EEM_Attendee::system_question_email => 'ATT_email', |
||
105 | EEM_Attendee::system_question_address => 'ATT_address', |
||
106 | EEM_Attendee::system_question_address2 => 'ATT_address2', |
||
107 | EEM_Attendee::system_question_city => 'ATT_city', |
||
108 | EEM_Attendee::system_question_state => 'STA_ID', |
||
109 | EEM_Attendee::system_question_country => 'CNT_ISO', |
||
110 | EEM_Attendee::system_question_zip => 'ATT_zip', |
||
111 | EEM_Attendee::system_question_phone => 'ATT_phone', |
||
112 | ); |
||
113 | |||
114 | |||
115 | /** |
||
116 | * private constructor to prevent direct creation |
||
117 | * |
||
118 | * @Constructor |
||
119 | * @access protected |
||
120 | * @param null $timezone |
||
121 | */ |
||
122 | protected function __construct( $timezone = NULL ) { |
||
123 | $this->singular_item = __('Attendee','event_espresso'); |
||
124 | $this->plural_item = __('Attendees','event_espresso'); |
||
125 | $this->_tables = array( |
||
|
|||
126 | 'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'), |
||
127 | 'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID') |
||
128 | ); |
||
129 | $this->_fields = array( |
||
130 | 'Attendee_CPT'=>array( |
||
131 | 'ATT_ID'=>new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")), |
||
132 | 'ATT_full_name'=>new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"), false, __("Unknown", "event_espresso")), |
||
133 | 'ATT_bio'=>new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"), false, __("No Biography Provided", "event_espresso")), |
||
134 | 'ATT_slug'=>new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false), |
||
135 | 'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, time()), |
||
136 | 'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), |
||
137 | 'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, time()), |
||
138 | 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ), |
||
139 | 'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0), |
||
140 | 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
||
141 | 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish') |
||
142 | ), |
||
143 | 'Attendee_Meta'=>array( |
||
144 | 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false), |
||
145 | 'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
||
146 | 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''), |
||
147 | 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''), |
||
148 | 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''), |
||
149 | 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''), |
||
150 | 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''), |
||
151 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'), |
||
152 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'), |
||
153 | 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''), |
||
154 | 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''), |
||
155 | 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '') |
||
156 | )); |
||
157 | $this->_model_relations = array( |
||
158 | 'Registration'=>new EE_Has_Many_Relation(), |
||
159 | 'State'=>new EE_Belongs_To_Relation(), |
||
160 | 'Country'=>new EE_Belongs_To_Relation(), |
||
161 | 'Event'=>new EE_HABTM_Relation('Registration', FALSE ), |
||
162 | 'WP_User' => new EE_Belongs_To_Relation(), |
||
163 | 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletion of attendees even if they have messages in the queue for them. |
||
164 | ); |
||
165 | $this->_caps_slug = 'contacts'; |
||
166 | parent::__construct( $timezone ); |
||
167 | |||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Gets the name of the field on the attendee model corresponding to the system question string |
||
172 | * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
||
173 | * @param string $system_question_string |
||
174 | * @return string|null if not found |
||
175 | */ |
||
176 | public function get_attendee_field_for_system_question( $system_question_string ) { |
||
179 | |||
180 | |||
181 | |||
182 | |||
183 | /** |
||
184 | * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
||
185 | * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID |
||
186 | * @return EE_Attendee[] |
||
187 | */ |
||
188 | public function get_attendees_for_transaction( $transaction_id_or_obj ){ |
||
189 | return $this->get_all( array( array( |
||
190 | 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj |
||
191 | ))); |
||
192 | } |
||
193 | |||
194 | |||
195 | |||
196 | /** |
||
197 | * retrieve a single attendee from db via their ID |
||
198 | * |
||
199 | * @access public |
||
200 | * @param $ATT_ID |
||
201 | * @return mixed array on success, FALSE on fail |
||
202 | * @deprecated |
||
203 | */ |
||
204 | public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
||
208 | |||
209 | |||
210 | |||
211 | |||
212 | /** |
||
213 | * retrieve a single attendee from db via their ID |
||
214 | * |
||
215 | * @access public |
||
216 | * @param array $where_cols_n_values |
||
217 | * @return mixed array on success, FALSE on fail |
||
218 | */ |
||
219 | public function get_attendee( $where_cols_n_values = array() ) { |
||
232 | |||
233 | |||
234 | |||
235 | /** |
||
236 | * Search for an existing Attendee record in the DB |
||
237 | * |
||
238 | * @access public |
||
239 | * @param array $where_cols_n_values |
||
240 | * @return bool|mixed |
||
241 | */ |
||
242 | public function find_existing_attendee( $where_cols_n_values = NULL ) { |
||
262 | |||
263 | |||
264 | |||
265 | /** |
||
266 | * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate |
||
267 | * EE_Attendee objects. |
||
268 | * |
||
269 | * @since 4.3.0 |
||
270 | * @param array $ids array of EE_Registration ids |
||
271 | * @return EE_Attendee[] |
||
272 | */ |
||
273 | public function get_array_of_contacts_from_reg_ids( $ids ) { |
||
280 | |||
281 | |||
282 | } |
||
283 | // End of file EEM_Attendee.model.php |
||
285 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..