@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * ------------------------------------------------------------------------ |
28 | 28 | */ |
29 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
29 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
30 | 30 | |
31 | 31 | class EEM_Extra_Meta extends EEM_Base { |
32 | 32 | |
33 | 33 | // private instance of the Attendee object |
34 | 34 | protected static $_instance = NULL; |
35 | 35 | |
36 | - protected function __construct( $timezone = NULL ) { |
|
37 | - $this->singular_item = __('Extra Meta','event_espresso'); |
|
38 | - $this->plural_item = __('Extra Metas','event_espresso'); |
|
36 | + protected function __construct($timezone = NULL) { |
|
37 | + $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
38 | + $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
39 | 39 | $this->_tables = array( |
40 | 40 | 'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
41 | 41 | ); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | )); |
52 | 52 | $this->_model_relations = array(); |
53 | - foreach($models_this_can_attach_to as $model){ |
|
53 | + foreach ($models_this_can_attach_to as $model) { |
|
54 | 54 | $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
55 | 55 | } |
56 | - parent::__construct( $timezone ); |
|
56 | + parent::__construct($timezone); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | - * Event Espresso |
|
5 | - * |
|
6 | - * Event Registration and Management Plugin for Wordpress |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @author Seth Shoultes |
|
10 | - * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
11 | - * @license @link http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing * * |
|
12 | - * @link http://www.eventespresso.com |
|
13 | - * @version 4.1 |
|
14 | - * |
|
15 | - * ------------------------------------------------------------------------ |
|
16 | - * |
|
17 | - * EEM_Message_Template |
|
18 | - * |
|
19 | - * |
|
20 | - * |
|
21 | - * @package Event Espresso |
|
22 | - * @subpackage includes/models/EEM_Message_Template.model.php |
|
23 | - * @author Darren Ethier |
|
24 | - * |
|
25 | - * |
|
26 | - * ------------------------------------------------------------------------ |
|
27 | - */ |
|
4 | + * Event Espresso |
|
5 | + * |
|
6 | + * Event Registration and Management Plugin for Wordpress |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @author Seth Shoultes |
|
10 | + * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
11 | + * @license @link http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing * * |
|
12 | + * @link http://www.eventespresso.com |
|
13 | + * @version 4.1 |
|
14 | + * |
|
15 | + * ------------------------------------------------------------------------ |
|
16 | + * |
|
17 | + * EEM_Message_Template |
|
18 | + * |
|
19 | + * |
|
20 | + * |
|
21 | + * @package Event Espresso |
|
22 | + * @subpackage includes/models/EEM_Message_Template.model.php |
|
23 | + * @author Darren Ethier |
|
24 | + * |
|
25 | + * |
|
26 | + * ------------------------------------------------------------------------ |
|
27 | + */ |
|
28 | 28 | class EEM_Message_Template extends EEM_Base { |
29 | 29 | //private instance of the EEM_Message_Template object |
30 | 30 | protected static $_instance = NULL; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | 4 | * Event Espresso |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | * @access protected |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - protected function __construct( $timezone = NULL ) { |
|
40 | - $this->singular_item = __('Message Template','event_espresso'); |
|
41 | - $this->plural_item = __('Message Templates','event_espresso'); |
|
39 | + protected function __construct($timezone = NULL) { |
|
40 | + $this->singular_item = __('Message Template', 'event_espresso'); |
|
41 | + $this->plural_item = __('Message Templates', 'event_espresso'); |
|
42 | 42 | |
43 | 43 | $this->_tables = array( |
44 | - 'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID' ) |
|
44 | + 'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID') |
|
45 | 45 | ); |
46 | 46 | $this->_fields = array( |
47 | 47 | 'Message_Template'=> array( |
48 | 48 | 'MTP_ID'=> new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')), |
49 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), FALSE, 0, 'Message_Template_Group' ), |
|
50 | - 'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default' ), |
|
51 | - 'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'),false,'admin' ), |
|
49 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), FALSE, 0, 'Message_Template_Group'), |
|
50 | + 'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'), |
|
51 | + 'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'), |
|
52 | 52 | 'MTP_content'=>new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, ''), |
53 | 53 | ) |
54 | 54 | ); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'Message_Template_Group' => new EE_Belongs_To_Relation() |
58 | 58 | ); |
59 | 59 | $this->_model_chain_to_wp_user = 'Message_Template_Group'; |
60 | - parent::__construct( $timezone ); |
|
60 | + parent::__construct($timezone); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 |
@@ -1,5 +1,6 @@ |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
2 | 2 | exit('NO direct script access allowed'); |
3 | +} |
|
3 | 4 | /** |
4 | 5 | * Event Espresso |
5 | 6 | * |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
3 | 5 | /** |
4 | 6 | * |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | |
18 | 18 | |
19 | 19 | /** |
20 | - * Status id in esp_status table that represents an approved payment |
|
21 | - */ |
|
20 | + * Status id in esp_status table that represents an approved payment |
|
21 | + */ |
|
22 | 22 | const status_id_approved = 'PAP'; |
23 | 23 | |
24 | 24 | |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | |
113 | 113 | /** |
114 | - * retrieve all payments from db for a particular transaction, optionally with |
|
114 | + * retrieve all payments from db for a particular transaction, optionally with |
|
115 | 115 | * a particular status |
116 | - * |
|
117 | - * @access public |
|
118 | - * @param $TXN_ID |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @param $TXN_ID |
|
119 | 119 | * @param string $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status |
120 | - * @return EE_Payment[] |
|
121 | - */ |
|
120 | + * @return EE_Payment[] |
|
121 | + */ |
|
122 | 122 | public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) { |
123 | 123 | // all payments for a TXN ordered chronologically |
124 | 124 | $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
148 | - * retrieve all payments from db between two dates |
|
149 | - * |
|
150 | - * @access public |
|
151 | - * @param string $start_date |
|
152 | - * @param string $end_date |
|
153 | - * @return EE_Payment[] |
|
154 | - */ |
|
148 | + * retrieve all payments from db between two dates |
|
149 | + * |
|
150 | + * @access public |
|
151 | + * @param string $start_date |
|
152 | + * @param string $end_date |
|
153 | + * @return EE_Payment[] |
|
154 | + */ |
|
155 | 155 | public function get_payments_made_between_dates( $start_date = '', $end_date = '' ) { |
156 | 156 | // initial values |
157 | 157 | $start_date = ! empty( $start_date ) ? $start_date : date('Y-m-d',current_time('timestamp')); |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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, current_time('timestamp'), $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, current_time('timestamp'), $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 | ) |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
90 | 90 | ); |
91 | 91 | $this->_model_chain_to_wp_user = 'Payment_Method'; |
92 | - parent::__construct( $timezone ); |
|
92 | + parent::__construct($timezone); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $PAY_txn_id_chq_nmbr |
102 | 102 | * @return EE_Payment |
103 | 103 | */ |
104 | - public function get_payment_by_txn_id_chq_nmbr( $PAY_txn_id_chq_nmbr ){ |
|
104 | + public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) { |
|
105 | 105 | return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr))); |
106 | 106 | } |
107 | 107 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @param string $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status |
118 | 118 | * @return EE_Payment[] |
119 | 119 | */ |
120 | - public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) { |
|
120 | + public function get_payments_for_transaction($TXN_ID = FALSE, $status_of_payment = null) { |
|
121 | 121 | // all payments for a TXN ordered chronologically |
122 | - $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
|
122 | + $query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC')); |
|
123 | 123 | // if provided with a status, search specifically for that status. Otherwise get them all |
124 | - if ( $status_of_payment ){ |
|
124 | + if ($status_of_payment) { |
|
125 | 125 | $query_params[0]['STS_ID'] = $status_of_payment; |
126 | 126 | } |
127 | 127 | // retrieve payments |
128 | - return $this->get_all ( $query_params ); |
|
128 | + return $this->get_all($query_params); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @param int $TXN_ID |
136 | 136 | * @return EE_Payment[] |
137 | 137 | */ |
138 | - public function get_approved_payments_for_transaction( $TXN_ID = 0 ) { |
|
139 | - return $this->get_payments_for_transaction( $TXN_ID, EEM_Payment::status_id_approved ); |
|
138 | + public function get_approved_payments_for_transaction($TXN_ID = 0) { |
|
139 | + return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved); |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | * @param string $end_date |
151 | 151 | * @return EE_Payment[] |
152 | 152 | */ |
153 | - public function get_payments_made_between_dates( $start_date = '', $end_date = '' ) { |
|
153 | + public function get_payments_made_between_dates($start_date = '', $end_date = '') { |
|
154 | 154 | // initial values |
155 | - $start_date = ! empty( $start_date ) ? $start_date : date('Y-m-d',current_time('timestamp')); |
|
156 | - $end_date = ! empty( $end_date ) ? $end_date : date('Y-m-d',current_time('timestamp')); |
|
155 | + $start_date = ! empty($start_date) ? $start_date : date('Y-m-d', current_time('timestamp')); |
|
156 | + $end_date = ! empty($end_date) ? $end_date : date('Y-m-d', current_time('timestamp')); |
|
157 | 157 | // make sure our timestamps start and end right at the boundaries for each day |
158 | - $start_date = date( 'Y-m-d', strtotime( $start_date )) . ' 00:00:00'; |
|
159 | - $end_date = date( 'Y-m-d', strtotime( $end_date )) . ' 23:59:59'; |
|
158 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
159 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
160 | 160 | // convert to timestamps |
161 | - $start_date = strtotime( $start_date ); |
|
162 | - $end_date = strtotime( $end_date ); |
|
161 | + $start_date = strtotime($start_date); |
|
162 | + $end_date = strtotime($end_date); |
|
163 | 163 | // make sure our start date is the lowest value and vice versa |
164 | - $start_date = min( $start_date, $end_date ); |
|
165 | - $end_date = max( $start_date, $end_date ); |
|
166 | - return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date)))); |
|
164 | + $start_date = min($start_date, $end_date); |
|
165 | + $end_date = max($start_date, $end_date); |
|
166 | + return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date)))); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -173,35 +173,35 @@ discard block |
||
173 | 173 | * returns a string for the approved status |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - function approved_status(){ |
|
176 | + function approved_status() { |
|
177 | 177 | return self::status_id_approved; |
178 | 178 | } |
179 | 179 | /** |
180 | 180 | * returns a string for the pending status |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - function pending_status(){ |
|
183 | + function pending_status() { |
|
184 | 184 | return self::status_id_pending; |
185 | 185 | } |
186 | 186 | /** |
187 | 187 | * returns a string for the cancelled status |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - function cancelled_status(){ |
|
190 | + function cancelled_status() { |
|
191 | 191 | return self::status_id_cancelled; |
192 | 192 | } |
193 | 193 | /** |
194 | 194 | * returns a string for the failed status |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - function failed_status(){ |
|
197 | + function failed_status() { |
|
198 | 198 | return self::status_id_failed; |
199 | 199 | } |
200 | 200 | /** |
201 | 201 | * returns a string for the declined status |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - function declined_status(){ |
|
204 | + function declined_status() { |
|
205 | 205 | return self::status_id_declined; |
206 | 206 | } |
207 | 207 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
3 | 5 | require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
4 | 6 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * This returns a wpdb->results array of all registration date month and years matching the incoming query params and grouped by month and year. |
203 | 203 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
204 | - * @return wpdb results array |
|
204 | + * @return stdClass[] results array |
|
205 | 205 | */ |
206 | 206 | public function get_reg_months_and_years( $where_params ) { |
207 | 207 | $query_params[0] = $where_params; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @param $TXN_ID |
256 | 256 | * @param $ATT_ID |
257 | 257 | * @param $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
258 | - * @return mixed array on success, FALSE on fail |
|
258 | + * @return EE_Soft_Delete_Base_Class|null array on success, FALSE on fail |
|
259 | 259 | */ |
260 | 260 | public function get_registration_for_transaction_attendee( $TXN_ID = FALSE, $ATT_ID = FALSE, $att_nmbr = FALSE ) { |
261 | 261 | return $this->get_one(array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | * 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) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Even tID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, current_time('timestamp'), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Final Price of registration','event_espresso'), false, 0), |
|
112 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
113 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
114 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
115 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
116 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
117 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
118 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Even tID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, current_time('timestamp'), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Final Price of registration', 'event_espresso'), false, 0), |
|
112 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
113 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
116 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
117 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
118 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
119 | 119 | ) |
120 | 120 | ); |
121 | 121 | $this->_model_relations = array( |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | ); |
130 | 130 | $this->_model_chain_to_wp_user = 'Event'; |
131 | 131 | |
132 | - parent::__construct( $timezone ); |
|
132 | + parent::__construct($timezone); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | * @param bool $translated If true will return the values as singular localized strings |
144 | 144 | * @return array |
145 | 145 | */ |
146 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
147 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
148 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
146 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
147 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
148 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | * @param array $exclude |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - private function _get_registration_status_array( $exclude = array() ) { |
|
159 | + private function _get_registration_status_array($exclude = array()) { |
|
160 | 160 | //in the very rare circumstance that we are deleting a model's table's data |
161 | 161 | //and the table hasn't actually been created, this could have an error |
162 | 162 | global $wpdb; |
163 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
164 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
165 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
166 | - $results = $wpdb->get_results( $SQL ); |
|
163 | + EE_Registry::instance()->load_helper('Activation'); |
|
164 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
165 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
166 | + $results = $wpdb->get_results($SQL); |
|
167 | 167 | self::$_reg_status = array(); |
168 | - foreach ( $results as $status ) { |
|
169 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
170 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
168 | + foreach ($results as $status) { |
|
169 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
170 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
183 | 183 | * @return wpdb results array |
184 | 184 | */ |
185 | - public function get_reg_months_and_years( $where_params ) { |
|
185 | + public function get_reg_months_and_years($where_params) { |
|
186 | 186 | $query_params[0] = $where_params; |
187 | 187 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
188 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
188 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
189 | 189 | $columns_to_select = array( |
190 | 190 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
191 | 191 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
192 | 192 | ); |
193 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
193 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | * @param int $ATT_ID |
203 | 203 | * @return EE_Registration[] |
204 | 204 | */ |
205 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
206 | - if ( ! $ATT_ID ) { |
|
205 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
206 | + if ( ! $ATT_ID) { |
|
207 | 207 | return FALSE; |
208 | 208 | } |
209 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
209 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | * @param string $REG_url_link |
218 | 218 | * @return EE_Registration |
219 | 219 | */ |
220 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
221 | - if(!$REG_url_link){ |
|
220 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
221 | + if ( ! $REG_url_link) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @param $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
237 | 237 | * @return mixed array on success, FALSE on fail |
238 | 238 | */ |
239 | - public function get_registration_for_transaction_attendee( $TXN_ID = FALSE, $ATT_ID = FALSE, $att_nmbr = FALSE ) { |
|
239 | + public function get_registration_for_transaction_attendee($TXN_ID = FALSE, $ATT_ID = FALSE, $att_nmbr = FALSE) { |
|
240 | 240 | return $this->get_one(array( |
241 | 241 | array( |
242 | 242 | 'TXN_ID'=>$TXN_ID, |
243 | 243 | 'ATT_ID'=>$ATT_ID), |
244 | - 'limit'=>array($att_nmbr-1,1) |
|
244 | + 'limit'=>array($att_nmbr - 1, 1) |
|
245 | 245 | )); |
246 | 246 | } |
247 | 247 | |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
254 | 254 | * @return stdClass[] with properties regDate and total |
255 | 255 | */ |
256 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
256 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
257 | 257 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
258 | - $where = array('REG_date'=>array('>=',$sql_date) ); |
|
258 | + $where = array('REG_date'=>array('>=', $sql_date)); |
|
259 | 259 | |
260 | - if ( ! EE_Registry::instance()->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
260 | + if ( ! EE_Registry::instance()->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
261 | 261 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
262 | 262 | } |
263 | 263 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | ), |
270 | 270 | OBJECT, |
271 | 271 | array( |
272 | - 'regDate'=>array('DATE(Registration.REG_date)','%s'), |
|
273 | - 'total'=>array('count(REG_ID)','%d') |
|
272 | + 'regDate'=>array('DATE(Registration.REG_date)', '%s'), |
|
273 | + 'total'=>array('count(REG_ID)', '%d') |
|
274 | 274 | )); |
275 | 275 | return $results; |
276 | 276 | } |
@@ -284,21 +284,21 @@ discard block |
||
284 | 284 | * @access public |
285 | 285 | * @return stdClass[] each with properties event_name, reg_limit, and total |
286 | 286 | */ |
287 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
287 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
288 | 288 | $date_sql = date("Y-m-d H:i:s", strtotime($period)); |
289 | - $where = array( 'REG_date'=>array('>=',$date_sql ) ); |
|
290 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
289 | + $where = array('REG_date'=>array('>=', $date_sql)); |
|
290 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
291 | 291 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
292 | 292 | } |
293 | 293 | $results = $this->_get_all_wpdb_results(array( |
294 | 294 | $where, |
295 | 295 | 'group_by'=>'Event.EVT_name', |
296 | 296 | 'order_by'=>'Event.EVT_name', |
297 | - 'limit'=>array(0,24)), |
|
297 | + 'limit'=>array(0, 24)), |
|
298 | 298 | OBJECT, |
299 | 299 | array( |
300 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
301 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
300 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
301 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
302 | 302 | ) |
303 | 303 | ); |
304 | 304 | |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | * @param int $TXN_ID |
313 | 313 | * @return EE_Registration |
314 | 314 | */ |
315 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = FALSE){ |
|
316 | - if( ! $TXN_ID ){ |
|
315 | + public function get_primary_registration_for_transaction_ID($TXN_ID = FALSE) { |
|
316 | + if ( ! $TXN_ID) { |
|
317 | 317 | return false; |
318 | 318 | } |
319 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
319 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | * @param boolean $for_incomplete_payments |
329 | 329 | * @return int |
330 | 330 | */ |
331 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
331 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
332 | 332 | // we only count approved registrations towards registration limits |
333 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
334 | - if( $for_incomplete_payments ){ |
|
335 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
333 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
334 | + if ($for_incomplete_payments) { |
|
335 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | return $this->count($query_params); |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | /** |
200 | - * retrieve ALL registrations for a particular Attendee from db |
|
201 | - * @access public |
|
202 | - * @param int $ATT_ID |
|
203 | - * @return EE_Registration[] |
|
204 | - */ |
|
200 | + * retrieve ALL registrations for a particular Attendee from db |
|
201 | + * @access public |
|
202 | + * @param int $ATT_ID |
|
203 | + * @return EE_Registration[] |
|
204 | + */ |
|
205 | 205 | public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
206 | 206 | if ( ! $ATT_ID ) { |
207 | 207 | return FALSE; |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | |
229 | 229 | |
230 | 230 | /** |
231 | - * retrieve registration for a specific transaction attendee from db |
|
232 | - * |
|
233 | - * @access public |
|
234 | - * @param $TXN_ID |
|
235 | - * @param $ATT_ID |
|
236 | - * @param $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
|
237 | - * @return mixed array on success, FALSE on fail |
|
238 | - */ |
|
231 | + * retrieve registration for a specific transaction attendee from db |
|
232 | + * |
|
233 | + * @access public |
|
234 | + * @param $TXN_ID |
|
235 | + * @param $ATT_ID |
|
236 | + * @param $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
|
237 | + * @return mixed array on success, FALSE on fail |
|
238 | + */ |
|
239 | 239 | public function get_registration_for_transaction_attendee( $TXN_ID = FALSE, $ATT_ID = FALSE, $att_nmbr = FALSE ) { |
240 | 240 | return $this->get_one(array( |
241 | 241 | array( |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | |
248 | 248 | |
249 | 249 | /** |
250 | - * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
250 | + * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
251 | 251 | * (doesn't utilize models because it's a fairly specialized query) |
252 | - * @access public |
|
252 | + * @access public |
|
253 | 253 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
254 | 254 | * @return stdClass[] with properties regDate and total |
255 | - */ |
|
255 | + */ |
|
256 | 256 | public function get_registrations_per_day_report( $period = '-1 month' ) { |
257 | 257 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
258 | 258 | $where = array('REG_date'=>array('>=',$sql_date) ); |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | |
281 | 281 | |
282 | 282 | /** |
283 | - * get the number of registrations per event for the Registration Admin page Reports Tab |
|
284 | - * @access public |
|
283 | + * get the number of registrations per event for the Registration Admin page Reports Tab |
|
284 | + * @access public |
|
285 | 285 | * @return stdClass[] each with properties event_name, reg_limit, and total |
286 | - */ |
|
286 | + */ |
|
287 | 287 | public function get_registrations_per_event_report( $period = '-1 month' ) { |
288 | 288 | $date_sql = date("Y-m-d H:i:s", strtotime($period)); |
289 | 289 | $where = array( 'REG_date'=>array('>=',$date_sql ) ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | require_once( EE_MODELS . 'EEM_Base.model.php'); |
3 | 5 | /** |
4 | 6 | * EEM_Soft_Delete_Base |
@@ -47,7 +49,7 @@ discard block |
||
47 | 49 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
48 | 50 | if($field){ |
49 | 51 | return $field->get_name(); |
50 | - }else{ |
|
52 | + } else{ |
|
51 | 53 | throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
52 | 54 | } |
53 | 55 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
244 | 244 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
245 | 245 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
246 | - * @return boolean success |
|
246 | + * @return integer success |
|
247 | 247 | */ |
248 | 248 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
249 | 249 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
259 | 259 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
260 | 260 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
261 | - * @return boolean success |
|
261 | + * @return integer success |
|
262 | 262 | */ |
263 | 263 | public function delete_permanently_by_ID($ID=FALSE, $allow_blocking = true){ |
264 | 264 | $query_params = array(); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | /** |
353 | 353 | * Updates all the items of this model which match the $query params, regardless of whether |
354 | 354 | * they've been soft-deleted or not |
355 | - * @param array $field_n_values like EEM_Base::update's $fields_n_value |
|
355 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
356 | 356 | * @param array $query_params like EEM_base::get_all's $query_params |
357 | 357 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
358 | 358 | * in this model's entity map according to $fields_n_values that match $query_params. This |
@@ -1,5 +1,5 @@ discard block |
||
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 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - require_once( EE_MODELS . 'strategies/EE_Soft_Delete_Where_Conditions.strategy.php'); |
|
35 | - if( ! $this->_default_where_conditions_strategy){ |
|
34 | + require_once(EE_MODELS.'strategies/EE_Soft_Delete_Where_Conditions.strategy.php'); |
|
35 | + if ( ! $this->_default_where_conditions_strategy) { |
|
36 | 36 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
37 | 37 | } |
38 | 38 | parent::__construct($timezone); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - public function deleted_field_name(){ |
|
46 | + public function deleted_field_name() { |
|
47 | 47 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
48 | - if($field){ |
|
48 | + if ($field) { |
|
49 | 49 | return $field->get_name(); |
50 | - }else{ |
|
51 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
50 | + } else { |
|
51 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param array $query_params like EEM_Base::get_all |
60 | 60 | * @return EE_Soft_Delete_Base_Class[] |
61 | 61 | */ |
62 | - public function get_all($query_params = array()){ |
|
62 | + public function get_all($query_params = array()) { |
|
63 | 63 | return parent::get_all($query_params); |
64 | 64 | } |
65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param array $query_params like EEM_Base::get_all's $query_params |
70 | 70 | * @return EE_Soft_Delete_Base_Class |
71 | 71 | */ |
72 | - public function get_one($query_params = array()){ |
|
72 | + public function get_one($query_params = array()) { |
|
73 | 73 | return parent::get_one($query_params); |
74 | 74 | } |
75 | 75 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param array $query_params like EEM_Base::get_all's $query_params |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_deleted($query_params = array()){ |
|
80 | + public function get_one_deleted($query_params = array()) { |
|
81 | 81 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
82 | 82 | return parent::get_one($query_params); |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param array $query_params like EEM_base::get_all's $query_params |
88 | 88 | * @return EE_Soft_Delete_Base_Class |
89 | 89 | */ |
90 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
90 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
91 | 91 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
92 | 92 | return parent::get_one($query_params); |
93 | 93 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param int|string $id |
109 | 109 | * @return EE_Soft_Delete_Base_Class |
110 | 110 | */ |
111 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
111 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
112 | 112 | return parent::get_one_by_ID($id); |
113 | 113 | } |
114 | 114 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param boolean $distinct |
120 | 120 | * @return int count |
121 | 121 | */ |
122 | - public function count($query_params = array(), $field_to_count = null, $distinct = false){ |
|
122 | + public function count($query_params = array(), $field_to_count = null, $distinct = false) { |
|
123 | 123 | //just calls parent, but changes PHP docs for this function |
124 | 124 | return parent::count($query_params, $field_to_count, $distinct); |
125 | 125 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
132 | 132 | * @return int |
133 | 133 | */ |
134 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
134 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
135 | 135 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
136 | 136 | return parent::count($query_params, $field_to_count, $distinct); |
137 | 137 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @param array $query_params like EEM_Base::get_all's $query_params |
142 | 142 | * @return array like EEM_Base::get_all's $query_params |
143 | 143 | */ |
144 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
145 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
146 | - $query_params[0][$deletedFlagFieldName]=true; |
|
144 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
145 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
146 | + $query_params[0][$deletedFlagFieldName] = true; |
|
147 | 147 | return $query_params; |
148 | 148 | } |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array $query_params |
153 | 153 | * @return array |
154 | 154 | */ |
155 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
155 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
156 | 156 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
157 | 157 | } |
158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param array $query_params |
162 | 162 | * @return array |
163 | 163 | */ |
164 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
164 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
165 | 165 | $query_params['default_where_conditions'] = 'other_models_only'; |
166 | 166 | return $query_params; |
167 | 167 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
174 | 174 | * @return int |
175 | 175 | */ |
176 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
176 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
177 | 177 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
178 | - return parent::count($query_params,$field_to_count, $distinct); |
|
178 | + return parent::count($query_params, $field_to_count, $distinct); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @param string $field_to_sum name of field |
185 | 185 | * @return int count |
186 | 186 | */ |
187 | - public function sum($query_params =null,$field_to_sum= null){ |
|
187 | + public function sum($query_params = null, $field_to_sum = null) { |
|
188 | 188 | //just calls parent, but changes PHP doc |
189 | - return parent::sum($query_params,$field_to_sum); |
|
189 | + return parent::sum($query_params, $field_to_sum); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param string $field_to_sum |
197 | 197 | * @return int |
198 | 198 | */ |
199 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
199 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
200 | 200 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
201 | 201 | return parent::sum($query_params, $field_to_sum); |
202 | 202 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string $field_to_sum |
208 | 208 | * @reutrn int |
209 | 209 | */ |
210 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
210 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
211 | 211 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
212 | 212 | parent::sum($query_params, $field_to_sum); |
213 | 213 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param array $query_params like EEM_Base::get_all |
218 | 218 | * @return EE_Soft_Delete_Base_Class[] |
219 | 219 | */ |
220 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
220 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
221 | 221 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
222 | 222 | return parent::get_all($query_params); |
223 | 223 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param array $query_params like EEM_Base::get_all |
228 | 228 | * @return EE_Soft_Delete_Base_Class[] |
229 | 229 | */ |
230 | - public function get_all_deleted($query_params = array()){ |
|
230 | + public function get_all_deleted($query_params = array()) { |
|
231 | 231 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
232 | 232 | return parent::get_all($query_params); |
233 | 233 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
246 | 246 | * @return boolean success |
247 | 247 | */ |
248 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
248 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
249 | 249 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
250 | 250 | return parent::delete($query_params, $allow_blocking); |
251 | 251 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
261 | 261 | * @return boolean success |
262 | 262 | */ |
263 | - public function delete_permanently_by_ID($ID=FALSE, $allow_blocking = true){ |
|
263 | + public function delete_permanently_by_ID($ID = FALSE, $allow_blocking = true) { |
|
264 | 264 | $query_params = array(); |
265 | 265 | $query_params[0] = array($this->get_primary_key_field()->get_name() => $ID); |
266 | 266 | $query_params['limit'] = 1; |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param mixed $ID value of the primary_key or primary_text_key |
275 | 275 | * @return boolean success |
276 | 276 | */ |
277 | - public function delete_by_ID($ID){ |
|
278 | - return $this->delete_or_restore_by_ID(true,$ID); |
|
277 | + public function delete_by_ID($ID) { |
|
278 | + return $this->delete_or_restore_by_ID(true, $ID); |
|
279 | 279 | } |
280 | 280 | /** |
281 | 281 | * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @param mixed $ID int if primary key is an int, string otherwise |
284 | 284 | * @return boolean success |
285 | 285 | */ |
286 | - public function restore_by_ID($ID=FALSE){ |
|
287 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
286 | + public function restore_by_ID($ID = FALSE) { |
|
287 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
288 | 288 | } |
289 | 289 | /** |
290 | 290 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -293,15 +293,15 @@ discard block |
||
293 | 293 | * @param mixed $ID int if primary key is an int, string otherwise |
294 | 294 | * @return boolean |
295 | 295 | */ |
296 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
297 | - if ( ! $ID ) { |
|
296 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
297 | + if ( ! $ID) { |
|
298 | 298 | return FALSE; |
299 | 299 | } |
300 | - $primaryKeyName=$this->primary_key_name(); |
|
300 | + $primaryKeyName = $this->primary_key_name(); |
|
301 | 301 | // retrieve a particular transaction |
302 | 302 | $query_params = array(); |
303 | - $query_params[0] = array( $primaryKeyName => $ID ); |
|
304 | - if ( $this->delete_or_restore ($delete, $query_params )) { |
|
303 | + $query_params[0] = array($primaryKeyName => $ID); |
|
304 | + if ($this->delete_or_restore($delete, $query_params)) { |
|
305 | 305 | return TRUE; |
306 | 306 | } else { |
307 | 307 | return FALSE; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param bool $block_deletes |
320 | 320 | * @return boolean |
321 | 321 | */ |
322 | - public function delete($query_params = array(), $block_deletes = false){ |
|
322 | + public function delete($query_params = array(), $block_deletes = false) { |
|
323 | 323 | //no matter what, we WON'T block soft deletes. |
324 | 324 | return $this->delete_or_restore(true, $query_params); |
325 | 325 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param array $query_params like EEM_Base::get_all |
331 | 331 | * @return boolean |
332 | 332 | */ |
333 | - public function restore($query_params = array()){ |
|
333 | + public function restore($query_params = array()) { |
|
334 | 334 | return $this->delete_or_restore(false, $query_params); |
335 | 335 | } |
336 | 336 | /** |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | * @param array $query_params like EEM_Base::get_all |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
343 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
342 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
343 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
344 | 344 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
345 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
345 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
346 | 346 | return TRUE; |
347 | 347 | } else { |
348 | 348 | return FALSE; |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * be aware that model objects being used could get out-of-sync with the database |
361 | 361 | * @return int number of items updated |
362 | 362 | */ |
363 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
363 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
364 | 364 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
365 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
365 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * be aware that model objects being used could get out-of-sync with the database |
378 | 378 | * @return int how many items were updated |
379 | 379 | */ |
380 | - public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
381 | - return parent::update($fields_n_values,$query_params, $keep_model_objs_in_sync ); |
|
380 | + public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
381 | + return parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function localized_status( $statuses, $plural = FALSE, $schema = 'upper' ) { |
79 | 79 | //note these are all in lower case because ucwords() on upper case will NOT convert. |
80 | 80 | $translation_array = array( |
81 | - EEM_Registration::status_id_pending_payment => array( |
|
81 | + EEM_Registration::status_id_pending_payment => array( |
|
82 | 82 | __('pending payment', 'event_espresso'), //singular |
83 | 83 | __('pending payments', 'event_espresso') //plural |
84 | 84 | ), |
@@ -203,37 +203,37 @@ discard block |
||
203 | 203 | __('postponed', 'event_espresso'), |
204 | 204 | __('postponed', 'event_espresso') |
205 | 205 | ) |
206 | - ); |
|
206 | + ); |
|
207 | 207 | |
208 | 208 | $translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array ); |
209 | 209 | |
210 | 210 | if ( !is_array($statuses) ) |
211 | 211 | throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
212 | 212 | |
213 | - $translation = array(); |
|
213 | + $translation = array(); |
|
214 | 214 | |
215 | - foreach ( $statuses as $id => $code ) { |
|
216 | - if ( isset( $translation_array[$id] ) ) { |
|
217 | - $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
|
218 | - } else { |
|
219 | - $translation[$id] = $code; |
|
220 | - } |
|
215 | + foreach ( $statuses as $id => $code ) { |
|
216 | + if ( isset( $translation_array[$id] ) ) { |
|
217 | + $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
|
218 | + } else { |
|
219 | + $translation[$id] = $code; |
|
220 | + } |
|
221 | 221 | |
222 | - //schema |
|
223 | - switch ( $schema ) { |
|
224 | - case 'lower' : |
|
225 | - $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
226 | - break; |
|
227 | - case 'sentence' : |
|
228 | - $translation[$id] = ucwords( $translation[$id] ); |
|
229 | - break; |
|
230 | - case 'upper' : |
|
231 | - $translation[$id] = strtoupper( $translation[$id] ); |
|
232 | - break; |
|
233 | - } |
|
234 | - } |
|
222 | + //schema |
|
223 | + switch ( $schema ) { |
|
224 | + case 'lower' : |
|
225 | + $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
226 | + break; |
|
227 | + case 'sentence' : |
|
228 | + $translation[$id] = ucwords( $translation[$id] ); |
|
229 | + break; |
|
230 | + case 'upper' : |
|
231 | + $translation[$id] = strtoupper( $translation[$id] ); |
|
232 | + break; |
|
233 | + } |
|
234 | + } |
|
235 | 235 | |
236 | - return $translation; |
|
236 | + return $translation; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -207,8 +209,9 @@ discard block |
||
207 | 209 | |
208 | 210 | $translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array ); |
209 | 211 | |
210 | - if ( !is_array($statuses) ) |
|
211 | - throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
|
212 | + if ( !is_array($statuses) ) { |
|
213 | + throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
|
214 | + } |
|
212 | 215 | |
213 | 216 | $translation = array(); |
214 | 217 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * ------------------------------------------------------------------------ |
15 | 15 | */ |
16 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
16 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
17 | 17 | /** |
18 | 18 | * |
19 | 19 | * Class EEM_Status |
@@ -32,27 +32,27 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @return EEM_Status |
34 | 34 | */ |
35 | - protected function __construct( $timezone = NULL ) { |
|
36 | - $this->singular_item = __('Status','event_espresso'); |
|
37 | - $this->plural_item = __('Stati','event_espresso'); |
|
35 | + protected function __construct($timezone = NULL) { |
|
36 | + $this->singular_item = __('Status', 'event_espresso'); |
|
37 | + $this->plural_item = __('Stati', 'event_espresso'); |
|
38 | 38 | $this->_tables = array( |
39 | 39 | 'Status'=> new EE_Primary_Table('esp_status', 'STS_ID') |
40 | 40 | ); |
41 | 41 | $this->_fields = array( |
42 | 42 | 'Status'=>array( |
43 | - 'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID','event_espresso')), |
|
44 | - 'STS_code'=>new EE_Plain_Text_Field('STS_code',__('Status Code','event_espresso'),false, ''), |
|
43 | + 'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), |
|
44 | + 'STS_code'=>new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), |
|
45 | 45 | 'STS_type'=>new EE_Enum_Text_Field('STS_type', __("Type", "event_espresso"), false, 'event', |
46 | 46 | array( |
47 | - 'event'=> __("Event", "event_espresso"),//deprecated |
|
47 | + 'event'=> __("Event", "event_espresso"), //deprecated |
|
48 | 48 | 'registration'=> __("Registration", "event_espresso"), |
49 | 49 | 'transaction'=> __("Transaction", "event_espresso"), |
50 | 50 | 'payment'=> __("Payment", "event_espresso"), |
51 | 51 | 'email'=> __("Email", "event_espresso") |
52 | 52 | )), |
53 | - 'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?','event_espresso'), false), |
|
53 | + 'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false), |
|
54 | 54 | 'STS_desc'=>new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), |
55 | - 'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false,false) |
|
55 | + 'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false) |
|
56 | 56 | )); |
57 | 57 | $this->_model_relations = array( |
58 | 58 | 'Registration'=>new EE_Has_Many_Relation(), |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'Payment'=>new EE_Has_Many_Relation() |
61 | 61 | ); |
62 | 62 | |
63 | - parent::__construct( $timezone ); |
|
63 | + parent::__construct($timezone); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @throws EE_Error |
74 | 74 | * @return array an array of translated strings for the incoming status id. |
75 | 75 | */ |
76 | - public function localized_status( $statuses, $plural = FALSE, $schema = 'upper' ) { |
|
76 | + public function localized_status($statuses, $plural = FALSE, $schema = 'upper') { |
|
77 | 77 | //note these are all in lower case because ucwords() on upper case will NOT convert. |
78 | 78 | $translation_array = array( |
79 | 79 | EEM_Registration::status_id_pending_payment => array( |
@@ -203,30 +203,30 @@ discard block |
||
203 | 203 | ) |
204 | 204 | ); |
205 | 205 | |
206 | - $translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array ); |
|
206 | + $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array); |
|
207 | 207 | |
208 | - if ( !is_array($statuses) ) |
|
209 | - throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
|
208 | + if ( ! is_array($statuses)) |
|
209 | + throw new EE_Error(__('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso')); |
|
210 | 210 | |
211 | 211 | $translation = array(); |
212 | 212 | |
213 | - foreach ( $statuses as $id => $code ) { |
|
214 | - if ( isset( $translation_array[$id] ) ) { |
|
213 | + foreach ($statuses as $id => $code) { |
|
214 | + if (isset($translation_array[$id])) { |
|
215 | 215 | $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
216 | 216 | } else { |
217 | 217 | $translation[$id] = $code; |
218 | 218 | } |
219 | 219 | |
220 | 220 | //schema |
221 | - switch ( $schema ) { |
|
221 | + switch ($schema) { |
|
222 | 222 | case 'lower' : |
223 | - $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
223 | + $translation[$id] = strtolower($translation[$id]); //even though these start in lower case, this will catch any statuses added via filter. |
|
224 | 224 | break; |
225 | 225 | case 'sentence' : |
226 | - $translation[$id] = ucwords( $translation[$id] ); |
|
226 | + $translation[$id] = ucwords($translation[$id]); |
|
227 | 227 | break; |
228 | 228 | case 'upper' : |
229 | - $translation[$id] = strtoupper( $translation[$id] ); |
|
229 | + $translation[$id] = strtoupper($translation[$id]); |
|
230 | 230 | break; |
231 | 231 | } |
232 | 232 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -89,7 +91,7 @@ discard block |
||
89 | 91 | global $wpdb; |
90 | 92 | if( $term_taxonomy_id ){ |
91 | 93 | $second_operand = $wpdb->prepare('%d',$term_taxonomy_id); |
92 | - }else{ |
|
94 | + } else{ |
|
93 | 95 | $second_operand = 'tr.term_taxonomy_id'; |
94 | 96 | } |
95 | 97 | $rows_affected = $this->_do_wpdb_query( 'query' , array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
@@ -21,24 +21,24 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Term_Relationship extends EEM_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Term Relationship','event_espresso'); |
|
33 | - $this->plural_item = __('Term Relationships','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Term Relationship', 'event_espresso'); |
|
33 | + $this->plural_item = __('Term Relationships', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Term_Relationship'=> new EE_Primary_Table('term_relationships') |
36 | 36 | ); |
37 | 37 | $this->_fields = array( |
38 | 38 | 'Term_Relationship'=>array( |
39 | - 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID','event_espresso'), false,0,array('Event','Venue','Attendee')), |
|
40 | - 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
41 | - 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0) |
|
39 | + 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID', 'event_espresso'), false, 0, array('Event', 'Venue', 'Attendee')), |
|
40 | + 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID', 'event_espresso'), false, 0, 'Term_Taxonomy'), |
|
41 | + 'term_order'=>new EE_Integer_Field('term_order', __('Term Order', 'event_espresso'), false, 0) |
|
42 | 42 | )); |
43 | 43 | $this->_model_relations = array( |
44 | 44 | 'Event'=>new EE_Belongs_To_Relation(), |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | 'Term_Taxonomy'=>new EE_Belongs_To_Relation() |
48 | 48 | ); |
49 | 49 | $this->_indexes = array( |
50 | - 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id','term_taxonomy_id')) |
|
50 | + 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')) |
|
51 | 51 | ); |
52 | 52 | |
53 | - parent::__construct( $timezone ); |
|
53 | + parent::__construct($timezone); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | * @global type $wpdb |
60 | 60 | * @return int the number of rows affected |
61 | 61 | */ |
62 | - public function update_term_taxonomy_counts($term_taxonomy_id = NULL){ |
|
62 | + public function update_term_taxonomy_counts($term_taxonomy_id = NULL) { |
|
63 | 63 | //because this uses a subquery and sometimes assigning to column to be another column's |
64 | 64 | //value, we just write the SQL directly. |
65 | 65 | global $wpdb; |
66 | - if( $term_taxonomy_id ){ |
|
67 | - $second_operand = $wpdb->prepare('%d',$term_taxonomy_id); |
|
68 | - }else{ |
|
66 | + if ($term_taxonomy_id) { |
|
67 | + $second_operand = $wpdb->prepare('%d', $term_taxonomy_id); |
|
68 | + } else { |
|
69 | 69 | $second_operand = 'tr.term_taxonomy_id'; |
70 | 70 | } |
71 | - $rows_affected = $this->_do_wpdb_query( 'query' , array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
72 | -from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)" ) ); |
|
71 | + $rows_affected = $this->_do_wpdb_query('query', array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
72 | +from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)")); |
|
73 | 73 | return $rows_affected; |
74 | 74 | } |
75 | 75 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function insert($field_n_values) { |
83 | 83 | $return = parent::insert($field_n_values); |
84 | - if( isset( $field_n_values[ 'term_taxonomy_id' ] ) ) { |
|
85 | - $this->update_term_taxonomy_counts($field_n_values[ 'term_taxonomy_id' ] ); |
|
84 | + if (isset($field_n_values['term_taxonomy_id'])) { |
|
85 | + $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
86 | 86 | } |
87 | 87 | return $return; |
88 | 88 | } |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @return int |
99 | 99 | */ |
100 | 100 | public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
101 | - $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
102 | - if( $count ){ |
|
101 | + $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
102 | + if ($count) { |
|
103 | 103 | $this->update_term_taxonomy_counts(); |
104 | 104 | } |
105 | 105 | return $count; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function delete($query_params, $allow_blocking = true) { |
115 | 115 | $count = parent::delete($query_params, $allow_blocking); |
116 | - if( $count ){ |
|
116 | + if ($count) { |
|
117 | 117 | $this->update_term_taxonomy_counts(); |
118 | 118 | } |
119 | 119 | return $count; |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -131,8 +133,9 @@ discard block |
||
131 | 133 | 'tickets_remaining'=>array('Ticket.TKT_qty-Ticket.TKT_sold','%d'),//note! calculations based on TKT_qty are dangerous because -1 means infinity in the db! |
132 | 134 | 'initially_available'=>array('Ticket.TKT_qty','%d'))); |
133 | 135 | |
134 | - if ( empty( $remaining_per_ticket ) ) |
|
135 | - return FALSE; |
|
136 | + if ( empty( $remaining_per_ticket ) ) { |
|
137 | + return FALSE; |
|
138 | + } |
|
136 | 139 | |
137 | 140 | |
138 | 141 | foreach($remaining_per_ticket as $remaining){ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | * @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) |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - protected function __construct( $timezone ) { |
|
40 | - $this->singular_item = __('Ticket','event_espresso'); |
|
41 | - $this->plural_item = __('Tickets','event_espresso'); |
|
39 | + protected function __construct($timezone) { |
|
40 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
41 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
42 | 42 | |
43 | 43 | $this->_tables = array( |
44 | 44 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
45 | 45 | ); |
46 | 46 | $this->_fields = array( |
47 | 47 | 'Ticket'=>array( |
48 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
49 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
48 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
49 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
50 | 50 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
51 | - 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
52 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, current_time('timestamp'), $timezone ), |
|
53 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, current_time('timestamp'), $timezone ), |
|
54 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
55 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, INF ), |
|
51 | + 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
52 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, current_time('timestamp'), $timezone), |
|
53 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, current_time('timestamp'), $timezone), |
|
54 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
55 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, INF), |
|
56 | 56 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
57 | 57 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
58 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, INF), |
|
59 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, INF ), |
|
60 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
61 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
62 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
58 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, INF), |
|
59 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, INF), |
|
60 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
61 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
62 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
63 | 63 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
64 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
64 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
65 | 65 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
66 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
67 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
66 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
67 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
68 | 68 | )); |
69 | 69 | $this->_model_relations = array( |
70 | 70 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | 'WP_User' => new EE_Belongs_To_Relation(), |
76 | 76 | ); |
77 | 77 | |
78 | - parent::__construct( $timezone ); |
|
78 | + parent::__construct($timezone); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | * @return EE_Ticket[] |
86 | 86 | */ |
87 | 87 | public function get_all_default_tickets() { |
88 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_order' => 'ASC')) ); |
|
88 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_order' => 'ASC'))); |
|
89 | 89 | |
90 | 90 | //we need to set the start date and end date to today's date and the start of the default dtt |
91 | - return $this->_set_default_dates( $tickets ); |
|
91 | + return $this->_set_default_dates($tickets); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @param EE_Ticket[] $tickets |
99 | 99 | * @return EE_Ticket[] |
100 | 100 | */ |
101 | - private function _set_default_dates( $tickets ) { |
|
102 | - foreach ( $tickets as $ticket ) { |
|
103 | - $ticket->set('TKT_start_date', current_time('timestamp') ); |
|
104 | - $ticket->set('TKT_end_date', current_time('timestamp') + (60 * 60 * 24 * 30 ) ); |
|
101 | + private function _set_default_dates($tickets) { |
|
102 | + foreach ($tickets as $ticket) { |
|
103 | + $ticket->set('TKT_start_date', current_time('timestamp')); |
|
104 | + $ticket->set('TKT_end_date', current_time('timestamp') + (60 * 60 * 24 * 30)); |
|
105 | 105 | $ticket->set_end_time("12am"); |
106 | 106 | } |
107 | 107 | |
@@ -115,25 +115,25 @@ discard block |
||
115 | 115 | * @param array $query_params |
116 | 116 | * @return int|boolean of tickets available. If sold out, return less than 1. If infinite, returns INF, IF there are NO tickets attached to datetime then FALSE is returned. |
117 | 117 | */ |
118 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
118 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
119 | 119 | $sum = 0; |
120 | 120 | $query_params[0]['Datetime.DTT_ID'] = $DTT_ID; |
121 | 121 | $remaining_per_ticket = $this->_get_all_wpdb_results( |
122 | 122 | $query_params, |
123 | 123 | ARRAY_A, |
124 | 124 | array( |
125 | - 'tickets_remaining'=>array('Ticket.TKT_qty-Ticket.TKT_sold','%d'),//note! calculations based on TKT_qty are dangerous because -1 means infinity in the db! |
|
126 | - 'initially_available'=>array('Ticket.TKT_qty','%d'))); |
|
125 | + 'tickets_remaining'=>array('Ticket.TKT_qty-Ticket.TKT_sold', '%d'), //note! calculations based on TKT_qty are dangerous because -1 means infinity in the db! |
|
126 | + 'initially_available'=>array('Ticket.TKT_qty', '%d'))); |
|
127 | 127 | |
128 | - if ( empty( $remaining_per_ticket ) ) |
|
128 | + if (empty($remaining_per_ticket)) |
|
129 | 129 | return FALSE; |
130 | 130 | |
131 | 131 | |
132 | - foreach($remaining_per_ticket as $remaining){ |
|
133 | - if(intval($remaining['initially_available'])==EE_INF_IN_DB){//infinite in DB |
|
132 | + foreach ($remaining_per_ticket as $remaining) { |
|
133 | + if (intval($remaining['initially_available']) == EE_INF_IN_DB) {//infinite in DB |
|
134 | 134 | return INF; |
135 | 135 | } |
136 | - $sum+=intval($remaining['tickets_remaining']); |
|
136 | + $sum += intval($remaining['tickets_remaining']); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $sum; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @param EE_Ticket[] $tickets |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - public function update_tickets_sold($tickets){ |
|
148 | - foreach($tickets as $ticket){ |
|
147 | + public function update_tickets_sold($tickets) { |
|
148 | + foreach ($tickets as $ticket) { |
|
149 | 149 | /* @var $ticket EE_Ticket */ |
150 | 150 | $ticket->update_tickets_sold(); |
151 | 151 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * WP User Model. Not intended to replace WP_User, but this just allows |
4 | 6 | * for EE model queries to more easily integrate with the WP User table |
@@ -22,24 +22,24 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @throws \EE_Error |
24 | 24 | */ |
25 | - protected function __construct( $timezone = NULL ){ |
|
26 | - $this->singular_item = __('WP_User','event_espresso'); |
|
27 | - $this->plural_item = __('WP_Users','event_espresso'); |
|
25 | + protected function __construct($timezone = NULL) { |
|
26 | + $this->singular_item = __('WP_User', 'event_espresso'); |
|
27 | + $this->plural_item = __('WP_Users', 'event_espresso'); |
|
28 | 28 | global $wpdb; |
29 | 29 | $this->_tables = array( |
30 | - 'WP_User'=> new EE_Primary_Table( $wpdb->users, 'ID', true) |
|
30 | + 'WP_User'=> new EE_Primary_Table($wpdb->users, 'ID', true) |
|
31 | 31 | ); |
32 | 32 | $this->_fields = array( |
33 | 33 | 'WP_User'=>array( |
34 | - 'ID'=> new EE_Primary_Key_Int_Field('ID', __('WP_User ID','event_espresso')), |
|
35 | - 'user_login'=>new EE_Plain_Text_Field('user_login', __('User Login','event_espresso'), false, '' ), |
|
36 | - 'user_pass'=>new EE_Plain_Text_Field('user_pass', __('User Password','event_espresso'), false, '' ), |
|
37 | - 'user_nicename'=>new EE_Plain_Text_Field('user_nicename', __(' User Nice Name','event_espresso'), false, ''), |
|
38 | - 'user_email' => new EE_Email_Field('user_email', __( 'User Email', 'event_espresso' ), false), |
|
39 | - 'user_registered' => new EE_Datetime_Field( 'user_registered', __( 'Date User Registered', 'event_espresso' ), false, current_time('timestamp'), $timezone ), |
|
40 | - 'user_activation_key' => new EE_Plain_Text_Field( 'user_activation_key', __( 'User Activation Key', 'event_espresso' ), false, '' ), |
|
41 | - 'user_status' => new EE_Integer_Field( 'user_status', __( 'User Status', 'event_espresso' ), false, 0 ), |
|
42 | - 'display_name' => new EE_Plain_Text_Field( 'display_name', __( 'Display Name', 'event_espresso' ), false, '' ) |
|
34 | + 'ID'=> new EE_Primary_Key_Int_Field('ID', __('WP_User ID', 'event_espresso')), |
|
35 | + 'user_login'=>new EE_Plain_Text_Field('user_login', __('User Login', 'event_espresso'), false, ''), |
|
36 | + 'user_pass'=>new EE_Plain_Text_Field('user_pass', __('User Password', 'event_espresso'), false, ''), |
|
37 | + 'user_nicename'=>new EE_Plain_Text_Field('user_nicename', __(' User Nice Name', 'event_espresso'), false, ''), |
|
38 | + 'user_email' => new EE_Email_Field('user_email', __('User Email', 'event_espresso'), false), |
|
39 | + 'user_registered' => new EE_Datetime_Field('user_registered', __('Date User Registered', 'event_espresso'), false, current_time('timestamp'), $timezone), |
|
40 | + 'user_activation_key' => new EE_Plain_Text_Field('user_activation_key', __('User Activation Key', 'event_espresso'), false, ''), |
|
41 | + 'user_status' => new EE_Integer_Field('user_status', __('User Status', 'event_espresso'), false, 0), |
|
42 | + 'display_name' => new EE_Plain_Text_Field('display_name', __('Display Name', 'event_espresso'), false, '') |
|
43 | 43 | )); |
44 | 44 | $this->_model_relations = array( |
45 | 45 | 'Attendee' => new EE_Has_Many_Relation(), |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'Venue' => new EE_Has_Many_Relation(), |
55 | 55 | ); |
56 | 56 | |
57 | - parent::__construct( $timezone ); |
|
57 | + parent::__construct($timezone); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | // End of file EEM_WP_User.model.php |