@@ -11,31 +11,31 @@ |
||
11 | 11 | */ |
12 | 12 | class EEM_Currency_Payment_Method extends EEM_Base |
13 | 13 | { |
14 | - // private instance of the Attendee object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the Attendee object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | - protected function __construct($timezone = null) |
|
19 | - { |
|
20 | - $this->singular_item = __('Currency Usable by Payment Method', 'event_espresso'); |
|
21 | - $this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso'); |
|
22 | - $this->_tables = array( |
|
23 | - 'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID') |
|
24 | - ); |
|
25 | - $this->_fields = array( |
|
26 | - 'Currency_Payment_Method'=>array( |
|
27 | - 'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')), |
|
28 | - 'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'), |
|
29 | - 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method') |
|
30 | - ) |
|
31 | - ); |
|
32 | - $this->_model_relations = array( |
|
33 | - 'Currency'=>new EE_Belongs_To_Relation(), |
|
34 | - 'Payment_Method'=>new EE_Belongs_To_Relation() |
|
35 | - ); |
|
36 | - // this model is generally available for reading |
|
37 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
38 | - $this->_caps_slug = 'payment_methods'; |
|
39 | - parent::__construct($timezone); |
|
40 | - } |
|
18 | + protected function __construct($timezone = null) |
|
19 | + { |
|
20 | + $this->singular_item = __('Currency Usable by Payment Method', 'event_espresso'); |
|
21 | + $this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso'); |
|
22 | + $this->_tables = array( |
|
23 | + 'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID') |
|
24 | + ); |
|
25 | + $this->_fields = array( |
|
26 | + 'Currency_Payment_Method'=>array( |
|
27 | + 'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')), |
|
28 | + 'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'), |
|
29 | + 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method') |
|
30 | + ) |
|
31 | + ); |
|
32 | + $this->_model_relations = array( |
|
33 | + 'Currency'=>new EE_Belongs_To_Relation(), |
|
34 | + 'Payment_Method'=>new EE_Belongs_To_Relation() |
|
35 | + ); |
|
36 | + // this model is generally available for reading |
|
37 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
38 | + $this->_caps_slug = 'payment_methods'; |
|
39 | + parent::__construct($timezone); |
|
40 | + } |
|
41 | 41 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | 'Payment_Method'=>new EE_Belongs_To_Relation() |
35 | 35 | ); |
36 | 36 | // this model is generally available for reading |
37 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
37 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
38 | 38 | $this->_caps_slug = 'payment_methods'; |
39 | 39 | parent::__construct($timezone); |
40 | 40 | } |
@@ -11,93 +11,93 @@ discard block |
||
11 | 11 | class EEM_Change_Log extends EEM_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * the related object was created log type |
|
16 | - */ |
|
17 | - const type_create = 'create'; |
|
18 | - /** |
|
19 | - * the related object was updated (changed, or soft-deleted) |
|
20 | - */ |
|
21 | - const type_update = 'update'; |
|
22 | - /** |
|
23 | - * the related object was deleted permanently |
|
24 | - */ |
|
25 | - const type_delete = 'delete'; |
|
26 | - /** |
|
27 | - * the related item had something worth noting happen on it, but |
|
28 | - * only for the purposes of debugging problems |
|
29 | - */ |
|
30 | - const type_debug = 'debug'; |
|
31 | - /** |
|
32 | - * the related item had an error occur on it |
|
33 | - */ |
|
34 | - const type_error = 'error'; |
|
35 | - /** |
|
36 | - * the related item is regarding some gateway interaction, like an IPN |
|
37 | - * or request to process a payment |
|
38 | - */ |
|
39 | - const type_gateway = 'gateway'; |
|
14 | + /** |
|
15 | + * the related object was created log type |
|
16 | + */ |
|
17 | + const type_create = 'create'; |
|
18 | + /** |
|
19 | + * the related object was updated (changed, or soft-deleted) |
|
20 | + */ |
|
21 | + const type_update = 'update'; |
|
22 | + /** |
|
23 | + * the related object was deleted permanently |
|
24 | + */ |
|
25 | + const type_delete = 'delete'; |
|
26 | + /** |
|
27 | + * the related item had something worth noting happen on it, but |
|
28 | + * only for the purposes of debugging problems |
|
29 | + */ |
|
30 | + const type_debug = 'debug'; |
|
31 | + /** |
|
32 | + * the related item had an error occur on it |
|
33 | + */ |
|
34 | + const type_error = 'error'; |
|
35 | + /** |
|
36 | + * the related item is regarding some gateway interaction, like an IPN |
|
37 | + * or request to process a payment |
|
38 | + */ |
|
39 | + const type_gateway = 'gateway'; |
|
40 | 40 | |
41 | - /** |
|
42 | - * private instance of the EEM_Change_Log object |
|
43 | - * |
|
44 | - * @access private |
|
45 | - * @var EEM_Change_Log $_instance |
|
46 | - */ |
|
47 | - protected static $_instance = null; |
|
41 | + /** |
|
42 | + * private instance of the EEM_Change_Log object |
|
43 | + * |
|
44 | + * @access private |
|
45 | + * @var EEM_Change_Log $_instance |
|
46 | + */ |
|
47 | + protected static $_instance = null; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * constructor |
|
52 | - * |
|
53 | - * @access protected |
|
54 | - * @param null $timezone |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - protected function __construct($timezone = null) |
|
58 | - { |
|
59 | - global $current_user; |
|
60 | - $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
61 | - $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
62 | - $this->_tables = array( |
|
63 | - 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
64 | - ); |
|
65 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
66 | - $this->_fields = array( |
|
67 | - 'Log' => array( |
|
68 | - 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
69 | - 'LOG_time' => new EE_Datetime_Field( |
|
70 | - 'LOG_time', |
|
71 | - esc_html__("Log Time", 'event_espresso'), |
|
72 | - false, |
|
73 | - EE_Datetime_Field::now |
|
74 | - ), |
|
75 | - 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
76 | - 'OBJ_ID', |
|
77 | - esc_html__("Object ID (int or string)", 'event_espresso'), |
|
78 | - true, |
|
79 | - null, |
|
80 | - $models_this_can_attach_to |
|
81 | - ), |
|
82 | - 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
83 | - 'OBJ_type', |
|
84 | - esc_html__("Object Type", 'event_espresso'), |
|
85 | - true, |
|
86 | - null, |
|
87 | - $models_this_can_attach_to |
|
88 | - ), |
|
89 | - 'LOG_type' => new EE_Plain_Text_Field( |
|
90 | - 'LOG_type', |
|
91 | - esc_html__("Type of log entry", "event_espresso"), |
|
92 | - false, |
|
93 | - self::type_debug |
|
94 | - ), |
|
95 | - 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
96 | - 'LOG_message', |
|
97 | - esc_html__("Log Message (body)", 'event_espresso'), |
|
98 | - true |
|
99 | - ), |
|
100 | - /* |
|
50 | + /** |
|
51 | + * constructor |
|
52 | + * |
|
53 | + * @access protected |
|
54 | + * @param null $timezone |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + protected function __construct($timezone = null) |
|
58 | + { |
|
59 | + global $current_user; |
|
60 | + $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
61 | + $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
62 | + $this->_tables = array( |
|
63 | + 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
64 | + ); |
|
65 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
66 | + $this->_fields = array( |
|
67 | + 'Log' => array( |
|
68 | + 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
69 | + 'LOG_time' => new EE_Datetime_Field( |
|
70 | + 'LOG_time', |
|
71 | + esc_html__("Log Time", 'event_espresso'), |
|
72 | + false, |
|
73 | + EE_Datetime_Field::now |
|
74 | + ), |
|
75 | + 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
76 | + 'OBJ_ID', |
|
77 | + esc_html__("Object ID (int or string)", 'event_espresso'), |
|
78 | + true, |
|
79 | + null, |
|
80 | + $models_this_can_attach_to |
|
81 | + ), |
|
82 | + 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
83 | + 'OBJ_type', |
|
84 | + esc_html__("Object Type", 'event_espresso'), |
|
85 | + true, |
|
86 | + null, |
|
87 | + $models_this_can_attach_to |
|
88 | + ), |
|
89 | + 'LOG_type' => new EE_Plain_Text_Field( |
|
90 | + 'LOG_type', |
|
91 | + esc_html__("Type of log entry", "event_espresso"), |
|
92 | + false, |
|
93 | + self::type_debug |
|
94 | + ), |
|
95 | + 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
96 | + 'LOG_message', |
|
97 | + esc_html__("Log Message (body)", 'event_espresso'), |
|
98 | + true |
|
99 | + ), |
|
100 | + /* |
|
101 | 101 | * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used, |
102 | 102 | * not the LOG_wp_user field. E.g., |
103 | 103 | * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return |
@@ -106,158 +106,158 @@ discard block |
||
106 | 106 | * If you want the latter, you can't use the model's magic joining. E.g, you would need to do |
107 | 107 | * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`. |
108 | 108 | */ |
109 | - 'LOG_wp_user' => new EE_WP_User_Field( |
|
110 | - 'LOG_wp_user', |
|
111 | - esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
112 | - true |
|
113 | - ), |
|
114 | - ), |
|
115 | - ); |
|
116 | - $this->_model_relations = array(); |
|
117 | - foreach ($models_this_can_attach_to as $model) { |
|
118 | - if ($model != 'Change_Log') { |
|
119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
120 | - } |
|
121 | - } |
|
122 | - // use completely custom caps for this |
|
123 | - $this->_cap_restriction_generators = false; |
|
124 | - // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
125 | - foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
127 | - = new EE_Return_None_Where_Conditions(); |
|
128 | - } |
|
129 | - parent::__construct($timezone); |
|
130 | - } |
|
109 | + 'LOG_wp_user' => new EE_WP_User_Field( |
|
110 | + 'LOG_wp_user', |
|
111 | + esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
112 | + true |
|
113 | + ), |
|
114 | + ), |
|
115 | + ); |
|
116 | + $this->_model_relations = array(); |
|
117 | + foreach ($models_this_can_attach_to as $model) { |
|
118 | + if ($model != 'Change_Log') { |
|
119 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
120 | + } |
|
121 | + } |
|
122 | + // use completely custom caps for this |
|
123 | + $this->_cap_restriction_generators = false; |
|
124 | + // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
125 | + foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
126 | + $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
127 | + = new EE_Return_None_Where_Conditions(); |
|
128 | + } |
|
129 | + parent::__construct($timezone); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
134 | - * @param mixed $message array|string of the message you want to record |
|
135 | - * @param EE_Base_Class $related_model_obj |
|
136 | - * @return EE_Change_Log |
|
137 | - * @throws EE_Error |
|
138 | - */ |
|
139 | - public function log($log_type, $message, $related_model_obj) |
|
140 | - { |
|
141 | - if ($related_model_obj instanceof EE_Base_Class) { |
|
142 | - $obj_id = $related_model_obj->ID(); |
|
143 | - $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
144 | - } else { |
|
145 | - $obj_id = null; |
|
146 | - $obj_type = null; |
|
147 | - } |
|
148 | - /** @var EE_Change_Log $log */ |
|
149 | - $log = EE_Change_Log::new_instance(array( |
|
150 | - 'LOG_type' => $log_type, |
|
151 | - 'LOG_message' => $message, |
|
152 | - 'OBJ_ID' => $obj_id, |
|
153 | - 'OBJ_type' => $obj_type, |
|
154 | - )); |
|
155 | - $log->save(); |
|
156 | - return $log; |
|
157 | - } |
|
132 | + /** |
|
133 | + * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
134 | + * @param mixed $message array|string of the message you want to record |
|
135 | + * @param EE_Base_Class $related_model_obj |
|
136 | + * @return EE_Change_Log |
|
137 | + * @throws EE_Error |
|
138 | + */ |
|
139 | + public function log($log_type, $message, $related_model_obj) |
|
140 | + { |
|
141 | + if ($related_model_obj instanceof EE_Base_Class) { |
|
142 | + $obj_id = $related_model_obj->ID(); |
|
143 | + $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
144 | + } else { |
|
145 | + $obj_id = null; |
|
146 | + $obj_type = null; |
|
147 | + } |
|
148 | + /** @var EE_Change_Log $log */ |
|
149 | + $log = EE_Change_Log::new_instance(array( |
|
150 | + 'LOG_type' => $log_type, |
|
151 | + 'LOG_message' => $message, |
|
152 | + 'OBJ_ID' => $obj_id, |
|
153 | + 'OBJ_type' => $obj_type, |
|
154 | + )); |
|
155 | + $log->save(); |
|
156 | + return $log; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * Adds a gateway log for the specified object, given its ID and type |
|
162 | - * |
|
163 | - * @param string $message |
|
164 | - * @param mixed $related_obj_id |
|
165 | - * @param string $related_obj_type |
|
166 | - * @throws EE_Error |
|
167 | - * @return EE_Change_Log |
|
168 | - */ |
|
169 | - public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
170 | - { |
|
171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | - throw new EE_Error( |
|
173 | - sprintf( |
|
174 | - esc_html__( |
|
175 | - "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
176 | - "event_espresso" |
|
177 | - ), |
|
178 | - $related_obj_type |
|
179 | - ) |
|
180 | - ); |
|
181 | - } |
|
182 | - /** @var EE_Change_Log $log */ |
|
183 | - $log = EE_Change_Log::new_instance(array( |
|
184 | - 'LOG_type' => EEM_Change_Log::type_gateway, |
|
185 | - 'LOG_message' => $message, |
|
186 | - 'OBJ_ID' => $related_obj_id, |
|
187 | - 'OBJ_type' => $related_obj_type, |
|
188 | - )); |
|
189 | - $log->save(); |
|
190 | - return $log; |
|
191 | - } |
|
160 | + /** |
|
161 | + * Adds a gateway log for the specified object, given its ID and type |
|
162 | + * |
|
163 | + * @param string $message |
|
164 | + * @param mixed $related_obj_id |
|
165 | + * @param string $related_obj_type |
|
166 | + * @throws EE_Error |
|
167 | + * @return EE_Change_Log |
|
168 | + */ |
|
169 | + public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
170 | + { |
|
171 | + if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | + throw new EE_Error( |
|
173 | + sprintf( |
|
174 | + esc_html__( |
|
175 | + "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
176 | + "event_espresso" |
|
177 | + ), |
|
178 | + $related_obj_type |
|
179 | + ) |
|
180 | + ); |
|
181 | + } |
|
182 | + /** @var EE_Change_Log $log */ |
|
183 | + $log = EE_Change_Log::new_instance(array( |
|
184 | + 'LOG_type' => EEM_Change_Log::type_gateway, |
|
185 | + 'LOG_message' => $message, |
|
186 | + 'OBJ_ID' => $related_obj_id, |
|
187 | + 'OBJ_type' => $related_obj_type, |
|
188 | + )); |
|
189 | + $log->save(); |
|
190 | + return $log; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
196 | - * |
|
197 | - * @param array $query_params @see EEM_Base::get_all |
|
198 | - * @return array of arrays |
|
199 | - * @throws EE_Error |
|
200 | - */ |
|
201 | - public function get_all_efficiently($query_params) |
|
202 | - { |
|
203 | - return $this->_get_all_wpdb_results($query_params); |
|
204 | - } |
|
194 | + /** |
|
195 | + * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
196 | + * |
|
197 | + * @param array $query_params @see EEM_Base::get_all |
|
198 | + * @return array of arrays |
|
199 | + * @throws EE_Error |
|
200 | + */ |
|
201 | + public function get_all_efficiently($query_params) |
|
202 | + { |
|
203 | + return $this->_get_all_wpdb_results($query_params); |
|
204 | + } |
|
205 | 205 | |
206 | 206 | |
207 | - /** |
|
208 | - * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
209 | - * models after this, they may be out-of-sync with the database |
|
210 | - * |
|
211 | - * @param DateTime $datetime |
|
212 | - * @return false|int |
|
213 | - * @throws EE_Error |
|
214 | - */ |
|
215 | - public function delete_gateway_logs_older_than(DateTime $datetime) |
|
216 | - { |
|
217 | - global $wpdb; |
|
218 | - return $wpdb->query( |
|
219 | - $wpdb->prepare( |
|
220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | - EEM_Change_Log::type_gateway, |
|
222 | - $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
207 | + /** |
|
208 | + * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
209 | + * models after this, they may be out-of-sync with the database |
|
210 | + * |
|
211 | + * @param DateTime $datetime |
|
212 | + * @return false|int |
|
213 | + * @throws EE_Error |
|
214 | + */ |
|
215 | + public function delete_gateway_logs_older_than(DateTime $datetime) |
|
216 | + { |
|
217 | + global $wpdb; |
|
218 | + return $wpdb->query( |
|
219 | + $wpdb->prepare( |
|
220 | + 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | + EEM_Change_Log::type_gateway, |
|
222 | + $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
230 | - * map vai the given filter. |
|
231 | - * |
|
232 | - * @return array |
|
233 | - */ |
|
234 | - public static function get_pretty_label_map_for_registered_types() |
|
235 | - { |
|
236 | - return apply_filters( |
|
237 | - 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
238 | - array( |
|
239 | - self::type_create=> esc_html__("Create", "event_espresso"), |
|
240 | - self::type_update=> esc_html__("Update", "event_espresso"), |
|
241 | - self::type_delete => esc_html__("Delete", "event_espresso"), |
|
242 | - self::type_debug=> esc_html__("Debug", "event_espresso"), |
|
243 | - self::type_error=> esc_html__("Error", "event_espresso"), |
|
244 | - self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
245 | - ) |
|
246 | - ); |
|
247 | - } |
|
228 | + /** |
|
229 | + * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
230 | + * map vai the given filter. |
|
231 | + * |
|
232 | + * @return array |
|
233 | + */ |
|
234 | + public static function get_pretty_label_map_for_registered_types() |
|
235 | + { |
|
236 | + return apply_filters( |
|
237 | + 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
238 | + array( |
|
239 | + self::type_create=> esc_html__("Create", "event_espresso"), |
|
240 | + self::type_update=> esc_html__("Update", "event_espresso"), |
|
241 | + self::type_delete => esc_html__("Delete", "event_espresso"), |
|
242 | + self::type_debug=> esc_html__("Debug", "event_espresso"), |
|
243 | + self::type_error=> esc_html__("Error", "event_espresso"), |
|
244 | + self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
245 | + ) |
|
246 | + ); |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * Return the pretty (localized) label for the given log type identifier. |
|
252 | - * @param string $type_identifier |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public static function get_pretty_label_for_type($type_identifier) |
|
256 | - { |
|
257 | - $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
258 | - // we fallback to the incoming type identifier if there is no localized label for it. |
|
259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
260 | - ? $type_identifier_map[ $type_identifier ] |
|
261 | - : $type_identifier; |
|
262 | - } |
|
250 | + /** |
|
251 | + * Return the pretty (localized) label for the given log type identifier. |
|
252 | + * @param string $type_identifier |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public static function get_pretty_label_for_type($type_identifier) |
|
256 | + { |
|
257 | + $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
258 | + // we fallback to the incoming type identifier if there is no localized label for it. |
|
259 | + return isset($type_identifier_map[ $type_identifier ]) |
|
260 | + ? $type_identifier_map[ $type_identifier ] |
|
261 | + : $type_identifier; |
|
262 | + } |
|
263 | 263 | } |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | ), |
114 | 114 | ), |
115 | 115 | ); |
116 | - $this->_model_relations = array(); |
|
116 | + $this->_model_relations = array(); |
|
117 | 117 | foreach ($models_this_can_attach_to as $model) { |
118 | 118 | if ($model != 'Change_Log') { |
119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
119 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | // use completely custom caps for this |
123 | 123 | $this->_cap_restriction_generators = false; |
124 | 124 | // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
125 | 125 | foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
126 | + $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] |
|
127 | 127 | = new EE_Return_None_Where_Conditions(); |
128 | 128 | } |
129 | 129 | parent::__construct($timezone); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function gateway_log($message, $related_obj_id, $related_obj_type) |
170 | 170 | { |
171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
171 | + if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | 172 | throw new EE_Error( |
173 | 173 | sprintf( |
174 | 174 | esc_html__( |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | global $wpdb; |
218 | 218 | return $wpdb->query( |
219 | 219 | $wpdb->prepare( |
220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
220 | + 'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | 221 | EEM_Change_Log::type_gateway, |
222 | 222 | $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
223 | 223 | ) |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | { |
257 | 257 | $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
258 | 258 | // we fallback to the incoming type identifier if there is no localized label for it. |
259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
260 | - ? $type_identifier_map[ $type_identifier ] |
|
259 | + return isset($type_identifier_map[$type_identifier]) |
|
260 | + ? $type_identifier_map[$type_identifier] |
|
261 | 261 | : $type_identifier; |
262 | 262 | } |
263 | 263 | } |
@@ -10,320 +10,320 @@ |
||
10 | 10 | class EEM_Ticket extends EEM_Soft_Delete_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * private instance of the EEM_Ticket object |
|
15 | - * |
|
16 | - * @var EEM_Ticket $_instance |
|
17 | - */ |
|
18 | - protected static $_instance; |
|
13 | + /** |
|
14 | + * private instance of the EEM_Ticket object |
|
15 | + * |
|
16 | + * @var EEM_Ticket $_instance |
|
17 | + */ |
|
18 | + protected static $_instance; |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * private constructor to prevent direct creation |
|
23 | - * |
|
24 | - * @Constructor |
|
25 | - * @access private |
|
26 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
27 | - * (and any incoming timezone data that gets saved). |
|
28 | - * Note this just sends the timezone info to the date time model field objects. |
|
29 | - * Default is NULL |
|
30 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
31 | - * @throws EE_Error |
|
32 | - */ |
|
33 | - protected function __construct($timezone) |
|
34 | - { |
|
35 | - $this->singular_item = esc_html__('Ticket', 'event_espresso'); |
|
36 | - $this->plural_item = esc_html__('Tickets', 'event_espresso'); |
|
37 | - $this->_tables = array( |
|
38 | - 'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'), |
|
39 | - ); |
|
40 | - $this->_fields = array( |
|
41 | - 'Ticket' => array( |
|
42 | - 'TKT_ID' => new EE_Primary_Key_Int_Field( |
|
43 | - 'TKT_ID', |
|
44 | - esc_html__('Ticket ID', 'event_espresso') |
|
45 | - ), |
|
46 | - 'TTM_ID' => new EE_Foreign_Key_Int_Field( |
|
47 | - 'TTM_ID', |
|
48 | - esc_html__('Ticket Template ID', 'event_espresso'), |
|
49 | - false, |
|
50 | - 0, |
|
51 | - 'Ticket_Template' |
|
52 | - ), |
|
53 | - 'TKT_name' => new EE_Plain_Text_Field( |
|
54 | - 'TKT_name', |
|
55 | - esc_html__('Ticket Name', 'event_espresso'), |
|
56 | - false, |
|
57 | - '' |
|
58 | - ), |
|
59 | - 'TKT_description' => new EE_Post_Content_Field( |
|
60 | - 'TKT_description', |
|
61 | - esc_html__('Description of Ticket', 'event_espresso'), |
|
62 | - false, |
|
63 | - '' |
|
64 | - ), |
|
65 | - 'TKT_start_date' => new EE_Datetime_Field( |
|
66 | - 'TKT_start_date', |
|
67 | - esc_html__('Start time/date of Ticket', 'event_espresso'), |
|
68 | - false, |
|
69 | - EE_Datetime_Field::now, |
|
70 | - $timezone |
|
71 | - ), |
|
72 | - 'TKT_end_date' => new EE_Datetime_Field( |
|
73 | - 'TKT_end_date', |
|
74 | - esc_html__('End time/date of Ticket', 'event_espresso'), |
|
75 | - false, |
|
76 | - EE_Datetime_Field::now, |
|
77 | - $timezone |
|
78 | - ), |
|
79 | - 'TKT_min' => new EE_Integer_Field( |
|
80 | - 'TKT_min', |
|
81 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
82 | - false, |
|
83 | - 0 |
|
84 | - ), |
|
85 | - 'TKT_max' => new EE_Infinite_Integer_Field( |
|
86 | - 'TKT_max', |
|
87 | - esc_html__( |
|
88 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
89 | - 'event_espresso' |
|
90 | - ), |
|
91 | - false, |
|
92 | - EE_INF |
|
93 | - ), |
|
94 | - 'TKT_price' => new EE_Money_Field( |
|
95 | - 'TKT_price', |
|
96 | - esc_html__('Final calculated price for ticket', 'event_espresso'), |
|
97 | - false, |
|
98 | - 0 |
|
99 | - ), |
|
100 | - 'TKT_sold' => new EE_Integer_Field( |
|
101 | - 'TKT_sold', |
|
102 | - esc_html__('Number of this ticket sold', 'event_espresso'), |
|
103 | - false, |
|
104 | - 0 |
|
105 | - ), |
|
106 | - 'TKT_qty' => new EE_Infinite_Integer_Field( |
|
107 | - 'TKT_qty', |
|
108 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
109 | - false, |
|
110 | - EE_INF |
|
111 | - ), |
|
112 | - 'TKT_reserved' => new EE_Integer_Field( |
|
113 | - 'TKT_reserved', |
|
114 | - esc_html__( |
|
115 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
116 | - 'event_espresso' |
|
117 | - ), |
|
118 | - false, |
|
119 | - 0 |
|
120 | - ), |
|
121 | - 'TKT_uses' => new EE_Infinite_Integer_Field( |
|
122 | - 'TKT_uses', |
|
123 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
124 | - false, |
|
125 | - EE_INF |
|
126 | - ), |
|
127 | - 'TKT_required' => new EE_Boolean_Field( |
|
128 | - 'TKT_required', |
|
129 | - esc_html__( |
|
130 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
131 | - 'event_espresso' |
|
132 | - ), |
|
133 | - false, |
|
134 | - false |
|
135 | - ), |
|
136 | - 'TKT_taxable' => new EE_Boolean_Field( |
|
137 | - 'TKT_taxable', |
|
138 | - esc_html__( |
|
139 | - 'Flag indicating whether there is tax applied on this ticket', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - false, |
|
143 | - false |
|
144 | - ), |
|
145 | - 'TKT_is_default' => new EE_Boolean_Field( |
|
146 | - 'TKT_is_default', |
|
147 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
148 | - false, |
|
149 | - false |
|
150 | - ), |
|
151 | - 'TKT_order' => new EE_Integer_Field( |
|
152 | - 'TKT_order', |
|
153 | - esc_html__( |
|
154 | - 'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', |
|
155 | - 'event_espresso' |
|
156 | - ), |
|
157 | - false, |
|
158 | - 0 |
|
159 | - ), |
|
160 | - 'TKT_row' => new EE_Integer_Field( |
|
161 | - 'TKT_row', |
|
162 | - esc_html__('How tickets are displayed in the ui', 'event_espresso'), |
|
163 | - false, |
|
164 | - 0 |
|
165 | - ), |
|
166 | - 'TKT_deleted' => new EE_Trashed_Flag_Field( |
|
167 | - 'TKT_deleted', |
|
168 | - esc_html__('Flag indicating if this has been archived or not', 'event_espresso'), |
|
169 | - false, |
|
170 | - false |
|
171 | - ), |
|
172 | - 'TKT_wp_user' => new EE_WP_User_Field( |
|
173 | - 'TKT_wp_user', |
|
174 | - esc_html__('Ticket Creator ID', 'event_espresso'), |
|
175 | - false |
|
176 | - ), |
|
177 | - 'TKT_parent' => new EE_Integer_Field( |
|
178 | - 'TKT_parent', |
|
179 | - esc_html__( |
|
180 | - 'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)', |
|
181 | - 'event_espresso' |
|
182 | - ), |
|
183 | - true, |
|
184 | - 0 |
|
185 | - ), |
|
186 | - ), |
|
187 | - ); |
|
188 | - $this->_model_relations = array( |
|
189 | - 'Datetime' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
190 | - 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
191 | - 'Price' => new EE_HABTM_Relation('Ticket_Price'), |
|
192 | - 'Ticket_Template' => new EE_Belongs_To_Relation(), |
|
193 | - 'Registration' => new EE_Has_Many_Relation(), |
|
194 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
195 | - ); |
|
196 | - // this model is generally available for reading |
|
197 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public( |
|
198 | - 'TKT_is_default', |
|
199 | - 'Datetime.Event' |
|
200 | - ); |
|
201 | - // account for default tickets in the caps |
|
202 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( |
|
203 | - 'TKT_is_default', |
|
204 | - 'Datetime.Event' |
|
205 | - ); |
|
206 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( |
|
207 | - 'TKT_is_default', |
|
208 | - 'Datetime.Event' |
|
209 | - ); |
|
210 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( |
|
211 | - 'TKT_is_default', |
|
212 | - 'Datetime.Event' |
|
213 | - ); |
|
214 | - parent::__construct($timezone); |
|
215 | - } |
|
21 | + /** |
|
22 | + * private constructor to prevent direct creation |
|
23 | + * |
|
24 | + * @Constructor |
|
25 | + * @access private |
|
26 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
27 | + * (and any incoming timezone data that gets saved). |
|
28 | + * Note this just sends the timezone info to the date time model field objects. |
|
29 | + * Default is NULL |
|
30 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
31 | + * @throws EE_Error |
|
32 | + */ |
|
33 | + protected function __construct($timezone) |
|
34 | + { |
|
35 | + $this->singular_item = esc_html__('Ticket', 'event_espresso'); |
|
36 | + $this->plural_item = esc_html__('Tickets', 'event_espresso'); |
|
37 | + $this->_tables = array( |
|
38 | + 'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'), |
|
39 | + ); |
|
40 | + $this->_fields = array( |
|
41 | + 'Ticket' => array( |
|
42 | + 'TKT_ID' => new EE_Primary_Key_Int_Field( |
|
43 | + 'TKT_ID', |
|
44 | + esc_html__('Ticket ID', 'event_espresso') |
|
45 | + ), |
|
46 | + 'TTM_ID' => new EE_Foreign_Key_Int_Field( |
|
47 | + 'TTM_ID', |
|
48 | + esc_html__('Ticket Template ID', 'event_espresso'), |
|
49 | + false, |
|
50 | + 0, |
|
51 | + 'Ticket_Template' |
|
52 | + ), |
|
53 | + 'TKT_name' => new EE_Plain_Text_Field( |
|
54 | + 'TKT_name', |
|
55 | + esc_html__('Ticket Name', 'event_espresso'), |
|
56 | + false, |
|
57 | + '' |
|
58 | + ), |
|
59 | + 'TKT_description' => new EE_Post_Content_Field( |
|
60 | + 'TKT_description', |
|
61 | + esc_html__('Description of Ticket', 'event_espresso'), |
|
62 | + false, |
|
63 | + '' |
|
64 | + ), |
|
65 | + 'TKT_start_date' => new EE_Datetime_Field( |
|
66 | + 'TKT_start_date', |
|
67 | + esc_html__('Start time/date of Ticket', 'event_espresso'), |
|
68 | + false, |
|
69 | + EE_Datetime_Field::now, |
|
70 | + $timezone |
|
71 | + ), |
|
72 | + 'TKT_end_date' => new EE_Datetime_Field( |
|
73 | + 'TKT_end_date', |
|
74 | + esc_html__('End time/date of Ticket', 'event_espresso'), |
|
75 | + false, |
|
76 | + EE_Datetime_Field::now, |
|
77 | + $timezone |
|
78 | + ), |
|
79 | + 'TKT_min' => new EE_Integer_Field( |
|
80 | + 'TKT_min', |
|
81 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
82 | + false, |
|
83 | + 0 |
|
84 | + ), |
|
85 | + 'TKT_max' => new EE_Infinite_Integer_Field( |
|
86 | + 'TKT_max', |
|
87 | + esc_html__( |
|
88 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
89 | + 'event_espresso' |
|
90 | + ), |
|
91 | + false, |
|
92 | + EE_INF |
|
93 | + ), |
|
94 | + 'TKT_price' => new EE_Money_Field( |
|
95 | + 'TKT_price', |
|
96 | + esc_html__('Final calculated price for ticket', 'event_espresso'), |
|
97 | + false, |
|
98 | + 0 |
|
99 | + ), |
|
100 | + 'TKT_sold' => new EE_Integer_Field( |
|
101 | + 'TKT_sold', |
|
102 | + esc_html__('Number of this ticket sold', 'event_espresso'), |
|
103 | + false, |
|
104 | + 0 |
|
105 | + ), |
|
106 | + 'TKT_qty' => new EE_Infinite_Integer_Field( |
|
107 | + 'TKT_qty', |
|
108 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
109 | + false, |
|
110 | + EE_INF |
|
111 | + ), |
|
112 | + 'TKT_reserved' => new EE_Integer_Field( |
|
113 | + 'TKT_reserved', |
|
114 | + esc_html__( |
|
115 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
116 | + 'event_espresso' |
|
117 | + ), |
|
118 | + false, |
|
119 | + 0 |
|
120 | + ), |
|
121 | + 'TKT_uses' => new EE_Infinite_Integer_Field( |
|
122 | + 'TKT_uses', |
|
123 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
124 | + false, |
|
125 | + EE_INF |
|
126 | + ), |
|
127 | + 'TKT_required' => new EE_Boolean_Field( |
|
128 | + 'TKT_required', |
|
129 | + esc_html__( |
|
130 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
131 | + 'event_espresso' |
|
132 | + ), |
|
133 | + false, |
|
134 | + false |
|
135 | + ), |
|
136 | + 'TKT_taxable' => new EE_Boolean_Field( |
|
137 | + 'TKT_taxable', |
|
138 | + esc_html__( |
|
139 | + 'Flag indicating whether there is tax applied on this ticket', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + false, |
|
143 | + false |
|
144 | + ), |
|
145 | + 'TKT_is_default' => new EE_Boolean_Field( |
|
146 | + 'TKT_is_default', |
|
147 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
148 | + false, |
|
149 | + false |
|
150 | + ), |
|
151 | + 'TKT_order' => new EE_Integer_Field( |
|
152 | + 'TKT_order', |
|
153 | + esc_html__( |
|
154 | + 'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', |
|
155 | + 'event_espresso' |
|
156 | + ), |
|
157 | + false, |
|
158 | + 0 |
|
159 | + ), |
|
160 | + 'TKT_row' => new EE_Integer_Field( |
|
161 | + 'TKT_row', |
|
162 | + esc_html__('How tickets are displayed in the ui', 'event_espresso'), |
|
163 | + false, |
|
164 | + 0 |
|
165 | + ), |
|
166 | + 'TKT_deleted' => new EE_Trashed_Flag_Field( |
|
167 | + 'TKT_deleted', |
|
168 | + esc_html__('Flag indicating if this has been archived or not', 'event_espresso'), |
|
169 | + false, |
|
170 | + false |
|
171 | + ), |
|
172 | + 'TKT_wp_user' => new EE_WP_User_Field( |
|
173 | + 'TKT_wp_user', |
|
174 | + esc_html__('Ticket Creator ID', 'event_espresso'), |
|
175 | + false |
|
176 | + ), |
|
177 | + 'TKT_parent' => new EE_Integer_Field( |
|
178 | + 'TKT_parent', |
|
179 | + esc_html__( |
|
180 | + 'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)', |
|
181 | + 'event_espresso' |
|
182 | + ), |
|
183 | + true, |
|
184 | + 0 |
|
185 | + ), |
|
186 | + ), |
|
187 | + ); |
|
188 | + $this->_model_relations = array( |
|
189 | + 'Datetime' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
190 | + 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
191 | + 'Price' => new EE_HABTM_Relation('Ticket_Price'), |
|
192 | + 'Ticket_Template' => new EE_Belongs_To_Relation(), |
|
193 | + 'Registration' => new EE_Has_Many_Relation(), |
|
194 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
195 | + ); |
|
196 | + // this model is generally available for reading |
|
197 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public( |
|
198 | + 'TKT_is_default', |
|
199 | + 'Datetime.Event' |
|
200 | + ); |
|
201 | + // account for default tickets in the caps |
|
202 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( |
|
203 | + 'TKT_is_default', |
|
204 | + 'Datetime.Event' |
|
205 | + ); |
|
206 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( |
|
207 | + 'TKT_is_default', |
|
208 | + 'Datetime.Event' |
|
209 | + ); |
|
210 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( |
|
211 | + 'TKT_is_default', |
|
212 | + 'Datetime.Event' |
|
213 | + ); |
|
214 | + parent::__construct($timezone); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * This returns all tickets that are defaults from the db |
|
220 | - * |
|
221 | - * @return EE_Ticket[] |
|
222 | - * @throws EE_Error |
|
223 | - */ |
|
224 | - public function get_all_default_tickets() |
|
225 | - { |
|
226 | - /** @type EE_Ticket[] $tickets */ |
|
227 | - $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
228 | - // we need to set the start date and end date to today's date and the start of the default dtt |
|
229 | - return $this->_set_default_dates($tickets); |
|
230 | - } |
|
218 | + /** |
|
219 | + * This returns all tickets that are defaults from the db |
|
220 | + * |
|
221 | + * @return EE_Ticket[] |
|
222 | + * @throws EE_Error |
|
223 | + */ |
|
224 | + public function get_all_default_tickets() |
|
225 | + { |
|
226 | + /** @type EE_Ticket[] $tickets */ |
|
227 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
228 | + // we need to set the start date and end date to today's date and the start of the default dtt |
|
229 | + return $this->_set_default_dates($tickets); |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * sets up relevant start and end date for EE_Ticket (s) |
|
235 | - * |
|
236 | - * @param EE_Ticket[] $tickets |
|
237 | - * @return EE_Ticket[] |
|
238 | - * @throws EE_Error |
|
239 | - */ |
|
240 | - private function _set_default_dates($tickets) |
|
241 | - { |
|
242 | - foreach ($tickets as $ticket) { |
|
243 | - $ticket->set( |
|
244 | - 'TKT_start_date', |
|
245 | - (int) $this->current_time_for_query('TKT_start_date', true) |
|
246 | - ); |
|
247 | - $ticket->set( |
|
248 | - 'TKT_end_date', |
|
249 | - (int) $this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
250 | - ); |
|
251 | - $ticket->set_end_time( |
|
252 | - $this->convert_datetime_for_query( |
|
253 | - 'TKT_end_date', |
|
254 | - '11:59 pm', |
|
255 | - 'g:i a', |
|
256 | - $this->_timezone |
|
257 | - ) |
|
258 | - ); |
|
259 | - } |
|
260 | - return $tickets; |
|
261 | - } |
|
233 | + /** |
|
234 | + * sets up relevant start and end date for EE_Ticket (s) |
|
235 | + * |
|
236 | + * @param EE_Ticket[] $tickets |
|
237 | + * @return EE_Ticket[] |
|
238 | + * @throws EE_Error |
|
239 | + */ |
|
240 | + private function _set_default_dates($tickets) |
|
241 | + { |
|
242 | + foreach ($tickets as $ticket) { |
|
243 | + $ticket->set( |
|
244 | + 'TKT_start_date', |
|
245 | + (int) $this->current_time_for_query('TKT_start_date', true) |
|
246 | + ); |
|
247 | + $ticket->set( |
|
248 | + 'TKT_end_date', |
|
249 | + (int) $this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
250 | + ); |
|
251 | + $ticket->set_end_time( |
|
252 | + $this->convert_datetime_for_query( |
|
253 | + 'TKT_end_date', |
|
254 | + '11:59 pm', |
|
255 | + 'g:i a', |
|
256 | + $this->_timezone |
|
257 | + ) |
|
258 | + ); |
|
259 | + } |
|
260 | + return $tickets; |
|
261 | + } |
|
262 | 262 | |
263 | 263 | |
264 | - /** |
|
265 | - * Gets the total number of tickets available at a particular datetime (does |
|
266 | - * NOT take int account the datetime's spaces available) |
|
267 | - * |
|
268 | - * @param int $DTT_ID |
|
269 | - * @param array $query_params |
|
270 | - * @return int |
|
271 | - */ |
|
272 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) |
|
273 | - { |
|
274 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
275 | - } |
|
264 | + /** |
|
265 | + * Gets the total number of tickets available at a particular datetime (does |
|
266 | + * NOT take int account the datetime's spaces available) |
|
267 | + * |
|
268 | + * @param int $DTT_ID |
|
269 | + * @param array $query_params |
|
270 | + * @return int |
|
271 | + */ |
|
272 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) |
|
273 | + { |
|
274 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
275 | + } |
|
276 | 276 | |
277 | 277 | |
278 | - /** |
|
279 | - * Updates the TKT_sold quantity on all the tickets matching $query_params |
|
280 | - * |
|
281 | - * @param EE_Ticket[] $tickets |
|
282 | - * @return void |
|
283 | - * @throws EE_Error |
|
284 | - */ |
|
285 | - public function update_tickets_sold($tickets) |
|
286 | - { |
|
287 | - foreach ($tickets as $ticket) { |
|
288 | - /* @var $ticket EE_Ticket */ |
|
289 | - $ticket->update_tickets_sold(); |
|
290 | - } |
|
291 | - } |
|
278 | + /** |
|
279 | + * Updates the TKT_sold quantity on all the tickets matching $query_params |
|
280 | + * |
|
281 | + * @param EE_Ticket[] $tickets |
|
282 | + * @return void |
|
283 | + * @throws EE_Error |
|
284 | + */ |
|
285 | + public function update_tickets_sold($tickets) |
|
286 | + { |
|
287 | + foreach ($tickets as $ticket) { |
|
288 | + /* @var $ticket EE_Ticket */ |
|
289 | + $ticket->update_tickets_sold(); |
|
290 | + } |
|
291 | + } |
|
292 | 292 | |
293 | 293 | |
294 | - /** |
|
295 | - * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved |
|
296 | - * |
|
297 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
298 | - * @throws EE_Error |
|
299 | - */ |
|
300 | - public function get_tickets_with_reservations() |
|
301 | - { |
|
302 | - return $this->get_all( |
|
303 | - array( |
|
304 | - array( |
|
305 | - 'TKT_reserved' => array('>', 0), |
|
306 | - ), |
|
307 | - ) |
|
308 | - ); |
|
309 | - } |
|
294 | + /** |
|
295 | + * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved |
|
296 | + * |
|
297 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
298 | + * @throws EE_Error |
|
299 | + */ |
|
300 | + public function get_tickets_with_reservations() |
|
301 | + { |
|
302 | + return $this->get_all( |
|
303 | + array( |
|
304 | + array( |
|
305 | + 'TKT_reserved' => array('>', 0), |
|
306 | + ), |
|
307 | + ) |
|
308 | + ); |
|
309 | + } |
|
310 | 310 | |
311 | 311 | |
312 | - /** |
|
313 | - * returns an array of EE_Ticket objects matching the supplied list of IDs |
|
314 | - * |
|
315 | - * @param array $ticket_IDs |
|
316 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
317 | - * @throws EE_Error |
|
318 | - */ |
|
319 | - public function get_tickets_with_IDs(array $ticket_IDs) |
|
320 | - { |
|
321 | - return $this->get_all( |
|
322 | - array( |
|
323 | - array( |
|
324 | - 'TKT_ID' => array('IN', $ticket_IDs), |
|
325 | - ), |
|
326 | - ) |
|
327 | - ); |
|
328 | - } |
|
312 | + /** |
|
313 | + * returns an array of EE_Ticket objects matching the supplied list of IDs |
|
314 | + * |
|
315 | + * @param array $ticket_IDs |
|
316 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
317 | + * @throws EE_Error |
|
318 | + */ |
|
319 | + public function get_tickets_with_IDs(array $ticket_IDs) |
|
320 | + { |
|
321 | + return $this->get_all( |
|
322 | + array( |
|
323 | + array( |
|
324 | + 'TKT_ID' => array('IN', $ticket_IDs), |
|
325 | + ), |
|
326 | + ) |
|
327 | + ); |
|
328 | + } |
|
329 | 329 | } |
@@ -194,20 +194,20 @@ |
||
194 | 194 | 'WP_User' => new EE_Belongs_To_Relation(), |
195 | 195 | ); |
196 | 196 | // this model is generally available for reading |
197 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public( |
|
197 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public( |
|
198 | 198 | 'TKT_is_default', |
199 | 199 | 'Datetime.Event' |
200 | 200 | ); |
201 | 201 | // account for default tickets in the caps |
202 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( |
|
202 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected( |
|
203 | 203 | 'TKT_is_default', |
204 | 204 | 'Datetime.Event' |
205 | 205 | ); |
206 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( |
|
206 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected( |
|
207 | 207 | 'TKT_is_default', |
208 | 208 | 'Datetime.Event' |
209 | 209 | ); |
210 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( |
|
210 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected( |
|
211 | 211 | 'TKT_is_default', |
212 | 212 | 'Datetime.Event' |
213 | 213 | ); |
@@ -16,33 +16,33 @@ |
||
16 | 16 | class EEM_Extra_Meta extends EEM_Base |
17 | 17 | { |
18 | 18 | |
19 | - // private instance of the Attendee object |
|
20 | - protected static $_instance = null; |
|
19 | + // private instance of the Attendee object |
|
20 | + protected static $_instance = null; |
|
21 | 21 | |
22 | - protected function __construct($timezone = null) |
|
23 | - { |
|
24 | - $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
25 | - $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
26 | - $this->_tables = array( |
|
27 | - 'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
28 | - ); |
|
29 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
30 | - $this->_fields = array( |
|
31 | - 'Extra_Meta'=>array( |
|
32 | - 'EXM_ID'=>new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")), |
|
33 | - 'OBJ_ID'=>new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
34 | - 'EXM_type'=>new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
35 | - 'EXM_key'=>new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''), |
|
36 | - 'EXM_value'=>new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true) |
|
22 | + protected function __construct($timezone = null) |
|
23 | + { |
|
24 | + $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
25 | + $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
26 | + $this->_tables = array( |
|
27 | + 'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
|
28 | + ); |
|
29 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
30 | + $this->_fields = array( |
|
31 | + 'Extra_Meta'=>array( |
|
32 | + 'EXM_ID'=>new EE_Primary_Key_Int_Field('EXM_ID', __("Extra Meta ID", "event_espresso")), |
|
33 | + 'OBJ_ID'=>new EE_Foreign_Key_Int_Field('OBJ_ID', __("Primary Key of Attached Thing", "event_espresso"), false, 0, $models_this_can_attach_to), |
|
34 | + 'EXM_type'=>new EE_Any_Foreign_Model_Name_Field('EXM_type', __("Model of Attached Thing", "event_espresso"), false, 'Transaction', $models_this_can_attach_to), |
|
35 | + 'EXM_key'=>new EE_Plain_Text_Field('EXM_key', __("Meta Key", "event_espresso"), false, ''), |
|
36 | + 'EXM_value'=>new EE_Maybe_Serialized_Text_Field('EXM_value', __("Meta Value", "event_espresso"), true) |
|
37 | 37 | |
38 | - )); |
|
39 | - $this->_model_relations = array(); |
|
40 | - foreach ($models_this_can_attach_to as $model) { |
|
41 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
42 | - } |
|
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'); |
|
45 | - } |
|
46 | - parent::__construct($timezone); |
|
47 | - } |
|
38 | + )); |
|
39 | + $this->_model_relations = array(); |
|
40 | + foreach ($models_this_can_attach_to as $model) { |
|
41 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
42 | + } |
|
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'); |
|
45 | + } |
|
46 | + parent::__construct($timezone); |
|
47 | + } |
|
48 | 48 | } |
@@ -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 | } |
@@ -10,58 +10,58 @@ |
||
10 | 10 | */ |
11 | 11 | class EEM_Question_Group extends EEM_Soft_Delete_Base |
12 | 12 | { |
13 | - const system_personal = 1; |
|
14 | - const system_address = 2; |
|
15 | - // private instance of the Attendee object |
|
16 | - protected static $_instance = null; |
|
13 | + const system_personal = 1; |
|
14 | + const system_address = 2; |
|
15 | + // private instance of the Attendee object |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | 18 | |
19 | - protected function __construct($timezone = null) |
|
20 | - { |
|
21 | - $this->singular_item = __('Question Group', 'event_espresso'); |
|
22 | - $this->plural_item = __('Question Groups', 'event_espresso'); |
|
19 | + protected function __construct($timezone = null) |
|
20 | + { |
|
21 | + $this->singular_item = __('Question Group', 'event_espresso'); |
|
22 | + $this->plural_item = __('Question Groups', 'event_espresso'); |
|
23 | 23 | |
24 | - $this->_tables = array( |
|
25 | - 'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID') |
|
26 | - ); |
|
27 | - $this->_fields = array( |
|
28 | - 'Question_Group'=>array( |
|
29 | - 'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')), |
|
30 | - 'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''), |
|
31 | - 'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''), |
|
32 | - 'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''), |
|
33 | - 'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0), |
|
34 | - 'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true), |
|
35 | - 'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false), |
|
36 | - 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), false), |
|
37 | - 'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0), |
|
38 | - 'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false) |
|
39 | - ) |
|
40 | - ); |
|
41 | - $this->_model_relations = array( |
|
42 | - 'Question'=>new EE_HABTM_Relation('Question_Group_Question'), |
|
43 | - 'Event'=>new EE_HABTM_Relation('Event_Question_Group'), |
|
44 | - 'Event_Question_Group'=>new EE_Has_Many_Relation(), |
|
45 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
46 | - ); |
|
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'); |
|
52 | - parent::__construct($timezone); |
|
53 | - } |
|
54 | - /** |
|
55 | - * searches the db for the question group with the latest question order and returns that value. |
|
56 | - * @access public |
|
57 | - * @return int |
|
58 | - */ |
|
59 | - public function get_latest_question_group_order() |
|
60 | - { |
|
61 | - $columns_to_select = array( |
|
62 | - 'max_order' => array("MAX(QSG_order)","%d") |
|
63 | - ); |
|
64 | - $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
65 | - return $max[0]['max_order']; |
|
66 | - } |
|
24 | + $this->_tables = array( |
|
25 | + 'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID') |
|
26 | + ); |
|
27 | + $this->_fields = array( |
|
28 | + 'Question_Group'=>array( |
|
29 | + 'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')), |
|
30 | + 'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''), |
|
31 | + 'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''), |
|
32 | + 'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''), |
|
33 | + 'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0), |
|
34 | + 'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true), |
|
35 | + 'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false), |
|
36 | + 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), false), |
|
37 | + 'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0), |
|
38 | + 'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false) |
|
39 | + ) |
|
40 | + ); |
|
41 | + $this->_model_relations = array( |
|
42 | + 'Question'=>new EE_HABTM_Relation('Question_Group_Question'), |
|
43 | + 'Event'=>new EE_HABTM_Relation('Event_Question_Group'), |
|
44 | + 'Event_Question_Group'=>new EE_Has_Many_Relation(), |
|
45 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
46 | + ); |
|
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'); |
|
52 | + parent::__construct($timezone); |
|
53 | + } |
|
54 | + /** |
|
55 | + * searches the db for the question group with the latest question order and returns that value. |
|
56 | + * @access public |
|
57 | + * @return int |
|
58 | + */ |
|
59 | + public function get_latest_question_group_order() |
|
60 | + { |
|
61 | + $columns_to_select = array( |
|
62 | + 'max_order' => array("MAX(QSG_order)","%d") |
|
63 | + ); |
|
64 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
65 | + return $max[0]['max_order']; |
|
66 | + } |
|
67 | 67 | } |
@@ -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']; |
@@ -13,126 +13,126 @@ |
||
13 | 13 | class EEM_WP_User extends EEM_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * private instance of the EEM_WP_User object |
|
18 | - * |
|
19 | - * @type EEM_WP_User |
|
20 | - */ |
|
21 | - protected static $_instance; |
|
16 | + /** |
|
17 | + * private instance of the EEM_WP_User object |
|
18 | + * |
|
19 | + * @type EEM_WP_User |
|
20 | + */ |
|
21 | + protected static $_instance; |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * constructor |
|
27 | - * |
|
28 | - * @param null $timezone |
|
29 | - * @param ModelFieldFactory $model_field_factory |
|
30 | - * @throws EE_Error |
|
31 | - * @throws InvalidArgumentException |
|
32 | - */ |
|
33 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
34 | - { |
|
35 | - $this->singular_item = __('WP_User', 'event_espresso'); |
|
36 | - $this->plural_item = __('WP_Users', 'event_espresso'); |
|
37 | - global $wpdb; |
|
38 | - $this->_tables = array( |
|
39 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
40 | - ); |
|
41 | - $this->_fields = array( |
|
42 | - 'WP_User' => array( |
|
43 | - 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
44 | - 'ID', |
|
45 | - __('WP_User ID', 'event_espresso') |
|
46 | - ), |
|
47 | - 'user_login' => $model_field_factory->createPlainTextField( |
|
48 | - 'user_login', |
|
49 | - __('User Login', 'event_espresso'), |
|
50 | - false |
|
51 | - ), |
|
52 | - 'user_pass' => $model_field_factory->createPlainTextField( |
|
53 | - 'user_pass', |
|
54 | - __('User Password', 'event_espresso'), |
|
55 | - false |
|
56 | - ), |
|
57 | - 'user_nicename' => $model_field_factory->createPlainTextField( |
|
58 | - 'user_nicename', |
|
59 | - __(' User Nice Name', 'event_espresso'), |
|
60 | - false |
|
61 | - ), |
|
62 | - 'user_email' => $model_field_factory->createEmailField( |
|
63 | - 'user_email', |
|
64 | - __('User Email', 'event_espresso'), |
|
65 | - false, |
|
66 | - null |
|
67 | - ), |
|
68 | - 'user_registered' => $model_field_factory->createDatetimeField( |
|
69 | - 'user_registered', |
|
70 | - __('Date User Registered', 'event_espresso'), |
|
71 | - $timezone |
|
72 | - ), |
|
73 | - 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
74 | - 'user_activation_key', |
|
75 | - __('User Activation Key', 'event_espresso'), |
|
76 | - false |
|
77 | - ), |
|
78 | - 'user_status' => $model_field_factory->createIntegerField( |
|
79 | - 'user_status', |
|
80 | - __('User Status', 'event_espresso') |
|
81 | - ), |
|
82 | - 'display_name' => $model_field_factory->createPlainTextField( |
|
83 | - 'display_name', |
|
84 | - __('Display Name', 'event_espresso'), |
|
85 | - false |
|
86 | - ), |
|
87 | - ), |
|
88 | - ); |
|
89 | - $this->_model_relations = array( |
|
90 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
91 | - // all models are related to the change log |
|
92 | - // 'Change_Log' => new EE_Has_Many_Relation(), |
|
93 | - 'Event' => new EE_Has_Many_Relation(), |
|
94 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
95 | - 'Price' => new EE_Has_Many_Relation(), |
|
96 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
97 | - 'Question' => new EE_Has_Many_Relation(), |
|
98 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
99 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
100 | - 'Venue' => new EE_Has_Many_Relation(), |
|
101 | - 'Message' => new EE_Has_Many_Relation(), |
|
102 | - ); |
|
103 | - $this->_wp_core_model = true; |
|
104 | - $this->_caps_slug = 'users'; |
|
105 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
106 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
107 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
108 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
109 | - } |
|
110 | - // @todo: account for create_users controls whether they can create users at all |
|
111 | - parent::__construct($timezone); |
|
112 | - } |
|
25 | + /** |
|
26 | + * constructor |
|
27 | + * |
|
28 | + * @param null $timezone |
|
29 | + * @param ModelFieldFactory $model_field_factory |
|
30 | + * @throws EE_Error |
|
31 | + * @throws InvalidArgumentException |
|
32 | + */ |
|
33 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
34 | + { |
|
35 | + $this->singular_item = __('WP_User', 'event_espresso'); |
|
36 | + $this->plural_item = __('WP_Users', 'event_espresso'); |
|
37 | + global $wpdb; |
|
38 | + $this->_tables = array( |
|
39 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
40 | + ); |
|
41 | + $this->_fields = array( |
|
42 | + 'WP_User' => array( |
|
43 | + 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
44 | + 'ID', |
|
45 | + __('WP_User ID', 'event_espresso') |
|
46 | + ), |
|
47 | + 'user_login' => $model_field_factory->createPlainTextField( |
|
48 | + 'user_login', |
|
49 | + __('User Login', 'event_espresso'), |
|
50 | + false |
|
51 | + ), |
|
52 | + 'user_pass' => $model_field_factory->createPlainTextField( |
|
53 | + 'user_pass', |
|
54 | + __('User Password', 'event_espresso'), |
|
55 | + false |
|
56 | + ), |
|
57 | + 'user_nicename' => $model_field_factory->createPlainTextField( |
|
58 | + 'user_nicename', |
|
59 | + __(' User Nice Name', 'event_espresso'), |
|
60 | + false |
|
61 | + ), |
|
62 | + 'user_email' => $model_field_factory->createEmailField( |
|
63 | + 'user_email', |
|
64 | + __('User Email', 'event_espresso'), |
|
65 | + false, |
|
66 | + null |
|
67 | + ), |
|
68 | + 'user_registered' => $model_field_factory->createDatetimeField( |
|
69 | + 'user_registered', |
|
70 | + __('Date User Registered', 'event_espresso'), |
|
71 | + $timezone |
|
72 | + ), |
|
73 | + 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
74 | + 'user_activation_key', |
|
75 | + __('User Activation Key', 'event_espresso'), |
|
76 | + false |
|
77 | + ), |
|
78 | + 'user_status' => $model_field_factory->createIntegerField( |
|
79 | + 'user_status', |
|
80 | + __('User Status', 'event_espresso') |
|
81 | + ), |
|
82 | + 'display_name' => $model_field_factory->createPlainTextField( |
|
83 | + 'display_name', |
|
84 | + __('Display Name', 'event_espresso'), |
|
85 | + false |
|
86 | + ), |
|
87 | + ), |
|
88 | + ); |
|
89 | + $this->_model_relations = array( |
|
90 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
91 | + // all models are related to the change log |
|
92 | + // 'Change_Log' => new EE_Has_Many_Relation(), |
|
93 | + 'Event' => new EE_Has_Many_Relation(), |
|
94 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
95 | + 'Price' => new EE_Has_Many_Relation(), |
|
96 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
97 | + 'Question' => new EE_Has_Many_Relation(), |
|
98 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
99 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
100 | + 'Venue' => new EE_Has_Many_Relation(), |
|
101 | + 'Message' => new EE_Has_Many_Relation(), |
|
102 | + ); |
|
103 | + $this->_wp_core_model = true; |
|
104 | + $this->_caps_slug = 'users'; |
|
105 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
106 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
107 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
108 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
109 | + } |
|
110 | + // @todo: account for create_users controls whether they can create users at all |
|
111 | + parent::__construct($timezone); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
118 | - * |
|
119 | - * @return string |
|
120 | - * @throws EE_Error |
|
121 | - */ |
|
122 | - public function wp_user_field_name() |
|
123 | - { |
|
124 | - return $this->primary_key_name(); |
|
125 | - } |
|
116 | + /** |
|
117 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
118 | + * |
|
119 | + * @return string |
|
120 | + * @throws EE_Error |
|
121 | + */ |
|
122 | + public function wp_user_field_name() |
|
123 | + { |
|
124 | + return $this->primary_key_name(); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | 128 | |
129 | - /** |
|
130 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
131 | - * |
|
132 | - * @return boolean |
|
133 | - */ |
|
134 | - public function is_owned() |
|
135 | - { |
|
136 | - return true; |
|
137 | - } |
|
129 | + /** |
|
130 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
131 | + * |
|
132 | + * @return boolean |
|
133 | + */ |
|
134 | + public function is_owned() |
|
135 | + { |
|
136 | + return true; |
|
137 | + } |
|
138 | 138 | } |
@@ -102,10 +102,10 @@ |
||
102 | 102 | ); |
103 | 103 | $this->_wp_core_model = true; |
104 | 104 | $this->_caps_slug = 'users'; |
105 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
106 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
105 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
106 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
107 | 107 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
108 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
108 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
109 | 109 | } |
110 | 110 | // @todo: account for create_users controls whether they can create users at all |
111 | 111 | parent::__construct($timezone); |
@@ -23,32 +23,32 @@ |
||
23 | 23 | */ |
24 | 24 | class EEM_Extra_Join extends EEM_Base |
25 | 25 | { |
26 | - // private instance of the Extra Join object |
|
27 | - protected static $_instance = null; |
|
26 | + // private instance of the Extra Join object |
|
27 | + protected static $_instance = null; |
|
28 | 28 | |
29 | - public function __construct($timezone = null) |
|
30 | - { |
|
31 | - $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
32 | - $this->_tables = array( |
|
33 | - 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
34 | - ); |
|
35 | - $this->_fields = array( |
|
36 | - 'Extra_Join' => array( |
|
37 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
38 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
39 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
40 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
29 | + public function __construct($timezone = null) |
|
30 | + { |
|
31 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
32 | + $this->_tables = array( |
|
33 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
34 | + ); |
|
35 | + $this->_fields = array( |
|
36 | + 'Extra_Join' => array( |
|
37 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
38 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
39 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
40 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
42 | 42 | |
43 | - ) |
|
44 | - ); |
|
45 | - // this model is weird in that it has two foreign key columns which can point to any model/table. |
|
46 | - // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other |
|
47 | - // model linked to is alphabetically greater than event (eg venue). |
|
48 | - // but if the model linked to is alphabetically lower (eg attendee), |
|
49 | - // the foreign key to the event will be in "EXJ_second_model_ID" |
|
50 | - // so normal usage of foreign keys is weird. So don't define any |
|
51 | - // relations to other models because they won't work properly with this model |
|
52 | - parent::__construct($timezone); |
|
53 | - } |
|
43 | + ) |
|
44 | + ); |
|
45 | + // this model is weird in that it has two foreign key columns which can point to any model/table. |
|
46 | + // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other |
|
47 | + // model linked to is alphabetically greater than event (eg venue). |
|
48 | + // but if the model linked to is alphabetically lower (eg attendee), |
|
49 | + // the foreign key to the event will be in "EXJ_second_model_ID" |
|
50 | + // so normal usage of foreign keys is weird. So don't define any |
|
51 | + // relations to other models because they won't work properly with this model |
|
52 | + parent::__construct($timezone); |
|
53 | + } |
|
54 | 54 | } |
@@ -11,161 +11,161 @@ |
||
11 | 11 | class EEM_State extends EEM_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Attendee object |
|
15 | - protected static $_instance = null; |
|
16 | - // array of all states |
|
17 | - private static $_all_states = false; |
|
18 | - // array of all active states |
|
19 | - private static $_active_states = false; |
|
20 | - |
|
21 | - protected function __construct($timezone = null) |
|
22 | - { |
|
23 | - $this->singular_item = __('State/Province', 'event_espresso'); |
|
24 | - $this->plural_item = __('States/Provinces', 'event_espresso'); |
|
25 | - |
|
26 | - $this->_tables = array( |
|
27 | - 'State'=> new EE_Primary_Table('esp_state', 'STA_ID') |
|
28 | - ); |
|
29 | - |
|
30 | - $this->_fields = array( |
|
31 | - 'State'=>array( |
|
32 | - 'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID', 'event_espresso')), |
|
33 | - 'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso'), false, null, 'Country'), |
|
34 | - 'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation', 'event_espresso'), false, ''), |
|
35 | - 'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name', 'event_espresso'), false, ''), |
|
36 | - 'STA_active'=> new EE_Boolean_Field('STA_active', __('State Active Flag', 'event_espresso'), false, false) |
|
37 | - )); |
|
38 | - $this->_model_relations = array( |
|
39 | - 'Attendee'=>new EE_Has_Many_Relation(), |
|
40 | - 'Country' => new EE_Belongs_To_Relation(), |
|
41 | - 'Venue'=>new EE_Has_Many_Relation(), |
|
42 | - ); |
|
43 | - // this model is generally available for reading |
|
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
45 | - // @todo: only show STA_active |
|
46 | - parent::__construct($timezone); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * reset_cached_states |
|
54 | - * |
|
55 | - * @access private |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function reset_cached_states() |
|
59 | - { |
|
60 | - EEM_State::$_active_states = array(); |
|
61 | - EEM_State::$_all_states = array(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * _get_states |
|
69 | - * |
|
70 | - * @access private |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - public function get_all_states() |
|
74 | - { |
|
75 | - if (! self::$_all_states) { |
|
76 | - self::$_all_states = $this->get_all(array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 ))); |
|
77 | - } |
|
78 | - return self::$_all_states; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * _get_states |
|
85 | - * |
|
86 | - * @access public |
|
87 | - * @param array $countries |
|
88 | - * @param bool $flush_cache |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public function get_all_active_states($countries = array(), $flush_cache = false) |
|
92 | - { |
|
93 | - if (! self::$_active_states || $flush_cache) { |
|
94 | - $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries(); |
|
95 | - self::$_active_states = $this->get_all(array( |
|
96 | - array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))), |
|
97 | - 'order_by' => array( 'STA_name'=>'ASC' ), |
|
98 | - 'limit' => array( 0, 99999 ), |
|
99 | - 'force_join' => array( 'Country' ) |
|
100 | - )); |
|
101 | - } |
|
102 | - return self::$_active_states; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * get_all_states_of_active_countries |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - public function get_all_states_of_active_countries() |
|
112 | - { |
|
113 | - if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
114 | - return $states; |
|
115 | - } |
|
116 | - return false; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * get_all_states_of_active_countries |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function get_all_active_states_for_these_countries($countries) |
|
126 | - { |
|
127 | - if (! $countries) { |
|
128 | - return false; |
|
129 | - } |
|
130 | - if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
131 | - return $states; |
|
132 | - } |
|
133 | - return false; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * get_all_states_of_active_countries |
|
140 | - * @return array |
|
141 | - */ |
|
142 | - public function get_all_states_for_these_countries($countries) |
|
143 | - { |
|
144 | - if (! $countries) { |
|
145 | - return false; |
|
146 | - } |
|
147 | - if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
148 | - return $states; |
|
149 | - } |
|
150 | - return false; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Gets the state's name by its ID |
|
155 | - * @param string $state_ID |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function get_state_name_by_ID($state_ID) |
|
159 | - { |
|
160 | - if (isset(self::$_all_states[ $state_ID ]) && |
|
161 | - self::$_all_states[ $state_ID ] instanceof EE_State ) { |
|
162 | - return self::$_all_states[ $state_ID ]->name(); |
|
163 | - } |
|
164 | - $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name'); |
|
165 | - if (is_array($names) && ! empty($names)) { |
|
166 | - return reset($names); |
|
167 | - } else { |
|
168 | - return ''; |
|
169 | - } |
|
170 | - } |
|
14 | + // private instance of the Attendee object |
|
15 | + protected static $_instance = null; |
|
16 | + // array of all states |
|
17 | + private static $_all_states = false; |
|
18 | + // array of all active states |
|
19 | + private static $_active_states = false; |
|
20 | + |
|
21 | + protected function __construct($timezone = null) |
|
22 | + { |
|
23 | + $this->singular_item = __('State/Province', 'event_espresso'); |
|
24 | + $this->plural_item = __('States/Provinces', 'event_espresso'); |
|
25 | + |
|
26 | + $this->_tables = array( |
|
27 | + 'State'=> new EE_Primary_Table('esp_state', 'STA_ID') |
|
28 | + ); |
|
29 | + |
|
30 | + $this->_fields = array( |
|
31 | + 'State'=>array( |
|
32 | + 'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID', 'event_espresso')), |
|
33 | + 'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso'), false, null, 'Country'), |
|
34 | + 'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation', 'event_espresso'), false, ''), |
|
35 | + 'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name', 'event_espresso'), false, ''), |
|
36 | + 'STA_active'=> new EE_Boolean_Field('STA_active', __('State Active Flag', 'event_espresso'), false, false) |
|
37 | + )); |
|
38 | + $this->_model_relations = array( |
|
39 | + 'Attendee'=>new EE_Has_Many_Relation(), |
|
40 | + 'Country' => new EE_Belongs_To_Relation(), |
|
41 | + 'Venue'=>new EE_Has_Many_Relation(), |
|
42 | + ); |
|
43 | + // this model is generally available for reading |
|
44 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
45 | + // @todo: only show STA_active |
|
46 | + parent::__construct($timezone); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * reset_cached_states |
|
54 | + * |
|
55 | + * @access private |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function reset_cached_states() |
|
59 | + { |
|
60 | + EEM_State::$_active_states = array(); |
|
61 | + EEM_State::$_all_states = array(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * _get_states |
|
69 | + * |
|
70 | + * @access private |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + public function get_all_states() |
|
74 | + { |
|
75 | + if (! self::$_all_states) { |
|
76 | + self::$_all_states = $this->get_all(array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 ))); |
|
77 | + } |
|
78 | + return self::$_all_states; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * _get_states |
|
85 | + * |
|
86 | + * @access public |
|
87 | + * @param array $countries |
|
88 | + * @param bool $flush_cache |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public function get_all_active_states($countries = array(), $flush_cache = false) |
|
92 | + { |
|
93 | + if (! self::$_active_states || $flush_cache) { |
|
94 | + $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries(); |
|
95 | + self::$_active_states = $this->get_all(array( |
|
96 | + array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))), |
|
97 | + 'order_by' => array( 'STA_name'=>'ASC' ), |
|
98 | + 'limit' => array( 0, 99999 ), |
|
99 | + 'force_join' => array( 'Country' ) |
|
100 | + )); |
|
101 | + } |
|
102 | + return self::$_active_states; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * get_all_states_of_active_countries |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + public function get_all_states_of_active_countries() |
|
112 | + { |
|
113 | + if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
114 | + return $states; |
|
115 | + } |
|
116 | + return false; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * get_all_states_of_active_countries |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function get_all_active_states_for_these_countries($countries) |
|
126 | + { |
|
127 | + if (! $countries) { |
|
128 | + return false; |
|
129 | + } |
|
130 | + if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
131 | + return $states; |
|
132 | + } |
|
133 | + return false; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * get_all_states_of_active_countries |
|
140 | + * @return array |
|
141 | + */ |
|
142 | + public function get_all_states_for_these_countries($countries) |
|
143 | + { |
|
144 | + if (! $countries) { |
|
145 | + return false; |
|
146 | + } |
|
147 | + if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
148 | + return $states; |
|
149 | + } |
|
150 | + return false; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Gets the state's name by its ID |
|
155 | + * @param string $state_ID |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function get_state_name_by_ID($state_ID) |
|
159 | + { |
|
160 | + if (isset(self::$_all_states[ $state_ID ]) && |
|
161 | + self::$_all_states[ $state_ID ] instanceof EE_State ) { |
|
162 | + return self::$_all_states[ $state_ID ]->name(); |
|
163 | + } |
|
164 | + $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name'); |
|
165 | + if (is_array($names) && ! empty($names)) { |
|
166 | + return reset($names); |
|
167 | + } else { |
|
168 | + return ''; |
|
169 | + } |
|
170 | + } |
|
171 | 171 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | 'Venue'=>new EE_Has_Many_Relation(), |
42 | 42 | ); |
43 | 43 | // this model is generally available for reading |
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
44 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
45 | 45 | // @todo: only show STA_active |
46 | 46 | parent::__construct($timezone); |
47 | 47 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function get_all_states() |
74 | 74 | { |
75 | - if (! self::$_all_states) { |
|
76 | - self::$_all_states = $this->get_all(array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 ))); |
|
75 | + if ( ! self::$_all_states) { |
|
76 | + self::$_all_states = $this->get_all(array('order_by'=>array('STA_name'=>'ASC'), 'limit'=> array(0, 99999))); |
|
77 | 77 | } |
78 | 78 | return self::$_all_states; |
79 | 79 | } |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_all_active_states($countries = array(), $flush_cache = false) |
92 | 92 | { |
93 | - if (! self::$_active_states || $flush_cache) { |
|
93 | + if ( ! self::$_active_states || $flush_cache) { |
|
94 | 94 | $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries(); |
95 | - self::$_active_states = $this->get_all(array( |
|
96 | - array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))), |
|
97 | - 'order_by' => array( 'STA_name'=>'ASC' ), |
|
98 | - 'limit' => array( 0, 99999 ), |
|
99 | - 'force_join' => array( 'Country' ) |
|
95 | + self::$_active_states = $this->get_all(array( |
|
96 | + array('STA_active' => true, 'CNT_ISO' => array('IN', array_keys($countries))), |
|
97 | + 'order_by' => array('STA_name'=>'ASC'), |
|
98 | + 'limit' => array(0, 99999), |
|
99 | + 'force_join' => array('Country') |
|
100 | 100 | )); |
101 | 101 | } |
102 | 102 | return self::$_active_states; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function get_all_states_of_active_countries() |
112 | 112 | { |
113 | - if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
113 | + if ($states = $this->get_all(array(array('Country.CNT_active' => true, 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
114 | 114 | return $states; |
115 | 115 | } |
116 | 116 | return false; |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_all_active_states_for_these_countries($countries) |
126 | 126 | { |
127 | - if (! $countries) { |
|
127 | + if ( ! $countries) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | - if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
130 | + if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries)), 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
131 | 131 | return $states; |
132 | 132 | } |
133 | 133 | return false; |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function get_all_states_for_these_countries($countries) |
143 | 143 | { |
144 | - if (! $countries) { |
|
144 | + if ( ! $countries) { |
|
145 | 145 | return false; |
146 | 146 | } |
147 | - if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
147 | + if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries))), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
148 | 148 | return $states; |
149 | 149 | } |
150 | 150 | return false; |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function get_state_name_by_ID($state_ID) |
159 | 159 | { |
160 | - if (isset(self::$_all_states[ $state_ID ]) && |
|
161 | - self::$_all_states[ $state_ID ] instanceof EE_State ) { |
|
162 | - return self::$_all_states[ $state_ID ]->name(); |
|
160 | + if (isset(self::$_all_states[$state_ID]) && |
|
161 | + self::$_all_states[$state_ID] instanceof EE_State) { |
|
162 | + return self::$_all_states[$state_ID]->name(); |
|
163 | 163 | } |
164 | - $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name'); |
|
164 | + $names = $this->get_col(array(array('STA_ID' => $state_ID), 'limit' => 1), 'STA_name'); |
|
165 | 165 | if (is_array($names) && ! empty($names)) { |
166 | 166 | return reset($names); |
167 | 167 | } else { |
@@ -13,40 +13,40 @@ |
||
13 | 13 | |
14 | 14 | |
15 | 15 | |
16 | - // private instance of the EEM_Ticket_Template object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the EEM_Ticket_Template object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | - /** |
|
20 | - * private constructor to prevent direct creation |
|
21 | - * @Constructor |
|
22 | - * @access private |
|
23 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - protected function __construct($timezone) |
|
27 | - { |
|
28 | - $this->singular_item = __('Ticket Template', 'event_espresso'); |
|
29 | - $this->plural_item = __('Ticket Templates', 'event_espresso'); |
|
19 | + /** |
|
20 | + * private constructor to prevent direct creation |
|
21 | + * @Constructor |
|
22 | + * @access private |
|
23 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + protected function __construct($timezone) |
|
27 | + { |
|
28 | + $this->singular_item = __('Ticket Template', 'event_espresso'); |
|
29 | + $this->plural_item = __('Ticket Templates', 'event_espresso'); |
|
30 | 30 | |
31 | - $this->_tables = array( |
|
32 | - 'Ticket_Template'=> new EE_Primary_Table('esp_ticket_template', 'TTM_ID') |
|
33 | - ); |
|
34 | - $this->_fields = array( |
|
35 | - 'Ticket_Template'=>array( |
|
36 | - 'TTM_ID'=>new EE_Primary_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso')), |
|
37 | - 'TTM_name'=>new EE_Plain_Text_Field('TTM_name', __('The name of the ticket template', 'event_espresso'), false, ''), |
|
38 | - 'TTM_description'=>new EE_Plain_Text_Field('TTM_description', __('The description for the ticket template', 'event_espresso'), true, ''), |
|
39 | - 'TTM_file'=>new EE_Plain_Text_Field('TTM_file', __('The file name for the actual template file saved on disk', 'event_espresso'), true, ''), |
|
40 | - )); |
|
41 | - $this->_model_relations = array( |
|
42 | - 'Ticket'=>new EE_Has_Many_Relation() |
|
43 | - ); |
|
44 | - $this->_model_chain_to_wp_user = 'Ticket'; |
|
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
46 | - // account for default tickets in the caps |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
50 | - parent::__construct($timezone); |
|
51 | - } |
|
31 | + $this->_tables = array( |
|
32 | + 'Ticket_Template'=> new EE_Primary_Table('esp_ticket_template', 'TTM_ID') |
|
33 | + ); |
|
34 | + $this->_fields = array( |
|
35 | + 'Ticket_Template'=>array( |
|
36 | + 'TTM_ID'=>new EE_Primary_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso')), |
|
37 | + 'TTM_name'=>new EE_Plain_Text_Field('TTM_name', __('The name of the ticket template', 'event_espresso'), false, ''), |
|
38 | + 'TTM_description'=>new EE_Plain_Text_Field('TTM_description', __('The description for the ticket template', 'event_espresso'), true, ''), |
|
39 | + 'TTM_file'=>new EE_Plain_Text_Field('TTM_file', __('The file name for the actual template file saved on disk', 'event_espresso'), true, ''), |
|
40 | + )); |
|
41 | + $this->_model_relations = array( |
|
42 | + 'Ticket'=>new EE_Has_Many_Relation() |
|
43 | + ); |
|
44 | + $this->_model_chain_to_wp_user = 'Ticket'; |
|
45 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
46 | + // account for default tickets in the caps |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
50 | + parent::__construct($timezone); |
|
51 | + } |
|
52 | 52 | } |
@@ -42,11 +42,11 @@ |
||
42 | 42 | 'Ticket'=>new EE_Has_Many_Relation() |
43 | 43 | ); |
44 | 44 | $this->_model_chain_to_wp_user = 'Ticket'; |
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
45 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
46 | 46 | // account for default tickets in the caps |
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
50 | 50 | parent::__construct($timezone); |
51 | 51 | } |
52 | 52 | } |