@@ -21,12 +21,12 @@ |
||
| 21 | 21 | $updated = $wpdb->update($this->_old_table, |
| 22 | 22 | array('PRC_wp_user'=>$user_id), |
| 23 | 23 | array('PRC_ID'=>$old_row['PRC_ID']), |
| 24 | - array('%d',//PRC_wp_user |
|
| 24 | + array('%d', //PRC_wp_user |
|
| 25 | 25 | ), |
| 26 | - array('%d',//PRC_ID |
|
| 26 | + array('%d', //PRC_ID |
|
| 27 | 27 | )); |
| 28 | - if ( FALSE === $updated ) { |
|
| 29 | - $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting PRC_wp_user = %d where PRC_ID = %d", 'event_espresso'),$user_id,$old_row['PRC_ID'])); |
|
| 28 | + if (FALSE === $updated) { |
|
| 29 | + $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting PRC_wp_user = %d where PRC_ID = %d", 'event_espresso'), $user_id, $old_row['PRC_ID'])); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | $updated = $wpdb->update($this->_old_table, |
| 22 | 22 | array('QSG_wp_user'=>$user_id), |
| 23 | 23 | array('QSG_ID'=>$old_row['QSG_ID']), |
| 24 | - array('%d',//QSG_wp_user |
|
| 24 | + array('%d', //QSG_wp_user |
|
| 25 | 25 | ), |
| 26 | - array('%d',//QSG_ID |
|
| 26 | + array('%d', //QSG_ID |
|
| 27 | 27 | )); |
| 28 | - if ( FALSE === $updated ) { |
|
| 29 | - $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting QSG_wp_user = %d where QSG_ID = %d", 'event_espresso'),$user_id,$old_row['QSG_ID'])); |
|
| 28 | + if (FALSE === $updated) { |
|
| 29 | + $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting QSG_wp_user = %d where QSG_ID = %d", 'event_espresso'), $user_id, $old_row['QSG_ID'])); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | $updated = $wpdb->update($this->_old_table, |
| 22 | 22 | array('TKT_wp_user'=>$user_id), |
| 23 | 23 | array('TKT_ID'=>$old_row['TKT_ID']), |
| 24 | - array('%d',//TKT_wp_user |
|
| 24 | + array('%d', //TKT_wp_user |
|
| 25 | 25 | ), |
| 26 | - array('%d',//TKT_ID |
|
| 26 | + array('%d', //TKT_ID |
|
| 27 | 27 | )); |
| 28 | - if ( FALSE === $updated ) { |
|
| 29 | - $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting TKT_wp_user = %d where TKT_ID = %d", 'event_espresso'),$user_id,$old_row['TKT_ID'])); |
|
| 28 | + if (FALSE === $updated) { |
|
| 29 | + $this->add_error(sprintf(__("Error in updating table {$this->_old_table} setting TKT_wp_user = %d where TKT_ID = %d", 'event_espresso'), $user_id, $old_row['TKT_ID'])); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -12,24 +12,24 @@ discard block |
||
| 12 | 12 | * @author Mike Nelson |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -class EE_DMS_4_6_0_billing_info extends EE_Data_Migration_Script_Stage_Table{ |
|
| 16 | - function __construct(){ |
|
| 15 | +class EE_DMS_4_6_0_billing_info extends EE_Data_Migration_Script_Stage_Table { |
|
| 16 | + function __construct() { |
|
| 17 | 17 | global $wpdb; |
| 18 | 18 | $this->_old_table = $wpdb->postmeta; |
| 19 | 19 | $this->_pretty_name = __('Billing Info', 'event_espresso'); |
| 20 | 20 | $this->_extra_where_sql = "WHERE meta_key LIKE 'billing_info_%'"; |
| 21 | 21 | parent::__construct(); |
| 22 | 22 | } |
| 23 | - protected function _migrate_old_row( $old_row ) { |
|
| 23 | + protected function _migrate_old_row($old_row) { |
|
| 24 | 24 | $new_billing_info = array(); |
| 25 | - $old_billing_info = maybe_unserialize( $old_row[ 'meta_value' ] ); |
|
| 26 | - $gateway_name = str_replace( "billing_info_",'',$old_row[ 'meta_key' ] ); |
|
| 25 | + $old_billing_info = maybe_unserialize($old_row['meta_value']); |
|
| 26 | + $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']); |
|
| 27 | 27 | $repetitive_prefix = '_reg-page-billing-'; |
| 28 | - $repetitive_suffix = "-" . $gateway_name; |
|
| 29 | - foreach( $old_billing_info as $old_input_name => $input_value ){ |
|
| 30 | - $old_input_name_important_part = str_replace( array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name ); |
|
| 28 | + $repetitive_suffix = "-".$gateway_name; |
|
| 29 | + foreach ($old_billing_info as $old_input_name => $input_value) { |
|
| 30 | + $old_input_name_important_part = str_replace(array($repetitive_prefix, $repetitive_suffix), array('', ''), $old_input_name); |
|
| 31 | 31 | |
| 32 | - switch( $old_input_name_important_part ){ |
|
| 32 | + switch ($old_input_name_important_part) { |
|
| 33 | 33 | case 'fname': |
| 34 | 34 | $new_input_name = 'first_name'; |
| 35 | 35 | break; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | case 'state': |
| 40 | 40 | //we used to store the state's id ,but now we just store the name |
| 41 | 41 | $new_input_name = $old_input_name_important_part; |
| 42 | - $input_value = $this->_get_state_name_by_ID( $input_value ); |
|
| 42 | + $input_value = $this->_get_state_name_by_ID($input_value); |
|
| 43 | 43 | break; |
| 44 | 44 | case 'card-nmbr': |
| 45 | 45 | $new_input_name = 'credit_card'; |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $new_input_name = $old_input_name_important_part; |
| 63 | 63 | |
| 64 | 64 | } |
| 65 | - $new_billing_info[ $new_input_name ] = $input_value; |
|
| 65 | + $new_billing_info[$new_input_name] = $input_value; |
|
| 66 | 66 | } |
| 67 | - update_post_meta( $old_row[ 'post_id' ], $old_row[ 'meta_key' ], $new_billing_info ); |
|
| 67 | + update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info); |
|
| 68 | 68 | } |
| 69 | 69 | /** |
| 70 | 70 | * |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * @param int $id |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - protected function _get_state_name_by_ID( $id ){ |
|
| 75 | + protected function _get_state_name_by_ID($id) { |
|
| 76 | 76 | global $wpdb; |
| 77 | - return $wpdb->get_var( $wpdb->prepare( "SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id ) ); |
|
| 77 | + return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM ".$wpdb->prefix."esp_state WHERE STA_ID = %d", $id)); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -12,20 +12,20 @@ discard block |
||
| 12 | 12 | * @author Brent Christensen |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -class EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price extends EE_Data_Migration_Script_Stage_Table{ |
|
| 15 | +class EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price extends EE_Data_Migration_Script_Stage_Table { |
|
| 16 | 16 | |
| 17 | 17 | protected $_ticket_table; |
| 18 | 18 | |
| 19 | 19 | protected $_line_item_table; |
| 20 | 20 | |
| 21 | - function __construct(){ |
|
| 21 | + function __construct() { |
|
| 22 | 22 | /** @type WPDB $wpdb */ |
| 23 | 23 | global $wpdb; |
| 24 | - $this->_pretty_name = __( 'Registration Final Price Tax Calculations', 'event_espresso' ); |
|
| 24 | + $this->_pretty_name = __('Registration Final Price Tax Calculations', 'event_espresso'); |
|
| 25 | 25 | // define tables |
| 26 | - $this->_old_table = $wpdb->prefix . 'esp_registration'; |
|
| 27 | - $this->_ticket_table = $wpdb->prefix . 'esp_ticket'; |
|
| 28 | - $this->_line_item_table = $wpdb->prefix . 'esp_line_item'; |
|
| 26 | + $this->_old_table = $wpdb->prefix.'esp_registration'; |
|
| 27 | + $this->_ticket_table = $wpdb->prefix.'esp_ticket'; |
|
| 28 | + $this->_line_item_table = $wpdb->prefix.'esp_line_item'; |
|
| 29 | 29 | parent::__construct(); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | global $wpdb; |
| 56 | 56 | $SQL = "SELECT count( reg.REG_ID ) "; |
| 57 | 57 | $SQL .= $this->_get_rest_of_sql_for_query(); |
| 58 | - $count = $wpdb->get_var( $SQL ); |
|
| 58 | + $count = $wpdb->get_var($SQL); |
|
| 59 | 59 | return $count; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @param int $limit |
| 68 | 68 | * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
| 69 | 69 | */ |
| 70 | - protected function _get_rows( $limit ) { |
|
| 70 | + protected function _get_rows($limit) { |
|
| 71 | 71 | /** @type WPDB $wpdb */ |
| 72 | 72 | global $wpdb; |
| 73 | 73 | $start_at_record = $this->count_records_migrated(); |
| 74 | 74 | $SQL = "SELECT reg.REG_ID, reg.REG_final_price, line.LIN_ID "; |
| 75 | 75 | $SQL .= $this->_get_rest_of_sql_for_query(); |
| 76 | - $SQL .= $wpdb->prepare( "LIMIT %d, %d", $start_at_record, $limit ); |
|
| 76 | + $SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit); |
|
| 77 | 77 | |
| 78 | 78 | // produces something like: |
| 79 | 79 | /* |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | LIMIT 1, 50 |
| 94 | 94 | */ |
| 95 | 95 | |
| 96 | - return $wpdb->get_results( $SQL, ARRAY_A ); |
|
| 96 | + return $wpdb->get_results($SQL, ARRAY_A); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -102,38 +102,38 @@ discard block |
||
| 102 | 102 | * @param array $row |
| 103 | 103 | * @return void |
| 104 | 104 | */ |
| 105 | - protected function _migrate_old_row( $row ) { |
|
| 105 | + protected function _migrate_old_row($row) { |
|
| 106 | 106 | /** @type WPDB $wpdb */ |
| 107 | 107 | global $wpdb; |
| 108 | 108 | // ensure all required values are present |
| 109 | - if ( ! isset( $row[ 'REG_ID' ], $row[ 'REG_final_price' ], $row[ 'LIN_ID' ] )) { |
|
| 109 | + if ( ! isset($row['REG_ID'], $row['REG_final_price'], $row['LIN_ID'])) { |
|
| 110 | 110 | $this->add_error( |
| 111 | 111 | sprintf( |
| 112 | - __( 'Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso' ), |
|
| 112 | + __('Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', 'event_espresso'), |
|
| 113 | 113 | '<br />', |
| 114 | - isset( $row[ 'REG_ID' ] ) ? $row[ 'REG_ID' ] : '', |
|
| 115 | - isset( $row[ 'REG_final_price' ] ) ? $row[ 'REG_final_price' ] : '', |
|
| 116 | - isset( $row[ 'LIN_ID' ] ) ? $row[ 'LIN_ID' ] : '', |
|
| 114 | + isset($row['REG_ID']) ? $row['REG_ID'] : '', |
|
| 115 | + isset($row['REG_final_price']) ? $row['REG_final_price'] : '', |
|
| 116 | + isset($row['LIN_ID']) ? $row['LIN_ID'] : '', |
|
| 117 | 117 | $wpdb->last_error |
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | // get tax subtotal |
| 123 | - $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal( $row['LIN_ID'] ); |
|
| 124 | - if ( ! $tax_subtotal_line_item_ID ) { |
|
| 123 | + $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($row['LIN_ID']); |
|
| 124 | + if ( ! $tax_subtotal_line_item_ID) { |
|
| 125 | 125 | $this->add_error( |
| 126 | 126 | sprintf( |
| 127 | - __( 'Invalid line item ID returned. Error: "%1$s"', 'event_espresso' ), |
|
| 127 | + __('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'), |
|
| 128 | 128 | $wpdb->last_error |
| 129 | 129 | ) |
| 130 | 130 | ); |
| 131 | 131 | return; |
| 132 | 132 | } |
| 133 | 133 | // now get taxes |
| 134 | - $taxes = $this->_get_tax_amounts( $tax_subtotal_line_item_ID ); |
|
| 134 | + $taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID); |
|
| 135 | 135 | // apply taxes to registration final price |
| 136 | - $this->_apply_taxes( $row[ 'REG_ID' ], $row[ 'REG_final_price' ], $taxes ); |
|
| 136 | + $this->_apply_taxes($row['REG_ID'], $row['REG_final_price'], $taxes); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | * @param int $LIN_ID |
| 146 | 146 | * @return int |
| 147 | 147 | */ |
| 148 | - protected function _get_line_item_ID_for_tax_subtotal( $LIN_ID ) { |
|
| 148 | + protected function _get_line_item_ID_for_tax_subtotal($LIN_ID) { |
|
| 149 | 149 | /** @type WPDB $wpdb */ |
| 150 | 150 | global $wpdb; |
| 151 | 151 | $SQL = "SELECT LIN_ID "; |
| 152 | 152 | $SQL .= "FROM {$this->_line_item_table} "; |
| 153 | 153 | $SQL .= "WHERE LIN_parent = %d "; |
| 154 | 154 | $SQL .= "AND LIN_code = 'taxes'"; |
| 155 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $LIN_ID ) ); |
|
| 155 | + return $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID)); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | * @param int $LIN_ID |
| 164 | 164 | * @return array |
| 165 | 165 | */ |
| 166 | - protected function _get_tax_amounts( $LIN_ID ) { |
|
| 166 | + protected function _get_tax_amounts($LIN_ID) { |
|
| 167 | 167 | /** @type WPDB $wpdb */ |
| 168 | 168 | global $wpdb; |
| 169 | 169 | $SQL = "SELECT LIN_percent "; |
| 170 | 170 | $SQL .= "FROM {$this->_line_item_table} "; |
| 171 | 171 | $SQL .= "WHERE LIN_parent = %d"; |
| 172 | - return $wpdb->get_results( $wpdb->prepare( $SQL, $LIN_ID ), OBJECT_K ); |
|
| 172 | + return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | * @param array $taxes |
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | - protected function _apply_taxes( $REG_ID = 0, $final_price = 0.00, $taxes = array() ) { |
|
| 186 | - if ( is_array( $taxes ) && ! empty( $taxes ) ) { |
|
| 185 | + protected function _apply_taxes($REG_ID = 0, $final_price = 0.00, $taxes = array()) { |
|
| 186 | + if (is_array($taxes) && ! empty($taxes)) { |
|
| 187 | 187 | $total_taxes = 0; |
| 188 | - foreach ( $taxes as $tax ) { |
|
| 189 | - $total_taxes += $final_price * ( $tax->LIN_percent / 100 ); |
|
| 188 | + foreach ($taxes as $tax) { |
|
| 189 | + $total_taxes += $final_price * ($tax->LIN_percent / 100); |
|
| 190 | 190 | } |
| 191 | 191 | $final_price += $total_taxes; |
| 192 | - $this->_update_registration_final_price( $REG_ID, $final_price ); |
|
| 192 | + $this->_update_registration_final_price($REG_ID, $final_price); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,20 +202,20 @@ discard block |
||
| 202 | 202 | * @param float $REG_final_price |
| 203 | 203 | * @return void |
| 204 | 204 | */ |
| 205 | - protected function _update_registration_final_price( $REG_ID = 0, $REG_final_price = 0.00 ) { |
|
| 205 | + protected function _update_registration_final_price($REG_ID = 0, $REG_final_price = 0.00) { |
|
| 206 | 206 | /** @type WPDB $wpdb */ |
| 207 | 207 | global $wpdb; |
| 208 | 208 | $success = $wpdb->update( |
| 209 | 209 | $this->_old_table, |
| 210 | - array( 'REG_final_price' => $REG_final_price ), // data |
|
| 211 | - array( 'REG_ID' => $REG_ID ), // where |
|
| 212 | - array( '%f' ), // data format |
|
| 213 | - array( '%d' ) // where format |
|
| 210 | + array('REG_final_price' => $REG_final_price), // data |
|
| 211 | + array('REG_ID' => $REG_ID), // where |
|
| 212 | + array('%f'), // data format |
|
| 213 | + array('%d') // where format |
|
| 214 | 214 | ); |
| 215 | - if ( $success === false ) { |
|
| 215 | + if ($success === false) { |
|
| 216 | 216 | $this->add_error( |
| 217 | 217 | sprintf( |
| 218 | - __( 'Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso' ), |
|
| 218 | + __('Could not update registration final price value for registration ID=%1$d because "%2$s"', 'event_espresso'), |
|
| 219 | 219 | $REG_ID, |
| 220 | 220 | $wpdb->last_error |
| 221 | 221 | ) |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * Migrates line items that used to have LIN_code="tickets" to "pre-tax-total" |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage{ |
|
| 16 | +class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage { |
|
| 17 | 17 | |
| 18 | 18 | protected $_line_item_table_name; |
| 19 | 19 | |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | global $wpdb; |
| 54 | 54 | $rows_updated = $wpdb->update( |
| 55 | 55 | $this->_line_item_table_name, |
| 56 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
| 57 | - array( 'LIN_code' => 'tickets' ), |
|
| 58 | - array( '%s' ), |
|
| 59 | - array( '%s' ) ); |
|
| 56 | + array('LIN_code' => 'pre-tax-subtotal'), |
|
| 57 | + array('LIN_code' => 'tickets'), |
|
| 58 | + array('%s'), |
|
| 59 | + array('%s') ); |
|
| 60 | 60 | $this->set_completed(); |
| 61 | 61 | return 1; |
| 62 | 62 | } |
@@ -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 ); |
@@ -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 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @param string $dt_frmt - string representation of date format defaults to WP settings |
| 436 | 436 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with |
| 437 | 437 | * the end date ie: Jan 01 "to" Dec 31 |
| 438 | - * @return mixed string on success, FALSE on fail |
|
| 438 | + * @return string string on success, FALSE on fail |
|
| 439 | 439 | * @throws \EE_Error |
| 440 | 440 | */ |
| 441 | 441 | public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @param string $tm_format string representation of time format defaults to 'g:i a' |
| 508 | 508 | * @param string $conjunction conjunction junction what's your function ? |
| 509 | 509 | * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
| 510 | - * @return mixed string on success, FALSE on fail |
|
| 510 | + * @return string string on success, FALSE on fail |
|
| 511 | 511 | * @throws \EE_Error |
| 512 | 512 | */ |
| 513 | 513 | public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | // remove ticket reservation |
| 211 | 211 | $this->decrease_reserved( $qty ); |
| 212 | 212 | $this->set_sold( $sold ); |
| 213 | - do_action( |
|
| 214 | - 'AHEE__EE_Datetime__increase_sold', |
|
| 215 | - $this, |
|
| 216 | - $qty, |
|
| 217 | - $sold |
|
| 218 | - ); |
|
| 219 | - } |
|
| 213 | + do_action( |
|
| 214 | + 'AHEE__EE_Datetime__increase_sold', |
|
| 215 | + $this, |
|
| 216 | + $qty, |
|
| 217 | + $sold |
|
| 218 | + ); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | |
| 222 | 222 | |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | public function decrease_sold( $qty = 1 ) { |
| 228 | 228 | $sold = $this->sold() - $qty; |
| 229 | 229 | $this->set_sold( $sold ); |
| 230 | - do_action( |
|
| 231 | - 'AHEE__EE_Datetime__decrease_sold', |
|
| 232 | - $this, |
|
| 233 | - $qty, |
|
| 234 | - $sold |
|
| 235 | - ); |
|
| 236 | - } |
|
| 230 | + do_action( |
|
| 231 | + 'AHEE__EE_Datetime__decrease_sold', |
|
| 232 | + $this, |
|
| 233 | + $qty, |
|
| 234 | + $sold |
|
| 235 | + ); |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | public function increase_reserved( $qty = 1 ) { |
| 271 | 271 | $reserved = $this->reserved() + absint( $qty ); |
| 272 | - do_action( |
|
| 273 | - 'AHEE__EE_Datetime__increase_reserved', |
|
| 274 | - $this, |
|
| 275 | - $qty, |
|
| 276 | - $reserved |
|
| 277 | - ); |
|
| 278 | - $this->set_reserved( $reserved ); |
|
| 272 | + do_action( |
|
| 273 | + 'AHEE__EE_Datetime__increase_reserved', |
|
| 274 | + $this, |
|
| 275 | + $qty, |
|
| 276 | + $reserved |
|
| 277 | + ); |
|
| 278 | + $this->set_reserved( $reserved ); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -288,13 +288,13 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function decrease_reserved( $qty = 1 ) { |
| 290 | 290 | $reserved = $this->reserved() - absint( $qty ); |
| 291 | - do_action( |
|
| 292 | - 'AHEE__EE_Datetime__decrease_reserved', |
|
| 293 | - $this, |
|
| 294 | - $qty, |
|
| 295 | - $reserved |
|
| 296 | - ); |
|
| 297 | - $this->set_reserved( $reserved ); |
|
| 291 | + do_action( |
|
| 292 | + 'AHEE__EE_Datetime__decrease_reserved', |
|
| 293 | + $this, |
|
| 294 | + $qty, |
|
| 295 | + $reserved |
|
| 296 | + ); |
|
| 297 | + $this->set_reserved( $reserved ); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -382,13 +382,13 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | |
| 384 | 384 | |
| 385 | - /** |
|
| 386 | - * get event start date. Provide either the date format, or NULL to re-use the |
|
| 387 | - * last-used format, or '' to use the default date format |
|
| 388 | - * |
|
| 389 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 390 | - * @return mixed string on success, FALSE on fail |
|
| 391 | - */ |
|
| 385 | + /** |
|
| 386 | + * get event start date. Provide either the date format, or NULL to re-use the |
|
| 387 | + * last-used format, or '' to use the default date format |
|
| 388 | + * |
|
| 389 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 390 | + * @return mixed string on success, FALSE on fail |
|
| 391 | + */ |
|
| 392 | 392 | public function start_date( $dt_frmt = '' ) { |
| 393 | 393 | return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
| 394 | 394 | } |
@@ -405,13 +405,13 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | |
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * get end date. Provide either the date format, or NULL to re-use the |
|
| 410 | - * last-used format, or '' to use the default date format |
|
| 411 | - * |
|
| 412 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 413 | - * @return mixed string on success, FALSE on fail |
|
| 414 | - */ |
|
| 408 | + /** |
|
| 409 | + * get end date. Provide either the date format, or NULL to re-use the |
|
| 410 | + * last-used format, or '' to use the default date format |
|
| 411 | + * |
|
| 412 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 413 | + * @return mixed string on success, FALSE on fail |
|
| 414 | + */ |
|
| 415 | 415 | public function end_date( $dt_frmt = '' ) { |
| 416 | 416 | return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
| 417 | 417 | } |
@@ -533,23 +533,23 @@ discard block |
||
| 533 | 533 | /** |
| 534 | 534 | * This returns a range representation of the date and times. |
| 535 | 535 | * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end. |
| 536 | - * Also, the return value is localized. |
|
| 537 | - * |
|
| 538 | - * @param string $dt_format |
|
| 536 | + * Also, the return value is localized. |
|
| 537 | + * |
|
| 538 | + * @param string $dt_format |
|
| 539 | 539 | * @param string $tm_format |
| 540 | 540 | * @param string $conjunction used between two different dates or times. |
| 541 | - * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
| 542 | - * @param string $separator used between the date and time formats. |
|
| 543 | - * ex: Dec 1, 2016{$separator}2pm |
|
| 541 | + * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
| 542 | + * @param string $separator used between the date and time formats. |
|
| 543 | + * ex: Dec 1, 2016{$separator}2pm |
|
| 544 | 544 | * @return string |
| 545 | 545 | * @throws \EE_Error |
| 546 | 546 | */ |
| 547 | 547 | public function date_and_time_range( |
| 548 | - $dt_format = '', |
|
| 549 | - $tm_format = '', |
|
| 550 | - $conjunction = ' - ' , |
|
| 551 | - $separator = ' ' |
|
| 552 | - ) { |
|
| 548 | + $dt_format = '', |
|
| 549 | + $tm_format = '', |
|
| 550 | + $conjunction = ' - ' , |
|
| 551 | + $separator = ' ' |
|
| 552 | + ) { |
|
| 553 | 553 | $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
| 554 | 554 | $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
| 555 | 555 | $full_format = $dt_format . $separator . $tm_format; |
@@ -563,14 +563,14 @@ discard block |
||
| 563 | 563 | //start and end date are the same but times are different |
| 564 | 564 | case ( $this->start_date() === $this->end_date() ) : |
| 565 | 565 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
| 566 | - . $conjunction |
|
| 567 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 566 | + . $conjunction |
|
| 567 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 568 | 568 | break; |
| 569 | 569 | //all other conditions |
| 570 | 570 | default : |
| 571 | 571 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
| 572 | - . $conjunction |
|
| 573 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 572 | + . $conjunction |
|
| 573 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 574 | 574 | break; |
| 575 | 575 | } |
| 576 | 576 | return $output; |
@@ -654,13 +654,13 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | |
| 656 | 656 | /** |
| 657 | - * get end date and time |
|
| 658 | - * |
|
| 659 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 660 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
| 661 | - * @return mixed string on success, FALSE on fail |
|
| 662 | - */ |
|
| 663 | - public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 657 | + * get end date and time |
|
| 658 | + * |
|
| 659 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 660 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
| 661 | + * @return mixed string on success, FALSE on fail |
|
| 662 | + */ |
|
| 663 | + public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 664 | 664 | return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
| 665 | 665 | } |
| 666 | 666 | |
@@ -929,13 +929,13 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | |
| 931 | 931 | |
| 932 | - /** |
|
| 933 | - * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime (via the tickets). |
|
| 934 | - * into account |
|
| 935 | - * |
|
| 936 | - * @return int |
|
| 937 | - * @throws \EE_Error |
|
| 938 | - */ |
|
| 932 | + /** |
|
| 933 | + * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime (via the tickets). |
|
| 934 | + * into account |
|
| 935 | + * |
|
| 936 | + * @return int |
|
| 937 | + * @throws \EE_Error |
|
| 938 | + */ |
|
| 939 | 939 | public function update_sold() { |
| 940 | 940 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
| 941 | 941 | array( array( |
@@ -944,14 +944,14 @@ discard block |
||
| 944 | 944 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
| 945 | 945 | ) ) |
| 946 | 946 | ); |
| 947 | - $sold = $this->sold(); |
|
| 948 | - if ($count_regs_for_this_datetime > $sold) { |
|
| 949 | - $this->increase_sold($count_regs_for_this_datetime - $sold); |
|
| 950 | - $this->save(); |
|
| 951 | - } else if ($count_regs_for_this_datetime < $sold) { |
|
| 952 | - $this->decrease_sold($count_regs_for_this_datetime - $sold); |
|
| 953 | - $this->save(); |
|
| 954 | - } |
|
| 947 | + $sold = $this->sold(); |
|
| 948 | + if ($count_regs_for_this_datetime > $sold) { |
|
| 949 | + $this->increase_sold($count_regs_for_this_datetime - $sold); |
|
| 950 | + $this->save(); |
|
| 951 | + } else if ($count_regs_for_this_datetime < $sold) { |
|
| 952 | + $this->decrease_sold($count_regs_for_this_datetime - $sold); |
|
| 953 | + $this->save(); |
|
| 954 | + } |
|
| 955 | 955 | return $count_regs_for_this_datetime; |
| 956 | 956 | } |
| 957 | 957 | } |
@@ -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 | |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
| 120 | 120 | */ |
| 121 | - public function set_start_date( $date ) { |
|
| 122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
| 121 | + public function set_start_date($date) { |
|
| 122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
| 133 | 133 | */ |
| 134 | - public function set_start_time( $time ) { |
|
| 135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
| 134 | + public function set_start_time($time) { |
|
| 135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
| 146 | 146 | */ |
| 147 | - public function set_end_date( $date ) { |
|
| 148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
| 147 | + public function set_end_date($date) { |
|
| 148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
| 159 | 159 | */ |
| 160 | - public function set_end_time( $time ) { |
|
| 161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
| 160 | + public function set_end_time($time) { |
|
| 161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param int $reg_limit |
| 172 | 172 | */ |
| 173 | - public function set_reg_limit( $reg_limit ) { |
|
| 174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
| 173 | + public function set_reg_limit($reg_limit) { |
|
| 174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @return mixed int on success, FALSE on fail |
| 184 | 184 | */ |
| 185 | 185 | public function sold() { |
| 186 | - return $this->get_raw( 'DTT_sold' ); |
|
| 186 | + return $this->get_raw('DTT_sold'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param int $sold |
| 195 | 195 | */ |
| 196 | - public function set_sold( $sold ) { |
|
| 196 | + public function set_sold($sold) { |
|
| 197 | 197 | // sold can not go below zero |
| 198 | - $sold = max( 0, $sold ); |
|
| 199 | - $this->set( 'DTT_sold', $sold ); |
|
| 198 | + $sold = max(0, $sold); |
|
| 199 | + $this->set('DTT_sold', $sold); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | * increments sold by amount passed by $qty |
| 206 | 206 | * @param int $qty |
| 207 | 207 | */ |
| 208 | - public function increase_sold( $qty = 1 ) { |
|
| 208 | + public function increase_sold($qty = 1) { |
|
| 209 | 209 | $sold = $this->sold() + $qty; |
| 210 | 210 | // remove ticket reservation |
| 211 | - $this->decrease_reserved( $qty ); |
|
| 212 | - $this->set_sold( $sold ); |
|
| 211 | + $this->decrease_reserved($qty); |
|
| 212 | + $this->set_sold($sold); |
|
| 213 | 213 | do_action( |
| 214 | 214 | 'AHEE__EE_Datetime__increase_sold', |
| 215 | 215 | $this, |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | * decrements (subtracts) sold amount passed by $qty |
| 225 | 225 | * @param int $qty |
| 226 | 226 | */ |
| 227 | - public function decrease_sold( $qty = 1 ) { |
|
| 227 | + public function decrease_sold($qty = 1) { |
|
| 228 | 228 | $sold = $this->sold() - $qty; |
| 229 | - $this->set_sold( $sold ); |
|
| 229 | + $this->set_sold($sold); |
|
| 230 | 230 | do_action( |
| 231 | 231 | 'AHEE__EE_Datetime__decrease_sold', |
| 232 | 232 | $this, |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return int |
| 244 | 244 | */ |
| 245 | 245 | public function reserved() { |
| 246 | - return $this->get_raw( 'DTT_reserved' ); |
|
| 246 | + return $this->get_raw('DTT_reserved'); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param int $reserved |
| 255 | 255 | */ |
| 256 | - public function set_reserved( $reserved ) { |
|
| 256 | + public function set_reserved($reserved) { |
|
| 257 | 257 | // reserved can not go below zero |
| 258 | - $reserved = max( 0, (int) $reserved ); |
|
| 259 | - $this->set( 'DTT_reserved', $reserved ); |
|
| 258 | + $reserved = max(0, (int) $reserved); |
|
| 259 | + $this->set('DTT_reserved', $reserved); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | |
@@ -267,15 +267,15 @@ discard block |
||
| 267 | 267 | * @param int $qty |
| 268 | 268 | * @return void |
| 269 | 269 | */ |
| 270 | - public function increase_reserved( $qty = 1 ) { |
|
| 271 | - $reserved = $this->reserved() + absint( $qty ); |
|
| 270 | + public function increase_reserved($qty = 1) { |
|
| 271 | + $reserved = $this->reserved() + absint($qty); |
|
| 272 | 272 | do_action( |
| 273 | 273 | 'AHEE__EE_Datetime__increase_reserved', |
| 274 | 274 | $this, |
| 275 | 275 | $qty, |
| 276 | 276 | $reserved |
| 277 | 277 | ); |
| 278 | - $this->set_reserved( $reserved ); |
|
| 278 | + $this->set_reserved($reserved); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -286,15 +286,15 @@ discard block |
||
| 286 | 286 | * @param int $qty |
| 287 | 287 | * @return void |
| 288 | 288 | */ |
| 289 | - public function decrease_reserved( $qty = 1 ) { |
|
| 290 | - $reserved = $this->reserved() - absint( $qty ); |
|
| 289 | + public function decrease_reserved($qty = 1) { |
|
| 290 | + $reserved = $this->reserved() - absint($qty); |
|
| 291 | 291 | do_action( |
| 292 | 292 | 'AHEE__EE_Datetime__decrease_reserved', |
| 293 | 293 | $this, |
| 294 | 294 | $qty, |
| 295 | 295 | $reserved |
| 296 | 296 | ); |
| 297 | - $this->set_reserved( $reserved ); |
|
| 297 | + $this->set_reserved($reserved); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @return string |
| 316 | 316 | */ |
| 317 | 317 | public function name() { |
| 318 | - return $this->get( 'DTT_name' ); |
|
| 318 | + return $this->get('DTT_name'); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @return string |
| 326 | 326 | */ |
| 327 | 327 | public function description() { |
| 328 | - return $this->get( 'DTT_description' ); |
|
| 328 | + return $this->get('DTT_description'); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return boolean TRUE if is primary, FALSE if not. |
| 336 | 336 | */ |
| 337 | 337 | public function is_primary() { |
| 338 | - return $this->get( 'DTT_is_primary' ); |
|
| 338 | + return $this->get('DTT_is_primary'); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @return int The order of the datetime for this event. |
| 346 | 346 | */ |
| 347 | 347 | public function order() { |
| 348 | - return $this->get( 'DTT_order' ); |
|
| 348 | + return $this->get('DTT_order'); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @return int |
| 356 | 356 | */ |
| 357 | 357 | public function parent() { |
| 358 | - return $this->get( 'DTT_parent' ); |
|
| 358 | + return $this->get('DTT_parent'); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | |
@@ -371,10 +371,10 @@ discard block |
||
| 371 | 371 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
| 372 | 372 | * @return string|bool string on success, FALSE on fail |
| 373 | 373 | */ |
| 374 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
| 374 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
| 375 | 375 | $field_name = "DTT_EVT_{$start_or_end}"; |
| 376 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
| 377 | - if ( ! $echo ) { |
|
| 376 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
| 377 | + if ( ! $echo) { |
|
| 378 | 378 | return $dtt; |
| 379 | 379 | } |
| 380 | 380 | return ''; |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
| 390 | 390 | * @return mixed string on success, FALSE on fail |
| 391 | 391 | */ |
| 392 | - public function start_date( $dt_frmt = '' ) { |
|
| 393 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
| 392 | + public function start_date($dt_frmt = '') { |
|
| 393 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * Echoes start_date() |
| 400 | 400 | * @param string $dt_frmt |
| 401 | 401 | */ |
| 402 | - public function e_start_date( $dt_frmt = '' ) { |
|
| 403 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
| 402 | + public function e_start_date($dt_frmt = '') { |
|
| 403 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
| 413 | 413 | * @return mixed string on success, FALSE on fail |
| 414 | 414 | */ |
| 415 | - public function end_date( $dt_frmt = '' ) { |
|
| 416 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
| 415 | + public function end_date($dt_frmt = '') { |
|
| 416 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
@@ -422,8 +422,8 @@ discard block |
||
| 422 | 422 | * Echoes the end date. See end_date() |
| 423 | 423 | * @param string $dt_frmt |
| 424 | 424 | */ |
| 425 | - public function e_end_date( $dt_frmt = '' ) { |
|
| 426 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
| 425 | + public function e_end_date($dt_frmt = '') { |
|
| 426 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | |
@@ -438,11 +438,11 @@ discard block |
||
| 438 | 438 | * @return mixed string on success, FALSE on fail |
| 439 | 439 | * @throws \EE_Error |
| 440 | 440 | */ |
| 441 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
| 442 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
| 443 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
| 444 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
| 445 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
| 441 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
| 442 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
| 443 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
| 444 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
| 445 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | * @param string $conjunction |
| 453 | 453 | * @throws \EE_Error |
| 454 | 454 | */ |
| 455 | - public function e_date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
| 456 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
| 455 | + public function e_date_range($dt_frmt = '', $conjunction = ' - ') { |
|
| 456 | + echo $this->date_range($dt_frmt, $conjunction); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 465 | 465 | * @return mixed string on success, FALSE on fail |
| 466 | 466 | */ |
| 467 | - public function start_time( $tm_format = '' ) { |
|
| 468 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
| 467 | + public function start_time($tm_format = '') { |
|
| 468 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
@@ -473,8 +473,8 @@ discard block |
||
| 473 | 473 | /** |
| 474 | 474 | * @param string $tm_format |
| 475 | 475 | */ |
| 476 | - public function e_start_time( $tm_format = '' ) { |
|
| 477 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
| 476 | + public function e_start_time($tm_format = '') { |
|
| 477 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | |
@@ -485,8 +485,8 @@ discard block |
||
| 485 | 485 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 486 | 486 | * @return mixed string on success, FALSE on fail |
| 487 | 487 | */ |
| 488 | - public function end_time( $tm_format = '' ) { |
|
| 489 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
| 488 | + public function end_time($tm_format = '') { |
|
| 489 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | /** |
| 495 | 495 | * @param string $tm_format |
| 496 | 496 | */ |
| 497 | - public function e_end_time( $tm_format = '' ) { |
|
| 498 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
| 497 | + public function e_end_time($tm_format = '') { |
|
| 498 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -510,11 +510,11 @@ discard block |
||
| 510 | 510 | * @return mixed string on success, FALSE on fail |
| 511 | 511 | * @throws \EE_Error |
| 512 | 512 | */ |
| 513 | - public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
| 514 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
| 515 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
| 516 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
| 517 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
| 513 | + public function time_range($tm_format = '', $conjunction = ' - ') { |
|
| 514 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
| 515 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
| 516 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
| 517 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | * @param string $conjunction |
| 525 | 525 | * @throws \EE_Error |
| 526 | 526 | */ |
| 527 | - public function e_time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
| 528 | - echo $this->time_range( $tm_format, $conjunction ); |
|
| 527 | + public function e_time_range($tm_format = '', $conjunction = ' - ') { |
|
| 528 | + echo $this->time_range($tm_format, $conjunction); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | |
@@ -547,30 +547,30 @@ discard block |
||
| 547 | 547 | public function date_and_time_range( |
| 548 | 548 | $dt_format = '', |
| 549 | 549 | $tm_format = '', |
| 550 | - $conjunction = ' - ' , |
|
| 550 | + $conjunction = ' - ', |
|
| 551 | 551 | $separator = ' ' |
| 552 | 552 | ) { |
| 553 | - $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
|
| 554 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
| 555 | - $full_format = $dt_format . $separator . $tm_format; |
|
| 553 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
| 554 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
| 555 | + $full_format = $dt_format.$separator.$tm_format; |
|
| 556 | 556 | |
| 557 | 557 | //the range output depends on various conditions |
| 558 | - switch ( true ) { |
|
| 558 | + switch (true) { |
|
| 559 | 559 | //start date timestamp and end date timestamp are the same. |
| 560 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
| 561 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
| 560 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
| 561 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
| 562 | 562 | break; |
| 563 | 563 | //start and end date are the same but times are different |
| 564 | - case ( $this->start_date() === $this->end_date() ) : |
|
| 565 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
| 564 | + case ($this->start_date() === $this->end_date()) : |
|
| 565 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
| 566 | 566 | . $conjunction |
| 567 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 567 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
| 568 | 568 | break; |
| 569 | 569 | //all other conditions |
| 570 | 570 | default : |
| 571 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
| 571 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
| 572 | 572 | . $conjunction |
| 573 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 573 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
| 574 | 574 | break; |
| 575 | 575 | } |
| 576 | 576 | return $output; |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * @return void |
| 589 | 589 | * @throws \EE_Error |
| 590 | 590 | */ |
| 591 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
| 592 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
| 591 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
| 592 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 602 | 602 | * @return mixed string on success, FALSE on fail |
| 603 | 603 | */ |
| 604 | - public function start_date_and_time( $dt_format = '', $tm_format = '' ) { |
|
| 605 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
| 604 | + public function start_date_and_time($dt_format = '', $tm_format = '') { |
|
| 605 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | |
@@ -611,8 +611,8 @@ discard block |
||
| 611 | 611 | * @param string $dt_frmt |
| 612 | 612 | * @param string $tm_format |
| 613 | 613 | */ |
| 614 | - public function e_start_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
| 615 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
| 614 | + public function e_start_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 615 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | |
@@ -626,11 +626,11 @@ discard block |
||
| 626 | 626 | * @param bool $round_up |
| 627 | 627 | * @return float|int|mixed |
| 628 | 628 | */ |
| 629 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
| 630 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
| 631 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
| 629 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
| 630 | + $start = $this->get_raw('DTT_EVT_start'); |
|
| 631 | + $end = $this->get_raw('DTT_EVT_end'); |
|
| 632 | 632 | $length_in_units = $end - $start; |
| 633 | - switch ( $units ) { |
|
| 633 | + switch ($units) { |
|
| 634 | 634 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
| 635 | 635 | /** @noinspection PhpMissingBreakStatementInspection */ |
| 636 | 636 | case 'days': |
@@ -643,10 +643,10 @@ discard block |
||
| 643 | 643 | $length_in_units /= 60; |
| 644 | 644 | case 'seconds': |
| 645 | 645 | default: |
| 646 | - $length_in_units = ceil( $length_in_units ); |
|
| 646 | + $length_in_units = ceil($length_in_units); |
|
| 647 | 647 | } |
| 648 | - if ( $round_up ) { |
|
| 649 | - $length_in_units = max( $length_in_units, 1 ); |
|
| 648 | + if ($round_up) { |
|
| 649 | + $length_in_units = max($length_in_units, 1); |
|
| 650 | 650 | } |
| 651 | 651 | return $length_in_units; |
| 652 | 652 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @return mixed string on success, FALSE on fail |
| 662 | 662 | */ |
| 663 | 663 | public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
| 664 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
| 664 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | |
@@ -670,8 +670,8 @@ discard block |
||
| 670 | 670 | * @param string $dt_frmt |
| 671 | 671 | * @param string $tm_format |
| 672 | 672 | */ |
| 673 | - public function e_end_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
| 674 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
| 673 | + public function e_end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 674 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | * @return int |
| 683 | 683 | */ |
| 684 | 684 | public function start() { |
| 685 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
| 685 | + return $this->get_raw('DTT_EVT_start'); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * @return int |
| 694 | 694 | */ |
| 695 | 695 | public function end() { |
| 696 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
| 696 | + return $this->get_raw('DTT_EVT_end'); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | * @return mixed int on success, FALSE on fail |
| 705 | 705 | */ |
| 706 | 706 | public function reg_limit() { |
| 707 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
| 707 | + return $this->get_raw('DTT_reg_limit'); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | |
@@ -732,15 +732,15 @@ discard block |
||
| 732 | 732 | * the spaces remaining for this particular datetime, hence the flag. |
| 733 | 733 | * @return int |
| 734 | 734 | */ |
| 735 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
| 735 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
| 736 | 736 | // tickets remaining available for purchase |
| 737 | 737 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
| 738 | 738 | $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
| 739 | - if ( ! $consider_tickets ) { |
|
| 739 | + if ( ! $consider_tickets) { |
|
| 740 | 740 | return $dtt_remaining; |
| 741 | 741 | } |
| 742 | 742 | $tickets_remaining = $this->tickets_remaining(); |
| 743 | - return min( $dtt_remaining, $tickets_remaining ); |
|
| 743 | + return min($dtt_remaining, $tickets_remaining); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | |
@@ -751,19 +751,19 @@ discard block |
||
| 751 | 751 | * @param array $query_params like EEM_Base::get_all's |
| 752 | 752 | * @return int |
| 753 | 753 | */ |
| 754 | - public function tickets_remaining( $query_params = array() ) { |
|
| 754 | + public function tickets_remaining($query_params = array()) { |
|
| 755 | 755 | $sum = 0; |
| 756 | - $tickets = $this->tickets( $query_params ); |
|
| 757 | - if ( ! empty( $tickets ) ) { |
|
| 758 | - foreach ( $tickets as $ticket ) { |
|
| 759 | - if ( $ticket instanceof EE_Ticket ) { |
|
| 756 | + $tickets = $this->tickets($query_params); |
|
| 757 | + if ( ! empty($tickets)) { |
|
| 758 | + foreach ($tickets as $ticket) { |
|
| 759 | + if ($ticket instanceof EE_Ticket) { |
|
| 760 | 760 | // get the actual amount of tickets that can be sold |
| 761 | - $qty = $ticket->qty( 'saleable' ); |
|
| 762 | - if ( $qty === EE_INF ) { |
|
| 761 | + $qty = $ticket->qty('saleable'); |
|
| 762 | + if ($qty === EE_INF) { |
|
| 763 | 763 | return EE_INF; |
| 764 | 764 | } |
| 765 | 765 | // no negative ticket quantities plz |
| 766 | - if ( $qty > 0 ) { |
|
| 766 | + if ($qty > 0) { |
|
| 767 | 767 | $sum += $qty; |
| 768 | 768 | } |
| 769 | 769 | } |
@@ -780,8 +780,8 @@ discard block |
||
| 780 | 780 | * @param array $query_params like EEM_Base::get_all's |
| 781 | 781 | * @return int |
| 782 | 782 | */ |
| 783 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
| 784 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
| 783 | + public function sum_tickets_initially_available($query_params = array()) { |
|
| 784 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | * @return int |
| 794 | 794 | */ |
| 795 | 795 | public function total_tickets_available_at_this_datetime() { |
| 796 | - return $this->spaces_remaining( true ); |
|
| 796 | + return $this->spaces_remaining(true); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | * @return boolean |
| 805 | 805 | */ |
| 806 | 806 | public function is_upcoming() { |
| 807 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
| 807 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | * @return boolean |
| 815 | 815 | */ |
| 816 | 816 | public function is_active() { |
| 817 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
| 817 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | * @return boolean |
| 825 | 825 | */ |
| 826 | 826 | public function is_expired() { |
| 827 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
| 827 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | |
@@ -835,16 +835,16 @@ discard block |
||
| 835 | 835 | */ |
| 836 | 836 | public function get_active_status() { |
| 837 | 837 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
| 838 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
| 838 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
| 839 | 839 | return EE_Datetime::sold_out; |
| 840 | 840 | } |
| 841 | - if ( $this->is_expired() ) { |
|
| 841 | + if ($this->is_expired()) { |
|
| 842 | 842 | return EE_Datetime::expired; |
| 843 | 843 | } |
| 844 | - if ( $this->is_upcoming() ) { |
|
| 844 | + if ($this->is_upcoming()) { |
|
| 845 | 845 | return EE_Datetime::upcoming; |
| 846 | 846 | } |
| 847 | - if ( $this->is_active() ) { |
|
| 847 | + if ($this->is_active()) { |
|
| 848 | 848 | return EE_Datetime::active; |
| 849 | 849 | } |
| 850 | 850 | return NULL; |
@@ -858,24 +858,24 @@ discard block |
||
| 858 | 858 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
| 859 | 859 | * @return string |
| 860 | 860 | */ |
| 861 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
| 862 | - if ( $use_dtt_name ) { |
|
| 861 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
| 862 | + if ($use_dtt_name) { |
|
| 863 | 863 | $dtt_name = $this->name(); |
| 864 | - if ( !empty( $dtt_name ) ) { |
|
| 864 | + if ( ! empty($dtt_name)) { |
|
| 865 | 865 | return $dtt_name; |
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | //first condition is to see if the months are different |
| 869 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
| 870 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
| 869 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
| 870 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
| 871 | 871 | //next condition is if its the same month but different day |
| 872 | 872 | } |
| 873 | 873 | else { |
| 874 | - 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' ) ) ) { |
|
| 875 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
| 874 | + 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'))) { |
|
| 875 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
| 876 | 876 | } |
| 877 | 877 | else { |
| 878 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
| 878 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | return $display_date; |
@@ -889,8 +889,8 @@ discard block |
||
| 889 | 889 | *@param array $query_params see EEM_Base::get_all() |
| 890 | 890 | * @return EE_Ticket[] |
| 891 | 891 | */ |
| 892 | - public function tickets( $query_params = array() ) { |
|
| 893 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
| 892 | + public function tickets($query_params = array()) { |
|
| 893 | + return $this->get_many_related('Ticket', $query_params); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -900,21 +900,21 @@ discard block |
||
| 900 | 900 | * @param array $query_params like EEM_Base::get_all's |
| 901 | 901 | * @return EE_Ticket[] |
| 902 | 902 | */ |
| 903 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
| 903 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
| 904 | 904 | // first check if datetime is valid |
| 905 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
| 905 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
| 906 | 906 | return array(); |
| 907 | 907 | } |
| 908 | - if ( empty( $query_params ) ) { |
|
| 908 | + if (empty($query_params)) { |
|
| 909 | 909 | $query_params = array( |
| 910 | 910 | array( |
| 911 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
| 912 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
| 911 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
| 912 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
| 913 | 913 | 'TKT_deleted' => false |
| 914 | 914 | ) |
| 915 | 915 | ); |
| 916 | 916 | } |
| 917 | - return $this->tickets( $query_params ); |
|
| 917 | + return $this->tickets($query_params); |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * @return EE_Event |
| 925 | 925 | */ |
| 926 | 926 | public function event() { |
| 927 | - return $this->get_first_related( 'Event' ); |
|
| 927 | + return $this->get_first_related('Event'); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | |
@@ -938,11 +938,11 @@ discard block |
||
| 938 | 938 | */ |
| 939 | 939 | public function update_sold() { |
| 940 | 940 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
| 941 | - array( array( |
|
| 941 | + array(array( |
|
| 942 | 942 | 'STS_ID' => EEM_Registration::status_id_approved, |
| 943 | 943 | 'REG_deleted' => 0, |
| 944 | 944 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
| 945 | - ) ) |
|
| 945 | + )) |
|
| 946 | 946 | ); |
| 947 | 947 | $sold = $this->sold(); |
| 948 | 948 | if ($count_regs_for_this_datetime > $sold) { |