@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * date format |
|
51 | - * |
|
52 | - * pattern or format for displaying dates |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @var string |
|
56 | - */ |
|
50 | + * date format |
|
51 | + * |
|
52 | + * pattern or format for displaying dates |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $_dt_frmt; |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * time format |
|
63 | - * |
|
64 | - * pattern or format for displaying time |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @var string |
|
68 | - */ |
|
61 | + /** |
|
62 | + * time format |
|
63 | + * |
|
64 | + * pattern or format for displaying time |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | protected $_tm_frmt; |
70 | 70 | |
71 | 71 | |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets the field's original value when this object was constructed during this request. |
|
209 | - * This can be helpful when determining if a model object has changed or not |
|
210 | - * |
|
211 | - * @param string $field_name |
|
212 | - * @return mixed|null |
|
213 | - */ |
|
208 | + * Gets the field's original value when this object was constructed during this request. |
|
209 | + * This can be helpful when determining if a model object has changed or not |
|
210 | + * |
|
211 | + * @param string $field_name |
|
212 | + * @return mixed|null |
|
213 | + */ |
|
214 | 214 | public function get_original( $field_name ){ |
215 | 215 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
216 | 216 | $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
@@ -1310,28 +1310,28 @@ discard block |
||
1310 | 1310 | return $result ? true : false; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - /** |
|
1314 | - * When this model object is deleted, it may still be cached on related model objects. This clears the cache of |
|
1315 | - * related model objects |
|
1316 | - */ |
|
1317 | - public function refresh_cache_of_related_objects() { |
|
1318 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1319 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1320 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1321 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1322 | - //this relation only stores a single model object, not an array |
|
1323 | - //but let's make it consistent |
|
1324 | - $related_objects = array( $related_objects ); |
|
1325 | - } |
|
1326 | - foreach( $related_objects as $related_object ) { |
|
1327 | - //only refresh their cache if they're in memory |
|
1328 | - if( $related_object instanceof EE_Base_Class ) { |
|
1313 | + /** |
|
1314 | + * When this model object is deleted, it may still be cached on related model objects. This clears the cache of |
|
1315 | + * related model objects |
|
1316 | + */ |
|
1317 | + public function refresh_cache_of_related_objects() { |
|
1318 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1319 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1320 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1321 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1322 | + //this relation only stores a single model object, not an array |
|
1323 | + //but let's make it consistent |
|
1324 | + $related_objects = array( $related_objects ); |
|
1325 | + } |
|
1326 | + foreach( $related_objects as $related_object ) { |
|
1327 | + //only refresh their cache if they're in memory |
|
1328 | + if( $related_object instanceof EE_Base_Class ) { |
|
1329 | 1329 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1330 | - } |
|
1331 | - } |
|
1332 | - } |
|
1333 | - } |
|
1334 | - } |
|
1330 | + } |
|
1331 | + } |
|
1332 | + } |
|
1333 | + } |
|
1334 | + } |
|
1335 | 1335 | |
1336 | 1336 | |
1337 | 1337 | |
@@ -1681,9 +1681,9 @@ discard block |
||
1681 | 1681 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1682 | 1682 | //clear cache so future get_many_related and get_first_related() return new results. |
1683 | 1683 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1684 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1685 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1686 | - } |
|
1684 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1685 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1686 | + } |
|
1687 | 1687 | } else { |
1688 | 1688 | //this thing doesn't exist in the DB, so just cache it |
1689 | 1689 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1697,18 +1697,18 @@ discard block |
||
1697 | 1697 | } |
1698 | 1698 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1699 | 1699 | } |
1700 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1701 | - //fix the reciprocal relation too |
|
1702 | - if( $otherObject->ID() ) { |
|
1703 | - //its saved so assumed relations exist in the DB, so we can just |
|
1704 | - //clear the cache so future queries use the updated info in the DB |
|
1705 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1706 | - } else { |
|
1707 | - |
|
1708 | - //it's not saved, so it caches relations like this |
|
1709 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1710 | - } |
|
1711 | - } |
|
1700 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1701 | + //fix the reciprocal relation too |
|
1702 | + if( $otherObject->ID() ) { |
|
1703 | + //its saved so assumed relations exist in the DB, so we can just |
|
1704 | + //clear the cache so future queries use the updated info in the DB |
|
1705 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1706 | + } else { |
|
1707 | + |
|
1708 | + //it's not saved, so it caches relations like this |
|
1709 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1710 | + } |
|
1711 | + } |
|
1712 | 1712 | return $otherObject; |
1713 | 1713 | } |
1714 | 1714 | |
@@ -1738,9 +1738,9 @@ discard block |
||
1738 | 1738 | //this doesn't exist in the DB, just remove it from the cache |
1739 | 1739 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1740 | 1740 | } |
1741 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1742 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1743 | - } |
|
1741 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1742 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1743 | + } |
|
1744 | 1744 | return $otherObject; |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1759,11 +1759,11 @@ discard block |
||
1759 | 1759 | //this doesn't exist in the DB, just remove it from the cache |
1760 | 1760 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1761 | 1761 | } |
1762 | - if( is_array( $otherObjects ) ) { |
|
1763 | - foreach ( $otherObjects as $otherObject ) { |
|
1764 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1765 | - } |
|
1766 | - } |
|
1762 | + if( is_array( $otherObjects ) ) { |
|
1763 | + foreach ( $otherObjects as $otherObject ) { |
|
1764 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1765 | + } |
|
1766 | + } |
|
1767 | 1767 | return $otherObjects; |
1768 | 1768 | } |
1769 | 1769 |
@@ -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 | do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
3 | 5 | /** |
4 | 6 | * |
@@ -170,7 +172,7 @@ discard block |
||
170 | 172 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
171 | 173 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
172 | 174 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
175 | + } else{ |
|
174 | 176 | $this->_model_relations[$relation_name] = array(); |
175 | 177 | } |
176 | 178 | } |
@@ -215,7 +217,7 @@ discard block |
||
215 | 217 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
216 | 218 | $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
217 | 219 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
218 | - }else{ |
|
220 | + } else{ |
|
219 | 221 | return NULL; |
220 | 222 | } |
221 | 223 | } |
@@ -264,7 +266,7 @@ discard block |
||
264 | 266 | empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] ); |
265 | 267 | } |
266 | 268 | |
267 | - }else{ |
|
269 | + } else{ |
|
268 | 270 | $this->_fields[$field_name] = $holder_of_value; |
269 | 271 | } |
270 | 272 | |
@@ -292,7 +294,7 @@ discard block |
||
292 | 294 | } |
293 | 295 | //let's unset any cache for this field_name from the $_cached_properties property. |
294 | 296 | $this->_clear_cached_property( $field_name ); |
295 | - }else{ |
|
297 | + } else{ |
|
296 | 298 | throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
297 | 299 | } |
298 | 300 | |
@@ -588,8 +590,9 @@ discard block |
||
588 | 590 | * @return void |
589 | 591 | */ |
590 | 592 | protected function _clear_cached_property( $property_name ) { |
591 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
592 | - unset( $this->_cached_properties[ $property_name ] ); |
|
593 | + if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
594 | + unset( $this->_cached_properties[ $property_name ] ); |
|
595 | + } |
|
593 | 596 | } |
594 | 597 | |
595 | 598 | |
@@ -629,10 +632,10 @@ discard block |
||
629 | 632 | if($clear_all){ |
630 | 633 | $obj_removed = true; |
631 | 634 | $this->_model_relations[$relationName] = null; |
632 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
635 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
633 | 636 | $obj_removed = $this->_model_relations[$relationName]; |
634 | 637 | $this->_model_relations[$relationName] = null; |
635 | - }else{ |
|
638 | + } else{ |
|
636 | 639 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
637 | 640 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
638 | 641 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -646,20 +649,20 @@ discard block |
||
646 | 649 | } |
647 | 650 | if($index_found_at){ |
648 | 651 | $index_in_cache = $index_found_at; |
649 | - }else{ |
|
652 | + } else{ |
|
650 | 653 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
651 | 654 | //if it wasn't in it to begin with. So we're done |
652 | 655 | return $object_to_remove_or_index_into_array; |
653 | 656 | } |
654 | 657 | } |
655 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
658 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
656 | 659 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
657 | 660 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
658 | 661 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
659 | 662 | $index_in_cache = $index; |
660 | 663 | } |
661 | 664 | } |
662 | - }else{ |
|
665 | + } else{ |
|
663 | 666 | $index_in_cache = $object_to_remove_or_index_into_array; |
664 | 667 | } |
665 | 668 | //supposedly we've found it. But it could just be that the client code |
@@ -668,7 +671,7 @@ discard block |
||
668 | 671 | isset( $this->_model_relations[$relationName][$index_in_cache])){ |
669 | 672 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
670 | 673 | unset($this->_model_relations[$relationName][$index_in_cache]); |
671 | - }else{ |
|
674 | + } else{ |
|
672 | 675 | //that thing was never cached anyways. |
673 | 676 | $obj_removed = NULL; |
674 | 677 | } |
@@ -724,7 +727,7 @@ discard block |
||
724 | 727 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
725 | 728 | if(is_array($cached_array_or_object)){ |
726 | 729 | return array_shift($cached_array_or_object); |
727 | - }else{ |
|
730 | + } else{ |
|
728 | 731 | return $cached_array_or_object; |
729 | 732 | } |
730 | 733 | } |
@@ -743,10 +746,10 @@ discard block |
||
743 | 746 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
744 | 747 | if(is_array($cached_array_or_object)){ |
745 | 748 | $objects = $cached_array_or_object; |
746 | - }elseif($cached_array_or_object){ |
|
749 | + } elseif($cached_array_or_object){ |
|
747 | 750 | //if the result is not an array, but exists, make it an array |
748 | 751 | $objects = array($cached_array_or_object); |
749 | - }else{ |
|
752 | + } else{ |
|
750 | 753 | //if nothing was found, return an empty array |
751 | 754 | $objects = array(); |
752 | 755 | } |
@@ -761,7 +764,7 @@ discard block |
||
761 | 764 | if( $model_object->ID() ){ |
762 | 765 | $model->add_to_entity_map( $model_object ); |
763 | 766 | } |
764 | - }else{ |
|
767 | + } else{ |
|
765 | 768 | throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
766 | 769 | } |
767 | 770 | } |
@@ -886,10 +889,10 @@ discard block |
||
886 | 889 | if( $field_obj->is_nullable()){ |
887 | 890 | //if the field allows nulls, then let it be null |
888 | 891 | $field_value = NULL; |
889 | - }else{ |
|
892 | + } else{ |
|
890 | 893 | $field_value = $field_obj->get_default_value(); |
891 | 894 | } |
892 | - }else{ |
|
895 | + } else{ |
|
893 | 896 | $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
894 | 897 | } |
895 | 898 | $this->_fields[$field_name] = $field_value; |
@@ -1009,15 +1012,17 @@ discard block |
||
1009 | 1012 | $this->_tm_frmt = $in_tm_frmt; |
1010 | 1013 | } |
1011 | 1014 | |
1012 | - if ( $echo ) |
|
1013 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1014 | - else |
|
1015 | - $field->set_date_format( $in_dt_frmt ); |
|
1015 | + if ( $echo ) { |
|
1016 | + $field->set_pretty_date_format( $in_dt_frmt ); |
|
1017 | + } else { |
|
1018 | + $field->set_date_format( $in_dt_frmt ); |
|
1019 | + } |
|
1016 | 1020 | |
1017 | - if ( $echo ) |
|
1018 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1019 | - else |
|
1020 | - $field->set_time_format( $in_tm_frmt ); |
|
1021 | + if ( $echo ) { |
|
1022 | + $field->set_pretty_time_format( $in_tm_frmt ); |
|
1023 | + } else { |
|
1024 | + $field->set_time_format( $in_tm_frmt ); |
|
1025 | + } |
|
1021 | 1026 | |
1022 | 1027 | //set timezone in field object |
1023 | 1028 | $field->set_timezone( $this->_timezone ); |
@@ -1240,8 +1245,9 @@ discard block |
||
1240 | 1245 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1241 | 1246 | $timezone = EEH_DTT_Helper::get_timezone(); |
1242 | 1247 | |
1243 | - if ( $timezone == $this->_timezone ) |
|
1244 | - return ''; |
|
1248 | + if ( $timezone == $this->_timezone ) { |
|
1249 | + return ''; |
|
1250 | + } |
|
1245 | 1251 | |
1246 | 1252 | $original_timezone = $this->_timezone; |
1247 | 1253 | $this->set_timezone( $timezone ); |
@@ -1249,8 +1255,9 @@ discard block |
||
1249 | 1255 | $fn = (array) $field_name; |
1250 | 1256 | $args = array_merge( $fn, (array) $args ); |
1251 | 1257 | |
1252 | - if ( !method_exists( $this, $callback ) ) |
|
1253 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1258 | + if ( !method_exists( $this, $callback ) ) { |
|
1259 | + throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1260 | + } |
|
1254 | 1261 | $args = (array) $args; |
1255 | 1262 | $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
1256 | 1263 | |
@@ -1397,7 +1404,7 @@ discard block |
||
1397 | 1404 | $this->_update_cached_related_model_objs_fks(); |
1398 | 1405 | } |
1399 | 1406 | } |
1400 | - }else{//PK is NOT auto-increment |
|
1407 | + } else{//PK is NOT auto-increment |
|
1401 | 1408 | //so check if one like it already exists in the db |
1402 | 1409 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
1403 | 1410 | if( ! $this->in_entity_map() && WP_DEBUG ){ |
@@ -1412,12 +1419,12 @@ discard block |
||
1412 | 1419 | ); |
1413 | 1420 | } |
1414 | 1421 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1415 | - }else{ |
|
1422 | + } else{ |
|
1416 | 1423 | $results = $this->get_model()->insert($save_cols_n_values); |
1417 | 1424 | $this->_update_cached_related_model_objs_fks(); |
1418 | 1425 | } |
1419 | 1426 | } |
1420 | - }else{//there is NO primary key |
|
1427 | + } else{//there is NO primary key |
|
1421 | 1428 | $already_in_db = false; |
1422 | 1429 | foreach($this->get_model()->unique_indexes() as $index){ |
1423 | 1430 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1428,7 +1435,7 @@ discard block |
||
1428 | 1435 | if( $already_in_db ){ |
1429 | 1436 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
1430 | 1437 | $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
1431 | - }else{ |
|
1438 | + } else{ |
|
1432 | 1439 | $results = $this->get_model()->insert( $save_cols_n_values ); |
1433 | 1440 | } |
1434 | 1441 | } |
@@ -1480,7 +1487,7 @@ discard block |
||
1480 | 1487 | //make sure this has been saved |
1481 | 1488 | if( ! $this->ID()){ |
1482 | 1489 | $id = $this->save(); |
1483 | - }else{ |
|
1490 | + } else{ |
|
1484 | 1491 | $id = $this->ID(); |
1485 | 1492 | } |
1486 | 1493 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1499,7 +1506,7 @@ discard block |
||
1499 | 1506 | $this->_add_relation_to($related_model_obj, $relationName); |
1500 | 1507 | $related_model_obj->save_new_cached_related_model_objs(); |
1501 | 1508 | // } |
1502 | - }else{ |
|
1509 | + } else{ |
|
1503 | 1510 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
1504 | 1511 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1505 | 1512 | //but ONLY if it DOES NOT exist in the DB |
@@ -1558,13 +1565,13 @@ discard block |
||
1558 | 1565 | |
1559 | 1566 | if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
1560 | 1567 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
1561 | - }else{ |
|
1568 | + } else{ |
|
1562 | 1569 | $existing = null; |
1563 | 1570 | } |
1564 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1571 | + } elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1565 | 1572 | //no primary key on this model, but there's still a matching item in the DB |
1566 | 1573 | $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
1567 | - }else{ |
|
1574 | + } else{ |
|
1568 | 1575 | $existing = null; |
1569 | 1576 | } |
1570 | 1577 | if ( $existing ) { |
@@ -1622,7 +1629,7 @@ discard block |
||
1622 | 1629 | private static function _get_model_classname( $model_name = null){ |
1623 | 1630 | if(strpos($model_name,"EE_")===0){ |
1624 | 1631 | $model_classname=str_replace("EE_","EEM_",$model_name); |
1625 | - }else{ |
|
1632 | + } else{ |
|
1626 | 1633 | $model_classname = "EEM_".$model_name; |
1627 | 1634 | } |
1628 | 1635 | return $model_classname; |
@@ -1656,7 +1663,7 @@ discard block |
||
1656 | 1663 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1657 | 1664 | if( $this->get_model()->has_primary_key_field() ) { |
1658 | 1665 | return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
1659 | - }else{ |
|
1666 | + } else{ |
|
1660 | 1667 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
1661 | 1668 | } |
1662 | 1669 | } |
@@ -1784,7 +1791,7 @@ discard block |
||
1784 | 1791 | //if there are query parameters, forget about caching the related model objects. |
1785 | 1792 | if( $query_params ){ |
1786 | 1793 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1787 | - }else{ |
|
1794 | + } else{ |
|
1788 | 1795 | //did we already cache the result of this query? |
1789 | 1796 | $cached_results = $this->get_all_from_cache($relationName); |
1790 | 1797 | if ( ! $cached_results ){ |
@@ -1794,11 +1801,11 @@ discard block |
||
1794 | 1801 | foreach($related_model_objects as $related_model_object){ |
1795 | 1802 | $this->cache($relationName, $related_model_object); |
1796 | 1803 | } |
1797 | - }else{ |
|
1804 | + } else{ |
|
1798 | 1805 | $related_model_objects = $cached_results; |
1799 | 1806 | } |
1800 | 1807 | } |
1801 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1808 | + } else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1802 | 1809 | $related_model_objects = $this->get_all_from_cache($relationName); |
1803 | 1810 | } |
1804 | 1811 | return $related_model_objects; |
@@ -1850,22 +1857,22 @@ discard block |
||
1850 | 1857 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
1851 | 1858 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
1852 | 1859 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1853 | - }else{ |
|
1860 | + } else{ |
|
1854 | 1861 | //first, check if we've already cached the result of this query |
1855 | 1862 | $cached_result = $this->get_one_from_cache($relationName); |
1856 | 1863 | if ( ! $cached_result ){ |
1857 | 1864 | |
1858 | 1865 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1859 | 1866 | $this->cache($relationName,$related_model_object); |
1860 | - }else{ |
|
1867 | + } else{ |
|
1861 | 1868 | $related_model_object = $cached_result; |
1862 | 1869 | } |
1863 | 1870 | } |
1864 | - }else{ |
|
1871 | + } else{ |
|
1865 | 1872 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
1866 | 1873 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
1867 | 1874 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1868 | - }else{ |
|
1875 | + } else{ |
|
1869 | 1876 | $related_model_object = null; |
1870 | 1877 | } |
1871 | 1878 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
@@ -1891,7 +1898,7 @@ discard block |
||
1891 | 1898 | public function delete_related($relationName,$query_params = array()){ |
1892 | 1899 | if($this->ID()){ |
1893 | 1900 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
1894 | - }else{ |
|
1901 | + } else{ |
|
1895 | 1902 | $count = count($this->get_all_from_cache($relationName)); |
1896 | 1903 | $this->clear_cache($relationName,NULL,TRUE); |
1897 | 1904 | } |
@@ -1911,7 +1918,7 @@ discard block |
||
1911 | 1918 | public function delete_related_permanently($relationName,$query_params = array()){ |
1912 | 1919 | if($this->ID()){ |
1913 | 1920 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
1914 | - }else{ |
|
1921 | + } else{ |
|
1915 | 1922 | $count = count($this->get_all_from_cache($relationName)); |
1916 | 1923 | } |
1917 | 1924 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -1946,8 +1953,9 @@ discard block |
||
1946 | 1953 | |
1947 | 1954 | foreach ( (array) $properties as $property_name ) { |
1948 | 1955 | //first make sure this property exists |
1949 | - if ( ! $this->_fields[ $property_name ] ) |
|
1950 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1956 | + if ( ! $this->_fields[ $property_name ] ) { |
|
1957 | + throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1958 | + } |
|
1951 | 1959 | } |
1952 | 1960 | |
1953 | 1961 | return TRUE; |
@@ -2027,7 +2035,7 @@ discard block |
||
2027 | 2035 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
2028 | 2036 | if( ! $existing_rows_like_that){ |
2029 | 2037 | return $this->add_extra_meta($meta_key, $meta_value); |
2030 | - }else{ |
|
2038 | + } else{ |
|
2031 | 2039 | foreach( $existing_rows_like_that as $existing_row){ |
2032 | 2040 | $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
2033 | 2041 | } |
@@ -2093,10 +2101,10 @@ discard block |
||
2093 | 2101 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2094 | 2102 | if ( $result instanceof EE_Extra_Meta ){ |
2095 | 2103 | return $result->value(); |
2096 | - }else{ |
|
2104 | + } else{ |
|
2097 | 2105 | return $default; |
2098 | 2106 | } |
2099 | - }else{ |
|
2107 | + } else{ |
|
2100 | 2108 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2101 | 2109 | if($results){ |
2102 | 2110 | $values = array(); |
@@ -2106,7 +2114,7 @@ discard block |
||
2106 | 2114 | } |
2107 | 2115 | } |
2108 | 2116 | return $values; |
2109 | - }else{ |
|
2117 | + } else{ |
|
2110 | 2118 | return $default; |
2111 | 2119 | } |
2112 | 2120 | } |
@@ -2132,7 +2140,7 @@ discard block |
||
2132 | 2140 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2133 | 2141 | } |
2134 | 2142 | } |
2135 | - }else{ |
|
2143 | + } else{ |
|
2136 | 2144 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2137 | 2145 | foreach($extra_meta_objs as $extra_meta_obj){ |
2138 | 2146 | if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
@@ -2154,7 +2162,7 @@ discard block |
||
2154 | 2162 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2155 | 2163 | if($field_we_can_use){ |
2156 | 2164 | return $this->get($field_we_can_use->get_name()); |
2157 | - }else{ |
|
2165 | + } else{ |
|
2158 | 2166 | $first_few_properties = $this->model_field_array(); |
2159 | 2167 | $first_few_properties = array_slice($first_few_properties,0,3); |
2160 | 2168 | $name_parts = array(); |
@@ -2174,7 +2182,7 @@ discard block |
||
2174 | 2182 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
2175 | 2183 | //well, if we looked, did we find it in the entity map? |
2176 | 2184 | return TRUE; |
2177 | - }else{ |
|
2185 | + } else{ |
|
2178 | 2186 | return FALSE; |
2179 | 2187 | } |
2180 | 2188 | } |
@@ -2188,7 +2196,7 @@ discard block |
||
2188 | 2196 | public function refresh_from_db(){ |
2189 | 2197 | if( $this->ID() && $this->in_entity_map() ){ |
2190 | 2198 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
2191 | - }else{ |
|
2199 | + } else{ |
|
2192 | 2200 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2193 | 2201 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2194 | 2202 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @access protected |
513 | 513 | * @param string $fieldname the property item the corresponding value is for. |
514 | 514 | * @param mixed $value The value we are caching. |
515 | - * @param null $cache_type |
|
515 | + * @param string $cache_type |
|
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | * |
826 | 826 | * @param null $field_to_order_by What field is being used as the reference point. |
827 | 827 | * @param array $query_params Any additional conditions on the query. |
828 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
828 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
829 | 829 | * you can indicate just the columns you want returned |
830 | 830 | * |
831 | 831 | * @return array|EE_Base_Class |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @param null $field_to_order_by What field is being used as the reference point. |
852 | 852 | * @param array $query_params Any additional conditions on the query. |
853 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
853 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
854 | 854 | * you can indicate just the column you want returned |
855 | 855 | * |
856 | 856 | * @return array|EE_Base_Class |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | /** |
914 | 914 | * This method simply returns the RAW unprocessed value for the given property in this class |
915 | 915 | * @param string $field_name A valid fieldname |
916 | - * @return mixed Whatever the raw value stored on the property is. |
|
916 | + * @return integer|null Whatever the raw value stored on the property is. |
|
917 | 917 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
918 | 918 | */ |
919 | 919 | public function get_raw($field_name) { |
@@ -987,11 +987,11 @@ discard block |
||
987 | 987 | * |
988 | 988 | * @access protected |
989 | 989 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
990 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
991 | - * @param null $tm_frmt Same as above except this is for time format |
|
990 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
991 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
992 | 992 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
993 | 993 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
994 | - * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
|
994 | + * @return string|boolean | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
|
995 | 995 | */ |
996 | 996 | protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
997 | 997 | |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | * sets the time on a datetime property |
1165 | 1165 | * |
1166 | 1166 | * @access protected |
1167 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1167 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1168 | 1168 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1169 | 1169 | */ |
1170 | 1170 | protected function _set_time_for( $time, $fieldname ) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | * sets the date on a datetime property |
1180 | 1180 | * |
1181 | 1181 | * @access protected |
1182 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1182 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1183 | 1183 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1184 | 1184 | */ |
1185 | 1185 | protected function _set_date_for( $date, $fieldname ) { |
@@ -1233,6 +1233,7 @@ discard block |
||
1233 | 1233 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1234 | 1234 | * @param string $prepend You can include something to prepend on the timestamp |
1235 | 1235 | * @param string $append You can include something to append on the timestamp |
1236 | + * @param string $args |
|
1236 | 1237 | * @throws EE_Error |
1237 | 1238 | * @return string timestamp |
1238 | 1239 | */ |
@@ -1300,7 +1301,7 @@ discard block |
||
1300 | 1301 | * functionality for "delete" (which is to call `permanently_delete`) should override this method NOT `EE_Base_Class::delete` |
1301 | 1302 | * @param boolean $allow_blocking whether to allow prevention of deletion of this model object |
1302 | 1303 | * based on the existence of related model objects |
1303 | - * @return bool|int |
|
1304 | + * @return boolean |
|
1304 | 1305 | */ |
1305 | 1306 | protected function _delete( $allow_blocking = true ) { |
1306 | 1307 | $result = $this->delete_permanently( $allow_blocking ); |
@@ -1543,7 +1544,7 @@ discard block |
||
1543 | 1544 | |
1544 | 1545 | /** |
1545 | 1546 | * for getting a model while instantiated. |
1546 | - * @return \EEM_Base | \EEM_CPT_Base |
|
1547 | + * @return boolean | \EEM_CPT_Base |
|
1547 | 1548 | */ |
1548 | 1549 | public function get_model() { |
1549 | 1550 | $modelName = self::_get_model_classname( get_class($this) ); |
@@ -1574,7 +1575,7 @@ discard block |
||
1574 | 1575 | * If there is a key in the incoming array that matches the primary key for the model AND it is not null, then we check the db. If there's a an object we return it. If not we return false. |
1575 | 1576 | * @param array $props_n_values incoming array of properties and their values |
1576 | 1577 | * @param string $classname the classname of the child class |
1577 | - * @param null $timezone |
|
1578 | + * @param string|null $timezone |
|
1578 | 1579 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1579 | 1580 | * date_format and the second value is the time format |
1580 | 1581 | * @return mixed (EE_Base_Class|bool) |
@@ -1623,7 +1624,7 @@ discard block |
||
1623 | 1624 | * @param $classname |
1624 | 1625 | * @param null $timezone |
1625 | 1626 | * @throws EE_Error |
1626 | - * @return EEM_Base |
|
1627 | + * @return boolean |
|
1627 | 1628 | */ |
1628 | 1629 | protected static function _get_model( $classname, $timezone = NULL ){ |
1629 | 1630 | //find model for this class |
@@ -1639,8 +1640,8 @@ discard block |
||
1639 | 1640 | /** |
1640 | 1641 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1641 | 1642 | * @param string $model_classname |
1642 | - * @param null $timezone |
|
1643 | - * @return EEM_Base |
|
1643 | + * @param string|null $timezone |
|
1644 | + * @return boolean |
|
1644 | 1645 | */ |
1645 | 1646 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
1646 | 1647 | $model_classname = str_replace( 'EEM_', '', $model_classname ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | 26 | |
27 | -abstract class EE_Base_Class{ |
|
27 | +abstract class EE_Base_Class { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | * @throws EE_Error |
118 | 118 | * @return \EE_Base_Class |
119 | 119 | */ |
120 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
120 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
121 | 121 | |
122 | - $className=get_class($this); |
|
122 | + $className = get_class($this); |
|
123 | 123 | |
124 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
125 | - $model=$this->get_model(); |
|
126 | - $model_fields = $model->field_settings( FALSE ); |
|
124 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
125 | + $model = $this->get_model(); |
|
126 | + $model_fields = $model->field_settings(FALSE); |
|
127 | 127 | // ensure $fieldValues is an array |
128 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
128 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
129 | 129 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | 130 | // verify client code has not passed any invalid field names |
131 | - foreach($fieldValues as $field_name=> $field_value){ |
|
132 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
133 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
131 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
132 | + if ( ! isset($model_fields[$field_name])) { |
|
133 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
137 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
138 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
137 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
138 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
139 | 139 | |
140 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
140 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
141 | 141 | $this->_dt_frmt = $date_formats[0]; |
142 | 142 | $this->_tm_frmt = $date_formats[1]; |
143 | 143 | } else { |
144 | 144 | //set default formats for date and time |
145 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
146 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
145 | + $this->_dt_frmt = get_option('date_format'); |
|
146 | + $this->_tm_frmt = get_option('time_format'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | //if db model is instantiating |
150 | - if ( $bydb ){ |
|
150 | + if ($bydb) { |
|
151 | 151 | //client code has indicated these field values are from the database |
152 | - foreach( $model_fields as $fieldName => $field ){ |
|
153 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
152 | + foreach ($model_fields as $fieldName => $field) { |
|
153 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
154 | 154 | } |
155 | 155 | } else { |
156 | 156 | //we're constructing a brand |
157 | 157 | //new instance of the model object. Generally, this means we'll need to do more field validation |
158 | - foreach( $model_fields as $fieldName => $field ){ |
|
159 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
158 | + foreach ($model_fields as $fieldName => $field) { |
|
159 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | //remember what values were passed to this constructor |
164 | 164 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
165 | 165 | //remember in entity mapper |
166 | - if($model->has_primary_key_field() && $this->ID() && ! $bydb ){ |
|
166 | + if ($model->has_primary_key_field() && $this->ID() && ! $bydb) { |
|
167 | 167 | $model->add_to_entity_map($this); |
168 | 168 | } |
169 | 169 | //setup all the relations |
170 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
171 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
170 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
171 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
172 | 172 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
173 | + } else { |
|
174 | 174 | $this->_model_relations[$relation_name] = array(); |
175 | 175 | } |
176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * Action done at the end of each model object construction |
179 | 179 | * @param EE_Base_Class $this the model object just created |
180 | 180 | */ |
181 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
181 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param boolean $allow_persist |
199 | 199 | * @return boolean |
200 | 200 | */ |
201 | - function set_allow_persist( $allow_persist ) { |
|
201 | + function set_allow_persist($allow_persist) { |
|
202 | 202 | return $this->_allow_persist = $allow_persist; |
203 | 203 | } |
204 | 204 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @param string $field_name |
212 | 212 | * @return mixed|null |
213 | 213 | */ |
214 | - public function get_original( $field_name ){ |
|
215 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
216 | - $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
|
217 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
218 | - }else{ |
|
214 | + public function get_original($field_name) { |
|
215 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
216 | + $field_settings = $this->get_Model()->field_settings_for($field_name)) { |
|
217 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
218 | + } else { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param EE_Base_Class $obj |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function get_class($obj){ |
|
228 | + public function get_class($obj) { |
|
229 | 229 | return get_class($obj); |
230 | 230 | } |
231 | 231 | |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * @param mixed $field_value |
239 | 239 | * @param bool $use_default |
240 | 240 | */ |
241 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
242 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
243 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
241 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
242 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
243 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
244 | 244 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
245 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
246 | - $field_obj->set_timezone( $this->_timezone ); |
|
247 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
248 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
245 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
246 | + $field_obj->set_timezone($this->_timezone); |
|
247 | + $field_obj->set_date_format($this->_dt_frmt); |
|
248 | + $field_obj->set_time_format($this->_tm_frmt); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
252 | 252 | //should the value be null? |
253 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
253 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
254 | 254 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
255 | 255 | |
256 | 256 | /** |
@@ -260,19 +260,19 @@ discard block |
||
260 | 260 | * object. |
261 | 261 | * @since 4.6.10+ |
262 | 262 | */ |
263 | - if ( $field_obj instanceof EE_Datetime_Field && ! is_null( $this->_fields[$field_name] ) && ! $this->_fields[$field_name] instanceof DateTime ) { |
|
264 | - empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] ); |
|
263 | + if ($field_obj instanceof EE_Datetime_Field && ! is_null($this->_fields[$field_name]) && ! $this->_fields[$field_name] instanceof DateTime) { |
|
264 | + empty($this->_fields[$field_name]) ? $this->set($field_name, time()) : $this->set($field_name, $this->_fields[$field_name]); |
|
265 | 265 | } |
266 | 266 | |
267 | - }else{ |
|
267 | + } else { |
|
268 | 268 | $this->_fields[$field_name] = $holder_of_value; |
269 | 269 | } |
270 | 270 | |
271 | 271 | //if we're not in the constructor... |
272 | 272 | //now check if what we set was a primary key |
273 | - if($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
273 | + if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
274 | 274 | $field_name == $this->_get_primary_key_name(get_class($this)) && |
275 | - $field_value){ |
|
275 | + $field_value) { |
|
276 | 276 | //if so, we want all this object's fields to be filled either with |
277 | 277 | //what we've explicitly set on this model |
278 | 278 | //or what we have in the db |
@@ -280,20 +280,20 @@ discard block |
||
280 | 280 | $fields_on_model = $this->_get_model(get_class($this))->field_settings(); |
281 | 281 | |
282 | 282 | $obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value); |
283 | - foreach($fields_on_model as $field_obj){ |
|
284 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
285 | - && $field_obj->get_name() != $field_name ){ |
|
283 | + foreach ($fields_on_model as $field_obj) { |
|
284 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
285 | + && $field_obj->get_name() != $field_name) { |
|
286 | 286 | |
287 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
287 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | //oh this model object has an ID? well make sure its in the entity mapper |
291 | 291 | $this->get_model()->add_to_entity_map($this); |
292 | 292 | } |
293 | 293 | //let's unset any cache for this field_name from the $_cached_properties property. |
294 | - $this->_clear_cached_property( $field_name ); |
|
295 | - }else{ |
|
296 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
294 | + $this->_clear_cached_property($field_name); |
|
295 | + } else { |
|
296 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
@@ -312,14 +312,14 @@ discard block |
||
312 | 312 | * @param mixed $field_value The value to set. |
313 | 313 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
314 | 314 | */ |
315 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
316 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
317 | - $this->set( $field_name, $field_value ); |
|
315 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
316 | + if ($this->get_model()->has_field($field_name)) { |
|
317 | + $this->set($field_name, $field_value); |
|
318 | 318 | return true; |
319 | 319 | } else { |
320 | 320 | //ensure this object is saved first so that extra meta can be properly related. |
321 | 321 | $this->save(); |
322 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
322 | + return $this->update_extra_meta($field_name, $field_value); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | * @param string $field_name expecting the fully qualified field name. |
344 | 344 | * @return mixed|null value for the field if found. null if not found. |
345 | 345 | */ |
346 | - public function get_field_or_extra_meta( $field_name ) { |
|
347 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
348 | - $column_value = $this->get( $field_name ); |
|
346 | + public function get_field_or_extra_meta($field_name) { |
|
347 | + if ($this->get_model()->has_field($field_name)) { |
|
348 | + $column_value = $this->get($field_name); |
|
349 | 349 | } else { |
350 | 350 | //This isn't a column in the main table, let's see if it is in the extra meta. |
351 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
351 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
352 | 352 | } |
353 | 353 | return $column_value; |
354 | 354 | } |
@@ -367,19 +367,19 @@ discard block |
||
367 | 367 | * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
368 | 368 | * @return void |
369 | 369 | */ |
370 | - public function set_timezone( $timezone = '' ) { |
|
370 | + public function set_timezone($timezone = '') { |
|
371 | 371 | EE_Registry::instance()->load_helper('DTT_Helper'); |
372 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
372 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
373 | 373 | //make sure we clear all cached properties because they won't be relevant now |
374 | 374 | $this->_clear_cached_properties(); |
375 | 375 | |
376 | 376 | //make sure we update field settings and the date for all EE_Datetime_Fields |
377 | - $model_fields = $this->get_model()->field_settings( false ); |
|
378 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
379 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
380 | - $field_obj->set_timezone( $this->_timezone ); |
|
381 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
382 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
377 | + $model_fields = $this->get_model()->field_settings(false); |
|
378 | + foreach ($model_fields as $field_name => $field_obj) { |
|
379 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
380 | + $field_obj->set_timezone($this->_timezone); |
|
381 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
382 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param string $format should be a format recognizable by PHP date() functions. |
410 | 410 | */ |
411 | - public function set_date_format( $format ) { |
|
411 | + public function set_date_format($format) { |
|
412 | 412 | $this->_dt_frmt = $format; |
413 | 413 | //clear cached_properties because they won't be relevant now. |
414 | 414 | $this->_clear_cached_properties(); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @since 4.6 |
425 | 425 | * @param string $format should be a format recognizable by PHP date() functions. |
426 | 426 | */ |
427 | - public function set_time_format( $format ) { |
|
427 | + public function set_time_format($format) { |
|
428 | 428 | $this->_tm_frmt = $format; |
429 | 429 | //clear cached_properties because they won't be relevant now. |
430 | 430 | $this->_clear_cached_properties(); |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed string|array |
443 | 443 | */ |
444 | - public function get_format( $full = true ) { |
|
445 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
444 | + public function get_format($full = true) { |
|
445 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * @throws EE_Error |
461 | 461 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
462 | 462 | */ |
463 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
463 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
464 | 464 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
465 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
465 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
466 | 466 | return FALSE; |
467 | 467 | } |
468 | 468 | // also get "how" the object is related, or throw an error |
469 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
470 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
469 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
470 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
471 | 471 | } |
472 | 472 | // how many things are related ? |
473 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
473 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
474 | 474 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
475 | 475 | // so for these model objects just set it to be cached |
476 | 476 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -478,26 +478,26 @@ discard block |
||
478 | 478 | } else { |
479 | 479 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
480 | 480 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
481 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
481 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
482 | 482 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
483 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
483 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
484 | 484 | } |
485 | 485 | // first check for a cache_id which is normally empty |
486 | - if ( ! empty( $cache_id )) { |
|
486 | + if ( ! empty($cache_id)) { |
|
487 | 487 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
488 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
488 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
489 | 489 | $return = $cache_id; |
490 | - } elseif ( $object_to_cache->ID() ) { |
|
490 | + } elseif ($object_to_cache->ID()) { |
|
491 | 491 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
492 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
492 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
493 | 493 | $return = $object_to_cache->ID(); |
494 | 494 | } else { |
495 | 495 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
496 | 496 | $this->_model_relations[$relationName][] = $object_to_cache; |
497 | 497 | // move the internal pointer to the end of the array |
498 | - end( $this->_model_relations[$relationName] ); |
|
498 | + end($this->_model_relations[$relationName]); |
|
499 | 499 | // and grab the key so that we can return it |
500 | - $return = key( $this->_model_relations[$relationName] ); |
|
500 | + $return = key($this->_model_relations[$relationName]); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | } |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | * @param null $cache_type |
516 | 516 | * @return void |
517 | 517 | */ |
518 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
518 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
519 | 519 | //first make sure this property exists |
520 | 520 | $this->get_model()->field_settings_for($fieldname); |
521 | 521 | |
522 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
522 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
523 | 523 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
524 | 524 | } |
525 | 525 | |
@@ -534,34 +534,34 @@ discard block |
||
534 | 534 | * It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used |
535 | 535 | * @return mixed whatever the value for the property is we're retrieving |
536 | 536 | */ |
537 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
537 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
538 | 538 | //verify the field exists |
539 | 539 | $this->get_model()->field_settings_for($fieldname); |
540 | 540 | |
541 | 541 | $cache_type = $pretty ? 'pretty' : 'standard'; |
542 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
542 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
543 | 543 | |
544 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
544 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
545 | 545 | return $this->_cached_properties[$fieldname][$cache_type]; |
546 | 546 | } |
547 | 547 | |
548 | 548 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
549 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
549 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
550 | 550 | /** |
551 | 551 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
552 | 552 | * formats are correct. |
553 | 553 | */ |
554 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
555 | - $field_obj->set_timezone( $this->_timezone ); |
|
556 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
557 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
554 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
555 | + $field_obj->set_timezone($this->_timezone); |
|
556 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
557 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
558 | 558 | } |
559 | 559 | |
560 | - if( ! isset($this->_fields[$fieldname])){ |
|
560 | + if ( ! isset($this->_fields[$fieldname])) { |
|
561 | 561 | $this->_fields[$fieldname] = NULL; |
562 | 562 | } |
563 | - $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
564 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
563 | + $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
564 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
565 | 565 | return $value; |
566 | 566 | } |
567 | 567 | return FALSE; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
588 | 588 | * @return void |
589 | 589 | */ |
590 | - protected function _clear_cached_property( $property_name ) { |
|
591 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
592 | - unset( $this->_cached_properties[ $property_name ] ); |
|
590 | + protected function _clear_cached_property($property_name) { |
|
591 | + if (isset($this->_cached_properties[$property_name])) |
|
592 | + unset($this->_cached_properties[$property_name]); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @param string $model_name name of the related thing, eg 'Attendee', |
601 | 601 | * @return EE_Base_Class |
602 | 602 | */ |
603 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
603 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
604 | 604 | $other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone); |
605 | 605 | $model_obj = $other_model_instance->ensure_is_obj($object_or_id); |
606 | 606 | return $model_obj; |
@@ -620,55 +620,55 @@ discard block |
||
620 | 620 | * @throws EE_Error |
621 | 621 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
622 | 622 | */ |
623 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
623 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
624 | 624 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
625 | 625 | $index_in_cache = ''; |
626 | - if( ! $relationship_to_model){ |
|
627 | - throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this))); |
|
626 | + if ( ! $relationship_to_model) { |
|
627 | + throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this))); |
|
628 | 628 | } |
629 | - if($clear_all){ |
|
629 | + if ($clear_all) { |
|
630 | 630 | $obj_removed = true; |
631 | 631 | $this->_model_relations[$relationName] = null; |
632 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
632 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
633 | 633 | $obj_removed = $this->_model_relations[$relationName]; |
634 | 634 | $this->_model_relations[$relationName] = null; |
635 | - }else{ |
|
636 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
635 | + } else { |
|
636 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
637 | 637 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
638 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
638 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
639 | 639 | $index_found_at = NULL; |
640 | 640 | //find this object in the array even though it has a different key |
641 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
642 | - if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) { |
|
641 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
642 | + if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) { |
|
643 | 643 | $index_found_at = $index; |
644 | 644 | break; |
645 | 645 | } |
646 | 646 | } |
647 | - if($index_found_at){ |
|
647 | + if ($index_found_at) { |
|
648 | 648 | $index_in_cache = $index_found_at; |
649 | - }else{ |
|
649 | + } else { |
|
650 | 650 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
651 | 651 | //if it wasn't in it to begin with. So we're done |
652 | 652 | return $object_to_remove_or_index_into_array; |
653 | 653 | } |
654 | 654 | } |
655 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
655 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
656 | 656 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
657 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
658 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
657 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
658 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
659 | 659 | $index_in_cache = $index; |
660 | 660 | } |
661 | 661 | } |
662 | - }else{ |
|
662 | + } else { |
|
663 | 663 | $index_in_cache = $object_to_remove_or_index_into_array; |
664 | 664 | } |
665 | 665 | //supposedly we've found it. But it could just be that the client code |
666 | 666 | //provided a bad index/object |
667 | - if(isset( $this->_model_relations[$relationName]) && |
|
668 | - isset( $this->_model_relations[$relationName][$index_in_cache])){ |
|
667 | + if (isset($this->_model_relations[$relationName]) && |
|
668 | + isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
669 | 669 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
670 | 670 | unset($this->_model_relations[$relationName][$index_in_cache]); |
671 | - }else{ |
|
671 | + } else { |
|
672 | 672 | //that thing was never cached anyways. |
673 | 673 | $obj_removed = NULL; |
674 | 674 | } |
@@ -687,24 +687,24 @@ discard block |
||
687 | 687 | * @param string $current_cache_id - the ID that was used when originally caching the object |
688 | 688 | * @return boolean TRUE on success, FALSE on fail |
689 | 689 | */ |
690 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
690 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
691 | 691 | // verify that incoming object is of the correct type |
692 | - $obj_class = 'EE_' . $relationName; |
|
693 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
692 | + $obj_class = 'EE_'.$relationName; |
|
693 | + if ($newly_saved_object instanceof $obj_class) { |
|
694 | 694 | /* @type EE_Base_Class $newly_saved_object*/ |
695 | 695 | // now get the type of relation |
696 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
696 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
697 | 697 | // if this is a 1:1 relationship |
698 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
698 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
699 | 699 | // then just replace the cached object with the newly saved object |
700 | 700 | $this->_model_relations[$relationName] = $newly_saved_object; |
701 | 701 | return TRUE; |
702 | 702 | // or if it's some kind of sordid feral polyamorous relationship... |
703 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
703 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
704 | 704 | // then remove the current cached item |
705 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
705 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
706 | 706 | // and cache the newly saved object using it's new ID |
707 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
707 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
708 | 708 | return TRUE; |
709 | 709 | } |
710 | 710 | } |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | * @param string $relationName |
721 | 721 | * @return EE_Base_Class |
722 | 722 | */ |
723 | - public function get_one_from_cache($relationName){ |
|
724 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
725 | - if(is_array($cached_array_or_object)){ |
|
723 | + public function get_one_from_cache($relationName) { |
|
724 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
725 | + if (is_array($cached_array_or_object)) { |
|
726 | 726 | return array_shift($cached_array_or_object); |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | return $cached_array_or_object; |
729 | 729 | } |
730 | 730 | } |
@@ -739,14 +739,14 @@ discard block |
||
739 | 739 | * @throws \EE_Error |
740 | 740 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
741 | 741 | */ |
742 | - public function get_all_from_cache($relationName){ |
|
743 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
744 | - if(is_array($cached_array_or_object)){ |
|
742 | + public function get_all_from_cache($relationName) { |
|
743 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
744 | + if (is_array($cached_array_or_object)) { |
|
745 | 745 | $objects = $cached_array_or_object; |
746 | - }elseif($cached_array_or_object){ |
|
746 | + }elseif ($cached_array_or_object) { |
|
747 | 747 | //if the result is not an array, but exists, make it an array |
748 | 748 | $objects = array($cached_array_or_object); |
749 | - }else{ |
|
749 | + } else { |
|
750 | 750 | //if nothing was found, return an empty array |
751 | 751 | $objects = array(); |
752 | 752 | } |
@@ -754,15 +754,15 @@ discard block |
||
754 | 754 | //basically, if this model object was stored in the session, and these cached model objects |
755 | 755 | //already have IDs, let's make sure they're in their model's entity mapper |
756 | 756 | //otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
757 | - foreach( $objects as $model_object ){ |
|
758 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
759 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
757 | + foreach ($objects as $model_object) { |
|
758 | + $model = EE_Registry::instance()->load_model($relationName); |
|
759 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
760 | 760 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
761 | - if( $model_object->ID() ){ |
|
762 | - $model->add_to_entity_map( $model_object ); |
|
761 | + if ($model_object->ID()) { |
|
762 | + $model->add_to_entity_map($model_object); |
|
763 | 763 | } |
764 | - }else{ |
|
765 | - throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
|
764 | + } else { |
|
765 | + throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object))); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | return $objects; |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return array|EE_Base_Class[] |
783 | 783 | */ |
784 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
785 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
786 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
787 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
784 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
785 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
786 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
787 | + if (empty($field) || empty($current_value)) { |
|
788 | 788 | return array(); |
789 | 789 | } |
790 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
790 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return array|EE_Base_Class[] |
808 | 808 | */ |
809 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
810 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
811 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
812 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
809 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
810 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
811 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
812 | + if (empty($field) || empty($current_value)) { |
|
813 | 813 | return array(); |
814 | 814 | } |
815 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
815 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | |
@@ -830,13 +830,13 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @return array|EE_Base_Class |
832 | 832 | */ |
833 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
834 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
835 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
836 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
833 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
834 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
835 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
836 | + if (empty($field) || empty($current_value)) { |
|
837 | 837 | return array(); |
838 | 838 | } |
839 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
839 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | * |
856 | 856 | * @return array|EE_Base_Class |
857 | 857 | */ |
858 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
859 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
860 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
861 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
858 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
859 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
860 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
861 | + if (empty($field) || empty($current_value)) { |
|
862 | 862 | return array(); |
863 | 863 | } |
864 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
864 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -875,25 +875,25 @@ discard block |
||
875 | 875 | * @param string $field_name |
876 | 876 | * @param mixed $field_value_from_db |
877 | 877 | */ |
878 | - public function set_from_db($field_name,$field_value_from_db){ |
|
878 | + public function set_from_db($field_name, $field_value_from_db) { |
|
879 | 879 | $field_obj = $this->get_model()->field_settings_for($field_name); |
880 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
880 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
881 | 881 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
882 | 882 | //eg, a CPT model object could have an entry in the posts table, but no |
883 | 883 | //entry in the meta table. Meaning that all its columns in the meta table |
884 | 884 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
885 | - if($field_value_from_db === NULL ){ |
|
886 | - if( $field_obj->is_nullable()){ |
|
885 | + if ($field_value_from_db === NULL) { |
|
886 | + if ($field_obj->is_nullable()) { |
|
887 | 887 | //if the field allows nulls, then let it be null |
888 | 888 | $field_value = NULL; |
889 | - }else{ |
|
889 | + } else { |
|
890 | 890 | $field_value = $field_obj->get_default_value(); |
891 | 891 | } |
892 | - }else{ |
|
893 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
892 | + } else { |
|
893 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
894 | 894 | } |
895 | 895 | $this->_fields[$field_name] = $field_value; |
896 | - $this->_clear_cached_property( $field_name ); |
|
896 | + $this->_clear_cached_property($field_name); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
906 | 906 | * @return boolean |
907 | 907 | */ |
908 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
909 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
908 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
909 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | |
@@ -936,11 +936,11 @@ discard block |
||
936 | 936 | * just null is returned (because that indicates that likely |
937 | 937 | * this field is nullable). |
938 | 938 | */ |
939 | - public function get_DateTime_object( $field_name ) { |
|
940 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
939 | + public function get_DateTime_object($field_name) { |
|
940 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
941 | 941 | |
942 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
943 | - EE_Error::add_error( sprintf( __('The field %s is not an EE_Datetime_Field field. There is no DateTime object stored on this field type.', 'event_espresso' ), $field_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
942 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
943 | + EE_Error::add_error(sprintf(__('The field %s is not an EE_Datetime_Field field. There is no DateTime object stored on this field type.', 'event_espresso'), $field_name), __FILE__, __FUNCTION__, __LINE__); |
|
944 | 944 | return false; |
945 | 945 | } |
946 | 946 | |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
957 | 957 | * @return void |
958 | 958 | */ |
959 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
959 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
960 | 960 | echo $this->get_pretty($field_name, $extra_cache_ref); |
961 | 961 | } |
962 | 962 | /** |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * @param string $field_name |
966 | 966 | * @return void |
967 | 967 | */ |
968 | - public function f($field_name){ |
|
969 | - $this->e($field_name,'form_input'); |
|
968 | + public function f($field_name) { |
|
969 | + $this->e($field_name, 'form_input'); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | /** |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
976 | 976 | * @return mixed |
977 | 977 | */ |
978 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
979 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
978 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
979 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | |
@@ -993,37 +993,37 @@ discard block |
||
993 | 993 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
994 | 994 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
995 | 995 | */ |
996 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
996 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
997 | 997 | |
998 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
998 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
999 | 999 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1000 | 1000 | |
1001 | 1001 | //validate field for datetime and returns field settings if valid. |
1002 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1002 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1003 | 1003 | |
1004 | 1004 | //clear cached property if either formats are not null. |
1005 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1006 | - $this->_clear_cached_property( $field_name ); |
|
1005 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1006 | + $this->_clear_cached_property($field_name); |
|
1007 | 1007 | //reset format properties because they are used in get() |
1008 | 1008 | $this->_dt_frmt = $in_dt_frmt; |
1009 | 1009 | $this->_tm_frmt = $in_tm_frmt; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - if ( $echo ) |
|
1013 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1012 | + if ($echo) |
|
1013 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1014 | 1014 | else |
1015 | - $field->set_date_format( $in_dt_frmt ); |
|
1015 | + $field->set_date_format($in_dt_frmt); |
|
1016 | 1016 | |
1017 | - if ( $echo ) |
|
1018 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1017 | + if ($echo) |
|
1018 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1019 | 1019 | else |
1020 | - $field->set_time_format( $in_tm_frmt ); |
|
1020 | + $field->set_time_format($in_tm_frmt); |
|
1021 | 1021 | |
1022 | 1022 | //set timezone in field object |
1023 | - $field->set_timezone( $this->_timezone ); |
|
1023 | + $field->set_timezone($this->_timezone); |
|
1024 | 1024 | |
1025 | 1025 | //set the output returned |
1026 | - switch ( $date_or_time ) { |
|
1026 | + switch ($date_or_time) { |
|
1027 | 1027 | |
1028 | 1028 | case 'D' : |
1029 | 1029 | $field->set_date_time_output('date'); |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
1041 | - if ( $echo ) { |
|
1042 | - $this->e( $field_name, $date_or_time ); |
|
1041 | + if ($echo) { |
|
1042 | + $this->e($field_name, $date_or_time); |
|
1043 | 1043 | return ''; |
1044 | 1044 | } |
1045 | - return $this->get( $field_name, $date_or_time ); |
|
1045 | + return $this->get($field_name, $date_or_time); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | * @param string $format format for the date returned (if NULL we use default in dt_frmt property) |
1053 | 1053 | * @return string datetime value formatted |
1054 | 1054 | */ |
1055 | - public function get_date( $field_name, $format = NULL ) { |
|
1056 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1055 | + public function get_date($field_name, $format = NULL) { |
|
1056 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | |
@@ -1062,8 +1062,8 @@ discard block |
||
1062 | 1062 | * @param $field_name |
1063 | 1063 | * @param null $format |
1064 | 1064 | */ |
1065 | - public function e_date( $field_name, $format = NULL ) { |
|
1066 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1065 | + public function e_date($field_name, $format = NULL) { |
|
1066 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | * @param string $format format for the time returned ( if NULL we use default in tm_frmt property) |
1074 | 1074 | * @return string datetime value formatted |
1075 | 1075 | */ |
1076 | - public function get_time( $field_name, $format = NULL ) { |
|
1077 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1076 | + public function get_time($field_name, $format = NULL) { |
|
1077 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | |
@@ -1083,8 +1083,8 @@ discard block |
||
1083 | 1083 | * @param $field_name |
1084 | 1084 | * @param null $format |
1085 | 1085 | */ |
1086 | - public function e_time( $field_name, $format = NULL ) { |
|
1087 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1086 | + public function e_time($field_name, $format = NULL) { |
|
1087 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
@@ -1097,8 +1097,8 @@ discard block |
||
1097 | 1097 | * @param string $tm_frmt format for the time returned (if NULL we use default in tm_frmt property) |
1098 | 1098 | * @return string datetime value formatted |
1099 | 1099 | */ |
1100 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1101 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1100 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1101 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1108,8 +1108,8 @@ discard block |
||
1108 | 1108 | * @param null $dt_frmt |
1109 | 1109 | * @param null $tm_frmt |
1110 | 1110 | */ |
1111 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1112 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1111 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1112 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
@@ -1124,10 +1124,10 @@ discard block |
||
1124 | 1124 | * @return string Date and time string in set locale or false if no field exists for the given |
1125 | 1125 | * field name. |
1126 | 1126 | */ |
1127 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1128 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1129 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1130 | - return date_i18n( $format, EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) ); |
|
1127 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1128 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1129 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1130 | + return date_i18n($format, EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1139,14 +1139,14 @@ discard block |
||
1139 | 1139 | * @throws EE_Error |
1140 | 1140 | * @return EE_Datetime_Field |
1141 | 1141 | */ |
1142 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1142 | + protected function _get_dtt_field_settings($field_name) { |
|
1143 | 1143 | $field = $this->get_model()->field_settings_for($field_name); |
1144 | 1144 | |
1145 | 1145 | //check if field is dtt |
1146 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1146 | + if ($field instanceof EE_Datetime_Field) { |
|
1147 | 1147 | return $field; |
1148 | 1148 | } else { |
1149 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1149 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | |
@@ -1167,8 +1167,8 @@ discard block |
||
1167 | 1167 | * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
1168 | 1168 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1169 | 1169 | */ |
1170 | - protected function _set_time_for( $time, $fieldname ) { |
|
1171 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1170 | + protected function _set_time_for($time, $fieldname) { |
|
1171 | + $this->_set_date_time('T', $time, $fieldname); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
1183 | 1183 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1184 | 1184 | */ |
1185 | - protected function _set_date_for( $date, $fieldname ) { |
|
1186 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1185 | + protected function _set_date_for($date, $fieldname) { |
|
1186 | + $this->_set_date_time('D', $date, $fieldname); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1199,21 +1199,21 @@ discard block |
||
1199 | 1199 | * @param string|DateTime $datetime_value A valid Date or Time string (or DateTime object) |
1200 | 1200 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1201 | 1201 | */ |
1202 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1203 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1204 | - $field->set_timezone( $this->_timezone ); |
|
1205 | - $field->set_date_format( $this->_dt_frmt ); |
|
1206 | - $field->set_time_format( $this->_tm_frmt ); |
|
1202 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1203 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1204 | + $field->set_timezone($this->_timezone); |
|
1205 | + $field->set_date_format($this->_dt_frmt); |
|
1206 | + $field->set_time_format($this->_tm_frmt); |
|
1207 | 1207 | |
1208 | - switch ( $what ) { |
|
1208 | + switch ($what) { |
|
1209 | 1209 | case 'T' : |
1210 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] ); |
|
1210 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]); |
|
1211 | 1211 | break; |
1212 | 1212 | case 'D' : |
1213 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] ); |
|
1213 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]); |
|
1214 | 1214 | break; |
1215 | 1215 | case 'B' : |
1216 | - $this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value ); |
|
1216 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1217 | 1217 | break; |
1218 | 1218 | } |
1219 | 1219 | |
@@ -1236,25 +1236,25 @@ discard block |
||
1236 | 1236 | * @throws EE_Error |
1237 | 1237 | * @return string timestamp |
1238 | 1238 | */ |
1239 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1239 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1240 | 1240 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1241 | 1241 | $timezone = EEH_DTT_Helper::get_timezone(); |
1242 | 1242 | |
1243 | - if ( $timezone == $this->_timezone ) |
|
1243 | + if ($timezone == $this->_timezone) |
|
1244 | 1244 | return ''; |
1245 | 1245 | |
1246 | 1246 | $original_timezone = $this->_timezone; |
1247 | - $this->set_timezone( $timezone ); |
|
1247 | + $this->set_timezone($timezone); |
|
1248 | 1248 | |
1249 | 1249 | $fn = (array) $field_name; |
1250 | - $args = array_merge( $fn, (array) $args ); |
|
1250 | + $args = array_merge($fn, (array) $args); |
|
1251 | 1251 | |
1252 | - if ( !method_exists( $this, $callback ) ) |
|
1253 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1252 | + if ( ! method_exists($this, $callback)) |
|
1253 | + throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback)); |
|
1254 | 1254 | $args = (array) $args; |
1255 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1255 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1256 | 1256 | |
1257 | - $this->set_timezone( $original_timezone ); |
|
1257 | + $this->set_timezone($original_timezone); |
|
1258 | 1258 | return $return; |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | * |
1271 | 1271 | * @return boolean | int |
1272 | 1272 | */ |
1273 | - public function delete( $allow_blocking = true ){ |
|
1273 | + public function delete($allow_blocking = true) { |
|
1274 | 1274 | /** |
1275 | 1275 | * Called just before the `EE_Base_Class::_delete` method call. |
1276 | 1276 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1279,8 +1279,8 @@ discard block |
||
1279 | 1279 | * |
1280 | 1280 | * @param EE_Base_Class $model_object about to be 'deleted' |
1281 | 1281 | */ |
1282 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1283 | - $result = $this->_delete( $allow_blocking ); |
|
1282 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1283 | + $result = $this->_delete($allow_blocking); |
|
1284 | 1284 | /** |
1285 | 1285 | * Called just after the `EE_Base_Class::_delete` method call. |
1286 | 1286 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | * @param EE_Base_Class $model_object that was just 'deleted' |
1290 | 1290 | * @param boolean $result |
1291 | 1291 | */ |
1292 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1292 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1293 | 1293 | return $result; |
1294 | 1294 | } |
1295 | 1295 | |
@@ -1302,8 +1302,8 @@ discard block |
||
1302 | 1302 | * based on the existence of related model objects |
1303 | 1303 | * @return bool|int |
1304 | 1304 | */ |
1305 | - protected function _delete( $allow_blocking = true ) { |
|
1306 | - $result = $this->delete_permanently( $allow_blocking ); |
|
1305 | + protected function _delete($allow_blocking = true) { |
|
1306 | + $result = $this->delete_permanently($allow_blocking); |
|
1307 | 1307 | return $result; |
1308 | 1308 | } |
1309 | 1309 | |
@@ -1316,22 +1316,22 @@ discard block |
||
1316 | 1316 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
1317 | 1317 | * @return bool | int |
1318 | 1318 | */ |
1319 | - public function delete_permanently( $allow_blocking = true){ |
|
1319 | + public function delete_permanently($allow_blocking = true) { |
|
1320 | 1320 | /** |
1321 | 1321 | * Called just before HARD deleting a model object |
1322 | 1322 | * |
1323 | 1323 | * @param EE_Base_Class $model_object about to be 'deleted' |
1324 | 1324 | */ |
1325 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1326 | - $model=$this->get_model(); |
|
1327 | - $result=$model->delete_permanently_by_ID($this->ID(), $allow_blocking ); |
|
1325 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1326 | + $model = $this->get_model(); |
|
1327 | + $result = $model->delete_permanently_by_ID($this->ID(), $allow_blocking); |
|
1328 | 1328 | $this->refresh_cache_of_related_objects(); |
1329 | 1329 | /** |
1330 | 1330 | * Called just after HARD deleting a model object |
1331 | 1331 | * @param EE_Base_Class $model_object that was just 'deleted' |
1332 | 1332 | * @param boolean $result |
1333 | 1333 | */ |
1334 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1334 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1335 | 1335 | return $result; |
1336 | 1336 | } |
1337 | 1337 | |
@@ -1340,18 +1340,18 @@ discard block |
||
1340 | 1340 | * related model objects |
1341 | 1341 | */ |
1342 | 1342 | public function refresh_cache_of_related_objects() { |
1343 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1344 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1345 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1346 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1343 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1344 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1345 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1346 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1347 | 1347 | //this relation only stores a single model object, not an array |
1348 | 1348 | //but let's make it consistent |
1349 | - $related_objects = array( $related_objects ); |
|
1349 | + $related_objects = array($related_objects); |
|
1350 | 1350 | } |
1351 | - foreach( $related_objects as $related_object ) { |
|
1351 | + foreach ($related_objects as $related_object) { |
|
1352 | 1352 | //only refresh their cache if they're in memory |
1353 | - if( $related_object instanceof EE_Base_Class ) { |
|
1354 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1353 | + if ($related_object instanceof EE_Base_Class) { |
|
1354 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1355 | 1355 | } |
1356 | 1356 | } |
1357 | 1357 | } |
@@ -1371,17 +1371,17 @@ discard block |
||
1371 | 1371 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1372 | 1372 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1373 | 1373 | */ |
1374 | - public function save($set_cols_n_values=array()) { |
|
1374 | + public function save($set_cols_n_values = array()) { |
|
1375 | 1375 | /** |
1376 | 1376 | * Filters the fields we're about to save on the model object |
1377 | 1377 | * |
1378 | 1378 | * @param array $set_cols_n_values |
1379 | 1379 | * @param EE_Base_Class $model_object |
1380 | 1380 | */ |
1381 | - $set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1381 | + $set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1382 | 1382 | //set attributes as provided in $set_cols_n_values |
1383 | - foreach($set_cols_n_values as $column=>$value){ |
|
1384 | - $this->set($column,$value); |
|
1383 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1384 | + $this->set($column, $value); |
|
1385 | 1385 | } |
1386 | 1386 | /** |
1387 | 1387 | * Saving a model object. |
@@ -1389,8 +1389,8 @@ discard block |
||
1389 | 1389 | * Before we perform a save, this action is fired. |
1390 | 1390 | * @param EE_Base_Class $model_object the model object about to be saved. |
1391 | 1391 | */ |
1392 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1393 | - if( ! $this->allow_persist() ) { |
|
1392 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1393 | + if ( ! $this->allow_persist()) { |
|
1394 | 1394 | return 0; |
1395 | 1395 | } |
1396 | 1396 | //now get current attribute values |
@@ -1400,61 +1400,61 @@ discard block |
||
1400 | 1400 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1401 | 1401 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1402 | 1402 | //does this model have an autoincrement PK? |
1403 | - if($this->get_model()->has_primary_key_field()){ |
|
1404 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1403 | + if ($this->get_model()->has_primary_key_field()) { |
|
1404 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1405 | 1405 | //ok check if it's set, if so: update; if not, insert |
1406 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1407 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1406 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1407 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1408 | 1408 | } else { |
1409 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1410 | - $results = $this->get_model()->insert( $save_cols_n_values, true); |
|
1411 | - if($results){ |
|
1409 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1410 | + $results = $this->get_model()->insert($save_cols_n_values, true); |
|
1411 | + if ($results) { |
|
1412 | 1412 | //if successful, set the primary key |
1413 | 1413 | //but don't use the normal SET method, because it will check if |
1414 | 1414 | //an item with the same ID exists in the mapper & db, then |
1415 | 1415 | //will find it in the db (because we just added it) and THAT object |
1416 | 1416 | //will get added to the mapper before we can add this one! |
1417 | 1417 | //but if we just avoid using the SET method, all that headache can be avoided |
1418 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1418 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1419 | 1419 | $this->_fields[$pk_field_name] = $results; |
1420 | 1420 | $this->_clear_cached_property($pk_field_name); |
1421 | - $this->get_model()->add_to_entity_map( $this ); |
|
1421 | + $this->get_model()->add_to_entity_map($this); |
|
1422 | 1422 | $this->_update_cached_related_model_objs_fks(); |
1423 | 1423 | } |
1424 | 1424 | } |
1425 | - }else{//PK is NOT auto-increment |
|
1425 | + } else {//PK is NOT auto-increment |
|
1426 | 1426 | //so check if one like it already exists in the db |
1427 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1428 | - if( ! $this->in_entity_map() && WP_DEBUG ){ |
|
1427 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1428 | + if ( ! $this->in_entity_map() && WP_DEBUG) { |
|
1429 | 1429 | throw new EE_Error( |
1430 | 1430 | sprintf( |
1431 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1431 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1432 | 1432 | get_class($this), |
1433 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1434 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1433 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1434 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1435 | 1435 | '<br />' |
1436 | 1436 | ) |
1437 | 1437 | ); |
1438 | 1438 | } |
1439 | 1439 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1440 | - }else{ |
|
1440 | + } else { |
|
1441 | 1441 | $results = $this->get_model()->insert($save_cols_n_values); |
1442 | 1442 | $this->_update_cached_related_model_objs_fks(); |
1443 | 1443 | } |
1444 | 1444 | } |
1445 | - }else{//there is NO primary key |
|
1445 | + } else {//there is NO primary key |
|
1446 | 1446 | $already_in_db = false; |
1447 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1447 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1448 | 1448 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1449 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1449 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1450 | 1450 | $already_in_db = true; |
1451 | 1451 | } |
1452 | 1452 | } |
1453 | - if( $already_in_db ){ |
|
1454 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1455 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1456 | - }else{ |
|
1457 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1453 | + if ($already_in_db) { |
|
1454 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1455 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1456 | + } else { |
|
1457 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | //restore the old assumption about values being prepared by the model object |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1468 | 1468 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1469 | 1469 | */ |
1470 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1470 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1471 | 1471 | return $results; |
1472 | 1472 | } |
1473 | 1473 | |
@@ -1479,13 +1479,13 @@ discard block |
||
1479 | 1479 | * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated) |
1480 | 1480 | * @return void |
1481 | 1481 | */ |
1482 | - protected function _update_cached_related_model_objs_fks(){ |
|
1483 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1484 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1485 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1486 | - $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() ); |
|
1487 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1488 | - if( $related_model_obj_in_cache->ID() ){ |
|
1482 | + protected function _update_cached_related_model_objs_fks() { |
|
1483 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1484 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1485 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1486 | + $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name()); |
|
1487 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1488 | + if ($related_model_obj_in_cache->ID()) { |
|
1489 | 1489 | $related_model_obj_in_cache->save(); |
1490 | 1490 | } |
1491 | 1491 | } |
@@ -1501,21 +1501,21 @@ discard block |
||
1501 | 1501 | * and this object and properly setup |
1502 | 1502 | * @return int ID of new model object on save; 0 on failure+ |
1503 | 1503 | */ |
1504 | - public function save_new_cached_related_model_objs(){ |
|
1504 | + public function save_new_cached_related_model_objs() { |
|
1505 | 1505 | //make sure this has been saved |
1506 | - if( ! $this->ID()){ |
|
1506 | + if ( ! $this->ID()) { |
|
1507 | 1507 | $id = $this->save(); |
1508 | - }else{ |
|
1508 | + } else { |
|
1509 | 1509 | $id = $this->ID(); |
1510 | 1510 | } |
1511 | 1511 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1512 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1512 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1513 | 1513 | |
1514 | 1514 | |
1515 | - if($this->_model_relations[$relationName]){ |
|
1515 | + if ($this->_model_relations[$relationName]) { |
|
1516 | 1516 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1517 | 1517 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1518 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1518 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1519 | 1519 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1520 | 1520 | //but ONLY if it DOES NOT exist in the DB |
1521 | 1521 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1524,8 +1524,8 @@ discard block |
||
1524 | 1524 | $this->_add_relation_to($related_model_obj, $relationName); |
1525 | 1525 | $related_model_obj->save_new_cached_related_model_objs(); |
1526 | 1526 | // } |
1527 | - }else{ |
|
1528 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1527 | + } else { |
|
1528 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1529 | 1529 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1530 | 1530 | //but ONLY if it DOES NOT exist in the DB |
1531 | 1531 | // if( ! $related_model_obj->ID()){ |
@@ -1546,8 +1546,8 @@ discard block |
||
1546 | 1546 | * @return \EEM_Base | \EEM_CPT_Base |
1547 | 1547 | */ |
1548 | 1548 | public function get_model() { |
1549 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1550 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1549 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1550 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | |
@@ -1557,10 +1557,10 @@ discard block |
||
1557 | 1557 | * @param $classname |
1558 | 1558 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1559 | 1559 | */ |
1560 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1560 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1561 | 1561 | //TODO: will not work for Term_Relationships because they have no PK! |
1562 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1563 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1562 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1563 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1564 | 1564 | $id = $props_n_values[$primary_id_ref]; |
1565 | 1565 | return self::_get_model($classname)->get_from_entity_map($id); |
1566 | 1566 | } |
@@ -1579,35 +1579,35 @@ discard block |
||
1579 | 1579 | * date_format and the second value is the time format |
1580 | 1580 | * @return mixed (EE_Base_Class|bool) |
1581 | 1581 | */ |
1582 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1583 | - if( self::_get_model( $classname )->has_primary_key_field()){ |
|
1584 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1582 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1583 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1584 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1585 | 1585 | |
1586 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1587 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
|
1588 | - }else{ |
|
1586 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1587 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]); |
|
1588 | + } else { |
|
1589 | 1589 | $existing = null; |
1590 | 1590 | } |
1591 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1591 | + }elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1592 | 1592 | //no primary key on this model, but there's still a matching item in the DB |
1593 | - $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
|
1594 | - }else{ |
|
1593 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)); |
|
1594 | + } else { |
|
1595 | 1595 | $existing = null; |
1596 | 1596 | } |
1597 | - if ( $existing ) { |
|
1597 | + if ($existing) { |
|
1598 | 1598 | |
1599 | 1599 | //set date formats if present before setting values |
1600 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1601 | - $existing->set_date_format( $date_formats[0] ); |
|
1602 | - $existing->set_time_format( $date_formats[1] ); |
|
1600 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1601 | + $existing->set_date_format($date_formats[0]); |
|
1602 | + $existing->set_time_format($date_formats[1]); |
|
1603 | 1603 | } else { |
1604 | 1604 | //set default formats for date and time |
1605 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1606 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1605 | + $existing->set_date_format(get_option('date_format')); |
|
1606 | + $existing->set_time_format(get_option('time_format')); |
|
1607 | 1607 | } |
1608 | 1608 | |
1609 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1610 | - $existing->set( $property, $field_value ); |
|
1609 | + foreach ($props_n_values as $property => $field_value) { |
|
1610 | + $existing->set($property, $field_value); |
|
1611 | 1611 | } |
1612 | 1612 | return $existing; |
1613 | 1613 | } else { |
@@ -1625,13 +1625,13 @@ discard block |
||
1625 | 1625 | * @throws EE_Error |
1626 | 1626 | * @return EEM_Base |
1627 | 1627 | */ |
1628 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1628 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1629 | 1629 | //find model for this class |
1630 | - if( ! $classname ){ |
|
1631 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname)); |
|
1630 | + if ( ! $classname) { |
|
1631 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname)); |
|
1632 | 1632 | } |
1633 | - $modelName=self::_get_model_classname($classname); |
|
1634 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1633 | + $modelName = self::_get_model_classname($classname); |
|
1634 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | |
@@ -1642,10 +1642,10 @@ discard block |
||
1642 | 1642 | * @param null $timezone |
1643 | 1643 | * @return EEM_Base |
1644 | 1644 | */ |
1645 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1646 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1647 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1648 | - $model->set_timezone( $timezone ); |
|
1645 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1646 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1647 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1648 | + $model->set_timezone($timezone); |
|
1649 | 1649 | return $model; |
1650 | 1650 | } |
1651 | 1651 | |
@@ -1657,10 +1657,10 @@ discard block |
||
1657 | 1657 | * @param null $model_name |
1658 | 1658 | * @return string like EEM_Attendee |
1659 | 1659 | */ |
1660 | - private static function _get_model_classname( $model_name = null){ |
|
1661 | - if(strpos($model_name,"EE_")===0){ |
|
1662 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1663 | - }else{ |
|
1660 | + private static function _get_model_classname($model_name = null) { |
|
1661 | + if (strpos($model_name, "EE_") === 0) { |
|
1662 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1663 | + } else { |
|
1664 | 1664 | $model_classname = "EEM_".$model_name; |
1665 | 1665 | } |
1666 | 1666 | return $model_classname; |
@@ -1674,11 +1674,11 @@ discard block |
||
1674 | 1674 | * @throws EE_Error |
1675 | 1675 | * @return string |
1676 | 1676 | */ |
1677 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1678 | - if( ! $classname){ |
|
1679 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname)); |
|
1677 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1678 | + if ( ! $classname) { |
|
1679 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname)); |
|
1680 | 1680 | } |
1681 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1681 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | |
@@ -1690,12 +1690,12 @@ discard block |
||
1690 | 1690 | * Usually defaults for integer primary keys are 0; string primary keys are usually NULL). |
1691 | 1691 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1692 | 1692 | */ |
1693 | - public function ID(){ |
|
1693 | + public function ID() { |
|
1694 | 1694 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1695 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1696 | - return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
|
1697 | - }else{ |
|
1698 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1695 | + if ($this->get_model()->has_primary_key_field()) { |
|
1696 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1697 | + } else { |
|
1698 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1699 | 1699 | } |
1700 | 1700 | } |
1701 | 1701 | |
@@ -1713,38 +1713,38 @@ discard block |
||
1713 | 1713 | * @throws EE_Error |
1714 | 1714 | * @return EE_Base_Class the object the relation was added to |
1715 | 1715 | */ |
1716 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1716 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1717 | 1717 | //if this thing exists in the DB, save the relation to the DB |
1718 | - if( $this->ID() ){ |
|
1719 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1718 | + if ($this->ID()) { |
|
1719 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1720 | 1720 | //clear cache so future get_many_related and get_first_related() return new results. |
1721 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1722 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1723 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1721 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1722 | + if ($otherObject instanceof EE_Base_Class) { |
|
1723 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1724 | 1724 | } |
1725 | 1725 | } else { |
1726 | 1726 | //this thing doesn't exist in the DB, so just cache it |
1727 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1728 | - throw new EE_Error( sprintf( |
|
1729 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1727 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1728 | + throw new EE_Error(sprintf( |
|
1729 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1730 | 1730 | $otherObjectModelObjectOrID, |
1731 | - get_class( $this ) |
|
1731 | + get_class($this) |
|
1732 | 1732 | )); |
1733 | 1733 | } else { |
1734 | 1734 | $otherObject = $otherObjectModelObjectOrID; |
1735 | 1735 | } |
1736 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1736 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1737 | 1737 | } |
1738 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1738 | + if ($otherObject instanceof EE_Base_Class) { |
|
1739 | 1739 | //fix the reciprocal relation too |
1740 | - if( $otherObject->ID() ) { |
|
1740 | + if ($otherObject->ID()) { |
|
1741 | 1741 | //its saved so assumed relations exist in the DB, so we can just |
1742 | 1742 | //clear the cache so future queries use the updated info in the DB |
1743 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1743 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1744 | 1744 | } else { |
1745 | 1745 | |
1746 | 1746 | //it's not saved, so it caches relations like this |
1747 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1747 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | return $otherObject; |
@@ -1767,17 +1767,17 @@ discard block |
||
1767 | 1767 | * Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table. |
1768 | 1768 | * @return EE_Base_Class the relation was removed from |
1769 | 1769 | */ |
1770 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1771 | - if ( $this->ID() ) { |
|
1770 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1771 | + if ($this->ID()) { |
|
1772 | 1772 | //if this exists in the DB, save the relation change to the DB too |
1773 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1774 | - $this->clear_cache( $relationName, $otherObject ); |
|
1773 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1774 | + $this->clear_cache($relationName, $otherObject); |
|
1775 | 1775 | } else { |
1776 | 1776 | //this doesn't exist in the DB, just remove it from the cache |
1777 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1777 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1778 | 1778 | } |
1779 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1780 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1779 | + if ($otherObject instanceof EE_Base_Class) { |
|
1780 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1781 | 1781 | } |
1782 | 1782 | return $otherObject; |
1783 | 1783 | } |
@@ -1788,18 +1788,18 @@ discard block |
||
1788 | 1788 | * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions) |
1789 | 1789 | * @return EE_Base_Class |
1790 | 1790 | */ |
1791 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1792 | - if ( $this->ID() ) { |
|
1791 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1792 | + if ($this->ID()) { |
|
1793 | 1793 | //if this exists in the DB, save the relation change to the DB too |
1794 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1795 | - $this->clear_cache( $relationName, null, true ); |
|
1794 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1795 | + $this->clear_cache($relationName, null, true); |
|
1796 | 1796 | } else { |
1797 | 1797 | //this doesn't exist in the DB, just remove it from the cache |
1798 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1798 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1799 | 1799 | } |
1800 | - if( is_array( $otherObjects ) ) { |
|
1801 | - foreach ( $otherObjects as $otherObject ) { |
|
1802 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1800 | + if (is_array($otherObjects)) { |
|
1801 | + foreach ($otherObjects as $otherObject) { |
|
1802 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1803 | 1803 | } |
1804 | 1804 | } |
1805 | 1805 | return $otherObjects; |
@@ -1817,26 +1817,26 @@ discard block |
||
1817 | 1817 | * @return EE_Base_Class[] Results not necessarily indexed by IDs, because some results might not have primary keys |
1818 | 1818 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1819 | 1819 | */ |
1820 | - public function get_many_related($relationName,$query_params = array()){ |
|
1821 | - if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB |
|
1820 | + public function get_many_related($relationName, $query_params = array()) { |
|
1821 | + if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB |
|
1822 | 1822 | //if there are query parameters, forget about caching the related model objects. |
1823 | - if( $query_params ){ |
|
1823 | + if ($query_params) { |
|
1824 | 1824 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1825 | - }else{ |
|
1825 | + } else { |
|
1826 | 1826 | //did we already cache the result of this query? |
1827 | 1827 | $cached_results = $this->get_all_from_cache($relationName); |
1828 | - if ( ! $cached_results ){ |
|
1828 | + if ( ! $cached_results) { |
|
1829 | 1829 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1830 | 1830 | //if no query parameters were passed, then we got all the related model objects |
1831 | 1831 | //for that relation. We can cache them then. |
1832 | - foreach($related_model_objects as $related_model_object){ |
|
1832 | + foreach ($related_model_objects as $related_model_object) { |
|
1833 | 1833 | $this->cache($relationName, $related_model_object); |
1834 | 1834 | } |
1835 | - }else{ |
|
1835 | + } else { |
|
1836 | 1836 | $related_model_objects = $cached_results; |
1837 | 1837 | } |
1838 | 1838 | } |
1839 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1839 | + } else {//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1840 | 1840 | $related_model_objects = $this->get_all_from_cache($relationName); |
1841 | 1841 | } |
1842 | 1842 | return $related_model_objects; |
@@ -1853,8 +1853,8 @@ discard block |
||
1853 | 1853 | * @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; |
1854 | 1854 | * @return int |
1855 | 1855 | */ |
1856 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1857 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1856 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1857 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1858 | 1858 | } |
1859 | 1859 | |
1860 | 1860 | |
@@ -1868,7 +1868,7 @@ discard block |
||
1868 | 1868 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1869 | 1869 | * @return int |
1870 | 1870 | */ |
1871 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1871 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1872 | 1872 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1873 | 1873 | } |
1874 | 1874 | |
@@ -1880,34 +1880,34 @@ discard block |
||
1880 | 1880 | * @param array $query_params like EEM_Base::get_all |
1881 | 1881 | * @return EE_Base_Class (not an array, a single object) |
1882 | 1882 | */ |
1883 | - public function get_first_related($relationName,$query_params = array()){ |
|
1884 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
1883 | + public function get_first_related($relationName, $query_params = array()) { |
|
1884 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
1885 | 1885 | |
1886 | 1886 | //if they've provided some query parameters, don't bother trying to cache the result |
1887 | 1887 | //also make sure we're not caching the result of get_first_related |
1888 | 1888 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
1889 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
1890 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1891 | - }else{ |
|
1889 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
1890 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1891 | + } else { |
|
1892 | 1892 | //first, check if we've already cached the result of this query |
1893 | 1893 | $cached_result = $this->get_one_from_cache($relationName); |
1894 | - if ( ! $cached_result ){ |
|
1894 | + if ( ! $cached_result) { |
|
1895 | 1895 | |
1896 | 1896 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1897 | - $this->cache($relationName,$related_model_object); |
|
1898 | - }else{ |
|
1897 | + $this->cache($relationName, $related_model_object); |
|
1898 | + } else { |
|
1899 | 1899 | $related_model_object = $cached_result; |
1900 | 1900 | } |
1901 | 1901 | } |
1902 | - }else{ |
|
1902 | + } else { |
|
1903 | 1903 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
1904 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
1905 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1906 | - }else{ |
|
1904 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
1905 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1906 | + } else { |
|
1907 | 1907 | $related_model_object = null; |
1908 | 1908 | } |
1909 | 1909 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
1910 | - if( ! $related_model_object){ |
|
1910 | + if ( ! $related_model_object) { |
|
1911 | 1911 | $related_model_object = $this->get_one_from_cache($relationName); |
1912 | 1912 | } |
1913 | 1913 | |
@@ -1926,12 +1926,12 @@ discard block |
||
1926 | 1926 | * @param array $query_params like EEM_Base::get_all's |
1927 | 1927 | * @return int how many deleted |
1928 | 1928 | */ |
1929 | - public function delete_related($relationName,$query_params = array()){ |
|
1930 | - if($this->ID()){ |
|
1931 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
1932 | - }else{ |
|
1929 | + public function delete_related($relationName, $query_params = array()) { |
|
1930 | + if ($this->ID()) { |
|
1931 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
1932 | + } else { |
|
1933 | 1933 | $count = count($this->get_all_from_cache($relationName)); |
1934 | - $this->clear_cache($relationName,NULL,TRUE); |
|
1934 | + $this->clear_cache($relationName, NULL, TRUE); |
|
1935 | 1935 | } |
1936 | 1936 | return $count; |
1937 | 1937 | } |
@@ -1946,13 +1946,13 @@ discard block |
||
1946 | 1946 | * @param array $query_params like EEM_Base::get_all's |
1947 | 1947 | * @return int how many deleted (including those soft deleted) |
1948 | 1948 | */ |
1949 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
1950 | - if($this->ID()){ |
|
1951 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
1952 | - }else{ |
|
1949 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
1950 | + if ($this->ID()) { |
|
1951 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
1952 | + } else { |
|
1953 | 1953 | $count = count($this->get_all_from_cache($relationName)); |
1954 | 1954 | } |
1955 | - $this->clear_cache($relationName,NULL,TRUE); |
|
1955 | + $this->clear_cache($relationName, NULL, TRUE); |
|
1956 | 1956 | return $count; |
1957 | 1957 | } |
1958 | 1958 | |
@@ -1968,7 +1968,7 @@ discard block |
||
1968 | 1968 | * @param string $field_name property to check |
1969 | 1969 | * @return bool TRUE if existing,FALSE if not. |
1970 | 1970 | */ |
1971 | - public function is_set( $field_name ) { |
|
1971 | + public function is_set($field_name) { |
|
1972 | 1972 | return isset($this->_fields[$field_name]); |
1973 | 1973 | } |
1974 | 1974 | |
@@ -1980,12 +1980,12 @@ discard block |
||
1980 | 1980 | * @throws EE_Error |
1981 | 1981 | * @return bool TRUE if existing, throw EE_Error if not. |
1982 | 1982 | */ |
1983 | - protected function _property_exists( $properties ) { |
|
1983 | + protected function _property_exists($properties) { |
|
1984 | 1984 | |
1985 | - foreach ( (array) $properties as $property_name ) { |
|
1985 | + foreach ((array) $properties as $property_name) { |
|
1986 | 1986 | //first make sure this property exists |
1987 | - if ( ! $this->_fields[ $property_name ] ) |
|
1988 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1987 | + if ( ! $this->_fields[$property_name]) |
|
1988 | + throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name)); |
|
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | return TRUE; |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $fields = $this->get_model()->field_settings(FALSE); |
2003 | 2003 | $properties = array(); |
2004 | 2004 | //remove prepended underscore |
2005 | - foreach ( $fields as $field_name => $settings ) { |
|
2005 | + foreach ($fields as $field_name => $settings) { |
|
2006 | 2006 | $properties[$field_name] = $this->get($field_name); |
2007 | 2007 | } |
2008 | 2008 | return $properties; |
@@ -2032,14 +2032,14 @@ discard block |
||
2032 | 2032 | * @throws EE_Error |
2033 | 2033 | * @return mixed whatever the plugin which calls add_filter decides |
2034 | 2034 | */ |
2035 | - public function __call($methodName,$args){ |
|
2036 | - $className=get_class($this); |
|
2037 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2038 | - if(!has_filter($tagName)){ |
|
2039 | - throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"), |
|
2040 | - $methodName,$className,$tagName)); |
|
2035 | + public function __call($methodName, $args) { |
|
2036 | + $className = get_class($this); |
|
2037 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2038 | + if ( ! has_filter($tagName)) { |
|
2039 | + throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"), |
|
2040 | + $methodName, $className, $tagName)); |
|
2041 | 2041 | } |
2042 | - return apply_filters($tagName,null,$this,$args); |
|
2042 | + return apply_filters($tagName, null, $this, $args); |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | |
@@ -2054,22 +2054,22 @@ discard block |
||
2054 | 2054 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
2055 | 2055 | * NOTE: if the values haven't changed, returns 0 |
2056 | 2056 | */ |
2057 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2058 | - $query_params = array(array( |
|
2057 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2058 | + $query_params = array(array( |
|
2059 | 2059 | 'EXM_key'=>$meta_key, |
2060 | 2060 | 'OBJ_ID'=>$this->ID(), |
2061 | 2061 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
2062 | - if($previous_value !== NULL){ |
|
2062 | + if ($previous_value !== NULL) { |
|
2063 | 2063 | $query_params[0]['EXM_value'] = $meta_value; |
2064 | 2064 | } |
2065 | 2065 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
2066 | - if( ! $existing_rows_like_that){ |
|
2066 | + if ( ! $existing_rows_like_that) { |
|
2067 | 2067 | return $this->add_extra_meta($meta_key, $meta_value); |
2068 | - }else{ |
|
2069 | - foreach( $existing_rows_like_that as $existing_row){ |
|
2070 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2068 | + } else { |
|
2069 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2070 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2071 | 2071 | } |
2072 | - return count( $existing_rows_like_that ); |
|
2072 | + return count($existing_rows_like_that); |
|
2073 | 2073 | } |
2074 | 2074 | } |
2075 | 2075 | |
@@ -2082,10 +2082,10 @@ discard block |
||
2082 | 2082 | * @param boolean $unique |
2083 | 2083 | * @return boolean |
2084 | 2084 | */ |
2085 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2086 | - if($unique){ |
|
2087 | - $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
2088 | - if($existing_extra_meta){ |
|
2085 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2086 | + if ($unique) { |
|
2087 | + $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
2088 | + if ($existing_extra_meta) { |
|
2089 | 2089 | return false; |
2090 | 2090 | } |
2091 | 2091 | } |
@@ -2105,12 +2105,12 @@ discard block |
||
2105 | 2105 | * @param string $meta_value |
2106 | 2106 | * @return int number of extra meta rows deleted |
2107 | 2107 | */ |
2108 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2109 | - $query_params = array(array( |
|
2108 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2109 | + $query_params = array(array( |
|
2110 | 2110 | 'EXM_key'=>$meta_key, |
2111 | 2111 | 'OBJ_ID'=>$this->ID(), |
2112 | 2112 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
2113 | - if($meta_value !== NULL){ |
|
2113 | + if ($meta_value !== NULL) { |
|
2114 | 2114 | $query_params[0]['EXM_value'] = $meta_value; |
2115 | 2115 | } |
2116 | 2116 | $count_deleted = EEM_Extra_Meta::instance()->delete($query_params); |
@@ -2126,25 +2126,25 @@ discard block |
||
2126 | 2126 | * @param mixed $default if we don't find anything, what should we return? |
2127 | 2127 | * @return mixed single value if $single; array if ! $single |
2128 | 2128 | */ |
2129 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2130 | - if($single){ |
|
2131 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2132 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2129 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2130 | + if ($single) { |
|
2131 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2132 | + if ($result instanceof EE_Extra_Meta) { |
|
2133 | 2133 | return $result->value(); |
2134 | - }else{ |
|
2134 | + } else { |
|
2135 | 2135 | return $default; |
2136 | 2136 | } |
2137 | - }else{ |
|
2138 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2139 | - if($results){ |
|
2137 | + } else { |
|
2138 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2139 | + if ($results) { |
|
2140 | 2140 | $values = array(); |
2141 | - foreach($results as $result){ |
|
2142 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2141 | + foreach ($results as $result) { |
|
2142 | + if ($result instanceof EE_Extra_Meta) { |
|
2143 | 2143 | $values[$result->ID()] = $result->value(); |
2144 | 2144 | } |
2145 | 2145 | } |
2146 | 2146 | return $values; |
2147 | - }else{ |
|
2147 | + } else { |
|
2148 | 2148 | return $default; |
2149 | 2149 | } |
2150 | 2150 | } |
@@ -2161,20 +2161,20 @@ discard block |
||
2161 | 2161 | * @param boolean $one_of_each_key |
2162 | 2162 | * @return array |
2163 | 2163 | */ |
2164 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2164 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2165 | 2165 | $return_array = array(); |
2166 | - if($one_of_each_key){ |
|
2166 | + if ($one_of_each_key) { |
|
2167 | 2167 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2168 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2169 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2168 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2169 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2170 | 2170 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2171 | 2171 | } |
2172 | 2172 | } |
2173 | - }else{ |
|
2173 | + } else { |
|
2174 | 2174 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2175 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2176 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2177 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2175 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2176 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2177 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2178 | 2178 | $return_array[$extra_meta_obj->key()] = array(); |
2179 | 2179 | } |
2180 | 2180 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2187,19 +2187,19 @@ discard block |
||
2187 | 2187 | * Gets a pretty nice displayable nice for this model object. Often overridden |
2188 | 2188 | * @return string |
2189 | 2189 | */ |
2190 | - public function name(){ |
|
2190 | + public function name() { |
|
2191 | 2191 | //find a field that's not a text field |
2192 | 2192 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2193 | - if($field_we_can_use){ |
|
2193 | + if ($field_we_can_use) { |
|
2194 | 2194 | return $this->get($field_we_can_use->get_name()); |
2195 | - }else{ |
|
2195 | + } else { |
|
2196 | 2196 | $first_few_properties = $this->model_field_array(); |
2197 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2197 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2198 | 2198 | $name_parts = array(); |
2199 | - foreach( $first_few_properties as $name=> $value ){ |
|
2199 | + foreach ($first_few_properties as $name=> $value) { |
|
2200 | 2200 | $name_parts[] = "$name:$value"; |
2201 | 2201 | } |
2202 | - return implode(",",$name_parts); |
|
2202 | + return implode(",", $name_parts); |
|
2203 | 2203 | } |
2204 | 2204 | } |
2205 | 2205 | |
@@ -2208,11 +2208,11 @@ discard block |
||
2208 | 2208 | * Checks if this model object has been proven to already be in the entity map |
2209 | 2209 | * @return boolean |
2210 | 2210 | */ |
2211 | - public function in_entity_map(){ |
|
2212 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2211 | + public function in_entity_map() { |
|
2212 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2213 | 2213 | //well, if we looked, did we find it in the entity map? |
2214 | 2214 | return TRUE; |
2215 | - }else{ |
|
2215 | + } else { |
|
2216 | 2216 | return FALSE; |
2217 | 2217 | } |
2218 | 2218 | } |
@@ -2223,21 +2223,21 @@ discard block |
||
2223 | 2223 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2224 | 2224 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2225 | 2225 | */ |
2226 | - public function refresh_from_db(){ |
|
2227 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2228 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2229 | - }else{ |
|
2226 | + public function refresh_from_db() { |
|
2227 | + if ($this->ID() && $this->in_entity_map()) { |
|
2228 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2229 | + } else { |
|
2230 | 2230 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2231 | 2231 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2232 | 2232 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2233 | 2233 | //absolutely nothing in it for this ID |
2234 | - if( WP_DEBUG ) { |
|
2234 | + if (WP_DEBUG) { |
|
2235 | 2235 | throw new EE_Error( |
2236 | 2236 | sprintf( |
2237 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2237 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2238 | 2238 | $this->ID(), |
2239 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2240 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2239 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2240 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2241 | 2241 | ) |
2242 | 2242 | ); |
2243 | 2243 | } |
@@ -2249,8 +2249,8 @@ discard block |
||
2249 | 2249 | * (probably a bad assumption they have made, oh well) |
2250 | 2250 | * @return string |
2251 | 2251 | */ |
2252 | - public function __toString(){ |
|
2253 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2252 | + public function __toString() { |
|
2253 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | /** |
@@ -2282,16 +2282,16 @@ discard block |
||
2282 | 2282 | * @return array |
2283 | 2283 | */ |
2284 | 2284 | public function __sleep() { |
2285 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2286 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2287 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2288 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2289 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2290 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2285 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2286 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2287 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2288 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2289 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2290 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2291 | 2291 | } |
2292 | 2292 | } |
2293 | 2293 | } |
2294 | - return array_keys( get_object_vars( $this ) ); |
|
2294 | + return array_keys(get_object_vars($this)); |
|
2295 | 2295 | } |
2296 | 2296 | |
2297 | 2297 |
@@ -3,17 +3,17 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * |
|
7 | - * Class EE_Default_Where_Conditions |
|
8 | - * |
|
9 | - * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core/db_models |
|
13 | - * @author Mike Nelson |
|
14 | - * * @since 4.6.0 |
|
15 | - * |
|
16 | - */ |
|
6 | + * |
|
7 | + * Class EE_Default_Where_Conditions |
|
8 | + * |
|
9 | + * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core/db_models |
|
13 | + * @author Mike Nelson |
|
14 | + * * @since 4.6.0 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * * @since 4.6.0 |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{ |
|
17 | +class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions { |
|
18 | 18 | /** |
19 | 19 | * Gets the where default where conditions for a custom post type model |
20 | 20 | * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | return array_merge( |
26 | 26 | parent::_get_default_where_conditions(), |
27 | 27 | array( |
28 | - $status_field->get_name() => array('NOT IN',array('auto-draft','trash') ) |
|
28 | + $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash')) |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
@@ -3,18 +3,18 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * |
|
7 | - * Class EE_Default_Where_Conditions |
|
8 | - * |
|
9 | - * Strategy to be used for getting default where conditions for EEM_Base children. |
|
10 | - * Should be initialized and set on construction of model |
|
11 | - * |
|
12 | - * @package Event Espresso |
|
13 | - * @subpackage core/db_models |
|
14 | - * @author Mike Nelson |
|
15 | - * @since 4.6.0 |
|
16 | - * |
|
17 | - */ |
|
6 | + * |
|
7 | + * Class EE_Default_Where_Conditions |
|
8 | + * |
|
9 | + * Strategy to be used for getting default where conditions for EEM_Base children. |
|
10 | + * Should be initialized and set on construction of model |
|
11 | + * |
|
12 | + * @package Event Espresso |
|
13 | + * @subpackage core/db_models |
|
14 | + * @author Mike Nelson |
|
15 | + * @since 4.6.0 |
|
16 | + * |
|
17 | + */ |
|
18 | 18 | class EE_Default_Where_Conditions{ |
19 | 19 | /** |
20 | 20 | * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @since 4.6.0 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Default_Where_Conditions{ |
|
18 | +class EE_Default_Where_Conditions { |
|
19 | 19 | /** |
20 | 20 | * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
21 | 21 | * replaced with the current user's ID (because we don't want to use the current user's ID at time of |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * onto any field names |
48 | 48 | * @param array $custom_where_conditions |
49 | 49 | */ |
50 | - public function __construct( $custom_where_conditions = array() ) { |
|
50 | + public function __construct($custom_where_conditions = array()) { |
|
51 | 51 | $this->_where_conditions_provided = $custom_where_conditions; |
52 | 52 | } |
53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * for querying of the model. |
57 | 57 | * @param EEM_Base $model |
58 | 58 | */ |
59 | - function _finalize_construct(EEM_Base $model){ |
|
59 | + function _finalize_construct(EEM_Base $model) { |
|
60 | 60 | $this->_model = $model; |
61 | 61 | } |
62 | 62 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param string $model_relation_chain |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - function get_minimum_where_conditions( $model_relation_chain = null ){ |
|
73 | + function get_minimum_where_conditions($model_relation_chain = null) { |
|
74 | 74 | return $this->prepare_where_conditions_for_querying( |
75 | 75 | $this->get_where_conditions_provided(), |
76 | 76 | $model_relation_chain |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param string $model_relation_chain |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - protected function _ensure_model_relation_chain_ends_in_period( $model_relation_chain ){ |
|
86 | - if($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain)-1] !='.'){ |
|
87 | - $model_relation_chain=$model_relation_chain."."; |
|
85 | + protected function _ensure_model_relation_chain_ends_in_period($model_relation_chain) { |
|
86 | + if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') { |
|
87 | + $model_relation_chain = $model_relation_chain."."; |
|
88 | 88 | } |
89 | 89 | return $model_relation_chain; |
90 | 90 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $model_relation_chain |
101 | 101 | * @return array like what's expected in EEM_Base::get_all()'s $query_params[0] |
102 | 102 | */ |
103 | - function get_default_where_conditions( $model_relation_chain = '' ){ |
|
103 | + function get_default_where_conditions($model_relation_chain = '') { |
|
104 | 104 | return $this->prepare_where_conditions_for_querying( |
105 | 105 | array_replace_recursive( |
106 | 106 | $this->_get_default_where_conditions(), |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Adding model relation chains is handled by the public method get_default_where_conditions |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - protected function _get_default_where_conditions(){ |
|
117 | + protected function _get_default_where_conditions() { |
|
118 | 118 | return array(); |
119 | 119 | } |
120 | 120 | |
@@ -128,31 +128,31 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | * @throws \EE_Error |
130 | 130 | */ |
131 | - public function prepare_where_conditions_for_querying( $where_conditions, $model_relation_chain ) { |
|
131 | + public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) { |
|
132 | 132 | $where_conditions_with_model_relation_chain_prefixes = array(); |
133 | - if( ! is_array( $where_conditions ) ){ |
|
133 | + if ( ! is_array($where_conditions)) { |
|
134 | 134 | $where_conditions = array(); |
135 | 135 | } |
136 | - foreach( $where_conditions as $key => $value ) { |
|
137 | - if( in_array( $key, array( 'OR', 'AND', 'NOT' ) ) || |
|
138 | - strpos( $key, 'OR*' ) !== false || |
|
139 | - strpos( $key, 'AND*' ) !== false || |
|
140 | - strpos( $key, 'NOT*' ) !== false ){ |
|
141 | - $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( $value, $model_relation_chain ); |
|
142 | - }else{ |
|
143 | - $model_relation_chain = $this->_ensure_model_relation_chain_ends_in_period( $model_relation_chain ); |
|
136 | + foreach ($where_conditions as $key => $value) { |
|
137 | + if (in_array($key, array('OR', 'AND', 'NOT')) || |
|
138 | + strpos($key, 'OR*') !== false || |
|
139 | + strpos($key, 'AND*') !== false || |
|
140 | + strpos($key, 'NOT*') !== false) { |
|
141 | + $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying($value, $model_relation_chain); |
|
142 | + } else { |
|
143 | + $model_relation_chain = $this->_ensure_model_relation_chain_ends_in_period($model_relation_chain); |
|
144 | 144 | //check for the current user id place holder, and if present change it |
145 | - if( $value === self::current_user_placeholder ){ |
|
145 | + if ($value === self::current_user_placeholder) { |
|
146 | 146 | $value = get_current_user_id(); |
147 | 147 | } |
148 | 148 | //check for user field placeholder |
149 | - if( $key == self::user_field_name_placeholder ) { |
|
150 | - if( ! $this->_model->wp_user_field_name() ) { |
|
151 | - throw new EE_Error( sprintf( __( 'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso' ), $this->_model->get_this_model_name() ) ); |
|
149 | + if ($key == self::user_field_name_placeholder) { |
|
150 | + if ( ! $this->_model->wp_user_field_name()) { |
|
151 | + throw new EE_Error(sprintf(__('There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso'), $this->_model->get_this_model_name())); |
|
152 | 152 | } |
153 | 153 | $key = $this->_model->wp_user_field_name(); |
154 | 154 | } |
155 | - $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
155 | + $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | return $where_conditions_with_model_relation_chain_prefixes; |
@@ -3,16 +3,16 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * |
|
7 | - * Class EE_Default_Where_Conditions |
|
8 | - * |
|
9 | - * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core/db_models |
|
13 | - * @author Mike Nelson |
|
14 | - * @since 4.6.0 |
|
15 | - */ |
|
6 | + * |
|
7 | + * Class EE_Default_Where_Conditions |
|
8 | + * |
|
9 | + * Strategy specifically for adding where conditions specific to CPT models. |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core/db_models |
|
13 | + * @author Mike Nelson |
|
14 | + * @since 4.6.0 |
|
15 | + */ |
|
16 | 16 | class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
17 | 17 | /** |
18 | 18 | * Strategy for setting default soft delete where conditions. This strategy will find |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @author Mike Nelson |
14 | 14 | * @since 4.6.0 |
15 | 15 | */ |
16 | -class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
|
16 | +class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions { |
|
17 | 17 | |
18 | 18 | |
19 | 19 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array $custom_where_conditions |
28 | 28 | */ |
29 | - function __construct( $custom_where_conditions = array() ){ |
|
30 | - parent::__construct( $custom_where_conditions ); |
|
29 | + function __construct($custom_where_conditions = array()) { |
|
30 | + parent::__construct($custom_where_conditions); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * Gets the where default where conditions for a custom post type model |
37 | 37 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
38 | 38 | */ |
39 | - protected function _get_default_where_conditions(){ |
|
39 | + protected function _get_default_where_conditions() { |
|
40 | 40 | $trashed_field_name = $this->deleted_field_name(); |
41 | 41 | return array( |
42 | 42 | $trashed_field_name => false |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @return string |
52 | 52 | * @throws EE_Error |
53 | 53 | */ |
54 | - private function deleted_field_name(){ |
|
54 | + private function deleted_field_name() { |
|
55 | 55 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
56 | - if($field){ |
|
56 | + if ($field) { |
|
57 | 57 | return $field->get_name(); |
58 | - }else{ |
|
58 | + } else { |
|
59 | 59 | throw new EE_Error( |
60 | 60 | sprintf( |
61 | - __( 'We are trying to find the deleted flag field on %1$s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in the %1$s constructor?', 'event_espresso' ), |
|
62 | - get_class( $this ) |
|
61 | + __('We are trying to find the deleted flag field on %1$s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in the %1$s constructor?', 'event_espresso'), |
|
62 | + get_class($this) |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | } |
@@ -257,7 +257,7 @@ |
||
257 | 257 | * @param int $TXN_ID |
258 | 258 | * @param int $ATT_ID |
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | - * @return mixed array on success, FALSE on fail |
|
260 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
261 | 261 | */ |
262 | 262 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
263 | 263 | return $this->get_one(array( |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
11 | - * @ link {@link http://www.eventespresso.com} |
|
12 | - * @ since 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * Registrations Table class |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage includes/admin_screens/Registrations_List_Table.class.php |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
11 | + * @ link {@link http://www.eventespresso.com} |
|
12 | + * @ since 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * Registrations Table class |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage includes/admin_screens/Registrations_List_Table.class.php |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | |
26 | 26 | class EE_Registrations_List_Table extends EE_Admin_List_Table { |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | * @param \EE_Registration $item |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - function column_cb($item){ |
|
340 | + function column_cb($item){ |
|
341 | 341 | /** checkbox/lock **/ |
342 | 342 | $transaction = $item->get_first_related( 'Transaction' ); |
343 | 343 | $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
344 | 344 | return $payment_count > 0 ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) . '<span class="ee-lock-icon"></span>' : sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ); |
345 | - } |
|
345 | + } |
|
346 | 346 | |
347 | 347 | |
348 | 348 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function column__REG_date(EE_Registration $item){ |
378 | 378 | $this->_set_related_details($item); |
379 | - //Build row actions |
|
379 | + //Build row actions |
|
380 | 380 | $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
381 | 381 | $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
382 | 382 | $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } else { |
429 | 429 | return __( 'There is no ticket on this registration', 'event_espresso' ); |
430 | 430 | } |
431 | - } |
|
431 | + } |
|
432 | 432 | |
433 | 433 | |
434 | 434 | |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | $t = $item->get_first_related('Transaction'); |
451 | 451 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
452 | 452 | |
453 | - //append group count to name |
|
454 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
453 | + //append group count to name |
|
454 | + $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
455 | 455 | |
456 | - //append reg_code |
|
457 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
456 | + //append reg_code |
|
457 | + $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
458 | 458 | |
459 | - //reg status text for accessibility |
|
460 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
459 | + //reg status text for accessibility |
|
460 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
461 | 461 | |
462 | 462 | //trash/restore/delete actions |
463 | 463 | $actions = array(); |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | * @param \EE_Admin_Page $admin_page |
58 | 58 | * @return EE_Registrations_List_Table |
59 | 59 | */ |
60 | - function __construct( $admin_page ){ |
|
60 | + function __construct($admin_page) { |
|
61 | 61 | |
62 | - if ( ! empty( $_GET['event_id'] ) ) { |
|
62 | + if ( ! empty($_GET['event_id'])) { |
|
63 | 63 | $extra_query_args = array(); |
64 | - foreach ( $admin_page->get_views() as $key => $view_details ) { |
|
65 | - $extra_query_args[$view_details['slug']] = array( 'event_id' => $_GET['event_id'] ); |
|
64 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
65 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
66 | 66 | } |
67 | - $this->_views = $admin_page->get_list_table_view_RLs( $extra_query_args ); |
|
67 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | parent::__construct($admin_page); |
71 | 71 | $this->_status = $this->_admin_page->get_registration_status_array(); |
72 | 72 | |
73 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
73 | + EE_Registry::instance()->load_helper('Template'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @return void |
82 | 82 | */ |
83 | 83 | protected function _setup_data() { |
84 | - $this->_data = $this->_admin_page->get_registrations( $this->_per_page ); |
|
85 | - $this->_all_data_count = $this->_admin_page->get_registrations( $this->_per_page, TRUE, FALSE, FALSE ); |
|
84 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
85 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, TRUE, FALSE, FALSE); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -101,45 +101,45 @@ discard block |
||
101 | 101 | ); |
102 | 102 | |
103 | 103 | |
104 | - if ( isset( $_GET['event_id'] )) { |
|
104 | + if (isset($_GET['event_id'])) { |
|
105 | 105 | $this->_columns = array( |
106 | 106 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
107 | - '_REG_ID' => __( 'ID', 'event_espresso' ), |
|
108 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
107 | + '_REG_ID' => __('ID', 'event_espresso'), |
|
108 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
109 | 109 | 'ATT_email' => __('Email', 'event_espresso'), |
110 | - '_REG_date' => __( 'Reg Date', 'event_espresso' ), |
|
111 | - 'PRC_amount' => __( 'TKT Price', 'event_espresso' ), |
|
112 | - '_REG_final_price' => __( 'Final Price', 'event_espresso' ), |
|
113 | - 'TXN_total' => __( 'Total Txn', 'event_espresso' ), |
|
110 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
111 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
112 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
113 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
114 | 114 | 'TXN_paid' => __('Paid', 'event_espresso'), |
115 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
115 | + 'actions' => __('Actions', 'event_espresso') |
|
116 | 116 | ); |
117 | 117 | $this->_bottom_buttons = array( |
118 | 118 | 'report'=> array( |
119 | 119 | 'route' => 'registrations_report', |
120 | 120 | 'extra_request' => |
121 | 121 | array( |
122 | - 'EVT_ID'=> isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null, |
|
123 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) ) |
|
122 | + 'EVT_ID'=> isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
123 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ) |
|
124 | 124 | ), |
125 | 125 | ); |
126 | 126 | } else { |
127 | 127 | $this->_columns = array( |
128 | 128 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
129 | - '_REG_ID' => __( 'ID', 'event_espresso' ), |
|
130 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
131 | - '_REG_date' => __( 'TXN Date', 'event_espresso' ), |
|
132 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
133 | - 'DTT_EVT_start' => __( 'Event Date', 'event_espresso' ), |
|
134 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
135 | - '_REG_paid' => __( 'Paid', 'event_espresso' ), |
|
136 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
129 | + '_REG_ID' => __('ID', 'event_espresso'), |
|
130 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
131 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
132 | + 'event_name' => __('Event', 'event_espresso'), |
|
133 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
134 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
135 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
136 | + 'actions' => __('Actions', 'event_espresso') |
|
137 | 137 | ); |
138 | 138 | $this->_bottom_buttons = array( |
139 | 139 | 'report_all'=> array( |
140 | 140 | 'route' => 'registrations_report', |
141 | 141 | 'extra_request' => array( |
142 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) ) |
|
142 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ) |
|
143 | 143 | ), |
144 | 144 | ); |
145 | 145 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $this->_primary_column = '_REG_ID'; |
148 | 148 | |
149 | 149 | $this->_sortable_columns = array( |
150 | - '_REG_date' => array( '_REG_date' => TRUE ), //true means its already sorted |
|
151 | - 'ATT_fname' => array( 'ATT_fname' => FALSE ), |
|
152 | - 'event_name' => array( 'event_name' => FALSE ), |
|
153 | - 'DTT_EVT_start' => array( 'DTT_EVT_start' => FALSE ), |
|
154 | - '_REG_ID' => array( '_REG_ID' => FALSE ), |
|
150 | + '_REG_date' => array('_REG_date' => TRUE), //true means its already sorted |
|
151 | + 'ATT_fname' => array('ATT_fname' => FALSE), |
|
152 | + 'event_name' => array('event_name' => FALSE), |
|
153 | + 'DTT_EVT_start' => array('DTT_EVT_start' => FALSE), |
|
154 | + '_REG_ID' => array('_REG_ID' => FALSE), |
|
155 | 155 | ); |
156 | 156 | |
157 | 157 | $this->_hidden_columns = array(); |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - protected function _get_row_class( $item ) { |
|
164 | - $class = parent::_get_row_class( $item ); |
|
163 | + protected function _get_row_class($item) { |
|
164 | + $class = parent::_get_row_class($item); |
|
165 | 165 | //add status class |
166 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
167 | - if ( $this->_has_checkbox_column ) { |
|
166 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
167 | + if ($this->_has_checkbox_column) { |
|
168 | 168 | $class .= ' has-checkbox-column'; |
169 | 169 | } |
170 | 170 | return $class; |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param EE_Registration $registration |
179 | 179 | */ |
180 | - protected function _set_related_details( EE_Registration $registration ) { |
|
180 | + protected function _set_related_details(EE_Registration $registration) { |
|
181 | 181 | |
182 | - $transaction = $registration->get_first_related( 'Transaction' ); |
|
182 | + $transaction = $registration->get_first_related('Transaction'); |
|
183 | 183 | $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() : EEM_Transaction::failed_status_code; |
184 | 184 | $this->_transaction_details = array( |
185 | 185 | 'transaction' => $transaction, |
186 | 186 | 'status' => $status, |
187 | 187 | 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
188 | - 'title_attr' => sprintf( __('View Transaction Details (%s)', 'event_espresso'), EEH_Template::pretty_status( $status, false, 'sentence' ) ) |
|
188 | + 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), EEH_Template::pretty_status($status, false, 'sentence')) |
|
189 | 189 | ); |
190 | 190 | |
191 | 191 | $event = $registration->event(); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | 'event' => $event, |
195 | 195 | 'status' => $status, |
196 | 196 | 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
197 | - 'title_attr' => sprintf( __('Edit Event (%s)', 'event_espresso'), EEH_Template::pretty_status( $status, false, 'sentence' ) ) |
|
197 | + 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), EEH_Template::pretty_status($status, false, 'sentence')) |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | $filters = array(); |
210 | 210 | |
211 | 211 | //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
212 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
212 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
213 | 213 | |
214 | - $cur_date = isset( $this->_req_data['month_range'] ) ? $this->_req_data['month_range'] : ''; |
|
215 | - $cur_category = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
216 | - $reg_status = isset( $this->_req_data['_reg_status'] ) ? $this->_req_data['_reg_status'] : ''; |
|
214 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
215 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
216 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
217 | 217 | |
218 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown( $cur_date, $reg_status, $cur_category ); |
|
219 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown( $cur_category ); |
|
218 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
219 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
220 | 220 | |
221 | 221 | $status = array(); |
222 | - $status[] = array( 'id' => 0, 'text' => __('Select Status', 'event_espresso') ); |
|
223 | - foreach ( $this->_status as $key => $value ) { |
|
224 | - $status[] = array( 'id' => $key, 'text' => $value ); |
|
222 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
223 | + foreach ($this->_status as $key => $value) { |
|
224 | + $status[] = array('id' => $key, 'text' => $value); |
|
225 | 225 | } |
226 | - if ( $this->_view != 'incomplete' ) { |
|
227 | - $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, isset( $this->_req_data['_reg_status'] ) ? strtoupper( sanitize_key( $this->_req_data['_reg_status'] )) : '' ); |
|
226 | + if ($this->_view != 'incomplete') { |
|
227 | + $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) : ''); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( isset( $this->_req_data['event_id'] ) ) { |
|
231 | - $filters[] = EEH_Form_Fields::hidden_input( 'event_id', $this->_req_data['event_id'], 'reg_event_id' ); |
|
230 | + if (isset($this->_req_data['event_id'])) { |
|
231 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | return $filters; |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $this->_views['all']['count'] = $this->_total_registrations(); |
246 | 246 | $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
247 | 247 | $this->_views['today']['count'] = $this->_total_registrations_today(); |
248 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_trash_registrations' ) ) { |
|
249 | - $this->_views['incomplete']['count'] = $this->_total_registrations( 'incomplete' ); |
|
250 | - $this->_views['trash']['count'] = $this->_total_registrations( 'trash' ); |
|
248 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_trash_registrations')) { |
|
249 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
250 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param string $view |
260 | 260 | * @return int |
261 | 261 | */ |
262 | - protected function _total_registrations( $view = '' ){ |
|
262 | + protected function _total_registrations($view = '') { |
|
263 | 263 | $_where = array(); |
264 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
265 | - if( $EVT_ID ) { |
|
264 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
265 | + if ($EVT_ID) { |
|
266 | 266 | $_where['EVT_ID'] = $EVT_ID; |
267 | 267 | } |
268 | - switch ( $view ) { |
|
268 | + switch ($view) { |
|
269 | 269 | case 'trash' : |
270 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
270 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
271 | 271 | break; |
272 | 272 | case 'incomplete' : |
273 | 273 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
274 | 274 | break; |
275 | 275 | default : |
276 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
276 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
277 | 277 | } |
278 | - return EEM_Registration::instance()->count( array( $_where )); |
|
278 | + return EEM_Registration::instance()->count(array($_where)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @access protected |
286 | 286 | * @return int |
287 | 287 | */ |
288 | - protected function _total_registrations_this_month(){ |
|
289 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
290 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
288 | + protected function _total_registrations_this_month() { |
|
289 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
290 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
291 | 291 | $this_year_r = date('Y', current_time('timestamp')); |
292 | 292 | $time_start = ' 00:00:00'; |
293 | 293 | $time_end = ' 23:59:59'; |
294 | 294 | $this_month_r = date('m', current_time('timestamp')); |
295 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
295 | + $days_this_month = date('t', current_time('timestamp')); |
|
296 | 296 | //setup date query. |
297 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ); |
|
298 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ); |
|
299 | - $_where['REG_date']= array('BETWEEN', |
|
297 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'); |
|
298 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s'); |
|
299 | + $_where['REG_date'] = array('BETWEEN', |
|
300 | 300 | array( |
301 | 301 | $beginning_string, |
302 | 302 | $end_string |
303 | 303 | )); |
304 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
305 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
304 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
305 | + return EEM_Registration::instance()->count(array($_where)); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * @access protected |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - protected function _total_registrations_today(){ |
|
315 | + protected function _total_registrations_today() { |
|
316 | 316 | |
317 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
318 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
317 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
318 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
319 | 319 | $current_date = date('Y-m-d', current_time('timestamp')); |
320 | 320 | $time_start = ' 00:00:00'; |
321 | 321 | $time_end = ' 23:59:59'; |
322 | - $_where['REG_date']= array('BETWEEN', |
|
322 | + $_where['REG_date'] = array('BETWEEN', |
|
323 | 323 | array( |
324 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_start, 'Y-m-d H:i:s' ), |
|
325 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_end, 'Y-m-d H:i:s' ) |
|
324 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'), |
|
325 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s') |
|
326 | 326 | )); |
327 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
328 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
327 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
328 | + return EEM_Registration::instance()->count(array($_where)); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * @param \EE_Registration $item |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - function column_cb($item){ |
|
340 | + function column_cb($item) { |
|
341 | 341 | /** checkbox/lock **/ |
342 | - $transaction = $item->get_first_related( 'Transaction' ); |
|
343 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
|
344 | - return $payment_count > 0 ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) . '<span class="ee-lock-icon"></span>' : sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ); |
|
342 | + $transaction = $item->get_first_related('Transaction'); |
|
343 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
344 | + return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()).'<span class="ee-lock-icon"></span>' : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -353,14 +353,14 @@ discard block |
||
353 | 353 | * @param \EE_Registration $item |
354 | 354 | * @return string |
355 | 355 | */ |
356 | - function column__REG_ID(EE_Registration $item){ |
|
356 | + function column__REG_ID(EE_Registration $item) { |
|
357 | 357 | $attendee = $item->attendee(); |
358 | 358 | $content = $item->ID(); |
359 | 359 | $content .= '<div class="show-on-mobile-view-only">'; |
360 | 360 | $content .= '<br>'; |
361 | 361 | $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
362 | - $content .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
363 | - $content .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
362 | + $content .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
363 | + $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
364 | 364 | $content .= '</div>'; |
365 | 365 | return $content; |
366 | 366 | } |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | * @param \EE_Registration $item |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - function column__REG_date(EE_Registration $item){ |
|
377 | + function column__REG_date(EE_Registration $item) { |
|
378 | 378 | $this->_set_related_details($item); |
379 | 379 | //Build row actions |
380 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
381 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
|
382 | - $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
|
380 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id']), TXN_ADMIN_URL); |
|
381 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'.$this->_transaction_details['status'].'" href="'.$view_lnk_url.'" title="'.esc_attr($this->_transaction_details['title_attr']).'">'.$item->get_i18n_datetime('REG_date').'</a>' : $item->get_i18n_datetime('REG_date'); |
|
382 | + $view_link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence').'</span>'; |
|
383 | 383 | return $view_link; |
384 | 384 | } |
385 | 385 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | * @param \EE_Registration $item |
393 | 393 | * @return string |
394 | 394 | */ |
395 | - function column_event_name(EE_Registration $item){ |
|
396 | - $this->_set_related_details( $item ); |
|
395 | + function column_event_name(EE_Registration $item) { |
|
396 | + $this->_set_related_details($item); |
|
397 | 397 | // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
398 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$item->event_ID() ), EVENTS_ADMIN_URL ); |
|
398 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$item->event_ID()), EVENTS_ADMIN_URL); |
|
399 | 399 | $event_name = $item->event_name(); |
400 | 400 | $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
401 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID() ) ? '<a class="ee-status-color-' . $this->_event_details['status'] . '" href="' . $edit_event_url . '" title="' . esc_attr( $this->_event_details['title_attr'] ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ) ; |
|
401 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID()) ? '<a class="ee-status-color-'.$this->_event_details['status'].'" href="'.$edit_event_url.'" title="'.esc_attr($this->_event_details['title_attr']).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'); |
|
402 | 402 | |
403 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'event_id'=>$item->event_ID() ), REG_ADMIN_URL ); |
|
404 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Filter this list to only show registrations for %s', 'event_espresso' ), $event_name ) .'">' . __( 'View Registrations', 'event_espresso' ) . '</a>'; |
|
403 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id'=>$item->event_ID()), REG_ADMIN_URL); |
|
404 | + $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), $event_name).'">'.__('View Registrations', 'event_espresso').'</a>'; |
|
405 | 405 | |
406 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions) ); |
|
406 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -415,18 +415,18 @@ discard block |
||
415 | 415 | * @param \EE_Registration $item |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - function column_DTT_EVT_start(EE_Registration $item){ |
|
418 | + function column_DTT_EVT_start(EE_Registration $item) { |
|
419 | 419 | $datetime_strings = array(); |
420 | - $ticket = $item->ticket( TRUE ); |
|
421 | - if ( $ticket instanceof EE_Ticket ) { |
|
420 | + $ticket = $item->ticket(TRUE); |
|
421 | + if ($ticket instanceof EE_Ticket) { |
|
422 | 422 | $remove_defaults = array('default_where_conditions' => 'none'); |
423 | 423 | $datetimes = $ticket->datetimes($remove_defaults); |
424 | - foreach($datetimes as $datetime){ |
|
425 | - $datetime_strings[] = $datetime->get_i18n_datetime( 'DTT_EVT_start' ); |
|
424 | + foreach ($datetimes as $datetime) { |
|
425 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
426 | 426 | } |
427 | - return implode("<br />",$datetime_strings); |
|
427 | + return implode("<br />", $datetime_strings); |
|
428 | 428 | } else { |
429 | - return __( 'There is no ticket on this registration', 'event_espresso' ); |
|
429 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -439,45 +439,45 @@ discard block |
||
439 | 439 | * @param \EE_Registration $item |
440 | 440 | * @return string |
441 | 441 | */ |
442 | - function column_ATT_fname(EE_Registration $item){ |
|
442 | + function column_ATT_fname(EE_Registration $item) { |
|
443 | 443 | $attendee = $item->attendee(); |
444 | 444 | |
445 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
445 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
446 | 446 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
447 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee_name . '</a>' : $attendee_name; |
|
447 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee_name.'</a>' : $attendee_name; |
|
448 | 448 | $link .= $item->count() == 1 ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
449 | 449 | |
450 | 450 | $t = $item->get_first_related('Transaction'); |
451 | 451 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
452 | 452 | |
453 | 453 | //append group count to name |
454 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
454 | + $link .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
455 | 455 | |
456 | 456 | //append reg_code |
457 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
457 | + $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
458 | 458 | |
459 | 459 | //reg status text for accessibility |
460 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
460 | + $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
461 | 461 | |
462 | 462 | //trash/restore/delete actions |
463 | 463 | $actions = array(); |
464 | - if ( $this->_view != 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID() ) ) { |
|
465 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
466 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Trash Registration', 'event_espresso' ) . '">' . __( 'Trash', 'event_espresso' ) . '</a>'; |
|
467 | - } elseif ( $this->_view == 'trash' ) { |
|
464 | + if ($this->_view != 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID())) { |
|
465 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
466 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
467 | + } elseif ($this->_view == 'trash') { |
|
468 | 468 | // restore registration link |
469 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID() ) ) { |
|
470 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
471 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Registration', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
469 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID())) { |
|
470 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
471 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
472 | 472 | } |
473 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID() ) ) { |
|
474 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
473 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID())) { |
|
474 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
475 | 475 | |
476 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Registration Permanently', 'event_espresso' ). '">' . __( 'Delete', 'event_espresso' ) . '</a>'; |
|
476 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Registration Permanently', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions) ); |
|
480 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param \EE_Registration $item |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - function column_ATT_email( EE_Registration $item ) { |
|
492 | + function column_ATT_email(EE_Registration $item) { |
|
493 | 493 | $attendee = $item->get_first_related('Attendee'); |
494 | 494 | return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') : $attendee->email(); |
495 | 495 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * @param \EE_Registration $item |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - function column__REG_count(EE_Registration $item){ |
|
507 | - return sprintf(__( '%1$s / %2$s', 'event_espresso' ), $item->count(), $item->group_size()); |
|
506 | + function column__REG_count(EE_Registration $item) { |
|
507 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -516,16 +516,16 @@ discard block |
||
516 | 516 | * @param \EE_Registration $item |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - function column_PRC_amount(EE_Registration $item){ |
|
519 | + function column_PRC_amount(EE_Registration $item) { |
|
520 | 520 | $ticket = $item->ticket(); |
521 | 521 | |
522 | - $content = isset( $_GET['event_id'] ) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' . $ticket->name() . '</span><br />' : ''; |
|
522 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'.$ticket->name().'</span><br />' : ''; |
|
523 | 523 | |
524 | - if ( $item->final_price() > 0 ) { |
|
525 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
524 | + if ($item->final_price() > 0) { |
|
525 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
526 | 526 | } else { |
527 | 527 | // free event |
528 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
528 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'.__('free', 'event_espresso').'</span>'; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | return $content; |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | * @param \EE_Registration $item |
542 | 542 | * @return string |
543 | 543 | */ |
544 | - function column__REG_final_price(EE_Registration $item){ |
|
544 | + function column__REG_final_price(EE_Registration $item) { |
|
545 | 545 | $ticket = $item->ticket(); |
546 | - $content = isset( $_GET['event_id'] ) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">' . $ticket->name() . '</span><br />'; |
|
546 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">'.$ticket->name().'</span><br />'; |
|
547 | 547 | |
548 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
548 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
549 | 549 | return $content; |
550 | 550 | |
551 | 551 | } |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | * @param \EE_Registration $item |
560 | 560 | * @return string |
561 | 561 | */ |
562 | - function column__REG_paid(EE_Registration $item){ |
|
562 | + function column__REG_paid(EE_Registration $item) { |
|
563 | 563 | $payment_method = $item->payment_method(); |
564 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
564 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
565 | 565 | |
566 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
567 | - if ( $item->paid() > 0 ) { |
|
568 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
566 | + $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>'; |
|
567 | + if ($item->paid() > 0) { |
|
568 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
569 | 569 | } |
570 | 570 | return $content; |
571 | 571 | } |
@@ -579,11 +579,11 @@ discard block |
||
579 | 579 | * @param \EE_Registration $item |
580 | 580 | * @return string |
581 | 581 | */ |
582 | - function column_TXN_total(EE_Registration $item){ |
|
583 | - if($item->transaction()){ |
|
584 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
585 | - return EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $item->transaction()->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_total() . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
586 | - }else{ |
|
582 | + function column_TXN_total(EE_Registration $item) { |
|
583 | + if ($item->transaction()) { |
|
584 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
585 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$item->transaction()->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_total().'</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>'; |
|
586 | + } else { |
|
587 | 587 | return __("None", "event_espresso"); |
588 | 588 | } |
589 | 589 | } |
@@ -597,15 +597,15 @@ discard block |
||
597 | 597 | * @param \EE_Registration $item |
598 | 598 | * @return string |
599 | 599 | */ |
600 | - function column_TXN_paid(EE_Registration $item){ |
|
600 | + function column_TXN_paid(EE_Registration $item) { |
|
601 | 601 | |
602 | - if ( $item->count() == 1 ) { |
|
602 | + if ($item->count() == 1) { |
|
603 | 603 | $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
604 | - if ( $transaction->paid() >= $transaction->total() ) { |
|
604 | + if ($transaction->paid() >= $transaction->total()) { |
|
605 | 605 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
606 | 606 | } else { |
607 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
608 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $transaction->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_paid() . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
607 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
608 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$transaction->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_paid().'</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
@@ -626,44 +626,44 @@ discard block |
||
626 | 626 | EE_Registry::instance()->load_helper('MSG_Template'); |
627 | 627 | $attendee = $item->attendee(); |
628 | 628 | $ticket = $item->ticket(); |
629 | - $this->_set_related_details( $item ); |
|
629 | + $this->_set_related_details($item); |
|
630 | 630 | |
631 | 631 | //Build row actions |
632 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
633 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->attendee_ID() ), REG_ADMIN_URL ); |
|
632 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
633 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->attendee_ID()), REG_ADMIN_URL); |
|
634 | 634 | |
635 | 635 | // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
636 | 636 | //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
637 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL, true ); |
|
637 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL, true); |
|
638 | 638 | |
639 | 639 | |
640 | 640 | //Build row actions |
641 | - $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? ' |
|
641 | + $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
642 | 642 | <li> |
643 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
643 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
644 | 644 | <div class="dashicons dashicons-clipboard"></div> |
645 | 645 | </a> |
646 | 646 | </li>' : ''; |
647 | 647 | |
648 | - $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee' ) && $attendee instanceof EE_Attendee ?' |
|
648 | + $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') && $attendee instanceof EE_Attendee ? ' |
|
649 | 649 | <li> |
650 | - <a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact Details', 'event_espresso' ) . '" class="tiny-text"> |
|
650 | + <a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text"> |
|
651 | 651 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
652 | 652 | </a> |
653 | 653 | </li>' : ''; |
654 | 654 | |
655 | - $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration', $item->ID() ) ? ' |
|
655 | + $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
656 | 656 | <li> |
657 | - <a href="'.$resend_reg_lnk_url.'" title="' . esc_attr__( 'Resend Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
657 | + <a href="'.$resend_reg_lnk_url.'" title="'.esc_attr__('Resend Registration Details', 'event_espresso').'" class="tiny-text"> |
|
658 | 658 | <div class="dashicons dashicons-email-alt"></div> |
659 | 659 | </a> |
660 | 660 | </li>' : ''; |
661 | 661 | |
662 | 662 | // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
663 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
664 | - $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id'] ) ? ' |
|
663 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id']), TXN_ADMIN_URL); |
|
664 | + $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
665 | 665 | <li> |
666 | - <a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_txn_lnk_url.'" title="' . $this->_transaction_details['title_attr'] . '" class="tiny-text"> |
|
666 | + <a class="ee-status-color-' . $this->_transaction_details['status'].'" href="'.$view_txn_lnk_url.'" title="'.$this->_transaction_details['title_attr'].'" class="tiny-text"> |
|
667 | 667 | <div class="dashicons dashicons-cart"></div> |
668 | 668 | </a> |
669 | 669 | </li>' : ''; |
@@ -671,10 +671,10 @@ discard block |
||
671 | 671 | //invoice link |
672 | 672 | $dl_invoice_lnk_url = $item->invoice_url(); |
673 | 673 | //only show invoice link if message type is active. |
674 | - if ( $item->is_primary_registrant() && $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
674 | + if ($item->is_primary_registrant() && $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
675 | 675 | $dl_invoice_lnk = ' |
676 | 676 | <li> |
677 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
677 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
678 | 678 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
679 | 679 | </a> |
680 | 680 | </li>'; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | $dl_invoice_lnk = ''; |
683 | 683 | } |
684 | 684 | |
685 | - return $this->_action_string( $view_lnk . $edit_lnk . $resend_reg_lnk . $view_txn_lnk . $dl_invoice_lnk, $item, 'ul', 'reg-overview-actions-ul' ); |
|
685 | + return $this->_action_string($view_lnk.$edit_lnk.$resend_reg_lnk.$view_txn_lnk.$dl_invoice_lnk, $item, 'ul', 'reg-overview-actions-ul'); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | } |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
25 | 25 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
26 | 26 | */ |
27 | -class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{ |
|
27 | +class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field { |
|
28 | 28 | /** |
29 | 29 | * removes all non-basic tags when setting |
30 | 30 | * @param string $value_inputted_for_field_on_model_object |
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
34 | - return parent::prepare_for_set( $this->_remove_tags( $value_inputted_for_field_on_model_object ) ); |
|
34 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param array|string $value |
40 | 40 | * @return array|string |
41 | 41 | */ |
42 | - protected function _remove_tags( $value ) { |
|
43 | - if( is_array( $value ) ) { |
|
44 | - foreach( $value as $key => $v ) { |
|
45 | - $value[ $key ] = $this->_remove_tags( $v ); |
|
42 | + protected function _remove_tags($value) { |
|
43 | + if (is_array($value)) { |
|
44 | + foreach ($value as $key => $v) { |
|
45 | + $value[$key] = $this->_remove_tags($v); |
|
46 | 46 | } |
47 | - }elseif( is_string( $value ) ) { |
|
48 | - $value = wp_kses("$value", $this->_get_allowed_tags() ); |
|
47 | + }elseif (is_string($value)) { |
|
48 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
49 | 49 | } |
50 | 50 | return $value; |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return array|string |
57 | 57 | */ |
58 | 58 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
59 | - return $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) ); |
|
59 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * @global array $allowedtags |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - function _get_allowed_tags(){ |
|
68 | + function _get_allowed_tags() { |
|
69 | 69 | global $allowedtags; |
70 | 70 | $tags_we_allow = $allowedtags; |
71 | - $tags_we_allow['ol']=array(); |
|
72 | - $tags_we_allow['ul']=array(); |
|
73 | - $tags_we_allow['li']=array(); |
|
74 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this ); |
|
71 | + $tags_we_allow['ol'] = array(); |
|
72 | + $tags_we_allow['ul'] = array(); |
|
73 | + $tags_we_allow['li'] = array(); |
|
74 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this); |
|
75 | 75 | } |
76 | 76 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
59 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
60 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
61 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
59 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
60 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
61 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
62 | 62 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
63 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
63 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
64 | 64 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
65 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
66 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
65 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
66 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
67 | 67 | )); |
68 | 68 | $this->_model_relations = array( |
69 | 69 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | //this model is generally available for reading |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | 79 | //account for default tickets in the caps |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + parent::__construct($timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_all_default_tickets() { |
93 | 93 | /** @type EE_Ticket[] $tickets */ |
94 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
94 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
95 | 95 | //we need to set the start date and end date to today's date and the start of the default dtt |
96 | - return $this->_set_default_dates( $tickets ); |
|
96 | + return $this->_set_default_dates($tickets); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @param EE_Ticket[] $tickets |
104 | 104 | * @return EE_Ticket[] |
105 | 105 | */ |
106 | - private function _set_default_dates( $tickets ) { |
|
107 | - foreach ( $tickets as $ticket ) { |
|
108 | - $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) ); |
|
109 | - $ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
110 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
106 | + private function _set_default_dates($tickets) { |
|
107 | + foreach ($tickets as $ticket) { |
|
108 | + $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true)); |
|
109 | + $ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
110 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $tickets; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param array $query_params |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
126 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
125 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
126 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param EE_Ticket[] $tickets |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function update_tickets_sold($tickets){ |
|
137 | - foreach($tickets as $ticket){ |
|
136 | + public function update_tickets_sold($tickets) { |
|
137 | + foreach ($tickets as $ticket) { |
|
138 | 138 | /* @var $ticket EE_Ticket */ |
139 | 139 | $ticket->update_tickets_sold(); |
140 | 140 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,41 +198,41 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | 208 | $dtt = array_map( |
209 | - function( $datetime_data ) { |
|
210 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
209 | + function($datetime_data) { |
|
210 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
211 | 211 | }, |
212 | 212 | $dtt |
213 | 213 | ); |
214 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
215 | 215 | $datetime_values = array( |
216 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
217 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
218 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
216 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
217 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
218 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
219 | 219 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
220 | 220 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
221 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
222 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
221 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
222 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
226 | 226 | |
227 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
228 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
227 | + if ( ! empty($dtt['DTT_ID'])) { |
|
228 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
229 | 229 | |
230 | 230 | //set date and time format according to what is set in this class. |
231 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
232 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
231 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
232 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
233 | 233 | |
234 | - foreach ( $datetime_values as $field => $value ) { |
|
235 | - $DTM->set( $field, $value ); |
|
234 | + foreach ($datetime_values as $field => $value) { |
|
235 | + $DTM->set($field, $value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
241 | 241 | |
242 | 242 | } else { |
243 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
243 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
244 | 244 | |
245 | 245 | //reset date and times to match the format |
246 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
247 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
248 | - foreach( $datetime_values as $field => $value ) { |
|
249 | - $DTM->set( $field, $value ); |
|
246 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
247 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
248 | + foreach ($datetime_values as $field => $value) { |
|
249 | + $DTM->set($field, $value); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | $DTM->save(); |
255 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
255 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
256 | 256 | $evt_obj->save(); |
257 | 257 | |
258 | 258 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
259 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
260 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
259 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
260 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
261 | 261 | EE_Registry::instance()->load_helper('DTT_Helper'); |
262 | 262 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
263 | 263 | $DTM->save(); |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
276 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
276 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
277 | 277 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
278 | 278 | |
279 | - if ( is_array( $old_datetimes ) ) { |
|
280 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
281 | - foreach ( $dtts_to_delete as $id ) { |
|
282 | - $id = absint( $id ); |
|
283 | - if ( empty( $id ) ) |
|
279 | + if (is_array($old_datetimes)) { |
|
280 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
281 | + foreach ($dtts_to_delete as $id) { |
|
282 | + $id = absint($id); |
|
283 | + if (empty($id)) |
|
284 | 284 | continue; |
285 | 285 | |
286 | 286 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
287 | 287 | |
288 | 288 | //remove tkt relationships. |
289 | 289 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
290 | - foreach ( $related_tickets as $tkt ) { |
|
290 | + foreach ($related_tickets as $tkt) { |
|
291 | 291 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
292 | 292 | } |
293 | 293 | |
294 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
294 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
295 | 295 | $dtt_to_remove->refresh_cache_of_related_objects(); |
296 | 296 | |
297 | 297 | } |
@@ -312,86 +312,86 @@ discard block |
||
312 | 312 | * @param array $data incoming request data |
313 | 313 | * @return EE_Ticket[] |
314 | 314 | */ |
315 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
315 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
316 | 316 | |
317 | 317 | $new_tkt = null; |
318 | 318 | $new_default = null; |
319 | 319 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
320 | 320 | $data = stripslashes_deep($data); |
321 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
321 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
322 | 322 | $saved_tickets = $dtts_on_existing = array(); |
323 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
323 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
324 | 324 | |
325 | 325 | //load money helper |
326 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
326 | + EE_Registry::instance()->load_helper('Money'); |
|
327 | 327 | |
328 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
328 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
329 | 329 | |
330 | 330 | $update_prices = $create_new_TKT = FALSE; |
331 | 331 | |
332 | 332 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
333 | 333 | |
334 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
335 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
334 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
335 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
336 | 336 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
337 | 337 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
338 | 338 | |
339 | 339 | // trim inputs to ensure any excess whitespace is removed. |
340 | 340 | $tkt = array_map( |
341 | - function( $ticket_data ) { |
|
342 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
341 | + function($ticket_data) { |
|
342 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
343 | 343 | }, |
344 | 344 | $tkt |
345 | 345 | ); |
346 | 346 | |
347 | 347 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
348 | 348 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
349 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
349 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
350 | 350 | |
351 | 351 | //note incoming base price needs converted from localized value. |
352 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
352 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
353 | 353 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
354 | 354 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
355 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
355 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
356 | 356 | |
357 | 357 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
358 | 358 | |
359 | 359 | $now = null; |
360 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
360 | + if (empty($tkt['TKT_start_date'])) { |
|
361 | 361 | //lets' use now in the set timezone. |
362 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
363 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
362 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
363 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_end_date'])) { |
|
367 | 367 | /** |
368 | 368 | * set the TKT_end_date to the first datetime attached to the ticket. |
369 | 369 | */ |
370 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
371 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
370 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
371 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $TKT_values = array( |
375 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
376 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
377 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
378 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
375 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
376 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
377 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
378 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
379 | 379 | 'TKT_start_date' => $tkt['TKT_start_date'], |
380 | 380 | 'TKT_end_date' => $tkt['TKT_end_date'], |
381 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
382 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
384 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
381 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
382 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
384 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
385 | 385 | 'TKT_row' => $row, |
386 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
387 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
388 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
386 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
387 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
388 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
389 | 389 | 'TKT_price' => $ticket_price |
390 | 390 | ); |
391 | 391 | |
392 | 392 | |
393 | 393 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
394 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
394 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
395 | 395 | $TKT_values['TKT_ID'] = 0; |
396 | 396 | $TKT_values['TKT_is_default'] = 0; |
397 | 397 | $update_prices = TRUE; |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | // but DID have it's items modified. |
404 | 404 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
405 | 405 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
406 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
407 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
408 | - if ( $TKT instanceof EE_Ticket ) { |
|
406 | + if (absint($TKT_values['TKT_ID'])) { |
|
407 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
408 | + if ($TKT instanceof EE_Ticket) { |
|
409 | 409 | |
410 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
410 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
411 | 411 | // are there any registrations using this ticket ? |
412 | 412 | $tickets_sold = $TKT->count_related( |
413 | 413 | 'Registration', |
414 | - array( array( |
|
415 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
416 | - ) ) |
|
414 | + array(array( |
|
415 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
416 | + )) |
|
417 | 417 | ); |
418 | 418 | //set ticket formats |
419 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
420 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
419 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
420 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
421 | 421 | |
422 | 422 | // let's just check the total price for the existing ticket |
423 | 423 | // and determine if it matches the new total price. |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | ? TRUE : FALSE; |
428 | 428 | |
429 | 429 | //set new values |
430 | - foreach ( $TKT_values as $field => $value ) { |
|
431 | - if ( $field === 'TKT_qty' ) { |
|
432 | - $TKT->set_qty( $value ); |
|
430 | + foreach ($TKT_values as $field => $value) { |
|
431 | + if ($field === 'TKT_qty') { |
|
432 | + $TKT->set_qty($value); |
|
433 | 433 | } else { |
434 | - $TKT->set( $field, $value ); |
|
434 | + $TKT->set($field, $value); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
439 | - if ( $create_new_TKT ) { |
|
440 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
439 | + if ($create_new_TKT) { |
|
440 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $TKT = EE_Ticket::new_instance( |
447 | 447 | $TKT_values, |
448 | 448 | $timezone, |
449 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
449 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
450 | 450 | ); |
451 | - if ( $TKT instanceof EE_Ticket ) { |
|
451 | + if ($TKT instanceof EE_Ticket) { |
|
452 | 452 | // make sure ticket has an ID of setting relations won't work |
453 | 453 | $TKT->save(); |
454 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
454 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
455 | 455 | $update_prices = TRUE; |
456 | 456 | } |
457 | 457 | } |
@@ -459,38 +459,38 @@ discard block |
||
459 | 459 | //$TKT->save(); |
460 | 460 | |
461 | 461 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
462 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
463 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
462 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
463 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
464 | 464 | EE_Registry::instance()->load_helper('DTT_Helper'); |
465 | 465 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
466 | 466 | } |
467 | 467 | |
468 | 468 | //let's make sure the base price is handled |
469 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
469 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
470 | 470 | |
471 | 471 | //add/update price_modifiers |
472 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
472 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
473 | 473 | |
474 | 474 | //need to make sue that the TKT_price is accurate after saving the prices. |
475 | 475 | $TKT->ensure_TKT_Price_correct(); |
476 | 476 | |
477 | 477 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
478 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
479 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
478 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
479 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
480 | 480 | $update_prices = TRUE; |
481 | 481 | $new_default = clone $TKT; |
482 | - $new_default->set( 'TKT_ID', 0 ); |
|
483 | - $new_default->set( 'TKT_is_default', 1 ); |
|
484 | - $new_default->set( 'TKT_row', 1 ); |
|
485 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
482 | + $new_default->set('TKT_ID', 0); |
|
483 | + $new_default->set('TKT_is_default', 1); |
|
484 | + $new_default->set('TKT_row', 1); |
|
485 | + $new_default->set('TKT_price', $ticket_price); |
|
486 | 486 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
487 | 487 | $new_default->_remove_relations('Datetime'); |
488 | 488 | //todo we need to add the current attached prices as new prices to the new default ticket. |
489 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
489 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
490 | 490 | //don't forget the base price! |
491 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
491 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
492 | 492 | $new_default->save(); |
493 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
493 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | //let's assign any tickets that have been setup to the saved_tickets tracker |
502 | 502 | //save existing TKT |
503 | 503 | $TKT->save(); |
504 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
504 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
505 | 505 | //save new TKT |
506 | 506 | $new_tkt->save(); |
507 | 507 | //add new ticket to array |
508 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
508 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
509 | 509 | |
510 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
510 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
511 | 511 | |
512 | 512 | } else { |
513 | 513 | //add tkt to saved tkts |
514 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
514 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
515 | 515 | |
516 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
516 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | } |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
524 | 524 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
525 | 525 | // No sense in keeping all the related data in the db! |
526 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
526 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
528 | 528 | |
529 | - foreach ( $tickets_removed as $id ) { |
|
530 | - $id = absint( $id ); |
|
529 | + foreach ($tickets_removed as $id) { |
|
530 | + $id = absint($id); |
|
531 | 531 | |
532 | 532 | //get the ticket for this id |
533 | 533 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
534 | 534 | |
535 | 535 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
536 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
536 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
537 | 537 | continue; |
538 | 538 | |
539 | 539 | // if this tkt has any registrations attached so then we just ARCHIVE |
540 | 540 | // because we don't actually permanently delete these tickets. |
541 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
541 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
542 | 542 | $tkt_to_remove->delete(); |
543 | 543 | continue; |
544 | 544 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
548 | 548 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
549 | 549 | |
550 | - foreach( $dtts as $dtt ) { |
|
550 | + foreach ($dtts as $dtt) { |
|
551 | 551 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
552 | 552 | } |
553 | 553 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
556 | 556 | $tkt_to_remove->delete_related_permanently('Price'); |
557 | 557 | |
558 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
558 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
559 | 559 | |
560 | 560 | // finally let's delete this ticket |
561 | 561 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -587,39 +587,39 @@ discard block |
||
587 | 587 | // and removing the ticket from datetimes it got removed from. |
588 | 588 | |
589 | 589 | // first let's add datetimes |
590 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
591 | - foreach ( $added_datetimes as $row_id ) { |
|
592 | - $row_id = (int)$row_id; |
|
593 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
594 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
590 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
591 | + foreach ($added_datetimes as $row_id) { |
|
592 | + $row_id = (int) $row_id; |
|
593 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
594 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
595 | 595 | // Is this an existing ticket (has an ID) and does it have any sold? |
596 | 596 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
597 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
598 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
599 | - $saved_datetimes[ $row_id ]->save(); |
|
597 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
598 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
599 | + $saved_datetimes[$row_id]->save(); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
604 | 604 | // then remove datetimes |
605 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
606 | - foreach ( $removed_datetimes as $row_id ) { |
|
607 | - $row_id = (int)$row_id; |
|
605 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
606 | + foreach ($removed_datetimes as $row_id) { |
|
607 | + $row_id = (int) $row_id; |
|
608 | 608 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
609 | 609 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
610 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
611 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
610 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
611 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
612 | 612 | // Is this an existing ticket (has an ID) and does it have any sold? |
613 | 613 | // If so, then we need to remove it's sold from the DTT_sold. |
614 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
615 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
616 | - $saved_datetimes[ $row_id ]->save(); |
|
614 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
615 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
616 | + $saved_datetimes[$row_id]->save(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | // cap ticket qty by datetime reg limits |
622 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
622 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
623 | 623 | return $ticket; |
624 | 624 | } |
625 | 625 | |
@@ -640,39 +640,39 @@ discard block |
||
640 | 640 | EE_Ticket $ticket, |
641 | 641 | $price_rows = array(), |
642 | 642 | $ticket_price = 0, |
643 | - $base_price = 0 , |
|
643 | + $base_price = 0, |
|
644 | 644 | $base_price_id = 0 |
645 | 645 | ) { |
646 | 646 | |
647 | 647 | // create new ticket that's a copy of the existing |
648 | 648 | // except a new id of course (and not archived) |
649 | 649 | // AND has the new TKT_price associated with it. |
650 | - $new_ticket = clone( $ticket ); |
|
651 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
652 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
653 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
654 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
650 | + $new_ticket = clone($ticket); |
|
651 | + $new_ticket->set('TKT_ID', 0); |
|
652 | + $new_ticket->set('TKT_deleted', 0); |
|
653 | + $new_ticket->set('TKT_price', $ticket_price); |
|
654 | + $new_ticket->set('TKT_sold', 0); |
|
655 | 655 | // let's get a new ID for this ticket |
656 | 656 | $new_ticket->save(); |
657 | 657 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
658 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
658 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
659 | 659 | $new_ticket = $this->_update_ticket_datetimes( |
660 | 660 | $new_ticket, |
661 | 661 | $datetimes_on_existing, |
662 | - array_keys( $datetimes_on_existing ) |
|
662 | + array_keys($datetimes_on_existing) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
666 | 666 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
667 | 667 | // available. |
668 | - if ( $ticket->sold() > 0 ) { |
|
668 | + if ($ticket->sold() > 0) { |
|
669 | 669 | $new_qty = $ticket->qty() - $ticket->sold(); |
670 | - $new_ticket->set_qty( $new_qty ); |
|
670 | + $new_ticket->set_qty($new_qty); |
|
671 | 671 | } |
672 | 672 | //now we update the prices just for this ticket |
673 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
673 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
674 | 674 | //and we update the base price |
675 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
675 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
676 | 676 | return $new_ticket; |
677 | 677 | } |
678 | 678 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
693 | 693 | * @return EE_Ticket |
694 | 694 | */ |
695 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
695 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
696 | 696 | |
697 | 697 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
698 | 698 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $updated_prices = array(); |
701 | 701 | |
702 | 702 | // if $base_price ! FALSE then updating a base price. |
703 | - if ( $base_price !== FALSE ) { |
|
703 | + if ($base_price !== FALSE) { |
|
704 | 704 | $prices[1] = array( |
705 | 705 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
706 | 706 | 'PRT_ID' => 1, |
@@ -711,47 +711,47 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | //possibly need to save tkt |
714 | - if ( ! $ticket->ID() ) |
|
714 | + if ( ! $ticket->ID()) |
|
715 | 715 | $ticket->save(); |
716 | 716 | |
717 | - foreach ( $prices as $row => $prc ) { |
|
718 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
719 | - if ( empty($prt_id) ) |
|
717 | + foreach ($prices as $row => $prc) { |
|
718 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
719 | + if (empty($prt_id)) |
|
720 | 720 | continue; //prices MUST have a price type id. |
721 | 721 | $PRC_values = array( |
722 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
722 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
723 | 723 | 'PRT_ID' => $prt_id, |
724 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
725 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
726 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
724 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
725 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
726 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
727 | 727 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
728 | 728 | 'PRC_order' => $row |
729 | 729 | ); |
730 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
730 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
731 | 731 | $PRC_values['PRC_ID'] = 0; |
732 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
732 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
733 | 733 | } else { |
734 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
734 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
735 | 735 | //update this price with new values |
736 | - foreach ( $PRC_values as $field => $newprc ) { |
|
737 | - $PRC->set( $field, $newprc ); |
|
736 | + foreach ($PRC_values as $field => $newprc) { |
|
737 | + $PRC->set($field, $newprc); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | $PRC->save(); |
741 | 741 | $prcid = $PRC->ID(); |
742 | 742 | $updated_prices[$prcid] = $PRC; |
743 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
743 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | //now let's remove any prices that got removed from the ticket |
747 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
747 | + if ( ! empty ($current_prices_on_ticket)) { |
|
748 | 748 | $current = array_keys($current_prices_on_ticket); |
749 | 749 | $updated = array_keys($updated_prices); |
750 | 750 | $prices_to_remove = array_diff($current, $updated); |
751 | - if ( !empty( $prices_to_remove ) ) { |
|
752 | - foreach ( $prices_to_remove as $prc_id ) { |
|
751 | + if ( ! empty($prices_to_remove)) { |
|
752 | + foreach ($prices_to_remove as $prc_id) { |
|
753 | 753 | $p = $current_prices_on_ticket[$prc_id]; |
754 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
754 | + $ticket->_remove_relation_to($p, 'Price'); |
|
755 | 755 | |
756 | 756 | //delete permanently the price |
757 | 757 | $p->delete_permanently(); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | - public function autosave_handling( $event_admin_obj ) { |
|
767 | + public function autosave_handling($event_admin_obj) { |
|
768 | 768 | return $event_admin_obj; //doing nothing for the moment. |
769 | 769 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
770 | 770 | |
@@ -798,12 +798,12 @@ discard block |
||
798 | 798 | |
799 | 799 | //default main template args |
800 | 800 | $main_template_args = array( |
801 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
801 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
802 | 802 | 'existing_datetime_ids' => '', |
803 | 803 | 'total_dtt_rows' => 1, |
804 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
804 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
805 | 805 | 'datetime_rows' => '', |
806 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
806 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
807 | 807 | 'ticket_rows' => '', |
808 | 808 | 'existing_ticket_ids' => '', |
809 | 809 | 'total_ticket_rows' => 1, |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
815 | 815 | |
816 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
816 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * 1. Start with retrieving Datetimes |
@@ -821,37 +821,37 @@ discard block |
||
821 | 821 | * 3. For each ticket get related prices |
822 | 822 | */ |
823 | 823 | |
824 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
825 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
824 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
825 | + $times = $DTM->get_all_event_dates($evtID); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | |
829 | 829 | $main_template_args['total_dtt_rows'] = count($times); |
830 | - foreach ( $times as $time ) { |
|
830 | + foreach ($times as $time) { |
|
831 | 831 | $dttid = $time->get('DTT_ID'); |
832 | 832 | $dttrow = $time->get('DTT_order'); |
833 | 833 | $existing_datetime_ids[] = $dttid; |
834 | 834 | |
835 | 835 | //tickets attached |
836 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
836 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
837 | 837 | |
838 | 838 | //if there are no related tickets this is likely a new event OR autodraft |
839 | 839 | // event so we need to generate the default tickets because dtts |
840 | 840 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
841 | 841 | // datetime on the event. |
842 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
842 | + if (empty ($related_tickets) && count($times) < 2) { |
|
843 | 843 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
844 | 844 | |
845 | 845 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
846 | 846 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
847 | 847 | |
848 | - $main_default_ticket = reset( $related_tickets ); |
|
849 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
850 | - foreach ( $default_prices as $default_price ) { |
|
851 | - if ( $default_price->is_base_price() ) { |
|
848 | + $main_default_ticket = reset($related_tickets); |
|
849 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
850 | + foreach ($default_prices as $default_price) { |
|
851 | + if ($default_price->is_base_price()) { |
|
852 | 852 | continue; |
853 | 853 | } |
854 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
854 | + $main_default_ticket->cache('Price', $default_price); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -860,11 +860,11 @@ discard block |
||
860 | 860 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
861 | 861 | |
862 | 862 | //loop through and setup the ticket rows and make sure the order is set. |
863 | - foreach ( $related_tickets as $ticket ) { |
|
863 | + foreach ($related_tickets as $ticket) { |
|
864 | 864 | $tktid = $ticket->get('TKT_ID'); |
865 | 865 | $tktrow = $ticket->get('TKT_row'); |
866 | 866 | //we only want unique tickets in our final display!! |
867 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
867 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
868 | 868 | $existing_ticket_ids[] = $tktid; |
869 | 869 | $all_tickets[] = $ticket; |
870 | 870 | } |
@@ -873,56 +873,56 @@ discard block |
||
873 | 873 | $datetime_tickets[$dttid][] = $tktrow; |
874 | 874 | |
875 | 875 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
876 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
876 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
877 | 877 | $ticket_datetimes[$tktid][] = $dttrow; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
881 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
882 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
883 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
881 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
882 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
883 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
884 | 884 | |
885 | 885 | //sort $all_tickets by order |
886 | - usort( $all_tickets, function( $a, $b ) { |
|
886 | + usort($all_tickets, function($a, $b) { |
|
887 | 887 | $a_order = (int) $a->get('TKT_order'); |
888 | 888 | $b_order = (int) $b->get('TKT_order'); |
889 | - if ( $a_order == $b_order ) { |
|
889 | + if ($a_order == $b_order) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
892 | + return ($a_order < $b_order) ? -1 : 1; |
|
893 | 893 | }); |
894 | 894 | |
895 | 895 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
896 | 896 | $dttrow = 1; |
897 | - foreach ( $times as $time ) { |
|
898 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
897 | + foreach ($times as $time) { |
|
898 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
899 | 899 | $dttrow++; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //then loop through all tickets for the ticket rows. |
903 | 903 | $tktrow = 1; |
904 | - foreach ( $all_tickets as $ticket ) { |
|
905 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
904 | + foreach ($all_tickets as $ticket) { |
|
905 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
906 | 906 | $tktrow++; |
907 | 907 | } |
908 | 908 | |
909 | 909 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
910 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
911 | - EEH_Template::display_template( $template, $main_template_args ); |
|
910 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
911 | + EEH_Template::display_template($template, $main_template_args); |
|
912 | 912 | return; |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
917 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
918 | 918 | |
919 | 919 | $dtt_display_template_args = array( |
920 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
921 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
920 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
921 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
922 | 922 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
923 | 923 | ); |
924 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
924 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string Generated edit row. |
942 | 942 | */ |
943 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
943 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
944 | 944 | |
945 | 945 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
946 | 946 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | $template_args = array( |
949 | 949 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
950 | 950 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
951 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
951 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
952 | 952 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
953 | 953 | 'DTT_name' => $default ? '' : $dtt->name(), |
954 | 954 | 'DTT_description' => $default ? '' : $dtt->description(), |
955 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
956 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
957 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
955 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
956 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
957 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
958 | 958 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
960 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
960 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
962 | 962 | ); |
963 | 963 | |
964 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
964 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
965 | 965 | |
966 | 966 | //allow filtering of template args at this point. |
967 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
967 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
968 | 968 | |
969 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
970 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
969 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
970 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
974 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
974 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
975 | 975 | |
976 | 976 | $template_args = array( |
977 | 977 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -979,47 +979,47 @@ discard block |
||
979 | 979 | 'DTT_description' => $default ? '' : $dtt->description(), |
980 | 980 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
981 | 981 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
982 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
982 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
983 | 983 | 'DTT_ID' => $default ? '' : $dtt->ID() |
984 | 984 | ); |
985 | 985 | |
986 | 986 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
987 | - if ( !$default ) { |
|
987 | + if ( ! $default) { |
|
988 | 988 | $tktrow = 1; |
989 | - foreach ( $all_tickets as $ticket ) { |
|
990 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
989 | + foreach ($all_tickets as $ticket) { |
|
990 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
991 | 991 | $tktrow++; |
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | //filter template args at this point |
996 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
996 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
997 | 997 | |
998 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
998 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1005 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1006 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1004 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1005 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1006 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1007 | 1007 | |
1008 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1008 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1009 | 1009 | $template_args = array( |
1010 | 1010 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1011 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1011 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1012 | 1012 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1013 | 1013 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1014 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1014 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1016 | 1016 | ); |
1017 | 1017 | |
1018 | 1018 | //filter template args |
1019 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1019 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1020 | 1020 | |
1021 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1021 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1041,37 +1041,37 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return [type] [description] |
1043 | 1043 | */ |
1044 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1044 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1045 | 1045 | |
1046 | 1046 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1047 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1047 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1048 | 1048 | |
1049 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1049 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1050 | 1050 | |
1051 | 1051 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1052 | 1052 | //the object. This is done by not including any query_params. |
1053 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1054 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1053 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1054 | + $prices = $ticket->get_many_related('Price'); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1058 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1058 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1059 | 1059 | |
1060 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1060 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1061 | 1061 | |
1062 | 1062 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1063 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1063 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1064 | 1064 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1065 | 1065 | |
1066 | 1066 | //breaking out complicated condition for ticket_status |
1067 | - if ( $default ) { |
|
1068 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1067 | + if ($default) { |
|
1068 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1069 | 1069 | } else { |
1070 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1070 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //breaking out complicated condition for TKT_taxable |
1074 | - if ( $default ) { |
|
1074 | + if ($default) { |
|
1075 | 1075 | $TKT_taxable = ''; |
1076 | 1076 | } else { |
1077 | 1077 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1086,19 +1086,19 @@ discard block |
||
1086 | 1086 | 'edit_tkt_expanded' => '', |
1087 | 1087 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1088 | 1088 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1089 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1090 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1091 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1089 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1090 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1091 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1092 | 1092 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1093 | 1093 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1094 | 1094 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1095 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1096 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1097 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1098 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1099 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1095 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1096 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1097 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1098 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1099 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1100 | 1100 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1101 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1101 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1102 | 1102 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1103 | 1103 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1104 | 1104 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1107,99 +1107,99 @@ discard block |
||
1107 | 1107 | 'ticket_price_rows' => '', |
1108 | 1108 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1109 | 1109 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1110 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1111 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1110 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1111 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1112 | 1112 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1113 | 1113 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1114 | 1114 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1115 | 1115 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1116 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1116 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1117 | 1117 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1118 | 1118 | 'TKT_taxable' => $TKT_taxable, |
1119 | 1119 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1120 | 1120 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1121 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1121 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1122 | 1122 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1123 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1124 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1123 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1124 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1125 | 1125 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1126 | 1126 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1127 | 1127 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1130 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1131 | 1131 | |
1132 | 1132 | //handle rows that should NOT be empty |
1133 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1133 | + if (empty($template_args['TKT_start_date'])) { |
|
1134 | 1134 | //if empty then the start date will be now. |
1135 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1136 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1135 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1136 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1139 | + if (empty($template_args['TKT_end_date'])) { |
|
1140 | 1140 | |
1141 | 1141 | //get the earliest datetime (if present); |
1142 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1142 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1143 | 1143 | |
1144 | - if ( !empty( $earliest_dtt ) ) { |
|
1145 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1144 | + if ( ! empty($earliest_dtt)) { |
|
1145 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1146 | 1146 | } else { |
1147 | 1147 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1148 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1148 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1149 | 1149 | } |
1150 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //generate ticket_datetime items |
1154 | - if ( ! $default ) { |
|
1154 | + if ( ! $default) { |
|
1155 | 1155 | $dttrow = 1; |
1156 | - foreach ( $all_dtts as $dtt ) { |
|
1157 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1156 | + foreach ($all_dtts as $dtt) { |
|
1157 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1158 | 1158 | $dttrow++; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $prcrow = 1; |
1163 | - foreach ( $prices as $price ) { |
|
1164 | - if ( $price->is_base_price() ) { |
|
1163 | + foreach ($prices as $price) { |
|
1164 | + if ($price->is_base_price()) { |
|
1165 | 1165 | $prcrow++; |
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1169 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1170 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1168 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1169 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1170 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1171 | 1171 | $prcrow++; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | //filter $template_args |
1175 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1175 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1176 | 1176 | |
1177 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1177 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1185 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1186 | 1186 | $tax_rows = ''; |
1187 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1187 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1188 | 1188 | $template_args = array(); |
1189 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | - foreach ( $taxes as $tax ) { |
|
1191 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1189 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | + foreach ($taxes as $tax) { |
|
1191 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1192 | 1192 | $template_args = array( |
1193 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1193 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1194 | 1194 | 'tax_id' => $tax->ID(), |
1195 | 1195 | 'tkt_row' => $tktrow, |
1196 | 1196 | 'tax_label' => $tax->get('PRC_name'), |
1197 | 1197 | 'tax_added' => $tax_added, |
1198 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1198 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1199 | 1199 | 'tax_amount' => $tax->get('PRC_amount') |
1200 | 1200 | ); |
1201 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1202 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1201 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1202 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,81 +1207,81 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1211 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1210 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1211 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1212 | 1212 | return $subtotal * $tax->get('PRC_amount') / 100; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | |
1218 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1219 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1218 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1219 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1220 | 1220 | $template_args = array( |
1221 | 1221 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1222 | 1222 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1223 | 1223 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1224 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1224 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1225 | 1225 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1226 | 1226 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1227 | 1227 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1228 | 1228 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1229 | 1229 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1230 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1233 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1230 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1233 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1235 | 1235 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1236 | 1236 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1237 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1238 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1237 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1238 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1241 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1242 | 1242 | |
1243 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1243 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1249 | - if ( $price->is_base_price() ) { |
|
1250 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1248 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1249 | + if ($price->is_base_price()) { |
|
1250 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1251 | 1251 | } else { |
1252 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1252 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1258 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1259 | 1259 | $template_args = array( |
1260 | 1260 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1261 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1262 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1261 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1262 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1263 | 1263 | 'PRT_name' => __('Price', 'event_espresso'), |
1264 | 1264 | 'price_selected_operator' => '+', |
1265 | 1265 | 'price_selected_is_percent' => 0 |
1266 | 1266 | ); |
1267 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1267 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1268 | 1268 | |
1269 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1269 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1270 | 1270 | |
1271 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1271 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1277 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1278 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1279 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1281 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1276 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1277 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1278 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1279 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1281 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1282 | 1282 | $price_option_spans = ''; |
1283 | 1283 | //setup pricetypes for selector |
1284 | - foreach ( $price_types as $price_type ) { |
|
1284 | + foreach ($price_types as $price_type) { |
|
1285 | 1285 | $all_price_types[] = array( |
1286 | 1286 | 'id' => $price_type->ID(), |
1287 | 1287 | 'text' => $price_type->get('PRT_name'), |
@@ -1293,50 +1293,50 @@ discard block |
||
1293 | 1293 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1294 | 1294 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1295 | 1295 | ); |
1296 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1296 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1299 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1300 | 1300 | $main_name = $select_name; |
1301 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1301 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1302 | 1302 | |
1303 | 1303 | $template_args = array( |
1304 | 1304 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1305 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1306 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1305 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1306 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1307 | 1307 | 'main_name' => $main_name, |
1308 | 1308 | 'selected_price_type_id' => $selected_price_type_id, |
1309 | 1309 | 'price_option_spans' => $price_option_spans, |
1310 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1311 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1310 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1311 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1312 | 1312 | 'disabled' => $disabled |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1315 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1316 | 1316 | |
1317 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1317 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1318 | 1318 | |
1319 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1319 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | |
1324 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1325 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1326 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1324 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1325 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1326 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | 1328 | $template_args = array( |
1329 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1329 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1330 | 1330 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1331 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1332 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1333 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1331 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1332 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1333 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1334 | 1334 | 'tkt_status_class' => '', |
1335 | 1335 | ); |
1336 | 1336 | |
1337 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1338 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1337 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1338 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1344,53 +1344,53 @@ discard block |
||
1344 | 1344 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1345 | 1345 | $template_args = array( |
1346 | 1346 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1347 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1347 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1349 | 1349 | 'default_price_rows' => '', |
1350 | 1350 | 'default_base_price_amount' => 0, |
1351 | 1351 | 'default_base_price_name' => '', |
1352 | 1352 | 'default_base_price_description' => '', |
1353 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1354 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1353 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1354 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1355 | 1355 | 'existing_available_datetime_tickets_list' => '', |
1356 | 1356 | 'existing_available_ticket_datetimes_list' => '', |
1357 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1358 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1357 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1358 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | 1361 | $tktrow = 1; |
1362 | - foreach ( $all_tickets as $ticket ) { |
|
1363 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1362 | + foreach ($all_tickets as $ticket) { |
|
1363 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1364 | 1364 | $tktrow++; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | 1368 | $dttrow = 1; |
1369 | - foreach ( $all_dtts as $dtt ) { |
|
1370 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1369 | + foreach ($all_dtts as $dtt) { |
|
1370 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1371 | 1371 | $dttrow++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1375 | 1375 | $prcrow = 1; |
1376 | - foreach ( $default_prices as $price ) { |
|
1377 | - if ( $price->is_base_price() ) { |
|
1376 | + foreach ($default_prices as $price) { |
|
1377 | + if ($price->is_base_price()) { |
|
1378 | 1378 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1379 | 1379 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1380 | 1380 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1381 | 1381 | $prcrow++; |
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1385 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1386 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1384 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1385 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1386 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1387 | 1387 | $prcrow++; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1390 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1391 | 1391 | |
1392 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1392 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 |