@@ -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 Event Espresso |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EE_System |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage core/ |
|
20 | - * @author Brent Christensen, Michael Nelson |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Event Espresso |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EE_System |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage core/ |
|
20 | + * @author Brent Christensen, Michael Nelson |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | final class EE_System { |
25 | 25 | |
26 | 26 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | |
207 | 207 | |
208 | 208 | /** |
209 | - * detect_if_activation_or_upgrade |
|
210 | - * |
|
211 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
212 | - * and either setting up the DB or setting up maintenance mode etc. |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @return void |
|
216 | - */ |
|
209 | + * detect_if_activation_or_upgrade |
|
210 | + * |
|
211 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
212 | + * and either setting up the DB or setting up maintenance mode etc. |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @return void |
|
216 | + */ |
|
217 | 217 | public function detect_if_activation_or_upgrade() { |
218 | 218 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
219 | 219 | |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | $query_params = array( 'page' => 'espresso_about' ); |
518 | 518 | |
519 | 519 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
520 | - $query_params['new_activation'] = TRUE; |
|
520 | + $query_params['new_activation'] = TRUE; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
524 | - $query_params['reactivation'] = TRUE; |
|
524 | + $query_params['reactivation'] = TRUE; |
|
525 | 525 | } |
526 | 526 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
527 | 527 | wp_safe_redirect( $url ); |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | |
625 | 625 | |
626 | 626 | /** |
627 | - * _incompatible_addon_error |
|
628 | - * |
|
629 | - * @access public |
|
630 | - * @return void |
|
631 | - */ |
|
627 | + * _incompatible_addon_error |
|
628 | + * |
|
629 | + * @access public |
|
630 | + * @return void |
|
631 | + */ |
|
632 | 632 | private function _incompatible_addon_error() { |
633 | 633 | // get array of classes hooking into here |
634 | 634 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | |
751 | 751 | |
752 | 752 | /** |
753 | - * load_controllers |
|
754 | - * |
|
755 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
756 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
757 | - * |
|
758 | - * @access public |
|
759 | - * @return void |
|
760 | - */ |
|
753 | + * load_controllers |
|
754 | + * |
|
755 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
756 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
757 | + * |
|
758 | + * @access public |
|
759 | + * @return void |
|
760 | + */ |
|
761 | 761 | public function load_controllers() { |
762 | 762 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
763 | 763 | // let's get it started |
@@ -774,13 +774,13 @@ discard block |
||
774 | 774 | |
775 | 775 | |
776 | 776 | /** |
777 | - * core_loaded_and_ready |
|
778 | - * |
|
779 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
780 | - * |
|
781 | - * @access public |
|
782 | - * @return void |
|
783 | - */ |
|
777 | + * core_loaded_and_ready |
|
778 | + * |
|
779 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
780 | + * |
|
781 | + * @access public |
|
782 | + * @return void |
|
783 | + */ |
|
784 | 784 | public function core_loaded_and_ready() { |
785 | 785 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
786 | 786 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | |
792 | 792 | |
793 | 793 | /** |
794 | - * initialize |
|
795 | - * |
|
796 | - * this is the best place to begin initializing client code |
|
797 | - * |
|
798 | - * @access public |
|
799 | - * @return void |
|
800 | - */ |
|
794 | + * initialize |
|
795 | + * |
|
796 | + * this is the best place to begin initializing client code |
|
797 | + * |
|
798 | + * @access public |
|
799 | + * @return void |
|
800 | + */ |
|
801 | 801 | public function initialize() { |
802 | 802 | do_action( 'AHEE__EE_System__initialize' ); |
803 | 803 | } |
@@ -805,13 +805,13 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | /** |
808 | - * initialize_last |
|
809 | - * |
|
810 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
811 | - * |
|
812 | - * @access public |
|
813 | - * @return void |
|
814 | - */ |
|
808 | + * initialize_last |
|
809 | + * |
|
810 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
811 | + * |
|
812 | + * @access public |
|
813 | + * @return void |
|
814 | + */ |
|
815 | 815 | public function initialize_last() { |
816 | 816 | do_action( 'AHEE__EE_System__initialize_last' ); |
817 | 817 | } |
@@ -820,14 +820,14 @@ discard block |
||
820 | 820 | |
821 | 821 | |
822 | 822 | /** |
823 | - * set_hooks_for_shortcodes_modules_and_addons |
|
824 | - * |
|
825 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
826 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
827 | - * |
|
828 | - * @access public |
|
829 | - * @return void |
|
830 | - */ |
|
823 | + * set_hooks_for_shortcodes_modules_and_addons |
|
824 | + * |
|
825 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
826 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
827 | + * |
|
828 | + * @access public |
|
829 | + * @return void |
|
830 | + */ |
|
831 | 831 | public function set_hooks_for_shortcodes_modules_and_addons() { |
832 | 832 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
833 | 833 | } |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | |
837 | 837 | |
838 | 838 | /** |
839 | - * do_not_cache |
|
840 | - * |
|
841 | - * sets no cache headers and defines no cache constants for WP plugins |
|
842 | - * |
|
843 | - * @access public |
|
844 | - * @return void |
|
845 | - */ |
|
839 | + * do_not_cache |
|
840 | + * |
|
841 | + * sets no cache headers and defines no cache constants for WP plugins |
|
842 | + * |
|
843 | + * @access public |
|
844 | + * @return void |
|
845 | + */ |
|
846 | 846 | public static function do_not_cache() { |
847 | 847 | // set no cache constants |
848 | 848 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | //Current post |
962 | 962 | global $post; |
963 | 963 | |
964 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
964 | + if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
965 | 965 | //Events Edit Current Event |
966 | 966 | $admin_bar->add_menu(array( |
967 | 967 | 'id' => 'espresso-toolbar-events-edit', |
@@ -22,7 +22,6 @@ |
||
22 | 22 | /** |
23 | 23 | * Removes the checkin and checkout endpoints from the index for requests |
24 | 24 | * to api versions lowers than 4.8.33 |
25 | - * @param array $routes_on_this_version |
|
26 | 25 | * @param EventEspresso\core\libraries\rest_api\controllers\Base $controller |
27 | 26 | * @return array like $routes_on_this_version |
28 | 27 | */ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | //is for lower than 4.8.33 |
14 | 14 | add_filter( |
15 | 15 | 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
16 | - array( $this, 'remove_response_headers' ), |
|
16 | + array($this, 'remove_response_headers'), |
|
17 | 17 | 10, |
18 | 18 | 3 |
19 | 19 | ); |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @param EventEspresso\core\libraries\rest_api\controllers\Base $controller |
27 | 27 | * @return array like $routes_on_this_version |
28 | 28 | */ |
29 | - public function remove_response_headers( $response_headers, $controller, $requested_version ) { |
|
30 | - if( $controller instanceof Base |
|
31 | - && $this->applies_to_version( $requested_version ) ) { |
|
29 | + public function remove_response_headers($response_headers, $controller, $requested_version) { |
|
30 | + if ($controller instanceof Base |
|
31 | + && $this->applies_to_version($requested_version)) { |
|
32 | 32 | return array(); |
33 | 33 | } |
34 | 34 | return $response_headers; |
@@ -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 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table { |
33 | 33 | |
34 | - public function __construct( $admin_page ) { |
|
34 | + public function __construct($admin_page) { |
|
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
37 | 37 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _setup_data() { |
42 | - $this->_data = $this->_admin_page->get_categories( $this->_per_page, $this->_current_page); |
|
43 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( array( array( 'taxonomy' => 'espresso_event_categories' ) ) ); |
|
42 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
43 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count(array(array('taxonomy' => 'espresso_event_categories'))); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | protected function _set_properties() { |
51 | 51 | $this->_wp_list_args = array( |
52 | - 'singular' => __('event category', 'event_espresso' ), |
|
53 | - 'plural' => __('event categories', 'event_espresso' ), |
|
52 | + 'singular' => __('event category', 'event_espresso'), |
|
53 | + 'plural' => __('event categories', 'event_espresso'), |
|
54 | 54 | 'ajax' => TRUE, //for now, |
55 | 55 | 'screen' => $this->_admin_page->get_current_screen()->id |
56 | 56 | ); |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | $this->_sortable_columns = array( |
67 | - 'id' => array( 'Term.term_id' => true ), |
|
68 | - 'name' => array( 'Term.slug' => false ), |
|
69 | - 'count' => array( 'term_count' => false ) |
|
67 | + 'id' => array('Term.term_id' => true), |
|
68 | + 'name' => array('Term.slug' => false), |
|
69 | + 'count' => array('term_count' => false) |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $this->_primary_column = 'id'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | public function column_cb($item) { |
101 | - return sprintf( '<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id') ); |
|
101 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function column_id($item) { |
109 | 109 | $content = $item->get('term_id'); |
110 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get('name') . '</span>'; |
|
110 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get('name').'</span>'; |
|
111 | 111 | return $content; |
112 | 112 | } |
113 | 113 | |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | 'EVT_CAT_ID' => $item->get('term_id') |
128 | 128 | ); |
129 | 129 | |
130 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
131 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce( $delete_query_args, EVENTS_ADMIN_URL ); |
|
130 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
131 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
132 | 132 | |
133 | 133 | $actions = array( |
134 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Category', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>' |
|
134 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Category', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | |
138 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__('Delete Category', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>'; |
|
138 | + $actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__('Delete Category', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
139 | 139 | |
140 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get('name') . '</a></strong>'; |
|
140 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get('name').'</a></strong>'; |
|
141 | 141 | $content .= $this->row_actions($actions); |
142 | 142 | return $content; |
143 | 143 | } |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | public function column_shortcode($item) { |
149 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
149 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
150 | 150 | return $content; |
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - public function column_count( $item ) { |
|
156 | + public function column_count($item) { |
|
157 | 157 | $e_args = array( |
158 | 158 | 'action' => 'default', |
159 | 159 | 'EVT_CAT' => $item->get_first_related('Term')->ID() |
160 | 160 | ); |
161 | - $e_link = EE_Admin_Page::add_query_args_and_nonce( $e_args, EVENTS_ADMIN_URL ); |
|
162 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
161 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
162 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
163 | 163 | return $content; |
164 | 164 | } |
165 | 165 | } |
@@ -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 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //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. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //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. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //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. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //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. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,37 +1415,37 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = reset( $times ); |
|
1430 | + $first_datetime = reset($times); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime instanceof EE_Datetime |
|
1433 | - && $first_datetime->ID() !== 0 ) { |
|
1432 | + if ($first_datetime instanceof EE_Datetime |
|
1433 | + && $first_datetime->ID() !== 0) { |
|
1434 | 1434 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1435 | 1435 | $template_args['time'] = $first_datetime; |
1436 | 1436 | $related_tickets = $first_datetime->tickets( |
1437 | 1437 | array( |
1438 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1438 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1439 | 1439 | 'default_where_conditions' => 'none' |
1440 | 1440 | ) |
1441 | 1441 | ); |
1442 | 1442 | |
1443 | - if ( !empty($related_tickets) ) { |
|
1443 | + if ( ! empty($related_tickets)) { |
|
1444 | 1444 | $template_args['total_ticket_rows'] = count($related_tickets); |
1445 | 1445 | $row = 0; |
1446 | - foreach ( $related_tickets as $ticket ) { |
|
1446 | + foreach ($related_tickets as $ticket) { |
|
1447 | 1447 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1448 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1448 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1449 | 1449 | |
1450 | 1450 | $row++; |
1451 | 1451 | } |
@@ -1453,13 +1453,13 @@ discard block |
||
1453 | 1453 | $template_args['total_ticket_rows'] = 1; |
1454 | 1454 | /** @type EE_Ticket $ticket */ |
1455 | 1455 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1456 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1456 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1457 | 1457 | } |
1458 | 1458 | } else { |
1459 | 1459 | $template_args['time'] = $times[0]; |
1460 | 1460 | /** @type EE_Ticket $ticket */ |
1461 | 1461 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1462 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1462 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1463 | 1463 | // NOTE: we're just sending the first default row |
1464 | 1464 | // (decaf can't manage default tickets so this should be sufficient); |
1465 | 1465 | } |
@@ -1468,8 +1468,8 @@ discard block |
||
1468 | 1468 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1469 | 1469 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1470 | 1470 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1471 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1472 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1471 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1472 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1473 | 1473 | EEH_Template::display_template($template, $template_args); |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1484,21 +1484,21 @@ discard block |
||
1484 | 1484 | * @param int $row |
1485 | 1485 | * @return string generated html for the ticket row. |
1486 | 1486 | */ |
1487 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1487 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1488 | 1488 | $template_args = array( |
1489 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1490 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1489 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1490 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1491 | 1491 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1492 | 1492 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1493 | 1493 | 'TKT_name' => $ticket->get('TKT_name'), |
1494 | 1494 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1495 | 1495 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1496 | 1496 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1497 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1497 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1498 | 1498 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1499 | 1499 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1500 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1500 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1502 | 1502 | ); |
1503 | 1503 | |
1504 | 1504 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1514,23 +1514,23 @@ discard block |
||
1514 | 1514 | |
1515 | 1515 | //make sure we have default start and end dates if skeleton |
1516 | 1516 | //handle rows that should NOT be empty |
1517 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1517 | + if (empty($template_args['TKT_start_date'])) { |
|
1518 | 1518 | //if empty then the start date will be now. |
1519 | 1519 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1520 | 1520 | } |
1521 | 1521 | |
1522 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1522 | + if (empty($template_args['TKT_end_date'])) { |
|
1523 | 1523 | //get the earliest datetime (if present); |
1524 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1524 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1525 | 1525 | |
1526 | - if ( !empty( $earliest_dtt ) ) |
|
1526 | + if ( ! empty($earliest_dtt)) |
|
1527 | 1527 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1528 | 1528 | else |
1529 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1529 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $template_args = array_merge( $template_args, $price_args ); |
|
1533 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1532 | + $template_args = array_merge($template_args, $price_args); |
|
1533 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1534 | 1534 | return EEH_Template::display_template($template, $template_args, TRUE); |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1559,8 +1559,8 @@ discard block |
||
1559 | 1559 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1560 | 1560 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1561 | 1561 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1562 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1563 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1562 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1563 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1564 | 1564 | EEH_Template::display_template($templatepath, $template_args); |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1588,21 +1588,21 @@ discard block |
||
1588 | 1588 | $EEME = $this->_event_model(); |
1589 | 1589 | |
1590 | 1590 | $offset = ($current_page - 1) * $per_page; |
1591 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1591 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1592 | 1592 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1593 | 1593 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1594 | 1594 | |
1595 | 1595 | if (isset($this->_req_data['month_range'])) { |
1596 | 1596 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1597 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1597 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | $where = array(); |
1602 | 1602 | |
1603 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1603 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1604 | 1604 | //determine what post_status our condition will have for the query. |
1605 | - switch ( $status ) { |
|
1605 | + switch ($status) { |
|
1606 | 1606 | case 'month' : |
1607 | 1607 | case 'today' : |
1608 | 1608 | case NULL : |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | break; |
1611 | 1611 | |
1612 | 1612 | case 'draft' : |
1613 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1613 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1614 | 1614 | break; |
1615 | 1615 | |
1616 | 1616 | default : |
@@ -1618,43 +1618,43 @@ discard block |
||
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | //categories? |
1621 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1621 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1622 | 1622 | |
1623 | - if ( !empty ( $category ) ) { |
|
1623 | + if ( ! empty ($category)) { |
|
1624 | 1624 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1625 | 1625 | $where['Term_Taxonomy.term_id'] = $category; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | //date where conditions |
1629 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1629 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1630 | 1630 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1631 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1632 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1633 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1634 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1631 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1632 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1633 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1634 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1635 | 1635 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1636 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1637 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1638 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1639 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1640 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1641 | - $now = date( 'Y-m-01' ); |
|
1642 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1643 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1644 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1645 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1636 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1637 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1638 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1639 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1640 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1641 | + $now = date('Y-m-01'); |
|
1642 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1643 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1644 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1645 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | |
1649 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1650 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1649 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1650 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1651 | 1651 | } else { |
1652 | - if ( ! isset( $where['status'] ) ) { |
|
1653 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1652 | + if ( ! isset($where['status'])) { |
|
1653 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1654 | 1654 | $where['OR'] = array( |
1655 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1655 | + 'status*restrict_private' => array('!=', 'private'), |
|
1656 | 1656 | 'AND' => array( |
1657 | - 'status*inclusive' => array( '=', 'private' ), |
|
1657 | + 'status*inclusive' => array('=', 'private'), |
|
1658 | 1658 | 'EVT_wp_user' => get_current_user_id() |
1659 | 1659 | ) |
1660 | 1660 | ); |
@@ -1662,16 +1662,16 @@ discard block |
||
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | |
1665 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1666 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1665 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1666 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1667 | 1667 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1668 | 1668 | } |
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | |
1672 | 1672 | //search query handling |
1673 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1674 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1673 | + if (isset($this->_req_data['s'])) { |
|
1674 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1675 | 1675 | $where['OR'] = array( |
1676 | 1676 | 'EVT_name' => array('LIKE', $search_string), |
1677 | 1677 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1680,32 +1680,32 @@ discard block |
||
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
1683 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1684 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1683 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1684 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1685 | 1685 | |
1686 | 1686 | |
1687 | 1687 | //let's first check if we have special requests coming in. |
1688 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1689 | - switch ( $this->_req_data['active_status'] ) { |
|
1688 | + if (isset($this->_req_data['active_status'])) { |
|
1689 | + switch ($this->_req_data['active_status']) { |
|
1690 | 1690 | case 'upcoming' : |
1691 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1691 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1692 | 1692 | break; |
1693 | 1693 | |
1694 | 1694 | case 'expired' : |
1695 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1695 | + return $EEME->get_expired_events($query_params, $count); |
|
1696 | 1696 | break; |
1697 | 1697 | |
1698 | 1698 | case 'active' : |
1699 | - return $EEME->get_active_events( $query_params, $count ); |
|
1699 | + return $EEME->get_active_events($query_params, $count); |
|
1700 | 1700 | break; |
1701 | 1701 | |
1702 | 1702 | case 'inactive' : |
1703 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1703 | + return $EEME->get_inactive_events($query_params, $count); |
|
1704 | 1704 | break; |
1705 | 1705 | } |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1708 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1709 | 1709 | |
1710 | 1710 | return $events; |
1711 | 1711 | } |
@@ -1714,23 +1714,23 @@ discard block |
||
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | //handling for WordPress CPT actions (trash, restore, delete) |
1717 | - public function trash_cpt_item( $post_id ) { |
|
1717 | + public function trash_cpt_item($post_id) { |
|
1718 | 1718 | $this->_req_data['EVT_ID'] = $post_id; |
1719 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1719 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | |
1723 | 1723 | |
1724 | 1724 | |
1725 | - public function restore_cpt_item( $post_id ) { |
|
1725 | + public function restore_cpt_item($post_id) { |
|
1726 | 1726 | $this->_req_data['EVT_ID'] = $post_id; |
1727 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1727 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | |
1731 | - public function delete_cpt_item( $post_id ) { |
|
1731 | + public function delete_cpt_item($post_id) { |
|
1732 | 1732 | $this->_req_data['EVT_ID'] = $post_id; |
1733 | - $this->_delete_event( FALSE ); |
|
1733 | + $this->_delete_event(FALSE); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | * @param string $event_status |
1743 | 1743 | * @return void |
1744 | 1744 | */ |
1745 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1745 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1746 | 1746 | //determine the event id and set to array. |
1747 | 1747 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1748 | 1748 | // loop thru events |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | // clean status |
1751 | 1751 | $event_status = sanitize_key($event_status); |
1752 | 1752 | // grab status |
1753 | - if (!empty($event_status)) { |
|
1753 | + if ( ! empty($event_status)) { |
|
1754 | 1754 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1755 | 1755 | } else { |
1756 | 1756 | $success = FALSE; |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | } |
1765 | 1765 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1766 | 1766 | |
1767 | - if ( $redirect_after ) |
|
1767 | + if ($redirect_after) |
|
1768 | 1768 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1769 | 1769 | } |
1770 | 1770 | |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | // clean status |
1780 | 1780 | $event_status = sanitize_key($event_status); |
1781 | 1781 | // grab status |
1782 | - if (!empty($event_status)) { |
|
1782 | + if ( ! empty($event_status)) { |
|
1783 | 1783 | $success = TRUE; |
1784 | 1784 | //determine the event id and set to array. |
1785 | 1785 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1814,15 +1814,15 @@ discard block |
||
1814 | 1814 | * @param string $event_status |
1815 | 1815 | * @return bool |
1816 | 1816 | */ |
1817 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1817 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1818 | 1818 | // grab event id |
1819 | - if (!$EVT_ID) { |
|
1819 | + if ( ! $EVT_ID) { |
|
1820 | 1820 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1821 | 1821 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1822 | 1822 | return FALSE; |
1823 | 1823 | } |
1824 | 1824 | |
1825 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1825 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1826 | 1826 | |
1827 | 1827 | // clean status |
1828 | 1828 | $event_status = sanitize_key($event_status); |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | $hook = FALSE; |
1849 | 1849 | } |
1850 | 1850 | //use class to change status |
1851 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1851 | + $this->_cpt_model_obj->set_status($event_status); |
|
1852 | 1852 | $success = $this->_cpt_model_obj->save(); |
1853 | 1853 | |
1854 | 1854 | if ($success === FALSE) { |
@@ -1870,15 +1870,15 @@ discard block |
||
1870 | 1870 | * @access protected |
1871 | 1871 | * @param bool $redirect_after |
1872 | 1872 | */ |
1873 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1873 | + protected function _delete_event($redirect_after = TRUE) { |
|
1874 | 1874 | //determine the event id and set to array. |
1875 | 1875 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1876 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1876 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1877 | 1877 | |
1878 | 1878 | |
1879 | 1879 | // loop thru events |
1880 | 1880 | if ($EVT_ID) { |
1881 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1881 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1882 | 1882 | // get list of events with no prices |
1883 | 1883 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1884 | 1884 | // remove this event from the list of events with no prices |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - if ( $redirect_after ) |
|
1895 | + if ($redirect_after) |
|
1896 | 1896 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1910,12 +1910,12 @@ discard block |
||
1910 | 1910 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1911 | 1911 | // loop thru events |
1912 | 1912 | foreach ($EVT_IDs as $EVT_ID) { |
1913 | - $EVT_ID = absint( $EVT_ID ); |
|
1914 | - if ( $EVT_ID ) { |
|
1915 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1913 | + $EVT_ID = absint($EVT_ID); |
|
1914 | + if ($EVT_ID) { |
|
1915 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1916 | 1916 | $success = $results !== FALSE ? $success : FALSE; |
1917 | 1917 | // remove this event from the list of events with no prices |
1918 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1918 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1919 | 1919 | } else { |
1920 | 1920 | $success = FALSE; |
1921 | 1921 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1935,21 +1935,21 @@ discard block |
||
1935 | 1935 | * @param int $EVT_ID |
1936 | 1936 | * @return bool |
1937 | 1937 | */ |
1938 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1938 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1939 | 1939 | // grab event id |
1940 | - if ( ! $EVT_ID ) { |
|
1940 | + if ( ! $EVT_ID) { |
|
1941 | 1941 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1942 | 1942 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1943 | 1943 | return FALSE; |
1944 | 1944 | } |
1945 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1945 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1946 | 1946 | |
1947 | 1947 | //need to delete related tickets and prices first. |
1948 | 1948 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1949 | - foreach ( $datetimes as $datetime ) { |
|
1949 | + foreach ($datetimes as $datetime) { |
|
1950 | 1950 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1951 | 1951 | $tickets = $datetime->get_many_related('Ticket'); |
1952 | - foreach ( $tickets as $ticket ) { |
|
1952 | + foreach ($tickets as $ticket) { |
|
1953 | 1953 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1954 | 1954 | $ticket->delete_related_permanently('Price'); |
1955 | 1955 | $ticket->delete_permanently(); |
@@ -1959,14 +1959,14 @@ discard block |
||
1959 | 1959 | |
1960 | 1960 | //what about related venues or terms? |
1961 | 1961 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1962 | - foreach ( $venues as $venue ) { |
|
1962 | + foreach ($venues as $venue) { |
|
1963 | 1963 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1964 | 1964 | } |
1965 | 1965 | |
1966 | 1966 | //any attached question groups? |
1967 | 1967 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1968 | - if ( !empty( $question_groups ) ) { |
|
1969 | - foreach ( $question_groups as $question_group ) { |
|
1968 | + if ( ! empty($question_groups)) { |
|
1969 | + foreach ($question_groups as $question_group) { |
|
1970 | 1970 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1971 | 1971 | } |
1972 | 1972 | } |
@@ -1975,12 +1975,12 @@ discard block |
||
1975 | 1975 | |
1976 | 1976 | |
1977 | 1977 | //Message Template Groups |
1978 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1978 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1979 | 1979 | |
1980 | 1980 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1981 | 1981 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1982 | 1982 | |
1983 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1983 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1984 | 1984 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1985 | 1985 | } |
1986 | 1986 | |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1995 | 1995 | return FALSE; |
1996 | 1996 | } |
1997 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
1997 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
1998 | 1998 | return TRUE; |
1999 | 1999 | } |
2000 | 2000 | |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | */ |
2012 | 2012 | public function total_events() { |
2013 | 2013 | |
2014 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2014 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2015 | 2015 | return $count; |
2016 | 2016 | } |
2017 | 2017 | |
@@ -2026,10 +2026,10 @@ discard block |
||
2026 | 2026 | */ |
2027 | 2027 | public function total_events_draft() { |
2028 | 2028 | $where = array( |
2029 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2029 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2030 | 2030 | ); |
2031 | 2031 | |
2032 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2032 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2033 | 2033 | return $count; |
2034 | 2034 | } |
2035 | 2035 | |
@@ -2048,7 +2048,7 @@ discard block |
||
2048 | 2048 | 'status' => 'trash' |
2049 | 2049 | ); |
2050 | 2050 | |
2051 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2051 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2052 | 2052 | return $count; |
2053 | 2053 | } |
2054 | 2054 | |
@@ -2076,11 +2076,11 @@ discard block |
||
2076 | 2076 | // translated |
2077 | 2077 | TRUE |
2078 | 2078 | ); |
2079 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2079 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2080 | 2080 | |
2081 | 2081 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2082 | 2082 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2083 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2083 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2084 | 2084 | $this->display_admin_page_with_sidebar(); |
2085 | 2085 | } |
2086 | 2086 | |
@@ -2106,9 +2106,9 @@ discard block |
||
2106 | 2106 | |
2107 | 2107 | protected function _template_settings() { |
2108 | 2108 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2109 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2110 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2111 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2109 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2110 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2111 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2112 | 2112 | } |
2113 | 2113 | |
2114 | 2114 | |
@@ -2121,22 +2121,22 @@ discard block |
||
2121 | 2121 | * @return void |
2122 | 2122 | */ |
2123 | 2123 | private function _set_category_object() { |
2124 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2124 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2125 | 2125 | return; //already have the category object so get out. |
2126 | 2126 | |
2127 | 2127 | //set default category object |
2128 | 2128 | $this->_set_empty_category_object(); |
2129 | 2129 | |
2130 | 2130 | //only set if we've got an id |
2131 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2131 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2132 | 2132 | return; |
2133 | 2133 | } |
2134 | 2134 | |
2135 | 2135 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2136 | 2136 | |
2137 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2137 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2138 | 2138 | |
2139 | - if ( !empty( $term ) ) { |
|
2139 | + if ( ! empty($term)) { |
|
2140 | 2140 | $this->_category->category_name = $term->name; |
2141 | 2141 | $this->_category->category_identifier = $term->slug; |
2142 | 2142 | $this->_category->category_desc = $term->description; |
@@ -2150,13 +2150,13 @@ discard block |
||
2150 | 2150 | |
2151 | 2151 | private function _set_empty_category_object() { |
2152 | 2152 | $this->_category = new stdClass(); |
2153 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2153 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2154 | 2154 | $this->_category->id = $this->_category->parent = 0; |
2155 | 2155 | } |
2156 | 2156 | |
2157 | 2157 | |
2158 | 2158 | protected function _category_list_table() { |
2159 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2159 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2160 | 2160 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2161 | 2161 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2162 | 2162 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2166,22 +2166,22 @@ discard block |
||
2166 | 2166 | protected function _category_details($view) { |
2167 | 2167 | |
2168 | 2168 | //load formatter helper |
2169 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2169 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2170 | 2170 | //load field generator helper |
2171 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2171 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2172 | 2172 | |
2173 | 2173 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2174 | 2174 | $this->_set_add_edit_form_tags($route); |
2175 | 2175 | |
2176 | 2176 | $this->_set_category_object(); |
2177 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2177 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2178 | 2178 | |
2179 | 2179 | $delete_action = 'delete_category'; |
2180 | 2180 | |
2181 | 2181 | //custom redirect |
2182 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2182 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2183 | 2183 | |
2184 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2184 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2185 | 2185 | |
2186 | 2186 | //take care of contents |
2187 | 2187 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2195,25 +2195,25 @@ discard block |
||
2195 | 2195 | 'type' => 'wp_editor', |
2196 | 2196 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2197 | 2197 | 'class' => 'my_editor_custom', |
2198 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2198 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2199 | 2199 | ); |
2200 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2200 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2201 | 2201 | |
2202 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2202 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2203 | 2203 | |
2204 | 2204 | //setup category select for term parents. |
2205 | 2205 | $category_select_values[] = array( |
2206 | 2206 | 'text' => __('No Parent', 'event_espresso'), |
2207 | 2207 | 'id' => 0 |
2208 | 2208 | ); |
2209 | - foreach ( $all_terms as $term ) { |
|
2209 | + foreach ($all_terms as $term) { |
|
2210 | 2210 | $category_select_values[] = array( |
2211 | 2211 | 'text' => $term->name, |
2212 | 2212 | 'id' => $term->term_id |
2213 | 2213 | ); |
2214 | 2214 | } |
2215 | 2215 | |
2216 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2216 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2217 | 2217 | |
2218 | 2218 | $template_args = array( |
2219 | 2219 | 'category' => $this->_category, |
@@ -2223,15 +2223,15 @@ discard block |
||
2223 | 2223 | 'disable' => '', |
2224 | 2224 | 'disabled_message' => FALSE |
2225 | 2225 | ); |
2226 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2227 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2226 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2227 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | |
2231 | 2231 | protected function _delete_categories() { |
2232 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2232 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2233 | 2233 | |
2234 | - foreach ( $cat_ids as $cat_id ) { |
|
2234 | + foreach ($cat_ids as $cat_id) { |
|
2235 | 2235 | $this->_delete_category($cat_id); |
2236 | 2236 | } |
2237 | 2237 | |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $query_args = array( |
2240 | 2240 | 'action' => 'category_list' |
2241 | 2241 | ); |
2242 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2242 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2243 | 2243 | |
2244 | 2244 | } |
2245 | 2245 | |
@@ -2249,61 +2249,61 @@ discard block |
||
2249 | 2249 | |
2250 | 2250 | protected function _delete_category($cat_id) { |
2251 | 2251 | global $wpdb; |
2252 | - $cat_id = absint( $cat_id ); |
|
2253 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2252 | + $cat_id = absint($cat_id); |
|
2253 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | |
2257 | 2257 | |
2258 | 2258 | protected function _insert_or_update_category($new_category) { |
2259 | 2259 | |
2260 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2260 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2261 | 2261 | $success = 0; //we already have a success message so lets not send another. |
2262 | 2262 | |
2263 | - if ( $cat_id ) { |
|
2263 | + if ($cat_id) { |
|
2264 | 2264 | $query_args = array( |
2265 | 2265 | 'action' => 'edit_category', |
2266 | 2266 | 'EVT_CAT_ID' => $cat_id |
2267 | 2267 | ); |
2268 | 2268 | } else { |
2269 | - $query_args = array( 'action' => 'add_category' ); |
|
2269 | + $query_args = array('action' => 'add_category'); |
|
2270 | 2270 | } |
2271 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2271 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2272 | 2272 | |
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | |
2276 | 2276 | |
2277 | - private function _insert_category( $update = FALSE ) { |
|
2277 | + private function _insert_category($update = FALSE) { |
|
2278 | 2278 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2279 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2280 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2281 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2279 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2280 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2281 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2282 | 2282 | |
2283 | - if ( empty( $category_name ) ) { |
|
2284 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2285 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2283 | + if (empty($category_name)) { |
|
2284 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2285 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2286 | 2286 | return false; |
2287 | 2287 | } |
2288 | 2288 | |
2289 | - $term_args=array( |
|
2289 | + $term_args = array( |
|
2290 | 2290 | 'name'=>$category_name, |
2291 | 2291 | 'description'=>$category_desc, |
2292 | 2292 | 'parent'=>$category_parent |
2293 | 2293 | ); |
2294 | 2294 | //was the category_identifier input disabled? |
2295 | - if(isset($this->_req_data['category_identifier'])){ |
|
2295 | + if (isset($this->_req_data['category_identifier'])) { |
|
2296 | 2296 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2297 | 2297 | } |
2298 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2298 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2299 | 2299 | |
2300 | - if ( !is_array( $insert_ids ) ) { |
|
2301 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2302 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2300 | + if ( ! is_array($insert_ids)) { |
|
2301 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2302 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2303 | 2303 | } else { |
2304 | 2304 | $cat_id = $insert_ids['term_id']; |
2305 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2306 | - EE_Error::add_success( $msg ); |
|
2305 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2306 | + EE_Error::add_success($msg); |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | return $cat_id; |
@@ -2312,32 +2312,32 @@ discard block |
||
2312 | 2312 | |
2313 | 2313 | |
2314 | 2314 | |
2315 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2315 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2316 | 2316 | global $wpdb; |
2317 | 2317 | |
2318 | 2318 | //testing term stuff |
2319 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2320 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2321 | - $limit = ($current_page-1)*$per_page; |
|
2319 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2320 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2321 | + $limit = ($current_page - 1) * $per_page; |
|
2322 | 2322 | |
2323 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2323 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2324 | 2324 | |
2325 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2326 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2325 | + if (isset($this->_req_data['s'])) { |
|
2326 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2327 | 2327 | $where['OR'] = array( |
2328 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2329 | - 'description' => array( 'LIKE', $sstr ) |
|
2328 | + 'Term.name' => array('LIKE', $sstr), |
|
2329 | + 'description' => array('LIKE', $sstr) |
|
2330 | 2330 | ); |
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | $query_params = array( |
2334 | - $where , |
|
2335 | - 'order_by' => array( $orderby => $order ), |
|
2336 | - 'limit' => $limit . ',' . $per_page, |
|
2334 | + $where, |
|
2335 | + 'order_by' => array($orderby => $order), |
|
2336 | + 'limit' => $limit.','.$per_page, |
|
2337 | 2337 | 'force_join' => array('Term') |
2338 | 2338 | ); |
2339 | 2339 | |
2340 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2340 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2341 | 2341 | |
2342 | 2342 | return $categories; |
2343 | 2343 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | ){ |
240 | 240 | if( $relation instanceof \EE_Belongs_To_Relation ) { |
241 | 241 | $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
244 | 244 | } |
245 | 245 | return new \WP_Error( |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | if( $relation instanceof \EE_Belongs_To_Relation ){ |
293 | 293 | return array_shift( $nice_results ); |
294 | - }else{ |
|
294 | + } else{ |
|
295 | 295 | return $nice_results; |
296 | 296 | } |
297 | 297 | } |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
406 | 406 | if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
407 | 407 | unset( $result[ $field_name ] ); |
408 | - }elseif( |
|
408 | + } elseif( |
|
409 | 409 | $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
410 | 410 | ){ |
411 | 411 | $result[ $field_name ] = array( |
412 | 412 | 'raw' => $field_obj->prepare_for_get( $field_value ), |
413 | 413 | 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
414 | 414 | ); |
415 | - }elseif( |
|
415 | + } elseif( |
|
416 | 416 | $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
417 | 417 | ){ |
418 | 418 | $result[ $field_name ] = array( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public static function get_related_entity_name( $relation_name, $relation_obj ){ |
596 | 596 | if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
597 | 597 | return strtolower( $relation_name ); |
598 | - }else{ |
|
598 | + } else{ |
|
599 | 599 | return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
600 | 600 | } |
601 | 601 | } |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
666 | 666 | if( in_array( $context, $valid_contexts ) ){ |
667 | 667 | return $context; |
668 | - }else{ |
|
668 | + } else{ |
|
669 | 669 | return \EEM_Base::caps_read; |
670 | 670 | } |
671 | 671 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | $order_by = $query_parameters[ 'order_by' ]; |
691 | 691 | } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
692 | 692 | $order_by = $query_parameters[ 'orderby' ]; |
693 | - }else{ |
|
693 | + } else{ |
|
694 | 694 | $order_by = null; |
695 | 695 | } |
696 | 696 | if( $order_by !== null ){ |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $group_by = $query_parameters[ 'group_by' ]; |
701 | 701 | } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
702 | 702 | $group_by = $query_parameters[ 'groupby' ]; |
703 | - }else{ |
|
703 | + } else{ |
|
704 | 704 | $group_by = null; |
705 | 705 | } |
706 | 706 | if( $group_by !== null ){ |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
724 | 724 | if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
725 | 725 | $limit_array = explode(',', (string)$query_parameters['limit']); |
726 | - }else { |
|
726 | + } else { |
|
727 | 727 | $limit_array = $query_parameters[ 'limit' ]; |
728 | 728 | } |
729 | 729 | $sanitized_limit = array(); |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | $sanitized_limit[] = intval( $limit_part ); |
740 | 740 | } |
741 | 741 | $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
742 | - }else{ |
|
742 | + } else{ |
|
743 | 743 | $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
744 | 744 | } |
745 | 745 | if( isset( $query_parameters[ 'caps' ] ) ) { |
746 | 746 | $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
747 | - }else{ |
|
747 | + } else{ |
|
748 | 748 | $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
749 | 749 | } |
750 | 750 | return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | foreach( $query_params as $key => $value ) { |
765 | 765 | if( is_array( $value ) ) { |
766 | 766 | $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
767 | - }else{ |
|
767 | + } else{ |
|
768 | 768 | $model_ready_query_params[ $key ] = $value; |
769 | 769 | } |
770 | 770 | } |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | //found the model name at the exact start |
817 | 817 | $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
818 | 818 | $extracted_fields_to_include[] = $field_sans_model_name; |
819 | - }elseif( $field_to_include == $model_name ){ |
|
819 | + } elseif( $field_to_include == $model_name ){ |
|
820 | 820 | $extracted_fields_to_include[] = '*'; |
821 | 821 | } |
822 | 822 | } |
823 | - }else{ |
|
823 | + } else{ |
|
824 | 824 | //look for ones with no period |
825 | 825 | foreach( $includes as $field_to_include ) { |
826 | 826 | $field_to_include = trim( $field_to_include ); |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() { |
35 | 35 | parent::__construct(); |
36 | - \EE_Registry::instance()->load_helper( 'Inflector' ); |
|
36 | + \EE_Registry::instance()->load_helper('Inflector'); |
|
37 | 37 | $this->_fields_calculator = new Calculated_Model_Fields(); |
38 | 38 | } |
39 | 39 | |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | * @param \WP_REST_Request $request |
43 | 43 | * @return \WP_REST_Response|\WP_Error |
44 | 44 | */ |
45 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
45 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
46 | 46 | $controller = new Read(); |
47 | - try{ |
|
47 | + try { |
|
48 | 48 | $matches = $controller->parse_route( |
49 | 49 | $request->get_route(), |
50 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
51 | - array( 'version', 'model' ) |
|
50 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
51 | + array('version', 'model') |
|
52 | 52 | ); |
53 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
54 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
55 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
53 | + $controller->set_requested_version($matches['version']); |
|
54 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
55 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
56 | 56 | return $controller->send_response( |
57 | 57 | new \WP_Error( |
58 | 58 | 'endpoint_parsing_error', |
59 | 59 | sprintf( |
60 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
60 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
61 | 61 | $model_name_singular |
62 | 62 | ) |
63 | 63 | ) |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | } |
66 | 66 | return $controller->send_response( |
67 | 67 | $controller->get_entities_from_model( |
68 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
68 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
69 | 69 | $request |
70 | 70 | ) |
71 | 71 | ); |
72 | - } catch( \Exception $e ) { |
|
73 | - return $controller->send_response( $e ); |
|
72 | + } catch (\Exception $e) { |
|
73 | + return $controller->send_response($e); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -80,21 +80,21 @@ discard block |
||
80 | 80 | * @param \WP_Rest_Request $request |
81 | 81 | * @return \WP_REST_Response|\WP_Error |
82 | 82 | */ |
83 | - public static function handle_request_get_one( \WP_Rest_Request $request ) { |
|
83 | + public static function handle_request_get_one(\WP_Rest_Request $request) { |
|
84 | 84 | $controller = new Read(); |
85 | - try{ |
|
85 | + try { |
|
86 | 86 | $matches = $controller->parse_route( |
87 | 87 | $request->get_route(), |
88 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
89 | - array( 'version', 'model', 'id' ) ); |
|
90 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
91 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
92 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
88 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
89 | + array('version', 'model', 'id') ); |
|
90 | + $controller->set_requested_version($matches['version']); |
|
91 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
92 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
93 | 93 | return $controller->send_response( |
94 | 94 | new \WP_Error( |
95 | 95 | 'endpoint_parsing_error', |
96 | 96 | sprintf( |
97 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
97 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
98 | 98 | $model_name_singular |
99 | 99 | ) |
100 | 100 | ) |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | } |
103 | 103 | return $controller->send_response( |
104 | 104 | $controller->get_entity_from_model( |
105 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
105 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
106 | 106 | $request |
107 | 107 | ) |
108 | 108 | ); |
109 | - } catch( \Exception $e ) { |
|
110 | - return $controller->send_response( $e ); |
|
109 | + } catch (\Exception $e) { |
|
110 | + return $controller->send_response($e); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -119,40 +119,40 @@ discard block |
||
119 | 119 | * @param \WP_REST_Request $request |
120 | 120 | * @return \WP_REST_Response|\WP_Error |
121 | 121 | */ |
122 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
122 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
123 | 123 | $controller = new Read(); |
124 | - try{ |
|
124 | + try { |
|
125 | 125 | $matches = $controller->parse_route( |
126 | 126 | $request->get_route(), |
127 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
128 | - array( 'version', 'model', 'id', 'related_model' ) |
|
127 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
128 | + array('version', 'model', 'id', 'related_model') |
|
129 | 129 | ); |
130 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
131 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
132 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
130 | + $controller->set_requested_version($matches['version']); |
|
131 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
132 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
133 | 133 | return $controller->send_response( |
134 | 134 | new \WP_Error( |
135 | 135 | 'endpoint_parsing_error', |
136 | 136 | sprintf( |
137 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
137 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
138 | 138 | $main_model_name_singular |
139 | 139 | ) |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | } |
143 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
143 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
144 | 144 | //assume the related model name is plural and try to find the model's name |
145 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
146 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
145 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
146 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
147 | 147 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
148 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
148 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
149 | 149 | } |
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | return $controller->send_response( |
152 | 152 | new \WP_Error( |
153 | 153 | 'endpoint_parsing_error', |
154 | 154 | sprintf( |
155 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
155 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
156 | 156 | $related_model_name_singular |
157 | 157 | ) |
158 | 158 | ) |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | |
162 | 162 | return $controller->send_response( |
163 | 163 | $controller->get_entities_from_relation( |
164 | - $request->get_param( 'id' ), |
|
165 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
164 | + $request->get_param('id'), |
|
165 | + $main_model->related_settings_for($related_model_name_singular), |
|
166 | 166 | $request |
167 | 167 | ) |
168 | 168 | ); |
169 | - } catch( \Exception $e ) { |
|
170 | - return $controller->send_response( $e ); |
|
169 | + } catch (\Exception $e) { |
|
170 | + return $controller->send_response($e); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | * @param \WP_REST_Request $request |
181 | 181 | * @return array |
182 | 182 | */ |
183 | - public function get_entities_from_model( $model, $request) { |
|
184 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
185 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
186 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
183 | + public function get_entities_from_model($model, $request) { |
|
184 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
185 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
186 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
187 | 187 | return new \WP_Error( |
188 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
188 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
189 | 189 | sprintf( |
190 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
190 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
191 | 191 | $model_name_plural, |
192 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
192 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
193 | 193 | ), |
194 | - array( 'status' => 403 ) |
|
194 | + array('status' => 403) |
|
195 | 195 | ); |
196 | 196 | } |
197 | 197 | |
198 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
198 | + $this->_set_headers_from_query_params($model, $query_params); |
|
199 | 199 | /** @type array $results */ |
200 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
200 | + $results = $model->get_all_wpdb_results($query_params); |
|
201 | 201 | $nice_results = array( ); |
202 | - foreach ( $results as $result ) { |
|
203 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
202 | + foreach ($results as $result) { |
|
203 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
204 | 204 | $model, |
205 | 205 | $result, |
206 | 206 | $request |
@@ -221,62 +221,62 @@ discard block |
||
221 | 221 | * @param \WP_REST_Request $request |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
225 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
224 | + public function get_entities_from_relation($id, $relation, $request) { |
|
225 | + $context = $this->validate_context($request->get_param('caps')); |
|
226 | 226 | $model = $relation->get_this_model(); |
227 | 227 | $related_model = $relation->get_other_model(); |
228 | 228 | //check if they can access the 1st model object |
229 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
230 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
229 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
230 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
231 | 231 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
232 | 232 | } |
233 | 233 | $restricted_query_params = $query_params; |
234 | - $restricted_query_params[ 'caps' ] = $context; |
|
235 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
236 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
234 | + $restricted_query_params['caps'] = $context; |
|
235 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
236 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
237 | 237 | |
238 | - if( |
|
238 | + if ( |
|
239 | 239 | ! ( |
240 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
241 | - && $model->exists( $restricted_query_params ) |
|
240 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
241 | + && $model->exists($restricted_query_params) |
|
242 | 242 | ) |
243 | - ){ |
|
244 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
245 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
246 | - }else{ |
|
247 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
243 | + ) { |
|
244 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
245 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
246 | + } else { |
|
247 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
248 | 248 | } |
249 | 249 | return new \WP_Error( |
250 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
250 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
251 | 251 | sprintf( |
252 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
252 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
253 | 253 | $related_model_name_maybe_plural, |
254 | 254 | $relation->get_this_model()->get_this_model_name(), |
255 | 255 | implode( |
256 | 256 | ',', |
257 | 257 | array_keys( |
258 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
258 | + Capabilities::get_missing_permissions($related_model, $context) |
|
259 | 259 | ) |
260 | 260 | ) |
261 | 261 | ), |
262 | - array( 'status' => 403 ) |
|
262 | + array('status' => 403) |
|
263 | 263 | ); |
264 | 264 | } |
265 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
266 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
267 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
268 | - $query_params[ 'caps' ] = $context; |
|
269 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
265 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
266 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
267 | + $query_params['default_where_conditions'] = 'none'; |
|
268 | + $query_params['caps'] = $context; |
|
269 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
270 | 270 | /** @type array $results */ |
271 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
271 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
272 | 272 | $nice_results = array(); |
273 | - foreach( $results as $result ) { |
|
273 | + foreach ($results as $result) { |
|
274 | 274 | $nice_result = $this->create_entity_from_wpdb_result( |
275 | 275 | $relation->get_other_model(), |
276 | 276 | $result, |
277 | 277 | $request |
278 | 278 | ); |
279 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
279 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
280 | 280 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
281 | 281 | //if there are conflicts we prefer the properties from the main model |
282 | 282 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -284,18 +284,18 @@ discard block |
||
284 | 284 | $result, |
285 | 285 | $request |
286 | 286 | ); |
287 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
287 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
288 | 288 | //but keep the meta stuff from the main model |
289 | - if( isset( $nice_result['meta'] ) ){ |
|
289 | + if (isset($nice_result['meta'])) { |
|
290 | 290 | $joined_result['meta'] = $nice_result['meta']; |
291 | 291 | } |
292 | 292 | $nice_result = $joined_result; |
293 | 293 | } |
294 | 294 | $nice_results[] = $nice_result; |
295 | 295 | } |
296 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
297 | - return array_shift( $nice_results ); |
|
298 | - }else{ |
|
296 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
297 | + return array_shift($nice_results); |
|
298 | + } else { |
|
299 | 299 | return $nice_results; |
300 | 300 | } |
301 | 301 | } |
@@ -307,32 +307,32 @@ discard block |
||
307 | 307 | * @param array $query_params |
308 | 308 | * @return void |
309 | 309 | */ |
310 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
311 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
312 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
310 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
311 | + $this->_set_debug_info('model query params', $query_params); |
|
312 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
313 | 313 | //normally the limit to a 2-part array, where the 2nd item is the limit |
314 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
315 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
314 | + if ( ! isset($query_params['limit'])) { |
|
315 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
316 | 316 | } |
317 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
318 | - $limit_parts = $query_params[ 'limit' ]; |
|
317 | + if (is_array($query_params['limit'])) { |
|
318 | + $limit_parts = $query_params['limit']; |
|
319 | 319 | } else { |
320 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
321 | - if( count( $limit_parts ) == 1 ){ |
|
322 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
320 | + $limit_parts = explode(',', $query_params['limit']); |
|
321 | + if (count($limit_parts) == 1) { |
|
322 | + $limit_parts = array(0, $limit_parts[0]); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | //remove the group by and having parts of the query, as those will |
326 | 326 | //make the sql query return an array of values, instead of just a single value |
327 | - unset( $query_params[ 'group_by' ] ); |
|
328 | - unset( $query_params[ 'having' ] ); |
|
329 | - unset( $query_params[ 'limit' ] ); |
|
330 | - $count = $model->count( $query_params, null, true ); |
|
331 | - |
|
332 | - $pages = $count / $limit_parts[ 1 ]; |
|
333 | - $this->_set_response_header( 'Total', $count, false ); |
|
334 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
335 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
327 | + unset($query_params['group_by']); |
|
328 | + unset($query_params['having']); |
|
329 | + unset($query_params['limit']); |
|
330 | + $count = $model->count($query_params, null, true); |
|
331 | + |
|
332 | + $pages = $count / $limit_parts[1]; |
|
333 | + $this->_set_response_header('Total', $count, false); |
|
334 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
335 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -345,47 +345,47 @@ discard block |
||
345 | 345 | * @param string $deprecated no longer used |
346 | 346 | * @return array ready for being converted into json for sending to client |
347 | 347 | */ |
348 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
349 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
348 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
349 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
350 | 350 | //ok so this was called in the old style, where the 3rd arg was |
351 | 351 | //$include, and the 4th arg was $context |
352 | 352 | //now setup the request just to avoid fatal errors, although we won't be able |
353 | 353 | //to truly make use of it because it's kinda devoid of info |
354 | 354 | $rest_request = new \WP_REST_Request(); |
355 | - $rest_request->set_param( 'include', $rest_request ); |
|
356 | - $rest_request->set_param( 'caps', $deprecated ); |
|
355 | + $rest_request->set_param('include', $rest_request); |
|
356 | + $rest_request->set_param('caps', $deprecated); |
|
357 | 357 | } |
358 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
359 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
358 | + if ($rest_request->get_param('caps') == null) { |
|
359 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
360 | 360 | } |
361 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
362 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
363 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
364 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
365 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
361 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
362 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
363 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
364 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
365 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
366 | 366 | $entity_array = apply_filters( |
367 | 367 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
368 | 368 | $entity_array, |
369 | 369 | $model, |
370 | - $rest_request->get_param( 'caps' ), |
|
370 | + $rest_request->get_param('caps'), |
|
371 | 371 | $rest_request, |
372 | 372 | $this |
373 | 373 | ); |
374 | 374 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
375 | 375 | $entity_array, |
376 | 376 | $model, |
377 | - $rest_request->get_param( 'caps' ), |
|
377 | + $rest_request->get_param('caps'), |
|
378 | 378 | $this->get_model_version_info() |
379 | 379 | ); |
380 | 380 | $this->_set_debug_info( |
381 | 381 | 'inaccessible fields', |
382 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
382 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
383 | 383 | ); |
384 | 384 | return apply_filters( |
385 | 385 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
386 | 386 | $result_without_inaccessible_fields, |
387 | 387 | $model, |
388 | - $rest_request->get_param( 'caps' ) |
|
388 | + $rest_request->get_param('caps') |
|
389 | 389 | ); |
390 | 390 | } |
391 | 391 | |
@@ -397,38 +397,38 @@ discard block |
||
397 | 397 | * @param array $db_row |
398 | 398 | * @return array entity mostly ready for converting to JSON and sending in the response |
399 | 399 | */ |
400 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
401 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
402 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
403 | - foreach( $result as $field_name => $raw_field_value ) { |
|
400 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
401 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
402 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
403 | + foreach ($result as $field_name => $raw_field_value) { |
|
404 | 404 | $field_obj = $model->field_settings_for($field_name); |
405 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
406 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
407 | - unset( $result[ $field_name ] ); |
|
408 | - }elseif( |
|
409 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
410 | - ){ |
|
411 | - $result[ $field_name ] = array( |
|
412 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
413 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
405 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
406 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
407 | + unset($result[$field_name]); |
|
408 | + }elseif ( |
|
409 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
410 | + ) { |
|
411 | + $result[$field_name] = array( |
|
412 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
413 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
414 | 414 | ); |
415 | - }elseif( |
|
416 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
417 | - ){ |
|
418 | - $result[ $field_name ] = array( |
|
419 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
420 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
415 | + }elseif ( |
|
416 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
417 | + ) { |
|
418 | + $result[$field_name] = array( |
|
419 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
420 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
421 | 421 | ); |
422 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
423 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
422 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
423 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
424 | 424 | $field_obj, |
425 | 425 | $field_value, |
426 | 426 | $this->get_model_version_info()->requested_version() |
427 | 427 | ); |
428 | 428 | } else { |
429 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
429 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | 430 | $field_obj, |
431 | - $field_obj->prepare_for_get( $field_value ), |
|
431 | + $field_obj->prepare_for_get($field_value), |
|
432 | 432 | $this->get_model_version_info()->requested_version() |
433 | 433 | ); |
434 | 434 | } |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | * @param array $entity_array |
444 | 444 | * @return array modified entity |
445 | 445 | */ |
446 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
447 | - if( $model instanceof \EEM_CPT_Base ) { |
|
448 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
446 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
447 | + if ($model instanceof \EEM_CPT_Base) { |
|
448 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
449 | 449 | } |
450 | 450 | return $entity_array; |
451 | 451 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | * @param array $entity_array |
460 | 460 | * @return array the _links item in the entity |
461 | 461 | */ |
462 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
462 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
463 | 463 | //add basic links |
464 | 464 | $links = array( |
465 | 465 | 'self' => array( |
466 | 466 | array( |
467 | 467 | 'href' => $this->get_versioned_link_to( |
468 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
468 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
469 | 469 | ) |
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'collection' => array( |
473 | 473 | array( |
474 | 474 | 'href' => $this->get_versioned_link_to( |
475 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
475 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
476 | 476 | ) |
477 | 477 | ) |
478 | 478 | ), |
@@ -480,24 +480,24 @@ discard block |
||
480 | 480 | |
481 | 481 | //add link to the wp core endpoint, if wp api is active |
482 | 482 | global $wp_rest_server; |
483 | - if( $model instanceof \EEM_CPT_Base && |
|
483 | + if ($model instanceof \EEM_CPT_Base && |
|
484 | 484 | $wp_rest_server instanceof \WP_REST_Server && |
485 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
486 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
485 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
486 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
487 | 487 | array( |
488 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
488 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
489 | 489 | 'single' => true |
490 | 490 | ) |
491 | 491 | ); |
492 | 492 | } |
493 | 493 | |
494 | 494 | //add links to related models |
495 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
496 | - $related_model_part = $this->get_related_entity_name( $relation_name, $relation_obj ); |
|
497 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
495 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
496 | + $related_model_part = $this->get_related_entity_name($relation_name, $relation_obj); |
|
497 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
498 | 498 | array( |
499 | 499 | 'href' => $this->get_versioned_link_to( |
500 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
500 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
501 | 501 | ), |
502 | 502 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
503 | 503 | ) |
@@ -513,50 +513,50 @@ discard block |
||
513 | 513 | * @param array $entity_array |
514 | 514 | * @return array the modified entity |
515 | 515 | */ |
516 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
517 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
518 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
516 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
517 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
518 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
519 | 519 | //if they passed in * or didn't specify any includes, return everything |
520 | - if( ! in_array( '*', $includes_for_this_model ) |
|
521 | - && ! empty( $includes_for_this_model ) ) { |
|
522 | - if( $model->has_primary_key_field() ) { |
|
520 | + if ( ! in_array('*', $includes_for_this_model) |
|
521 | + && ! empty($includes_for_this_model)) { |
|
522 | + if ($model->has_primary_key_field()) { |
|
523 | 523 | //always include the primary key. ya just gotta know that at least |
524 | 524 | $includes_for_this_model[] = $model->primary_key_name(); |
525 | 525 | } |
526 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
526 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
527 | 527 | $includes_for_this_model[] = '_calculated_fields'; |
528 | 528 | } |
529 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
529 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
530 | 530 | } |
531 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
532 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
531 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
532 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
533 | 533 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
534 | - $rest_request->get_param( 'include' ), |
|
534 | + $rest_request->get_param('include'), |
|
535 | 535 | $relation_name |
536 | 536 | ); |
537 | 537 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
538 | - $rest_request->get_param( 'calculate' ), |
|
538 | + $rest_request->get_param('calculate'), |
|
539 | 539 | $relation_name |
540 | 540 | ); |
541 | 541 | //did they specify they wanted to include a related model, or |
542 | 542 | //specific fields from a related model? |
543 | 543 | //or did they specify to calculate a field from a related model? |
544 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
544 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
545 | 545 | //if so, we should include at least some part of the related model |
546 | 546 | $pretend_related_request = new \WP_REST_Request(); |
547 | 547 | $pretend_related_request->set_query_params( |
548 | 548 | array( |
549 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
549 | + 'caps' => $rest_request->get_param('caps'), |
|
550 | 550 | 'include' => $related_fields_to_include, |
551 | 551 | 'calculate' => $related_fields_to_calculate, |
552 | 552 | ) |
553 | 553 | ); |
554 | 554 | $related_results = $this->get_entities_from_relation( |
555 | - $entity_array[ $model->primary_key_name() ], |
|
555 | + $entity_array[$model->primary_key_name()], |
|
556 | 556 | $relation_obj, |
557 | 557 | $pretend_related_request |
558 | 558 | ); |
559 | - $entity_array[ $this->get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error ? null : $related_results; |
|
559 | + $entity_array[$this->get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error ? null : $related_results; |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | return $entity_array; |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | * @param array $arr |
569 | 569 | * @return array |
570 | 570 | */ |
571 | - private function _remove_model_names_from_array( $arr ) { |
|
572 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
571 | + private function _remove_model_names_from_array($arr) { |
|
572 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
573 | 573 | } |
574 | 574 | /** |
575 | 575 | * Gets the calculated fields for the response |
@@ -579,16 +579,16 @@ discard block |
||
579 | 579 | * @param \WP_REST_Request $rest_request |
580 | 580 | * @return array the _calculations item in the entity |
581 | 581 | */ |
582 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
582 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
583 | 583 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
584 | - $rest_request->get_param( 'calculate' ), |
|
584 | + $rest_request->get_param('calculate'), |
|
585 | 585 | '' |
586 | 586 | ); |
587 | 587 | //note: setting calculate=* doesn't do anything |
588 | 588 | $calculated_fields_to_return = array(); |
589 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
590 | - try{ |
|
591 | - $calculated_fields_to_return[ $field_to_calculate ] = Model_Data_Translator::prepare_field_value_for_json( |
|
589 | + foreach ($calculated_fields as $field_to_calculate) { |
|
590 | + try { |
|
591 | + $calculated_fields_to_return[$field_to_calculate] = Model_Data_Translator::prepare_field_value_for_json( |
|
592 | 592 | null, |
593 | 593 | $this->_fields_calculator->retrieve_calculated_field_value( |
594 | 594 | $model, |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | ), |
600 | 600 | $this->get_model_version_info()->requested_version() |
601 | 601 | ); |
602 | - } catch( Rest_Exception $e ) { |
|
602 | + } catch (Rest_Exception $e) { |
|
603 | 603 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
604 | 604 | $this->_set_response_header( |
605 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
605 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
606 | 606 | $e->getMessage(), |
607 | 607 | true |
608 | 608 | ); |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
617 | 617 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
618 | 618 | */ |
619 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
619 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
620 | 620 | return rest_url( |
621 | 621 | \EED_Core_Rest_Api::ee_api_namespace |
622 | 622 | . $this->get_model_version_info()->requested_version() |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | * @param \EE_Model_Relation_Base $relation_obj |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
636 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
637 | - return strtolower( $relation_name ); |
|
638 | - }else{ |
|
639 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
635 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
636 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
637 | + return strtolower($relation_name); |
|
638 | + } else { |
|
639 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
@@ -649,43 +649,43 @@ discard block |
||
649 | 649 | * @param \WP_REST_Request $request |
650 | 650 | * @return array |
651 | 651 | */ |
652 | - public function get_entity_from_model( $model, $request ) { |
|
653 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
654 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
652 | + public function get_entity_from_model($model, $request) { |
|
653 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
654 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
655 | 655 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
656 | 656 | } |
657 | 657 | $restricted_query_params = $query_params; |
658 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
659 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
660 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
661 | - if ( ! empty ( $model_rows ) ) { |
|
658 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
659 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
660 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
661 | + if ( ! empty ($model_rows)) { |
|
662 | 662 | return $this->create_entity_from_wpdb_result( |
663 | 663 | $model, |
664 | - array_shift( $model_rows ), |
|
664 | + array_shift($model_rows), |
|
665 | 665 | $request ); |
666 | 666 | } else { |
667 | 667 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
668 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
669 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
670 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
668 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
669 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
670 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
671 | 671 | //you got shafted- it existed but we didn't want to tell you! |
672 | 672 | return new \WP_Error( |
673 | 673 | 'rest_user_cannot_read', |
674 | 674 | sprintf( |
675 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
676 | - strtolower( $model->get_this_model_name() ), |
|
675 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
676 | + strtolower($model->get_this_model_name()), |
|
677 | 677 | Capabilities::get_missing_permissions_string( |
678 | 678 | $model, |
679 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
679 | + $this->validate_context($request->get_param('caps')) ) |
|
680 | 680 | ), |
681 | - array( 'status' => 403 ) |
|
681 | + array('status' => 403) |
|
682 | 682 | ); |
683 | 683 | } else { |
684 | 684 | //it's not you. It just doesn't exist |
685 | 685 | return new \WP_Error( |
686 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
687 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
688 | - array( 'status' => 404 ) |
|
686 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
687 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
688 | + array('status' => 404) |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | } |
@@ -698,14 +698,14 @@ discard block |
||
698 | 698 | * @param string $context |
699 | 699 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
700 | 700 | */ |
701 | - public function validate_context( $context ) { |
|
702 | - if( ! $context ) { |
|
701 | + public function validate_context($context) { |
|
702 | + if ( ! $context) { |
|
703 | 703 | $context = \EEM_Base::caps_read; |
704 | 704 | } |
705 | 705 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
706 | - if( in_array( $context, $valid_contexts ) ){ |
|
706 | + if (in_array($context, $valid_contexts)) { |
|
707 | 707 | return $context; |
708 | - }else{ |
|
708 | + } else { |
|
709 | 709 | return \EEM_Base::caps_read; |
710 | 710 | } |
711 | 711 | } |
@@ -724,77 +724,77 @@ discard block |
||
724 | 724 | * that absolutely no results should be returned |
725 | 725 | * @throws \EE_Error |
726 | 726 | */ |
727 | - public function create_model_query_params( $model, $query_parameters ) { |
|
727 | + public function create_model_query_params($model, $query_parameters) { |
|
728 | 728 | $model_query_params = array( ); |
729 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
730 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
731 | - $query_parameters[ 'where' ], |
|
729 | + if (isset($query_parameters['where'])) { |
|
730 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
731 | + $query_parameters['where'], |
|
732 | 732 | $model, |
733 | 733 | $this->get_model_version_info()->requested_version() |
734 | 734 | ); |
735 | 735 | } |
736 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
737 | - $order_by = $query_parameters[ 'order_by' ]; |
|
738 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
739 | - $order_by = $query_parameters[ 'orderby' ]; |
|
740 | - }else{ |
|
736 | + if (isset($query_parameters['order_by'])) { |
|
737 | + $order_by = $query_parameters['order_by']; |
|
738 | + } elseif (isset($query_parameters['orderby'])) { |
|
739 | + $order_by = $query_parameters['orderby']; |
|
740 | + } else { |
|
741 | 741 | $order_by = null; |
742 | 742 | } |
743 | - if( $order_by !== null ){ |
|
744 | - $model_query_params[ 'order_by' ] = $order_by; |
|
743 | + if ($order_by !== null) { |
|
744 | + $model_query_params['order_by'] = $order_by; |
|
745 | 745 | } |
746 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
747 | - $group_by = $query_parameters[ 'group_by' ]; |
|
748 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
749 | - $group_by = $query_parameters[ 'groupby' ]; |
|
750 | - }else{ |
|
746 | + if (isset($query_parameters['group_by'])) { |
|
747 | + $group_by = $query_parameters['group_by']; |
|
748 | + } elseif (isset($query_parameters['groupby'])) { |
|
749 | + $group_by = $query_parameters['groupby']; |
|
750 | + } else { |
|
751 | 751 | $group_by = null; |
752 | 752 | } |
753 | - if( $group_by !== null ){ |
|
754 | - $model_query_params[ 'group_by' ] = $group_by; |
|
753 | + if ($group_by !== null) { |
|
754 | + $model_query_params['group_by'] = $group_by; |
|
755 | 755 | } |
756 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
757 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
758 | - $query_parameters[ 'having' ], |
|
756 | + if (isset($query_parameters['having'])) { |
|
757 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
758 | + $query_parameters['having'], |
|
759 | 759 | $model, |
760 | 760 | $this->get_model_version_info()->requested_version() |
761 | 761 | ); |
762 | 762 | } |
763 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
764 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
763 | + if (isset($query_parameters['order'])) { |
|
764 | + $model_query_params['order'] = $query_parameters['order']; |
|
765 | 765 | } |
766 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
767 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
766 | + if (isset($query_parameters['mine'])) { |
|
767 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
768 | 768 | } |
769 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
769 | + if (isset($query_parameters['limit'])) { |
|
770 | 770 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
771 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
772 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
773 | - }else { |
|
774 | - $limit_array = $query_parameters[ 'limit' ]; |
|
771 | + if ( ! is_array($query_parameters['limit'])) { |
|
772 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
773 | + } else { |
|
774 | + $limit_array = $query_parameters['limit']; |
|
775 | 775 | } |
776 | 776 | $sanitized_limit = array(); |
777 | - foreach( $limit_array as $key => $limit_part ) { |
|
778 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
777 | + foreach ($limit_array as $key => $limit_part) { |
|
778 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
779 | 779 | throw new \EE_Error( |
780 | 780 | sprintf( |
781 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
782 | - json_encode( $query_parameters[ 'limit' ] ) |
|
781 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
782 | + json_encode($query_parameters['limit']) |
|
783 | 783 | ) |
784 | 784 | ); |
785 | 785 | } |
786 | - $sanitized_limit[] = intval( $limit_part ); |
|
786 | + $sanitized_limit[] = intval($limit_part); |
|
787 | 787 | } |
788 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
789 | - }else{ |
|
790 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
788 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
789 | + } else { |
|
790 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
791 | 791 | } |
792 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
793 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
794 | - }else{ |
|
795 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
792 | + if (isset($query_parameters['caps'])) { |
|
793 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
794 | + } else { |
|
795 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
796 | 796 | } |
797 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
797 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
807 | 807 | * @return array |
808 | 808 | */ |
809 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
809 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
810 | 810 | $model_ready_query_params = array(); |
811 | - foreach( $query_params as $key => $value ) { |
|
812 | - if( is_array( $value ) ) { |
|
813 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
814 | - }else{ |
|
815 | - $model_ready_query_params[ $key ] = $value; |
|
811 | + foreach ($query_params as $key => $value) { |
|
812 | + if (is_array($value)) { |
|
813 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
814 | + } else { |
|
815 | + $model_ready_query_params[$key] = $value; |
|
816 | 816 | } |
817 | 817 | } |
818 | 818 | return $model_ready_query_params; |
@@ -826,13 +826,13 @@ discard block |
||
826 | 826 | * @param $query_params |
827 | 827 | * @return array |
828 | 828 | */ |
829 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
829 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
830 | 830 | $model_ready_query_params = array(); |
831 | - foreach( $query_params as $key => $value ) { |
|
832 | - if( is_array( $value ) ) { |
|
833 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
831 | + foreach ($query_params as $key => $value) { |
|
832 | + if (is_array($value)) { |
|
833 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
834 | 834 | } else { |
835 | - $model_ready_query_params[ $key ] = $value; |
|
835 | + $model_ready_query_params[$key] = $value; |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 | return $model_ready_query_params; |
@@ -847,33 +847,33 @@ discard block |
||
847 | 847 | * we only return strings starting with that and a period; if no prefix was specified |
848 | 848 | * we return all items containing NO periods |
849 | 849 | */ |
850 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
851 | - if( is_string( $string_to_explode ) ) { |
|
852 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
853 | - } else if( is_array( $string_to_explode ) ) { |
|
850 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
851 | + if (is_string($string_to_explode)) { |
|
852 | + $exploded_contents = explode(',', $string_to_explode); |
|
853 | + } else if (is_array($string_to_explode)) { |
|
854 | 854 | $exploded_contents = $string_to_explode; |
855 | 855 | } else { |
856 | 856 | $exploded_contents = array(); |
857 | 857 | } |
858 | 858 | //if the string was empty, we want an empty array |
859 | - $exploded_contents = array_filter( $exploded_contents ); |
|
859 | + $exploded_contents = array_filter($exploded_contents); |
|
860 | 860 | $contents_with_prefix = array(); |
861 | - foreach( $exploded_contents as $item ) { |
|
862 | - $item = trim( $item ); |
|
861 | + foreach ($exploded_contents as $item) { |
|
862 | + $item = trim($item); |
|
863 | 863 | //if no prefix was provided, so we look for items with no "." in them |
864 | - if( ! $prefix ) { |
|
864 | + if ( ! $prefix) { |
|
865 | 865 | //does this item have a period? |
866 | - if( strpos( $item, '.' ) === false ) { |
|
866 | + if (strpos($item, '.') === false) { |
|
867 | 867 | //if not, then its what we're looking for |
868 | 868 | $contents_with_prefix[] = $item; |
869 | 869 | } |
870 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
870 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
871 | 871 | //this item has the prefix and a period, grab it |
872 | 872 | $contents_with_prefix[] = substr( |
873 | 873 | $item, |
874 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
874 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
875 | 875 | ); |
876 | - } else if( $item === $prefix ) { |
|
876 | + } else if ($item === $prefix) { |
|
877 | 877 | //this item is JUST the prefix |
878 | 878 | //so let's grab everything after, which is a blank string |
879 | 879 | $contents_with_prefix[] = ''; |
@@ -896,33 +896,33 @@ discard block |
||
896 | 896 | * the fields for that model, with the model's name removed from each. |
897 | 897 | * If $include_string was blank or '*' returns an empty array |
898 | 898 | */ |
899 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
900 | - if( is_array( $include_string ) ) { |
|
901 | - $include_string = implode( ',', $include_string ); |
|
899 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
900 | + if (is_array($include_string)) { |
|
901 | + $include_string = implode(',', $include_string); |
|
902 | 902 | } |
903 | - if( $include_string === '*' || $include_string === '' ) { |
|
903 | + if ($include_string === '*' || $include_string === '') { |
|
904 | 904 | return array(); |
905 | 905 | } |
906 | - $includes = explode( ',', $include_string ); |
|
906 | + $includes = explode(',', $include_string); |
|
907 | 907 | $extracted_fields_to_include = array(); |
908 | - if( $model_name ){ |
|
909 | - foreach( $includes as $field_to_include ) { |
|
910 | - $field_to_include = trim( $field_to_include ); |
|
911 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
908 | + if ($model_name) { |
|
909 | + foreach ($includes as $field_to_include) { |
|
910 | + $field_to_include = trim($field_to_include); |
|
911 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
912 | 912 | //found the model name at the exact start |
913 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
913 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
914 | 914 | $extracted_fields_to_include[] = $field_sans_model_name; |
915 | - }elseif( $field_to_include == $model_name ){ |
|
915 | + }elseif ($field_to_include == $model_name) { |
|
916 | 916 | $extracted_fields_to_include[] = '*'; |
917 | 917 | } |
918 | 918 | } |
919 | - }else{ |
|
919 | + } else { |
|
920 | 920 | //look for ones with no period |
921 | - foreach( $includes as $field_to_include ) { |
|
922 | - $field_to_include = trim( $field_to_include ); |
|
921 | + foreach ($includes as $field_to_include) { |
|
922 | + $field_to_include = trim($field_to_include); |
|
923 | 923 | if ( |
924 | - strpos( $field_to_include, '.' ) === false |
|
925 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
924 | + strpos($field_to_include, '.') === false |
|
925 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
926 | 926 | ) { |
927 | 927 | $extracted_fields_to_include[] = $field_to_include; |
928 | 928 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
112 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
113 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
114 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
115 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
116 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
117 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
118 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
119 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
112 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
113 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
116 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
117 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
118 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
119 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | $this->_model_relations = array( |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'Answer'=>new EE_Has_Many_Relation(), |
129 | 129 | 'Checkin'=>new EE_Has_Many_Relation(), |
130 | 130 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
131 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
131 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
132 | 132 | ); |
133 | 133 | $this->_model_chain_to_wp_user = 'Event'; |
134 | 134 | |
135 | - parent::__construct( $timezone ); |
|
135 | + parent::__construct($timezone); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param bool $translated If true will return the values as singular localized strings |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
169 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
170 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
168 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
169 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
170 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param array $exclude |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - private function _get_registration_status_array( $exclude = array() ) { |
|
181 | + private function _get_registration_status_array($exclude = array()) { |
|
182 | 182 | //in the very rare circumstance that we are deleting a model's table's data |
183 | 183 | //and the table hasn't actually been created, this could have an error |
184 | 184 | /** @type WPDB $wpdb */ |
185 | 185 | global $wpdb; |
186 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
187 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
188 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
189 | - $results = $wpdb->get_results( $SQL ); |
|
186 | + EE_Registry::instance()->load_helper('Activation'); |
|
187 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
188 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
189 | + $results = $wpdb->get_results($SQL); |
|
190 | 190 | self::$_reg_status = array(); |
191 | - foreach ( $results as $status ) { |
|
192 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
193 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
191 | + foreach ($results as $status) { |
|
192 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
193 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
206 | 206 | * @return wpdb results array |
207 | 207 | */ |
208 | - public function get_reg_months_and_years( $where_params ) { |
|
208 | + public function get_reg_months_and_years($where_params) { |
|
209 | 209 | $query_params[0] = $where_params; |
210 | 210 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
211 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
211 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
212 | 212 | $columns_to_select = array( |
213 | 213 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
214 | 214 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
215 | 215 | ); |
216 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
216 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param int $ATT_ID |
226 | 226 | * @return EE_Registration[] |
227 | 227 | */ |
228 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
229 | - if ( ! $ATT_ID ) { |
|
228 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
229 | + if ( ! $ATT_ID) { |
|
230 | 230 | return FALSE; |
231 | 231 | } |
232 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
232 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $REG_url_link |
241 | 241 | * @return EE_Registration |
242 | 242 | */ |
243 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
244 | - if(!$REG_url_link){ |
|
243 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
244 | + if ( ! $REG_url_link) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -259,13 +259,13 @@ discard block |
||
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 | 260 | * @return mixed array on success, FALSE on fail |
261 | 261 | */ |
262 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
262 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
263 | 263 | return $this->get_one(array( |
264 | 264 | array( |
265 | 265 | 'TXN_ID'=>$TXN_ID, |
266 | 266 | 'ATT_ID'=>$ATT_ID |
267 | 267 | ), |
268 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
268 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
269 | 269 | )); |
270 | 270 | } |
271 | 271 | |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
278 | 278 | * @return stdClass[] with properties regDate and total |
279 | 279 | */ |
280 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
280 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
281 | 281 | |
282 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
283 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
282 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
283 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
284 | 284 | |
285 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
285 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
286 | 286 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
287 | 287 | } |
288 | 288 | |
289 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
290 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
289 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
290 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
291 | 291 | |
292 | 292 | $results = $this->_get_all_wpdb_results( |
293 | 293 | array( |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | ), |
298 | 298 | OBJECT, |
299 | 299 | array( |
300 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
301 | - 'total'=>array('count(REG_ID)','%d') |
|
300 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
301 | + 'total'=>array('count(REG_ID)', '%d') |
|
302 | 302 | )); |
303 | 303 | return $results; |
304 | 304 | } |
@@ -313,23 +313,23 @@ discard block |
||
313 | 313 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
314 | 314 | * @return stdClass[] each with properties event_name, reg_limit, and total |
315 | 315 | */ |
316 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
316 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
317 | 317 | |
318 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
319 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
318 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
319 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
320 | 320 | |
321 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
321 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
322 | 322 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
323 | 323 | } |
324 | 324 | $results = $this->_get_all_wpdb_results(array( |
325 | 325 | $where, |
326 | 326 | 'group_by'=>'Event.EVT_name', |
327 | 327 | 'order_by'=>'Event.EVT_name', |
328 | - 'limit'=>array(0,24)), |
|
328 | + 'limit'=>array(0, 24)), |
|
329 | 329 | OBJECT, |
330 | 330 | array( |
331 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
332 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
331 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
332 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
333 | 333 | ) |
334 | 334 | ); |
335 | 335 | |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | * @param int $TXN_ID |
344 | 344 | * @return EE_Registration |
345 | 345 | */ |
346 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
347 | - if( ! $TXN_ID ){ |
|
346 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
347 | + if ( ! $TXN_ID) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
350 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | * @param boolean $for_incomplete_payments |
360 | 360 | * @return int |
361 | 361 | */ |
362 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
362 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
363 | 363 | // we only count approved registrations towards registration limits |
364 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
365 | - if( $for_incomplete_payments ){ |
|
366 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
364 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
365 | + if ($for_incomplete_payments) { |
|
366 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | return $this->count($query_params); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | /** @type WPDB $wpdb */ |
380 | 380 | global $wpdb; |
381 | 381 | return $wpdb->query( |
382 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
382 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param boolean $checked_in whether to coun registrations checked IN or OUT |
389 | 389 | * @return int |
390 | 390 | */ |
391 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
391 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
392 | 392 | return $this->count( |
393 | 393 | array( |
394 | 394 | array( |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @param boolean $checked_in whether to coun registrations checked IN or OUT |
406 | 406 | * @return int |
407 | 407 | */ |
408 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
408 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
409 | 409 | return $this->count( |
410 | 410 | array( |
411 | 411 | array( |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected $_cached_fields_on_models = array(); |
89 | 89 | |
90 | 90 | |
91 | - public function __construct( $requested_version ) { |
|
91 | + public function __construct($requested_version) { |
|
92 | 92 | $this->_requested_version = $requested_version; |
93 | 93 | $this->_model_changes = array( |
94 | 94 | '4.8.29' => array( |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | 'table_column' => 'N/A', |
111 | 111 | 'always_available' => true, |
112 | 112 | ); |
113 | - foreach( $this->_resource_changes as $version => $model_classnames ) { |
|
114 | - foreach( $model_classnames as $model_classname => $extra_fields ) { |
|
115 | - foreach( $extra_fields as $fieldname => $field_data ) { |
|
116 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ 'name' ] = $fieldname; |
|
117 | - foreach( $defaults as $attribute => $default_value ) { |
|
118 | - if( ! isset( $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] ) ) { |
|
119 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] = $default_value; |
|
113 | + foreach ($this->_resource_changes as $version => $model_classnames) { |
|
114 | + foreach ($model_classnames as $model_classname => $extra_fields) { |
|
115 | + foreach ($extra_fields as $fieldname => $field_data) { |
|
116 | + $this->_resource_changes[$model_classname][$fieldname]['name'] = $fieldname; |
|
117 | + foreach ($defaults as $attribute => $default_value) { |
|
118 | + if ( ! isset($this->_resource_changes[$model_classname][$fieldname][$attribute])) { |
|
119 | + $this->_resource_changes[$model_classname][$fieldname][$attribute] = $default_value; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | * @return array |
133 | 133 | */ |
134 | 134 | public function model_changes_between_requested_version_and_current() { |
135 | - if( $this->_cached_model_changes_between_requested_version_and_current === null ) { |
|
135 | + if ($this->_cached_model_changes_between_requested_version_and_current === null) { |
|
136 | 136 | $model_changes = array(); |
137 | - foreach( $this->model_changes() as $version => $models_changed_in_version ) { |
|
138 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
139 | - $model_changes[ $version ] = $models_changed_in_version; |
|
137 | + foreach ($this->model_changes() as $version => $models_changed_in_version) { |
|
138 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
139 | + $model_changes[$version] = $models_changed_in_version; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | $this->_cached_model_changes_between_requested_version_and_current = $model_changes; |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | */ |
154 | 154 | public function resource_changes_between_requested_version_and_current() { |
155 | - if( $this->_cached_resource_changes_between_requested_version_and_current === null ) { |
|
155 | + if ($this->_cached_resource_changes_between_requested_version_and_current === null) { |
|
156 | 156 | $resource_changes = array(); |
157 | - foreach( $this->resource_changes() as $version => $model_classnames ) { |
|
158 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
159 | - $resource_changes[ $version ] = $model_classnames; |
|
157 | + foreach ($this->resource_changes() as $version => $model_classnames) { |
|
158 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
159 | + $resource_changes[$version] = $model_classnames; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | $this->_cached_resource_changes_between_requested_version_and_current = $resource_changes; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * If a request was sent to 'wp-json/ee/v4.7/events' this would be '4.7' |
169 | 169 | * @return string like '4.6' |
170 | 170 | */ |
171 | - public function requested_version(){ |
|
171 | + public function requested_version() { |
|
172 | 172 | return $this->_requested_version; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * If a version is missing then we don't know anything about what changes it introduced from the previous version |
183 | 183 | * @return array |
184 | 184 | */ |
185 | - public function model_changes(){ |
|
185 | + public function model_changes() { |
|
186 | 186 | return $this->_model_changes; |
187 | 187 | } |
188 | 188 | |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @return array keys are model names, values are their classname |
194 | 194 | */ |
195 | 195 | public function models_for_requested_version() { |
196 | - if( $this->_cached_models_for_requested_version === null ) { |
|
196 | + if ($this->_cached_models_for_requested_version === null) { |
|
197 | 197 | $all_models_in_current_version = \EE_Registry::instance()->non_abstract_db_models; |
198 | - foreach( $this->model_changes_between_requested_version_and_current() as $version => $models_changed ) { |
|
199 | - foreach( $models_changed as $model_name => $new_indicator_or_fields_added ) { |
|
200 | - if( $new_indicator_or_fields_added === Model_Version_Info::model_added ) { |
|
201 | - unset( $all_models_in_current_version[ $model_name ] ); |
|
198 | + foreach ($this->model_changes_between_requested_version_and_current() as $version => $models_changed) { |
|
199 | + foreach ($models_changed as $model_name => $new_indicator_or_fields_added) { |
|
200 | + if ($new_indicator_or_fields_added === Model_Version_Info::model_added) { |
|
201 | + unset($all_models_in_current_version[$model_name]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * @param string $model_name eg 'Event' |
218 | 218 | * @return boolean |
219 | 219 | */ |
220 | - public function is_model_name_in_this_version( $model_name ) { |
|
220 | + public function is_model_name_in_this_version($model_name) { |
|
221 | 221 | $model_names = $this->models_for_requested_version(); |
222 | - if( isset( $model_names[ $model_name ] ) ) { |
|
222 | + if (isset($model_names[$model_name])) { |
|
223 | 223 | return true; |
224 | - }else{ |
|
224 | + } else { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | * @return \EEM_Base |
237 | 237 | * @throws \EE_Error |
238 | 238 | */ |
239 | - public function load_model( $model_name ) { |
|
240 | - if( $this->is_model_name_in_this_version( $model_name ) ) { |
|
241 | - return \EE_Registry::instance()->load_model( $model_name ); |
|
242 | - }else{ |
|
239 | + public function load_model($model_name) { |
|
240 | + if ($this->is_model_name_in_this_version($model_name)) { |
|
241 | + return \EE_Registry::instance()->load_model($model_name); |
|
242 | + } else { |
|
243 | 243 | throw new \EE_Error( |
244 | 244 | sprintf( |
245 | 245 | __( |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | * @param \EEM_Base $model |
262 | 262 | * @return array|\EE_Model_Field_Base[] |
263 | 263 | */ |
264 | - public function fields_on_model_in_this_version( $model ) { |
|
265 | - if( ! isset( $this->_cached_fields_on_models[ $model->get_this_model_name() ] ) ) { |
|
264 | + public function fields_on_model_in_this_version($model) { |
|
265 | + if ( ! isset($this->_cached_fields_on_models[$model->get_this_model_name()])) { |
|
266 | 266 | //get all model changes between the requested version and current core version |
267 | 267 | $changes = $this->model_changes_between_requested_version_and_current(); |
268 | 268 | //fetch all fields currently on this model |
269 | 269 | $current_fields = $model->field_settings(); |
270 | 270 | //remove all fields that have been added since |
271 | - foreach( $changes as $version => $changes_in_version ) { |
|
272 | - if( |
|
273 | - isset( $changes_in_version[ $model->get_this_model_name() ] ) |
|
274 | - && $changes_in_version[ $model->get_this_model_name() ] !== Model_Version_Info::model_added |
|
271 | + foreach ($changes as $version => $changes_in_version) { |
|
272 | + if ( |
|
273 | + isset($changes_in_version[$model->get_this_model_name()]) |
|
274 | + && $changes_in_version[$model->get_this_model_name()] !== Model_Version_Info::model_added |
|
275 | 275 | ) { |
276 | 276 | $current_fields = array_diff_key( |
277 | 277 | $current_fields, |
278 | - array_flip( $changes_in_version[ $model->get_this_model_name() ] ) |
|
278 | + array_flip($changes_in_version[$model->get_this_model_name()]) |
|
279 | 279 | ); |
280 | 280 | } |
281 | 281 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @param array $classnames |
294 | 294 | * @return boolean |
295 | 295 | */ |
296 | - public function is_subclass_of_one( $object, $classnames ) { |
|
297 | - foreach( $classnames as $classname ) { |
|
298 | - if( is_a( $object, $classname ) ) { |
|
296 | + public function is_subclass_of_one($object, $classnames) { |
|
297 | + foreach ($classnames as $classname) { |
|
298 | + if (is_a($object, $classname)) { |
|
299 | 299 | return true; |
300 | 300 | } |
301 | 301 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * Returns the list of model field classes that that the API basically ignores |
307 | 307 | * @return array |
308 | 308 | */ |
309 | - public function fields_ignored(){ |
|
309 | + public function fields_ignored() { |
|
310 | 310 | return apply_filters( |
311 | 311 | 'FHEE__Controller_Model_Read_fields_ignored', |
312 | - array( 'EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field' ) |
|
312 | + array('EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field') |
|
313 | 313 | ); |
314 | 314 | } |
315 | 315 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param EE_Model_Field_Base |
319 | 319 | * @return boolean |
320 | 320 | */ |
321 | - public function field_is_ignored( $field_obj ){ |
|
322 | - return $this->is_subclass_of_one( $field_obj, $this->fields_ignored() ); |
|
321 | + public function field_is_ignored($field_obj) { |
|
322 | + return $this->is_subclass_of_one($field_obj, $this->fields_ignored()); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | public function fields_that_have_rendered_format() { |
331 | 331 | return apply_filters( |
332 | 332 | 'FHEE__Controller_Model_Read__fields_raw', |
333 | - array( 'EE_Post_Content_Field', 'EE_Full_HTML_Field' ) |
|
333 | + array('EE_Post_Content_Field', 'EE_Full_HTML_Field') |
|
334 | 334 | ); |
335 | 335 | } |
336 | 336 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Model_Field_Base |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - public function field_has_rendered_format( $field_obj ){ |
|
343 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_rendered_format() ); |
|
342 | + public function field_has_rendered_format($field_obj) { |
|
343 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_rendered_format()); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function fields_that_have_pretty_format() { |
353 | 353 | return apply_filters( |
354 | 354 | 'FHEE__Controller_Model_Read__fields_pretty', |
355 | - array( 'EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field' ) |
|
355 | + array('EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field') |
|
356 | 356 | ); |
357 | 357 | } |
358 | 358 | |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * @param EE_Model_Field_Base |
362 | 362 | * @return boolean |
363 | 363 | */ |
364 | - public function field_has_pretty_format( $field_obj ){ |
|
365 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_pretty_format() ); |
|
364 | + public function field_has_pretty_format($field_obj) { |
|
365 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_pretty_format()); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | * @param \EEM_Base $model |
380 | 380 | * @return array |
381 | 381 | */ |
382 | - public function extra_resource_properties_for_model( $model ) { |
|
382 | + public function extra_resource_properties_for_model($model) { |
|
383 | 383 | $extra_properties = array(); |
384 | - foreach( $this->resource_changes_between_requested_version_and_current() as $version => $model_classnames ) { |
|
385 | - foreach( $model_classnames as $model_classname => $properties_added_in_this_version ) { |
|
386 | - if( is_subclass_of( $model, $model_classname ) ) { |
|
387 | - $extra_properties = array_merge( $extra_properties, $properties_added_in_this_version ); |
|
384 | + foreach ($this->resource_changes_between_requested_version_and_current() as $version => $model_classnames) { |
|
385 | + foreach ($model_classnames as $model_classname => $properties_added_in_this_version) { |
|
386 | + if (is_subclass_of($model, $model_classname)) { |
|
387 | + $extra_properties = array_merge($extra_properties, $properties_added_in_this_version); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param \EEM_Base $model |
398 | 398 | * @return \EE_Model_Relation_Base[] |
399 | 399 | */ |
400 | - public function relation_settings( \EEM_Base $model ) { |
|
400 | + public function relation_settings(\EEM_Base $model) { |
|
401 | 401 | $relations = array(); |
402 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
403 | - if( $this->is_model_name_in_this_version( $relation_name ) ) { |
|
404 | - $relations[ $relation_name ] = $relation_obj; |
|
402 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
403 | + if ($this->is_model_name_in_this_version($relation_name)) { |
|
404 | + $relations[$relation_name] = $relation_obj; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | //filter the results, but use the old filter name |
@@ -175,7 +175,7 @@ |
||
175 | 175 | * @param array $wpdb_row |
176 | 176 | * @param \WP_REST_Request $request |
177 | 177 | * @param Base $controller |
178 | - * @return int|null if permission denied |
|
178 | + * @return integer if permission denied |
|
179 | 179 | */ |
180 | 180 | public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){ |
181 | 181 | if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since $VID:$ |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Event extends Calculations_Base { |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | * @return int |
33 | 33 | * @throws \EE_Error |
34 | 34 | */ |
35 | - public static function optimum_sales_at_start( $wpdb_row, $request, $controller ){ |
|
36 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
37 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
35 | + public static function optimum_sales_at_start($wpdb_row, $request, $controller) { |
|
36 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
37 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
38 | 38 | } else { |
39 | 39 | $event_obj = null; |
40 | 40 | } |
41 | - if( $event_obj instanceof \EE_Event ) { |
|
42 | - return $event_obj->total_available_spaces( true ); |
|
41 | + if ($event_obj instanceof \EE_Event) { |
|
42 | + return $event_obj->total_available_spaces(true); |
|
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
47 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
48 | - print_r( $wpdb_row, true ) |
|
46 | + __('Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
47 | + $wpdb_row['Event_CPT.ID'], |
|
48 | + print_r($wpdb_row, true) |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | } |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @return int |
65 | 65 | * @throws \EE_Error |
66 | 66 | */ |
67 | - public static function optimum_sales_now( $wpdb_row, $request, $controller ){ |
|
68 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
69 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
67 | + public static function optimum_sales_now($wpdb_row, $request, $controller) { |
|
68 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
69 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
70 | 70 | } else { |
71 | 71 | $event_obj = null; |
72 | 72 | } |
73 | - if( $event_obj instanceof \EE_Event ) { |
|
74 | - return $event_obj->total_available_spaces( false ); |
|
73 | + if ($event_obj instanceof \EE_Event) { |
|
74 | + return $event_obj->total_available_spaces(false); |
|
75 | 75 | } else { |
76 | 76 | throw new \EE_Error( |
77 | 77 | sprintf( |
78 | - __( 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
79 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
80 | - print_r( $wpdb_row, true ) |
|
78 | + __('Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
79 | + $wpdb_row['Event_CPT.ID'], |
|
80 | + print_r($wpdb_row, true) |
|
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | } |
@@ -95,20 +95,20 @@ discard block |
||
95 | 95 | * @return int |
96 | 96 | * @throws \EE_Error |
97 | 97 | */ |
98 | - public static function spaces_remaining( $wpdb_row, $request, $controller ){ |
|
99 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
100 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
98 | + public static function spaces_remaining($wpdb_row, $request, $controller) { |
|
99 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
100 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
101 | 101 | } else { |
102 | 102 | $event_obj = null; |
103 | 103 | } |
104 | - if( $event_obj instanceof \EE_Event ) { |
|
104 | + if ($event_obj instanceof \EE_Event) { |
|
105 | 105 | return $event_obj->spaces_remaining_for_sale(); |
106 | 106 | } else { |
107 | 107 | throw new \EE_Error( |
108 | 108 | sprintf( |
109 | - __( 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
110 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
111 | - print_r( $wpdb_row, true ) |
|
109 | + __('Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
110 | + $wpdb_row['Event_CPT.ID'], |
|
111 | + print_r($wpdb_row, true) |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | } |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | * @return int |
127 | 127 | * @throws \EE_Error |
128 | 128 | */ |
129 | - public static function spots_taken( $wpdb_row, $request, $controller ){ |
|
130 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
129 | + public static function spots_taken($wpdb_row, $request, $controller) { |
|
130 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
131 | 131 | throw new \EE_Error( |
132 | 132 | sprintf( |
133 | - __( 'Cannot calculate spots_taken because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
134 | - print_r( $wpdb_row, true ) |
|
133 | + __('Cannot calculate spots_taken because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
134 | + print_r($wpdb_row, true) |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | } |
138 | 138 | return \EEM_Registration::instance()->count( |
139 | 139 | array( |
140 | 140 | array( |
141 | - 'EVT_ID' => $wpdb_row[ 'Event_CPT.ID' ], |
|
141 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
142 | 142 | 'STS_ID' => \EEM_Registration::status_id_approved |
143 | 143 | ) |
144 | 144 | ), |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | * @throws \EE_Error |
161 | 161 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
162 | 162 | */ |
163 | - public static function spots_taken_pending_payment( $wpdb_row, $request, $controller ){ |
|
164 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
163 | + public static function spots_taken_pending_payment($wpdb_row, $request, $controller) { |
|
164 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
165 | 165 | throw new \EE_Error( |
166 | 166 | sprintf( |
167 | - __( 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
168 | - print_r( $wpdb_row, true ) |
|
167 | + __('Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
168 | + print_r($wpdb_row, true) |
|
169 | 169 | ) |
170 | 170 | ); |
171 | 171 | } |
172 | - self::_verify_current_user_can( 'ee_read_registrations', 'spots_taken_pending_payment' ); |
|
172 | + self::_verify_current_user_can('ee_read_registrations', 'spots_taken_pending_payment'); |
|
173 | 173 | return \EEM_Registration::instance()->count( |
174 | 174 | array( |
175 | 175 | array( |
176 | - 'EVT_ID' => $wpdb_row[ 'Event_CPT.ID' ], |
|
176 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
177 | 177 | 'STS_ID' => \EEM_Registration::status_id_pending_payment |
178 | 178 | ) |
179 | 179 | ), |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | * @throws \EE_Error |
196 | 196 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
197 | 197 | */ |
198 | - public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){ |
|
199 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
198 | + public static function registrations_checked_in_count($wpdb_row, $request, $controller) { |
|
199 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
200 | 200 | throw new \EE_Error( |
201 | 201 | sprintf( |
202 | - __( 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
203 | - print_r( $wpdb_row, true ) |
|
202 | + __('Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
203 | + print_r($wpdb_row, true) |
|
204 | 204 | ) |
205 | 205 | ); |
206 | 206 | } |
207 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_in_count' ); |
|
208 | - return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], true ); |
|
207 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_in_count'); |
|
208 | + return \EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -221,17 +221,17 @@ discard block |
||
221 | 221 | * @throws \EE_Error |
222 | 222 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
223 | 223 | */ |
224 | - public static function registrations_checked_out_count( $wpdb_row, $request, $controller ){ |
|
225 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
224 | + public static function registrations_checked_out_count($wpdb_row, $request, $controller) { |
|
225 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
226 | 226 | throw new \EE_Error( |
227 | 227 | sprintf( |
228 | - __( 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
229 | - print_r( $wpdb_row, true ) |
|
228 | + __('Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
229 | + print_r($wpdb_row, true) |
|
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | } |
233 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_out_count' ); |
|
234 | - return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], false ); |
|
233 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_out_count'); |
|
234 | + return \EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @param Base $controller |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public static function image_thumbnail( $wpdb_row, $request, $controller ) { |
|
245 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'thumbnail' ); |
|
244 | + public static function image_thumbnail($wpdb_row, $request, $controller) { |
|
245 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'thumbnail'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param Base $controller |
253 | 253 | * @return array |
254 | 254 | */ |
255 | - public static function image_medium( $wpdb_row, $request, $controller ) { |
|
256 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'medium' ); |
|
255 | + public static function image_medium($wpdb_row, $request, $controller) { |
|
256 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'medium'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | * @param Base $controller |
264 | 264 | * @return array |
265 | 265 | */ |
266 | - public static function image_medium_large( $wpdb_row, $request, $controller ) { |
|
267 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'medium_large' ); |
|
266 | + public static function image_medium_large($wpdb_row, $request, $controller) { |
|
267 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'medium_large'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param Base $controller |
275 | 275 | * @return array |
276 | 276 | */ |
277 | - public static function image_large( $wpdb_row, $request, $controller ) { |
|
278 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'large' ); |
|
277 | + public static function image_large($wpdb_row, $request, $controller) { |
|
278 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'large'); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | * @param Base $controller |
286 | 286 | * @return array |
287 | 287 | */ |
288 | - public static function image_post_thumbnail( $wpdb_row, $request, $controller ) { |
|
289 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'post-thumbnail' ); |
|
288 | + public static function image_post_thumbnail($wpdb_row, $request, $controller) { |
|
289 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'post-thumbnail'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param Base $controller |
297 | 297 | * @return array |
298 | 298 | */ |
299 | - public static function image_full( $wpdb_row, $request, $controller ) { |
|
300 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'full' ); |
|
299 | + public static function image_full($wpdb_row, $request, $controller) { |
|
300 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'full'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
308 | 308 | * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
309 | 309 | */ |
310 | - protected static function _calculate_image_data( $EVT_ID, $image_size ) { |
|
311 | - $attachment_id = get_post_thumbnail_id( $EVT_ID ); |
|
312 | - $data = wp_get_attachment_image_src( $attachment_id, $image_size ); |
|
313 | - if( ! $data ) { |
|
310 | + protected static function _calculate_image_data($EVT_ID, $image_size) { |
|
311 | + $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
312 | + $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
313 | + if ( ! $data) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | - if( isset( $data[ 3] ) ) { |
|
317 | - $generated = $data[ 3 ]; |
|
316 | + if (isset($data[3])) { |
|
317 | + $generated = $data[3]; |
|
318 | 318 | } else { |
319 | 319 | $generated = true; |
320 | 320 | } |
321 | 321 | return array( |
322 | - 'url' => $data[ 0 ], |
|
323 | - 'width' => $data[ 1 ], |
|
324 | - 'height' => $data[ 2 ], |
|
322 | + 'url' => $data[0], |
|
323 | + 'width' => $data[1], |
|
324 | + 'height' => $data[2], |
|
325 | 325 | 'generated' => $generated |
326 | 326 | ); |
327 | 327 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Prepares incoming data from the json or $_REQUEST parameters for the models' |
57 | 57 | * "$query_params". |
58 | - * @param EE_Model_Field_Base $field_obj |
|
58 | + * @param \EE_Model_Field_Base $field_obj |
|
59 | 59 | * @param mixed $original_value |
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
@@ -77,6 +77,7 @@ discard block |
||
77 | 77 | * Prepares a field's value for display in the API |
78 | 78 | * @param \EE_Model_Field_Base $field_obj |
79 | 79 | * @param mixed $original_value |
80 | + * @param string $requested_version |
|
80 | 81 | * @return mixed |
81 | 82 | */ |
82 | 83 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
@@ -131,6 +132,9 @@ discard block |
||
131 | 132 | return $query_param_for_models; |
132 | 133 | } |
133 | 134 | |
135 | + /** |
|
136 | + * @return string |
|
137 | + */ |
|
134 | 138 | public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
135 | 139 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 140 | if($pos_of_star === FALSE){ |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Prepares a field's value for display in the API |
|
78 | - * @param \EE_Model_Field_Base $field_obj |
|
79 | - * @param mixed $original_value |
|
80 | - * @return mixed |
|
81 | - */ |
|
77 | + * Prepares a field's value for display in the API |
|
78 | + * @param \EE_Model_Field_Base $field_obj |
|
79 | + * @param mixed $original_value |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | 82 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
83 | 83 | if( $original_value === EE_INF ) { |
84 | 84 | $new_value = self::ee_inf_in_rest; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $original_value, |
96 | 96 | $requested_version |
97 | 97 | ); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Prepares condition-query-parameters (like what's in where and having) from |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
25 | - exit( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | + exit('No direct script access allowed'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $requested_version |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
44 | - if( is_array( $original_value_maybe_array ) ) { |
|
43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
44 | + if (is_array($original_value_maybe_array)) { |
|
45 | 45 | $new_value_maybe_array = array(); |
46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
47 | - $new_value_maybe_array[ $array_key ] = self::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
47 | + $new_value_maybe_array[$array_key] = self::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $new_value_maybe_array = self::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
50 | + $new_value_maybe_array = self::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
51 | 51 | } |
52 | 52 | return $new_value_maybe_array; |
53 | 53 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
63 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
64 | 64 | $new_value = null; |
65 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
65 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | + && in_array($original_value, array(null, ''), true)) { |
|
67 | 67 | $new_value = EE_INF; |
68 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
69 | - $new_value = rest_parse_date( $original_value ); |
|
68 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
69 | + $new_value = rest_parse_date($original_value); |
|
70 | 70 | } else { |
71 | 71 | $new_value = $original_value; |
72 | 72 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | * @param mixed $original_value |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
83 | - if( $original_value === EE_INF ) { |
|
82 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
83 | + if ($original_value === EE_INF) { |
|
84 | 84 | $new_value = self::ee_inf_in_rest; |
85 | - } elseif( $field_obj instanceof \EE_Datetime_Field && |
|
86 | - $original_value instanceof \DateTime ) { |
|
87 | - $new_value = $original_value->format( 'c' ); |
|
88 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
85 | + } elseif ($field_obj instanceof \EE_Datetime_Field && |
|
86 | + $original_value instanceof \DateTime) { |
|
87 | + $new_value = $original_value->format('c'); |
|
88 | + $new_value = mysql_to_rfc3339($new_value); |
|
89 | 89 | } else { |
90 | 90 | $new_value = $original_value; |
91 | 91 | } |
92 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
92 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
93 | 93 | $new_value, |
94 | 94 | $field_obj, |
95 | 95 | $original_value, |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | * @param string $requested_version |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
108 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
109 | 109 | $query_param_for_models = array(); |
110 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
110 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
111 | 111 | $field = self::deduce_field_from_query_param( |
112 | - self::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
112 | + self::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
113 | 113 | $model |
114 | 114 | ); |
115 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
115 | + if ($field instanceof \EE_Model_Field_Base) { |
|
116 | 116 | //did they specify an operator? |
117 | - if( is_array( $query_param_value ) ) { |
|
118 | - $op = $query_param_value[ 0 ]; |
|
119 | - $value = $query_param_value[ 1 ]; |
|
120 | - $new_value = self::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
121 | - $translated_value = array( $op, $new_value ); |
|
117 | + if (is_array($query_param_value)) { |
|
118 | + $op = $query_param_value[0]; |
|
119 | + $value = $query_param_value[1]; |
|
120 | + $new_value = self::prepare_field_values_from_json($field, $value, $requested_version); |
|
121 | + $translated_value = array($op, $new_value); |
|
122 | 122 | } else { |
123 | - $translated_value = self::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
123 | + $translated_value = self::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
124 | 124 | } |
125 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
125 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
126 | 126 | } else { |
127 | 127 | //so it's not for a field, assume it's a logic query param key |
128 | - $query_param_for_models[ $query_param_key ] = self::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
128 | + $query_param_for_models[$query_param_key] = self::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | return $query_param_for_models; |
132 | 132 | } |
133 | 133 | |
134 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
134 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | - if($pos_of_star === FALSE){ |
|
136 | + if ($pos_of_star === FALSE) { |
|
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else { |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | * @throws EE_Error |
148 | 148 | * @return EE_Model_Field_Base |
149 | 149 | */ |
150 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
150 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
151 | 151 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
152 | 152 | //which will help us find the database table and column |
153 | 153 | |
154 | - $query_param_parts = explode(".",$query_param_name); |
|
155 | - if(empty($query_param_parts)){ |
|
156 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
154 | + $query_param_parts = explode(".", $query_param_name); |
|
155 | + if (empty($query_param_parts)) { |
|
156 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
157 | 157 | } |
158 | 158 | $number_of_parts = count($query_param_parts); |
159 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
160 | - if($number_of_parts == 1){ |
|
159 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
160 | + if ($number_of_parts == 1) { |
|
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else {// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
165 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
166 | 166 | } |
167 | - try{ |
|
167 | + try { |
|
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch (\EE_Error $e) { |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 136 | if($pos_of_star === FALSE){ |
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else{ |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
160 | 160 | if($number_of_parts == 1){ |
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else{// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | 165 | $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
166 | 166 | } |
167 | 167 | try{ |
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch(\EE_Error $e){ |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |