@@ -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 |
@@ -1,4 +1,6 @@ discard block |
||
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 | * CSV Import Export class |
4 | 6 | * |
@@ -105,8 +107,9 @@ discard block |
||
105 | 107 | $fc = $fc . $c; |
106 | 108 | } |
107 | 109 | } |
108 | - if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) |
|
109 | - $fc = substr($fc,2); |
|
110 | + if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) { |
|
111 | + $fc = substr($fc,2); |
|
112 | + } |
|
110 | 113 | return ($fc); |
111 | 114 | } |
112 | 115 | |
@@ -144,7 +147,7 @@ discard block |
||
144 | 147 | while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){ |
145 | 148 | $csvarray[]= $data; |
146 | 149 | } |
147 | - }else{ |
|
150 | + } else{ |
|
148 | 151 | // loop through each row of the file |
149 | 152 | while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) { |
150 | 153 | $csvarray[]=$data; |
@@ -153,7 +156,7 @@ discard block |
||
153 | 156 | # Close the File. |
154 | 157 | fclose($file_handle); |
155 | 158 | return $csvarray; |
156 | - }else{ |
|
159 | + } else{ |
|
157 | 160 | EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ ); |
158 | 161 | return false; |
159 | 162 | } |
@@ -234,7 +237,7 @@ discard block |
||
234 | 237 | $matches = array(); |
235 | 238 | if($model_name == EE_CSV::metadata_header){ |
236 | 239 | $headers[$i] = $column_name; |
237 | - }else{ |
|
240 | + } else{ |
|
238 | 241 | //now get the db table name from it (the part between square brackets) |
239 | 242 | $success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches); |
240 | 243 | if (!$success){ |
@@ -244,7 +247,7 @@ discard block |
||
244 | 247 | $headers[$i] = $matches[2]; |
245 | 248 | } |
246 | 249 | |
247 | - }else{ |
|
250 | + } else{ |
|
248 | 251 | // no column names means our final array will just use counters for keys |
249 | 252 | $model_entry[$headers[$i]] = $data[$i]; |
250 | 253 | $headers[$i] = $i; |
@@ -371,7 +374,7 @@ discard block |
||
371 | 374 | echo $this->fputcsv2($filehandle, $data_row); |
372 | 375 | } |
373 | 376 | return true; |
374 | - }else{ |
|
377 | + } else{ |
|
375 | 378 | //no data TO write... so we can assume that's a success |
376 | 379 | return true; |
377 | 380 | } |
@@ -438,7 +441,7 @@ discard block |
||
438 | 441 | |
439 | 442 | if( ! empty($model_instance_arrays) ){ |
440 | 443 | $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
441 | - }else{ |
|
444 | + } else{ |
|
442 | 445 | // echo "no data to write... so just write the headers"; |
443 | 446 | //so there's actually NO model objects for that model. |
444 | 447 | //probably still want to show the columns |
@@ -315,7 +315,7 @@ |
||
315 | 315 | // header("Content-Type: application/download"); |
316 | 316 | header('Content-disposition: attachment; filename='.$filename); |
317 | 317 | header("Content-Type: text/csv; charset=utf-8"); |
318 | - do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' ); |
|
318 | + do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' ); |
|
319 | 319 | echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
320 | 320 | $fh = fopen('php://output', 'w'); |
321 | 321 | return $fh; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * CSV Import Export class |
4 | 4 | * |
@@ -45,31 +45,31 @@ discard block |
||
45 | 45 | global $wpdb; |
46 | 46 | |
47 | 47 | $this->_primary_keys = array( |
48 | - $wpdb->prefix . 'esp_answer' => array( 'ANS_ID' ), |
|
49 | - $wpdb->prefix . 'esp_attendee' => array( 'ATT_ID' ), |
|
50 | - $wpdb->prefix . 'esp_datetime' => array( 'DTT_ID' ), |
|
51 | - $wpdb->prefix . 'esp_event_question_group' => array( 'EQG_ID' ), |
|
52 | - $wpdb->prefix . 'esp_message_template' => array( 'MTP_ID' ), |
|
53 | - $wpdb->prefix . 'esp_payment' => array( 'PAY_ID' ), |
|
54 | - $wpdb->prefix . 'esp_price' => array( 'PRC_ID' ), |
|
55 | - $wpdb->prefix . 'esp_price_type' => array( 'PRT_ID' ), |
|
56 | - $wpdb->prefix . 'esp_question' => array( 'QST_ID' ), |
|
57 | - $wpdb->prefix . 'esp_question_group' => array( 'QSG_ID' ), |
|
58 | - $wpdb->prefix . 'esp_question_group_question' => array( 'QGQ_ID' ), |
|
59 | - $wpdb->prefix . 'esp_question_option' => array( 'QSO_ID' ), |
|
60 | - $wpdb->prefix . 'esp_registration' => array( 'REG_ID' ), |
|
61 | - $wpdb->prefix . 'esp_status' => array( 'STS_ID' ), |
|
62 | - $wpdb->prefix . 'esp_transaction' => array( 'TXN_ID' ), |
|
63 | - $wpdb->prefix . 'esp_transaction' => array( 'TXN_ID' ), |
|
64 | - $wpdb->prefix . 'events_detail' => array( 'id' ), |
|
65 | - $wpdb->prefix . 'events_category_detail' => array( 'id' ), |
|
66 | - $wpdb->prefix . 'events_category_rel' => array( 'id' ), |
|
67 | - $wpdb->prefix . 'events_venue' => array( 'id' ), |
|
68 | - $wpdb->prefix . 'events_venue_rel' => array( 'emeta_id' ), |
|
69 | - $wpdb->prefix . 'events_locale' => array( 'id' ), |
|
70 | - $wpdb->prefix . 'events_locale_rel' => array( 'id' ), |
|
71 | - $wpdb->prefix . 'events_personnel' => array( 'id' ), |
|
72 | - $wpdb->prefix . 'events_personnel_rel' => array( 'id' ), |
|
48 | + $wpdb->prefix.'esp_answer' => array('ANS_ID'), |
|
49 | + $wpdb->prefix.'esp_attendee' => array('ATT_ID'), |
|
50 | + $wpdb->prefix.'esp_datetime' => array('DTT_ID'), |
|
51 | + $wpdb->prefix.'esp_event_question_group' => array('EQG_ID'), |
|
52 | + $wpdb->prefix.'esp_message_template' => array('MTP_ID'), |
|
53 | + $wpdb->prefix.'esp_payment' => array('PAY_ID'), |
|
54 | + $wpdb->prefix.'esp_price' => array('PRC_ID'), |
|
55 | + $wpdb->prefix.'esp_price_type' => array('PRT_ID'), |
|
56 | + $wpdb->prefix.'esp_question' => array('QST_ID'), |
|
57 | + $wpdb->prefix.'esp_question_group' => array('QSG_ID'), |
|
58 | + $wpdb->prefix.'esp_question_group_question' => array('QGQ_ID'), |
|
59 | + $wpdb->prefix.'esp_question_option' => array('QSO_ID'), |
|
60 | + $wpdb->prefix.'esp_registration' => array('REG_ID'), |
|
61 | + $wpdb->prefix.'esp_status' => array('STS_ID'), |
|
62 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
63 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
64 | + $wpdb->prefix.'events_detail' => array('id'), |
|
65 | + $wpdb->prefix.'events_category_detail' => array('id'), |
|
66 | + $wpdb->prefix.'events_category_rel' => array('id'), |
|
67 | + $wpdb->prefix.'events_venue' => array('id'), |
|
68 | + $wpdb->prefix.'events_venue_rel' => array('emeta_id'), |
|
69 | + $wpdb->prefix.'events_locale' => array('id'), |
|
70 | + $wpdb->prefix.'events_locale_rel' => array('id'), |
|
71 | + $wpdb->prefix.'events_personnel' => array('id'), |
|
72 | + $wpdb->prefix.'events_personnel_rel' => array('id'), |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @ access public |
82 | 82 | * @return EE_CSV |
83 | 83 | */ |
84 | - public static function instance ( ) { |
|
84 | + public static function instance( ) { |
|
85 | 85 | // check if class object is instantiated |
86 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_CSV )) { |
|
86 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) { |
|
87 | 87 | self::$_instance = new self(); |
88 | 88 | } |
89 | 89 | return self::$_instance; |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | * @throws EE_Error |
97 | 97 | */ |
98 | - private function read_unicode_file($file_path){ |
|
98 | + private function read_unicode_file($file_path) { |
|
99 | 99 | $fc = ""; |
100 | - $fh = fopen($file_path,"rb"); |
|
101 | - if( ! $fh ){ |
|
102 | - throw new EE_Error( sprintf( __("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path ) ); |
|
100 | + $fh = fopen($file_path, "rb"); |
|
101 | + if ( ! $fh) { |
|
102 | + throw new EE_Error(sprintf(__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path)); |
|
103 | 103 | } |
104 | 104 | $flen = filesize($file_path); |
105 | 105 | $bc = fread($fh, $flen); |
106 | - for ($i=0; $i<$flen; $i++){ |
|
107 | - $c = substr($bc,$i,1); |
|
108 | - if ((ord($c) != 0) && (ord($c) != 13)){ |
|
109 | - $fc = $fc . $c; |
|
106 | + for ($i = 0; $i < $flen; $i++) { |
|
107 | + $c = substr($bc, $i, 1); |
|
108 | + if ((ord($c) != 0) && (ord($c) != 13)) { |
|
109 | + $fc = $fc.$c; |
|
110 | 110 | } |
111 | 111 | } |
112 | - if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) |
|
113 | - $fc = substr($fc,2); |
|
112 | + if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254)) |
|
113 | + $fc = substr($fc, 2); |
|
114 | 114 | return ($fc); |
115 | 115 | } |
116 | 116 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * @param string $path_to_file |
123 | 123 | * @return array of arrays. Top-level array has rows, second-level array has each item |
124 | 124 | */ |
125 | - public function import_csv_to_multi_dimensional_array($path_to_file){ |
|
125 | + public function import_csv_to_multi_dimensional_array($path_to_file) { |
|
126 | 126 | // needed to deal with Mac line endings |
127 | - ini_set('auto_detect_line_endings',TRUE); |
|
127 | + ini_set('auto_detect_line_endings', TRUE); |
|
128 | 128 | |
129 | 129 | // because fgetcsv does not correctly deal with backslashed quotes such as \" |
130 | 130 | // we'll read the file into a string |
131 | - $file_contents = $this->read_unicode_file( $path_to_file ); |
|
131 | + $file_contents = $this->read_unicode_file($path_to_file); |
|
132 | 132 | // replace backslashed quotes with CSV enclosures |
133 | - $file_contents = str_replace ( '\\"', '"""', $file_contents ); |
|
133 | + $file_contents = str_replace('\\"', '"""', $file_contents); |
|
134 | 134 | // HEY YOU! PUT THAT FILE BACK!!! |
135 | 135 | file_put_contents($path_to_file, $file_contents); |
136 | 136 | |
@@ -140,25 +140,25 @@ discard block |
||
140 | 140 | $csvarray = array(); |
141 | 141 | |
142 | 142 | // in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what? |
143 | - if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { |
|
143 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
144 | 144 | |
145 | 145 | // PHP 5.2- version |
146 | 146 | |
147 | 147 | // loop through each row of the file |
148 | - while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){ |
|
149 | - $csvarray[]= $data; |
|
148 | + while (($data = fgetcsv($file_handle, 0, ',', '"')) !== FALSE) { |
|
149 | + $csvarray[] = $data; |
|
150 | 150 | } |
151 | - }else{ |
|
151 | + } else { |
|
152 | 152 | // loop through each row of the file |
153 | - while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) { |
|
154 | - $csvarray[]=$data; |
|
153 | + while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== FALSE) { |
|
154 | + $csvarray[] = $data; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | # Close the File. |
158 | 158 | fclose($file_handle); |
159 | 159 | return $csvarray; |
160 | - }else{ |
|
161 | - EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ ); |
|
160 | + } else { |
|
161 | + EE_Error::add_error(sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), __FILE__, __FUNCTION__, __LINE__); |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * ... |
189 | 189 | * ) |
190 | 190 | */ |
191 | - public function import_csv_to_model_data_array( $path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE ) { |
|
191 | + public function import_csv_to_model_data_array($path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE) { |
|
192 | 192 | $multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file); |
193 | - if( ! $multi_dimensional_array ){ |
|
193 | + if ( ! $multi_dimensional_array) { |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | // gotta start somewhere |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | $ee_formatted_data = array(); |
200 | 200 | // array to store headers (column names) |
201 | 201 | $headers = array(); |
202 | - foreach($multi_dimensional_array as $data){ |
|
202 | + foreach ($multi_dimensional_array as $data) { |
|
203 | 203 | // if first cell is MODEL, then second cell is the MODEL name |
204 | - if ( $data[0] == 'MODEL' ) { |
|
204 | + if ($data[0] == 'MODEL') { |
|
205 | 205 | $model_name = $data[1]; |
206 | 206 | //don't bother looking for model data in this row. The rest of this |
207 | 207 | //row should be blank |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $headers = array(); |
212 | 212 | continue; |
213 | 213 | } |
214 | - if( strpos( $data[0], EE_CSV::metadata_header ) !==FALSE ){ |
|
214 | + if (strpos($data[0], EE_CSV::metadata_header) !== FALSE) { |
|
215 | 215 | $model_name = EE_CSV::metadata_header; |
216 | 216 | //store like model data, we just won't try importing it etc. |
217 | 217 | $row = 1; |
@@ -224,31 +224,31 @@ discard block |
||
224 | 224 | |
225 | 225 | $model_entry = array(); |
226 | 226 | // loop through each column |
227 | - for ( $i=0; $i < $columns; $i++ ) { |
|
227 | + for ($i = 0; $i < $columns; $i++) { |
|
228 | 228 | |
229 | 229 | //replace csv_enclosures with backslashed quotes |
230 | - $data[$i] = str_replace ( '"""', '\\"', $data[$i] ); |
|
230 | + $data[$i] = str_replace('"""', '\\"', $data[$i]); |
|
231 | 231 | // do we need to grab the column names? |
232 | - if ( $row === 1){ |
|
233 | - if( $first_row_is_headers ) { |
|
232 | + if ($row === 1) { |
|
233 | + if ($first_row_is_headers) { |
|
234 | 234 | // store the column names to use for keys |
235 | 235 | $column_name = $data[$i]; |
236 | 236 | //check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end... |
237 | - if(!$column_name){continue;} |
|
237 | + if ( ! $column_name) {continue; } |
|
238 | 238 | $matches = array(); |
239 | - if($model_name == EE_CSV::metadata_header){ |
|
239 | + if ($model_name == EE_CSV::metadata_header) { |
|
240 | 240 | $headers[$i] = $column_name; |
241 | - }else{ |
|
241 | + } else { |
|
242 | 242 | //now get the db table name from it (the part between square brackets) |
243 | - $success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches); |
|
244 | - if (!$success){ |
|
245 | - EE_Error::add_error( sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"),$column_name,implode(",",$data)), __FILE__, __FUNCTION__, __LINE__ ); |
|
243 | + $success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches); |
|
244 | + if ( ! $success) { |
|
245 | + EE_Error::add_error(sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"), $column_name, implode(",", $data)), __FILE__, __FUNCTION__, __LINE__); |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | $headers[$i] = $matches[2]; |
249 | 249 | } |
250 | 250 | |
251 | - }else{ |
|
251 | + } else { |
|
252 | 252 | // no column names means our final array will just use counters for keys |
253 | 253 | $model_entry[$headers[$i]] = $data[$i]; |
254 | 254 | $headers[$i] = $i; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | // and we need to store csv data |
257 | 257 | } else { |
258 | 258 | // this column isn' ta header, store it if there is a header for it |
259 | - if(isset($headers[$i])){ |
|
259 | + if (isset($headers[$i])) { |
|
260 | 260 | $model_entry[$headers[$i]] = $data[$i]; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | } |
265 | 265 | //save the row's data IF it's a non-header-row |
266 | - if( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)){ |
|
266 | + if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
267 | 267 | $ee_formatted_data[$model_name][] = $model_entry; |
268 | 268 | } |
269 | 269 | // advance to next row |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - public function save_csv_to_db( $csv_data_array, $model_name = FALSE ) { |
|
286 | - EE_Error::doing_it_wrong('save_csv_to_db', __( 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso' ), '4.6.7' ); |
|
287 | - return EE_Import::instance()->save_csv_data_array_to_db( $csv_data_array, $model_name ); |
|
285 | + public function save_csv_to_db($csv_data_array, $model_name = FALSE) { |
|
286 | + EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7'); |
|
287 | + return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * @param string $new_filename the name of the file that the user will download |
295 | 295 | * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc. |
296 | 296 | */ |
297 | - public function begin_sending_csv($filename){ |
|
297 | + public function begin_sending_csv($filename) { |
|
298 | 298 | // grab file extension |
299 | 299 | $ext = substr(strrchr($filename, '.'), 1); |
300 | - if ( $ext == '.csv' or $ext == '.xls' ) { |
|
301 | - str_replace( $ext, '', $filename ); |
|
300 | + if ($ext == '.csv' or $ext == '.xls') { |
|
301 | + str_replace($ext, '', $filename); |
|
302 | 302 | } |
303 | 303 | $filename .= '.csv'; |
304 | 304 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | // header("Content-Type: application/download"); |
320 | 320 | header('Content-disposition: attachment; filename='.$filename); |
321 | 321 | header("Content-Type: text/csv; charset=utf-8"); |
322 | - do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' ); |
|
323 | - echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
322 | + do_action('AHEE__EE_CSV__begin_sending_csv__headers'); |
|
323 | + echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF"); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
324 | 324 | $fh = fopen('php://output', 'w'); |
325 | 325 | return $fh; |
326 | 326 | } |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | * mentioning the version and timezone |
331 | 331 | * @param resource $filehandle |
332 | 332 | */ |
333 | - public function write_metadata_to_csv($filehandle){ |
|
334 | - $data_row = array(EE_CSV::metadata_header);//do NOT translate because this exact string is used when importing |
|
333 | + public function write_metadata_to_csv($filehandle) { |
|
334 | + $data_row = array(EE_CSV::metadata_header); //do NOT translate because this exact string is used when importing |
|
335 | 335 | $this->fputcsv2($filehandle, $data_row); |
336 | - $meta_data = array( 0=> array( |
|
336 | + $meta_data = array(0=> array( |
|
337 | 337 | 'version'=>espresso_version(), |
338 | 338 | 'timezone'=> EEH_DTT_Helper::get_timezone(), |
339 | 339 | 'time_of_export'=>current_time('mysql'), |
@@ -351,29 +351,29 @@ discard block |
||
351 | 351 | * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..." |
352 | 352 | * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing) |
353 | 353 | */ |
354 | - public function write_data_array_to_csv($filehandle, $data){ |
|
354 | + public function write_data_array_to_csv($filehandle, $data) { |
|
355 | 355 | |
356 | 356 | |
357 | 357 | //determine if $data is actually a 2d array |
358 | - if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){ |
|
358 | + if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { |
|
359 | 359 | //make sure top level is numerically indexed, |
360 | 360 | |
361 | - if( EEH_Array::is_associative_array($data)){ |
|
362 | - throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data)))); |
|
361 | + if (EEH_Array::is_associative_array($data)) { |
|
362 | + throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data)))); |
|
363 | 363 | } |
364 | 364 | $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); |
365 | 365 | //now, is the last item in the top-level array of $data an associative or numeric array? |
366 | - if(EEH_Array::is_associative_array($item_in_top_level_array)){ |
|
366 | + if (EEH_Array::is_associative_array($item_in_top_level_array)) { |
|
367 | 367 | //its associative, so we want to output its keys as column headers |
368 | 368 | $keys = array_keys($item_in_top_level_array); |
369 | 369 | echo $this->fputcsv2($filehandle, $keys); |
370 | 370 | } |
371 | 371 | //start writing data |
372 | - foreach($data as $data_row){ |
|
372 | + foreach ($data as $data_row) { |
|
373 | 373 | echo $this->fputcsv2($filehandle, $data_row); |
374 | 374 | } |
375 | 375 | return true; |
376 | - }else{ |
|
376 | + } else { |
|
377 | 377 | //no data TO write... so we can assume that's a success |
378 | 378 | return true; |
379 | 379 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * Calls exit to prevent polluting the CSV file with other junk |
419 | 419 | * @param resource $fh filehandle where we're writing the CSV to |
420 | 420 | */ |
421 | - public function end_sending_csv($fh){ |
|
421 | + public function end_sending_csv($fh) { |
|
422 | 422 | fclose($fh); |
423 | 423 | exit(0); |
424 | 424 | } |
@@ -431,23 +431,23 @@ discard block |
||
431 | 431 | * has all the attributes o fthat model object (eg, the event's id, name, etc) |
432 | 432 | * @return boolean success |
433 | 433 | */ |
434 | - public function write_model_data_to_csv($filehandle,$model_data_array){ |
|
434 | + public function write_model_data_to_csv($filehandle, $model_data_array) { |
|
435 | 435 | $this->write_metadata_to_csv($filehandle); |
436 | - foreach($model_data_array as $model_name => $model_instance_arrays){ |
|
436 | + foreach ($model_data_array as $model_name => $model_instance_arrays) { |
|
437 | 437 | //first: output a special row stating the model |
438 | - echo $this->fputcsv2($filehandle,array('MODEL',$model_name)); |
|
438 | + echo $this->fputcsv2($filehandle, array('MODEL', $model_name)); |
|
439 | 439 | //if we have items to put in the CSV, do it normally |
440 | 440 | |
441 | - if( ! empty($model_instance_arrays) ){ |
|
441 | + if ( ! empty($model_instance_arrays)) { |
|
442 | 442 | $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
443 | - }else{ |
|
443 | + } else { |
|
444 | 444 | // echo "no data to write... so just write the headers"; |
445 | 445 | //so there's actually NO model objects for that model. |
446 | 446 | //probably still want to show the columns |
447 | 447 | $model = EE_Registry::instance()->load_model($model_name); |
448 | 448 | $column_names = array(); |
449 | - foreach($model->field_settings() as $field){ |
|
450 | - $column_names[$field->get_nicename()."[".$field->get_name()."]"] = null ; |
|
449 | + foreach ($model->field_settings() as $field) { |
|
450 | + $column_names[$field->get_nicename()."[".$field->get_name()."]"] = null; |
|
451 | 451 | } |
452 | 452 | $this->write_data_array_to_csv($filehandle, array($column_names)); |
453 | 453 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv() |
462 | 462 | * @return bool | void writes CSV file to output and dies |
463 | 463 | */ |
464 | - public function export_multiple_model_data_to_csv($filename,$model_data_array){ |
|
464 | + public function export_multiple_model_data_to_csv($filename, $model_data_array) { |
|
465 | 465 | $filehandle = $this->begin_sending_csv($filename); |
466 | 466 | $this->write_model_data_to_csv($filehandle, $model_data_array); |
467 | 467 | $this->end_sending_csv($filehandle); |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | * @param string $filename - name for newly created csv file |
474 | 474 | * @return TRUE on success, FALSE on fail |
475 | 475 | */ |
476 | - public function export_array_to_csv( $data = FALSE, $filename = FALSE ) { |
|
476 | + public function export_array_to_csv($data = FALSE, $filename = FALSE) { |
|
477 | 477 | |
478 | 478 | // no data file?? get outta here |
479 | - if ( ! $data or ! is_array( $data ) or empty( $data ) ) { |
|
479 | + if ( ! $data or ! is_array($data) or empty($data)) { |
|
480 | 480 | return FALSE; |
481 | 481 | } |
482 | 482 | |
483 | 483 | // no filename?? get outta here |
484 | - if ( ! $filename ) { |
|
484 | + if ( ! $filename) { |
|
485 | 485 | return FALSE; |
486 | 486 | } |
487 | 487 | |
@@ -507,11 +507,11 @@ discard block |
||
507 | 507 | * @param int $percent_of_max - desired percentage of the max upload_mb |
508 | 508 | * @return int KB |
509 | 509 | */ |
510 | - public function get_max_upload_size ( $percent_of_max = FALSE ) { |
|
510 | + public function get_max_upload_size($percent_of_max = FALSE) { |
|
511 | 511 | |
512 | - $max_upload = (int)(ini_get('upload_max_filesize')); |
|
513 | - $max_post = (int)(ini_get('post_max_size')); |
|
514 | - $memory_limit = (int)(ini_get('memory_limit')); |
|
512 | + $max_upload = (int) (ini_get('upload_max_filesize')); |
|
513 | + $max_post = (int) (ini_get('post_max_size')); |
|
514 | + $memory_limit = (int) (ini_get('memory_limit')); |
|
515 | 515 | |
516 | 516 | // determine the smallest of the three values from above |
517 | 517 | $upload_mb = min($max_upload, $max_post, $memory_limit); |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | $upload_mb = $upload_mb * 1024; |
521 | 521 | |
522 | 522 | // don't want the full monty? then reduce the max uplaod size |
523 | - if ( $percent_of_max ) { |
|
523 | + if ($percent_of_max) { |
|
524 | 524 | // is percent_of_max like this -> 50 or like this -> 0.50 ? |
525 | - if ( $percent_of_max > 1 ) { |
|
525 | + if ($percent_of_max > 1) { |
|
526 | 526 | // chnages 50 to 0.50 |
527 | 527 | $percent_of_max = $percent_of_max / 100; |
528 | 528 | } |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | * @param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - private function fputcsv2 ($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) { |
|
547 | + private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) { |
|
548 | 548 | //Allow user to filter the csv delimiter and enclosure for other countries csv standards |
549 | - $delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter ); |
|
550 | - $enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure ); |
|
549 | + $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter); |
|
550 | + $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure); |
|
551 | 551 | |
552 | 552 | $delimiter_esc = preg_quote($delimiter, '/'); |
553 | 553 | $enclosure_esc = preg_quote($enclosure, '/'); |
554 | 554 | |
555 | 555 | $output = array(); |
556 | 556 | foreach ($row as $field_value) { |
557 | - if(is_object($field_value) || is_array($field_value)){ |
|
557 | + if (is_object($field_value) || is_array($field_value)) { |
|
558 | 558 | $field_value = serialize($field_value); |
559 | 559 | } |
560 | 560 | if ($field_value === null && $mysql_null) { |
@@ -563,10 +563,10 @@ discard block |
||
563 | 563 | } |
564 | 564 | |
565 | 565 | $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
566 | - ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value; |
|
566 | + ($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value; |
|
567 | 567 | } |
568 | 568 | |
569 | - fwrite($fh, join($delimiter, $output) . PHP_EOL); |
|
569 | + fwrite($fh, join($delimiter, $output).PHP_EOL); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * @param string $current_format |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function get_date_format_for_csv( $current_format = null ) { |
|
608 | - return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format ); |
|
607 | + public function get_date_format_for_csv($current_format = null) { |
|
608 | + return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | * @param string $current_format |
614 | 614 | * @return string |
615 | 615 | */ |
616 | - public function get_time_format_for_csv( $current_format = null ) { |
|
617 | - return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format ); |
|
616 | + public function get_time_format_for_csv($current_format = null) { |
|
617 | + return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 |
@@ -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 | } |
@@ -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) { |
@@ -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 | * Contains definition for EE_Event_Message_Template model object |
4 | 6 | * @package Event Espresso |
@@ -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 |
@@ -2,15 +2,15 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
4 | 4 | */ |
5 | -class EE_Event_Venue extends EE_Base_Class{ |
|
5 | +class EE_Event_Venue extends EE_Base_Class { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @param array $props_n_values |
9 | 9 | * @return EE_Event_Venue|mixed |
10 | 10 | */ |
11 | - public static function new_instance( $props_n_values = array() ) { |
|
12 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
13 | - return $has_object ? $has_object : new self( $props_n_values); |
|
11 | + public static function new_instance($props_n_values = array()) { |
|
12 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
13 | + return $has_object ? $has_object : new self($props_n_values); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | * @param array $props_n_values |
20 | 20 | * @return EE_Event_Venue |
21 | 21 | */ |
22 | - public static function new_instance_from_db ( $props_n_values = array() ) { |
|
23 | - return new self( $props_n_values, TRUE ); |
|
22 | + public static function new_instance_from_db($props_n_values = array()) { |
|
23 | + return new self($props_n_values, TRUE); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -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_Extra_Meta|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_Extra_Meta |
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 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return int |
53 | 53 | */ |
54 | 54 | function FK_ID() { |
55 | - return $this->get( 'FK_ID' ); |
|
55 | + return $this->get('FK_ID'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param int $FK_ID |
63 | 63 | * @return boolean |
64 | 64 | */ |
65 | - function set_FK_ID( $FK_ID ) { |
|
66 | - $this->set( 'FK_ID', $FK_ID ); |
|
65 | + function set_FK_ID($FK_ID) { |
|
66 | + $this->set('FK_ID', $FK_ID); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return string |
74 | 74 | */ |
75 | 75 | function model() { |
76 | - return $this->get( 'EXM_model' ); |
|
76 | + return $this->get('EXM_model'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param string $model |
84 | 84 | * @return boolean |
85 | 85 | */ |
86 | - function set_model( $model ) { |
|
87 | - $this->set( 'EXM_model', $model ); |
|
86 | + function set_model($model) { |
|
87 | + $this->set('EXM_model', $model); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return string |
95 | 95 | */ |
96 | 96 | function key() { |
97 | - return $this->get( 'EXM_key' ); |
|
97 | + return $this->get('EXM_key'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param string $key |
105 | 105 | * @return boolean |
106 | 106 | */ |
107 | - function set_key( $key ) { |
|
108 | - $this->set( 'EXM_key', $key ); |
|
107 | + function set_key($key) { |
|
108 | + $this->set('EXM_key', $key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return string |
116 | 116 | */ |
117 | 117 | function value() { |
118 | - return $this->get( 'EXM_value' ); |
|
118 | + return $this->get('EXM_value'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $value |
126 | 126 | * @return boolean |
127 | 127 | */ |
128 | - function set_value( $value ) { |
|
129 | - $this->set( 'EXM_value', $value ); |
|
128 | + function set_value($value) { |
|
129 | + $this->set('EXM_value', $value); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 |
@@ -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 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * @param string $timezone |
35 | 35 | * @return EE_Message_Template|mixed |
36 | 36 | */ |
37 | - public static function new_instance( $props_n_values = array(), $timezone = '' ) { |
|
38 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
39 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
37 | + public static function new_instance($props_n_values = array(), $timezone = '') { |
|
38 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
39 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param string $timezone |
47 | 47 | * @return EE_Message_Template |
48 | 48 | */ |
49 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) { |
|
50 | - return new self( $props_n_values, TRUE, $timezone ); |
|
49 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') { |
|
50 | + return new self($props_n_values, TRUE, $timezone); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @param bool $GRP_ID |
57 | 57 | * @throws EE_Error |
58 | 58 | */ |
59 | - public function set_group_template_id( $GRP_ID = FALSE ) { |
|
60 | - if ( ! $GRP_ID ) { |
|
61 | - throw new EE_Error( __( 'Missing required value for the message template group id', 'event_espresso' ) ); |
|
59 | + public function set_group_template_id($GRP_ID = FALSE) { |
|
60 | + if ( ! $GRP_ID) { |
|
61 | + throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
62 | 62 | } |
63 | - $this->set( 'GRP_ID', $GRP_ID ); |
|
63 | + $this->set('GRP_ID', $GRP_ID); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return int |
72 | 72 | */ |
73 | 73 | public function GRP_ID() { |
74 | - return $this->get( 'GRP_ID' ); |
|
74 | + return $this->get('GRP_ID'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return int |
83 | 83 | */ |
84 | 84 | public function user() { |
85 | - return $this->get_first_related( 'Message_Template_Group' )->get( 'MTP_user_id' ); |
|
85 | + return $this->get_first_related('Message_Template_Group')->get('MTP_user_id'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return string |
94 | 94 | */ |
95 | 95 | public function messenger() { |
96 | - return $this->get_first_related( 'Message_Template_Group' )->messenger(); |
|
96 | + return $this->get_first_related('Message_Template_Group')->messenger(); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return object Messenger Object for the given messenger |
106 | 106 | */ |
107 | 107 | public function messenger_obj() { |
108 | - return $this->get_first_related( 'Message_Template_Group' )->messenger_obj(); |
|
108 | + return $this->get_first_related('Message_Template_Group')->messenger_obj(); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return string |
118 | 118 | */ |
119 | 119 | public function message_type() { |
120 | - return $this->get_first_related( 'Message_Template_Group' )->message_type(); |
|
120 | + return $this->get_first_related('Message_Template_Group')->message_type(); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return object Message Type object for the given message type |
130 | 130 | */ |
131 | 131 | public function message_type_obj() { |
132 | - return $this->get_first_related( 'Message_Template_Group' )->message_type_obj(); |
|
132 | + return $this->get_first_related('Message_Template_Group')->message_type_obj(); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return array array of contexts and their configuration. |
142 | 142 | */ |
143 | 143 | public function contexts_config() { |
144 | - return $this->get_first_related( 'Message_Template_Group' )->contexts_config(); |
|
144 | + return $this->get_first_related('Message_Template_Group')->contexts_config(); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return string label for "context" |
154 | 154 | */ |
155 | 155 | public function context_label() { |
156 | - return $this->get_first_related( 'Message_Template_Group' )->context_label(); |
|
156 | + return $this->get_first_related('Message_Template_Group')->context_label(); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return boolean true if it is, false if it isn't |
164 | 164 | */ |
165 | 165 | public function is_global() { |
166 | - return $this->get_first_related( 'Message_Template_Group' )->is_global(); |
|
166 | + return $this->get_first_related('Message_Template_Group')->is_global(); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return boolean true if it is, false if it isn't |
174 | 174 | */ |
175 | 175 | public function is_active() { |
176 | - return $this->get_first_related( 'Message_Template_Group' )->is_active(); |
|
176 | + return $this->get_first_related('Message_Template_Group')->is_active(); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are to be merged and returned. |
187 | 187 | * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no shortcodes found. |
188 | 188 | */ |
189 | - public function get_shortcodes( $context, $fields = array() ) { |
|
190 | - return $this->get_first_related( 'Message_Template_Group' )->get_shortcodes( $context, $fields ); |
|
189 | + public function get_shortcodes($context, $fields = array()) { |
|
190 | + return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields); |
|
191 | 191 | } |
192 | 192 | } |