@@ -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 | * Event Espresso |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $parent_term_taxonomy_id optional |
48 | 48 | * @return EE_Term_Taxonomy |
49 | 49 | */ |
50 | - function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) { |
|
51 | - return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id ); |
|
50 | + function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) { |
|
51 | + return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param string $category_name |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - function remove_event_category( $category_name ) { |
|
62 | - return $this->get_model()->remove_event_category( $this, $category_name ); |
|
61 | + function remove_event_category($category_name) { |
|
62 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param EE_Term_Taxonomy $term_taxonomy |
71 | 71 | * @return EE_Base_Class the relation was removed from |
72 | 72 | */ |
73 | - function remove_relation_to_term_taxonomy( $term_taxonomy ) { |
|
74 | - if ( !$term_taxonomy ) { |
|
75 | - EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
73 | + function remove_relation_to_term_taxonomy($term_taxonomy) { |
|
74 | + if ( ! $term_taxonomy) { |
|
75 | + EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return NULL; |
77 | 77 | } |
78 | - $term_taxonomy->set_count( $term_taxonomy->count() - 1 ); |
|
78 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
79 | 79 | $term_taxonomy->save(); |
80 | - return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' ); |
|
80 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return int |
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | - return $this->get( 'parent' ); |
|
104 | + return $this->get('parent'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return string |
112 | 112 | */ |
113 | 113 | public function status() { |
114 | - return $this->get( 'status' ); |
|
114 | + return $this->get('status'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string $status |
121 | 121 | */ |
122 | - public function set_status( $status ) { |
|
123 | - $this->set( 'status', $status ); |
|
122 | + public function set_status($status) { |
|
123 | + $this->set('status', $status); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
137 | - protected function _get_feature_image( $size, $attr ) { |
|
137 | + protected function _get_feature_image($size, $attr) { |
|
138 | 138 | //first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
139 | - $attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr; |
|
140 | - $cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key; |
|
141 | - $this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr ); |
|
142 | - return $this->_feature_image[ $cache_key ]; |
|
139 | + $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
140 | + $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key; |
|
141 | + $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
142 | + return $this->_feature_image[$cache_key]; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string|array $attr |
151 | 151 | * @return string of html |
152 | 152 | */ |
153 | - public function feature_image( $size = 'thumbnail', $attr = '' ) { |
|
154 | - return $this->_get_feature_image( $size, $attr ); |
|
153 | + public function feature_image($size = 'thumbnail', $attr = '') { |
|
154 | + return $this->_get_feature_image($size, $attr); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | - public function feature_image_url( $size = 'thumbnail' ) { |
|
165 | - $attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size ); |
|
166 | - return !empty( $attachment ) ? $attachment[ 0 ] : FALSE; |
|
164 | + public function feature_image_url($size = 'thumbnail') { |
|
165 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
166 | + return ! empty($attachment) ? $attachment[0] : FALSE; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -176,37 +176,37 @@ discard block |
||
176 | 176 | * @internal param array|string $related_obj_names if included this will be used to restore for related obj if not included then we just do restore on the meta. We will accept an array of related_obj_names for restoration here. |
177 | 177 | * @return void |
178 | 178 | */ |
179 | - public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) { |
|
179 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) { |
|
180 | 180 | //get revision object |
181 | - $revision_obj = $this->get_model()->get_one_by_ID( $revision_id ); |
|
182 | - if ( $revision_obj instanceof EE_CPT_Base ) { |
|
181 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
182 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
183 | 183 | //no related_obj_name so we assume we're saving a revision on this object. |
184 | - if ( empty( $related_obj_names ) ) { |
|
184 | + if (empty($related_obj_names)) { |
|
185 | 185 | $fields = $this->get_model()->get_meta_table_fields(); |
186 | - foreach ( $fields as $field ) { |
|
187 | - $this->set( $field, $revision_obj->get( $field ) ); |
|
186 | + foreach ($fields as $field) { |
|
187 | + $this->set($field, $revision_obj->get($field)); |
|
188 | 188 | } |
189 | 189 | $this->save(); |
190 | 190 | } |
191 | - $related_obj_names = (array)$related_obj_names; |
|
192 | - foreach ( $related_obj_names as $related_name ) { |
|
191 | + $related_obj_names = (array) $related_obj_names; |
|
192 | + foreach ($related_obj_names as $related_name) { |
|
193 | 193 | //related_obj_name so we're saving a revision on an object related to this object |
194 | 194 | //do we have $where_query params for this related object? If we do then we include that. |
195 | - $cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array(); |
|
196 | - $where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array(); |
|
197 | - $related_objs = $this->get_many_related( $related_name, $where_params ); |
|
198 | - $revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params ); |
|
195 | + $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array(); |
|
196 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
197 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
198 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
199 | 199 | //load helper |
200 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
200 | + EE_Registry::instance()->load_helper('Array'); |
|
201 | 201 | //remove related objs from this object that are not in revision |
202 | 202 | //array_diff *should* work cause I think objects are indexed by ID? |
203 | - $related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs ); |
|
204 | - foreach ( $related_to_remove as $rr ) { |
|
205 | - $this->_remove_relation_to( $rr, $related_name, $cols_n_values ); |
|
203 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
204 | + foreach ($related_to_remove as $rr) { |
|
205 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
206 | 206 | } |
207 | 207 | //add all related objs attached to revision to this object |
208 | - foreach ( $revision_related_objs as $r_obj ) { |
|
209 | - $this->_add_relation_to( $r_obj, $related_name, $cols_n_values ); |
|
208 | + foreach ($revision_related_objs as $r_obj) { |
|
209 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
223 | 223 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
224 | 224 | */ |
225 | - public function get_post_meta( $meta_key = NULL, $single = FALSE ) { |
|
226 | - return get_post_meta( $this->ID(), $meta_key, $single ); |
|
225 | + public function get_post_meta($meta_key = NULL, $single = FALSE) { |
|
226 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | * @throws EE_Error |
237 | 237 | * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false. |
238 | 238 | */ |
239 | - public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) { |
|
240 | - if ( !$this->ID() ) { |
|
241 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
239 | + public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) { |
|
240 | + if ( ! $this->ID()) { |
|
241 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
242 | 242 | } |
243 | - return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value ); |
|
243 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | * @throws EE_Error |
254 | 254 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
255 | 255 | */ |
256 | - public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) { |
|
257 | - if ( !$this->ID() ) { |
|
258 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
256 | + public function add_post_meta($meta_key, $meta_value, $unique = FALSE) { |
|
257 | + if ( ! $this->ID()) { |
|
258 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
259 | 259 | } |
260 | - return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique ); |
|
260 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string |
268 | 268 | */ |
269 | 269 | public function get_permalink() { |
270 | - return get_permalink( $this->ID() ); |
|
270 | + return get_permalink($this->ID()); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param array $query_params |
278 | 278 | * @return EE_Term_Taxonomy |
279 | 279 | */ |
280 | - public function term_taxonomies( $query_params = array() ) { |
|
281 | - return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
|
280 | + public function term_taxonomies($query_params = array()) { |
|
281 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * The main purpose of this method is to return the parent for the model object |
99 | 99 | * |
100 | 100 | * @access public |
101 | - * @return int |
|
101 | + * @return boolean |
|
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | 104 | return $this->get( 'parent' ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | /** |
110 | 110 | * return the _status property |
111 | - * @return string |
|
111 | + * @return boolean |
|
112 | 112 | */ |
113 | 113 | public function status() { |
114 | 114 | return $this->get( 'status' ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
132 | 132 | * @access protected |
133 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
133 | + * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class using the given size params. |
161 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
161 | + * @param integer[] $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | 164 | public function feature_image_url( $size = 'thumbnail' ) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | /** |
276 | 276 | * Gets all the term-taxonomies for this CPT |
277 | 277 | * @param array $query_params |
278 | - * @return EE_Term_Taxonomy |
|
278 | + * @return EE_Base_Class[] |
|
279 | 279 | */ |
280 | 280 | public function term_taxonomies( $query_params = array() ) { |
281 | 281 | return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
@@ -2,18 +2,18 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Event Espresso |
|
6 | - * |
|
7 | - * Event Registration and Management Plugin for WordPress |
|
8 | - * |
|
9 | - * @ package Event Espresso |
|
10 | - * @ author Event Espresso |
|
11 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | - * @ link {@link http://www.eventespresso.com} |
|
14 | - * @ since 4.0 |
|
15 | - * |
|
16 | - */ |
|
5 | + * Event Espresso |
|
6 | + * |
|
7 | + * Event Registration and Management Plugin for WordPress |
|
8 | + * |
|
9 | + * @ package Event Espresso |
|
10 | + * @ author Event Espresso |
|
11 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | + * @ link {@link http://www.eventespresso.com} |
|
14 | + * @ since 4.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | |
18 | 18 | |
19 | 19 |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @return EE_Event_Message_Template|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
25 | + public static function new_instance($props_n_values = array(), $timezone = NULL) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
27 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param null $timezone |
35 | 35 | * @return EE_Event_Message_Template |
36 | 36 | */ |
37 | - public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
|
38 | - return new self( $props_n_values, TRUE, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) { |
|
38 | + return new self($props_n_values, TRUE, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -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,18 +1,18 @@ 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 | * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
6 | 6 | */ |
7 | -class EE_Event_Question_Group extends EE_Base_Class{ |
|
7 | +class EE_Event_Question_Group extends EE_Base_Class { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @param array $props_n_values |
11 | 11 | * @return EE_Event_Question_Group|mixed |
12 | 12 | */ |
13 | - public static function new_instance( $props_n_values = array() ) { |
|
14 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
15 | - return $has_object ? $has_object : new self( $props_n_values); |
|
13 | + public static function new_instance($props_n_values = array()) { |
|
14 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
15 | + return $has_object ? $has_object : new self($props_n_values); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param array $props_n_values |
22 | 22 | * @return EE_Event_Question_Group |
23 | 23 | */ |
24 | - public static function new_instance_from_db ( $props_n_values = array() ) { |
|
25 | - return new self( $props_n_values, TRUE ); |
|
24 | + public static function new_instance_from_db($props_n_values = array()) { |
|
25 | + return new self($props_n_values, TRUE); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
|
4 | - */ |
|
3 | + * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
|
4 | + */ |
|
5 | 5 | class EE_Event_Venue extends EE_Base_Class{ |
6 | 6 | |
7 | 7 | /** |
@@ -2,15 +2,15 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Required by EEM_Event_Question_Group in case someone queries for all its model objects |
4 | 4 | */ |
5 | -class EE_Event_Venue extends EE_Base_Class{ |
|
5 | +class EE_Event_Venue extends EE_Base_Class { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @param array $props_n_values |
9 | 9 | * @return EE_Event_Venue|mixed |
10 | 10 | */ |
11 | - public static function new_instance( $props_n_values = array() ) { |
|
12 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
13 | - return $has_object ? $has_object : new self( $props_n_values); |
|
11 | + public static function new_instance($props_n_values = array()) { |
|
12 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
13 | + return $has_object ? $has_object : new self($props_n_values); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | * @param array $props_n_values |
20 | 20 | * @return EE_Event_Venue |
21 | 21 | */ |
22 | - public static function new_instance_from_db ( $props_n_values = array() ) { |
|
23 | - return new self( $props_n_values, TRUE ); |
|
22 | + public static function new_instance_from_db($props_n_values = array()) { |
|
23 | + return new self($props_n_values, TRUE); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | if( isset( $this->_children[ $code ] ) ) { |
671 | 671 | unset( $this->_children[ $code ] ); |
672 | 672 | return 1; |
673 | - }else{ |
|
673 | + } else{ |
|
674 | 674 | return 0; |
675 | 675 | } |
676 | 676 | } |
@@ -1007,10 +1007,10 @@ discard block |
||
1007 | 1007 | //that's taxable too (the taxable total so far) |
1008 | 1008 | if( $child_line_item->is_percent() ) { |
1009 | 1009 | $total = $total + ( $total * $child_line_item->percent() / 100 ); |
1010 | - }else{ |
|
1010 | + } else{ |
|
1011 | 1011 | $total += $child_line_item->total(); |
1012 | 1012 | } |
1013 | - }elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){ |
|
1013 | + } elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){ |
|
1014 | 1014 | $total += $child_line_item->taxable_total(); |
1015 | 1015 | } |
1016 | 1016 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Gets TXN_ID |
83 | - * @return int |
|
83 | + * @return boolean |
|
84 | 84 | */ |
85 | 85 | function TXN_ID() { |
86 | 86 | return $this->get( 'TXN_ID' ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Sets TXN_ID |
93 | 93 | * @param int $TXN_ID |
94 | - * @return boolean |
|
94 | + * @return boolean|null |
|
95 | 95 | */ |
96 | 96 | function set_TXN_ID( $TXN_ID ) { |
97 | 97 | $this->set( 'TXN_ID', $TXN_ID ); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Sets name |
118 | 118 | * @param string $name |
119 | - * @return boolean |
|
119 | + * @return boolean|null |
|
120 | 120 | */ |
121 | 121 | function set_name( $name ) { |
122 | 122 | $this->set( 'LIN_name', $name ); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Gets desc |
129 | - * @return string |
|
129 | + * @return boolean |
|
130 | 130 | */ |
131 | 131 | function desc() { |
132 | 132 | return $this->get( 'LIN_desc' ); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * Sets desc |
139 | 139 | * @param string $desc |
140 | - * @return boolean |
|
140 | + * @return boolean|null |
|
141 | 141 | */ |
142 | 142 | function set_desc( $desc ) { |
143 | 143 | $this->set( 'LIN_desc', $desc ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Gets quantity |
150 | - * @return int |
|
150 | + * @return boolean |
|
151 | 151 | */ |
152 | 152 | function quantity() { |
153 | 153 | return $this->get( 'LIN_quantity' ); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * Sets quantity |
160 | 160 | * @param int $quantity |
161 | - * @return boolean |
|
161 | + * @return boolean|null |
|
162 | 162 | */ |
163 | 163 | function set_quantity( $quantity ) { |
164 | 164 | $this->set( 'LIN_quantity', $quantity ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Gets item_id |
171 | - * @return string |
|
171 | + * @return boolean |
|
172 | 172 | */ |
173 | 173 | function OBJ_ID() { |
174 | 174 | return $this->get( 'OBJ_ID' ); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * Sets item_id |
181 | 181 | * @param string $item_id |
182 | - * @return boolean |
|
182 | + * @return boolean|null |
|
183 | 183 | */ |
184 | 184 | function set_OBJ_ID( $item_id ) { |
185 | 185 | $this->set( 'OBJ_ID', $item_id ); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Gets item_type |
192 | - * @return string |
|
192 | + * @return boolean |
|
193 | 193 | */ |
194 | 194 | function OBJ_type() { |
195 | 195 | return $this->get( 'OBJ_type' ); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * Sets item_type |
202 | 202 | * @param string $OBJ_type |
203 | - * @return boolean |
|
203 | + * @return boolean|null |
|
204 | 204 | */ |
205 | 205 | function set_OBJ_type( $OBJ_type ) { |
206 | 206 | $this->set( 'OBJ_type', $OBJ_type ); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Gets unit_price |
213 | - * @return float |
|
213 | + * @return boolean |
|
214 | 214 | */ |
215 | 215 | function unit_price() { |
216 | 216 | return $this->get( 'LIN_unit_price' ); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * Sets unit_price |
223 | 223 | * @param float $unit_price |
224 | - * @return boolean |
|
224 | + * @return boolean|null |
|
225 | 225 | */ |
226 | 226 | function set_unit_price( $unit_price ) { |
227 | 227 | $this->set( 'LIN_unit_price', $unit_price ); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Gets percent (between 100-.001) |
256 | - * @return float |
|
256 | + * @return boolean |
|
257 | 257 | */ |
258 | 258 | function percent() { |
259 | 259 | return $this->get( 'LIN_percent' ); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | /** |
265 | 265 | * Sets percent (between 100-0.01) |
266 | 266 | * @param float $percent |
267 | - * @return boolean |
|
267 | + * @return boolean|null |
|
268 | 268 | */ |
269 | 269 | function set_percent( $percent ) { |
270 | 270 | $this->set( 'LIN_percent', $percent ); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Gets total |
277 | - * @return float |
|
277 | + * @return boolean |
|
278 | 278 | */ |
279 | 279 | function total() { |
280 | 280 | return $this->get( 'LIN_total' ); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | /** |
286 | 286 | * Sets total |
287 | 287 | * @param float $total |
288 | - * @return boolean |
|
288 | + * @return boolean|null |
|
289 | 289 | */ |
290 | 290 | function set_total( $total ) { |
291 | 291 | $this->set( 'LIN_total', $total ); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Gets parent |
308 | - * @return int |
|
308 | + * @return boolean |
|
309 | 309 | */ |
310 | 310 | function parent_ID() { |
311 | 311 | return $this->get( 'LIN_parent' ); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | /** |
317 | 317 | * Sets parent |
318 | 318 | * @param int $parent |
319 | - * @return boolean |
|
319 | + * @return boolean|null |
|
320 | 320 | */ |
321 | 321 | function set_parent_ID( $parent ) { |
322 | 322 | $this->set( 'LIN_parent', $parent ); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Gets type |
329 | - * @return string |
|
329 | + * @return boolean |
|
330 | 330 | */ |
331 | 331 | function type() { |
332 | 332 | return $this->get( 'LIN_type' ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | /** |
338 | 338 | * Sets type |
339 | 339 | * @param string $type |
340 | - * @return boolean |
|
340 | + * @return boolean|null |
|
341 | 341 | */ |
342 | 342 | function set_type( $type ) { |
343 | 343 | $this->set( 'LIN_type', $type ); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Gets code |
377 | - * @return string |
|
377 | + * @return boolean |
|
378 | 378 | */ |
379 | 379 | function code() { |
380 | 380 | return $this->get( 'LIN_code' ); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | /** |
386 | 386 | * Sets code |
387 | 387 | * @param string $code |
388 | - * @return boolean |
|
388 | + * @return boolean|null |
|
389 | 389 | */ |
390 | 390 | function set_code( $code ) { |
391 | 391 | $this->set( 'LIN_code', $code ); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | /** |
407 | 407 | * Sets is_taxable |
408 | 408 | * @param boolean $is_taxable |
409 | - * @return boolean |
|
409 | + * @return boolean|null |
|
410 | 410 | */ |
411 | 411 | function set_is_taxable( $is_taxable ) { |
412 | 412 | $this->set( 'LIN_is_taxable', $is_taxable ); |
@@ -2,18 +2,18 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Event Espresso |
|
6 | - * |
|
7 | - * Event Registration and Management Plugin for WordPress |
|
8 | - * |
|
9 | - * @ package Event Espresso |
|
10 | - * @ author Event Espresso |
|
11 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | - * @ link {@link http://www.eventespresso.com} |
|
14 | - * @ since 4.0 |
|
15 | - * |
|
16 | - */ |
|
5 | + * Event Espresso |
|
6 | + * |
|
7 | + * Event Registration and Management Plugin for WordPress |
|
8 | + * |
|
9 | + * @ package Event Espresso |
|
10 | + * @ author Event Espresso |
|
11 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | + * @ link {@link http://www.eventespresso.com} |
|
14 | + * @ since 4.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | |
18 | 18 | |
19 | 19 |
@@ -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 | * Event Espresso |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * date_format and the second value is the time format |
45 | 45 | * @return EE_Line_Item |
46 | 46 | */ |
47 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
48 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
49 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
47 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
48 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
49 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * the website will be used. |
58 | 58 | * @return EE_Line_Item |
59 | 59 | */ |
60 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
61 | - return new self( $props_n_values, TRUE, $timezone ); |
|
60 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
61 | + return new self($props_n_values, TRUE, $timezone); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @param bool $bydb |
70 | 70 | * @param string $timezone |
71 | 71 | */ |
72 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) { |
|
73 | - parent::__construct( $fieldValues, $bydb, $timezone ); |
|
74 | - if ( ! $this->get( 'LIN_code' ) ) { |
|
75 | - $this->set_code( $this->generate_code() ); |
|
72 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') { |
|
73 | + parent::__construct($fieldValues, $bydb, $timezone); |
|
74 | + if ( ! $this->get('LIN_code')) { |
|
75 | + $this->set_code($this->generate_code()); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return int |
84 | 84 | */ |
85 | 85 | function TXN_ID() { |
86 | - return $this->get( 'TXN_ID' ); |
|
86 | + return $this->get('TXN_ID'); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param int $TXN_ID |
94 | 94 | * @return boolean |
95 | 95 | */ |
96 | - function set_TXN_ID( $TXN_ID ) { |
|
97 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
96 | + function set_TXN_ID($TXN_ID) { |
|
97 | + $this->set('TXN_ID', $TXN_ID); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @return string |
105 | 105 | */ |
106 | 106 | function name() { |
107 | - $name = $this->get( 'LIN_name' ); |
|
108 | - if( ! $name ){ |
|
109 | - $name = ucwords( str_replace( '-', ' ', $this->type() ) ); |
|
107 | + $name = $this->get('LIN_name'); |
|
108 | + if ( ! $name) { |
|
109 | + $name = ucwords(str_replace('-', ' ', $this->type())); |
|
110 | 110 | } |
111 | 111 | return $name; |
112 | 112 | } |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @param string $name |
119 | 119 | * @return boolean |
120 | 120 | */ |
121 | - function set_name( $name ) { |
|
122 | - $this->set( 'LIN_name', $name ); |
|
121 | + function set_name($name) { |
|
122 | + $this->set('LIN_name', $name); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string |
130 | 130 | */ |
131 | 131 | function desc() { |
132 | - return $this->get( 'LIN_desc' ); |
|
132 | + return $this->get('LIN_desc'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $desc |
140 | 140 | * @return boolean |
141 | 141 | */ |
142 | - function set_desc( $desc ) { |
|
143 | - $this->set( 'LIN_desc', $desc ); |
|
142 | + function set_desc($desc) { |
|
143 | + $this->set('LIN_desc', $desc); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function quantity() { |
153 | - return $this->get( 'LIN_quantity' ); |
|
153 | + return $this->get('LIN_quantity'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param int $quantity |
161 | 161 | * @return boolean |
162 | 162 | */ |
163 | - function set_quantity( $quantity ) { |
|
164 | - $this->set( 'LIN_quantity', $quantity ); |
|
163 | + function set_quantity($quantity) { |
|
164 | + $this->set('LIN_quantity', $quantity); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @return string |
172 | 172 | */ |
173 | 173 | function OBJ_ID() { |
174 | - return $this->get( 'OBJ_ID' ); |
|
174 | + return $this->get('OBJ_ID'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param string $item_id |
182 | 182 | * @return boolean |
183 | 183 | */ |
184 | - function set_OBJ_ID( $item_id ) { |
|
185 | - $this->set( 'OBJ_ID', $item_id ); |
|
184 | + function set_OBJ_ID($item_id) { |
|
185 | + $this->set('OBJ_ID', $item_id); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return string |
193 | 193 | */ |
194 | 194 | function OBJ_type() { |
195 | - return $this->get( 'OBJ_type' ); |
|
195 | + return $this->get('OBJ_type'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @param string $OBJ_type |
203 | 203 | * @return boolean |
204 | 204 | */ |
205 | - function set_OBJ_type( $OBJ_type ) { |
|
206 | - $this->set( 'OBJ_type', $OBJ_type ); |
|
205 | + function set_OBJ_type($OBJ_type) { |
|
206 | + $this->set('OBJ_type', $OBJ_type); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @return float |
214 | 214 | */ |
215 | 215 | function unit_price() { |
216 | - return $this->get( 'LIN_unit_price' ); |
|
216 | + return $this->get('LIN_unit_price'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param float $unit_price |
224 | 224 | * @return boolean |
225 | 225 | */ |
226 | - function set_unit_price( $unit_price ) { |
|
227 | - $this->set( 'LIN_unit_price', $unit_price ); |
|
226 | + function set_unit_price($unit_price) { |
|
227 | + $this->set('LIN_unit_price', $unit_price); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | * @return boolean |
236 | 236 | */ |
237 | 237 | function is_percent() { |
238 | - if( $this->is_tax_sub_total() ) { |
|
238 | + if ($this->is_tax_sub_total()) { |
|
239 | 239 | //tax subtotals HAVE a percent on them, that percentage only applies |
240 | 240 | //to taxable items, so its' an exception. Treat it like a flat line item |
241 | 241 | return false; |
242 | 242 | } |
243 | - $unit_price = $this->get( 'LIN_unit_price' ); |
|
244 | - $percent = $this->get( 'LIN_percent' ); |
|
245 | - if ( $unit_price < .001 && $percent ) { |
|
243 | + $unit_price = $this->get('LIN_unit_price'); |
|
244 | + $percent = $this->get('LIN_percent'); |
|
245 | + if ($unit_price < .001 && $percent) { |
|
246 | 246 | return TRUE; |
247 | - } elseif ( $unit_price >= .001 && !$percent ) { |
|
247 | + } elseif ($unit_price >= .001 && ! $percent) { |
|
248 | 248 | return FALSE; |
249 | - } elseif ( $unit_price >= .001 && $percent ) { |
|
250 | - throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) ); |
|
249 | + } elseif ($unit_price >= .001 && $percent) { |
|
250 | + throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent)); |
|
251 | 251 | } else { |
252 | 252 | // if they're both 0, assume its not a percent item |
253 | 253 | return FALSE; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return float |
262 | 262 | */ |
263 | 263 | function percent() { |
264 | - return $this->get( 'LIN_percent' ); |
|
264 | + return $this->get('LIN_percent'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | * @param float $percent |
272 | 272 | * @return boolean |
273 | 273 | */ |
274 | - function set_percent( $percent ) { |
|
275 | - $this->set( 'LIN_percent', $percent ); |
|
274 | + function set_percent($percent) { |
|
275 | + $this->set('LIN_percent', $percent); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return float |
283 | 283 | */ |
284 | 284 | function total() { |
285 | - return $this->get( 'LIN_total' ); |
|
285 | + return $this->get('LIN_total'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param float $total |
293 | 293 | * @return boolean |
294 | 294 | */ |
295 | - function set_total( $total ) { |
|
296 | - $this->set( 'LIN_total', $total ); |
|
295 | + function set_total($total) { |
|
296 | + $this->set('LIN_total', $total); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * Sets order |
303 | 303 | * @param int $order |
304 | 304 | */ |
305 | - function set_order( $order ) { |
|
306 | - $this->set( 'LIN_order', $order ); |
|
305 | + function set_order($order) { |
|
306 | + $this->set('LIN_order', $order); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * @return int |
314 | 314 | */ |
315 | 315 | function parent_ID() { |
316 | - return $this->get( 'LIN_parent' ); |
|
316 | + return $this->get('LIN_parent'); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param int $parent |
324 | 324 | * @return boolean |
325 | 325 | */ |
326 | - function set_parent_ID( $parent ) { |
|
327 | - $this->set( 'LIN_parent', $parent ); |
|
326 | + function set_parent_ID($parent) { |
|
327 | + $this->set('LIN_parent', $parent); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @return string |
335 | 335 | */ |
336 | 336 | function type() { |
337 | - return $this->get( 'LIN_type' ); |
|
337 | + return $this->get('LIN_type'); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param string $type |
345 | 345 | * @return boolean |
346 | 346 | */ |
347 | - function set_type( $type ) { |
|
348 | - $this->set( 'LIN_type', $type ); |
|
347 | + function set_type($type) { |
|
348 | + $this->set('LIN_type', $type); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return EE_Line_Item |
356 | 356 | */ |
357 | 357 | public function parent() { |
358 | - return $this->get_model()->get_one_by_ID( $this->parent_ID() ); |
|
358 | + return $this->get_model()->get_one_by_ID($this->parent_ID()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @return EE_Line_Item[] |
366 | 366 | */ |
367 | 367 | public function children() { |
368 | - if ( $this->ID() ) { |
|
368 | + if ($this->ID()) { |
|
369 | 369 | return $this->get_model()->get_all( |
370 | 370 | array( |
371 | - array( 'LIN_parent' => $this->ID() ), |
|
372 | - 'order_by' => array( 'LIN_order' => 'ASC' ) ) ); |
|
371 | + array('LIN_parent' => $this->ID()), |
|
372 | + 'order_by' => array('LIN_order' => 'ASC') ) ); |
|
373 | 373 | } else { |
374 | - if ( ! is_array( $this->_children ) ) { |
|
374 | + if ( ! is_array($this->_children)) { |
|
375 | 375 | $this->_children = array(); |
376 | 376 | } |
377 | 377 | return $this->_children; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @return string |
386 | 386 | */ |
387 | 387 | function code() { |
388 | - return $this->get( 'LIN_code' ); |
|
388 | + return $this->get('LIN_code'); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $code |
396 | 396 | * @return boolean |
397 | 397 | */ |
398 | - function set_code( $code ) { |
|
399 | - $this->set( 'LIN_code', $code ); |
|
398 | + function set_code($code) { |
|
399 | + $this->set('LIN_code', $code); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @return boolean |
407 | 407 | */ |
408 | 408 | function is_taxable() { |
409 | - return $this->get( 'LIN_is_taxable' ); |
|
409 | + return $this->get('LIN_is_taxable'); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param boolean $is_taxable |
417 | 417 | * @return boolean |
418 | 418 | */ |
419 | - function set_is_taxable( $is_taxable ) { |
|
420 | - $this->set( 'LIN_is_taxable', $is_taxable ); |
|
419 | + function set_is_taxable($is_taxable) { |
|
420 | + $this->set('LIN_is_taxable', $is_taxable); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | */ |
433 | 433 | function get_object() { |
434 | 434 | $model_name_of_related_obj = $this->OBJ_type(); |
435 | - return $this->get_model()->has_relation( $model_name_of_related_obj ) ? $this->get_first_related( $model_name_of_related_obj ) : NULL; |
|
435 | + return $this->get_model()->has_relation($model_name_of_related_obj) ? $this->get_first_related($model_name_of_related_obj) : NULL; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -443,11 +443,11 @@ discard block |
||
443 | 443 | * @param array $query_params |
444 | 444 | * @return EE_Ticket |
445 | 445 | */ |
446 | - function ticket( $query_params = array() ) { |
|
446 | + function ticket($query_params = array()) { |
|
447 | 447 | //we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived. This can be overridden via the incoming $query_params argument |
448 | - $remove_defaults = array( 'default_where_conditions' => 'none' ); |
|
449 | - $query_params = array_merge( $remove_defaults, $query_params ); |
|
450 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
448 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
449 | + $query_params = array_merge($remove_defaults, $query_params); |
|
450 | + return $this->get_first_related('Ticket', $query_params); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | * @return EE_Datetime | NULL |
458 | 458 | */ |
459 | 459 | function get_ticket_datetime() { |
460 | - if ( $this->OBJ_type() === 'Ticket' ) { |
|
460 | + if ($this->OBJ_type() === 'Ticket') { |
|
461 | 461 | $ticket = $this->ticket(); |
462 | - if ( $ticket instanceof EE_Ticket ) { |
|
462 | + if ($ticket instanceof EE_Ticket) { |
|
463 | 463 | $datetime = $ticket->first_datetime(); |
464 | - if ( $datetime instanceof EE_Datetime ) { |
|
464 | + if ($datetime instanceof EE_Datetime) { |
|
465 | 465 | return $datetime; |
466 | 466 | } |
467 | 467 | } |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @return string |
478 | 478 | */ |
479 | 479 | function ticket_event_name() { |
480 | - $event_name = __( "Unknown", "event_espresso" ); |
|
480 | + $event_name = __("Unknown", "event_espresso"); |
|
481 | 481 | $event = $this->ticket_event(); |
482 | - if ( $event instanceof EE_Event ) { |
|
482 | + if ($event instanceof EE_Event) { |
|
483 | 483 | $event_name = $event->name(); |
484 | 484 | } |
485 | 485 | return $event_name; |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | function ticket_event() { |
494 | 494 | $event = null; |
495 | 495 | $ticket = $this->ticket(); |
496 | - if ( $ticket instanceof EE_Ticket ) { |
|
496 | + if ($ticket instanceof EE_Ticket) { |
|
497 | 497 | $datetime = $ticket->first_datetime(); |
498 | - if ( $datetime instanceof EE_Datetime ) { |
|
498 | + if ($datetime instanceof EE_Datetime) { |
|
499 | 499 | $event = $datetime->event(); |
500 | 500 | } |
501 | 501 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @param string $time_format |
511 | 511 | * @return string |
512 | 512 | */ |
513 | - function ticket_datetime_start( $date_format = '', $time_format = '' ) { |
|
514 | - $first_datetime_string = __( "Unknown", "event_espresso" ); |
|
513 | + function ticket_datetime_start($date_format = '', $time_format = '') { |
|
514 | + $first_datetime_string = __("Unknown", "event_espresso"); |
|
515 | 515 | $datetime = $this->get_ticket_datetime(); |
516 | - if ( $datetime ) { |
|
517 | - $first_datetime_string = $datetime->start_date_and_time( $date_format, $time_format ); |
|
516 | + if ($datetime) { |
|
517 | + $first_datetime_string = $datetime->start_date_and_time($date_format, $time_format); |
|
518 | 518 | } |
519 | 519 | return $first_datetime_string; |
520 | 520 | } |
@@ -527,21 +527,21 @@ discard block |
||
527 | 527 | * @param EE_Line_Item $line_item |
528 | 528 | * @return boolean success |
529 | 529 | */ |
530 | - function add_child_line_item( EE_Line_Item $line_item ) { |
|
531 | - $line_item->set_order( count( $this->children() ) ); |
|
532 | - if ( $this->ID() ) { |
|
530 | + function add_child_line_item(EE_Line_Item $line_item) { |
|
531 | + $line_item->set_order(count($this->children())); |
|
532 | + if ($this->ID()) { |
|
533 | 533 | //check for any duplicate line items (with the same code), if so, this replaces it |
534 | - $line_item_with_same_code = $this->get_child_line_item( $line_item->code() ); |
|
535 | - if( $line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item ) { |
|
536 | - $this->delete_child_line_item( $line_item_with_same_code->code() ); |
|
534 | + $line_item_with_same_code = $this->get_child_line_item($line_item->code()); |
|
535 | + if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) { |
|
536 | + $this->delete_child_line_item($line_item_with_same_code->code()); |
|
537 | 537 | } |
538 | - $line_item->set_parent_ID( $this->ID() ); |
|
539 | - if( $this->TXN_ID() ){ |
|
540 | - $line_item->set_TXN_ID( $this->TXN_ID() ); |
|
538 | + $line_item->set_parent_ID($this->ID()); |
|
539 | + if ($this->TXN_ID()) { |
|
540 | + $line_item->set_TXN_ID($this->TXN_ID()); |
|
541 | 541 | } |
542 | 542 | return $line_item->save(); |
543 | 543 | } else { |
544 | - $this->_children[ $line_item->code() ] = $line_item; |
|
544 | + $this->_children[$line_item->code()] = $line_item; |
|
545 | 545 | return TRUE; |
546 | 546 | } |
547 | 547 | } |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | * @param string $code |
556 | 556 | * @return EE_Line_Item |
557 | 557 | */ |
558 | - function get_child_line_item( $code ) { |
|
559 | - if ( $this->ID() ) { |
|
560 | - return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) ); |
|
558 | + function get_child_line_item($code) { |
|
559 | + if ($this->ID()) { |
|
560 | + return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code))); |
|
561 | 561 | } else { |
562 | - return isset( $this->_children[ $code ] ) ? $this->_children[ $code ] : null; |
|
562 | + return isset($this->_children[$code]) ? $this->_children[$code] : null; |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
@@ -570,10 +570,10 @@ discard block |
||
570 | 570 | * @return int |
571 | 571 | */ |
572 | 572 | function delete_children_line_items() { |
573 | - if ( $this->ID() ) { |
|
574 | - return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) ); |
|
573 | + if ($this->ID()) { |
|
574 | + return $this->get_model()->delete(array(array('LIN_parent' => $this->ID()))); |
|
575 | 575 | } else { |
576 | - $count = count( $this->_children ); |
|
576 | + $count = count($this->_children); |
|
577 | 577 | $this->_children = array(); |
578 | 578 | return $count; |
579 | 579 | } |
@@ -590,25 +590,25 @@ discard block |
||
590 | 590 | * @param bool $stop_search_once_found |
591 | 591 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
592 | 592 | */ |
593 | - function delete_child_line_item( $code, $stop_search_once_found = true ) { |
|
594 | - if ( $this->ID() ) { |
|
593 | + function delete_child_line_item($code, $stop_search_once_found = true) { |
|
594 | + if ($this->ID()) { |
|
595 | 595 | $items_deleted = 0; |
596 | - if( $this->code() == $code ) { |
|
597 | - $items_deleted += EEH_Line_Item::delete_all_child_items( $this ); |
|
598 | - $items_deleted += intval( $this->delete() ); |
|
599 | - if( $stop_search_once_found ){ |
|
596 | + if ($this->code() == $code) { |
|
597 | + $items_deleted += EEH_Line_Item::delete_all_child_items($this); |
|
598 | + $items_deleted += intval($this->delete()); |
|
599 | + if ($stop_search_once_found) { |
|
600 | 600 | return $items_deleted; |
601 | 601 | } |
602 | 602 | } |
603 | - foreach( $this->children() as $child_line_item ) { |
|
604 | - $items_deleted += $child_line_item->delete_child_line_item( $code, $stop_search_once_found ); |
|
603 | + foreach ($this->children() as $child_line_item) { |
|
604 | + $items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found); |
|
605 | 605 | } |
606 | 606 | return $items_deleted; |
607 | 607 | } else { |
608 | - if( isset( $this->_children[ $code ] ) ) { |
|
609 | - unset( $this->_children[ $code ] ); |
|
608 | + if (isset($this->_children[$code])) { |
|
609 | + unset($this->_children[$code]); |
|
610 | 610 | return 1; |
611 | - }else{ |
|
611 | + } else { |
|
612 | 612 | return 0; |
613 | 613 | } |
614 | 614 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | * @return boolean |
622 | 622 | */ |
623 | 623 | public function delete_if_childless_subtotal() { |
624 | - if( $this->ID() && |
|
624 | + if ($this->ID() && |
|
625 | 625 | $this->type() == EEM_Line_Item::type_sub_total && |
626 | - ! $this->children() ) { |
|
626 | + ! $this->children()) { |
|
627 | 627 | return $this->delete(); |
628 | 628 | } else { |
629 | 629 | return false; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | function generate_code() { |
640 | 640 | // each line item in the cart requires a unique identifier |
641 | - return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . microtime() ); |
|
641 | + return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime()); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * @return string like '2, 004.00', formatted according to the localized currency |
703 | 703 | */ |
704 | 704 | function unit_price_no_code() { |
705 | - return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' ); |
|
705 | + return $this->get_pretty('LIN_unit_price', 'no_currency_code'); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @return string like '2, 004.00', formatted according to the localized currency |
713 | 713 | */ |
714 | 714 | function total_no_code() { |
715 | - return $this->get_pretty( 'LIN_total', 'no_currency_code' ); |
|
715 | + return $this->get_pretty('LIN_total', 'no_currency_code'); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
@@ -730,14 +730,14 @@ discard block |
||
730 | 730 | |
731 | 731 | $total = $pre_tax_total + $tax_total; |
732 | 732 | // no negative totals plz |
733 | - $total = max( $total, 0 ); |
|
734 | - $this->set_total( $total ); |
|
735 | - if( $this->type() == EEM_Line_Item::type_total && $this->transaction() instanceof EE_Transaction ){ |
|
736 | - $this->transaction()->set_total( $total ); |
|
737 | - if ( $this->transaction()->ID() ) { |
|
733 | + $total = max($total, 0); |
|
734 | + $this->set_total($total); |
|
735 | + if ($this->type() == EEM_Line_Item::type_total && $this->transaction() instanceof EE_Transaction) { |
|
736 | + $this->transaction()->set_total($total); |
|
737 | + if ($this->transaction()->ID()) { |
|
738 | 738 | $this->transaction()->save(); |
739 | - $reg_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
740 | - $reg_processor->update_registration_final_prices( $this->transaction() ); |
|
739 | + $reg_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
740 | + $reg_processor->update_registration_final_prices($this->transaction()); |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | $this->maybe_save(); |
@@ -754,39 +754,39 @@ discard block |
||
754 | 754 | * @return float |
755 | 755 | * @throws \EE_Error |
756 | 756 | */ |
757 | - function recalculate_pre_tax_total( EE_Line_Item $parent_line_item = null ) { |
|
757 | + function recalculate_pre_tax_total(EE_Line_Item $parent_line_item = null) { |
|
758 | 758 | $total = 0; |
759 | 759 | //completely ignore tax sub-totals when calculating the pre-tax-total |
760 | - if ( $this->is_tax_sub_total() ) { |
|
760 | + if ($this->is_tax_sub_total()) { |
|
761 | 761 | return 0; |
762 | - } elseif ( $this->is_sub_line_item() ) { |
|
763 | - throw new EE_Error( sprintf( __( 'Calculating the pretax-total on sub-line items doesn\'t make sense right now. You were trying to calculate it on %s', "event_espresso" ), print_r( $this, TRUE ) ) ); |
|
764 | - } elseif ( $this->is_line_item() ) { |
|
765 | - if ( $this->is_percent() && $parent_line_item instanceof EE_Line_Item ) { |
|
762 | + } elseif ($this->is_sub_line_item()) { |
|
763 | + throw new EE_Error(sprintf(__('Calculating the pretax-total on sub-line items doesn\'t make sense right now. You were trying to calculate it on %s', "event_espresso"), print_r($this, TRUE))); |
|
764 | + } elseif ($this->is_line_item()) { |
|
765 | + if ($this->is_percent() && $parent_line_item instanceof EE_Line_Item) { |
|
766 | 766 | $total += $parent_line_item->total() * $this->percent() / 100; |
767 | 767 | } else { |
768 | 768 | $total = $this->unit_price() * $this->quantity(); |
769 | 769 | } |
770 | - $this->set_total( $total ); |
|
770 | + $this->set_total($total); |
|
771 | 771 | $this->maybe_save(); |
772 | - } elseif ( $this->is_sub_total() || $this->is_total() ) { |
|
772 | + } elseif ($this->is_sub_total() || $this->is_total()) { |
|
773 | 773 | //get the total of all its children |
774 | - foreach ( $this->children() as $child_line_item ) { |
|
775 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
774 | + foreach ($this->children() as $child_line_item) { |
|
775 | + if ($child_line_item instanceof EE_Line_Item) { |
|
776 | 776 | //only recalculate sub-totals for NON-taxes |
777 | - if ( $child_line_item->is_percent() ) { |
|
777 | + if ($child_line_item->is_percent()) { |
|
778 | 778 | $total += $total * $child_line_item->percent() / 100; |
779 | 779 | } else { |
780 | - $total += $child_line_item->recalculate_pre_tax_total( $this ); |
|
780 | + $total += $child_line_item->recalculate_pre_tax_total($this); |
|
781 | 781 | } |
782 | 782 | } |
783 | 783 | } |
784 | 784 | //we only want to update sub-totals if we're including non-taxable items |
785 | 785 | //and grand totals shouldn't be updated when calculating pre-tax totals |
786 | - if( $this->is_sub_total() ){ |
|
786 | + if ($this->is_sub_total()) { |
|
787 | 787 | // no negative totals plz |
788 | - $total = max( $total, 0 ); |
|
789 | - $this->set_total( $total ); |
|
788 | + $total = max($total, 0); |
|
789 | + $this->set_total($total); |
|
790 | 790 | $this->maybe_save(); |
791 | 791 | } |
792 | 792 | } |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | //calculate the pretax total |
807 | 807 | $taxable_total = $this->taxable_total(); |
808 | 808 | $tax_total = 0; |
809 | - foreach ( $taxes as $tax ) { |
|
809 | + foreach ($taxes as $tax) { |
|
810 | 810 | $total_on_this_tax = $taxable_total * $tax->percent() / 100; |
811 | 811 | //remember the total on this line item |
812 | - $tax->set_total( $total_on_this_tax ); |
|
812 | + $tax->set_total($total_on_this_tax); |
|
813 | 813 | $tax_total += $tax->total(); |
814 | 814 | } |
815 | 815 | $this->_recalculate_tax_sub_total(); |
@@ -823,21 +823,21 @@ discard block |
||
823 | 823 | * @return void |
824 | 824 | */ |
825 | 825 | private function _recalculate_tax_sub_total() { |
826 | - if ( $this->is_tax_sub_total() ) { |
|
826 | + if ($this->is_tax_sub_total()) { |
|
827 | 827 | $total = 0; |
828 | 828 | $total_percent = 0; |
829 | 829 | //simply loop through all its children (which should be taxes) and sum their total |
830 | - foreach ( $this->children() as $child_tax ) { |
|
831 | - if ( $child_tax instanceof EE_Line_Item ) { |
|
830 | + foreach ($this->children() as $child_tax) { |
|
831 | + if ($child_tax instanceof EE_Line_Item) { |
|
832 | 832 | $total += $child_tax->total(); |
833 | 833 | $total_percent += $child_tax->percent(); |
834 | 834 | } |
835 | 835 | } |
836 | - $this->set_total( $total ); |
|
837 | - $this->set_percent( $total_percent ); |
|
838 | - } elseif ( $this->is_total() ) { |
|
839 | - foreach ( $this->children() as $maybe_tax_subtotal ) { |
|
840 | - if ( $maybe_tax_subtotal instanceof EE_Line_Item ) { |
|
836 | + $this->set_total($total); |
|
837 | + $this->set_percent($total_percent); |
|
838 | + } elseif ($this->is_total()) { |
|
839 | + foreach ($this->children() as $maybe_tax_subtotal) { |
|
840 | + if ($maybe_tax_subtotal instanceof EE_Line_Item) { |
|
841 | 841 | $maybe_tax_subtotal->_recalculate_tax_sub_total(); |
842 | 842 | } |
843 | 843 | } |
@@ -853,8 +853,8 @@ discard block |
||
853 | 853 | public function get_total_tax() { |
854 | 854 | $this->_recalculate_tax_sub_total(); |
855 | 855 | $total = 0; |
856 | - foreach ( $this->tax_descendants() as $tax_line_item ) { |
|
857 | - if ( $tax_line_item instanceof EE_Line_Item ) { |
|
856 | + foreach ($this->tax_descendants() as $tax_line_item) { |
|
857 | + if ($tax_line_item instanceof EE_Line_Item) { |
|
858 | 858 | $total += $tax_line_item->total(); |
859 | 859 | } |
860 | 860 | } |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | */ |
869 | 869 | public function get_items_total() { |
870 | 870 | $total = 0; |
871 | - foreach ( $this->get_items() as $item ) { |
|
872 | - if ( $item instanceof EE_Line_Item ) { |
|
871 | + foreach ($this->get_items() as $item) { |
|
872 | + if ($item instanceof EE_Line_Item) { |
|
873 | 873 | $total += $item->total(); |
874 | 874 | } |
875 | 875 | } |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | * @return EE_Line_Item[] |
885 | 885 | */ |
886 | 886 | function tax_descendants() { |
887 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
888 | - return EEH_Line_Item::get_tax_descendants( $this ); |
|
887 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
888 | + return EEH_Line_Item::get_tax_descendants($this); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * @return EE_Line_Item[] |
896 | 896 | */ |
897 | 897 | function get_items() { |
898 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
899 | - return EEH_Line_Item::get_line_item_descendants( $this ); |
|
898 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
899 | + return EEH_Line_Item::get_line_item_descendants($this); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | |
@@ -908,17 +908,17 @@ discard block |
||
908 | 908 | */ |
909 | 909 | function taxable_total() { |
910 | 910 | $total = 0; |
911 | - if ( $this->children() ) { |
|
912 | - foreach ( $this->children() as $child_line_item ) { |
|
913 | - if ( $child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
911 | + if ($this->children()) { |
|
912 | + foreach ($this->children() as $child_line_item) { |
|
913 | + if ($child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
914 | 914 | //if it's a percent item, only take into account the percent |
915 | 915 | //that's taxable too (the taxable total so far) |
916 | - if( $child_line_item->is_percent() ) { |
|
917 | - $total = $total + ( $total * $child_line_item->percent() / 100 ); |
|
918 | - }else{ |
|
916 | + if ($child_line_item->is_percent()) { |
|
917 | + $total = $total + ($total * $child_line_item->percent() / 100); |
|
918 | + } else { |
|
919 | 919 | $total += $child_line_item->total(); |
920 | 920 | } |
921 | - }elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){ |
|
921 | + }elseif ($child_line_item->type() == EEM_Line_Item::type_sub_total) { |
|
922 | 922 | $total += $child_line_item->taxable_total(); |
923 | 923 | } |
924 | 924 | } |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * @return EE_Transaction |
934 | 934 | */ |
935 | 935 | public function transaction() { |
936 | - return $this->get_first_related( 'Transaction' ); |
|
936 | + return $this->get_first_related('Transaction'); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -946,17 +946,17 @@ discard block |
||
946 | 946 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
947 | 947 | * @return int count of items saved |
948 | 948 | */ |
949 | - public function save_this_and_descendants_to_txn( $txn_id = NULL ) { |
|
950 | - if ( ! $txn_id ) { |
|
949 | + public function save_this_and_descendants_to_txn($txn_id = NULL) { |
|
950 | + if ( ! $txn_id) { |
|
951 | 951 | $txn_id = $this->TXN_ID(); |
952 | 952 | } |
953 | - $this->set_TXN_ID( $txn_id ); |
|
953 | + $this->set_TXN_ID($txn_id); |
|
954 | 954 | $children = $this->children(); |
955 | 955 | $this->save(); |
956 | - foreach ( $children as $child_line_item ) { |
|
957 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
958 | - $child_line_item->set_parent_ID( $this->ID() ); |
|
959 | - $child_line_item->save_this_and_descendants_to_txn( $txn_id ); |
|
956 | + foreach ($children as $child_line_item) { |
|
957 | + if ($child_line_item instanceof EE_Line_Item) { |
|
958 | + $child_line_item->set_parent_ID($this->ID()); |
|
959 | + $child_line_item->save_this_and_descendants_to_txn($txn_id); |
|
960 | 960 | } |
961 | 961 | } |
962 | 962 | } |
@@ -968,10 +968,10 @@ discard block |
||
968 | 968 | * @param string $type one of the constants on EEM_Line_Item |
969 | 969 | * @return EE_Line_Item[] |
970 | 970 | */ |
971 | - protected function _get_descendants_of_type( $type ) { |
|
972 | - EE_Error::doing_it_wrong( 'EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0' ); |
|
973 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
974 | - return EEH_Line_Item::get_descendants_of_type( $this, $type ); |
|
971 | + protected function _get_descendants_of_type($type) { |
|
972 | + EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'); |
|
973 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
974 | + return EEH_Line_Item::get_descendants_of_type($this, $type); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | |
@@ -981,10 +981,10 @@ discard block |
||
981 | 981 | * @param string $type like one of the EEM_Line_Item::type_* |
982 | 982 | * @return EE_Line_Item |
983 | 983 | */ |
984 | - public function get_nearest_descendant_of_type( $type ) { |
|
985 | - EE_Error::doing_it_wrong( 'EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0' ); |
|
986 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
987 | - return EEH_Line_Item::get_nearest_descendant_of_type( $this, $type ); |
|
984 | + public function get_nearest_descendant_of_type($type) { |
|
985 | + EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'); |
|
986 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
987 | + return EEH_Line_Item::get_nearest_descendant_of_type($this, $type); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | * @return int count of items saved |
996 | 996 | */ |
997 | 997 | public function maybe_save() { |
998 | - if ( $this->ID() ) { |
|
998 | + if ($this->ID()) { |
|
999 | 999 | return $this->save(); |
1000 | 1000 | } |
1001 | 1001 | return false; |
@@ -2,15 +2,15 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Required by EEM_Question_Group_Question in case someone queries for all its model objects |
4 | 4 | */ |
5 | -class EE_Question_Group_Question extends EE_Base_Class{ |
|
5 | +class EE_Question_Group_Question extends EE_Base_Class { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @param array $props_n_values |
9 | 9 | * @return EE_Question_Group_Question|mixed |
10 | 10 | */ |
11 | - public static function new_instance( $props_n_values = array() ) { |
|
12 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
13 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
11 | + public static function new_instance($props_n_values = array()) { |
|
12 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
13 | + return $has_object ? $has_object : new self($props_n_values); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param array $props_n_values |
20 | 20 | * @return EE_Question_Group_Question |
21 | 21 | */ |
22 | - public static function new_instance_from_db ( $props_n_values = array() ) { |
|
23 | - return new self( $props_n_values, TRUE ); |
|
22 | + public static function new_instance_from_db($props_n_values = array()) { |
|
23 | + return new self($props_n_values, TRUE); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -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 | * Event Espresso |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return boolean success |
34 | 34 | */ |
35 | 35 | public function delete() { |
36 | - return $this->delete_or_restore( TRUE ); |
|
36 | + return $this->delete_or_restore(TRUE); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return boolean success |
44 | 44 | */ |
45 | 45 | public function delete_permanently() { |
46 | - return $this->get_model()->delete_permanently_by_ID( $this->ID() ); |
|
46 | + return $this->get_model()->delete_permanently_by_ID($this->ID()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @param bool $delete true=>delete, false=>restore |
54 | 54 | * @return bool |
55 | 55 | */ |
56 | - public function delete_or_restore( $delete = TRUE ) { |
|
56 | + public function delete_or_restore($delete = TRUE) { |
|
57 | 57 | $model = $this->get_model(); |
58 | - return $model->delete_or_restore_by_ID( $delete, $this->ID() ); |
|
58 | + return $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -65,6 +65,6 @@ discard block |
||
65 | 65 | * @return boolean |
66 | 66 | */ |
67 | 67 | public function restore() { |
68 | - return $this->delete_or_restore( FALSE ); |
|
68 | + return $this->delete_or_restore(FALSE); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -2,18 +2,18 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Event Espresso |
|
6 | - * |
|
7 | - * Event Registration and Management Plugin for WordPress |
|
8 | - * |
|
9 | - * @ package Event Espresso |
|
10 | - * @ author Event Espresso |
|
11 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | - * @ link {@link http://www.eventespresso.com} |
|
14 | - * @ since 4.0 |
|
15 | - * |
|
16 | - */ |
|
5 | + * Event Espresso |
|
6 | + * |
|
7 | + * Event Registration and Management Plugin for WordPress |
|
8 | + * |
|
9 | + * @ package Event Espresso |
|
10 | + * @ author Event Espresso |
|
11 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | + * @ link {@link http://www.eventespresso.com} |
|
14 | + * @ since 4.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | |
18 | 18 | |
19 | 19 |
@@ -2,12 +2,12 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Taxes class |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage includes/classes/EE_Taxes.class.php |
|
9 | - * @author Brent Christensen |
|
10 | - */ |
|
5 | + * Taxes class |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage includes/classes/EE_Taxes.class.php |
|
9 | + * @author Brent Christensen |
|
10 | + */ |
|
11 | 11 | class EE_Taxes extends EE_BASE { |
12 | 12 | |
13 | 13 | /** |
@@ -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 | * Taxes class |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | * @param EE_Ticket $ticket incoming EE_Ticket |
33 | 33 | * @return float total taxes to apply to ticket. |
34 | 34 | */ |
35 | - public static function get_total_taxes_for_admin( EE_Ticket $ticket ) { |
|
35 | + public static function get_total_taxes_for_admin(EE_Ticket $ticket) { |
|
36 | 36 | $tax = 0; |
37 | 37 | $total_tax = 0; |
38 | 38 | //This first checks to see if the given ticket is taxable. |
39 | - if ( ! $ticket->get( 'TKT_taxable' ) ) |
|
39 | + if ( ! $ticket->get('TKT_taxable')) |
|
40 | 40 | return $tax; |
41 | 41 | //get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
42 | - $subtotal = self::get_subtotal_for_admin( $ticket ); |
|
42 | + $subtotal = self::get_subtotal_for_admin($ticket); |
|
43 | 43 | //get taxes |
44 | 44 | $taxes = self::get_taxes_for_admin(); |
45 | 45 | //apply taxes to subtotal |
46 | - foreach ( $taxes as $tax ) { |
|
46 | + foreach ($taxes as $tax) { |
|
47 | 47 | //assuming taxes are not cumulative |
48 | - $total_tax += $subtotal * $tax->get( 'PRC_amount' ) / 100; |
|
48 | + $total_tax += $subtotal * $tax->get('PRC_amount') / 100; |
|
49 | 49 | } |
50 | 50 | return $total_tax; |
51 | 51 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public static function get_total_taxes_percentage() { |
59 | 59 | $total_tax_percent = 0; |
60 | - foreach( self::get_taxes_for_admin() as $tax_price ) { |
|
61 | - $total_tax_percent += $tax_price->get( 'PRC_amount' ); |
|
60 | + foreach (self::get_taxes_for_admin() as $tax_price) { |
|
61 | + $total_tax_percent += $tax_price->get('PRC_amount'); |
|
62 | 62 | } |
63 | 63 | return $total_tax_percent; |
64 | 64 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param EE_Ticket $ticket |
70 | 70 | * @return float |
71 | 71 | */ |
72 | - public static function get_subtotal_for_admin( EE_Ticket $ticket ) { |
|
72 | + public static function get_subtotal_for_admin(EE_Ticket $ticket) { |
|
73 | 73 | $TKT_ID = $ticket->ID(); |
74 | - return isset( self::$_subtotal[ $TKT_ID ] ) ? self::$_subtotal[ $TKT_ID ] : self::_get_subtotal_for_admin( $ticket ); |
|
74 | + return isset(self::$_subtotal[$TKT_ID]) ? self::$_subtotal[$TKT_ID] : self::_get_subtotal_for_admin($ticket); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -81,26 +81,26 @@ discard block |
||
81 | 81 | * @param EE_Ticket $ticket |
82 | 82 | * @return float subtotal calculated from all EE_Price[] on Ticket. |
83 | 83 | */ |
84 | - private static function _get_subtotal_for_admin( EE_Ticket $ticket ) { |
|
84 | + private static function _get_subtotal_for_admin(EE_Ticket $ticket) { |
|
85 | 85 | $subtotal = 0; |
86 | 86 | //get all prices |
87 | - $prices = $ticket->get_many_related( 'Price', array( 'default_where_conditions' => 'none', 'order_by' => array( 'PRC_order' => 'ASC' ) ) ); |
|
87 | + $prices = $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))); |
|
88 | 88 | //let's loop through them (base price is always the first item) |
89 | - foreach ( $prices as $price ) { |
|
90 | - if ( $price instanceof EE_Price ) { |
|
91 | - switch ( $price->type_obj()->base_type() ) { |
|
89 | + foreach ($prices as $price) { |
|
90 | + if ($price instanceof EE_Price) { |
|
91 | + switch ($price->type_obj()->base_type()) { |
|
92 | 92 | case 1: // base price |
93 | 93 | case 3: // surcharges |
94 | - $subtotal += $price->is_percent() ? $subtotal * $price->get( 'PRC_amount' ) / 100 : $price->get( 'PRC_amount' ); |
|
94 | + $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 : $price->get('PRC_amount'); |
|
95 | 95 | break; |
96 | 96 | case 2: // discounts |
97 | - $subtotal -= $price->is_percent() ? $subtotal * $price->get( 'PRC_amount' ) / 100 : $price->get( 'PRC_amount' ); |
|
97 | + $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 : $price->get('PRC_amount'); |
|
98 | 98 | break; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | $TKT_ID = $ticket->ID(); |
103 | - self::$_subtotal = array( $TKT_ID => $subtotal ); |
|
103 | + self::$_subtotal = array($TKT_ID => $subtotal); |
|
104 | 104 | return $subtotal; |
105 | 105 | } |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
112 | 112 | */ |
113 | 113 | public static function get_taxes_for_admin() { |
114 | - self::$_default_taxes = ! empty( self::$_default_taxes ) ? self::$_default_taxes : EE_Registry::instance()->load_model( 'Price' )->get_all( array( array( 'Price_Type.PBT_ID' => 4 ) ) ); |
|
114 | + self::$_default_taxes = ! empty(self::$_default_taxes) ? self::$_default_taxes : EE_Registry::instance()->load_model('Price')->get_all(array(array('Price_Type.PBT_ID' => 4))); |
|
115 | 115 | return self::$_default_taxes; |
116 | 116 | } |
117 | 117 |
@@ -36,8 +36,9 @@ |
||
36 | 36 | $tax = 0; |
37 | 37 | $total_tax = 0; |
38 | 38 | //This first checks to see if the given ticket is taxable. |
39 | - if ( ! $ticket->get( 'TKT_taxable' ) ) |
|
40 | - return $tax; |
|
39 | + if ( ! $ticket->get( 'TKT_taxable' ) ) { |
|
40 | + return $tax; |
|
41 | + } |
|
41 | 42 | //get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
42 | 43 | $subtotal = self::get_subtotal_for_admin( $ticket ); |
43 | 44 | //get taxes |
@@ -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 | * Event Espresso |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param array $props_n_values |
31 | 31 | * @return EE_Term_Relationship |
32 | 32 | */ |
33 | - public static function new_instance( $props_n_values = array() ) { |
|
34 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
35 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
33 | + public static function new_instance($props_n_values = array()) { |
|
34 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
35 | + return $has_object ? $has_object : new self($props_n_values); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @param array $props_n_values |
42 | 42 | * @return EE_Term_Relationship |
43 | 43 | */ |
44 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
45 | - return new self( $props_n_values, TRUE ); |
|
44 | + public static function new_instance_from_db($props_n_values = array()) { |
|
45 | + return new self($props_n_values, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -2,18 +2,18 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Event Espresso |
|
6 | - * |
|
7 | - * Event Registration and Management Plugin for WordPress |
|
8 | - * |
|
9 | - * @ package Event Espresso |
|
10 | - * @ author Event Espresso |
|
11 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | - * @ link {@link http://www.eventespresso.com} |
|
14 | - * @ since 4.0 |
|
15 | - * |
|
16 | - */ |
|
5 | + * Event Espresso |
|
6 | + * |
|
7 | + * Event Registration and Management Plugin for WordPress |
|
8 | + * |
|
9 | + * @ package Event Espresso |
|
10 | + * @ author Event Espresso |
|
11 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
12 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
13 | + * @ link {@link http://www.eventespresso.com} |
|
14 | + * @ since 4.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | |
18 | 18 | |
19 | 19 |