@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param string $timezone |
36 | 36 | * @return EE_Ticket_Price|mixed |
37 | 37 | */ |
38 | - public static function new_instance( $props_n_values = array(), $timezone = '', $date_formats = array() ) { |
|
39 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
40 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone, $date_formats ); |
|
38 | + public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
40 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone, $date_formats); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param string $timezone |
48 | 48 | * @return EE_Ticket_Price |
49 | 49 | */ |
50 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) { |
|
51 | - return new self( $props_n_values, TRUE, $timezone ); |
|
50 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') { |
|
51 | + return new self($props_n_values, TRUE, $timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | //is for lower than 4.8.33 |
14 | 14 | add_filter( |
15 | 15 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
16 | - array( $this, 'remove_checkin_routes_earlier_than_4_8_33' ), |
|
16 | + array($this, 'remove_checkin_routes_earlier_than_4_8_33'), |
|
17 | 17 | 10, |
18 | 18 | 2 |
19 | 19 | ); |
20 | 20 | add_filter( |
21 | 21 | 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return', |
22 | - array( $this, 'dont_add_headers_from_ee_notices' ), |
|
22 | + array($this, 'dont_add_headers_from_ee_notices'), |
|
23 | 23 | 10, |
24 | 24 | 2 |
25 | 25 | ); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @param string $version |
33 | 33 | * @return array like $routes_on_this_version |
34 | 34 | */ |
35 | - public function remove_checkin_routes_earlier_than_4_8_33( $routes_on_this_version, $version ) { |
|
36 | - if( $this->applies_to_version( $version ) ) { |
|
37 | - unset( $routes_on_this_version[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] ); |
|
35 | + public function remove_checkin_routes_earlier_than_4_8_33($routes_on_this_version, $version) { |
|
36 | + if ($this->applies_to_version($version)) { |
|
37 | + unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']); |
|
38 | 38 | } |
39 | 39 | return $routes_on_this_version; |
40 | 40 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param string $requested_version |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - public function dont_add_headers_from_ee_notices( $headers_from_ee_notices, $requested_version ) { |
|
49 | - if( $this->applies_to_version( $requested_version ) ) { |
|
48 | + public function dont_add_headers_from_ee_notices($headers_from_ee_notices, $requested_version) { |
|
49 | + if ($this->applies_to_version($requested_version)) { |
|
50 | 50 | return array(); |
51 | 51 | } |
52 | 52 | return $headers_from_ee_notices; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @return boolean true: this class' name indicates its filters and actions |
57 | 57 | * should take effect. False: this class' name indicates it shouldn't do anything |
58 | 58 | */ |
59 | - public function applies_to_version( $requested_version ) { |
|
60 | - if( $this->version() > $requested_version ) { |
|
59 | + public function applies_to_version($requested_version) { |
|
60 | + if ($this->version() > $requested_version) { |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | return false; |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | * @throws \EE_Error |
72 | 72 | */ |
73 | 73 | public function version() { |
74 | - if( $this->_version === null ) { |
|
74 | + if ($this->_version === null) { |
|
75 | 75 | $matches = array(); |
76 | 76 | $regex = '~Changes_In_(.*)_(.*)_(.*)$~'; |
77 | 77 | $success = preg_match( |
78 | 78 | $regex, |
79 | - get_class( $this ), |
|
79 | + get_class($this), |
|
80 | 80 | $matches |
81 | 81 | ); |
82 | - if( ! $success ) { |
|
82 | + if ( ! $success) { |
|
83 | 83 | throw new \EE_Error( |
84 | 84 | sprintf( |
85 | - __( 'The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso' ), |
|
86 | - get_class( $this ), |
|
85 | + __('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'), |
|
86 | + get_class($this), |
|
87 | 87 | $regex |
88 | 88 | ) |
89 | 89 | ); |
90 | 90 | } |
91 | - $this->_version = $matches[1] . '.' . $matches[2] . '.' . $matches[3]; |
|
91 | + $this->_version = $matches[1].'.'.$matches[2].'.'.$matches[3]; |
|
92 | 92 | } |
93 | 93 | return $this->_version; |
94 | 94 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\rest_api\controllers\Base as Base; |
3 | 3 | use EventEspresso\core\libraries\rest_api\controllers\model\Read; |
4 | 4 | |
5 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
6 | - exit( 'No direct script access allowed' ); |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /** |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | * @param \WP_REST_Request $request |
25 | 25 | * @return \WP_Error|\WP_REST_Response |
26 | 26 | */ |
27 | - public static function handle_request_toggle_checkin( \WP_REST_Request $request ) { |
|
27 | + public static function handle_request_toggle_checkin(\WP_REST_Request $request) { |
|
28 | 28 | $controller = new Checkin(); |
29 | - return $controller->_create_checkin_checkout_object( $request ); |
|
29 | + return $controller->_create_checkin_checkout_object($request); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -37,47 +37,47 @@ discard block |
||
37 | 37 | * @param \WP_REST_Request $request |
38 | 38 | * @return \WP_Error|\WP_REST_Response |
39 | 39 | */ |
40 | - protected function _create_checkin_checkout_object( \WP_REST_Request $request ) { |
|
41 | - $reg_id = $request->get_param( 'REG_ID' ); |
|
42 | - $dtt_id = $request->get_param( 'DTT_ID' ); |
|
43 | - $force = $request->get_param( 'force' ); |
|
44 | - if( $force == 'true' ) { |
|
40 | + protected function _create_checkin_checkout_object(\WP_REST_Request $request) { |
|
41 | + $reg_id = $request->get_param('REG_ID'); |
|
42 | + $dtt_id = $request->get_param('DTT_ID'); |
|
43 | + $force = $request->get_param('force'); |
|
44 | + if ($force == 'true') { |
|
45 | 45 | $force = true; |
46 | 46 | } else { |
47 | 47 | $force = false; |
48 | 48 | } |
49 | - $reg = \EEM_Registration::instance()->get_one_by_ID( $reg_id ); |
|
50 | - if( ! $reg instanceof \EE_Registration ) { |
|
49 | + $reg = \EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
50 | + if ( ! $reg instanceof \EE_Registration) { |
|
51 | 51 | return $this->send_response( |
52 | 52 | new \WP_Error( |
53 | 53 | 'rest_registration_toggle_checkin_invalid_id', |
54 | 54 | sprintf( |
55 | - __( 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso' ), |
|
55 | + __('You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso'), |
|
56 | 56 | $reg_id |
57 | 57 | ), |
58 | - array( 'status' => 422 ) |
|
58 | + array('status' => 422) |
|
59 | 59 | ) |
60 | 60 | ); |
61 | 61 | } |
62 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id ) ) { |
|
62 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
63 | 63 | return $this->send_response( |
64 | 64 | new \WP_Error( |
65 | 65 | 'rest_user_cannot_toggle_checkin', |
66 | 66 | sprintf( |
67 | - __( 'You are not allowed to checkin registration with ID %1$s.', 'event_espresso' ), |
|
67 | + __('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
68 | 68 | $reg_id |
69 | 69 | ), |
70 | - array( 'status' => 403 ) |
|
70 | + array('status' => 403) |
|
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | } |
74 | - $success = $reg->toggle_checkin_status( $dtt_id, ! $force ); |
|
75 | - if( $success === false ) { |
|
74 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
75 | + if ($success === false) { |
|
76 | 76 | //rely on EE_Error::add_error messages to have been added to give more data about hwy it failed |
77 | 77 | return $this->send_response( |
78 | 78 | new \WP_Error( |
79 | 79 | 'rest_toggle_checkin_failed', |
80 | - __( 'Registration checkin failed. Please see additional error data.', 'event_espresso' ) |
|
80 | + __('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | } |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | ) |
93 | 93 | ) |
94 | 94 | ); |
95 | - if( ! $checkin instanceof \EE_Checkin ) { |
|
95 | + if ( ! $checkin instanceof \EE_Checkin) { |
|
96 | 96 | return $this->send_response( |
97 | 97 | new \WP_Error( |
98 | 98 | 'rest_toggle_checkin_error', |
99 | 99 | sprintf( |
100 | - __( 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso' ), |
|
100 | + __('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso'), |
|
101 | 101 | $reg_id, |
102 | 102 | $dtt_id |
103 | 103 | ) |
104 | 104 | ) |
105 | 105 | ); |
106 | 106 | } |
107 | - $requested_version = $this->get_requested_version( $request->get_route() ); |
|
107 | + $requested_version = $this->get_requested_version($request->get_route()); |
|
108 | 108 | $get_request = new \WP_REST_Request( |
109 | 109 | 'GET', |
110 | - \EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID() |
|
110 | + \EED_Core_Rest_Api::ee_api_namespace.$requested_version.'/checkins/'.$checkin->ID() |
|
111 | 111 | ); |
112 | 112 | $get_request->set_url_params( |
113 | 113 | array( |
114 | 114 | 'id' => $checkin->ID() |
115 | 115 | ) |
116 | 116 | ); |
117 | - return Read::handle_request_get_one( $get_request ); |
|
117 | + return Read::handle_request_get_one($get_request); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -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 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param EE_Admin_Page $admin_page |
45 | 45 | */ |
46 | - public function __construct( $admin_page ) { |
|
46 | + public function __construct($admin_page) { |
|
47 | 47 | parent::__construct($admin_page); |
48 | - require_once( EE_HELPERS . 'EEH_DTT_Helper.helper.php' ); |
|
48 | + require_once(EE_HELPERS.'EEH_DTT_Helper.helper.php'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function _setup_data() { |
56 | 56 | $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
57 | - $this->_all_data_count = $this->_admin_page->get_events(0,0, TRUE); |
|
57 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, TRUE); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | $this->_sortable_columns = array( |
88 | - 'id' => array( 'EVT_ID' => true ), |
|
89 | - 'name' => array( 'EVT_name' => false ), |
|
90 | - 'author' => array( 'EVT_wp_user' => false ), |
|
91 | - 'venue' => array( 'Venue.VNU_name' => false ), |
|
88 | + 'id' => array('EVT_ID' => true), |
|
89 | + 'name' => array('EVT_name' => false), |
|
90 | + 'author' => array('EVT_wp_user' => false), |
|
91 | + 'venue' => array('Venue.VNU_name' => false), |
|
92 | 92 | 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
93 | 93 | 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
94 | 94 | ); |
95 | 95 | |
96 | 96 | $this->_primary_column = 'id'; |
97 | 97 | |
98 | - $this->_hidden_columns = array( 'author' ); |
|
98 | + $this->_hidden_columns = array('author'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | protected function _add_view_counts() { |
114 | 114 | $this->_views['all']['count'] = $this->_admin_page->total_events(); |
115 | 115 | $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
116 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
116 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
117 | 117 | $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
118 | 118 | } |
119 | 119 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - protected function _get_row_class( $item ) { |
|
128 | - $class = parent::_get_row_class( $item ); |
|
127 | + protected function _get_row_class($item) { |
|
128 | + $class = parent::_get_row_class($item); |
|
129 | 129 | //add status class |
130 | - $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-' . $item->get_active_status() : ''; |
|
131 | - if ( $this->_has_checkbox_column ) { |
|
130 | + $class .= $item instanceof EE_Event ? ' ee-status-strip event-status-'.$item->get_active_status() : ''; |
|
131 | + if ($this->_has_checkbox_column) { |
|
132 | 132 | $class .= ' has-checkbox-column'; |
133 | 133 | } |
134 | 134 | return $class; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function column_status( EE_Event $item ) { |
|
144 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>'; |
|
143 | + public function column_status(EE_Event $item) { |
|
144 | + return '<span class="ee-status-strip ee-status-strip-td event-status-'.$item->get_active_status().'"></span>'; |
|
145 | 145 | }/**/ |
146 | 146 | |
147 | 147 | |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function column_cb( $item ) { |
|
154 | - if ( ! $item instanceof EE_Event ) { |
|
153 | + public function column_cb($item) { |
|
154 | + if ( ! $item instanceof EE_Event) { |
|
155 | 155 | return ''; |
156 | 156 | } |
157 | 157 | $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
158 | 158 | |
159 | 159 | //does event have any attached registrations? |
160 | - $regs = $item->count_related( 'Registration' ); |
|
160 | + $regs = $item->count_related('Registration'); |
|
161 | 161 | return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf( |
162 | 162 | '<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID() |
163 | 163 | ); |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return mixed|string |
171 | 171 | */ |
172 | - public function column_id( EE_Event $item ) { |
|
172 | + public function column_id(EE_Event $item) { |
|
173 | 173 | $content = $item->ID(); |
174 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
174 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
175 | 175 | return $content; |
176 | 176 | } |
177 | 177 | |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function column_name( EE_Event $item ) { |
|
184 | + public function column_name(EE_Event $item) { |
|
185 | 185 | $edit_query_args = array( |
186 | 186 | 'action' => 'edit', |
187 | 187 | 'post' => $item->ID() |
188 | 188 | ); |
189 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
190 | - $actions = $this->_column_name_action_setup( $item ); |
|
189 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
190 | + $actions = $this->_column_name_action_setup($item); |
|
191 | 191 | $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
192 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status; |
|
193 | - $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->get_active_status(), false, 'sentence' ) . '</span>'; |
|
192 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>'.$status; |
|
193 | + $content .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->get_active_status(), false, 'sentence').'</span>'; |
|
194 | 194 | $content .= $this->row_actions($actions); |
195 | 195 | return $content; |
196 | 196 | |
@@ -207,72 +207,72 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return array array of actions |
209 | 209 | */ |
210 | - protected function _column_name_action_setup( EE_Event $item ) { |
|
210 | + protected function _column_name_action_setup(EE_Event $item) { |
|
211 | 211 | //todo: remove when attendees is active |
212 | - if ( !defined('REG_ADMIN_URL') ) |
|
212 | + if ( ! defined('REG_ADMIN_URL')) |
|
213 | 213 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
214 | 214 | |
215 | 215 | $actions = array(); |
216 | 216 | |
217 | - if ( EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID() ) ) { |
|
217 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
218 | 218 | $edit_query_args = array( |
219 | 219 | 'action' => 'edit', |
220 | 220 | 'post' => $item->ID() |
221 | 221 | ); |
222 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
223 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; |
|
222 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
223 | + $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
227 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) { |
|
227 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) { |
|
228 | 228 | $attendees_query_args = array( |
229 | 229 | 'action' => 'default', |
230 | 230 | 'event_id' => $item->ID() |
231 | 231 | ); |
232 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
233 | - $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>'; |
|
232 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
233 | + $actions['attendees'] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrations', 'event_espresso').'">'.__('Registrations', 'event_espresso').'</a>'; |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) { |
|
236 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) { |
|
237 | 237 | $trash_event_query_args = array( |
238 | 238 | 'action' => 'trash_event', |
239 | 239 | 'EVT_ID' => $item->ID() |
240 | 240 | ); |
241 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( $trash_event_query_args, EVENTS_ADMIN_URL ); |
|
241 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, EVENTS_ADMIN_URL); |
|
242 | 242 | } |
243 | 243 | |
244 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) { |
|
244 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) { |
|
245 | 245 | $restore_event_query_args = array( |
246 | 246 | 'action' => 'restore_event', |
247 | 247 | 'EVT_ID' => $item->ID() |
248 | 248 | ); |
249 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( $restore_event_query_args, EVENTS_ADMIN_URL ); |
|
249 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, EVENTS_ADMIN_URL); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) { |
|
252 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) { |
|
253 | 253 | $delete_event_query_args = array( |
254 | 254 | 'action' => 'delete_event', |
255 | 255 | 'EVT_ID' => $item->ID() |
256 | 256 | ); |
257 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( $delete_event_query_args, EVENTS_ADMIN_URL ); |
|
257 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, EVENTS_ADMIN_URL); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | $view_link = get_permalink($item->ID()); |
261 | 261 | |
262 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>'; |
|
262 | + $actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'">'.__('View', 'event_espresso').'</a>'; |
|
263 | 263 | |
264 | - switch ( $item->get( 'status' ) ) { |
|
264 | + switch ($item->get('status')) { |
|
265 | 265 | case 'trash' : |
266 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) { |
|
267 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>'; |
|
266 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) { |
|
267 | + $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" title="'.esc_attr__('Restore from Trash', 'event_espresso').'">'.__('Restore from Trash', 'event_espresso').'</a>'; |
|
268 | 268 | } |
269 | - if ( $item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) { |
|
270 | - $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
269 | + if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) { |
|
270 | + $actions['delete'] = '<a href="'.$delete_event_link.'" title="'.esc_attr__('Delete Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
271 | 271 | } |
272 | 272 | break; |
273 | 273 | default : |
274 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) { |
|
275 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
274 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) { |
|
275 | + $actions['move to trash'] = '<a href="'.$trash_event_link.'" title="'.esc_attr__('Trash Event', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | return $actions; |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - public function column_author( EE_Event $item ) { |
|
287 | + public function column_author(EE_Event $item) { |
|
288 | 288 | //user author info |
289 | - $event_author = get_userdata( $item->wp_user() ); |
|
290 | - $gravatar = get_avatar( $item->wp_user(), '15' ); |
|
289 | + $event_author = get_userdata($item->wp_user()); |
|
290 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
291 | 291 | //filter link |
292 | 292 | $query_args = array( |
293 | 293 | 'action' => 'default', |
294 | 294 | 'EVT_wp_user' => $item->wp_user() |
295 | 295 | ); |
296 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce( $query_args, EVENTS_ADMIN_URL ); |
|
297 | - return $gravatar . ' <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' . $event_author->display_name . '</a>'; |
|
296 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
297 | + return $gravatar.' <a href="'.$filter_url.'" title="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">'.$event_author->display_name.'</a>'; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - public function column_venue( EE_Event $item ) { |
|
307 | - $venue = $item->get_first_related( 'Venue' ); |
|
308 | - return !empty( $venue ) ? $venue->name() : ''; |
|
306 | + public function column_venue(EE_Event $item) { |
|
307 | + $venue = $item->get_first_related('Venue'); |
|
308 | + return ! empty($venue) ? $venue->name() : ''; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @throws EE_Error |
316 | 316 | */ |
317 | - public function column_start_date_time( EE_Event $item ) { |
|
318 | - echo !empty( $this->_dtt ) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso'); |
|
317 | + public function column_start_date_time(EE_Event $item) { |
|
318 | + echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso'); |
|
319 | 319 | //display in user's timezone? |
320 | - echo !empty( $this->_dtt ) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ' ) : ''; |
|
320 | + echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ') : ''; |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @throws EE_Error |
329 | 329 | */ |
330 | - public function column_reg_begins( EE_Event $item ) { |
|
330 | + public function column_reg_begins(EE_Event $item) { |
|
331 | 331 | $reg_start = $item->get_ticket_with_earliest_start_time(); |
332 | - echo !empty( $reg_start ) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso'); |
|
332 | + echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso'); |
|
333 | 333 | //display in user's timezone? |
334 | - echo !empty( $reg_start ) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ' ) : '';/**/ |
|
334 | + echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ') : ''; /**/ |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return int|string |
342 | 342 | */ |
343 | - public function column_attendees( EE_Event $item ) { |
|
343 | + public function column_attendees(EE_Event $item) { |
|
344 | 344 | $attendees_query_args = array( |
345 | 345 | 'action' => 'default', |
346 | 346 | 'event_id' => $item->ID() |
347 | 347 | ); |
348 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
349 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count( $item->ID() ); |
|
350 | - return EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees; |
|
348 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
349 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
350 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' : $registered_attendees; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return float |
358 | 358 | */ |
359 | - public function column_tkts_sold( EE_Event $item ) { |
|
360 | - return EEM_Ticket::instance()->sum(array( array('Datetime.EVT_ID' => $item->ID() )), 'TKT_sold' ); |
|
359 | + public function column_tkts_sold(EE_Event $item) { |
|
360 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
@@ -366,38 +366,38 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function column_actions( EE_Event $item ) { |
|
369 | + public function column_actions(EE_Event $item) { |
|
370 | 370 | //todo: remove when attendees is active |
371 | - if ( !defined('REG_ADMIN_URL') ) |
|
371 | + if ( ! defined('REG_ADMIN_URL')) |
|
372 | 372 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
373 | 373 | $actionlinks = array(); |
374 | 374 | |
375 | 375 | $view_link = get_permalink($item->ID()); |
376 | 376 | |
377 | - $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
377 | + $actionlinks[] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">'; |
|
378 | 378 | $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>'; |
379 | 379 | |
380 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $item->ID() ) ) { |
|
380 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
381 | 381 | $edit_query_args = array( |
382 | 382 | 'action' => 'edit', |
383 | 383 | 'post' => $item->ID() |
384 | 384 | ); |
385 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
386 | - $actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
385 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
386 | + $actionlinks[] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
387 | 387 | } |
388 | 388 | |
389 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) { |
|
389 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) { |
|
390 | 390 | $attendees_query_args = array( |
391 | 391 | 'action' => 'default', |
392 | 392 | 'event_id' => $item->ID() |
393 | 393 | ); |
394 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
395 | - $actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>'; |
|
394 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
395 | + $actionlinks[] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrants', 'event_espresso').'"><div class="dashicons dashicons-groups"></div></a>'; |
|
396 | 396 | } |
397 | 397 | |
398 | - $actionlinks = apply_filters( 'FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item ); |
|
398 | + $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item); |
|
399 | 399 | |
400 | - return $this->_action_string( implode( "\n\t", $actionlinks ), $item, 'div' ); |
|
400 | + return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div'); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 |
@@ -167,7 +167,7 @@ |
||
167 | 167 | /** |
168 | 168 | * @param EE_Event $item |
169 | 169 | * |
170 | - * @return mixed|string |
|
170 | + * @return string |
|
171 | 171 | */ |
172 | 172 | public function column_id( EE_Event $item ) { |
173 | 173 | $content = $item->ID(); |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -209,8 +210,9 @@ discard block |
||
209 | 210 | */ |
210 | 211 | protected function _column_name_action_setup( EE_Event $item ) { |
211 | 212 | //todo: remove when attendees is active |
212 | - if ( !defined('REG_ADMIN_URL') ) |
|
213 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
213 | + if ( !defined('REG_ADMIN_URL') ) { |
|
214 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
215 | + } |
|
214 | 216 | |
215 | 217 | $actions = array(); |
216 | 218 | |
@@ -368,8 +370,9 @@ discard block |
||
368 | 370 | */ |
369 | 371 | public function column_actions( EE_Event $item ) { |
370 | 372 | //todo: remove when attendees is active |
371 | - if ( !defined('REG_ADMIN_URL') ) |
|
372 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
373 | + if ( !defined('REG_ADMIN_URL') ) { |
|
374 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
375 | + } |
|
373 | 376 | $actionlinks = array(); |
374 | 377 | |
375 | 378 | $view_link = get_permalink($item->ID()); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @since 4.6.0 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Default_Where_Conditions{ |
|
18 | +class EE_Default_Where_Conditions { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * onto any field names |
49 | 49 | * @param array $custom_where_conditions |
50 | 50 | */ |
51 | - public function __construct( $custom_where_conditions = array() ) { |
|
51 | + public function __construct($custom_where_conditions = array()) { |
|
52 | 52 | $this->_where_conditions_provided = $custom_where_conditions; |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * for querying of the model. |
60 | 60 | * @param EEM_Base $model |
61 | 61 | */ |
62 | - function _finalize_construct(EEM_Base $model){ |
|
62 | + function _finalize_construct(EEM_Base $model) { |
|
63 | 63 | $this->_model = $model; |
64 | 64 | } |
65 | 65 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param string $model_relation_chain |
81 | 81 | * @return array like what's expected in EEM_Base::get_all()'s $query_params[0] |
82 | 82 | */ |
83 | - function get_default_where_conditions( $model_relation_chain = '' ){ |
|
84 | - return $this->prepare_where_conditions_for_querying( array_merge( $this->_get_default_where_conditions(), $this->get_where_conditions_provided() ), $model_relation_chain ); |
|
83 | + function get_default_where_conditions($model_relation_chain = '') { |
|
84 | + return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Adding model relation chains is handled by the public method get_default_where_conditions |
92 | 92 | * @return array |
93 | 93 | */ |
94 | - protected function _get_default_where_conditions(){ |
|
94 | + protected function _get_default_where_conditions() { |
|
95 | 95 | return array(); |
96 | 96 | } |
97 | 97 | |
@@ -105,36 +105,36 @@ discard block |
||
105 | 105 | * @return array |
106 | 106 | * @throws \EE_Error |
107 | 107 | */ |
108 | - public function prepare_where_conditions_for_querying( $where_conditions, $model_relation_chain ) { |
|
108 | + public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) { |
|
109 | 109 | $where_conditions_with_model_relation_chain_prefixes = array(); |
110 | - if ( ! is_array( $where_conditions ) ) { |
|
110 | + if ( ! is_array($where_conditions)) { |
|
111 | 111 | $where_conditions = array(); |
112 | 112 | } |
113 | - foreach ( $where_conditions as $key => $value ) { |
|
113 | + foreach ($where_conditions as $key => $value) { |
|
114 | 114 | if ( |
115 | - in_array( $key, array( 'OR', 'AND', 'NOT' ) ) |
|
116 | - || strpos( $key, 'OR*' ) !== false |
|
117 | - || strpos( $key, 'AND*' ) !== false |
|
118 | - || strpos( $key, 'NOT*' ) !== false |
|
115 | + in_array($key, array('OR', 'AND', 'NOT')) |
|
116 | + || strpos($key, 'OR*') !== false |
|
117 | + || strpos($key, 'AND*') !== false |
|
118 | + || strpos($key, 'NOT*') !== false |
|
119 | 119 | ) { |
120 | - $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( |
|
120 | + $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying( |
|
121 | 121 | $value, |
122 | 122 | $model_relation_chain |
123 | 123 | ); |
124 | 124 | } else { |
125 | 125 | if ( |
126 | 126 | $model_relation_chain != '' |
127 | - && $model_relation_chain[ strlen( $model_relation_chain ) - 1 ] != '.' |
|
127 | + && $model_relation_chain[strlen($model_relation_chain) - 1] != '.' |
|
128 | 128 | ) { |
129 | - $model_relation_chain = $model_relation_chain . "."; |
|
129 | + $model_relation_chain = $model_relation_chain."."; |
|
130 | 130 | } |
131 | 131 | //check for the current user id place holder, and if present change it |
132 | - if ( $value === self::current_user_placeholder ) { |
|
132 | + if ($value === self::current_user_placeholder) { |
|
133 | 133 | $value = get_current_user_id(); |
134 | 134 | } |
135 | 135 | //check for user field placeholder |
136 | - if ( $key == self::user_field_name_placeholder ) { |
|
137 | - if ( ! $this->_model->wp_user_field_name() ) { |
|
136 | + if ($key == self::user_field_name_placeholder) { |
|
137 | + if ( ! $this->_model->wp_user_field_name()) { |
|
138 | 138 | throw new EE_Error( |
139 | 139 | sprintf( |
140 | 140 | __( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $key = $this->_model->wp_user_field_name(); |
149 | 149 | } |
150 | - $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
150 | + $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $where_conditions_with_model_relation_chain_prefixes; |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_Default_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy to be used for getting default where conditions for EEM_Base children. |
10 | 10 | * Should be initialized and set on construction of model |
11 | 11 | * |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param \EE_Message_Resource_Manager $Message_Resource_Manager |
54 | 54 | * @return \EE_Message_Factory instance |
55 | 55 | */ |
56 | - public static function instance( EE_Message_Resource_Manager $Message_Resource_Manager ) { |
|
56 | + public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager) { |
|
57 | 57 | // check if class object is instantiated, and instantiated properly |
58 | - if ( ! self::$_instance instanceof EE_Message_Factory ) { |
|
59 | - self::$_instance = new EE_Message_Factory( $Message_Resource_Manager ); |
|
58 | + if ( ! self::$_instance instanceof EE_Message_Factory) { |
|
59 | + self::$_instance = new EE_Message_Factory($Message_Resource_Manager); |
|
60 | 60 | } |
61 | 61 | return self::$_instance; |
62 | 62 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param array $props_n_values |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function create( $props_n_values = array() ) { |
|
71 | + public static function create($props_n_values = array()) { |
|
72 | 72 | /** @type EE_Message_Factory $Message_Factory */ |
73 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
74 | - return $Message_Factory->_create( $props_n_values ); |
|
73 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
74 | + return $Message_Factory->_create($props_n_values); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return \EE_Message |
83 | 83 | * @throws \EE_Error |
84 | 84 | */ |
85 | - public static function set_messenger_and_message_type( EE_Message $message ) { |
|
85 | + public static function set_messenger_and_message_type(EE_Message $message) { |
|
86 | 86 | /** @type EE_Message_Factory $Message_Factory */ |
87 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
88 | - return $Message_Factory->_set_messenger_and_message_type( $message ); |
|
87 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
88 | + return $Message_Factory->_set_messenger_and_message_type($message); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @return \EE_Message |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public static function set_messenger( EE_Message $message ) { |
|
99 | + public static function set_messenger(EE_Message $message) { |
|
100 | 100 | /** @type EE_Message_Factory $Message_Factory */ |
101 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
102 | - return $Message_Factory->_set_messenger( $message ); |
|
101 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
102 | + return $Message_Factory->_set_messenger($message); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @return \EE_Message |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public static function set_message_type( EE_Message $message ) { |
|
113 | + public static function set_message_type(EE_Message $message) { |
|
114 | 114 | /** @type EE_Message_Factory $Message_Factory */ |
115 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
116 | - return $Message_Factory->_set_message_type( $message ); |
|
115 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
116 | + return $Message_Factory->_set_message_type($message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @return \EE_Message |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - protected function _create( $props_n_values = array() ) { |
|
127 | + protected function _create($props_n_values = array()) { |
|
128 | 128 | $new_instance = false; |
129 | - if ( ! empty( $props_n_values['MSG_ID'] ) ) { |
|
130 | - $message = EE_Message::new_instance_from_db( $props_n_values ); |
|
129 | + if ( ! empty($props_n_values['MSG_ID'])) { |
|
130 | + $message = EE_Message::new_instance_from_db($props_n_values); |
|
131 | 131 | } else { |
132 | - $message = EE_Message::new_instance( $props_n_values ); |
|
132 | + $message = EE_Message::new_instance($props_n_values); |
|
133 | 133 | $new_instance = true; |
134 | 134 | } |
135 | - return $this->_set_messenger_and_message_type( $message, $new_instance ); |
|
135 | + return $this->_set_messenger_and_message_type($message, $new_instance); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * @return \EE_Message |
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | - protected function _set_messenger_and_message_type( EE_Message $message, $new_instance = false ) { |
|
148 | - $message = $this->_set_messenger( $message ); |
|
149 | - $message = $this->_set_message_type( $message, $new_instance ); |
|
147 | + protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false) { |
|
148 | + $message = $this->_set_messenger($message); |
|
149 | + $message = $this->_set_message_type($message, $new_instance); |
|
150 | 150 | return $message; |
151 | 151 | } |
152 | 152 | |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | * @return \EE_Message |
159 | 159 | * @throws \EE_Error |
160 | 160 | */ |
161 | - protected function _set_messenger( EE_Message $message ) { |
|
162 | - $messenger = $this->_message_resource_manager->get_messenger( $message->messenger() ); |
|
163 | - if ( $messenger instanceof EE_messenger ) { |
|
164 | - $message->set_messenger_object( $messenger ); |
|
161 | + protected function _set_messenger(EE_Message $message) { |
|
162 | + $messenger = $this->_message_resource_manager->get_messenger($message->messenger()); |
|
163 | + if ($messenger instanceof EE_messenger) { |
|
164 | + $message->set_messenger_object($messenger); |
|
165 | 165 | } |
166 | 166 | return $message; |
167 | 167 | } |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @return \EE_Message |
176 | 176 | * @throws \EE_Error |
177 | 177 | */ |
178 | - protected function _set_message_type( EE_Message $message, $new_instance = false ) { |
|
179 | - $message_type = $this->_message_resource_manager->get_message_type( $message->message_type() ); |
|
180 | - if ( $message_type instanceof EE_message_type ) { |
|
181 | - $message->set_message_type_object( $message_type, $new_instance ); |
|
178 | + protected function _set_message_type(EE_Message $message, $new_instance = false) { |
|
179 | + $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); |
|
180 | + if ($message_type instanceof EE_message_type) { |
|
181 | + $message->set_message_type_object($message_type, $new_instance); |
|
182 | 182 | } |
183 | 183 | return $message; |
184 | 184 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * This is then used to populate the properties in here. |
37 | 37 | * @param EE_Message_Resource_Manager $message_resource_manager |
38 | 38 | */ |
39 | - public function __construct( $token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager ) { |
|
39 | + public function __construct($token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager) { |
|
40 | 40 | $this->token = $token; |
41 | - $this->_sending_messenger = $this->_set_sending_messenger( $sending_messenger_slug, $message_resource_manager ); |
|
41 | + $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager); |
|
42 | 42 | $this->_message = $this->_generate_message(); |
43 | 43 | //set params for parent from the message object |
44 | 44 | parent::__construct( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $sending_messenger_slug, |
62 | 62 | EE_Message_Resource_Manager $message_resource_manager |
63 | 63 | ) { |
64 | - $sending_messenger = $message_resource_manager->get_active_messenger( $sending_messenger_slug ); |
|
64 | + $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug); |
|
65 | 65 | return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug; |
66 | 66 | } |
67 | 67 | |
@@ -83,27 +83,27 @@ discard block |
||
83 | 83 | * @return EE_Message |
84 | 84 | * @throws \EE_Error |
85 | 85 | */ |
86 | - protected function _generate_message( $properties = array() ) { |
|
86 | + protected function _generate_message($properties = array()) { |
|
87 | 87 | // a message was generated immediately but the parent class will call this again |
88 | - if ( $this->_message instanceof EE_Message ) { |
|
88 | + if ($this->_message instanceof EE_Message) { |
|
89 | 89 | return $this->_message; |
90 | 90 | } |
91 | - $message = EEM_Message::instance()->get_one_by_token( $this->token ); |
|
92 | - if ( ! $message instanceof EE_Message ) { |
|
91 | + $message = EEM_Message::instance()->get_one_by_token($this->token); |
|
92 | + if ( ! $message instanceof EE_Message) { |
|
93 | 93 | throw new EE_Error( |
94 | 94 | sprintf( |
95 | - __( 'Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso' ), |
|
95 | + __('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'), |
|
96 | 96 | $this->token |
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | - $message->set_STS_ID( EEM_Message::status_idle ); |
|
100 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
101 | 101 | |
102 | - if ( ! $this->_sending_messenger instanceof EE_messenger ) { |
|
103 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
102 | + if ( ! $this->_sending_messenger instanceof EE_messenger) { |
|
103 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
104 | 104 | $message->set_error_message( |
105 | 105 | sprintf( |
106 | - __( 'Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso' ), |
|
106 | + __('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'), |
|
107 | 107 | $this->_sending_messenger |
108 | 108 | ) |
109 | 109 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * indexing the template by key. |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | - public function add( $message_template_group, $EVT_ID = null ) { |
|
32 | - if ( $message_template_group instanceof $this->interface ) { |
|
33 | - $data[ 'key' ] = $this->get_key( |
|
31 | + public function add($message_template_group, $EVT_ID = null) { |
|
32 | + if ($message_template_group instanceof $this->interface) { |
|
33 | + $data['key'] = $this->get_key( |
|
34 | 34 | $message_template_group->messenger(), |
35 | 35 | $message_template_group->message_type(), |
36 | 36 | $EVT_ID |
37 | 37 | ); |
38 | - return parent::add( $message_template_group, $data ); |
|
38 | + return parent::add($message_template_group, $data); |
|
39 | 39 | } |
40 | 40 | return false; |
41 | 41 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param $GRP_ID |
49 | 49 | * @return EE_Message_Template_Group | null |
50 | 50 | */ |
51 | - public function get_by_ID( $GRP_ID ) { |
|
51 | + public function get_by_ID($GRP_ID) { |
|
52 | 52 | $this->rewind(); |
53 | - while ( $this->valid() ) { |
|
54 | - if ( $this->current()->ID() === $GRP_ID ) { |
|
53 | + while ($this->valid()) { |
|
54 | + if ($this->current()->ID() === $GRP_ID) { |
|
55 | 55 | $grp = $this->current(); |
56 | 56 | $this->rewind(); |
57 | 57 | return $grp; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - public function get_key( $messenger, $message_type, $EVT_ID = 0 ) { |
|
77 | - return md5( $messenger.$message_type.$EVT_ID ); |
|
76 | + public function get_key($messenger, $message_type, $EVT_ID = 0) { |
|
77 | + return md5($messenger.$message_type.$EVT_ID); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return null|EE_Message_Template_Group |
88 | 88 | */ |
89 | - public function get_by_key( $key ) { |
|
89 | + public function get_by_key($key) { |
|
90 | 90 | $this->rewind(); |
91 | - while ( $this->valid() ) { |
|
91 | + while ($this->valid()) { |
|
92 | 92 | $data = $this->getInfo(); |
93 | - if ( isset( $data['key'] ) && $data['key'] === $key ) { |
|
93 | + if (isset($data['key']) && $data['key'] === $key) { |
|
94 | 94 | $handler = $this->current(); |
95 | 95 | $this->rewind(); |
96 | 96 | return $handler; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | /** |
47 | 47 | * This retrieves any EE_Message_Template_Group in the repo by its ID. |
48 | - * @param $GRP_ID |
|
48 | + * @param integer $GRP_ID |
|
49 | 49 | * @return EE_Message_Template_Group | null |
50 | 50 | */ |
51 | 51 | public function get_by_ID( $GRP_ID ) { |