@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | public $type = NULL; |
34 | 34 | |
35 | 35 | /** |
36 | - * Price Base types |
|
37 | - * |
|
38 | - * @access private |
|
39 | - * @var int |
|
40 | - */ |
|
36 | + * Price Base types |
|
37 | + * |
|
38 | + * @access private |
|
39 | + * @var int |
|
40 | + */ |
|
41 | 41 | public $base_types = null; |
42 | 42 | |
43 | 43 | /** |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param type $query_params |
146 | 146 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
147 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
148 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
147 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
148 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
149 | 149 | * @return boolean |
150 | 150 | */ |
151 | 151 | public function delete_permanently($query_params = array(), $allow_blocking = true) { |
@@ -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_Price_Type.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Price_Type.class.php'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | class EEM_Price_Type extends EEM_Soft_Delete_Base { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * values are text-representations of the base type. |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - public function get_base_types(){ |
|
48 | + public function get_base_types() { |
|
49 | 49 | return $this->base_types; |
50 | 50 | } |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param type $base_type_int |
55 | 55 | * @return type |
56 | 56 | */ |
57 | - public function get_base_type_name($base_type_int){ |
|
57 | + public function get_base_type_name($base_type_int) { |
|
58 | 58 | return $this->base_types[$base_type_int]; |
59 | 59 | } |
60 | 60 | |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | * @access protected |
80 | 80 | * @return void |
81 | 81 | */ |
82 | - protected function __construct( $timezone = NULL ) { |
|
82 | + protected function __construct($timezone = NULL) { |
|
83 | 83 | $this->base_types = array( |
84 | - EEM_Price_Type::base_type_base_price => __('Price','event_espresso'), |
|
85 | - EEM_Price_Type::base_type_discount => __('Discount','event_espresso'), |
|
86 | - EEM_Price_Type::base_type_surcharge => __('Surcharge','event_espresso'), |
|
87 | - EEM_Price_Type::base_type_tax => __('Tax','event_espresso') ); |
|
88 | - $this->singular_item = __('Price Type','event_espresso'); |
|
89 | - $this->plural_item = __('Price Types','event_espresso'); |
|
84 | + EEM_Price_Type::base_type_base_price => __('Price', 'event_espresso'), |
|
85 | + EEM_Price_Type::base_type_discount => __('Discount', 'event_espresso'), |
|
86 | + EEM_Price_Type::base_type_surcharge => __('Surcharge', 'event_espresso'), |
|
87 | + EEM_Price_Type::base_type_tax => __('Tax', 'event_espresso') ); |
|
88 | + $this->singular_item = __('Price Type', 'event_espresso'); |
|
89 | + $this->plural_item = __('Price Types', 'event_espresso'); |
|
90 | 90 | |
91 | 91 | $this->_tables = array( |
92 | - 'Price_Type'=>new EE_Primary_Table('esp_price_type','PRT_ID') |
|
92 | + 'Price_Type'=>new EE_Primary_Table('esp_price_type', 'PRT_ID') |
|
93 | 93 | ); |
94 | 94 | $this->_fields = array( |
95 | 95 | 'Price_Type'=>array( |
96 | - 'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID','event_espresso')), |
|
97 | - 'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name','event_espresso'), false, ''), |
|
98 | - 'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax','event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types), |
|
99 | - 'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage','event_espresso'), false, false), |
|
100 | - 'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ','event_espresso'), false, 0), |
|
101 | - 'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed','event_espresso'), false, false), |
|
102 | - 'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), FALSE ), |
|
96 | + 'PRT_ID'=>new EE_Primary_Key_Int_Field('PRT_ID', __('Price Type ID', 'event_espresso')), |
|
97 | + 'PRT_name'=>new EE_Plain_Text_Field('PRT_name', __('Price Type Name', 'event_espresso'), false, ''), |
|
98 | + 'PBT_ID'=>new EE_Enum_Integer_Field('PBT_ID', __('Price Base type ID, 1 = Price , 2 = Discount , 3 = Surcharge , 4 = Tax', 'event_espresso'), false, EEM_Price_Type::base_type_base_price, $this->base_types), |
|
99 | + 'PRT_is_percent'=>new EE_Boolean_Field('PRT_is_percent', __('Flag indicating price is a percentage', 'event_espresso'), false, false), |
|
100 | + 'PRT_order'=>new EE_Integer_Field('PRT_order', __('Order in which price should be applied. ', 'event_espresso'), false, 0), |
|
101 | + 'PRT_deleted'=>new EE_Trashed_Flag_Field('PRT_deleted', __('Flag indicating price type has been trashed', 'event_espresso'), false, false), |
|
102 | + 'PRT_wp_user' => new EE_WP_User_Field('PRT_wp_user', __('Price Type Creator ID', 'event_espresso'), FALSE), |
|
103 | 103 | ) |
104 | 104 | ); |
105 | 105 | $this->_model_relations = array( |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'WP_User' => new EE_Belongs_To_Relation(), |
108 | 108 | ); |
109 | 109 | |
110 | - parent::__construct( $timezone ); |
|
110 | + parent::__construct($timezone); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | $ID = $query_params[0][$this->get_primary_key_field()->get_name()]; |
154 | 154 | |
155 | 155 | //check if any prices use this price type |
156 | - $prc_query_params = array(array('PRT_ID'=>array('IN',$would_be_deleted_price_type_ids))); |
|
157 | - if ( $prices = $this->get_all_related($ID,'Price',$prc_query_params)) { |
|
156 | + $prc_query_params = array(array('PRT_ID'=>array('IN', $would_be_deleted_price_type_ids))); |
|
157 | + if ($prices = $this->get_all_related($ID, 'Price', $prc_query_params)) { |
|
158 | 158 | $prices_names_and_ids = array(); |
159 | - foreach($prices as $price){ |
|
159 | + foreach ($prices as $price) { |
|
160 | 160 | /* @var $price EE_Price */ |
161 | 161 | $prices_names_and_ids[] = $price->name()."(".$price->ID().")"; |
162 | 162 | } |
163 | - $msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type. If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'),implode(",",$prices_names_and_ids)); |
|
164 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
163 | + $msg = sprintf(__('The Price Type(s) could not be deleted because there are existing Prices that currently use this Price Type. If you still wish to delete this Price Type, then either delete those Prices or change them to use other Price Types.The prices are: %s', 'event_espresso'), implode(",", $prices_names_and_ids)); |
|
164 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
165 | 165 | return FALSE; |
166 | 166 | } |
167 | 167 |
@@ -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,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 | /** |
@@ -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 | } |
@@ -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 |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
67 | - * reset_cached_states |
|
68 | - * |
|
69 | - * @access private |
|
70 | - * @return void |
|
71 | - */ |
|
67 | + * reset_cached_states |
|
68 | + * |
|
69 | + * @access private |
|
70 | + * @return void |
|
71 | + */ |
|
72 | 72 | public function reset_cached_states() { |
73 | 73 | EEM_State::$_active_states = array(); |
74 | 74 | EEM_State::$_all_states = array(); |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | /** |
81 | - * _get_states |
|
82 | - * |
|
83 | - * @access private |
|
84 | - * @return array |
|
85 | - */ |
|
81 | + * _get_states |
|
82 | + * |
|
83 | + * @access private |
|
84 | + * @return array |
|
85 | + */ |
|
86 | 86 | public function get_all_states() { |
87 | 87 | if ( ! self::$_all_states ) { |
88 | 88 | self::$_all_states = $this->get_all( array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 ))); |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | |
162 | 162 | |
163 | 163 | /** |
164 | - * delete a single state from db via their ID |
|
165 | - * |
|
166 | - * @access public |
|
167 | - * @param $STA_ID |
|
168 | - * @return mixed array on success, FALSE on fail |
|
169 | - */ |
|
164 | + * delete a single state from db via their ID |
|
165 | + * |
|
166 | + * @access public |
|
167 | + * @param $STA_ID |
|
168 | + * @return mixed array on success, FALSE on fail |
|
169 | + */ |
|
170 | 170 | public function delete_by_ID( $STA_ID = FALSE ) { |
171 | 171 | |
172 | 172 | if ( ! $STA_ID ) { |
@@ -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 | * |
@@ -196,7 +198,7 @@ discard block |
||
196 | 198 | $names = $this->get_col( array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name' ); |
197 | 199 | if( is_array( $names ) && ! empty( $names ) ){ |
198 | 200 | return reset( $names ); |
199 | - }else{ |
|
201 | + } else{ |
|
200 | 202 | return ''; |
201 | 203 | } |
202 | 204 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_State.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_State.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_State extends EEM_Base { |
28 | 28 | |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | // array of all active states |
34 | 34 | private static $_active_states = FALSE; |
35 | 35 | |
36 | - protected function __construct( $timezone = NULL ) { |
|
37 | - $this->singular_item = __('State/Province','event_espresso'); |
|
38 | - $this->plural_item = __('States/Provinces','event_espresso'); |
|
36 | + protected function __construct($timezone = NULL) { |
|
37 | + $this->singular_item = __('State/Province', 'event_espresso'); |
|
38 | + $this->plural_item = __('States/Provinces', 'event_espresso'); |
|
39 | 39 | |
40 | 40 | $this->_tables = array( |
41 | 41 | 'State'=> new EE_Primary_Table('esp_state', 'STA_ID') |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->_fields = array( |
45 | 45 | 'State'=>array( |
46 | - 'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID','event_espresso')), |
|
47 | - 'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code','event_espresso'), false, NULL, 'Country'), |
|
48 | - 'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation','event_espresso'), false, ''), |
|
49 | - 'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name','event_espresso'), false, ''), |
|
46 | + 'STA_ID'=> new EE_Primary_Key_Int_Field('STA_ID', __('State ID', 'event_espresso')), |
|
47 | + 'CNT_ISO'=> new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso'), false, NULL, 'Country'), |
|
48 | + 'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation', 'event_espresso'), false, ''), |
|
49 | + 'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name', 'event_espresso'), false, ''), |
|
50 | 50 | 'STA_active'=> new EE_Boolean_Field('STA_active', __('State Active Flag', 'event_espresso'), false, false) |
51 | 51 | )); |
52 | 52 | $this->_model_relations = array( |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'Country' => new EE_Belongs_To_Relation(), |
55 | 55 | 'Venue'=>new EE_Has_Many_Relation(), |
56 | 56 | ); |
57 | - parent::__construct( $timezone ); |
|
57 | + parent::__construct($timezone); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @return array |
82 | 82 | */ |
83 | 83 | public function get_all_states() { |
84 | - if ( ! self::$_all_states ) { |
|
85 | - self::$_all_states = $this->get_all( array( 'order_by'=>array( 'STA_name'=>'ASC' ), 'limit'=> array( 0, 99999 ))); |
|
84 | + if ( ! self::$_all_states) { |
|
85 | + self::$_all_states = $this->get_all(array('order_by'=>array('STA_name'=>'ASC'), 'limit'=> array(0, 99999))); |
|
86 | 86 | } |
87 | 87 | return self::$_all_states; |
88 | 88 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @param bool $flush_cache |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - public function get_all_active_states( $countries = array(), $flush_cache = FALSE ) { |
|
101 | - if ( ! self::$_active_states || $flush_cache ) { |
|
102 | - $countries = is_array( $countries ) && ! empty( $countries ) ? $countries : EEM_Country::instance()->get_all_active_countries(); |
|
103 | - self::$_active_states = $this->get_all( array( |
|
104 | - array( 'STA_active' => TRUE, 'CNT_ISO' => array( 'IN', array_keys( $countries ))), |
|
105 | - 'order_by' => array( 'STA_name'=>'ASC' ), |
|
106 | - 'limit' => array( 0, 99999 ), |
|
107 | - 'force_join' => array( 'Country' ) |
|
100 | + public function get_all_active_states($countries = array(), $flush_cache = FALSE) { |
|
101 | + if ( ! self::$_active_states || $flush_cache) { |
|
102 | + $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries(); |
|
103 | + self::$_active_states = $this->get_all(array( |
|
104 | + array('STA_active' => TRUE, 'CNT_ISO' => array('IN', array_keys($countries))), |
|
105 | + 'order_by' => array('STA_name'=>'ASC'), |
|
106 | + 'limit' => array(0, 99999), |
|
107 | + 'force_join' => array('Country') |
|
108 | 108 | )); |
109 | 109 | } |
110 | 110 | return self::$_active_states; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * get_all_states_of_active_countries |
117 | 117 | * @return array |
118 | 118 | */ |
119 | - public function get_all_states_of_active_countries(){ |
|
120 | - if ( $states = $this->get_all( array( array( 'Country.CNT_active' => TRUE, 'STA_active' => TRUE ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
119 | + public function get_all_states_of_active_countries() { |
|
120 | + if ($states = $this->get_all(array(array('Country.CNT_active' => TRUE, 'STA_active' => TRUE), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
121 | 121 | return $states; |
122 | 122 | } |
123 | 123 | return FALSE; |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * get_all_states_of_active_countries |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function get_all_active_states_for_these_countries( $countries ){ |
|
133 | - if ( ! $countries ) { |
|
132 | + public function get_all_active_states_for_these_countries($countries) { |
|
133 | + if ( ! $countries) { |
|
134 | 134 | return FALSE; |
135 | 135 | } |
136 | - if ( $states = $this->get_all( array( array( 'Country.CNT_ISO' => array( 'IN', array_keys( $countries )), 'STA_active' => TRUE ), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
136 | + if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries)), 'STA_active' => TRUE), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
137 | 137 | return $states; |
138 | 138 | } |
139 | 139 | return FALSE; |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | * get_all_states_of_active_countries |
146 | 146 | * @return array |
147 | 147 | */ |
148 | - public function get_all_states_for_these_countries( $countries ){ |
|
149 | - if ( ! $countries ) { |
|
148 | + public function get_all_states_for_these_countries($countries) { |
|
149 | + if ( ! $countries) { |
|
150 | 150 | return FALSE; |
151 | 151 | } |
152 | - if ( $states = $this->get_all( array( array( 'Country.CNT_ISO' => array( 'IN', array_keys( $countries ))), 'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) { |
|
152 | + if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries))), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) { |
|
153 | 153 | return $states; |
154 | 154 | } |
155 | 155 | return FALSE; |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * @param $STA_ID |
165 | 165 | * @return mixed array on success, FALSE on fail |
166 | 166 | */ |
167 | - public function delete_by_ID( $STA_ID = FALSE ) { |
|
167 | + public function delete_by_ID($STA_ID = FALSE) { |
|
168 | 168 | |
169 | - if ( ! $STA_ID ) { |
|
169 | + if ( ! $STA_ID) { |
|
170 | 170 | return FALSE; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // retrieve a particular transaction |
174 | - $where_cols_n_values = array( array( 'STA_ID' => $STA_ID )); |
|
175 | - if ( $answer = $this->delete ( $where_cols_n_values )) { |
|
174 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
175 | + if ($answer = $this->delete($where_cols_n_values)) { |
|
176 | 176 | return TRUE; |
177 | 177 | } else { |
178 | 178 | return FALSE; |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * @param string $state_ID |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_state_name_by_ID( $state_ID ){ |
|
189 | - if( isset( self::$_all_states[ $state_ID ] ) && |
|
190 | - self::$_all_states[ $state_ID ] instanceof EE_State ){ |
|
191 | - return self::$_all_states[ $state_ID ]->name(); |
|
188 | + public function get_state_name_by_ID($state_ID) { |
|
189 | + if (isset(self::$_all_states[$state_ID]) && |
|
190 | + self::$_all_states[$state_ID] instanceof EE_State) { |
|
191 | + return self::$_all_states[$state_ID]->name(); |
|
192 | 192 | } |
193 | - $names = $this->get_col( array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name' ); |
|
194 | - if( is_array( $names ) && ! empty( $names ) ){ |
|
195 | - return reset( $names ); |
|
196 | - }else{ |
|
193 | + $names = $this->get_col(array(array('STA_ID' => $state_ID), 'limit' => 1), 'STA_name'); |
|
194 | + if (is_array($names) && ! empty($names)) { |
|
195 | + return reset($names); |
|
196 | + } else { |
|
197 | 197 | return ''; |
198 | 198 | } |
199 | 199 | } |
@@ -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 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Model for retrieving Information about the Event Espresso status. |
5 | 5 | */ |
6 | -class EEM_System_Status{ |
|
6 | +class EEM_System_Status { |
|
7 | 7 | |
8 | 8 | // private instance of the EEM_System_Status object |
9 | 9 | protected static $_instance = NULL; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | return self::$_instance; |
28 | 28 | } |
29 | - private function __construct(){ |
|
29 | + private function __construct() { |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return array where each key is a function name on this class, and each value is SOMETHING-- |
35 | 35 | * it might be a value, an array, or an object |
36 | 36 | */ |
37 | - function get_system_stati(){ |
|
37 | + function get_system_stati() { |
|
38 | 38 | return array( |
39 | 39 | 'ee_version'=>$this->get_ee_version(), |
40 | 40 | 'ee_activation_history'=>$this->get_ee_activation_history(), |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - function get_ee_version(){ |
|
58 | + function get_ee_version() { |
|
59 | 59 | return espresso_version(); |
60 | 60 | } |
61 | 61 | /** |
62 | 62 | * |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - function php_version(){ |
|
65 | + function php_version() { |
|
66 | 66 | return phpversion(); |
67 | 67 | } |
68 | 68 | /** |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | 'DomainPath' => 'Domain Path', |
80 | 80 | 'Network' => 'Network', |
81 | 81 | */ |
82 | - function get_active_plugins(){ |
|
83 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
84 | - if ( is_multisite() ) |
|
85 | - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
86 | - $active_plugins = array_map( 'strtolower', $active_plugins ); |
|
82 | + function get_active_plugins() { |
|
83 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
84 | + if (is_multisite()) |
|
85 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
86 | + $active_plugins = array_map('strtolower', $active_plugins); |
|
87 | 87 | $plugin_info = array(); |
88 | - foreach ( $active_plugins as $plugin ) { |
|
89 | - $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
88 | + foreach ($active_plugins as $plugin) { |
|
89 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
90 | 90 | |
91 | - $plugin_info[ $plugin ] = $plugin_data; |
|
91 | + $plugin_info[$plugin] = $plugin_data; |
|
92 | 92 | } |
93 | 93 | return $plugin_info; |
94 | 94 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array with keys 'home_url' and 'site_url' |
99 | 99 | */ |
100 | - function get_wp_settings(){ |
|
101 | - $wp_memory_int = $this->let_to_num( WP_MEMORY_LIMIT ); |
|
102 | - if ( $wp_memory_int < 67108864 ) { |
|
103 | - $wp_memory_to_display = '<mark class="error">' . sprintf( __('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"' ) . '</mark>'; |
|
100 | + function get_wp_settings() { |
|
101 | + $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
|
102 | + if ($wp_memory_int < 67108864) { |
|
103 | + $wp_memory_to_display = '<mark class="error">'.sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"').'</mark>'; |
|
104 | 104 | } else { |
105 | - $wp_memory_to_display = '<mark class="yes">' . size_format( $wp_memory_int ) . '</mark>'; |
|
105 | + $wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>'; |
|
106 | 106 | } |
107 | 107 | return array( |
108 | - 'name'=>get_bloginfo('name','display'), |
|
108 | + 'name'=>get_bloginfo('name', 'display'), |
|
109 | 109 | 'is_multisite'=>is_multisite(), |
110 | - 'version'=> get_bloginfo( 'version', 'display' ), |
|
110 | + 'version'=> get_bloginfo('version', 'display'), |
|
111 | 111 | 'home_url'=>home_url(), |
112 | 112 | 'site_url'=>site_url(), |
113 | 113 | 'WP_DEBUG'=>WP_DEBUG, |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | 'gmt_offset'=>get_option('gmt_offset'), |
117 | 117 | 'timezone_string'=>get_option('timezone_string'), |
118 | 118 | 'admin_email'=> get_bloginfo('admin_email', 'display'), |
119 | - 'language'=>get_bloginfo('language','display'), |
|
120 | - 'wp_max_upload_size' => size_format( wp_max_upload_size() ), |
|
119 | + 'language'=>get_bloginfo('language', 'display'), |
|
120 | + 'wp_max_upload_size' => size_format(wp_max_upload_size()), |
|
121 | 121 | 'wp_memory' => $wp_memory_to_display |
122 | 122 | ); |
123 | 123 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * Gets an array of information about the history of ee versions installed |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - function get_ee_activation_history(){ |
|
129 | + function get_ee_activation_history() { |
|
130 | 130 | return get_option('espresso_db_update'); |
131 | 131 | } |
132 | 132 | |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed |
136 | 136 | * @return EE_Data_Migration_Script_Base[] |
137 | 137 | */ |
138 | - function get_ee_migration_history(){ |
|
138 | + function get_ee_migration_history() { |
|
139 | 139 | $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
140 | 140 | $presentable_migration_scripts = array(); |
141 | - foreach($options as $option_array){ |
|
142 | - $presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$option_array['option_name'])] = maybe_unserialize($option_array['option_value']); |
|
141 | + foreach ($options as $option_array) { |
|
142 | + $presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name'])] = maybe_unserialize($option_array['option_value']); |
|
143 | 143 | } |
144 | 144 | return $presentable_migration_scripts; |
145 | 145 | // return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran(); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return array like EE_Config class |
151 | 151 | */ |
152 | - function get_ee_config(){ |
|
152 | + function get_ee_config() { |
|
153 | 153 | return EE_Config::instance(); |
154 | 154 | } |
155 | 155 | |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463 |
158 | 158 | * @return array like the output of phpinfo(), but in an array |
159 | 159 | */ |
160 | - function get_php_info(){ |
|
160 | + function get_php_info() { |
|
161 | 161 | ob_start(); |
162 | 162 | phpinfo(-1); |
163 | 163 | |
164 | 164 | $pi = preg_replace( |
165 | 165 | array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
166 | - '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
166 | + '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
167 | 167 | "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
168 | 168 | '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
169 | 169 | .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
170 | 170 | '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
171 | 171 | '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
172 | 172 | "# +#", '#<tr>#', '#</tr>#'), |
173 | - array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
173 | + array('$1', '', '', '', '</$1>'."\n", '<', ' ', ' ', ' ', '', ' ', |
|
174 | 174 | '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
175 | 175 | "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
176 | 176 | '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
177 | - '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
177 | + '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n". |
|
178 | 178 | '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
179 | 179 | ob_get_clean()); |
180 | 180 | |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | unset($sections[0]); |
183 | 183 | |
184 | 184 | $pi = array(); |
185 | - foreach($sections as $section){ |
|
185 | + foreach ($sections as $section) { |
|
186 | 186 | $n = substr($section, 0, strpos($section, '</h2>')); |
187 | 187 | preg_match_all( |
188 | 188 | '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
189 | 189 | $section, $askapache, PREG_SET_ORDER); |
190 | - foreach($askapache as $m) |
|
190 | + foreach ($askapache as $m) |
|
191 | 191 | $m2 = isset($m[2]) ? $m[2] : null; |
192 | - $pi[$n][$m[1]]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m,2); |
|
192 | + $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | return $pi; |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | * Checks if site responds ot HTTPS |
200 | 200 | * @return boolean |
201 | 201 | */ |
202 | - function get_https_enabled(){ |
|
202 | + function get_https_enabled() { |
|
203 | 203 | $home = str_replace("http://", "https://", home_url()); |
204 | 204 | $response = wp_remote_get($home); |
205 | - if($response instanceof WP_Error){ |
|
205 | + if ($response instanceof WP_Error) { |
|
206 | 206 | $error_string = ''; |
207 | - foreach($response->errors as $short_name => $description_array){ |
|
208 | - $error_string .= "<b>$short_name</b>: ".implode(", ",$description_array); |
|
207 | + foreach ($response->errors as $short_name => $description_array) { |
|
208 | + $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array); |
|
209 | 209 | } |
210 | 210 | return $error_string; |
211 | 211 | } |
@@ -215,25 +215,25 @@ discard block |
||
215 | 215 | * Whether or not logging is enabled |
216 | 216 | * @return string descripting logging's status |
217 | 217 | */ |
218 | - function get_logging_enabled(){ |
|
219 | - $opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' ); |
|
220 | - return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ; |
|
218 | + function get_logging_enabled() { |
|
219 | + $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a'); |
|
220 | + return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>'); |
|
221 | 221 | } |
222 | 222 | /** |
223 | 223 | * Whether curl ro fsock works |
224 | 224 | * @return string describing posting's status |
225 | 225 | */ |
226 | - function get_remote_posting(){ |
|
227 | - $fsock_works = function_exists( 'fsockopen' ); |
|
228 | - $curl_works = function_exists( 'curl_init' ); |
|
229 | - if ( $fsock_works && $curl_works ) { |
|
226 | + function get_remote_posting() { |
|
227 | + $fsock_works = function_exists('fsockopen'); |
|
228 | + $curl_works = function_exists('curl_init'); |
|
229 | + if ($fsock_works && $curl_works) { |
|
230 | 230 | $status = __('Your server has fsockopen and cURL enabled.', 'event_espresso'); |
231 | - } elseif ( $fsock_works ) { |
|
231 | + } elseif ($fsock_works) { |
|
232 | 232 | $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
233 | - } elseif( $curl_works ) { |
|
233 | + } elseif ($curl_works) { |
|
234 | 234 | $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
235 | - }else{ |
|
236 | - $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
235 | + } else { |
|
236 | + $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso').'</mark>'; |
|
237 | 237 | } |
238 | 238 | return $status; |
239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Gets all the php.ini settings |
243 | 243 | * @return array |
244 | 244 | */ |
245 | - function get_php_ini_all(){ |
|
245 | + function get_php_ini_all() { |
|
246 | 246 | return ini_get_all(); |
247 | 247 | } |
248 | 248 | /** |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * @param type $size |
252 | 252 | * @return int |
253 | 253 | */ |
254 | - function let_to_num( $size ) { |
|
255 | - $l = substr( $size, -1 ); |
|
256 | - $ret = substr( $size, 0, -1 ); |
|
257 | - switch( strtoupper( $l ) ) { |
|
254 | + function let_to_num($size) { |
|
255 | + $l = substr($size, -1); |
|
256 | + $ret = substr($size, 0, -1); |
|
257 | + switch (strtoupper($l)) { |
|
258 | 258 | case 'P': |
259 | 259 | $ret *= 1024; |
260 | 260 | case 'T': |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function get_active_plugins(){ |
83 | 83 | $active_plugins = (array) get_option( 'active_plugins', array() ); |
84 | - if ( is_multisite() ) |
|
85 | - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
84 | + if ( is_multisite() ) { |
|
85 | + $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
86 | + } |
|
86 | 87 | $active_plugins = array_map( 'strtolower', $active_plugins ); |
87 | 88 | $plugin_info = array(); |
88 | 89 | foreach ( $active_plugins as $plugin ) { |
@@ -187,8 +188,9 @@ discard block |
||
187 | 188 | preg_match_all( |
188 | 189 | '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
189 | 190 | $section, $askapache, PREG_SET_ORDER); |
190 | - foreach($askapache as $m) |
|
191 | - $m2 = isset($m[2]) ? $m[2] : null; |
|
191 | + foreach($askapache as $m) { |
|
192 | + $m2 = isset($m[2]) ? $m[2] : null; |
|
193 | + } |
|
192 | 194 | $pi[$n][$m[1]]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m,2); |
193 | 195 | } |
194 | 196 | |
@@ -232,7 +234,7 @@ discard block |
||
232 | 234 | $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
233 | 235 | } elseif( $curl_works ) { |
234 | 236 | $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
235 | - }else{ |
|
237 | + } else{ |
|
236 | 238 | $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
237 | 239 | } |
238 | 240 | return $status; |
@@ -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,23 +22,23 @@ 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 | $this->_tables = array( |
29 | 29 | 'WP_User'=> new EE_Primary_Table('users', 'ID') |
30 | 30 | ); |
31 | 31 | $this->_fields = array( |
32 | 32 | 'WP_User'=>array( |
33 | - 'ID'=> new EE_Primary_Key_Int_Field('ID', __('WP_User ID','event_espresso')), |
|
34 | - 'user_login'=>new EE_Plain_Text_Field('user_login', __('User Login','event_espresso'), false, '' ), |
|
35 | - 'user_pass'=>new EE_Plain_Text_Field('user_pass', __('User Password','event_espresso'), false, '' ), |
|
36 | - 'user_nicename'=>new EE_Plain_Text_Field('user_nicename', __(' User Nice Name','event_espresso'), false, ''), |
|
37 | - 'user_email' => new EE_Email_Field('user_email', __( 'User Email', 'event_espresso' ), false), |
|
38 | - 'user_registered' => new EE_Datetime_Field( 'user_registered', __( 'Date User Registered', 'event_espresso' ), false, current_time('timestamp'), $timezone ), |
|
39 | - 'user_activation_key' => new EE_Plain_Text_Field( 'user_activation_key', __( 'User Activation Key', 'event_espresso' ), false, '' ), |
|
40 | - 'user_status' => new EE_Integer_Field( 'user_status', __( 'User Status', 'event_espresso' ), false, 0 ), |
|
41 | - 'display_name' => new EE_Plain_Text_Field( 'display_name', __( 'Display Name', 'event_espresso' ), false, '' ) |
|
33 | + 'ID'=> new EE_Primary_Key_Int_Field('ID', __('WP_User ID', 'event_espresso')), |
|
34 | + 'user_login'=>new EE_Plain_Text_Field('user_login', __('User Login', 'event_espresso'), false, ''), |
|
35 | + 'user_pass'=>new EE_Plain_Text_Field('user_pass', __('User Password', 'event_espresso'), false, ''), |
|
36 | + 'user_nicename'=>new EE_Plain_Text_Field('user_nicename', __(' User Nice Name', 'event_espresso'), false, ''), |
|
37 | + 'user_email' => new EE_Email_Field('user_email', __('User Email', 'event_espresso'), false), |
|
38 | + 'user_registered' => new EE_Datetime_Field('user_registered', __('Date User Registered', 'event_espresso'), false, current_time('timestamp'), $timezone), |
|
39 | + 'user_activation_key' => new EE_Plain_Text_Field('user_activation_key', __('User Activation Key', 'event_espresso'), false, ''), |
|
40 | + 'user_status' => new EE_Integer_Field('user_status', __('User Status', 'event_espresso'), false, 0), |
|
41 | + 'display_name' => new EE_Plain_Text_Field('display_name', __('Display Name', 'event_espresso'), false, '') |
|
42 | 42 | )); |
43 | 43 | $this->_model_relations = array( |
44 | 44 | 'Attendee' => new EE_Has_Many_Relation(), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'Venue' => new EE_Has_Many_Relation(), |
54 | 54 | ); |
55 | 55 | |
56 | - parent::__construct( $timezone ); |
|
56 | + parent::__construct($timezone); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | // End of file EEM_WP_User.model.php |