@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated); |
307 | 307 | $num_records_actually_migrated += $records_migrated_during_stage; |
308 | 308 | $records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage; |
309 | - }catch(Exception $e){ |
|
309 | + } catch(Exception $e){ |
|
310 | 310 | //yes if we catch an exception here, we consider that migration stage borked. |
311 | 311 | $stage->set_status(EE_Data_Migration_Manager::status_fatal_error); |
312 | 312 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | //this migration script apparently has NO stages... which is super weird, but whatever |
333 | 333 | $this->set_completed(); |
334 | 334 | $this->_maybe_do_schema_changes(false); |
335 | - }else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){ |
|
335 | + } else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){ |
|
336 | 336 | //apparently we're done, because we couldn't migrate the number we intended to |
337 | 337 | $this->set_completed(); |
338 | 338 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
339 | 339 | //do schema changes for after the migration now |
340 | 340 | //first double-check we haven't already done this |
341 | 341 | $this->_maybe_do_schema_changes(false); |
342 | - }else{ |
|
342 | + } else{ |
|
343 | 343 | //update feedback message, keeping in mind that we show them with the most recent at the top |
344 | 344 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
345 | 345 | } |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | ob_start(); |
379 | 379 | if($before){ |
380 | 380 | $this->schema_changes_before_migration(); |
381 | - }else{ |
|
381 | + } else{ |
|
382 | 382 | $this->schema_changes_after_migration(); |
383 | 383 | } |
384 | 384 | $output = ob_get_contents(); |
385 | 385 | ob_end_clean(); |
386 | - }catch(Exception $e){ |
|
386 | + } catch(Exception $e){ |
|
387 | 387 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
388 | 388 | throw $e; |
389 | 389 | } |
@@ -511,13 +511,13 @@ discard block |
||
511 | 511 | if( $table_is_new ) { |
512 | 512 | if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating() ){ |
513 | 513 | return true; |
514 | - }else{ |
|
514 | + } else{ |
|
515 | 515 | return false; |
516 | 516 | } |
517 | - }else{ |
|
517 | + } else{ |
|
518 | 518 | if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){ |
519 | 519 | return true; |
520 | - }else{ |
|
520 | + } else{ |
|
521 | 521 | return false; |
522 | 522 | } |
523 | 523 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | EE_Registry::instance()->load_helper('Activation'); |
535 | 535 | try{ |
536 | 536 | EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables); |
537 | - }catch( EE_Error $e ) { |
|
537 | + } catch( EE_Error $e ) { |
|
538 | 538 | $message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString(); |
539 | 539 | $this->add_error( $message ); |
540 | 540 | $this->_feedback_message .= $message; |
@@ -551,11 +551,11 @@ discard block |
||
551 | 551 | private function _get_req_type_for_plugin_corresponding_to_this_dms(){ |
552 | 552 | if($this->slug() == 'Core'){ |
553 | 553 | return EE_System::instance()->detect_req_type(); |
554 | - }else{//it must be for an addon |
|
554 | + } else{//it must be for an addon |
|
555 | 555 | $addon_name = $this->slug(); |
556 | 556 | if( EE_Registry::instance()->get_addon_by_name($addon_name)){ |
557 | 557 | return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type(); |
558 | - }else{ |
|
558 | + } else{ |
|
559 | 559 | throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ; |
560 | 560 | } |
561 | 561 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences! |
118 | 118 | */ |
119 | 119 | public function __construct() { |
120 | - $this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages); |
|
121 | - foreach($this->_migration_stages as $migration_stage){ |
|
122 | - if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) { |
|
120 | + $this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages); |
|
121 | + foreach ($this->_migration_stages as $migration_stage) { |
|
122 | + if ($migration_stage instanceof EE_Data_Migration_Script_Stage) { |
|
123 | 123 | $migration_stage->_construct_finalize($this); |
124 | 124 | } |
125 | 125 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * Place to add hooks and filters for tweaking the migrations page, in order |
133 | 133 | * to customize it |
134 | 134 | */ |
135 | - public function migration_page_hooks(){ |
|
135 | + public function migration_page_hooks() { |
|
136 | 136 | //by default none are added because we normally like the default look of the migration page |
137 | 137 | } |
138 | 138 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param int|string $new_pk eg posts.ID |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function set_mapping($old_table,$old_pk,$new_table,$new_pk){ |
|
150 | + public function set_mapping($old_table, $old_pk, $new_table, $new_pk) { |
|
151 | 151 | //make sure it has the needed keys |
152 | - if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){ |
|
152 | + if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) { |
|
153 | 153 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
154 | 154 | } |
155 | 155 | $this->_mappings[$old_table][$new_table][$old_pk] = $new_pk; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts |
166 | 166 | * @return mixed the primary key on the new table |
167 | 167 | */ |
168 | - public function get_mapping_new_pk($old_table,$old_pk,$new_table){ |
|
169 | - if( ! isset($this->_mappings[$old_table]) || |
|
170 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
168 | + public function get_mapping_new_pk($old_table, $old_pk, $new_table) { |
|
169 | + if ( ! isset($this->_mappings[$old_table]) || |
|
170 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
171 | 171 | //try fetching the option |
172 | 172 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
173 | 173 | } |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | * @param mixed $new_pk |
185 | 185 | * @return mixed |
186 | 186 | */ |
187 | - public function get_mapping_old_pk($old_table,$new_table,$new_pk){ |
|
188 | - if( ! isset($this->_mappings[$old_table]) || |
|
189 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
187 | + public function get_mapping_old_pk($old_table, $new_table, $new_pk) { |
|
188 | + if ( ! isset($this->_mappings[$old_table]) || |
|
189 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
190 | 190 | //try fetching the option |
191 | 191 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
192 | 192 | } |
193 | - if(isset($this->_mappings[$old_table][$new_table])){ |
|
193 | + if (isset($this->_mappings[$old_table][$new_table])) { |
|
194 | 194 | $new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]); |
195 | - if(isset($new_pk_to_old_pk[$new_pk])){ |
|
195 | + if (isset($new_pk_to_old_pk[$new_pk])) { |
|
196 | 196 | return $new_pk_to_old_pk[$new_pk]; |
197 | 197 | } |
198 | 198 | } |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $new_table_name |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - protected function _get_mapping_option($old_table_name,$new_table_name){ |
|
211 | - $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array()); |
|
210 | + protected function _get_mapping_option($old_table_name, $new_table_name) { |
|
211 | + $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array()); |
|
212 | 212 | return $option; |
213 | 213 | } |
214 | 214 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * @param array $mapping_array |
222 | 222 | * @return boolean success of updating option |
223 | 223 | */ |
224 | - protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){ |
|
224 | + protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) { |
|
225 | 225 | // echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>"; |
226 | - $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array); |
|
226 | + $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array); |
|
227 | 227 | return $success; |
228 | 228 | } |
229 | 229 | |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $new_table_name |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - protected function _get_mapping_option_name($old_table_name,$new_table_name){ |
|
238 | + protected function _get_mapping_option_name($old_table_name, $new_table_name) { |
|
239 | 239 | global $wpdb; |
240 | - $old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name); |
|
241 | - $new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name); |
|
240 | + $old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name); |
|
241 | + $new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name); |
|
242 | 242 | $migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
243 | - return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 ); |
|
243 | + return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete. |
258 | 258 | * @return int |
259 | 259 | */ |
260 | - protected function _count_records_to_migrate(){ |
|
260 | + protected function _count_records_to_migrate() { |
|
261 | 261 | $count = 0; |
262 | - foreach($this->stages() as $stage){ |
|
263 | - $count+= $stage->count_records_to_migrate(); |
|
262 | + foreach ($this->stages() as $stage) { |
|
263 | + $count += $stage->count_records_to_migrate(); |
|
264 | 264 | } |
265 | 265 | return $count; |
266 | 266 | } |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | * by just setting a transient and updating it after each migration_step |
273 | 273 | * @return int |
274 | 274 | */ |
275 | - public function count_records_migrated(){ |
|
275 | + public function count_records_migrated() { |
|
276 | 276 | $count = 0; |
277 | - foreach($this->stages() as $stage){ |
|
278 | - $count+= $stage->count_records_migrated(); |
|
277 | + foreach ($this->stages() as $stage) { |
|
278 | + $count += $stage->count_records_migrated(); |
|
279 | 279 | } |
280 | 280 | $this->_records_migrated = $count; |
281 | 281 | return $count; |
@@ -289,24 +289,24 @@ discard block |
||
289 | 289 | * @throws EE_Error |
290 | 290 | * @throws Exception |
291 | 291 | */ |
292 | - public function migration_step($num_records_to_migrate_limit){ |
|
292 | + public function migration_step($num_records_to_migrate_limit) { |
|
293 | 293 | //reset the feedback message |
294 | 294 | $this->_feedback_message = ''; |
295 | 295 | //if we haven't yet done the 1st schema changes, do them now. buffer any output |
296 | 296 | $this->_maybe_do_schema_changes(true); |
297 | 297 | |
298 | - $num_records_actually_migrated =0; |
|
298 | + $num_records_actually_migrated = 0; |
|
299 | 299 | $records_migrated_per_stage = array(); |
300 | 300 | //setup the 'stage' variable, which should hold the last run stage of the migration (or none at all if nothing runs) |
301 | 301 | $stage = null; |
302 | 302 | //get the next stage that isn't complete |
303 | - foreach($this->stages() as $stage){ |
|
304 | - if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){ |
|
305 | - try{ |
|
303 | + foreach ($this->stages() as $stage) { |
|
304 | + if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) { |
|
305 | + try { |
|
306 | 306 | $records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated); |
307 | 307 | $num_records_actually_migrated += $records_migrated_during_stage; |
308 | 308 | $records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage; |
309 | - }catch(Exception $e){ |
|
309 | + } catch (Exception $e) { |
|
310 | 310 | //yes if we catch an exception here, we consider that migration stage borked. |
311 | 311 | $stage->set_status(EE_Data_Migration_Manager::status_fatal_error); |
312 | 312 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | throw $e; |
315 | 315 | } |
316 | 316 | //check that the migration stage didn't mark itself as having a fatal error |
317 | - if($stage->is_broken()){ |
|
317 | + if ($stage->is_broken()) { |
|
318 | 318 | $this->set_broken(); |
319 | 319 | throw new EE_Error($stage->get_last_error()); |
320 | 320 | } |
@@ -322,24 +322,24 @@ discard block |
||
322 | 322 | //once we've migrated all the number we intended to (possibly from different stages), stop migrating |
323 | 323 | //or if we had a fatal error |
324 | 324 | //or if the current script stopped early- its not done, but it's done all it thinks we should do on this step |
325 | - if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){ |
|
325 | + if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) { |
|
326 | 326 | break; |
327 | 327 | } |
328 | 328 | } |
329 | 329 | //check if we're all done this data migration... |
330 | 330 | //which is indicated by being done early AND the last stage claims to be done |
331 | - if($stage == NULL){ |
|
331 | + if ($stage == NULL) { |
|
332 | 332 | //this migration script apparently has NO stages... which is super weird, but whatever |
333 | 333 | $this->set_completed(); |
334 | 334 | $this->_maybe_do_schema_changes(false); |
335 | - }else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){ |
|
335 | + } else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) { |
|
336 | 336 | //apparently we're done, because we couldn't migrate the number we intended to |
337 | 337 | $this->set_completed(); |
338 | 338 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
339 | 339 | //do schema changes for after the migration now |
340 | 340 | //first double-check we haven't already done this |
341 | 341 | $this->_maybe_do_schema_changes(false); |
342 | - }else{ |
|
342 | + } else { |
|
343 | 343 | //update feedback message, keeping in mind that we show them with the most recent at the top |
344 | 344 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
345 | 345 | } |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage |
354 | 354 | * @return void |
355 | 355 | */ |
356 | - private function _update_feedback_message($records_migrated_per_stage){ |
|
356 | + private function _update_feedback_message($records_migrated_per_stage) { |
|
357 | 357 | $feedback_message_array = array(); |
358 | - foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){ |
|
359 | - $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ; |
|
358 | + foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) { |
|
359 | + $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name); |
|
360 | 360 | } |
361 | - $this->_feedback_message .= implode("<br>",$feedback_message_array); |
|
361 | + $this->_feedback_message .= implode("<br>", $feedback_message_array); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | |
@@ -370,27 +370,27 @@ discard block |
||
370 | 370 | * @throws Exception |
371 | 371 | * @return void |
372 | 372 | */ |
373 | - private function _maybe_do_schema_changes($before = true){ |
|
373 | + private function _maybe_do_schema_changes($before = true) { |
|
374 | 374 | //so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran |
375 | - $property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran'; |
|
376 | - if ( ! $this->{$property_name} ){ |
|
377 | - try{ |
|
375 | + $property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran'; |
|
376 | + if ( ! $this->{$property_name} ) { |
|
377 | + try { |
|
378 | 378 | ob_start(); |
379 | - if($before){ |
|
379 | + if ($before) { |
|
380 | 380 | $this->schema_changes_before_migration(); |
381 | - }else{ |
|
381 | + } else { |
|
382 | 382 | $this->schema_changes_after_migration(); |
383 | 383 | } |
384 | 384 | $output = ob_get_contents(); |
385 | 385 | ob_end_clean(); |
386 | - }catch(Exception $e){ |
|
386 | + } catch (Exception $e) { |
|
387 | 387 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
388 | 388 | throw $e; |
389 | 389 | } |
390 | 390 | //record that we've done these schema changes |
391 | 391 | $this->{$property_name} = true; |
392 | 392 | //if there were any warnings etc, record them as non-fatal errors |
393 | - if( $output ){ |
|
393 | + if ($output) { |
|
394 | 394 | //there were some warnings |
395 | 395 | $this->_errors[] = $output; |
396 | 396 | } |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | * @param string $table_definition_sql |
418 | 418 | * @param string $engine_string |
419 | 419 | */ |
420 | - protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){ |
|
420 | + protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') { |
|
421 | 421 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name ); |
422 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( true ) ); |
|
422 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true)); |
|
423 | 423 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name ); |
424 | 424 | } |
425 | 425 | |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | * @param string $table_definition_sql |
434 | 434 | * @param string $engine_string |
435 | 435 | */ |
436 | - protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
436 | + protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
437 | 437 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name ); |
438 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
438 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
439 | 439 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name ); |
440 | 440 | } |
441 | 441 | |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | * @param string $table_name |
447 | 447 | * @return boolean |
448 | 448 | */ |
449 | - protected function _old_table_exists( $table_name ) { |
|
450 | - return EEH_Activation::table_exists( $table_name ); |
|
449 | + protected function _old_table_exists($table_name) { |
|
450 | + return EEH_Activation::table_exists($table_name); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @param string $table_name |
458 | 458 | * @return boolean |
459 | 459 | */ |
460 | - protected function _delete_table_if_empty( $table_name ) { |
|
461 | - return EEH_Activation::delete_db_table_if_empty( $table_name ); |
|
460 | + protected function _delete_table_if_empty($table_name) { |
|
461 | + return EEH_Activation::delete_db_table_if_empty($table_name); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @param string $table_definition_sql |
478 | 478 | * @param string $engine_string |
479 | 479 | */ |
480 | - protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
480 | + protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
481 | 481 | // EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name ); |
482 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
482 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
483 | 483 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
484 | 484 | } |
485 | 485 | |
@@ -494,13 +494,13 @@ discard block |
||
494 | 494 | * @param string $table_definition_sql |
495 | 495 | * @param string $engine_string |
496 | 496 | */ |
497 | - protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
498 | - if( $this->_currently_migrating() ) { |
|
497 | + protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
498 | + if ($this->_currently_migrating()) { |
|
499 | 499 | //if we're doing a migration, and this table apparently already exists, then we don't need do anything right? |
500 | 500 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
501 | 501 | return; |
502 | 502 | } |
503 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
503 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | protected function _currently_migrating() { |
511 | 511 | //we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM) |
512 | 512 | return $this->_migrating && |
513 | - $this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) && |
|
513 | + $this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) && |
|
514 | 514 | EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance; |
515 | 515 | } |
516 | 516 | |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | * @param boolean $table_is_new |
522 | 522 | * @return boolean |
523 | 523 | */ |
524 | - protected function _pre_existing_table_should_be_dropped( $table_is_new ) { |
|
525 | - if( $table_is_new ) { |
|
526 | - if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating() ){ |
|
524 | + protected function _pre_existing_table_should_be_dropped($table_is_new) { |
|
525 | + if ($table_is_new) { |
|
526 | + if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) { |
|
527 | 527 | return true; |
528 | - }else{ |
|
528 | + } else { |
|
529 | 529 | return false; |
530 | 530 | } |
531 | - }else{ |
|
532 | - if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){ |
|
531 | + } else { |
|
532 | + if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) { |
|
533 | 533 | return true; |
534 | - }else{ |
|
534 | + } else { |
|
535 | 535 | return false; |
536 | 536 | } |
537 | 537 | } |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $engine_string |
545 | 545 | * @param boolean $drop_pre_existing_tables |
546 | 546 | */ |
547 | - private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){ |
|
548 | - try{ |
|
549 | - EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
550 | - }catch( EE_Error $e ) { |
|
551 | - $message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString(); |
|
552 | - $this->add_error( $message ); |
|
547 | + private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) { |
|
548 | + try { |
|
549 | + EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
550 | + } catch (EE_Error $e) { |
|
551 | + $message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString(); |
|
552 | + $this->add_error($message); |
|
553 | 553 | $this->_feedback_message .= $message; |
554 | 554 | } |
555 | 555 | } |
@@ -561,15 +561,15 @@ discard block |
||
561 | 561 | * @return int one of EE_System::_req_type_* constants |
562 | 562 | * @throws EE_Error |
563 | 563 | */ |
564 | - private function _get_req_type_for_plugin_corresponding_to_this_dms(){ |
|
565 | - if($this->slug() == 'Core'){ |
|
564 | + private function _get_req_type_for_plugin_corresponding_to_this_dms() { |
|
565 | + if ($this->slug() == 'Core') { |
|
566 | 566 | return EE_System::instance()->detect_req_type(); |
567 | - }else{//it must be for an addon |
|
567 | + } else {//it must be for an addon |
|
568 | 568 | $addon_name = $this->slug(); |
569 | - if( EE_Registry::instance()->get_addon_by_name($addon_name)){ |
|
569 | + if (EE_Registry::instance()->get_addon_by_name($addon_name)) { |
|
570 | 570 | return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type(); |
571 | - }else{ |
|
572 | - throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ; |
|
571 | + } else { |
|
572 | + throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name())))); |
|
573 | 573 | } |
574 | 574 | } |
575 | 575 | } |
@@ -580,13 +580,13 @@ discard block |
||
580 | 580 | * returns an array of strings describing errors by all the script's stages |
581 | 581 | * @return array |
582 | 582 | */ |
583 | - public function get_errors(){ |
|
583 | + public function get_errors() { |
|
584 | 584 | $all_errors = $this->_errors; |
585 | - if( ! is_array($all_errors)){ |
|
585 | + if ( ! is_array($all_errors)) { |
|
586 | 586 | $all_errors = array(); |
587 | 587 | } |
588 | - foreach($this->stages() as $stage){ |
|
589 | - $all_errors = array_merge($stage->get_errors(),$all_errors); |
|
588 | + foreach ($this->stages() as $stage) { |
|
589 | + $all_errors = array_merge($stage->get_errors(), $all_errors); |
|
590 | 590 | } |
591 | 591 | return $all_errors; |
592 | 592 | } |
@@ -597,8 +597,8 @@ discard block |
||
597 | 597 | * Indicates whether or not this migration script should continue |
598 | 598 | * @return boolean |
599 | 599 | */ |
600 | - public function can_continue(){ |
|
601 | - return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
600 | + public function can_continue() { |
|
601 | + return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * get ordered by the indexes |
611 | 611 | * @return EE_Data_Migration_Script_Stage[] |
612 | 612 | */ |
613 | - protected function stages(){ |
|
614 | - $stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages ); |
|
613 | + protected function stages() { |
|
614 | + $stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages); |
|
615 | 615 | ksort($stages); |
616 | 616 | return $stages; |
617 | 617 | } |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | * can be displayed to the user |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public function get_feedback_message(){ |
|
626 | + public function get_feedback_message() { |
|
627 | 627 | return $this->_feedback_message; |
628 | 628 | } |
629 | 629 | |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | * possible that this class is defined when it goes to sleep, but NOT available when it |
636 | 636 | * awakes (eg, this class is part of an addon that is deactivated at some point). |
637 | 637 | */ |
638 | - public function properties_as_array(){ |
|
638 | + public function properties_as_array() { |
|
639 | 639 | $properties = parent::properties_as_array(); |
640 | 640 | $properties['_migration_stages'] = array(); |
641 | - foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){ |
|
641 | + foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) { |
|
642 | 642 | $properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array(); |
643 | 643 | } |
644 | 644 | unset($properties['_mappings']); |
645 | 645 | |
646 | - foreach($this->_mappings as $old_table_name => $mapping_to_new_table){ |
|
647 | - foreach($mapping_to_new_table as $new_table_name => $mapping){ |
|
646 | + foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) { |
|
647 | + foreach ($mapping_to_new_table as $new_table_name => $mapping) { |
|
648 | 648 | $this->_set_mapping_option($old_table_name, $new_table_name, $mapping); |
649 | 649 | } |
650 | 650 | } |
@@ -659,19 +659,19 @@ discard block |
||
659 | 659 | * @param array $array_of_properties like what's produced from properties_as_array() method |
660 | 660 | * @return void |
661 | 661 | */ |
662 | - public function instantiate_from_array_of_properties($array_of_properties){ |
|
662 | + public function instantiate_from_array_of_properties($array_of_properties) { |
|
663 | 663 | $stages_properties_arrays = $array_of_properties['_migration_stages']; |
664 | 664 | unset($array_of_properties['_migration_stages']); |
665 | 665 | unset($array_of_properties['class']); |
666 | - foreach($array_of_properties as $property_name => $property_value){ |
|
666 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
667 | 667 | $this->{$property_name} = $property_value; |
668 | 668 | } |
669 | 669 | //_migration_stages are already instantiated, but have only default data |
670 | - foreach($this->_migration_stages as $stage){ |
|
671 | - $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays); |
|
670 | + foreach ($this->_migration_stages as $stage) { |
|
671 | + $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays); |
|
672 | 672 | //SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by |
673 | 673 | //an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet) |
674 | - if($stage_data){ |
|
674 | + if ($stage_data) { |
|
675 | 675 | $stage->instantiate_from_array_of_properties($stage_data); |
676 | 676 | } |
677 | 677 | } |
@@ -687,9 +687,9 @@ discard block |
||
687 | 687 | * @param array $migration_stage_data_arrays |
688 | 688 | * @return null |
689 | 689 | */ |
690 | - private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){ |
|
691 | - foreach($migration_stage_data_arrays as $migration_stage_data_array){ |
|
692 | - if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){ |
|
690 | + private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) { |
|
691 | + foreach ($migration_stage_data_arrays as $migration_stage_data_array) { |
|
692 | + if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) { |
|
693 | 693 | return $migration_stage_data_array; |
694 | 694 | } |
695 | 695 | } |
@@ -705,8 +705,8 @@ discard block |
||
705 | 705 | * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin |
706 | 706 | * that will be updated to. Eg array('Core','4.1.0') |
707 | 707 | */ |
708 | - public final function migrates_to_version(){ |
|
709 | - return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) ); |
|
708 | + public final function migrates_to_version() { |
|
709 | + return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | * Or 'Core' for core (non-addon). |
719 | 719 | * @return string |
720 | 720 | */ |
721 | - public function slug(){ |
|
721 | + public function slug() { |
|
722 | 722 | $migrates_to_version_info = $this->migrates_to_version(); |
723 | 723 | //the slug is the first part of the array |
724 | - return $migrates_to_version_info[ 'slug' ]; |
|
724 | + return $migrates_to_version_info['slug']; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * the database up so it can run), then you can set "A" to priority 3 or something. |
736 | 736 | * @return int |
737 | 737 | */ |
738 | - public function priority(){ |
|
738 | + public function priority() { |
|
739 | 739 | return $this->_priority; |
740 | 740 | } |
741 | 741 | |
@@ -748,18 +748,18 @@ discard block |
||
748 | 748 | * @param boolean $migrating |
749 | 749 | * @return void |
750 | 750 | */ |
751 | - public function set_migrating( $migrating = TRUE ){ |
|
751 | + public function set_migrating($migrating = TRUE) { |
|
752 | 752 | $this->_migrating = $migrating; |
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Marks that we think this migration class can continue to migrate |
757 | 757 | */ |
758 | - public function reattempt(){ |
|
758 | + public function reattempt() { |
|
759 | 759 | parent::reattempt(); |
760 | 760 | //also, we want to reattempt any stages that were marked as borked |
761 | - foreach( $this->stages() as $stage ) { |
|
762 | - if( $stage->is_broken() ) { |
|
761 | + foreach ($this->stages() as $stage) { |
|
762 | + if ($stage->is_broken()) { |
|
763 | 763 | $stage->reattempt(); |
764 | 764 | } |
765 | 765 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * _migration_step() (ie, it its a count of rows in the old attendees table in _count_records_to_migrate(), it should also be OLD attendee rows migrated |
35 | 35 | * on each call to _migration_step(). |
36 | 36 | */ |
37 | -abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base{ |
|
37 | +abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base { |
|
38 | 38 | /** |
39 | 39 | * The migration script this is a stage of |
40 | 40 | * @var EE_Data_Migration_Script_Base |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
48 | 48 | * @param EE_Data_Migration_Script_Base $migration_script |
49 | 49 | */ |
50 | - public function _construct_finalize($migration_script){ |
|
50 | + public function _construct_finalize($migration_script) { |
|
51 | 51 | $this->_migration_script = $migration_script; |
52 | 52 | } |
53 | 53 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | * @param int $num_items_to_migrate |
59 | 59 | * @return int |
60 | 60 | */ |
61 | - public function migration_step($num_items_to_migrate=50){ |
|
61 | + public function migration_step($num_items_to_migrate = 50) { |
|
62 | 62 | //before we run the migration step, we want ot take note of warnings that get outputted |
63 | 63 | ob_start(); |
64 | 64 | $items_migrated = $this->_migration_step($num_items_to_migrate); |
65 | 65 | $output = ob_get_contents(); |
66 | 66 | ob_end_clean(); |
67 | - if( $output ){ |
|
67 | + if ($output) { |
|
68 | 68 | $this->add_error($output); |
69 | 69 | } |
70 | 70 | $this->_records_migrated += $items_migrated; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int $num_items_to_migrate |
83 | 83 | * @return int number of items ACTUALLY migrated |
84 | 84 | */ |
85 | - abstract protected function _migration_step($num_items_to_migrate=50); |
|
85 | + abstract protected function _migration_step($num_items_to_migrate = 50); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Counts the records that have been migrated so far |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * returns an array of strings describing errors |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function get_errors(){ |
|
99 | + public function get_errors() { |
|
100 | 100 | return $this->_errors; |
101 | 101 | } |
102 | 102 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * to have been made from the properties_as_array() function. |
107 | 107 | * @param array $array_of_properties like what's produced from properties_as_array() method |
108 | 108 | */ |
109 | - public function instantiate_from_array_of_properties($array_of_properties){ |
|
109 | + public function instantiate_from_array_of_properties($array_of_properties) { |
|
110 | 110 | unset($array_of_properties['class']); |
111 | - foreach($array_of_properties as $property_name => $property_value){ |
|
111 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
112 | 112 | $this->$property_name = $property_value; |
113 | 113 | } |
114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * Gets the script this is a stage of |
118 | 118 | * @return EE_Data_Migration_Script_Base |
119 | 119 | */ |
120 | - protected function get_migration_script(){ |
|
120 | + protected function get_migration_script() { |
|
121 | 121 | return $this->_migration_script; |
122 | 122 | } |
123 | 123 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | protected $_old_table; |
22 | 22 | |
23 | 23 | /** |
24 | - * Set in the constructor to add this sql to both the counting query in |
|
25 | - * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and |
|
26 | - * EE_Data_Migration_Script_Stage_Table::_get_rows(). |
|
27 | - * Eg "where column_name like '%some_value%'" |
|
28 | - * @var string |
|
29 | - */ |
|
24 | + * Set in the constructor to add this sql to both the counting query in |
|
25 | + * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and |
|
26 | + * EE_Data_Migration_Script_Stage_Table::_get_rows(). |
|
27 | + * Eg "where column_name like '%some_value%'" |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | protected $_extra_where_sql; |
31 | 31 | |
32 | 32 |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @param int $num_items |
42 | 42 | * @return int number of items ACTUALLY migrated |
43 | 43 | */ |
44 | - function _migration_step($num_items=50){ |
|
45 | - $rows = $this->_get_rows( $num_items ); |
|
44 | + function _migration_step($num_items = 50) { |
|
45 | + $rows = $this->_get_rows($num_items); |
|
46 | 46 | $items_actually_migrated = 0; |
47 | - foreach($rows as $old_row){ |
|
47 | + foreach ($rows as $old_row) { |
|
48 | 48 | $this->_migrate_old_row($old_row); |
49 | 49 | $items_actually_migrated++; |
50 | 50 | } |
51 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
51 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
52 | 52 | $this->set_completed(); |
53 | 53 | } |
54 | 54 | return $items_actually_migrated; |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * @param int $limit |
61 | 61 | * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
62 | 62 | */ |
63 | - protected function _get_rows( $limit ){ |
|
63 | + protected function _get_rows($limit) { |
|
64 | 64 | global $wpdb; |
65 | 65 | $start_at_record = $this->count_records_migrated(); |
66 | - $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare("LIMIT %d, %d",$start_at_record,$limit); |
|
67 | - return $wpdb->get_results($query,ARRAY_A); |
|
66 | + $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit); |
|
67 | + return $wpdb->get_results($query, ARRAY_A); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function _count_records_to_migrate() { |
77 | 77 | global $wpdb; |
78 | - $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}"; |
|
79 | - $count = $wpdb->get_var( $query ); |
|
78 | + $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}"; |
|
79 | + $count = $wpdb->get_var($query); |
|
80 | 80 | return $count; |
81 | 81 | } |
82 | 82 |
@@ -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 | * Event Espresso |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | * @param array $props_n_values |
32 | 32 | * @return EE_Answer |
33 | 33 | */ |
34 | - public static function new_instance( $props_n_values = array() ) { |
|
35 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
36 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
34 | + public static function new_instance($props_n_values = array()) { |
|
35 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
36 | + return $has_object ? $has_object : new self($props_n_values); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @param array $props_n_values |
44 | 44 | * @return EE_Answer |
45 | 45 | */ |
46 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
47 | - return new self( $props_n_values, TRUE ); |
|
46 | + public static function new_instance_from_db($props_n_values = array()) { |
|
47 | + return new self($props_n_values, TRUE); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @access public |
56 | 56 | * @param int $QST_ID |
57 | 57 | */ |
58 | - public function set_question( $QST_ID = 0 ) { |
|
59 | - $this->set( 'QST_ID', $QST_ID ); |
|
58 | + public function set_question($QST_ID = 0) { |
|
59 | + $this->set('QST_ID', $QST_ID); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @access public |
68 | 68 | * @param int $REG_ID |
69 | 69 | */ |
70 | - public function set_registration( $REG_ID = 0 ) { |
|
71 | - $this->set( 'REG_ID', $REG_ID ); |
|
70 | + public function set_registration($REG_ID = 0) { |
|
71 | + $this->set('REG_ID', $REG_ID); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | * @access public |
80 | 80 | * @param mixed $ANS_value |
81 | 81 | */ |
82 | - public function set_value( $ANS_value = '' ) { |
|
83 | - $this->set( 'ANS_value', $ANS_value ); |
|
82 | + public function set_value($ANS_value = '') { |
|
83 | + $this->set('ANS_value', $ANS_value); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return int |
93 | 93 | */ |
94 | 94 | public function registration_ID() { |
95 | - return $this->get( 'REG_ID' ); |
|
95 | + return $this->get('REG_ID'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return int |
105 | 105 | */ |
106 | 106 | public function question_ID() { |
107 | - return $this->get( 'QST_ID' ); |
|
107 | + return $this->get('QST_ID'); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return string |
117 | 117 | */ |
118 | 118 | public function value() { |
119 | - return $this->get( 'ANS_value' ); |
|
119 | + return $this->get('ANS_value'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param null $schema |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function pretty_value( $schema = NULL ) { |
|
130 | - return $this->get_pretty( 'ANS_value', $schema ); |
|
129 | + public function pretty_value($schema = NULL) { |
|
130 | + return $this->get_pretty('ANS_value', $schema); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * Echoes out a pretty value (even for multi-choice options) |
137 | 137 | * @param string $schema |
138 | 138 | */ |
139 | - public function e_value( $schema = NULL ) { |
|
140 | - $this->e( 'ANS_value', $schema ); |
|
139 | + public function e_value($schema = NULL) { |
|
140 | + $this->e('ANS_value', $schema); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return EE_Question |
148 | 148 | */ |
149 | 149 | public function question() { |
150 | - return $this->get_first_related( 'Question' ); |
|
150 | + return $this->get_first_related('Question'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return EE_Registration |
158 | 158 | */ |
159 | 159 | public function registration() { |
160 | - return $this->get_first_related( 'Registration' ); |
|
160 | + return $this->get_first_related('Registration'); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * Set Answer value |
78 | 78 | * |
79 | 79 | * @access public |
80 | - * @param mixed $ANS_value |
|
80 | + * @param string $ANS_value |
|
81 | 81 | */ |
82 | 82 | public function set_value( $ANS_value = '' ) { |
83 | 83 | $this->set( 'ANS_value', $ANS_value ); |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -152,7 +153,7 @@ discard block |
||
152 | 153 | $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
153 | 154 | if( ! $is_model_name ){ |
154 | 155 | return null; |
155 | - }else{ |
|
156 | + } else{ |
|
156 | 157 | return $this->get_first_related($model_name_of_related_obj); |
157 | 158 | } |
158 | 159 | } |
@@ -169,13 +170,13 @@ discard block |
||
169 | 170 | if($object instanceof EE_Base_Class){ |
170 | 171 | $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
171 | 172 | $this->set_OBJ_ID($object->ID()); |
172 | - }else{ |
|
173 | + } else{ |
|
173 | 174 | $this->set_OBJ_type(NULL); |
174 | 175 | $this->set_OBJ_ID(NULL); |
175 | 176 | } |
176 | 177 | if($save){ |
177 | 178 | return $this->save(); |
178 | - }else{ |
|
179 | + } else{ |
|
179 | 180 | return NULL; |
180 | 181 | } |
181 | 182 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_Change_Log extends EE_Base_Class{ |
|
28 | +class EE_Change_Log extends EE_Base_Class { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * date_format and the second value is the time format |
37 | 37 | * @return EE_Attendee |
38 | 38 | */ |
39 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
40 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
41 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
39 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
40 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
41 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * the website will be used. |
50 | 50 | * @return EE_Attendee |
51 | 51 | */ |
52 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
53 | - return new self( $props_n_values, TRUE, $timezone ); |
|
52 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
53 | + return new self($props_n_values, TRUE, $timezone); |
|
54 | 54 | } |
55 | 55 | /** |
56 | 56 | * Gets message |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | * Gets the model object attached to this log |
148 | 148 | * @return EE_Base_Class |
149 | 149 | */ |
150 | - function object(){ |
|
150 | + function object() { |
|
151 | 151 | $model_name_of_related_obj = $this->OBJ_type(); |
152 | 152 | $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
153 | - if( ! $is_model_name ){ |
|
153 | + if ( ! $is_model_name) { |
|
154 | 154 | return null; |
155 | - }else{ |
|
155 | + } else { |
|
156 | 156 | return $this->get_first_related($model_name_of_related_obj); |
157 | 157 | } |
158 | 158 | } |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | * @param boolean $save |
166 | 166 | * @return boolean if $save=true, NULL is $save=false |
167 | 167 | */ |
168 | - function set_object($object, $save = TRUE ) { |
|
169 | - if($object instanceof EE_Base_Class){ |
|
168 | + function set_object($object, $save = TRUE) { |
|
169 | + if ($object instanceof EE_Base_Class) { |
|
170 | 170 | $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
171 | 171 | $this->set_OBJ_ID($object->ID()); |
172 | - }else{ |
|
172 | + } else { |
|
173 | 173 | $this->set_OBJ_type(NULL); |
174 | 174 | $this->set_OBJ_ID(NULL); |
175 | 175 | } |
176 | - if($save){ |
|
176 | + if ($save) { |
|
177 | 177 | return $this->save(); |
178 | - }else{ |
|
178 | + } else { |
|
179 | 179 | return NULL; |
180 | 180 | } |
181 | 181 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | * @param array $props_n_values incoming values from the database |
48 | 48 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
49 | 49 | * the website will be used. |
50 | - * @return EE_Attendee |
|
50 | + * @return EE_Change_Log |
|
51 | 51 | */ |
52 | 52 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
53 | 53 | return new self( $props_n_values, TRUE, $timezone ); |
@@ -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 | * Event Espresso |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param array $props_n_values |
31 | 31 | * @return EE_Country|mixed |
32 | 32 | */ |
33 | - public static function new_instance( $props_n_values = array() ) { |
|
34 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
35 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
33 | + public static function new_instance($props_n_values = array()) { |
|
34 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
35 | + return $has_object ? $has_object : new self($props_n_values); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @param array $props_n_values |
42 | 42 | * @return EE_Country |
43 | 43 | */ |
44 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
45 | - return new self( $props_n_values, TRUE ); |
|
44 | + public static function new_instance_from_db($props_n_values = array()) { |
|
45 | + return new self($props_n_values, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public function name() { |
57 | - return $this->get( 'CNT_name' ); |
|
57 | + return $this->get('CNT_name'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return string |
65 | 65 | */ |
66 | 66 | public function currency_code() { |
67 | - return $this->get( 'CNT_cur_code' ); |
|
67 | + return $this->get('CNT_cur_code'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return string |
75 | 75 | */ |
76 | 76 | public function currency_sign() { |
77 | - $CNT_cur_sign = $this->get( 'CNT_cur_sign' ); |
|
77 | + $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
78 | 78 | return $CNT_cur_sign ? $CNT_cur_sign : '¤'; |
79 | 79 | } |
80 | 80 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return string |
86 | 86 | */ |
87 | 87 | public function currency_name_single() { |
88 | - return $this->get( 'CNT_cur_single' ); |
|
88 | + return $this->get('CNT_cur_single'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | */ |
97 | 97 | public function currency_name_plural() { |
98 | - return $this->get( 'CNT_cur_plural' ); |
|
98 | + return $this->get('CNT_cur_plural'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return boolean |
106 | 106 | */ |
107 | 107 | public function currency_sign_before() { |
108 | - return $this->get( 'CNT_cur_sign_b4' ); |
|
108 | + return $this->get('CNT_cur_sign_b4'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return integer |
116 | 116 | */ |
117 | 117 | public function currency_decimal_places() { |
118 | - return $this->get( 'CNT_cur_dec_plc' ); |
|
118 | + return $this->get('CNT_cur_dec_plc'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return string |
126 | 126 | */ |
127 | 127 | public function currency_decimal_mark() { |
128 | - return $this->get( 'CNT_cur_dec_mrk' ); |
|
128 | + return $this->get('CNT_cur_dec_mrk'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return string |
136 | 136 | */ |
137 | 137 | public function currency_thousands_separator() { |
138 | - return $this->get( 'CNT_cur_thsnds' ); |
|
138 | + return $this->get('CNT_cur_thsnds'); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | /* End of file EE_Country.class.php */ |
@@ -708,12 +708,10 @@ |
||
708 | 708 | if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
709 | 709 | $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
710 | 710 | //next condition is if its the same month but different day |
711 | - } |
|
712 | - else { |
|
711 | + } else { |
|
713 | 712 | if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
714 | 713 | $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
715 | - } |
|
716 | - else { |
|
714 | + } else { |
|
717 | 715 | $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
718 | 716 | } |
719 | 717 | } |
@@ -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 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @access public |
120 | 120 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
121 | 121 | */ |
122 | - public function set_start_date( $date ) { |
|
123 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
122 | + public function set_start_date($date) { |
|
123 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @access public |
134 | 134 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
135 | 135 | */ |
136 | - public function set_start_time( $time ) { |
|
137 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
136 | + public function set_start_time($time) { |
|
137 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @access public |
148 | 148 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
149 | 149 | */ |
150 | - public function set_end_date( $date ) { |
|
151 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
150 | + public function set_end_date($date) { |
|
151 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @access public |
162 | 162 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
163 | 163 | */ |
164 | - public function set_end_time( $time ) { |
|
165 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
164 | + public function set_end_time($time) { |
|
165 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param int $reg_limit |
177 | 177 | */ |
178 | - public function set_reg_limit( $reg_limit ) { |
|
179 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
178 | + public function set_reg_limit($reg_limit) { |
|
179 | + $this->set('DTT_reg_limit', $reg_limit); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | * @param int $sold |
189 | 189 | */ |
190 | - public function set_sold( $sold ) { |
|
190 | + public function set_sold($sold) { |
|
191 | 191 | // sold can not go below zero |
192 | - $sold = max( 0, $sold ); |
|
193 | - $this->set( 'DTT_sold', $sold ); |
|
192 | + $sold = max(0, $sold); |
|
193 | + $this->set('DTT_sold', $sold); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * increments sold by amount passed by $qty |
200 | 200 | * @param int $qty |
201 | 201 | */ |
202 | - function increase_sold( $qty = 1 ) { |
|
202 | + function increase_sold($qty = 1) { |
|
203 | 203 | $sold = $this->sold() + $qty; |
204 | - $this->set_sold( $sold ); |
|
204 | + $this->set_sold($sold); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * decrements (subtracts) sold amount passed by $qty |
211 | 211 | * @param int $qty |
212 | 212 | */ |
213 | - function decrease_sold( $qty = 1 ) { |
|
213 | + function decrease_sold($qty = 1) { |
|
214 | 214 | $sold = $this->sold() - $qty; |
215 | - $this->set_sold( $sold ); |
|
215 | + $this->set_sold($sold); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return string |
223 | 223 | */ |
224 | 224 | public function name() { |
225 | - return $this->get( 'DTT_name' ); |
|
225 | + return $this->get('DTT_name'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return string |
233 | 233 | */ |
234 | 234 | public function description() { |
235 | - return $this->get( 'DTT_description' ); |
|
235 | + return $this->get('DTT_description'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return boolean TRUE if is primary, FALSE if not. |
243 | 243 | */ |
244 | 244 | public function is_primary() { |
245 | - return $this->get( 'DTT_is_primary' ); |
|
245 | + return $this->get('DTT_is_primary'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @return int The order of the datetime for this event. |
253 | 253 | */ |
254 | 254 | public function order() { |
255 | - return $this->get( 'DTT_order' ); |
|
255 | + return $this->get('DTT_order'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return int |
263 | 263 | */ |
264 | 264 | public function parent() { |
265 | - return $this->get( 'DTT_parent' ); |
|
265 | + return $this->get('DTT_parent'); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
279 | 279 | * @return string|bool|void string on success, FALSE on fail |
280 | 280 | */ |
281 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
281 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
282 | 282 | $field_name = "DTT_EVT_{$start_or_end}"; |
283 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
284 | - if ( ! $echo ) { |
|
283 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
284 | + if ( ! $echo) { |
|
285 | 285 | return $dtt; |
286 | 286 | } |
287 | 287 | return ''; |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
298 | 298 | * @return mixed string on success, FALSE on fail |
299 | 299 | */ |
300 | - public function start_date( $dt_frmt = NULL ) { |
|
301 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
300 | + public function start_date($dt_frmt = NULL) { |
|
301 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | * Echoes start_date() |
308 | 308 | * @param string $dt_frmt |
309 | 309 | */ |
310 | - public function e_start_date( $dt_frmt = NULL ) { |
|
311 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
310 | + public function e_start_date($dt_frmt = NULL) { |
|
311 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
322 | 322 | * @return mixed string on success, FALSE on fail |
323 | 323 | */ |
324 | - public function end_date( $dt_frmt = NULL ) { |
|
325 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
324 | + public function end_date($dt_frmt = NULL) { |
|
325 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | * Echoes the end date. See end_date() |
332 | 332 | * @param string $dt_frmt |
333 | 333 | */ |
334 | - public function e_end_date( $dt_frmt = NULL ) { |
|
335 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
334 | + public function e_end_date($dt_frmt = NULL) { |
|
335 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
346 | 346 | * @return mixed string on success, FALSE on fail |
347 | 347 | */ |
348 | - public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
349 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
350 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
351 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
352 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
348 | + public function date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
349 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
350 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
351 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
352 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @param null $dt_frmt |
359 | 359 | * @param string $conjunction |
360 | 360 | */ |
361 | - public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
362 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
361 | + public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
362 | + echo $this->date_range($dt_frmt, $conjunction); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
372 | 372 | * @return mixed string on success, FALSE on fail |
373 | 373 | */ |
374 | - public function start_time( $tm_format = NULL ) { |
|
375 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
374 | + public function start_time($tm_format = NULL) { |
|
375 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | /** |
381 | 381 | * @param null $tm_format |
382 | 382 | */ |
383 | - public function e_start_time( $tm_format = NULL ) { |
|
384 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
383 | + public function e_start_time($tm_format = NULL) { |
|
384 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
394 | 394 | * @return mixed string on success, FALSE on fail |
395 | 395 | */ |
396 | - public function end_time( $tm_format = NULL ) { |
|
397 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
396 | + public function end_time($tm_format = NULL) { |
|
397 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * @param null $tm_format |
404 | 404 | */ |
405 | - public function e_end_time( $tm_format = NULL ) { |
|
406 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
405 | + public function e_end_time($tm_format = NULL) { |
|
406 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
417 | 417 | * @return mixed string on success, FALSE on fail |
418 | 418 | */ |
419 | - public function time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
420 | - $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
419 | + public function time_range($tm_format = NULL, $conjunction = ' - ') { |
|
420 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
421 | 421 | |
422 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
423 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
424 | - return $start != $end ? $start . $conjunction . $end : $start; |
|
422 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
423 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
424 | + return $start != $end ? $start.$conjunction.$end : $start; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param null $tm_format |
431 | 431 | * @param string $conjunction |
432 | 432 | */ |
433 | - public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
434 | - echo $this->time_range( $tm_format, $conjunction ); |
|
433 | + public function e_time_range($tm_format = NULL, $conjunction = ' - ') { |
|
434 | + echo $this->time_range($tm_format, $conjunction); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
445 | 445 | * @return mixed string on success, FALSE on fail |
446 | 446 | */ |
447 | - public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
|
448 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
447 | + public function start_date_and_time($dt_format = NULL, $tm_format = NULL) { |
|
448 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param null $dt_frmt |
455 | 455 | * @param null $tm_format |
456 | 456 | */ |
457 | - public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) { |
|
458 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
457 | + public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) { |
|
458 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param bool $round_up |
470 | 470 | * @return float|int|mixed |
471 | 471 | */ |
472 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
473 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
474 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
472 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
473 | + $start = $this->get_raw('DTT_EVT_start'); |
|
474 | + $end = $this->get_raw('DTT_EVT_end'); |
|
475 | 475 | $length_in_units = $end - $start; |
476 | - switch ( $units ) { |
|
476 | + switch ($units) { |
|
477 | 477 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
478 | 478 | /** @noinspection PhpMissingBreakStatementInspection */ |
479 | 479 | case 'days': |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | $length_in_units /= 60; |
487 | 487 | case 'seconds': |
488 | 488 | default: |
489 | - $length_in_units = ceil( $length_in_units ); |
|
489 | + $length_in_units = ceil($length_in_units); |
|
490 | 490 | } |
491 | - if ( $round_up ) { |
|
492 | - $length_in_units = max( $length_in_units, 1 ); |
|
491 | + if ($round_up) { |
|
492 | + $length_in_units = max($length_in_units, 1); |
|
493 | 493 | } |
494 | 494 | return $length_in_units; |
495 | 495 | } |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
505 | 505 | * @return mixed string on success, FALSE on fail |
506 | 506 | */ |
507 | - public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
508 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
507 | + public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
508 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | * @param bool $dt_frmt |
515 | 515 | * @param bool $tm_format |
516 | 516 | */ |
517 | - public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
518 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
517 | + public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
518 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @return int |
528 | 528 | */ |
529 | 529 | public function start() { |
530 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
530 | + return $this->get_raw('DTT_EVT_start'); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @return int |
540 | 540 | */ |
541 | 541 | public function end() { |
542 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
542 | + return $this->get_raw('DTT_EVT_end'); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @return mixed int on success, FALSE on fail |
552 | 552 | */ |
553 | 553 | public function reg_limit() { |
554 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
554 | + return $this->get_raw('DTT_reg_limit'); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @return mixed int on success, FALSE on fail |
564 | 564 | */ |
565 | 565 | public function sold() { |
566 | - return $this->get_raw( 'DTT_sold' ); |
|
566 | + return $this->get_raw('DTT_sold'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -592,15 +592,15 @@ discard block |
||
592 | 592 | * the spaces remaining for this particular datetime, hence the flag. |
593 | 593 | * @return int |
594 | 594 | */ |
595 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
595 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
596 | 596 | // tickets remaining available for purchase |
597 | 597 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
598 | 598 | $dtt_remaining = $this->reg_limit() - $this->sold(); |
599 | - if ( ! $consider_tickets ) { |
|
599 | + if ( ! $consider_tickets) { |
|
600 | 600 | return $dtt_remaining; |
601 | 601 | } |
602 | 602 | $tickets_remaining = $this->tickets_remaining(); |
603 | - return min( $dtt_remaining, $tickets_remaining ); |
|
603 | + return min($dtt_remaining, $tickets_remaining); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | |
@@ -611,19 +611,19 @@ discard block |
||
611 | 611 | * @param array $query_params like EEM_Base::get_all's |
612 | 612 | * @return int |
613 | 613 | */ |
614 | - public function tickets_remaining( $query_params = array() ) { |
|
614 | + public function tickets_remaining($query_params = array()) { |
|
615 | 615 | $sum = 0; |
616 | - $tickets = $this->tickets( $query_params ); |
|
617 | - if ( ! empty( $tickets ) ) { |
|
618 | - foreach ( $tickets as $ticket ) { |
|
619 | - if ( $ticket instanceof EE_Ticket ) { |
|
616 | + $tickets = $this->tickets($query_params); |
|
617 | + if ( ! empty($tickets)) { |
|
618 | + foreach ($tickets as $ticket) { |
|
619 | + if ($ticket instanceof EE_Ticket) { |
|
620 | 620 | // get the actual amount of tickets that can be sold |
621 | - $qty = $ticket->qty( 'saleable' ); |
|
622 | - if ( $qty === EE_INF ) { |
|
621 | + $qty = $ticket->qty('saleable'); |
|
622 | + if ($qty === EE_INF) { |
|
623 | 623 | return EE_INF; |
624 | 624 | } |
625 | 625 | // no negative ticket quantities plz |
626 | - if ( $qty > 0 ) { |
|
626 | + if ($qty > 0) { |
|
627 | 627 | $sum += $qty; |
628 | 628 | } |
629 | 629 | } |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @param array $query_params like EEM_Base::get_all's |
641 | 641 | * @return int |
642 | 642 | */ |
643 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
644 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
643 | + public function sum_tickets_initially_available($query_params = array()) { |
|
644 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @return int |
654 | 654 | */ |
655 | 655 | public function total_tickets_available_at_this_datetime() { |
656 | - return $this->spaces_remaining( true ); |
|
656 | + return $this->spaces_remaining(true); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @return boolean |
665 | 665 | */ |
666 | 666 | public function is_upcoming() { |
667 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
667 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @return boolean |
675 | 675 | */ |
676 | 676 | public function is_active() { |
677 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
677 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @return boolean |
685 | 685 | */ |
686 | 686 | public function is_expired() { |
687 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
687 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -695,16 +695,16 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function get_active_status() { |
697 | 697 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
698 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
698 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
699 | 699 | return EE_Datetime::sold_out; |
700 | 700 | } |
701 | - if ( $this->is_expired() ) { |
|
701 | + if ($this->is_expired()) { |
|
702 | 702 | return EE_Datetime::expired; |
703 | 703 | } |
704 | - if ( $this->is_upcoming() ) { |
|
704 | + if ($this->is_upcoming()) { |
|
705 | 705 | return EE_Datetime::upcoming; |
706 | 706 | } |
707 | - if ( $this->is_active() ) { |
|
707 | + if ($this->is_active()) { |
|
708 | 708 | return EE_Datetime::active; |
709 | 709 | } |
710 | 710 | return NULL; |
@@ -718,24 +718,24 @@ discard block |
||
718 | 718 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
719 | 719 | * @return string |
720 | 720 | */ |
721 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
722 | - if ( $use_dtt_name ) { |
|
721 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
722 | + if ($use_dtt_name) { |
|
723 | 723 | $dtt_name = $this->name(); |
724 | - if ( !empty( $dtt_name ) ) { |
|
724 | + if ( ! empty($dtt_name)) { |
|
725 | 725 | return $dtt_name; |
726 | 726 | } |
727 | 727 | } |
728 | 728 | //first condition is to see if the months are different |
729 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
730 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
729 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
730 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
731 | 731 | //next condition is if its the same month but different day |
732 | 732 | } |
733 | 733 | else { |
734 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
735 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
734 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
735 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
736 | 736 | } |
737 | 737 | else { |
738 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
738 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
739 | 739 | } |
740 | 740 | } |
741 | 741 | return $display_date; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | *@param array $query_params see EEM_Base::get_all() |
750 | 750 | * @return EE_Ticket[] |
751 | 751 | */ |
752 | - public function tickets( $query_params = array() ) { |
|
753 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
752 | + public function tickets($query_params = array()) { |
|
753 | + return $this->get_many_related('Ticket', $query_params); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | |
@@ -760,21 +760,21 @@ discard block |
||
760 | 760 | * @param array $query_params like EEM_Base::get_all's |
761 | 761 | * @return EE_Ticket[] |
762 | 762 | */ |
763 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
763 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
764 | 764 | // first check if datetime is valid |
765 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
765 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
766 | 766 | return array(); |
767 | 767 | } |
768 | - if ( empty( $query_params ) ) { |
|
768 | + if (empty($query_params)) { |
|
769 | 769 | $query_params = array( |
770 | 770 | array( |
771 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
772 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
771 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
772 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
773 | 773 | 'TKT_deleted' => false |
774 | 774 | ) |
775 | 775 | ); |
776 | 776 | } |
777 | - return $this->tickets( $query_params ); |
|
777 | + return $this->tickets($query_params); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | * @return EE_Event |
785 | 785 | */ |
786 | 786 | public function event() { |
787 | - return $this->get_first_related( 'Event' ); |
|
787 | + return $this->get_first_related('Event'); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | |
@@ -796,13 +796,13 @@ discard block |
||
796 | 796 | */ |
797 | 797 | public function update_sold() { |
798 | 798 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
799 | - array( array( |
|
799 | + array(array( |
|
800 | 800 | 'STS_ID' => EEM_Registration::status_id_approved, |
801 | 801 | 'REG_deleted' => 0, |
802 | 802 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
803 | - ) ) |
|
803 | + )) |
|
804 | 804 | ); |
805 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
805 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
806 | 806 | $this->save(); |
807 | 807 | return $count_regs_for_this_datetime; |
808 | 808 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string $dt_frmt |
277 | 277 | * @param string $tm_frmt |
278 | 278 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
279 | - * @return string|bool|void string on success, FALSE on fail |
|
279 | + * @return null|string string on success, FALSE on fail |
|
280 | 280 | */ |
281 | 281 | private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
282 | 282 | $field_name = "DTT_EVT_{$start_or_end}"; |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | * last-used format, or '' to use the default date format |
295 | 295 | * |
296 | 296 | * @access public |
297 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
298 | - * @return mixed string on success, FALSE on fail |
|
297 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
298 | + * @return null|string string on success, FALSE on fail |
|
299 | 299 | */ |
300 | 300 | public function start_date( $dt_frmt = NULL ) { |
301 | 301 | return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * last-used format, or '' to use the default date format |
319 | 319 | * |
320 | 320 | * @access public |
321 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
322 | - * @return mixed string on success, FALSE on fail |
|
321 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
322 | + * @return null|string string on success, FALSE on fail |
|
323 | 323 | */ |
324 | 324 | public function end_date( $dt_frmt = NULL ) { |
325 | 325 | return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @access public |
344 | 344 | * @param null $dt_frmt - string representation of date format defaults to WP settings |
345 | 345 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
346 | - * @return mixed string on success, FALSE on fail |
|
346 | + * @return string string on success, FALSE on fail |
|
347 | 347 | */ |
348 | 348 | public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
349 | 349 | $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @access public |
371 | 371 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
372 | - * @return mixed string on success, FALSE on fail |
|
372 | + * @return null|string string on success, FALSE on fail |
|
373 | 373 | */ |
374 | 374 | public function start_time( $tm_format = NULL ) { |
375 | 375 | return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @access public |
393 | 393 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
394 | - * @return mixed string on success, FALSE on fail |
|
394 | + * @return null|string string on success, FALSE on fail |
|
395 | 395 | */ |
396 | 396 | public function end_time( $tm_format = NULL ) { |
397 | 397 | return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @access public |
415 | 415 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
416 | 416 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
417 | - * @return mixed string on success, FALSE on fail |
|
417 | + * @return string string on success, FALSE on fail |
|
418 | 418 | */ |
419 | 419 | public function time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
420 | 420 | $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @access public |
443 | 443 | * @param string $dt_format - string representation of date format defaults to 'F j, Y' |
444 | 444 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
445 | - * @return mixed string on success, FALSE on fail |
|
445 | + * @return null|string string on success, FALSE on fail |
|
446 | 446 | */ |
447 | 447 | public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
448 | 448 | return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @access public |
503 | 503 | * @param bool | string $dt_frmt- string representation of date format defaults to 'F j, Y' |
504 | 504 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
505 | - * @return mixed string on success, FALSE on fail |
|
505 | + * @return null|string string on success, FALSE on fail |
|
506 | 506 | */ |
507 | 507 | public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
508 | 508 | return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @return EE_Event_Message_Template|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
25 | + public static function new_instance($props_n_values = array(), $timezone = NULL) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
27 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param null $timezone |
35 | 35 | * @return EE_Event_Message_Template |
36 | 36 | */ |
37 | - public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
|
38 | - return new self( $props_n_values, TRUE, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) { |
|
38 | + return new self($props_n_values, TRUE, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,18 +1,18 @@ 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 | * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
6 | 6 | */ |
7 | -class EE_Event_Question_Group extends EE_Base_Class{ |
|
7 | +class EE_Event_Question_Group extends EE_Base_Class { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @param array $props_n_values |
11 | 11 | * @return EE_Event_Question_Group|mixed |
12 | 12 | */ |
13 | - public static function new_instance( $props_n_values = array() ) { |
|
14 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
15 | - return $has_object ? $has_object : new self( $props_n_values); |
|
13 | + public static function new_instance($props_n_values = array()) { |
|
14 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
15 | + return $has_object ? $has_object : new self($props_n_values); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param array $props_n_values |
22 | 22 | * @return EE_Event_Question_Group |
23 | 23 | */ |
24 | - public static function new_instance_from_db ( $props_n_values = array() ) { |
|
25 | - return new self( $props_n_values, TRUE ); |
|
24 | + public static function new_instance_from_db($props_n_values = array()) { |
|
25 | + return new self($props_n_values, TRUE); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |