Completed
Branch TASK-10272-slack-badge (91344b)
by
unknown
165:51 queued 150:46
created
data_migration_scripts/4_8_0_stages/EE_DMS_4_8_0_pretax_totals.dmsstage.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  *
14 14
  * Migrates line items that used to have LIN_code="tickets" to "pre-tax-total"
15 15
  */
16
-class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage{
16
+class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage {
17 17
 
18 18
 	protected $_line_item_table_name;
19 19
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 		global $wpdb;
54 54
 		$rows_updated = $wpdb->update(
55 55
 				$this->_line_item_table_name,
56
-				array( 'LIN_code' => 'pre-tax-subtotal' ),
57
-				array( 'LIN_code' => 'tickets' ),
58
-				array( '%s' ),
59
-				array( '%s' ) );
56
+				array('LIN_code' => 'pre-tax-subtotal'),
57
+				array('LIN_code' => 'tickets'),
58
+				array('%s'),
59
+				array('%s') );
60 60
 		$this->set_completed();
61 61
 		return 1;
62 62
 	}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage_Table.core.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/db_classes/EE_Answer.class.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/db_classes/EE_CSV.class.php 3 patches
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/db_classes/EE_Change_Log.class.php 2 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -152,7 +153,7 @@  discard block
 block discarded – undo
152 153
 		$is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
153 154
 		if( ! $is_model_name ){
154 155
 			return null;
155
-		}else{
156
+		} else{
156 157
 			return $this->get_first_related($model_name_of_related_obj);
157 158
 		}
158 159
 	}
@@ -169,13 +170,13 @@  discard block
 block discarded – undo
169 170
 		if($object instanceof EE_Base_Class){
170 171
 			$this->set_OBJ_type($object->get_model()->get_this_model_name());
171 172
 			$this->set_OBJ_ID($object->ID());
172
-		}else{
173
+		} else{
173 174
 			$this->set_OBJ_type(NULL);
174 175
 			$this->set_OBJ_ID(NULL);
175 176
 		}
176 177
 		if($save){
177 178
 			return $this->save();
178
-		}else{
179
+		} else{
179 180
 			return NULL;
180 181
 		}
181 182
 	}
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_Change_Log extends EE_Base_Class{
28
+class EE_Change_Log extends EE_Base_Class {
29 29
 
30 30
 	/**
31 31
 	 *
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *                             		    date_format and the second value is the time format
37 37
 	 * @return EE_Attendee
38 38
 	 */
39
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
40
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
41
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
39
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
40
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
41
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
42 42
 	}
43 43
 
44 44
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 *                          		the website will be used.
50 50
 	 * @return EE_Attendee
51 51
 	 */
52
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
53
-		return new self( $props_n_values, TRUE, $timezone );
52
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
53
+		return new self($props_n_values, TRUE, $timezone);
54 54
 	}
55 55
 	/**
56 56
 	 * Gets message
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 * Gets the model object attached to this log
148 148
 	 * @return EE_Base_Class
149 149
 	 */
150
-	function object(){
150
+	function object() {
151 151
 		$model_name_of_related_obj = $this->OBJ_type();
152 152
 		$is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
153
-		if( ! $is_model_name ){
153
+		if ( ! $is_model_name) {
154 154
 			return null;
155
-		}else{
155
+		} else {
156 156
 			return $this->get_first_related($model_name_of_related_obj);
157 157
 		}
158 158
 	}
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 	 * @param boolean $save
166 166
 	 * @return boolean if $save=true, NULL is $save=false
167 167
 	 */
168
-	function set_object($object, $save = TRUE ) {
169
-		if($object instanceof EE_Base_Class){
168
+	function set_object($object, $save = TRUE) {
169
+		if ($object instanceof EE_Base_Class) {
170 170
 			$this->set_OBJ_type($object->get_model()->get_this_model_name());
171 171
 			$this->set_OBJ_ID($object->ID());
172
-		}else{
172
+		} else {
173 173
 			$this->set_OBJ_type(NULL);
174 174
 			$this->set_OBJ_ID(NULL);
175 175
 		}
176
-		if($save){
176
+		if ($save) {
177 177
 			return $this->save();
178
-		}else{
178
+		} else {
179 179
 			return NULL;
180 180
 		}
181 181
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Checkin.class.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
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
 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
3 5
 /**
4 6
  * Event Espresso
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * Event Espresso
5 5
  *
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @subpackage		includes/classes/EE_Checkin.class.php
24 24
  * @author				Darren Ethier
25 25
  */
26
-class EE_Checkin extends EE_Base_Class{
26
+class EE_Checkin extends EE_Base_Class {
27 27
 
28 28
 	/**
29 29
 	 *
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	 *                             		    date_format and the second value is the time format
35 35
 	 * @return EE_Checkin
36 36
 	 */
37
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
38
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
39
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
37
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
38
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
39
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
40 40
 	}
41 41
 
42 42
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 *                          		the website will be used.
48 48
 	 * @return EE_Checkin
49 49
 	 */
50
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
51
-		return new self( $props_n_values, TRUE, $timezone );
50
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
51
+		return new self($props_n_values, TRUE, $timezone);
52 52
 	}
53 53
 
54 54
 
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime.class.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -708,12 +708,10 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -456,14 +456,14 @@
 block discarded – undo
456 456
 			//start and end date are the same but times are different
457 457
 			case ( $this->start_date() === $this->end_date() ) :
458 458
 				$output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format )
459
-				          . $conjunction
460
-				          . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format );
459
+						  . $conjunction
460
+						  . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format );
461 461
 				break;
462 462
 			//all other conditions
463 463
 			default :
464 464
 				$output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format )
465
-				          . $conjunction
466
-				          . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format );
465
+						  . $conjunction
466
+						  . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format );
467 467
 				break;
468 468
 		}
469 469
 		return $output;
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
214 214
 
215 215
 
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	 * decrements (subtracts) sold amount passed by $qty
219 219
 	 * @param int $qty
220 220
 	 */
221
-	public function decrease_sold( $qty = 1 ) {
221
+	public function decrease_sold($qty = 1) {
222 222
 		$sold = $this->sold() - $qty;
223
-		$this->set_sold( $sold );
223
+		$this->set_sold($sold);
224 224
 	}
225 225
 
226 226
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 * @return int
232 232
 	 */
233 233
 	function reserved() {
234
-		return $this->get_raw( 'DTT_reserved' );
234
+		return $this->get_raw('DTT_reserved');
235 235
 	}
236 236
 
237 237
 
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	 * @param int $reserved
243 243
 	 * @return boolean
244 244
 	 */
245
-	function set_reserved( $reserved ) {
245
+	function set_reserved($reserved) {
246 246
 		// reserved can not go below zero
247
-		$reserved = max( 0, intval( $reserved ) );
248
-		$this->set( 'DTT_reserved', $reserved );
247
+		$reserved = max(0, intval($reserved));
248
+		$this->set('DTT_reserved', $reserved);
249 249
 	}
250 250
 
251 251
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	 * @param int $qty
257 257
 	 * @return boolean
258 258
 	 */
259
-	function increase_reserved( $qty = 1 ) {
260
-		$reserved = $this->reserved() + absint( $qty );
261
-		return $this->set_reserved( $reserved );
259
+	function increase_reserved($qty = 1) {
260
+		$reserved = $this->reserved() + absint($qty);
261
+		return $this->set_reserved($reserved);
262 262
 	}
263 263
 
264 264
 
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 	 * @param int $qty
270 270
 	 * @return boolean
271 271
 	 */
272
-	function decrease_reserved( $qty = 1 ) {
273
-		$reserved = $this->reserved() - absint( $qty );
274
-		return $this->set_reserved( $reserved );
272
+	function decrease_reserved($qty = 1) {
273
+		$reserved = $this->reserved() - absint($qty);
274
+		return $this->set_reserved($reserved);
275 275
 	}
276 276
 
277 277
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return string
293 293
 	 */
294 294
 	public function name() {
295
-		return $this->get( 'DTT_name' );
295
+		return $this->get('DTT_name');
296 296
 	}
297 297
 
298 298
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @return string
303 303
 	 */
304 304
 	public function description() {
305
-		return $this->get( 'DTT_description' );
305
+		return $this->get('DTT_description');
306 306
 	}
307 307
 
308 308
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @return boolean          TRUE if is primary, FALSE if not.
313 313
 	 */
314 314
 	public function is_primary() {
315
-		return $this->get( 'DTT_is_primary' );
315
+		return $this->get('DTT_is_primary');
316 316
 	}
317 317
 
318 318
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return int         The order of the datetime for this event.
323 323
 	 */
324 324
 	public function order() {
325
-		return $this->get( 'DTT_order' );
325
+		return $this->get('DTT_order');
326 326
 	}
327 327
 
328 328
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @return int
333 333
 	 */
334 334
 	public function parent() {
335
-		return $this->get( 'DTT_parent' );
335
+		return $this->get('DTT_parent');
336 336
 	}
337 337
 
338 338
 
@@ -348,10 +348,10 @@  discard block
 block discarded – undo
348 348
 	 * @param    bool   $echo         - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats)
349 349
 	 * @return    string|bool|void  string on success, FALSE on fail
350 350
 	 */
351
-	private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) {
351
+	private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) {
352 352
 		$field_name = "DTT_EVT_{$start_or_end}";
353
-		$dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo );
354
-		if ( ! $echo ) {
353
+		$dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo);
354
+		if ( ! $echo) {
355 355
 			return $dtt;
356 356
 		}
357 357
 		return '';
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
367 367
 	 * @return        mixed        string on success, FALSE on fail
368 368
 	 */
369
-	public function start_date( $dt_frmt = NULL ) {
370
-		return $this->_show_datetime( 'D', 'start', $dt_frmt );
369
+	public function start_date($dt_frmt = NULL) {
370
+		return $this->_show_datetime('D', 'start', $dt_frmt);
371 371
 	}
372 372
 
373 373
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * Echoes start_date()
377 377
 	 * @param string $dt_frmt
378 378
 	 */
379
-	public function e_start_date( $dt_frmt = NULL ) {
380
-		$this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE );
379
+	public function e_start_date($dt_frmt = NULL) {
380
+		$this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE);
381 381
 	}
382 382
 
383 383
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	 * @param null $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 end_date( $dt_frmt = NULL ) {
393
-		return $this->_show_datetime( 'D', 'end', $dt_frmt );
392
+	public function end_date($dt_frmt = NULL) {
393
+		return $this->_show_datetime('D', 'end', $dt_frmt);
394 394
 	}
395 395
 
396 396
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	 * Echoes the end date. See end_date()
400 400
 	 * @param string $dt_frmt
401 401
 	 */
402
-	public function e_end_date( $dt_frmt = NULL ) {
403
-		$this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE );
402
+	public function e_end_date($dt_frmt = NULL) {
403
+		$this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE);
404 404
 	}
405 405
 
406 406
 
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
 	 * @return mixed        string on success, FALSE on fail
416 416
 	 * @throws \EE_Error
417 417
 	 */
418
-	public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
419
-		$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt;
420
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) );
421
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) );
422
-		return $start !== $end ? $start . $conjunction . $end : $start;
418
+	public function date_range($dt_frmt = NULL, $conjunction = ' - ') {
419
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
420
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt));
421
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt));
422
+		return $start !== $end ? $start.$conjunction.$end : $start;
423 423
 	}
424 424
 
425 425
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param string $conjunction
430 430
 	 * @throws \EE_Error
431 431
 	 */
432
-	public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
433
-		echo $this->date_range( $dt_frmt, $conjunction );
432
+	public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') {
433
+		echo $this->date_range($dt_frmt, $conjunction);
434 434
 	}
435 435
 
436 436
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
442 442
 	 * @return        mixed        string on success, FALSE on fail
443 443
 	 */
444
-	public function start_time( $tm_format = NULL ) {
445
-		return $this->_show_datetime( 'T', 'start', NULL, $tm_format );
444
+	public function start_time($tm_format = NULL) {
445
+		return $this->_show_datetime('T', 'start', NULL, $tm_format);
446 446
 	}
447 447
 
448 448
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 	/**
451 451
 	 * @param null $tm_format
452 452
 	 */
453
-	public function e_start_time( $tm_format = NULL ) {
454
-		$this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE );
453
+	public function e_start_time($tm_format = NULL) {
454
+		$this->_show_datetime('T', 'start', NULL, $tm_format, TRUE);
455 455
 	}
456 456
 
457 457
 
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
463 463
 	 * @return        mixed        string on success, FALSE on fail
464 464
 	 */
465
-	public function end_time( $tm_format = NULL ) {
466
-		return $this->_show_datetime( 'T', 'end', NULL, $tm_format );
465
+	public function end_time($tm_format = NULL) {
466
+		return $this->_show_datetime('T', 'end', NULL, $tm_format);
467 467
 	}
468 468
 
469 469
 
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	/**
472 472
 	 * @param null $tm_format
473 473
 	 */
474
-	public function e_end_time( $tm_format = NULL ) {
475
-		$this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE );
474
+	public function e_end_time($tm_format = NULL) {
475
+		$this->_show_datetime('T', 'end', NULL, $tm_format, TRUE);
476 476
 	}
477 477
 
478 478
 
@@ -487,11 +487,11 @@  discard block
 block discarded – undo
487 487
 	 * @return mixed              string on success, FALSE on fail
488 488
 	 * @throws \EE_Error
489 489
 	 */
490
-	public function time_range( $tm_format = null, $conjunction = ' - ' ) {
491
-		$tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
492
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) );
493
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end',  $tm_format ) );
494
-		return $start !== $end ? $start . $conjunction . $end : $start;
490
+	public function time_range($tm_format = null, $conjunction = ' - ') {
491
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
492
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $tm_format));
493
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $tm_format));
494
+		return $start !== $end ? $start.$conjunction.$end : $start;
495 495
 	}
496 496
 
497 497
 
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param string $conjunction
502 502
 	 * @throws \EE_Error
503 503
 	 */
504
-	public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) {
505
-		echo $this->time_range( $tm_format, $conjunction );
504
+	public function e_time_range($tm_format = NULL, $conjunction = ' - ') {
505
+		echo $this->time_range($tm_format, $conjunction);
506 506
 	}
507 507
 
508 508
 
@@ -518,28 +518,28 @@  discard block
 block discarded – undo
518 518
 	 * @return string
519 519
 	 * @throws \EE_Error
520 520
 	 */
521
-	public function date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - '  ) {
522
-		$dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt;
523
-		$tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
524
-		$full_format = $dt_format . ' ' . $tm_format;
521
+	public function date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') {
522
+		$dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
523
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
524
+		$full_format = $dt_format.' '.$tm_format;
525 525
 
526 526
 		//the range output depends on various conditions
527
-		switch ( true ) {
527
+		switch (true) {
528 528
 			//start date timestamp and end date timestamp are the same.
529
-			case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) :
530
-				$output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format );
529
+			case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) :
530
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format);
531 531
 				break;
532 532
 			//start and end date are the same but times are different
533
-			case ( $this->start_date() === $this->end_date() ) :
534
-				$output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format )
533
+			case ($this->start_date() === $this->end_date()) :
534
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
535 535
 				          . $conjunction
536
-				          . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format );
536
+				          . $this->get_i18n_datetime('DTT_EVT_end', $tm_format);
537 537
 				break;
538 538
 			//all other conditions
539 539
 			default :
540
-				$output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format )
540
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
541 541
 				          . $conjunction
542
-				          . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format );
542
+				          . $this->get_i18n_datetime('DTT_EVT_end', $full_format);
543 543
 				break;
544 544
 		}
545 545
 		return $output;
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 	 * @return void
558 558
 	 * @throws \EE_Error
559 559
 	 */
560
-	public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) {
561
-		echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction );
560
+	public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') {
561
+		echo $this->date_and_time_range($dt_format, $tm_format, $conjunction);
562 562
 	}
563 563
 
564 564
 
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 * @param 	string 	$tm_format - string representation of time format defaults to 'g:i a'
571 571
 	 * @return 	mixed 	string on success, FALSE on fail
572 572
 	 */
573
-	public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) {
574
-		return $this->_show_datetime( '', 'start', $dt_format, $tm_format );
573
+	public function start_date_and_time($dt_format = NULL, $tm_format = NULL) {
574
+		return $this->_show_datetime('', 'start', $dt_format, $tm_format);
575 575
 	}
576 576
 
577 577
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @param null $dt_frmt
581 581
 	 * @param null $tm_format
582 582
 	 */
583
-	public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) {
584
-		$this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE );
583
+	public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) {
584
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE);
585 585
 	}
586 586
 
587 587
 
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 	 * @param bool   $round_up
596 596
 	 * @return float|int|mixed
597 597
 	 */
598
-	public function length( $units = 'seconds', $round_up = FALSE ) {
599
-		$start = $this->get_raw( 'DTT_EVT_start' );
600
-		$end = $this->get_raw( 'DTT_EVT_end' );
598
+	public function length($units = 'seconds', $round_up = FALSE) {
599
+		$start = $this->get_raw('DTT_EVT_start');
600
+		$end = $this->get_raw('DTT_EVT_end');
601 601
 		$length_in_units = $end - $start;
602
-		switch ( $units ) {
602
+		switch ($units) {
603 603
 			//NOTE: We purposefully don't use "break;" in order to chain the divisions
604 604
 			/** @noinspection PhpMissingBreakStatementInspection */
605 605
 			case 'days':
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
 				$length_in_units /= 60;
613 613
 			case 'seconds':
614 614
 			default:
615
-				$length_in_units = ceil( $length_in_units );
615
+				$length_in_units = ceil($length_in_units);
616 616
 		}
617
-		if ( $round_up ) {
618
-			$length_in_units = max( $length_in_units, 1 );
617
+		if ($round_up) {
618
+			$length_in_units = max($length_in_units, 1);
619 619
 		}
620 620
 		return $length_in_units;
621 621
 	}
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param bool | string 	$tm_format - string representation of time format defaults to 'g:i a'
630 630
 	 * @return 	mixed        		string on success, FALSE on fail
631 631
 	 */
632
-	public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
633
-		return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format );
632
+	public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
633
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
634 634
 	}
635 635
 
636 636
 
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 * @param bool $dt_frmt
640 640
 	 * @param bool $tm_format
641 641
 	 */
642
-	public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
643
-		$this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE );
642
+	public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
643
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE);
644 644
 	}
645 645
 
646 646
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	 * @return        int
652 652
 	 */
653 653
 	public function start() {
654
-		return $this->get_raw( 'DTT_EVT_start' );
654
+		return $this->get_raw('DTT_EVT_start');
655 655
 	}
656 656
 
657 657
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 * @return        int
663 663
 	 */
664 664
 	public function end() {
665
-		return $this->get_raw( 'DTT_EVT_end' );
665
+		return $this->get_raw('DTT_EVT_end');
666 666
 	}
667 667
 
668 668
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 * @return        mixed        int on success, FALSE on fail
674 674
 	 */
675 675
 	public function reg_limit() {
676
-		return $this->get_raw( 'DTT_reg_limit' );
676
+		return $this->get_raw('DTT_reg_limit');
677 677
 	}
678 678
 
679 679
 
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
 	 * 																	the spaces remaining for this particular datetime, hence the flag.
702 702
 	 * @return 	int
703 703
 	 */
704
-	public function spaces_remaining( $consider_tickets = FALSE ) {
704
+	public function spaces_remaining($consider_tickets = FALSE) {
705 705
 		// tickets remaining available for purchase
706 706
 		//no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
707 707
 		$dtt_remaining = $this->reg_limit() - $this->sold();
708
-		if ( ! $consider_tickets ) {
708
+		if ( ! $consider_tickets) {
709 709
 			return $dtt_remaining;
710 710
 		}
711 711
 		$tickets_remaining = $this->tickets_remaining();
712
-		return min( $dtt_remaining, $tickets_remaining );
712
+		return min($dtt_remaining, $tickets_remaining);
713 713
 	}
714 714
 
715 715
 
@@ -720,19 +720,19 @@  discard block
 block discarded – undo
720 720
 	 * @param array $query_params like EEM_Base::get_all's
721 721
 	 * @return int
722 722
 	 */
723
-	public function tickets_remaining( $query_params = array() ) {
723
+	public function tickets_remaining($query_params = array()) {
724 724
 		$sum = 0;
725
-		$tickets = $this->tickets( $query_params );
726
-		if ( ! empty( $tickets ) ) {
727
-			foreach ( $tickets as $ticket ) {
728
-				if ( $ticket instanceof EE_Ticket ) {
725
+		$tickets = $this->tickets($query_params);
726
+		if ( ! empty($tickets)) {
727
+			foreach ($tickets as $ticket) {
728
+				if ($ticket instanceof EE_Ticket) {
729 729
 					// get the actual amount of tickets that can be sold
730
-					$qty = $ticket->qty( 'saleable' );
731
-					if ( $qty === EE_INF ) {
730
+					$qty = $ticket->qty('saleable');
731
+					if ($qty === EE_INF) {
732 732
 						return EE_INF;
733 733
 					}
734 734
 					// no negative ticket quantities plz
735
-					if ( $qty > 0 ) {
735
+					if ($qty > 0) {
736 736
 						$sum += $qty;
737 737
 					}
738 738
 				}
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 	 * @param array $query_params like EEM_Base::get_all's
750 750
 	 * @return int
751 751
 	 */
752
-	public function sum_tickets_initially_available( $query_params = array() ) {
753
-		return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' );
752
+	public function sum_tickets_initially_available($query_params = array()) {
753
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
754 754
 	}
755 755
 
756 756
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 	 * @return int
763 763
 	 */
764 764
 	public function total_tickets_available_at_this_datetime() {
765
-		return $this->spaces_remaining( true );
765
+		return $this->spaces_remaining(true);
766 766
 	}
767 767
 
768 768
 
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 	 * @return boolean
774 774
 	 */
775 775
 	public function is_upcoming() {
776
-		return ( $this->get_raw( 'DTT_EVT_start' ) > time() );
776
+		return ($this->get_raw('DTT_EVT_start') > time());
777 777
 	}
778 778
 
779 779
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @return boolean
784 784
 	 */
785 785
 	public function is_active() {
786
-		return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() );
786
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
787 787
 	}
788 788
 
789 789
 
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	 * @return boolean
794 794
 	 */
795 795
 	public function is_expired() {
796
-		return ( $this->get_raw( 'DTT_EVT_end' ) < time() );
796
+		return ($this->get_raw('DTT_EVT_end') < time());
797 797
 	}
798 798
 
799 799
 
@@ -804,16 +804,16 @@  discard block
 block discarded – undo
804 804
 	 */
805 805
 	public function get_active_status() {
806 806
 		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
807
-		if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) {
807
+		if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) {
808 808
 			return EE_Datetime::sold_out;
809 809
 		}
810
-		if ( $this->is_expired() ) {
810
+		if ($this->is_expired()) {
811 811
 			return EE_Datetime::expired;
812 812
 		}
813
-		if ( $this->is_upcoming() ) {
813
+		if ($this->is_upcoming()) {
814 814
 			return EE_Datetime::upcoming;
815 815
 		}
816
-		if ( $this->is_active() ) {
816
+		if ($this->is_active()) {
817 817
 			return EE_Datetime::active;
818 818
 		}
819 819
 		return NULL;
@@ -827,24 +827,24 @@  discard block
 block discarded – undo
827 827
 	 * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
828 828
 	 * @return string
829 829
 	 */
830
-	public function get_dtt_display_name( $use_dtt_name = FALSE ) {
831
-		if ( $use_dtt_name ) {
830
+	public function get_dtt_display_name($use_dtt_name = FALSE) {
831
+		if ($use_dtt_name) {
832 832
 			$dtt_name = $this->name();
833
-			if ( !empty( $dtt_name ) ) {
833
+			if ( ! empty($dtt_name)) {
834 834
 				return $dtt_name;
835 835
 			}
836 836
 		}
837 837
 		//first condition is to see if the months are different
838
-		if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) {
839
-			$display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' );
838
+		if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) {
839
+			$display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
840 840
 			//next condition is if its the same month but different day
841 841
 		}
842 842
 		else {
843
-			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' ) ) ) {
844
-				$display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' );
843
+			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'))) {
844
+				$display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
845 845
 			}
846 846
 			else {
847
-				$display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' );
847
+				$display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a');
848 848
 			}
849 849
 		}
850 850
 		return $display_date;
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 *@param array $query_params see EEM_Base::get_all()
859 859
 	 * @return EE_Ticket[]
860 860
 	 */
861
-	public function tickets( $query_params = array() ) {
862
-		return $this->get_many_related( 'Ticket', $query_params );
861
+	public function tickets($query_params = array()) {
862
+		return $this->get_many_related('Ticket', $query_params);
863 863
 	}
864 864
 
865 865
 
@@ -869,21 +869,21 @@  discard block
 block discarded – undo
869 869
 	 * @param array $query_params like EEM_Base::get_all's
870 870
 	 * @return EE_Ticket[]
871 871
 	 */
872
-	public function ticket_types_available_for_purchase( $query_params = array() ) {
872
+	public function ticket_types_available_for_purchase($query_params = array()) {
873 873
 		// first check if datetime is valid
874
-		if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) {
874
+		if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) {
875 875
 			return array();
876 876
 		}
877
-		if ( empty( $query_params ) ) {
877
+		if (empty($query_params)) {
878 878
 			$query_params = array(
879 879
 				array(
880
-					'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ),
881
-					'TKT_end_date'   => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ),
880
+					'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')),
881
+					'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
882 882
 					'TKT_deleted'    => false
883 883
 				)
884 884
 			);
885 885
 		}
886
-		return $this->tickets( $query_params );
886
+		return $this->tickets($query_params);
887 887
 	}
888 888
 
889 889
 
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 	 * @return EE_Event
894 894
 	 */
895 895
 	public function event() {
896
-		return $this->get_first_related( 'Event' );
896
+		return $this->get_first_related('Event');
897 897
 	}
898 898
 
899 899
 
@@ -905,13 +905,13 @@  discard block
 block discarded – undo
905 905
 	 */
906 906
 	public function update_sold() {
907 907
 		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
908
-			array( array(
908
+			array(array(
909 909
 				'STS_ID' 					=> EEM_Registration::status_id_approved,
910 910
 				'REG_deleted' 				=> 0,
911 911
 				'Ticket.Datetime.DTT_ID' 	=> $this->ID(),
912
-			) )
912
+			))
913 913
 		);
914
-		$this->set( 'DTT_sold', $count_regs_for_this_datetime );
914
+		$this->set('DTT_sold', $count_regs_for_this_datetime);
915 915
 		$this->save();
916 916
 		return $count_regs_for_this_datetime;
917 917
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Message_Template.class.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Question_Group.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.