@@ -38,10 +38,10 @@ |
||
38 | 38 | )); |
39 | 39 | $this->_model_relations = array(); |
40 | 40 | foreach ($models_this_can_attach_to as $model) { |
41 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
41 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
42 | 42 | } |
43 | 43 | foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
44 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
44 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
45 | 45 | } |
46 | 46 | parent::__construct($timezone); |
47 | 47 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | class EEM_Extra_Meta extends EEM_Base |
18 | 18 | { |
19 | 19 | |
20 | - // private instance of the Attendee object |
|
21 | - protected static $_instance = null; |
|
20 | + // private instance of the Attendee object |
|
21 | + protected static $_instance = null; |
|
22 | 22 | |
23 | - protected function __construct($timezone = null) |
|
24 | - { |
|
25 | - $this->singular_item = esc_html__('Extra Meta', 'event_espresso'); |
|
26 | - $this->plural_item = esc_html__('Extra Metas', 'event_espresso'); |
|
27 | - $this->_tables = array( |
|
28 | - 'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
29 | - ); |
|
30 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
31 | - $this->_fields = array( |
|
32 | - 'Extra_Meta' => array( |
|
33 | - 'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', esc_html__("Extra Meta ID", "event_espresso")), |
|
34 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', esc_html__("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
35 | - 'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', esc_html__("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
36 | - 'EXM_key' => new EE_Plain_Text_Field('EXM_key', esc_html__("Meta Key", "event_espresso"), false, ''), |
|
37 | - 'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', esc_html__("Meta Value", "event_espresso"), true) |
|
23 | + protected function __construct($timezone = null) |
|
24 | + { |
|
25 | + $this->singular_item = esc_html__('Extra Meta', 'event_espresso'); |
|
26 | + $this->plural_item = esc_html__('Extra Metas', 'event_espresso'); |
|
27 | + $this->_tables = array( |
|
28 | + 'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
29 | + ); |
|
30 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
31 | + $this->_fields = array( |
|
32 | + 'Extra_Meta' => array( |
|
33 | + 'EXM_ID' => new EE_Primary_Key_Int_Field('EXM_ID', esc_html__("Extra Meta ID", "event_espresso")), |
|
34 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', esc_html__("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
35 | + 'EXM_type' => new EE_Any_Foreign_Model_Name_Field('EXM_type', esc_html__("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
36 | + 'EXM_key' => new EE_Plain_Text_Field('EXM_key', esc_html__("Meta Key", "event_espresso"), false, ''), |
|
37 | + 'EXM_value' => new EE_Maybe_Serialized_Text_Field('EXM_value', esc_html__("Meta Value", "event_espresso"), true) |
|
38 | 38 | |
39 | - )); |
|
40 | - $this->_model_relations = array(); |
|
41 | - foreach ($models_this_can_attach_to as $model) { |
|
42 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
43 | - } |
|
44 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
45 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
46 | - } |
|
47 | - parent::__construct($timezone); |
|
48 | - } |
|
39 | + )); |
|
40 | + $this->_model_relations = array(); |
|
41 | + foreach ($models_this_can_attach_to as $model) { |
|
42 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
43 | + } |
|
44 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
45 | + $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
46 | + } |
|
47 | + parent::__construct($timezone); |
|
48 | + } |
|
49 | 49 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | 'WP_User' => new EE_Belongs_To_Relation(), |
46 | 46 | ); |
47 | 47 | // this model is generally available for reading |
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
50 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
49 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
50 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
52 | 52 | parent::__construct($timezone); |
53 | 53 | } |
54 | 54 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function get_latest_question_group_order() |
60 | 60 | { |
61 | 61 | $columns_to_select = array( |
62 | - 'max_order' => array("MAX(QSG_order)","%d") |
|
62 | + 'max_order' => array("MAX(QSG_order)", "%d") |
|
63 | 63 | ); |
64 | 64 | $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
65 | 65 | return $max[0]['max_order']; |
@@ -11,58 +11,58 @@ |
||
11 | 11 | */ |
12 | 12 | class EEM_Question_Group extends EEM_Soft_Delete_Base |
13 | 13 | { |
14 | - const system_personal = 1; |
|
15 | - const system_address = 2; |
|
16 | - // private instance of the Attendee object |
|
17 | - protected static $_instance = null; |
|
14 | + const system_personal = 1; |
|
15 | + const system_address = 2; |
|
16 | + // private instance of the Attendee object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | 19 | |
20 | - protected function __construct($timezone = null) |
|
21 | - { |
|
22 | - $this->singular_item = esc_html__('Question Group', 'event_espresso'); |
|
23 | - $this->plural_item = esc_html__('Question Groups', 'event_espresso'); |
|
20 | + protected function __construct($timezone = null) |
|
21 | + { |
|
22 | + $this->singular_item = esc_html__('Question Group', 'event_espresso'); |
|
23 | + $this->plural_item = esc_html__('Question Groups', 'event_espresso'); |
|
24 | 24 | |
25 | - $this->_tables = array( |
|
26 | - 'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID') |
|
27 | - ); |
|
28 | - $this->_fields = array( |
|
29 | - 'Question_Group' => array( |
|
30 | - 'QSG_ID' => new EE_Primary_Key_Int_Field('QSG_ID', esc_html__('Question Group ID', 'event_espresso')), |
|
31 | - 'QSG_name' => new EE_Plain_Text_Field('QSG_name', esc_html__('Question Group Name', 'event_espresso'), false, ''), |
|
32 | - 'QSG_identifier' => new EE_Plain_Text_Field('QSG_identifier', esc_html__('Text ID for question Group', 'event_espresso'), false, ''), |
|
33 | - 'QSG_desc' => new EE_Post_Content_Field('QSG_desc', esc_html__('Description of Question Group', 'event_espresso'), true, ''), |
|
34 | - 'QSG_order' => new EE_Integer_Field('QSG_order', esc_html__('Order in which to show the question group', 'event_espresso'), true, 0), |
|
35 | - 'QSG_show_group_name' => new EE_Boolean_Field('QSG_show_group_name', esc_html__('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true), |
|
36 | - 'QSG_show_group_desc' => new EE_Boolean_Field('QSG_show_group_desc', esc_html__('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false), |
|
37 | - 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', esc_html__('Question Group Creator ID', 'event_espresso'), false), |
|
38 | - 'QSG_system' => new EE_Integer_Field('QSG_system', esc_html__('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0), |
|
39 | - 'QSG_deleted' => new EE_Trashed_Flag_Field('QSG_deleted', esc_html__('Flag indicating this question group was deleted', 'event_espresso'), false, false) |
|
40 | - ) |
|
41 | - ); |
|
42 | - $this->_model_relations = array( |
|
43 | - 'Question' => new EE_HABTM_Relation('Question_Group_Question'), |
|
44 | - 'Event' => new EE_HABTM_Relation('Event_Question_Group'), |
|
45 | - 'Event_Question_Group' => new EE_Has_Many_Relation(), |
|
46 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
47 | - ); |
|
48 | - // this model is generally available for reading |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
50 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
53 | - parent::__construct($timezone); |
|
54 | - } |
|
55 | - /** |
|
56 | - * searches the db for the question group with the latest question order and returns that value. |
|
57 | - * @access public |
|
58 | - * @return int |
|
59 | - */ |
|
60 | - public function get_latest_question_group_order() |
|
61 | - { |
|
62 | - $columns_to_select = array( |
|
63 | - 'max_order' => array("MAX(QSG_order)","%d") |
|
64 | - ); |
|
65 | - $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
66 | - return $max[0]['max_order']; |
|
67 | - } |
|
25 | + $this->_tables = array( |
|
26 | + 'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID') |
|
27 | + ); |
|
28 | + $this->_fields = array( |
|
29 | + 'Question_Group' => array( |
|
30 | + 'QSG_ID' => new EE_Primary_Key_Int_Field('QSG_ID', esc_html__('Question Group ID', 'event_espresso')), |
|
31 | + 'QSG_name' => new EE_Plain_Text_Field('QSG_name', esc_html__('Question Group Name', 'event_espresso'), false, ''), |
|
32 | + 'QSG_identifier' => new EE_Plain_Text_Field('QSG_identifier', esc_html__('Text ID for question Group', 'event_espresso'), false, ''), |
|
33 | + 'QSG_desc' => new EE_Post_Content_Field('QSG_desc', esc_html__('Description of Question Group', 'event_espresso'), true, ''), |
|
34 | + 'QSG_order' => new EE_Integer_Field('QSG_order', esc_html__('Order in which to show the question group', 'event_espresso'), true, 0), |
|
35 | + 'QSG_show_group_name' => new EE_Boolean_Field('QSG_show_group_name', esc_html__('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true), |
|
36 | + 'QSG_show_group_desc' => new EE_Boolean_Field('QSG_show_group_desc', esc_html__('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false), |
|
37 | + 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', esc_html__('Question Group Creator ID', 'event_espresso'), false), |
|
38 | + 'QSG_system' => new EE_Integer_Field('QSG_system', esc_html__('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0), |
|
39 | + 'QSG_deleted' => new EE_Trashed_Flag_Field('QSG_deleted', esc_html__('Flag indicating this question group was deleted', 'event_espresso'), false, false) |
|
40 | + ) |
|
41 | + ); |
|
42 | + $this->_model_relations = array( |
|
43 | + 'Question' => new EE_HABTM_Relation('Question_Group_Question'), |
|
44 | + 'Event' => new EE_HABTM_Relation('Event_Question_Group'), |
|
45 | + 'Event_Question_Group' => new EE_Has_Many_Relation(), |
|
46 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
47 | + ); |
|
48 | + // this model is generally available for reading |
|
49 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
50 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
51 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
52 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
53 | + parent::__construct($timezone); |
|
54 | + } |
|
55 | + /** |
|
56 | + * searches the db for the question group with the latest question order and returns that value. |
|
57 | + * @access public |
|
58 | + * @return int |
|
59 | + */ |
|
60 | + public function get_latest_question_group_order() |
|
61 | + { |
|
62 | + $columns_to_select = array( |
|
63 | + 'max_order' => array("MAX(QSG_order)","%d") |
|
64 | + ); |
|
65 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
66 | + return $max[0]['max_order']; |
|
67 | + } |
|
68 | 68 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function get_attendee_field_for_system_question($system_question_string) |
286 | 286 | { |
287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
287 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
288 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] |
|
289 | 289 | : null; |
290 | 290 | } |
291 | 291 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | $attendee = $this->get_all(array($where_cols_n_values)); |
356 | - if (! empty($attendee)) { |
|
356 | + if ( ! empty($attendee)) { |
|
357 | 357 | return array_shift($attendee); |
358 | 358 | } |
359 | 359 | return false; |
@@ -13,432 +13,432 @@ |
||
13 | 13 | class EEM_Attendee extends EEM_CPT_Base |
14 | 14 | { |
15 | 15 | |
16 | - // private instance of the Attendee object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the Attendee object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | - /** |
|
20 | - * QST_system for questions are strings not integers now, |
|
21 | - * so these constants are deprecated. |
|
22 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
23 | - * |
|
24 | - * @deprecated |
|
25 | - */ |
|
26 | - const fname_question_id = 1; |
|
19 | + /** |
|
20 | + * QST_system for questions are strings not integers now, |
|
21 | + * so these constants are deprecated. |
|
22 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
23 | + * |
|
24 | + * @deprecated |
|
25 | + */ |
|
26 | + const fname_question_id = 1; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @deprecated |
|
30 | - */ |
|
31 | - const lname_question_id = 2; |
|
28 | + /** |
|
29 | + * @deprecated |
|
30 | + */ |
|
31 | + const lname_question_id = 2; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @deprecated |
|
36 | - */ |
|
37 | - const email_question_id = 3; |
|
34 | + /** |
|
35 | + * @deprecated |
|
36 | + */ |
|
37 | + const email_question_id = 3; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @deprecated |
|
42 | - */ |
|
43 | - const address_question_id = 4; |
|
40 | + /** |
|
41 | + * @deprecated |
|
42 | + */ |
|
43 | + const address_question_id = 4; |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @deprecated |
|
48 | - */ |
|
49 | - const address2_question_id = 5; |
|
46 | + /** |
|
47 | + * @deprecated |
|
48 | + */ |
|
49 | + const address2_question_id = 5; |
|
50 | 50 | |
51 | - |
|
52 | - /** |
|
53 | - * @deprecated |
|
54 | - */ |
|
55 | - const city_question_id = 6; |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @deprecated |
|
60 | - */ |
|
61 | - const state_question_id = 7; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @deprecated |
|
66 | - */ |
|
67 | - const country_question_id = 8; |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @deprecated |
|
72 | - */ |
|
73 | - const zip_question_id = 9; |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @deprecated |
|
78 | - */ |
|
79 | - const phone_question_id = 10; |
|
80 | - |
|
81 | - /** |
|
82 | - * When looking for questions that correspond to attendee fields, |
|
83 | - * look for the question with this QST_system value. |
|
84 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
85 | - */ |
|
86 | - const system_question_fname = 'fname'; |
|
87 | - |
|
88 | - const system_question_lname = 'lname'; |
|
89 | - |
|
90 | - const system_question_email = 'email'; |
|
91 | - |
|
92 | - const system_question_email_confirm = 'email_confirm'; |
|
93 | - |
|
94 | - const system_question_address = 'address'; |
|
95 | - |
|
96 | - const system_question_address2 = 'address2'; |
|
97 | - |
|
98 | - const system_question_city = 'city'; |
|
99 | - |
|
100 | - const system_question_state = 'state'; |
|
101 | - |
|
102 | - const system_question_country = 'country'; |
|
103 | - |
|
104 | - const system_question_zip = 'zip'; |
|
105 | - |
|
106 | - const system_question_phone = 'phone'; |
|
107 | - |
|
108 | - /** |
|
109 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
110 | - * also all the values of QST_system in the questions table, and values |
|
111 | - * are their corresponding Attendee field names |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $_system_question_to_attendee_field_name = array( |
|
116 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
117 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
118 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
119 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
120 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
121 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
122 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
123 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
124 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
125 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
126 | - ); |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * EEM_Attendee constructor. |
|
132 | - * |
|
133 | - * @param null $timezone |
|
134 | - * @param ModelFieldFactory $model_field_factory |
|
135 | - * @throws EE_Error |
|
136 | - * @throws InvalidArgumentException |
|
137 | - */ |
|
138 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
139 | - { |
|
140 | - $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
141 | - $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
142 | - $this->_tables = array( |
|
143 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
144 | - 'Attendee_Meta' => new EE_Secondary_Table( |
|
145 | - 'esp_attendee_meta', |
|
146 | - 'ATTM_ID', |
|
147 | - 'ATT_ID' |
|
148 | - ), |
|
149 | - ); |
|
150 | - $this->_fields = array( |
|
151 | - 'Attendee_CPT' => array( |
|
152 | - 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
153 | - 'ID', |
|
154 | - esc_html__('Attendee ID', 'event_espresso') |
|
155 | - ), |
|
156 | - 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
157 | - 'post_title', |
|
158 | - esc_html__('Attendee Full Name', 'event_espresso'), |
|
159 | - false, |
|
160 | - esc_html__('Unknown', 'event_espresso') |
|
161 | - ), |
|
162 | - 'ATT_bio' => $model_field_factory->createPostContentField( |
|
163 | - 'post_content', |
|
164 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
165 | - false, |
|
166 | - esc_html__('No Biography Provided', 'event_espresso') |
|
167 | - ), |
|
168 | - 'ATT_slug' => $model_field_factory->createSlugField( |
|
169 | - 'post_name', |
|
170 | - esc_html__('Attendee URL Slug', 'event_espresso') |
|
171 | - ), |
|
172 | - 'ATT_created' => $model_field_factory->createDatetimeField( |
|
173 | - 'post_date', |
|
174 | - esc_html__('Time Attendee Created', 'event_espresso') |
|
175 | - ), |
|
176 | - 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
177 | - 'post_excerpt', |
|
178 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
179 | - true, |
|
180 | - esc_html__('No Biography Provided', 'event_espresso') |
|
181 | - ), |
|
182 | - 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
183 | - 'post_modified', |
|
184 | - esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
185 | - ), |
|
186 | - 'ATT_author' => $model_field_factory->createWpUserField( |
|
187 | - 'post_author', |
|
188 | - esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
189 | - false |
|
190 | - ), |
|
191 | - 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
192 | - 'post_parent', |
|
193 | - esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
194 | - false, |
|
195 | - 0 |
|
196 | - ), |
|
197 | - 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
198 | - 'status' => $model_field_factory->createWpPostStatusField( |
|
199 | - 'post_status', |
|
200 | - esc_html__('Attendee Status', 'event_espresso'), |
|
201 | - false, |
|
202 | - 'publish' |
|
203 | - ), |
|
204 | - 'password' => new EE_Password_Field( |
|
205 | - 'post_password', |
|
206 | - esc_html__('Password', 'event_espresso'), |
|
207 | - false, |
|
208 | - '', |
|
209 | - array( |
|
210 | - 'ATT_bio', |
|
211 | - 'ATT_short_bio', |
|
212 | - 'ATT_address', |
|
213 | - 'ATT_address2', |
|
214 | - 'ATT_city', |
|
215 | - 'STA_ID', |
|
216 | - 'CNT_ISO', |
|
217 | - 'ATT_zip', |
|
218 | - 'ATT_email', |
|
219 | - 'ATT_phone' |
|
220 | - ) |
|
221 | - ) |
|
222 | - ), |
|
223 | - 'Attendee_Meta' => array( |
|
224 | - 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
225 | - 'ATTM_ID', |
|
226 | - esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
227 | - false |
|
228 | - ), |
|
229 | - 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
230 | - 'ATT_ID', |
|
231 | - esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
232 | - false |
|
233 | - ), |
|
234 | - 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
235 | - 'ATT_fname', |
|
236 | - esc_html__('First Name', 'event_espresso') |
|
237 | - ), |
|
238 | - 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
239 | - 'ATT_lname', |
|
240 | - esc_html__('Last Name', 'event_espresso') |
|
241 | - ), |
|
242 | - 'ATT_address' => $model_field_factory->createPlainTextField( |
|
243 | - 'ATT_address', |
|
244 | - esc_html__('Address Part 1', 'event_espresso') |
|
245 | - ), |
|
246 | - 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
247 | - 'ATT_address2', |
|
248 | - esc_html__('Address Part 2', 'event_espresso') |
|
249 | - ), |
|
250 | - 'ATT_city' => $model_field_factory->createPlainTextField( |
|
251 | - 'ATT_city', |
|
252 | - esc_html__('City', 'event_espresso') |
|
253 | - ), |
|
254 | - 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
255 | - 'STA_ID', |
|
256 | - esc_html__('State', 'event_espresso'), |
|
257 | - true, |
|
258 | - 0, |
|
259 | - 'State' |
|
260 | - ), |
|
261 | - 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
262 | - 'CNT_ISO', |
|
263 | - esc_html__('Country', 'event_espresso'), |
|
264 | - true, |
|
265 | - '', |
|
266 | - 'Country' |
|
267 | - ), |
|
268 | - 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
269 | - 'ATT_zip', |
|
270 | - esc_html__('ZIP/Postal Code', 'event_espresso') |
|
271 | - ), |
|
272 | - 'ATT_email' => $model_field_factory->createEmailField( |
|
273 | - 'ATT_email', |
|
274 | - esc_html__('Email Address', 'event_espresso') |
|
275 | - ), |
|
276 | - 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
277 | - 'ATT_phone', |
|
278 | - esc_html__('Phone', 'event_espresso') |
|
279 | - ), |
|
280 | - ), |
|
281 | - ); |
|
282 | - $this->_model_relations = array( |
|
283 | - 'Registration' => new EE_Has_Many_Relation(), |
|
284 | - 'State' => new EE_Belongs_To_Relation(), |
|
285 | - 'Country' => new EE_Belongs_To_Relation(), |
|
286 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
287 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
288 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
289 | - // allow deletion of attendees even if they have messages in the queue for them. |
|
290 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
291 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
292 | - ); |
|
293 | - $this->_caps_slug = 'contacts'; |
|
294 | - $this->model_chain_to_password = ''; |
|
295 | - parent::__construct($timezone); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
302 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
303 | - * |
|
304 | - * @param string $system_question_string |
|
305 | - * @return string|null if not found |
|
306 | - */ |
|
307 | - public function get_attendee_field_for_system_question($system_question_string) |
|
308 | - { |
|
309 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
310 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
311 | - : null; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
318 | - * |
|
319 | - * @return array |
|
320 | - */ |
|
321 | - public function system_question_to_attendee_field_mapping() |
|
322 | - { |
|
323 | - return $this->_system_question_to_attendee_field_name; |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
330 | - * |
|
331 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
332 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
333 | - * @throws EE_Error |
|
334 | - */ |
|
335 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
336 | - { |
|
337 | - return $this->get_all( |
|
338 | - array( |
|
339 | - array( |
|
340 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
341 | - ? $transaction_id_or_obj->ID() |
|
342 | - : $transaction_id_or_obj, |
|
343 | - ), |
|
344 | - ) |
|
345 | - ); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * retrieve a single attendee from db via their ID |
|
352 | - * |
|
353 | - * @param $ATT_ID |
|
354 | - * @return mixed array on success, FALSE on fail |
|
355 | - * @deprecated |
|
356 | - */ |
|
357 | - public function get_attendee_by_ID($ATT_ID = false) |
|
358 | - { |
|
359 | - // retrieve a particular EE_Attendee |
|
360 | - return $this->get_one_by_ID($ATT_ID); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * retrieve a single attendee from db via their ID |
|
367 | - * |
|
368 | - * @param array $where_cols_n_values |
|
369 | - * @return mixed array on success, FALSE on fail |
|
370 | - * @throws EE_Error |
|
371 | - */ |
|
372 | - public function get_attendee($where_cols_n_values = array()) |
|
373 | - { |
|
374 | - if (empty($where_cols_n_values)) { |
|
375 | - return false; |
|
376 | - } |
|
377 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
378 | - if (! empty($attendee)) { |
|
379 | - return array_shift($attendee); |
|
380 | - } |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * Search for an existing Attendee record in the DB |
|
388 | - * |
|
389 | - * @param array $where_cols_n_values |
|
390 | - * @return bool|mixed |
|
391 | - * @throws EE_Error |
|
392 | - */ |
|
393 | - public function find_existing_attendee($where_cols_n_values = null) |
|
394 | - { |
|
395 | - // search by combo of first and last names plus the email address |
|
396 | - $attendee_data_keys = array( |
|
397 | - 'ATT_fname' => $this->_ATT_fname, |
|
398 | - 'ATT_lname' => $this->_ATT_lname, |
|
399 | - 'ATT_email' => $this->_ATT_email, |
|
400 | - ); |
|
401 | - // no search params means attendee object already exists. |
|
402 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
403 | - ? $where_cols_n_values |
|
404 | - : $attendee_data_keys; |
|
405 | - $valid_data = true; |
|
406 | - // check for required values |
|
407 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
408 | - ? $valid_data |
|
409 | - : false; |
|
410 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
411 | - ? $valid_data |
|
412 | - : false; |
|
413 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
414 | - ? $valid_data |
|
415 | - : false; |
|
416 | - if ($valid_data) { |
|
417 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
418 | - if ($attendee instanceof EE_Attendee) { |
|
419 | - return $attendee; |
|
420 | - } |
|
421 | - } |
|
422 | - return false; |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * Takes an incoming array of EE_Registration ids |
|
429 | - * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
430 | - * |
|
431 | - * @since 4.3.0 |
|
432 | - * @param array $ids array of EE_Registration ids |
|
433 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
434 | - * @throws EE_Error |
|
435 | - */ |
|
436 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
437 | - { |
|
438 | - $ids = (array) $ids; |
|
439 | - $_where = array( |
|
440 | - 'Registration.REG_ID' => array('in', $ids), |
|
441 | - ); |
|
442 | - return $this->get_all(array($_where)); |
|
443 | - } |
|
51 | + |
|
52 | + /** |
|
53 | + * @deprecated |
|
54 | + */ |
|
55 | + const city_question_id = 6; |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @deprecated |
|
60 | + */ |
|
61 | + const state_question_id = 7; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @deprecated |
|
66 | + */ |
|
67 | + const country_question_id = 8; |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @deprecated |
|
72 | + */ |
|
73 | + const zip_question_id = 9; |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @deprecated |
|
78 | + */ |
|
79 | + const phone_question_id = 10; |
|
80 | + |
|
81 | + /** |
|
82 | + * When looking for questions that correspond to attendee fields, |
|
83 | + * look for the question with this QST_system value. |
|
84 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
85 | + */ |
|
86 | + const system_question_fname = 'fname'; |
|
87 | + |
|
88 | + const system_question_lname = 'lname'; |
|
89 | + |
|
90 | + const system_question_email = 'email'; |
|
91 | + |
|
92 | + const system_question_email_confirm = 'email_confirm'; |
|
93 | + |
|
94 | + const system_question_address = 'address'; |
|
95 | + |
|
96 | + const system_question_address2 = 'address2'; |
|
97 | + |
|
98 | + const system_question_city = 'city'; |
|
99 | + |
|
100 | + const system_question_state = 'state'; |
|
101 | + |
|
102 | + const system_question_country = 'country'; |
|
103 | + |
|
104 | + const system_question_zip = 'zip'; |
|
105 | + |
|
106 | + const system_question_phone = 'phone'; |
|
107 | + |
|
108 | + /** |
|
109 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
110 | + * also all the values of QST_system in the questions table, and values |
|
111 | + * are their corresponding Attendee field names |
|
112 | + * |
|
113 | + * @var array |
|
114 | + */ |
|
115 | + protected $_system_question_to_attendee_field_name = array( |
|
116 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
117 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
118 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
119 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
120 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
121 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
122 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
123 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
124 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
125 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
126 | + ); |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * EEM_Attendee constructor. |
|
132 | + * |
|
133 | + * @param null $timezone |
|
134 | + * @param ModelFieldFactory $model_field_factory |
|
135 | + * @throws EE_Error |
|
136 | + * @throws InvalidArgumentException |
|
137 | + */ |
|
138 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
139 | + { |
|
140 | + $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
141 | + $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
142 | + $this->_tables = array( |
|
143 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
144 | + 'Attendee_Meta' => new EE_Secondary_Table( |
|
145 | + 'esp_attendee_meta', |
|
146 | + 'ATTM_ID', |
|
147 | + 'ATT_ID' |
|
148 | + ), |
|
149 | + ); |
|
150 | + $this->_fields = array( |
|
151 | + 'Attendee_CPT' => array( |
|
152 | + 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
153 | + 'ID', |
|
154 | + esc_html__('Attendee ID', 'event_espresso') |
|
155 | + ), |
|
156 | + 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
157 | + 'post_title', |
|
158 | + esc_html__('Attendee Full Name', 'event_espresso'), |
|
159 | + false, |
|
160 | + esc_html__('Unknown', 'event_espresso') |
|
161 | + ), |
|
162 | + 'ATT_bio' => $model_field_factory->createPostContentField( |
|
163 | + 'post_content', |
|
164 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
165 | + false, |
|
166 | + esc_html__('No Biography Provided', 'event_espresso') |
|
167 | + ), |
|
168 | + 'ATT_slug' => $model_field_factory->createSlugField( |
|
169 | + 'post_name', |
|
170 | + esc_html__('Attendee URL Slug', 'event_espresso') |
|
171 | + ), |
|
172 | + 'ATT_created' => $model_field_factory->createDatetimeField( |
|
173 | + 'post_date', |
|
174 | + esc_html__('Time Attendee Created', 'event_espresso') |
|
175 | + ), |
|
176 | + 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
177 | + 'post_excerpt', |
|
178 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
179 | + true, |
|
180 | + esc_html__('No Biography Provided', 'event_espresso') |
|
181 | + ), |
|
182 | + 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
183 | + 'post_modified', |
|
184 | + esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
185 | + ), |
|
186 | + 'ATT_author' => $model_field_factory->createWpUserField( |
|
187 | + 'post_author', |
|
188 | + esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
189 | + false |
|
190 | + ), |
|
191 | + 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
192 | + 'post_parent', |
|
193 | + esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
194 | + false, |
|
195 | + 0 |
|
196 | + ), |
|
197 | + 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
198 | + 'status' => $model_field_factory->createWpPostStatusField( |
|
199 | + 'post_status', |
|
200 | + esc_html__('Attendee Status', 'event_espresso'), |
|
201 | + false, |
|
202 | + 'publish' |
|
203 | + ), |
|
204 | + 'password' => new EE_Password_Field( |
|
205 | + 'post_password', |
|
206 | + esc_html__('Password', 'event_espresso'), |
|
207 | + false, |
|
208 | + '', |
|
209 | + array( |
|
210 | + 'ATT_bio', |
|
211 | + 'ATT_short_bio', |
|
212 | + 'ATT_address', |
|
213 | + 'ATT_address2', |
|
214 | + 'ATT_city', |
|
215 | + 'STA_ID', |
|
216 | + 'CNT_ISO', |
|
217 | + 'ATT_zip', |
|
218 | + 'ATT_email', |
|
219 | + 'ATT_phone' |
|
220 | + ) |
|
221 | + ) |
|
222 | + ), |
|
223 | + 'Attendee_Meta' => array( |
|
224 | + 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
225 | + 'ATTM_ID', |
|
226 | + esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
227 | + false |
|
228 | + ), |
|
229 | + 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
230 | + 'ATT_ID', |
|
231 | + esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
232 | + false |
|
233 | + ), |
|
234 | + 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
235 | + 'ATT_fname', |
|
236 | + esc_html__('First Name', 'event_espresso') |
|
237 | + ), |
|
238 | + 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
239 | + 'ATT_lname', |
|
240 | + esc_html__('Last Name', 'event_espresso') |
|
241 | + ), |
|
242 | + 'ATT_address' => $model_field_factory->createPlainTextField( |
|
243 | + 'ATT_address', |
|
244 | + esc_html__('Address Part 1', 'event_espresso') |
|
245 | + ), |
|
246 | + 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
247 | + 'ATT_address2', |
|
248 | + esc_html__('Address Part 2', 'event_espresso') |
|
249 | + ), |
|
250 | + 'ATT_city' => $model_field_factory->createPlainTextField( |
|
251 | + 'ATT_city', |
|
252 | + esc_html__('City', 'event_espresso') |
|
253 | + ), |
|
254 | + 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
255 | + 'STA_ID', |
|
256 | + esc_html__('State', 'event_espresso'), |
|
257 | + true, |
|
258 | + 0, |
|
259 | + 'State' |
|
260 | + ), |
|
261 | + 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
262 | + 'CNT_ISO', |
|
263 | + esc_html__('Country', 'event_espresso'), |
|
264 | + true, |
|
265 | + '', |
|
266 | + 'Country' |
|
267 | + ), |
|
268 | + 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
269 | + 'ATT_zip', |
|
270 | + esc_html__('ZIP/Postal Code', 'event_espresso') |
|
271 | + ), |
|
272 | + 'ATT_email' => $model_field_factory->createEmailField( |
|
273 | + 'ATT_email', |
|
274 | + esc_html__('Email Address', 'event_espresso') |
|
275 | + ), |
|
276 | + 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
277 | + 'ATT_phone', |
|
278 | + esc_html__('Phone', 'event_espresso') |
|
279 | + ), |
|
280 | + ), |
|
281 | + ); |
|
282 | + $this->_model_relations = array( |
|
283 | + 'Registration' => new EE_Has_Many_Relation(), |
|
284 | + 'State' => new EE_Belongs_To_Relation(), |
|
285 | + 'Country' => new EE_Belongs_To_Relation(), |
|
286 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
287 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
288 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
289 | + // allow deletion of attendees even if they have messages in the queue for them. |
|
290 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
291 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
292 | + ); |
|
293 | + $this->_caps_slug = 'contacts'; |
|
294 | + $this->model_chain_to_password = ''; |
|
295 | + parent::__construct($timezone); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
302 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
303 | + * |
|
304 | + * @param string $system_question_string |
|
305 | + * @return string|null if not found |
|
306 | + */ |
|
307 | + public function get_attendee_field_for_system_question($system_question_string) |
|
308 | + { |
|
309 | + return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
310 | + ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
311 | + : null; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
318 | + * |
|
319 | + * @return array |
|
320 | + */ |
|
321 | + public function system_question_to_attendee_field_mapping() |
|
322 | + { |
|
323 | + return $this->_system_question_to_attendee_field_name; |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
330 | + * |
|
331 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
332 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
333 | + * @throws EE_Error |
|
334 | + */ |
|
335 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
336 | + { |
|
337 | + return $this->get_all( |
|
338 | + array( |
|
339 | + array( |
|
340 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
341 | + ? $transaction_id_or_obj->ID() |
|
342 | + : $transaction_id_or_obj, |
|
343 | + ), |
|
344 | + ) |
|
345 | + ); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * retrieve a single attendee from db via their ID |
|
352 | + * |
|
353 | + * @param $ATT_ID |
|
354 | + * @return mixed array on success, FALSE on fail |
|
355 | + * @deprecated |
|
356 | + */ |
|
357 | + public function get_attendee_by_ID($ATT_ID = false) |
|
358 | + { |
|
359 | + // retrieve a particular EE_Attendee |
|
360 | + return $this->get_one_by_ID($ATT_ID); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * retrieve a single attendee from db via their ID |
|
367 | + * |
|
368 | + * @param array $where_cols_n_values |
|
369 | + * @return mixed array on success, FALSE on fail |
|
370 | + * @throws EE_Error |
|
371 | + */ |
|
372 | + public function get_attendee($where_cols_n_values = array()) |
|
373 | + { |
|
374 | + if (empty($where_cols_n_values)) { |
|
375 | + return false; |
|
376 | + } |
|
377 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
378 | + if (! empty($attendee)) { |
|
379 | + return array_shift($attendee); |
|
380 | + } |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * Search for an existing Attendee record in the DB |
|
388 | + * |
|
389 | + * @param array $where_cols_n_values |
|
390 | + * @return bool|mixed |
|
391 | + * @throws EE_Error |
|
392 | + */ |
|
393 | + public function find_existing_attendee($where_cols_n_values = null) |
|
394 | + { |
|
395 | + // search by combo of first and last names plus the email address |
|
396 | + $attendee_data_keys = array( |
|
397 | + 'ATT_fname' => $this->_ATT_fname, |
|
398 | + 'ATT_lname' => $this->_ATT_lname, |
|
399 | + 'ATT_email' => $this->_ATT_email, |
|
400 | + ); |
|
401 | + // no search params means attendee object already exists. |
|
402 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
403 | + ? $where_cols_n_values |
|
404 | + : $attendee_data_keys; |
|
405 | + $valid_data = true; |
|
406 | + // check for required values |
|
407 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
408 | + ? $valid_data |
|
409 | + : false; |
|
410 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
411 | + ? $valid_data |
|
412 | + : false; |
|
413 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
414 | + ? $valid_data |
|
415 | + : false; |
|
416 | + if ($valid_data) { |
|
417 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
418 | + if ($attendee instanceof EE_Attendee) { |
|
419 | + return $attendee; |
|
420 | + } |
|
421 | + } |
|
422 | + return false; |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * Takes an incoming array of EE_Registration ids |
|
429 | + * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
430 | + * |
|
431 | + * @since 4.3.0 |
|
432 | + * @param array $ids array of EE_Registration ids |
|
433 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
434 | + * @throws EE_Error |
|
435 | + */ |
|
436 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
437 | + { |
|
438 | + $ids = (array) $ids; |
|
439 | + $_where = array( |
|
440 | + 'Registration.REG_ID' => array('in', $ids), |
|
441 | + ); |
|
442 | + return $this->get_all(array($_where)); |
|
443 | + } |
|
444 | 444 | } |
@@ -59,11 +59,11 @@ |
||
59 | 59 | ); |
60 | 60 | $this->_model_relations = array(); |
61 | 61 | foreach ($models_this_can_attach_to as $model) { |
62 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
62 | + $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
63 | 63 | } |
64 | 64 | $this->_wp_core_model = true; |
65 | 65 | foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
66 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
66 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
67 | 67 | 'meta_key', |
68 | 68 | 'meta_value' |
69 | 69 | ); |
@@ -19,56 +19,56 @@ |
||
19 | 19 | class EEM_Post_Meta extends EEM_Base |
20 | 20 | { |
21 | 21 | |
22 | - // private instance of the EE_Post_Meta object |
|
23 | - protected static $_instance = null; |
|
22 | + // private instance of the EE_Post_Meta object |
|
23 | + protected static $_instance = null; |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - protected function __construct($timezone = null) |
|
28 | - { |
|
29 | - $this->singular_item = esc_html__('Post Meta', 'event_espresso'); |
|
30 | - $this->plural_item = esc_html__('Post Metas', 'event_espresso'); |
|
31 | - $this->_tables = array( |
|
32 | - 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
33 | - ); |
|
34 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
35 | - $this->_fields = array( |
|
36 | - 'Post_Meta' => array( |
|
37 | - 'meta_id' => new EE_Primary_Key_Int_Field( |
|
38 | - 'meta_id', |
|
39 | - esc_html__("Meta ID", "event_espresso") |
|
40 | - ), |
|
41 | - 'post_id' => new EE_Foreign_Key_Int_Field( |
|
42 | - 'post_id', |
|
43 | - esc_html__("Primary Key of Post", "event_espresso"), |
|
44 | - false, |
|
45 | - 0, |
|
46 | - $models_this_can_attach_to |
|
47 | - ), |
|
48 | - 'meta_key' => new EE_Plain_Text_Field( |
|
49 | - 'meta_key', |
|
50 | - esc_html__("Meta Key", "event_espresso"), |
|
51 | - false, |
|
52 | - '' |
|
53 | - ), |
|
54 | - 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
55 | - 'meta_value', |
|
56 | - esc_html__("Meta Value", "event_espresso"), |
|
57 | - true |
|
58 | - ), |
|
59 | - ), |
|
60 | - ); |
|
61 | - $this->_model_relations = array(); |
|
62 | - foreach ($models_this_can_attach_to as $model) { |
|
63 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
64 | - } |
|
65 | - $this->_wp_core_model = true; |
|
66 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
67 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
68 | - 'meta_key', |
|
69 | - 'meta_value' |
|
70 | - ); |
|
71 | - } |
|
72 | - parent::__construct($timezone); |
|
73 | - } |
|
27 | + protected function __construct($timezone = null) |
|
28 | + { |
|
29 | + $this->singular_item = esc_html__('Post Meta', 'event_espresso'); |
|
30 | + $this->plural_item = esc_html__('Post Metas', 'event_espresso'); |
|
31 | + $this->_tables = array( |
|
32 | + 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
33 | + ); |
|
34 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
35 | + $this->_fields = array( |
|
36 | + 'Post_Meta' => array( |
|
37 | + 'meta_id' => new EE_Primary_Key_Int_Field( |
|
38 | + 'meta_id', |
|
39 | + esc_html__("Meta ID", "event_espresso") |
|
40 | + ), |
|
41 | + 'post_id' => new EE_Foreign_Key_Int_Field( |
|
42 | + 'post_id', |
|
43 | + esc_html__("Primary Key of Post", "event_espresso"), |
|
44 | + false, |
|
45 | + 0, |
|
46 | + $models_this_can_attach_to |
|
47 | + ), |
|
48 | + 'meta_key' => new EE_Plain_Text_Field( |
|
49 | + 'meta_key', |
|
50 | + esc_html__("Meta Key", "event_espresso"), |
|
51 | + false, |
|
52 | + '' |
|
53 | + ), |
|
54 | + 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
55 | + 'meta_value', |
|
56 | + esc_html__("Meta Value", "event_espresso"), |
|
57 | + true |
|
58 | + ), |
|
59 | + ), |
|
60 | + ); |
|
61 | + $this->_model_relations = array(); |
|
62 | + foreach ($models_this_can_attach_to as $model) { |
|
63 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
64 | + } |
|
65 | + $this->_wp_core_model = true; |
|
66 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
67 | + $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
68 | + 'meta_key', |
|
69 | + 'meta_value' |
|
70 | + ); |
|
71 | + } |
|
72 | + parent::__construct($timezone); |
|
73 | + } |
|
74 | 74 | } |
@@ -7,77 +7,77 @@ |
||
7 | 7 | class EE_Float_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('number'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('number'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | - * Returns a float |
|
28 | - * |
|
29 | - * @param type $value_inputted_for_field_on_model_object |
|
30 | - * @return float |
|
31 | - */ |
|
32 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | - { |
|
23 | + /** |
|
24 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | + * Returns a float |
|
28 | + * |
|
29 | + * @param type $value_inputted_for_field_on_model_object |
|
30 | + * @return float |
|
31 | + */ |
|
32 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | + { |
|
34 | 34 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
35 | - // remove whitespaces and thousands separators |
|
36 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | - $value_inputted_for_field_on_model_object = str_replace( |
|
38 | - array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | - "", |
|
40 | - $value_inputted_for_field_on_model_object |
|
41 | - ); |
|
35 | + // remove whitespaces and thousands separators |
|
36 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | + $value_inputted_for_field_on_model_object = str_replace( |
|
38 | + array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | + "", |
|
40 | + $value_inputted_for_field_on_model_object |
|
41 | + ); |
|
42 | 42 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
43 | 43 | // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
44 | - $value_inputted_for_field_on_model_object = str_replace( |
|
45 | - EE_Config::instance()->currency->dec_mrk, |
|
46 | - ".", |
|
47 | - $value_inputted_for_field_on_model_object |
|
48 | - ); |
|
44 | + $value_inputted_for_field_on_model_object = str_replace( |
|
45 | + EE_Config::instance()->currency->dec_mrk, |
|
46 | + ".", |
|
47 | + $value_inputted_for_field_on_model_object |
|
48 | + ); |
|
49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
50 | 50 | // double-check there's absolutely nothing left on this string besides numbers |
51 | - $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | - "/[^0-9,.]/", |
|
53 | - "", |
|
54 | - $value_inputted_for_field_on_model_object |
|
55 | - ); |
|
56 | - } |
|
51 | + $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | + "/[^0-9,.]/", |
|
53 | + "", |
|
54 | + $value_inputted_for_field_on_model_object |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
58 | - return floatval($value_inputted_for_field_on_model_object); |
|
59 | - } |
|
58 | + return floatval($value_inputted_for_field_on_model_object); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | - * |
|
64 | - * @param float $value_on_field_to_be_outputted |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | - { |
|
69 | - $EE = EE_Registry::instance(); |
|
70 | - return number_format( |
|
71 | - $value_on_field_to_be_outputted, |
|
72 | - $EE->CFG->currency->dec_plc, |
|
73 | - $EE->CFG->currency->dec_mrk, |
|
74 | - $EE->CFG->currency->thsnds |
|
75 | - ); |
|
76 | - } |
|
61 | + /** |
|
62 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | + * |
|
64 | + * @param float $value_on_field_to_be_outputted |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | + { |
|
69 | + $EE = EE_Registry::instance(); |
|
70 | + return number_format( |
|
71 | + $value_on_field_to_be_outputted, |
|
72 | + $EE->CFG->currency->dec_plc, |
|
73 | + $EE->CFG->currency->dec_mrk, |
|
74 | + $EE->CFG->currency->thsnds |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | - { |
|
78 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | + { |
|
80 | 80 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
81 | - return floatval($value_found_in_db_for_model_object); |
|
82 | - } |
|
81 | + return floatval($value_found_in_db_for_model_object); |
|
82 | + } |
|
83 | 83 | } |
@@ -6,14 +6,14 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * makes it all upper case, and key-like |
|
11 | - * |
|
12 | - * @param string $value_inputted_for_field_on_model_object |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | - { |
|
17 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | - } |
|
9 | + /** |
|
10 | + * makes it all upper case, and key-like |
|
11 | + * |
|
12 | + * @param string $value_inputted_for_field_on_model_object |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | + { |
|
17 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | + } |
|
19 | 19 | } |
@@ -7,49 +7,49 @@ |
||
7 | 7 | abstract class EE_Text_Field_Base extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Gets the value in the format expected when being set. |
|
12 | - * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | - * @param mixed $value_of_field_on_model_object |
|
14 | - * @return mixed|string |
|
15 | - */ |
|
16 | - public function prepare_for_get($value_of_field_on_model_object) |
|
17 | - { |
|
18 | - return $value_of_field_on_model_object; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Gets the value in the format expected when being set. |
|
12 | + * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | + * @param mixed $value_of_field_on_model_object |
|
14 | + * @return mixed|string |
|
15 | + */ |
|
16 | + public function prepare_for_get($value_of_field_on_model_object) |
|
17 | + { |
|
18 | + return $value_of_field_on_model_object; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | - * |
|
24 | - * @param string $value_on_field_to_be_outputted |
|
25 | - * @param string $schema |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | - { |
|
30 | - if ($schema === 'form_input') { |
|
31 | - $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | - $value_on_field_to_be_outputted, |
|
33 | - ENT_QUOTES, |
|
34 | - 'UTF-8' |
|
35 | - ); |
|
36 | - } |
|
37 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | - } |
|
21 | + /** |
|
22 | + * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | + * |
|
24 | + * @param string $value_on_field_to_be_outputted |
|
25 | + * @param string $schema |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | + { |
|
30 | + if ($schema === 'form_input') { |
|
31 | + $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | + $value_on_field_to_be_outputted, |
|
33 | + ENT_QUOTES, |
|
34 | + 'UTF-8' |
|
35 | + ); |
|
36 | + } |
|
37 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | - * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | - * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | - * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | - * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | - * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | - * |
|
48 | - * @param string $value_inputted_for_field_on_model_object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | - { |
|
53 | - return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | - } |
|
40 | + /** |
|
41 | + * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | + * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | + * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | + * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | + * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | + * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | + * |
|
48 | + * @param string $value_inputted_for_field_on_model_object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | + { |
|
53 | + return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | + } |
|
55 | 55 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | class EE_Slug_Field extends EE_Text_Field_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * ensures string is usable in URLs |
|
7 | - * |
|
8 | - * @param string $value_inputted_for_field_on_model_object |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | - { |
|
13 | - // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | - return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | - } |
|
5 | + /** |
|
6 | + * ensures string is usable in URLs |
|
7 | + * |
|
8 | + * @param string $value_inputted_for_field_on_model_object |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | + { |
|
13 | + // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | + return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | + } |
|
16 | 16 | } |
@@ -3,27 +3,27 @@ |
||
3 | 3 | class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base |
4 | 4 | { |
5 | 5 | |
6 | - public function __construct($table_column, $nicename) |
|
7 | - { |
|
8 | - parent::__construct($table_column, $nicename, 0); |
|
9 | - $this->setSchemaType('integer'); |
|
10 | - } |
|
6 | + public function __construct($table_column, $nicename) |
|
7 | + { |
|
8 | + parent::__construct($table_column, $nicename, 0); |
|
9 | + $this->setSchemaType('integer'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | - } |
|
17 | - return absint($value_inputted_for_field_on_model_object); |
|
18 | - } |
|
12 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | + } |
|
17 | + return absint($value_inputted_for_field_on_model_object); |
|
18 | + } |
|
19 | 19 | |
20 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | - { |
|
22 | - return intval($value_found_in_db_for_model_object); |
|
23 | - } |
|
20 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | + { |
|
22 | + return intval($value_found_in_db_for_model_object); |
|
23 | + } |
|
24 | 24 | |
25 | - public function is_auto_increment() |
|
26 | - { |
|
27 | - return true; |
|
28 | - } |
|
25 | + public function is_auto_increment() |
|
26 | + { |
|
27 | + return true; |
|
28 | + } |
|
29 | 29 | } |