@@ -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 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Sum all the deleted items. |
147 | 147 | * @param array $query_params like EEM_Base::get_all |
148 | 148 | * @param string $field_to_sum |
149 | - * @return int |
|
149 | + * @return double |
|
150 | 150 | */ |
151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | - * @return boolean success |
|
198 | + * @return integer success |
|
199 | 199 | */ |
200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Updates all the items of this model which match the $query params, regardless of whether |
280 | 280 | * they've been soft-deleted or not |
281 | - * @param array $field_n_values like EEM_Base::update's $fields_n_value |
|
281 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
282 | 282 | * @param array $query_params like EEM_base::get_all's $query_params |
283 | 283 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
284 | 284 | * in this model's entity map according to $fields_n_values that match $query_params. This |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ 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 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - 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))); |
|
49 | + } else { |
|
50 | + 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))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @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; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $query_params |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
119 | 119 | } |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
129 | 129 | } |
130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @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; |
138 | 138 | * @return int |
139 | 139 | */ |
140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $field_to_sum |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
153 | 153 | return parent::sum($query_params, $field_to_sum); |
154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @reutrn int |
161 | 161 | */ |
162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
164 | 164 | parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $query_params like EEM_Base::get_all |
170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
171 | 171 | */ |
172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
174 | 174 | return parent::get_all($query_params); |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $query_params like EEM_Base::get_all |
180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
181 | 181 | */ |
182 | - public function get_all_deleted($query_params = array()){ |
|
182 | + public function get_all_deleted($query_params = array()) { |
|
183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
184 | 184 | return parent::get_all($query_params); |
185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | 198 | * @return boolean success |
199 | 199 | */ |
200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function restore_by_ID($ID=FALSE){ |
|
212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
211 | + public function restore_by_ID($ID = FALSE) { |
|
212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
222 | - if ( ! $ID ) { |
|
221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
222 | + if ( ! $ID) { |
|
223 | 223 | return FALSE; |
224 | 224 | } |
225 | 225 | if ( |
226 | 226 | $this->delete_or_restore( |
227 | 227 | $delete, |
228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
229 | 229 | ) |
230 | 230 | ) { |
231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param bool $block_deletes |
246 | 246 | * @return boolean |
247 | 247 | */ |
248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
249 | 249 | //no matter what, we WON'T block soft deletes. |
250 | 250 | return $this->delete_or_restore(true, $query_params); |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $query_params like EEM_Base::get_all |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function restore($query_params = array()){ |
|
259 | + public function restore($query_params = array()) { |
|
260 | 260 | return $this->delete_or_restore(false, $query_params); |
261 | 261 | } |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @param array $query_params like EEM_Base::get_all |
266 | 266 | * @return boolean |
267 | 267 | */ |
268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
272 | 272 | return TRUE; |
273 | 273 | } else { |
274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
287 | 287 | * @return int number of items updated |
288 | 288 | */ |
289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
292 | 292 | } |
293 | 293 | } |
@@ -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 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -21,61 +21,61 @@ 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 | - $models_this_can_attach_to = array_keys( EE_Registry::instance()->cpt_models() ); |
|
37 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
38 | 38 | $this->_fields = array( |
39 | 39 | 'Term_Relationship'=>array( |
40 | - 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID','event_espresso'), false,0, $models_this_can_attach_to ), |
|
41 | - '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'), |
|
42 | - 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0) |
|
40 | + 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID', 'event_espresso'), false, 0, $models_this_can_attach_to), |
|
41 | + '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'), |
|
42 | + 'term_order'=>new EE_Integer_Field('term_order', __('Term Order', 'event_espresso'), false, 0) |
|
43 | 43 | )); |
44 | 44 | $this->_model_relations = array( |
45 | 45 | 'Term_Taxonomy'=>new EE_Belongs_To_Relation() |
46 | 46 | ); |
47 | - foreach( $models_this_can_attach_to as $model_name ) { |
|
48 | - $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
|
47 | + foreach ($models_this_can_attach_to as $model_name) { |
|
48 | + $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); |
|
49 | 49 | } |
50 | 50 | $this->_indexes = array( |
51 | - 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id','term_taxonomy_id')) |
|
51 | + 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')) |
|
52 | 52 | ); |
53 | 53 | $path_to_event_model = 'Event.'; |
54 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( $path_to_event_model ); |
|
55 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model ); |
|
56 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model ); |
|
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model, EEM_Base::caps_edit ); |
|
54 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event_model); |
|
55 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); |
|
56 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model, EEM_Base::caps_edit); |
|
58 | 58 | |
59 | 59 | $path_to_tax_model = 'Term_Taxonomy.'; |
60 | 60 | //add cap restrictions for editing term relations to the "ee_assign_*" |
61 | 61 | //and for deleting term relations too |
62 | - $cap_contexts_affected = array( EEM_Base::caps_edit, EEM_Base::caps_delete ); |
|
63 | - foreach( $cap_contexts_affected as $cap_context_affected ) { |
|
64 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = new EE_Default_Where_Conditions( |
|
62 | + $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
63 | + foreach ($cap_contexts_affected as $cap_context_affected) { |
|
64 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = new EE_Default_Where_Conditions( |
|
65 | 65 | array( |
66 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( '!=', 'espresso_event_categories' ) |
|
66 | + $path_to_tax_model.'taxonomy*ee_assign_event_category' => array('!=', 'espresso_event_categories') |
|
67 | 67 | )); |
68 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = new EE_Default_Where_Conditions( |
|
68 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = new EE_Default_Where_Conditions( |
|
69 | 69 | array( |
70 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
70 | + $path_to_tax_model.'taxonomy*ee_assign_venue_category' => array('!=', 'espresso_venue_categories') |
|
71 | 71 | )); |
72 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
72 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
73 | 73 | array( |
74 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array( '!=', 'espresso_event_type' ) |
|
74 | + $path_to_tax_model.'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type') |
|
75 | 75 | )); |
76 | 76 | } |
77 | 77 | |
78 | - parent::__construct( $timezone ); |
|
78 | + parent::__construct($timezone); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | * @global type $wpdb |
85 | 85 | * @return int the number of rows affected |
86 | 86 | */ |
87 | - public function update_term_taxonomy_counts($term_taxonomy_id = NULL){ |
|
87 | + public function update_term_taxonomy_counts($term_taxonomy_id = NULL) { |
|
88 | 88 | //because this uses a subquery and sometimes assigning to column to be another column's |
89 | 89 | //value, we just write the SQL directly. |
90 | 90 | global $wpdb; |
91 | - if( $term_taxonomy_id ){ |
|
92 | - $second_operand = $wpdb->prepare('%d',$term_taxonomy_id); |
|
93 | - }else{ |
|
91 | + if ($term_taxonomy_id) { |
|
92 | + $second_operand = $wpdb->prepare('%d', $term_taxonomy_id); |
|
93 | + } else { |
|
94 | 94 | $second_operand = 'tr.term_taxonomy_id'; |
95 | 95 | } |
96 | - $rows_affected = $this->_do_wpdb_query( 'query' , array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
97 | -from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)" ) ); |
|
96 | + $rows_affected = $this->_do_wpdb_query('query', array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
97 | +from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)")); |
|
98 | 98 | return $rows_affected; |
99 | 99 | } |
100 | 100 | |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function insert($field_n_values) { |
108 | 108 | $return = parent::insert($field_n_values); |
109 | - if( isset( $field_n_values[ 'term_taxonomy_id' ] ) ) { |
|
110 | - $this->update_term_taxonomy_counts($field_n_values[ 'term_taxonomy_id' ] ); |
|
109 | + if (isset($field_n_values['term_taxonomy_id'])) { |
|
110 | + $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
111 | 111 | } |
112 | 112 | return $return; |
113 | 113 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @return int |
124 | 124 | */ |
125 | 125 | public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
126 | - $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
127 | - if( $count ){ |
|
126 | + $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
127 | + if ($count) { |
|
128 | 128 | $this->update_term_taxonomy_counts(); |
129 | 129 | } |
130 | 130 | return $count; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function delete($query_params, $allow_blocking = true) { |
140 | 140 | $count = parent::delete($query_params, $allow_blocking); |
141 | - if( $count ){ |
|
141 | + if ($count) { |
|
142 | 142 | $this->update_term_taxonomy_counts(); |
143 | 143 | } |
144 | 144 | return $count; |
@@ -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 | * |
@@ -21,7 +21,7 @@ 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_Taxonomy extends EEM_Base { |
27 | 27 | |
@@ -29,67 +29,67 @@ discard block |
||
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | 31 | |
32 | - protected function __construct( $timezone = NULL ) { |
|
33 | - $this->singular_item = __('Term Taxonomy','event_espresso'); |
|
34 | - $this->plural_item = __('Term Taxonomy','event_espresso'); |
|
32 | + protected function __construct($timezone = NULL) { |
|
33 | + $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
34 | + $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
35 | 35 | $this->_tables = array( |
36 | 36 | 'Term_Taxonomy'=> new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id') |
37 | 37 | ); |
38 | 38 | $this->_fields = array( |
39 | 39 | 'Term_Taxonomy'=>array( |
40 | - 'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID','event_espresso')), |
|
41 | - 'term_id'=>new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | - 'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name','event_espresso'), false, 'category'), |
|
43 | - 'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false,''), |
|
44 | - 'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false,0), |
|
40 | + 'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')), |
|
41 | + 'term_id'=>new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | + 'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'), |
|
43 | + 'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false, ''), |
|
44 | + 'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
45 | 45 | 'term_count'=> new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0) |
46 | 46 | )); |
47 | 47 | $this->_model_relations = array( |
48 | 48 | 'Term_Relationship'=>new EE_Has_Many_Relation(), |
49 | 49 | 'Term'=>new EE_Belongs_To_Relation(), |
50 | 50 | ); |
51 | - $cpt_models = array_keys( EE_Registry::instance()->cpt_models() ); |
|
52 | - foreach( $cpt_models as $model_name ) { |
|
53 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation( 'Term_Relationship' ); |
|
51 | + $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
52 | + foreach ($cpt_models as $model_name) { |
|
53 | + $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
54 | 54 | } |
55 | 55 | $this->_indexes = array( |
56 | - 'term_id_taxonomy'=>new EE_Unique_Index(array('term_id','taxonomy')) |
|
56 | + 'term_id_taxonomy'=>new EE_Unique_Index(array('term_id', 'taxonomy')) |
|
57 | 57 | ); |
58 | 58 | $path_to_tax_model = ''; |
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( $path_to_tax_model ); |
|
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected($path_to_tax_model); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
62 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
63 | 63 | |
64 | 64 | //add cap restrictions for editing relating to the "ee_edit_*" |
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
66 | 66 | array( |
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array( '!=', 'espresso_event_categories' ) |
|
67 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories') |
|
68 | 68 | )); |
69 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
69 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
70 | 70 | array( |
71 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
71 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories') |
|
72 | 72 | )); |
73 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
73 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
74 | 74 | array( |
75 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array( '!=', 'espresso_event_type' ) |
|
75 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type') |
|
76 | 76 | )); |
77 | 77 | |
78 | 78 | //add cap restrictions for deleting relating to the "ee_deleting_*" |
79 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
79 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
80 | 80 | array( |
81 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array( '!=', 'espresso_event_categories' ) |
|
81 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories') |
|
82 | 82 | )); |
83 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
83 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
84 | 84 | array( |
85 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
85 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories') |
|
86 | 86 | )); |
87 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
87 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
88 | 88 | array( |
89 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array( '!=', 'espresso_event_type' ) |
|
89 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type') |
|
90 | 90 | )); |
91 | 91 | |
92 | - parent::__construct( $timezone ); |
|
92 | + parent::__construct($timezone); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | } |
@@ -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 | * |
@@ -21,16 +21,16 @@ 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_Venue extends EEM_CPT_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 = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE,time()), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE,time()), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ); |
77 | 77 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID'); |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
80 | - parent::__construct( $timezone ); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
80 | + parent::__construct($timezone); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Integer_Field.php'); |
|
3 | -class EE_Boolean_Field extends EE_Integer_Field{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Integer_Field.php'); |
|
3 | +class EE_Boolean_Field extends EE_Integer_Field { |
|
4 | 4 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
5 | - if ($value_inputted_for_field_on_model_object){ |
|
5 | + if ($value_inputted_for_field_on_model_object) { |
|
6 | 6 | return true; |
7 | - }else{ |
|
7 | + } else { |
|
8 | 8 | return false; |
9 | 9 | } |
10 | 10 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @return boolean |
15 | 15 | */ |
16 | 16 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
17 | - return intval( $value_inputted_for_field_on_model_object ) ? true : false; |
|
17 | + return intval($value_inputted_for_field_on_model_object) ? true : false; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @param boolean $value_on_field_to_be_outputted |
23 | 23 | * @return string Yes or No |
24 | 24 | */ |
25 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted ) { |
|
25 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted) { |
|
26 | 26 | return apply_filters( |
27 | 27 | 'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return', |
28 | - $value_on_field_to_be_outputted ? __( 'Yes', 'event_espresso' ) : __( 'No', 'event_espresso' ), |
|
28 | + $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'), |
|
29 | 29 | $value_on_field_to_be_outputted |
30 | 30 | ); |
31 | 31 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function construction_finalized(){ |
93 | 93 | if( $this->_model instanceof EEM_Base && $this->_action ){ |
94 | 94 | return true; |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function has_generated_cap_restrictions(){ |
126 | 126 | if( $this->_cap_restrictions_generated === false ){ |
127 | 127 | return false; |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities( 'administrator' ); |
154 | 154 | if( in_array( self::get_cap_name( $model, $action ), $caps_for_admin ) ) { |
155 | 155 | return true; |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | } |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * other than explicitly setting it to EE_INF. |
8 | 8 | * Makes use of constant EE_INF_IN_DB set in espresso.php, and EE_INF, which is a PHP constant definedin the ether |
9 | 9 | */ |
10 | -class EE_Infinite_Integer_Field extends EE_Model_Field_Base{ |
|
11 | - function get_wpdb_data_type(){ |
|
10 | +class EE_Infinite_Integer_Field extends EE_Model_Field_Base { |
|
11 | + function get_wpdb_data_type() { |
|
12 | 12 | return '%d'; |
13 | 13 | } |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if($value_of_field_on_model_object === EE_INF){ |
|
15 | + if ($value_of_field_on_model_object === EE_INF) { |
|
16 | 16 | return EE_INF_IN_DB; |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return intval($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
22 | - if($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
22 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
23 | 23 | $value_inputted_for_field_on_model_object === EE_INF || |
24 | 24 | $value_inputted_for_field_on_model_object === "EE_INF" |
25 | - ){ |
|
25 | + ) { |
|
26 | 26 | return EE_INF; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | return intval($value_inputted_for_field_on_model_object); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
32 | 32 | $intval = intval($value_inputted_for_field_on_model_object); |
33 | - if($intval == EE_INF_IN_DB){ |
|
33 | + if ($intval == EE_INF_IN_DB) { |
|
34 | 34 | return EE_INF; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return $intval; |
37 | 37 | } |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = null ) { |
|
49 | - if( $value_on_field_to_be_outputted === EE_INF ){ |
|
50 | - switch($schema){ |
|
48 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
49 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
50 | + switch ($schema) { |
|
51 | 51 | case 'input': |
52 | 52 | return ''; |
53 | 53 | case 'symbol': |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @subpackage /core/db_models/fields/EE_Model_Field_Base.php |
19 | 19 | * @author Michael Nelson |
20 | 20 | */ |
21 | -abstract class EE_Model_Field_Base{ |
|
21 | +abstract class EE_Model_Field_Base { |
|
22 | 22 | var $_table_alias; |
23 | 23 | var $_table_column; |
24 | 24 | var $_name; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param $nullable |
35 | 35 | * @param null $default_value |
36 | 36 | */ |
37 | - function __construct($table_column, $nicename, $nullable, $default_value = null){ |
|
37 | + function __construct($table_column, $nicename, $nullable, $default_value = null) { |
|
38 | 38 | $this->_table_column = $table_column; |
39 | 39 | $this->_nicename = $nicename; |
40 | 40 | $this->_nullable = $nullable; |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | * @param $name |
49 | 49 | * @param $model_name |
50 | 50 | */ |
51 | - function _construct_finalize($table_alias, $name, $model_name){ |
|
51 | + function _construct_finalize($table_alias, $name, $model_name) { |
|
52 | 52 | $this->_table_alias = $table_alias; |
53 | 53 | $this->_name = $name; |
54 | 54 | $this->_model_name = $model_name; |
55 | 55 | /** |
56 | 56 | * allow for changing the defaults |
57 | 57 | */ |
58 | - $this->_nicename = apply_filters( 'FHEE__EE_Model_Field_Base___construct_finalize___nicename', $this->_nicename, $this ); |
|
59 | - $this->_default_value = apply_filters( 'FHEE__EE_Model_Field_Base___construct_finalize___default_value', $this->_default_value, $this ); |
|
58 | + $this->_nicename = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___nicename', $this->_nicename, $this); |
|
59 | + $this->_default_value = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___default_value', $this->_default_value, $this); |
|
60 | 60 | } |
61 | - function get_table_alias(){ |
|
61 | + function get_table_alias() { |
|
62 | 62 | return $this->_table_alias; |
63 | 63 | } |
64 | - function get_table_column(){ |
|
64 | + function get_table_column() { |
|
65 | 65 | return $this->_table_column; |
66 | 66 | } |
67 | 67 | /** |
68 | 68 | * Returns the name of the model this field is on. Eg 'Event' or 'Ticket_Datetime' |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - function get_model_name(){ |
|
71 | + function get_model_name() { |
|
72 | 72 | return $this->_model_name; |
73 | 73 | } |
74 | 74 | |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | * @throws \EE_Error |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - function get_name(){ |
|
80 | - if($this->_name){ |
|
79 | + function get_name() { |
|
80 | + if ($this->_name) { |
|
81 | 81 | return $this->_name; |
82 | - }else{ |
|
83 | - throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", "event_espresso"),get_class($this))); |
|
82 | + } else { |
|
83 | + throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", "event_espresso"), get_class($this))); |
|
84 | 84 | } |
85 | 85 | } |
86 | - function get_nicename(){ |
|
86 | + function get_nicename() { |
|
87 | 87 | return $this->_nicename; |
88 | 88 | } |
89 | - function is_nullable(){ |
|
89 | + function is_nullable() { |
|
90 | 90 | return $this->_nullable; |
91 | 91 | } |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * on insertion it can be null. However, on updates it must be present. |
95 | 95 | * @return boolean |
96 | 96 | */ |
97 | - function is_auto_increment(){ |
|
97 | + function is_auto_increment() { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * value domains at the top of EEM_Base |
103 | 103 | * @return mixed |
104 | 104 | */ |
105 | - function get_default_value(){ |
|
105 | + function get_default_value() { |
|
106 | 106 | return $this->_default_value; |
107 | 107 | } |
108 | 108 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * in the current query |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - function get_qualified_column(){ |
|
116 | + function get_qualified_column() { |
|
117 | 117 | return $this->get_table_alias().".".$this->get_table_column(); |
118 | 118 | } |
119 | 119 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param mixed $value_of_field_on_model_object |
125 | 125 | * @return mixed |
126 | 126 | */ |
127 | - function prepare_for_get($value_of_field_on_model_object){ |
|
127 | + function prepare_for_get($value_of_field_on_model_object) { |
|
128 | 128 | return $value_of_field_on_model_object; |
129 | 129 | } |
130 | 130 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param mixed $value_of_field_on_model_object |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - function prepare_for_use_in_db($value_of_field_on_model_object){ |
|
137 | + function prepare_for_use_in_db($value_of_field_on_model_object) { |
|
138 | 138 | return $value_of_field_on_model_object; |
139 | 139 | } |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param mixed $value_inputted_for_field_on_model_object |
146 | 146 | * @return mixed |
147 | 147 | */ |
148 | - function prepare_for_set($value_inputted_for_field_on_model_object){ |
|
148 | + function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
149 | 149 | return $value_inputted_for_field_on_model_object; |
150 | 150 | } |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param mixed $value_found_in_db_for_model_object |
157 | 157 | * @return mixed |
158 | 158 | */ |
159 | - function prepare_for_set_from_db($value_found_in_db_for_model_object){ |
|
159 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
|
160 | 160 | return $this->prepare_for_set($value_found_in_db_for_model_object); |
161 | 161 | } |
162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param mixed $value_on_field_to_be_outputted |
168 | 168 | * @return mixed |
169 | 169 | */ |
170 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted ){ |
|
170 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted) { |
|
171 | 171 | return $value_on_field_to_be_outputted; |
172 | 172 | } |
173 | 173 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * By default, all fields aren't db-only. |
183 | 183 | * @return boolean |
184 | 184 | */ |
185 | - function is_db_only_field(){ |
|
185 | + function is_db_only_field() { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -29,9 +29,9 @@ |
||
29 | 29 | protected $_model_name; |
30 | 30 | |
31 | 31 | /** |
32 | - * @param $table_column |
|
32 | + * @param string $table_column |
|
33 | 33 | * @param $nicename |
34 | - * @param $nullable |
|
34 | + * @param boolean $nullable |
|
35 | 35 | * @param null $default_value |
36 | 36 | */ |
37 | 37 | function __construct($table_column, $nicename, $nullable, $default_value = null){ |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...) |
4 | 4 | */ |
5 | -class EE_Money_Field extends EE_Float_Field{ |
|
6 | - function get_wpdb_data_type(){ |
|
5 | +class EE_Money_Field extends EE_Float_Field { |
|
6 | + function get_wpdb_data_type() { |
|
7 | 7 | return '%f'; |
8 | 8 | } |
9 | 9 | /** |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @param type $schema |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){ |
|
18 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
19 | 19 | $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
20 | 20 | |
21 | - if($schema == 'localized_float'){ |
|
21 | + if ($schema == 'localized_float') { |
|
22 | 22 | return $pretty_float; |
23 | 23 | } |
24 | - if($schema == 'no_currency_code'){ |
|
24 | + if ($schema == 'no_currency_code') { |
|
25 | 25 | // echo "schema no currency!"; |
26 | 26 | $display_code = false; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | $display_code = true; |
29 | 29 | } |
30 | 30 | //we don't use the $pretty_float because format_currency will take care of it. |
31 | - return EEH_Template::format_currency( $value_on_field_to_be_outputted, false, $display_code ); |
|
31 | + return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | //now it's a float-style string or number |
48 | 48 | $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object); |
49 | 49 | //round to the correctly number of decimal places for this currency |
50 | - $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
50 | + $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
51 | 51 | return $rounded_value; |
52 | 52 | } |
53 | 53 |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
2 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * Class EE_Belongs_To_Relation |
5 | 5 | * |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | //create the sql string like |
37 | 37 | $this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
38 | 38 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
39 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias(); |
|
40 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
39 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias(); |
|
40 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
41 | 41 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
42 | - return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
42 | + return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
54 | 54 | //find the field on the other model which is a foreign key to this model |
55 | 55 | $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
56 | - if ( $this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()){ |
|
56 | + if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) { |
|
57 | 57 | //set that field on the other model to this model's ID |
58 | 58 | $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID()); |
59 | 59 | $this_model_obj->save(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function remove_relation_to($this_obj_or_id, $other_obj_or_id) { |
71 | 71 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
72 | - $other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id ); |
|
72 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
73 | 73 | //find the field on the other model which is a foreign key to this model |
74 | 74 | $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
75 | 75 | //set that field on the other model to this model's ID |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | * @return EE_Base_Class[] |
87 | 87 | */ |
88 | 88 | public function get_all_related($model_obj_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
89 | - if( $values_already_prepared_by_model_object !== false ) { |
|
90 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
89 | + if ($values_already_prepared_by_model_object !== false) { |
|
90 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
91 | 91 | } |
92 | 92 | //get column on this model object which is a foreign key to the other model |
93 | 93 | $fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
94 | 94 | //get its value |
95 | - if( $model_obj_or_id instanceof EE_Base_Class){ |
|
95 | + if ($model_obj_or_id instanceof EE_Base_Class) { |
|
96 | 96 | $model_obj = $model_obj_or_id; |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | $model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id); |
99 | 99 | } |
100 | 100 | $ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name()); |