@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @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) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
56 | 56 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
57 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
58 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
57 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
58 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
59 | 59 | )); |
60 | 60 | $this->_model_relations = array( |
61 | 61 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | ); |
65 | 65 | $this->_model_chain_to_wp_user = 'Event'; |
66 | 66 | //this model is generally available for reading |
67 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
71 | - parent::__construct( $timezone ); |
|
67 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
71 | + parent::__construct($timezone); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
86 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
87 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
86 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
88 | 88 | 'DTT_order' => 1, |
89 | 89 | 'DTT_reg_limit' => EE_INF |
90 | 90 | ), |
91 | 91 | $this->_timezone |
92 | 92 | ); |
93 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
94 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
95 | - return array( $blank_datetime ); |
|
93 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
94 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
95 | + return array($blank_datetime); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param int $EVT_ID |
107 | 107 | * @return EE_Datetime[] array on success, FALSE on fail |
108 | 108 | */ |
109 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
110 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
109 | + public function get_all_event_dates($EVT_ID = 0) { |
|
110 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
111 | 111 | return $this->create_new_blank_datetime(); |
112 | 112 | } |
113 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
113 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | 114 | |
115 | - if ( empty( $results ) ) { |
|
115 | + if (empty($results)) { |
|
116 | 116 | return $this->create_new_blank_datetime(); |
117 | 117 | } |
118 | 118 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | * the given number |
134 | 134 | * @return EE_Datetime[] |
135 | 135 | */ |
136 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
136 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
137 | 137 | |
138 | 138 | //sanitize EVT_ID |
139 | - $EVT_ID = intval( $EVT_ID ); |
|
139 | + $EVT_ID = intval($EVT_ID); |
|
140 | 140 | |
141 | 141 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
142 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
143 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
142 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
143 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
144 | 144 | |
145 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
145 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
146 | 146 | |
147 | - if( ! $include_expired){ |
|
148 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
147 | + if ( ! $include_expired) { |
|
148 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
149 | 149 | } |
150 | - if( $include_deleted){ |
|
151 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
150 | + if ($include_deleted) { |
|
151 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
152 | 152 | } |
153 | 153 | |
154 | - $result = $this->get_all( $query_params ); |
|
155 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
154 | + $result = $this->get_all($query_params); |
|
155 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
156 | 156 | return $result; |
157 | 157 | } |
158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param int $limit |
168 | 168 | * @return EE_Datetime[] |
169 | 169 | */ |
170 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
171 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
170 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
171 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
172 | 172 | 'limit'=>$limit, |
173 | 173 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
174 | 174 | 'default_where_conditions' => 'none')); |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param boolean $include_deleted |
184 | 184 | * @return EE_Datetime |
185 | 185 | */ |
186 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
187 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | - if($results){ |
|
186 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
187 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | + if ($results) { |
|
189 | 189 | return array_shift($results); |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return NULL; |
192 | 192 | } |
193 | 193 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param bool $try_to_exclude_deleted |
202 | 202 | * @return \EE_Datetime |
203 | 203 | */ |
204 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
205 | - if($try_to_exclude_expired){ |
|
206 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
207 | - if($non_expired){ |
|
204 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
205 | + if ($try_to_exclude_expired) { |
|
206 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
207 | + if ($non_expired) { |
|
208 | 208 | return $non_expired; |
209 | 209 | } |
210 | 210 | } |
211 | - if($try_to_exclude_deleted){ |
|
211 | + if ($try_to_exclude_deleted) { |
|
212 | 212 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
213 | - if($expired_even){ |
|
213 | + if ($expired_even) { |
|
214 | 214 | return $expired_even; |
215 | 215 | } |
216 | 216 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * @param int $limit |
230 | 230 | * @return EE_Datetime[] |
231 | 231 | */ |
232 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
232 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
233 | 233 | //sanitize EVT_ID |
234 | - $EVT_ID = intval( $EVT_ID ); |
|
234 | + $EVT_ID = intval($EVT_ID); |
|
235 | 235 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
236 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
237 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | - if( ! $include_expired){ |
|
239 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
236 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
237 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | + if ( ! $include_expired) { |
|
239 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
240 | 240 | } |
241 | - if( $include_deleted){ |
|
242 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
241 | + if ($include_deleted) { |
|
242 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
243 | 243 | } |
244 | - if($limit){ |
|
244 | + if ($limit) { |
|
245 | 245 | $query_params['limit'] = $limit; |
246 | 246 | } |
247 | - $result = $this->get_all( $query_params ); |
|
248 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
247 | + $result = $this->get_all($query_params); |
|
248 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
249 | 249 | return $result; |
250 | 250 | } |
251 | 251 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | * @param int $limit |
259 | 259 | * @return EE_Datetime[] |
260 | 260 | */ |
261 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
261 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
262 | 262 | //sanitize TKT_ID |
263 | - $TKT_ID = intval( $TKT_ID ); |
|
263 | + $TKT_ID = intval($TKT_ID); |
|
264 | 264 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
265 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
266 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | - if( ! $include_expired){ |
|
268 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
265 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
266 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | + if ( ! $include_expired) { |
|
268 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
269 | 269 | } |
270 | - if( $include_deleted){ |
|
271 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
270 | + if ($include_deleted) { |
|
271 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
272 | 272 | } |
273 | - if($limit){ |
|
273 | + if ($limit) { |
|
274 | 274 | $query_params['limit'] = $limit; |
275 | 275 | } |
276 | - $result = $this->get_all( $query_params ); |
|
277 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
276 | + $result = $this->get_all($query_params); |
|
277 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
278 | 278 | return $result; |
279 | 279 | } |
280 | 280 | |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * that number |
291 | 291 | * @return EE_Datetime[] |
292 | 292 | */ |
293 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
293 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
294 | 294 | //sanitize id. |
295 | - $TKT_ID = intval( $TKT_ID ); |
|
295 | + $TKT_ID = intval($TKT_ID); |
|
296 | 296 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
297 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
298 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
299 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
300 | - if( ! $include_expired){ |
|
301 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
297 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
298 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
299 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
300 | + if ( ! $include_expired) { |
|
301 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
302 | 302 | } |
303 | - if( $include_deleted){ |
|
304 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
303 | + if ($include_deleted) { |
|
304 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
305 | 305 | } |
306 | - if($limit){ |
|
306 | + if ($limit) { |
|
307 | 307 | $query_params['limit'] = $limit; |
308 | 308 | } |
309 | - $result = $this->get_all( $query_params ); |
|
310 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
309 | + $result = $this->get_all($query_params); |
|
310 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
311 | 311 | return $result; |
312 | 312 | } |
313 | 313 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | * @param int $EVT_ID |
319 | 319 | * @return EE_Datetime |
320 | 320 | */ |
321 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
321 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
322 | 322 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | - if($results){ |
|
323 | + if ($results) { |
|
324 | 324 | return array_shift($results); |
325 | - }else{ |
|
325 | + } else { |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | } |
@@ -341,77 +341,77 @@ discard block |
||
341 | 341 | * - inactive = Events that are either not published. |
342 | 342 | * @return wpdb results array |
343 | 343 | */ |
344 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
345 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
346 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
344 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
345 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
346 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
347 | 347 | |
348 | - switch ( $evt_active_status ) { |
|
348 | + switch ($evt_active_status) { |
|
349 | 349 | case 'upcoming' : |
350 | 350 | $where_params['Event.status'] = 'publish'; |
351 | 351 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
352 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
352 | + if (isset($where_params['DTT_EVT_start'])) { |
|
353 | 353 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
354 | 354 | } |
355 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
355 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'expired' : |
359 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
359 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
360 | 360 | //get events to exclude |
361 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
361 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
362 | 362 | //first get all events that have datetimes where its not expired. |
363 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
364 | - $event_ids = array_keys( $event_ids ); |
|
363 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
364 | + $event_ids = array_keys($event_ids); |
|
365 | 365 | |
366 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
366 | + if (isset($where_params['DTT_EVT_end'])) { |
|
367 | 367 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
368 | 368 | } |
369 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
370 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
369 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
370 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
371 | 371 | break; |
372 | 372 | |
373 | 373 | case 'active' : |
374 | 374 | $where_params['Event.status'] = 'publish'; |
375 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
375 | + if (isset($where_params['DTT_EVT_start'])) { |
|
376 | 376 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
377 | 377 | } |
378 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
378 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
379 | 379 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
380 | 380 | } |
381 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
382 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
381 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
382 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
383 | 383 | break; |
384 | 384 | |
385 | 385 | case 'inactive' : |
386 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
387 | - if ( isset( $where_params['OR'] ) ) { |
|
386 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
387 | + if (isset($where_params['OR'])) { |
|
388 | 388 | $where_params['AND']['OR'] = $where_params['OR']; |
389 | 389 | } |
390 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
390 | + if (isset($where_params['DTT_EVT_end'])) { |
|
391 | 391 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
392 | - unset( $where_params['DTT_EVT_end'] ); |
|
392 | + unset($where_params['DTT_EVT_end']); |
|
393 | 393 | } |
394 | 394 | |
395 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
395 | + if (isset($where_params['DTT_EVT_start'])) { |
|
396 | 396 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
397 | - unset( $where_params['DTT_EVT_start'] ); |
|
397 | + unset($where_params['DTT_EVT_start']); |
|
398 | 398 | } |
399 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
399 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
400 | 400 | break; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $query_params[0] = $where_params; |
404 | 404 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
405 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
405 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
406 | 406 | |
407 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
407 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
408 | 408 | |
409 | 409 | $columns_to_select = array( |
410 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
411 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
412 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
410 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
411 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
412 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
413 | 413 | ); |
414 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
414 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * for the tickets for each datetime) |
420 | 420 | * @param EE_Datetime[] $datetimes |
421 | 421 | */ |
422 | - public function update_sold($datetimes){ |
|
423 | - foreach($datetimes as $datetime){ |
|
422 | + public function update_sold($datetimes) { |
|
423 | + foreach ($datetimes as $datetime) { |
|
424 | 424 | $datetime->update_sold(); |
425 | 425 | } |
426 | 426 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * @param array $query_params |
436 | 436 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
437 | 437 | */ |
438 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
439 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
440 | - if ( $datetime instanceof EE_Datetime ) { |
|
441 | - return $datetime->tickets_remaining( $query_params ); |
|
438 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
439 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
440 | + if ($datetime instanceof EE_Datetime) { |
|
441 | + return $datetime->tickets_remaining($query_params); |
|
442 | 442 | } |
443 | 443 | return 0; |
444 | 444 | } |
@@ -460,36 +460,36 @@ discard block |
||
460 | 460 | * EE_Datetime::upcoming |
461 | 461 | * EE_Datetime::expired |
462 | 462 | */ |
463 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
463 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
464 | 464 | //only accept where conditions for this query. |
465 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
465 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
466 | 466 | $status_query_args = array( |
467 | 467 | EE_Datetime::active => array_merge( |
468 | 468 | $_where, |
469 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
469 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
470 | 470 | ), |
471 | 471 | EE_Datetime::upcoming => array_merge( |
472 | 472 | $_where, |
473 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
473 | + array('DTT_EVT_start' => array('>', time())) |
|
474 | 474 | ), |
475 | 475 | EE_Datetime::expired => array_merge( |
476 | 476 | $_where, |
477 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
477 | + array('DTT_EVT_end' => array('<', time())) |
|
478 | 478 | ) |
479 | 479 | ); |
480 | 480 | |
481 | - if ( ! empty( $stati_to_include ) ) { |
|
482 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
483 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
484 | - unset( $status_query_args[$status] ); |
|
481 | + if ( ! empty($stati_to_include)) { |
|
482 | + foreach (array_keys($status_query_args) as $status) { |
|
483 | + if ( ! in_array($status, $stati_to_include)) { |
|
484 | + unset($status_query_args[$status]); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | 489 | //loop through and query counts for each stati. |
490 | 490 | $status_query_results = array(); |
491 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
492 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
491 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
492 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return $status_query_results; |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | * @param array $query_params |
504 | 504 | * @return int |
505 | 505 | */ |
506 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
507 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
508 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
506 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
507 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
508 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...) |
4 | 4 | */ |
5 | -class EE_Money_Field extends EE_Float_Field{ |
|
6 | - function get_wpdb_data_type(){ |
|
5 | +class EE_Money_Field extends EE_Float_Field { |
|
6 | + function get_wpdb_data_type() { |
|
7 | 7 | return '%f'; |
8 | 8 | } |
9 | 9 | /** |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @param type $schema |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){ |
|
18 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
19 | 19 | $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
20 | 20 | |
21 | - if($schema == 'localized_float'){ |
|
21 | + if ($schema == 'localized_float') { |
|
22 | 22 | return $pretty_float; |
23 | 23 | } |
24 | - if($schema == 'no_currency_code'){ |
|
24 | + if ($schema == 'no_currency_code') { |
|
25 | 25 | // echo "schema no currency!"; |
26 | 26 | $display_code = false; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | $display_code = true; |
29 | 29 | } |
30 | 30 | //we don't use the $pretty_float because format_currency will take care of it. |
31 | - return EEH_Template::format_currency( $value_on_field_to_be_outputted, false, $display_code ); |
|
31 | + return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | //now it's a float-style string or number |
48 | 48 | $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object); |
49 | 49 | //round to the correctly number of decimal places for this currency |
50 | - $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
50 | + $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
51 | 51 | return $rounded_value; |
52 | 52 | } |
53 | 53 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Datetime_Field |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @param string $pretty_date_format |
112 | 112 | * @param string $pretty_time_format |
113 | 113 | */ |
114 | - public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){ |
|
114 | + public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') { |
|
115 | 115 | |
116 | - $this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format'); |
|
117 | - $this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format'); |
|
118 | - $this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format'); |
|
119 | - $this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format'); |
|
116 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
117 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
118 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
119 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
120 | 120 | |
121 | - parent::__construct( $table_column, $nice_name, $nullable, $default_value ); |
|
122 | - $this->set_timezone( $timezone_string ); |
|
121 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
122 | + $this->set_timezone($timezone_string); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return DateTimeZone |
139 | 139 | */ |
140 | 140 | public function get_UTC_DateTimeZone() { |
141 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' ); |
|
141 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return DateTimeZone |
148 | 148 | */ |
149 | 149 | public function get_blog_DateTimeZone() { |
150 | - return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' ); |
|
150 | + return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string(''); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp |
158 | 158 | * @return DateTime |
159 | 159 | */ |
160 | - public function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
161 | - return $this->_get_date_object( $value_inputted_for_field_on_model_object ); |
|
160 | + public function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
161 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @param bool $pretty If we're returning the pretty formats or standard format string. |
175 | 175 | * @return string The final assembled format string. |
176 | 176 | */ |
177 | - protected function _get_date_time_output( $pretty = FALSE ) { |
|
177 | + protected function _get_date_time_output($pretty = FALSE) { |
|
178 | 178 | |
179 | - switch ( $this->_date_time_output ) { |
|
179 | + switch ($this->_date_time_output) { |
|
180 | 180 | case 'time' : |
181 | 181 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
182 | 182 | break; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | break; |
187 | 187 | |
188 | 188 | default : |
189 | - return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format; |
|
189 | + return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param string $what acceptable values are 'time' or 'date'. Any other value will be set but will always result in both 'date' and 'time' being returned. |
201 | 201 | * @return void |
202 | 202 | */ |
203 | - public function set_date_time_output( $what = NULL ) { |
|
203 | + public function set_date_time_output($what = NULL) { |
|
204 | 204 | $this->_date_time_output = $what; |
205 | 205 | } |
206 | 206 | |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
217 | 217 | * @return void |
218 | 218 | */ |
219 | - public function set_timezone( $timezone_string ) { |
|
220 | - if( empty( $timezone_string ) && $this->_timezone_string != NULL ){ |
|
219 | + public function set_timezone($timezone_string) { |
|
220 | + if (empty($timezone_string) && $this->_timezone_string != NULL) { |
|
221 | 221 | // leave the timezone AS-IS if we already have one and |
222 | 222 | // the function arg didn't provide one |
223 | 223 | return; |
224 | 224 | } |
225 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
226 | - $this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC'; |
|
227 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string ); |
|
225 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
226 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
227 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * @param string $timezone_string |
237 | 237 | * @return \DateTimeZone |
238 | 238 | */ |
239 | - protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) { |
|
240 | - return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) ); |
|
239 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') { |
|
240 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param bool $pretty Whether to set pretty format or not. |
263 | 263 | * @return void |
264 | 264 | */ |
265 | - public function set_date_format( $format, $pretty = false ) { |
|
266 | - if ( $pretty ) { |
|
265 | + public function set_date_format($format, $pretty = false) { |
|
266 | + if ($pretty) { |
|
267 | 267 | $this->_pretty_date_format = $format; |
268 | 268 | } else { |
269 | 269 | $this->_date_format = $format; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param bool $pretty Whether to get pretty format or not. |
279 | 279 | * @return string |
280 | 280 | */ |
281 | - public function get_date_format( $pretty = false ) { |
|
281 | + public function get_date_format($pretty = false) { |
|
282 | 282 | return $pretty ? $this->_pretty_date_format : $this->_date_format; |
283 | 283 | } |
284 | 284 | |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | * @param bool $pretty Whether to set pretty format or not. |
294 | 294 | * @return void |
295 | 295 | */ |
296 | - public function set_time_format( $format, $pretty = false ) { |
|
297 | - if ( $pretty ) { |
|
296 | + public function set_time_format($format, $pretty = false) { |
|
297 | + if ($pretty) { |
|
298 | 298 | $this->_pretty_time_format = $format; |
299 | 299 | } else { |
300 | 300 | $this->_time_format = $format; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param bool $pretty Whether to get pretty format or not. |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - public function get_time_format( $pretty = false ) { |
|
312 | + public function get_time_format($pretty = false) { |
|
313 | 313 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
314 | 314 | } |
315 | 315 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
325 | 325 | * @return void |
326 | 326 | */ |
327 | - public function set_pretty_date_format( $format ) { |
|
327 | + public function set_pretty_date_format($format) { |
|
328 | 328 | $this->_pretty_date_format = $format; |
329 | 329 | } |
330 | 330 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
342 | 342 | * @return void |
343 | 343 | */ |
344 | - public function set_pretty_time_format( $format ) { |
|
344 | + public function set_pretty_time_format($format) { |
|
345 | 345 | $this->_pretty_time_format = $format; |
346 | 346 | } |
347 | 347 | |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | * @param DateTime $current current DateTime object for the datetime field |
354 | 354 | * @return DateTime |
355 | 355 | */ |
356 | - public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){ |
|
356 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) { |
|
357 | 357 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
358 | - if ( $time_to_set_string instanceof DateTime ) { |
|
358 | + if ($time_to_set_string instanceof DateTime) { |
|
359 | 359 | $parsed = array( |
360 | 360 | 'hour' => $time_to_set_string->format('H'), |
361 | 361 | 'minute' => $time_to_set_string->format('i'), |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | ); |
364 | 364 | } else { |
365 | 365 | //parse incoming string |
366 | - $parsed = date_parse_from_format( $this->_time_format, $time_to_set_string ); |
|
366 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | //make sure $current is in the correct timezone. |
370 | - $current->setTimezone( $this->_DateTimeZone ); |
|
371 | - return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] ); |
|
370 | + $current->setTimezone($this->_DateTimeZone); |
|
371 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | * @param DateTime $current current DateTime object for the datetime field |
380 | 380 | * @return DateTime |
381 | 381 | */ |
382 | - public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){ |
|
382 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) { |
|
383 | 383 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
384 | - if ( $date_to_set_string instanceof DateTime ) { |
|
384 | + if ($date_to_set_string instanceof DateTime) { |
|
385 | 385 | $parsed = array( |
386 | 386 | 'year' => $date_to_set_string->format('Y'), |
387 | 387 | 'month' => $date_to_set_string->format('m'), |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | ); |
390 | 390 | } else { |
391 | 391 | //parse incoming string |
392 | - $parsed = date_parse_from_format( $this->_date_format, $date_to_set_string ); |
|
392 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | //make sure $current is in the correct timezone |
396 | - $current->setTimezone( $this->_DateTimeZone ); |
|
397 | - return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] ); |
|
396 | + $current->setTimezone($this->_DateTimeZone); |
|
397 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | * @param DateTime $DateTime |
407 | 407 | * @return string formatted date time for given timezone |
408 | 408 | */ |
409 | - public function prepare_for_get( $DateTime ) { |
|
410 | - return $this->_prepare_for_display( $DateTime ); |
|
409 | + public function prepare_for_get($DateTime) { |
|
410 | + return $this->_prepare_for_display($DateTime); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | * @param null $schema |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public function prepare_for_pretty_echoing( $DateTime, $schema = null ) { |
|
426 | - return $this->_prepare_for_display( $DateTime, $schema ? $schema : true ); |
|
425 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) { |
|
426 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
@@ -437,36 +437,36 @@ discard block |
||
437 | 437 | * @return string |
438 | 438 | * @throws \EE_Error |
439 | 439 | */ |
440 | - protected function _prepare_for_display( $DateTime, $schema = false ) { |
|
441 | - if ( ! $DateTime instanceof DateTime ) { |
|
442 | - if ( $this->_nullable ) { |
|
440 | + protected function _prepare_for_display($DateTime, $schema = false) { |
|
441 | + if ( ! $DateTime instanceof DateTime) { |
|
442 | + if ($this->_nullable) { |
|
443 | 443 | return ''; |
444 | 444 | } else { |
445 | - if ( WP_DEBUG ) { |
|
446 | - throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) ); |
|
445 | + if (WP_DEBUG) { |
|
446 | + throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename)); |
|
447 | 447 | } else { |
448 | - $DateTime = new DateTime( "now" ); |
|
449 | - EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) ); |
|
448 | + $DateTime = new DateTime("now"); |
|
449 | + EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename)); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | - $format_string = $this->_get_date_time_output( $schema ); |
|
453 | + $format_string = $this->_get_date_time_output($schema); |
|
454 | 454 | //make sure datetime_value is in the correct timezone (in case that's been updated). |
455 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
456 | - if ( $schema ) { |
|
457 | - if( $this->_display_timezone() ) { |
|
455 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
456 | + if ($schema) { |
|
457 | + if ($this->_display_timezone()) { |
|
458 | 458 | //must be explicit because schema could equal true. |
459 | - if( $schema === 'no_html' ){ |
|
460 | - $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
|
461 | - }else{ |
|
462 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
|
459 | + if ($schema === 'no_html') { |
|
460 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
461 | + } else { |
|
462 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
463 | 463 | } |
464 | 464 | } else { |
465 | 465 | $timezone_string = ''; |
466 | 466 | } |
467 | - return $DateTime->format( $format_string ) . $timezone_string; |
|
467 | + return $DateTime->format($format_string).$timezone_string; |
|
468 | 468 | } else { |
469 | - return $DateTime->format( $format_string ); |
|
469 | + return $DateTime->format($format_string); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
@@ -480,18 +480,18 @@ discard block |
||
480 | 480 | * @return string mysql timestamp in UTC |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - public function prepare_for_use_in_db( $datetime_value ) { |
|
483 | + public function prepare_for_use_in_db($datetime_value) { |
|
484 | 484 | //we allow an empty value or DateTime object, but nothing else. |
485 | - if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) { |
|
486 | - throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) ); |
|
485 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
486 | + throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso')); |
|
487 | 487 | } |
488 | 488 | |
489 | - if ( $datetime_value instanceof DateTime ) { |
|
490 | - return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format ); |
|
489 | + if ($datetime_value instanceof DateTime) { |
|
490 | + return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
494 | - return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null; |
|
494 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -504,20 +504,20 @@ discard block |
||
504 | 504 | * @param string $datetime_string mysql timestamp in UTC |
505 | 505 | * @return mixed null | DateTime |
506 | 506 | */ |
507 | - public function prepare_for_set_from_db( $datetime_string ) { |
|
507 | + public function prepare_for_set_from_db($datetime_string) { |
|
508 | 508 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
509 | - if ( empty( $datetime_string) && $this->_nullable ) { |
|
509 | + if (empty($datetime_string) && $this->_nullable) { |
|
510 | 510 | return null; |
511 | 511 | } |
512 | 512 | // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
513 | - $DateTime = empty( $datetime_string ) ? new DateTime( 'now', $this->get_UTC_DateTimeZone() ) : DateTime::createFromFormat( EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone() ); |
|
513 | + $DateTime = empty($datetime_string) ? new DateTime('now', $this->get_UTC_DateTimeZone()) : DateTime::createFromFormat(EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone()); |
|
514 | 514 | |
515 | - if ( ! $DateTime instanceof DateTime ) { |
|
515 | + if ( ! $DateTime instanceof DateTime) { |
|
516 | 516 | //if still no datetime object, then let's just use now |
517 | - $DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() ); |
|
517 | + $DateTime = new DateTime('now', $this->get_UTC_DateTimeZone()); |
|
518 | 518 | } |
519 | 519 | // THEN apply the field's set DateTimeZone |
520 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
520 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
521 | 521 | return $DateTime; |
522 | 522 | } |
523 | 523 | |
@@ -534,15 +534,15 @@ discard block |
||
534 | 534 | protected function _display_timezone() { |
535 | 535 | |
536 | 536 | // first let's do a comparison of timezone strings. If they match then we can get out without any further calculations |
537 | - $blog_string = get_option( 'timezone_string' ); |
|
538 | - if ( $blog_string == $this->_timezone_string ) { |
|
537 | + $blog_string = get_option('timezone_string'); |
|
538 | + if ($blog_string == $this->_timezone_string) { |
|
539 | 539 | return FALSE; |
540 | 540 | } |
541 | 541 | // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
542 | - $this_offset = $this->get_timezone_offset( $this->_DateTimeZone ); |
|
543 | - $blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() ); |
|
542 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
543 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
544 | 544 | // now compare |
545 | - if ( $blog_offset === $this_offset ) { |
|
545 | + if ($blog_offset === $this_offset) { |
|
546 | 546 | return FALSE; |
547 | 547 | } |
548 | 548 | return TRUE; |
@@ -560,24 +560,24 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @return DateTime |
562 | 562 | */ |
563 | - protected function _get_date_object( $date_string ) { |
|
563 | + protected function _get_date_object($date_string) { |
|
564 | 564 | //first if this is an empty date_string and nullable is allowed, just return null. |
565 | - if ( $this->_nullable && empty( $date_string ) ) { |
|
565 | + if ($this->_nullable && empty($date_string)) { |
|
566 | 566 | return null; |
567 | 567 | } |
568 | 568 | |
569 | 569 | // if incoming date |
570 | - if ( $date_string instanceof DateTime ) { |
|
571 | - $date_string->setTimezone( $this->_DateTimeZone ); |
|
570 | + if ($date_string instanceof DateTime) { |
|
571 | + $date_string->setTimezone($this->_DateTimeZone); |
|
572 | 572 | return $date_string; |
573 | 573 | } |
574 | 574 | // if empty date_string and made it here. |
575 | 575 | // Return a datetime object for now in the given timezone. |
576 | - if ( empty( $date_string ) ) { |
|
577 | - return new DateTime( "now", $this->_DateTimeZone ); |
|
576 | + if (empty($date_string)) { |
|
577 | + return new DateTime("now", $this->_DateTimeZone); |
|
578 | 578 | } |
579 | 579 | // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
580 | - if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) { |
|
580 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
581 | 581 | try { |
582 | 582 | /** |
583 | 583 | * This is operating under the assumption that the incoming Unix timestamp is |
@@ -585,29 +585,29 @@ discard block |
||
585 | 585 | * current_time('timestamp'); |
586 | 586 | * |
587 | 587 | */ |
588 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
589 | - return $DateTime->setTimestamp( $date_string ); |
|
590 | - } catch ( Exception $e ) { |
|
588 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
589 | + return $DateTime->setTimestamp($date_string); |
|
590 | + } catch (Exception $e) { |
|
591 | 591 | // should be rare, but if things got fooled then let's just continue |
592 | 592 | } |
593 | 593 | } |
594 | 594 | //not a unix timestamp. So we will use the set format on this object and set timezone to |
595 | 595 | //create the DateTime object. |
596 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
596 | + $format = $this->_date_format.' '.$this->_time_format; |
|
597 | 597 | try { |
598 | - $DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone ); |
|
599 | - if ( ! $DateTime instanceof DateTime ) { |
|
598 | + $DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
599 | + if ( ! $DateTime instanceof DateTime) { |
|
600 | 600 | throw new EE_Error( |
601 | 601 | sprintf( |
602 | - __( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ), |
|
602 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
603 | 603 | $date_string, |
604 | 604 | $format |
605 | 605 | ) |
606 | 606 | ); |
607 | 607 | } |
608 | - } catch ( Exception $e ) { |
|
608 | + } catch (Exception $e) { |
|
609 | 609 | // if we made it here then likely then something went really wrong. Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
610 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
610 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
611 | 611 | } |
612 | 612 | return $DateTime; |
613 | 613 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | * @param null $time |
622 | 622 | * @return mixed |
623 | 623 | */ |
624 | - public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
|
625 | - $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
|
626 | - $transitions = $DateTimeZone->getTransitions( $time ); |
|
624 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) { |
|
625 | + $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time(); |
|
626 | + $transitions = $DateTimeZone->getTransitions($time); |
|
627 | 627 | return $transitions[0]['offset']; |
628 | 628 | } |
629 | 629 | |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | * @param string $timezone_string |
636 | 636 | * @return string abbreviation |
637 | 637 | */ |
638 | - public function get_timezone_abbrev( $timezone_string ) { |
|
639 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
640 | - $dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); |
|
641 | - return $dateTime->format( 'T' ); |
|
638 | + public function get_timezone_abbrev($timezone_string) { |
|
639 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
640 | + $dateTime = new DateTime('now', new DateTimeZone($timezone_string)); |
|
641 | + return $dateTime->format('T'); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * However, when inserting into the DB, it should be serialized. |
8 | 8 | * Upon retrieval from the DB, it should be unserialized back into an array. |
9 | 9 | */ |
10 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
11 | -class EE_Serialized_Text_Field extends EE_Text_Field_Base{ |
|
10 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
11 | +class EE_Serialized_Text_Field extends EE_Text_Field_Base { |
|
12 | 12 | /** |
13 | 13 | * Value SHOULD be an array, and we want to now convert it to a serialized string |
14 | 14 | * @param array $value_of_field_on_model_object |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | return maybe_serialize($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
21 | - $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize( $value_inputted_for_field_on_model_object ); |
|
22 | - if(is_string($value_inputted_for_field_on_model_object)){ |
|
21 | + $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object); |
|
22 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
23 | 23 | return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
24 | - }elseif(is_array($value_inputted_for_field_on_model_object)){ |
|
25 | - return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
26 | - }else{//so they passed NULL or an INT or something wack |
|
24 | + }elseif (is_array($value_inputted_for_field_on_model_object)) { |
|
25 | + return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
26 | + } else {//so they passed NULL or an INT or something wack |
|
27 | 27 | return $value_inputted_for_field_on_model_object; |
28 | 28 | } |
29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return array |
34 | 34 | */ |
35 | 35 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
36 | - return EEH_Array::maybe_unserialize( $value_found_in_db_for_model_object ); |
|
36 | + return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | */ |
45 | 45 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
46 | - switch($schema){ |
|
46 | + switch ($schema) { |
|
47 | 47 | case 'print_r': |
48 | - $pretty_value = print_r($value_on_field_to_be_outputted,true); |
|
48 | + $pretty_value = print_r($value_on_field_to_be_outputted, true); |
|
49 | 49 | break; |
50 | 50 | case 'as_table': |
51 | 51 | $pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted); |
52 | 52 | break; |
53 | 53 | default: |
54 | - $pretty_value = implode(", ",$value_on_field_to_be_outputted); |
|
54 | + $pretty_value = implode(", ", $value_on_field_to_be_outputted); |
|
55 | 55 | } |
56 | 56 | return $pretty_value; |
57 | 57 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Payment Model |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Michael Nelson, Brent Christensen |
10 | 10 | * |
11 | 11 | */ |
12 | -class EEM_Payment extends EEM_Base implements EEMI_Payment{ |
|
12 | +class EEM_Payment extends EEM_Base implements EEMI_Payment { |
|
13 | 13 | |
14 | 14 | // private instance of the Payment object |
15 | 15 | protected static $_instance = NULL; |
@@ -57,28 +57,28 @@ discard block |
||
57 | 57 | * @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) |
58 | 58 | * @return EEM_Payment |
59 | 59 | */ |
60 | - protected function __construct( $timezone ) { |
|
60 | + protected function __construct($timezone) { |
|
61 | 61 | |
62 | - $this->singular_item = __('Payment','event_espresso'); |
|
63 | - $this->plural_item = __('Payments','event_espresso'); |
|
62 | + $this->singular_item = __('Payment', 'event_espresso'); |
|
63 | + $this->plural_item = __('Payments', 'event_espresso'); |
|
64 | 64 | |
65 | 65 | $this->_tables = array( |
66 | - 'Payment'=>new EE_Primary_Table('esp_payment','PAY_ID') |
|
66 | + 'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID') |
|
67 | 67 | ); |
68 | 68 | $this->_fields = array( |
69 | 69 | 'Payment'=>array( |
70 | - 'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID','event_espresso')), |
|
71 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
72 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Payment::status_id_failed, 'Status'), |
|
73 | - 'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted','event_espresso'), false, time(), $timezone ), |
|
74 | - 'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment','event_espresso'), false, 'CART'), |
|
75 | - 'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for','event_espresso'), false, 0), |
|
70 | + 'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')), |
|
71 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
72 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'), |
|
73 | + 'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, time(), $timezone), |
|
74 | + 'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'), |
|
75 | + 'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0), |
|
76 | 76 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, NULL, 'Payment_Method'), |
77 | - 'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment','event_espresso'), false, ''), |
|
78 | - 'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number','event_espresso'), true, ''), |
|
79 | - 'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number','event_espresso'), true, ''), |
|
80 | - 'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info','event_espresso'), true, ''), |
|
81 | - 'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment','event_espresso'), true, ''), |
|
77 | + 'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''), |
|
78 | + 'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''), |
|
79 | + 'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''), |
|
80 | + 'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''), |
|
81 | + 'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''), |
|
82 | 82 | 'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true), |
83 | 83 | 'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true) |
84 | 84 | ) |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | 'Status'=> new EE_Belongs_To_Relation(), |
89 | 89 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
90 | 90 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
91 | - 'Registration' => new EE_HABTM_Relation( 'Registration_Payment' ), |
|
91 | + 'Registration' => new EE_HABTM_Relation('Registration_Payment'), |
|
92 | 92 | ); |
93 | 93 | $this->_model_chain_to_wp_user = 'Payment_Method'; |
94 | 94 | $this->_caps_slug = 'transactions'; |
95 | - parent::__construct( $timezone ); |
|
95 | + parent::__construct($timezone); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string $PAY_txn_id_chq_nmbr |
105 | 105 | * @return EE_Payment |
106 | 106 | */ |
107 | - public function get_payment_by_txn_id_chq_nmbr( $PAY_txn_id_chq_nmbr ){ |
|
107 | + public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) { |
|
108 | 108 | return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr))); |
109 | 109 | } |
110 | 110 | |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | * @param string $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status |
121 | 121 | * @return EE_Payment[] |
122 | 122 | */ |
123 | - public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) { |
|
123 | + public function get_payments_for_transaction($TXN_ID = FALSE, $status_of_payment = null) { |
|
124 | 124 | // all payments for a TXN ordered chronologically |
125 | - $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
|
125 | + $query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC')); |
|
126 | 126 | // if provided with a status, search specifically for that status. Otherwise get them all |
127 | - if ( $status_of_payment ){ |
|
127 | + if ($status_of_payment) { |
|
128 | 128 | $query_params[0]['STS_ID'] = $status_of_payment; |
129 | 129 | } |
130 | 130 | // retrieve payments |
131 | - return $this->get_all ( $query_params ); |
|
131 | + return $this->get_all($query_params); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @param int $TXN_ID |
139 | 139 | * @return EE_Payment[] |
140 | 140 | */ |
141 | - public function get_approved_payments_for_transaction( $TXN_ID = 0 ) { |
|
142 | - return $this->get_payments_for_transaction( $TXN_ID, EEM_Payment::status_id_approved ); |
|
141 | + public function get_approved_payments_for_transaction($TXN_ID = 0) { |
|
142 | + return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved); |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
@@ -160,36 +160,36 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return EE_Payment[] |
162 | 162 | */ |
163 | - public function get_payments_made_between_dates( $start_date = '', $end_date = '', $format = '', $timezone = '' ) { |
|
164 | - $timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
163 | + public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') { |
|
164 | + $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
165 | 165 | //if $start_date or $end date, verify $format is included. |
166 | - if ( ( ! empty( $start_date ) || ! empty( $end_date ) ) && empty( $format ) ) { |
|
167 | - throw new EE_Error( __('You included a start date and/or a end date for this method but did not include a format string. The format string is needed for setting up the query', 'event_espresso' ) ); |
|
166 | + if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) { |
|
167 | + throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string. The format string is needed for setting up the query', 'event_espresso')); |
|
168 | 168 | } |
169 | - $now = new DateTime( 'now' ); |
|
169 | + $now = new DateTime('now'); |
|
170 | 170 | // setup timezone objects once |
171 | - $modelDateTimeZone = new DateTimeZone( $this->_timezone ); |
|
172 | - $passedDateTimeZone = new DateTimeZone( $timezone ); |
|
171 | + $modelDateTimeZone = new DateTimeZone($this->_timezone); |
|
172 | + $passedDateTimeZone = new DateTimeZone($timezone); |
|
173 | 173 | // setup start date |
174 | - $start_date = ! empty( $start_date ) ? date_create_from_format( $format, $start_date, $passedDateTimeZone ) : $now; |
|
175 | - $start_date->setTimeZone( $modelDateTimeZone ); |
|
176 | - $start_date = $start_date->format( 'Y-m-d' ) . ' 00:00:00'; |
|
177 | - $start_date = strtotime( $start_date ); |
|
174 | + $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now; |
|
175 | + $start_date->setTimeZone($modelDateTimeZone); |
|
176 | + $start_date = $start_date->format('Y-m-d').' 00:00:00'; |
|
177 | + $start_date = strtotime($start_date); |
|
178 | 178 | // setup end date |
179 | - $end_date = ! empty( $end_date ) ? date_create_from_format( $format, $end_date, $passedDateTimeZone ) : $now; |
|
180 | - $end_date->setTimeZone( $modelDateTimeZone ); |
|
181 | - $end_date = $end_date->format('Y-m-d') . ' 23:59:59'; |
|
182 | - $end_date = strtotime( $end_date ); |
|
179 | + $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now; |
|
180 | + $end_date->setTimeZone($modelDateTimeZone); |
|
181 | + $end_date = $end_date->format('Y-m-d').' 23:59:59'; |
|
182 | + $end_date = strtotime($end_date); |
|
183 | 183 | |
184 | 184 | // make sure our start date is the lowest value and vice versa |
185 | - $start = min( $start_date, $end_date ); |
|
186 | - $end = max( $start_date, $end_date ); |
|
185 | + $start = min($start_date, $end_date); |
|
186 | + $end = max($start_date, $end_date); |
|
187 | 187 | |
188 | 188 | //yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model. |
189 | - $start_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $start ) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone() ); |
|
190 | - $end_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $end) . ' 23:59:59' , 'Y-m-d H:i:s', $this->get_timezone() ); |
|
189 | + $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone()); |
|
190 | + $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone()); |
|
191 | 191 | |
192 | - return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date)))); |
|
192 | + return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date)))); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,35 +199,35 @@ discard block |
||
199 | 199 | * returns a string for the approved status |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - function approved_status(){ |
|
202 | + function approved_status() { |
|
203 | 203 | return self::status_id_approved; |
204 | 204 | } |
205 | 205 | /** |
206 | 206 | * returns a string for the pending status |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - function pending_status(){ |
|
209 | + function pending_status() { |
|
210 | 210 | return self::status_id_pending; |
211 | 211 | } |
212 | 212 | /** |
213 | 213 | * returns a string for the cancelled status |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - function cancelled_status(){ |
|
216 | + function cancelled_status() { |
|
217 | 217 | return self::status_id_cancelled; |
218 | 218 | } |
219 | 219 | /** |
220 | 220 | * returns a string for the failed status |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - function failed_status(){ |
|
223 | + function failed_status() { |
|
224 | 224 | return self::status_id_failed; |
225 | 225 | } |
226 | 226 | /** |
227 | 227 | * returns a string for the declined status |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - function declined_status(){ |
|
230 | + function declined_status() { |
|
231 | 231 | return self::status_id_declined; |
232 | 232 | } |
233 | 233 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | * @access protected |
38 | 38 | * @return EEM_Payment_Method |
39 | 39 | */ |
40 | - protected function __construct( $timezone = NULL ) { |
|
41 | - $this->singlular_item = __( 'Payment Method', 'event_espresso' ); |
|
42 | - $this->plural_item = __( 'Payment Methods', 'event_espresso' ); |
|
43 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) ); |
|
40 | + protected function __construct($timezone = NULL) { |
|
41 | + $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
42 | + $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
43 | + $this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID')); |
|
44 | 44 | $this->_fields = array( |
45 | 45 | 'Payment_Method' => array( |
46 | - 'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ), |
|
47 | - 'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ), |
|
48 | - 'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ), |
|
49 | - 'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ), |
|
50 | - 'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ), |
|
51 | - 'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ), |
|
52 | - 'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ), |
|
53 | - 'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ), |
|
54 | - 'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ), |
|
55 | - 'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ), |
|
56 | - 'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ), |
|
57 | - 'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API' |
|
46 | + 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
47 | + 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'), |
|
48 | + 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE), |
|
49 | + 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''), |
|
50 | + 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE), |
|
51 | + 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE), |
|
52 | + 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE), |
|
53 | + 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0), |
|
54 | + 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE), |
|
55 | + 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE), |
|
56 | + 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''), |
|
57 | + 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API' |
|
58 | 58 | ) ); |
59 | 59 | $this->_model_relations = array( |
60 | 60 | // 'Event'=>new EE_HABTM_Relation('Event_Payment_Method'), |
61 | 61 | 'Payment' => new EE_Has_Many_Relation(), |
62 | - 'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ), |
|
62 | + 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
63 | 63 | 'Transaction' => new EE_Has_Many_Relation(), |
64 | 64 | 'WP_User' => new EE_Belongs_To_Relation(), |
65 | 65 | ); |
66 | - parent::__construct( $timezone ); |
|
66 | + parent::__construct($timezone); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param string $slug |
74 | 74 | * @return EE_Payment_Method |
75 | 75 | */ |
76 | - public function get_one_by_slug( $slug ) { |
|
77 | - return $this->get_one( array( array( 'PMD_slug' => $slug ) ) ); |
|
76 | + public function get_one_by_slug($slug) { |
|
77 | + return $this->get_one(array(array('PMD_slug' => $slug))); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return apply_filters( |
89 | 89 | 'FHEE__EEM_Payment_Method__scopes', |
90 | 90 | array( |
91 | - self::scope_cart => __( "Front-end Registration Page", 'event_espresso' ), |
|
92 | - self::scope_admin => __( "Admin Registration Page (no online processing)", 'event_espresso' ) |
|
91 | + self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
92 | + self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
93 | 93 | ) |
94 | 94 | ); |
95 | 95 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function is_valid_scope( $scope ) { |
|
104 | + public function is_valid_scope($scope) { |
|
105 | 105 | $scopes = $this->scopes(); |
106 | - if ( isset( $scopes[ $scope ] ) ) { |
|
106 | + if (isset($scopes[$scope])) { |
|
107 | 107 | return TRUE; |
108 | 108 | } else { |
109 | 109 | return FALSE; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @throws EE_Error |
120 | 120 | * @return EE_Payment_Method[] |
121 | 121 | */ |
122 | - public function get_all_active( $scope = NULL, $query_params = array() ) { |
|
123 | - if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) { |
|
124 | - $query_params = array( 'order_by' => array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ) ); |
|
122 | + public function get_all_active($scope = NULL, $query_params = array()) { |
|
123 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
124 | + $query_params = array('order_by' => array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC')); |
|
125 | 125 | } |
126 | - return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
126 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param array $query_params |
133 | 133 | * @return int |
134 | 134 | */ |
135 | - public function count_active( $scope = NULL, $query_params = array() ){ |
|
136 | - return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
135 | + public function count_active($scope = NULL, $query_params = array()) { |
|
136 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | * @return array like param of EEM_Base::get_all() |
145 | 145 | * @throws EE_Error |
146 | 146 | */ |
147 | - protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){ |
|
148 | - if ( $scope ) { |
|
149 | - if ( $this->is_valid_scope( $scope ) ) { |
|
150 | - return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params ); |
|
147 | + protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
148 | + if ($scope) { |
|
149 | + if ($this->is_valid_scope($scope)) { |
|
150 | + return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params); |
|
151 | 151 | } else { |
152 | - throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) ); |
|
152 | + throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | $acceptable_scopes = array(); |
156 | 156 | $count = 0; |
157 | - foreach ( $this->scopes() as $scope_name => $desc ) { |
|
157 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
158 | 158 | $count++; |
159 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
159 | + $acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%'); |
|
160 | 160 | } |
161 | - return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params ); |
|
161 | + return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return array like param of EEM_Base::get_all() |
171 | 171 | * @throws EE_Error |
172 | 172 | */ |
173 | - public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) { |
|
174 | - return $this->_get_query_params_for_all_active( $scope, $query_params ); |
|
173 | + public function get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
174 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return EE_Payment_Method |
183 | 183 | */ |
184 | - public function get_one_active( $scope = NULL, $query_params = array() ) { |
|
185 | - return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
184 | + public function get_one_active($scope = NULL, $query_params = array()) { |
|
185 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $type |
193 | 193 | * @return EE_Payment_Method |
194 | 194 | */ |
195 | - public function get_one_of_type( $type ) { |
|
196 | - return $this->get_one( array( array( 'PMD_type' => $type ) ) ); |
|
195 | + public function get_one_of_type($type) { |
|
196 | + return $this->get_one(array(array('PMD_type' => $type))); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * @return EE_Payment_Method |
207 | 207 | * @throws EE_Error |
208 | 208 | */ |
209 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) { |
|
209 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
210 | 210 | //first: check if it's a slug |
211 | - if( is_string( $base_class_obj_or_id ) ) { |
|
212 | - $obj = $this->get_one_by_slug( $base_class_obj_or_id ); |
|
213 | - if( $obj ) { |
|
211 | + if (is_string($base_class_obj_or_id)) { |
|
212 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
213 | + if ($obj) { |
|
214 | 214 | return $obj; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | //ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
218 | 218 | try { |
219 | - return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db ); |
|
219 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
220 | 220 | } |
221 | - catch ( EE_Error $e ) { |
|
221 | + catch (EE_Error $e) { |
|
222 | 222 | //handle it outside the catch |
223 | 223 | } |
224 | - throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) ); |
|
224 | + throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | * @param mixed $base_obj_or_id_or_slug |
233 | 233 | * @return int |
234 | 234 | */ |
235 | - function ensure_is_ID( $base_obj_or_id_or_slug ) { |
|
236 | - if ( is_string( $base_obj_or_id_or_slug ) ) { |
|
235 | + function ensure_is_ID($base_obj_or_id_or_slug) { |
|
236 | + if (is_string($base_obj_or_id_or_slug)) { |
|
237 | 237 | //assume it's a slug |
238 | - $base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug ); |
|
238 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
239 | 239 | } |
240 | - return parent::ensure_is_ID( $base_obj_or_id_or_slug ); |
|
240 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -246,36 +246,36 @@ discard block |
||
246 | 246 | * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
247 | 247 | * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
248 | 248 | */ |
249 | - function verify_button_urls( $payment_methods = NULL ) { |
|
250 | - $payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | - foreach ( $payment_methods as $payment_method ) { |
|
249 | + function verify_button_urls($payment_methods = NULL) { |
|
250 | + $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | + foreach ($payment_methods as $payment_method) { |
|
252 | 252 | try { |
253 | 253 | $current_button_url = $payment_method->button_url(); |
254 | - $buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | - 'current_ssl' => str_replace( "http://", "https://", $current_button_url ), |
|
256 | - 'current' => str_replace( "https://", "http://", $current_button_url ), |
|
257 | - 'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ), |
|
258 | - 'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ), |
|
259 | - ) ); |
|
260 | - foreach( $buttons_urls_to_try as $button_url_to_try ) { |
|
261 | - if( |
|
254 | + $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | + 'current_ssl' => str_replace("http://", "https://", $current_button_url), |
|
256 | + 'current' => str_replace("https://", "http://", $current_button_url), |
|
257 | + 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), |
|
258 | + 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()), |
|
259 | + )); |
|
260 | + foreach ($buttons_urls_to_try as $button_url_to_try) { |
|
261 | + if ( |
|
262 | 262 | (//this is the current url and it exists, regardless of SSL issues |
263 | 263 | $button_url_to_try == $current_button_url && |
264 | 264 | EEH_URL::remote_file_exists( |
265 | 265 | $button_url_to_try, |
266 | 266 | array( |
267 | 267 | 'sslverify' => false, |
268 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
268 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
269 | 269 | ) ) |
270 | 270 | ) |
271 | 271 | || |
272 | 272 | (//this is NOT the current url and it exists with a working SSL cert |
273 | 273 | $button_url_to_try != $current_button_url && |
274 | - EEH_URL::remote_file_exists( $button_url_to_try ) |
|
274 | + EEH_URL::remote_file_exists($button_url_to_try) |
|
275 | 275 | ) ) { |
276 | - if( $current_button_url != $button_url_to_try ){ |
|
277 | - $payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) ); |
|
278 | - EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) ); |
|
276 | + if ($current_button_url != $button_url_to_try) { |
|
277 | + $payment_method->save(array('PMD_button_url' => $button_url_to_try)); |
|
278 | + EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try)); |
|
279 | 279 | } |
280 | 280 | //this image exists. So if wasn't set before, now it is; |
281 | 281 | //or if it was already set, we have nothing to do |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
286 | - catch ( EE_Error $e ) { |
|
287 | - $payment_method->set_active( FALSE ); |
|
286 | + catch (EE_Error $e) { |
|
287 | + $payment_method->set_active(FALSE); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | * @param array $rows |
299 | 299 | * @return EE_Payment_Method[] |
300 | 300 | */ |
301 | - protected function _create_objects( $rows = array() ) { |
|
302 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
303 | - $payment_methods = parent::_create_objects( $rows ); |
|
301 | + protected function _create_objects($rows = array()) { |
|
302 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
303 | + $payment_methods = parent::_create_objects($rows); |
|
304 | 304 | /* @var $payment_methods EE_Payment_Method[] */ |
305 | 305 | $usable_payment_methods = array(); |
306 | - foreach ( $payment_methods as $key => $payment_method ) { |
|
307 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) { |
|
308 | - $usable_payment_methods[ $key ] = $payment_method; |
|
306 | + foreach ($payment_methods as $key => $payment_method) { |
|
307 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
308 | + $usable_payment_methods[$key] = $payment_method; |
|
309 | 309 | //some payment methods enqueue their scripts in EE_PMT_*::__construct |
310 | 310 | //which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
311 | 311 | //its scripts). but for backwards-compat we should continue to do that |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | $payment_method->deactivate(); |
315 | 315 | $payment_method->save(); |
316 | 316 | EE_Error::add_persistent_admin_notice( |
317 | - 'auto-deactivated-' . $payment_method->type(), |
|
317 | + 'auto-deactivated-'.$payment_method->type(), |
|
318 | 318 | sprintf( |
319 | - __( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ), |
|
319 | + __('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'), |
|
320 | 320 | $payment_method->admin_name(), |
321 | 321 | '<br />', |
322 | - '<a href="' . admin_url('plugins.php') . '">', |
|
322 | + '<a href="'.admin_url('plugins.php').'">', |
|
323 | 323 | '</a>' |
324 | 324 | ), |
325 | 325 | true |
@@ -339,16 +339,16 @@ discard block |
||
339 | 339 | * @param string $scope @see EEM_Payment_Method::get_all_for_events |
340 | 340 | * @return EE_Payment_Method[] |
341 | 341 | */ |
342 | - public function get_all_for_transaction( $transaction, $scope ) { |
|
342 | + public function get_all_for_transaction($transaction, $scope) { |
|
343 | 343 | //@todo take relations between events and payment methods into account, once that relation exists |
344 | - if ( $transaction instanceof EE_Transaction ) { |
|
344 | + if ($transaction instanceof EE_Transaction) { |
|
345 | 345 | //@todo take the relation between transaction and currencies into account |
346 | 346 | } |
347 | - $currencies_for_events = array( EE_Config::instance()->currency->code ); |
|
347 | + $currencies_for_events = array(EE_Config::instance()->currency->code); |
|
348 | 348 | //give addons a chance to override what payment methods are chosen based on the transaction |
349 | 349 | return apply_filters( |
350 | 350 | 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
351 | - $this->get_all_active( $scope, array( array( 'Currency.CUR_code' => array( 'IN', $currencies_for_events ) ) ) ), |
|
351 | + $this->get_all_active($scope, array(array('Currency.CUR_code' => array('IN', $currencies_for_events)))), |
|
352 | 352 | $transaction, |
353 | 353 | $scope |
354 | 354 | ); |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
365 | 365 | * @return EE_Payment|null |
366 | 366 | */ |
367 | - public function get_last_used_for_registration( $registration_or_reg_id ) { |
|
368 | - $registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id ); |
|
367 | + public function get_last_used_for_registration($registration_or_reg_id) { |
|
368 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
369 | 369 | |
370 | 370 | $query_params = array( |
371 | 371 | 0 => array( |
372 | 372 | 'Payment.Registration.REG_ID' => $registration_id, |
373 | 373 | ), |
374 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
374 | + 'order_by' => array('Payment.PAY_ID' => 'DESC') |
|
375 | 375 | ); |
376 | - return $this->get_one( $query_params ); |
|
376 | + return $this->get_one($query_params); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Transaction Model |
@@ -67,35 +67,35 @@ discard block |
||
67 | 67 | * @return EEM_Transaction |
68 | 68 | * @throws \EE_Error |
69 | 69 | */ |
70 | - protected function __construct( $timezone ) { |
|
71 | - $this->singular_item = __('Transaction','event_espresso'); |
|
72 | - $this->plural_item = __('Transactions','event_espresso'); |
|
70 | + protected function __construct($timezone) { |
|
71 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
72 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
73 | 73 | |
74 | 74 | $this->_tables = array( |
75 | - 'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID') |
|
75 | + 'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
76 | 76 | ); |
77 | 77 | $this->_fields = array( |
78 | 78 | 'Transaction'=>array( |
79 | - 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')), |
|
80 | - 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ), |
|
81 | - 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0), |
|
82 | - 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0), |
|
83 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
84 | - 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''), |
|
85 | - 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''), |
|
79 | + 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
80 | + 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), |
|
81 | + 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), |
|
82 | + 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
83 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
84 | + 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), |
|
85 | + 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
86 | 86 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), |
87 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ), |
|
87 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()), |
|
88 | 88 | ) |
89 | 89 | ); |
90 | 90 | $this->_model_relations = array( |
91 | 91 | 'Registration'=>new EE_Has_Many_Relation(), |
92 | 92 | 'Payment'=>new EE_Has_Many_Relation(), |
93 | 93 | 'Status'=>new EE_Belongs_To_Relation(), |
94 | - 'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items |
|
94 | + 'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items |
|
95 | 95 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
96 | 96 | ); |
97 | 97 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
98 | - parent::__construct( $timezone ); |
|
98 | + parent::__construct($timezone); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -106,22 +106,22 @@ discard block |
||
106 | 106 | * @param string $period |
107 | 107 | * @return \stdClass[] |
108 | 108 | */ |
109 | - public function get_revenue_per_day_report( $period = '-1 month' ) { |
|
110 | - $sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', strtotime( $period ) ), 'Y-m-d H:i:s', 'UTC' ); |
|
109 | + public function get_revenue_per_day_report($period = '-1 month') { |
|
110 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
111 | 111 | |
112 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'TXN_timestamp' ); |
|
112 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
113 | 113 | return $this->_get_all_wpdb_results( |
114 | 114 | array( |
115 | 115 | array( |
116 | - 'TXN_timestamp' => array( '>=', $sql_date ) |
|
116 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
117 | 117 | ), |
118 | 118 | 'group_by' => 'txnDate', |
119 | - 'order_by' => array( 'TXN_timestamp' => 'ASC' ) |
|
119 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
120 | 120 | ), |
121 | 121 | OBJECT, |
122 | 122 | array( |
123 | - 'txnDate' => array( 'DATE(' . $query_interval . ')', '%s' ), |
|
124 | - 'revenue' => array( 'SUM(Transaction.TXN_paid)', '%d' ) |
|
123 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
124 | + 'revenue' => array('SUM(Transaction.TXN_paid)', '%d') |
|
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | } |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | * @throws \EE_Error |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get_revenue_per_event_report( $period = '-1 month' ) { |
|
139 | + public function get_revenue_per_event_report($period = '-1 month') { |
|
140 | 140 | global $wpdb; |
141 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
142 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
141 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
142 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
143 | 143 | $event_table = $wpdb->posts; |
144 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
145 | - $sql_date = date( 'Y-m-d H:i:s', strtotime( $period ) ); |
|
144 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
145 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
146 | 146 | $approved_payment_status = EEM_Payment::status_id_approved; |
147 | 147 | $extra_event_on_join = ''; |
148 | 148 | //exclude events not authored by user if permissions in effect |
149 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
150 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
149 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
150 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $wpdb->get_results( |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * @param string $reg_url_link |
188 | 188 | * @return EE_Transaction |
189 | 189 | */ |
190 | - public function get_transaction_from_reg_url_link( $reg_url_link = '' ){ |
|
191 | - return $this->get_one( array( |
|
190 | + public function get_transaction_from_reg_url_link($reg_url_link = '') { |
|
191 | + return $this->get_one(array( |
|
192 | 192 | array( |
193 | - 'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) |
|
193 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '') |
|
194 | 194 | ) |
195 | 195 | )); |
196 | 196 | } |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | * @return boolean |
208 | 208 | * @throws \EE_Error |
209 | 209 | */ |
210 | - public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){ |
|
210 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) { |
|
211 | 211 | EE_Error::doing_it_wrong( |
212 | - __CLASS__ . '::' . __FUNCTION__, |
|
213 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
212 | + __CLASS__.'::'.__FUNCTION__, |
|
213 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
214 | 214 | '4.6.0' |
215 | 215 | ); |
216 | 216 | /** @type EE_Transaction_Processor $transaction_processor */ |
217 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
217 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
218 | 218 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
219 | - $this->ensure_is_obj( $transaction_obj_or_id ) |
|
219 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
220 | 220 | ); |
221 | 221 | } |
222 | 222 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | array( |
249 | 249 | 0 => array( |
250 | 250 | 'STS_ID' => EEM_Transaction::failed_status_code, |
251 | - 'TXN_timestamp' => array( '<', time() - $time_to_leave_alone ) |
|
251 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
252 | 252 | ) |
253 | 253 | ), |
254 | 254 | $time_to_leave_alone |
@@ -261,29 +261,29 @@ discard block |
||
261 | 261 | */ |
262 | 262 | $txn_ids = apply_filters( |
263 | 263 | 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
264 | - EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ), |
|
264 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
265 | 265 | $time_to_leave_alone |
266 | 266 | ); |
267 | 267 | //now that we have the ids to delete |
268 | - if ( ! empty( $txn_ids ) && is_array( $txn_ids ) ) { |
|
268 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
269 | 269 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
270 | - EEM_Transaction::unset_locked_transactions( $txn_ids ); |
|
270 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
271 | 271 | // let's get deletin'... |
272 | 272 | // Why no wpdb->prepare? Because the data is trusted. |
273 | 273 | // We got the ids from the original query to get them FROM |
274 | 274 | // the db (which is sanitized) so no need to prepare them again. |
275 | - $query = ' |
|
275 | + $query = ' |
|
276 | 276 | DELETE |
277 | - FROM ' . $this->table() . ' |
|
277 | + FROM ' . $this->table().' |
|
278 | 278 | WHERE |
279 | - TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')'; |
|
280 | - $deleted = $wpdb->query( $query ); |
|
279 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
280 | + $deleted = $wpdb->query($query); |
|
281 | 281 | } |
282 | - if ( $deleted ) { |
|
282 | + if ($deleted) { |
|
283 | 283 | /** |
284 | 284 | * Allows code to do something after the transactions have been deleted. |
285 | 285 | */ |
286 | - do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids ); |
|
286 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
287 | 287 | } |
288 | 288 | return $deleted; |
289 | 289 | } |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | * @param array $transaction_IDs |
295 | 295 | * @return bool |
296 | 296 | */ |
297 | - public static function unset_locked_transactions( array $transaction_IDs ) { |
|
298 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
297 | + public static function unset_locked_transactions(array $transaction_IDs) { |
|
298 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
299 | 299 | $update = false; |
300 | - foreach ( $transaction_IDs as $TXN_ID ) { |
|
301 | - if ( isset( $locked_transactions[ $TXN_ID ] ) ) { |
|
302 | - unset( $locked_transactions[ $TXN_ID ] ); |
|
300 | + foreach ($transaction_IDs as $TXN_ID) { |
|
301 | + if (isset($locked_transactions[$TXN_ID])) { |
|
302 | + unset($locked_transactions[$TXN_ID]); |
|
303 | 303 | $update = true; |
304 | 304 | } |
305 | 305 | } |
306 | - if ( $update ) { |
|
307 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
306 | + if ($update) { |
|
307 | + update_option('ee_locked_transactions', $locked_transactions); |
|
308 | 308 | } |
309 | 309 | return $update; |
310 | 310 | } |
@@ -8,16 +8,16 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param null $validation_error_message |
15 | 15 | */ |
16 | - public function __construct( $validation_error_message = NULL ) { |
|
17 | - if( ! $validation_error_message ){ |
|
16 | + public function __construct($validation_error_message = NULL) { |
|
17 | + if ( ! $validation_error_message) { |
|
18 | 18 | $validation_error_message = __("Please enter a valid URL", "event_espresso"); |
19 | 19 | } |
20 | - parent::__construct( $validation_error_message ); |
|
20 | + parent::__construct($validation_error_message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | * @throws \EE_Validation_Error |
31 | 31 | */ |
32 | 32 | function validate($normalized_value) { |
33 | - if( $normalized_value ){ |
|
34 | - if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){ |
|
35 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url'); |
|
36 | - }else{ |
|
37 | - if( ! EEH_URL::remote_file_exists( |
|
33 | + if ($normalized_value) { |
|
34 | + if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) { |
|
35 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); |
|
36 | + } else { |
|
37 | + if ( ! EEH_URL::remote_file_exists( |
|
38 | 38 | $normalized_value, |
39 | 39 | array( |
40 | 40 | 'sslverify' => false, |
41 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
42 | - ))){ |
|
41 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
42 | + ))) { |
|
43 | 43 | throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso"))); |
44 | 44 | } |
45 | 45 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - function get_jquery_validation_rule_array(){ |
|
55 | - return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) ); |
|
54 | + function get_jquery_validation_rule_array() { |
|
55 | + return array('validUrl'=>true, 'messages' => array('validUrl' => $this->get_validation_error_message())); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -class EE_Template_Layout extends EE_Div_Per_Section_Layout{ |
|
24 | +class EE_Template_Layout extends EE_Div_Per_Section_Layout { |
|
25 | 25 | |
26 | 26 | protected $_layout_template_file = NULL; |
27 | 27 | protected $_layout_begin_template_file = NULL; |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @type array $_template_args |
43 | 43 | * } |
44 | 44 | */ |
45 | - public function __construct( $template_options = array() ) { |
|
45 | + public function __construct($template_options = array()) { |
|
46 | 46 | // loop thru incoming options |
47 | - foreach( $template_options as $key => $value ) { |
|
47 | + foreach ($template_options as $key => $value) { |
|
48 | 48 | // add underscore to $key to match property names |
49 | - $_key = '_' . $key; |
|
50 | - if ( property_exists( $this, $_key )) { |
|
49 | + $_key = '_'.$key; |
|
50 | + if (property_exists($this, $_key)) { |
|
51 | 51 | $this->{$_key} = $value; |
52 | 52 | } |
53 | 53 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | */ |
67 | 67 | public function layout_form() { |
68 | - if ( $this->_layout_template_file ) { |
|
69 | - return EEH_Template::locate_template( $this->_layout_template_file, $this->template_args(), TRUE, TRUE ); |
|
68 | + if ($this->_layout_template_file) { |
|
69 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), TRUE, TRUE); |
|
70 | 70 | } else { |
71 | 71 | return parent::layout_form(); |
72 | 72 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function layout_form_begin() { |
82 | - if($this->_layout_begin_template_file){ |
|
83 | - return EEH_Template::locate_template( $this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE ); |
|
84 | - }else{ |
|
82 | + if ($this->_layout_begin_template_file) { |
|
83 | + return EEH_Template::locate_template($this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE); |
|
84 | + } else { |
|
85 | 85 | return parent::layout_form_begin(); |
86 | 86 | } |
87 | 87 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param EE_Form_Input_Base $input |
95 | 95 | * @return string |
96 | 96 | */ |
97 | - public function layout_input( $input ) { |
|
98 | - if($this->_input_template_file){ |
|
99 | - return EEH_Template::locate_template( $this->_input_template_file, array( 'input' => $input ), TRUE, TRUE ); |
|
97 | + public function layout_input($input) { |
|
98 | + if ($this->_input_template_file) { |
|
99 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), TRUE, TRUE); |
|
100 | 100 | } |
101 | 101 | return parent::layout_input($input); |
102 | 102 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * @param EE_Form_Section_Proper $form_section |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function layout_subsection( $form_section ) { |
|
113 | - if($this->_subsection_template_file){ |
|
114 | - return EEH_Template::locate_template( $this->_subsection_template_file, $this->template_args(), TRUE, TRUE ); |
|
112 | + public function layout_subsection($form_section) { |
|
113 | + if ($this->_subsection_template_file) { |
|
114 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), TRUE, TRUE); |
|
115 | 115 | } |
116 | - return parent::layout_subsection( $form_section ); |
|
116 | + return parent::layout_subsection($form_section); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @return string |
124 | 124 | */ |
125 | 125 | public function layout_form_end() { |
126 | - if($this->_layout_end_template_file){ |
|
127 | - return EEH_Template::locate_template( $this->_layout_end_template_file, $this->template_args(), TRUE, TRUE); |
|
128 | - }else{ |
|
126 | + if ($this->_layout_end_template_file) { |
|
127 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), TRUE, TRUE); |
|
128 | + } else { |
|
129 | 129 | return parent::layout_form_end(); |
130 | 130 | } |
131 | 131 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * @param array $template_args |
137 | 137 | */ |
138 | - public function set_template_args( $template_args = array() ) { |
|
138 | + public function set_template_args($template_args = array()) { |
|
139 | 139 | $this->_template_args = $template_args; |
140 | 140 | } |
141 | 141 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | /** |
145 | 145 | * @param array $template_args |
146 | 146 | */ |
147 | - public function add_template_args( $template_args = array() ) { |
|
148 | - $this->_template_args = array_merge_recursive( $this->_template_args, $template_args ); |
|
147 | + public function add_template_args($template_args = array()) { |
|
148 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | * @return array |
155 | 155 | */ |
156 | 156 | public function template_args() { |
157 | - foreach ( $this->form_section()->subsections() as $subsection_name => $subsection ) { |
|
158 | - $subsection_name = self::prep_form_subsection_key_name( $subsection_name ); |
|
159 | - if ( strpos( $subsection_name, '[' ) !== FALSE ) { |
|
160 | - $sub_name = explode( '[', $subsection_name ); |
|
161 | - $this->_template_args[ $sub_name[0] ][ rtrim( $sub_name[1], ']' ) ] = $this->layout_subsection( $subsection ); |
|
157 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
158 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
159 | + if (strpos($subsection_name, '[') !== FALSE) { |
|
160 | + $sub_name = explode('[', $subsection_name); |
|
161 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
162 | 162 | } else { |
163 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection( $subsection ); |
|
163 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | // d( $this->_template_args ); |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * @param string $subsection_name |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - public static function prep_form_subsection_key_name( $subsection_name = '' ) { |
|
180 | - $subsection_name = str_replace( array( '-', ' ' ), array( '', '_' ), $subsection_name ); |
|
181 | - return is_numeric( substr( $subsection_name, 0, 1 )) ? 'form_' . $subsection_name : $subsection_name; |
|
179 | + public static function prep_form_subsection_key_name($subsection_name = '') { |
|
180 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
181 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $subsection_name |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public static function get_subform_name( $subsection_name = '' ) { |
|
194 | - return EE_Template_Layout::prep_form_subsection_key_name( $subsection_name ); |
|
193 | + public static function get_subform_name($subsection_name = '') { |
|
194 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 |