Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
560:12 queued 545:24
created
core/db_models/fields/EE_Serialized_Text_Field.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * However, when inserting into the DB, it should be serialized.
8 8
  * Upon retrieval from the DB, it should be unserialized back into an array.
9 9
  */
10
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
11
-class EE_Serialized_Text_Field extends EE_Text_Field_Base{
10
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
11
+class EE_Serialized_Text_Field extends EE_Text_Field_Base {
12 12
 	/**
13 13
 	 * Value SHOULD be an array, and we want to now convert it to a serialized string
14 14
 	 * @param array $value_of_field_on_model_object
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		return maybe_serialize($value_of_field_on_model_object);
19 19
 	}
20 20
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
21
-		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize( $value_inputted_for_field_on_model_object );
22
-		if(is_string($value_inputted_for_field_on_model_object)){
21
+		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object);
22
+		if (is_string($value_inputted_for_field_on_model_object)) {
23 23
 			return parent::prepare_for_set($value_inputted_for_field_on_model_object);
24
-		}elseif(is_array($value_inputted_for_field_on_model_object)){
25
-			return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object);
26
-		}else{//so they passed NULL or an INT or something wack
24
+		}elseif (is_array($value_inputted_for_field_on_model_object)) {
25
+			return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object);
26
+		} else {//so they passed NULL or an INT or something wack
27 27
 			return $value_inputted_for_field_on_model_object;
28 28
 		}
29 29
 	}
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @return array
34 34
 	 */
35 35
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
36
-		return EEH_Array::maybe_unserialize( $value_found_in_db_for_model_object );
36
+		return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object);
37 37
 	}
38 38
 
39 39
 	/**
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 * @return string
44 44
 	 */
45 45
 	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
46
-		switch($schema){
46
+		switch ($schema) {
47 47
 			case 'print_r':
48
-				$pretty_value = print_r($value_on_field_to_be_outputted,true);
48
+				$pretty_value = print_r($value_on_field_to_be_outputted, true);
49 49
 				break;
50 50
 			case 'as_table':
51 51
 				$pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted);
52 52
 				break;
53 53
 			default:
54
-				$pretty_value = implode(", ",$value_on_field_to_be_outputted);
54
+				$pretty_value = implode(", ", $value_on_field_to_be_outputted);
55 55
 		}
56 56
 		return $pretty_value;
57 57
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Payment.model.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * Payment Model
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @author				Michael Nelson, Brent Christensen
10 10
  *
11 11
  */
12
-class EEM_Payment extends EEM_Base implements EEMI_Payment{
12
+class EEM_Payment extends EEM_Base implements EEMI_Payment {
13 13
 
14 14
   	// private instance of the Payment object
15 15
 	protected static $_instance = NULL;
@@ -57,28 +57,28 @@  discard block
 block discarded – undo
57 57
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
58 58
 	 *		@return EEM_Payment
59 59
 	 */
60
-	protected function __construct( $timezone ) {
60
+	protected function __construct($timezone) {
61 61
 
62
-		$this->singular_item = __('Payment','event_espresso');
63
-		$this->plural_item = __('Payments','event_espresso');
62
+		$this->singular_item = __('Payment', 'event_espresso');
63
+		$this->plural_item = __('Payments', 'event_espresso');
64 64
 
65 65
 		$this->_tables = array(
66
-			'Payment'=>new EE_Primary_Table('esp_payment','PAY_ID')
66
+			'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID')
67 67
 		);
68 68
 		$this->_fields = array(
69 69
 			'Payment'=>array(
70
-				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID','event_espresso')),
71
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
72
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
73
-				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted','event_espresso'), false, time(), $timezone ),
74
-				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment','event_espresso'), false, 'CART'),
75
-				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for','event_espresso'), false, 0),
70
+				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')),
71
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
72
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
73
+				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, time(), $timezone),
74
+				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'),
75
+				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0),
76 76
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, NULL, 'Payment_Method'),
77
-				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment','event_espresso'), false, ''),
78
-				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number','event_espresso'), true, ''),
79
-				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number','event_espresso'), true, ''),
80
-				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info','event_espresso'), true, ''),
81
-				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment','event_espresso'), true, ''),
77
+				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''),
78
+				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''),
79
+				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''),
80
+				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''),
81
+				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''),
82 82
 				'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true),
83 83
 				'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)
84 84
 			)
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 			'Status'=> new EE_Belongs_To_Relation(),
89 89
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
90 90
 			'Registration_Payment' => new EE_Has_Many_Relation(),
91
-			'Registration' => new EE_HABTM_Relation( 'Registration_Payment' ),
91
+			'Registration' => new EE_HABTM_Relation('Registration_Payment'),
92 92
 		);
93 93
 		$this->_model_chain_to_wp_user = 'Payment_Method';
94 94
 		$this->_caps_slug = 'transactions';
95
-		parent::__construct( $timezone );
95
+		parent::__construct($timezone);
96 96
 	}
97 97
 
98 98
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $PAY_txn_id_chq_nmbr
105 105
 	 * @return EE_Payment
106 106
 	 */
107
-	public function get_payment_by_txn_id_chq_nmbr( $PAY_txn_id_chq_nmbr ){
107
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) {
108 108
 		return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr)));
109 109
 	}
110 110
 
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 	 *		@param	string	$status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status
121 121
 	*		@return		EE_Payment[]
122 122
 	*/
123
-	public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) {
123
+	public function get_payments_for_transaction($TXN_ID = FALSE, $status_of_payment = null) {
124 124
 		// all payments for a TXN ordered chronologically
125
-		$query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
125
+		$query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC'));
126 126
 		// if provided with a status, search specifically for that status. Otherwise get them all
127
-		if ( $status_of_payment ){
127
+		if ($status_of_payment) {
128 128
 			$query_params[0]['STS_ID'] = $status_of_payment;
129 129
 		}
130 130
 		// retrieve payments
131
-		return $this->get_all ( $query_params );
131
+		return $this->get_all($query_params);
132 132
 	}
133 133
 
134 134
 
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 	 * @param int $TXN_ID
139 139
 	 * @return EE_Payment[]
140 140
 	 */
141
-	public function get_approved_payments_for_transaction( $TXN_ID = 0 ) {
142
-		return $this->get_payments_for_transaction( $TXN_ID, EEM_Payment::status_id_approved );
141
+	public function get_approved_payments_for_transaction($TXN_ID = 0) {
142
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
143 143
 
144 144
 	}
145 145
 
@@ -160,36 +160,36 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return EE_Payment[]
162 162
 	 */
163
-	public function get_payments_made_between_dates( $start_date = '', $end_date = '', $format = '', $timezone = '' ) {
164
-		$timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
163
+	public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') {
164
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
165 165
 		//if $start_date or $end date, verify $format is included.
166
-		if ( ( ! empty( $start_date ) || ! empty( $end_date ) ) && empty( $format ) ) {
167
-			throw new EE_Error( __('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso' ) );
166
+		if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
167
+			throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
168 168
 		}
169
-		$now = new DateTime( 'now' );
169
+		$now = new DateTime('now');
170 170
 		// setup timezone objects once
171
-		$modelDateTimeZone = new DateTimeZone( $this->_timezone );
172
-		$passedDateTimeZone = new DateTimeZone( $timezone );
171
+		$modelDateTimeZone = new DateTimeZone($this->_timezone);
172
+		$passedDateTimeZone = new DateTimeZone($timezone);
173 173
 		// setup start date
174
-		$start_date = ! empty( $start_date ) ? date_create_from_format( $format, $start_date, $passedDateTimeZone ) : $now;
175
-		$start_date->setTimeZone( $modelDateTimeZone );
176
-		$start_date = $start_date->format( 'Y-m-d' ) . ' 00:00:00';
177
-		$start_date = strtotime( $start_date );
174
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
175
+		$start_date->setTimeZone($modelDateTimeZone);
176
+		$start_date = $start_date->format('Y-m-d').' 00:00:00';
177
+		$start_date = strtotime($start_date);
178 178
 		// setup end date
179
-		$end_date = ! empty( $end_date ) ? date_create_from_format( $format, $end_date, $passedDateTimeZone ) : $now;
180
-		$end_date->setTimeZone( $modelDateTimeZone );
181
-		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
182
-		$end_date = strtotime( $end_date );
179
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
180
+		$end_date->setTimeZone($modelDateTimeZone);
181
+		$end_date = $end_date->format('Y-m-d').' 23:59:59';
182
+		$end_date = strtotime($end_date);
183 183
 
184 184
 		// make sure our start date is the lowest value and vice versa
185
-		$start = min( $start_date, $end_date );
186
-		$end = max( $start_date, $end_date );
185
+		$start = min($start_date, $end_date);
186
+		$end = max($start_date, $end_date);
187 187
 
188 188
 		//yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
189
-		$start_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $start ) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone() );
190
-		$end_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $end) . ' 23:59:59' , 'Y-m-d H:i:s', $this->get_timezone() );
189
+		$start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
190
+		$end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
191 191
 
192
-		return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
192
+		return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date))));
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,35 +199,35 @@  discard block
 block discarded – undo
199 199
 	 * returns a string for the approved status
200 200
 	 * @return 	string
201 201
 	 */
202
-	function approved_status(){
202
+	function approved_status() {
203 203
 		return self::status_id_approved;
204 204
 	}
205 205
 	/**
206 206
 	 * returns a string for the pending status
207 207
 	 * @return 	string
208 208
 	 */
209
-	function pending_status(){
209
+	function pending_status() {
210 210
 		return self::status_id_pending;
211 211
 	}
212 212
 	/**
213 213
 	 * returns a string for the cancelled status
214 214
 	 * @return 	string
215 215
 	 */
216
-	function cancelled_status(){
216
+	function cancelled_status() {
217 217
 		return self::status_id_cancelled;
218 218
 	}
219 219
 	/**
220 220
 	 * returns a string for the failed status
221 221
 	 * @return 	string
222 222
 	 */
223
-	function failed_status(){
223
+	function failed_status() {
224 224
 		return self::status_id_failed;
225 225
 	}
226 226
 	/**
227 227
 	 * returns a string for the declined status
228 228
 	 * @return 	string
229 229
 	 */
230
-	function declined_status(){
230
+	function declined_status() {
231 231
 		return self::status_id_declined;
232 232
 	}
233 233
 
Please login to merge, or discard this patch.
core/db_models/EEM_Payment_Method.model.php 1 patch
Spacing   +92 added lines, -92 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
  *
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
 	 * @access   protected
38 38
 	 * @return EEM_Payment_Method
39 39
 	 */
40
-	protected function __construct( $timezone = NULL ) {
41
-		$this->singlular_item = __( 'Payment Method', 'event_espresso' );
42
-		$this->plural_item = __( 'Payment Methods', 'event_espresso' );
43
-		$this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) );
40
+	protected function __construct($timezone = NULL) {
41
+		$this->singlular_item = __('Payment Method', 'event_espresso');
42
+		$this->plural_item = __('Payment Methods', 'event_espresso');
43
+		$this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID'));
44 44
 		$this->_fields = array(
45 45
 			'Payment_Method' => array(
46
-				'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ),
47
-				'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ),
48
-				'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ),
49
-				'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ),
50
-				'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ),
51
-				'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ),
52
-				'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ),
53
-				'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ),
54
-				'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ),
55
-				'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ),
56
-				'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ),
57
-				'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API'
46
+				'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')),
47
+				'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'),
48
+				'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE),
49
+				'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''),
50
+				'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE),
51
+				'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE),
52
+				'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE),
53
+				'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0),
54
+				'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE),
55
+				'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE),
56
+				'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''),
57
+				'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API'
58 58
 		) );
59 59
 		$this->_model_relations = array(
60 60
  //			'Event'=>new EE_HABTM_Relation('Event_Payment_Method'),
61 61
 			'Payment' => new EE_Has_Many_Relation(),
62
-			'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ),
62
+			'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'),
63 63
 			'Transaction' => new EE_Has_Many_Relation(),
64 64
 			'WP_User' => new EE_Belongs_To_Relation(),
65 65
 		);
66
-		parent::__construct( $timezone );
66
+		parent::__construct($timezone);
67 67
 	}
68 68
 
69 69
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param string $slug
74 74
 	 * @return EE_Payment_Method
75 75
 	 */
76
-	public function get_one_by_slug( $slug ) {
77
-		return $this->get_one( array( array( 'PMD_slug' => $slug ) ) );
76
+	public function get_one_by_slug($slug) {
77
+		return $this->get_one(array(array('PMD_slug' => $slug)));
78 78
 	}
79 79
 
80 80
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		return apply_filters(
89 89
 			'FHEE__EEM_Payment_Method__scopes',
90 90
 			array(
91
-				self::scope_cart 		=> __( "Front-end Registration Page", 'event_espresso' ),
92
-				self::scope_admin 	=> __( "Admin Registration Page (no online processing)", 'event_espresso' )
91
+				self::scope_cart 		=> __("Front-end Registration Page", 'event_espresso'),
92
+				self::scope_admin 	=> __("Admin Registration Page (no online processing)", 'event_espresso')
93 93
 			)
94 94
 		);
95 95
 	}
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param string $scope like one of EEM_Payment_Method::instance()->scopes()
102 102
 	 * @return boolean
103 103
 	 */
104
-	public function is_valid_scope( $scope ) {
104
+	public function is_valid_scope($scope) {
105 105
 		$scopes = $this->scopes();
106
-		if ( isset( $scopes[ $scope ] ) ) {
106
+		if (isset($scopes[$scope])) {
107 107
 			return TRUE;
108 108
 		} else {
109 109
 			return FALSE;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @throws EE_Error
120 120
 	 * @return EE_Payment_Method[]
121 121
 	 */
122
-	public function get_all_active( $scope = NULL, $query_params = array() ) {
123
-		if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) {
124
-			$query_params = array( 'order_by' => array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ) );
122
+	public function get_all_active($scope = NULL, $query_params = array()) {
123
+		if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) {
124
+			$query_params = array('order_by' => array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC'));
125 125
 		}
126
-		return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) );
126
+		return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params));
127 127
 	}
128 128
 
129 129
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @param array $query_params
133 133
 	 * @return int
134 134
 	 */
135
-	public function count_active( $scope = NULL, $query_params = array() ){
136
-		return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) );
135
+	public function count_active($scope = NULL, $query_params = array()) {
136
+		return $this->count($this->_get_query_params_for_all_active($scope, $query_params));
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 	 * @return array like param of EEM_Base::get_all()
145 145
 	 * @throws EE_Error
146 146
 	 */
147
-	protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){
148
-		if ( $scope ) {
149
-			if ( $this->is_valid_scope( $scope ) ) {
150
-				return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params );
147
+	protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) {
148
+		if ($scope) {
149
+			if ($this->is_valid_scope($scope)) {
150
+				return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params);
151 151
 			} else {
152
-				throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) );
152
+				throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope));
153 153
 			}
154 154
 		} else {
155 155
 			$acceptable_scopes = array();
156 156
 			$count = 0;
157
-			foreach ( $this->scopes() as $scope_name => $desc ) {
157
+			foreach ($this->scopes() as $scope_name => $desc) {
158 158
 				$count++;
159
-				$acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' );
159
+				$acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%');
160 160
 			}
161
-			return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params );
161
+			return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params);
162 162
 		}
163 163
 	}
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @return array like param of EEM_Base::get_all()
171 171
 	 * @throws EE_Error
172 172
 	 */
173
-	public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) {
174
-		return $this->_get_query_params_for_all_active( $scope, $query_params );
173
+	public function get_query_params_for_all_active($scope = NULL, $query_params = array()) {
174
+		return $this->_get_query_params_for_all_active($scope, $query_params);
175 175
 	}
176 176
 
177 177
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array  $query_params
182 182
 	 * @return EE_Payment_Method
183 183
 	 */
184
-	public function get_one_active( $scope = NULL, $query_params = array() ) {
185
-		return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) );
184
+	public function get_one_active($scope = NULL, $query_params = array()) {
185
+		return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params));
186 186
 	}
187 187
 
188 188
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param string $type
193 193
 	 * @return EE_Payment_Method
194 194
 	 */
195
-	public function get_one_of_type( $type ) {
196
-		return $this->get_one( array( array( 'PMD_type' => $type ) ) );
195
+	public function get_one_of_type($type) {
196
+		return $this->get_one(array(array('PMD_type' => $type)));
197 197
 	}
198 198
 
199 199
 
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
 	 * @return EE_Payment_Method
207 207
 	 * @throws EE_Error
208 208
 	 */
209
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) {
209
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
210 210
 		//first: check if it's a slug
211
-		if( is_string( $base_class_obj_or_id ) ) {
212
-			$obj = $this->get_one_by_slug( $base_class_obj_or_id );
213
-			if( $obj ) {
211
+		if (is_string($base_class_obj_or_id)) {
212
+			$obj = $this->get_one_by_slug($base_class_obj_or_id);
213
+			if ($obj) {
214 214
 				return $obj;
215 215
 			}
216 216
 		}
217 217
 		//ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID)
218 218
 		try {
219
-			return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db );
219
+			return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db);
220 220
 		}
221
-		catch ( EE_Error $e ) {
221
+		catch (EE_Error $e) {
222 222
 			//handle it outside the catch
223 223
 		}
224
-		throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) );
224
+		throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id));
225 225
 	}
226 226
 
227 227
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 * @param mixed $base_obj_or_id_or_slug
233 233
 	 * @return int
234 234
 	 */
235
-	function ensure_is_ID( $base_obj_or_id_or_slug ) {
236
-		if ( is_string( $base_obj_or_id_or_slug ) ) {
235
+	function ensure_is_ID($base_obj_or_id_or_slug) {
236
+		if (is_string($base_obj_or_id_or_slug)) {
237 237
 			//assume it's a slug
238
-			$base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug );
238
+			$base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug);
239 239
 		}
240
-		return parent::ensure_is_ID( $base_obj_or_id_or_slug );
240
+		return parent::ensure_is_ID($base_obj_or_id_or_slug);
241 241
 	}
242 242
 
243 243
 
@@ -246,36 +246,36 @@  discard block
 block discarded – undo
246 246
 	 * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default.
247 247
 	 * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart
248 248
 	 */
249
-	function verify_button_urls( $payment_methods = NULL ) {
250
-		$payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
-		foreach ( $payment_methods as $payment_method ) {
249
+	function verify_button_urls($payment_methods = NULL) {
250
+		$payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
+		foreach ($payment_methods as $payment_method) {
252 252
 			try {
253 253
 				$current_button_url = $payment_method->button_url();
254
-				$buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
-					'current_ssl' => str_replace( "http://", "https://", $current_button_url ),
256
-					'current' => str_replace( "https://", "http://", $current_button_url ),
257
-					'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ),
258
-					'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ),
259
-				) );
260
-				foreach( $buttons_urls_to_try as $button_url_to_try ) {
261
-					if(
254
+				$buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
+					'current_ssl' => str_replace("http://", "https://", $current_button_url),
256
+					'current' => str_replace("https://", "http://", $current_button_url),
257
+					'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()),
258
+					'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()),
259
+				));
260
+				foreach ($buttons_urls_to_try as $button_url_to_try) {
261
+					if (
262 262
 							(//this is the current url and it exists, regardless of SSL issues
263 263
 								$button_url_to_try == $current_button_url &&
264 264
 								EEH_URL::remote_file_exists(
265 265
 										$button_url_to_try,
266 266
 										array(
267 267
 											'sslverify' => false,
268
-											'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
268
+											'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
269 269
 											) )
270 270
 							)
271 271
 							||
272 272
 							(//this is NOT the current url and it exists with a working SSL cert
273 273
 								$button_url_to_try != $current_button_url &&
274
-								EEH_URL::remote_file_exists( $button_url_to_try )
274
+								EEH_URL::remote_file_exists($button_url_to_try)
275 275
 							) ) {
276
-						if( $current_button_url != $button_url_to_try ){
277
-							$payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) );
278
-							EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) );
276
+						if ($current_button_url != $button_url_to_try) {
277
+							$payment_method->save(array('PMD_button_url' => $button_url_to_try));
278
+							EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try));
279 279
 						}
280 280
 						//this image exists. So if wasn't set before, now it is;
281 281
 						//or if it was already set, we have nothing to do
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 					}
284 284
 				}
285 285
 			}
286
-			catch ( EE_Error $e ) {
287
-				$payment_method->set_active( FALSE );
286
+			catch (EE_Error $e) {
287
+				$payment_method->set_active(FALSE);
288 288
 			}
289 289
 		}
290 290
 	}
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 	 * @param array $rows
299 299
 	 * @return EE_Payment_Method[]
300 300
 	 */
301
-	protected function _create_objects( $rows = array() ) {
302
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
303
-		$payment_methods = parent::_create_objects( $rows );
301
+	protected function _create_objects($rows = array()) {
302
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
303
+		$payment_methods = parent::_create_objects($rows);
304 304
 		/* @var $payment_methods EE_Payment_Method[] */
305 305
 		$usable_payment_methods = array();
306
-		foreach ( $payment_methods as $key => $payment_method ) {
307
-			if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) {
308
-				$usable_payment_methods[ $key ] = $payment_method;
306
+		foreach ($payment_methods as $key => $payment_method) {
307
+			if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) {
308
+				$usable_payment_methods[$key] = $payment_method;
309 309
 				//some payment methods enqueue their scripts in EE_PMT_*::__construct
310 310
 				//which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue
311 311
 				//its scripts). but for backwards-compat we should continue to do that
@@ -314,12 +314,12 @@  discard block
 block discarded – undo
314 314
 				$payment_method->deactivate();
315 315
 				$payment_method->save();
316 316
 				EE_Error::add_persistent_admin_notice(
317
-					'auto-deactivated-' . $payment_method->type(),
317
+					'auto-deactivated-'.$payment_method->type(),
318 318
 					sprintf(
319
-						__( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ),
319
+						__('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'),
320 320
 						$payment_method->admin_name(),
321 321
 						'<br />',
322
-						'<a href="' . admin_url('plugins.php') . '">',
322
+						'<a href="'.admin_url('plugins.php').'">',
323 323
 						'</a>'
324 324
 					),
325 325
 					true
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @param string 	$scope @see EEM_Payment_Method::get_all_for_events
340 340
 	 * @return EE_Payment_Method[]
341 341
 	 */
342
-	public function get_all_for_transaction( $transaction, $scope ) {
342
+	public function get_all_for_transaction($transaction, $scope) {
343 343
 		//@todo take relations between events and payment methods into account, once that relation exists
344
-		if ( $transaction instanceof EE_Transaction ) {
344
+		if ($transaction instanceof EE_Transaction) {
345 345
 			//@todo take the relation between transaction and currencies into account
346 346
 		}
347
-		$currencies_for_events = array( EE_Config::instance()->currency->code );
347
+		$currencies_for_events = array(EE_Config::instance()->currency->code);
348 348
 		//give addons a chance to override what payment methods are chosen based on the transaction
349 349
 		return apply_filters(
350 350
 			'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods',
351
-			$this->get_all_active( $scope, array( array( 'Currency.CUR_code' => array( 'IN', $currencies_for_events ) ) ) ),
351
+			$this->get_all_active($scope, array(array('Currency.CUR_code' => array('IN', $currencies_for_events)))),
352 352
 			$transaction,
353 353
 			$scope
354 354
 		);
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 	 * @param EE_Registration|int $registration_or_reg_id  Either the EE_Registration object or the id for the registration.
365 365
 	 * @return EE_Payment|null
366 366
 	 */
367
-	public function get_last_used_for_registration( $registration_or_reg_id ) {
368
-		$registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id );
367
+	public function get_last_used_for_registration($registration_or_reg_id) {
368
+		$registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id);
369 369
 
370 370
 		$query_params = array(
371 371
 			0 => array(
372 372
 				'Payment.Registration.REG_ID' => $registration_id,
373 373
 			),
374
-			'order_by' => array( 'Payment.PAY_ID' => 'DESC' )
374
+			'order_by' => array('Payment.PAY_ID' => 'DESC')
375 375
 		);
376
-		return $this->get_one( $query_params );
376
+		return $this->get_one($query_params);
377 377
 	}
378 378
 
379 379
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 1 patch
Spacing   +55 added lines, -55 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
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * Transaction Model
@@ -67,35 +67,35 @@  discard block
 block discarded – undo
67 67
 	 * @return EEM_Transaction
68 68
 	 * @throws \EE_Error
69 69
 	 */
70
-	protected function __construct( $timezone ) {
71
-		$this->singular_item = __('Transaction','event_espresso');
72
-		$this->plural_item = __('Transactions','event_espresso');
70
+	protected function __construct($timezone) {
71
+		$this->singular_item = __('Transaction', 'event_espresso');
72
+		$this->plural_item = __('Transactions', 'event_espresso');
73 73
 
74 74
 		$this->_tables = array(
75
-			'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID')
75
+			'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID')
76 76
 		);
77 77
 		$this->_fields = array(
78 78
 			'Transaction'=>array(
79
-				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')),
80
-				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ),
81
-				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0),
82
-				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0),
83
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
84
-				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''),
85
-				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''),
79
+				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
80
+				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone),
81
+				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0),
82
+				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
83
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
84
+				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''),
85
+				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''),
86 86
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'),
87
-				'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ),
87
+				'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()),
88 88
 			)
89 89
 		);
90 90
 		$this->_model_relations = array(
91 91
 			'Registration'=>new EE_Has_Many_Relation(),
92 92
 			'Payment'=>new EE_Has_Many_Relation(),
93 93
 			'Status'=>new EE_Belongs_To_Relation(),
94
-			'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items
94
+			'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items
95 95
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
96 96
 		);
97 97
 		$this->_model_chain_to_wp_user = 'Registration.Event';
98
-		parent::__construct( $timezone );
98
+		parent::__construct($timezone);
99 99
 
100 100
 	}
101 101
 
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
 	 * @param string $period
107 107
 	 * @return \stdClass[]
108 108
 	 */
109
-	public function get_revenue_per_day_report( $period = '-1 month' ) {
110
-		$sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', strtotime( $period ) ), 'Y-m-d H:i:s', 'UTC' );
109
+	public function get_revenue_per_day_report($period = '-1 month') {
110
+		$sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), 'Y-m-d H:i:s', 'UTC');
111 111
 
112
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'TXN_timestamp' );
112
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
113 113
 		return $this->_get_all_wpdb_results(
114 114
 			array(
115 115
 				array(
116
-					'TXN_timestamp' => array( '>=', $sql_date )
116
+					'TXN_timestamp' => array('>=', $sql_date)
117 117
 				),
118 118
 				'group_by' => 'txnDate',
119
-				'order_by' => array( 'TXN_timestamp' => 'ASC' )
119
+				'order_by' => array('TXN_timestamp' => 'ASC')
120 120
 			),
121 121
 			OBJECT,
122 122
 			array(
123
-				'txnDate' => array( 'DATE(' . $query_interval . ')', '%s' ),
124
-				'revenue' => array( 'SUM(Transaction.TXN_paid)', '%d' )
123
+				'txnDate' => array('DATE('.$query_interval.')', '%s'),
124
+				'revenue' => array('SUM(Transaction.TXN_paid)', '%d')
125 125
 			)
126 126
 		);
127 127
 	}
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 	 * @throws \EE_Error
137 137
 	 * @return mixed
138 138
 	 */
139
-	public function get_revenue_per_event_report( $period = '-1 month' ) {
139
+	public function get_revenue_per_event_report($period = '-1 month') {
140 140
 		global $wpdb;
141
-		$transaction_table = $wpdb->prefix . 'esp_transaction';
142
-		$registration_table = $wpdb->prefix . 'esp_registration';
141
+		$transaction_table = $wpdb->prefix.'esp_transaction';
142
+		$registration_table = $wpdb->prefix.'esp_registration';
143 143
 		$event_table = $wpdb->posts;
144
-		$payment_table = $wpdb->prefix . 'esp_payment';
145
-		$sql_date = date( 'Y-m-d H:i:s', strtotime( $period ) );
144
+		$payment_table = $wpdb->prefix.'esp_payment';
145
+		$sql_date = date('Y-m-d H:i:s', strtotime($period));
146 146
 		$approved_payment_status = EEM_Payment::status_id_approved;
147 147
 		$extra_event_on_join = '';
148 148
 		//exclude events not authored by user if permissions in effect
149
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
150
-			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
149
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
150
+			$extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
151 151
 		}
152 152
 
153 153
 		return $wpdb->get_results(
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	 * @param string $reg_url_link
188 188
 	 * @return EE_Transaction
189 189
 	 */
190
-	public function get_transaction_from_reg_url_link( $reg_url_link = '' ){
191
-		return $this->get_one( array(
190
+	public function get_transaction_from_reg_url_link($reg_url_link = '') {
191
+		return $this->get_one(array(
192 192
 			array(
193
-				'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' )
193
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '')
194 194
 			)
195 195
 		));
196 196
 	}
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 	 * @return boolean
208 208
 	 * @throws \EE_Error
209 209
 	 */
210
-	public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){
210
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) {
211 211
 		EE_Error::doing_it_wrong(
212
-			__CLASS__ . '::' . __FUNCTION__,
213
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
212
+			__CLASS__.'::'.__FUNCTION__,
213
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
214 214
 			'4.6.0'
215 215
 		);
216 216
 		/** @type EE_Transaction_Processor $transaction_processor */
217
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
217
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
218 218
 		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
219
-			$this->ensure_is_obj( $transaction_obj_or_id )
219
+			$this->ensure_is_obj($transaction_obj_or_id)
220 220
 		);
221 221
 	}
222 222
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			array(
249 249
 				0 => array(
250 250
 					'STS_ID' => EEM_Transaction::failed_status_code,
251
-					'TXN_timestamp' => array( '<', time() - $time_to_leave_alone )
251
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
252 252
 				)
253 253
 			),
254 254
 			$time_to_leave_alone
@@ -261,29 +261,29 @@  discard block
 block discarded – undo
261 261
 		 */
262 262
 		$txn_ids = apply_filters(
263 263
 			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
264
-			EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ),
264
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
265 265
 			$time_to_leave_alone
266 266
 		);
267 267
 		//now that we have the ids to delete
268
-		if ( ! empty( $txn_ids ) && is_array( $txn_ids ) ) {
268
+		if ( ! empty($txn_ids) && is_array($txn_ids)) {
269 269
 			// first, make sure these TXN's are removed the "ee_locked_transactions" array
270
-			EEM_Transaction::unset_locked_transactions( $txn_ids );
270
+			EEM_Transaction::unset_locked_transactions($txn_ids);
271 271
 			// let's get deletin'...
272 272
 			// Why no wpdb->prepare?  Because the data is trusted.
273 273
 			// We got the ids from the original query to get them FROM
274 274
 			// the db (which is sanitized) so no need to prepare them again.
275
-			$query   = '
275
+			$query = '
276 276
 				DELETE
277
-				FROM ' . $this->table() . '
277
+				FROM ' . $this->table().'
278 278
 				WHERE
279
-					TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')';
280
-			$deleted = $wpdb->query( $query );
279
+					TXN_ID IN ( ' . implode(",", $txn_ids).')';
280
+			$deleted = $wpdb->query($query);
281 281
 		}
282
-		if ( $deleted ) {
282
+		if ($deleted) {
283 283
 			/**
284 284
 			 * Allows code to do something after the transactions have been deleted.
285 285
 			 */
286
-			do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids );
286
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
287 287
 		}
288 288
 		return $deleted;
289 289
 	}
@@ -294,17 +294,17 @@  discard block
 block discarded – undo
294 294
 	 * @param array $transaction_IDs
295 295
 	 * @return bool
296 296
 	 */
297
-	public static function unset_locked_transactions( array $transaction_IDs ) {
298
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
297
+	public static function unset_locked_transactions(array $transaction_IDs) {
298
+		$locked_transactions = get_option('ee_locked_transactions', array());
299 299
 		$update = false;
300
-		foreach ( $transaction_IDs as $TXN_ID ) {
301
-			if ( isset( $locked_transactions[ $TXN_ID ] ) ) {
302
-				unset( $locked_transactions[ $TXN_ID ] );
300
+		foreach ($transaction_IDs as $TXN_ID) {
301
+			if (isset($locked_transactions[$TXN_ID])) {
302
+				unset($locked_transactions[$TXN_ID]);
303 303
 				$update = true;
304 304
 			}
305 305
 		}
306
-		if ( $update ) {
307
-			update_option( 'ee_locked_transactions', $locked_transactions );
306
+		if ($update) {
307
+			update_option('ee_locked_transactions', $locked_transactions);
308 308
 		}
309 309
 		return $update;
310 310
 	}
Please login to merge, or discard this patch.
core/EE_Cart.core.php 1 patch
Spacing   +48 added lines, -48 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
  *
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
 	  * @param EE_Line_Item $grand_total
60 60
 	  * @return \EE_Cart
61 61
 	  */
62
-	public static function instance( EE_Line_Item $grand_total = null ) {
62
+	public static function instance(EE_Line_Item $grand_total = null) {
63 63
 		// rest cart with new grand total ?
64
-		if ( ! empty( $grand_total ) ){
65
-			self::$_instance = new self( $grand_total );
64
+		if ( ! empty($grand_total)) {
65
+			self::$_instance = new self($grand_total);
66 66
 		}
67 67
 		// or maybe retrieve an existing one ?
68
-		if ( ! self::$_instance instanceof EE_Cart ) {
68
+		if ( ! self::$_instance instanceof EE_Cart) {
69 69
 			// try getting the cart out of the session
70 70
 			self::$_instance = EE_Registry::instance()->SSN->cart();
71 71
 		}
72 72
 		// verify that cart is ok and grand total line item exists
73
-		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item ) {
74
-			self::$_instance = new self( $grand_total );
73
+		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
74
+			self::$_instance = new self($grand_total);
75 75
 		}
76 76
 		self::$_instance->get_grand_total();
77 77
 		// once everything is all said and done, save the cart to the EE_Session
78
-		add_action( 'shutdown', array( self::$_instance, 'save_cart' ), 90 );
78
+		add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
79 79
 		return self::$_instance;
80 80
 	}
81 81
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	  * @param EE_Line_Item $grand_total
89 89
 	  * @return \EE_Cart
90 90
 	  */
91
-	 private function __construct( EE_Line_Item $grand_total = NULL ) {
92
-		 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
93
-		 if ( ! defined( 'ESPRESSO_CART' )) {
94
-			 define( 'ESPRESSO_CART', TRUE );
91
+	 private function __construct(EE_Line_Item $grand_total = NULL) {
92
+		 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
93
+		 if ( ! defined('ESPRESSO_CART')) {
94
+			 define('ESPRESSO_CART', TRUE);
95 95
 		 }
96
-		 if ( $grand_total instanceof EE_Line_Item ) {
97
-			 $this->set_grand_total_line_item( $grand_total );
96
+		 if ($grand_total instanceof EE_Line_Item) {
97
+			 $this->set_grand_total_line_item($grand_total);
98 98
 		 }
99 99
 	 }
100 100
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	 * @param EE_Line_Item $grand_total
106 106
 	 * @return EE_Cart
107 107
 	 */
108
-	public static function reset( EE_Line_Item $grand_total = NULL ){
109
-		remove_action( 'shutdown', array( self::$_instance, 'save_cart'), 90 );
108
+	public static function reset(EE_Line_Item $grand_total = NULL) {
109
+		remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
110 110
 		EE_Registry::instance()->SSN->reset_cart();
111 111
 		self::$_instance = NULL;
112
-		return self::instance( $grand_total );
112
+		return self::instance($grand_total);
113 113
 	}
114 114
 
115 115
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	  * @param EE_Transaction $transaction
121 121
 	  * @return \EE_Cart
122 122
 	  */
123
-	public static function get_cart_from_txn( EE_Transaction $transaction ) {
123
+	public static function get_cart_from_txn(EE_Transaction $transaction) {
124 124
 		$grand_total = $transaction->total_line_item();
125 125
 		$grand_total->get_items();
126 126
 		$grand_total->tax_descendants();
127
-		return EE_Cart::instance( $grand_total );
127
+		return EE_Cart::instance($grand_total);
128 128
 	}
129 129
 
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
134 134
 	 * @return EE_Line_Item
135 135
 	 */
136
-	private function _create_grand_total(){
136
+	private function _create_grand_total() {
137 137
 		$this->_grand_total = EEH_Line_Item::create_total_line_item();
138 138
 		return $this->_grand_total;
139 139
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 *	@return \EE_Line_Item[]
147 147
 	 */
148 148
 	public function get_tickets() {
149
-		return EEH_Line_Item::get_ticket_line_items( $this->_grand_total );
149
+		return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
150 150
 	}
151 151
 
152 152
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function all_ticket_quantity_count() {
161 161
 		$tickets = $this->get_tickets();
162
-		if ( empty( $tickets )) {
162
+		if (empty($tickets)) {
163 163
 			return 0;
164 164
 		}
165 165
 		$count = 0;
166
-		foreach ( $tickets as $ticket ) {
166
+		foreach ($tickets as $ticket) {
167 167
 			$count = $count + $ticket->get('LIN_quantity');
168 168
 		}
169 169
 		return $count;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *  Gets all the tax line items
176 176
 	 * @return \EE_Line_Item[]
177 177
 	 */
178
-	public function get_taxes(){
179
-		return EEH_Line_Item::get_taxes_subtotal( $this->_grand_total )->children();
178
+	public function get_taxes() {
179
+		return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
180 180
 	}
181 181
 
182 182
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * Gets the total line item (which is a parent of all other line items) on this cart
186 186
 	 * @return EE_Line_Item
187 187
 	 */
188
-	public function get_grand_total(){
188
+	public function get_grand_total() {
189 189
 		return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
190 190
 	}
191 191
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 *	@param int $qty
199 199
 	 *	@return TRUE on success, FALSE on fail
200 200
 	 */
201
-	public function add_ticket_to_cart( EE_Ticket $ticket, $qty = 1 ) {
202
-		EEH_Line_Item::add_ticket_purchase( $this->get_grand_total(), $ticket, $qty );
201
+	public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) {
202
+		EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
203 203
 		return $this->save_cart() ? TRUE : FALSE;
204 204
 	}
205 205
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 *	@return float
223 223
 	 */
224 224
 	public function get_applied_taxes() {
225
-		return EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
225
+		return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
226 226
 	}
227 227
 
228 228
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 *	@return float
234 234
 	 */
235 235
 	public function get_cart_grand_total() {
236
-		EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
236
+		EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
237 237
 		return $this->get_grand_total()->total();
238 238
 	}
239 239
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function recalculate_all_cart_totals() {
248 248
 		$pre_tax_total = $this->get_cart_total_before_tax();
249
-		$taxes_total = EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
250
-		$this->_grand_total->set_total( $pre_tax_total + $taxes_total );
249
+		$taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
250
+		$this->_grand_total->set_total($pre_tax_total + $taxes_total);
251 251
 		$this->_grand_total->save_this_and_descendants_to_txn();
252 252
 		return $this->get_grand_total()->total();
253 253
 	}
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 *	@param mixed - string or array - line_item_ids
261 261
 	 *	@return int on success, FALSE on fail
262 262
 	 */
263
-	public function delete_items( $line_item_codes = FALSE ) {
264
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
265
-		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes );
263
+	public function delete_items($line_item_codes = FALSE) {
264
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
265
+		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
266 266
 	}
267 267
 
268 268
 
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	 *	@return bool
274 274
 	 */
275 275
 	public function empty_cart() {
276
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
276
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
277 277
 		$this->_grand_total = $this->_create_grand_total();
278
-		return $this->save_cart( TRUE );
278
+		return $this->save_cart(TRUE);
279 279
 	}
280 280
 
281 281
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 *	@return bool
287 287
 	 */
288 288
 	public function delete_cart() {
289
-		$deleted = EEH_Line_Item::delete_all_child_items( $this->_grand_total );
290
-		if ( $deleted ) {
289
+		$deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
290
+		if ($deleted) {
291 291
 			$deleted += $this->_grand_total->delete();
292 292
 			$this->_grand_total = null;
293 293
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 *  know the grand total line item on it
302 302
 	 * @param EE_Line_Item $line_item
303 303
 	 */
304
-	public function set_grand_total_line_item( EE_Line_Item $line_item ) {
304
+	public function set_grand_total_line_item(EE_Line_Item $line_item) {
305 305
 		$this->_grand_total = $line_item;
306 306
 	}
307 307
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 	  * @param bool $apply_taxes
314 314
 	  * @return TRUE on success, FALSE on fail
315 315
 	  */
316
-	public function save_cart( $apply_taxes = TRUE ) {
317
-		if ( $apply_taxes && $this->_grand_total instanceof EE_Line_Item ) {
318
-			EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
316
+	public function save_cart($apply_taxes = TRUE) {
317
+		if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
318
+			EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319 319
 			//make sure we don't cache the transaction because it can get stale
320
-			if( $this->_grand_total->get_one_from_cache( 'Transaction' ) instanceof EE_Transaction &&
321
-				$this->_grand_total->get_one_from_cache( 'Transaction' )->ID()) {
322
-				$this->_grand_total->clear_cache( 'Transaction', null, true );
320
+			if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction &&
321
+				$this->_grand_total->get_one_from_cache('Transaction')->ID()) {
322
+				$this->_grand_total->clear_cache('Transaction', null, true);
323 323
 			}
324 324
 		}
325
-		return EE_Registry::instance()->SSN->set_cart( $this );
325
+		return EE_Registry::instance()->SSN->set_cart($this);
326 326
 	}
327 327
 
328 328
 
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_URL_Validation_Strategy.strategy.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
  * @since 				4.6
9 9
  *
10 10
  */
11
-class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base{
11
+class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base {
12 12
 
13 13
 	/**
14 14
 	 * @param null $validation_error_message
15 15
 	 */
16
-	public function __construct( $validation_error_message = NULL ) {
17
-		if( ! $validation_error_message ){
16
+	public function __construct($validation_error_message = NULL) {
17
+		if ( ! $validation_error_message) {
18 18
 			$validation_error_message = __("Please enter a valid URL", "event_espresso");
19 19
 		}
20
-		parent::__construct( $validation_error_message );
20
+		parent::__construct($validation_error_message);
21 21
 	}
22 22
 
23 23
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	 * @throws \EE_Validation_Error
31 31
 	 */
32 32
 	function validate($normalized_value) {
33
-		if( $normalized_value ){
34
-			if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){
35
-				throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url');
36
-			}else{
37
-				if( ! EEH_URL::remote_file_exists(
33
+		if ($normalized_value) {
34
+			if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
35
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
36
+			} else {
37
+				if ( ! EEH_URL::remote_file_exists(
38 38
 						$normalized_value,
39 39
 						array(
40 40
 							'sslverify' => false, 
41
-							'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
42
-						))){
41
+							'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
42
+						))) {
43 43
 					throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
44 44
 				}
45 45
 			}
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @return array
53 53
 	 */
54
-	function get_jquery_validation_rule_array(){
55
-		return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
54
+	function get_jquery_validation_rule_array() {
55
+		return array('validUrl'=>true, 'messages' => array('validUrl' => $this->get_validation_error_message()));
56 56
 	}
57 57
 }
58 58
 
Please login to merge, or discard this patch.
libraries/form_sections/base/EE_Form_Section_HTML_From_Template.form.php 1 patch
Spacing   +4 added lines, -4 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,9 +25,9 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML{
29
-	public function __construct($template_file,$args = array(), $options_array = array()) {
30
-		$html = EEH_Template::locate_template( $template_file, $args );
28
+class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML {
29
+	public function __construct($template_file, $args = array(), $options_array = array()) {
30
+		$html = EEH_Template::locate_template($template_file, $args);
31 31
 
32 32
 //		echo " filepath:$template_file html $html";
33 33
 		parent::__construct($html, $options_array);
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts).
8 8
  * However, you may output the form (usually by calling get_html_and_js) anywhere you like.
9 9
  */
10
-class EE_Form_Section_Proper extends EE_Form_Section_Validatable{
10
+class EE_Form_Section_Proper extends EE_Form_Section_Validatable {
11 11
 
12 12
 	/**
13 13
 	 * Subsections
@@ -68,37 +68,37 @@  discard block
 block discarded – undo
68 68
 	 * } @see EE_Form_Section_Validatable::__construct()
69 69
 	 *
70 70
 	 */
71
-	public function __construct( $options_array = array() ){
72
-		$options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this );
71
+	public function __construct($options_array = array()) {
72
+		$options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this);
73 73
 		//call parent first, as it may be setting the name
74 74
 		parent::__construct($options_array);
75 75
 		//if they've included subsections in the constructor, add them now
76
-		if( isset( $options_array['include'] )){
76
+		if (isset($options_array['include'])) {
77 77
 			//we are going to make sure we ONLY have those subsections to include
78 78
 			//AND we are going to make sure they're in that specified order
79 79
 			$reordered_subsections = array();
80
-			foreach($options_array['include'] as $input_name){
81
-				if(isset($this->_subsections[$input_name])){
80
+			foreach ($options_array['include'] as $input_name) {
81
+				if (isset($this->_subsections[$input_name])) {
82 82
 					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
83 83
 				}
84 84
 			}
85 85
 			$this->_subsections = $reordered_subsections;
86 86
 		}
87
-		if(isset($options_array['exclude'])){
87
+		if (isset($options_array['exclude'])) {
88 88
 			$exclude = $options_array['exclude'];
89 89
 			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
90 90
 		}
91
-		if(isset($options_array['layout_strategy'])){
91
+		if (isset($options_array['layout_strategy'])) {
92 92
 			$this->_layout_strategy = $options_array['layout_strategy'];
93 93
 		}
94
-		if( ! $this->_layout_strategy){
94
+		if ( ! $this->_layout_strategy) {
95 95
 			$this->_layout_strategy = new EE_Two_Column_Layout();
96 96
 		}
97 97
 		$this->_layout_strategy->_construct_finalize($this);
98 98
 
99
-		add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
100
-		add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
101
-		add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 );
99
+		add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
100
+		add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
101
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
102 102
 	}
103 103
 
104 104
 
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
 	 * @param string                 $name
111 111
 	 * @throws \EE_Error
112 112
 	 */
113
-	public function _construct_finalize( $parent_form_section, $name ) {
113
+	public function _construct_finalize($parent_form_section, $name) {
114 114
 		parent::_construct_finalize($parent_form_section, $name);
115 115
 		$this->_set_default_name_if_empty();
116 116
 		$this->_set_default_html_id_if_empty();
117
-		foreach( $this->_subsections as $subsection_name => $subsection ){
118
-			if ( $subsection instanceof EE_Form_Section_Base ) {
119
-				$subsection->_construct_finalize( $this, $subsection_name );
117
+		foreach ($this->_subsections as $subsection_name => $subsection) {
118
+			if ($subsection instanceof EE_Form_Section_Base) {
119
+				$subsection->_construct_finalize($this, $subsection_name);
120 120
 			} else {
121 121
 				throw new EE_Error(
122 122
 					sprintf(
123
-						__( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ),
123
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'),
124 124
 						$subsection_name,
125 125
 						get_class($this),
126
-						$subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' )
126
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
127 127
 					)
128 128
 				);
129 129
 			}
130 130
 		}
131
-		do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name );
131
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
132 132
 	}
133 133
 
134 134
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * Gets the layout strategy for this form section
138 138
 	 * @return EE_Form_Section_Layout_Base
139 139
 	 */
140
-	public function get_layout_strategy(){
140
+	public function get_layout_strategy() {
141 141
 		return $this->_layout_strategy;
142 142
 	}
143 143
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param EE_Form_Input_Base $input
150 150
 	 * @return string
151 151
 	 */
152
-	public function get_html_for_input($input){
152
+	public function get_html_for_input($input) {
153 153
 		return $this->_layout_strategy->layout_input($input);
154 154
 	}
155 155
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @param null $form_data
163 163
 	 * @return boolean
164 164
 	 */
165
-	public function was_submitted($form_data = NULL){
165
+	public function was_submitted($form_data = NULL) {
166 166
 		return $this->form_data_present_in($form_data);
167 167
 	}
168 168
 
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 	 *                          (eg you validated the data then stored it in the DB) you may want to skip this step.
188 188
 	 * @return void
189 189
 	 */
190
-	public function receive_form_submission($req_data = NULL, $validate = TRUE){
191
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate );
192
-		if( $req_data === NULL){
193
-			$req_data = array_merge( $_GET, $_POST );
190
+	public function receive_form_submission($req_data = NULL, $validate = TRUE) {
191
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate);
192
+		if ($req_data === NULL) {
193
+			$req_data = array_merge($_GET, $_POST);
194 194
 		}
195 195
 		$this->_normalize($req_data);
196
-		if( $validate ){
196
+		if ($validate) {
197 197
 			$this->_validate();
198 198
 		}
199
-		do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate );
199
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
200 200
 	}
201 201
 
202 202
 
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 	 * the value being an array formatted in teh same way
210 210
 	 * @param array $default_data
211 211
 	 */
212
-	public function populate_defaults($default_data){
213
-		foreach($this->subsections() as $subsection_name => $subsection){
214
-			if(isset($default_data[$subsection_name])){
215
-				if($subsection instanceof EE_Form_Input_Base){
212
+	public function populate_defaults($default_data) {
213
+		foreach ($this->subsections() as $subsection_name => $subsection) {
214
+			if (isset($default_data[$subsection_name])) {
215
+				if ($subsection instanceof EE_Form_Input_Base) {
216 216
 					$subsection->set_default($default_data[$subsection_name]);
217
-				}elseif($subsection instanceof EE_Form_Section_Proper){
217
+				}elseif ($subsection instanceof EE_Form_Section_Proper) {
218 218
 					$subsection->populate_defaults($default_data[$subsection_name]);
219 219
 				}
220 220
 			}
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 * (realizing that the subsections' html names might not be set yet, etc.)
233 233
 	 * @return EE_Form_Section_Base
234 234
 	 */
235
-	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
236
-		if( $require_construction_to_be_finalized ){
235
+	public function get_subsection($name, $require_construction_to_be_finalized = TRUE) {
236
+		if ($require_construction_to_be_finalized) {
237 237
 			$this->ensure_construct_finalized_called();
238 238
 		}
239 239
 		return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL;
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 * Gets all the validatable subsections of this form section
246 246
 	 * @return EE_Form_Section_Validatable[]
247 247
 	 */
248
-	public function get_validatable_subsections(){
248
+	public function get_validatable_subsections() {
249 249
 		$validatable_subsections = array();
250
-		foreach($this->subsections() as $name=>$obj){
251
-			if($obj instanceof EE_Form_Section_Validatable){
250
+		foreach ($this->subsections() as $name=>$obj) {
251
+			if ($obj instanceof EE_Form_Section_Validatable) {
252 252
 				$validatable_subsections[$name] = $obj;
253 253
 			}
254 254
 		}
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @return EE_Form_Input_Base
269 269
 	 * @throws EE_Error
270 270
 	 */
271
-	public function get_input($name, $require_construction_to_be_finalized = TRUE ){
271
+	public function get_input($name, $require_construction_to_be_finalized = TRUE) {
272 272
 		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
273
-		if( ! $subsection instanceof EE_Form_Input_Base){
274
-			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
273
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
274
+			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
275 275
 		}
276 276
 		return $subsection;
277 277
 	}
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 * @return EE_Form_Section_Proper
290 290
 	 * @throws EE_Error
291 291
 	 */
292
-	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){
293
-		$subsection = $this->get_subsection( $name, $require_construction_to_be_finalized );
294
-		if( ! $subsection instanceof EE_Form_Section_Proper){
295
-			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this)));
292
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) {
293
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
294
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
295
+			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this)));
296 296
 		}
297 297
 		return $subsection;
298 298
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 * @param string $name
306 306
 	 * @return mixed depending on the input's type and its normalization strategy
307 307
 	 */
308
-	public function get_input_value($name){
308
+	public function get_input_value($name) {
309 309
 		$input = $this->get_input($name);
310 310
 		return $input->normalized_value();
311 311
 	}
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	 * @return boolean
319 319
 	 */
320 320
 	public function is_valid() {
321
-		if( ! $this->has_received_submission()){
321
+		if ( ! $this->has_received_submission()) {
322 322
 			throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso")));
323 323
 		}
324
-		if( ! parent::is_valid()){
324
+		if ( ! parent::is_valid()) {
325 325
 			return false;
326 326
 		}
327 327
 		//ok so no errors general to this entire form section. so let's check the subsections
328
-		foreach( $this->get_validatable_subsections() as $subsection ){
329
-			if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){
330
-				$this->set_submission_error_message( $subsection->get_validation_error_string() );
328
+		foreach ($this->get_validatable_subsections() as $subsection) {
329
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') {
330
+				$this->set_submission_error_message($subsection->get_validation_error_string());
331 331
 				return false;
332 332
 			}
333 333
 		}
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
 	 * gets teh default name of this form section if none is specified
341 341
 	 * @return string
342 342
 	 */
343
-	protected function _set_default_name_if_empty(){
344
-		if( ! $this->_name ){
343
+	protected function _set_default_name_if_empty() {
344
+		if ( ! $this->_name) {
345 345
 			$classname = get_class($this);
346 346
 			$default_name = str_replace("EE_", "", $classname);
347
-			$this->_name =  $default_name;
347
+			$this->_name = $default_name;
348 348
 		}
349 349
 	}
350 350
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * Also returns the HTML for the form, except for the form opening and closing tags
356 356
 	 * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button.
357 357
 	 */
358
-	public function get_html_and_js(){
358
+	public function get_html_and_js() {
359 359
 		$this->enqueue_js();
360 360
 		return $this->get_html();
361 361
 	}
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_html(){
369
+	public function get_html() {
370 370
 		$this->ensure_construct_finalized_called();
371 371
 		return $this->_layout_strategy->layout_form();
372 372
 	}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 * enqueues JS for the form
378 378
 	 * @return string
379 379
 	 */
380
-	public function enqueue_js(){
380
+	public function enqueue_js() {
381 381
 		$this->_enqueue_and_localize_form_js();
382 382
 	}
383 383
 
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 	 * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not
394 394
 	 * @return void
395 395
 	 */
396
-	public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){
397
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
398
-		wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE );
399
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) );
396
+	public static function wp_enqueue_scripts($init_form_validation_automatically = false) {
397
+		add_filter('FHEE_load_jquery_validate', '__return_true');
398
+		wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE);
399
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically));
400 400
 	}
401 401
 
402 402
 
@@ -406,14 +406,14 @@  discard block
 block discarded – undo
406 406
 	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
407 407
 	 * but before the wordpress hook wp_loaded
408 408
 	 */
409
-	public function _enqueue_and_localize_form_js(){
409
+	public function _enqueue_and_localize_form_js() {
410 410
 		$this->ensure_construct_finalized_called();
411 411
 		//actually, we don't want to localize just yet. There may be other forms on the page.
412 412
 		//so we need to add our form section data to a static variable accessible by all form sections
413 413
 		//and localize it just before the footer
414 414
 		$this->localize_validation_rules();
415
-		add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 );
416
-		add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) );
415
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
416
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
417 417
 	}
418 418
 
419 419
 
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	 * @param bool $return_for_subsection
424 424
 	 * @return void
425 425
 	 */
426
-	public function localize_validation_rules( $return_for_subsection = FALSE ){
426
+	public function localize_validation_rules($return_for_subsection = FALSE) {
427 427
 		// we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog
428
-		if ( ! $this->parent_section() || $return_for_subsection ) {
429
-			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
430
-				'form_section_id'=> $this->html_id( TRUE ),
428
+		if ( ! $this->parent_section() || $return_for_subsection) {
429
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
430
+				'form_section_id'=> $this->html_id(TRUE),
431 431
 				'validation_rules'=> $this->get_jquery_validation_rules(),
432 432
 				'errors'=> $this->subsection_validation_errors_by_html_name()
433 433
 			);
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	 * Keys are their form names, and values are the inputs themselves
443 443
 	 * @return EE_Form_Input_Base
444 444
 	 */
445
-	public function inputs_in_subsections(){
445
+	public function inputs_in_subsections() {
446 446
 		$inputs = array();
447
-		foreach($this->subsections() as $subsection){
448
-			if( $subsection instanceof EE_Form_Input_Base ){
449
-				$inputs[ $subsection->html_name() ] = $subsection;
450
-			}elseif($subsection instanceof EE_Form_Section_Proper ){
447
+		foreach ($this->subsections() as $subsection) {
448
+			if ($subsection instanceof EE_Form_Input_Base) {
449
+				$inputs[$subsection->html_name()] = $subsection;
450
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
451 451
 				$inputs += $subsection->inputs_in_subsections();
452 452
 			}
453 453
 		}
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
 	 * and values are a string of all their validation errors
461 461
 	 * @return string[]
462 462
 	 */
463
-	public function subsection_validation_errors_by_html_name(){
463
+	public function subsection_validation_errors_by_html_name() {
464 464
 		$inputs = $this->inputs();
465 465
 		$errors = array();
466
-		foreach( $inputs as $form_input ){
467
-			if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){
468
-				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
466
+		foreach ($inputs as $form_input) {
467
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
468
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
469 469
 			}
470 470
 		}
471 471
 		return $errors;
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
478 478
 	 * Should be setup by each form during the _enqueues_and_localize_form_js
479 479
 	 */
480
-	public static function localize_script_for_all_forms(){
480
+	public static function localize_script_for_all_forms() {
481 481
 		//allow inputs and stuff to hook in their JS and stuff here
482 482
 		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
483 483
 		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
484
-		$email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
484
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
485 485
 			? EE_Registry::instance()->CFG->registration->email_validation_level
486 486
 			: 'wp_default';
487 487
 		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
488
-		wp_enqueue_script( 'ee_form_section_validation' );
489
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization );
488
+		wp_enqueue_script('ee_form_section_validation');
489
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization);
490 490
 	}
491 491
 
492 492
 
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 	/**
495 495
 	 * ensure_scripts_localized
496 496
 	 */
497
-	public function ensure_scripts_localized(){
498
-		if ( ! EE_Form_Section_Proper::$_scripts_localized ) {
497
+	public function ensure_scripts_localized() {
498
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
499 499
 			$this->_enqueue_and_localize_form_js();
500 500
 		}
501 501
 	}
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * is that the key here should be the same as the custom validation rule put in the JS file
508 508
 	 * @return array keys are custom validation rules, and values are internationalized strings
509 509
 	 */
510
-	private static function _get_localized_error_messages(){
510
+	private static function _get_localized_error_messages() {
511 511
 		return array(
512 512
 			'validUrl'=>  __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
513
-			'regex' => __( 'Please check your input', 'event_espresso' ),
513
+			'regex' => __('Please check your input', 'event_espresso'),
514 514
 		);
515 515
 	}
516 516
 
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 	 * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more...
539 539
 	 * @return array
540 540
 	 */
541
-	function get_jquery_validation_rules(){
541
+	function get_jquery_validation_rules() {
542 542
 		$jquery_validation_rules = array();
543
-		foreach($this->get_validatable_subsections() as $subsection){
544
-			$jquery_validation_rules = array_merge( $jquery_validation_rules,  $subsection->get_jquery_validation_rules() );
543
+		foreach ($this->get_validatable_subsections() as $subsection) {
544
+			$jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules());
545 545
 		}
546 546
 		return $jquery_validation_rules;
547 547
 	}
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
 	protected function _normalize($req_data) {
557 557
 		$this->_received_submission = TRUE;
558 558
 		$this->_validation_errors = array();
559
-		foreach($this->get_validatable_subsections() as $subsection){
560
-			try{
559
+		foreach ($this->get_validatable_subsections() as $subsection) {
560
+			try {
561 561
 				$subsection->_normalize($req_data);
562
-			}catch( EE_Validation_Error $e ){
563
-				$subsection->add_validation_error( $e );
562
+			} catch (EE_Validation_Error $e) {
563
+				$subsection->add_validation_error($e);
564 564
 			}
565 565
 		}
566 566
 	}
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	 * calling parent::_validate() first.
575 575
 	 */
576 576
 	protected function _validate() {
577
-		foreach($this->get_validatable_subsections() as $subsection_name => $subsection){
578
-			if(method_exists($this,'_validate_'.$subsection_name)){
579
-				call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
577
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
578
+			if (method_exists($this, '_validate_'.$subsection_name)) {
579
+				call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
580 580
 			}
581 581
 			$subsection->_validate();
582 582
 		}
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 	 * Gets all the validated inputs for the form section
589 589
 	 * @return array
590 590
 	 */
591
-	public function valid_data(){
591
+	public function valid_data() {
592 592
 		$inputs = array();
593
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
594
-			if ( $subsection instanceof EE_Form_Section_Proper ) {
595
-				$inputs[ $subsection_name ] = $subsection->valid_data();
596
-			} else if ( $subsection instanceof EE_Form_Input_Base ){
597
-				$inputs[ $subsection_name ] = $subsection->normalized_value();
593
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
594
+			if ($subsection instanceof EE_Form_Section_Proper) {
595
+				$inputs[$subsection_name] = $subsection->valid_data();
596
+			} else if ($subsection instanceof EE_Form_Input_Base) {
597
+				$inputs[$subsection_name] = $subsection->normalized_value();
598 598
 			}
599 599
 		}
600 600
 		return $inputs;
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
 	 * Gets all the inputs on this form section
607 607
 	 * @return EE_Form_Input_Base[]
608 608
 	 */
609
-	public function inputs(){
609
+	public function inputs() {
610 610
 		$inputs = array();
611
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
612
-			if ( $subsection instanceof EE_Form_Input_Base ){
613
-				$inputs[ $subsection_name ] = $subsection;
611
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
612
+			if ($subsection instanceof EE_Form_Input_Base) {
613
+				$inputs[$subsection_name] = $subsection;
614 614
 			}
615 615
 		}
616 616
 		return $inputs;
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
 	 * Gets all the subsections which are a proper form
623 623
 	 * @return EE_Form_Section_Proper[]
624 624
 	 */
625
-	public function subforms(){
625
+	public function subforms() {
626 626
 		$form_sections = array();
627
-		foreach($this->subsections() as $name=>$obj){
628
-			if($obj instanceof EE_Form_Section_Proper){
627
+		foreach ($this->subsections() as $name=>$obj) {
628
+			if ($obj instanceof EE_Form_Section_Proper) {
629 629
 				$form_sections[$name] = $obj;
630 630
 			}
631 631
 		}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 * if you only want form inputs or proper form sections.
641 641
 	 * @return EE_Form_Section_Proper[]
642 642
 	 */
643
-	public function subsections(){
643
+	public function subsections() {
644 644
 		$this->ensure_construct_finalized_called();
645 645
 		return $this->_subsections;
646 646
 	}
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
659 659
 	 * input's normalized value, or an array like the top-level array
660 660
 	 */
661
-	public function input_values( $include_subform_inputs = false, $flatten = false ){
662
-		return $this->_input_values( false, $include_subform_inputs, $flatten );
661
+	public function input_values($include_subform_inputs = false, $flatten = false) {
662
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
663 663
 	}
664 664
 
665 665
 	/**
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
676 676
 	 * input's normalized value, or an array like the top-level array
677 677
 	 */
678
-	public function input_pretty_values(  $include_subform_inputs = false, $flatten = false ){
679
-		return $this->_input_values( true, $include_subform_inputs, $flatten );
678
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false) {
679
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
680 680
 	}
681 681
 
682 682
 	/**
@@ -689,17 +689,17 @@  discard block
 block discarded – undo
689 689
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
690 690
 	 * input's normalized value, or an array like the top-level array
691 691
 	 */
692
-	public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) {
692
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) {
693 693
 		$input_values = array();
694
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
695
-			if( $subsection instanceof EE_Form_Input_Base ) {
696
-				$input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
697
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) {
698
-				$subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten );
699
-				if( $flatten ) {
700
-					$input_values = array_merge( $input_values, $subform_input_values );
694
+		foreach ($this->subsections() as $subsection_name => $subsection) {
695
+			if ($subsection instanceof EE_Form_Input_Base) {
696
+				$input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
697
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
698
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
699
+				if ($flatten) {
700
+					$input_values = array_merge($input_values, $subform_input_values);
701 701
 				} else {
702
-					$input_values[ $subsection_name ] = $subform_input_values;
702
+					$input_values[$subsection_name] = $subform_input_values;
703 703
 				}
704 704
 			}
705 705
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	 * (ie, had receive_form_submission called on it yet)
714 714
 	 * @return boolean
715 715
 	 */
716
-	public function has_received_submission(){
716
+	public function has_received_submission() {
717 717
 		$this->ensure_construct_finalized_called();
718 718
 		return $this->_received_submission;
719 719
 	}
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 	 * @param array $inputs_to_exclude values are the input names
727 727
 	 * @return void
728 728
 	 */
729
-	public function exclude($inputs_to_exclude = array()){
730
-		foreach($inputs_to_exclude as $input_to_exclude_name){
729
+	public function exclude($inputs_to_exclude = array()) {
730
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
731 731
 			unset($this->_subsections[$input_to_exclude_name]);
732 732
 		}
733 733
 	}
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	/**
738 738
 	 * @param array $inputs_to_hide
739 739
 	 */
740
-	public function hide($inputs_to_hide= array()){
741
-		foreach($inputs_to_hide as $input_to_hide){
740
+	public function hide($inputs_to_hide = array()) {
741
+		foreach ($inputs_to_hide as $input_to_hide) {
742 742
 			$input = $this->get_input($input_to_hide);
743 743
 
744 744
 			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 	 * 																								or if $subsection_name_to_target is null, before or after entire subsections array
764 764
 	 * @return void
765 765
 	 */
766
-	public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){
767
-		foreach($new_subsections as $subsection_name => $subsection){
768
-			if( ! $subsection instanceof EE_Form_Section_Base){
766
+	public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) {
767
+		foreach ($new_subsections as $subsection_name => $subsection) {
768
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
769 769
 				EE_Error::add_error(
770 770
 					sprintf(
771 771
 						__("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"),
772
-						get_class( $subsection ),
772
+						get_class($subsection),
773 773
 						$subsection_name,
774 774
 						$this->name()
775 775
 					)
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 			}
779 779
 		}
780 780
 
781
-		$this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before );
781
+		$this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before);
782 782
 
783 783
 		/*$subsections_before = array();
784 784
 		if( $subsection_name_to_target ){
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 				$this->_subsections = $new_subsections;
810 810
 			}
811 811
 		}*/
812
-		if( $this->_construction_finalized ){
813
-			foreach($this->_subsections as $name => $subsection){
812
+		if ($this->_construction_finalized) {
813
+			foreach ($this->_subsections as $name => $subsection) {
814 814
 				$subsection->_construct_finalize($this, $name);
815 815
 			}
816 816
 		}
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	/**
822 822
 	 * Just gets all validatable subsections to clean their sensitive data
823 823
 	 */
824
-	public function clean_sensitive_data(){
825
-		foreach($this->get_validatable_subsections() as $subsection){
824
+	public function clean_sensitive_data() {
825
+		foreach ($this->get_validatable_subsections() as $subsection) {
826 826
 			$subsection->clean_sensitive_data();
827 827
 		}
828 828
 	}
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	/**
833 833
 	 * @param string $form_submission_error_message
834 834
 	 */
835
-	public function set_submission_error_message( $form_submission_error_message = '' ) {
836
-		$this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' );
835
+	public function set_submission_error_message($form_submission_error_message = '') {
836
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso');
837 837
 	}
838 838
 
839 839
 
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	/**
851 851
 	 * @param string $form_submission_success_message
852 852
 	 */
853
-	public function set_submission_success_message( $form_submission_success_message ) {
854
-		$this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' );
853
+	public function set_submission_success_message($form_submission_success_message) {
854
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso');
855 855
 	}
856 856
 
857 857
 
@@ -873,10 +873,10 @@  discard block
 block discarded – undo
873 873
 	 * EE_Form_Input_Base::_set_default_html_name_if_empty
874 874
 	 * @return string
875 875
 	 */
876
-	public function html_name_prefix(){
877
-		if( $this->parent_section() instanceof EE_Form_Section_Proper ){
878
-			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
879
-		}else{
876
+	public function html_name_prefix() {
877
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
878
+			return $this->parent_section()->html_name_prefix().'['.$this->name().']';
879
+		} else {
880 880
 			return $this->name();
881 881
 		}
882 882
 	}
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * was set, which is probably nothing, or the classname)
888 888
 	 * @return string
889 889
 	 */
890
-	public function name(){
890
+	public function name() {
891 891
 		$this->ensure_construct_finalized_called();
892 892
 		return parent::name();
893 893
 	}
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 *
897 897
 	 * @return EE_Form_Section_Proper
898 898
 	 */
899
-	public function parent_section(){
899
+	public function parent_section() {
900 900
 		$this->ensure_construct_finalized_called();
901 901
 		return parent::parent_section();
902 902
 	}
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
 	 * make sure construction finalized was called, otherwise children might not be ready
906 906
 	 * @return void
907 907
 	 */
908
-	public function ensure_construct_finalized_called(){
909
-		if( ! $this->_construction_finalized ){
910
-			$this->_construct_finalize($this->_parent_section, $this->_name );
908
+	public function ensure_construct_finalized_called() {
909
+		if ( ! $this->_construction_finalized) {
910
+			$this->_construct_finalize($this->_parent_section, $this->_name);
911 911
 		}
912 912
 	}
913 913
 
@@ -919,17 +919,17 @@  discard block
 block discarded – undo
919 919
 	 * @param array $req_data
920 920
 	 * @return boolean
921 921
 	 */
922
-	public function form_data_present_in( $req_data = NULL ) {
923
-		if( $req_data === NULL){
922
+	public function form_data_present_in($req_data = NULL) {
923
+		if ($req_data === NULL) {
924 924
 			$req_data = $_POST;
925 925
 		}
926
-		foreach( $this->subsections() as $subsection ) {
927
-			if($subsection instanceof EE_Form_Input_Base ) {
928
-				if( $subsection->form_data_present_in( $req_data ) ) {
926
+		foreach ($this->subsections() as $subsection) {
927
+			if ($subsection instanceof EE_Form_Input_Base) {
928
+				if ($subsection->form_data_present_in($req_data)) {
929 929
 					return TRUE;
930 930
 				}
931
-			}elseif( $subsection instanceof EE_Form_Section_Proper ) {
932
-				if( $subsection->form_data_present_in( $req_data ) ) {
931
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
932
+				if ($subsection->form_data_present_in($req_data)) {
933 933
 					return TRUE;
934 934
 				}
935 935
 			}
@@ -946,14 +946,14 @@  discard block
 block discarded – undo
946 946
 	 */
947 947
 	public function get_validation_errors_accumulated() {
948 948
 		$validation_errors = $this->get_validation_errors();
949
-		foreach($this->get_validatable_subsections() as $subsection ) {
950
-			if( $subsection instanceof EE_Form_Section_Proper ) {
949
+		foreach ($this->get_validatable_subsections() as $subsection) {
950
+			if ($subsection instanceof EE_Form_Section_Proper) {
951 951
 				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
952 952
 			} else {
953
-				$validation_errors_on_this_subsection =  $subsection->get_validation_errors();
953
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
954 954
 			}
955
-			if( $validation_errors_on_this_subsection ){
956
-				$validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection );
955
+			if ($validation_errors_on_this_subsection) {
956
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
957 957
 			}
958 958
 		}
959 959
 		return $validation_errors;
Please login to merge, or discard this patch.
core/libraries/form_sections/payment_methods/EE_Billing_Info_Form.form.php 1 patch
Spacing   +10 added lines, -10 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
  *
4 4
  * EE_Billing_Info_Form
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author				Mike Nelson
12 12
  *
13 13
  */
14
-class EE_Billing_Info_Form extends EE_Form_Section_Proper{
14
+class EE_Billing_Info_Form extends EE_Form_Section_Proper {
15 15
 
16 16
 	/**
17 17
 	 * The payment method this billing form is for
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 * @param EE_Payment_Method $payment_method
27 27
 	 * @param array $options_array @see EE_Form_Section_Proper::__construct()
28 28
 	 */
29
-	public function __construct( EE_Payment_Method $payment_method, $options_array= array()){
29
+	public function __construct(EE_Payment_Method $payment_method, $options_array = array()) {
30 30
 		$this->_pm_instance = $payment_method;
31 31
 		$this->_layout_strategy = new EE_Div_Per_Section_Layout();
32
-		parent::__construct( $options_array );
32
+		parent::__construct($options_array);
33 33
 
34 34
 	}
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param EE_Payment_Method $payment_method
41 41
 	 * @return void
42 42
 	 */
43
-	public function set_payment_method( EE_Payment_Method $payment_method ){
43
+	public function set_payment_method(EE_Payment_Method $payment_method) {
44 44
 		$this->_pm_instance = $payment_method;
45 45
 	}
46 46
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Returns the instance of the payment method this billing form is for
51 51
 	 * @return EE_Payment_Method
52 52
 	 */
53
-	public function payment_method(){
53
+	public function payment_method() {
54 54
 		return $this->_pm_instance;
55 55
 	}
56 56
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 	 * payment_fields_autofilled_notice_html
61 61
 	 * @return string
62 62
 	 */
63
-	public function payment_fields_autofilled_notice_html(){
63
+	public function payment_fields_autofilled_notice_html() {
64 64
 		return  new EE_Form_Section_HTML(
65 65
 			EEH_HTML::p(
66
-				apply_filters( 'FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __( 'Payment fields have been autofilled because you are in debug mode', 'event_espresso' )),
66
+				apply_filters('FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __('Payment fields have been autofilled because you are in debug mode', 'event_espresso')),
67 67
 				'',
68 68
 				'important-notice'
69 69
 			)
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @return string
77 77
 	 */
78
-	public function html_class(){
79
-		return ! empty( $this->_html_class ) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form';
78
+	public function html_class() {
79
+		return ! empty($this->_html_class) ? $this->_html_class.' ee-billing-form' : 'ee-billing-form';
80 80
 	}
81 81
 
82 82
 
Please login to merge, or discard this patch.