@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function __construct($generator) |
| 41 | 41 | { |
| 42 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 42 | + if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 43 | 43 | throw new InvalidArgumentException( |
| 44 | 44 | esc_html__( |
| 45 | 45 | 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function load($fqcn, $arguments = array(), $shared = true) |
| 63 | 63 | { |
| 64 | - if($this->generator instanceof EE_Registry) { |
|
| 64 | + if ($this->generator instanceof EE_Registry) { |
|
| 65 | 65 | return $this->generator->create($fqcn, $arguments, $shared); |
| 66 | 66 | } |
| 67 | 67 | $shared = $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW; |
@@ -26,67 +26,67 @@ |
||
| 26 | 26 | class CoreLoader implements LoaderDecoratorInterface |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var EE_Registry|CoffeeShop $generator |
|
| 31 | - */ |
|
| 32 | - private $generator; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * CoreLoader constructor. |
|
| 38 | - * |
|
| 39 | - * @param EE_Registry|CoffeeShop $generator |
|
| 40 | - * @throws InvalidArgumentException |
|
| 41 | - */ |
|
| 42 | - public function __construct($generator) |
|
| 43 | - { |
|
| 44 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 45 | - throw new InvalidArgumentException( |
|
| 46 | - esc_html__( |
|
| 47 | - 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
| 48 | - 'event_espresso' |
|
| 49 | - ) |
|
| 50 | - ); |
|
| 51 | - } |
|
| 52 | - $this->generator = $generator; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param string $fqcn |
|
| 59 | - * @param array $arguments |
|
| 60 | - * @param bool $shared |
|
| 61 | - * @return mixed |
|
| 62 | - * @throws EE_Error |
|
| 63 | - * @throws ServiceNotFoundException |
|
| 64 | - * @throws ReflectionException |
|
| 65 | - */ |
|
| 66 | - public function load($fqcn, $arguments = array(), $shared = true) |
|
| 67 | - { |
|
| 68 | - if($this->generator instanceof EE_Registry) { |
|
| 69 | - return $this->generator->create($fqcn, $arguments, $shared); |
|
| 70 | - } |
|
| 71 | - $shared = $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW; |
|
| 72 | - return $this->generator->brew($fqcn, $arguments, $shared); |
|
| 73 | - |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * calls reset() on generator if method exists |
|
| 80 | - * |
|
| 81 | - * @throws EE_Error |
|
| 82 | - * @throws ReflectionException |
|
| 83 | - */ |
|
| 84 | - public function reset() |
|
| 85 | - { |
|
| 86 | - if (method_exists($this->generator, 'reset')) { |
|
| 87 | - $this->generator->reset(); |
|
| 88 | - } |
|
| 89 | - } |
|
| 29 | + /** |
|
| 30 | + * @var EE_Registry|CoffeeShop $generator |
|
| 31 | + */ |
|
| 32 | + private $generator; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * CoreLoader constructor. |
|
| 38 | + * |
|
| 39 | + * @param EE_Registry|CoffeeShop $generator |
|
| 40 | + * @throws InvalidArgumentException |
|
| 41 | + */ |
|
| 42 | + public function __construct($generator) |
|
| 43 | + { |
|
| 44 | + if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 45 | + throw new InvalidArgumentException( |
|
| 46 | + esc_html__( |
|
| 47 | + 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
| 48 | + 'event_espresso' |
|
| 49 | + ) |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | + $this->generator = $generator; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param string $fqcn |
|
| 59 | + * @param array $arguments |
|
| 60 | + * @param bool $shared |
|
| 61 | + * @return mixed |
|
| 62 | + * @throws EE_Error |
|
| 63 | + * @throws ServiceNotFoundException |
|
| 64 | + * @throws ReflectionException |
|
| 65 | + */ |
|
| 66 | + public function load($fqcn, $arguments = array(), $shared = true) |
|
| 67 | + { |
|
| 68 | + if($this->generator instanceof EE_Registry) { |
|
| 69 | + return $this->generator->create($fqcn, $arguments, $shared); |
|
| 70 | + } |
|
| 71 | + $shared = $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW; |
|
| 72 | + return $this->generator->brew($fqcn, $arguments, $shared); |
|
| 73 | + |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * calls reset() on generator if method exists |
|
| 80 | + * |
|
| 81 | + * @throws EE_Error |
|
| 82 | + * @throws ReflectionException |
|
| 83 | + */ |
|
| 84 | + public function reset() |
|
| 85 | + { |
|
| 86 | + if (method_exists($this->generator, 'reset')) { |
|
| 87 | + $this->generator->reset(); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | // End of file CoreLoader.php |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php use EventEspresso\core\services\orm\ModelFieldFactory; |
|
| 1 | +<?php |
|
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | 4 | exit('No direct script access allowed'); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\orm\ModelFieldFactory; |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | require_once(EE_MODELS . 'EEM_CPT_Base.model.php'); |
| 7 | 7 | |
@@ -18,772 +18,772 @@ discard block |
||
| 18 | 18 | class EEM_Event extends EEM_CPT_Base |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the |
|
| 23 | - * event |
|
| 24 | - */ |
|
| 25 | - const sold_out = 'sold_out'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later |
|
| 29 | - * date) |
|
| 30 | - */ |
|
| 31 | - const postponed = 'postponed'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * constant used by status(), indicating that the event will no longer occur |
|
| 35 | - */ |
|
| 36 | - const cancelled = 'cancelled'; |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - protected static $_default_reg_status; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * This is the default for the additional limit field. |
|
| 47 | - * @var int |
|
| 48 | - */ |
|
| 49 | - protected static $_default_additional_limit = 10; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * private instance of the Event object |
|
| 54 | - * |
|
| 55 | - * @var EEM_Event |
|
| 56 | - */ |
|
| 57 | - protected static $_instance; |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Adds a relationship to Term_Taxonomy for each CPT_Base |
|
| 64 | - * |
|
| 65 | - * @param string $timezone |
|
| 66 | - * @throws \EE_Error |
|
| 67 | - */ |
|
| 68 | - protected function __construct($timezone = null) |
|
| 69 | - { |
|
| 70 | - EE_Registry::instance()->load_model('Registration'); |
|
| 71 | - $this->singular_item = esc_html__('Event', 'event_espresso'); |
|
| 72 | - $this->plural_item = esc_html__('Events', 'event_espresso'); |
|
| 73 | - // to remove Cancelled events from the frontend, copy the following filter to your functions.php file |
|
| 74 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' ); |
|
| 75 | - // to remove Postponed events from the frontend, copy the following filter to your functions.php file |
|
| 76 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' ); |
|
| 77 | - // to remove Sold Out events from the frontend, copy the following filter to your functions.php file |
|
| 78 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' ); |
|
| 79 | - $this->_custom_stati = apply_filters( |
|
| 80 | - 'AFEE__EEM_Event__construct___custom_stati', |
|
| 81 | - array( |
|
| 82 | - EEM_Event::cancelled => array( |
|
| 83 | - 'label' => esc_html__('Cancelled', 'event_espresso'), |
|
| 84 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true), |
|
| 85 | - ), |
|
| 86 | - EEM_Event::postponed => array( |
|
| 87 | - 'label' => esc_html__('Postponed', 'event_espresso'), |
|
| 88 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true), |
|
| 89 | - ), |
|
| 90 | - EEM_Event::sold_out => array( |
|
| 91 | - 'label' => esc_html__('Sold Out', 'event_espresso'), |
|
| 92 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true), |
|
| 93 | - ), |
|
| 94 | - ) |
|
| 95 | - ); |
|
| 96 | - self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment |
|
| 97 | - : self::$_default_reg_status; |
|
| 98 | - $this->_tables = array( |
|
| 99 | - 'Event_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 100 | - 'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'), |
|
| 101 | - ); |
|
| 102 | - $this->_fields = array( |
|
| 103 | - 'Event_CPT' => array( |
|
| 104 | - 'EVT_ID' => new EE_Primary_Key_Int_Field('ID', |
|
| 105 | - esc_html__('Post ID for Event', 'event_espresso')), |
|
| 106 | - 'EVT_name' => new EE_Plain_Text_Field('post_title', esc_html__('Event Name', 'event_espresso'), |
|
| 107 | - false, |
|
| 108 | - ''), |
|
| 109 | - 'EVT_desc' => new EE_Post_Content_Field('post_content', |
|
| 110 | - esc_html__('Event Description', 'event_espresso'), |
|
| 111 | - false, ''), |
|
| 112 | - 'EVT_slug' => new EE_Slug_Field('post_name', esc_html__('Event Slug', 'event_espresso'), false, |
|
| 113 | - ''), |
|
| 114 | - 'EVT_created' => new EE_Datetime_Field('post_date', |
|
| 115 | - esc_html__('Date/Time Event Created', 'event_espresso'), |
|
| 116 | - false, EE_Datetime_Field::now), |
|
| 117 | - 'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt', |
|
| 118 | - esc_html__('Event Short Description', 'event_espresso'), false, ''), |
|
| 119 | - 'EVT_modified' => new EE_Datetime_Field('post_modified', |
|
| 120 | - esc_html__('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now), |
|
| 121 | - 'EVT_wp_user' => new EE_WP_User_Field('post_author', |
|
| 122 | - esc_html__('Event Creator ID', 'event_espresso'), |
|
| 123 | - false), |
|
| 124 | - 'parent' => new EE_Integer_Field('post_parent', esc_html__('Event Parent ID', 'event_espresso'), |
|
| 125 | - false, |
|
| 126 | - 0), |
|
| 127 | - 'EVT_order' => new EE_Integer_Field('menu_order', esc_html__('Event Menu Order', 'event_espresso'), |
|
| 128 | - false, |
|
| 129 | - 1), |
|
| 130 | - 'post_type' => new EE_WP_Post_Type_Field('espresso_events'), |
|
| 131 | - // EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
| 132 | - 'status' => new EE_WP_Post_Status_Field('post_status', |
|
| 133 | - esc_html__('Event Status', 'event_espresso'), |
|
| 134 | - false, 'draft', $this->_custom_stati), |
|
| 135 | - ), |
|
| 136 | - 'Event_Meta' => array( |
|
| 137 | - 'EVTM_ID' => new EE_DB_Only_Float_Field('EVTM_ID', |
|
| 138 | - esc_html__('Event Meta Row ID', 'event_espresso'), false), |
|
| 139 | - 'EVT_ID_fk' => new EE_DB_Only_Int_Field('EVT_ID', |
|
| 140 | - esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'), false), |
|
| 141 | - 'EVT_display_desc' => new EE_Boolean_Field('EVT_display_desc', |
|
| 142 | - esc_html__('Display Description Flag', 'event_espresso'), false, 1), |
|
| 143 | - 'EVT_display_ticket_selector' => new EE_Boolean_Field('EVT_display_ticket_selector', |
|
| 144 | - esc_html__('Display Ticket Selector Flag', 'event_espresso'), false, 1), |
|
| 145 | - 'EVT_visible_on' => new EE_Datetime_Field('EVT_visible_on', |
|
| 146 | - esc_html__('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now), |
|
| 147 | - 'EVT_additional_limit' => new EE_Integer_Field( |
|
| 148 | - 'EVT_additional_limit', |
|
| 149 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'), |
|
| 150 | - true, |
|
| 151 | - self::$_default_additional_limit |
|
| 152 | - ), |
|
| 153 | - 'EVT_default_registration_status' => new EE_Enum_Text_Field( |
|
| 154 | - 'EVT_default_registration_status', |
|
| 155 | - esc_html__('Default Registration Status on this Event', 'event_espresso'), false, |
|
| 156 | - EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
| 157 | - ), |
|
| 158 | - 'EVT_member_only' => new EE_Boolean_Field('EVT_member_only', |
|
| 159 | - esc_html__('Member-Only Event Flag', 'event_espresso'), false, false), |
|
| 160 | - 'EVT_phone' => new EE_Plain_Text_Field('EVT_phone', |
|
| 161 | - esc_html__('Event Phone Number', 'event_espresso'), false), |
|
| 162 | - 'EVT_allow_overflow' => new EE_Boolean_Field('EVT_allow_overflow', |
|
| 163 | - esc_html__('Allow Overflow on Event', 'event_espresso'), false, false), |
|
| 164 | - 'EVT_timezone_string' => new EE_Plain_Text_Field('EVT_timezone_string', |
|
| 165 | - esc_html__('Timezone (name) for Event times', 'event_espresso'), false), |
|
| 166 | - 'EVT_external_URL' => new EE_Plain_Text_Field('EVT_external_URL', |
|
| 167 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'), true), |
|
| 168 | - 'EVT_donations' => new EE_Boolean_Field('EVT_donations', |
|
| 169 | - esc_html__('Accept Donations?', 'event_espresso'), false, false), |
|
| 170 | - ), |
|
| 171 | - ); |
|
| 172 | - $this->_model_relations = array( |
|
| 173 | - 'Registration' => new EE_Has_Many_Relation(), |
|
| 174 | - 'Datetime' => new EE_Has_Many_Relation(), |
|
| 175 | - 'Question_Group' => new EE_HABTM_Relation('Event_Question_Group'), |
|
| 176 | - 'Venue' => new EE_HABTM_Relation('Event_Venue'), |
|
| 177 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 178 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 179 | - 'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'), |
|
| 180 | - 'Attendee' => new EE_HABTM_Relation('Registration'), |
|
| 181 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 182 | - ); |
|
| 183 | - //this model is generally available for reading |
|
| 184 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
| 185 | - parent::__construct($timezone); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @param string $default_reg_status |
|
| 192 | - */ |
|
| 193 | - public static function set_default_reg_status($default_reg_status) |
|
| 194 | - { |
|
| 195 | - self::$_default_reg_status = $default_reg_status; |
|
| 196 | - // if EEM_Event has already been instantiated, |
|
| 197 | - // then we need to reset the `EVT_default_reg_status` field to use the new default. |
|
| 198 | - if (self::$_instance instanceof EEM_Event) { |
|
| 199 | - $default_reg_status = new EE_Enum_Text_Field( |
|
| 200 | - 'EVT_default_registration_status', |
|
| 201 | - esc_html__('Default Registration Status on this Event', 'event_espresso'), |
|
| 202 | - false, |
|
| 203 | - $default_reg_status, |
|
| 204 | - EEM_Registration::reg_status_array() |
|
| 205 | - ); |
|
| 206 | - $default_reg_status->_construct_finalize( |
|
| 207 | - 'Event_Meta', |
|
| 208 | - 'EVT_default_registration_status', |
|
| 209 | - 'EEM_Event' |
|
| 210 | - ); |
|
| 211 | - self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Used to override the default for the additional limit field. |
|
| 218 | - * @param $additional_limit |
|
| 219 | - */ |
|
| 220 | - public static function set_default_additional_limit($additional_limit) |
|
| 221 | - { |
|
| 222 | - self::$_default_additional_limit = (int) $additional_limit; |
|
| 223 | - if (self::$_instance instanceof EEM_Event) { |
|
| 224 | - self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field( |
|
| 225 | - 'EVT_additional_limit', |
|
| 226 | - __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), |
|
| 227 | - true, |
|
| 228 | - self::$_default_additional_limit |
|
| 229 | - ); |
|
| 230 | - self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize( |
|
| 231 | - 'Event_Meta', |
|
| 232 | - 'EVT_additional_limit', |
|
| 233 | - 'EEM_Event' |
|
| 234 | - ); |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Return what is currently set as the default additional limit for the event. |
|
| 241 | - * @return int |
|
| 242 | - */ |
|
| 243 | - public static function get_default_additional_limit() |
|
| 244 | - { |
|
| 245 | - return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * get_question_groups |
|
| 251 | - * |
|
| 252 | - * @return array |
|
| 253 | - * @throws \EE_Error |
|
| 254 | - */ |
|
| 255 | - public function get_all_question_groups() |
|
| 256 | - { |
|
| 257 | - return EE_Registry::instance()->load_model('Question_Group')->get_all( |
|
| 258 | - array( |
|
| 259 | - array('QSG_deleted' => false), |
|
| 260 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
| 261 | - ) |
|
| 262 | - ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * get_question_groups |
|
| 269 | - * |
|
| 270 | - * @param int $EVT_ID |
|
| 271 | - * @return array|bool |
|
| 272 | - * @throws \EE_Error |
|
| 273 | - */ |
|
| 274 | - public function get_all_event_question_groups($EVT_ID = 0) |
|
| 275 | - { |
|
| 276 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 277 | - EE_Error::add_error( |
|
| 278 | - esc_html__( |
|
| 279 | - 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
| 280 | - 'event_espresso' |
|
| 281 | - ), |
|
| 282 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 283 | - ); |
|
| 284 | - return false; |
|
| 285 | - } |
|
| 286 | - return EE_Registry::instance()->load_model('Event_Question_Group')->get_all( |
|
| 287 | - array( |
|
| 288 | - array('EVT_ID' => $EVT_ID), |
|
| 289 | - ) |
|
| 290 | - ); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * get_question_groups |
|
| 297 | - * |
|
| 298 | - * @param int $EVT_ID |
|
| 299 | - * @param boolean $for_primary_attendee |
|
| 300 | - * @return array|bool |
|
| 301 | - * @throws \EE_Error |
|
| 302 | - */ |
|
| 303 | - public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true) |
|
| 304 | - { |
|
| 305 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 306 | - EE_Error::add_error( |
|
| 307 | - esc_html__( |
|
| 308 | - 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
| 309 | - 'event_espresso' |
|
| 310 | - ), |
|
| 311 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 312 | - ); |
|
| 313 | - return false; |
|
| 314 | - } |
|
| 315 | - return EE_Registry::instance()->load_model('Event_Question_Group')->get_all( |
|
| 316 | - array( |
|
| 317 | - array( |
|
| 318 | - 'EVT_ID' => $EVT_ID, |
|
| 319 | - 'EQG_primary' => $for_primary_attendee, |
|
| 320 | - ), |
|
| 321 | - ) |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * get_question_groups |
|
| 329 | - * |
|
| 330 | - * @param int $EVT_ID |
|
| 331 | - * @param EE_Registration $registration |
|
| 332 | - * @return array|bool |
|
| 333 | - * @throws \EE_Error |
|
| 334 | - */ |
|
| 335 | - public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) |
|
| 336 | - { |
|
| 337 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 338 | - EE_Error::add_error( |
|
| 339 | - esc_html__( |
|
| 340 | - 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', |
|
| 341 | - 'event_espresso' |
|
| 342 | - ), |
|
| 343 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 344 | - ); |
|
| 345 | - return false; |
|
| 346 | - } |
|
| 347 | - $where_params = array( |
|
| 348 | - 'Event_Question_Group.EVT_ID' => $EVT_ID, |
|
| 349 | - 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false, |
|
| 350 | - 'QSG_deleted' => false, |
|
| 351 | - ); |
|
| 352 | - return EE_Registry::instance()->load_model('Question_Group')->get_all( |
|
| 353 | - array( |
|
| 354 | - $where_params, |
|
| 355 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
| 356 | - ) |
|
| 357 | - ); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * get_question_target_db_column |
|
| 364 | - * |
|
| 365 | - * @param string $QSG_IDs csv list of $QSG IDs |
|
| 366 | - * @return array|bool |
|
| 367 | - * @throws \EE_Error |
|
| 368 | - */ |
|
| 369 | - public function get_questions_in_groups($QSG_IDs = '') |
|
| 370 | - { |
|
| 371 | - if (empty($QSG_IDs)) { |
|
| 372 | - EE_Error::add_error( |
|
| 373 | - esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'), |
|
| 374 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 375 | - ); |
|
| 376 | - return false; |
|
| 377 | - } |
|
| 378 | - return EE_Registry::instance()->load_model('Question')->get_all( |
|
| 379 | - array( |
|
| 380 | - array( |
|
| 381 | - 'Question_Group.QSG_ID' => array('IN', $QSG_IDs), |
|
| 382 | - 'QST_deleted' => false, |
|
| 383 | - 'QST_admin_only' => is_admin(), |
|
| 384 | - ), |
|
| 385 | - 'order_by' => 'QST_order', |
|
| 386 | - ) |
|
| 387 | - ); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * get_options_for_question |
|
| 394 | - * |
|
| 395 | - * @param string $QST_IDs csv list of $QST IDs |
|
| 396 | - * @return array|bool |
|
| 397 | - * @throws \EE_Error |
|
| 398 | - */ |
|
| 399 | - public function get_options_for_question($QST_IDs) |
|
| 400 | - { |
|
| 401 | - if (empty($QST_IDs)) { |
|
| 402 | - EE_Error::add_error( |
|
| 403 | - esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'), |
|
| 404 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 405 | - ); |
|
| 406 | - return false; |
|
| 407 | - } |
|
| 408 | - return EE_Registry::instance()->load_model('Question_Option')->get_all( |
|
| 409 | - array( |
|
| 410 | - array( |
|
| 411 | - 'Question.QST_ID' => array('IN', $QST_IDs), |
|
| 412 | - 'QSO_deleted' => false, |
|
| 413 | - ), |
|
| 414 | - 'order_by' => 'QSO_ID', |
|
| 415 | - ) |
|
| 416 | - ); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Gets all events that are published |
|
| 427 | - * and have event start time earlier than now and an event end time later than now |
|
| 428 | - * |
|
| 429 | - * @param array $query_params An array of query params to further filter on |
|
| 430 | - * (note that status and DTT_EVT_start and DTT_EVT_end will be overridden) |
|
| 431 | - * @param bool $count whether to return the count or not (default FALSE) |
|
| 432 | - * @return EE_Event[]|int |
|
| 433 | - * @throws \EE_Error |
|
| 434 | - */ |
|
| 435 | - public function get_active_events($query_params, $count = false) |
|
| 436 | - { |
|
| 437 | - if (array_key_exists(0, $query_params)) { |
|
| 438 | - $where_params = $query_params[0]; |
|
| 439 | - unset($query_params[0]); |
|
| 440 | - } else { |
|
| 441 | - $where_params = array(); |
|
| 442 | - } |
|
| 443 | - // if we have count make sure we don't include group by |
|
| 444 | - if ($count && isset($query_params['group_by'])) { |
|
| 445 | - unset($query_params['group_by']); |
|
| 446 | - } |
|
| 447 | - // let's add specific query_params for active_events |
|
| 448 | - // keep in mind this will override any sent status in the query AND any date queries. |
|
| 449 | - $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 450 | - //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
|
| 451 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 452 | - $where_params['Datetime.DTT_EVT_start******'] = array( |
|
| 453 | - '<', |
|
| 454 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 455 | - ); |
|
| 456 | - } else { |
|
| 457 | - $where_params['Datetime.DTT_EVT_start'] = array( |
|
| 458 | - '<', |
|
| 459 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 460 | - ); |
|
| 461 | - } |
|
| 462 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 463 | - $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
| 464 | - '>', |
|
| 465 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 466 | - ); |
|
| 467 | - } else { |
|
| 468 | - $where_params['Datetime.DTT_EVT_end'] = array( |
|
| 469 | - '>', |
|
| 470 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 471 | - ); |
|
| 472 | - } |
|
| 473 | - $query_params[0] = $where_params; |
|
| 474 | - // don't use $query_params with count() |
|
| 475 | - // because we don't want to include additional query clauses like "GROUP BY" |
|
| 476 | - return $count |
|
| 477 | - ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 478 | - : $this->get_all($query_params); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * get all events that are published and have an event start time later than now |
|
| 485 | - * |
|
| 486 | - * @param array $query_params An array of query params to further filter on |
|
| 487 | - * (Note that status and DTT_EVT_start will be overridden) |
|
| 488 | - * @param bool $count whether to return the count or not (default FALSE) |
|
| 489 | - * @return EE_Event[]|int |
|
| 490 | - * @throws \EE_Error |
|
| 491 | - */ |
|
| 492 | - public function get_upcoming_events($query_params, $count = false) |
|
| 493 | - { |
|
| 494 | - if (array_key_exists(0, $query_params)) { |
|
| 495 | - $where_params = $query_params[0]; |
|
| 496 | - unset($query_params[0]); |
|
| 497 | - } else { |
|
| 498 | - $where_params = array(); |
|
| 499 | - } |
|
| 500 | - // if we have count make sure we don't include group by |
|
| 501 | - if ($count && isset($query_params['group_by'])) { |
|
| 502 | - unset($query_params['group_by']); |
|
| 503 | - } |
|
| 504 | - // let's add specific query_params for active_events |
|
| 505 | - // keep in mind this will override any sent status in the query AND any date queries. |
|
| 506 | - $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 507 | - // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 508 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 509 | - $where_params['Datetime.DTT_EVT_start*****'] = array( |
|
| 510 | - '>', |
|
| 511 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 512 | - ); |
|
| 513 | - } else { |
|
| 514 | - $where_params['Datetime.DTT_EVT_start'] = array( |
|
| 515 | - '>', |
|
| 516 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 517 | - ); |
|
| 518 | - } |
|
| 519 | - $query_params[0] = $where_params; |
|
| 520 | - // don't use $query_params with count() |
|
| 521 | - // because we don't want to include additional query clauses like "GROUP BY" |
|
| 522 | - return $count |
|
| 523 | - ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 524 | - : $this->get_all($query_params); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Gets all events that are published |
|
| 531 | - * and have an event end time later than now |
|
| 532 | - * |
|
| 533 | - * @param array $query_params An array of query params to further filter on |
|
| 534 | - * (note that status and DTT_EVT_end will be overridden) |
|
| 535 | - * @param bool $count whether to return the count or not (default FALSE) |
|
| 536 | - * @return EE_Event[]|int |
|
| 537 | - * @throws \EE_Error |
|
| 538 | - */ |
|
| 539 | - public function get_active_and_upcoming_events($query_params, $count = false) |
|
| 540 | - { |
|
| 541 | - if (array_key_exists(0, $query_params)) { |
|
| 542 | - $where_params = $query_params[0]; |
|
| 543 | - unset($query_params[0]); |
|
| 544 | - } else { |
|
| 545 | - $where_params = array(); |
|
| 546 | - } |
|
| 547 | - // if we have count make sure we don't include group by |
|
| 548 | - if ($count && isset($query_params['group_by'])) { |
|
| 549 | - unset($query_params['group_by']); |
|
| 550 | - } |
|
| 551 | - // let's add specific query_params for active_events |
|
| 552 | - // keep in mind this will override any sent status in the query AND any date queries. |
|
| 553 | - $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 554 | - // add where params for DTT_EVT_end |
|
| 555 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 556 | - $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
| 557 | - '>', |
|
| 558 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 559 | - ); |
|
| 560 | - } else { |
|
| 561 | - $where_params['Datetime.DTT_EVT_end'] = array( |
|
| 562 | - '>', |
|
| 563 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 564 | - ); |
|
| 565 | - } |
|
| 566 | - $query_params[0] = $where_params; |
|
| 567 | - // don't use $query_params with count() |
|
| 568 | - // because we don't want to include additional query clauses like "GROUP BY" |
|
| 569 | - return $count |
|
| 570 | - ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 571 | - : $this->get_all($query_params); |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * This only returns events that are expired. |
|
| 578 | - * They may still be published but all their datetimes have expired. |
|
| 579 | - * |
|
| 580 | - * @param array $query_params An array of query params to further filter on |
|
| 581 | - * (note that status and DTT_EVT_end will be overridden) |
|
| 582 | - * @param bool $count whether to return the count or not (default FALSE) |
|
| 583 | - * @return EE_Event[]|int |
|
| 584 | - * @throws \EE_Error |
|
| 585 | - */ |
|
| 586 | - public function get_expired_events($query_params, $count = false) |
|
| 587 | - { |
|
| 588 | - $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 589 | - // if we have count make sure we don't include group by |
|
| 590 | - if ($count && isset($query_params['group_by'])) { |
|
| 591 | - unset($query_params['group_by']); |
|
| 592 | - } |
|
| 593 | - // let's add specific query_params for active_events |
|
| 594 | - // keep in mind this will override any sent status in the query AND any date queries. |
|
| 595 | - if (isset($where_params['status'])) { |
|
| 596 | - unset($where_params['status']); |
|
| 597 | - } |
|
| 598 | - $exclude_query = $query_params; |
|
| 599 | - if (isset($exclude_query[0])) { |
|
| 600 | - unset($exclude_query[0]); |
|
| 601 | - } |
|
| 602 | - $exclude_query[0] = array( |
|
| 603 | - 'Datetime.DTT_EVT_end' => array( |
|
| 604 | - '>', |
|
| 605 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 606 | - ), |
|
| 607 | - ); |
|
| 608 | - // first get all events that have datetimes where its not expired. |
|
| 609 | - $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID'); |
|
| 610 | - $event_ids = array_keys($event_ids); |
|
| 611 | - // if we have any additional query_params, let's add them to the 'AND' condition |
|
| 612 | - $and_condition = array( |
|
| 613 | - 'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')), |
|
| 614 | - 'EVT_ID' => array('NOT IN', $event_ids), |
|
| 615 | - ); |
|
| 616 | - if (isset($where_params['OR'])) { |
|
| 617 | - $and_condition['OR'] = $where_params['OR']; |
|
| 618 | - unset($where_params['OR']); |
|
| 619 | - } |
|
| 620 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 621 | - $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
| 622 | - unset($where_params['Datetime.DTT_EVT_end']); |
|
| 623 | - } |
|
| 624 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 625 | - $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
| 626 | - unset($where_params['Datetime.DTT_EVT_start']); |
|
| 627 | - } |
|
| 628 | - // merge remaining $where params with the and conditions. |
|
| 629 | - $where_params['AND'] = array_merge($and_condition, $where_params); |
|
| 630 | - $query_params[0] = $where_params; |
|
| 631 | - // don't use $query_params with count() |
|
| 632 | - // because we don't want to include additional query clauses like "GROUP BY" |
|
| 633 | - return $count |
|
| 634 | - ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 635 | - : $this->get_all($query_params); |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - |
|
| 640 | - /** |
|
| 641 | - * This basically just returns the events that do not have the publish status. |
|
| 642 | - * |
|
| 643 | - * @param array $query_params An array of query params to further filter on |
|
| 644 | - * (note that status will be overwritten) |
|
| 645 | - * @param boolean $count whether to return the count or not (default FALSE) |
|
| 646 | - * @return EE_Event[]|int |
|
| 647 | - * @throws \EE_Error |
|
| 648 | - */ |
|
| 649 | - public function get_inactive_events($query_params, $count = false) |
|
| 650 | - { |
|
| 651 | - $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 652 | - // let's add in specific query_params for inactive events. |
|
| 653 | - if (isset($where_params['status'])) { |
|
| 654 | - unset($where_params['status']); |
|
| 655 | - } |
|
| 656 | - // if we have count make sure we don't include group by |
|
| 657 | - if ($count && isset($query_params['group_by'])) { |
|
| 658 | - unset($query_params['group_by']); |
|
| 659 | - } |
|
| 660 | - // if we have any additional query_params, let's add them to the 'AND' condition |
|
| 661 | - $where_params['AND']['status'] = array('!=', 'publish'); |
|
| 662 | - if (isset($where_params['OR'])) { |
|
| 663 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
| 664 | - unset($where_params['OR']); |
|
| 665 | - } |
|
| 666 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 667 | - $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
| 668 | - unset($where_params['Datetime.DTT_EVT_end']); |
|
| 669 | - } |
|
| 670 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 671 | - $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
| 672 | - unset($where_params['Datetime.DTT_EVT_start']); |
|
| 673 | - } |
|
| 674 | - $query_params[0] = $where_params; |
|
| 675 | - // don't use $query_params with count() |
|
| 676 | - // because we don't want to include additional query clauses like "GROUP BY" |
|
| 677 | - return $count |
|
| 678 | - ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 679 | - : $this->get_all($query_params); |
|
| 680 | - } |
|
| 681 | - |
|
| 682 | - |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * This is just injecting into the parent add_relationship_to so we do special handling on price relationships |
|
| 686 | - * because we don't want to override any existing global default prices but instead insert NEW prices that get |
|
| 687 | - * attached to the event. See parent for param descriptions |
|
| 688 | - * |
|
| 689 | - * @param $id_or_obj |
|
| 690 | - * @param $other_model_id_or_obj |
|
| 691 | - * @param string $relationName |
|
| 692 | - * @param array $where_query |
|
| 693 | - * @return EE_Base_Class |
|
| 694 | - * @throws EE_Error |
|
| 695 | - */ |
|
| 696 | - public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) |
|
| 697 | - { |
|
| 698 | - if ($relationName === 'Price') { |
|
| 699 | - //let's get the PRC object for the given ID to make sure that we aren't dealing with a default |
|
| 700 | - $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj); |
|
| 701 | - //if EVT_ID = 0, then this is a default |
|
| 702 | - if ((int) $prc_chk->get('EVT_ID') === 0) { |
|
| 703 | - //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation |
|
| 704 | - $prc_chk->set('PRC_ID', 0); |
|
| 705 | - } |
|
| 706 | - //run parent |
|
| 707 | - return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query); |
|
| 708 | - } |
|
| 709 | - //otherwise carry on as normal |
|
| 710 | - return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query); |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - |
|
| 714 | - |
|
| 715 | - /******************** DEPRECATED METHODS ********************/ |
|
| 716 | - |
|
| 717 | - |
|
| 718 | - |
|
| 719 | - /** |
|
| 720 | - * _get_question_target_db_column |
|
| 721 | - * |
|
| 722 | - * @deprecated as of 4.8.32.rc.001. Instead consider using |
|
| 723 | - * EE_Registration_Custom_Questions_Form located in |
|
| 724 | - * admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php |
|
| 725 | - * @access public |
|
| 726 | - * @param EE_Registration $registration (so existing answers for registration are included) |
|
| 727 | - * @param int $EVT_ID so all question groups are included for event (not just answers from |
|
| 728 | - * registration). |
|
| 729 | - * @throws EE_Error |
|
| 730 | - * @return array |
|
| 731 | - */ |
|
| 732 | - public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) |
|
| 733 | - { |
|
| 734 | - if (empty($EVT_ID)) { |
|
| 735 | - throw new EE_Error(__('An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', |
|
| 736 | - 'event_espresso')); |
|
| 737 | - } |
|
| 738 | - $questions = array(); |
|
| 739 | - // get all question groups for event |
|
| 740 | - $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
|
| 741 | - if (! empty($qgs)) { |
|
| 742 | - foreach ($qgs as $qg) { |
|
| 743 | - $qsts = $qg->questions(); |
|
| 744 | - $questions[$qg->ID()] = $qg->model_field_array(); |
|
| 745 | - $questions[$qg->ID()]['QSG_questions'] = array(); |
|
| 746 | - foreach ($qsts as $qst) { |
|
| 747 | - if ($qst->is_system_question()) { |
|
| 748 | - continue; |
|
| 749 | - } |
|
| 750 | - $answer = EEM_Answer::instance()->get_one(array( |
|
| 751 | - array( |
|
| 752 | - 'QST_ID' => $qst->ID(), |
|
| 753 | - 'REG_ID' => $registration->ID(), |
|
| 754 | - ), |
|
| 755 | - )); |
|
| 756 | - $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
|
| 757 | - $qst_name = $qstn_id = $qst->ID(); |
|
| 758 | - $ans_id = $answer->ID(); |
|
| 759 | - $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
| 760 | - $input_name = ''; |
|
| 761 | - $input_id = sanitize_key($qst->display_text()); |
|
| 762 | - $input_class = ''; |
|
| 763 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
|
| 764 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' |
|
| 765 | - . $input_name |
|
| 766 | - . $qst_name; |
|
| 767 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
| 768 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
|
| 769 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
|
| 770 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
|
| 771 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer; |
|
| 772 | - //leave responses as-is, don't convert stuff into html entities please! |
|
| 773 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false; |
|
| 774 | - if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') { |
|
| 775 | - $QSOs = $qst->options(true, $answer->value()); |
|
| 776 | - if (is_array($QSOs)) { |
|
| 777 | - foreach ($QSOs as $QSO_ID => $QSO) { |
|
| 778 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array(); |
|
| 779 | - } |
|
| 780 | - } |
|
| 781 | - } |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - } |
|
| 785 | - return $questions; |
|
| 786 | - } |
|
| 21 | + /** |
|
| 22 | + * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the |
|
| 23 | + * event |
|
| 24 | + */ |
|
| 25 | + const sold_out = 'sold_out'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later |
|
| 29 | + * date) |
|
| 30 | + */ |
|
| 31 | + const postponed = 'postponed'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * constant used by status(), indicating that the event will no longer occur |
|
| 35 | + */ |
|
| 36 | + const cancelled = 'cancelled'; |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + protected static $_default_reg_status; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * This is the default for the additional limit field. |
|
| 47 | + * @var int |
|
| 48 | + */ |
|
| 49 | + protected static $_default_additional_limit = 10; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * private instance of the Event object |
|
| 54 | + * |
|
| 55 | + * @var EEM_Event |
|
| 56 | + */ |
|
| 57 | + protected static $_instance; |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Adds a relationship to Term_Taxonomy for each CPT_Base |
|
| 64 | + * |
|
| 65 | + * @param string $timezone |
|
| 66 | + * @throws \EE_Error |
|
| 67 | + */ |
|
| 68 | + protected function __construct($timezone = null) |
|
| 69 | + { |
|
| 70 | + EE_Registry::instance()->load_model('Registration'); |
|
| 71 | + $this->singular_item = esc_html__('Event', 'event_espresso'); |
|
| 72 | + $this->plural_item = esc_html__('Events', 'event_espresso'); |
|
| 73 | + // to remove Cancelled events from the frontend, copy the following filter to your functions.php file |
|
| 74 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' ); |
|
| 75 | + // to remove Postponed events from the frontend, copy the following filter to your functions.php file |
|
| 76 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' ); |
|
| 77 | + // to remove Sold Out events from the frontend, copy the following filter to your functions.php file |
|
| 78 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' ); |
|
| 79 | + $this->_custom_stati = apply_filters( |
|
| 80 | + 'AFEE__EEM_Event__construct___custom_stati', |
|
| 81 | + array( |
|
| 82 | + EEM_Event::cancelled => array( |
|
| 83 | + 'label' => esc_html__('Cancelled', 'event_espresso'), |
|
| 84 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true), |
|
| 85 | + ), |
|
| 86 | + EEM_Event::postponed => array( |
|
| 87 | + 'label' => esc_html__('Postponed', 'event_espresso'), |
|
| 88 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true), |
|
| 89 | + ), |
|
| 90 | + EEM_Event::sold_out => array( |
|
| 91 | + 'label' => esc_html__('Sold Out', 'event_espresso'), |
|
| 92 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true), |
|
| 93 | + ), |
|
| 94 | + ) |
|
| 95 | + ); |
|
| 96 | + self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment |
|
| 97 | + : self::$_default_reg_status; |
|
| 98 | + $this->_tables = array( |
|
| 99 | + 'Event_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 100 | + 'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID'), |
|
| 101 | + ); |
|
| 102 | + $this->_fields = array( |
|
| 103 | + 'Event_CPT' => array( |
|
| 104 | + 'EVT_ID' => new EE_Primary_Key_Int_Field('ID', |
|
| 105 | + esc_html__('Post ID for Event', 'event_espresso')), |
|
| 106 | + 'EVT_name' => new EE_Plain_Text_Field('post_title', esc_html__('Event Name', 'event_espresso'), |
|
| 107 | + false, |
|
| 108 | + ''), |
|
| 109 | + 'EVT_desc' => new EE_Post_Content_Field('post_content', |
|
| 110 | + esc_html__('Event Description', 'event_espresso'), |
|
| 111 | + false, ''), |
|
| 112 | + 'EVT_slug' => new EE_Slug_Field('post_name', esc_html__('Event Slug', 'event_espresso'), false, |
|
| 113 | + ''), |
|
| 114 | + 'EVT_created' => new EE_Datetime_Field('post_date', |
|
| 115 | + esc_html__('Date/Time Event Created', 'event_espresso'), |
|
| 116 | + false, EE_Datetime_Field::now), |
|
| 117 | + 'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt', |
|
| 118 | + esc_html__('Event Short Description', 'event_espresso'), false, ''), |
|
| 119 | + 'EVT_modified' => new EE_Datetime_Field('post_modified', |
|
| 120 | + esc_html__('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now), |
|
| 121 | + 'EVT_wp_user' => new EE_WP_User_Field('post_author', |
|
| 122 | + esc_html__('Event Creator ID', 'event_espresso'), |
|
| 123 | + false), |
|
| 124 | + 'parent' => new EE_Integer_Field('post_parent', esc_html__('Event Parent ID', 'event_espresso'), |
|
| 125 | + false, |
|
| 126 | + 0), |
|
| 127 | + 'EVT_order' => new EE_Integer_Field('menu_order', esc_html__('Event Menu Order', 'event_espresso'), |
|
| 128 | + false, |
|
| 129 | + 1), |
|
| 130 | + 'post_type' => new EE_WP_Post_Type_Field('espresso_events'), |
|
| 131 | + // EE_Plain_Text_Field( 'post_type', esc_html__( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
| 132 | + 'status' => new EE_WP_Post_Status_Field('post_status', |
|
| 133 | + esc_html__('Event Status', 'event_espresso'), |
|
| 134 | + false, 'draft', $this->_custom_stati), |
|
| 135 | + ), |
|
| 136 | + 'Event_Meta' => array( |
|
| 137 | + 'EVTM_ID' => new EE_DB_Only_Float_Field('EVTM_ID', |
|
| 138 | + esc_html__('Event Meta Row ID', 'event_espresso'), false), |
|
| 139 | + 'EVT_ID_fk' => new EE_DB_Only_Int_Field('EVT_ID', |
|
| 140 | + esc_html__('Foreign key to Event ID from Event Meta table', 'event_espresso'), false), |
|
| 141 | + 'EVT_display_desc' => new EE_Boolean_Field('EVT_display_desc', |
|
| 142 | + esc_html__('Display Description Flag', 'event_espresso'), false, 1), |
|
| 143 | + 'EVT_display_ticket_selector' => new EE_Boolean_Field('EVT_display_ticket_selector', |
|
| 144 | + esc_html__('Display Ticket Selector Flag', 'event_espresso'), false, 1), |
|
| 145 | + 'EVT_visible_on' => new EE_Datetime_Field('EVT_visible_on', |
|
| 146 | + esc_html__('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now), |
|
| 147 | + 'EVT_additional_limit' => new EE_Integer_Field( |
|
| 148 | + 'EVT_additional_limit', |
|
| 149 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso'), |
|
| 150 | + true, |
|
| 151 | + self::$_default_additional_limit |
|
| 152 | + ), |
|
| 153 | + 'EVT_default_registration_status' => new EE_Enum_Text_Field( |
|
| 154 | + 'EVT_default_registration_status', |
|
| 155 | + esc_html__('Default Registration Status on this Event', 'event_espresso'), false, |
|
| 156 | + EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
| 157 | + ), |
|
| 158 | + 'EVT_member_only' => new EE_Boolean_Field('EVT_member_only', |
|
| 159 | + esc_html__('Member-Only Event Flag', 'event_espresso'), false, false), |
|
| 160 | + 'EVT_phone' => new EE_Plain_Text_Field('EVT_phone', |
|
| 161 | + esc_html__('Event Phone Number', 'event_espresso'), false), |
|
| 162 | + 'EVT_allow_overflow' => new EE_Boolean_Field('EVT_allow_overflow', |
|
| 163 | + esc_html__('Allow Overflow on Event', 'event_espresso'), false, false), |
|
| 164 | + 'EVT_timezone_string' => new EE_Plain_Text_Field('EVT_timezone_string', |
|
| 165 | + esc_html__('Timezone (name) for Event times', 'event_espresso'), false), |
|
| 166 | + 'EVT_external_URL' => new EE_Plain_Text_Field('EVT_external_URL', |
|
| 167 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso'), true), |
|
| 168 | + 'EVT_donations' => new EE_Boolean_Field('EVT_donations', |
|
| 169 | + esc_html__('Accept Donations?', 'event_espresso'), false, false), |
|
| 170 | + ), |
|
| 171 | + ); |
|
| 172 | + $this->_model_relations = array( |
|
| 173 | + 'Registration' => new EE_Has_Many_Relation(), |
|
| 174 | + 'Datetime' => new EE_Has_Many_Relation(), |
|
| 175 | + 'Question_Group' => new EE_HABTM_Relation('Event_Question_Group'), |
|
| 176 | + 'Venue' => new EE_HABTM_Relation('Event_Venue'), |
|
| 177 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 178 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 179 | + 'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'), |
|
| 180 | + 'Attendee' => new EE_HABTM_Relation('Registration'), |
|
| 181 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 182 | + ); |
|
| 183 | + //this model is generally available for reading |
|
| 184 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
| 185 | + parent::__construct($timezone); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @param string $default_reg_status |
|
| 192 | + */ |
|
| 193 | + public static function set_default_reg_status($default_reg_status) |
|
| 194 | + { |
|
| 195 | + self::$_default_reg_status = $default_reg_status; |
|
| 196 | + // if EEM_Event has already been instantiated, |
|
| 197 | + // then we need to reset the `EVT_default_reg_status` field to use the new default. |
|
| 198 | + if (self::$_instance instanceof EEM_Event) { |
|
| 199 | + $default_reg_status = new EE_Enum_Text_Field( |
|
| 200 | + 'EVT_default_registration_status', |
|
| 201 | + esc_html__('Default Registration Status on this Event', 'event_espresso'), |
|
| 202 | + false, |
|
| 203 | + $default_reg_status, |
|
| 204 | + EEM_Registration::reg_status_array() |
|
| 205 | + ); |
|
| 206 | + $default_reg_status->_construct_finalize( |
|
| 207 | + 'Event_Meta', |
|
| 208 | + 'EVT_default_registration_status', |
|
| 209 | + 'EEM_Event' |
|
| 210 | + ); |
|
| 211 | + self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = $default_reg_status; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Used to override the default for the additional limit field. |
|
| 218 | + * @param $additional_limit |
|
| 219 | + */ |
|
| 220 | + public static function set_default_additional_limit($additional_limit) |
|
| 221 | + { |
|
| 222 | + self::$_default_additional_limit = (int) $additional_limit; |
|
| 223 | + if (self::$_instance instanceof EEM_Event) { |
|
| 224 | + self::$_instance->_fields['Event_Meta']['EVT_additional_limit'] = new EE_Integer_Field( |
|
| 225 | + 'EVT_additional_limit', |
|
| 226 | + __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), |
|
| 227 | + true, |
|
| 228 | + self::$_default_additional_limit |
|
| 229 | + ); |
|
| 230 | + self::$_instance->_fields['Event_Meta']['EVT_additional_limit']->_construct_finalize( |
|
| 231 | + 'Event_Meta', |
|
| 232 | + 'EVT_additional_limit', |
|
| 233 | + 'EEM_Event' |
|
| 234 | + ); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Return what is currently set as the default additional limit for the event. |
|
| 241 | + * @return int |
|
| 242 | + */ |
|
| 243 | + public static function get_default_additional_limit() |
|
| 244 | + { |
|
| 245 | + return apply_filters('FHEE__EEM_Event__get_default_additional_limit', self::$_default_additional_limit); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * get_question_groups |
|
| 251 | + * |
|
| 252 | + * @return array |
|
| 253 | + * @throws \EE_Error |
|
| 254 | + */ |
|
| 255 | + public function get_all_question_groups() |
|
| 256 | + { |
|
| 257 | + return EE_Registry::instance()->load_model('Question_Group')->get_all( |
|
| 258 | + array( |
|
| 259 | + array('QSG_deleted' => false), |
|
| 260 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
| 261 | + ) |
|
| 262 | + ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * get_question_groups |
|
| 269 | + * |
|
| 270 | + * @param int $EVT_ID |
|
| 271 | + * @return array|bool |
|
| 272 | + * @throws \EE_Error |
|
| 273 | + */ |
|
| 274 | + public function get_all_event_question_groups($EVT_ID = 0) |
|
| 275 | + { |
|
| 276 | + if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 277 | + EE_Error::add_error( |
|
| 278 | + esc_html__( |
|
| 279 | + 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
| 280 | + 'event_espresso' |
|
| 281 | + ), |
|
| 282 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 283 | + ); |
|
| 284 | + return false; |
|
| 285 | + } |
|
| 286 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all( |
|
| 287 | + array( |
|
| 288 | + array('EVT_ID' => $EVT_ID), |
|
| 289 | + ) |
|
| 290 | + ); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * get_question_groups |
|
| 297 | + * |
|
| 298 | + * @param int $EVT_ID |
|
| 299 | + * @param boolean $for_primary_attendee |
|
| 300 | + * @return array|bool |
|
| 301 | + * @throws \EE_Error |
|
| 302 | + */ |
|
| 303 | + public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true) |
|
| 304 | + { |
|
| 305 | + if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 306 | + EE_Error::add_error( |
|
| 307 | + esc_html__( |
|
| 308 | + 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
| 309 | + 'event_espresso' |
|
| 310 | + ), |
|
| 311 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 312 | + ); |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all( |
|
| 316 | + array( |
|
| 317 | + array( |
|
| 318 | + 'EVT_ID' => $EVT_ID, |
|
| 319 | + 'EQG_primary' => $for_primary_attendee, |
|
| 320 | + ), |
|
| 321 | + ) |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * get_question_groups |
|
| 329 | + * |
|
| 330 | + * @param int $EVT_ID |
|
| 331 | + * @param EE_Registration $registration |
|
| 332 | + * @return array|bool |
|
| 333 | + * @throws \EE_Error |
|
| 334 | + */ |
|
| 335 | + public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) |
|
| 336 | + { |
|
| 337 | + if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 338 | + EE_Error::add_error( |
|
| 339 | + esc_html__( |
|
| 340 | + 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', |
|
| 341 | + 'event_espresso' |
|
| 342 | + ), |
|
| 343 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 344 | + ); |
|
| 345 | + return false; |
|
| 346 | + } |
|
| 347 | + $where_params = array( |
|
| 348 | + 'Event_Question_Group.EVT_ID' => $EVT_ID, |
|
| 349 | + 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false, |
|
| 350 | + 'QSG_deleted' => false, |
|
| 351 | + ); |
|
| 352 | + return EE_Registry::instance()->load_model('Question_Group')->get_all( |
|
| 353 | + array( |
|
| 354 | + $where_params, |
|
| 355 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
| 356 | + ) |
|
| 357 | + ); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * get_question_target_db_column |
|
| 364 | + * |
|
| 365 | + * @param string $QSG_IDs csv list of $QSG IDs |
|
| 366 | + * @return array|bool |
|
| 367 | + * @throws \EE_Error |
|
| 368 | + */ |
|
| 369 | + public function get_questions_in_groups($QSG_IDs = '') |
|
| 370 | + { |
|
| 371 | + if (empty($QSG_IDs)) { |
|
| 372 | + EE_Error::add_error( |
|
| 373 | + esc_html__('An error occurred. No Question Group IDs were received.', 'event_espresso'), |
|
| 374 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 375 | + ); |
|
| 376 | + return false; |
|
| 377 | + } |
|
| 378 | + return EE_Registry::instance()->load_model('Question')->get_all( |
|
| 379 | + array( |
|
| 380 | + array( |
|
| 381 | + 'Question_Group.QSG_ID' => array('IN', $QSG_IDs), |
|
| 382 | + 'QST_deleted' => false, |
|
| 383 | + 'QST_admin_only' => is_admin(), |
|
| 384 | + ), |
|
| 385 | + 'order_by' => 'QST_order', |
|
| 386 | + ) |
|
| 387 | + ); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * get_options_for_question |
|
| 394 | + * |
|
| 395 | + * @param string $QST_IDs csv list of $QST IDs |
|
| 396 | + * @return array|bool |
|
| 397 | + * @throws \EE_Error |
|
| 398 | + */ |
|
| 399 | + public function get_options_for_question($QST_IDs) |
|
| 400 | + { |
|
| 401 | + if (empty($QST_IDs)) { |
|
| 402 | + EE_Error::add_error( |
|
| 403 | + esc_html__('An error occurred. No Question IDs were received.', 'event_espresso'), |
|
| 404 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 405 | + ); |
|
| 406 | + return false; |
|
| 407 | + } |
|
| 408 | + return EE_Registry::instance()->load_model('Question_Option')->get_all( |
|
| 409 | + array( |
|
| 410 | + array( |
|
| 411 | + 'Question.QST_ID' => array('IN', $QST_IDs), |
|
| 412 | + 'QSO_deleted' => false, |
|
| 413 | + ), |
|
| 414 | + 'order_by' => 'QSO_ID', |
|
| 415 | + ) |
|
| 416 | + ); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Gets all events that are published |
|
| 427 | + * and have event start time earlier than now and an event end time later than now |
|
| 428 | + * |
|
| 429 | + * @param array $query_params An array of query params to further filter on |
|
| 430 | + * (note that status and DTT_EVT_start and DTT_EVT_end will be overridden) |
|
| 431 | + * @param bool $count whether to return the count or not (default FALSE) |
|
| 432 | + * @return EE_Event[]|int |
|
| 433 | + * @throws \EE_Error |
|
| 434 | + */ |
|
| 435 | + public function get_active_events($query_params, $count = false) |
|
| 436 | + { |
|
| 437 | + if (array_key_exists(0, $query_params)) { |
|
| 438 | + $where_params = $query_params[0]; |
|
| 439 | + unset($query_params[0]); |
|
| 440 | + } else { |
|
| 441 | + $where_params = array(); |
|
| 442 | + } |
|
| 443 | + // if we have count make sure we don't include group by |
|
| 444 | + if ($count && isset($query_params['group_by'])) { |
|
| 445 | + unset($query_params['group_by']); |
|
| 446 | + } |
|
| 447 | + // let's add specific query_params for active_events |
|
| 448 | + // keep in mind this will override any sent status in the query AND any date queries. |
|
| 449 | + $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 450 | + //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
|
| 451 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 452 | + $where_params['Datetime.DTT_EVT_start******'] = array( |
|
| 453 | + '<', |
|
| 454 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 455 | + ); |
|
| 456 | + } else { |
|
| 457 | + $where_params['Datetime.DTT_EVT_start'] = array( |
|
| 458 | + '<', |
|
| 459 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 460 | + ); |
|
| 461 | + } |
|
| 462 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 463 | + $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
| 464 | + '>', |
|
| 465 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 466 | + ); |
|
| 467 | + } else { |
|
| 468 | + $where_params['Datetime.DTT_EVT_end'] = array( |
|
| 469 | + '>', |
|
| 470 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 471 | + ); |
|
| 472 | + } |
|
| 473 | + $query_params[0] = $where_params; |
|
| 474 | + // don't use $query_params with count() |
|
| 475 | + // because we don't want to include additional query clauses like "GROUP BY" |
|
| 476 | + return $count |
|
| 477 | + ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 478 | + : $this->get_all($query_params); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * get all events that are published and have an event start time later than now |
|
| 485 | + * |
|
| 486 | + * @param array $query_params An array of query params to further filter on |
|
| 487 | + * (Note that status and DTT_EVT_start will be overridden) |
|
| 488 | + * @param bool $count whether to return the count or not (default FALSE) |
|
| 489 | + * @return EE_Event[]|int |
|
| 490 | + * @throws \EE_Error |
|
| 491 | + */ |
|
| 492 | + public function get_upcoming_events($query_params, $count = false) |
|
| 493 | + { |
|
| 494 | + if (array_key_exists(0, $query_params)) { |
|
| 495 | + $where_params = $query_params[0]; |
|
| 496 | + unset($query_params[0]); |
|
| 497 | + } else { |
|
| 498 | + $where_params = array(); |
|
| 499 | + } |
|
| 500 | + // if we have count make sure we don't include group by |
|
| 501 | + if ($count && isset($query_params['group_by'])) { |
|
| 502 | + unset($query_params['group_by']); |
|
| 503 | + } |
|
| 504 | + // let's add specific query_params for active_events |
|
| 505 | + // keep in mind this will override any sent status in the query AND any date queries. |
|
| 506 | + $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 507 | + // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 508 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 509 | + $where_params['Datetime.DTT_EVT_start*****'] = array( |
|
| 510 | + '>', |
|
| 511 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 512 | + ); |
|
| 513 | + } else { |
|
| 514 | + $where_params['Datetime.DTT_EVT_start'] = array( |
|
| 515 | + '>', |
|
| 516 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 517 | + ); |
|
| 518 | + } |
|
| 519 | + $query_params[0] = $where_params; |
|
| 520 | + // don't use $query_params with count() |
|
| 521 | + // because we don't want to include additional query clauses like "GROUP BY" |
|
| 522 | + return $count |
|
| 523 | + ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 524 | + : $this->get_all($query_params); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Gets all events that are published |
|
| 531 | + * and have an event end time later than now |
|
| 532 | + * |
|
| 533 | + * @param array $query_params An array of query params to further filter on |
|
| 534 | + * (note that status and DTT_EVT_end will be overridden) |
|
| 535 | + * @param bool $count whether to return the count or not (default FALSE) |
|
| 536 | + * @return EE_Event[]|int |
|
| 537 | + * @throws \EE_Error |
|
| 538 | + */ |
|
| 539 | + public function get_active_and_upcoming_events($query_params, $count = false) |
|
| 540 | + { |
|
| 541 | + if (array_key_exists(0, $query_params)) { |
|
| 542 | + $where_params = $query_params[0]; |
|
| 543 | + unset($query_params[0]); |
|
| 544 | + } else { |
|
| 545 | + $where_params = array(); |
|
| 546 | + } |
|
| 547 | + // if we have count make sure we don't include group by |
|
| 548 | + if ($count && isset($query_params['group_by'])) { |
|
| 549 | + unset($query_params['group_by']); |
|
| 550 | + } |
|
| 551 | + // let's add specific query_params for active_events |
|
| 552 | + // keep in mind this will override any sent status in the query AND any date queries. |
|
| 553 | + $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
| 554 | + // add where params for DTT_EVT_end |
|
| 555 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 556 | + $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
| 557 | + '>', |
|
| 558 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 559 | + ); |
|
| 560 | + } else { |
|
| 561 | + $where_params['Datetime.DTT_EVT_end'] = array( |
|
| 562 | + '>', |
|
| 563 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 564 | + ); |
|
| 565 | + } |
|
| 566 | + $query_params[0] = $where_params; |
|
| 567 | + // don't use $query_params with count() |
|
| 568 | + // because we don't want to include additional query clauses like "GROUP BY" |
|
| 569 | + return $count |
|
| 570 | + ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 571 | + : $this->get_all($query_params); |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * This only returns events that are expired. |
|
| 578 | + * They may still be published but all their datetimes have expired. |
|
| 579 | + * |
|
| 580 | + * @param array $query_params An array of query params to further filter on |
|
| 581 | + * (note that status and DTT_EVT_end will be overridden) |
|
| 582 | + * @param bool $count whether to return the count or not (default FALSE) |
|
| 583 | + * @return EE_Event[]|int |
|
| 584 | + * @throws \EE_Error |
|
| 585 | + */ |
|
| 586 | + public function get_expired_events($query_params, $count = false) |
|
| 587 | + { |
|
| 588 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 589 | + // if we have count make sure we don't include group by |
|
| 590 | + if ($count && isset($query_params['group_by'])) { |
|
| 591 | + unset($query_params['group_by']); |
|
| 592 | + } |
|
| 593 | + // let's add specific query_params for active_events |
|
| 594 | + // keep in mind this will override any sent status in the query AND any date queries. |
|
| 595 | + if (isset($where_params['status'])) { |
|
| 596 | + unset($where_params['status']); |
|
| 597 | + } |
|
| 598 | + $exclude_query = $query_params; |
|
| 599 | + if (isset($exclude_query[0])) { |
|
| 600 | + unset($exclude_query[0]); |
|
| 601 | + } |
|
| 602 | + $exclude_query[0] = array( |
|
| 603 | + 'Datetime.DTT_EVT_end' => array( |
|
| 604 | + '>', |
|
| 605 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 606 | + ), |
|
| 607 | + ); |
|
| 608 | + // first get all events that have datetimes where its not expired. |
|
| 609 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID'); |
|
| 610 | + $event_ids = array_keys($event_ids); |
|
| 611 | + // if we have any additional query_params, let's add them to the 'AND' condition |
|
| 612 | + $and_condition = array( |
|
| 613 | + 'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')), |
|
| 614 | + 'EVT_ID' => array('NOT IN', $event_ids), |
|
| 615 | + ); |
|
| 616 | + if (isset($where_params['OR'])) { |
|
| 617 | + $and_condition['OR'] = $where_params['OR']; |
|
| 618 | + unset($where_params['OR']); |
|
| 619 | + } |
|
| 620 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 621 | + $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
| 622 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
| 623 | + } |
|
| 624 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 625 | + $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
| 626 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
| 627 | + } |
|
| 628 | + // merge remaining $where params with the and conditions. |
|
| 629 | + $where_params['AND'] = array_merge($and_condition, $where_params); |
|
| 630 | + $query_params[0] = $where_params; |
|
| 631 | + // don't use $query_params with count() |
|
| 632 | + // because we don't want to include additional query clauses like "GROUP BY" |
|
| 633 | + return $count |
|
| 634 | + ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 635 | + : $this->get_all($query_params); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + |
|
| 640 | + /** |
|
| 641 | + * This basically just returns the events that do not have the publish status. |
|
| 642 | + * |
|
| 643 | + * @param array $query_params An array of query params to further filter on |
|
| 644 | + * (note that status will be overwritten) |
|
| 645 | + * @param boolean $count whether to return the count or not (default FALSE) |
|
| 646 | + * @return EE_Event[]|int |
|
| 647 | + * @throws \EE_Error |
|
| 648 | + */ |
|
| 649 | + public function get_inactive_events($query_params, $count = false) |
|
| 650 | + { |
|
| 651 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 652 | + // let's add in specific query_params for inactive events. |
|
| 653 | + if (isset($where_params['status'])) { |
|
| 654 | + unset($where_params['status']); |
|
| 655 | + } |
|
| 656 | + // if we have count make sure we don't include group by |
|
| 657 | + if ($count && isset($query_params['group_by'])) { |
|
| 658 | + unset($query_params['group_by']); |
|
| 659 | + } |
|
| 660 | + // if we have any additional query_params, let's add them to the 'AND' condition |
|
| 661 | + $where_params['AND']['status'] = array('!=', 'publish'); |
|
| 662 | + if (isset($where_params['OR'])) { |
|
| 663 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
| 664 | + unset($where_params['OR']); |
|
| 665 | + } |
|
| 666 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 667 | + $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
| 668 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
| 669 | + } |
|
| 670 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
| 671 | + $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
| 672 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
| 673 | + } |
|
| 674 | + $query_params[0] = $where_params; |
|
| 675 | + // don't use $query_params with count() |
|
| 676 | + // because we don't want to include additional query clauses like "GROUP BY" |
|
| 677 | + return $count |
|
| 678 | + ? $this->count(array($where_params), 'EVT_ID', true) |
|
| 679 | + : $this->get_all($query_params); |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * This is just injecting into the parent add_relationship_to so we do special handling on price relationships |
|
| 686 | + * because we don't want to override any existing global default prices but instead insert NEW prices that get |
|
| 687 | + * attached to the event. See parent for param descriptions |
|
| 688 | + * |
|
| 689 | + * @param $id_or_obj |
|
| 690 | + * @param $other_model_id_or_obj |
|
| 691 | + * @param string $relationName |
|
| 692 | + * @param array $where_query |
|
| 693 | + * @return EE_Base_Class |
|
| 694 | + * @throws EE_Error |
|
| 695 | + */ |
|
| 696 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) |
|
| 697 | + { |
|
| 698 | + if ($relationName === 'Price') { |
|
| 699 | + //let's get the PRC object for the given ID to make sure that we aren't dealing with a default |
|
| 700 | + $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj); |
|
| 701 | + //if EVT_ID = 0, then this is a default |
|
| 702 | + if ((int) $prc_chk->get('EVT_ID') === 0) { |
|
| 703 | + //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation |
|
| 704 | + $prc_chk->set('PRC_ID', 0); |
|
| 705 | + } |
|
| 706 | + //run parent |
|
| 707 | + return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query); |
|
| 708 | + } |
|
| 709 | + //otherwise carry on as normal |
|
| 710 | + return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query); |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + |
|
| 714 | + |
|
| 715 | + /******************** DEPRECATED METHODS ********************/ |
|
| 716 | + |
|
| 717 | + |
|
| 718 | + |
|
| 719 | + /** |
|
| 720 | + * _get_question_target_db_column |
|
| 721 | + * |
|
| 722 | + * @deprecated as of 4.8.32.rc.001. Instead consider using |
|
| 723 | + * EE_Registration_Custom_Questions_Form located in |
|
| 724 | + * admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php |
|
| 725 | + * @access public |
|
| 726 | + * @param EE_Registration $registration (so existing answers for registration are included) |
|
| 727 | + * @param int $EVT_ID so all question groups are included for event (not just answers from |
|
| 728 | + * registration). |
|
| 729 | + * @throws EE_Error |
|
| 730 | + * @return array |
|
| 731 | + */ |
|
| 732 | + public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) |
|
| 733 | + { |
|
| 734 | + if (empty($EVT_ID)) { |
|
| 735 | + throw new EE_Error(__('An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', |
|
| 736 | + 'event_espresso')); |
|
| 737 | + } |
|
| 738 | + $questions = array(); |
|
| 739 | + // get all question groups for event |
|
| 740 | + $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
|
| 741 | + if (! empty($qgs)) { |
|
| 742 | + foreach ($qgs as $qg) { |
|
| 743 | + $qsts = $qg->questions(); |
|
| 744 | + $questions[$qg->ID()] = $qg->model_field_array(); |
|
| 745 | + $questions[$qg->ID()]['QSG_questions'] = array(); |
|
| 746 | + foreach ($qsts as $qst) { |
|
| 747 | + if ($qst->is_system_question()) { |
|
| 748 | + continue; |
|
| 749 | + } |
|
| 750 | + $answer = EEM_Answer::instance()->get_one(array( |
|
| 751 | + array( |
|
| 752 | + 'QST_ID' => $qst->ID(), |
|
| 753 | + 'REG_ID' => $registration->ID(), |
|
| 754 | + ), |
|
| 755 | + )); |
|
| 756 | + $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
|
| 757 | + $qst_name = $qstn_id = $qst->ID(); |
|
| 758 | + $ans_id = $answer->ID(); |
|
| 759 | + $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
| 760 | + $input_name = ''; |
|
| 761 | + $input_id = sanitize_key($qst->display_text()); |
|
| 762 | + $input_class = ''; |
|
| 763 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
|
| 764 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' |
|
| 765 | + . $input_name |
|
| 766 | + . $qst_name; |
|
| 767 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
| 768 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
|
| 769 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
|
| 770 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
|
| 771 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer; |
|
| 772 | + //leave responses as-is, don't convert stuff into html entities please! |
|
| 773 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false; |
|
| 774 | + if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') { |
|
| 775 | + $QSOs = $qst->options(true, $answer->value()); |
|
| 776 | + if (is_array($QSOs)) { |
|
| 777 | + foreach ($QSOs as $QSO_ID => $QSO) { |
|
| 778 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array(); |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + } |
|
| 785 | + return $questions; |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | 788 | |
| 789 | 789 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\orm\ModelFieldFactory; |
| 2 | 2 | |
| 3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | -require_once(EE_MODELS . 'EEM_CPT_Base.model.php'); |
|
| 6 | +require_once(EE_MODELS.'EEM_CPT_Base.model.php'); |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function get_all_event_question_groups($EVT_ID = 0) |
| 275 | 275 | { |
| 276 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 276 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 277 | 277 | EE_Error::add_error( |
| 278 | 278 | esc_html__( |
| 279 | 279 | 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true) |
| 304 | 304 | { |
| 305 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 305 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 306 | 306 | EE_Error::add_error( |
| 307 | 307 | esc_html__( |
| 308 | 308 | 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) |
| 336 | 336 | { |
| 337 | - if (! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 337 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
| 338 | 338 | EE_Error::add_error( |
| 339 | 339 | esc_html__( |
| 340 | 340 | 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $questions = array(); |
| 739 | 739 | // get all question groups for event |
| 740 | 740 | $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
| 741 | - if (! empty($qgs)) { |
|
| 741 | + if ( ! empty($qgs)) { |
|
| 742 | 742 | foreach ($qgs as $qg) { |
| 743 | 743 | $qsts = $qg->questions(); |
| 744 | 744 | $questions[$qg->ID()] = $qg->model_field_array(); |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
| 757 | 757 | $qst_name = $qstn_id = $qst->ID(); |
| 758 | 758 | $ans_id = $answer->ID(); |
| 759 | - $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
| 759 | + $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']'; |
|
| 760 | 760 | $input_name = ''; |
| 761 | 761 | $input_id = sanitize_key($qst->display_text()); |
| 762 | 762 | $input_class = ''; |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' |
| 765 | 765 | . $input_name |
| 766 | 766 | . $qst_name; |
| 767 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
| 767 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id; |
|
| 768 | 768 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
| 769 | 769 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
| 770 | 770 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
@@ -132,7 +132,6 @@ discard block |
||
| 132 | 132 | /** |
| 133 | 133 | * @param string $table_column |
| 134 | 134 | * @param string $nice_name |
| 135 | - * @param string $timezone_string |
|
| 136 | 135 | * @param bool $nullable |
| 137 | 136 | * @param string $default_value |
| 138 | 137 | * @throws EE_Error |
@@ -179,7 +178,7 @@ discard block |
||
| 179 | 178 | * @param string $table_column |
| 180 | 179 | * @param string $nice_name |
| 181 | 180 | * @param bool $nullable |
| 182 | - * @param null $default_value |
|
| 181 | + * @param integer $default_value |
|
| 183 | 182 | * @return EE_DB_Only_Int_Field |
| 184 | 183 | */ |
| 185 | 184 | public function createDbOnlyIntField($table_column, $nice_name, $nullable, $default_value = null) |
@@ -295,7 +294,7 @@ discard block |
||
| 295 | 294 | * @param string $table_column |
| 296 | 295 | * @param string $nice_name |
| 297 | 296 | * @param bool $nullable |
| 298 | - * @param null $default_value |
|
| 297 | + * @param integer $default_value |
|
| 299 | 298 | * @param string $model_name |
| 300 | 299 | * @return EE_Foreign_Key_Int_Field |
| 301 | 300 | */ |
@@ -313,7 +312,7 @@ discard block |
||
| 313 | 312 | * @param string $table_column |
| 314 | 313 | * @param string $nice_name |
| 315 | 314 | * @param bool $nullable |
| 316 | - * @param null $default_value |
|
| 315 | + * @param string $default_value |
|
| 317 | 316 | * @param string $model_name |
| 318 | 317 | * @return EE_Foreign_Key_String_Field |
| 319 | 318 | */ |
@@ -564,7 +563,7 @@ discard block |
||
| 564 | 563 | * @param string $table_column |
| 565 | 564 | * @param string $nice_name |
| 566 | 565 | * @param bool $nullable |
| 567 | - * @param mixed $default_value |
|
| 566 | + * @param string $default_value |
|
| 568 | 567 | * @param array $values If additional stati are to be used other than the default WP statuses, |
| 569 | 568 | * then they can be registered via this property. |
| 570 | 569 | * The format of the array should be as follows: |
@@ -33,9 +33,6 @@ |
||
| 33 | 33 | use EE_WP_Post_Status_Field; |
| 34 | 34 | use EE_WP_Post_Type_Field; |
| 35 | 35 | use EE_WP_User_Field; |
| 36 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
| 37 | -use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
| 38 | -use EventEspresso\core\services\loaders\LoaderFactory; |
|
| 39 | 36 | use EventEspresso\core\services\loaders\LoaderInterface; |
| 40 | 37 | use InvalidArgumentException; |
| 41 | 38 | |
@@ -53,576 +53,576 @@ |
||
| 53 | 53 | class ModelFieldFactory |
| 54 | 54 | { |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var LoaderInterface $loader |
|
| 58 | - */ |
|
| 59 | - private $loader; |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * ModelFieldFactory constructor. |
|
| 65 | - * |
|
| 66 | - * @param LoaderInterface $loader |
|
| 67 | - */ |
|
| 68 | - public function __construct(LoaderInterface $loader) |
|
| 69 | - { |
|
| 70 | - $this->loader = $loader; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param string $table_column |
|
| 77 | - * @param string $nice_name |
|
| 78 | - * @param bool $nullable |
|
| 79 | - * @param null $default_value |
|
| 80 | - * @return EE_All_Caps_Text_Field |
|
| 81 | - */ |
|
| 82 | - public function createAllCapsTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 83 | - { |
|
| 84 | - return $this->loader->getNew( |
|
| 85 | - 'EE_All_Caps_Text_Field', |
|
| 86 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @param string $table_column |
|
| 94 | - * @param string $nice_name |
|
| 95 | - * @param bool $nullable |
|
| 96 | - * @param null $default_value |
|
| 97 | - * @param string $model_name |
|
| 98 | - * @return EE_Any_Foreign_Model_Name_Field |
|
| 99 | - */ |
|
| 100 | - public function createAnyForeignModelNameField( |
|
| 101 | - $table_column, |
|
| 102 | - $nice_name, |
|
| 103 | - $nullable, |
|
| 104 | - $default_value = null, |
|
| 105 | - $model_name |
|
| 106 | - ) { |
|
| 107 | - return $this->loader->getNew( |
|
| 108 | - 'EE_Any_Foreign_Model_Name_Field', |
|
| 109 | - array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 110 | - ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @param string $table_column |
|
| 117 | - * @param string $nice_name |
|
| 118 | - * @param bool $nullable |
|
| 119 | - * @param null $default_value |
|
| 120 | - * @return EE_Boolean_Field |
|
| 121 | - */ |
|
| 122 | - public function createBooleanField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 123 | - { |
|
| 124 | - return $this->loader->getNew( |
|
| 125 | - 'EE_Boolean_Field', |
|
| 126 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 127 | - ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @param string $table_column |
|
| 134 | - * @param string $nice_name |
|
| 135 | - * @param string $timezone_string |
|
| 136 | - * @param bool $nullable |
|
| 137 | - * @param string $default_value |
|
| 138 | - * @throws EE_Error |
|
| 139 | - * @throws InvalidArgumentException |
|
| 140 | - * @return EE_Datetime_Field |
|
| 141 | - */ |
|
| 142 | - public function createDatetimeField( |
|
| 143 | - $table_column, |
|
| 144 | - $nice_name, |
|
| 145 | - $nullable = false, |
|
| 146 | - $default_value = EE_Datetime_Field::now |
|
| 147 | - ) { |
|
| 148 | - return $this->loader->getNew( |
|
| 149 | - 'EE_Datetime_Field', |
|
| 150 | - array( |
|
| 151 | - $table_column, |
|
| 152 | - $nice_name, |
|
| 153 | - $nullable, |
|
| 154 | - $default_value |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @param string $table_column |
|
| 163 | - * @param string $nice_name |
|
| 164 | - * @param bool $nullable |
|
| 165 | - * @param null $default_value |
|
| 166 | - * @return EE_DB_Only_Float_Field |
|
| 167 | - */ |
|
| 168 | - public function createDbOnlyFloatField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 169 | - { |
|
| 170 | - return $this->loader->getNew( |
|
| 171 | - 'EE_DB_Only_Float_Field', |
|
| 172 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 173 | - ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @param string $table_column |
|
| 180 | - * @param string $nice_name |
|
| 181 | - * @param bool $nullable |
|
| 182 | - * @param null $default_value |
|
| 183 | - * @return EE_DB_Only_Int_Field |
|
| 184 | - */ |
|
| 185 | - public function createDbOnlyIntField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 186 | - { |
|
| 187 | - return $this->loader->getNew( |
|
| 188 | - 'EE_DB_Only_Int_Field', |
|
| 189 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 190 | - ); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * @param string $table_column |
|
| 197 | - * @param string $nice_name |
|
| 198 | - * @param bool $nullable |
|
| 199 | - * @param null $default_value |
|
| 200 | - * @return EE_DB_Only_Text_Field |
|
| 201 | - */ |
|
| 202 | - public function createDbOnlyTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 203 | - { |
|
| 204 | - return $this->loader->getNew( |
|
| 205 | - 'EE_DB_Only_Text_Field', |
|
| 206 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 207 | - ); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @param string $table_column |
|
| 214 | - * @param string $nice_name |
|
| 215 | - * @param bool $nullable |
|
| 216 | - * @param string $default_value |
|
| 217 | - * @return EE_Email_Field |
|
| 218 | - */ |
|
| 219 | - public function createEmailField($table_column, $nice_name, $nullable = true, $default_value = '') |
|
| 220 | - { |
|
| 221 | - return $this->loader->getNew( |
|
| 222 | - 'EE_Email_Field', |
|
| 223 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * @param string $table_column |
|
| 231 | - * @param string $nice_name |
|
| 232 | - * @param bool $nullable |
|
| 233 | - * @param null $default_value |
|
| 234 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 235 | - * values are how they should be displayed |
|
| 236 | - * @return EE_Enum_Integer_Field |
|
| 237 | - */ |
|
| 238 | - public function createEnumIntegerField( |
|
| 239 | - $table_column, |
|
| 240 | - $nice_name, |
|
| 241 | - $nullable, |
|
| 242 | - $default_value = null, |
|
| 243 | - array $allowed_enum_values |
|
| 244 | - ) { |
|
| 245 | - return $this->loader->getNew( |
|
| 246 | - 'EE_Enum_Integer_Field', |
|
| 247 | - array($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) |
|
| 248 | - ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @param string $table_column |
|
| 255 | - * @param string $nice_name |
|
| 256 | - * @param bool $nullable |
|
| 257 | - * @param null $default_value |
|
| 258 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 259 | - * values are how they should be displayed |
|
| 260 | - * @return EE_Enum_Text_Field |
|
| 261 | - */ |
|
| 262 | - public function createEnumTextField( |
|
| 263 | - $table_column, |
|
| 264 | - $nice_name, |
|
| 265 | - $nullable, |
|
| 266 | - $default_value, |
|
| 267 | - array $allowed_enum_values |
|
| 268 | - ) { |
|
| 269 | - return $this->loader->getNew( |
|
| 270 | - 'EE_Enum_Text_Field', |
|
| 271 | - array($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) |
|
| 272 | - ); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * @param string $table_column |
|
| 279 | - * @param string $nice_name |
|
| 280 | - * @param bool $nullable |
|
| 281 | - * @param null $default_value |
|
| 282 | - * @return EE_Float_Field |
|
| 283 | - */ |
|
| 284 | - public function createFloatField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 285 | - { |
|
| 286 | - return $this->loader->getNew( |
|
| 287 | - 'EE_Float_Field', |
|
| 288 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 289 | - ); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * @param string $table_column |
|
| 296 | - * @param string $nice_name |
|
| 297 | - * @param bool $nullable |
|
| 298 | - * @param null $default_value |
|
| 299 | - * @param string $model_name |
|
| 300 | - * @return EE_Foreign_Key_Int_Field |
|
| 301 | - */ |
|
| 302 | - public function createForeignKeyIntField($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 303 | - { |
|
| 304 | - return $this->loader->getNew( |
|
| 305 | - 'EE_Foreign_Key_Int_Field', |
|
| 306 | - array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 307 | - ); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * @param string $table_column |
|
| 314 | - * @param string $nice_name |
|
| 315 | - * @param bool $nullable |
|
| 316 | - * @param null $default_value |
|
| 317 | - * @param string $model_name |
|
| 318 | - * @return EE_Foreign_Key_String_Field |
|
| 319 | - */ |
|
| 320 | - public function createForeignKeyStringField( |
|
| 321 | - $table_column, |
|
| 322 | - $nice_name, |
|
| 323 | - $nullable, |
|
| 324 | - $default_value, |
|
| 325 | - $model_name |
|
| 326 | - ) { |
|
| 327 | - return $this->loader->getNew( |
|
| 328 | - 'EE_Foreign_Key_String_Field', |
|
| 329 | - array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 330 | - ); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * @param string $table_column |
|
| 337 | - * @param string $nice_name |
|
| 338 | - * @param bool $nullable |
|
| 339 | - * @param null $default_value |
|
| 340 | - * @return EE_Full_HTML_Field |
|
| 341 | - */ |
|
| 342 | - public function createFullHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 343 | - { |
|
| 344 | - return $this->loader->getNew( |
|
| 345 | - 'EE_Full_HTML_Field', |
|
| 346 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 347 | - ); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * @param string $table_column |
|
| 354 | - * @param string $nice_name |
|
| 355 | - * @param bool $nullable |
|
| 356 | - * @param null $default_value |
|
| 357 | - * @return EE_Infinite_Integer_Field |
|
| 358 | - */ |
|
| 359 | - public function createInfiniteIntegerField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 360 | - { |
|
| 361 | - return $this->loader->getNew( |
|
| 362 | - 'EE_Infinite_Integer_Field', |
|
| 363 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 364 | - ); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * @param string $table_column |
|
| 371 | - * @param string $nice_name |
|
| 372 | - * @param bool $nullable |
|
| 373 | - * @param null $default_value |
|
| 374 | - * @return EE_Integer_Field |
|
| 375 | - */ |
|
| 376 | - public function createIntegerField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 377 | - { |
|
| 378 | - return $this->loader->getNew( |
|
| 379 | - 'EE_Integer_Field', |
|
| 380 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 381 | - ); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * @param string $table_column |
|
| 388 | - * @param string $nice_name |
|
| 389 | - * @param bool $nullable |
|
| 390 | - * @param null $default_value |
|
| 391 | - * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
| 392 | - */ |
|
| 393 | - public function createMaybeSerializedSimpleHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 394 | - { |
|
| 395 | - return $this->loader->getNew( |
|
| 396 | - 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
| 397 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 398 | - ); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * @param string $table_column |
|
| 405 | - * @param string $nice_name |
|
| 406 | - * @param bool $nullable |
|
| 407 | - * @param null $default_value |
|
| 408 | - * @return EE_Maybe_Serialized_Text_Field |
|
| 409 | - */ |
|
| 410 | - public function createMaybeSerializedTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 411 | - { |
|
| 412 | - return $this->loader->getNew( |
|
| 413 | - 'EE_Maybe_Serialized_Text_Field', |
|
| 414 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 415 | - ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * @param string $table_column |
|
| 422 | - * @param string $nice_name |
|
| 423 | - * @param bool $nullable |
|
| 424 | - * @param null $default_value |
|
| 425 | - * @return EE_Money_Field |
|
| 426 | - */ |
|
| 427 | - public function createMoneyField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 428 | - { |
|
| 429 | - return $this->loader->getNew( |
|
| 430 | - 'EE_Money_Field', |
|
| 431 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 432 | - ); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - /** |
|
| 438 | - * @param string $table_column |
|
| 439 | - * @param string $nice_name |
|
| 440 | - * @param bool $nullable |
|
| 441 | - * @param string $default_value |
|
| 442 | - * @return EE_Plain_Text_Field |
|
| 443 | - */ |
|
| 444 | - public function createPlainTextField($table_column, $nice_name, $nullable = true, $default_value = '') |
|
| 445 | - { |
|
| 446 | - return $this->loader->getNew( |
|
| 447 | - 'EE_Plain_Text_Field', |
|
| 448 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 449 | - ); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * @param string $table_column |
|
| 456 | - * @param string $nice_name |
|
| 457 | - * @param bool $nullable |
|
| 458 | - * @param null $default_value |
|
| 459 | - * @return EE_Post_Content_Field |
|
| 460 | - */ |
|
| 461 | - public function createPostContentField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 462 | - { |
|
| 463 | - return $this->loader->getNew( |
|
| 464 | - 'EE_Post_Content_Field', |
|
| 465 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 466 | - ); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * @param string $table_column |
|
| 473 | - * @param string $nice_name |
|
| 474 | - * @return EE_Primary_Key_Int_Field |
|
| 475 | - */ |
|
| 476 | - public function createPrimaryKeyIntField($table_column, $nice_name) |
|
| 477 | - { |
|
| 478 | - return $this->loader->getNew('EE_Primary_Key_Int_Field', array($table_column, $nice_name)); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * @param string $table_column |
|
| 485 | - * @param string $nice_name |
|
| 486 | - * @return EE_Primary_Key_String_Field |
|
| 487 | - */ |
|
| 488 | - public function createPrimaryKeyStringField($table_column, $nice_name) |
|
| 489 | - { |
|
| 490 | - return $this->loader->getNew('EE_Primary_Key_String_Field', array($table_column, $nice_name)); |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * @param string $table_column |
|
| 497 | - * @param string $nice_name |
|
| 498 | - * @param bool $nullable |
|
| 499 | - * @param null $default_value |
|
| 500 | - * @return EE_Serialized_Text_Field |
|
| 501 | - */ |
|
| 502 | - public function createSerializedTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 503 | - { |
|
| 504 | - return $this->loader->getNew( |
|
| 505 | - 'EE_Serialized_Text_Field', |
|
| 506 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * @param string $table_column |
|
| 514 | - * @param string $nice_name |
|
| 515 | - * @param bool $nullable |
|
| 516 | - * @param null $default_value |
|
| 517 | - * @return EE_Simple_HTML_Field |
|
| 518 | - */ |
|
| 519 | - public function createSimpleHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 520 | - { |
|
| 521 | - return $this->loader->getNew( |
|
| 522 | - 'EE_Simple_HTML_Field', |
|
| 523 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 524 | - ); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * @param string $table_column |
|
| 531 | - * @param string $nice_name |
|
| 532 | - * @param bool $nullable |
|
| 533 | - * @param null $default_value |
|
| 534 | - * @return EE_Slug_Field |
|
| 535 | - */ |
|
| 536 | - public function createSlugField($table_column, $nice_name, $nullable = false, $default_value = null) |
|
| 537 | - { |
|
| 538 | - return $this->loader->getNew( |
|
| 539 | - 'EE_Slug_Field', |
|
| 540 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 541 | - ); |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * @param string $table_column |
|
| 548 | - * @param string $nice_name |
|
| 549 | - * @param bool $nullable |
|
| 550 | - * @param null $default_value |
|
| 551 | - * @return EE_Trashed_Flag_Field |
|
| 552 | - */ |
|
| 553 | - public function createTrashedFlagField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 554 | - { |
|
| 555 | - return $this->loader->getNew( |
|
| 556 | - 'EE_Trashed_Flag_Field', |
|
| 557 | - array($table_column, $nice_name, $nullable, $default_value) |
|
| 558 | - ); |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - |
|
| 562 | - |
|
| 563 | - /** |
|
| 564 | - * @param string $table_column |
|
| 565 | - * @param string $nice_name |
|
| 566 | - * @param bool $nullable |
|
| 567 | - * @param mixed $default_value |
|
| 568 | - * @param array $values If additional stati are to be used other than the default WP statuses, |
|
| 569 | - * then they can be registered via this property. |
|
| 570 | - * The format of the array should be as follows: |
|
| 571 | - * array( |
|
| 572 | - * 'status_reference' => array( |
|
| 573 | - * 'label' => __('Status Reference Label', 'event_espresso'), |
|
| 574 | - * 'public' => true, // whether this status should be shown on the frontend of the site |
|
| 575 | - * 'exclude_from_search' => false, // whether this status should be excluded from wp searches |
|
| 576 | - * 'show_in_admin_all_list' => true, // whether this status is included in queries |
|
| 577 | - * for the admin "all" view in list table views. |
|
| 578 | - * 'show_in_admin_status_list' => true, // show in the list of statuses with post counts at the top |
|
| 579 | - * of the admin list tables (i.e. Status Reference(2) ) |
|
| 580 | - * 'label_count' => _n_noop( |
|
| 581 | - * 'Status Reference <span class="count">(%s)</span>', |
|
| 582 | - * 'Status References <span class="count">(%s)</span>' |
|
| 583 | - * ), // the text to display on the admin screen |
|
| 584 | - * ( or you won't see your status count ). |
|
| 585 | - * ) |
|
| 586 | - * ) |
|
| 587 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
| 588 | - * @return EE_WP_Post_Status_Field |
|
| 589 | - */ |
|
| 590 | - public function createWpPostStatusField( |
|
| 591 | - $table_column, |
|
| 592 | - $nice_name, |
|
| 593 | - $nullable, |
|
| 594 | - $default_value = null, |
|
| 595 | - array $values = array() |
|
| 596 | - ) { |
|
| 597 | - return $this->loader->getNew( |
|
| 598 | - 'EE_WP_Post_Status_Field', |
|
| 599 | - array($table_column, $nice_name, $nullable, $default_value, $values) |
|
| 600 | - ); |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * @param string $post_type |
|
| 607 | - * @return EE_WP_Post_Type_Field |
|
| 608 | - */ |
|
| 609 | - public function createWpPostTypeField($post_type) |
|
| 610 | - { |
|
| 611 | - return $this->loader->getNew('EE_WP_Post_Type_Field', array($post_type)); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - |
|
| 616 | - /** |
|
| 617 | - * @param string $table_column |
|
| 618 | - * @param string $nice_name |
|
| 619 | - * @param bool $nullable |
|
| 620 | - * @return EE_WP_User_Field |
|
| 621 | - */ |
|
| 622 | - public function createWpUserField($table_column, $nice_name, $nullable) |
|
| 623 | - { |
|
| 624 | - return $this->loader->getNew('EE_WP_User_Field', array($table_column, $nice_name, $nullable)); |
|
| 625 | - } |
|
| 56 | + /** |
|
| 57 | + * @var LoaderInterface $loader |
|
| 58 | + */ |
|
| 59 | + private $loader; |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * ModelFieldFactory constructor. |
|
| 65 | + * |
|
| 66 | + * @param LoaderInterface $loader |
|
| 67 | + */ |
|
| 68 | + public function __construct(LoaderInterface $loader) |
|
| 69 | + { |
|
| 70 | + $this->loader = $loader; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param string $table_column |
|
| 77 | + * @param string $nice_name |
|
| 78 | + * @param bool $nullable |
|
| 79 | + * @param null $default_value |
|
| 80 | + * @return EE_All_Caps_Text_Field |
|
| 81 | + */ |
|
| 82 | + public function createAllCapsTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 83 | + { |
|
| 84 | + return $this->loader->getNew( |
|
| 85 | + 'EE_All_Caps_Text_Field', |
|
| 86 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @param string $table_column |
|
| 94 | + * @param string $nice_name |
|
| 95 | + * @param bool $nullable |
|
| 96 | + * @param null $default_value |
|
| 97 | + * @param string $model_name |
|
| 98 | + * @return EE_Any_Foreign_Model_Name_Field |
|
| 99 | + */ |
|
| 100 | + public function createAnyForeignModelNameField( |
|
| 101 | + $table_column, |
|
| 102 | + $nice_name, |
|
| 103 | + $nullable, |
|
| 104 | + $default_value = null, |
|
| 105 | + $model_name |
|
| 106 | + ) { |
|
| 107 | + return $this->loader->getNew( |
|
| 108 | + 'EE_Any_Foreign_Model_Name_Field', |
|
| 109 | + array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @param string $table_column |
|
| 117 | + * @param string $nice_name |
|
| 118 | + * @param bool $nullable |
|
| 119 | + * @param null $default_value |
|
| 120 | + * @return EE_Boolean_Field |
|
| 121 | + */ |
|
| 122 | + public function createBooleanField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 123 | + { |
|
| 124 | + return $this->loader->getNew( |
|
| 125 | + 'EE_Boolean_Field', |
|
| 126 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 127 | + ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @param string $table_column |
|
| 134 | + * @param string $nice_name |
|
| 135 | + * @param string $timezone_string |
|
| 136 | + * @param bool $nullable |
|
| 137 | + * @param string $default_value |
|
| 138 | + * @throws EE_Error |
|
| 139 | + * @throws InvalidArgumentException |
|
| 140 | + * @return EE_Datetime_Field |
|
| 141 | + */ |
|
| 142 | + public function createDatetimeField( |
|
| 143 | + $table_column, |
|
| 144 | + $nice_name, |
|
| 145 | + $nullable = false, |
|
| 146 | + $default_value = EE_Datetime_Field::now |
|
| 147 | + ) { |
|
| 148 | + return $this->loader->getNew( |
|
| 149 | + 'EE_Datetime_Field', |
|
| 150 | + array( |
|
| 151 | + $table_column, |
|
| 152 | + $nice_name, |
|
| 153 | + $nullable, |
|
| 154 | + $default_value |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @param string $table_column |
|
| 163 | + * @param string $nice_name |
|
| 164 | + * @param bool $nullable |
|
| 165 | + * @param null $default_value |
|
| 166 | + * @return EE_DB_Only_Float_Field |
|
| 167 | + */ |
|
| 168 | + public function createDbOnlyFloatField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 169 | + { |
|
| 170 | + return $this->loader->getNew( |
|
| 171 | + 'EE_DB_Only_Float_Field', |
|
| 172 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 173 | + ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @param string $table_column |
|
| 180 | + * @param string $nice_name |
|
| 181 | + * @param bool $nullable |
|
| 182 | + * @param null $default_value |
|
| 183 | + * @return EE_DB_Only_Int_Field |
|
| 184 | + */ |
|
| 185 | + public function createDbOnlyIntField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 186 | + { |
|
| 187 | + return $this->loader->getNew( |
|
| 188 | + 'EE_DB_Only_Int_Field', |
|
| 189 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 190 | + ); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * @param string $table_column |
|
| 197 | + * @param string $nice_name |
|
| 198 | + * @param bool $nullable |
|
| 199 | + * @param null $default_value |
|
| 200 | + * @return EE_DB_Only_Text_Field |
|
| 201 | + */ |
|
| 202 | + public function createDbOnlyTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 203 | + { |
|
| 204 | + return $this->loader->getNew( |
|
| 205 | + 'EE_DB_Only_Text_Field', |
|
| 206 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 207 | + ); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @param string $table_column |
|
| 214 | + * @param string $nice_name |
|
| 215 | + * @param bool $nullable |
|
| 216 | + * @param string $default_value |
|
| 217 | + * @return EE_Email_Field |
|
| 218 | + */ |
|
| 219 | + public function createEmailField($table_column, $nice_name, $nullable = true, $default_value = '') |
|
| 220 | + { |
|
| 221 | + return $this->loader->getNew( |
|
| 222 | + 'EE_Email_Field', |
|
| 223 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * @param string $table_column |
|
| 231 | + * @param string $nice_name |
|
| 232 | + * @param bool $nullable |
|
| 233 | + * @param null $default_value |
|
| 234 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 235 | + * values are how they should be displayed |
|
| 236 | + * @return EE_Enum_Integer_Field |
|
| 237 | + */ |
|
| 238 | + public function createEnumIntegerField( |
|
| 239 | + $table_column, |
|
| 240 | + $nice_name, |
|
| 241 | + $nullable, |
|
| 242 | + $default_value = null, |
|
| 243 | + array $allowed_enum_values |
|
| 244 | + ) { |
|
| 245 | + return $this->loader->getNew( |
|
| 246 | + 'EE_Enum_Integer_Field', |
|
| 247 | + array($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param string $table_column |
|
| 255 | + * @param string $nice_name |
|
| 256 | + * @param bool $nullable |
|
| 257 | + * @param null $default_value |
|
| 258 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 259 | + * values are how they should be displayed |
|
| 260 | + * @return EE_Enum_Text_Field |
|
| 261 | + */ |
|
| 262 | + public function createEnumTextField( |
|
| 263 | + $table_column, |
|
| 264 | + $nice_name, |
|
| 265 | + $nullable, |
|
| 266 | + $default_value, |
|
| 267 | + array $allowed_enum_values |
|
| 268 | + ) { |
|
| 269 | + return $this->loader->getNew( |
|
| 270 | + 'EE_Enum_Text_Field', |
|
| 271 | + array($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) |
|
| 272 | + ); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * @param string $table_column |
|
| 279 | + * @param string $nice_name |
|
| 280 | + * @param bool $nullable |
|
| 281 | + * @param null $default_value |
|
| 282 | + * @return EE_Float_Field |
|
| 283 | + */ |
|
| 284 | + public function createFloatField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 285 | + { |
|
| 286 | + return $this->loader->getNew( |
|
| 287 | + 'EE_Float_Field', |
|
| 288 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 289 | + ); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * @param string $table_column |
|
| 296 | + * @param string $nice_name |
|
| 297 | + * @param bool $nullable |
|
| 298 | + * @param null $default_value |
|
| 299 | + * @param string $model_name |
|
| 300 | + * @return EE_Foreign_Key_Int_Field |
|
| 301 | + */ |
|
| 302 | + public function createForeignKeyIntField($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 303 | + { |
|
| 304 | + return $this->loader->getNew( |
|
| 305 | + 'EE_Foreign_Key_Int_Field', |
|
| 306 | + array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 307 | + ); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * @param string $table_column |
|
| 314 | + * @param string $nice_name |
|
| 315 | + * @param bool $nullable |
|
| 316 | + * @param null $default_value |
|
| 317 | + * @param string $model_name |
|
| 318 | + * @return EE_Foreign_Key_String_Field |
|
| 319 | + */ |
|
| 320 | + public function createForeignKeyStringField( |
|
| 321 | + $table_column, |
|
| 322 | + $nice_name, |
|
| 323 | + $nullable, |
|
| 324 | + $default_value, |
|
| 325 | + $model_name |
|
| 326 | + ) { |
|
| 327 | + return $this->loader->getNew( |
|
| 328 | + 'EE_Foreign_Key_String_Field', |
|
| 329 | + array($table_column, $nice_name, $nullable, $default_value, $model_name) |
|
| 330 | + ); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * @param string $table_column |
|
| 337 | + * @param string $nice_name |
|
| 338 | + * @param bool $nullable |
|
| 339 | + * @param null $default_value |
|
| 340 | + * @return EE_Full_HTML_Field |
|
| 341 | + */ |
|
| 342 | + public function createFullHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 343 | + { |
|
| 344 | + return $this->loader->getNew( |
|
| 345 | + 'EE_Full_HTML_Field', |
|
| 346 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 347 | + ); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * @param string $table_column |
|
| 354 | + * @param string $nice_name |
|
| 355 | + * @param bool $nullable |
|
| 356 | + * @param null $default_value |
|
| 357 | + * @return EE_Infinite_Integer_Field |
|
| 358 | + */ |
|
| 359 | + public function createInfiniteIntegerField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 360 | + { |
|
| 361 | + return $this->loader->getNew( |
|
| 362 | + 'EE_Infinite_Integer_Field', |
|
| 363 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 364 | + ); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * @param string $table_column |
|
| 371 | + * @param string $nice_name |
|
| 372 | + * @param bool $nullable |
|
| 373 | + * @param null $default_value |
|
| 374 | + * @return EE_Integer_Field |
|
| 375 | + */ |
|
| 376 | + public function createIntegerField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 377 | + { |
|
| 378 | + return $this->loader->getNew( |
|
| 379 | + 'EE_Integer_Field', |
|
| 380 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 381 | + ); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * @param string $table_column |
|
| 388 | + * @param string $nice_name |
|
| 389 | + * @param bool $nullable |
|
| 390 | + * @param null $default_value |
|
| 391 | + * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
| 392 | + */ |
|
| 393 | + public function createMaybeSerializedSimpleHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 394 | + { |
|
| 395 | + return $this->loader->getNew( |
|
| 396 | + 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
| 397 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 398 | + ); |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * @param string $table_column |
|
| 405 | + * @param string $nice_name |
|
| 406 | + * @param bool $nullable |
|
| 407 | + * @param null $default_value |
|
| 408 | + * @return EE_Maybe_Serialized_Text_Field |
|
| 409 | + */ |
|
| 410 | + public function createMaybeSerializedTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 411 | + { |
|
| 412 | + return $this->loader->getNew( |
|
| 413 | + 'EE_Maybe_Serialized_Text_Field', |
|
| 414 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 415 | + ); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * @param string $table_column |
|
| 422 | + * @param string $nice_name |
|
| 423 | + * @param bool $nullable |
|
| 424 | + * @param null $default_value |
|
| 425 | + * @return EE_Money_Field |
|
| 426 | + */ |
|
| 427 | + public function createMoneyField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 428 | + { |
|
| 429 | + return $this->loader->getNew( |
|
| 430 | + 'EE_Money_Field', |
|
| 431 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 432 | + ); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * @param string $table_column |
|
| 439 | + * @param string $nice_name |
|
| 440 | + * @param bool $nullable |
|
| 441 | + * @param string $default_value |
|
| 442 | + * @return EE_Plain_Text_Field |
|
| 443 | + */ |
|
| 444 | + public function createPlainTextField($table_column, $nice_name, $nullable = true, $default_value = '') |
|
| 445 | + { |
|
| 446 | + return $this->loader->getNew( |
|
| 447 | + 'EE_Plain_Text_Field', |
|
| 448 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 449 | + ); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + |
|
| 454 | + /** |
|
| 455 | + * @param string $table_column |
|
| 456 | + * @param string $nice_name |
|
| 457 | + * @param bool $nullable |
|
| 458 | + * @param null $default_value |
|
| 459 | + * @return EE_Post_Content_Field |
|
| 460 | + */ |
|
| 461 | + public function createPostContentField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 462 | + { |
|
| 463 | + return $this->loader->getNew( |
|
| 464 | + 'EE_Post_Content_Field', |
|
| 465 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 466 | + ); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * @param string $table_column |
|
| 473 | + * @param string $nice_name |
|
| 474 | + * @return EE_Primary_Key_Int_Field |
|
| 475 | + */ |
|
| 476 | + public function createPrimaryKeyIntField($table_column, $nice_name) |
|
| 477 | + { |
|
| 478 | + return $this->loader->getNew('EE_Primary_Key_Int_Field', array($table_column, $nice_name)); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * @param string $table_column |
|
| 485 | + * @param string $nice_name |
|
| 486 | + * @return EE_Primary_Key_String_Field |
|
| 487 | + */ |
|
| 488 | + public function createPrimaryKeyStringField($table_column, $nice_name) |
|
| 489 | + { |
|
| 490 | + return $this->loader->getNew('EE_Primary_Key_String_Field', array($table_column, $nice_name)); |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * @param string $table_column |
|
| 497 | + * @param string $nice_name |
|
| 498 | + * @param bool $nullable |
|
| 499 | + * @param null $default_value |
|
| 500 | + * @return EE_Serialized_Text_Field |
|
| 501 | + */ |
|
| 502 | + public function createSerializedTextField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 503 | + { |
|
| 504 | + return $this->loader->getNew( |
|
| 505 | + 'EE_Serialized_Text_Field', |
|
| 506 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * @param string $table_column |
|
| 514 | + * @param string $nice_name |
|
| 515 | + * @param bool $nullable |
|
| 516 | + * @param null $default_value |
|
| 517 | + * @return EE_Simple_HTML_Field |
|
| 518 | + */ |
|
| 519 | + public function createSimpleHtmlField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 520 | + { |
|
| 521 | + return $this->loader->getNew( |
|
| 522 | + 'EE_Simple_HTML_Field', |
|
| 523 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 524 | + ); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * @param string $table_column |
|
| 531 | + * @param string $nice_name |
|
| 532 | + * @param bool $nullable |
|
| 533 | + * @param null $default_value |
|
| 534 | + * @return EE_Slug_Field |
|
| 535 | + */ |
|
| 536 | + public function createSlugField($table_column, $nice_name, $nullable = false, $default_value = null) |
|
| 537 | + { |
|
| 538 | + return $this->loader->getNew( |
|
| 539 | + 'EE_Slug_Field', |
|
| 540 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 541 | + ); |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * @param string $table_column |
|
| 548 | + * @param string $nice_name |
|
| 549 | + * @param bool $nullable |
|
| 550 | + * @param null $default_value |
|
| 551 | + * @return EE_Trashed_Flag_Field |
|
| 552 | + */ |
|
| 553 | + public function createTrashedFlagField($table_column, $nice_name, $nullable, $default_value = null) |
|
| 554 | + { |
|
| 555 | + return $this->loader->getNew( |
|
| 556 | + 'EE_Trashed_Flag_Field', |
|
| 557 | + array($table_column, $nice_name, $nullable, $default_value) |
|
| 558 | + ); |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + |
|
| 562 | + |
|
| 563 | + /** |
|
| 564 | + * @param string $table_column |
|
| 565 | + * @param string $nice_name |
|
| 566 | + * @param bool $nullable |
|
| 567 | + * @param mixed $default_value |
|
| 568 | + * @param array $values If additional stati are to be used other than the default WP statuses, |
|
| 569 | + * then they can be registered via this property. |
|
| 570 | + * The format of the array should be as follows: |
|
| 571 | + * array( |
|
| 572 | + * 'status_reference' => array( |
|
| 573 | + * 'label' => __('Status Reference Label', 'event_espresso'), |
|
| 574 | + * 'public' => true, // whether this status should be shown on the frontend of the site |
|
| 575 | + * 'exclude_from_search' => false, // whether this status should be excluded from wp searches |
|
| 576 | + * 'show_in_admin_all_list' => true, // whether this status is included in queries |
|
| 577 | + * for the admin "all" view in list table views. |
|
| 578 | + * 'show_in_admin_status_list' => true, // show in the list of statuses with post counts at the top |
|
| 579 | + * of the admin list tables (i.e. Status Reference(2) ) |
|
| 580 | + * 'label_count' => _n_noop( |
|
| 581 | + * 'Status Reference <span class="count">(%s)</span>', |
|
| 582 | + * 'Status References <span class="count">(%s)</span>' |
|
| 583 | + * ), // the text to display on the admin screen |
|
| 584 | + * ( or you won't see your status count ). |
|
| 585 | + * ) |
|
| 586 | + * ) |
|
| 587 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
| 588 | + * @return EE_WP_Post_Status_Field |
|
| 589 | + */ |
|
| 590 | + public function createWpPostStatusField( |
|
| 591 | + $table_column, |
|
| 592 | + $nice_name, |
|
| 593 | + $nullable, |
|
| 594 | + $default_value = null, |
|
| 595 | + array $values = array() |
|
| 596 | + ) { |
|
| 597 | + return $this->loader->getNew( |
|
| 598 | + 'EE_WP_Post_Status_Field', |
|
| 599 | + array($table_column, $nice_name, $nullable, $default_value, $values) |
|
| 600 | + ); |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * @param string $post_type |
|
| 607 | + * @return EE_WP_Post_Type_Field |
|
| 608 | + */ |
|
| 609 | + public function createWpPostTypeField($post_type) |
|
| 610 | + { |
|
| 611 | + return $this->loader->getNew('EE_WP_Post_Type_Field', array($post_type)); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + |
|
| 616 | + /** |
|
| 617 | + * @param string $table_column |
|
| 618 | + * @param string $nice_name |
|
| 619 | + * @param bool $nullable |
|
| 620 | + * @return EE_WP_User_Field |
|
| 621 | + */ |
|
| 622 | + public function createWpUserField($table_column, $nice_name, $nullable) |
|
| 623 | + { |
|
| 624 | + return $this->loader->getNew('EE_WP_User_Field', array($table_column, $nice_name, $nullable)); |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | 627 | |
| 628 | 628 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // when adding a new registration... |
| 70 | 70 | if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
| 71 | 71 | EE_System::do_not_cache(); |
| 72 | - if (! isset($this->_req_data['processing_registration']) |
|
| 72 | + if ( ! isset($this->_req_data['processing_registration']) |
|
| 73 | 73 | || absint($this->_req_data['processing_registration']) !== 1 |
| 74 | 74 | ) { |
| 75 | 75 | // and it's NOT the attendee information reg step |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | public function _set_page_routes() |
| 165 | 165 | { |
| 166 | 166 | $this->_get_registration_status_array(); |
| 167 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 167 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | 168 | ? $this->_req_data['_REG_ID'] : 0; |
| 169 | 169 | $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID']) |
| 170 | 170 | ? $this->_req_data['reg_status_change_form']['REG_ID'] |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | //style |
| 647 | 647 | wp_register_style( |
| 648 | 648 | 'espresso_reg', |
| 649 | - REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 649 | + REG_ASSETS_URL.'espresso_registrations_admin.css', |
|
| 650 | 650 | array('ee-admin-css'), |
| 651 | 651 | EVENT_ESPRESSO_VERSION |
| 652 | 652 | ); |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | //script |
| 655 | 655 | wp_register_script( |
| 656 | 656 | 'espresso_reg', |
| 657 | - REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 657 | + REG_ASSETS_URL.'espresso_registrations_admin.js', |
|
| 658 | 658 | array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
| 659 | 659 | EVENT_ESPRESSO_VERSION, |
| 660 | 660 | true |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | wp_deregister_style('espresso_reg'); |
| 693 | 693 | wp_register_style( |
| 694 | 694 | 'espresso_att', |
| 695 | - REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 695 | + REG_ASSETS_URL.'espresso_attendees_admin.css', |
|
| 696 | 696 | array('ee-admin-css'), |
| 697 | 697 | EVENT_ESPRESSO_VERSION |
| 698 | 698 | ); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | { |
| 705 | 705 | wp_register_script( |
| 706 | 706 | 'ee-spco-for-admin', |
| 707 | - REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 707 | + REG_ASSETS_URL.'spco_for_admin.js', |
|
| 708 | 708 | array('underscore', 'jquery'), |
| 709 | 709 | EVENT_ESPRESSO_VERSION, |
| 710 | 710 | true |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
| 838 | 838 | ), |
| 839 | 839 | ); |
| 840 | - $this->_views['trash'] = array( |
|
| 840 | + $this->_views['trash'] = array( |
|
| 841 | 841 | 'slug' => 'trash', |
| 842 | 842 | 'label' => esc_html__('Trash', 'event_espresso'), |
| 843 | 843 | 'count' => 0, |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | } |
| 927 | 927 | $sc_items = array( |
| 928 | 928 | 'approved_status' => array( |
| 929 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 929 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 930 | 930 | 'desc' => EEH_Template::pretty_status( |
| 931 | 931 | EEM_Registration::status_id_approved, |
| 932 | 932 | false, |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | ), |
| 935 | 935 | ), |
| 936 | 936 | 'pending_status' => array( |
| 937 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 937 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 938 | 938 | 'desc' => EEH_Template::pretty_status( |
| 939 | 939 | EEM_Registration::status_id_pending_payment, |
| 940 | 940 | false, |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | ), |
| 943 | 943 | ), |
| 944 | 944 | 'wait_list' => array( |
| 945 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 945 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 946 | 946 | 'desc' => EEH_Template::pretty_status( |
| 947 | 947 | EEM_Registration::status_id_wait_list, |
| 948 | 948 | false, |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | ), |
| 951 | 951 | ), |
| 952 | 952 | 'incomplete_status' => array( |
| 953 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 953 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
| 954 | 954 | 'desc' => EEH_Template::pretty_status( |
| 955 | 955 | EEM_Registration::status_id_incomplete, |
| 956 | 956 | false, |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | ), |
| 959 | 959 | ), |
| 960 | 960 | 'not_approved' => array( |
| 961 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 961 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 962 | 962 | 'desc' => EEH_Template::pretty_status( |
| 963 | 963 | EEM_Registration::status_id_not_approved, |
| 964 | 964 | false, |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | ), |
| 967 | 967 | ), |
| 968 | 968 | 'declined_status' => array( |
| 969 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 969 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 970 | 970 | 'desc' => EEH_Template::pretty_status( |
| 971 | 971 | EEM_Registration::status_id_declined, |
| 972 | 972 | false, |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | ), |
| 975 | 975 | ), |
| 976 | 976 | 'cancelled_status' => array( |
| 977 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 977 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 978 | 978 | 'desc' => EEH_Template::pretty_status( |
| 979 | 979 | EEM_Registration::status_id_cancelled, |
| 980 | 980 | false, |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | 'espresso_registrations_new_registration', |
| 1004 | 1004 | $EVT_ID |
| 1005 | 1005 | )) { |
| 1006 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1006 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 1007 | 1007 | 'new_registration', |
| 1008 | 1008 | 'add-registrant', |
| 1009 | 1009 | array('event_id' => $EVT_ID), |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
| 1044 | 1044 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 1045 | 1045 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
| 1046 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 1046 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
| 1047 | 1047 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
| 1048 | 1048 | } |
| 1049 | 1049 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | 'caps' => EEM_Registration::caps_read_admin, |
| 1144 | 1144 | 'default_where_conditions' => 'this_model_only', |
| 1145 | 1145 | ); |
| 1146 | - if (! $count) { |
|
| 1146 | + if ( ! $count) { |
|
| 1147 | 1147 | $query_params = array_merge( |
| 1148 | 1148 | $query_params, |
| 1149 | 1149 | $this->_get_orderby_for_registrations_query(), |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | protected function _add_event_id_to_where_conditions(array $request) |
| 1165 | 1165 | { |
| 1166 | 1166 | $where = array(); |
| 1167 | - if (! empty($request['event_id'])) { |
|
| 1167 | + if ( ! empty($request['event_id'])) { |
|
| 1168 | 1168 | $where['EVT_ID'] = absint($request['event_id']); |
| 1169 | 1169 | } |
| 1170 | 1170 | return $where; |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | protected function _add_category_id_to_where_conditions(array $request) |
| 1181 | 1181 | { |
| 1182 | 1182 | $where = array(); |
| 1183 | - if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1183 | + if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) { |
|
| 1184 | 1184 | $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
| 1185 | 1185 | } |
| 1186 | 1186 | return $where; |
@@ -1196,10 +1196,10 @@ discard block |
||
| 1196 | 1196 | protected function _add_datetime_id_to_where_conditions(array $request) |
| 1197 | 1197 | { |
| 1198 | 1198 | $where = array(); |
| 1199 | - if (! empty($request['datetime_id'])) { |
|
| 1199 | + if ( ! empty($request['datetime_id'])) { |
|
| 1200 | 1200 | $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
| 1201 | 1201 | } |
| 1202 | - if (! empty($request['DTT_ID'])) { |
|
| 1202 | + if ( ! empty($request['DTT_ID'])) { |
|
| 1203 | 1203 | $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
| 1204 | 1204 | } |
| 1205 | 1205 | return $where; |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations |
| 1226 | 1226 | * UNLESS viewing trashed registrations. |
| 1227 | 1227 | */ |
| 1228 | - if (! empty($registration_status)) { |
|
| 1228 | + if ( ! empty($registration_status)) { |
|
| 1229 | 1229 | $where['STS_ID'] = $registration_status; |
| 1230 | 1230 | } else { |
| 1231 | 1231 | //make sure we exclude incomplete registrations, but only if not trashed. |
@@ -1265,12 +1265,12 @@ discard block |
||
| 1265 | 1265 | array( |
| 1266 | 1266 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1267 | 1267 | 'REG_date', |
| 1268 | - $now . ' 00:00:00', |
|
| 1268 | + $now.' 00:00:00', |
|
| 1269 | 1269 | 'Y-m-d H:i:s' |
| 1270 | 1270 | ), |
| 1271 | 1271 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1272 | 1272 | 'REG_date', |
| 1273 | - $now . ' 23:59:59', |
|
| 1273 | + $now.' 23:59:59', |
|
| 1274 | 1274 | 'Y-m-d H:i:s' |
| 1275 | 1275 | ), |
| 1276 | 1276 | ), |
@@ -1283,12 +1283,12 @@ discard block |
||
| 1283 | 1283 | array( |
| 1284 | 1284 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1285 | 1285 | 'REG_date', |
| 1286 | - $current_year_and_month . '-01 00:00:00', |
|
| 1286 | + $current_year_and_month.'-01 00:00:00', |
|
| 1287 | 1287 | 'Y-m-d H:i:s' |
| 1288 | 1288 | ), |
| 1289 | 1289 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1290 | 1290 | 'REG_date', |
| 1291 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1291 | + $current_year_and_month.'-'.$days_this_month.' 23:59:59', |
|
| 1292 | 1292 | 'Y-m-d H:i:s' |
| 1293 | 1293 | ), |
| 1294 | 1294 | ), |
@@ -1303,18 +1303,18 @@ discard block |
||
| 1303 | 1303 | : ''; |
| 1304 | 1304 | //if there is not a month or year then we can't go further |
| 1305 | 1305 | if ($month_requested && $year_requested) { |
| 1306 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1306 | + $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01')); |
|
| 1307 | 1307 | $where['REG_date'] = array( |
| 1308 | 1308 | 'BETWEEN', |
| 1309 | 1309 | array( |
| 1310 | 1310 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1311 | 1311 | 'REG_date', |
| 1312 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1312 | + $year_requested.'-'.$month_requested.'-01 00:00:00', |
|
| 1313 | 1313 | 'Y-m-d H:i:s' |
| 1314 | 1314 | ), |
| 1315 | 1315 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1316 | 1316 | 'REG_date', |
| 1317 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1317 | + $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59', |
|
| 1318 | 1318 | 'Y-m-d H:i:s' |
| 1319 | 1319 | ), |
| 1320 | 1320 | ), |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | protected function _add_search_to_where_conditions(array $request) |
| 1335 | 1335 | { |
| 1336 | 1336 | $where = array(); |
| 1337 | - if (! empty($request['s'])) { |
|
| 1338 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1337 | + if ( ! empty($request['s'])) { |
|
| 1338 | + $search_string = '%'.sanitize_text_field($request['s']).'%'; |
|
| 1339 | 1339 | $where['OR*search_conditions'] = array( |
| 1340 | 1340 | 'Event.EVT_name' => array('LIKE', $search_string), |
| 1341 | 1341 | 'Event.EVT_desc' => array('LIKE', $search_string), |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | : $per_page; |
| 1449 | 1449 | |
| 1450 | 1450 | //-1 means return all results so get out if that's set. |
| 1451 | - if ((int)$per_page === -1) { |
|
| 1451 | + if ((int) $per_page === -1) { |
|
| 1452 | 1452 | return array(); |
| 1453 | 1453 | } |
| 1454 | 1454 | $per_page = absint($per_page); |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | ), |
| 1502 | 1502 | REG_ADMIN_URL |
| 1503 | 1503 | ); |
| 1504 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1504 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1505 | 1505 | array( |
| 1506 | 1506 | 'action' => 'default', |
| 1507 | 1507 | 'EVT_ID' => $event_id, |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | ), |
| 1510 | 1510 | admin_url('admin.php') |
| 1511 | 1511 | ); |
| 1512 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1512 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1513 | 1513 | array( |
| 1514 | 1514 | 'page' => 'espresso_events', |
| 1515 | 1515 | 'action' => 'edit', |
@@ -1518,12 +1518,12 @@ discard block |
||
| 1518 | 1518 | admin_url('admin.php') |
| 1519 | 1519 | ); |
| 1520 | 1520 | //next and previous links |
| 1521 | - $next_reg = $this->_registration->next( |
|
| 1521 | + $next_reg = $this->_registration->next( |
|
| 1522 | 1522 | null, |
| 1523 | 1523 | array(), |
| 1524 | 1524 | 'REG_ID' |
| 1525 | 1525 | ); |
| 1526 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1526 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1527 | 1527 | ? $this->_next_link( |
| 1528 | 1528 | EE_Admin_Page::add_query_args_and_nonce( |
| 1529 | 1529 | array( |
@@ -1535,7 +1535,7 @@ discard block |
||
| 1535 | 1535 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
| 1536 | 1536 | ) |
| 1537 | 1537 | : ''; |
| 1538 | - $previous_reg = $this->_registration->previous( |
|
| 1538 | + $previous_reg = $this->_registration->previous( |
|
| 1539 | 1539 | null, |
| 1540 | 1540 | array(), |
| 1541 | 1541 | 'REG_ID' |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | ) |
| 1554 | 1554 | : ''; |
| 1555 | 1555 | // grab header |
| 1556 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1556 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
| 1557 | 1557 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1558 | 1558 | $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
| 1559 | 1559 | $template_path, |
@@ -1669,7 +1669,7 @@ discard block |
||
| 1669 | 1669 | EEH_HTML::strong( |
| 1670 | 1670 | $this->_registration->pretty_status(), |
| 1671 | 1671 | '', |
| 1672 | - 'status-' . $this->_registration->status_ID(), |
|
| 1672 | + 'status-'.$this->_registration->status_ID(), |
|
| 1673 | 1673 | 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
| 1674 | 1674 | ) |
| 1675 | 1675 | ) |
@@ -1741,9 +1741,9 @@ discard block |
||
| 1741 | 1741 | { |
| 1742 | 1742 | if (isset($this->_req_data['reg_status_change_form'])) { |
| 1743 | 1743 | $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
| 1744 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1744 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1745 | 1745 | } else { |
| 1746 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1746 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
| 1747 | 1747 | } |
| 1748 | 1748 | $success = $this->_set_registration_status($REG_IDs, $status); |
| 1749 | 1749 | //notify? |
@@ -1778,7 +1778,7 @@ discard block |
||
| 1778 | 1778 | { |
| 1779 | 1779 | $success = false; |
| 1780 | 1780 | // typecast $REG_IDs |
| 1781 | - $REG_IDs = (array)$REG_IDs; |
|
| 1781 | + $REG_IDs = (array) $REG_IDs; |
|
| 1782 | 1782 | if ( ! empty($REG_IDs)) { |
| 1783 | 1783 | $success = true; |
| 1784 | 1784 | // set default status if none is passed |
@@ -1917,7 +1917,7 @@ discard block |
||
| 1917 | 1917 | $action, |
| 1918 | 1918 | $notify |
| 1919 | 1919 | ); |
| 1920 | - $method = $action . '_registration'; |
|
| 1920 | + $method = $action.'_registration'; |
|
| 1921 | 1921 | if (method_exists($this, $method)) { |
| 1922 | 1922 | $this->$method($notify); |
| 1923 | 1923 | } |
@@ -2031,7 +2031,7 @@ discard block |
||
| 2031 | 2031 | $filtered_line_item_tree, |
| 2032 | 2032 | array('EE_Registration' => $this->_registration) |
| 2033 | 2033 | ); |
| 2034 | - $attendee = $this->_registration->attendee(); |
|
| 2034 | + $attendee = $this->_registration->attendee(); |
|
| 2035 | 2035 | if (EE_Registry::instance()->CAP->current_user_can( |
| 2036 | 2036 | 'ee_read_transaction', |
| 2037 | 2037 | 'espresso_transactions_view_transaction' |
@@ -2110,7 +2110,7 @@ discard block |
||
| 2110 | 2110 | 'Payment method response', |
| 2111 | 2111 | 'event_espresso' |
| 2112 | 2112 | ); |
| 2113 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2113 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2114 | 2114 | } |
| 2115 | 2115 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
| 2116 | 2116 | $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
@@ -2138,7 +2138,7 @@ discard block |
||
| 2138 | 2138 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 2139 | 2139 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
| 2140 | 2140 | $template_path = |
| 2141 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2141 | + REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2142 | 2142 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2143 | 2143 | } |
| 2144 | 2144 | |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
| 2168 | 2168 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 2169 | 2169 | $template_path = |
| 2170 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2170 | + REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2171 | 2171 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2172 | 2172 | } |
| 2173 | 2173 | } |
@@ -2184,7 +2184,7 @@ discard block |
||
| 2184 | 2184 | public function form_before_question_group($output) |
| 2185 | 2185 | { |
| 2186 | 2186 | EE_Error::doing_it_wrong( |
| 2187 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2187 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2188 | 2188 | esc_html__( |
| 2189 | 2189 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2190 | 2190 | 'event_espresso' |
@@ -2209,7 +2209,7 @@ discard block |
||
| 2209 | 2209 | public function form_after_question_group($output) |
| 2210 | 2210 | { |
| 2211 | 2211 | EE_Error::doing_it_wrong( |
| 2212 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2212 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2213 | 2213 | esc_html__( |
| 2214 | 2214 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2215 | 2215 | 'event_espresso' |
@@ -2247,7 +2247,7 @@ discard block |
||
| 2247 | 2247 | public function form_form_field_label_wrap($label) |
| 2248 | 2248 | { |
| 2249 | 2249 | EE_Error::doing_it_wrong( |
| 2250 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2250 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2251 | 2251 | esc_html__( |
| 2252 | 2252 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2253 | 2253 | 'event_espresso' |
@@ -2257,7 +2257,7 @@ discard block |
||
| 2257 | 2257 | return ' |
| 2258 | 2258 | <tr> |
| 2259 | 2259 | <th> |
| 2260 | - ' . $label . ' |
|
| 2260 | + ' . $label.' |
|
| 2261 | 2261 | </th>'; |
| 2262 | 2262 | } |
| 2263 | 2263 | |
@@ -2273,7 +2273,7 @@ discard block |
||
| 2273 | 2273 | public function form_form_field_input__wrap($input) |
| 2274 | 2274 | { |
| 2275 | 2275 | EE_Error::doing_it_wrong( |
| 2276 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2276 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2277 | 2277 | esc_html__( |
| 2278 | 2278 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2279 | 2279 | 'event_espresso' |
@@ -2282,7 +2282,7 @@ discard block |
||
| 2282 | 2282 | ); |
| 2283 | 2283 | return ' |
| 2284 | 2284 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 2285 | - ' . $input . ' |
|
| 2285 | + ' . $input.' |
|
| 2286 | 2286 | </td> |
| 2287 | 2287 | </tr>'; |
| 2288 | 2288 | } |
@@ -2324,7 +2324,7 @@ discard block |
||
| 2324 | 2324 | protected function _get_reg_custom_questions_form($REG_ID) |
| 2325 | 2325 | { |
| 2326 | 2326 | if ( ! $this->_reg_custom_questions_form) { |
| 2327 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2327 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2328 | 2328 | $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
| 2329 | 2329 | EEM_Registration::instance()->get_one_by_ID($REG_ID) |
| 2330 | 2330 | ); |
@@ -2357,7 +2357,7 @@ discard block |
||
| 2357 | 2357 | if ($form->is_valid()) { |
| 2358 | 2358 | foreach ($form->subforms() as $question_group_id => $question_group_form) { |
| 2359 | 2359 | foreach ($question_group_form->inputs() as $question_id => $input) { |
| 2360 | - $where_conditions = array( |
|
| 2360 | + $where_conditions = array( |
|
| 2361 | 2361 | 'QST_ID' => $question_id, |
| 2362 | 2362 | 'REG_ID' => $REG_ID, |
| 2363 | 2363 | ); |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | $REG = EEM_Registration::instance(); |
| 2396 | 2396 | //get all other registrations on this transaction, and cache |
| 2397 | 2397 | //the attendees for them so we don't have to run another query using force_join |
| 2398 | - $registrations = $REG->get_all(array( |
|
| 2398 | + $registrations = $REG->get_all(array( |
|
| 2399 | 2399 | array( |
| 2400 | 2400 | 'TXN_ID' => $this->_registration->transaction_ID(), |
| 2401 | 2401 | 'REG_ID' => array('!=', $this->_registration->ID()), |
@@ -2419,7 +2419,7 @@ discard block |
||
| 2419 | 2419 | $att_nmbr = 1; |
| 2420 | 2420 | foreach ($registrations as $registration) { |
| 2421 | 2421 | /* @var $registration EE_Registration */ |
| 2422 | - $attendee = $registration->attendee() |
|
| 2422 | + $attendee = $registration->attendee() |
|
| 2423 | 2423 | ? $registration->attendee() |
| 2424 | 2424 | : EEM_Attendee::instance() |
| 2425 | 2425 | ->create_default_object(); |
@@ -2432,19 +2432,19 @@ discard block |
||
| 2432 | 2432 | ', ', |
| 2433 | 2433 | $attendee->full_address_as_array() |
| 2434 | 2434 | ); |
| 2435 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2435 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2436 | 2436 | array( |
| 2437 | 2437 | 'action' => 'edit_attendee', |
| 2438 | 2438 | 'post' => $attendee->ID(), |
| 2439 | 2439 | ), |
| 2440 | 2440 | REG_ADMIN_URL |
| 2441 | 2441 | ); |
| 2442 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2442 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2443 | 2443 | $att_nmbr++; |
| 2444 | 2444 | } |
| 2445 | 2445 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 2446 | 2446 | } |
| 2447 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2447 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2448 | 2448 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2449 | 2449 | } |
| 2450 | 2450 | |
@@ -2484,20 +2484,20 @@ discard block |
||
| 2484 | 2484 | $this->_template_args['phone'] = $attendee->phone(); |
| 2485 | 2485 | $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
| 2486 | 2486 | //edit link |
| 2487 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2487 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2488 | 2488 | 'action' => 'edit_attendee', |
| 2489 | 2489 | 'post' => $attendee->ID(), |
| 2490 | 2490 | ), REG_ADMIN_URL); |
| 2491 | 2491 | $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
| 2492 | 2492 | //create link |
| 2493 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2493 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2494 | 2494 | ? EE_Admin_Page::add_query_args_and_nonce(array( |
| 2495 | 2495 | 'action' => 'duplicate_attendee', |
| 2496 | 2496 | '_REG_ID' => $this->_registration->ID(), |
| 2497 | 2497 | ), REG_ADMIN_URL) : ''; |
| 2498 | 2498 | $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
| 2499 | 2499 | $this->_template_args['att_check'] = $att_check; |
| 2500 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2500 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2501 | 2501 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2502 | 2502 | } |
| 2503 | 2503 | |
@@ -2539,7 +2539,7 @@ discard block |
||
| 2539 | 2539 | /** @var EE_Registration $REG */ |
| 2540 | 2540 | $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
| 2541 | 2541 | $payments = $REG->registration_payments(); |
| 2542 | - if (! empty($payments)) { |
|
| 2542 | + if ( ! empty($payments)) { |
|
| 2543 | 2543 | $name = $REG->attendee() instanceof EE_Attendee |
| 2544 | 2544 | ? $REG->attendee()->full_name() |
| 2545 | 2545 | : esc_html__('Unknown Attendee', 'event_espresso'); |
@@ -2732,7 +2732,7 @@ discard block |
||
| 2732 | 2732 | 'action' => 'edit', |
| 2733 | 2733 | 'post' => $this->_reg_event->ID(), |
| 2734 | 2734 | ), EVENTS_ADMIN_URL); |
| 2735 | - $edit_event_lnk = '<a href="' |
|
| 2735 | + $edit_event_lnk = '<a href="' |
|
| 2736 | 2736 | . $edit_event_url |
| 2737 | 2737 | . '" title="' |
| 2738 | 2738 | . esc_attr__('Edit ', 'event_espresso') |
@@ -2750,7 +2750,7 @@ discard block |
||
| 2750 | 2750 | } |
| 2751 | 2751 | // grab header |
| 2752 | 2752 | $template_path = |
| 2753 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2753 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
| 2754 | 2754 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
| 2755 | 2755 | $this->_template_args, true); |
| 2756 | 2756 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
@@ -2785,7 +2785,7 @@ discard block |
||
| 2785 | 2785 | '</b>' |
| 2786 | 2786 | ); |
| 2787 | 2787 | return ' |
| 2788 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
| 2788 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
| 2789 | 2789 | <script > |
| 2790 | 2790 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
| 2791 | 2791 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2853,7 +2853,7 @@ discard block |
||
| 2853 | 2853 | //we come back to the process_registration_step route. |
| 2854 | 2854 | $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
| 2855 | 2855 | return EEH_Template::display_template( |
| 2856 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2856 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2857 | 2857 | $template_args, |
| 2858 | 2858 | true |
| 2859 | 2859 | ); |
@@ -2872,7 +2872,7 @@ discard block |
||
| 2872 | 2872 | if (is_object($this->_reg_event)) { |
| 2873 | 2873 | return true; |
| 2874 | 2874 | } |
| 2875 | - $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2875 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2876 | 2876 | if ( ! $EVT_ID) { |
| 2877 | 2877 | return false; |
| 2878 | 2878 | } |
@@ -2938,7 +2938,7 @@ discard block |
||
| 2938 | 2938 | } |
| 2939 | 2939 | break; |
| 2940 | 2940 | case 'questions' : |
| 2941 | - if (! isset( |
|
| 2941 | + if ( ! isset( |
|
| 2942 | 2942 | $this->_req_data['txn_reg_status_change'], |
| 2943 | 2943 | $this->_req_data['txn_reg_status_change']['send_notifications']) |
| 2944 | 2944 | ) { |
@@ -3052,7 +3052,7 @@ discard block |
||
| 3052 | 3052 | public function get_attendees($per_page, $count = false, $trash = false) |
| 3053 | 3053 | { |
| 3054 | 3054 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 3055 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3055 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3056 | 3056 | $ATT_MDL = EEM_Attendee::instance(); |
| 3057 | 3057 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 3058 | 3058 | switch ($this->_req_data['orderby']) { |
@@ -3089,7 +3089,7 @@ discard block |
||
| 3089 | 3089 | : $per_page; |
| 3090 | 3090 | $_where = array(); |
| 3091 | 3091 | if ( ! empty($this->_req_data['s'])) { |
| 3092 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 3092 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 3093 | 3093 | $_where['OR'] = array( |
| 3094 | 3094 | 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
| 3095 | 3095 | 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
@@ -3165,9 +3165,9 @@ discard block |
||
| 3165 | 3165 | * the query parameters from the request |
| 3166 | 3166 | * @return void ends the request with a redirect or download |
| 3167 | 3167 | */ |
| 3168 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3168 | + public function _registrations_report_base($method_name_for_getting_query_params) |
|
| 3169 | 3169 | { |
| 3170 | - if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3170 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3171 | 3171 | wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
| 3172 | 3172 | array( |
| 3173 | 3173 | 'page' => 'espresso_batch', |
@@ -3176,7 +3176,7 @@ discard block |
||
| 3176 | 3176 | 'filters' => urlencode( |
| 3177 | 3177 | serialize( |
| 3178 | 3178 | call_user_func( |
| 3179 | - array( $this, $method_name_for_getting_query_params ), |
|
| 3179 | + array($this, $method_name_for_getting_query_params), |
|
| 3180 | 3180 | EEH_Array::is_set( |
| 3181 | 3181 | $this->_req_data, |
| 3182 | 3182 | 'filters', |
@@ -3196,8 +3196,8 @@ discard block |
||
| 3196 | 3196 | 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
| 3197 | 3197 | ); |
| 3198 | 3198 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
| 3199 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3200 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3199 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3200 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3201 | 3201 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3202 | 3202 | $EE_Export->export(); |
| 3203 | 3203 | } |
@@ -3218,8 +3218,8 @@ discard block |
||
| 3218 | 3218 | |
| 3219 | 3219 | public function _contact_list_export() |
| 3220 | 3220 | { |
| 3221 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3222 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3221 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3222 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3223 | 3223 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3224 | 3224 | $EE_Export->export_attendees(); |
| 3225 | 3225 | } |
@@ -3236,8 +3236,8 @@ discard block |
||
| 3236 | 3236 | 'return_url' => urlencode($this->_req_data['return_url']), |
| 3237 | 3237 | ))); |
| 3238 | 3238 | } else { |
| 3239 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3240 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3239 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3240 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3241 | 3241 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3242 | 3242 | $EE_Export->report_attendees(); |
| 3243 | 3243 | } |
@@ -3303,7 +3303,7 @@ discard block |
||
| 3303 | 3303 | $updated_fields = array( |
| 3304 | 3304 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
| 3305 | 3305 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
| 3306 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3306 | + 'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
| 3307 | 3307 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
| 3308 | 3308 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
| 3309 | 3309 | 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
@@ -3436,7 +3436,7 @@ discard block |
||
| 3436 | 3436 | { |
| 3437 | 3437 | //get attendee object ( should already have it ) |
| 3438 | 3438 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 3439 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3439 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
| 3440 | 3440 | EEH_Template::display_template($template, $this->_template_args); |
| 3441 | 3441 | } |
| 3442 | 3442 | |
@@ -3498,8 +3498,8 @@ discard block |
||
| 3498 | 3498 | ) |
| 3499 | 3499 | ) |
| 3500 | 3500 | ); |
| 3501 | - $template = |
|
| 3502 | - REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3501 | + $template = |
|
| 3502 | + REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
| 3503 | 3503 | EEH_Template::display_template($template, $this->_template_args); |
| 3504 | 3504 | } |
| 3505 | 3505 | |
@@ -3518,7 +3518,7 @@ discard block |
||
| 3518 | 3518 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 3519 | 3519 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
| 3520 | 3520 | $template = |
| 3521 | - REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3521 | + REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
| 3522 | 3522 | EEH_Template::display_template($template, $this->_template_args); |
| 3523 | 3523 | } |
| 3524 | 3524 | |
@@ -3533,7 +3533,7 @@ discard block |
||
| 3533 | 3533 | public function after_title_form_fields($post) |
| 3534 | 3534 | { |
| 3535 | 3535 | if ($post->post_type == 'espresso_attendees') { |
| 3536 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3536 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
| 3537 | 3537 | $template_args['attendee'] = $this->_cpt_model_obj; |
| 3538 | 3538 | EEH_Template::display_template($template, $template_args); |
| 3539 | 3539 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -23,2218 +23,2218 @@ discard block |
||
| 23 | 23 | class Registrations_Admin_Page extends EE_Admin_Page_CPT |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EE_Registration |
|
| 28 | - */ |
|
| 29 | - private $_registration; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var EE_Event |
|
| 33 | - */ |
|
| 34 | - private $_reg_event; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var EE_Session |
|
| 38 | - */ |
|
| 39 | - private $_session; |
|
| 40 | - |
|
| 41 | - private static $_reg_status; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Form for displaying the custom questions for this registration. |
|
| 45 | - * This gets used a few times throughout the request so its best to cache it |
|
| 46 | - * |
|
| 47 | - * @var EE_Registration_Custom_Questions_Form |
|
| 48 | - */ |
|
| 49 | - protected $_reg_custom_questions_form = null; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * constructor |
|
| 54 | - * |
|
| 55 | - * @Constructor |
|
| 56 | - * @access public |
|
| 57 | - * @param bool $routing |
|
| 58 | - * @return Registrations_Admin_Page |
|
| 59 | - */ |
|
| 60 | - public function __construct($routing = true) |
|
| 61 | - { |
|
| 62 | - parent::__construct($routing); |
|
| 63 | - add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - public function wp_loaded() |
|
| 68 | - { |
|
| 69 | - // when adding a new registration... |
|
| 70 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | - EE_System::do_not_cache(); |
|
| 72 | - if (! isset($this->_req_data['processing_registration']) |
|
| 73 | - || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | - ) { |
|
| 75 | - // and it's NOT the attendee information reg step |
|
| 76 | - // force cookie expiration by setting time to last week |
|
| 77 | - setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | - // and update the global |
|
| 79 | - $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - protected function _init_page_props() |
|
| 86 | - { |
|
| 87 | - $this->page_slug = REG_PG_SLUG; |
|
| 88 | - $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | - $this->_admin_base_path = REG_ADMIN; |
|
| 90 | - $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 91 | - $this->_cpt_routes = array( |
|
| 92 | - 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | - 'edit_attendee' => 'espresso_attendees', |
|
| 94 | - 'insert_attendee' => 'espresso_attendees', |
|
| 95 | - 'update_attendee' => 'espresso_attendees', |
|
| 96 | - ); |
|
| 97 | - $this->_cpt_model_names = array( |
|
| 98 | - 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | - 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | - ); |
|
| 101 | - $this->_cpt_edit_routes = array( |
|
| 102 | - 'espresso_attendees' => 'edit_attendee', |
|
| 103 | - ); |
|
| 104 | - $this->_pagenow_map = array( |
|
| 105 | - 'add_new_attendee' => 'post-new.php', |
|
| 106 | - 'edit_attendee' => 'post.php', |
|
| 107 | - 'trash' => 'post.php', |
|
| 108 | - ); |
|
| 109 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | - //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | - add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - public function clear_comment_link($link, $comment, $args) |
|
| 116 | - { |
|
| 117 | - //gotta make sure this only happens on this route |
|
| 118 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | - if ($post_type === 'espresso_attendees') { |
|
| 120 | - return '#commentsdiv'; |
|
| 121 | - } |
|
| 122 | - return $link; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - protected function _ajax_hooks() |
|
| 127 | - { |
|
| 128 | - //todo: all hooks for registrations ajax goes in here |
|
| 129 | - add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - protected function _define_page_props() |
|
| 134 | - { |
|
| 135 | - $this->_admin_page_title = $this->page_label; |
|
| 136 | - $this->_labels = array( |
|
| 137 | - 'buttons' => array( |
|
| 138 | - 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 139 | - 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 140 | - 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 141 | - 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | - 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | - 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 144 | - 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 145 | - 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 146 | - ), |
|
| 147 | - 'publishbox' => array( |
|
| 148 | - 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 149 | - 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 150 | - ), |
|
| 151 | - 'hide_add_button_on_cpt_route' => array( |
|
| 152 | - 'edit_attendee' => true, |
|
| 153 | - ), |
|
| 154 | - ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * grab url requests and route them |
|
| 160 | - * |
|
| 161 | - * @access private |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - public function _set_page_routes() |
|
| 165 | - { |
|
| 166 | - $this->_get_registration_status_array(); |
|
| 167 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | - ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | - $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 170 | - ? $this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 171 | - : $reg_id; |
|
| 172 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 173 | - ? $this->_req_data['ATT_ID'] : 0; |
|
| 174 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 175 | - ? $this->_req_data['post'] |
|
| 176 | - : $att_id; |
|
| 177 | - $this->_page_routes = array( |
|
| 178 | - 'default' => array( |
|
| 179 | - 'func' => '_registrations_overview_list_table', |
|
| 180 | - 'capability' => 'ee_read_registrations', |
|
| 181 | - ), |
|
| 182 | - 'view_registration' => array( |
|
| 183 | - 'func' => '_registration_details', |
|
| 184 | - 'capability' => 'ee_read_registration', |
|
| 185 | - 'obj_id' => $reg_id, |
|
| 186 | - ), |
|
| 187 | - 'edit_registration' => array( |
|
| 188 | - 'func' => '_update_attendee_registration_form', |
|
| 189 | - 'noheader' => true, |
|
| 190 | - 'headers_sent_route' => 'view_registration', |
|
| 191 | - 'capability' => 'ee_edit_registration', |
|
| 192 | - 'obj_id' => $reg_id, |
|
| 193 | - '_REG_ID' => $reg_id, |
|
| 194 | - ), |
|
| 195 | - 'trash_registrations' => array( |
|
| 196 | - 'func' => '_trash_or_restore_registrations', |
|
| 197 | - 'args' => array('trash' => true), |
|
| 198 | - 'noheader' => true, |
|
| 199 | - 'capability' => 'ee_delete_registrations', |
|
| 200 | - ), |
|
| 201 | - 'restore_registrations' => array( |
|
| 202 | - 'func' => '_trash_or_restore_registrations', |
|
| 203 | - 'args' => array('trash' => false), |
|
| 204 | - 'noheader' => true, |
|
| 205 | - 'capability' => 'ee_delete_registrations', |
|
| 206 | - ), |
|
| 207 | - 'delete_registrations' => array( |
|
| 208 | - 'func' => '_delete_registrations', |
|
| 209 | - 'noheader' => true, |
|
| 210 | - 'capability' => 'ee_delete_registrations', |
|
| 211 | - ), |
|
| 212 | - 'new_registration' => array( |
|
| 213 | - 'func' => 'new_registration', |
|
| 214 | - 'capability' => 'ee_edit_registrations', |
|
| 215 | - ), |
|
| 216 | - 'process_reg_step' => array( |
|
| 217 | - 'func' => 'process_reg_step', |
|
| 218 | - 'noheader' => true, |
|
| 219 | - 'capability' => 'ee_edit_registrations', |
|
| 220 | - ), |
|
| 221 | - 'redirect_to_txn' => array( |
|
| 222 | - 'func' => 'redirect_to_txn', |
|
| 223 | - 'noheader' => true, |
|
| 224 | - 'capability' => 'ee_edit_registrations', |
|
| 225 | - ), |
|
| 226 | - 'change_reg_status' => array( |
|
| 227 | - 'func' => '_change_reg_status', |
|
| 228 | - 'noheader' => true, |
|
| 229 | - 'capability' => 'ee_edit_registration', |
|
| 230 | - 'obj_id' => $reg_id, |
|
| 231 | - ), |
|
| 232 | - 'approve_registration' => array( |
|
| 233 | - 'func' => 'approve_registration', |
|
| 234 | - 'noheader' => true, |
|
| 235 | - 'capability' => 'ee_edit_registration', |
|
| 236 | - 'obj_id' => $reg_id, |
|
| 237 | - ), |
|
| 238 | - 'approve_and_notify_registration' => array( |
|
| 239 | - 'func' => 'approve_registration', |
|
| 240 | - 'noheader' => true, |
|
| 241 | - 'args' => array(true), |
|
| 242 | - 'capability' => 'ee_edit_registration', |
|
| 243 | - 'obj_id' => $reg_id, |
|
| 244 | - ), |
|
| 245 | - 'approve_registrations' => array( |
|
| 246 | - 'func' => 'bulk_action_on_registrations', |
|
| 247 | - 'noheader' => true, |
|
| 248 | - 'capability' => 'ee_edit_registrations', |
|
| 249 | - 'args' => array('approve') |
|
| 250 | - ), |
|
| 251 | - 'approve_and_notify_registrations' => array( |
|
| 252 | - 'func' => 'bulk_action_on_registrations', |
|
| 253 | - 'noheader' => true, |
|
| 254 | - 'capability' => 'ee_edit_registrations', |
|
| 255 | - 'args' => array('approve', true) |
|
| 256 | - ), |
|
| 257 | - 'decline_registration' => array( |
|
| 258 | - 'func' => 'decline_registration', |
|
| 259 | - 'noheader' => true, |
|
| 260 | - 'capability' => 'ee_edit_registration', |
|
| 261 | - 'obj_id' => $reg_id, |
|
| 262 | - ), |
|
| 263 | - 'decline_and_notify_registration' => array( |
|
| 264 | - 'func' => 'decline_registration', |
|
| 265 | - 'noheader' => true, |
|
| 266 | - 'args' => array(true), |
|
| 267 | - 'capability' => 'ee_edit_registration', |
|
| 268 | - 'obj_id' => $reg_id, |
|
| 269 | - ), |
|
| 270 | - 'decline_registrations' => array( |
|
| 271 | - 'func' => 'bulk_action_on_registrations', |
|
| 272 | - 'noheader' => true, |
|
| 273 | - 'capability' => 'ee_edit_registrations', |
|
| 274 | - 'args' => array('decline') |
|
| 275 | - ), |
|
| 276 | - 'decline_and_notify_registrations' => array( |
|
| 277 | - 'func' => 'bulk_action_on_registrations', |
|
| 278 | - 'noheader' => true, |
|
| 279 | - 'capability' => 'ee_edit_registrations', |
|
| 280 | - 'args' => array('decline', true) |
|
| 281 | - ), |
|
| 282 | - 'pending_registration' => array( |
|
| 283 | - 'func' => 'pending_registration', |
|
| 284 | - 'noheader' => true, |
|
| 285 | - 'capability' => 'ee_edit_registration', |
|
| 286 | - 'obj_id' => $reg_id, |
|
| 287 | - ), |
|
| 288 | - 'pending_and_notify_registration' => array( |
|
| 289 | - 'func' => 'pending_registration', |
|
| 290 | - 'noheader' => true, |
|
| 291 | - 'args' => array(true), |
|
| 292 | - 'capability' => 'ee_edit_registration', |
|
| 293 | - 'obj_id' => $reg_id, |
|
| 294 | - ), |
|
| 295 | - 'pending_registrations' => array( |
|
| 296 | - 'func' => 'bulk_action_on_registrations', |
|
| 297 | - 'noheader' => true, |
|
| 298 | - 'capability' => 'ee_edit_registrations', |
|
| 299 | - 'args' => array('pending') |
|
| 300 | - ), |
|
| 301 | - 'pending_and_notify_registrations' => array( |
|
| 302 | - 'func' => 'bulk_action_on_registrations', |
|
| 303 | - 'noheader' => true, |
|
| 304 | - 'capability' => 'ee_edit_registrations', |
|
| 305 | - 'args' => array('pending', true) |
|
| 306 | - ), |
|
| 307 | - 'no_approve_registration' => array( |
|
| 308 | - 'func' => 'not_approve_registration', |
|
| 309 | - 'noheader' => true, |
|
| 310 | - 'capability' => 'ee_edit_registration', |
|
| 311 | - 'obj_id' => $reg_id, |
|
| 312 | - ), |
|
| 313 | - 'no_approve_and_notify_registration' => array( |
|
| 314 | - 'func' => 'not_approve_registration', |
|
| 315 | - 'noheader' => true, |
|
| 316 | - 'args' => array(true), |
|
| 317 | - 'capability' => 'ee_edit_registration', |
|
| 318 | - 'obj_id' => $reg_id, |
|
| 319 | - ), |
|
| 320 | - 'no_approve_registrations' => array( |
|
| 321 | - 'func' => 'bulk_action_on_registrations', |
|
| 322 | - 'noheader' => true, |
|
| 323 | - 'capability' => 'ee_edit_registrations', |
|
| 324 | - 'args' => array('no_approve') |
|
| 325 | - ), |
|
| 326 | - 'no_approve_and_notify_registrations' => array( |
|
| 327 | - 'func' => 'bulk_action_on_registrations', |
|
| 328 | - 'noheader' => true, |
|
| 329 | - 'capability' => 'ee_edit_registrations', |
|
| 330 | - 'args' => array('no_approve', true) |
|
| 331 | - ), |
|
| 332 | - 'cancel_registration' => array( |
|
| 333 | - 'func' => 'cancel_registration', |
|
| 334 | - 'noheader' => true, |
|
| 335 | - 'capability' => 'ee_edit_registration', |
|
| 336 | - 'obj_id' => $reg_id, |
|
| 337 | - ), |
|
| 338 | - 'cancel_and_notify_registration' => array( |
|
| 339 | - 'func' => 'cancel_registration', |
|
| 340 | - 'noheader' => true, |
|
| 341 | - 'args' => array(true), |
|
| 342 | - 'capability' => 'ee_edit_registration', |
|
| 343 | - 'obj_id' => $reg_id, |
|
| 344 | - ), |
|
| 345 | - 'cancel_registrations' => array( |
|
| 346 | - 'func' => 'bulk_action_on_registrations', |
|
| 347 | - 'noheader' => true, |
|
| 348 | - 'capability' => 'ee_edit_registrations', |
|
| 349 | - 'args' => array('cancel') |
|
| 350 | - ), |
|
| 351 | - 'cancel_and_notify_registrations' => array( |
|
| 352 | - 'func' => 'bulk_action_on_registrations', |
|
| 353 | - 'noheader' => true, |
|
| 354 | - 'capability' => 'ee_edit_registrations', |
|
| 355 | - 'args' => array('cancel', true) |
|
| 356 | - ), |
|
| 357 | - 'wait_list_registration' => array( |
|
| 358 | - 'func' => 'wait_list_registration', |
|
| 359 | - 'noheader' => true, |
|
| 360 | - 'capability' => 'ee_edit_registration', |
|
| 361 | - 'obj_id' => $reg_id, |
|
| 362 | - ), |
|
| 363 | - 'contact_list' => array( |
|
| 364 | - 'func' => '_attendee_contact_list_table', |
|
| 365 | - 'capability' => 'ee_read_contacts', |
|
| 366 | - ), |
|
| 367 | - 'add_new_attendee' => array( |
|
| 368 | - 'func' => '_create_new_cpt_item', |
|
| 369 | - 'args' => array( |
|
| 370 | - 'new_attendee' => true, |
|
| 371 | - 'capability' => 'ee_edit_contacts', |
|
| 372 | - ), |
|
| 373 | - ), |
|
| 374 | - 'edit_attendee' => array( |
|
| 375 | - 'func' => '_edit_cpt_item', |
|
| 376 | - 'capability' => 'ee_edit_contacts', |
|
| 377 | - 'obj_id' => $att_id, |
|
| 378 | - ), |
|
| 379 | - 'duplicate_attendee' => array( |
|
| 380 | - 'func' => '_duplicate_attendee', |
|
| 381 | - 'noheader' => true, |
|
| 382 | - 'capability' => 'ee_edit_contacts', |
|
| 383 | - 'obj_id' => $att_id, |
|
| 384 | - ), |
|
| 385 | - 'insert_attendee' => array( |
|
| 386 | - 'func' => '_insert_or_update_attendee', |
|
| 387 | - 'args' => array( |
|
| 388 | - 'new_attendee' => true, |
|
| 389 | - ), |
|
| 390 | - 'noheader' => true, |
|
| 391 | - 'capability' => 'ee_edit_contacts', |
|
| 392 | - ), |
|
| 393 | - 'update_attendee' => array( |
|
| 394 | - 'func' => '_insert_or_update_attendee', |
|
| 395 | - 'args' => array( |
|
| 396 | - 'new_attendee' => false, |
|
| 397 | - ), |
|
| 398 | - 'noheader' => true, |
|
| 399 | - 'capability' => 'ee_edit_contacts', |
|
| 400 | - 'obj_id' => $att_id, |
|
| 401 | - ), |
|
| 402 | - 'trash_attendees' => array( |
|
| 403 | - 'func' => '_trash_or_restore_attendees', |
|
| 404 | - 'args' => array( |
|
| 405 | - 'trash' => 'true' |
|
| 406 | - ), |
|
| 407 | - 'noheader' => true, |
|
| 408 | - 'capability' => 'ee_delete_contacts' |
|
| 409 | - ), |
|
| 410 | - 'trash_attendee' => array( |
|
| 411 | - 'func' => '_trash_or_restore_attendees', |
|
| 412 | - 'args' => array( |
|
| 413 | - 'trash' => true, |
|
| 414 | - ), |
|
| 415 | - 'noheader' => true, |
|
| 416 | - 'capability' => 'ee_delete_contacts', |
|
| 417 | - 'obj_id' => $att_id, |
|
| 418 | - ), |
|
| 419 | - 'restore_attendees' => array( |
|
| 420 | - 'func' => '_trash_or_restore_attendees', |
|
| 421 | - 'args' => array( |
|
| 422 | - 'trash' => false, |
|
| 423 | - ), |
|
| 424 | - 'noheader' => true, |
|
| 425 | - 'capability' => 'ee_delete_contacts', |
|
| 426 | - 'obj_id' => $att_id, |
|
| 427 | - ), |
|
| 428 | - 'resend_registration' => array( |
|
| 429 | - 'func' => '_resend_registration', |
|
| 430 | - 'noheader' => true, |
|
| 431 | - 'capability' => 'ee_send_message', |
|
| 432 | - ), |
|
| 433 | - 'registrations_report' => array( |
|
| 434 | - 'func' => '_registrations_report', |
|
| 435 | - 'noheader' => true, |
|
| 436 | - 'capability' => 'ee_read_registrations', |
|
| 437 | - ), |
|
| 438 | - 'contact_list_export' => array( |
|
| 439 | - 'func' => '_contact_list_export', |
|
| 440 | - 'noheader' => true, |
|
| 441 | - 'capability' => 'export', |
|
| 442 | - ), |
|
| 443 | - 'contact_list_report' => array( |
|
| 444 | - 'func' => '_contact_list_report', |
|
| 445 | - 'noheader' => true, |
|
| 446 | - 'capability' => 'ee_read_contacts', |
|
| 447 | - ), |
|
| 448 | - ); |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - protected function _set_page_config() |
|
| 453 | - { |
|
| 454 | - $this->_page_config = array( |
|
| 455 | - 'default' => array( |
|
| 456 | - 'nav' => array( |
|
| 457 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 458 | - 'order' => 5, |
|
| 459 | - ), |
|
| 460 | - 'help_tabs' => array( |
|
| 461 | - 'registrations_overview_help_tab' => array( |
|
| 462 | - 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 463 | - 'filename' => 'registrations_overview', |
|
| 464 | - ), |
|
| 465 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 466 | - 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 467 | - 'filename' => 'registrations_overview_table_column_headings', |
|
| 468 | - ), |
|
| 469 | - 'registrations_overview_filters_help_tab' => array( |
|
| 470 | - 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 471 | - 'filename' => 'registrations_overview_filters', |
|
| 472 | - ), |
|
| 473 | - 'registrations_overview_views_help_tab' => array( |
|
| 474 | - 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 475 | - 'filename' => 'registrations_overview_views', |
|
| 476 | - ), |
|
| 477 | - 'registrations_regoverview_other_help_tab' => array( |
|
| 478 | - 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 479 | - 'filename' => 'registrations_overview_other', |
|
| 480 | - ), |
|
| 481 | - ), |
|
| 482 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 483 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 484 | - 'list_table' => 'EE_Registrations_List_Table', |
|
| 485 | - 'require_nonce' => false, |
|
| 486 | - ), |
|
| 487 | - 'view_registration' => array( |
|
| 488 | - 'nav' => array( |
|
| 489 | - 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 490 | - 'order' => 15, |
|
| 491 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
| 492 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 493 | - : $this->_admin_base_url, |
|
| 494 | - 'persistent' => false, |
|
| 495 | - ), |
|
| 496 | - 'help_tabs' => array( |
|
| 497 | - 'registrations_details_help_tab' => array( |
|
| 498 | - 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 499 | - 'filename' => 'registrations_details', |
|
| 500 | - ), |
|
| 501 | - 'registrations_details_table_help_tab' => array( |
|
| 502 | - 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 503 | - 'filename' => 'registrations_details_table', |
|
| 504 | - ), |
|
| 505 | - 'registrations_details_form_answers_help_tab' => array( |
|
| 506 | - 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 507 | - 'filename' => 'registrations_details_form_answers', |
|
| 508 | - ), |
|
| 509 | - 'registrations_details_registrant_details_help_tab' => array( |
|
| 510 | - 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 511 | - 'filename' => 'registrations_details_registrant_details', |
|
| 512 | - ), |
|
| 513 | - ), |
|
| 514 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 515 | - 'metaboxes' => array_merge( |
|
| 516 | - $this->_default_espresso_metaboxes, |
|
| 517 | - array('_registration_details_metaboxes') |
|
| 518 | - ), |
|
| 519 | - 'require_nonce' => false, |
|
| 520 | - ), |
|
| 521 | - 'new_registration' => array( |
|
| 522 | - 'nav' => array( |
|
| 523 | - 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 524 | - 'url' => '#', |
|
| 525 | - 'order' => 15, |
|
| 526 | - 'persistent' => false, |
|
| 527 | - ), |
|
| 528 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 529 | - 'labels' => array( |
|
| 530 | - 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 531 | - ), |
|
| 532 | - 'require_nonce' => false, |
|
| 533 | - ), |
|
| 534 | - 'add_new_attendee' => array( |
|
| 535 | - 'nav' => array( |
|
| 536 | - 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 537 | - 'order' => 15, |
|
| 538 | - 'persistent' => false, |
|
| 539 | - ), |
|
| 540 | - 'metaboxes' => array_merge( |
|
| 541 | - $this->_default_espresso_metaboxes, |
|
| 542 | - array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 543 | - ), |
|
| 544 | - 'require_nonce' => false, |
|
| 545 | - ), |
|
| 546 | - 'edit_attendee' => array( |
|
| 547 | - 'nav' => array( |
|
| 548 | - 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 549 | - 'order' => 15, |
|
| 550 | - 'persistent' => false, |
|
| 551 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
| 552 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 553 | - : $this->_admin_base_url, |
|
| 554 | - ), |
|
| 555 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 556 | - 'require_nonce' => false, |
|
| 557 | - ), |
|
| 558 | - 'contact_list' => array( |
|
| 559 | - 'nav' => array( |
|
| 560 | - 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 561 | - 'order' => 20, |
|
| 562 | - ), |
|
| 563 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 564 | - 'help_tabs' => array( |
|
| 565 | - 'registrations_contact_list_help_tab' => array( |
|
| 566 | - 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 567 | - 'filename' => 'registrations_contact_list', |
|
| 568 | - ), |
|
| 569 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 570 | - 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 571 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 572 | - ), |
|
| 573 | - 'registrations_contact_list_views_help_tab' => array( |
|
| 574 | - 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 575 | - 'filename' => 'registrations_contact_list_views', |
|
| 576 | - ), |
|
| 577 | - 'registrations_contact_list_other_help_tab' => array( |
|
| 578 | - 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 579 | - 'filename' => 'registrations_contact_list_other', |
|
| 580 | - ), |
|
| 581 | - ), |
|
| 582 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 583 | - 'metaboxes' => array(), |
|
| 584 | - 'require_nonce' => false, |
|
| 585 | - ), |
|
| 586 | - //override default cpt routes |
|
| 587 | - 'create_new' => '', |
|
| 588 | - 'edit' => '', |
|
| 589 | - ); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * The below methods aren't used by this class currently |
|
| 595 | - */ |
|
| 596 | - protected function _add_screen_options() |
|
| 597 | - { |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - |
|
| 601 | - protected function _add_feature_pointers() |
|
| 602 | - { |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - |
|
| 606 | - public function admin_init() |
|
| 607 | - { |
|
| 608 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 609 | - 'click "Update Registration Questions" to save your changes', |
|
| 610 | - 'event_espresso' |
|
| 611 | - ); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - public function admin_notices() |
|
| 616 | - { |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - |
|
| 620 | - public function admin_footer_scripts() |
|
| 621 | - { |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - |
|
| 625 | - /** |
|
| 626 | - * get list of registration statuses |
|
| 627 | - * |
|
| 628 | - * @access private |
|
| 629 | - * @return void |
|
| 630 | - */ |
|
| 631 | - private function _get_registration_status_array() |
|
| 632 | - { |
|
| 633 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - |
|
| 637 | - protected function _add_screen_options_default() |
|
| 638 | - { |
|
| 639 | - $this->_per_page_screen_option(); |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - |
|
| 643 | - protected function _add_screen_options_contact_list() |
|
| 644 | - { |
|
| 645 | - $page_title = $this->_admin_page_title; |
|
| 646 | - $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 647 | - $this->_per_page_screen_option(); |
|
| 648 | - $this->_admin_page_title = $page_title; |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - public function load_scripts_styles() |
|
| 653 | - { |
|
| 654 | - //style |
|
| 655 | - wp_register_style( |
|
| 656 | - 'espresso_reg', |
|
| 657 | - REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 658 | - array('ee-admin-css'), |
|
| 659 | - EVENT_ESPRESSO_VERSION |
|
| 660 | - ); |
|
| 661 | - wp_enqueue_style('espresso_reg'); |
|
| 662 | - //script |
|
| 663 | - wp_register_script( |
|
| 664 | - 'espresso_reg', |
|
| 665 | - REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 666 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 667 | - EVENT_ESPRESSO_VERSION, |
|
| 668 | - true |
|
| 669 | - ); |
|
| 670 | - wp_enqueue_script('espresso_reg'); |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - |
|
| 674 | - public function load_scripts_styles_edit_attendee() |
|
| 675 | - { |
|
| 676 | - //stuff to only show up on our attendee edit details page. |
|
| 677 | - $attendee_details_translations = array( |
|
| 678 | - 'att_publish_text' => sprintf( |
|
| 679 | - esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 680 | - $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 681 | - ), |
|
| 682 | - ); |
|
| 683 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 684 | - wp_enqueue_script('jquery-validate'); |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - |
|
| 688 | - public function load_scripts_styles_view_registration() |
|
| 689 | - { |
|
| 690 | - //styles |
|
| 691 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 692 | - //scripts |
|
| 693 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 694 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - |
|
| 698 | - public function load_scripts_styles_contact_list() |
|
| 699 | - { |
|
| 700 | - wp_deregister_style('espresso_reg'); |
|
| 701 | - wp_register_style( |
|
| 702 | - 'espresso_att', |
|
| 703 | - REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 704 | - array('ee-admin-css'), |
|
| 705 | - EVENT_ESPRESSO_VERSION |
|
| 706 | - ); |
|
| 707 | - wp_enqueue_style('espresso_att'); |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - |
|
| 711 | - public function load_scripts_styles_new_registration() |
|
| 712 | - { |
|
| 713 | - wp_register_script( |
|
| 714 | - 'ee-spco-for-admin', |
|
| 715 | - REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 716 | - array('underscore', 'jquery'), |
|
| 717 | - EVENT_ESPRESSO_VERSION, |
|
| 718 | - true |
|
| 719 | - ); |
|
| 720 | - wp_enqueue_script('ee-spco-for-admin'); |
|
| 721 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 722 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 723 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 724 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - |
|
| 728 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 729 | - { |
|
| 730 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - |
|
| 734 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 735 | - { |
|
| 736 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - |
|
| 740 | - protected function _set_list_table_views_default() |
|
| 741 | - { |
|
| 742 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 743 | - EED_Messages::set_autoloaders(); |
|
| 744 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 745 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 746 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 747 | - //key= bulk_action_slug, value= message type. |
|
| 748 | - $match_array = array( |
|
| 749 | - 'approve_registrations' => 'registration', |
|
| 750 | - 'decline_registrations' => 'declined_registration', |
|
| 751 | - 'pending_registrations' => 'pending_approval', |
|
| 752 | - 'no_approve_registrations' => 'not_approved_registration', |
|
| 753 | - 'cancel_registrations' => 'cancelled_registration', |
|
| 754 | - ); |
|
| 755 | - $can_send = EE_Registry::instance()->CAP->current_user_can( |
|
| 756 | - 'ee_send_message', |
|
| 757 | - 'batch_send_messages' |
|
| 758 | - ); |
|
| 759 | - /** setup reg status bulk actions **/ |
|
| 760 | - $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 761 | - if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) { |
|
| 762 | - $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__( |
|
| 763 | - 'Approve and Notify Registrations', |
|
| 764 | - 'event_espresso' |
|
| 765 | - ); |
|
| 766 | - } |
|
| 767 | - $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 768 | - if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) { |
|
| 769 | - $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__( |
|
| 770 | - 'Decline and Notify Registrations', |
|
| 771 | - 'event_espresso' |
|
| 772 | - ); |
|
| 773 | - } |
|
| 774 | - $def_reg_status_actions['pending_registrations'] = esc_html__( |
|
| 775 | - 'Set Registrations to Pending Payment', |
|
| 776 | - 'event_espresso' |
|
| 777 | - ); |
|
| 778 | - if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) { |
|
| 779 | - $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__( |
|
| 780 | - 'Set Registrations to Pending Payment and Notify', |
|
| 781 | - 'event_espresso' |
|
| 782 | - ); |
|
| 783 | - } |
|
| 784 | - $def_reg_status_actions['no_approve_registrations'] = esc_html__( |
|
| 785 | - 'Set Registrations to Not Approved', |
|
| 786 | - 'event_espresso' |
|
| 787 | - ); |
|
| 788 | - if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) { |
|
| 789 | - $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__( |
|
| 790 | - 'Set Registrations to Not Approved and Notify', |
|
| 791 | - 'event_espresso' |
|
| 792 | - ); |
|
| 793 | - } |
|
| 794 | - $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 795 | - if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) { |
|
| 796 | - $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__( |
|
| 797 | - 'Cancel Registrations and Notify', |
|
| 798 | - 'event_espresso' |
|
| 799 | - ); |
|
| 800 | - } |
|
| 801 | - $def_reg_status_actions = apply_filters( |
|
| 802 | - 'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array', |
|
| 803 | - $def_reg_status_actions, |
|
| 804 | - $active_mts |
|
| 805 | - ); |
|
| 806 | - |
|
| 807 | - $this->_views = array( |
|
| 808 | - 'all' => array( |
|
| 809 | - 'slug' => 'all', |
|
| 810 | - 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 811 | - 'count' => 0, |
|
| 812 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 813 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 814 | - )), |
|
| 815 | - ), |
|
| 816 | - 'month' => array( |
|
| 817 | - 'slug' => 'month', |
|
| 818 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 819 | - 'count' => 0, |
|
| 820 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 821 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 822 | - )), |
|
| 823 | - ), |
|
| 824 | - 'today' => array( |
|
| 825 | - 'slug' => 'today', |
|
| 826 | - 'label' => sprintf( |
|
| 827 | - esc_html__('Today - %s', 'event_espresso'), |
|
| 828 | - date('M d, Y', current_time('timestamp')) |
|
| 829 | - ), |
|
| 830 | - 'count' => 0, |
|
| 831 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 832 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 833 | - )), |
|
| 834 | - ), |
|
| 835 | - ); |
|
| 836 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 837 | - 'ee_delete_registrations', |
|
| 838 | - 'espresso_registrations_delete_registration' |
|
| 839 | - )) { |
|
| 840 | - $this->_views['incomplete'] = array( |
|
| 841 | - 'slug' => 'incomplete', |
|
| 842 | - 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 843 | - 'count' => 0, |
|
| 844 | - 'bulk_action' => array( |
|
| 845 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 846 | - ), |
|
| 847 | - ); |
|
| 848 | - $this->_views['trash'] = array( |
|
| 849 | - 'slug' => 'trash', |
|
| 850 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 851 | - 'count' => 0, |
|
| 852 | - 'bulk_action' => array( |
|
| 853 | - 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 854 | - 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 855 | - ), |
|
| 856 | - ); |
|
| 857 | - } |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - |
|
| 861 | - protected function _set_list_table_views_contact_list() |
|
| 862 | - { |
|
| 863 | - $this->_views = array( |
|
| 864 | - 'in_use' => array( |
|
| 865 | - 'slug' => 'in_use', |
|
| 866 | - 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 867 | - 'count' => 0, |
|
| 868 | - 'bulk_action' => array( |
|
| 869 | - 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 870 | - ), |
|
| 871 | - ), |
|
| 872 | - ); |
|
| 873 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 874 | - 'espresso_registrations_trash_attendees') |
|
| 875 | - ) { |
|
| 876 | - $this->_views['trash'] = array( |
|
| 877 | - 'slug' => 'trash', |
|
| 878 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 879 | - 'count' => 0, |
|
| 880 | - 'bulk_action' => array( |
|
| 881 | - 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 882 | - ), |
|
| 883 | - ); |
|
| 884 | - } |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - |
|
| 888 | - protected function _registration_legend_items() |
|
| 889 | - { |
|
| 890 | - $fc_items = array( |
|
| 891 | - 'star-icon' => array( |
|
| 892 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 893 | - 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 894 | - ), |
|
| 895 | - 'view_details' => array( |
|
| 896 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 897 | - 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 898 | - ), |
|
| 899 | - 'edit_attendee' => array( |
|
| 900 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 901 | - 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 902 | - ), |
|
| 903 | - 'view_transaction' => array( |
|
| 904 | - 'class' => 'dashicons dashicons-cart', |
|
| 905 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 906 | - ), |
|
| 907 | - 'view_invoice' => array( |
|
| 908 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 909 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 910 | - ), |
|
| 911 | - ); |
|
| 912 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 913 | - 'ee_send_message', |
|
| 914 | - 'espresso_registrations_resend_registration' |
|
| 915 | - )) { |
|
| 916 | - $fc_items['resend_registration'] = array( |
|
| 917 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 918 | - 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 919 | - ); |
|
| 920 | - } else { |
|
| 921 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 922 | - } |
|
| 923 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 924 | - 'ee_read_global_messages', |
|
| 925 | - 'view_filtered_messages' |
|
| 926 | - )) { |
|
| 927 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 928 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 929 | - $fc_items['view_related_messages'] = array( |
|
| 930 | - 'class' => $related_for_icon['css_class'], |
|
| 931 | - 'desc' => $related_for_icon['label'], |
|
| 932 | - ); |
|
| 933 | - } |
|
| 934 | - } |
|
| 935 | - $sc_items = array( |
|
| 936 | - 'approved_status' => array( |
|
| 937 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 938 | - 'desc' => EEH_Template::pretty_status( |
|
| 939 | - EEM_Registration::status_id_approved, |
|
| 940 | - false, |
|
| 941 | - 'sentence' |
|
| 942 | - ), |
|
| 943 | - ), |
|
| 944 | - 'pending_status' => array( |
|
| 945 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 946 | - 'desc' => EEH_Template::pretty_status( |
|
| 947 | - EEM_Registration::status_id_pending_payment, |
|
| 948 | - false, |
|
| 949 | - 'sentence' |
|
| 950 | - ), |
|
| 951 | - ), |
|
| 952 | - 'wait_list' => array( |
|
| 953 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 954 | - 'desc' => EEH_Template::pretty_status( |
|
| 955 | - EEM_Registration::status_id_wait_list, |
|
| 956 | - false, |
|
| 957 | - 'sentence' |
|
| 958 | - ), |
|
| 959 | - ), |
|
| 960 | - 'incomplete_status' => array( |
|
| 961 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 962 | - 'desc' => EEH_Template::pretty_status( |
|
| 963 | - EEM_Registration::status_id_incomplete, |
|
| 964 | - false, |
|
| 965 | - 'sentence' |
|
| 966 | - ), |
|
| 967 | - ), |
|
| 968 | - 'not_approved' => array( |
|
| 969 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 970 | - 'desc' => EEH_Template::pretty_status( |
|
| 971 | - EEM_Registration::status_id_not_approved, |
|
| 972 | - false, |
|
| 973 | - 'sentence' |
|
| 974 | - ), |
|
| 975 | - ), |
|
| 976 | - 'declined_status' => array( |
|
| 977 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 978 | - 'desc' => EEH_Template::pretty_status( |
|
| 979 | - EEM_Registration::status_id_declined, |
|
| 980 | - false, |
|
| 981 | - 'sentence' |
|
| 982 | - ), |
|
| 983 | - ), |
|
| 984 | - 'cancelled_status' => array( |
|
| 985 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 986 | - 'desc' => EEH_Template::pretty_status( |
|
| 987 | - EEM_Registration::status_id_cancelled, |
|
| 988 | - false, |
|
| 989 | - 'sentence' |
|
| 990 | - ), |
|
| 991 | - ), |
|
| 992 | - ); |
|
| 993 | - return array_merge($fc_items, $sc_items); |
|
| 994 | - } |
|
| 995 | - |
|
| 996 | - |
|
| 997 | - |
|
| 998 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 999 | - /** |
|
| 1000 | - * @throws \EE_Error |
|
| 1001 | - */ |
|
| 1002 | - protected function _registrations_overview_list_table() |
|
| 1003 | - { |
|
| 1004 | - $this->_template_args['admin_page_header'] = ''; |
|
| 1005 | - $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 1006 | - ? absint($this->_req_data['event_id']) |
|
| 1007 | - : 0; |
|
| 1008 | - if ($EVT_ID) { |
|
| 1009 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1010 | - 'ee_edit_registrations', |
|
| 1011 | - 'espresso_registrations_new_registration', |
|
| 1012 | - $EVT_ID |
|
| 1013 | - )) { |
|
| 1014 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1015 | - 'new_registration', |
|
| 1016 | - 'add-registrant', |
|
| 1017 | - array('event_id' => $EVT_ID), |
|
| 1018 | - 'add-new-h2' |
|
| 1019 | - ); |
|
| 1020 | - } |
|
| 1021 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 1022 | - if ($event instanceof EE_Event) { |
|
| 1023 | - $this->_template_args['admin_page_header'] = sprintf( |
|
| 1024 | - esc_html__( |
|
| 1025 | - '%s Viewing registrations for the event: %s%s', |
|
| 1026 | - 'event_espresso' |
|
| 1027 | - ), |
|
| 1028 | - '<h3 style="line-height:1.5em;">', |
|
| 1029 | - '<br /><a href="' |
|
| 1030 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
| 1031 | - array( |
|
| 1032 | - 'action' => 'edit', |
|
| 1033 | - 'post' => $event->ID(), |
|
| 1034 | - ), |
|
| 1035 | - EVENTS_ADMIN_URL |
|
| 1036 | - ) |
|
| 1037 | - . '"> ' |
|
| 1038 | - . $event->get('EVT_name') |
|
| 1039 | - . ' </a> ', |
|
| 1040 | - '</h3>' |
|
| 1041 | - ); |
|
| 1042 | - } |
|
| 1043 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 1044 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1045 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 1046 | - $this->_template_args['admin_page_header'] = substr( |
|
| 1047 | - $this->_template_args['admin_page_header'], |
|
| 1048 | - 0, |
|
| 1049 | - -5 |
|
| 1050 | - ); |
|
| 1051 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 1052 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1053 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 1054 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 1055 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 1056 | - } |
|
| 1057 | - } |
|
| 1058 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 1059 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1060 | - } |
|
| 1061 | - |
|
| 1062 | - |
|
| 1063 | - /** |
|
| 1064 | - * This sets the _registration property for the registration details screen |
|
| 1065 | - * |
|
| 1066 | - * @access private |
|
| 1067 | - * @return bool |
|
| 1068 | - */ |
|
| 1069 | - private function _set_registration_object() |
|
| 1070 | - { |
|
| 1071 | - //get out if we've already set the object |
|
| 1072 | - if (is_object($this->_registration)) { |
|
| 1073 | - return true; |
|
| 1074 | - } |
|
| 1075 | - $REG = EEM_Registration::instance(); |
|
| 1076 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1077 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1078 | - return true; |
|
| 1079 | - } else { |
|
| 1080 | - $error_msg = sprintf( |
|
| 1081 | - esc_html__( |
|
| 1082 | - 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1083 | - 'event_espresso' |
|
| 1084 | - ), |
|
| 1085 | - $REG_ID |
|
| 1086 | - ); |
|
| 1087 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1088 | - $this->_registration = null; |
|
| 1089 | - return false; |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - |
|
| 1093 | - |
|
| 1094 | - /** |
|
| 1095 | - * Used to retrieve registrations for the list table. |
|
| 1096 | - * |
|
| 1097 | - * @param int $per_page |
|
| 1098 | - * @param bool $count |
|
| 1099 | - * @param bool $this_month |
|
| 1100 | - * @param bool $today |
|
| 1101 | - * @return EE_Registration[]|int |
|
| 1102 | - * @throws EE_Error |
|
| 1103 | - */ |
|
| 1104 | - public function get_registrations( |
|
| 1105 | - $per_page = 10, |
|
| 1106 | - $count = false, |
|
| 1107 | - $this_month = false, |
|
| 1108 | - $today = false |
|
| 1109 | - ) { |
|
| 1110 | - if ($this_month) { |
|
| 1111 | - $this->_req_data['status'] = 'month'; |
|
| 1112 | - } |
|
| 1113 | - if ($today) { |
|
| 1114 | - $this->_req_data['status'] = 'today'; |
|
| 1115 | - } |
|
| 1116 | - $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1117 | - /** |
|
| 1118 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1119 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1120 | - * @see EEM_Base::get_all() |
|
| 1121 | - */ |
|
| 1122 | - $query_params['group_by'] = ''; |
|
| 1123 | - |
|
| 1124 | - return $count |
|
| 1125 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1126 | - /** @type EE_Registration[] */ |
|
| 1127 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1134 | - * Note: this listens to values on the request for some of the query parameters. |
|
| 1135 | - * |
|
| 1136 | - * @param array $request |
|
| 1137 | - * @param int $per_page |
|
| 1138 | - * @param bool $count |
|
| 1139 | - * @return array |
|
| 1140 | - */ |
|
| 1141 | - protected function _get_registration_query_parameters( |
|
| 1142 | - $request = array(), |
|
| 1143 | - $per_page = 10, |
|
| 1144 | - $count = false |
|
| 1145 | - ) { |
|
| 1146 | - |
|
| 1147 | - $query_params = array( |
|
| 1148 | - 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1149 | - $request |
|
| 1150 | - ), |
|
| 1151 | - 'caps' => EEM_Registration::caps_read_admin, |
|
| 1152 | - 'default_where_conditions' => 'this_model_only', |
|
| 1153 | - ); |
|
| 1154 | - if (! $count) { |
|
| 1155 | - $query_params = array_merge( |
|
| 1156 | - $query_params, |
|
| 1157 | - $this->_get_orderby_for_registrations_query(), |
|
| 1158 | - $this->_get_limit($per_page) |
|
| 1159 | - ); |
|
| 1160 | - } |
|
| 1161 | - |
|
| 1162 | - return $query_params; |
|
| 1163 | - } |
|
| 1164 | - |
|
| 1165 | - |
|
| 1166 | - /** |
|
| 1167 | - * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1168 | - * |
|
| 1169 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1170 | - * @return array |
|
| 1171 | - */ |
|
| 1172 | - protected function _add_event_id_to_where_conditions(array $request) |
|
| 1173 | - { |
|
| 1174 | - $where = array(); |
|
| 1175 | - if (! empty($request['event_id'])) { |
|
| 1176 | - $where['EVT_ID'] = absint($request['event_id']); |
|
| 1177 | - } |
|
| 1178 | - return $where; |
|
| 1179 | - } |
|
| 1180 | - |
|
| 1181 | - |
|
| 1182 | - /** |
|
| 1183 | - * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1184 | - * |
|
| 1185 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1186 | - * @return array |
|
| 1187 | - */ |
|
| 1188 | - protected function _add_category_id_to_where_conditions(array $request) |
|
| 1189 | - { |
|
| 1190 | - $where = array(); |
|
| 1191 | - if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1192 | - $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1193 | - } |
|
| 1194 | - return $where; |
|
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - |
|
| 1198 | - /** |
|
| 1199 | - * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1200 | - * |
|
| 1201 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1202 | - * @return array |
|
| 1203 | - */ |
|
| 1204 | - protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1205 | - { |
|
| 1206 | - $where = array(); |
|
| 1207 | - if (! empty($request['datetime_id'])) { |
|
| 1208 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1209 | - } |
|
| 1210 | - if (! empty($request['DTT_ID'])) { |
|
| 1211 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1212 | - } |
|
| 1213 | - return $where; |
|
| 1214 | - } |
|
| 1215 | - |
|
| 1216 | - |
|
| 1217 | - /** |
|
| 1218 | - * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1219 | - * |
|
| 1220 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1221 | - * @return array |
|
| 1222 | - */ |
|
| 1223 | - protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1224 | - { |
|
| 1225 | - $where = array(); |
|
| 1226 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1227 | - $registration_status = ! empty($request['_reg_status']) |
|
| 1228 | - ? sanitize_text_field($request['_reg_status']) |
|
| 1229 | - : ''; |
|
| 1230 | - |
|
| 1231 | - /* |
|
| 26 | + /** |
|
| 27 | + * @var EE_Registration |
|
| 28 | + */ |
|
| 29 | + private $_registration; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var EE_Event |
|
| 33 | + */ |
|
| 34 | + private $_reg_event; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var EE_Session |
|
| 38 | + */ |
|
| 39 | + private $_session; |
|
| 40 | + |
|
| 41 | + private static $_reg_status; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Form for displaying the custom questions for this registration. |
|
| 45 | + * This gets used a few times throughout the request so its best to cache it |
|
| 46 | + * |
|
| 47 | + * @var EE_Registration_Custom_Questions_Form |
|
| 48 | + */ |
|
| 49 | + protected $_reg_custom_questions_form = null; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * constructor |
|
| 54 | + * |
|
| 55 | + * @Constructor |
|
| 56 | + * @access public |
|
| 57 | + * @param bool $routing |
|
| 58 | + * @return Registrations_Admin_Page |
|
| 59 | + */ |
|
| 60 | + public function __construct($routing = true) |
|
| 61 | + { |
|
| 62 | + parent::__construct($routing); |
|
| 63 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + public function wp_loaded() |
|
| 68 | + { |
|
| 69 | + // when adding a new registration... |
|
| 70 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | + EE_System::do_not_cache(); |
|
| 72 | + if (! isset($this->_req_data['processing_registration']) |
|
| 73 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | + ) { |
|
| 75 | + // and it's NOT the attendee information reg step |
|
| 76 | + // force cookie expiration by setting time to last week |
|
| 77 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | + // and update the global |
|
| 79 | + $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + protected function _init_page_props() |
|
| 86 | + { |
|
| 87 | + $this->page_slug = REG_PG_SLUG; |
|
| 88 | + $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | + $this->_admin_base_path = REG_ADMIN; |
|
| 90 | + $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 91 | + $this->_cpt_routes = array( |
|
| 92 | + 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | + 'edit_attendee' => 'espresso_attendees', |
|
| 94 | + 'insert_attendee' => 'espresso_attendees', |
|
| 95 | + 'update_attendee' => 'espresso_attendees', |
|
| 96 | + ); |
|
| 97 | + $this->_cpt_model_names = array( |
|
| 98 | + 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | + 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | + ); |
|
| 101 | + $this->_cpt_edit_routes = array( |
|
| 102 | + 'espresso_attendees' => 'edit_attendee', |
|
| 103 | + ); |
|
| 104 | + $this->_pagenow_map = array( |
|
| 105 | + 'add_new_attendee' => 'post-new.php', |
|
| 106 | + 'edit_attendee' => 'post.php', |
|
| 107 | + 'trash' => 'post.php', |
|
| 108 | + ); |
|
| 109 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | + //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + public function clear_comment_link($link, $comment, $args) |
|
| 116 | + { |
|
| 117 | + //gotta make sure this only happens on this route |
|
| 118 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | + if ($post_type === 'espresso_attendees') { |
|
| 120 | + return '#commentsdiv'; |
|
| 121 | + } |
|
| 122 | + return $link; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + protected function _ajax_hooks() |
|
| 127 | + { |
|
| 128 | + //todo: all hooks for registrations ajax goes in here |
|
| 129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + protected function _define_page_props() |
|
| 134 | + { |
|
| 135 | + $this->_admin_page_title = $this->page_label; |
|
| 136 | + $this->_labels = array( |
|
| 137 | + 'buttons' => array( |
|
| 138 | + 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 139 | + 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 140 | + 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 141 | + 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | + 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | + 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 144 | + 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 145 | + 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 146 | + ), |
|
| 147 | + 'publishbox' => array( |
|
| 148 | + 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 149 | + 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 150 | + ), |
|
| 151 | + 'hide_add_button_on_cpt_route' => array( |
|
| 152 | + 'edit_attendee' => true, |
|
| 153 | + ), |
|
| 154 | + ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * grab url requests and route them |
|
| 160 | + * |
|
| 161 | + * @access private |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + public function _set_page_routes() |
|
| 165 | + { |
|
| 166 | + $this->_get_registration_status_array(); |
|
| 167 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | + ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | + $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 170 | + ? $this->_req_data['reg_status_change_form']['REG_ID'] |
|
| 171 | + : $reg_id; |
|
| 172 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 173 | + ? $this->_req_data['ATT_ID'] : 0; |
|
| 174 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 175 | + ? $this->_req_data['post'] |
|
| 176 | + : $att_id; |
|
| 177 | + $this->_page_routes = array( |
|
| 178 | + 'default' => array( |
|
| 179 | + 'func' => '_registrations_overview_list_table', |
|
| 180 | + 'capability' => 'ee_read_registrations', |
|
| 181 | + ), |
|
| 182 | + 'view_registration' => array( |
|
| 183 | + 'func' => '_registration_details', |
|
| 184 | + 'capability' => 'ee_read_registration', |
|
| 185 | + 'obj_id' => $reg_id, |
|
| 186 | + ), |
|
| 187 | + 'edit_registration' => array( |
|
| 188 | + 'func' => '_update_attendee_registration_form', |
|
| 189 | + 'noheader' => true, |
|
| 190 | + 'headers_sent_route' => 'view_registration', |
|
| 191 | + 'capability' => 'ee_edit_registration', |
|
| 192 | + 'obj_id' => $reg_id, |
|
| 193 | + '_REG_ID' => $reg_id, |
|
| 194 | + ), |
|
| 195 | + 'trash_registrations' => array( |
|
| 196 | + 'func' => '_trash_or_restore_registrations', |
|
| 197 | + 'args' => array('trash' => true), |
|
| 198 | + 'noheader' => true, |
|
| 199 | + 'capability' => 'ee_delete_registrations', |
|
| 200 | + ), |
|
| 201 | + 'restore_registrations' => array( |
|
| 202 | + 'func' => '_trash_or_restore_registrations', |
|
| 203 | + 'args' => array('trash' => false), |
|
| 204 | + 'noheader' => true, |
|
| 205 | + 'capability' => 'ee_delete_registrations', |
|
| 206 | + ), |
|
| 207 | + 'delete_registrations' => array( |
|
| 208 | + 'func' => '_delete_registrations', |
|
| 209 | + 'noheader' => true, |
|
| 210 | + 'capability' => 'ee_delete_registrations', |
|
| 211 | + ), |
|
| 212 | + 'new_registration' => array( |
|
| 213 | + 'func' => 'new_registration', |
|
| 214 | + 'capability' => 'ee_edit_registrations', |
|
| 215 | + ), |
|
| 216 | + 'process_reg_step' => array( |
|
| 217 | + 'func' => 'process_reg_step', |
|
| 218 | + 'noheader' => true, |
|
| 219 | + 'capability' => 'ee_edit_registrations', |
|
| 220 | + ), |
|
| 221 | + 'redirect_to_txn' => array( |
|
| 222 | + 'func' => 'redirect_to_txn', |
|
| 223 | + 'noheader' => true, |
|
| 224 | + 'capability' => 'ee_edit_registrations', |
|
| 225 | + ), |
|
| 226 | + 'change_reg_status' => array( |
|
| 227 | + 'func' => '_change_reg_status', |
|
| 228 | + 'noheader' => true, |
|
| 229 | + 'capability' => 'ee_edit_registration', |
|
| 230 | + 'obj_id' => $reg_id, |
|
| 231 | + ), |
|
| 232 | + 'approve_registration' => array( |
|
| 233 | + 'func' => 'approve_registration', |
|
| 234 | + 'noheader' => true, |
|
| 235 | + 'capability' => 'ee_edit_registration', |
|
| 236 | + 'obj_id' => $reg_id, |
|
| 237 | + ), |
|
| 238 | + 'approve_and_notify_registration' => array( |
|
| 239 | + 'func' => 'approve_registration', |
|
| 240 | + 'noheader' => true, |
|
| 241 | + 'args' => array(true), |
|
| 242 | + 'capability' => 'ee_edit_registration', |
|
| 243 | + 'obj_id' => $reg_id, |
|
| 244 | + ), |
|
| 245 | + 'approve_registrations' => array( |
|
| 246 | + 'func' => 'bulk_action_on_registrations', |
|
| 247 | + 'noheader' => true, |
|
| 248 | + 'capability' => 'ee_edit_registrations', |
|
| 249 | + 'args' => array('approve') |
|
| 250 | + ), |
|
| 251 | + 'approve_and_notify_registrations' => array( |
|
| 252 | + 'func' => 'bulk_action_on_registrations', |
|
| 253 | + 'noheader' => true, |
|
| 254 | + 'capability' => 'ee_edit_registrations', |
|
| 255 | + 'args' => array('approve', true) |
|
| 256 | + ), |
|
| 257 | + 'decline_registration' => array( |
|
| 258 | + 'func' => 'decline_registration', |
|
| 259 | + 'noheader' => true, |
|
| 260 | + 'capability' => 'ee_edit_registration', |
|
| 261 | + 'obj_id' => $reg_id, |
|
| 262 | + ), |
|
| 263 | + 'decline_and_notify_registration' => array( |
|
| 264 | + 'func' => 'decline_registration', |
|
| 265 | + 'noheader' => true, |
|
| 266 | + 'args' => array(true), |
|
| 267 | + 'capability' => 'ee_edit_registration', |
|
| 268 | + 'obj_id' => $reg_id, |
|
| 269 | + ), |
|
| 270 | + 'decline_registrations' => array( |
|
| 271 | + 'func' => 'bulk_action_on_registrations', |
|
| 272 | + 'noheader' => true, |
|
| 273 | + 'capability' => 'ee_edit_registrations', |
|
| 274 | + 'args' => array('decline') |
|
| 275 | + ), |
|
| 276 | + 'decline_and_notify_registrations' => array( |
|
| 277 | + 'func' => 'bulk_action_on_registrations', |
|
| 278 | + 'noheader' => true, |
|
| 279 | + 'capability' => 'ee_edit_registrations', |
|
| 280 | + 'args' => array('decline', true) |
|
| 281 | + ), |
|
| 282 | + 'pending_registration' => array( |
|
| 283 | + 'func' => 'pending_registration', |
|
| 284 | + 'noheader' => true, |
|
| 285 | + 'capability' => 'ee_edit_registration', |
|
| 286 | + 'obj_id' => $reg_id, |
|
| 287 | + ), |
|
| 288 | + 'pending_and_notify_registration' => array( |
|
| 289 | + 'func' => 'pending_registration', |
|
| 290 | + 'noheader' => true, |
|
| 291 | + 'args' => array(true), |
|
| 292 | + 'capability' => 'ee_edit_registration', |
|
| 293 | + 'obj_id' => $reg_id, |
|
| 294 | + ), |
|
| 295 | + 'pending_registrations' => array( |
|
| 296 | + 'func' => 'bulk_action_on_registrations', |
|
| 297 | + 'noheader' => true, |
|
| 298 | + 'capability' => 'ee_edit_registrations', |
|
| 299 | + 'args' => array('pending') |
|
| 300 | + ), |
|
| 301 | + 'pending_and_notify_registrations' => array( |
|
| 302 | + 'func' => 'bulk_action_on_registrations', |
|
| 303 | + 'noheader' => true, |
|
| 304 | + 'capability' => 'ee_edit_registrations', |
|
| 305 | + 'args' => array('pending', true) |
|
| 306 | + ), |
|
| 307 | + 'no_approve_registration' => array( |
|
| 308 | + 'func' => 'not_approve_registration', |
|
| 309 | + 'noheader' => true, |
|
| 310 | + 'capability' => 'ee_edit_registration', |
|
| 311 | + 'obj_id' => $reg_id, |
|
| 312 | + ), |
|
| 313 | + 'no_approve_and_notify_registration' => array( |
|
| 314 | + 'func' => 'not_approve_registration', |
|
| 315 | + 'noheader' => true, |
|
| 316 | + 'args' => array(true), |
|
| 317 | + 'capability' => 'ee_edit_registration', |
|
| 318 | + 'obj_id' => $reg_id, |
|
| 319 | + ), |
|
| 320 | + 'no_approve_registrations' => array( |
|
| 321 | + 'func' => 'bulk_action_on_registrations', |
|
| 322 | + 'noheader' => true, |
|
| 323 | + 'capability' => 'ee_edit_registrations', |
|
| 324 | + 'args' => array('no_approve') |
|
| 325 | + ), |
|
| 326 | + 'no_approve_and_notify_registrations' => array( |
|
| 327 | + 'func' => 'bulk_action_on_registrations', |
|
| 328 | + 'noheader' => true, |
|
| 329 | + 'capability' => 'ee_edit_registrations', |
|
| 330 | + 'args' => array('no_approve', true) |
|
| 331 | + ), |
|
| 332 | + 'cancel_registration' => array( |
|
| 333 | + 'func' => 'cancel_registration', |
|
| 334 | + 'noheader' => true, |
|
| 335 | + 'capability' => 'ee_edit_registration', |
|
| 336 | + 'obj_id' => $reg_id, |
|
| 337 | + ), |
|
| 338 | + 'cancel_and_notify_registration' => array( |
|
| 339 | + 'func' => 'cancel_registration', |
|
| 340 | + 'noheader' => true, |
|
| 341 | + 'args' => array(true), |
|
| 342 | + 'capability' => 'ee_edit_registration', |
|
| 343 | + 'obj_id' => $reg_id, |
|
| 344 | + ), |
|
| 345 | + 'cancel_registrations' => array( |
|
| 346 | + 'func' => 'bulk_action_on_registrations', |
|
| 347 | + 'noheader' => true, |
|
| 348 | + 'capability' => 'ee_edit_registrations', |
|
| 349 | + 'args' => array('cancel') |
|
| 350 | + ), |
|
| 351 | + 'cancel_and_notify_registrations' => array( |
|
| 352 | + 'func' => 'bulk_action_on_registrations', |
|
| 353 | + 'noheader' => true, |
|
| 354 | + 'capability' => 'ee_edit_registrations', |
|
| 355 | + 'args' => array('cancel', true) |
|
| 356 | + ), |
|
| 357 | + 'wait_list_registration' => array( |
|
| 358 | + 'func' => 'wait_list_registration', |
|
| 359 | + 'noheader' => true, |
|
| 360 | + 'capability' => 'ee_edit_registration', |
|
| 361 | + 'obj_id' => $reg_id, |
|
| 362 | + ), |
|
| 363 | + 'contact_list' => array( |
|
| 364 | + 'func' => '_attendee_contact_list_table', |
|
| 365 | + 'capability' => 'ee_read_contacts', |
|
| 366 | + ), |
|
| 367 | + 'add_new_attendee' => array( |
|
| 368 | + 'func' => '_create_new_cpt_item', |
|
| 369 | + 'args' => array( |
|
| 370 | + 'new_attendee' => true, |
|
| 371 | + 'capability' => 'ee_edit_contacts', |
|
| 372 | + ), |
|
| 373 | + ), |
|
| 374 | + 'edit_attendee' => array( |
|
| 375 | + 'func' => '_edit_cpt_item', |
|
| 376 | + 'capability' => 'ee_edit_contacts', |
|
| 377 | + 'obj_id' => $att_id, |
|
| 378 | + ), |
|
| 379 | + 'duplicate_attendee' => array( |
|
| 380 | + 'func' => '_duplicate_attendee', |
|
| 381 | + 'noheader' => true, |
|
| 382 | + 'capability' => 'ee_edit_contacts', |
|
| 383 | + 'obj_id' => $att_id, |
|
| 384 | + ), |
|
| 385 | + 'insert_attendee' => array( |
|
| 386 | + 'func' => '_insert_or_update_attendee', |
|
| 387 | + 'args' => array( |
|
| 388 | + 'new_attendee' => true, |
|
| 389 | + ), |
|
| 390 | + 'noheader' => true, |
|
| 391 | + 'capability' => 'ee_edit_contacts', |
|
| 392 | + ), |
|
| 393 | + 'update_attendee' => array( |
|
| 394 | + 'func' => '_insert_or_update_attendee', |
|
| 395 | + 'args' => array( |
|
| 396 | + 'new_attendee' => false, |
|
| 397 | + ), |
|
| 398 | + 'noheader' => true, |
|
| 399 | + 'capability' => 'ee_edit_contacts', |
|
| 400 | + 'obj_id' => $att_id, |
|
| 401 | + ), |
|
| 402 | + 'trash_attendees' => array( |
|
| 403 | + 'func' => '_trash_or_restore_attendees', |
|
| 404 | + 'args' => array( |
|
| 405 | + 'trash' => 'true' |
|
| 406 | + ), |
|
| 407 | + 'noheader' => true, |
|
| 408 | + 'capability' => 'ee_delete_contacts' |
|
| 409 | + ), |
|
| 410 | + 'trash_attendee' => array( |
|
| 411 | + 'func' => '_trash_or_restore_attendees', |
|
| 412 | + 'args' => array( |
|
| 413 | + 'trash' => true, |
|
| 414 | + ), |
|
| 415 | + 'noheader' => true, |
|
| 416 | + 'capability' => 'ee_delete_contacts', |
|
| 417 | + 'obj_id' => $att_id, |
|
| 418 | + ), |
|
| 419 | + 'restore_attendees' => array( |
|
| 420 | + 'func' => '_trash_or_restore_attendees', |
|
| 421 | + 'args' => array( |
|
| 422 | + 'trash' => false, |
|
| 423 | + ), |
|
| 424 | + 'noheader' => true, |
|
| 425 | + 'capability' => 'ee_delete_contacts', |
|
| 426 | + 'obj_id' => $att_id, |
|
| 427 | + ), |
|
| 428 | + 'resend_registration' => array( |
|
| 429 | + 'func' => '_resend_registration', |
|
| 430 | + 'noheader' => true, |
|
| 431 | + 'capability' => 'ee_send_message', |
|
| 432 | + ), |
|
| 433 | + 'registrations_report' => array( |
|
| 434 | + 'func' => '_registrations_report', |
|
| 435 | + 'noheader' => true, |
|
| 436 | + 'capability' => 'ee_read_registrations', |
|
| 437 | + ), |
|
| 438 | + 'contact_list_export' => array( |
|
| 439 | + 'func' => '_contact_list_export', |
|
| 440 | + 'noheader' => true, |
|
| 441 | + 'capability' => 'export', |
|
| 442 | + ), |
|
| 443 | + 'contact_list_report' => array( |
|
| 444 | + 'func' => '_contact_list_report', |
|
| 445 | + 'noheader' => true, |
|
| 446 | + 'capability' => 'ee_read_contacts', |
|
| 447 | + ), |
|
| 448 | + ); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + protected function _set_page_config() |
|
| 453 | + { |
|
| 454 | + $this->_page_config = array( |
|
| 455 | + 'default' => array( |
|
| 456 | + 'nav' => array( |
|
| 457 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 458 | + 'order' => 5, |
|
| 459 | + ), |
|
| 460 | + 'help_tabs' => array( |
|
| 461 | + 'registrations_overview_help_tab' => array( |
|
| 462 | + 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 463 | + 'filename' => 'registrations_overview', |
|
| 464 | + ), |
|
| 465 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 466 | + 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 467 | + 'filename' => 'registrations_overview_table_column_headings', |
|
| 468 | + ), |
|
| 469 | + 'registrations_overview_filters_help_tab' => array( |
|
| 470 | + 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 471 | + 'filename' => 'registrations_overview_filters', |
|
| 472 | + ), |
|
| 473 | + 'registrations_overview_views_help_tab' => array( |
|
| 474 | + 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 475 | + 'filename' => 'registrations_overview_views', |
|
| 476 | + ), |
|
| 477 | + 'registrations_regoverview_other_help_tab' => array( |
|
| 478 | + 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 479 | + 'filename' => 'registrations_overview_other', |
|
| 480 | + ), |
|
| 481 | + ), |
|
| 482 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 483 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 484 | + 'list_table' => 'EE_Registrations_List_Table', |
|
| 485 | + 'require_nonce' => false, |
|
| 486 | + ), |
|
| 487 | + 'view_registration' => array( |
|
| 488 | + 'nav' => array( |
|
| 489 | + 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 490 | + 'order' => 15, |
|
| 491 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
| 492 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 493 | + : $this->_admin_base_url, |
|
| 494 | + 'persistent' => false, |
|
| 495 | + ), |
|
| 496 | + 'help_tabs' => array( |
|
| 497 | + 'registrations_details_help_tab' => array( |
|
| 498 | + 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 499 | + 'filename' => 'registrations_details', |
|
| 500 | + ), |
|
| 501 | + 'registrations_details_table_help_tab' => array( |
|
| 502 | + 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 503 | + 'filename' => 'registrations_details_table', |
|
| 504 | + ), |
|
| 505 | + 'registrations_details_form_answers_help_tab' => array( |
|
| 506 | + 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 507 | + 'filename' => 'registrations_details_form_answers', |
|
| 508 | + ), |
|
| 509 | + 'registrations_details_registrant_details_help_tab' => array( |
|
| 510 | + 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 511 | + 'filename' => 'registrations_details_registrant_details', |
|
| 512 | + ), |
|
| 513 | + ), |
|
| 514 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 515 | + 'metaboxes' => array_merge( |
|
| 516 | + $this->_default_espresso_metaboxes, |
|
| 517 | + array('_registration_details_metaboxes') |
|
| 518 | + ), |
|
| 519 | + 'require_nonce' => false, |
|
| 520 | + ), |
|
| 521 | + 'new_registration' => array( |
|
| 522 | + 'nav' => array( |
|
| 523 | + 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 524 | + 'url' => '#', |
|
| 525 | + 'order' => 15, |
|
| 526 | + 'persistent' => false, |
|
| 527 | + ), |
|
| 528 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 529 | + 'labels' => array( |
|
| 530 | + 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 531 | + ), |
|
| 532 | + 'require_nonce' => false, |
|
| 533 | + ), |
|
| 534 | + 'add_new_attendee' => array( |
|
| 535 | + 'nav' => array( |
|
| 536 | + 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 537 | + 'order' => 15, |
|
| 538 | + 'persistent' => false, |
|
| 539 | + ), |
|
| 540 | + 'metaboxes' => array_merge( |
|
| 541 | + $this->_default_espresso_metaboxes, |
|
| 542 | + array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 543 | + ), |
|
| 544 | + 'require_nonce' => false, |
|
| 545 | + ), |
|
| 546 | + 'edit_attendee' => array( |
|
| 547 | + 'nav' => array( |
|
| 548 | + 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 549 | + 'order' => 15, |
|
| 550 | + 'persistent' => false, |
|
| 551 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
| 552 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 553 | + : $this->_admin_base_url, |
|
| 554 | + ), |
|
| 555 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 556 | + 'require_nonce' => false, |
|
| 557 | + ), |
|
| 558 | + 'contact_list' => array( |
|
| 559 | + 'nav' => array( |
|
| 560 | + 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 561 | + 'order' => 20, |
|
| 562 | + ), |
|
| 563 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 564 | + 'help_tabs' => array( |
|
| 565 | + 'registrations_contact_list_help_tab' => array( |
|
| 566 | + 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 567 | + 'filename' => 'registrations_contact_list', |
|
| 568 | + ), |
|
| 569 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 570 | + 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 571 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 572 | + ), |
|
| 573 | + 'registrations_contact_list_views_help_tab' => array( |
|
| 574 | + 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 575 | + 'filename' => 'registrations_contact_list_views', |
|
| 576 | + ), |
|
| 577 | + 'registrations_contact_list_other_help_tab' => array( |
|
| 578 | + 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 579 | + 'filename' => 'registrations_contact_list_other', |
|
| 580 | + ), |
|
| 581 | + ), |
|
| 582 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 583 | + 'metaboxes' => array(), |
|
| 584 | + 'require_nonce' => false, |
|
| 585 | + ), |
|
| 586 | + //override default cpt routes |
|
| 587 | + 'create_new' => '', |
|
| 588 | + 'edit' => '', |
|
| 589 | + ); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * The below methods aren't used by this class currently |
|
| 595 | + */ |
|
| 596 | + protected function _add_screen_options() |
|
| 597 | + { |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + |
|
| 601 | + protected function _add_feature_pointers() |
|
| 602 | + { |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + |
|
| 606 | + public function admin_init() |
|
| 607 | + { |
|
| 608 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 609 | + 'click "Update Registration Questions" to save your changes', |
|
| 610 | + 'event_espresso' |
|
| 611 | + ); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + public function admin_notices() |
|
| 616 | + { |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + |
|
| 620 | + public function admin_footer_scripts() |
|
| 621 | + { |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + |
|
| 625 | + /** |
|
| 626 | + * get list of registration statuses |
|
| 627 | + * |
|
| 628 | + * @access private |
|
| 629 | + * @return void |
|
| 630 | + */ |
|
| 631 | + private function _get_registration_status_array() |
|
| 632 | + { |
|
| 633 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + |
|
| 637 | + protected function _add_screen_options_default() |
|
| 638 | + { |
|
| 639 | + $this->_per_page_screen_option(); |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + |
|
| 643 | + protected function _add_screen_options_contact_list() |
|
| 644 | + { |
|
| 645 | + $page_title = $this->_admin_page_title; |
|
| 646 | + $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 647 | + $this->_per_page_screen_option(); |
|
| 648 | + $this->_admin_page_title = $page_title; |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + public function load_scripts_styles() |
|
| 653 | + { |
|
| 654 | + //style |
|
| 655 | + wp_register_style( |
|
| 656 | + 'espresso_reg', |
|
| 657 | + REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 658 | + array('ee-admin-css'), |
|
| 659 | + EVENT_ESPRESSO_VERSION |
|
| 660 | + ); |
|
| 661 | + wp_enqueue_style('espresso_reg'); |
|
| 662 | + //script |
|
| 663 | + wp_register_script( |
|
| 664 | + 'espresso_reg', |
|
| 665 | + REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 666 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 667 | + EVENT_ESPRESSO_VERSION, |
|
| 668 | + true |
|
| 669 | + ); |
|
| 670 | + wp_enqueue_script('espresso_reg'); |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + |
|
| 674 | + public function load_scripts_styles_edit_attendee() |
|
| 675 | + { |
|
| 676 | + //stuff to only show up on our attendee edit details page. |
|
| 677 | + $attendee_details_translations = array( |
|
| 678 | + 'att_publish_text' => sprintf( |
|
| 679 | + esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 680 | + $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 681 | + ), |
|
| 682 | + ); |
|
| 683 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 684 | + wp_enqueue_script('jquery-validate'); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + |
|
| 688 | + public function load_scripts_styles_view_registration() |
|
| 689 | + { |
|
| 690 | + //styles |
|
| 691 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 692 | + //scripts |
|
| 693 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 694 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + |
|
| 698 | + public function load_scripts_styles_contact_list() |
|
| 699 | + { |
|
| 700 | + wp_deregister_style('espresso_reg'); |
|
| 701 | + wp_register_style( |
|
| 702 | + 'espresso_att', |
|
| 703 | + REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 704 | + array('ee-admin-css'), |
|
| 705 | + EVENT_ESPRESSO_VERSION |
|
| 706 | + ); |
|
| 707 | + wp_enqueue_style('espresso_att'); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + |
|
| 711 | + public function load_scripts_styles_new_registration() |
|
| 712 | + { |
|
| 713 | + wp_register_script( |
|
| 714 | + 'ee-spco-for-admin', |
|
| 715 | + REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 716 | + array('underscore', 'jquery'), |
|
| 717 | + EVENT_ESPRESSO_VERSION, |
|
| 718 | + true |
|
| 719 | + ); |
|
| 720 | + wp_enqueue_script('ee-spco-for-admin'); |
|
| 721 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 722 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 723 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 724 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + |
|
| 728 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 729 | + { |
|
| 730 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + |
|
| 734 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 735 | + { |
|
| 736 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + |
|
| 740 | + protected function _set_list_table_views_default() |
|
| 741 | + { |
|
| 742 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 743 | + EED_Messages::set_autoloaders(); |
|
| 744 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 745 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 746 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 747 | + //key= bulk_action_slug, value= message type. |
|
| 748 | + $match_array = array( |
|
| 749 | + 'approve_registrations' => 'registration', |
|
| 750 | + 'decline_registrations' => 'declined_registration', |
|
| 751 | + 'pending_registrations' => 'pending_approval', |
|
| 752 | + 'no_approve_registrations' => 'not_approved_registration', |
|
| 753 | + 'cancel_registrations' => 'cancelled_registration', |
|
| 754 | + ); |
|
| 755 | + $can_send = EE_Registry::instance()->CAP->current_user_can( |
|
| 756 | + 'ee_send_message', |
|
| 757 | + 'batch_send_messages' |
|
| 758 | + ); |
|
| 759 | + /** setup reg status bulk actions **/ |
|
| 760 | + $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 761 | + if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) { |
|
| 762 | + $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__( |
|
| 763 | + 'Approve and Notify Registrations', |
|
| 764 | + 'event_espresso' |
|
| 765 | + ); |
|
| 766 | + } |
|
| 767 | + $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 768 | + if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) { |
|
| 769 | + $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__( |
|
| 770 | + 'Decline and Notify Registrations', |
|
| 771 | + 'event_espresso' |
|
| 772 | + ); |
|
| 773 | + } |
|
| 774 | + $def_reg_status_actions['pending_registrations'] = esc_html__( |
|
| 775 | + 'Set Registrations to Pending Payment', |
|
| 776 | + 'event_espresso' |
|
| 777 | + ); |
|
| 778 | + if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) { |
|
| 779 | + $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__( |
|
| 780 | + 'Set Registrations to Pending Payment and Notify', |
|
| 781 | + 'event_espresso' |
|
| 782 | + ); |
|
| 783 | + } |
|
| 784 | + $def_reg_status_actions['no_approve_registrations'] = esc_html__( |
|
| 785 | + 'Set Registrations to Not Approved', |
|
| 786 | + 'event_espresso' |
|
| 787 | + ); |
|
| 788 | + if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) { |
|
| 789 | + $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__( |
|
| 790 | + 'Set Registrations to Not Approved and Notify', |
|
| 791 | + 'event_espresso' |
|
| 792 | + ); |
|
| 793 | + } |
|
| 794 | + $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 795 | + if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) { |
|
| 796 | + $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__( |
|
| 797 | + 'Cancel Registrations and Notify', |
|
| 798 | + 'event_espresso' |
|
| 799 | + ); |
|
| 800 | + } |
|
| 801 | + $def_reg_status_actions = apply_filters( |
|
| 802 | + 'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array', |
|
| 803 | + $def_reg_status_actions, |
|
| 804 | + $active_mts |
|
| 805 | + ); |
|
| 806 | + |
|
| 807 | + $this->_views = array( |
|
| 808 | + 'all' => array( |
|
| 809 | + 'slug' => 'all', |
|
| 810 | + 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 811 | + 'count' => 0, |
|
| 812 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 813 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 814 | + )), |
|
| 815 | + ), |
|
| 816 | + 'month' => array( |
|
| 817 | + 'slug' => 'month', |
|
| 818 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 819 | + 'count' => 0, |
|
| 820 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 821 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 822 | + )), |
|
| 823 | + ), |
|
| 824 | + 'today' => array( |
|
| 825 | + 'slug' => 'today', |
|
| 826 | + 'label' => sprintf( |
|
| 827 | + esc_html__('Today - %s', 'event_espresso'), |
|
| 828 | + date('M d, Y', current_time('timestamp')) |
|
| 829 | + ), |
|
| 830 | + 'count' => 0, |
|
| 831 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 832 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 833 | + )), |
|
| 834 | + ), |
|
| 835 | + ); |
|
| 836 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 837 | + 'ee_delete_registrations', |
|
| 838 | + 'espresso_registrations_delete_registration' |
|
| 839 | + )) { |
|
| 840 | + $this->_views['incomplete'] = array( |
|
| 841 | + 'slug' => 'incomplete', |
|
| 842 | + 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 843 | + 'count' => 0, |
|
| 844 | + 'bulk_action' => array( |
|
| 845 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 846 | + ), |
|
| 847 | + ); |
|
| 848 | + $this->_views['trash'] = array( |
|
| 849 | + 'slug' => 'trash', |
|
| 850 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 851 | + 'count' => 0, |
|
| 852 | + 'bulk_action' => array( |
|
| 853 | + 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 854 | + 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 855 | + ), |
|
| 856 | + ); |
|
| 857 | + } |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + |
|
| 861 | + protected function _set_list_table_views_contact_list() |
|
| 862 | + { |
|
| 863 | + $this->_views = array( |
|
| 864 | + 'in_use' => array( |
|
| 865 | + 'slug' => 'in_use', |
|
| 866 | + 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 867 | + 'count' => 0, |
|
| 868 | + 'bulk_action' => array( |
|
| 869 | + 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 870 | + ), |
|
| 871 | + ), |
|
| 872 | + ); |
|
| 873 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 874 | + 'espresso_registrations_trash_attendees') |
|
| 875 | + ) { |
|
| 876 | + $this->_views['trash'] = array( |
|
| 877 | + 'slug' => 'trash', |
|
| 878 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 879 | + 'count' => 0, |
|
| 880 | + 'bulk_action' => array( |
|
| 881 | + 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 882 | + ), |
|
| 883 | + ); |
|
| 884 | + } |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + |
|
| 888 | + protected function _registration_legend_items() |
|
| 889 | + { |
|
| 890 | + $fc_items = array( |
|
| 891 | + 'star-icon' => array( |
|
| 892 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 893 | + 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 894 | + ), |
|
| 895 | + 'view_details' => array( |
|
| 896 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 897 | + 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 898 | + ), |
|
| 899 | + 'edit_attendee' => array( |
|
| 900 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 901 | + 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 902 | + ), |
|
| 903 | + 'view_transaction' => array( |
|
| 904 | + 'class' => 'dashicons dashicons-cart', |
|
| 905 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 906 | + ), |
|
| 907 | + 'view_invoice' => array( |
|
| 908 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 909 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 910 | + ), |
|
| 911 | + ); |
|
| 912 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 913 | + 'ee_send_message', |
|
| 914 | + 'espresso_registrations_resend_registration' |
|
| 915 | + )) { |
|
| 916 | + $fc_items['resend_registration'] = array( |
|
| 917 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 918 | + 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 919 | + ); |
|
| 920 | + } else { |
|
| 921 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 922 | + } |
|
| 923 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 924 | + 'ee_read_global_messages', |
|
| 925 | + 'view_filtered_messages' |
|
| 926 | + )) { |
|
| 927 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 928 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 929 | + $fc_items['view_related_messages'] = array( |
|
| 930 | + 'class' => $related_for_icon['css_class'], |
|
| 931 | + 'desc' => $related_for_icon['label'], |
|
| 932 | + ); |
|
| 933 | + } |
|
| 934 | + } |
|
| 935 | + $sc_items = array( |
|
| 936 | + 'approved_status' => array( |
|
| 937 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 938 | + 'desc' => EEH_Template::pretty_status( |
|
| 939 | + EEM_Registration::status_id_approved, |
|
| 940 | + false, |
|
| 941 | + 'sentence' |
|
| 942 | + ), |
|
| 943 | + ), |
|
| 944 | + 'pending_status' => array( |
|
| 945 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 946 | + 'desc' => EEH_Template::pretty_status( |
|
| 947 | + EEM_Registration::status_id_pending_payment, |
|
| 948 | + false, |
|
| 949 | + 'sentence' |
|
| 950 | + ), |
|
| 951 | + ), |
|
| 952 | + 'wait_list' => array( |
|
| 953 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 954 | + 'desc' => EEH_Template::pretty_status( |
|
| 955 | + EEM_Registration::status_id_wait_list, |
|
| 956 | + false, |
|
| 957 | + 'sentence' |
|
| 958 | + ), |
|
| 959 | + ), |
|
| 960 | + 'incomplete_status' => array( |
|
| 961 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 962 | + 'desc' => EEH_Template::pretty_status( |
|
| 963 | + EEM_Registration::status_id_incomplete, |
|
| 964 | + false, |
|
| 965 | + 'sentence' |
|
| 966 | + ), |
|
| 967 | + ), |
|
| 968 | + 'not_approved' => array( |
|
| 969 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 970 | + 'desc' => EEH_Template::pretty_status( |
|
| 971 | + EEM_Registration::status_id_not_approved, |
|
| 972 | + false, |
|
| 973 | + 'sentence' |
|
| 974 | + ), |
|
| 975 | + ), |
|
| 976 | + 'declined_status' => array( |
|
| 977 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 978 | + 'desc' => EEH_Template::pretty_status( |
|
| 979 | + EEM_Registration::status_id_declined, |
|
| 980 | + false, |
|
| 981 | + 'sentence' |
|
| 982 | + ), |
|
| 983 | + ), |
|
| 984 | + 'cancelled_status' => array( |
|
| 985 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 986 | + 'desc' => EEH_Template::pretty_status( |
|
| 987 | + EEM_Registration::status_id_cancelled, |
|
| 988 | + false, |
|
| 989 | + 'sentence' |
|
| 990 | + ), |
|
| 991 | + ), |
|
| 992 | + ); |
|
| 993 | + return array_merge($fc_items, $sc_items); |
|
| 994 | + } |
|
| 995 | + |
|
| 996 | + |
|
| 997 | + |
|
| 998 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 999 | + /** |
|
| 1000 | + * @throws \EE_Error |
|
| 1001 | + */ |
|
| 1002 | + protected function _registrations_overview_list_table() |
|
| 1003 | + { |
|
| 1004 | + $this->_template_args['admin_page_header'] = ''; |
|
| 1005 | + $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 1006 | + ? absint($this->_req_data['event_id']) |
|
| 1007 | + : 0; |
|
| 1008 | + if ($EVT_ID) { |
|
| 1009 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1010 | + 'ee_edit_registrations', |
|
| 1011 | + 'espresso_registrations_new_registration', |
|
| 1012 | + $EVT_ID |
|
| 1013 | + )) { |
|
| 1014 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 1015 | + 'new_registration', |
|
| 1016 | + 'add-registrant', |
|
| 1017 | + array('event_id' => $EVT_ID), |
|
| 1018 | + 'add-new-h2' |
|
| 1019 | + ); |
|
| 1020 | + } |
|
| 1021 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 1022 | + if ($event instanceof EE_Event) { |
|
| 1023 | + $this->_template_args['admin_page_header'] = sprintf( |
|
| 1024 | + esc_html__( |
|
| 1025 | + '%s Viewing registrations for the event: %s%s', |
|
| 1026 | + 'event_espresso' |
|
| 1027 | + ), |
|
| 1028 | + '<h3 style="line-height:1.5em;">', |
|
| 1029 | + '<br /><a href="' |
|
| 1030 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
| 1031 | + array( |
|
| 1032 | + 'action' => 'edit', |
|
| 1033 | + 'post' => $event->ID(), |
|
| 1034 | + ), |
|
| 1035 | + EVENTS_ADMIN_URL |
|
| 1036 | + ) |
|
| 1037 | + . '"> ' |
|
| 1038 | + . $event->get('EVT_name') |
|
| 1039 | + . ' </a> ', |
|
| 1040 | + '</h3>' |
|
| 1041 | + ); |
|
| 1042 | + } |
|
| 1043 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 1044 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1045 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 1046 | + $this->_template_args['admin_page_header'] = substr( |
|
| 1047 | + $this->_template_args['admin_page_header'], |
|
| 1048 | + 0, |
|
| 1049 | + -5 |
|
| 1050 | + ); |
|
| 1051 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 1052 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1053 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 1054 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 1055 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 1056 | + } |
|
| 1057 | + } |
|
| 1058 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 1059 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1060 | + } |
|
| 1061 | + |
|
| 1062 | + |
|
| 1063 | + /** |
|
| 1064 | + * This sets the _registration property for the registration details screen |
|
| 1065 | + * |
|
| 1066 | + * @access private |
|
| 1067 | + * @return bool |
|
| 1068 | + */ |
|
| 1069 | + private function _set_registration_object() |
|
| 1070 | + { |
|
| 1071 | + //get out if we've already set the object |
|
| 1072 | + if (is_object($this->_registration)) { |
|
| 1073 | + return true; |
|
| 1074 | + } |
|
| 1075 | + $REG = EEM_Registration::instance(); |
|
| 1076 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1077 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1078 | + return true; |
|
| 1079 | + } else { |
|
| 1080 | + $error_msg = sprintf( |
|
| 1081 | + esc_html__( |
|
| 1082 | + 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1083 | + 'event_espresso' |
|
| 1084 | + ), |
|
| 1085 | + $REG_ID |
|
| 1086 | + ); |
|
| 1087 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1088 | + $this->_registration = null; |
|
| 1089 | + return false; |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1092 | + |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * Used to retrieve registrations for the list table. |
|
| 1096 | + * |
|
| 1097 | + * @param int $per_page |
|
| 1098 | + * @param bool $count |
|
| 1099 | + * @param bool $this_month |
|
| 1100 | + * @param bool $today |
|
| 1101 | + * @return EE_Registration[]|int |
|
| 1102 | + * @throws EE_Error |
|
| 1103 | + */ |
|
| 1104 | + public function get_registrations( |
|
| 1105 | + $per_page = 10, |
|
| 1106 | + $count = false, |
|
| 1107 | + $this_month = false, |
|
| 1108 | + $today = false |
|
| 1109 | + ) { |
|
| 1110 | + if ($this_month) { |
|
| 1111 | + $this->_req_data['status'] = 'month'; |
|
| 1112 | + } |
|
| 1113 | + if ($today) { |
|
| 1114 | + $this->_req_data['status'] = 'today'; |
|
| 1115 | + } |
|
| 1116 | + $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1117 | + /** |
|
| 1118 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1119 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1120 | + * @see EEM_Base::get_all() |
|
| 1121 | + */ |
|
| 1122 | + $query_params['group_by'] = ''; |
|
| 1123 | + |
|
| 1124 | + return $count |
|
| 1125 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1126 | + /** @type EE_Registration[] */ |
|
| 1127 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1134 | + * Note: this listens to values on the request for some of the query parameters. |
|
| 1135 | + * |
|
| 1136 | + * @param array $request |
|
| 1137 | + * @param int $per_page |
|
| 1138 | + * @param bool $count |
|
| 1139 | + * @return array |
|
| 1140 | + */ |
|
| 1141 | + protected function _get_registration_query_parameters( |
|
| 1142 | + $request = array(), |
|
| 1143 | + $per_page = 10, |
|
| 1144 | + $count = false |
|
| 1145 | + ) { |
|
| 1146 | + |
|
| 1147 | + $query_params = array( |
|
| 1148 | + 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1149 | + $request |
|
| 1150 | + ), |
|
| 1151 | + 'caps' => EEM_Registration::caps_read_admin, |
|
| 1152 | + 'default_where_conditions' => 'this_model_only', |
|
| 1153 | + ); |
|
| 1154 | + if (! $count) { |
|
| 1155 | + $query_params = array_merge( |
|
| 1156 | + $query_params, |
|
| 1157 | + $this->_get_orderby_for_registrations_query(), |
|
| 1158 | + $this->_get_limit($per_page) |
|
| 1159 | + ); |
|
| 1160 | + } |
|
| 1161 | + |
|
| 1162 | + return $query_params; |
|
| 1163 | + } |
|
| 1164 | + |
|
| 1165 | + |
|
| 1166 | + /** |
|
| 1167 | + * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1168 | + * |
|
| 1169 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1170 | + * @return array |
|
| 1171 | + */ |
|
| 1172 | + protected function _add_event_id_to_where_conditions(array $request) |
|
| 1173 | + { |
|
| 1174 | + $where = array(); |
|
| 1175 | + if (! empty($request['event_id'])) { |
|
| 1176 | + $where['EVT_ID'] = absint($request['event_id']); |
|
| 1177 | + } |
|
| 1178 | + return $where; |
|
| 1179 | + } |
|
| 1180 | + |
|
| 1181 | + |
|
| 1182 | + /** |
|
| 1183 | + * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1184 | + * |
|
| 1185 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1186 | + * @return array |
|
| 1187 | + */ |
|
| 1188 | + protected function _add_category_id_to_where_conditions(array $request) |
|
| 1189 | + { |
|
| 1190 | + $where = array(); |
|
| 1191 | + if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1192 | + $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1193 | + } |
|
| 1194 | + return $where; |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + |
|
| 1198 | + /** |
|
| 1199 | + * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1200 | + * |
|
| 1201 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1202 | + * @return array |
|
| 1203 | + */ |
|
| 1204 | + protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1205 | + { |
|
| 1206 | + $where = array(); |
|
| 1207 | + if (! empty($request['datetime_id'])) { |
|
| 1208 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1209 | + } |
|
| 1210 | + if (! empty($request['DTT_ID'])) { |
|
| 1211 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1212 | + } |
|
| 1213 | + return $where; |
|
| 1214 | + } |
|
| 1215 | + |
|
| 1216 | + |
|
| 1217 | + /** |
|
| 1218 | + * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1219 | + * |
|
| 1220 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1221 | + * @return array |
|
| 1222 | + */ |
|
| 1223 | + protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1224 | + { |
|
| 1225 | + $where = array(); |
|
| 1226 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1227 | + $registration_status = ! empty($request['_reg_status']) |
|
| 1228 | + ? sanitize_text_field($request['_reg_status']) |
|
| 1229 | + : ''; |
|
| 1230 | + |
|
| 1231 | + /* |
|
| 1232 | 1232 | * If filtering by registration status, then we show registrations matching that status. |
| 1233 | 1233 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations |
| 1234 | 1234 | * UNLESS viewing trashed registrations. |
| 1235 | 1235 | */ |
| 1236 | - if (! empty($registration_status)) { |
|
| 1237 | - $where['STS_ID'] = $registration_status; |
|
| 1238 | - } else { |
|
| 1239 | - //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1240 | - if ($view === 'trash') { |
|
| 1241 | - $where['REG_deleted'] = true; |
|
| 1242 | - } elseif ($view === 'incomplete') { |
|
| 1243 | - $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1244 | - } else { |
|
| 1245 | - $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1246 | - } |
|
| 1247 | - } |
|
| 1248 | - return $where; |
|
| 1249 | - } |
|
| 1250 | - |
|
| 1251 | - |
|
| 1252 | - /** |
|
| 1253 | - * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1254 | - * |
|
| 1255 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1256 | - * @return array |
|
| 1257 | - * @throws EE_Error |
|
| 1258 | - */ |
|
| 1259 | - protected function _add_date_to_where_conditions(array $request) |
|
| 1260 | - { |
|
| 1261 | - $where = array(); |
|
| 1262 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1263 | - $month_range = ! empty($request['month_range']) |
|
| 1264 | - ? sanitize_text_field($request['month_range']) |
|
| 1265 | - : ''; |
|
| 1266 | - $retrieve_for_today = $view === 'today'; |
|
| 1267 | - $retrieve_for_this_month = $view === 'month'; |
|
| 1268 | - |
|
| 1269 | - if ($retrieve_for_today) { |
|
| 1270 | - $now = date('Y-m-d', current_time('timestamp')); |
|
| 1271 | - $where['REG_date'] = array( |
|
| 1272 | - 'BETWEEN', |
|
| 1273 | - array( |
|
| 1274 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1275 | - 'REG_date', |
|
| 1276 | - $now . ' 00:00:00', |
|
| 1277 | - 'Y-m-d H:i:s' |
|
| 1278 | - ), |
|
| 1279 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1280 | - 'REG_date', |
|
| 1281 | - $now . ' 23:59:59', |
|
| 1282 | - 'Y-m-d H:i:s' |
|
| 1283 | - ), |
|
| 1284 | - ), |
|
| 1285 | - ); |
|
| 1286 | - } elseif ($retrieve_for_this_month) { |
|
| 1287 | - $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1288 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 1289 | - $where['REG_date'] = array( |
|
| 1290 | - 'BETWEEN', |
|
| 1291 | - array( |
|
| 1292 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1293 | - 'REG_date', |
|
| 1294 | - $current_year_and_month . '-01 00:00:00', |
|
| 1295 | - 'Y-m-d H:i:s' |
|
| 1296 | - ), |
|
| 1297 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1298 | - 'REG_date', |
|
| 1299 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1300 | - 'Y-m-d H:i:s' |
|
| 1301 | - ), |
|
| 1302 | - ), |
|
| 1303 | - ); |
|
| 1304 | - } elseif ($month_range) { |
|
| 1305 | - $pieces = explode(' ', $month_range, 3); |
|
| 1306 | - $month_requested = ! empty($pieces[0]) |
|
| 1307 | - ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1308 | - : ''; |
|
| 1309 | - $year_requested = ! empty($pieces[1]) |
|
| 1310 | - ? $pieces[1] |
|
| 1311 | - : ''; |
|
| 1312 | - //if there is not a month or year then we can't go further |
|
| 1313 | - if ($month_requested && $year_requested) { |
|
| 1314 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1315 | - $where['REG_date'] = array( |
|
| 1316 | - 'BETWEEN', |
|
| 1317 | - array( |
|
| 1318 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1319 | - 'REG_date', |
|
| 1320 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1321 | - 'Y-m-d H:i:s' |
|
| 1322 | - ), |
|
| 1323 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1324 | - 'REG_date', |
|
| 1325 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1326 | - 'Y-m-d H:i:s' |
|
| 1327 | - ), |
|
| 1328 | - ), |
|
| 1329 | - ); |
|
| 1330 | - } |
|
| 1331 | - } |
|
| 1332 | - return $where; |
|
| 1333 | - } |
|
| 1334 | - |
|
| 1335 | - |
|
| 1336 | - /** |
|
| 1337 | - * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1338 | - * |
|
| 1339 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1340 | - * @return array |
|
| 1341 | - */ |
|
| 1342 | - protected function _add_search_to_where_conditions(array $request) |
|
| 1343 | - { |
|
| 1344 | - $where = array(); |
|
| 1345 | - if (! empty($request['s'])) { |
|
| 1346 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1347 | - $where['OR*search_conditions'] = array( |
|
| 1348 | - 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1349 | - 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1350 | - 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1351 | - 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1352 | - 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1353 | - 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1354 | - 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1355 | - 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1356 | - 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1357 | - 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1358 | - 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1359 | - 'REG_final_price' => array('LIKE', $search_string), |
|
| 1360 | - 'REG_code' => array('LIKE', $search_string), |
|
| 1361 | - 'REG_count' => array('LIKE', $search_string), |
|
| 1362 | - 'REG_group_size' => array('LIKE', $search_string), |
|
| 1363 | - 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1364 | - 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1365 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1366 | - ); |
|
| 1367 | - } |
|
| 1368 | - return $where; |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - |
|
| 1372 | - /** |
|
| 1373 | - * Sets up the where conditions for the registrations query. |
|
| 1374 | - * |
|
| 1375 | - * @param array $request |
|
| 1376 | - * @return array |
|
| 1377 | - * @throws EE_Error |
|
| 1378 | - */ |
|
| 1379 | - protected function _get_where_conditions_for_registrations_query($request) |
|
| 1380 | - { |
|
| 1381 | - return apply_filters( |
|
| 1382 | - 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1383 | - array_merge( |
|
| 1384 | - $this->_add_event_id_to_where_conditions($request), |
|
| 1385 | - $this->_add_category_id_to_where_conditions($request), |
|
| 1386 | - $this->_add_datetime_id_to_where_conditions($request), |
|
| 1387 | - $this->_add_registration_status_to_where_conditions($request), |
|
| 1388 | - $this->_add_date_to_where_conditions($request), |
|
| 1389 | - $this->_add_search_to_where_conditions($request) |
|
| 1390 | - ), |
|
| 1391 | - $request |
|
| 1392 | - ); |
|
| 1393 | - } |
|
| 1394 | - |
|
| 1395 | - |
|
| 1396 | - /** |
|
| 1397 | - * Sets up the orderby for the registrations query. |
|
| 1398 | - * |
|
| 1399 | - * @return array |
|
| 1400 | - */ |
|
| 1401 | - protected function _get_orderby_for_registrations_query() |
|
| 1402 | - { |
|
| 1403 | - $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1404 | - ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1405 | - : ''; |
|
| 1406 | - switch ($orderby_field) { |
|
| 1407 | - case '_REG_ID': |
|
| 1408 | - $orderby_field = 'REG_ID'; |
|
| 1409 | - break; |
|
| 1410 | - case '_Reg_status': |
|
| 1411 | - $orderby_field = 'STS_ID'; |
|
| 1412 | - break; |
|
| 1413 | - case 'ATT_fname': |
|
| 1414 | - $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1415 | - break; |
|
| 1416 | - case 'ATT_lname': |
|
| 1417 | - $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1418 | - break; |
|
| 1419 | - case 'event_name': |
|
| 1420 | - $orderby_field = 'Event.EVT_name'; |
|
| 1421 | - break; |
|
| 1422 | - case 'DTT_EVT_start': |
|
| 1423 | - $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1424 | - break; |
|
| 1425 | - default: //'REG_date' |
|
| 1426 | - $orderby_field = 'REG_date'; |
|
| 1427 | - } |
|
| 1428 | - |
|
| 1429 | - //order |
|
| 1430 | - $order = ! empty($this->_req_data['order']) |
|
| 1431 | - ? sanitize_text_field($this->_req_data['order']) |
|
| 1432 | - : 'DESC'; |
|
| 1433 | - |
|
| 1434 | - //mutate orderby_field |
|
| 1435 | - $orderby_field = array_combine( |
|
| 1436 | - (array) $orderby_field, |
|
| 1437 | - array_fill(0, count($orderby_field), $order) |
|
| 1438 | - ); |
|
| 1439 | - return array('order_by' => $orderby_field); |
|
| 1440 | - } |
|
| 1441 | - |
|
| 1442 | - |
|
| 1443 | - /** |
|
| 1444 | - * Sets up the limit for the registrations query. |
|
| 1445 | - * |
|
| 1446 | - * @param $per_page |
|
| 1447 | - * @return array |
|
| 1448 | - */ |
|
| 1449 | - protected function _get_limit($per_page) |
|
| 1450 | - { |
|
| 1451 | - $current_page = ! empty($this->_req_data['paged']) |
|
| 1452 | - ? absint($this->_req_data['paged']) |
|
| 1453 | - : 1; |
|
| 1454 | - $per_page = ! empty($this->_req_data['perpage']) |
|
| 1455 | - ? $this->_req_data['perpage'] |
|
| 1456 | - : $per_page; |
|
| 1457 | - |
|
| 1458 | - //-1 means return all results so get out if that's set. |
|
| 1459 | - if ((int)$per_page === -1) { |
|
| 1460 | - return array(); |
|
| 1461 | - } |
|
| 1462 | - $per_page = absint($per_page); |
|
| 1463 | - $offset = ($current_page - 1) * $per_page; |
|
| 1464 | - return array('limit' => array($offset, $per_page)); |
|
| 1465 | - } |
|
| 1466 | - |
|
| 1467 | - |
|
| 1468 | - public function get_registration_status_array() |
|
| 1469 | - { |
|
| 1470 | - return self::$_reg_status; |
|
| 1471 | - } |
|
| 1472 | - |
|
| 1473 | - |
|
| 1474 | - |
|
| 1475 | - |
|
| 1476 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1477 | - /** |
|
| 1478 | - * generates HTML for the View Registration Details Admin page |
|
| 1479 | - * |
|
| 1480 | - * @access protected |
|
| 1481 | - * @return void |
|
| 1482 | - * @throws DomainException |
|
| 1483 | - * @throws EE_Error |
|
| 1484 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1485 | - */ |
|
| 1486 | - protected function _registration_details() |
|
| 1487 | - { |
|
| 1488 | - $this->_template_args = array(); |
|
| 1489 | - $this->_set_registration_object(); |
|
| 1490 | - if (is_object($this->_registration)) { |
|
| 1491 | - $transaction = $this->_registration->transaction() |
|
| 1492 | - ? $this->_registration->transaction() |
|
| 1493 | - : EE_Transaction::new_instance(); |
|
| 1494 | - $this->_session = $transaction->session_data(); |
|
| 1495 | - $event_id = $this->_registration->event_ID(); |
|
| 1496 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1497 | - $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1498 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1499 | - $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1500 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1501 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1502 | - // link back to overview |
|
| 1503 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1504 | - $this->_template_args['registration'] = $this->_registration; |
|
| 1505 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1506 | - array( |
|
| 1507 | - 'action' => 'default', |
|
| 1508 | - 'event_id' => $event_id, |
|
| 1509 | - ), |
|
| 1510 | - REG_ADMIN_URL |
|
| 1511 | - ); |
|
| 1512 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1513 | - array( |
|
| 1514 | - 'action' => 'default', |
|
| 1515 | - 'EVT_ID' => $event_id, |
|
| 1516 | - 'page' => 'espresso_transactions', |
|
| 1517 | - ), |
|
| 1518 | - admin_url('admin.php') |
|
| 1519 | - ); |
|
| 1520 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1521 | - array( |
|
| 1522 | - 'page' => 'espresso_events', |
|
| 1523 | - 'action' => 'edit', |
|
| 1524 | - 'post' => $event_id, |
|
| 1525 | - ), |
|
| 1526 | - admin_url('admin.php') |
|
| 1527 | - ); |
|
| 1528 | - //next and previous links |
|
| 1529 | - $next_reg = $this->_registration->next( |
|
| 1530 | - null, |
|
| 1531 | - array(), |
|
| 1532 | - 'REG_ID' |
|
| 1533 | - ); |
|
| 1534 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1535 | - ? $this->_next_link( |
|
| 1536 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1537 | - array( |
|
| 1538 | - 'action' => 'view_registration', |
|
| 1539 | - '_REG_ID' => $next_reg['REG_ID'], |
|
| 1540 | - ), |
|
| 1541 | - REG_ADMIN_URL |
|
| 1542 | - ), |
|
| 1543 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1544 | - ) |
|
| 1545 | - : ''; |
|
| 1546 | - $previous_reg = $this->_registration->previous( |
|
| 1547 | - null, |
|
| 1548 | - array(), |
|
| 1549 | - 'REG_ID' |
|
| 1550 | - ); |
|
| 1551 | - $this->_template_args['previous_registration'] = $previous_reg |
|
| 1552 | - ? $this->_previous_link( |
|
| 1553 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1554 | - array( |
|
| 1555 | - 'action' => 'view_registration', |
|
| 1556 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1557 | - ), |
|
| 1558 | - REG_ADMIN_URL |
|
| 1559 | - ), |
|
| 1560 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1561 | - ) |
|
| 1562 | - : ''; |
|
| 1563 | - // grab header |
|
| 1564 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1565 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1566 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1567 | - $template_path, |
|
| 1568 | - $this->_template_args, |
|
| 1569 | - true |
|
| 1570 | - ); |
|
| 1571 | - } else { |
|
| 1572 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1573 | - } |
|
| 1574 | - // the details template wrapper |
|
| 1575 | - $this->display_admin_page_with_sidebar(); |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - |
|
| 1579 | - protected function _registration_details_metaboxes() |
|
| 1580 | - { |
|
| 1581 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1582 | - $this->_set_registration_object(); |
|
| 1583 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1584 | - add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1585 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1586 | - add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1587 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1588 | - if ($attendee instanceof EE_Attendee |
|
| 1589 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1590 | - 'ee_edit_registration', |
|
| 1591 | - 'edit-reg-questions-mbox', |
|
| 1592 | - $this->_registration->ID() |
|
| 1593 | - ) |
|
| 1594 | - ) { |
|
| 1595 | - add_meta_box( |
|
| 1596 | - 'edit-reg-questions-mbox', |
|
| 1597 | - esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1598 | - array($this, '_reg_questions_meta_box'), |
|
| 1599 | - $this->wp_page_slug, |
|
| 1600 | - 'normal', |
|
| 1601 | - 'high' |
|
| 1602 | - ); |
|
| 1603 | - } |
|
| 1604 | - add_meta_box( |
|
| 1605 | - 'edit-reg-registrant-mbox', |
|
| 1606 | - esc_html__('Contact Details', 'event_espresso'), |
|
| 1607 | - array($this, '_reg_registrant_side_meta_box'), |
|
| 1608 | - $this->wp_page_slug, |
|
| 1609 | - 'side', |
|
| 1610 | - 'high' |
|
| 1611 | - ); |
|
| 1612 | - if ($this->_registration->group_size() > 1) { |
|
| 1613 | - add_meta_box( |
|
| 1614 | - 'edit-reg-attendees-mbox', |
|
| 1615 | - esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1616 | - array($this, '_reg_attendees_meta_box'), |
|
| 1617 | - $this->wp_page_slug, |
|
| 1618 | - 'normal', |
|
| 1619 | - 'high' |
|
| 1620 | - ); |
|
| 1621 | - } |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - |
|
| 1625 | - /** |
|
| 1626 | - * set_reg_status_buttons_metabox |
|
| 1627 | - * |
|
| 1628 | - * @access protected |
|
| 1629 | - * @return string |
|
| 1630 | - * @throws \EE_Error |
|
| 1631 | - */ |
|
| 1632 | - public function set_reg_status_buttons_metabox() |
|
| 1633 | - { |
|
| 1634 | - $this->_set_registration_object(); |
|
| 1635 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1636 | - echo $change_reg_status_form->form_open( |
|
| 1637 | - self::add_query_args_and_nonce( |
|
| 1638 | - array( |
|
| 1639 | - 'action' => 'change_reg_status', |
|
| 1640 | - ), |
|
| 1641 | - REG_ADMIN_URL |
|
| 1642 | - ) |
|
| 1643 | - ); |
|
| 1644 | - echo $change_reg_status_form->get_html(); |
|
| 1645 | - echo $change_reg_status_form->form_close(); |
|
| 1646 | - } |
|
| 1647 | - |
|
| 1648 | - |
|
| 1649 | - |
|
| 1650 | - /** |
|
| 1651 | - * @return EE_Form_Section_Proper |
|
| 1652 | - * @throws EE_Error |
|
| 1653 | - */ |
|
| 1654 | - protected function _generate_reg_status_change_form() |
|
| 1655 | - { |
|
| 1656 | - return new EE_Form_Section_Proper(array( |
|
| 1657 | - 'name' => 'reg_status_change_form', |
|
| 1658 | - 'html_id' => 'reg-status-change-form', |
|
| 1659 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1660 | - 'subsections' => array( |
|
| 1661 | - 'return' => new EE_Hidden_Input(array( |
|
| 1662 | - 'name' => 'return', |
|
| 1663 | - 'default' => 'view_registration', |
|
| 1664 | - )), |
|
| 1665 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1666 | - 'name' => 'REG_ID', |
|
| 1667 | - 'default' => $this->_registration->ID(), |
|
| 1668 | - )), |
|
| 1669 | - 'current_status' => new EE_Form_Section_HTML( |
|
| 1670 | - EEH_HTML::tr( |
|
| 1671 | - EEH_HTML::th( |
|
| 1672 | - EEH_HTML::label( |
|
| 1673 | - EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1674 | - ) |
|
| 1675 | - ) |
|
| 1676 | - ) |
|
| 1677 | - . EEH_HTML::td( |
|
| 1678 | - EEH_HTML::strong( |
|
| 1679 | - $this->_registration->pretty_status(), |
|
| 1680 | - '', |
|
| 1681 | - 'status-' . $this->_registration->status_ID(), |
|
| 1682 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1683 | - ) |
|
| 1684 | - ) |
|
| 1685 | - ) |
|
| 1686 | - ), |
|
| 1687 | - 'reg_status' => new EE_Select_Input( |
|
| 1688 | - $this->_get_reg_statuses(), |
|
| 1689 | - array( |
|
| 1690 | - 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1691 | - 'default' => $this->_registration->status_ID(), |
|
| 1692 | - ) |
|
| 1693 | - ), |
|
| 1694 | - 'send_notifications' => new EE_Yes_No_Input( |
|
| 1695 | - array( |
|
| 1696 | - 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1697 | - 'default' => false, |
|
| 1698 | - 'html_help_text' => esc_html__( |
|
| 1699 | - 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1700 | - 'event_espresso' |
|
| 1701 | - ), |
|
| 1702 | - ) |
|
| 1703 | - ), |
|
| 1704 | - 'submit' => new EE_Submit_Input( |
|
| 1705 | - array( |
|
| 1706 | - 'html_class' => 'button-primary', |
|
| 1707 | - 'html_label_text' => ' ', |
|
| 1708 | - 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1709 | - ) |
|
| 1710 | - ), |
|
| 1711 | - ), |
|
| 1712 | - )); |
|
| 1713 | - } |
|
| 1714 | - |
|
| 1715 | - |
|
| 1716 | - /** |
|
| 1717 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1718 | - * |
|
| 1719 | - * @return array |
|
| 1720 | - * @throws EE_Error |
|
| 1721 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1722 | - */ |
|
| 1723 | - protected function _get_reg_statuses() |
|
| 1724 | - { |
|
| 1725 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1726 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1727 | - // get current reg status |
|
| 1728 | - $current_status = $this->_registration->status_ID(); |
|
| 1729 | - // is registration for free event? This will determine whether to display the pending payment option |
|
| 1730 | - if ( |
|
| 1731 | - $current_status !== EEM_Registration::status_id_pending_payment |
|
| 1732 | - && $this->_registration->transaction()->is_free() |
|
| 1733 | - ) { |
|
| 1734 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1735 | - } |
|
| 1736 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - |
|
| 1740 | - |
|
| 1741 | - /** |
|
| 1742 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1743 | - * |
|
| 1744 | - * @param bool $status REG status given for changing registrations to. |
|
| 1745 | - * @param bool $notify Whether to send messages notifications or not. |
|
| 1746 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1747 | - * @throws \EE_Error |
|
| 1748 | - */ |
|
| 1749 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1750 | - { |
|
| 1751 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1752 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1753 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1754 | - } else { |
|
| 1755 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1756 | - } |
|
| 1757 | - $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1758 | - //notify? |
|
| 1759 | - if ($success |
|
| 1760 | - && $notify |
|
| 1761 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1762 | - 'ee_send_message', |
|
| 1763 | - 'espresso_registrations_resend_registration' |
|
| 1764 | - ) |
|
| 1765 | - ) { |
|
| 1766 | - $this->_process_resend_registration(); |
|
| 1767 | - } |
|
| 1768 | - return $success; |
|
| 1769 | - } |
|
| 1770 | - |
|
| 1771 | - |
|
| 1772 | - |
|
| 1773 | - /** |
|
| 1774 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1775 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1776 | - * |
|
| 1777 | - * @param array $REG_IDs |
|
| 1778 | - * @param bool $status |
|
| 1779 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1780 | - * @throws \RuntimeException |
|
| 1781 | - * @throws \EE_Error |
|
| 1782 | - * the array of updated registrations). |
|
| 1783 | - * @throws EE_Error |
|
| 1784 | - * @throws RuntimeException |
|
| 1785 | - */ |
|
| 1786 | - protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1787 | - { |
|
| 1788 | - $success = false; |
|
| 1789 | - // typecast $REG_IDs |
|
| 1790 | - $REG_IDs = (array)$REG_IDs; |
|
| 1791 | - if ( ! empty($REG_IDs)) { |
|
| 1792 | - $success = true; |
|
| 1793 | - // set default status if none is passed |
|
| 1794 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1795 | - // sanitize $REG_IDs |
|
| 1796 | - $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1797 | - //loop through REG_ID's and change status |
|
| 1798 | - foreach ($REG_IDs as $REG_ID) { |
|
| 1799 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1800 | - if ($registration instanceof EE_Registration) { |
|
| 1801 | - $registration->set_status($status); |
|
| 1802 | - $result = $registration->save(); |
|
| 1803 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1804 | - $success = $result !== false ? $success : false; |
|
| 1805 | - } |
|
| 1806 | - } |
|
| 1807 | - } |
|
| 1808 | - //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1809 | - $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1810 | - //return $success and processed registrations |
|
| 1811 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1812 | - } |
|
| 1813 | - |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * Common logic for setting up success message and redirecting to appropriate route |
|
| 1817 | - * |
|
| 1818 | - * @param string $STS_ID status id for the registration changed to |
|
| 1819 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1820 | - * @return void |
|
| 1821 | - */ |
|
| 1822 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1823 | - { |
|
| 1824 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1825 | - : array('success' => false); |
|
| 1826 | - $success = isset($result['success']) && $result['success']; |
|
| 1827 | - //setup success message |
|
| 1828 | - if ($success) { |
|
| 1829 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1830 | - $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1831 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1832 | - } else { |
|
| 1833 | - $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1834 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1835 | - } |
|
| 1836 | - EE_Error::add_success($msg); |
|
| 1837 | - } else { |
|
| 1838 | - EE_Error::add_error( |
|
| 1839 | - esc_html__( |
|
| 1840 | - 'Something went wrong, and the status was not changed', |
|
| 1841 | - 'event_espresso' |
|
| 1842 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1843 | - ); |
|
| 1844 | - } |
|
| 1845 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1846 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1847 | - } else { |
|
| 1848 | - $route = array('action' => 'default'); |
|
| 1849 | - } |
|
| 1850 | - //unset nonces |
|
| 1851 | - foreach ($this->_req_data as $ref => $value) { |
|
| 1852 | - if (strpos($ref, 'nonce') !== false) { |
|
| 1853 | - unset($this->_req_data[$ref]); |
|
| 1854 | - continue; |
|
| 1855 | - } |
|
| 1856 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1857 | - $this->_req_data[$ref] = $value; |
|
| 1858 | - } |
|
| 1859 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1860 | - $route = array_merge($this->_req_data, $route); |
|
| 1861 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1862 | - } |
|
| 1863 | - |
|
| 1864 | - |
|
| 1865 | - /** |
|
| 1866 | - * incoming reg status change from reg details page. |
|
| 1867 | - * |
|
| 1868 | - * @return void |
|
| 1869 | - */ |
|
| 1870 | - protected function _change_reg_status() |
|
| 1871 | - { |
|
| 1872 | - $this->_req_data['return'] = 'view_registration'; |
|
| 1873 | - //set notify based on whether the send notifications toggle is set or not |
|
| 1874 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1875 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1876 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1877 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1878 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1879 | - case EEM_Registration::status_id_approved : |
|
| 1880 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1881 | - $this->approve_registration($notify); |
|
| 1882 | - break; |
|
| 1883 | - case EEM_Registration::status_id_pending_payment : |
|
| 1884 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1885 | - $this->pending_registration($notify); |
|
| 1886 | - break; |
|
| 1887 | - case EEM_Registration::status_id_not_approved : |
|
| 1888 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1889 | - $this->not_approve_registration($notify); |
|
| 1890 | - break; |
|
| 1891 | - case EEM_Registration::status_id_declined : |
|
| 1892 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1893 | - $this->decline_registration($notify); |
|
| 1894 | - break; |
|
| 1895 | - case EEM_Registration::status_id_cancelled : |
|
| 1896 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1897 | - $this->cancel_registration($notify); |
|
| 1898 | - break; |
|
| 1899 | - case EEM_Registration::status_id_wait_list : |
|
| 1900 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1901 | - $this->wait_list_registration($notify); |
|
| 1902 | - break; |
|
| 1903 | - case EEM_Registration::status_id_incomplete : |
|
| 1904 | - default : |
|
| 1905 | - $result['success'] = false; |
|
| 1906 | - unset($this->_req_data['return']); |
|
| 1907 | - $this->_reg_status_change_return('', false); |
|
| 1908 | - break; |
|
| 1909 | - } |
|
| 1910 | - } |
|
| 1911 | - |
|
| 1912 | - |
|
| 1913 | - /** |
|
| 1914 | - * Callback for bulk action routes. |
|
| 1915 | - * Note: although we could just register the singular route callbacks for each bulk action route as well, this |
|
| 1916 | - * method was chosen so there is one central place all the registration status bulk actions are going through. |
|
| 1917 | - * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to |
|
| 1918 | - * when an action is happening on just a single registration). |
|
| 1919 | - * @param $action |
|
| 1920 | - * @param bool $notify |
|
| 1921 | - */ |
|
| 1922 | - protected function bulk_action_on_registrations($action, $notify = false) { |
|
| 1923 | - do_action( |
|
| 1924 | - 'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution', |
|
| 1925 | - $this, |
|
| 1926 | - $action, |
|
| 1927 | - $notify |
|
| 1928 | - ); |
|
| 1929 | - $method = $action . '_registration'; |
|
| 1930 | - if (method_exists($this, $method)) { |
|
| 1931 | - $this->$method($notify); |
|
| 1932 | - } |
|
| 1933 | - } |
|
| 1934 | - |
|
| 1935 | - |
|
| 1936 | - /** |
|
| 1937 | - * approve_registration |
|
| 1938 | - * |
|
| 1939 | - * @access protected |
|
| 1940 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1941 | - * @return void |
|
| 1942 | - */ |
|
| 1943 | - protected function approve_registration($notify = false) |
|
| 1944 | - { |
|
| 1945 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1946 | - } |
|
| 1947 | - |
|
| 1948 | - |
|
| 1949 | - /** |
|
| 1950 | - * decline_registration |
|
| 1951 | - * |
|
| 1952 | - * @access protected |
|
| 1953 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1954 | - * @return void |
|
| 1955 | - */ |
|
| 1956 | - protected function decline_registration($notify = false) |
|
| 1957 | - { |
|
| 1958 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - |
|
| 1962 | - /** |
|
| 1963 | - * cancel_registration |
|
| 1964 | - * |
|
| 1965 | - * @access protected |
|
| 1966 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1967 | - * @return void |
|
| 1968 | - */ |
|
| 1969 | - protected function cancel_registration($notify = false) |
|
| 1970 | - { |
|
| 1971 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1972 | - } |
|
| 1973 | - |
|
| 1974 | - |
|
| 1975 | - /** |
|
| 1976 | - * not_approve_registration |
|
| 1977 | - * |
|
| 1978 | - * @access protected |
|
| 1979 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1980 | - * @return void |
|
| 1981 | - */ |
|
| 1982 | - protected function not_approve_registration($notify = false) |
|
| 1983 | - { |
|
| 1984 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - |
|
| 1988 | - /** |
|
| 1989 | - * decline_registration |
|
| 1990 | - * |
|
| 1991 | - * @access protected |
|
| 1992 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1993 | - * @return void |
|
| 1994 | - */ |
|
| 1995 | - protected function pending_registration($notify = false) |
|
| 1996 | - { |
|
| 1997 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1998 | - } |
|
| 1999 | - |
|
| 2000 | - |
|
| 2001 | - /** |
|
| 2002 | - * waitlist_registration |
|
| 2003 | - * |
|
| 2004 | - * @access protected |
|
| 2005 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2006 | - * @return void |
|
| 2007 | - */ |
|
| 2008 | - protected function wait_list_registration($notify = false) |
|
| 2009 | - { |
|
| 2010 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 2011 | - } |
|
| 2012 | - |
|
| 2013 | - |
|
| 2014 | - /** |
|
| 2015 | - * generates HTML for the Registration main meta box |
|
| 2016 | - * |
|
| 2017 | - * @access public |
|
| 2018 | - * @return void |
|
| 2019 | - * @throws DomainException |
|
| 2020 | - * @throws EE_Error |
|
| 2021 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 2022 | - */ |
|
| 2023 | - public function _reg_details_meta_box() |
|
| 2024 | - { |
|
| 2025 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 2026 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 2027 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
| 2028 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 2029 | - : EE_Transaction::new_instance(); |
|
| 2030 | - $this->_session = $transaction->session_data(); |
|
| 2031 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
| 2032 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 2033 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 2034 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 2035 | - $transaction->total_line_item()); |
|
| 2036 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 2037 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 2038 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 2039 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 2040 | - $filtered_line_item_tree, |
|
| 2041 | - array('EE_Registration' => $this->_registration) |
|
| 2042 | - ); |
|
| 2043 | - $attendee = $this->_registration->attendee(); |
|
| 2044 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 2045 | - 'ee_read_transaction', |
|
| 2046 | - 'espresso_transactions_view_transaction' |
|
| 2047 | - )) { |
|
| 2048 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 2049 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 2050 | - array( |
|
| 2051 | - 'action' => 'view_transaction', |
|
| 2052 | - 'TXN_ID' => $transaction->ID(), |
|
| 2053 | - ), |
|
| 2054 | - TXN_ADMIN_URL |
|
| 2055 | - ), |
|
| 2056 | - esc_html__(' View Transaction', 'event_espresso'), |
|
| 2057 | - 'button secondary-button right', |
|
| 2058 | - 'dashicons dashicons-cart' |
|
| 2059 | - ); |
|
| 2060 | - } else { |
|
| 2061 | - $this->_template_args['view_transaction_button'] = ''; |
|
| 2062 | - } |
|
| 2063 | - if ($attendee instanceof EE_Attendee |
|
| 2064 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 2065 | - 'ee_send_message', |
|
| 2066 | - 'espresso_registrations_resend_registration' |
|
| 2067 | - ) |
|
| 2068 | - ) { |
|
| 2069 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 2070 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 2071 | - array( |
|
| 2072 | - 'action' => 'resend_registration', |
|
| 2073 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2074 | - 'redirect_to' => 'view_registration', |
|
| 2075 | - ), |
|
| 2076 | - REG_ADMIN_URL |
|
| 2077 | - ), |
|
| 2078 | - esc_html__(' Resend Registration', 'event_espresso'), |
|
| 2079 | - 'button secondary-button right', |
|
| 2080 | - 'dashicons dashicons-email-alt' |
|
| 2081 | - ); |
|
| 2082 | - } else { |
|
| 2083 | - $this->_template_args['resend_registration_button'] = ''; |
|
| 2084 | - } |
|
| 2085 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2086 | - $payment = $transaction->get_first_related('Payment'); |
|
| 2087 | - $payment = ! $payment instanceof EE_Payment |
|
| 2088 | - ? EE_Payment::new_instance() |
|
| 2089 | - : $payment; |
|
| 2090 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 2091 | - $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 2092 | - ? EE_Payment_Method::new_instance() |
|
| 2093 | - : $payment_method; |
|
| 2094 | - $reg_details = array( |
|
| 2095 | - 'payment_method' => $payment_method->name(), |
|
| 2096 | - 'response_msg' => $payment->gateway_response(), |
|
| 2097 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
| 2098 | - 'registration_session' => $this->_registration->session_ID(), |
|
| 2099 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 2100 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 2101 | - ); |
|
| 2102 | - if (isset($reg_details['registration_id'])) { |
|
| 2103 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 2104 | - $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 2105 | - 'Registration ID', |
|
| 2106 | - 'event_espresso' |
|
| 2107 | - ); |
|
| 2108 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2109 | - } |
|
| 2110 | - if (isset($reg_details['payment_method'])) { |
|
| 2111 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2112 | - $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2113 | - 'Most Recent Payment Method', |
|
| 2114 | - 'event_espresso' |
|
| 2115 | - ); |
|
| 2116 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2117 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2118 | - $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2119 | - 'Payment method response', |
|
| 2120 | - 'event_espresso' |
|
| 2121 | - ); |
|
| 2122 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2123 | - } |
|
| 2124 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2125 | - $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2126 | - 'Registration Session', |
|
| 2127 | - 'event_espresso' |
|
| 2128 | - ); |
|
| 2129 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2130 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2131 | - $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2132 | - 'Registration placed from IP', |
|
| 2133 | - 'event_espresso' |
|
| 2134 | - ); |
|
| 2135 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2136 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2137 | - $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2138 | - 'event_espresso'); |
|
| 2139 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2140 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2141 | - array( |
|
| 2142 | - 'action' => 'default', |
|
| 2143 | - 'event_id' => $this->_registration->event_ID(), |
|
| 2144 | - ), |
|
| 2145 | - REG_ADMIN_URL |
|
| 2146 | - ); |
|
| 2147 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2148 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2149 | - $template_path = |
|
| 2150 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2151 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2152 | - } |
|
| 2153 | - |
|
| 2154 | - |
|
| 2155 | - /** |
|
| 2156 | - * generates HTML for the Registration Questions meta box. |
|
| 2157 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2158 | - * otherwise uses new forms system |
|
| 2159 | - * |
|
| 2160 | - * @access public |
|
| 2161 | - * @return void |
|
| 2162 | - * @throws DomainException |
|
| 2163 | - * @throws EE_Error |
|
| 2164 | - */ |
|
| 2165 | - public function _reg_questions_meta_box() |
|
| 2166 | - { |
|
| 2167 | - //allow someone to override this method entirely |
|
| 2168 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2169 | - $this->_registration)) { |
|
| 2170 | - $form = $this->_get_reg_custom_questions_form( |
|
| 2171 | - $this->_registration->ID() |
|
| 2172 | - ); |
|
| 2173 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2174 | - ? $form->get_html_and_js() |
|
| 2175 | - : ''; |
|
| 2176 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2177 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2178 | - $template_path = |
|
| 2179 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2180 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2181 | - } |
|
| 2182 | - } |
|
| 2183 | - |
|
| 2184 | - |
|
| 2185 | - /** |
|
| 2186 | - * form_before_question_group |
|
| 2187 | - * |
|
| 2188 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2189 | - * @access public |
|
| 2190 | - * @param string $output |
|
| 2191 | - * @return string |
|
| 2192 | - */ |
|
| 2193 | - public function form_before_question_group($output) |
|
| 2194 | - { |
|
| 2195 | - EE_Error::doing_it_wrong( |
|
| 2196 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2197 | - esc_html__( |
|
| 2198 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2199 | - 'event_espresso' |
|
| 2200 | - ), |
|
| 2201 | - '4.8.32.rc.000' |
|
| 2202 | - ); |
|
| 2203 | - return ' |
|
| 1236 | + if (! empty($registration_status)) { |
|
| 1237 | + $where['STS_ID'] = $registration_status; |
|
| 1238 | + } else { |
|
| 1239 | + //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1240 | + if ($view === 'trash') { |
|
| 1241 | + $where['REG_deleted'] = true; |
|
| 1242 | + } elseif ($view === 'incomplete') { |
|
| 1243 | + $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1244 | + } else { |
|
| 1245 | + $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1246 | + } |
|
| 1247 | + } |
|
| 1248 | + return $where; |
|
| 1249 | + } |
|
| 1250 | + |
|
| 1251 | + |
|
| 1252 | + /** |
|
| 1253 | + * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1254 | + * |
|
| 1255 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1256 | + * @return array |
|
| 1257 | + * @throws EE_Error |
|
| 1258 | + */ |
|
| 1259 | + protected function _add_date_to_where_conditions(array $request) |
|
| 1260 | + { |
|
| 1261 | + $where = array(); |
|
| 1262 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1263 | + $month_range = ! empty($request['month_range']) |
|
| 1264 | + ? sanitize_text_field($request['month_range']) |
|
| 1265 | + : ''; |
|
| 1266 | + $retrieve_for_today = $view === 'today'; |
|
| 1267 | + $retrieve_for_this_month = $view === 'month'; |
|
| 1268 | + |
|
| 1269 | + if ($retrieve_for_today) { |
|
| 1270 | + $now = date('Y-m-d', current_time('timestamp')); |
|
| 1271 | + $where['REG_date'] = array( |
|
| 1272 | + 'BETWEEN', |
|
| 1273 | + array( |
|
| 1274 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1275 | + 'REG_date', |
|
| 1276 | + $now . ' 00:00:00', |
|
| 1277 | + 'Y-m-d H:i:s' |
|
| 1278 | + ), |
|
| 1279 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1280 | + 'REG_date', |
|
| 1281 | + $now . ' 23:59:59', |
|
| 1282 | + 'Y-m-d H:i:s' |
|
| 1283 | + ), |
|
| 1284 | + ), |
|
| 1285 | + ); |
|
| 1286 | + } elseif ($retrieve_for_this_month) { |
|
| 1287 | + $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1288 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1289 | + $where['REG_date'] = array( |
|
| 1290 | + 'BETWEEN', |
|
| 1291 | + array( |
|
| 1292 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1293 | + 'REG_date', |
|
| 1294 | + $current_year_and_month . '-01 00:00:00', |
|
| 1295 | + 'Y-m-d H:i:s' |
|
| 1296 | + ), |
|
| 1297 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1298 | + 'REG_date', |
|
| 1299 | + $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1300 | + 'Y-m-d H:i:s' |
|
| 1301 | + ), |
|
| 1302 | + ), |
|
| 1303 | + ); |
|
| 1304 | + } elseif ($month_range) { |
|
| 1305 | + $pieces = explode(' ', $month_range, 3); |
|
| 1306 | + $month_requested = ! empty($pieces[0]) |
|
| 1307 | + ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1308 | + : ''; |
|
| 1309 | + $year_requested = ! empty($pieces[1]) |
|
| 1310 | + ? $pieces[1] |
|
| 1311 | + : ''; |
|
| 1312 | + //if there is not a month or year then we can't go further |
|
| 1313 | + if ($month_requested && $year_requested) { |
|
| 1314 | + $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1315 | + $where['REG_date'] = array( |
|
| 1316 | + 'BETWEEN', |
|
| 1317 | + array( |
|
| 1318 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1319 | + 'REG_date', |
|
| 1320 | + $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1321 | + 'Y-m-d H:i:s' |
|
| 1322 | + ), |
|
| 1323 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1324 | + 'REG_date', |
|
| 1325 | + $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1326 | + 'Y-m-d H:i:s' |
|
| 1327 | + ), |
|
| 1328 | + ), |
|
| 1329 | + ); |
|
| 1330 | + } |
|
| 1331 | + } |
|
| 1332 | + return $where; |
|
| 1333 | + } |
|
| 1334 | + |
|
| 1335 | + |
|
| 1336 | + /** |
|
| 1337 | + * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1338 | + * |
|
| 1339 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1340 | + * @return array |
|
| 1341 | + */ |
|
| 1342 | + protected function _add_search_to_where_conditions(array $request) |
|
| 1343 | + { |
|
| 1344 | + $where = array(); |
|
| 1345 | + if (! empty($request['s'])) { |
|
| 1346 | + $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1347 | + $where['OR*search_conditions'] = array( |
|
| 1348 | + 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1349 | + 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1350 | + 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1351 | + 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1352 | + 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1353 | + 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1354 | + 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1355 | + 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1356 | + 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1357 | + 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1358 | + 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1359 | + 'REG_final_price' => array('LIKE', $search_string), |
|
| 1360 | + 'REG_code' => array('LIKE', $search_string), |
|
| 1361 | + 'REG_count' => array('LIKE', $search_string), |
|
| 1362 | + 'REG_group_size' => array('LIKE', $search_string), |
|
| 1363 | + 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1364 | + 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1365 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1366 | + ); |
|
| 1367 | + } |
|
| 1368 | + return $where; |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + |
|
| 1372 | + /** |
|
| 1373 | + * Sets up the where conditions for the registrations query. |
|
| 1374 | + * |
|
| 1375 | + * @param array $request |
|
| 1376 | + * @return array |
|
| 1377 | + * @throws EE_Error |
|
| 1378 | + */ |
|
| 1379 | + protected function _get_where_conditions_for_registrations_query($request) |
|
| 1380 | + { |
|
| 1381 | + return apply_filters( |
|
| 1382 | + 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1383 | + array_merge( |
|
| 1384 | + $this->_add_event_id_to_where_conditions($request), |
|
| 1385 | + $this->_add_category_id_to_where_conditions($request), |
|
| 1386 | + $this->_add_datetime_id_to_where_conditions($request), |
|
| 1387 | + $this->_add_registration_status_to_where_conditions($request), |
|
| 1388 | + $this->_add_date_to_where_conditions($request), |
|
| 1389 | + $this->_add_search_to_where_conditions($request) |
|
| 1390 | + ), |
|
| 1391 | + $request |
|
| 1392 | + ); |
|
| 1393 | + } |
|
| 1394 | + |
|
| 1395 | + |
|
| 1396 | + /** |
|
| 1397 | + * Sets up the orderby for the registrations query. |
|
| 1398 | + * |
|
| 1399 | + * @return array |
|
| 1400 | + */ |
|
| 1401 | + protected function _get_orderby_for_registrations_query() |
|
| 1402 | + { |
|
| 1403 | + $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1404 | + ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1405 | + : ''; |
|
| 1406 | + switch ($orderby_field) { |
|
| 1407 | + case '_REG_ID': |
|
| 1408 | + $orderby_field = 'REG_ID'; |
|
| 1409 | + break; |
|
| 1410 | + case '_Reg_status': |
|
| 1411 | + $orderby_field = 'STS_ID'; |
|
| 1412 | + break; |
|
| 1413 | + case 'ATT_fname': |
|
| 1414 | + $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1415 | + break; |
|
| 1416 | + case 'ATT_lname': |
|
| 1417 | + $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1418 | + break; |
|
| 1419 | + case 'event_name': |
|
| 1420 | + $orderby_field = 'Event.EVT_name'; |
|
| 1421 | + break; |
|
| 1422 | + case 'DTT_EVT_start': |
|
| 1423 | + $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1424 | + break; |
|
| 1425 | + default: //'REG_date' |
|
| 1426 | + $orderby_field = 'REG_date'; |
|
| 1427 | + } |
|
| 1428 | + |
|
| 1429 | + //order |
|
| 1430 | + $order = ! empty($this->_req_data['order']) |
|
| 1431 | + ? sanitize_text_field($this->_req_data['order']) |
|
| 1432 | + : 'DESC'; |
|
| 1433 | + |
|
| 1434 | + //mutate orderby_field |
|
| 1435 | + $orderby_field = array_combine( |
|
| 1436 | + (array) $orderby_field, |
|
| 1437 | + array_fill(0, count($orderby_field), $order) |
|
| 1438 | + ); |
|
| 1439 | + return array('order_by' => $orderby_field); |
|
| 1440 | + } |
|
| 1441 | + |
|
| 1442 | + |
|
| 1443 | + /** |
|
| 1444 | + * Sets up the limit for the registrations query. |
|
| 1445 | + * |
|
| 1446 | + * @param $per_page |
|
| 1447 | + * @return array |
|
| 1448 | + */ |
|
| 1449 | + protected function _get_limit($per_page) |
|
| 1450 | + { |
|
| 1451 | + $current_page = ! empty($this->_req_data['paged']) |
|
| 1452 | + ? absint($this->_req_data['paged']) |
|
| 1453 | + : 1; |
|
| 1454 | + $per_page = ! empty($this->_req_data['perpage']) |
|
| 1455 | + ? $this->_req_data['perpage'] |
|
| 1456 | + : $per_page; |
|
| 1457 | + |
|
| 1458 | + //-1 means return all results so get out if that's set. |
|
| 1459 | + if ((int)$per_page === -1) { |
|
| 1460 | + return array(); |
|
| 1461 | + } |
|
| 1462 | + $per_page = absint($per_page); |
|
| 1463 | + $offset = ($current_page - 1) * $per_page; |
|
| 1464 | + return array('limit' => array($offset, $per_page)); |
|
| 1465 | + } |
|
| 1466 | + |
|
| 1467 | + |
|
| 1468 | + public function get_registration_status_array() |
|
| 1469 | + { |
|
| 1470 | + return self::$_reg_status; |
|
| 1471 | + } |
|
| 1472 | + |
|
| 1473 | + |
|
| 1474 | + |
|
| 1475 | + |
|
| 1476 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1477 | + /** |
|
| 1478 | + * generates HTML for the View Registration Details Admin page |
|
| 1479 | + * |
|
| 1480 | + * @access protected |
|
| 1481 | + * @return void |
|
| 1482 | + * @throws DomainException |
|
| 1483 | + * @throws EE_Error |
|
| 1484 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1485 | + */ |
|
| 1486 | + protected function _registration_details() |
|
| 1487 | + { |
|
| 1488 | + $this->_template_args = array(); |
|
| 1489 | + $this->_set_registration_object(); |
|
| 1490 | + if (is_object($this->_registration)) { |
|
| 1491 | + $transaction = $this->_registration->transaction() |
|
| 1492 | + ? $this->_registration->transaction() |
|
| 1493 | + : EE_Transaction::new_instance(); |
|
| 1494 | + $this->_session = $transaction->session_data(); |
|
| 1495 | + $event_id = $this->_registration->event_ID(); |
|
| 1496 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1497 | + $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1498 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1499 | + $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1500 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1501 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1502 | + // link back to overview |
|
| 1503 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1504 | + $this->_template_args['registration'] = $this->_registration; |
|
| 1505 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1506 | + array( |
|
| 1507 | + 'action' => 'default', |
|
| 1508 | + 'event_id' => $event_id, |
|
| 1509 | + ), |
|
| 1510 | + REG_ADMIN_URL |
|
| 1511 | + ); |
|
| 1512 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1513 | + array( |
|
| 1514 | + 'action' => 'default', |
|
| 1515 | + 'EVT_ID' => $event_id, |
|
| 1516 | + 'page' => 'espresso_transactions', |
|
| 1517 | + ), |
|
| 1518 | + admin_url('admin.php') |
|
| 1519 | + ); |
|
| 1520 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1521 | + array( |
|
| 1522 | + 'page' => 'espresso_events', |
|
| 1523 | + 'action' => 'edit', |
|
| 1524 | + 'post' => $event_id, |
|
| 1525 | + ), |
|
| 1526 | + admin_url('admin.php') |
|
| 1527 | + ); |
|
| 1528 | + //next and previous links |
|
| 1529 | + $next_reg = $this->_registration->next( |
|
| 1530 | + null, |
|
| 1531 | + array(), |
|
| 1532 | + 'REG_ID' |
|
| 1533 | + ); |
|
| 1534 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1535 | + ? $this->_next_link( |
|
| 1536 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1537 | + array( |
|
| 1538 | + 'action' => 'view_registration', |
|
| 1539 | + '_REG_ID' => $next_reg['REG_ID'], |
|
| 1540 | + ), |
|
| 1541 | + REG_ADMIN_URL |
|
| 1542 | + ), |
|
| 1543 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1544 | + ) |
|
| 1545 | + : ''; |
|
| 1546 | + $previous_reg = $this->_registration->previous( |
|
| 1547 | + null, |
|
| 1548 | + array(), |
|
| 1549 | + 'REG_ID' |
|
| 1550 | + ); |
|
| 1551 | + $this->_template_args['previous_registration'] = $previous_reg |
|
| 1552 | + ? $this->_previous_link( |
|
| 1553 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1554 | + array( |
|
| 1555 | + 'action' => 'view_registration', |
|
| 1556 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1557 | + ), |
|
| 1558 | + REG_ADMIN_URL |
|
| 1559 | + ), |
|
| 1560 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1561 | + ) |
|
| 1562 | + : ''; |
|
| 1563 | + // grab header |
|
| 1564 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1565 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1566 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1567 | + $template_path, |
|
| 1568 | + $this->_template_args, |
|
| 1569 | + true |
|
| 1570 | + ); |
|
| 1571 | + } else { |
|
| 1572 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1573 | + } |
|
| 1574 | + // the details template wrapper |
|
| 1575 | + $this->display_admin_page_with_sidebar(); |
|
| 1576 | + } |
|
| 1577 | + |
|
| 1578 | + |
|
| 1579 | + protected function _registration_details_metaboxes() |
|
| 1580 | + { |
|
| 1581 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1582 | + $this->_set_registration_object(); |
|
| 1583 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1584 | + add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1585 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1586 | + add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1587 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1588 | + if ($attendee instanceof EE_Attendee |
|
| 1589 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1590 | + 'ee_edit_registration', |
|
| 1591 | + 'edit-reg-questions-mbox', |
|
| 1592 | + $this->_registration->ID() |
|
| 1593 | + ) |
|
| 1594 | + ) { |
|
| 1595 | + add_meta_box( |
|
| 1596 | + 'edit-reg-questions-mbox', |
|
| 1597 | + esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1598 | + array($this, '_reg_questions_meta_box'), |
|
| 1599 | + $this->wp_page_slug, |
|
| 1600 | + 'normal', |
|
| 1601 | + 'high' |
|
| 1602 | + ); |
|
| 1603 | + } |
|
| 1604 | + add_meta_box( |
|
| 1605 | + 'edit-reg-registrant-mbox', |
|
| 1606 | + esc_html__('Contact Details', 'event_espresso'), |
|
| 1607 | + array($this, '_reg_registrant_side_meta_box'), |
|
| 1608 | + $this->wp_page_slug, |
|
| 1609 | + 'side', |
|
| 1610 | + 'high' |
|
| 1611 | + ); |
|
| 1612 | + if ($this->_registration->group_size() > 1) { |
|
| 1613 | + add_meta_box( |
|
| 1614 | + 'edit-reg-attendees-mbox', |
|
| 1615 | + esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1616 | + array($this, '_reg_attendees_meta_box'), |
|
| 1617 | + $this->wp_page_slug, |
|
| 1618 | + 'normal', |
|
| 1619 | + 'high' |
|
| 1620 | + ); |
|
| 1621 | + } |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + |
|
| 1625 | + /** |
|
| 1626 | + * set_reg_status_buttons_metabox |
|
| 1627 | + * |
|
| 1628 | + * @access protected |
|
| 1629 | + * @return string |
|
| 1630 | + * @throws \EE_Error |
|
| 1631 | + */ |
|
| 1632 | + public function set_reg_status_buttons_metabox() |
|
| 1633 | + { |
|
| 1634 | + $this->_set_registration_object(); |
|
| 1635 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1636 | + echo $change_reg_status_form->form_open( |
|
| 1637 | + self::add_query_args_and_nonce( |
|
| 1638 | + array( |
|
| 1639 | + 'action' => 'change_reg_status', |
|
| 1640 | + ), |
|
| 1641 | + REG_ADMIN_URL |
|
| 1642 | + ) |
|
| 1643 | + ); |
|
| 1644 | + echo $change_reg_status_form->get_html(); |
|
| 1645 | + echo $change_reg_status_form->form_close(); |
|
| 1646 | + } |
|
| 1647 | + |
|
| 1648 | + |
|
| 1649 | + |
|
| 1650 | + /** |
|
| 1651 | + * @return EE_Form_Section_Proper |
|
| 1652 | + * @throws EE_Error |
|
| 1653 | + */ |
|
| 1654 | + protected function _generate_reg_status_change_form() |
|
| 1655 | + { |
|
| 1656 | + return new EE_Form_Section_Proper(array( |
|
| 1657 | + 'name' => 'reg_status_change_form', |
|
| 1658 | + 'html_id' => 'reg-status-change-form', |
|
| 1659 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1660 | + 'subsections' => array( |
|
| 1661 | + 'return' => new EE_Hidden_Input(array( |
|
| 1662 | + 'name' => 'return', |
|
| 1663 | + 'default' => 'view_registration', |
|
| 1664 | + )), |
|
| 1665 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1666 | + 'name' => 'REG_ID', |
|
| 1667 | + 'default' => $this->_registration->ID(), |
|
| 1668 | + )), |
|
| 1669 | + 'current_status' => new EE_Form_Section_HTML( |
|
| 1670 | + EEH_HTML::tr( |
|
| 1671 | + EEH_HTML::th( |
|
| 1672 | + EEH_HTML::label( |
|
| 1673 | + EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1674 | + ) |
|
| 1675 | + ) |
|
| 1676 | + ) |
|
| 1677 | + . EEH_HTML::td( |
|
| 1678 | + EEH_HTML::strong( |
|
| 1679 | + $this->_registration->pretty_status(), |
|
| 1680 | + '', |
|
| 1681 | + 'status-' . $this->_registration->status_ID(), |
|
| 1682 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1683 | + ) |
|
| 1684 | + ) |
|
| 1685 | + ) |
|
| 1686 | + ), |
|
| 1687 | + 'reg_status' => new EE_Select_Input( |
|
| 1688 | + $this->_get_reg_statuses(), |
|
| 1689 | + array( |
|
| 1690 | + 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1691 | + 'default' => $this->_registration->status_ID(), |
|
| 1692 | + ) |
|
| 1693 | + ), |
|
| 1694 | + 'send_notifications' => new EE_Yes_No_Input( |
|
| 1695 | + array( |
|
| 1696 | + 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1697 | + 'default' => false, |
|
| 1698 | + 'html_help_text' => esc_html__( |
|
| 1699 | + 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1700 | + 'event_espresso' |
|
| 1701 | + ), |
|
| 1702 | + ) |
|
| 1703 | + ), |
|
| 1704 | + 'submit' => new EE_Submit_Input( |
|
| 1705 | + array( |
|
| 1706 | + 'html_class' => 'button-primary', |
|
| 1707 | + 'html_label_text' => ' ', |
|
| 1708 | + 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1709 | + ) |
|
| 1710 | + ), |
|
| 1711 | + ), |
|
| 1712 | + )); |
|
| 1713 | + } |
|
| 1714 | + |
|
| 1715 | + |
|
| 1716 | + /** |
|
| 1717 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1718 | + * |
|
| 1719 | + * @return array |
|
| 1720 | + * @throws EE_Error |
|
| 1721 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1722 | + */ |
|
| 1723 | + protected function _get_reg_statuses() |
|
| 1724 | + { |
|
| 1725 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1726 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1727 | + // get current reg status |
|
| 1728 | + $current_status = $this->_registration->status_ID(); |
|
| 1729 | + // is registration for free event? This will determine whether to display the pending payment option |
|
| 1730 | + if ( |
|
| 1731 | + $current_status !== EEM_Registration::status_id_pending_payment |
|
| 1732 | + && $this->_registration->transaction()->is_free() |
|
| 1733 | + ) { |
|
| 1734 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1735 | + } |
|
| 1736 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + |
|
| 1740 | + |
|
| 1741 | + /** |
|
| 1742 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1743 | + * |
|
| 1744 | + * @param bool $status REG status given for changing registrations to. |
|
| 1745 | + * @param bool $notify Whether to send messages notifications or not. |
|
| 1746 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1747 | + * @throws \EE_Error |
|
| 1748 | + */ |
|
| 1749 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1750 | + { |
|
| 1751 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1752 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1753 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1754 | + } else { |
|
| 1755 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1756 | + } |
|
| 1757 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1758 | + //notify? |
|
| 1759 | + if ($success |
|
| 1760 | + && $notify |
|
| 1761 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1762 | + 'ee_send_message', |
|
| 1763 | + 'espresso_registrations_resend_registration' |
|
| 1764 | + ) |
|
| 1765 | + ) { |
|
| 1766 | + $this->_process_resend_registration(); |
|
| 1767 | + } |
|
| 1768 | + return $success; |
|
| 1769 | + } |
|
| 1770 | + |
|
| 1771 | + |
|
| 1772 | + |
|
| 1773 | + /** |
|
| 1774 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1775 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1776 | + * |
|
| 1777 | + * @param array $REG_IDs |
|
| 1778 | + * @param bool $status |
|
| 1779 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1780 | + * @throws \RuntimeException |
|
| 1781 | + * @throws \EE_Error |
|
| 1782 | + * the array of updated registrations). |
|
| 1783 | + * @throws EE_Error |
|
| 1784 | + * @throws RuntimeException |
|
| 1785 | + */ |
|
| 1786 | + protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1787 | + { |
|
| 1788 | + $success = false; |
|
| 1789 | + // typecast $REG_IDs |
|
| 1790 | + $REG_IDs = (array)$REG_IDs; |
|
| 1791 | + if ( ! empty($REG_IDs)) { |
|
| 1792 | + $success = true; |
|
| 1793 | + // set default status if none is passed |
|
| 1794 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1795 | + // sanitize $REG_IDs |
|
| 1796 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1797 | + //loop through REG_ID's and change status |
|
| 1798 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1799 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1800 | + if ($registration instanceof EE_Registration) { |
|
| 1801 | + $registration->set_status($status); |
|
| 1802 | + $result = $registration->save(); |
|
| 1803 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1804 | + $success = $result !== false ? $success : false; |
|
| 1805 | + } |
|
| 1806 | + } |
|
| 1807 | + } |
|
| 1808 | + //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1809 | + $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1810 | + //return $success and processed registrations |
|
| 1811 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1812 | + } |
|
| 1813 | + |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * Common logic for setting up success message and redirecting to appropriate route |
|
| 1817 | + * |
|
| 1818 | + * @param string $STS_ID status id for the registration changed to |
|
| 1819 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1820 | + * @return void |
|
| 1821 | + */ |
|
| 1822 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1823 | + { |
|
| 1824 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1825 | + : array('success' => false); |
|
| 1826 | + $success = isset($result['success']) && $result['success']; |
|
| 1827 | + //setup success message |
|
| 1828 | + if ($success) { |
|
| 1829 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1830 | + $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1831 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1832 | + } else { |
|
| 1833 | + $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1834 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1835 | + } |
|
| 1836 | + EE_Error::add_success($msg); |
|
| 1837 | + } else { |
|
| 1838 | + EE_Error::add_error( |
|
| 1839 | + esc_html__( |
|
| 1840 | + 'Something went wrong, and the status was not changed', |
|
| 1841 | + 'event_espresso' |
|
| 1842 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1843 | + ); |
|
| 1844 | + } |
|
| 1845 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1846 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1847 | + } else { |
|
| 1848 | + $route = array('action' => 'default'); |
|
| 1849 | + } |
|
| 1850 | + //unset nonces |
|
| 1851 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1852 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1853 | + unset($this->_req_data[$ref]); |
|
| 1854 | + continue; |
|
| 1855 | + } |
|
| 1856 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1857 | + $this->_req_data[$ref] = $value; |
|
| 1858 | + } |
|
| 1859 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1860 | + $route = array_merge($this->_req_data, $route); |
|
| 1861 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1862 | + } |
|
| 1863 | + |
|
| 1864 | + |
|
| 1865 | + /** |
|
| 1866 | + * incoming reg status change from reg details page. |
|
| 1867 | + * |
|
| 1868 | + * @return void |
|
| 1869 | + */ |
|
| 1870 | + protected function _change_reg_status() |
|
| 1871 | + { |
|
| 1872 | + $this->_req_data['return'] = 'view_registration'; |
|
| 1873 | + //set notify based on whether the send notifications toggle is set or not |
|
| 1874 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1875 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1876 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1877 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1878 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1879 | + case EEM_Registration::status_id_approved : |
|
| 1880 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1881 | + $this->approve_registration($notify); |
|
| 1882 | + break; |
|
| 1883 | + case EEM_Registration::status_id_pending_payment : |
|
| 1884 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1885 | + $this->pending_registration($notify); |
|
| 1886 | + break; |
|
| 1887 | + case EEM_Registration::status_id_not_approved : |
|
| 1888 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1889 | + $this->not_approve_registration($notify); |
|
| 1890 | + break; |
|
| 1891 | + case EEM_Registration::status_id_declined : |
|
| 1892 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1893 | + $this->decline_registration($notify); |
|
| 1894 | + break; |
|
| 1895 | + case EEM_Registration::status_id_cancelled : |
|
| 1896 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1897 | + $this->cancel_registration($notify); |
|
| 1898 | + break; |
|
| 1899 | + case EEM_Registration::status_id_wait_list : |
|
| 1900 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1901 | + $this->wait_list_registration($notify); |
|
| 1902 | + break; |
|
| 1903 | + case EEM_Registration::status_id_incomplete : |
|
| 1904 | + default : |
|
| 1905 | + $result['success'] = false; |
|
| 1906 | + unset($this->_req_data['return']); |
|
| 1907 | + $this->_reg_status_change_return('', false); |
|
| 1908 | + break; |
|
| 1909 | + } |
|
| 1910 | + } |
|
| 1911 | + |
|
| 1912 | + |
|
| 1913 | + /** |
|
| 1914 | + * Callback for bulk action routes. |
|
| 1915 | + * Note: although we could just register the singular route callbacks for each bulk action route as well, this |
|
| 1916 | + * method was chosen so there is one central place all the registration status bulk actions are going through. |
|
| 1917 | + * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to |
|
| 1918 | + * when an action is happening on just a single registration). |
|
| 1919 | + * @param $action |
|
| 1920 | + * @param bool $notify |
|
| 1921 | + */ |
|
| 1922 | + protected function bulk_action_on_registrations($action, $notify = false) { |
|
| 1923 | + do_action( |
|
| 1924 | + 'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution', |
|
| 1925 | + $this, |
|
| 1926 | + $action, |
|
| 1927 | + $notify |
|
| 1928 | + ); |
|
| 1929 | + $method = $action . '_registration'; |
|
| 1930 | + if (method_exists($this, $method)) { |
|
| 1931 | + $this->$method($notify); |
|
| 1932 | + } |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + |
|
| 1936 | + /** |
|
| 1937 | + * approve_registration |
|
| 1938 | + * |
|
| 1939 | + * @access protected |
|
| 1940 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1941 | + * @return void |
|
| 1942 | + */ |
|
| 1943 | + protected function approve_registration($notify = false) |
|
| 1944 | + { |
|
| 1945 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1946 | + } |
|
| 1947 | + |
|
| 1948 | + |
|
| 1949 | + /** |
|
| 1950 | + * decline_registration |
|
| 1951 | + * |
|
| 1952 | + * @access protected |
|
| 1953 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1954 | + * @return void |
|
| 1955 | + */ |
|
| 1956 | + protected function decline_registration($notify = false) |
|
| 1957 | + { |
|
| 1958 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + |
|
| 1962 | + /** |
|
| 1963 | + * cancel_registration |
|
| 1964 | + * |
|
| 1965 | + * @access protected |
|
| 1966 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1967 | + * @return void |
|
| 1968 | + */ |
|
| 1969 | + protected function cancel_registration($notify = false) |
|
| 1970 | + { |
|
| 1971 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1972 | + } |
|
| 1973 | + |
|
| 1974 | + |
|
| 1975 | + /** |
|
| 1976 | + * not_approve_registration |
|
| 1977 | + * |
|
| 1978 | + * @access protected |
|
| 1979 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1980 | + * @return void |
|
| 1981 | + */ |
|
| 1982 | + protected function not_approve_registration($notify = false) |
|
| 1983 | + { |
|
| 1984 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + |
|
| 1988 | + /** |
|
| 1989 | + * decline_registration |
|
| 1990 | + * |
|
| 1991 | + * @access protected |
|
| 1992 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1993 | + * @return void |
|
| 1994 | + */ |
|
| 1995 | + protected function pending_registration($notify = false) |
|
| 1996 | + { |
|
| 1997 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1998 | + } |
|
| 1999 | + |
|
| 2000 | + |
|
| 2001 | + /** |
|
| 2002 | + * waitlist_registration |
|
| 2003 | + * |
|
| 2004 | + * @access protected |
|
| 2005 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 2006 | + * @return void |
|
| 2007 | + */ |
|
| 2008 | + protected function wait_list_registration($notify = false) |
|
| 2009 | + { |
|
| 2010 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 2011 | + } |
|
| 2012 | + |
|
| 2013 | + |
|
| 2014 | + /** |
|
| 2015 | + * generates HTML for the Registration main meta box |
|
| 2016 | + * |
|
| 2017 | + * @access public |
|
| 2018 | + * @return void |
|
| 2019 | + * @throws DomainException |
|
| 2020 | + * @throws EE_Error |
|
| 2021 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 2022 | + */ |
|
| 2023 | + public function _reg_details_meta_box() |
|
| 2024 | + { |
|
| 2025 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 2026 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 2027 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 2028 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 2029 | + : EE_Transaction::new_instance(); |
|
| 2030 | + $this->_session = $transaction->session_data(); |
|
| 2031 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
| 2032 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 2033 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 2034 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 2035 | + $transaction->total_line_item()); |
|
| 2036 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 2037 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 2038 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 2039 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 2040 | + $filtered_line_item_tree, |
|
| 2041 | + array('EE_Registration' => $this->_registration) |
|
| 2042 | + ); |
|
| 2043 | + $attendee = $this->_registration->attendee(); |
|
| 2044 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 2045 | + 'ee_read_transaction', |
|
| 2046 | + 'espresso_transactions_view_transaction' |
|
| 2047 | + )) { |
|
| 2048 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 2049 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 2050 | + array( |
|
| 2051 | + 'action' => 'view_transaction', |
|
| 2052 | + 'TXN_ID' => $transaction->ID(), |
|
| 2053 | + ), |
|
| 2054 | + TXN_ADMIN_URL |
|
| 2055 | + ), |
|
| 2056 | + esc_html__(' View Transaction', 'event_espresso'), |
|
| 2057 | + 'button secondary-button right', |
|
| 2058 | + 'dashicons dashicons-cart' |
|
| 2059 | + ); |
|
| 2060 | + } else { |
|
| 2061 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 2062 | + } |
|
| 2063 | + if ($attendee instanceof EE_Attendee |
|
| 2064 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 2065 | + 'ee_send_message', |
|
| 2066 | + 'espresso_registrations_resend_registration' |
|
| 2067 | + ) |
|
| 2068 | + ) { |
|
| 2069 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 2070 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 2071 | + array( |
|
| 2072 | + 'action' => 'resend_registration', |
|
| 2073 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2074 | + 'redirect_to' => 'view_registration', |
|
| 2075 | + ), |
|
| 2076 | + REG_ADMIN_URL |
|
| 2077 | + ), |
|
| 2078 | + esc_html__(' Resend Registration', 'event_espresso'), |
|
| 2079 | + 'button secondary-button right', |
|
| 2080 | + 'dashicons dashicons-email-alt' |
|
| 2081 | + ); |
|
| 2082 | + } else { |
|
| 2083 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 2084 | + } |
|
| 2085 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2086 | + $payment = $transaction->get_first_related('Payment'); |
|
| 2087 | + $payment = ! $payment instanceof EE_Payment |
|
| 2088 | + ? EE_Payment::new_instance() |
|
| 2089 | + : $payment; |
|
| 2090 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 2091 | + $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 2092 | + ? EE_Payment_Method::new_instance() |
|
| 2093 | + : $payment_method; |
|
| 2094 | + $reg_details = array( |
|
| 2095 | + 'payment_method' => $payment_method->name(), |
|
| 2096 | + 'response_msg' => $payment->gateway_response(), |
|
| 2097 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 2098 | + 'registration_session' => $this->_registration->session_ID(), |
|
| 2099 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 2100 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 2101 | + ); |
|
| 2102 | + if (isset($reg_details['registration_id'])) { |
|
| 2103 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 2104 | + $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 2105 | + 'Registration ID', |
|
| 2106 | + 'event_espresso' |
|
| 2107 | + ); |
|
| 2108 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2109 | + } |
|
| 2110 | + if (isset($reg_details['payment_method'])) { |
|
| 2111 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2112 | + $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2113 | + 'Most Recent Payment Method', |
|
| 2114 | + 'event_espresso' |
|
| 2115 | + ); |
|
| 2116 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2117 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2118 | + $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2119 | + 'Payment method response', |
|
| 2120 | + 'event_espresso' |
|
| 2121 | + ); |
|
| 2122 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2123 | + } |
|
| 2124 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2125 | + $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2126 | + 'Registration Session', |
|
| 2127 | + 'event_espresso' |
|
| 2128 | + ); |
|
| 2129 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2130 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2131 | + $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2132 | + 'Registration placed from IP', |
|
| 2133 | + 'event_espresso' |
|
| 2134 | + ); |
|
| 2135 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2136 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2137 | + $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2138 | + 'event_espresso'); |
|
| 2139 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2140 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2141 | + array( |
|
| 2142 | + 'action' => 'default', |
|
| 2143 | + 'event_id' => $this->_registration->event_ID(), |
|
| 2144 | + ), |
|
| 2145 | + REG_ADMIN_URL |
|
| 2146 | + ); |
|
| 2147 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2148 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2149 | + $template_path = |
|
| 2150 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2151 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2152 | + } |
|
| 2153 | + |
|
| 2154 | + |
|
| 2155 | + /** |
|
| 2156 | + * generates HTML for the Registration Questions meta box. |
|
| 2157 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2158 | + * otherwise uses new forms system |
|
| 2159 | + * |
|
| 2160 | + * @access public |
|
| 2161 | + * @return void |
|
| 2162 | + * @throws DomainException |
|
| 2163 | + * @throws EE_Error |
|
| 2164 | + */ |
|
| 2165 | + public function _reg_questions_meta_box() |
|
| 2166 | + { |
|
| 2167 | + //allow someone to override this method entirely |
|
| 2168 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2169 | + $this->_registration)) { |
|
| 2170 | + $form = $this->_get_reg_custom_questions_form( |
|
| 2171 | + $this->_registration->ID() |
|
| 2172 | + ); |
|
| 2173 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2174 | + ? $form->get_html_and_js() |
|
| 2175 | + : ''; |
|
| 2176 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2177 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2178 | + $template_path = |
|
| 2179 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2180 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2181 | + } |
|
| 2182 | + } |
|
| 2183 | + |
|
| 2184 | + |
|
| 2185 | + /** |
|
| 2186 | + * form_before_question_group |
|
| 2187 | + * |
|
| 2188 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2189 | + * @access public |
|
| 2190 | + * @param string $output |
|
| 2191 | + * @return string |
|
| 2192 | + */ |
|
| 2193 | + public function form_before_question_group($output) |
|
| 2194 | + { |
|
| 2195 | + EE_Error::doing_it_wrong( |
|
| 2196 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2197 | + esc_html__( |
|
| 2198 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2199 | + 'event_espresso' |
|
| 2200 | + ), |
|
| 2201 | + '4.8.32.rc.000' |
|
| 2202 | + ); |
|
| 2203 | + return ' |
|
| 2204 | 2204 | <table class="form-table ee-width-100"> |
| 2205 | 2205 | <tbody> |
| 2206 | 2206 | '; |
| 2207 | - } |
|
| 2208 | - |
|
| 2209 | - |
|
| 2210 | - /** |
|
| 2211 | - * form_after_question_group |
|
| 2212 | - * |
|
| 2213 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2214 | - * @access public |
|
| 2215 | - * @param string $output |
|
| 2216 | - * @return string |
|
| 2217 | - */ |
|
| 2218 | - public function form_after_question_group($output) |
|
| 2219 | - { |
|
| 2220 | - EE_Error::doing_it_wrong( |
|
| 2221 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2222 | - esc_html__( |
|
| 2223 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2224 | - 'event_espresso' |
|
| 2225 | - ), |
|
| 2226 | - '4.8.32.rc.000' |
|
| 2227 | - ); |
|
| 2228 | - return ' |
|
| 2207 | + } |
|
| 2208 | + |
|
| 2209 | + |
|
| 2210 | + /** |
|
| 2211 | + * form_after_question_group |
|
| 2212 | + * |
|
| 2213 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2214 | + * @access public |
|
| 2215 | + * @param string $output |
|
| 2216 | + * @return string |
|
| 2217 | + */ |
|
| 2218 | + public function form_after_question_group($output) |
|
| 2219 | + { |
|
| 2220 | + EE_Error::doing_it_wrong( |
|
| 2221 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2222 | + esc_html__( |
|
| 2223 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2224 | + 'event_espresso' |
|
| 2225 | + ), |
|
| 2226 | + '4.8.32.rc.000' |
|
| 2227 | + ); |
|
| 2228 | + return ' |
|
| 2229 | 2229 | <tr class="hide-if-no-js"> |
| 2230 | 2230 | <th> </th> |
| 2231 | 2231 | <td class="reg-admin-edit-attendee-question-td"> |
| 2232 | 2232 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
| 2233 | - . esc_attr__('click to edit question', 'event_espresso') |
|
| 2234 | - . '"> |
|
| 2233 | + . esc_attr__('click to edit question', 'event_espresso') |
|
| 2234 | + . '"> |
|
| 2235 | 2235 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
| 2236 | - . esc_html__('edit the above question group', 'event_espresso') |
|
| 2237 | - . '</span> |
|
| 2236 | + . esc_html__('edit the above question group', 'event_espresso') |
|
| 2237 | + . '</span> |
|
| 2238 | 2238 | <div class="dashicons dashicons-edit"></div> |
| 2239 | 2239 | </a> |
| 2240 | 2240 | </td> |
@@ -2242,558 +2242,558 @@ discard block |
||
| 2242 | 2242 | </tbody> |
| 2243 | 2243 | </table> |
| 2244 | 2244 | '; |
| 2245 | - } |
|
| 2246 | - |
|
| 2247 | - |
|
| 2248 | - /** |
|
| 2249 | - * form_form_field_label_wrap |
|
| 2250 | - * |
|
| 2251 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2252 | - * @access public |
|
| 2253 | - * @param string $label |
|
| 2254 | - * @return string |
|
| 2255 | - */ |
|
| 2256 | - public function form_form_field_label_wrap($label) |
|
| 2257 | - { |
|
| 2258 | - EE_Error::doing_it_wrong( |
|
| 2259 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2260 | - esc_html__( |
|
| 2261 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2262 | - 'event_espresso' |
|
| 2263 | - ), |
|
| 2264 | - '4.8.32.rc.000' |
|
| 2265 | - ); |
|
| 2266 | - return ' |
|
| 2245 | + } |
|
| 2246 | + |
|
| 2247 | + |
|
| 2248 | + /** |
|
| 2249 | + * form_form_field_label_wrap |
|
| 2250 | + * |
|
| 2251 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2252 | + * @access public |
|
| 2253 | + * @param string $label |
|
| 2254 | + * @return string |
|
| 2255 | + */ |
|
| 2256 | + public function form_form_field_label_wrap($label) |
|
| 2257 | + { |
|
| 2258 | + EE_Error::doing_it_wrong( |
|
| 2259 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2260 | + esc_html__( |
|
| 2261 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2262 | + 'event_espresso' |
|
| 2263 | + ), |
|
| 2264 | + '4.8.32.rc.000' |
|
| 2265 | + ); |
|
| 2266 | + return ' |
|
| 2267 | 2267 | <tr> |
| 2268 | 2268 | <th> |
| 2269 | 2269 | ' . $label . ' |
| 2270 | 2270 | </th>'; |
| 2271 | - } |
|
| 2272 | - |
|
| 2273 | - |
|
| 2274 | - /** |
|
| 2275 | - * form_form_field_input__wrap |
|
| 2276 | - * |
|
| 2277 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2278 | - * @access public |
|
| 2279 | - * @param string $input |
|
| 2280 | - * @return string |
|
| 2281 | - */ |
|
| 2282 | - public function form_form_field_input__wrap($input) |
|
| 2283 | - { |
|
| 2284 | - EE_Error::doing_it_wrong( |
|
| 2285 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2286 | - esc_html__( |
|
| 2287 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2288 | - 'event_espresso' |
|
| 2289 | - ), |
|
| 2290 | - '4.8.32.rc.000' |
|
| 2291 | - ); |
|
| 2292 | - return ' |
|
| 2271 | + } |
|
| 2272 | + |
|
| 2273 | + |
|
| 2274 | + /** |
|
| 2275 | + * form_form_field_input__wrap |
|
| 2276 | + * |
|
| 2277 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2278 | + * @access public |
|
| 2279 | + * @param string $input |
|
| 2280 | + * @return string |
|
| 2281 | + */ |
|
| 2282 | + public function form_form_field_input__wrap($input) |
|
| 2283 | + { |
|
| 2284 | + EE_Error::doing_it_wrong( |
|
| 2285 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2286 | + esc_html__( |
|
| 2287 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2288 | + 'event_espresso' |
|
| 2289 | + ), |
|
| 2290 | + '4.8.32.rc.000' |
|
| 2291 | + ); |
|
| 2292 | + return ' |
|
| 2293 | 2293 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 2294 | 2294 | ' . $input . ' |
| 2295 | 2295 | </td> |
| 2296 | 2296 | </tr>'; |
| 2297 | - } |
|
| 2298 | - |
|
| 2299 | - |
|
| 2300 | - /** |
|
| 2301 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2302 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2303 | - * to display the page |
|
| 2304 | - * |
|
| 2305 | - * @access protected |
|
| 2306 | - * @return void |
|
| 2307 | - * @throws EE_Error |
|
| 2308 | - */ |
|
| 2309 | - protected function _update_attendee_registration_form() |
|
| 2310 | - { |
|
| 2311 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2312 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2313 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2314 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2315 | - if ($success) { |
|
| 2316 | - $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2317 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2318 | - : array('action' => 'default'); |
|
| 2319 | - $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2320 | - } |
|
| 2321 | - } |
|
| 2322 | - } |
|
| 2323 | - |
|
| 2324 | - |
|
| 2325 | - /** |
|
| 2326 | - * Gets the form for saving registrations custom questions (if done |
|
| 2327 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2328 | - * |
|
| 2329 | - * @param int $REG_ID |
|
| 2330 | - * @return EE_Registration_Custom_Questions_Form |
|
| 2331 | - * @throws EE_Error |
|
| 2332 | - */ |
|
| 2333 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2334 | - { |
|
| 2335 | - if ( ! $this->_reg_custom_questions_form) { |
|
| 2336 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2337 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2338 | - EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2339 | - ); |
|
| 2340 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2341 | - } |
|
| 2342 | - return $this->_reg_custom_questions_form; |
|
| 2343 | - } |
|
| 2344 | - |
|
| 2345 | - |
|
| 2346 | - /** |
|
| 2347 | - * Saves |
|
| 2348 | - * |
|
| 2349 | - * @access private |
|
| 2350 | - * @param bool $REG_ID |
|
| 2351 | - * @return bool |
|
| 2352 | - * @throws EE_Error |
|
| 2353 | - */ |
|
| 2354 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2355 | - { |
|
| 2356 | - if ( ! $REG_ID) { |
|
| 2357 | - EE_Error::add_error( |
|
| 2358 | - esc_html__( |
|
| 2359 | - 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2360 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2361 | - ); |
|
| 2362 | - } |
|
| 2363 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2364 | - $form->receive_form_submission($this->_req_data); |
|
| 2365 | - $success = false; |
|
| 2366 | - if ($form->is_valid()) { |
|
| 2367 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2368 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2369 | - $where_conditions = array( |
|
| 2370 | - 'QST_ID' => $question_id, |
|
| 2371 | - 'REG_ID' => $REG_ID, |
|
| 2372 | - ); |
|
| 2373 | - $possibly_new_values = array( |
|
| 2374 | - 'ANS_value' => $input->normalized_value(), |
|
| 2375 | - ); |
|
| 2376 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2377 | - if ($answer instanceof EE_Answer) { |
|
| 2378 | - $success = $answer->save($possibly_new_values); |
|
| 2379 | - } else { |
|
| 2380 | - //insert it then |
|
| 2381 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2382 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2383 | - $success = $answer->save(); |
|
| 2384 | - } |
|
| 2385 | - } |
|
| 2386 | - } |
|
| 2387 | - } else { |
|
| 2388 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2389 | - } |
|
| 2390 | - return $success; |
|
| 2391 | - } |
|
| 2392 | - |
|
| 2393 | - |
|
| 2394 | - /** |
|
| 2395 | - * generates HTML for the Registration main meta box |
|
| 2396 | - * |
|
| 2397 | - * @access public |
|
| 2398 | - * @return void |
|
| 2399 | - * @throws DomainException |
|
| 2400 | - * @throws EE_Error |
|
| 2401 | - */ |
|
| 2402 | - public function _reg_attendees_meta_box() |
|
| 2403 | - { |
|
| 2404 | - $REG = EEM_Registration::instance(); |
|
| 2405 | - //get all other registrations on this transaction, and cache |
|
| 2406 | - //the attendees for them so we don't have to run another query using force_join |
|
| 2407 | - $registrations = $REG->get_all(array( |
|
| 2408 | - array( |
|
| 2409 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2410 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2411 | - ), |
|
| 2412 | - 'force_join' => array('Attendee'), |
|
| 2413 | - )); |
|
| 2414 | - $this->_template_args['attendees'] = array(); |
|
| 2415 | - $this->_template_args['attendee_notice'] = ''; |
|
| 2416 | - if (empty($registrations) |
|
| 2417 | - || (is_array($registrations) |
|
| 2418 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2419 | - ) { |
|
| 2420 | - EE_Error::add_error( |
|
| 2421 | - esc_html__( |
|
| 2422 | - 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2423 | - 'event_espresso' |
|
| 2424 | - ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2425 | - ); |
|
| 2426 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2427 | - } else { |
|
| 2428 | - $att_nmbr = 1; |
|
| 2429 | - foreach ($registrations as $registration) { |
|
| 2430 | - /* @var $registration EE_Registration */ |
|
| 2431 | - $attendee = $registration->attendee() |
|
| 2432 | - ? $registration->attendee() |
|
| 2433 | - : EEM_Attendee::instance() |
|
| 2434 | - ->create_default_object(); |
|
| 2435 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2436 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2437 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2438 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2439 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2440 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2441 | - ', ', |
|
| 2442 | - $attendee->full_address_as_array() |
|
| 2443 | - ); |
|
| 2444 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2445 | - array( |
|
| 2446 | - 'action' => 'edit_attendee', |
|
| 2447 | - 'post' => $attendee->ID(), |
|
| 2448 | - ), |
|
| 2449 | - REG_ADMIN_URL |
|
| 2450 | - ); |
|
| 2451 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2452 | - $att_nmbr++; |
|
| 2453 | - } |
|
| 2454 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2455 | - } |
|
| 2456 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2457 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2458 | - } |
|
| 2459 | - |
|
| 2460 | - |
|
| 2461 | - /** |
|
| 2462 | - * generates HTML for the Edit Registration side meta box |
|
| 2463 | - * |
|
| 2464 | - * @access public |
|
| 2465 | - * @return void |
|
| 2466 | - * @throws DomainException |
|
| 2467 | - * @throws EE_Error |
|
| 2468 | - */ |
|
| 2469 | - public function _reg_registrant_side_meta_box() |
|
| 2470 | - { |
|
| 2471 | - /*@var $attendee EE_Attendee */ |
|
| 2472 | - $att_check = $this->_registration->attendee(); |
|
| 2473 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2474 | - //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2475 | - //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2476 | - //primary registration object (that way we know if we need to show create button or not) |
|
| 2477 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2478 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2479 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2480 | - : null; |
|
| 2481 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2482 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2483 | - //custom attendee object so let's not worry about the primary reg. |
|
| 2484 | - $primary_registration = null; |
|
| 2485 | - } |
|
| 2486 | - } else { |
|
| 2487 | - $primary_registration = null; |
|
| 2488 | - } |
|
| 2489 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2490 | - $this->_template_args['fname'] = $attendee->fname(); |
|
| 2491 | - $this->_template_args['lname'] = $attendee->lname(); |
|
| 2492 | - $this->_template_args['email'] = $attendee->email(); |
|
| 2493 | - $this->_template_args['phone'] = $attendee->phone(); |
|
| 2494 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2495 | - //edit link |
|
| 2496 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2497 | - 'action' => 'edit_attendee', |
|
| 2498 | - 'post' => $attendee->ID(), |
|
| 2499 | - ), REG_ADMIN_URL); |
|
| 2500 | - $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2501 | - //create link |
|
| 2502 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2503 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2504 | - 'action' => 'duplicate_attendee', |
|
| 2505 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2506 | - ), REG_ADMIN_URL) : ''; |
|
| 2507 | - $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2508 | - $this->_template_args['att_check'] = $att_check; |
|
| 2509 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2510 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - |
|
| 2514 | - /** |
|
| 2515 | - * trash or restore registrations |
|
| 2516 | - * |
|
| 2517 | - * @param boolean $trash whether to archive or restore |
|
| 2518 | - * @return void |
|
| 2519 | - * @throws EE_Error |
|
| 2520 | - * @throws RuntimeException |
|
| 2521 | - * @access protected |
|
| 2522 | - */ |
|
| 2523 | - protected function _trash_or_restore_registrations($trash = true) |
|
| 2524 | - { |
|
| 2525 | - //if empty _REG_ID then get out because there's nothing to do |
|
| 2526 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2527 | - EE_Error::add_error( |
|
| 2528 | - sprintf( |
|
| 2529 | - esc_html__( |
|
| 2530 | - 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2531 | - 'event_espresso' |
|
| 2532 | - ), |
|
| 2533 | - $trash ? 'trash' : 'restore' |
|
| 2534 | - ), |
|
| 2535 | - __FILE__, __LINE__, __FUNCTION__ |
|
| 2536 | - ); |
|
| 2537 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2538 | - } |
|
| 2539 | - $success = 0; |
|
| 2540 | - $overwrite_msgs = false; |
|
| 2541 | - //Checkboxes |
|
| 2542 | - if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2543 | - $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2544 | - } |
|
| 2545 | - $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2546 | - // cycle thru checkboxes |
|
| 2547 | - foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2548 | - /** @var EE_Registration $REG */ |
|
| 2549 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2550 | - $payments = $REG->registration_payments(); |
|
| 2551 | - if (! empty($payments)) { |
|
| 2552 | - $name = $REG->attendee() instanceof EE_Attendee |
|
| 2553 | - ? $REG->attendee()->full_name() |
|
| 2554 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2555 | - $overwrite_msgs = true; |
|
| 2556 | - EE_Error::add_error( |
|
| 2557 | - sprintf( |
|
| 2558 | - esc_html__( |
|
| 2559 | - 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2560 | - 'event_espresso' |
|
| 2561 | - ), |
|
| 2562 | - $name |
|
| 2563 | - ), |
|
| 2564 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2565 | - ); |
|
| 2566 | - //can't trash this registration because it has payments. |
|
| 2567 | - continue; |
|
| 2568 | - } |
|
| 2569 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2570 | - if ($updated) { |
|
| 2571 | - $success++; |
|
| 2572 | - } |
|
| 2573 | - } |
|
| 2574 | - $this->_redirect_after_action( |
|
| 2575 | - $success === $reg_count, // were ALL registrations affected? |
|
| 2576 | - $success > 1 |
|
| 2577 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2578 | - : esc_html__('Registration', 'event_espresso'), |
|
| 2579 | - $trash |
|
| 2580 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2581 | - : esc_html__('restored', 'event_espresso'), |
|
| 2582 | - array('action' => 'default'), |
|
| 2583 | - $overwrite_msgs |
|
| 2584 | - ); |
|
| 2585 | - } |
|
| 2586 | - |
|
| 2587 | - |
|
| 2588 | - /** |
|
| 2589 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2590 | - * registration but also. |
|
| 2591 | - * 1. Removing relations to EE_Attendee |
|
| 2592 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2593 | - * ALSO trashed. |
|
| 2594 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2595 | - * 4. Removing relationships between all tickets and the related registrations |
|
| 2596 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2597 | - * 6. Deleting permanently any related Checkins. |
|
| 2598 | - * |
|
| 2599 | - * @return void |
|
| 2600 | - * @throws EE_Error |
|
| 2601 | - */ |
|
| 2602 | - protected function _delete_registrations() |
|
| 2603 | - { |
|
| 2604 | - $REG_MDL = EEM_Registration::instance(); |
|
| 2605 | - $success = 1; |
|
| 2606 | - //Checkboxes |
|
| 2607 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2608 | - // if array has more than one element than success message should be plural |
|
| 2609 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2610 | - // cycle thru checkboxes |
|
| 2611 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2612 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2613 | - if ( ! $REG instanceof EE_Registration) { |
|
| 2614 | - continue; |
|
| 2615 | - } |
|
| 2616 | - $deleted = $this->_delete_registration($REG); |
|
| 2617 | - if ( ! $deleted) { |
|
| 2618 | - $success = 0; |
|
| 2619 | - } |
|
| 2620 | - } |
|
| 2621 | - } else { |
|
| 2622 | - // grab single id and delete |
|
| 2623 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2624 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2625 | - $deleted = $this->_delete_registration($REG); |
|
| 2626 | - if ( ! $deleted) { |
|
| 2627 | - $success = 0; |
|
| 2628 | - } |
|
| 2629 | - } |
|
| 2630 | - $what = $success > 1 |
|
| 2631 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2632 | - : esc_html__('Registration', 'event_espresso'); |
|
| 2633 | - $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2634 | - $this->_redirect_after_action( |
|
| 2635 | - $success, |
|
| 2636 | - $what, |
|
| 2637 | - $action_desc, |
|
| 2638 | - array('action' => 'default'), |
|
| 2639 | - true |
|
| 2640 | - ); |
|
| 2641 | - } |
|
| 2642 | - |
|
| 2643 | - |
|
| 2644 | - /** |
|
| 2645 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2646 | - * models get affected. |
|
| 2647 | - * |
|
| 2648 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2649 | - * @return bool true = successful deletion, false = fail. |
|
| 2650 | - * @throws EE_Error |
|
| 2651 | - */ |
|
| 2652 | - protected function _delete_registration(EE_Registration $REG) |
|
| 2653 | - { |
|
| 2654 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2655 | - //registrations on the transaction that are NOT trashed. |
|
| 2656 | - $TXN = $REG->get_first_related('Transaction'); |
|
| 2657 | - $REGS = $TXN->get_many_related('Registration'); |
|
| 2658 | - $all_trashed = true; |
|
| 2659 | - foreach ($REGS as $registration) { |
|
| 2660 | - if ( ! $registration->get('REG_deleted')) { |
|
| 2661 | - $all_trashed = false; |
|
| 2662 | - } |
|
| 2663 | - } |
|
| 2664 | - if ( ! $all_trashed) { |
|
| 2665 | - EE_Error::add_error( |
|
| 2666 | - esc_html__( |
|
| 2667 | - 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2668 | - 'event_espresso' |
|
| 2669 | - ), |
|
| 2670 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2671 | - ); |
|
| 2672 | - return false; |
|
| 2673 | - } |
|
| 2674 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2675 | - //separately from THIS one). |
|
| 2676 | - foreach ($REGS as $registration) { |
|
| 2677 | - //delete related answers |
|
| 2678 | - $registration->delete_related_permanently('Answer'); |
|
| 2679 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2680 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 2681 | - if ($attendee instanceof EE_Attendee) { |
|
| 2682 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2683 | - } |
|
| 2684 | - //now remove relationships to tickets on this registration. |
|
| 2685 | - $registration->_remove_relations('Ticket'); |
|
| 2686 | - //now delete permanently the checkins related to this registration. |
|
| 2687 | - $registration->delete_related_permanently('Checkin'); |
|
| 2688 | - if ($registration->ID() === $REG->ID()) { |
|
| 2689 | - continue; |
|
| 2690 | - } //we don't want to delete permanently the existing registration just yet. |
|
| 2691 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2692 | - $registration->_remove_relations('Transaction'); |
|
| 2693 | - //delete permanently any related messages. |
|
| 2694 | - $registration->delete_related_permanently('Message'); |
|
| 2695 | - //now delete this registration permanently |
|
| 2696 | - $registration->delete_permanently(); |
|
| 2697 | - } |
|
| 2698 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2699 | - // (the transaction and line items should be all that's left). |
|
| 2700 | - // delete the line items related to the transaction for this registration. |
|
| 2701 | - $TXN->delete_related_permanently('Line_Item'); |
|
| 2702 | - //we need to remove all the relationships on the transaction |
|
| 2703 | - $TXN->delete_related_permanently('Payment'); |
|
| 2704 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2705 | - $TXN->delete_related_permanently('Message'); |
|
| 2706 | - //now we can delete this REG permanently (and the transaction of course) |
|
| 2707 | - $REG->delete_related_permanently('Transaction'); |
|
| 2708 | - return $REG->delete_permanently(); |
|
| 2709 | - } |
|
| 2710 | - |
|
| 2711 | - |
|
| 2712 | - /** |
|
| 2713 | - * generates HTML for the Register New Attendee Admin page |
|
| 2714 | - * |
|
| 2715 | - * @access private |
|
| 2716 | - * @throws DomainException |
|
| 2717 | - * @throws EE_Error |
|
| 2718 | - */ |
|
| 2719 | - public function new_registration() |
|
| 2720 | - { |
|
| 2721 | - if ( ! $this->_set_reg_event()) { |
|
| 2722 | - throw new EE_Error( |
|
| 2723 | - esc_html__( |
|
| 2724 | - 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2725 | - 'event_espresso' |
|
| 2726 | - ) |
|
| 2727 | - ); |
|
| 2728 | - } |
|
| 2729 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2730 | - // gotta start with a clean slate if we're not coming here via ajax |
|
| 2731 | - if ( ! defined('DOING_AJAX') |
|
| 2732 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2733 | - ) { |
|
| 2734 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2735 | - } |
|
| 2736 | - $this->_template_args['event_name'] = ''; |
|
| 2737 | - // event name |
|
| 2738 | - if ($this->_reg_event) { |
|
| 2739 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2740 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2741 | - 'action' => 'edit', |
|
| 2742 | - 'post' => $this->_reg_event->ID(), |
|
| 2743 | - ), EVENTS_ADMIN_URL); |
|
| 2744 | - $edit_event_lnk = '<a href="' |
|
| 2745 | - . $edit_event_url |
|
| 2746 | - . '" title="' |
|
| 2747 | - . esc_attr__('Edit ', 'event_espresso') |
|
| 2748 | - . $this->_reg_event->name() |
|
| 2749 | - . '">' |
|
| 2750 | - . esc_html__('Edit Event', 'event_espresso') |
|
| 2751 | - . '</a>'; |
|
| 2752 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2753 | - . $edit_event_lnk |
|
| 2754 | - . '</span>'; |
|
| 2755 | - } |
|
| 2756 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2757 | - if (defined('DOING_AJAX')) { |
|
| 2758 | - $this->_return_json(); |
|
| 2759 | - } |
|
| 2760 | - // grab header |
|
| 2761 | - $template_path = |
|
| 2762 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2763 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2764 | - $this->_template_args, true); |
|
| 2765 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2766 | - // the details template wrapper |
|
| 2767 | - $this->display_admin_page_with_sidebar(); |
|
| 2768 | - } |
|
| 2769 | - |
|
| 2770 | - |
|
| 2771 | - /** |
|
| 2772 | - * This returns the content for a registration step |
|
| 2773 | - * |
|
| 2774 | - * @access protected |
|
| 2775 | - * @return string html |
|
| 2776 | - * @throws DomainException |
|
| 2777 | - * @throws EE_Error |
|
| 2778 | - */ |
|
| 2779 | - protected function _get_registration_step_content() |
|
| 2780 | - { |
|
| 2781 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2782 | - $warning_msg = sprintf( |
|
| 2783 | - esc_html__( |
|
| 2784 | - '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2785 | - 'event_espresso' |
|
| 2786 | - ), |
|
| 2787 | - '<br />', |
|
| 2788 | - '<h3 class="important-notice">', |
|
| 2789 | - '</h3>', |
|
| 2790 | - '<div class="float-right">', |
|
| 2791 | - '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2792 | - '</div>', |
|
| 2793 | - '<b>', |
|
| 2794 | - '</b>' |
|
| 2795 | - ); |
|
| 2796 | - return ' |
|
| 2297 | + } |
|
| 2298 | + |
|
| 2299 | + |
|
| 2300 | + /** |
|
| 2301 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2302 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2303 | + * to display the page |
|
| 2304 | + * |
|
| 2305 | + * @access protected |
|
| 2306 | + * @return void |
|
| 2307 | + * @throws EE_Error |
|
| 2308 | + */ |
|
| 2309 | + protected function _update_attendee_registration_form() |
|
| 2310 | + { |
|
| 2311 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2312 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2313 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2314 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2315 | + if ($success) { |
|
| 2316 | + $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2317 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2318 | + : array('action' => 'default'); |
|
| 2319 | + $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2320 | + } |
|
| 2321 | + } |
|
| 2322 | + } |
|
| 2323 | + |
|
| 2324 | + |
|
| 2325 | + /** |
|
| 2326 | + * Gets the form for saving registrations custom questions (if done |
|
| 2327 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2328 | + * |
|
| 2329 | + * @param int $REG_ID |
|
| 2330 | + * @return EE_Registration_Custom_Questions_Form |
|
| 2331 | + * @throws EE_Error |
|
| 2332 | + */ |
|
| 2333 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2334 | + { |
|
| 2335 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 2336 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2337 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2338 | + EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2339 | + ); |
|
| 2340 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2341 | + } |
|
| 2342 | + return $this->_reg_custom_questions_form; |
|
| 2343 | + } |
|
| 2344 | + |
|
| 2345 | + |
|
| 2346 | + /** |
|
| 2347 | + * Saves |
|
| 2348 | + * |
|
| 2349 | + * @access private |
|
| 2350 | + * @param bool $REG_ID |
|
| 2351 | + * @return bool |
|
| 2352 | + * @throws EE_Error |
|
| 2353 | + */ |
|
| 2354 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2355 | + { |
|
| 2356 | + if ( ! $REG_ID) { |
|
| 2357 | + EE_Error::add_error( |
|
| 2358 | + esc_html__( |
|
| 2359 | + 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2360 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2361 | + ); |
|
| 2362 | + } |
|
| 2363 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2364 | + $form->receive_form_submission($this->_req_data); |
|
| 2365 | + $success = false; |
|
| 2366 | + if ($form->is_valid()) { |
|
| 2367 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2368 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2369 | + $where_conditions = array( |
|
| 2370 | + 'QST_ID' => $question_id, |
|
| 2371 | + 'REG_ID' => $REG_ID, |
|
| 2372 | + ); |
|
| 2373 | + $possibly_new_values = array( |
|
| 2374 | + 'ANS_value' => $input->normalized_value(), |
|
| 2375 | + ); |
|
| 2376 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2377 | + if ($answer instanceof EE_Answer) { |
|
| 2378 | + $success = $answer->save($possibly_new_values); |
|
| 2379 | + } else { |
|
| 2380 | + //insert it then |
|
| 2381 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2382 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2383 | + $success = $answer->save(); |
|
| 2384 | + } |
|
| 2385 | + } |
|
| 2386 | + } |
|
| 2387 | + } else { |
|
| 2388 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2389 | + } |
|
| 2390 | + return $success; |
|
| 2391 | + } |
|
| 2392 | + |
|
| 2393 | + |
|
| 2394 | + /** |
|
| 2395 | + * generates HTML for the Registration main meta box |
|
| 2396 | + * |
|
| 2397 | + * @access public |
|
| 2398 | + * @return void |
|
| 2399 | + * @throws DomainException |
|
| 2400 | + * @throws EE_Error |
|
| 2401 | + */ |
|
| 2402 | + public function _reg_attendees_meta_box() |
|
| 2403 | + { |
|
| 2404 | + $REG = EEM_Registration::instance(); |
|
| 2405 | + //get all other registrations on this transaction, and cache |
|
| 2406 | + //the attendees for them so we don't have to run another query using force_join |
|
| 2407 | + $registrations = $REG->get_all(array( |
|
| 2408 | + array( |
|
| 2409 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2410 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2411 | + ), |
|
| 2412 | + 'force_join' => array('Attendee'), |
|
| 2413 | + )); |
|
| 2414 | + $this->_template_args['attendees'] = array(); |
|
| 2415 | + $this->_template_args['attendee_notice'] = ''; |
|
| 2416 | + if (empty($registrations) |
|
| 2417 | + || (is_array($registrations) |
|
| 2418 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2419 | + ) { |
|
| 2420 | + EE_Error::add_error( |
|
| 2421 | + esc_html__( |
|
| 2422 | + 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2423 | + 'event_espresso' |
|
| 2424 | + ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2425 | + ); |
|
| 2426 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2427 | + } else { |
|
| 2428 | + $att_nmbr = 1; |
|
| 2429 | + foreach ($registrations as $registration) { |
|
| 2430 | + /* @var $registration EE_Registration */ |
|
| 2431 | + $attendee = $registration->attendee() |
|
| 2432 | + ? $registration->attendee() |
|
| 2433 | + : EEM_Attendee::instance() |
|
| 2434 | + ->create_default_object(); |
|
| 2435 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2436 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2437 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2438 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2439 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2440 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2441 | + ', ', |
|
| 2442 | + $attendee->full_address_as_array() |
|
| 2443 | + ); |
|
| 2444 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2445 | + array( |
|
| 2446 | + 'action' => 'edit_attendee', |
|
| 2447 | + 'post' => $attendee->ID(), |
|
| 2448 | + ), |
|
| 2449 | + REG_ADMIN_URL |
|
| 2450 | + ); |
|
| 2451 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2452 | + $att_nmbr++; |
|
| 2453 | + } |
|
| 2454 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2455 | + } |
|
| 2456 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2457 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2458 | + } |
|
| 2459 | + |
|
| 2460 | + |
|
| 2461 | + /** |
|
| 2462 | + * generates HTML for the Edit Registration side meta box |
|
| 2463 | + * |
|
| 2464 | + * @access public |
|
| 2465 | + * @return void |
|
| 2466 | + * @throws DomainException |
|
| 2467 | + * @throws EE_Error |
|
| 2468 | + */ |
|
| 2469 | + public function _reg_registrant_side_meta_box() |
|
| 2470 | + { |
|
| 2471 | + /*@var $attendee EE_Attendee */ |
|
| 2472 | + $att_check = $this->_registration->attendee(); |
|
| 2473 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2474 | + //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2475 | + //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2476 | + //primary registration object (that way we know if we need to show create button or not) |
|
| 2477 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2478 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2479 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2480 | + : null; |
|
| 2481 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2482 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2483 | + //custom attendee object so let's not worry about the primary reg. |
|
| 2484 | + $primary_registration = null; |
|
| 2485 | + } |
|
| 2486 | + } else { |
|
| 2487 | + $primary_registration = null; |
|
| 2488 | + } |
|
| 2489 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2490 | + $this->_template_args['fname'] = $attendee->fname(); |
|
| 2491 | + $this->_template_args['lname'] = $attendee->lname(); |
|
| 2492 | + $this->_template_args['email'] = $attendee->email(); |
|
| 2493 | + $this->_template_args['phone'] = $attendee->phone(); |
|
| 2494 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2495 | + //edit link |
|
| 2496 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2497 | + 'action' => 'edit_attendee', |
|
| 2498 | + 'post' => $attendee->ID(), |
|
| 2499 | + ), REG_ADMIN_URL); |
|
| 2500 | + $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2501 | + //create link |
|
| 2502 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2503 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2504 | + 'action' => 'duplicate_attendee', |
|
| 2505 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2506 | + ), REG_ADMIN_URL) : ''; |
|
| 2507 | + $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2508 | + $this->_template_args['att_check'] = $att_check; |
|
| 2509 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2510 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2511 | + } |
|
| 2512 | + |
|
| 2513 | + |
|
| 2514 | + /** |
|
| 2515 | + * trash or restore registrations |
|
| 2516 | + * |
|
| 2517 | + * @param boolean $trash whether to archive or restore |
|
| 2518 | + * @return void |
|
| 2519 | + * @throws EE_Error |
|
| 2520 | + * @throws RuntimeException |
|
| 2521 | + * @access protected |
|
| 2522 | + */ |
|
| 2523 | + protected function _trash_or_restore_registrations($trash = true) |
|
| 2524 | + { |
|
| 2525 | + //if empty _REG_ID then get out because there's nothing to do |
|
| 2526 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2527 | + EE_Error::add_error( |
|
| 2528 | + sprintf( |
|
| 2529 | + esc_html__( |
|
| 2530 | + 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2531 | + 'event_espresso' |
|
| 2532 | + ), |
|
| 2533 | + $trash ? 'trash' : 'restore' |
|
| 2534 | + ), |
|
| 2535 | + __FILE__, __LINE__, __FUNCTION__ |
|
| 2536 | + ); |
|
| 2537 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2538 | + } |
|
| 2539 | + $success = 0; |
|
| 2540 | + $overwrite_msgs = false; |
|
| 2541 | + //Checkboxes |
|
| 2542 | + if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2543 | + $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2544 | + } |
|
| 2545 | + $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2546 | + // cycle thru checkboxes |
|
| 2547 | + foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2548 | + /** @var EE_Registration $REG */ |
|
| 2549 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2550 | + $payments = $REG->registration_payments(); |
|
| 2551 | + if (! empty($payments)) { |
|
| 2552 | + $name = $REG->attendee() instanceof EE_Attendee |
|
| 2553 | + ? $REG->attendee()->full_name() |
|
| 2554 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2555 | + $overwrite_msgs = true; |
|
| 2556 | + EE_Error::add_error( |
|
| 2557 | + sprintf( |
|
| 2558 | + esc_html__( |
|
| 2559 | + 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2560 | + 'event_espresso' |
|
| 2561 | + ), |
|
| 2562 | + $name |
|
| 2563 | + ), |
|
| 2564 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2565 | + ); |
|
| 2566 | + //can't trash this registration because it has payments. |
|
| 2567 | + continue; |
|
| 2568 | + } |
|
| 2569 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2570 | + if ($updated) { |
|
| 2571 | + $success++; |
|
| 2572 | + } |
|
| 2573 | + } |
|
| 2574 | + $this->_redirect_after_action( |
|
| 2575 | + $success === $reg_count, // were ALL registrations affected? |
|
| 2576 | + $success > 1 |
|
| 2577 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2578 | + : esc_html__('Registration', 'event_espresso'), |
|
| 2579 | + $trash |
|
| 2580 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2581 | + : esc_html__('restored', 'event_espresso'), |
|
| 2582 | + array('action' => 'default'), |
|
| 2583 | + $overwrite_msgs |
|
| 2584 | + ); |
|
| 2585 | + } |
|
| 2586 | + |
|
| 2587 | + |
|
| 2588 | + /** |
|
| 2589 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2590 | + * registration but also. |
|
| 2591 | + * 1. Removing relations to EE_Attendee |
|
| 2592 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2593 | + * ALSO trashed. |
|
| 2594 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2595 | + * 4. Removing relationships between all tickets and the related registrations |
|
| 2596 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2597 | + * 6. Deleting permanently any related Checkins. |
|
| 2598 | + * |
|
| 2599 | + * @return void |
|
| 2600 | + * @throws EE_Error |
|
| 2601 | + */ |
|
| 2602 | + protected function _delete_registrations() |
|
| 2603 | + { |
|
| 2604 | + $REG_MDL = EEM_Registration::instance(); |
|
| 2605 | + $success = 1; |
|
| 2606 | + //Checkboxes |
|
| 2607 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2608 | + // if array has more than one element than success message should be plural |
|
| 2609 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2610 | + // cycle thru checkboxes |
|
| 2611 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2612 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2613 | + if ( ! $REG instanceof EE_Registration) { |
|
| 2614 | + continue; |
|
| 2615 | + } |
|
| 2616 | + $deleted = $this->_delete_registration($REG); |
|
| 2617 | + if ( ! $deleted) { |
|
| 2618 | + $success = 0; |
|
| 2619 | + } |
|
| 2620 | + } |
|
| 2621 | + } else { |
|
| 2622 | + // grab single id and delete |
|
| 2623 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2624 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2625 | + $deleted = $this->_delete_registration($REG); |
|
| 2626 | + if ( ! $deleted) { |
|
| 2627 | + $success = 0; |
|
| 2628 | + } |
|
| 2629 | + } |
|
| 2630 | + $what = $success > 1 |
|
| 2631 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2632 | + : esc_html__('Registration', 'event_espresso'); |
|
| 2633 | + $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2634 | + $this->_redirect_after_action( |
|
| 2635 | + $success, |
|
| 2636 | + $what, |
|
| 2637 | + $action_desc, |
|
| 2638 | + array('action' => 'default'), |
|
| 2639 | + true |
|
| 2640 | + ); |
|
| 2641 | + } |
|
| 2642 | + |
|
| 2643 | + |
|
| 2644 | + /** |
|
| 2645 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2646 | + * models get affected. |
|
| 2647 | + * |
|
| 2648 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2649 | + * @return bool true = successful deletion, false = fail. |
|
| 2650 | + * @throws EE_Error |
|
| 2651 | + */ |
|
| 2652 | + protected function _delete_registration(EE_Registration $REG) |
|
| 2653 | + { |
|
| 2654 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2655 | + //registrations on the transaction that are NOT trashed. |
|
| 2656 | + $TXN = $REG->get_first_related('Transaction'); |
|
| 2657 | + $REGS = $TXN->get_many_related('Registration'); |
|
| 2658 | + $all_trashed = true; |
|
| 2659 | + foreach ($REGS as $registration) { |
|
| 2660 | + if ( ! $registration->get('REG_deleted')) { |
|
| 2661 | + $all_trashed = false; |
|
| 2662 | + } |
|
| 2663 | + } |
|
| 2664 | + if ( ! $all_trashed) { |
|
| 2665 | + EE_Error::add_error( |
|
| 2666 | + esc_html__( |
|
| 2667 | + 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2668 | + 'event_espresso' |
|
| 2669 | + ), |
|
| 2670 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2671 | + ); |
|
| 2672 | + return false; |
|
| 2673 | + } |
|
| 2674 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2675 | + //separately from THIS one). |
|
| 2676 | + foreach ($REGS as $registration) { |
|
| 2677 | + //delete related answers |
|
| 2678 | + $registration->delete_related_permanently('Answer'); |
|
| 2679 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2680 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 2681 | + if ($attendee instanceof EE_Attendee) { |
|
| 2682 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2683 | + } |
|
| 2684 | + //now remove relationships to tickets on this registration. |
|
| 2685 | + $registration->_remove_relations('Ticket'); |
|
| 2686 | + //now delete permanently the checkins related to this registration. |
|
| 2687 | + $registration->delete_related_permanently('Checkin'); |
|
| 2688 | + if ($registration->ID() === $REG->ID()) { |
|
| 2689 | + continue; |
|
| 2690 | + } //we don't want to delete permanently the existing registration just yet. |
|
| 2691 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2692 | + $registration->_remove_relations('Transaction'); |
|
| 2693 | + //delete permanently any related messages. |
|
| 2694 | + $registration->delete_related_permanently('Message'); |
|
| 2695 | + //now delete this registration permanently |
|
| 2696 | + $registration->delete_permanently(); |
|
| 2697 | + } |
|
| 2698 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2699 | + // (the transaction and line items should be all that's left). |
|
| 2700 | + // delete the line items related to the transaction for this registration. |
|
| 2701 | + $TXN->delete_related_permanently('Line_Item'); |
|
| 2702 | + //we need to remove all the relationships on the transaction |
|
| 2703 | + $TXN->delete_related_permanently('Payment'); |
|
| 2704 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2705 | + $TXN->delete_related_permanently('Message'); |
|
| 2706 | + //now we can delete this REG permanently (and the transaction of course) |
|
| 2707 | + $REG->delete_related_permanently('Transaction'); |
|
| 2708 | + return $REG->delete_permanently(); |
|
| 2709 | + } |
|
| 2710 | + |
|
| 2711 | + |
|
| 2712 | + /** |
|
| 2713 | + * generates HTML for the Register New Attendee Admin page |
|
| 2714 | + * |
|
| 2715 | + * @access private |
|
| 2716 | + * @throws DomainException |
|
| 2717 | + * @throws EE_Error |
|
| 2718 | + */ |
|
| 2719 | + public function new_registration() |
|
| 2720 | + { |
|
| 2721 | + if ( ! $this->_set_reg_event()) { |
|
| 2722 | + throw new EE_Error( |
|
| 2723 | + esc_html__( |
|
| 2724 | + 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2725 | + 'event_espresso' |
|
| 2726 | + ) |
|
| 2727 | + ); |
|
| 2728 | + } |
|
| 2729 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2730 | + // gotta start with a clean slate if we're not coming here via ajax |
|
| 2731 | + if ( ! defined('DOING_AJAX') |
|
| 2732 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2733 | + ) { |
|
| 2734 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2735 | + } |
|
| 2736 | + $this->_template_args['event_name'] = ''; |
|
| 2737 | + // event name |
|
| 2738 | + if ($this->_reg_event) { |
|
| 2739 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2740 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2741 | + 'action' => 'edit', |
|
| 2742 | + 'post' => $this->_reg_event->ID(), |
|
| 2743 | + ), EVENTS_ADMIN_URL); |
|
| 2744 | + $edit_event_lnk = '<a href="' |
|
| 2745 | + . $edit_event_url |
|
| 2746 | + . '" title="' |
|
| 2747 | + . esc_attr__('Edit ', 'event_espresso') |
|
| 2748 | + . $this->_reg_event->name() |
|
| 2749 | + . '">' |
|
| 2750 | + . esc_html__('Edit Event', 'event_espresso') |
|
| 2751 | + . '</a>'; |
|
| 2752 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2753 | + . $edit_event_lnk |
|
| 2754 | + . '</span>'; |
|
| 2755 | + } |
|
| 2756 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2757 | + if (defined('DOING_AJAX')) { |
|
| 2758 | + $this->_return_json(); |
|
| 2759 | + } |
|
| 2760 | + // grab header |
|
| 2761 | + $template_path = |
|
| 2762 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2763 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2764 | + $this->_template_args, true); |
|
| 2765 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2766 | + // the details template wrapper |
|
| 2767 | + $this->display_admin_page_with_sidebar(); |
|
| 2768 | + } |
|
| 2769 | + |
|
| 2770 | + |
|
| 2771 | + /** |
|
| 2772 | + * This returns the content for a registration step |
|
| 2773 | + * |
|
| 2774 | + * @access protected |
|
| 2775 | + * @return string html |
|
| 2776 | + * @throws DomainException |
|
| 2777 | + * @throws EE_Error |
|
| 2778 | + */ |
|
| 2779 | + protected function _get_registration_step_content() |
|
| 2780 | + { |
|
| 2781 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2782 | + $warning_msg = sprintf( |
|
| 2783 | + esc_html__( |
|
| 2784 | + '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2785 | + 'event_espresso' |
|
| 2786 | + ), |
|
| 2787 | + '<br />', |
|
| 2788 | + '<h3 class="important-notice">', |
|
| 2789 | + '</h3>', |
|
| 2790 | + '<div class="float-right">', |
|
| 2791 | + '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2792 | + '</div>', |
|
| 2793 | + '<b>', |
|
| 2794 | + '</b>' |
|
| 2795 | + ); |
|
| 2796 | + return ' |
|
| 2797 | 2797 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
| 2798 | 2798 | <script > |
| 2799 | 2799 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2806,792 +2806,792 @@ discard block |
||
| 2806 | 2806 | } |
| 2807 | 2807 | }, 800 ); |
| 2808 | 2808 | </script >'; |
| 2809 | - } |
|
| 2810 | - $template_args = array( |
|
| 2811 | - 'title' => '', |
|
| 2812 | - 'content' => '', |
|
| 2813 | - 'step_button_text' => '', |
|
| 2814 | - 'show_notification_toggle' => false, |
|
| 2815 | - ); |
|
| 2816 | - //to indicate we're processing a new registration |
|
| 2817 | - $hidden_fields = array( |
|
| 2818 | - 'processing_registration' => array( |
|
| 2819 | - 'type' => 'hidden', |
|
| 2820 | - 'value' => 0, |
|
| 2821 | - ), |
|
| 2822 | - 'event_id' => array( |
|
| 2823 | - 'type' => 'hidden', |
|
| 2824 | - 'value' => $this->_reg_event->ID(), |
|
| 2825 | - ), |
|
| 2826 | - ); |
|
| 2827 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2828 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2829 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2830 | - switch ($step) { |
|
| 2831 | - case 'ticket' : |
|
| 2832 | - $hidden_fields['processing_registration']['value'] = 1; |
|
| 2833 | - $template_args['title'] = esc_html__( |
|
| 2834 | - 'Step One: Select the Ticket for this registration', |
|
| 2835 | - 'event_espresso' |
|
| 2836 | - ); |
|
| 2837 | - $template_args['content'] = |
|
| 2838 | - EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2839 | - $template_args['step_button_text'] = esc_html__( |
|
| 2840 | - 'Add Tickets and Continue to Registrant Details', |
|
| 2841 | - 'event_espresso' |
|
| 2842 | - ); |
|
| 2843 | - $template_args['show_notification_toggle'] = false; |
|
| 2844 | - break; |
|
| 2845 | - case 'questions' : |
|
| 2846 | - $hidden_fields['processing_registration']['value'] = 2; |
|
| 2847 | - $template_args['title'] = esc_html__( |
|
| 2848 | - 'Step Two: Add Registrant Details for this Registration', |
|
| 2849 | - 'event_espresso' |
|
| 2850 | - ); |
|
| 2851 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2852 | - // properly by the first process_reg_step run. |
|
| 2853 | - $template_args['content'] = |
|
| 2854 | - EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2855 | - $template_args['step_button_text'] = esc_html__( |
|
| 2856 | - 'Save Registration and Continue to Details', |
|
| 2857 | - 'event_espresso' |
|
| 2858 | - ); |
|
| 2859 | - $template_args['show_notification_toggle'] = true; |
|
| 2860 | - break; |
|
| 2861 | - } |
|
| 2862 | - //we come back to the process_registration_step route. |
|
| 2863 | - $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2864 | - return EEH_Template::display_template( |
|
| 2865 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2866 | - $template_args, |
|
| 2867 | - true |
|
| 2868 | - ); |
|
| 2869 | - } |
|
| 2870 | - |
|
| 2871 | - |
|
| 2872 | - /** |
|
| 2873 | - * set_reg_event |
|
| 2874 | - * |
|
| 2875 | - * @access private |
|
| 2876 | - * @return bool |
|
| 2877 | - * @throws EE_Error |
|
| 2878 | - */ |
|
| 2879 | - private function _set_reg_event() |
|
| 2880 | - { |
|
| 2881 | - if (is_object($this->_reg_event)) { |
|
| 2882 | - return true; |
|
| 2883 | - } |
|
| 2884 | - $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2885 | - if ( ! $EVT_ID) { |
|
| 2886 | - return false; |
|
| 2887 | - } |
|
| 2888 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2889 | - return true; |
|
| 2890 | - } |
|
| 2891 | - |
|
| 2892 | - |
|
| 2893 | - /** |
|
| 2894 | - * process_reg_step |
|
| 2895 | - * |
|
| 2896 | - * @access public |
|
| 2897 | - * @return string |
|
| 2898 | - * @throws DomainException |
|
| 2899 | - * @throws EE_Error |
|
| 2900 | - * @throws RuntimeException |
|
| 2901 | - */ |
|
| 2902 | - public function process_reg_step() |
|
| 2903 | - { |
|
| 2904 | - EE_System::do_not_cache(); |
|
| 2905 | - $this->_set_reg_event(); |
|
| 2906 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2907 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2908 | - //what step are we on? |
|
| 2909 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2910 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2911 | - //if doing ajax then we need to verify the nonce |
|
| 2912 | - if (defined('DOING_AJAX')) { |
|
| 2913 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2914 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2915 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2916 | - } |
|
| 2917 | - switch ($step) { |
|
| 2918 | - case 'ticket' : |
|
| 2919 | - //process ticket selection |
|
| 2920 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2921 | - if ($success) { |
|
| 2922 | - EE_Error::add_success( |
|
| 2923 | - esc_html__( |
|
| 2924 | - 'Tickets Selected. Now complete the registration.', |
|
| 2925 | - 'event_espresso' |
|
| 2926 | - ) |
|
| 2927 | - ); |
|
| 2928 | - } else { |
|
| 2929 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2930 | - } |
|
| 2931 | - if (defined('DOING_AJAX')) { |
|
| 2932 | - $this->new_registration(); //display next step |
|
| 2933 | - } else { |
|
| 2934 | - $query_args = array( |
|
| 2935 | - 'action' => 'new_registration', |
|
| 2936 | - 'processing_registration' => 1, |
|
| 2937 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2938 | - 'uts' => time(), |
|
| 2939 | - ); |
|
| 2940 | - $this->_redirect_after_action( |
|
| 2941 | - false, |
|
| 2942 | - '', |
|
| 2943 | - '', |
|
| 2944 | - $query_args, |
|
| 2945 | - true |
|
| 2946 | - ); |
|
| 2947 | - } |
|
| 2948 | - break; |
|
| 2949 | - case 'questions' : |
|
| 2950 | - if (! isset( |
|
| 2951 | - $this->_req_data['txn_reg_status_change'], |
|
| 2952 | - $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 2953 | - ) { |
|
| 2954 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2955 | - } |
|
| 2956 | - //process registration |
|
| 2957 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2958 | - if ($cart instanceof EE_Cart) { |
|
| 2959 | - $grand_total = $cart->get_cart_grand_total(); |
|
| 2960 | - if ($grand_total instanceof EE_Line_Item) { |
|
| 2961 | - $grand_total->save_this_and_descendants_to_txn(); |
|
| 2962 | - } |
|
| 2963 | - } |
|
| 2964 | - if ( ! $transaction instanceof EE_Transaction) { |
|
| 2965 | - $query_args = array( |
|
| 2966 | - 'action' => 'new_registration', |
|
| 2967 | - 'processing_registration' => 2, |
|
| 2968 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2969 | - 'uts' => time(), |
|
| 2970 | - ); |
|
| 2971 | - if (defined('DOING_AJAX')) { |
|
| 2972 | - //display registration form again because there are errors (maybe validation?) |
|
| 2973 | - $this->new_registration(); |
|
| 2974 | - return; |
|
| 2975 | - } else { |
|
| 2976 | - $this->_redirect_after_action( |
|
| 2977 | - false, |
|
| 2978 | - '', |
|
| 2979 | - '', |
|
| 2980 | - $query_args, |
|
| 2981 | - true |
|
| 2982 | - ); |
|
| 2983 | - return; |
|
| 2984 | - } |
|
| 2985 | - } |
|
| 2986 | - // maybe update status, and make sure to save transaction if not done already |
|
| 2987 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2988 | - $transaction->save(); |
|
| 2989 | - } |
|
| 2990 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2991 | - $this->_req_data = array(); |
|
| 2992 | - $query_args = array( |
|
| 2993 | - 'action' => 'redirect_to_txn', |
|
| 2994 | - 'TXN_ID' => $transaction->ID(), |
|
| 2995 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2996 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2997 | - 'redirect_from' => 'new_registration', |
|
| 2998 | - ); |
|
| 2999 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3000 | - break; |
|
| 3001 | - } |
|
| 3002 | - //what are you looking here for? Should be nothing to do at this point. |
|
| 3003 | - } |
|
| 3004 | - |
|
| 3005 | - |
|
| 3006 | - /** |
|
| 3007 | - * redirect_to_txn |
|
| 3008 | - * |
|
| 3009 | - * @access public |
|
| 3010 | - * @return void |
|
| 3011 | - * @throws EE_Error |
|
| 3012 | - */ |
|
| 3013 | - public function redirect_to_txn() |
|
| 3014 | - { |
|
| 3015 | - EE_System::do_not_cache(); |
|
| 3016 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3017 | - $query_args = array( |
|
| 3018 | - 'action' => 'view_transaction', |
|
| 3019 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 3020 | - 'page' => 'espresso_transactions', |
|
| 3021 | - ); |
|
| 3022 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 3023 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 3024 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 3025 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 3026 | - } |
|
| 3027 | - EE_Error::add_success( |
|
| 3028 | - esc_html__( |
|
| 3029 | - 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 3030 | - 'event_espresso' |
|
| 3031 | - ) |
|
| 3032 | - ); |
|
| 3033 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3034 | - } |
|
| 3035 | - |
|
| 3036 | - |
|
| 3037 | - /** |
|
| 3038 | - * generates HTML for the Attendee Contact List |
|
| 3039 | - * |
|
| 3040 | - * @access protected |
|
| 3041 | - * @return void |
|
| 3042 | - */ |
|
| 3043 | - protected function _attendee_contact_list_table() |
|
| 3044 | - { |
|
| 3045 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3046 | - $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 3047 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 3048 | - } |
|
| 3049 | - |
|
| 3050 | - |
|
| 3051 | - /** |
|
| 3052 | - * get_attendees |
|
| 3053 | - * |
|
| 3054 | - * @param $per_page |
|
| 3055 | - * @param bool $count whether to return count or data. |
|
| 3056 | - * @param bool $trash |
|
| 3057 | - * @return array |
|
| 3058 | - * @throws EE_Error |
|
| 3059 | - * @access public |
|
| 3060 | - */ |
|
| 3061 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
| 3062 | - { |
|
| 3063 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3064 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3065 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 3066 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 3067 | - switch ($this->_req_data['orderby']) { |
|
| 3068 | - case 'ATT_ID': |
|
| 3069 | - $orderby = 'ATT_ID'; |
|
| 3070 | - break; |
|
| 3071 | - case 'ATT_fname': |
|
| 3072 | - $orderby = 'ATT_fname'; |
|
| 3073 | - break; |
|
| 3074 | - case 'ATT_email': |
|
| 3075 | - $orderby = 'ATT_email'; |
|
| 3076 | - break; |
|
| 3077 | - case 'ATT_city': |
|
| 3078 | - $orderby = 'ATT_city'; |
|
| 3079 | - break; |
|
| 3080 | - case 'STA_ID': |
|
| 3081 | - $orderby = 'STA_ID'; |
|
| 3082 | - break; |
|
| 3083 | - case 'CNT_ID': |
|
| 3084 | - $orderby = 'CNT_ID'; |
|
| 3085 | - break; |
|
| 3086 | - default: |
|
| 3087 | - $orderby = 'ATT_lname'; |
|
| 3088 | - } |
|
| 3089 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 3090 | - ? $this->_req_data['order'] |
|
| 3091 | - : 'ASC'; |
|
| 3092 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 3093 | - ? $this->_req_data['paged'] |
|
| 3094 | - : 1; |
|
| 3095 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 3096 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 3097 | - ? $this->_req_data['perpage'] |
|
| 3098 | - : $per_page; |
|
| 3099 | - $_where = array(); |
|
| 3100 | - if ( ! empty($this->_req_data['s'])) { |
|
| 3101 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 3102 | - $_where['OR'] = array( |
|
| 3103 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 3104 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 3105 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 3106 | - 'ATT_fname' => array('LIKE', $sstr), |
|
| 3107 | - 'ATT_lname' => array('LIKE', $sstr), |
|
| 3108 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3109 | - 'ATT_email' => array('LIKE', $sstr), |
|
| 3110 | - 'ATT_address' => array('LIKE', $sstr), |
|
| 3111 | - 'ATT_address2' => array('LIKE', $sstr), |
|
| 3112 | - 'ATT_city' => array('LIKE', $sstr), |
|
| 3113 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3114 | - 'State.STA_name' => array('LIKE', $sstr), |
|
| 3115 | - 'ATT_phone' => array('LIKE', $sstr), |
|
| 3116 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3117 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3118 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3119 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3120 | - ); |
|
| 3121 | - } |
|
| 3122 | - $offset = ($current_page - 1) * $per_page; |
|
| 3123 | - $limit = $count ? null : array($offset, $per_page); |
|
| 3124 | - if ($trash) { |
|
| 3125 | - $_where['status'] = array('!=', 'publish'); |
|
| 3126 | - $all_attendees = $count |
|
| 3127 | - ? $ATT_MDL->count(array( |
|
| 3128 | - $_where, |
|
| 3129 | - 'order_by' => array($orderby => $sort), |
|
| 3130 | - 'limit' => $limit, |
|
| 3131 | - ), 'ATT_ID', true) |
|
| 3132 | - : $ATT_MDL->get_all(array( |
|
| 3133 | - $_where, |
|
| 3134 | - 'order_by' => array($orderby => $sort), |
|
| 3135 | - 'limit' => $limit, |
|
| 3136 | - )); |
|
| 3137 | - } else { |
|
| 3138 | - $_where['status'] = array('IN', array('publish')); |
|
| 3139 | - $all_attendees = $count |
|
| 3140 | - ? $ATT_MDL->count(array( |
|
| 3141 | - $_where, |
|
| 3142 | - 'order_by' => array($orderby => $sort), |
|
| 3143 | - 'limit' => $limit, |
|
| 3144 | - ), 'ATT_ID', true) |
|
| 3145 | - : $ATT_MDL->get_all(array( |
|
| 3146 | - $_where, |
|
| 3147 | - 'order_by' => array($orderby => $sort), |
|
| 3148 | - 'limit' => $limit, |
|
| 3149 | - )); |
|
| 3150 | - } |
|
| 3151 | - return $all_attendees; |
|
| 3152 | - } |
|
| 3153 | - |
|
| 3154 | - |
|
| 3155 | - /** |
|
| 3156 | - * This is just taking care of resending the registration confirmation |
|
| 3157 | - * |
|
| 3158 | - * @access protected |
|
| 3159 | - * @return void |
|
| 3160 | - */ |
|
| 3161 | - protected function _resend_registration() |
|
| 3162 | - { |
|
| 3163 | - $this->_process_resend_registration(); |
|
| 3164 | - $query_args = isset($this->_req_data['redirect_to']) |
|
| 3165 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3166 | - : array('action' => 'default'); |
|
| 3167 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3168 | - } |
|
| 3169 | - |
|
| 3170 | - /** |
|
| 3171 | - * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3172 | - * to use when selecting registrations |
|
| 3173 | - * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3174 | - * the query parameters from the request |
|
| 3175 | - * @return void ends the request with a redirect or download |
|
| 3176 | - */ |
|
| 3177 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3178 | - { |
|
| 3179 | - if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3180 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3181 | - array( |
|
| 3182 | - 'page' => 'espresso_batch', |
|
| 3183 | - 'batch' => 'file', |
|
| 3184 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3185 | - 'filters' => urlencode( |
|
| 3186 | - serialize( |
|
| 3187 | - call_user_func( |
|
| 3188 | - array( $this, $method_name_for_getting_query_params ), |
|
| 3189 | - EEH_Array::is_set( |
|
| 3190 | - $this->_req_data, |
|
| 3191 | - 'filters', |
|
| 3192 | - array() |
|
| 3193 | - ) |
|
| 3194 | - ) |
|
| 3195 | - ) |
|
| 3196 | - ), |
|
| 3197 | - 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3198 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3199 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3200 | - ))); |
|
| 3201 | - } else { |
|
| 3202 | - $new_request_args = array( |
|
| 3203 | - 'export' => 'report', |
|
| 3204 | - 'action' => 'registrations_report_for_event', |
|
| 3205 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3206 | - ); |
|
| 3207 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3208 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3209 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3210 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3211 | - $EE_Export->export(); |
|
| 3212 | - } |
|
| 3213 | - } |
|
| 3214 | - } |
|
| 3215 | - |
|
| 3216 | - |
|
| 3217 | - |
|
| 3218 | - /** |
|
| 3219 | - * Creates a registration report using only query parameters in the request |
|
| 3220 | - * @return void |
|
| 3221 | - */ |
|
| 3222 | - public function _registrations_report() |
|
| 3223 | - { |
|
| 3224 | - $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3225 | - } |
|
| 3226 | - |
|
| 3227 | - |
|
| 3228 | - public function _contact_list_export() |
|
| 3229 | - { |
|
| 3230 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3231 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3232 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3233 | - $EE_Export->export_attendees(); |
|
| 3234 | - } |
|
| 3235 | - } |
|
| 3236 | - |
|
| 3237 | - |
|
| 3238 | - public function _contact_list_report() |
|
| 3239 | - { |
|
| 3240 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3241 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3242 | - 'page' => 'espresso_batch', |
|
| 3243 | - 'batch' => 'file', |
|
| 3244 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3245 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3246 | - ))); |
|
| 3247 | - } else { |
|
| 3248 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3249 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3250 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3251 | - $EE_Export->report_attendees(); |
|
| 3252 | - } |
|
| 3253 | - } |
|
| 3254 | - } |
|
| 3255 | - |
|
| 3256 | - |
|
| 3257 | - |
|
| 3258 | - |
|
| 3259 | - |
|
| 3260 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3261 | - /** |
|
| 3262 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3263 | - * |
|
| 3264 | - * @return void |
|
| 3265 | - * @throws EE_Error |
|
| 3266 | - */ |
|
| 3267 | - protected function _duplicate_attendee() |
|
| 3268 | - { |
|
| 3269 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3270 | - //verify we have necessary info |
|
| 3271 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 3272 | - EE_Error::add_error( |
|
| 3273 | - esc_html__( |
|
| 3274 | - 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3275 | - 'event_espresso' |
|
| 3276 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3277 | - ); |
|
| 3278 | - $query_args = array('action' => $action); |
|
| 3279 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3280 | - } |
|
| 3281 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3282 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3283 | - $attendee = $registration->attendee(); |
|
| 3284 | - //remove relation of existing attendee on registration |
|
| 3285 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3286 | - //new attendee |
|
| 3287 | - $new_attendee = clone $attendee; |
|
| 3288 | - $new_attendee->set('ATT_ID', 0); |
|
| 3289 | - $new_attendee->save(); |
|
| 3290 | - //add new attendee to reg |
|
| 3291 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3292 | - EE_Error::add_success( |
|
| 3293 | - esc_html__( |
|
| 3294 | - 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3295 | - 'event_espresso' |
|
| 3296 | - ) |
|
| 3297 | - ); |
|
| 3298 | - //redirect to edit page for attendee |
|
| 3299 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3300 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3301 | - } |
|
| 3302 | - |
|
| 3303 | - |
|
| 3304 | - //related to cpt routes |
|
| 3305 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 3306 | - { |
|
| 3307 | - $success = true; |
|
| 3308 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3309 | - //for attendee updates |
|
| 3310 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3311 | - //note we should only be UPDATING attendees at this point. |
|
| 3312 | - $updated_fields = array( |
|
| 3313 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3314 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3315 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3316 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3317 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3318 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3319 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3320 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3321 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3322 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3323 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3324 | - ); |
|
| 3325 | - foreach ($updated_fields as $field => $value) { |
|
| 3326 | - $attendee->set($field, $value); |
|
| 3327 | - } |
|
| 3328 | - $success = $attendee->save(); |
|
| 3329 | - $attendee_update_callbacks = apply_filters( |
|
| 3330 | - 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3331 | - array() |
|
| 3332 | - ); |
|
| 3333 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3334 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3335 | - throw new EE_Error( |
|
| 3336 | - sprintf( |
|
| 3337 | - esc_html__( |
|
| 3338 | - 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3339 | - 'event_espresso' |
|
| 3340 | - ), |
|
| 3341 | - $a_callback |
|
| 3342 | - ) |
|
| 3343 | - ); |
|
| 3344 | - } |
|
| 3345 | - } |
|
| 3346 | - } |
|
| 3347 | - if ($success === false) { |
|
| 3348 | - EE_Error::add_error( |
|
| 3349 | - esc_html__( |
|
| 3350 | - 'Something went wrong with updating the meta table data for the registration.', |
|
| 3351 | - 'event_espresso' |
|
| 3352 | - ), |
|
| 3353 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 3354 | - ); |
|
| 3355 | - } |
|
| 3356 | - } |
|
| 3357 | - |
|
| 3358 | - |
|
| 3359 | - public function trash_cpt_item($post_id) |
|
| 3360 | - { |
|
| 3361 | - } |
|
| 3362 | - |
|
| 3363 | - |
|
| 3364 | - public function delete_cpt_item($post_id) |
|
| 3365 | - { |
|
| 3366 | - } |
|
| 3367 | - |
|
| 3368 | - |
|
| 3369 | - public function restore_cpt_item($post_id) |
|
| 3370 | - { |
|
| 3371 | - } |
|
| 3372 | - |
|
| 3373 | - |
|
| 3374 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3375 | - { |
|
| 3376 | - } |
|
| 3377 | - |
|
| 3378 | - |
|
| 3379 | - public function attendee_editor_metaboxes() |
|
| 3380 | - { |
|
| 3381 | - $this->verify_cpt_object(); |
|
| 3382 | - remove_meta_box( |
|
| 3383 | - 'postexcerpt', |
|
| 3384 | - esc_html__('Excerpt', 'event_espresso'), |
|
| 3385 | - 'post_excerpt_meta_box', |
|
| 3386 | - $this->_cpt_routes[$this->_req_action], |
|
| 3387 | - 'normal', |
|
| 3388 | - 'core' |
|
| 3389 | - ); |
|
| 3390 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3391 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3392 | - add_meta_box( |
|
| 3393 | - 'postexcerpt', |
|
| 3394 | - esc_html__('Short Biography', 'event_espresso'), |
|
| 3395 | - 'post_excerpt_meta_box', |
|
| 3396 | - $this->_cpt_routes[$this->_req_action], |
|
| 3397 | - 'normal' |
|
| 3398 | - ); |
|
| 3399 | - } |
|
| 3400 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3401 | - add_meta_box( |
|
| 3402 | - 'commentsdiv', |
|
| 3403 | - esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3404 | - 'post_comment_meta_box', |
|
| 3405 | - $this->_cpt_routes[$this->_req_action], |
|
| 3406 | - 'normal', |
|
| 3407 | - 'core' |
|
| 3408 | - ); |
|
| 3409 | - } |
|
| 3410 | - add_meta_box( |
|
| 3411 | - 'attendee_contact_info', |
|
| 3412 | - esc_html__('Contact Info', 'event_espresso'), |
|
| 3413 | - array($this, 'attendee_contact_info'), |
|
| 3414 | - $this->_cpt_routes[$this->_req_action], |
|
| 3415 | - 'side', |
|
| 3416 | - 'core' |
|
| 3417 | - ); |
|
| 3418 | - add_meta_box( |
|
| 3419 | - 'attendee_details_address', |
|
| 3420 | - esc_html__('Address Details', 'event_espresso'), |
|
| 3421 | - array($this, 'attendee_address_details'), |
|
| 3422 | - $this->_cpt_routes[$this->_req_action], |
|
| 3423 | - 'normal', |
|
| 3424 | - 'core' |
|
| 3425 | - ); |
|
| 3426 | - add_meta_box( |
|
| 3427 | - 'attendee_registrations', |
|
| 3428 | - esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3429 | - array($this, 'attendee_registrations_meta_box'), |
|
| 3430 | - $this->_cpt_routes[$this->_req_action], |
|
| 3431 | - 'normal', |
|
| 3432 | - 'high' |
|
| 3433 | - ); |
|
| 3434 | - } |
|
| 3435 | - |
|
| 3436 | - |
|
| 3437 | - /** |
|
| 3438 | - * Metabox for attendee contact info |
|
| 3439 | - * |
|
| 3440 | - * @param WP_Post $post wp post object |
|
| 3441 | - * @return string attendee contact info ( and form ) |
|
| 3442 | - * @throws DomainException |
|
| 3443 | - */ |
|
| 3444 | - public function attendee_contact_info($post) |
|
| 3445 | - { |
|
| 3446 | - //get attendee object ( should already have it ) |
|
| 3447 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3448 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3449 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3450 | - } |
|
| 3451 | - |
|
| 3452 | - |
|
| 3453 | - /** |
|
| 3454 | - * Metabox for attendee details |
|
| 3455 | - * |
|
| 3456 | - * @param WP_Post $post wp post object |
|
| 3457 | - * @return string attendee address details (and form) |
|
| 3458 | - * @throws DomainException |
|
| 3459 | - */ |
|
| 3460 | - public function attendee_address_details($post) |
|
| 3461 | - { |
|
| 3462 | - //get attendee object (should already have it) |
|
| 3463 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3464 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3465 | - new EE_Question_Form_Input( |
|
| 3466 | - EE_Question::new_instance( |
|
| 3467 | - array( |
|
| 3468 | - 'QST_ID' => 0, |
|
| 3469 | - 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3470 | - 'QST_system' => 'admin-state', |
|
| 3471 | - ) |
|
| 3472 | - ), |
|
| 3473 | - EE_Answer::new_instance( |
|
| 3474 | - array( |
|
| 3475 | - 'ANS_ID' => 0, |
|
| 3476 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3477 | - ) |
|
| 3478 | - ), |
|
| 3479 | - array( |
|
| 3480 | - 'input_id' => 'STA_ID', |
|
| 3481 | - 'input_name' => 'STA_ID', |
|
| 3482 | - 'input_prefix' => '', |
|
| 3483 | - 'append_qstn_id' => false, |
|
| 3484 | - ) |
|
| 3485 | - ) |
|
| 3486 | - ); |
|
| 3487 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3488 | - new EE_Question_Form_Input( |
|
| 3489 | - EE_Question::new_instance( |
|
| 3490 | - array( |
|
| 3491 | - 'QST_ID' => 0, |
|
| 3492 | - 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3493 | - 'QST_system' => 'admin-country', |
|
| 3494 | - ) |
|
| 3495 | - ), |
|
| 3496 | - EE_Answer::new_instance( |
|
| 3497 | - array( |
|
| 3498 | - 'ANS_ID' => 0, |
|
| 3499 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3500 | - ) |
|
| 3501 | - ), |
|
| 3502 | - array( |
|
| 3503 | - 'input_id' => 'CNT_ISO', |
|
| 3504 | - 'input_name' => 'CNT_ISO', |
|
| 3505 | - 'input_prefix' => '', |
|
| 3506 | - 'append_qstn_id' => false, |
|
| 3507 | - ) |
|
| 3508 | - ) |
|
| 3509 | - ); |
|
| 3510 | - $template = |
|
| 3511 | - REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3512 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3513 | - } |
|
| 3514 | - |
|
| 3515 | - |
|
| 3516 | - /** |
|
| 3517 | - * _attendee_details |
|
| 3518 | - * |
|
| 3519 | - * @access protected |
|
| 3520 | - * @param $post |
|
| 3521 | - * @return void |
|
| 3522 | - * @throws DomainException |
|
| 3523 | - * @throws EE_Error |
|
| 3524 | - */ |
|
| 3525 | - public function attendee_registrations_meta_box($post) |
|
| 3526 | - { |
|
| 3527 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3528 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3529 | - $template = |
|
| 3530 | - REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3531 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3532 | - } |
|
| 3533 | - |
|
| 3534 | - |
|
| 3535 | - /** |
|
| 3536 | - * add in the form fields for the attendee edit |
|
| 3537 | - * |
|
| 3538 | - * @param WP_Post $post wp post object |
|
| 3539 | - * @return string html for new form. |
|
| 3540 | - * @throws DomainException |
|
| 3541 | - */ |
|
| 3542 | - public function after_title_form_fields($post) |
|
| 3543 | - { |
|
| 3544 | - if ($post->post_type == 'espresso_attendees') { |
|
| 3545 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3546 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3547 | - EEH_Template::display_template($template, $template_args); |
|
| 3548 | - } |
|
| 3549 | - } |
|
| 3550 | - |
|
| 3551 | - |
|
| 3552 | - /** |
|
| 3553 | - * _trash_or_restore_attendee |
|
| 3554 | - * |
|
| 3555 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3556 | - * @return void |
|
| 3557 | - * @throws EE_Error |
|
| 3558 | - * @access protected |
|
| 3559 | - */ |
|
| 3560 | - protected function _trash_or_restore_attendees($trash = true) |
|
| 3561 | - { |
|
| 3562 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3563 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 3564 | - $success = 1; |
|
| 3565 | - //Checkboxes |
|
| 3566 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3567 | - // if array has more than one element than success message should be plural |
|
| 3568 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3569 | - // cycle thru checkboxes |
|
| 3570 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3571 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3572 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3573 | - if ( ! $updated) { |
|
| 3574 | - $success = 0; |
|
| 3575 | - } |
|
| 3576 | - } |
|
| 3577 | - } else { |
|
| 3578 | - // grab single id and delete |
|
| 3579 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3580 | - //get attendee |
|
| 3581 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3582 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3583 | - $updated = $att->save(); |
|
| 3584 | - if ( ! $updated) { |
|
| 3585 | - $success = 0; |
|
| 3586 | - } |
|
| 3587 | - } |
|
| 3588 | - $what = $success > 1 |
|
| 3589 | - ? esc_html__('Contacts', 'event_espresso') |
|
| 3590 | - : esc_html__('Contact', 'event_espresso'); |
|
| 3591 | - $action_desc = $trash |
|
| 3592 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3593 | - : esc_html__('restored', 'event_espresso'); |
|
| 3594 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3595 | - } |
|
| 2809 | + } |
|
| 2810 | + $template_args = array( |
|
| 2811 | + 'title' => '', |
|
| 2812 | + 'content' => '', |
|
| 2813 | + 'step_button_text' => '', |
|
| 2814 | + 'show_notification_toggle' => false, |
|
| 2815 | + ); |
|
| 2816 | + //to indicate we're processing a new registration |
|
| 2817 | + $hidden_fields = array( |
|
| 2818 | + 'processing_registration' => array( |
|
| 2819 | + 'type' => 'hidden', |
|
| 2820 | + 'value' => 0, |
|
| 2821 | + ), |
|
| 2822 | + 'event_id' => array( |
|
| 2823 | + 'type' => 'hidden', |
|
| 2824 | + 'value' => $this->_reg_event->ID(), |
|
| 2825 | + ), |
|
| 2826 | + ); |
|
| 2827 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2828 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2829 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2830 | + switch ($step) { |
|
| 2831 | + case 'ticket' : |
|
| 2832 | + $hidden_fields['processing_registration']['value'] = 1; |
|
| 2833 | + $template_args['title'] = esc_html__( |
|
| 2834 | + 'Step One: Select the Ticket for this registration', |
|
| 2835 | + 'event_espresso' |
|
| 2836 | + ); |
|
| 2837 | + $template_args['content'] = |
|
| 2838 | + EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2839 | + $template_args['step_button_text'] = esc_html__( |
|
| 2840 | + 'Add Tickets and Continue to Registrant Details', |
|
| 2841 | + 'event_espresso' |
|
| 2842 | + ); |
|
| 2843 | + $template_args['show_notification_toggle'] = false; |
|
| 2844 | + break; |
|
| 2845 | + case 'questions' : |
|
| 2846 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2847 | + $template_args['title'] = esc_html__( |
|
| 2848 | + 'Step Two: Add Registrant Details for this Registration', |
|
| 2849 | + 'event_espresso' |
|
| 2850 | + ); |
|
| 2851 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2852 | + // properly by the first process_reg_step run. |
|
| 2853 | + $template_args['content'] = |
|
| 2854 | + EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2855 | + $template_args['step_button_text'] = esc_html__( |
|
| 2856 | + 'Save Registration and Continue to Details', |
|
| 2857 | + 'event_espresso' |
|
| 2858 | + ); |
|
| 2859 | + $template_args['show_notification_toggle'] = true; |
|
| 2860 | + break; |
|
| 2861 | + } |
|
| 2862 | + //we come back to the process_registration_step route. |
|
| 2863 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2864 | + return EEH_Template::display_template( |
|
| 2865 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2866 | + $template_args, |
|
| 2867 | + true |
|
| 2868 | + ); |
|
| 2869 | + } |
|
| 2870 | + |
|
| 2871 | + |
|
| 2872 | + /** |
|
| 2873 | + * set_reg_event |
|
| 2874 | + * |
|
| 2875 | + * @access private |
|
| 2876 | + * @return bool |
|
| 2877 | + * @throws EE_Error |
|
| 2878 | + */ |
|
| 2879 | + private function _set_reg_event() |
|
| 2880 | + { |
|
| 2881 | + if (is_object($this->_reg_event)) { |
|
| 2882 | + return true; |
|
| 2883 | + } |
|
| 2884 | + $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2885 | + if ( ! $EVT_ID) { |
|
| 2886 | + return false; |
|
| 2887 | + } |
|
| 2888 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2889 | + return true; |
|
| 2890 | + } |
|
| 2891 | + |
|
| 2892 | + |
|
| 2893 | + /** |
|
| 2894 | + * process_reg_step |
|
| 2895 | + * |
|
| 2896 | + * @access public |
|
| 2897 | + * @return string |
|
| 2898 | + * @throws DomainException |
|
| 2899 | + * @throws EE_Error |
|
| 2900 | + * @throws RuntimeException |
|
| 2901 | + */ |
|
| 2902 | + public function process_reg_step() |
|
| 2903 | + { |
|
| 2904 | + EE_System::do_not_cache(); |
|
| 2905 | + $this->_set_reg_event(); |
|
| 2906 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2907 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2908 | + //what step are we on? |
|
| 2909 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2910 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2911 | + //if doing ajax then we need to verify the nonce |
|
| 2912 | + if (defined('DOING_AJAX')) { |
|
| 2913 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2914 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2915 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2916 | + } |
|
| 2917 | + switch ($step) { |
|
| 2918 | + case 'ticket' : |
|
| 2919 | + //process ticket selection |
|
| 2920 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2921 | + if ($success) { |
|
| 2922 | + EE_Error::add_success( |
|
| 2923 | + esc_html__( |
|
| 2924 | + 'Tickets Selected. Now complete the registration.', |
|
| 2925 | + 'event_espresso' |
|
| 2926 | + ) |
|
| 2927 | + ); |
|
| 2928 | + } else { |
|
| 2929 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2930 | + } |
|
| 2931 | + if (defined('DOING_AJAX')) { |
|
| 2932 | + $this->new_registration(); //display next step |
|
| 2933 | + } else { |
|
| 2934 | + $query_args = array( |
|
| 2935 | + 'action' => 'new_registration', |
|
| 2936 | + 'processing_registration' => 1, |
|
| 2937 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2938 | + 'uts' => time(), |
|
| 2939 | + ); |
|
| 2940 | + $this->_redirect_after_action( |
|
| 2941 | + false, |
|
| 2942 | + '', |
|
| 2943 | + '', |
|
| 2944 | + $query_args, |
|
| 2945 | + true |
|
| 2946 | + ); |
|
| 2947 | + } |
|
| 2948 | + break; |
|
| 2949 | + case 'questions' : |
|
| 2950 | + if (! isset( |
|
| 2951 | + $this->_req_data['txn_reg_status_change'], |
|
| 2952 | + $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 2953 | + ) { |
|
| 2954 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2955 | + } |
|
| 2956 | + //process registration |
|
| 2957 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2958 | + if ($cart instanceof EE_Cart) { |
|
| 2959 | + $grand_total = $cart->get_cart_grand_total(); |
|
| 2960 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 2961 | + $grand_total->save_this_and_descendants_to_txn(); |
|
| 2962 | + } |
|
| 2963 | + } |
|
| 2964 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 2965 | + $query_args = array( |
|
| 2966 | + 'action' => 'new_registration', |
|
| 2967 | + 'processing_registration' => 2, |
|
| 2968 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2969 | + 'uts' => time(), |
|
| 2970 | + ); |
|
| 2971 | + if (defined('DOING_AJAX')) { |
|
| 2972 | + //display registration form again because there are errors (maybe validation?) |
|
| 2973 | + $this->new_registration(); |
|
| 2974 | + return; |
|
| 2975 | + } else { |
|
| 2976 | + $this->_redirect_after_action( |
|
| 2977 | + false, |
|
| 2978 | + '', |
|
| 2979 | + '', |
|
| 2980 | + $query_args, |
|
| 2981 | + true |
|
| 2982 | + ); |
|
| 2983 | + return; |
|
| 2984 | + } |
|
| 2985 | + } |
|
| 2986 | + // maybe update status, and make sure to save transaction if not done already |
|
| 2987 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2988 | + $transaction->save(); |
|
| 2989 | + } |
|
| 2990 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2991 | + $this->_req_data = array(); |
|
| 2992 | + $query_args = array( |
|
| 2993 | + 'action' => 'redirect_to_txn', |
|
| 2994 | + 'TXN_ID' => $transaction->ID(), |
|
| 2995 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2996 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2997 | + 'redirect_from' => 'new_registration', |
|
| 2998 | + ); |
|
| 2999 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3000 | + break; |
|
| 3001 | + } |
|
| 3002 | + //what are you looking here for? Should be nothing to do at this point. |
|
| 3003 | + } |
|
| 3004 | + |
|
| 3005 | + |
|
| 3006 | + /** |
|
| 3007 | + * redirect_to_txn |
|
| 3008 | + * |
|
| 3009 | + * @access public |
|
| 3010 | + * @return void |
|
| 3011 | + * @throws EE_Error |
|
| 3012 | + */ |
|
| 3013 | + public function redirect_to_txn() |
|
| 3014 | + { |
|
| 3015 | + EE_System::do_not_cache(); |
|
| 3016 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 3017 | + $query_args = array( |
|
| 3018 | + 'action' => 'view_transaction', |
|
| 3019 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 3020 | + 'page' => 'espresso_transactions', |
|
| 3021 | + ); |
|
| 3022 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 3023 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 3024 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 3025 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 3026 | + } |
|
| 3027 | + EE_Error::add_success( |
|
| 3028 | + esc_html__( |
|
| 3029 | + 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 3030 | + 'event_espresso' |
|
| 3031 | + ) |
|
| 3032 | + ); |
|
| 3033 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3034 | + } |
|
| 3035 | + |
|
| 3036 | + |
|
| 3037 | + /** |
|
| 3038 | + * generates HTML for the Attendee Contact List |
|
| 3039 | + * |
|
| 3040 | + * @access protected |
|
| 3041 | + * @return void |
|
| 3042 | + */ |
|
| 3043 | + protected function _attendee_contact_list_table() |
|
| 3044 | + { |
|
| 3045 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3046 | + $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 3047 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 3048 | + } |
|
| 3049 | + |
|
| 3050 | + |
|
| 3051 | + /** |
|
| 3052 | + * get_attendees |
|
| 3053 | + * |
|
| 3054 | + * @param $per_page |
|
| 3055 | + * @param bool $count whether to return count or data. |
|
| 3056 | + * @param bool $trash |
|
| 3057 | + * @return array |
|
| 3058 | + * @throws EE_Error |
|
| 3059 | + * @access public |
|
| 3060 | + */ |
|
| 3061 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
| 3062 | + { |
|
| 3063 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3064 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 3065 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 3066 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 3067 | + switch ($this->_req_data['orderby']) { |
|
| 3068 | + case 'ATT_ID': |
|
| 3069 | + $orderby = 'ATT_ID'; |
|
| 3070 | + break; |
|
| 3071 | + case 'ATT_fname': |
|
| 3072 | + $orderby = 'ATT_fname'; |
|
| 3073 | + break; |
|
| 3074 | + case 'ATT_email': |
|
| 3075 | + $orderby = 'ATT_email'; |
|
| 3076 | + break; |
|
| 3077 | + case 'ATT_city': |
|
| 3078 | + $orderby = 'ATT_city'; |
|
| 3079 | + break; |
|
| 3080 | + case 'STA_ID': |
|
| 3081 | + $orderby = 'STA_ID'; |
|
| 3082 | + break; |
|
| 3083 | + case 'CNT_ID': |
|
| 3084 | + $orderby = 'CNT_ID'; |
|
| 3085 | + break; |
|
| 3086 | + default: |
|
| 3087 | + $orderby = 'ATT_lname'; |
|
| 3088 | + } |
|
| 3089 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 3090 | + ? $this->_req_data['order'] |
|
| 3091 | + : 'ASC'; |
|
| 3092 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 3093 | + ? $this->_req_data['paged'] |
|
| 3094 | + : 1; |
|
| 3095 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 3096 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 3097 | + ? $this->_req_data['perpage'] |
|
| 3098 | + : $per_page; |
|
| 3099 | + $_where = array(); |
|
| 3100 | + if ( ! empty($this->_req_data['s'])) { |
|
| 3101 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 3102 | + $_where['OR'] = array( |
|
| 3103 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 3104 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 3105 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 3106 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 3107 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 3108 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3109 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 3110 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 3111 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 3112 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 3113 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3114 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 3115 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 3116 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3117 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3118 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3119 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3120 | + ); |
|
| 3121 | + } |
|
| 3122 | + $offset = ($current_page - 1) * $per_page; |
|
| 3123 | + $limit = $count ? null : array($offset, $per_page); |
|
| 3124 | + if ($trash) { |
|
| 3125 | + $_where['status'] = array('!=', 'publish'); |
|
| 3126 | + $all_attendees = $count |
|
| 3127 | + ? $ATT_MDL->count(array( |
|
| 3128 | + $_where, |
|
| 3129 | + 'order_by' => array($orderby => $sort), |
|
| 3130 | + 'limit' => $limit, |
|
| 3131 | + ), 'ATT_ID', true) |
|
| 3132 | + : $ATT_MDL->get_all(array( |
|
| 3133 | + $_where, |
|
| 3134 | + 'order_by' => array($orderby => $sort), |
|
| 3135 | + 'limit' => $limit, |
|
| 3136 | + )); |
|
| 3137 | + } else { |
|
| 3138 | + $_where['status'] = array('IN', array('publish')); |
|
| 3139 | + $all_attendees = $count |
|
| 3140 | + ? $ATT_MDL->count(array( |
|
| 3141 | + $_where, |
|
| 3142 | + 'order_by' => array($orderby => $sort), |
|
| 3143 | + 'limit' => $limit, |
|
| 3144 | + ), 'ATT_ID', true) |
|
| 3145 | + : $ATT_MDL->get_all(array( |
|
| 3146 | + $_where, |
|
| 3147 | + 'order_by' => array($orderby => $sort), |
|
| 3148 | + 'limit' => $limit, |
|
| 3149 | + )); |
|
| 3150 | + } |
|
| 3151 | + return $all_attendees; |
|
| 3152 | + } |
|
| 3153 | + |
|
| 3154 | + |
|
| 3155 | + /** |
|
| 3156 | + * This is just taking care of resending the registration confirmation |
|
| 3157 | + * |
|
| 3158 | + * @access protected |
|
| 3159 | + * @return void |
|
| 3160 | + */ |
|
| 3161 | + protected function _resend_registration() |
|
| 3162 | + { |
|
| 3163 | + $this->_process_resend_registration(); |
|
| 3164 | + $query_args = isset($this->_req_data['redirect_to']) |
|
| 3165 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3166 | + : array('action' => 'default'); |
|
| 3167 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3168 | + } |
|
| 3169 | + |
|
| 3170 | + /** |
|
| 3171 | + * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3172 | + * to use when selecting registrations |
|
| 3173 | + * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3174 | + * the query parameters from the request |
|
| 3175 | + * @return void ends the request with a redirect or download |
|
| 3176 | + */ |
|
| 3177 | + public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3178 | + { |
|
| 3179 | + if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3180 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3181 | + array( |
|
| 3182 | + 'page' => 'espresso_batch', |
|
| 3183 | + 'batch' => 'file', |
|
| 3184 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3185 | + 'filters' => urlencode( |
|
| 3186 | + serialize( |
|
| 3187 | + call_user_func( |
|
| 3188 | + array( $this, $method_name_for_getting_query_params ), |
|
| 3189 | + EEH_Array::is_set( |
|
| 3190 | + $this->_req_data, |
|
| 3191 | + 'filters', |
|
| 3192 | + array() |
|
| 3193 | + ) |
|
| 3194 | + ) |
|
| 3195 | + ) |
|
| 3196 | + ), |
|
| 3197 | + 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3198 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3199 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3200 | + ))); |
|
| 3201 | + } else { |
|
| 3202 | + $new_request_args = array( |
|
| 3203 | + 'export' => 'report', |
|
| 3204 | + 'action' => 'registrations_report_for_event', |
|
| 3205 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3206 | + ); |
|
| 3207 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3208 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3209 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3210 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3211 | + $EE_Export->export(); |
|
| 3212 | + } |
|
| 3213 | + } |
|
| 3214 | + } |
|
| 3215 | + |
|
| 3216 | + |
|
| 3217 | + |
|
| 3218 | + /** |
|
| 3219 | + * Creates a registration report using only query parameters in the request |
|
| 3220 | + * @return void |
|
| 3221 | + */ |
|
| 3222 | + public function _registrations_report() |
|
| 3223 | + { |
|
| 3224 | + $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3225 | + } |
|
| 3226 | + |
|
| 3227 | + |
|
| 3228 | + public function _contact_list_export() |
|
| 3229 | + { |
|
| 3230 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3231 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3232 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3233 | + $EE_Export->export_attendees(); |
|
| 3234 | + } |
|
| 3235 | + } |
|
| 3236 | + |
|
| 3237 | + |
|
| 3238 | + public function _contact_list_report() |
|
| 3239 | + { |
|
| 3240 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3241 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3242 | + 'page' => 'espresso_batch', |
|
| 3243 | + 'batch' => 'file', |
|
| 3244 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3245 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3246 | + ))); |
|
| 3247 | + } else { |
|
| 3248 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3249 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3250 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3251 | + $EE_Export->report_attendees(); |
|
| 3252 | + } |
|
| 3253 | + } |
|
| 3254 | + } |
|
| 3255 | + |
|
| 3256 | + |
|
| 3257 | + |
|
| 3258 | + |
|
| 3259 | + |
|
| 3260 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3261 | + /** |
|
| 3262 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3263 | + * |
|
| 3264 | + * @return void |
|
| 3265 | + * @throws EE_Error |
|
| 3266 | + */ |
|
| 3267 | + protected function _duplicate_attendee() |
|
| 3268 | + { |
|
| 3269 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3270 | + //verify we have necessary info |
|
| 3271 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 3272 | + EE_Error::add_error( |
|
| 3273 | + esc_html__( |
|
| 3274 | + 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3275 | + 'event_espresso' |
|
| 3276 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3277 | + ); |
|
| 3278 | + $query_args = array('action' => $action); |
|
| 3279 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3280 | + } |
|
| 3281 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3282 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3283 | + $attendee = $registration->attendee(); |
|
| 3284 | + //remove relation of existing attendee on registration |
|
| 3285 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3286 | + //new attendee |
|
| 3287 | + $new_attendee = clone $attendee; |
|
| 3288 | + $new_attendee->set('ATT_ID', 0); |
|
| 3289 | + $new_attendee->save(); |
|
| 3290 | + //add new attendee to reg |
|
| 3291 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3292 | + EE_Error::add_success( |
|
| 3293 | + esc_html__( |
|
| 3294 | + 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3295 | + 'event_espresso' |
|
| 3296 | + ) |
|
| 3297 | + ); |
|
| 3298 | + //redirect to edit page for attendee |
|
| 3299 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3300 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3301 | + } |
|
| 3302 | + |
|
| 3303 | + |
|
| 3304 | + //related to cpt routes |
|
| 3305 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 3306 | + { |
|
| 3307 | + $success = true; |
|
| 3308 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3309 | + //for attendee updates |
|
| 3310 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3311 | + //note we should only be UPDATING attendees at this point. |
|
| 3312 | + $updated_fields = array( |
|
| 3313 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3314 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3315 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3316 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3317 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3318 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3319 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3320 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3321 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3322 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3323 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3324 | + ); |
|
| 3325 | + foreach ($updated_fields as $field => $value) { |
|
| 3326 | + $attendee->set($field, $value); |
|
| 3327 | + } |
|
| 3328 | + $success = $attendee->save(); |
|
| 3329 | + $attendee_update_callbacks = apply_filters( |
|
| 3330 | + 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3331 | + array() |
|
| 3332 | + ); |
|
| 3333 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3334 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3335 | + throw new EE_Error( |
|
| 3336 | + sprintf( |
|
| 3337 | + esc_html__( |
|
| 3338 | + 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3339 | + 'event_espresso' |
|
| 3340 | + ), |
|
| 3341 | + $a_callback |
|
| 3342 | + ) |
|
| 3343 | + ); |
|
| 3344 | + } |
|
| 3345 | + } |
|
| 3346 | + } |
|
| 3347 | + if ($success === false) { |
|
| 3348 | + EE_Error::add_error( |
|
| 3349 | + esc_html__( |
|
| 3350 | + 'Something went wrong with updating the meta table data for the registration.', |
|
| 3351 | + 'event_espresso' |
|
| 3352 | + ), |
|
| 3353 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 3354 | + ); |
|
| 3355 | + } |
|
| 3356 | + } |
|
| 3357 | + |
|
| 3358 | + |
|
| 3359 | + public function trash_cpt_item($post_id) |
|
| 3360 | + { |
|
| 3361 | + } |
|
| 3362 | + |
|
| 3363 | + |
|
| 3364 | + public function delete_cpt_item($post_id) |
|
| 3365 | + { |
|
| 3366 | + } |
|
| 3367 | + |
|
| 3368 | + |
|
| 3369 | + public function restore_cpt_item($post_id) |
|
| 3370 | + { |
|
| 3371 | + } |
|
| 3372 | + |
|
| 3373 | + |
|
| 3374 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3375 | + { |
|
| 3376 | + } |
|
| 3377 | + |
|
| 3378 | + |
|
| 3379 | + public function attendee_editor_metaboxes() |
|
| 3380 | + { |
|
| 3381 | + $this->verify_cpt_object(); |
|
| 3382 | + remove_meta_box( |
|
| 3383 | + 'postexcerpt', |
|
| 3384 | + esc_html__('Excerpt', 'event_espresso'), |
|
| 3385 | + 'post_excerpt_meta_box', |
|
| 3386 | + $this->_cpt_routes[$this->_req_action], |
|
| 3387 | + 'normal', |
|
| 3388 | + 'core' |
|
| 3389 | + ); |
|
| 3390 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3391 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3392 | + add_meta_box( |
|
| 3393 | + 'postexcerpt', |
|
| 3394 | + esc_html__('Short Biography', 'event_espresso'), |
|
| 3395 | + 'post_excerpt_meta_box', |
|
| 3396 | + $this->_cpt_routes[$this->_req_action], |
|
| 3397 | + 'normal' |
|
| 3398 | + ); |
|
| 3399 | + } |
|
| 3400 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3401 | + add_meta_box( |
|
| 3402 | + 'commentsdiv', |
|
| 3403 | + esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3404 | + 'post_comment_meta_box', |
|
| 3405 | + $this->_cpt_routes[$this->_req_action], |
|
| 3406 | + 'normal', |
|
| 3407 | + 'core' |
|
| 3408 | + ); |
|
| 3409 | + } |
|
| 3410 | + add_meta_box( |
|
| 3411 | + 'attendee_contact_info', |
|
| 3412 | + esc_html__('Contact Info', 'event_espresso'), |
|
| 3413 | + array($this, 'attendee_contact_info'), |
|
| 3414 | + $this->_cpt_routes[$this->_req_action], |
|
| 3415 | + 'side', |
|
| 3416 | + 'core' |
|
| 3417 | + ); |
|
| 3418 | + add_meta_box( |
|
| 3419 | + 'attendee_details_address', |
|
| 3420 | + esc_html__('Address Details', 'event_espresso'), |
|
| 3421 | + array($this, 'attendee_address_details'), |
|
| 3422 | + $this->_cpt_routes[$this->_req_action], |
|
| 3423 | + 'normal', |
|
| 3424 | + 'core' |
|
| 3425 | + ); |
|
| 3426 | + add_meta_box( |
|
| 3427 | + 'attendee_registrations', |
|
| 3428 | + esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3429 | + array($this, 'attendee_registrations_meta_box'), |
|
| 3430 | + $this->_cpt_routes[$this->_req_action], |
|
| 3431 | + 'normal', |
|
| 3432 | + 'high' |
|
| 3433 | + ); |
|
| 3434 | + } |
|
| 3435 | + |
|
| 3436 | + |
|
| 3437 | + /** |
|
| 3438 | + * Metabox for attendee contact info |
|
| 3439 | + * |
|
| 3440 | + * @param WP_Post $post wp post object |
|
| 3441 | + * @return string attendee contact info ( and form ) |
|
| 3442 | + * @throws DomainException |
|
| 3443 | + */ |
|
| 3444 | + public function attendee_contact_info($post) |
|
| 3445 | + { |
|
| 3446 | + //get attendee object ( should already have it ) |
|
| 3447 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3448 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3449 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3450 | + } |
|
| 3451 | + |
|
| 3452 | + |
|
| 3453 | + /** |
|
| 3454 | + * Metabox for attendee details |
|
| 3455 | + * |
|
| 3456 | + * @param WP_Post $post wp post object |
|
| 3457 | + * @return string attendee address details (and form) |
|
| 3458 | + * @throws DomainException |
|
| 3459 | + */ |
|
| 3460 | + public function attendee_address_details($post) |
|
| 3461 | + { |
|
| 3462 | + //get attendee object (should already have it) |
|
| 3463 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3464 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3465 | + new EE_Question_Form_Input( |
|
| 3466 | + EE_Question::new_instance( |
|
| 3467 | + array( |
|
| 3468 | + 'QST_ID' => 0, |
|
| 3469 | + 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3470 | + 'QST_system' => 'admin-state', |
|
| 3471 | + ) |
|
| 3472 | + ), |
|
| 3473 | + EE_Answer::new_instance( |
|
| 3474 | + array( |
|
| 3475 | + 'ANS_ID' => 0, |
|
| 3476 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3477 | + ) |
|
| 3478 | + ), |
|
| 3479 | + array( |
|
| 3480 | + 'input_id' => 'STA_ID', |
|
| 3481 | + 'input_name' => 'STA_ID', |
|
| 3482 | + 'input_prefix' => '', |
|
| 3483 | + 'append_qstn_id' => false, |
|
| 3484 | + ) |
|
| 3485 | + ) |
|
| 3486 | + ); |
|
| 3487 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3488 | + new EE_Question_Form_Input( |
|
| 3489 | + EE_Question::new_instance( |
|
| 3490 | + array( |
|
| 3491 | + 'QST_ID' => 0, |
|
| 3492 | + 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3493 | + 'QST_system' => 'admin-country', |
|
| 3494 | + ) |
|
| 3495 | + ), |
|
| 3496 | + EE_Answer::new_instance( |
|
| 3497 | + array( |
|
| 3498 | + 'ANS_ID' => 0, |
|
| 3499 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3500 | + ) |
|
| 3501 | + ), |
|
| 3502 | + array( |
|
| 3503 | + 'input_id' => 'CNT_ISO', |
|
| 3504 | + 'input_name' => 'CNT_ISO', |
|
| 3505 | + 'input_prefix' => '', |
|
| 3506 | + 'append_qstn_id' => false, |
|
| 3507 | + ) |
|
| 3508 | + ) |
|
| 3509 | + ); |
|
| 3510 | + $template = |
|
| 3511 | + REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3512 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3513 | + } |
|
| 3514 | + |
|
| 3515 | + |
|
| 3516 | + /** |
|
| 3517 | + * _attendee_details |
|
| 3518 | + * |
|
| 3519 | + * @access protected |
|
| 3520 | + * @param $post |
|
| 3521 | + * @return void |
|
| 3522 | + * @throws DomainException |
|
| 3523 | + * @throws EE_Error |
|
| 3524 | + */ |
|
| 3525 | + public function attendee_registrations_meta_box($post) |
|
| 3526 | + { |
|
| 3527 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3528 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3529 | + $template = |
|
| 3530 | + REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3531 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3532 | + } |
|
| 3533 | + |
|
| 3534 | + |
|
| 3535 | + /** |
|
| 3536 | + * add in the form fields for the attendee edit |
|
| 3537 | + * |
|
| 3538 | + * @param WP_Post $post wp post object |
|
| 3539 | + * @return string html for new form. |
|
| 3540 | + * @throws DomainException |
|
| 3541 | + */ |
|
| 3542 | + public function after_title_form_fields($post) |
|
| 3543 | + { |
|
| 3544 | + if ($post->post_type == 'espresso_attendees') { |
|
| 3545 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3546 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3547 | + EEH_Template::display_template($template, $template_args); |
|
| 3548 | + } |
|
| 3549 | + } |
|
| 3550 | + |
|
| 3551 | + |
|
| 3552 | + /** |
|
| 3553 | + * _trash_or_restore_attendee |
|
| 3554 | + * |
|
| 3555 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3556 | + * @return void |
|
| 3557 | + * @throws EE_Error |
|
| 3558 | + * @access protected |
|
| 3559 | + */ |
|
| 3560 | + protected function _trash_or_restore_attendees($trash = true) |
|
| 3561 | + { |
|
| 3562 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3563 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 3564 | + $success = 1; |
|
| 3565 | + //Checkboxes |
|
| 3566 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3567 | + // if array has more than one element than success message should be plural |
|
| 3568 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3569 | + // cycle thru checkboxes |
|
| 3570 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3571 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3572 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3573 | + if ( ! $updated) { |
|
| 3574 | + $success = 0; |
|
| 3575 | + } |
|
| 3576 | + } |
|
| 3577 | + } else { |
|
| 3578 | + // grab single id and delete |
|
| 3579 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3580 | + //get attendee |
|
| 3581 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3582 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3583 | + $updated = $att->save(); |
|
| 3584 | + if ( ! $updated) { |
|
| 3585 | + $success = 0; |
|
| 3586 | + } |
|
| 3587 | + } |
|
| 3588 | + $what = $success > 1 |
|
| 3589 | + ? esc_html__('Contacts', 'event_espresso') |
|
| 3590 | + : esc_html__('Contact', 'event_espresso'); |
|
| 3591 | + $action_desc = $trash |
|
| 3592 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3593 | + : esc_html__('restored', 'event_espresso'); |
|
| 3594 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3595 | + } |
|
| 3596 | 3596 | |
| 3597 | 3597 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -26,875 +26,875 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - private $_status; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * An array of transaction details for the related transaction to the registration being processed. |
|
| 35 | - * This is set via the _set_related_details method. |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected $_transaction_details = array(); |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * An array of event details for the related event to the registration being processed. |
|
| 45 | - * This is set via the _set_related_details method. |
|
| 46 | - * |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 49 | - protected $_event_details = array(); |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param \Registrations_Admin_Page $admin_page |
|
| 55 | - */ |
|
| 56 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
| 57 | - { |
|
| 58 | - if ( ! empty($_GET['event_id'])) { |
|
| 59 | - $extra_query_args = array(); |
|
| 60 | - foreach ($admin_page->get_views() as $key => $view_details) { |
|
| 61 | - $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
| 62 | - } |
|
| 63 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 64 | - } |
|
| 65 | - parent::__construct($admin_page); |
|
| 66 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * _setup_data |
|
| 73 | - * |
|
| 74 | - * @access protected |
|
| 75 | - * @return void |
|
| 76 | - */ |
|
| 77 | - protected function _setup_data() |
|
| 78 | - { |
|
| 79 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 80 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * _set_properties |
|
| 87 | - * |
|
| 88 | - * @access protected |
|
| 89 | - * @return void |
|
| 90 | - */ |
|
| 91 | - protected function _set_properties() |
|
| 92 | - { |
|
| 93 | - $this->_wp_list_args = array( |
|
| 94 | - 'singular' => __('registration', 'event_espresso'), |
|
| 95 | - 'plural' => __('registrations', 'event_espresso'), |
|
| 96 | - 'ajax' => true, |
|
| 97 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 98 | - ); |
|
| 99 | - $ID_column_name = __('ID', 'event_espresso'); |
|
| 100 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 101 | - $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
| 102 | - $ID_column_name .= '</span> '; |
|
| 103 | - if (isset($_GET['event_id'])) { |
|
| 104 | - $this->_columns = array( |
|
| 105 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 106 | - '_REG_ID' => $ID_column_name, |
|
| 107 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 108 | - 'ATT_email' => __('Email', 'event_espresso'), |
|
| 109 | - '_REG_date' => __('Reg Date', 'event_espresso'), |
|
| 110 | - 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
| 111 | - '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
| 112 | - 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
| 113 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 114 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 115 | - ); |
|
| 116 | - $this->_bottom_buttons = array( |
|
| 117 | - 'report' => array( |
|
| 118 | - 'route' => 'registrations_report', |
|
| 119 | - 'extra_request' => array( |
|
| 120 | - 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 121 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 122 | - ), |
|
| 123 | - ), |
|
| 124 | - ); |
|
| 125 | - } else { |
|
| 126 | - $this->_columns = array( |
|
| 127 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 128 | - '_REG_ID' => $ID_column_name, |
|
| 129 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 130 | - '_REG_date' => __('TXN Date', 'event_espresso'), |
|
| 131 | - 'event_name' => __('Event', 'event_espresso'), |
|
| 132 | - 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
| 133 | - '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 134 | - '_REG_paid' => __('Paid', 'event_espresso'), |
|
| 135 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 136 | - ); |
|
| 137 | - $this->_bottom_buttons = array( |
|
| 138 | - 'report_all' => array( |
|
| 139 | - 'route' => 'registrations_report', |
|
| 140 | - 'extra_request' => array( |
|
| 141 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 142 | - ), |
|
| 143 | - ), |
|
| 144 | - ); |
|
| 145 | - } |
|
| 146 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 147 | - 'route' => 'registrations_report', |
|
| 148 | - 'extra_request' => array( |
|
| 149 | - 'use_filters' => true, |
|
| 150 | - 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
| 151 | - 'page', |
|
| 152 | - 'action', |
|
| 153 | - 'default_nonce', |
|
| 154 | - ))), |
|
| 155 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 156 | - ), |
|
| 157 | - ); |
|
| 158 | - $this->_primary_column = '_REG_ID'; |
|
| 159 | - $this->_sortable_columns = array( |
|
| 160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 161 | - /** |
|
| 162 | - * Allows users to change the default sort if they wish. |
|
| 163 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 164 | - */ |
|
| 165 | - 'ATT_fname' => array( |
|
| 166 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 167 | - true, |
|
| 168 | - $this |
|
| 169 | - ) |
|
| 170 | - ? array('ATT_lname' => false) |
|
| 171 | - : array('ATT_fname' => false), |
|
| 172 | - 'event_name' => array('event_name' => false), |
|
| 173 | - 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
| 174 | - '_REG_ID' => array('_REG_ID' => false), |
|
| 175 | - ); |
|
| 176 | - $this->_hidden_columns = array(); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * This simply sets up the row class for the table rows. |
|
| 183 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | - * |
|
| 185 | - * @param EE_Registration $item the current item |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - protected function _get_row_class($item) |
|
| 189 | - { |
|
| 190 | - $class = parent::_get_row_class($item); |
|
| 191 | - //add status class |
|
| 192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | - if ($this->_has_checkbox_column) { |
|
| 194 | - $class .= ' has-checkbox-column'; |
|
| 195 | - } |
|
| 196 | - return $class; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Set the $_transaction_details property if not set yet. |
|
| 203 | - * |
|
| 204 | - * @param EE_Registration $registration |
|
| 205 | - * @throws \EE_Error |
|
| 206 | - */ |
|
| 207 | - protected function _set_related_details(EE_Registration $registration) |
|
| 208 | - { |
|
| 209 | - $transaction = $registration->get_first_related('Transaction'); |
|
| 210 | - $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
| 211 | - : EEM_Transaction::failed_status_code; |
|
| 212 | - $this->_transaction_details = array( |
|
| 213 | - 'transaction' => $transaction, |
|
| 214 | - 'status' => $status, |
|
| 215 | - 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
| 216 | - 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
| 217 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 218 | - ); |
|
| 219 | - try { |
|
| 220 | - $event = $registration->event(); |
|
| 221 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 222 | - $event = null; |
|
| 223 | - } |
|
| 224 | - $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
| 225 | - $this->_event_details = array( |
|
| 226 | - 'event' => $event, |
|
| 227 | - 'status' => $status, |
|
| 228 | - 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
| 229 | - 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
| 230 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 231 | - ); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * _get_table_filters |
|
| 238 | - * |
|
| 239 | - * @access protected |
|
| 240 | - * @return array |
|
| 241 | - */ |
|
| 242 | - protected function _get_table_filters() |
|
| 243 | - { |
|
| 244 | - $filters = array(); |
|
| 245 | - //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
| 246 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 247 | - $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 248 | - $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
| 249 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 250 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 251 | - $status = array(); |
|
| 252 | - $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
| 253 | - foreach ($this->_status as $key => $value) { |
|
| 254 | - $status[] = array('id' => $key, 'text' => $value); |
|
| 255 | - } |
|
| 256 | - if ($this->_view !== 'incomplete') { |
|
| 257 | - $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
| 258 | - isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 259 | - : ''); |
|
| 260 | - } |
|
| 261 | - if (isset($this->_req_data['event_id'])) { |
|
| 262 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 263 | - } |
|
| 264 | - return $filters; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * _add_view_counts |
|
| 271 | - * |
|
| 272 | - * @access protected |
|
| 273 | - * @return void |
|
| 274 | - * @throws \EE_Error |
|
| 275 | - */ |
|
| 276 | - protected function _add_view_counts() |
|
| 277 | - { |
|
| 278 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 279 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 280 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 281 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 282 | - 'espresso_registrations_trash_registrations') |
|
| 283 | - ) { |
|
| 284 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 285 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * _total_registrations |
|
| 293 | - * |
|
| 294 | - * @access protected |
|
| 295 | - * @param string $view |
|
| 296 | - * @return int |
|
| 297 | - * @throws \EE_Error |
|
| 298 | - */ |
|
| 299 | - protected function _total_registrations($view = '') |
|
| 300 | - { |
|
| 301 | - $_where = array(); |
|
| 302 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 303 | - if ($EVT_ID) { |
|
| 304 | - $_where['EVT_ID'] = $EVT_ID; |
|
| 305 | - } |
|
| 306 | - switch ($view) { |
|
| 307 | - case 'trash' : |
|
| 308 | - return EEM_Registration::instance()->count_deleted(array($_where)); |
|
| 309 | - break; |
|
| 310 | - case 'incomplete' : |
|
| 311 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 312 | - break; |
|
| 313 | - default : |
|
| 314 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 315 | - } |
|
| 316 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * _total_registrations_this_month |
|
| 323 | - * |
|
| 324 | - * @access protected |
|
| 325 | - * @return int |
|
| 326 | - * @throws \EE_Error |
|
| 327 | - */ |
|
| 328 | - protected function _total_registrations_this_month() |
|
| 329 | - { |
|
| 330 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 331 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 332 | - $this_year_r = date('Y', current_time('timestamp')); |
|
| 333 | - $time_start = ' 00:00:00'; |
|
| 334 | - $time_end = ' 23:59:59'; |
|
| 335 | - $this_month_r = date('m', current_time('timestamp')); |
|
| 336 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 337 | - //setup date query. |
|
| 338 | - $beginning_string = EEM_Registration::instance() |
|
| 339 | - ->convert_datetime_for_query('REG_date', |
|
| 340 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 341 | - 'Y-m-d H:i:s'); |
|
| 342 | - $end_string = EEM_Registration::instance() |
|
| 343 | - ->convert_datetime_for_query('REG_date', |
|
| 344 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 345 | - 'Y-m-d H:i:s'); |
|
| 346 | - $_where['REG_date'] = array( |
|
| 347 | - 'BETWEEN', |
|
| 348 | - array( |
|
| 349 | - $beginning_string, |
|
| 350 | - $end_string, |
|
| 351 | - ), |
|
| 352 | - ); |
|
| 353 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 354 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * _total_registrations_today |
|
| 361 | - * |
|
| 362 | - * @access protected |
|
| 363 | - * @return int |
|
| 364 | - * @throws \EE_Error |
|
| 365 | - */ |
|
| 366 | - protected function _total_registrations_today() |
|
| 367 | - { |
|
| 368 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 369 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 370 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 371 | - $time_start = ' 00:00:00'; |
|
| 372 | - $time_end = ' 23:59:59'; |
|
| 373 | - $_where['REG_date'] = array( |
|
| 374 | - 'BETWEEN', |
|
| 375 | - array( |
|
| 376 | - EEM_Registration::instance() |
|
| 377 | - ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
| 378 | - EEM_Registration::instance() |
|
| 379 | - ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
| 380 | - ), |
|
| 381 | - ); |
|
| 382 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 383 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * column_cb |
|
| 390 | - * |
|
| 391 | - * @access public |
|
| 392 | - * @param \EE_Registration $item |
|
| 393 | - * @return string |
|
| 394 | - * @throws \EE_Error |
|
| 395 | - */ |
|
| 396 | - public function column_cb($item) |
|
| 397 | - { |
|
| 398 | - /** checkbox/lock **/ |
|
| 399 | - $transaction = $item->get_first_related('Transaction'); |
|
| 400 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
| 401 | - return $payment_count > 0 |
|
| 402 | - || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 403 | - 'ee_edit_registration', |
|
| 404 | - 'registration_list_table_checkbox_input', |
|
| 405 | - $item->ID() |
|
| 406 | - ) |
|
| 407 | - ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
| 408 | - . '<span class="ee-lock-icon"></span>' |
|
| 409 | - : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * column__REG_ID |
|
| 416 | - * |
|
| 417 | - * @access public |
|
| 418 | - * @param \EE_Registration $item |
|
| 419 | - * @return string |
|
| 420 | - * @throws \EE_Error |
|
| 421 | - */ |
|
| 422 | - public function column__REG_ID(EE_Registration $item) |
|
| 423 | - { |
|
| 424 | - $attendee = $item->attendee(); |
|
| 425 | - $content = $item->ID(); |
|
| 426 | - $content .= '<div class="show-on-mobile-view-only">'; |
|
| 427 | - $content .= '<br>'; |
|
| 428 | - $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 429 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 430 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 431 | - $content .= '</div>'; |
|
| 432 | - return $content; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - /** |
|
| 438 | - * column__REG_date |
|
| 439 | - * |
|
| 440 | - * @access public |
|
| 441 | - * @param \EE_Registration $item |
|
| 442 | - * @return string |
|
| 443 | - * @throws \EE_Error |
|
| 444 | - */ |
|
| 445 | - public function column__REG_date(EE_Registration $item) |
|
| 446 | - { |
|
| 447 | - $this->_set_related_details($item); |
|
| 448 | - //Build row actions |
|
| 449 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 450 | - 'action' => 'view_transaction', |
|
| 451 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 452 | - ), TXN_ADMIN_URL); |
|
| 453 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 454 | - 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
| 455 | - . $this->_transaction_details['status'] |
|
| 456 | - . '" href="' |
|
| 457 | - . $view_lnk_url |
|
| 458 | - . '" title="' |
|
| 459 | - . esc_attr($this->_transaction_details['title_attr']) |
|
| 460 | - . '">' |
|
| 461 | - . $item->get_i18n_datetime('REG_date') |
|
| 462 | - . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
| 463 | - $view_link .= '<br><span class="ee-status-text-small">' |
|
| 464 | - . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 465 | - . '</span>'; |
|
| 466 | - return $view_link; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * column_event_name |
|
| 473 | - * |
|
| 474 | - * @access public |
|
| 475 | - * @param \EE_Registration $item |
|
| 476 | - * @return string |
|
| 477 | - * @throws \EE_Error |
|
| 478 | - */ |
|
| 479 | - public function column_event_name(EE_Registration $item) |
|
| 480 | - { |
|
| 481 | - $this->_set_related_details($item); |
|
| 482 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 483 | - $EVT_ID = $item->event_ID(); |
|
| 484 | - $event_name = $item->event_name(); |
|
| 485 | - $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
| 486 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 487 | - if ($EVT_ID) { |
|
| 488 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
| 489 | - EVENTS_ADMIN_URL); |
|
| 490 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 491 | - ? '<a class="ee-status-color-' |
|
| 492 | - . $this->_event_details['status'] |
|
| 493 | - . '" href="' |
|
| 494 | - . $edit_event_url |
|
| 495 | - . '" title="' |
|
| 496 | - . esc_attr($this->_event_details['title_attr']) |
|
| 497 | - . '">' |
|
| 498 | - . $event_name |
|
| 499 | - . '</a>' : $event_name; |
|
| 500 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
| 501 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 502 | - $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
| 503 | - 'event_espresso'), $event_name); |
|
| 504 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
| 505 | - } else { |
|
| 506 | - $edit_event = $event_name; |
|
| 507 | - $actions['event_filter'] = ''; |
|
| 508 | - } |
|
| 509 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * column_DTT_EVT_start |
|
| 516 | - * |
|
| 517 | - * @access public |
|
| 518 | - * @param \EE_Registration $item |
|
| 519 | - * @return string |
|
| 520 | - * @throws \EE_Error |
|
| 521 | - */ |
|
| 522 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
| 523 | - { |
|
| 524 | - $datetime_strings = array(); |
|
| 525 | - $ticket = $item->ticket(true); |
|
| 526 | - if ($ticket instanceof EE_Ticket) { |
|
| 527 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 528 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
| 529 | - foreach ($datetimes as $datetime) { |
|
| 530 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 531 | - } |
|
| 532 | - return implode("<br />", $datetime_strings); |
|
| 533 | - } else { |
|
| 534 | - return __('There is no ticket on this registration', 'event_espresso'); |
|
| 535 | - } |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * column_ATT_fname |
|
| 542 | - * |
|
| 543 | - * @access public |
|
| 544 | - * @param \EE_Registration $item |
|
| 545 | - * @return string |
|
| 546 | - * @throws \EE_Error |
|
| 547 | - */ |
|
| 548 | - public function column_ATT_fname(EE_Registration $item) |
|
| 549 | - { |
|
| 550 | - $attendee = $item->attendee(); |
|
| 551 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 552 | - 'action' => 'view_registration', |
|
| 553 | - '_REG_ID' => $item->ID(), |
|
| 554 | - ), REG_ADMIN_URL); |
|
| 555 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 556 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 557 | - 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
| 558 | - . $edit_lnk_url |
|
| 559 | - . '" title="' |
|
| 560 | - . esc_attr__('View Registration Details', |
|
| 561 | - 'event_espresso') |
|
| 562 | - . '">' |
|
| 563 | - . $attendee_name |
|
| 564 | - . '</a>' : $attendee_name; |
|
| 565 | - $link .= $item->count() === 1 |
|
| 566 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
| 567 | - $t = $item->get_first_related('Transaction'); |
|
| 568 | - $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
| 569 | - //append group count to name |
|
| 570 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 571 | - //append reg_code |
|
| 572 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 573 | - //reg status text for accessibility |
|
| 574 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 575 | - 'sentence') . '</span>'; |
|
| 576 | - //trash/restore/delete actions |
|
| 577 | - $actions = array(); |
|
| 578 | - if ($this->_view !== 'trash' |
|
| 579 | - && $payment_count === 0 |
|
| 580 | - && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 581 | - 'espresso_registrations_trash_registrations', $item->ID()) |
|
| 582 | - ) { |
|
| 583 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 584 | - 'action' => 'trash_registrations', |
|
| 585 | - '_REG_ID' => $item->ID(), |
|
| 586 | - ), REG_ADMIN_URL); |
|
| 587 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
| 588 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 589 | - } elseif ($this->_view === 'trash') { |
|
| 590 | - // restore registration link |
|
| 591 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 592 | - 'espresso_registrations_restore_registrations', $item->ID()) |
|
| 593 | - ) { |
|
| 594 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 595 | - 'action' => 'restore_registrations', |
|
| 596 | - '_REG_ID' => $item->ID(), |
|
| 597 | - ), REG_ADMIN_URL); |
|
| 598 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
| 599 | - 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
| 600 | - } |
|
| 601 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 602 | - 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
| 603 | - ) { |
|
| 604 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 605 | - 'action' => 'delete_registrations', |
|
| 606 | - '_REG_ID' => $item->ID(), |
|
| 607 | - ), REG_ADMIN_URL); |
|
| 608 | - $actions['delete'] = '<a href="' |
|
| 609 | - . $delete_lnk_url |
|
| 610 | - . '" title="' |
|
| 611 | - . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 612 | - . '">' |
|
| 613 | - . __('Delete', 'event_espresso') |
|
| 614 | - . '</a>'; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * column_ATT_email |
|
| 624 | - * |
|
| 625 | - * @access public |
|
| 626 | - * @param \EE_Registration $item |
|
| 627 | - * @return string |
|
| 628 | - * @throws \EE_Error |
|
| 629 | - */ |
|
| 630 | - public function column_ATT_email(EE_Registration $item) |
|
| 631 | - { |
|
| 632 | - $attendee = $item->get_first_related('Attendee'); |
|
| 633 | - return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
| 634 | - : $attendee->email(); |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * column__REG_count |
|
| 641 | - * |
|
| 642 | - * @access public |
|
| 643 | - * @param \EE_Registration $item |
|
| 644 | - * @return string |
|
| 645 | - */ |
|
| 646 | - public function column__REG_count(EE_Registration $item) |
|
| 647 | - { |
|
| 648 | - return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * column_PRC_amount |
|
| 655 | - * |
|
| 656 | - * @access public |
|
| 657 | - * @param \EE_Registration $item |
|
| 658 | - * @return string |
|
| 659 | - */ |
|
| 660 | - public function column_PRC_amount(EE_Registration $item) |
|
| 661 | - { |
|
| 662 | - $ticket = $item->ticket(); |
|
| 663 | - $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
| 664 | - . $ticket->name() |
|
| 665 | - . '</span><br />' : ''; |
|
| 666 | - if ($item->final_price() > 0) { |
|
| 667 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 668 | - } else { |
|
| 669 | - // free event |
|
| 670 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 671 | - . __('free', 'event_espresso') |
|
| 672 | - . '</span>'; |
|
| 673 | - } |
|
| 674 | - return $content; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * column__REG_final_price |
|
| 681 | - * |
|
| 682 | - * @access public |
|
| 683 | - * @param \EE_Registration $item |
|
| 684 | - * @return string |
|
| 685 | - */ |
|
| 686 | - public function column__REG_final_price(EE_Registration $item) |
|
| 687 | - { |
|
| 688 | - $ticket = $item->ticket(); |
|
| 689 | - $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 690 | - ? '' |
|
| 691 | - : '<span class="TKT_name">' |
|
| 692 | - . $ticket->name() |
|
| 693 | - . '</span><br />'; |
|
| 694 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 695 | - return $content; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * column__REG_paid |
|
| 702 | - * |
|
| 703 | - * @access public |
|
| 704 | - * @param \EE_Registration $item |
|
| 705 | - * @return string |
|
| 706 | - */ |
|
| 707 | - public function column__REG_paid(EE_Registration $item) |
|
| 708 | - { |
|
| 709 | - $payment_method = $item->payment_method(); |
|
| 710 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
| 711 | - : __('Unknown', 'event_espresso'); |
|
| 712 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 713 | - if ($item->paid() > 0) { |
|
| 714 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 715 | - $payment_method_name) . '</span>'; |
|
| 716 | - } |
|
| 717 | - return $content; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * column_TXN_total |
|
| 724 | - * |
|
| 725 | - * @access public |
|
| 726 | - * @param \EE_Registration $item |
|
| 727 | - * @return string |
|
| 728 | - * @throws \EE_Error |
|
| 729 | - */ |
|
| 730 | - public function column_TXN_total(EE_Registration $item) |
|
| 731 | - { |
|
| 732 | - if ($item->transaction()) { |
|
| 733 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 734 | - 'action' => 'view_transaction', |
|
| 735 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 736 | - ), TXN_ADMIN_URL); |
|
| 737 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 738 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 739 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 740 | - . $item->transaction()->status_ID() |
|
| 741 | - . '" href="' |
|
| 742 | - . $view_txn_lnk_url |
|
| 743 | - . '" title="' |
|
| 744 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 745 | - . '">' |
|
| 746 | - . $item->transaction()->pretty_total() |
|
| 747 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 748 | - } else { |
|
| 749 | - return __("None", "event_espresso"); |
|
| 750 | - } |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - |
|
| 755 | - /** |
|
| 756 | - * column_TXN_paid |
|
| 757 | - * |
|
| 758 | - * @access public |
|
| 759 | - * @param \EE_Registration $item |
|
| 760 | - * @return string |
|
| 761 | - * @throws \EE_Error |
|
| 762 | - */ |
|
| 763 | - public function column_TXN_paid(EE_Registration $item) |
|
| 764 | - { |
|
| 765 | - if ($item->count() === 1) { |
|
| 766 | - $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
| 767 | - if ($transaction->paid() >= $transaction->total()) { |
|
| 768 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 769 | - } else { |
|
| 770 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 771 | - 'action' => 'view_transaction', |
|
| 772 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 773 | - ), TXN_ADMIN_URL); |
|
| 774 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 775 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 776 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 777 | - . $transaction->status_ID() |
|
| 778 | - . '" href="' |
|
| 779 | - . $view_txn_lnk_url |
|
| 780 | - . '" title="' |
|
| 781 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 782 | - . '">' |
|
| 783 | - . $item->transaction()->pretty_paid() |
|
| 784 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 785 | - } |
|
| 786 | - } |
|
| 787 | - return ' '; |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * column_actions |
|
| 794 | - * |
|
| 795 | - * @access public |
|
| 796 | - * @param \EE_Registration $item |
|
| 797 | - * @return string |
|
| 798 | - * @throws \EE_Error |
|
| 799 | - */ |
|
| 800 | - public function column_actions(EE_Registration $item) |
|
| 801 | - { |
|
| 802 | - $actions = array(); |
|
| 803 | - $attendee = $item->attendee(); |
|
| 804 | - $this->_set_related_details($item); |
|
| 805 | - //Build row actions |
|
| 806 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 807 | - 'action' => 'view_registration', |
|
| 808 | - '_REG_ID' => $item->ID(), |
|
| 809 | - ), REG_ADMIN_URL); |
|
| 810 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 811 | - 'action' => 'edit_attendee', |
|
| 812 | - 'post' => $item->attendee_ID(), |
|
| 813 | - ), REG_ADMIN_URL); |
|
| 814 | - // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
| 815 | - //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
| 816 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 817 | - 'action' => 'resend_registration', |
|
| 818 | - '_REG_ID' => $item->ID(), |
|
| 819 | - ), REG_ADMIN_URL, true); |
|
| 820 | - //Build row actions |
|
| 821 | - $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 822 | - 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
| 29 | + private $_status; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * An array of transaction details for the related transaction to the registration being processed. |
|
| 35 | + * This is set via the _set_related_details method. |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected $_transaction_details = array(); |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * An array of event details for the related event to the registration being processed. |
|
| 45 | + * This is set via the _set_related_details method. |
|
| 46 | + * |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | + protected $_event_details = array(); |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param \Registrations_Admin_Page $admin_page |
|
| 55 | + */ |
|
| 56 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
| 57 | + { |
|
| 58 | + if ( ! empty($_GET['event_id'])) { |
|
| 59 | + $extra_query_args = array(); |
|
| 60 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
| 61 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
| 62 | + } |
|
| 63 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 64 | + } |
|
| 65 | + parent::__construct($admin_page); |
|
| 66 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * _setup_data |
|
| 73 | + * |
|
| 74 | + * @access protected |
|
| 75 | + * @return void |
|
| 76 | + */ |
|
| 77 | + protected function _setup_data() |
|
| 78 | + { |
|
| 79 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 80 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * _set_properties |
|
| 87 | + * |
|
| 88 | + * @access protected |
|
| 89 | + * @return void |
|
| 90 | + */ |
|
| 91 | + protected function _set_properties() |
|
| 92 | + { |
|
| 93 | + $this->_wp_list_args = array( |
|
| 94 | + 'singular' => __('registration', 'event_espresso'), |
|
| 95 | + 'plural' => __('registrations', 'event_espresso'), |
|
| 96 | + 'ajax' => true, |
|
| 97 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 98 | + ); |
|
| 99 | + $ID_column_name = __('ID', 'event_espresso'); |
|
| 100 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 101 | + $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
| 102 | + $ID_column_name .= '</span> '; |
|
| 103 | + if (isset($_GET['event_id'])) { |
|
| 104 | + $this->_columns = array( |
|
| 105 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 106 | + '_REG_ID' => $ID_column_name, |
|
| 107 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 108 | + 'ATT_email' => __('Email', 'event_espresso'), |
|
| 109 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
| 110 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
| 111 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
| 112 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
| 113 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 114 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 115 | + ); |
|
| 116 | + $this->_bottom_buttons = array( |
|
| 117 | + 'report' => array( |
|
| 118 | + 'route' => 'registrations_report', |
|
| 119 | + 'extra_request' => array( |
|
| 120 | + 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 121 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 122 | + ), |
|
| 123 | + ), |
|
| 124 | + ); |
|
| 125 | + } else { |
|
| 126 | + $this->_columns = array( |
|
| 127 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 128 | + '_REG_ID' => $ID_column_name, |
|
| 129 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 130 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
| 131 | + 'event_name' => __('Event', 'event_espresso'), |
|
| 132 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
| 133 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 134 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
| 135 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 136 | + ); |
|
| 137 | + $this->_bottom_buttons = array( |
|
| 138 | + 'report_all' => array( |
|
| 139 | + 'route' => 'registrations_report', |
|
| 140 | + 'extra_request' => array( |
|
| 141 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 142 | + ), |
|
| 143 | + ), |
|
| 144 | + ); |
|
| 145 | + } |
|
| 146 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 147 | + 'route' => 'registrations_report', |
|
| 148 | + 'extra_request' => array( |
|
| 149 | + 'use_filters' => true, |
|
| 150 | + 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
| 151 | + 'page', |
|
| 152 | + 'action', |
|
| 153 | + 'default_nonce', |
|
| 154 | + ))), |
|
| 155 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 156 | + ), |
|
| 157 | + ); |
|
| 158 | + $this->_primary_column = '_REG_ID'; |
|
| 159 | + $this->_sortable_columns = array( |
|
| 160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 161 | + /** |
|
| 162 | + * Allows users to change the default sort if they wish. |
|
| 163 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 164 | + */ |
|
| 165 | + 'ATT_fname' => array( |
|
| 166 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 167 | + true, |
|
| 168 | + $this |
|
| 169 | + ) |
|
| 170 | + ? array('ATT_lname' => false) |
|
| 171 | + : array('ATT_fname' => false), |
|
| 172 | + 'event_name' => array('event_name' => false), |
|
| 173 | + 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
| 174 | + '_REG_ID' => array('_REG_ID' => false), |
|
| 175 | + ); |
|
| 176 | + $this->_hidden_columns = array(); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * This simply sets up the row class for the table rows. |
|
| 183 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | + * |
|
| 185 | + * @param EE_Registration $item the current item |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + protected function _get_row_class($item) |
|
| 189 | + { |
|
| 190 | + $class = parent::_get_row_class($item); |
|
| 191 | + //add status class |
|
| 192 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | + if ($this->_has_checkbox_column) { |
|
| 194 | + $class .= ' has-checkbox-column'; |
|
| 195 | + } |
|
| 196 | + return $class; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Set the $_transaction_details property if not set yet. |
|
| 203 | + * |
|
| 204 | + * @param EE_Registration $registration |
|
| 205 | + * @throws \EE_Error |
|
| 206 | + */ |
|
| 207 | + protected function _set_related_details(EE_Registration $registration) |
|
| 208 | + { |
|
| 209 | + $transaction = $registration->get_first_related('Transaction'); |
|
| 210 | + $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
| 211 | + : EEM_Transaction::failed_status_code; |
|
| 212 | + $this->_transaction_details = array( |
|
| 213 | + 'transaction' => $transaction, |
|
| 214 | + 'status' => $status, |
|
| 215 | + 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
| 216 | + 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
| 217 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 218 | + ); |
|
| 219 | + try { |
|
| 220 | + $event = $registration->event(); |
|
| 221 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 222 | + $event = null; |
|
| 223 | + } |
|
| 224 | + $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
| 225 | + $this->_event_details = array( |
|
| 226 | + 'event' => $event, |
|
| 227 | + 'status' => $status, |
|
| 228 | + 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
| 229 | + 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
| 230 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * _get_table_filters |
|
| 238 | + * |
|
| 239 | + * @access protected |
|
| 240 | + * @return array |
|
| 241 | + */ |
|
| 242 | + protected function _get_table_filters() |
|
| 243 | + { |
|
| 244 | + $filters = array(); |
|
| 245 | + //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
| 246 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 247 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 248 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
| 249 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 250 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 251 | + $status = array(); |
|
| 252 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
| 253 | + foreach ($this->_status as $key => $value) { |
|
| 254 | + $status[] = array('id' => $key, 'text' => $value); |
|
| 255 | + } |
|
| 256 | + if ($this->_view !== 'incomplete') { |
|
| 257 | + $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
| 258 | + isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 259 | + : ''); |
|
| 260 | + } |
|
| 261 | + if (isset($this->_req_data['event_id'])) { |
|
| 262 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 263 | + } |
|
| 264 | + return $filters; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * _add_view_counts |
|
| 271 | + * |
|
| 272 | + * @access protected |
|
| 273 | + * @return void |
|
| 274 | + * @throws \EE_Error |
|
| 275 | + */ |
|
| 276 | + protected function _add_view_counts() |
|
| 277 | + { |
|
| 278 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 279 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 280 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 281 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 282 | + 'espresso_registrations_trash_registrations') |
|
| 283 | + ) { |
|
| 284 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 285 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * _total_registrations |
|
| 293 | + * |
|
| 294 | + * @access protected |
|
| 295 | + * @param string $view |
|
| 296 | + * @return int |
|
| 297 | + * @throws \EE_Error |
|
| 298 | + */ |
|
| 299 | + protected function _total_registrations($view = '') |
|
| 300 | + { |
|
| 301 | + $_where = array(); |
|
| 302 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 303 | + if ($EVT_ID) { |
|
| 304 | + $_where['EVT_ID'] = $EVT_ID; |
|
| 305 | + } |
|
| 306 | + switch ($view) { |
|
| 307 | + case 'trash' : |
|
| 308 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
| 309 | + break; |
|
| 310 | + case 'incomplete' : |
|
| 311 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 312 | + break; |
|
| 313 | + default : |
|
| 314 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 315 | + } |
|
| 316 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * _total_registrations_this_month |
|
| 323 | + * |
|
| 324 | + * @access protected |
|
| 325 | + * @return int |
|
| 326 | + * @throws \EE_Error |
|
| 327 | + */ |
|
| 328 | + protected function _total_registrations_this_month() |
|
| 329 | + { |
|
| 330 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 331 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 332 | + $this_year_r = date('Y', current_time('timestamp')); |
|
| 333 | + $time_start = ' 00:00:00'; |
|
| 334 | + $time_end = ' 23:59:59'; |
|
| 335 | + $this_month_r = date('m', current_time('timestamp')); |
|
| 336 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 337 | + //setup date query. |
|
| 338 | + $beginning_string = EEM_Registration::instance() |
|
| 339 | + ->convert_datetime_for_query('REG_date', |
|
| 340 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 341 | + 'Y-m-d H:i:s'); |
|
| 342 | + $end_string = EEM_Registration::instance() |
|
| 343 | + ->convert_datetime_for_query('REG_date', |
|
| 344 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 345 | + 'Y-m-d H:i:s'); |
|
| 346 | + $_where['REG_date'] = array( |
|
| 347 | + 'BETWEEN', |
|
| 348 | + array( |
|
| 349 | + $beginning_string, |
|
| 350 | + $end_string, |
|
| 351 | + ), |
|
| 352 | + ); |
|
| 353 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 354 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * _total_registrations_today |
|
| 361 | + * |
|
| 362 | + * @access protected |
|
| 363 | + * @return int |
|
| 364 | + * @throws \EE_Error |
|
| 365 | + */ |
|
| 366 | + protected function _total_registrations_today() |
|
| 367 | + { |
|
| 368 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 369 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 370 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 371 | + $time_start = ' 00:00:00'; |
|
| 372 | + $time_end = ' 23:59:59'; |
|
| 373 | + $_where['REG_date'] = array( |
|
| 374 | + 'BETWEEN', |
|
| 375 | + array( |
|
| 376 | + EEM_Registration::instance() |
|
| 377 | + ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
| 378 | + EEM_Registration::instance() |
|
| 379 | + ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
| 380 | + ), |
|
| 381 | + ); |
|
| 382 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 383 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * column_cb |
|
| 390 | + * |
|
| 391 | + * @access public |
|
| 392 | + * @param \EE_Registration $item |
|
| 393 | + * @return string |
|
| 394 | + * @throws \EE_Error |
|
| 395 | + */ |
|
| 396 | + public function column_cb($item) |
|
| 397 | + { |
|
| 398 | + /** checkbox/lock **/ |
|
| 399 | + $transaction = $item->get_first_related('Transaction'); |
|
| 400 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
| 401 | + return $payment_count > 0 |
|
| 402 | + || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 403 | + 'ee_edit_registration', |
|
| 404 | + 'registration_list_table_checkbox_input', |
|
| 405 | + $item->ID() |
|
| 406 | + ) |
|
| 407 | + ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
| 408 | + . '<span class="ee-lock-icon"></span>' |
|
| 409 | + : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * column__REG_ID |
|
| 416 | + * |
|
| 417 | + * @access public |
|
| 418 | + * @param \EE_Registration $item |
|
| 419 | + * @return string |
|
| 420 | + * @throws \EE_Error |
|
| 421 | + */ |
|
| 422 | + public function column__REG_ID(EE_Registration $item) |
|
| 423 | + { |
|
| 424 | + $attendee = $item->attendee(); |
|
| 425 | + $content = $item->ID(); |
|
| 426 | + $content .= '<div class="show-on-mobile-view-only">'; |
|
| 427 | + $content .= '<br>'; |
|
| 428 | + $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 429 | + $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 430 | + $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 431 | + $content .= '</div>'; |
|
| 432 | + return $content; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * column__REG_date |
|
| 439 | + * |
|
| 440 | + * @access public |
|
| 441 | + * @param \EE_Registration $item |
|
| 442 | + * @return string |
|
| 443 | + * @throws \EE_Error |
|
| 444 | + */ |
|
| 445 | + public function column__REG_date(EE_Registration $item) |
|
| 446 | + { |
|
| 447 | + $this->_set_related_details($item); |
|
| 448 | + //Build row actions |
|
| 449 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 450 | + 'action' => 'view_transaction', |
|
| 451 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 452 | + ), TXN_ADMIN_URL); |
|
| 453 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 454 | + 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
| 455 | + . $this->_transaction_details['status'] |
|
| 456 | + . '" href="' |
|
| 457 | + . $view_lnk_url |
|
| 458 | + . '" title="' |
|
| 459 | + . esc_attr($this->_transaction_details['title_attr']) |
|
| 460 | + . '">' |
|
| 461 | + . $item->get_i18n_datetime('REG_date') |
|
| 462 | + . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
| 463 | + $view_link .= '<br><span class="ee-status-text-small">' |
|
| 464 | + . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 465 | + . '</span>'; |
|
| 466 | + return $view_link; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * column_event_name |
|
| 473 | + * |
|
| 474 | + * @access public |
|
| 475 | + * @param \EE_Registration $item |
|
| 476 | + * @return string |
|
| 477 | + * @throws \EE_Error |
|
| 478 | + */ |
|
| 479 | + public function column_event_name(EE_Registration $item) |
|
| 480 | + { |
|
| 481 | + $this->_set_related_details($item); |
|
| 482 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 483 | + $EVT_ID = $item->event_ID(); |
|
| 484 | + $event_name = $item->event_name(); |
|
| 485 | + $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
| 486 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 487 | + if ($EVT_ID) { |
|
| 488 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
| 489 | + EVENTS_ADMIN_URL); |
|
| 490 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 491 | + ? '<a class="ee-status-color-' |
|
| 492 | + . $this->_event_details['status'] |
|
| 493 | + . '" href="' |
|
| 494 | + . $edit_event_url |
|
| 495 | + . '" title="' |
|
| 496 | + . esc_attr($this->_event_details['title_attr']) |
|
| 497 | + . '">' |
|
| 498 | + . $event_name |
|
| 499 | + . '</a>' : $event_name; |
|
| 500 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
| 501 | + $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 502 | + $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
| 503 | + 'event_espresso'), $event_name); |
|
| 504 | + $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
| 505 | + } else { |
|
| 506 | + $edit_event = $event_name; |
|
| 507 | + $actions['event_filter'] = ''; |
|
| 508 | + } |
|
| 509 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * column_DTT_EVT_start |
|
| 516 | + * |
|
| 517 | + * @access public |
|
| 518 | + * @param \EE_Registration $item |
|
| 519 | + * @return string |
|
| 520 | + * @throws \EE_Error |
|
| 521 | + */ |
|
| 522 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
| 523 | + { |
|
| 524 | + $datetime_strings = array(); |
|
| 525 | + $ticket = $item->ticket(true); |
|
| 526 | + if ($ticket instanceof EE_Ticket) { |
|
| 527 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 528 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
| 529 | + foreach ($datetimes as $datetime) { |
|
| 530 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 531 | + } |
|
| 532 | + return implode("<br />", $datetime_strings); |
|
| 533 | + } else { |
|
| 534 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * column_ATT_fname |
|
| 542 | + * |
|
| 543 | + * @access public |
|
| 544 | + * @param \EE_Registration $item |
|
| 545 | + * @return string |
|
| 546 | + * @throws \EE_Error |
|
| 547 | + */ |
|
| 548 | + public function column_ATT_fname(EE_Registration $item) |
|
| 549 | + { |
|
| 550 | + $attendee = $item->attendee(); |
|
| 551 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 552 | + 'action' => 'view_registration', |
|
| 553 | + '_REG_ID' => $item->ID(), |
|
| 554 | + ), REG_ADMIN_URL); |
|
| 555 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 556 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 557 | + 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
| 558 | + . $edit_lnk_url |
|
| 559 | + . '" title="' |
|
| 560 | + . esc_attr__('View Registration Details', |
|
| 561 | + 'event_espresso') |
|
| 562 | + . '">' |
|
| 563 | + . $attendee_name |
|
| 564 | + . '</a>' : $attendee_name; |
|
| 565 | + $link .= $item->count() === 1 |
|
| 566 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
| 567 | + $t = $item->get_first_related('Transaction'); |
|
| 568 | + $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
| 569 | + //append group count to name |
|
| 570 | + $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 571 | + //append reg_code |
|
| 572 | + $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 573 | + //reg status text for accessibility |
|
| 574 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 575 | + 'sentence') . '</span>'; |
|
| 576 | + //trash/restore/delete actions |
|
| 577 | + $actions = array(); |
|
| 578 | + if ($this->_view !== 'trash' |
|
| 579 | + && $payment_count === 0 |
|
| 580 | + && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 581 | + 'espresso_registrations_trash_registrations', $item->ID()) |
|
| 582 | + ) { |
|
| 583 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 584 | + 'action' => 'trash_registrations', |
|
| 585 | + '_REG_ID' => $item->ID(), |
|
| 586 | + ), REG_ADMIN_URL); |
|
| 587 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
| 588 | + 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 589 | + } elseif ($this->_view === 'trash') { |
|
| 590 | + // restore registration link |
|
| 591 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 592 | + 'espresso_registrations_restore_registrations', $item->ID()) |
|
| 593 | + ) { |
|
| 594 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 595 | + 'action' => 'restore_registrations', |
|
| 596 | + '_REG_ID' => $item->ID(), |
|
| 597 | + ), REG_ADMIN_URL); |
|
| 598 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
| 599 | + 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
| 600 | + } |
|
| 601 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 602 | + 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
| 603 | + ) { |
|
| 604 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 605 | + 'action' => 'delete_registrations', |
|
| 606 | + '_REG_ID' => $item->ID(), |
|
| 607 | + ), REG_ADMIN_URL); |
|
| 608 | + $actions['delete'] = '<a href="' |
|
| 609 | + . $delete_lnk_url |
|
| 610 | + . '" title="' |
|
| 611 | + . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 612 | + . '">' |
|
| 613 | + . __('Delete', 'event_espresso') |
|
| 614 | + . '</a>'; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * column_ATT_email |
|
| 624 | + * |
|
| 625 | + * @access public |
|
| 626 | + * @param \EE_Registration $item |
|
| 627 | + * @return string |
|
| 628 | + * @throws \EE_Error |
|
| 629 | + */ |
|
| 630 | + public function column_ATT_email(EE_Registration $item) |
|
| 631 | + { |
|
| 632 | + $attendee = $item->get_first_related('Attendee'); |
|
| 633 | + return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
| 634 | + : $attendee->email(); |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * column__REG_count |
|
| 641 | + * |
|
| 642 | + * @access public |
|
| 643 | + * @param \EE_Registration $item |
|
| 644 | + * @return string |
|
| 645 | + */ |
|
| 646 | + public function column__REG_count(EE_Registration $item) |
|
| 647 | + { |
|
| 648 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * column_PRC_amount |
|
| 655 | + * |
|
| 656 | + * @access public |
|
| 657 | + * @param \EE_Registration $item |
|
| 658 | + * @return string |
|
| 659 | + */ |
|
| 660 | + public function column_PRC_amount(EE_Registration $item) |
|
| 661 | + { |
|
| 662 | + $ticket = $item->ticket(); |
|
| 663 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
| 664 | + . $ticket->name() |
|
| 665 | + . '</span><br />' : ''; |
|
| 666 | + if ($item->final_price() > 0) { |
|
| 667 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 668 | + } else { |
|
| 669 | + // free event |
|
| 670 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 671 | + . __('free', 'event_espresso') |
|
| 672 | + . '</span>'; |
|
| 673 | + } |
|
| 674 | + return $content; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * column__REG_final_price |
|
| 681 | + * |
|
| 682 | + * @access public |
|
| 683 | + * @param \EE_Registration $item |
|
| 684 | + * @return string |
|
| 685 | + */ |
|
| 686 | + public function column__REG_final_price(EE_Registration $item) |
|
| 687 | + { |
|
| 688 | + $ticket = $item->ticket(); |
|
| 689 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 690 | + ? '' |
|
| 691 | + : '<span class="TKT_name">' |
|
| 692 | + . $ticket->name() |
|
| 693 | + . '</span><br />'; |
|
| 694 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 695 | + return $content; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * column__REG_paid |
|
| 702 | + * |
|
| 703 | + * @access public |
|
| 704 | + * @param \EE_Registration $item |
|
| 705 | + * @return string |
|
| 706 | + */ |
|
| 707 | + public function column__REG_paid(EE_Registration $item) |
|
| 708 | + { |
|
| 709 | + $payment_method = $item->payment_method(); |
|
| 710 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
| 711 | + : __('Unknown', 'event_espresso'); |
|
| 712 | + $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 713 | + if ($item->paid() > 0) { |
|
| 714 | + $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 715 | + $payment_method_name) . '</span>'; |
|
| 716 | + } |
|
| 717 | + return $content; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * column_TXN_total |
|
| 724 | + * |
|
| 725 | + * @access public |
|
| 726 | + * @param \EE_Registration $item |
|
| 727 | + * @return string |
|
| 728 | + * @throws \EE_Error |
|
| 729 | + */ |
|
| 730 | + public function column_TXN_total(EE_Registration $item) |
|
| 731 | + { |
|
| 732 | + if ($item->transaction()) { |
|
| 733 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 734 | + 'action' => 'view_transaction', |
|
| 735 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 736 | + ), TXN_ADMIN_URL); |
|
| 737 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 738 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 739 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 740 | + . $item->transaction()->status_ID() |
|
| 741 | + . '" href="' |
|
| 742 | + . $view_txn_lnk_url |
|
| 743 | + . '" title="' |
|
| 744 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 745 | + . '">' |
|
| 746 | + . $item->transaction()->pretty_total() |
|
| 747 | + . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 748 | + } else { |
|
| 749 | + return __("None", "event_espresso"); |
|
| 750 | + } |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * column_TXN_paid |
|
| 757 | + * |
|
| 758 | + * @access public |
|
| 759 | + * @param \EE_Registration $item |
|
| 760 | + * @return string |
|
| 761 | + * @throws \EE_Error |
|
| 762 | + */ |
|
| 763 | + public function column_TXN_paid(EE_Registration $item) |
|
| 764 | + { |
|
| 765 | + if ($item->count() === 1) { |
|
| 766 | + $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
| 767 | + if ($transaction->paid() >= $transaction->total()) { |
|
| 768 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 769 | + } else { |
|
| 770 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 771 | + 'action' => 'view_transaction', |
|
| 772 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 773 | + ), TXN_ADMIN_URL); |
|
| 774 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 775 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 776 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 777 | + . $transaction->status_ID() |
|
| 778 | + . '" href="' |
|
| 779 | + . $view_txn_lnk_url |
|
| 780 | + . '" title="' |
|
| 781 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 782 | + . '">' |
|
| 783 | + . $item->transaction()->pretty_paid() |
|
| 784 | + . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 785 | + } |
|
| 786 | + } |
|
| 787 | + return ' '; |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * column_actions |
|
| 794 | + * |
|
| 795 | + * @access public |
|
| 796 | + * @param \EE_Registration $item |
|
| 797 | + * @return string |
|
| 798 | + * @throws \EE_Error |
|
| 799 | + */ |
|
| 800 | + public function column_actions(EE_Registration $item) |
|
| 801 | + { |
|
| 802 | + $actions = array(); |
|
| 803 | + $attendee = $item->attendee(); |
|
| 804 | + $this->_set_related_details($item); |
|
| 805 | + //Build row actions |
|
| 806 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 807 | + 'action' => 'view_registration', |
|
| 808 | + '_REG_ID' => $item->ID(), |
|
| 809 | + ), REG_ADMIN_URL); |
|
| 810 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 811 | + 'action' => 'edit_attendee', |
|
| 812 | + 'post' => $item->attendee_ID(), |
|
| 813 | + ), REG_ADMIN_URL); |
|
| 814 | + // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
| 815 | + //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
| 816 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 817 | + 'action' => 'resend_registration', |
|
| 818 | + '_REG_ID' => $item->ID(), |
|
| 819 | + ), REG_ADMIN_URL, true); |
|
| 820 | + //Build row actions |
|
| 821 | + $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 822 | + 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
| 823 | 823 | <li> |
| 824 | 824 | <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
| 825 | 825 | <div class="dashicons dashicons-clipboard"></div> |
| 826 | 826 | </a> |
| 827 | 827 | </li>' : ''; |
| 828 | - $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
| 829 | - 'espresso_registrations_edit_attendee') |
|
| 830 | - && $attendee instanceof EE_Attendee ? ' |
|
| 828 | + $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
| 829 | + 'espresso_registrations_edit_attendee') |
|
| 830 | + && $attendee instanceof EE_Attendee ? ' |
|
| 831 | 831 | <li> |
| 832 | 832 | <a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
| 833 | 833 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
| 834 | 834 | </a> |
| 835 | 835 | </li>' : ''; |
| 836 | - $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
| 837 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 838 | - 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
| 836 | + $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
| 837 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 838 | + 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
| 839 | 839 | <li> |
| 840 | 840 | <a href="' |
| 841 | - . $resend_reg_lnk_url |
|
| 842 | - . '" title="' |
|
| 843 | - . esc_attr__('Resend Registration Details', |
|
| 844 | - 'event_espresso') |
|
| 845 | - . '" class="tiny-text"> |
|
| 841 | + . $resend_reg_lnk_url |
|
| 842 | + . '" title="' |
|
| 843 | + . esc_attr__('Resend Registration Details', |
|
| 844 | + 'event_espresso') |
|
| 845 | + . '" class="tiny-text"> |
|
| 846 | 846 | <div class="dashicons dashicons-email-alt"></div> |
| 847 | 847 | </a> |
| 848 | 848 | </li>' : ''; |
| 849 | - // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
| 850 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 851 | - 'action' => 'view_transaction', |
|
| 852 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 853 | - ), TXN_ADMIN_URL); |
|
| 854 | - $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 855 | - 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
| 849 | + // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
| 850 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 851 | + 'action' => 'view_transaction', |
|
| 852 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 853 | + ), TXN_ADMIN_URL); |
|
| 854 | + $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 855 | + 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
| 856 | 856 | <li> |
| 857 | 857 | <a class="ee-status-color-' |
| 858 | - . $this->_transaction_details['status'] |
|
| 859 | - . ' tiny-text" href="' |
|
| 860 | - . $view_txn_lnk_url |
|
| 861 | - . '" title="' |
|
| 862 | - . $this->_transaction_details['title_attr'] |
|
| 863 | - . '"> |
|
| 858 | + . $this->_transaction_details['status'] |
|
| 859 | + . ' tiny-text" href="' |
|
| 860 | + . $view_txn_lnk_url |
|
| 861 | + . '" title="' |
|
| 862 | + . $this->_transaction_details['title_attr'] |
|
| 863 | + . '"> |
|
| 864 | 864 | <div class="dashicons dashicons-cart"></div> |
| 865 | 865 | </a> |
| 866 | 866 | </li>' : ''; |
| 867 | - //invoice link |
|
| 868 | - $actions['dl_invoice_lnk'] = ''; |
|
| 869 | - $dl_invoice_lnk_url = $item->invoice_url(); |
|
| 870 | - //only show invoice link if message type is active. |
|
| 871 | - if ($attendee instanceof EE_Attendee |
|
| 872 | - && $item->is_primary_registrant() |
|
| 873 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
| 874 | - ) { |
|
| 875 | - $actions['dl_invoice_lnk'] = ' |
|
| 867 | + //invoice link |
|
| 868 | + $actions['dl_invoice_lnk'] = ''; |
|
| 869 | + $dl_invoice_lnk_url = $item->invoice_url(); |
|
| 870 | + //only show invoice link if message type is active. |
|
| 871 | + if ($attendee instanceof EE_Attendee |
|
| 872 | + && $item->is_primary_registrant() |
|
| 873 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
| 874 | + ) { |
|
| 875 | + $actions['dl_invoice_lnk'] = ' |
|
| 876 | 876 | <li> |
| 877 | 877 | <a title="' |
| 878 | - . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
| 879 | - . '" target="_blank" href="' |
|
| 880 | - . $dl_invoice_lnk_url |
|
| 881 | - . '" class="tiny-text"> |
|
| 878 | + . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
| 879 | + . '" target="_blank" href="' |
|
| 880 | + . $dl_invoice_lnk_url |
|
| 881 | + . '" class="tiny-text"> |
|
| 882 | 882 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
| 883 | 883 | </a> |
| 884 | 884 | </li>'; |
| 885 | - } |
|
| 886 | - $actions['filtered_messages_link'] = ''; |
|
| 887 | - //message list table link (filtered by REG_ID |
|
| 888 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 889 | - $actions['filtered_messages_link'] = '<li>' |
|
| 890 | - . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
| 891 | - null, array( |
|
| 892 | - '_REG_ID' => $item->ID(), |
|
| 893 | - )) |
|
| 894 | - . '</li>'; |
|
| 895 | - } |
|
| 896 | - $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 897 | - return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 898 | - } |
|
| 885 | + } |
|
| 886 | + $actions['filtered_messages_link'] = ''; |
|
| 887 | + //message list table link (filtered by REG_ID |
|
| 888 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 889 | + $actions['filtered_messages_link'] = '<li>' |
|
| 890 | + . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
| 891 | + null, array( |
|
| 892 | + '_REG_ID' => $item->ID(), |
|
| 893 | + )) |
|
| 894 | + . '</li>'; |
|
| 895 | + } |
|
| 896 | + $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 897 | + return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | 900 | } |
@@ -17,303 +17,303 @@ |
||
| 17 | 17 | class Benchmark |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * array containing the start time for the timers |
|
| 22 | - */ |
|
| 23 | - private static $start_times; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * array containing all the timer'd times, which can be outputted via show_times() |
|
| 27 | - */ |
|
| 28 | - private static $times = array(); |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - protected static $memory_usage = array(); |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * whether to benchmark code or not |
|
| 39 | - */ |
|
| 40 | - public static function doNotRun() |
|
| 41 | - { |
|
| 42 | - return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * resetTimes |
|
| 49 | - */ |
|
| 50 | - public static function resetTimes() |
|
| 51 | - { |
|
| 52 | - Benchmark::$times = array(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Add Benchmark::startTimer() before a block of code you want to measure the performance of |
|
| 59 | - * |
|
| 60 | - * @param null $timer_name |
|
| 61 | - */ |
|
| 62 | - public static function startTimer($timer_name = null) |
|
| 63 | - { |
|
| 64 | - if (Benchmark::doNotRun()) { |
|
| 65 | - return; |
|
| 66 | - } |
|
| 67 | - $timer_name = $timer_name !== '' ? $timer_name : get_called_class(); |
|
| 68 | - Benchmark::$start_times[$timer_name] = microtime(true); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Add Benchmark::stopTimer() after a block of code you want to measure the performance of |
|
| 75 | - * |
|
| 76 | - * @param string $timer_name |
|
| 77 | - */ |
|
| 78 | - public static function stopTimer($timer_name = '') |
|
| 79 | - { |
|
| 80 | - if (Benchmark::doNotRun()) { |
|
| 81 | - return; |
|
| 82 | - } |
|
| 83 | - $timer_name = $timer_name !== '' ? $timer_name : get_called_class(); |
|
| 84 | - if (isset(Benchmark::$start_times[$timer_name])) { |
|
| 85 | - $start_time = Benchmark::$start_times[$timer_name]; |
|
| 86 | - unset(Benchmark::$start_times[$timer_name]); |
|
| 87 | - } else { |
|
| 88 | - $start_time = array_pop(Benchmark::$start_times); |
|
| 89 | - } |
|
| 90 | - Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Measure the memory usage by PHP so far. |
|
| 97 | - * |
|
| 98 | - * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 99 | - * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 100 | - * @param bool $formatted |
|
| 101 | - * @return void |
|
| 102 | - */ |
|
| 103 | - public static function measureMemory($label = 'memory usage', $output_now = false, $formatted = true) |
|
| 104 | - { |
|
| 105 | - if (Benchmark::doNotRun()) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - $memory_used = Benchmark::convert(memory_get_peak_usage(true)); |
|
| 109 | - Benchmark::$memory_usage[$label] = $memory_used; |
|
| 110 | - if ($output_now) { |
|
| 111 | - echo $formatted |
|
| 112 | - ? "<br>{$label} : {$memory_used}" |
|
| 113 | - : "\n {$label} : {$memory_used}"; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * will display the benchmarking results at shutdown |
|
| 121 | - * |
|
| 122 | - * @param bool $formatted |
|
| 123 | - * @return void |
|
| 124 | - */ |
|
| 125 | - public static function displayResultsAtShutdown($formatted = true) |
|
| 126 | - { |
|
| 127 | - add_action( |
|
| 128 | - 'shutdown', |
|
| 129 | - function () use ($formatted) { |
|
| 130 | - Benchmark::displayResults(true, $formatted); |
|
| 131 | - } |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * will display the benchmarking results at shutdown |
|
| 139 | - * |
|
| 140 | - * @param string $filepath |
|
| 141 | - * @param bool $formatted |
|
| 142 | - * @param bool $append |
|
| 143 | - * @return void |
|
| 144 | - */ |
|
| 145 | - public static function writeResultsAtShutdown($filepath = '', $formatted = true, $append = true) |
|
| 146 | - { |
|
| 147 | - add_action( |
|
| 148 | - 'shutdown', |
|
| 149 | - function () use ($filepath, $formatted, $append) { |
|
| 150 | - Benchmark::writeResultsToFile($filepath, $formatted, $append); |
|
| 151 | - } |
|
| 152 | - ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @param bool $formatted |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - private static function generateResults($formatted = true) |
|
| 162 | - { |
|
| 163 | - if (Benchmark::doNotRun()) { |
|
| 164 | - return ''; |
|
| 165 | - } |
|
| 166 | - $output = ''; |
|
| 167 | - if (! empty(Benchmark::$times)) { |
|
| 168 | - $total = 0; |
|
| 169 | - $output .= $formatted |
|
| 170 | - ? '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />' |
|
| 171 | - : ''; |
|
| 172 | - foreach (Benchmark::$times as $timer_name => $total_time) { |
|
| 173 | - $output .= Benchmark::formatTime($timer_name, $total_time, $formatted); |
|
| 174 | - $output .= $formatted ? '<br />' : "\n"; |
|
| 175 | - $total += $total_time; |
|
| 176 | - } |
|
| 177 | - if($formatted) { |
|
| 178 | - $output .= '<br />'; |
|
| 179 | - $output .= '<h4>TOTAL TIME</h4>'; |
|
| 180 | - $output .= Benchmark::formatTime('', $total, $formatted); |
|
| 181 | - $output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />'; |
|
| 182 | - $output .= '<br />'; |
|
| 183 | - $output .= '<h5>Performance scale (from best to worse)</h5>'; |
|
| 184 | - $output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />'; |
|
| 185 | - $output .= '<span style="color:deepskyblue">Like...no way man!</span><br />'; |
|
| 186 | - $output .= '<span style="color:limegreen">Like...groovy!</span><br />'; |
|
| 187 | - $output .= '<span style="color:gold">Ruh Oh</span><br />'; |
|
| 188 | - $output .= '<span style="color:darkorange">Zoinks!</span><br />'; |
|
| 189 | - $output .= '<span style="color:red">Like...HEEELLLP</span><br />'; |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - if (! empty(Benchmark::$memory_usage)) { |
|
| 193 | - $output .= $formatted |
|
| 194 | - ? '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage) |
|
| 195 | - : implode("\n", Benchmark::$memory_usage); |
|
| 196 | - } |
|
| 197 | - if (empty($output)) { |
|
| 198 | - return ''; |
|
| 199 | - } |
|
| 200 | - $output = $formatted |
|
| 201 | - ? '<div style="border:1px solid #dddddd; background-color:#ffffff;' |
|
| 202 | - . (is_admin() |
|
| 203 | - ? ' margin:2em 2em 2em 180px;' |
|
| 204 | - : ' margin:2em;') |
|
| 205 | - . ' padding:2em;">' |
|
| 206 | - . '<h4>BENCHMARKING</h4>' |
|
| 207 | - . $output |
|
| 208 | - . '</div>' |
|
| 209 | - : $output; |
|
| 210 | - return $output; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @param bool $echo |
|
| 217 | - * @param bool $formatted |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 220 | - public static function displayResults($echo = true, $formatted = true) |
|
| 221 | - { |
|
| 222 | - $results = Benchmark::generateResults($formatted); |
|
| 223 | - if ($echo) { |
|
| 224 | - echo $results; |
|
| 225 | - $results = ''; |
|
| 226 | - } |
|
| 227 | - return $results; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * @param string $filepath |
|
| 234 | - * @param bool $formatted |
|
| 235 | - * @param bool $append |
|
| 236 | - */ |
|
| 237 | - public static function writeResultsToFile($filepath = '', $formatted = true, $append = true) |
|
| 238 | - { |
|
| 239 | - $filepath = ! empty($filepath) && is_readable(dirname($filepath)) |
|
| 240 | - ? $filepath |
|
| 241 | - : ''; |
|
| 242 | - if( empty($filepath)) { |
|
| 243 | - $filepath = EVENT_ESPRESSO_UPLOAD_DIR . 'logs/benchmarking-' . date('Y-m-d') . '.html'; |
|
| 244 | - } |
|
| 245 | - file_put_contents( |
|
| 246 | - $filepath, |
|
| 247 | - "\n" . date('Y-m-d H:i:s') . Benchmark::generateResults($formatted), |
|
| 248 | - $append ? FILE_APPEND | LOCK_EX : LOCK_EX |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc) |
|
| 256 | - * |
|
| 257 | - * @param int $size |
|
| 258 | - * @return string |
|
| 259 | - */ |
|
| 260 | - public static function convert($size) |
|
| 261 | - { |
|
| 262 | - $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
| 263 | - return round( |
|
| 264 | - $size / pow(1024, $i = floor(log($size, 1024))), |
|
| 265 | - 2 |
|
| 266 | - ) . ' ' . $unit[absint($i)]; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @param string $timer_name |
|
| 273 | - * @param float $total_time |
|
| 274 | - * @param bool $formatted |
|
| 275 | - * @return string |
|
| 276 | - */ |
|
| 277 | - public static function formatTime($timer_name, $total_time, $formatted = true) |
|
| 278 | - { |
|
| 279 | - $total_time *= 1000; |
|
| 280 | - switch ($total_time) { |
|
| 281 | - case $total_time > 12500 : |
|
| 282 | - $color = 'red'; |
|
| 283 | - $bold = 'bold'; |
|
| 284 | - break; |
|
| 285 | - case $total_time > 2500 : |
|
| 286 | - $color = 'darkorange'; |
|
| 287 | - $bold = 'bold'; |
|
| 288 | - break; |
|
| 289 | - case $total_time > 500 : |
|
| 290 | - $color = 'gold'; |
|
| 291 | - $bold = 'bold'; |
|
| 292 | - break; |
|
| 293 | - case $total_time > 100 : |
|
| 294 | - $color = 'limegreen'; |
|
| 295 | - $bold = 'normal'; |
|
| 296 | - break; |
|
| 297 | - case $total_time > 20 : |
|
| 298 | - $color = 'deepskyblue'; |
|
| 299 | - $bold = 'normal'; |
|
| 300 | - break; |
|
| 301 | - default : |
|
| 302 | - $color = 'mediumpurple'; |
|
| 303 | - $bold = 'normal'; |
|
| 304 | - break; |
|
| 305 | - } |
|
| 306 | - return $formatted |
|
| 307 | - ? '<span style="min-width: 10px; margin:0 1em; color:' |
|
| 308 | - . $color |
|
| 309 | - . '; font-weight:' |
|
| 310 | - . $bold |
|
| 311 | - . '; font-size:1.2em;">' |
|
| 312 | - . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT) |
|
| 313 | - . '</span> ' |
|
| 314 | - . $timer_name |
|
| 315 | - : str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT); |
|
| 316 | - } |
|
| 20 | + /** |
|
| 21 | + * array containing the start time for the timers |
|
| 22 | + */ |
|
| 23 | + private static $start_times; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * array containing all the timer'd times, which can be outputted via show_times() |
|
| 27 | + */ |
|
| 28 | + private static $times = array(); |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + protected static $memory_usage = array(); |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * whether to benchmark code or not |
|
| 39 | + */ |
|
| 40 | + public static function doNotRun() |
|
| 41 | + { |
|
| 42 | + return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * resetTimes |
|
| 49 | + */ |
|
| 50 | + public static function resetTimes() |
|
| 51 | + { |
|
| 52 | + Benchmark::$times = array(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Add Benchmark::startTimer() before a block of code you want to measure the performance of |
|
| 59 | + * |
|
| 60 | + * @param null $timer_name |
|
| 61 | + */ |
|
| 62 | + public static function startTimer($timer_name = null) |
|
| 63 | + { |
|
| 64 | + if (Benchmark::doNotRun()) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 67 | + $timer_name = $timer_name !== '' ? $timer_name : get_called_class(); |
|
| 68 | + Benchmark::$start_times[$timer_name] = microtime(true); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Add Benchmark::stopTimer() after a block of code you want to measure the performance of |
|
| 75 | + * |
|
| 76 | + * @param string $timer_name |
|
| 77 | + */ |
|
| 78 | + public static function stopTimer($timer_name = '') |
|
| 79 | + { |
|
| 80 | + if (Benchmark::doNotRun()) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 83 | + $timer_name = $timer_name !== '' ? $timer_name : get_called_class(); |
|
| 84 | + if (isset(Benchmark::$start_times[$timer_name])) { |
|
| 85 | + $start_time = Benchmark::$start_times[$timer_name]; |
|
| 86 | + unset(Benchmark::$start_times[$timer_name]); |
|
| 87 | + } else { |
|
| 88 | + $start_time = array_pop(Benchmark::$start_times); |
|
| 89 | + } |
|
| 90 | + Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Measure the memory usage by PHP so far. |
|
| 97 | + * |
|
| 98 | + * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 99 | + * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 100 | + * @param bool $formatted |
|
| 101 | + * @return void |
|
| 102 | + */ |
|
| 103 | + public static function measureMemory($label = 'memory usage', $output_now = false, $formatted = true) |
|
| 104 | + { |
|
| 105 | + if (Benchmark::doNotRun()) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + $memory_used = Benchmark::convert(memory_get_peak_usage(true)); |
|
| 109 | + Benchmark::$memory_usage[$label] = $memory_used; |
|
| 110 | + if ($output_now) { |
|
| 111 | + echo $formatted |
|
| 112 | + ? "<br>{$label} : {$memory_used}" |
|
| 113 | + : "\n {$label} : {$memory_used}"; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * will display the benchmarking results at shutdown |
|
| 121 | + * |
|
| 122 | + * @param bool $formatted |
|
| 123 | + * @return void |
|
| 124 | + */ |
|
| 125 | + public static function displayResultsAtShutdown($formatted = true) |
|
| 126 | + { |
|
| 127 | + add_action( |
|
| 128 | + 'shutdown', |
|
| 129 | + function () use ($formatted) { |
|
| 130 | + Benchmark::displayResults(true, $formatted); |
|
| 131 | + } |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * will display the benchmarking results at shutdown |
|
| 139 | + * |
|
| 140 | + * @param string $filepath |
|
| 141 | + * @param bool $formatted |
|
| 142 | + * @param bool $append |
|
| 143 | + * @return void |
|
| 144 | + */ |
|
| 145 | + public static function writeResultsAtShutdown($filepath = '', $formatted = true, $append = true) |
|
| 146 | + { |
|
| 147 | + add_action( |
|
| 148 | + 'shutdown', |
|
| 149 | + function () use ($filepath, $formatted, $append) { |
|
| 150 | + Benchmark::writeResultsToFile($filepath, $formatted, $append); |
|
| 151 | + } |
|
| 152 | + ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @param bool $formatted |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + private static function generateResults($formatted = true) |
|
| 162 | + { |
|
| 163 | + if (Benchmark::doNotRun()) { |
|
| 164 | + return ''; |
|
| 165 | + } |
|
| 166 | + $output = ''; |
|
| 167 | + if (! empty(Benchmark::$times)) { |
|
| 168 | + $total = 0; |
|
| 169 | + $output .= $formatted |
|
| 170 | + ? '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />' |
|
| 171 | + : ''; |
|
| 172 | + foreach (Benchmark::$times as $timer_name => $total_time) { |
|
| 173 | + $output .= Benchmark::formatTime($timer_name, $total_time, $formatted); |
|
| 174 | + $output .= $formatted ? '<br />' : "\n"; |
|
| 175 | + $total += $total_time; |
|
| 176 | + } |
|
| 177 | + if($formatted) { |
|
| 178 | + $output .= '<br />'; |
|
| 179 | + $output .= '<h4>TOTAL TIME</h4>'; |
|
| 180 | + $output .= Benchmark::formatTime('', $total, $formatted); |
|
| 181 | + $output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />'; |
|
| 182 | + $output .= '<br />'; |
|
| 183 | + $output .= '<h5>Performance scale (from best to worse)</h5>'; |
|
| 184 | + $output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />'; |
|
| 185 | + $output .= '<span style="color:deepskyblue">Like...no way man!</span><br />'; |
|
| 186 | + $output .= '<span style="color:limegreen">Like...groovy!</span><br />'; |
|
| 187 | + $output .= '<span style="color:gold">Ruh Oh</span><br />'; |
|
| 188 | + $output .= '<span style="color:darkorange">Zoinks!</span><br />'; |
|
| 189 | + $output .= '<span style="color:red">Like...HEEELLLP</span><br />'; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + if (! empty(Benchmark::$memory_usage)) { |
|
| 193 | + $output .= $formatted |
|
| 194 | + ? '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage) |
|
| 195 | + : implode("\n", Benchmark::$memory_usage); |
|
| 196 | + } |
|
| 197 | + if (empty($output)) { |
|
| 198 | + return ''; |
|
| 199 | + } |
|
| 200 | + $output = $formatted |
|
| 201 | + ? '<div style="border:1px solid #dddddd; background-color:#ffffff;' |
|
| 202 | + . (is_admin() |
|
| 203 | + ? ' margin:2em 2em 2em 180px;' |
|
| 204 | + : ' margin:2em;') |
|
| 205 | + . ' padding:2em;">' |
|
| 206 | + . '<h4>BENCHMARKING</h4>' |
|
| 207 | + . $output |
|
| 208 | + . '</div>' |
|
| 209 | + : $output; |
|
| 210 | + return $output; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param bool $echo |
|
| 217 | + * @param bool $formatted |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | + public static function displayResults($echo = true, $formatted = true) |
|
| 221 | + { |
|
| 222 | + $results = Benchmark::generateResults($formatted); |
|
| 223 | + if ($echo) { |
|
| 224 | + echo $results; |
|
| 225 | + $results = ''; |
|
| 226 | + } |
|
| 227 | + return $results; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * @param string $filepath |
|
| 234 | + * @param bool $formatted |
|
| 235 | + * @param bool $append |
|
| 236 | + */ |
|
| 237 | + public static function writeResultsToFile($filepath = '', $formatted = true, $append = true) |
|
| 238 | + { |
|
| 239 | + $filepath = ! empty($filepath) && is_readable(dirname($filepath)) |
|
| 240 | + ? $filepath |
|
| 241 | + : ''; |
|
| 242 | + if( empty($filepath)) { |
|
| 243 | + $filepath = EVENT_ESPRESSO_UPLOAD_DIR . 'logs/benchmarking-' . date('Y-m-d') . '.html'; |
|
| 244 | + } |
|
| 245 | + file_put_contents( |
|
| 246 | + $filepath, |
|
| 247 | + "\n" . date('Y-m-d H:i:s') . Benchmark::generateResults($formatted), |
|
| 248 | + $append ? FILE_APPEND | LOCK_EX : LOCK_EX |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc) |
|
| 256 | + * |
|
| 257 | + * @param int $size |
|
| 258 | + * @return string |
|
| 259 | + */ |
|
| 260 | + public static function convert($size) |
|
| 261 | + { |
|
| 262 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
| 263 | + return round( |
|
| 264 | + $size / pow(1024, $i = floor(log($size, 1024))), |
|
| 265 | + 2 |
|
| 266 | + ) . ' ' . $unit[absint($i)]; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @param string $timer_name |
|
| 273 | + * @param float $total_time |
|
| 274 | + * @param bool $formatted |
|
| 275 | + * @return string |
|
| 276 | + */ |
|
| 277 | + public static function formatTime($timer_name, $total_time, $formatted = true) |
|
| 278 | + { |
|
| 279 | + $total_time *= 1000; |
|
| 280 | + switch ($total_time) { |
|
| 281 | + case $total_time > 12500 : |
|
| 282 | + $color = 'red'; |
|
| 283 | + $bold = 'bold'; |
|
| 284 | + break; |
|
| 285 | + case $total_time > 2500 : |
|
| 286 | + $color = 'darkorange'; |
|
| 287 | + $bold = 'bold'; |
|
| 288 | + break; |
|
| 289 | + case $total_time > 500 : |
|
| 290 | + $color = 'gold'; |
|
| 291 | + $bold = 'bold'; |
|
| 292 | + break; |
|
| 293 | + case $total_time > 100 : |
|
| 294 | + $color = 'limegreen'; |
|
| 295 | + $bold = 'normal'; |
|
| 296 | + break; |
|
| 297 | + case $total_time > 20 : |
|
| 298 | + $color = 'deepskyblue'; |
|
| 299 | + $bold = 'normal'; |
|
| 300 | + break; |
|
| 301 | + default : |
|
| 302 | + $color = 'mediumpurple'; |
|
| 303 | + $bold = 'normal'; |
|
| 304 | + break; |
|
| 305 | + } |
|
| 306 | + return $formatted |
|
| 307 | + ? '<span style="min-width: 10px; margin:0 1em; color:' |
|
| 308 | + . $color |
|
| 309 | + . '; font-weight:' |
|
| 310 | + . $bold |
|
| 311 | + . '; font-size:1.2em;">' |
|
| 312 | + . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT) |
|
| 313 | + . '</span> ' |
|
| 314 | + . $timer_name |
|
| 315 | + : str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT); |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | add_action( |
| 128 | 128 | 'shutdown', |
| 129 | - function () use ($formatted) { |
|
| 129 | + function() use ($formatted) { |
|
| 130 | 130 | Benchmark::displayResults(true, $formatted); |
| 131 | 131 | } |
| 132 | 132 | ); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | add_action( |
| 148 | 148 | 'shutdown', |
| 149 | - function () use ($filepath, $formatted, $append) { |
|
| 149 | + function() use ($filepath, $formatted, $append) { |
|
| 150 | 150 | Benchmark::writeResultsToFile($filepath, $formatted, $append); |
| 151 | 151 | } |
| 152 | 152 | ); |
@@ -164,17 +164,17 @@ discard block |
||
| 164 | 164 | return ''; |
| 165 | 165 | } |
| 166 | 166 | $output = ''; |
| 167 | - if (! empty(Benchmark::$times)) { |
|
| 167 | + if ( ! empty(Benchmark::$times)) { |
|
| 168 | 168 | $total = 0; |
| 169 | 169 | $output .= $formatted |
| 170 | 170 | ? '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />' |
| 171 | 171 | : ''; |
| 172 | 172 | foreach (Benchmark::$times as $timer_name => $total_time) { |
| 173 | 173 | $output .= Benchmark::formatTime($timer_name, $total_time, $formatted); |
| 174 | - $output .= $formatted ? '<br />' : "\n"; |
|
| 174 | + $output .= $formatted ? '<br />' : "\n"; |
|
| 175 | 175 | $total += $total_time; |
| 176 | 176 | } |
| 177 | - if($formatted) { |
|
| 177 | + if ($formatted) { |
|
| 178 | 178 | $output .= '<br />'; |
| 179 | 179 | $output .= '<h4>TOTAL TIME</h4>'; |
| 180 | 180 | $output .= Benchmark::formatTime('', $total, $formatted); |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | $output .= '<span style="color:red">Like...HEEELLLP</span><br />'; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if (! empty(Benchmark::$memory_usage)) { |
|
| 192 | + if ( ! empty(Benchmark::$memory_usage)) { |
|
| 193 | 193 | $output .= $formatted |
| 194 | - ? '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage) |
|
| 194 | + ? '<h5>Memory</h5>'.implode('<br />', Benchmark::$memory_usage) |
|
| 195 | 195 | : implode("\n", Benchmark::$memory_usage); |
| 196 | 196 | } |
| 197 | 197 | if (empty($output)) { |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | $filepath = ! empty($filepath) && is_readable(dirname($filepath)) |
| 240 | 240 | ? $filepath |
| 241 | 241 | : ''; |
| 242 | - if( empty($filepath)) { |
|
| 243 | - $filepath = EVENT_ESPRESSO_UPLOAD_DIR . 'logs/benchmarking-' . date('Y-m-d') . '.html'; |
|
| 242 | + if (empty($filepath)) { |
|
| 243 | + $filepath = EVENT_ESPRESSO_UPLOAD_DIR.'logs/benchmarking-'.date('Y-m-d').'.html'; |
|
| 244 | 244 | } |
| 245 | 245 | file_put_contents( |
| 246 | 246 | $filepath, |
| 247 | - "\n" . date('Y-m-d H:i:s') . Benchmark::generateResults($formatted), |
|
| 247 | + "\n".date('Y-m-d H:i:s').Benchmark::generateResults($formatted), |
|
| 248 | 248 | $append ? FILE_APPEND | LOCK_EX : LOCK_EX |
| 249 | 249 | ); |
| 250 | 250 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | return round( |
| 264 | 264 | $size / pow(1024, $i = floor(log($size, 1024))), |
| 265 | 265 | 2 |
| 266 | - ) . ' ' . $unit[absint($i)]; |
|
| 266 | + ).' '.$unit[absint($i)]; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | && $most_recent_migration->is_broken() |
| 262 | 262 | ) |
| 263 | 263 | ) { |
| 264 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 264 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php'; |
|
| 265 | 265 | $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
| 266 | 266 | $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
| 267 | 267 | 'success' => '0', |
| 268 | 268 | ), EE_MAINTENANCE_ADMIN_URL); |
| 269 | 269 | } elseif ($addons_should_be_upgraded_first) { |
| 270 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 270 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php'; |
|
| 271 | 271 | } else { |
| 272 | 272 | if ($most_recent_migration |
| 273 | 273 | && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | $this->_template_args['current_db_state'] = null; |
| 298 | 298 | $this->_template_args['next_db_state'] = null; |
| 299 | 299 | } |
| 300 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 300 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php'; |
|
| 301 | 301 | $this->_template_args = array_merge( |
| 302 | 302 | $this->_template_args, |
| 303 | 303 | array( |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | 'status_completed' => EE_Data_Migration_Manager::status_completed, |
| 337 | 337 | )); |
| 338 | 338 | } |
| 339 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 339 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration |
|
| 340 | 340 | //now render the migration options part, and put it in a variable |
| 341 | 341 | $migration_options_template_file = apply_filters( |
| 342 | 342 | 'FHEE__ee_migration_page__migration_options_template', |
| 343 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 343 | + EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php' |
|
| 344 | 344 | ); |
| 345 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 345 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true); |
|
| 346 | 346 | $this->_template_args['migration_options_html'] = $migration_options_html; |
| 347 | 347 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 348 | 348 | $this->_template_args, true); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | public function _data_reset_and_delete() |
| 403 | 403 | { |
| 404 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 404 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php'; |
|
| 405 | 405 | $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
| 406 | 406 | 'reset_reservations', |
| 407 | 407 | 'reset_reservations', |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | protected function _reset_reservations() |
| 440 | 440 | { |
| 441 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 441 | + if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 442 | 442 | EE_Error::add_success( |
| 443 | 443 | __( |
| 444 | 444 | 'Ticket and datetime reserved counts have been successfully reset.', |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | public function _system_status() |
| 488 | 488 | { |
| 489 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 489 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php'; |
|
| 490 | 490 | $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
| 491 | 491 | $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
| 492 | 492 | array( |
@@ -505,11 +505,11 @@ discard block |
||
| 505 | 505 | public function _download_system_status() |
| 506 | 506 | { |
| 507 | 507 | $status_info = EEM_System_Status::instance()->get_system_stati(); |
| 508 | - header( 'Content-Disposition: attachment' ); |
|
| 509 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 508 | + header('Content-Disposition: attachment'); |
|
| 509 | + header("Content-Disposition: attachment; filename=system_status_".sanitize_key(site_url()).".html"); |
|
| 510 | 510 | echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
| 511 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 512 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 511 | + echo "<h1>System Information for ".site_url()."</h1>"; |
|
| 512 | + echo EEH_Template::layout_array_as_table($status_info); |
|
| 513 | 513 | die; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | try { |
| 524 | 524 | $success = wp_mail(EE_SUPPORT_EMAIL, |
| 525 | 525 | 'Migration Crash Report', |
| 526 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 526 | + $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 527 | 527 | array( |
| 528 | 528 | "from:$from_name<$from>", |
| 529 | 529 | // 'content-type:text/html charset=UTF-8' |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | EE_MAINTENANCE_ADMIN_URL); |
| 559 | 559 | $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
| 560 | 560 | EE_MAINTENANCE_ADMIN_URL); |
| 561 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 561 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 562 | 562 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 563 | 563 | $this->_template_args, true); |
| 564 | 564 | $this->display_admin_page_with_sidebar(); |
@@ -659,9 +659,9 @@ discard block |
||
| 659 | 659 | wp_enqueue_script('ee_admin_js'); |
| 660 | 660 | // wp_enqueue_media(); |
| 661 | 661 | // wp_enqueue_script('media-upload'); |
| 662 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 662 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), |
|
| 663 | 663 | EVENT_ESPRESSO_VERSION, true); |
| 664 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 664 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), |
|
| 665 | 665 | EVENT_ESPRESSO_VERSION); |
| 666 | 666 | wp_enqueue_style('espresso_maintenance'); |
| 667 | 667 | } |
@@ -698,8 +698,8 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | protected function _get_datetime_offset_fix_form() |
| 700 | 700 | { |
| 701 | - if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { |
|
| 702 | - $this->datetime_fix_offset_form = new EE_Form_Section_Proper( |
|
| 701 | + if ( ! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { |
|
| 702 | + $this->datetime_fix_offset_form = new EE_Form_Section_Proper( |
|
| 703 | 703 | array( |
| 704 | 704 | 'name' => 'datetime_offset_fix_option', |
| 705 | 705 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
@@ -28,755 +28,755 @@ |
||
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var EE_Datetime_Offset_Fix_Form |
|
| 33 | - */ |
|
| 34 | - protected $datetime_fix_offset_form; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - protected function _init_page_props() |
|
| 39 | - { |
|
| 40 | - $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
| 41 | - $this->page_label = EE_MAINTENANCE_LABEL; |
|
| 42 | - $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
| 43 | - $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - protected function _ajax_hooks() |
|
| 49 | - { |
|
| 50 | - add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
| 51 | - add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - protected function _define_page_props() |
|
| 57 | - { |
|
| 58 | - $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
| 59 | - $this->_labels = array( |
|
| 60 | - 'buttons' => array( |
|
| 61 | - 'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), |
|
| 62 | - 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
| 63 | - ), |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - protected function _set_page_routes() |
|
| 70 | - { |
|
| 71 | - $this->_page_routes = array( |
|
| 72 | - 'default' => array( |
|
| 73 | - 'func' => '_maintenance', |
|
| 74 | - 'capability' => 'manage_options', |
|
| 75 | - ), |
|
| 76 | - 'change_maintenance_level' => array( |
|
| 77 | - 'func' => '_change_maintenance_level', |
|
| 78 | - 'capability' => 'manage_options', |
|
| 79 | - 'noheader' => true, |
|
| 80 | - ), |
|
| 81 | - 'system_status' => array( |
|
| 82 | - 'func' => '_system_status', |
|
| 83 | - 'capability' => 'manage_options', |
|
| 84 | - ), |
|
| 85 | - 'download_system_status' => array( |
|
| 86 | - 'func' => '_download_system_status', |
|
| 87 | - 'capability' => 'manage_options', |
|
| 88 | - 'noheader' => true, |
|
| 89 | - ), |
|
| 90 | - 'send_migration_crash_report' => array( |
|
| 91 | - 'func' => '_send_migration_crash_report', |
|
| 92 | - 'capability' => 'manage_options', |
|
| 93 | - 'noheader' => true, |
|
| 94 | - ), |
|
| 95 | - 'confirm_migration_crash_report_sent' => array( |
|
| 96 | - 'func' => '_confirm_migration_crash_report_sent', |
|
| 97 | - 'capability' => 'manage_options', |
|
| 98 | - ), |
|
| 99 | - 'data_reset' => array( |
|
| 100 | - 'func' => '_data_reset_and_delete', |
|
| 101 | - 'capability' => 'manage_options', |
|
| 102 | - ), |
|
| 103 | - 'reset_db' => array( |
|
| 104 | - 'func' => '_reset_db', |
|
| 105 | - 'capability' => 'manage_options', |
|
| 106 | - 'noheader' => true, |
|
| 107 | - 'args' => array('nuke_old_ee4_data' => true), |
|
| 108 | - ), |
|
| 109 | - 'start_with_fresh_ee4_db' => array( |
|
| 110 | - 'func' => '_reset_db', |
|
| 111 | - 'capability' => 'manage_options', |
|
| 112 | - 'noheader' => true, |
|
| 113 | - 'args' => array('nuke_old_ee4_data' => false), |
|
| 114 | - ), |
|
| 115 | - 'delete_db' => array( |
|
| 116 | - 'func' => '_delete_db', |
|
| 117 | - 'capability' => 'manage_options', |
|
| 118 | - 'noheader' => true, |
|
| 119 | - ), |
|
| 120 | - 'rerun_migration_from_ee3' => array( |
|
| 121 | - 'func' => '_rerun_migration_from_ee3', |
|
| 122 | - 'capability' => 'manage_options', |
|
| 123 | - 'noheader' => true, |
|
| 124 | - ), |
|
| 125 | - 'reset_reservations' => array( |
|
| 126 | - 'func' => '_reset_reservations', |
|
| 127 | - 'capability' => 'manage_options', |
|
| 128 | - 'noheader' => true, |
|
| 129 | - ), |
|
| 130 | - 'reset_capabilities' => array( |
|
| 131 | - 'func' => '_reset_capabilities', |
|
| 132 | - 'capability' => 'manage_options', |
|
| 133 | - 'noheader' => true, |
|
| 134 | - ), |
|
| 135 | - 'reattempt_migration' => array( |
|
| 136 | - 'func' => '_reattempt_migration', |
|
| 137 | - 'capability' => 'manage_options', |
|
| 138 | - 'noheader' => true, |
|
| 139 | - ), |
|
| 140 | - 'datetime_tools' => array( |
|
| 141 | - 'func' => '_datetime_tools', |
|
| 142 | - 'capability' => 'manage_options' |
|
| 143 | - ), |
|
| 144 | - 'run_datetime_offset_fix' => array( |
|
| 145 | - 'func' => '_apply_datetime_offset', |
|
| 146 | - 'noheader' => true, |
|
| 147 | - 'headers_sent_route' => 'datetime_tools', |
|
| 148 | - 'capability' => 'manage_options' |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - protected function _set_page_config() |
|
| 156 | - { |
|
| 157 | - $this->_page_config = array( |
|
| 158 | - 'default' => array( |
|
| 159 | - 'nav' => array( |
|
| 160 | - 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 161 | - 'order' => 10, |
|
| 162 | - ), |
|
| 163 | - 'require_nonce' => false, |
|
| 164 | - ), |
|
| 165 | - 'data_reset' => array( |
|
| 166 | - 'nav' => array( |
|
| 167 | - 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 168 | - 'order' => 20, |
|
| 169 | - ), |
|
| 170 | - 'require_nonce' => false, |
|
| 171 | - ), |
|
| 172 | - 'datetime_tools' => array( |
|
| 173 | - 'nav' => array( |
|
| 174 | - 'label' => esc_html__('Datetime Utilities', 'event_espresso'), |
|
| 175 | - 'order' => 25 |
|
| 176 | - ), |
|
| 177 | - 'require_nonce' => false, |
|
| 178 | - ), |
|
| 179 | - 'system_status' => array( |
|
| 180 | - 'nav' => array( |
|
| 181 | - 'label' => esc_html__("System Information", "event_espresso"), |
|
| 182 | - 'order' => 30, |
|
| 183 | - ), |
|
| 184 | - 'require_nonce' => false, |
|
| 185 | - ), |
|
| 186 | - ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 193 | - * the migration scripts and all that UI. |
|
| 194 | - */ |
|
| 195 | - public function _maintenance() |
|
| 196 | - { |
|
| 197 | - //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 198 | - //level 2 (everything except maintenance page) |
|
| 199 | - try { |
|
| 200 | - //get the current maintenance level and check if |
|
| 201 | - //we are removed |
|
| 202 | - $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 203 | - $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 204 | - if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 205 | - //we just took the site out of maintenance mode, so notify the user. |
|
| 206 | - //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 207 | - //oh well, we should really be checking for this on addon deactivation anyways |
|
| 208 | - EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 209 | - 'event_espresso')); |
|
| 210 | - $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 211 | - } |
|
| 212 | - //in case an exception is thrown while trying to handle migrations |
|
| 213 | - switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 214 | - case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 215 | - case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 216 | - $show_maintenance_switch = true; |
|
| 217 | - $show_backup_db_text = false; |
|
| 218 | - $show_migration_progress = false; |
|
| 219 | - $script_names = array(); |
|
| 220 | - $addons_should_be_upgraded_first = false; |
|
| 221 | - break; |
|
| 222 | - case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 223 | - $show_maintenance_switch = false; |
|
| 224 | - $show_migration_progress = true; |
|
| 225 | - if (isset($this->_req_data['continue_migration'])) { |
|
| 226 | - $show_backup_db_text = false; |
|
| 227 | - } else { |
|
| 228 | - $show_backup_db_text = true; |
|
| 229 | - } |
|
| 230 | - $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 231 | - ->check_for_applicable_data_migration_scripts(); |
|
| 232 | - $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 233 | - $script_names = array(); |
|
| 234 | - $current_script = null; |
|
| 235 | - foreach ($scripts_needing_to_run as $script) { |
|
| 236 | - if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 237 | - if ( ! $current_script) { |
|
| 238 | - $current_script = $script; |
|
| 239 | - $current_script->migration_page_hooks(); |
|
| 240 | - } |
|
| 241 | - $script_names[] = $script->pretty_name(); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - break; |
|
| 245 | - } |
|
| 246 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 247 | - $exception_thrown = false; |
|
| 248 | - } catch (EE_Error $e) { |
|
| 249 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 250 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 251 | - //and also put the error on it. It only persists for the duration of this request |
|
| 252 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 253 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 254 | - $exception_thrown = true; |
|
| 255 | - } |
|
| 256 | - $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 257 | - $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 258 | - if ($exception_thrown |
|
| 259 | - || ($most_recent_migration |
|
| 260 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 261 | - && $most_recent_migration->is_broken() |
|
| 262 | - ) |
|
| 263 | - ) { |
|
| 264 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 265 | - $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 266 | - $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 267 | - 'success' => '0', |
|
| 268 | - ), EE_MAINTENANCE_ADMIN_URL); |
|
| 269 | - } elseif ($addons_should_be_upgraded_first) { |
|
| 270 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 271 | - } else { |
|
| 272 | - if ($most_recent_migration |
|
| 273 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 274 | - && $most_recent_migration->can_continue() |
|
| 275 | - ) { |
|
| 276 | - $show_backup_db_text = false; |
|
| 277 | - $show_continue_current_migration_script = true; |
|
| 278 | - $show_most_recent_migration = true; |
|
| 279 | - } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 280 | - $show_most_recent_migration = true; |
|
| 281 | - $show_continue_current_migration_script = false; |
|
| 282 | - } else { |
|
| 283 | - $show_most_recent_migration = false; |
|
| 284 | - $show_continue_current_migration_script = false; |
|
| 285 | - } |
|
| 286 | - if (isset($current_script)) { |
|
| 287 | - $migrates_to = $current_script->migrates_to_version(); |
|
| 288 | - $plugin_slug = $migrates_to['slug']; |
|
| 289 | - $new_version = $migrates_to['version']; |
|
| 290 | - $this->_template_args = array_merge($this->_template_args, array( |
|
| 291 | - 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 292 | - isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 293 | - 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 294 | - $new_version, $plugin_slug) : null, |
|
| 295 | - )); |
|
| 296 | - } else { |
|
| 297 | - $this->_template_args['current_db_state'] = null; |
|
| 298 | - $this->_template_args['next_db_state'] = null; |
|
| 299 | - } |
|
| 300 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 301 | - $this->_template_args = array_merge( |
|
| 302 | - $this->_template_args, |
|
| 303 | - array( |
|
| 304 | - 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 305 | - //flag for showing the most recent migration's status and/or errors |
|
| 306 | - 'show_migration_progress' => $show_migration_progress, |
|
| 307 | - //flag for showing the option to run migrations and see their progress |
|
| 308 | - 'show_backup_db_text' => $show_backup_db_text, |
|
| 309 | - //flag for showing text telling the user to backup their DB |
|
| 310 | - 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 311 | - //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 312 | - 'script_names' => $script_names, |
|
| 313 | - //array of names of scripts that have run |
|
| 314 | - 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 315 | - //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 316 | - 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 317 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 318 | - 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 319 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 320 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 321 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 322 | - 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 323 | - espresso_version()), |
|
| 324 | - ) |
|
| 325 | - ); |
|
| 326 | - //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 327 | - //localize script stuff |
|
| 328 | - wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 329 | - 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 330 | - 'next' => esc_html__("Next", "event_espresso"), |
|
| 331 | - 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 332 | - 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 333 | - "event_espresso"), |
|
| 334 | - 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 335 | - 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 336 | - 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 337 | - )); |
|
| 338 | - } |
|
| 339 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 340 | - //now render the migration options part, and put it in a variable |
|
| 341 | - $migration_options_template_file = apply_filters( |
|
| 342 | - 'FHEE__ee_migration_page__migration_options_template', |
|
| 343 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 344 | - ); |
|
| 345 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 346 | - $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 347 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 348 | - $this->_template_args, true); |
|
| 349 | - $this->display_admin_page_with_sidebar(); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 356 | - */ |
|
| 357 | - public function migration_step() |
|
| 358 | - { |
|
| 359 | - $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 360 | - $this->_return_json(); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Can be used by js when it notices a response with HTML in it in order |
|
| 367 | - * to log the malformed response |
|
| 368 | - */ |
|
| 369 | - public function add_error_to_migrations_ran() |
|
| 370 | - { |
|
| 371 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 372 | - $this->_template_args['data'] = array('ok' => true); |
|
| 373 | - $this->_return_json(); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 380 | - */ |
|
| 381 | - public function _change_maintenance_level() |
|
| 382 | - { |
|
| 383 | - $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 384 | - if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 385 | - EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 386 | - $success = true; |
|
| 387 | - } else { |
|
| 388 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 389 | - $success = false; |
|
| 390 | - } |
|
| 391 | - $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * a tab with options for resetting and/or deleting EE data |
|
| 398 | - * |
|
| 399 | - * @throws \EE_Error |
|
| 400 | - * @throws \DomainException |
|
| 401 | - */ |
|
| 402 | - public function _data_reset_and_delete() |
|
| 403 | - { |
|
| 404 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 405 | - $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 406 | - 'reset_reservations', |
|
| 407 | - 'reset_reservations', |
|
| 408 | - array(), |
|
| 409 | - 'button button-primary', |
|
| 410 | - '', |
|
| 411 | - false |
|
| 412 | - ); |
|
| 413 | - $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 414 | - 'reset_capabilities', |
|
| 415 | - 'reset_capabilities', |
|
| 416 | - array(), |
|
| 417 | - 'button button-primary', |
|
| 418 | - '', |
|
| 419 | - false |
|
| 420 | - ); |
|
| 421 | - $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 422 | - array('action' => 'delete_db'), |
|
| 423 | - EE_MAINTENANCE_ADMIN_URL |
|
| 424 | - ); |
|
| 425 | - $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 426 | - array('action' => 'reset_db'), |
|
| 427 | - EE_MAINTENANCE_ADMIN_URL |
|
| 428 | - ); |
|
| 429 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 430 | - $this->_template_path, |
|
| 431 | - $this->_template_args, |
|
| 432 | - true |
|
| 433 | - ); |
|
| 434 | - $this->display_admin_page_with_sidebar(); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - protected function _reset_reservations() |
|
| 440 | - { |
|
| 441 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 442 | - EE_Error::add_success( |
|
| 443 | - __( |
|
| 444 | - 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 445 | - 'event_espresso' |
|
| 446 | - ) |
|
| 447 | - ); |
|
| 448 | - } else { |
|
| 449 | - EE_Error::add_success( |
|
| 450 | - __( |
|
| 451 | - 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 452 | - 'event_espresso' |
|
| 453 | - ) |
|
| 454 | - ); |
|
| 455 | - } |
|
| 456 | - $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - |
|
| 460 | - |
|
| 461 | - protected function _reset_capabilities() |
|
| 462 | - { |
|
| 463 | - EE_Registry::instance()->CAP->init_caps(true); |
|
| 464 | - EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 465 | - 'event_espresso')); |
|
| 466 | - $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 473 | - * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 474 | - * the fatal error in teh first place) |
|
| 475 | - */ |
|
| 476 | - protected function _reattempt_migration() |
|
| 477 | - { |
|
| 478 | - EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 479 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * shows the big ol' System Information page |
|
| 486 | - */ |
|
| 487 | - public function _system_status() |
|
| 488 | - { |
|
| 489 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 490 | - $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 491 | - $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 492 | - array( |
|
| 493 | - 'action' => 'download_system_status', |
|
| 494 | - ), |
|
| 495 | - EE_MAINTENANCE_ADMIN_URL |
|
| 496 | - ); |
|
| 497 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 498 | - $this->_template_args, true); |
|
| 499 | - $this->display_admin_page_with_sidebar(); |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 504 | - */ |
|
| 505 | - public function _download_system_status() |
|
| 506 | - { |
|
| 507 | - $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 508 | - header( 'Content-Disposition: attachment' ); |
|
| 509 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 510 | - echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 511 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 512 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 513 | - die; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - public function _send_migration_crash_report() |
|
| 519 | - { |
|
| 520 | - $from = $this->_req_data['from']; |
|
| 521 | - $from_name = $this->_req_data['from_name']; |
|
| 522 | - $body = $this->_req_data['body']; |
|
| 523 | - try { |
|
| 524 | - $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 525 | - 'Migration Crash Report', |
|
| 526 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 527 | - array( |
|
| 528 | - "from:$from_name<$from>", |
|
| 529 | - // 'content-type:text/html charset=UTF-8' |
|
| 530 | - )); |
|
| 531 | - } catch (Exception $e) { |
|
| 532 | - $success = false; |
|
| 533 | - } |
|
| 534 | - $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 535 | - esc_html__("sent", "event_espresso"), |
|
| 536 | - array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - public function _confirm_migration_crash_report_sent() |
|
| 542 | - { |
|
| 543 | - try { |
|
| 544 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 545 | - } catch (EE_Error $e) { |
|
| 546 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 547 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 548 | - //and also put the error on it. It only persists for the duration of this request |
|
| 549 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 550 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 551 | - } |
|
| 552 | - $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 553 | - $this->_template_args['success'] = $success; |
|
| 554 | - $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 555 | - $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 556 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 557 | - $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 558 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 559 | - $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 560 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 561 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 562 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 563 | - $this->_template_args, true); |
|
| 564 | - $this->display_admin_page_with_sidebar(); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * Resets the entire EE4 database. |
|
| 571 | - * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 572 | - * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 573 | - * |
|
| 574 | - * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 575 | - * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 576 | - */ |
|
| 577 | - public function _reset_db($nuke_old_ee4_data = true) |
|
| 578 | - { |
|
| 579 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 580 | - if ($nuke_old_ee4_data) { |
|
| 581 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 582 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 583 | - EEH_Activation::remove_cron_tasks(); |
|
| 584 | - } |
|
| 585 | - //make sure when we reset the registry's config that it |
|
| 586 | - //switches to using the new singleton |
|
| 587 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 588 | - EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 589 | - EE_System::instance()->redirect_to_about_ee(); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * Deletes ALL EE tables, Records, and Options from the database. |
|
| 596 | - */ |
|
| 597 | - public function _delete_db() |
|
| 598 | - { |
|
| 599 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 600 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 601 | - EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 602 | - EEH_Activation::remove_cron_tasks(); |
|
| 603 | - EEH_Activation::deactivate_event_espresso(); |
|
| 604 | - wp_safe_redirect(admin_url('plugins.php')); |
|
| 605 | - exit; |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 612 | - */ |
|
| 613 | - public function _rerun_migration_from_ee3() |
|
| 614 | - { |
|
| 615 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 616 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 617 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 618 | - //set the db state to something that will require migrations |
|
| 619 | - update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 620 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 621 | - $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - |
|
| 625 | - |
|
| 626 | - //none of the below group are currently used for Gateway Settings |
|
| 627 | - protected function _add_screen_options() |
|
| 628 | - { |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - |
|
| 632 | - |
|
| 633 | - protected function _add_feature_pointers() |
|
| 634 | - { |
|
| 635 | - } |
|
| 636 | - |
|
| 31 | + /** |
|
| 32 | + * @var EE_Datetime_Offset_Fix_Form |
|
| 33 | + */ |
|
| 34 | + protected $datetime_fix_offset_form; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + protected function _init_page_props() |
|
| 39 | + { |
|
| 40 | + $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
| 41 | + $this->page_label = EE_MAINTENANCE_LABEL; |
|
| 42 | + $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
| 43 | + $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + protected function _ajax_hooks() |
|
| 49 | + { |
|
| 50 | + add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
| 51 | + add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + protected function _define_page_props() |
|
| 57 | + { |
|
| 58 | + $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
| 59 | + $this->_labels = array( |
|
| 60 | + 'buttons' => array( |
|
| 61 | + 'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), |
|
| 62 | + 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
| 63 | + ), |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + protected function _set_page_routes() |
|
| 70 | + { |
|
| 71 | + $this->_page_routes = array( |
|
| 72 | + 'default' => array( |
|
| 73 | + 'func' => '_maintenance', |
|
| 74 | + 'capability' => 'manage_options', |
|
| 75 | + ), |
|
| 76 | + 'change_maintenance_level' => array( |
|
| 77 | + 'func' => '_change_maintenance_level', |
|
| 78 | + 'capability' => 'manage_options', |
|
| 79 | + 'noheader' => true, |
|
| 80 | + ), |
|
| 81 | + 'system_status' => array( |
|
| 82 | + 'func' => '_system_status', |
|
| 83 | + 'capability' => 'manage_options', |
|
| 84 | + ), |
|
| 85 | + 'download_system_status' => array( |
|
| 86 | + 'func' => '_download_system_status', |
|
| 87 | + 'capability' => 'manage_options', |
|
| 88 | + 'noheader' => true, |
|
| 89 | + ), |
|
| 90 | + 'send_migration_crash_report' => array( |
|
| 91 | + 'func' => '_send_migration_crash_report', |
|
| 92 | + 'capability' => 'manage_options', |
|
| 93 | + 'noheader' => true, |
|
| 94 | + ), |
|
| 95 | + 'confirm_migration_crash_report_sent' => array( |
|
| 96 | + 'func' => '_confirm_migration_crash_report_sent', |
|
| 97 | + 'capability' => 'manage_options', |
|
| 98 | + ), |
|
| 99 | + 'data_reset' => array( |
|
| 100 | + 'func' => '_data_reset_and_delete', |
|
| 101 | + 'capability' => 'manage_options', |
|
| 102 | + ), |
|
| 103 | + 'reset_db' => array( |
|
| 104 | + 'func' => '_reset_db', |
|
| 105 | + 'capability' => 'manage_options', |
|
| 106 | + 'noheader' => true, |
|
| 107 | + 'args' => array('nuke_old_ee4_data' => true), |
|
| 108 | + ), |
|
| 109 | + 'start_with_fresh_ee4_db' => array( |
|
| 110 | + 'func' => '_reset_db', |
|
| 111 | + 'capability' => 'manage_options', |
|
| 112 | + 'noheader' => true, |
|
| 113 | + 'args' => array('nuke_old_ee4_data' => false), |
|
| 114 | + ), |
|
| 115 | + 'delete_db' => array( |
|
| 116 | + 'func' => '_delete_db', |
|
| 117 | + 'capability' => 'manage_options', |
|
| 118 | + 'noheader' => true, |
|
| 119 | + ), |
|
| 120 | + 'rerun_migration_from_ee3' => array( |
|
| 121 | + 'func' => '_rerun_migration_from_ee3', |
|
| 122 | + 'capability' => 'manage_options', |
|
| 123 | + 'noheader' => true, |
|
| 124 | + ), |
|
| 125 | + 'reset_reservations' => array( |
|
| 126 | + 'func' => '_reset_reservations', |
|
| 127 | + 'capability' => 'manage_options', |
|
| 128 | + 'noheader' => true, |
|
| 129 | + ), |
|
| 130 | + 'reset_capabilities' => array( |
|
| 131 | + 'func' => '_reset_capabilities', |
|
| 132 | + 'capability' => 'manage_options', |
|
| 133 | + 'noheader' => true, |
|
| 134 | + ), |
|
| 135 | + 'reattempt_migration' => array( |
|
| 136 | + 'func' => '_reattempt_migration', |
|
| 137 | + 'capability' => 'manage_options', |
|
| 138 | + 'noheader' => true, |
|
| 139 | + ), |
|
| 140 | + 'datetime_tools' => array( |
|
| 141 | + 'func' => '_datetime_tools', |
|
| 142 | + 'capability' => 'manage_options' |
|
| 143 | + ), |
|
| 144 | + 'run_datetime_offset_fix' => array( |
|
| 145 | + 'func' => '_apply_datetime_offset', |
|
| 146 | + 'noheader' => true, |
|
| 147 | + 'headers_sent_route' => 'datetime_tools', |
|
| 148 | + 'capability' => 'manage_options' |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + protected function _set_page_config() |
|
| 156 | + { |
|
| 157 | + $this->_page_config = array( |
|
| 158 | + 'default' => array( |
|
| 159 | + 'nav' => array( |
|
| 160 | + 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 161 | + 'order' => 10, |
|
| 162 | + ), |
|
| 163 | + 'require_nonce' => false, |
|
| 164 | + ), |
|
| 165 | + 'data_reset' => array( |
|
| 166 | + 'nav' => array( |
|
| 167 | + 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 168 | + 'order' => 20, |
|
| 169 | + ), |
|
| 170 | + 'require_nonce' => false, |
|
| 171 | + ), |
|
| 172 | + 'datetime_tools' => array( |
|
| 173 | + 'nav' => array( |
|
| 174 | + 'label' => esc_html__('Datetime Utilities', 'event_espresso'), |
|
| 175 | + 'order' => 25 |
|
| 176 | + ), |
|
| 177 | + 'require_nonce' => false, |
|
| 178 | + ), |
|
| 179 | + 'system_status' => array( |
|
| 180 | + 'nav' => array( |
|
| 181 | + 'label' => esc_html__("System Information", "event_espresso"), |
|
| 182 | + 'order' => 30, |
|
| 183 | + ), |
|
| 184 | + 'require_nonce' => false, |
|
| 185 | + ), |
|
| 186 | + ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 193 | + * the migration scripts and all that UI. |
|
| 194 | + */ |
|
| 195 | + public function _maintenance() |
|
| 196 | + { |
|
| 197 | + //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 198 | + //level 2 (everything except maintenance page) |
|
| 199 | + try { |
|
| 200 | + //get the current maintenance level and check if |
|
| 201 | + //we are removed |
|
| 202 | + $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 203 | + $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 204 | + if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 205 | + //we just took the site out of maintenance mode, so notify the user. |
|
| 206 | + //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 207 | + //oh well, we should really be checking for this on addon deactivation anyways |
|
| 208 | + EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 209 | + 'event_espresso')); |
|
| 210 | + $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 211 | + } |
|
| 212 | + //in case an exception is thrown while trying to handle migrations |
|
| 213 | + switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 214 | + case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 215 | + case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 216 | + $show_maintenance_switch = true; |
|
| 217 | + $show_backup_db_text = false; |
|
| 218 | + $show_migration_progress = false; |
|
| 219 | + $script_names = array(); |
|
| 220 | + $addons_should_be_upgraded_first = false; |
|
| 221 | + break; |
|
| 222 | + case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 223 | + $show_maintenance_switch = false; |
|
| 224 | + $show_migration_progress = true; |
|
| 225 | + if (isset($this->_req_data['continue_migration'])) { |
|
| 226 | + $show_backup_db_text = false; |
|
| 227 | + } else { |
|
| 228 | + $show_backup_db_text = true; |
|
| 229 | + } |
|
| 230 | + $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 231 | + ->check_for_applicable_data_migration_scripts(); |
|
| 232 | + $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 233 | + $script_names = array(); |
|
| 234 | + $current_script = null; |
|
| 235 | + foreach ($scripts_needing_to_run as $script) { |
|
| 236 | + if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 237 | + if ( ! $current_script) { |
|
| 238 | + $current_script = $script; |
|
| 239 | + $current_script->migration_page_hooks(); |
|
| 240 | + } |
|
| 241 | + $script_names[] = $script->pretty_name(); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + break; |
|
| 245 | + } |
|
| 246 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 247 | + $exception_thrown = false; |
|
| 248 | + } catch (EE_Error $e) { |
|
| 249 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 250 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 251 | + //and also put the error on it. It only persists for the duration of this request |
|
| 252 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 253 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 254 | + $exception_thrown = true; |
|
| 255 | + } |
|
| 256 | + $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 257 | + $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 258 | + if ($exception_thrown |
|
| 259 | + || ($most_recent_migration |
|
| 260 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 261 | + && $most_recent_migration->is_broken() |
|
| 262 | + ) |
|
| 263 | + ) { |
|
| 264 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 265 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 266 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 267 | + 'success' => '0', |
|
| 268 | + ), EE_MAINTENANCE_ADMIN_URL); |
|
| 269 | + } elseif ($addons_should_be_upgraded_first) { |
|
| 270 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 271 | + } else { |
|
| 272 | + if ($most_recent_migration |
|
| 273 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 274 | + && $most_recent_migration->can_continue() |
|
| 275 | + ) { |
|
| 276 | + $show_backup_db_text = false; |
|
| 277 | + $show_continue_current_migration_script = true; |
|
| 278 | + $show_most_recent_migration = true; |
|
| 279 | + } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 280 | + $show_most_recent_migration = true; |
|
| 281 | + $show_continue_current_migration_script = false; |
|
| 282 | + } else { |
|
| 283 | + $show_most_recent_migration = false; |
|
| 284 | + $show_continue_current_migration_script = false; |
|
| 285 | + } |
|
| 286 | + if (isset($current_script)) { |
|
| 287 | + $migrates_to = $current_script->migrates_to_version(); |
|
| 288 | + $plugin_slug = $migrates_to['slug']; |
|
| 289 | + $new_version = $migrates_to['version']; |
|
| 290 | + $this->_template_args = array_merge($this->_template_args, array( |
|
| 291 | + 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 292 | + isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 293 | + 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 294 | + $new_version, $plugin_slug) : null, |
|
| 295 | + )); |
|
| 296 | + } else { |
|
| 297 | + $this->_template_args['current_db_state'] = null; |
|
| 298 | + $this->_template_args['next_db_state'] = null; |
|
| 299 | + } |
|
| 300 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 301 | + $this->_template_args = array_merge( |
|
| 302 | + $this->_template_args, |
|
| 303 | + array( |
|
| 304 | + 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 305 | + //flag for showing the most recent migration's status and/or errors |
|
| 306 | + 'show_migration_progress' => $show_migration_progress, |
|
| 307 | + //flag for showing the option to run migrations and see their progress |
|
| 308 | + 'show_backup_db_text' => $show_backup_db_text, |
|
| 309 | + //flag for showing text telling the user to backup their DB |
|
| 310 | + 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 311 | + //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 312 | + 'script_names' => $script_names, |
|
| 313 | + //array of names of scripts that have run |
|
| 314 | + 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 315 | + //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 316 | + 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 317 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 318 | + 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 319 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 320 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 321 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 322 | + 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 323 | + espresso_version()), |
|
| 324 | + ) |
|
| 325 | + ); |
|
| 326 | + //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 327 | + //localize script stuff |
|
| 328 | + wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 329 | + 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 330 | + 'next' => esc_html__("Next", "event_espresso"), |
|
| 331 | + 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 332 | + 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 333 | + "event_espresso"), |
|
| 334 | + 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 335 | + 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 336 | + 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 337 | + )); |
|
| 338 | + } |
|
| 339 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 340 | + //now render the migration options part, and put it in a variable |
|
| 341 | + $migration_options_template_file = apply_filters( |
|
| 342 | + 'FHEE__ee_migration_page__migration_options_template', |
|
| 343 | + EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 344 | + ); |
|
| 345 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 346 | + $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 347 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 348 | + $this->_template_args, true); |
|
| 349 | + $this->display_admin_page_with_sidebar(); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 356 | + */ |
|
| 357 | + public function migration_step() |
|
| 358 | + { |
|
| 359 | + $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 360 | + $this->_return_json(); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Can be used by js when it notices a response with HTML in it in order |
|
| 367 | + * to log the malformed response |
|
| 368 | + */ |
|
| 369 | + public function add_error_to_migrations_ran() |
|
| 370 | + { |
|
| 371 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 372 | + $this->_template_args['data'] = array('ok' => true); |
|
| 373 | + $this->_return_json(); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 380 | + */ |
|
| 381 | + public function _change_maintenance_level() |
|
| 382 | + { |
|
| 383 | + $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 384 | + if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 385 | + EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 386 | + $success = true; |
|
| 387 | + } else { |
|
| 388 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 389 | + $success = false; |
|
| 390 | + } |
|
| 391 | + $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * a tab with options for resetting and/or deleting EE data |
|
| 398 | + * |
|
| 399 | + * @throws \EE_Error |
|
| 400 | + * @throws \DomainException |
|
| 401 | + */ |
|
| 402 | + public function _data_reset_and_delete() |
|
| 403 | + { |
|
| 404 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 405 | + $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 406 | + 'reset_reservations', |
|
| 407 | + 'reset_reservations', |
|
| 408 | + array(), |
|
| 409 | + 'button button-primary', |
|
| 410 | + '', |
|
| 411 | + false |
|
| 412 | + ); |
|
| 413 | + $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 414 | + 'reset_capabilities', |
|
| 415 | + 'reset_capabilities', |
|
| 416 | + array(), |
|
| 417 | + 'button button-primary', |
|
| 418 | + '', |
|
| 419 | + false |
|
| 420 | + ); |
|
| 421 | + $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 422 | + array('action' => 'delete_db'), |
|
| 423 | + EE_MAINTENANCE_ADMIN_URL |
|
| 424 | + ); |
|
| 425 | + $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 426 | + array('action' => 'reset_db'), |
|
| 427 | + EE_MAINTENANCE_ADMIN_URL |
|
| 428 | + ); |
|
| 429 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 430 | + $this->_template_path, |
|
| 431 | + $this->_template_args, |
|
| 432 | + true |
|
| 433 | + ); |
|
| 434 | + $this->display_admin_page_with_sidebar(); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + protected function _reset_reservations() |
|
| 440 | + { |
|
| 441 | + if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 442 | + EE_Error::add_success( |
|
| 443 | + __( |
|
| 444 | + 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 445 | + 'event_espresso' |
|
| 446 | + ) |
|
| 447 | + ); |
|
| 448 | + } else { |
|
| 449 | + EE_Error::add_success( |
|
| 450 | + __( |
|
| 451 | + 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 452 | + 'event_espresso' |
|
| 453 | + ) |
|
| 454 | + ); |
|
| 455 | + } |
|
| 456 | + $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + |
|
| 460 | + |
|
| 461 | + protected function _reset_capabilities() |
|
| 462 | + { |
|
| 463 | + EE_Registry::instance()->CAP->init_caps(true); |
|
| 464 | + EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 465 | + 'event_espresso')); |
|
| 466 | + $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 473 | + * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 474 | + * the fatal error in teh first place) |
|
| 475 | + */ |
|
| 476 | + protected function _reattempt_migration() |
|
| 477 | + { |
|
| 478 | + EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 479 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * shows the big ol' System Information page |
|
| 486 | + */ |
|
| 487 | + public function _system_status() |
|
| 488 | + { |
|
| 489 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 490 | + $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 491 | + $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 492 | + array( |
|
| 493 | + 'action' => 'download_system_status', |
|
| 494 | + ), |
|
| 495 | + EE_MAINTENANCE_ADMIN_URL |
|
| 496 | + ); |
|
| 497 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 498 | + $this->_template_args, true); |
|
| 499 | + $this->display_admin_page_with_sidebar(); |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 504 | + */ |
|
| 505 | + public function _download_system_status() |
|
| 506 | + { |
|
| 507 | + $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 508 | + header( 'Content-Disposition: attachment' ); |
|
| 509 | + header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 510 | + echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 511 | + echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 512 | + echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 513 | + die; |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + public function _send_migration_crash_report() |
|
| 519 | + { |
|
| 520 | + $from = $this->_req_data['from']; |
|
| 521 | + $from_name = $this->_req_data['from_name']; |
|
| 522 | + $body = $this->_req_data['body']; |
|
| 523 | + try { |
|
| 524 | + $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 525 | + 'Migration Crash Report', |
|
| 526 | + $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 527 | + array( |
|
| 528 | + "from:$from_name<$from>", |
|
| 529 | + // 'content-type:text/html charset=UTF-8' |
|
| 530 | + )); |
|
| 531 | + } catch (Exception $e) { |
|
| 532 | + $success = false; |
|
| 533 | + } |
|
| 534 | + $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 535 | + esc_html__("sent", "event_espresso"), |
|
| 536 | + array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + public function _confirm_migration_crash_report_sent() |
|
| 542 | + { |
|
| 543 | + try { |
|
| 544 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 545 | + } catch (EE_Error $e) { |
|
| 546 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 547 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 548 | + //and also put the error on it. It only persists for the duration of this request |
|
| 549 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 550 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 551 | + } |
|
| 552 | + $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 553 | + $this->_template_args['success'] = $success; |
|
| 554 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 555 | + $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 556 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 557 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 558 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 559 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 560 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 561 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 562 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 563 | + $this->_template_args, true); |
|
| 564 | + $this->display_admin_page_with_sidebar(); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * Resets the entire EE4 database. |
|
| 571 | + * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 572 | + * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 573 | + * |
|
| 574 | + * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 575 | + * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 576 | + */ |
|
| 577 | + public function _reset_db($nuke_old_ee4_data = true) |
|
| 578 | + { |
|
| 579 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 580 | + if ($nuke_old_ee4_data) { |
|
| 581 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 582 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 583 | + EEH_Activation::remove_cron_tasks(); |
|
| 584 | + } |
|
| 585 | + //make sure when we reset the registry's config that it |
|
| 586 | + //switches to using the new singleton |
|
| 587 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 588 | + EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 589 | + EE_System::instance()->redirect_to_about_ee(); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * Deletes ALL EE tables, Records, and Options from the database. |
|
| 596 | + */ |
|
| 597 | + public function _delete_db() |
|
| 598 | + { |
|
| 599 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 600 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 601 | + EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 602 | + EEH_Activation::remove_cron_tasks(); |
|
| 603 | + EEH_Activation::deactivate_event_espresso(); |
|
| 604 | + wp_safe_redirect(admin_url('plugins.php')); |
|
| 605 | + exit; |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 612 | + */ |
|
| 613 | + public function _rerun_migration_from_ee3() |
|
| 614 | + { |
|
| 615 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 616 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 617 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 618 | + //set the db state to something that will require migrations |
|
| 619 | + update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 620 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 621 | + $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + |
|
| 625 | + |
|
| 626 | + //none of the below group are currently used for Gateway Settings |
|
| 627 | + protected function _add_screen_options() |
|
| 628 | + { |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + |
|
| 632 | + |
|
| 633 | + protected function _add_feature_pointers() |
|
| 634 | + { |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | 637 | |
| 638 | 638 | |
| 639 | - public function admin_init() |
|
| 640 | - { |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - |
|
| 644 | - |
|
| 645 | - public function admin_notices() |
|
| 646 | - { |
|
| 647 | - } |
|
| 648 | - |
|
| 639 | + public function admin_init() |
|
| 640 | + { |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + |
|
| 644 | + |
|
| 645 | + public function admin_notices() |
|
| 646 | + { |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | 649 | |
| 650 | 650 | |
| 651 | - public function admin_footer_scripts() |
|
| 652 | - { |
|
| 653 | - } |
|
| 651 | + public function admin_footer_scripts() |
|
| 652 | + { |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | 655 | |
| 656 | 656 | |
| 657 | - public function load_scripts_styles() |
|
| 658 | - { |
|
| 659 | - wp_enqueue_script('ee_admin_js'); |
|
| 657 | + public function load_scripts_styles() |
|
| 658 | + { |
|
| 659 | + wp_enqueue_script('ee_admin_js'); |
|
| 660 | 660 | // wp_enqueue_media(); |
| 661 | 661 | // wp_enqueue_script('media-upload'); |
| 662 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 663 | - EVENT_ESPRESSO_VERSION, true); |
|
| 664 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 665 | - EVENT_ESPRESSO_VERSION); |
|
| 666 | - wp_enqueue_style('espresso_maintenance'); |
|
| 667 | - } |
|
| 662 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 663 | + EVENT_ESPRESSO_VERSION, true); |
|
| 664 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 665 | + EVENT_ESPRESSO_VERSION); |
|
| 666 | + wp_enqueue_style('espresso_maintenance'); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | |
| 670 | 670 | |
| 671 | - public function load_scripts_styles_default() |
|
| 672 | - { |
|
| 673 | - //styles |
|
| 671 | + public function load_scripts_styles_default() |
|
| 672 | + { |
|
| 673 | + //styles |
|
| 674 | 674 | // wp_enqueue_style('ee-text-links'); |
| 675 | 675 | // //scripts |
| 676 | 676 | // wp_enqueue_script('ee-text-links'); |
| 677 | - } |
|
| 678 | - |
|
| 679 | - |
|
| 680 | - protected function _datetime_tools() |
|
| 681 | - { |
|
| 682 | - $form_action = EE_Admin_Page::add_query_args_and_nonce( |
|
| 683 | - array( |
|
| 684 | - 'action' => 'run_datetime_offset_fix', |
|
| 685 | - 'return_action' => $this->_req_action |
|
| 686 | - ), |
|
| 687 | - EE_MAINTENANCE_ADMIN_URL |
|
| 688 | - ); |
|
| 689 | - $form = $this->_get_datetime_offset_fix_form(); |
|
| 690 | - $this->_admin_page_title = esc_html__('Datetime Utilities', 'event_espresso'); |
|
| 691 | - $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post') |
|
| 692 | - . $form->get_html_and_js() |
|
| 693 | - . $form->form_close(); |
|
| 694 | - $this->display_admin_page_with_no_sidebar(); |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - protected function _get_datetime_offset_fix_form() |
|
| 700 | - { |
|
| 701 | - if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { |
|
| 702 | - $this->datetime_fix_offset_form = new EE_Form_Section_Proper( |
|
| 703 | - array( |
|
| 704 | - 'name' => 'datetime_offset_fix_option', |
|
| 705 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 706 | - 'subsections' => array( |
|
| 707 | - 'title' => new EE_Form_Section_HTML( |
|
| 708 | - EEH_HTML::h2( |
|
| 709 | - esc_html__('Datetime Offset Tool', 'event_espresso') |
|
| 710 | - ) |
|
| 711 | - ), |
|
| 712 | - 'explanation' => new EE_Form_Section_HTML( |
|
| 713 | - EEH_HTML::p( |
|
| 714 | - esc_html__( |
|
| 715 | - 'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.', |
|
| 716 | - 'event_espresso' |
|
| 717 | - ) |
|
| 718 | - ) |
|
| 719 | - . EEH_HTML::p( |
|
| 720 | - esc_html__( |
|
| 721 | - 'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied. Decimals represent the fraction of hours, not minutes.', |
|
| 722 | - 'event_espresso' |
|
| 723 | - ) |
|
| 724 | - ) |
|
| 725 | - ), |
|
| 726 | - 'offset_input' => new EE_Float_Input( |
|
| 727 | - array( |
|
| 728 | - 'html_name' => 'offset_for_datetimes', |
|
| 729 | - 'html_label_text' => esc_html__( |
|
| 730 | - 'Offset to apply (in hours):', |
|
| 731 | - 'event_espresso' |
|
| 732 | - ), |
|
| 733 | - 'min_value' => '-12', |
|
| 734 | - 'max_value' => '14', |
|
| 735 | - 'step_value' => '.25', |
|
| 736 | - 'default' => DatetimeOffsetFix::getOffset() |
|
| 737 | - ) |
|
| 738 | - ), |
|
| 739 | - 'submit' => new EE_Submit_Input( |
|
| 740 | - array( |
|
| 741 | - 'html_label_text' => '', |
|
| 742 | - 'default' => esc_html__('Apply Offset', 'event_espresso') |
|
| 743 | - ) |
|
| 744 | - ) |
|
| 745 | - ) |
|
| 746 | - ) |
|
| 747 | - ); |
|
| 748 | - } |
|
| 749 | - return $this->datetime_fix_offset_form; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - |
|
| 753 | - /** |
|
| 754 | - * Callback for the run_datetime_offset_fix route. |
|
| 755 | - * @throws EE_Error |
|
| 756 | - */ |
|
| 757 | - protected function _apply_datetime_offset() |
|
| 758 | - { |
|
| 759 | - if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
| 760 | - $form = $this->_get_datetime_offset_fix_form(); |
|
| 761 | - $form->receive_form_submission($this->_req_data); |
|
| 762 | - if ($form->is_valid()) { |
|
| 763 | - //save offset so batch processor can get it. |
|
| 764 | - DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input')); |
|
| 765 | - //redirect to batch tool |
|
| 766 | - wp_redirect( |
|
| 767 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 768 | - array( |
|
| 769 | - 'page' => 'espresso_batch', |
|
| 770 | - 'batch' => 'job', |
|
| 771 | - 'label' => esc_html__('Applying Offset', 'event_espresso'), |
|
| 772 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'), |
|
| 773 | - 'return_url' => urlencode(home_url(add_query_arg(null, null))), |
|
| 774 | - ), |
|
| 775 | - admin_url() |
|
| 776 | - ) |
|
| 777 | - ); |
|
| 778 | - exit; |
|
| 779 | - } |
|
| 780 | - } |
|
| 781 | - } |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + |
|
| 680 | + protected function _datetime_tools() |
|
| 681 | + { |
|
| 682 | + $form_action = EE_Admin_Page::add_query_args_and_nonce( |
|
| 683 | + array( |
|
| 684 | + 'action' => 'run_datetime_offset_fix', |
|
| 685 | + 'return_action' => $this->_req_action |
|
| 686 | + ), |
|
| 687 | + EE_MAINTENANCE_ADMIN_URL |
|
| 688 | + ); |
|
| 689 | + $form = $this->_get_datetime_offset_fix_form(); |
|
| 690 | + $this->_admin_page_title = esc_html__('Datetime Utilities', 'event_espresso'); |
|
| 691 | + $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post') |
|
| 692 | + . $form->get_html_and_js() |
|
| 693 | + . $form->form_close(); |
|
| 694 | + $this->display_admin_page_with_no_sidebar(); |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + protected function _get_datetime_offset_fix_form() |
|
| 700 | + { |
|
| 701 | + if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { |
|
| 702 | + $this->datetime_fix_offset_form = new EE_Form_Section_Proper( |
|
| 703 | + array( |
|
| 704 | + 'name' => 'datetime_offset_fix_option', |
|
| 705 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 706 | + 'subsections' => array( |
|
| 707 | + 'title' => new EE_Form_Section_HTML( |
|
| 708 | + EEH_HTML::h2( |
|
| 709 | + esc_html__('Datetime Offset Tool', 'event_espresso') |
|
| 710 | + ) |
|
| 711 | + ), |
|
| 712 | + 'explanation' => new EE_Form_Section_HTML( |
|
| 713 | + EEH_HTML::p( |
|
| 714 | + esc_html__( |
|
| 715 | + 'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.', |
|
| 716 | + 'event_espresso' |
|
| 717 | + ) |
|
| 718 | + ) |
|
| 719 | + . EEH_HTML::p( |
|
| 720 | + esc_html__( |
|
| 721 | + 'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied. Decimals represent the fraction of hours, not minutes.', |
|
| 722 | + 'event_espresso' |
|
| 723 | + ) |
|
| 724 | + ) |
|
| 725 | + ), |
|
| 726 | + 'offset_input' => new EE_Float_Input( |
|
| 727 | + array( |
|
| 728 | + 'html_name' => 'offset_for_datetimes', |
|
| 729 | + 'html_label_text' => esc_html__( |
|
| 730 | + 'Offset to apply (in hours):', |
|
| 731 | + 'event_espresso' |
|
| 732 | + ), |
|
| 733 | + 'min_value' => '-12', |
|
| 734 | + 'max_value' => '14', |
|
| 735 | + 'step_value' => '.25', |
|
| 736 | + 'default' => DatetimeOffsetFix::getOffset() |
|
| 737 | + ) |
|
| 738 | + ), |
|
| 739 | + 'submit' => new EE_Submit_Input( |
|
| 740 | + array( |
|
| 741 | + 'html_label_text' => '', |
|
| 742 | + 'default' => esc_html__('Apply Offset', 'event_espresso') |
|
| 743 | + ) |
|
| 744 | + ) |
|
| 745 | + ) |
|
| 746 | + ) |
|
| 747 | + ); |
|
| 748 | + } |
|
| 749 | + return $this->datetime_fix_offset_form; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + |
|
| 753 | + /** |
|
| 754 | + * Callback for the run_datetime_offset_fix route. |
|
| 755 | + * @throws EE_Error |
|
| 756 | + */ |
|
| 757 | + protected function _apply_datetime_offset() |
|
| 758 | + { |
|
| 759 | + if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
| 760 | + $form = $this->_get_datetime_offset_fix_form(); |
|
| 761 | + $form->receive_form_submission($this->_req_data); |
|
| 762 | + if ($form->is_valid()) { |
|
| 763 | + //save offset so batch processor can get it. |
|
| 764 | + DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input')); |
|
| 765 | + //redirect to batch tool |
|
| 766 | + wp_redirect( |
|
| 767 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 768 | + array( |
|
| 769 | + 'page' => 'espresso_batch', |
|
| 770 | + 'batch' => 'job', |
|
| 771 | + 'label' => esc_html__('Applying Offset', 'event_espresso'), |
|
| 772 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'), |
|
| 773 | + 'return_url' => urlencode(home_url(add_query_arg(null, null))), |
|
| 774 | + ), |
|
| 775 | + admin_url() |
|
| 776 | + ) |
|
| 777 | + ); |
|
| 778 | + exit; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + } |
|
| 782 | 782 | } //end Maintenance_Admin_Page class |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public static function instance() |
| 33 | 33 | { |
| 34 | 34 | // check if class object is instantiated |
| 35 | - if (! self::$_instance instanceof EE_Admin) { |
|
| 35 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
| 36 | 36 | self::$_instance = new self(); |
| 37 | 37 | } |
| 38 | 38 | return self::$_instance; |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | private function _define_all_constants() |
| 93 | 93 | { |
| 94 | - if (! defined('EE_ADMIN_URL')) { |
|
| 95 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 96 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 97 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
| 98 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 94 | + if ( ! defined('EE_ADMIN_URL')) { |
|
| 95 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
| 96 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
| 97 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
| 98 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
| 99 | 99 | define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // set $main_file in stone |
| 115 | 115 | static $main_file; |
| 116 | 116 | // if $main_file is not set yet |
| 117 | - if (! $main_file) { |
|
| 117 | + if ( ! $main_file) { |
|
| 118 | 118 | $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
| 119 | 119 | } |
| 120 | 120 | if ($plugin === $main_file) { |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
| 166 | 166 | { |
| 167 | 167 | return array( |
| 168 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
| 169 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
| 170 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
| 168 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
| 169 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
| 170 | + 'support' => EE_ADMIN_PAGES.'support'.DS, |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
| 196 | 196 | } |
| 197 | 197 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
| 198 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 198 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 199 | 199 | try { |
| 200 | 200 | //this loads the controller for the admin pages which will setup routing etc |
| 201 | 201 | EE_Registry::instance()->load_core('Admin_Page_Loader'); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | public function enable_hidden_ee_nav_menu_metaboxes() |
| 248 | 248 | { |
| 249 | 249 | global $wp_meta_boxes, $pagenow; |
| 250 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 250 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 251 | 251 | return; |
| 252 | 252 | } |
| 253 | 253 | $user = wp_get_current_user(); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function modify_edit_post_link($link, $id) |
| 320 | 320 | { |
| 321 | - if (! $post = get_post($id)) { |
|
| 321 | + if ( ! $post = get_post($id)) { |
|
| 322 | 322 | return $link; |
| 323 | 323 | } |
| 324 | 324 | if ($post->post_type === 'espresso_attendees') { |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | //loop through to remove any critical pages from the array. |
| 546 | 546 | foreach ($critical_pages as $page_id) { |
| 547 | - $needle = 'value="' . $page_id . '"'; |
|
| 547 | + $needle = 'value="'.$page_id.'"'; |
|
| 548 | 548 | foreach ($split_output as $key => $haystack) { |
| 549 | 549 | if (strpos($haystack, $needle) !== false) { |
| 550 | 550 | unset($split_output[$key]); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | // calls. |
| 571 | 571 | wp_enqueue_script( |
| 572 | 572 | 'ee-inject-wp', |
| 573 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
| 573 | + EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', |
|
| 574 | 574 | array('jquery'), |
| 575 | 575 | EVENT_ESPRESSO_VERSION, |
| 576 | 576 | true |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | // register cookie script for future dependencies |
| 579 | 579 | wp_register_script( |
| 580 | 580 | 'jquery-cookie', |
| 581 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
| 581 | + EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', |
|
| 582 | 582 | array('jquery'), |
| 583 | 583 | '2.1', |
| 584 | 584 | true |
@@ -587,16 +587,16 @@ discard block |
||
| 587 | 587 | // via: add_filter('FHEE_load_joyride', '__return_true' ); |
| 588 | 588 | if (apply_filters('FHEE_load_joyride', false)) { |
| 589 | 589 | //joyride style |
| 590 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 590 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 591 | 591 | wp_register_style( |
| 592 | 592 | 'ee-joyride-css', |
| 593 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
| 593 | + EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', |
|
| 594 | 594 | array('joyride-css'), |
| 595 | 595 | EVENT_ESPRESSO_VERSION |
| 596 | 596 | ); |
| 597 | 597 | wp_register_script( |
| 598 | 598 | 'joyride-modernizr', |
| 599 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
| 599 | + EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', |
|
| 600 | 600 | array(), |
| 601 | 601 | '2.1', |
| 602 | 602 | true |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | //joyride JS |
| 605 | 605 | wp_register_script( |
| 606 | 606 | 'jquery-joyride', |
| 607 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
| 607 | + EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', |
|
| 608 | 608 | array('jquery-cookie', 'joyride-modernizr'), |
| 609 | 609 | '2.1', |
| 610 | 610 | true |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | public function get_persistent_admin_notices() |
| 658 | 658 | { |
| 659 | 659 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
| 660 | - $args = array( |
|
| 660 | + $args = array( |
|
| 661 | 661 | 'page' => EE_Registry::instance()->REQ->is_set('page') |
| 662 | 662 | ? EE_Registry::instance()->REQ->get('page') |
| 663 | 663 | : '', |
@@ -704,21 +704,21 @@ discard block |
||
| 704 | 704 | ), |
| 705 | 705 | ) |
| 706 | 706 | ); |
| 707 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 707 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 708 | 708 | array('page' => 'espresso_registrations'), |
| 709 | 709 | admin_url('admin.php') |
| 710 | 710 | ); |
| 711 | - $items['registrations']['text'] = sprintf( |
|
| 711 | + $items['registrations']['text'] = sprintf( |
|
| 712 | 712 | _n('%s Registration', '%s Registrations', $registrations), |
| 713 | 713 | number_format_i18n($registrations) |
| 714 | 714 | ); |
| 715 | 715 | $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
| 716 | 716 | |
| 717 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 717 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 718 | 718 | |
| 719 | 719 | foreach ($items as $type => $item_properties) { |
| 720 | 720 | $elements[] = sprintf( |
| 721 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 721 | + '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', |
|
| 722 | 722 | $item_properties['url'], |
| 723 | 723 | $item_properties['title'], |
| 724 | 724 | $item_properties['text'] |
@@ -744,10 +744,10 @@ discard block |
||
| 744 | 744 | // check for date_format or time_format |
| 745 | 745 | switch ($option) { |
| 746 | 746 | case 'date_format': |
| 747 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 747 | + $date_time_format = $value.' '.get_option('time_format'); |
|
| 748 | 748 | break; |
| 749 | 749 | case 'time_format': |
| 750 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 750 | + $date_time_format = get_option('date_format').' '.$value; |
|
| 751 | 751 | break; |
| 752 | 752 | default: |
| 753 | 753 | $date_time_format = false; |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | |
| 772 | 772 | foreach ($error_msg as $error) { |
| 773 | - $msg .= '<li>' . $error . '</li>'; |
|
| 773 | + $msg .= '<li>'.$error.'</li>'; |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | $msg .= '</ul></p><p>' |
@@ -15,395 +15,395 @@ discard block |
||
| 15 | 15 | final class EE_Admin implements InterminableInterface |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @access private |
|
| 20 | - * @var EE_Admin $_instance |
|
| 21 | - */ |
|
| 22 | - private static $_instance; |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - *@ singleton method used to instantiate class object |
|
| 27 | - *@ access public |
|
| 28 | - *@ return class instance |
|
| 29 | - * |
|
| 30 | - * @throws \EE_Error |
|
| 31 | - */ |
|
| 32 | - public static function instance() |
|
| 33 | - { |
|
| 34 | - // check if class object is instantiated |
|
| 35 | - if (! self::$_instance instanceof EE_Admin) { |
|
| 36 | - self::$_instance = new self(); |
|
| 37 | - } |
|
| 38 | - return self::$_instance; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @return EE_Admin |
|
| 44 | - * @throws EE_Error |
|
| 45 | - */ |
|
| 46 | - public static function reset() |
|
| 47 | - { |
|
| 48 | - self::$_instance = null; |
|
| 49 | - return self::instance(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * class constructor |
|
| 55 | - * |
|
| 56 | - * @throws \EE_Error |
|
| 57 | - */ |
|
| 58 | - protected function __construct() |
|
| 59 | - { |
|
| 60 | - // define global EE_Admin constants |
|
| 61 | - $this->_define_all_constants(); |
|
| 62 | - // set autoloaders for our admin page classes based on included path information |
|
| 63 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
| 64 | - // admin hooks |
|
| 65 | - add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
| 66 | - // load EE_Request_Handler early |
|
| 67 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
| 68 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
| 69 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
| 70 | - add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
| 71 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
| 72 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
| 73 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 74 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 75 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
| 76 | - add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
| 77 | - |
|
| 78 | - //reset Environment config (we only do this on admin page loads); |
|
| 79 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
| 80 | - |
|
| 81 | - do_action('AHEE__EE_Admin__loaded'); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * _define_all_constants |
|
| 87 | - * define constants that are set globally for all admin pages |
|
| 88 | - * |
|
| 89 | - * @access private |
|
| 90 | - * @return void |
|
| 91 | - */ |
|
| 92 | - private function _define_all_constants() |
|
| 93 | - { |
|
| 94 | - if (! defined('EE_ADMIN_URL')) { |
|
| 95 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 96 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 97 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
| 98 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 99 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
| 106 | - * |
|
| 107 | - * @access public |
|
| 108 | - * @param array $links |
|
| 109 | - * @param string $plugin |
|
| 110 | - * @return array |
|
| 111 | - */ |
|
| 112 | - public function filter_plugin_actions($links, $plugin) |
|
| 113 | - { |
|
| 114 | - // set $main_file in stone |
|
| 115 | - static $main_file; |
|
| 116 | - // if $main_file is not set yet |
|
| 117 | - if (! $main_file) { |
|
| 118 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
| 119 | - } |
|
| 120 | - if ($plugin === $main_file) { |
|
| 121 | - // compare current plugin to this one |
|
| 122 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 123 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
| 124 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
| 125 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
| 126 | - . '</a>'; |
|
| 127 | - array_unshift($links, $maintenance_link); |
|
| 128 | - } else { |
|
| 129 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
| 130 | - . esc_html__('Settings', 'event_espresso') |
|
| 131 | - . '</a>'; |
|
| 132 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
| 133 | - . esc_html__('Events', 'event_espresso') |
|
| 134 | - . '</a>'; |
|
| 135 | - // add before other links |
|
| 136 | - array_unshift($links, $org_settings_link, $events_link); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - return $links; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * _get_request |
|
| 145 | - * |
|
| 146 | - * @access public |
|
| 147 | - * @return void |
|
| 148 | - * @throws EE_Error |
|
| 149 | - * @throws ReflectionException |
|
| 150 | - */ |
|
| 151 | - public function get_request() |
|
| 152 | - { |
|
| 153 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
| 154 | - EE_Registry::instance()->load_core('CPT_Strategy'); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * hide_admin_pages_except_maintenance_mode |
|
| 160 | - * |
|
| 161 | - * @access public |
|
| 162 | - * @param array $admin_page_folder_names |
|
| 163 | - * @return array |
|
| 164 | - */ |
|
| 165 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
| 166 | - { |
|
| 167 | - return array( |
|
| 168 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
| 169 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
| 170 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
| 171 | - ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
| 177 | - * EE_Front_Controller's init phases have run |
|
| 178 | - * |
|
| 179 | - * @access public |
|
| 180 | - * @return void |
|
| 181 | - * @throws EE_Error |
|
| 182 | - * @throws ReflectionException |
|
| 183 | - */ |
|
| 184 | - public function init() |
|
| 185 | - { |
|
| 186 | - //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
| 187 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 188 | - //ok so we want to enable the entire admin |
|
| 189 | - add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
| 190 | - add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 191 | - add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 192 | - //at a glance dashboard widget |
|
| 193 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
| 194 | - //filter for get_edit_post_link used on comments for custom post types |
|
| 195 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
| 196 | - } |
|
| 197 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
| 198 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 199 | - try { |
|
| 200 | - //this loads the controller for the admin pages which will setup routing etc |
|
| 201 | - EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
| 202 | - } catch (EE_Error $e) { |
|
| 203 | - $e->get_error(); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
| 207 | - //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
| 208 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
| 209 | - add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
| 210 | - //exclude EE critical pages from all nav menus and wp_list_pages |
|
| 211 | - add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
| 217 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
| 218 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
| 219 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
| 220 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
| 221 | - * |
|
| 222 | - * @param object $post_type WP post type object |
|
| 223 | - * @return object WP post type object |
|
| 224 | - */ |
|
| 225 | - public function remove_pages_from_nav_menu($post_type) |
|
| 226 | - { |
|
| 227 | - //if this isn't the "pages" post type let's get out |
|
| 228 | - if ($post_type->name !== 'page') { |
|
| 229 | - return $post_type; |
|
| 230 | - } |
|
| 231 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 232 | - |
|
| 233 | - $post_type->_default_query = array( |
|
| 234 | - 'post__not_in' => $critical_pages, |
|
| 235 | - ); |
|
| 236 | - return $post_type; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
| 242 | - * metaboxes get shown as well |
|
| 243 | - * |
|
| 244 | - * @access public |
|
| 245 | - * @return void |
|
| 246 | - */ |
|
| 247 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
| 248 | - { |
|
| 249 | - global $wp_meta_boxes, $pagenow; |
|
| 250 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 251 | - return; |
|
| 252 | - } |
|
| 253 | - $user = wp_get_current_user(); |
|
| 254 | - //has this been done yet? |
|
| 255 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
| 256 | - return; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
| 260 | - $initial_meta_boxes = apply_filters( |
|
| 261 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
| 262 | - array( |
|
| 263 | - 'nav-menu-theme-locations', |
|
| 264 | - 'add-page', |
|
| 265 | - 'add-custom-links', |
|
| 266 | - 'add-category', |
|
| 267 | - 'add-espresso_events', |
|
| 268 | - 'add-espresso_venues', |
|
| 269 | - 'add-espresso_event_categories', |
|
| 270 | - 'add-espresso_venue_categories', |
|
| 271 | - 'add-post-type-post', |
|
| 272 | - 'add-post-type-page', |
|
| 273 | - ) |
|
| 274 | - ); |
|
| 275 | - |
|
| 276 | - if (is_array($hidden_meta_boxes)) { |
|
| 277 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
| 278 | - if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
| 279 | - unset($hidden_meta_boxes[$key]); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 285 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
| 291 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
| 292 | - * |
|
| 293 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
| 294 | - * addons etc. |
|
| 295 | - * @access public |
|
| 296 | - * @return void |
|
| 297 | - */ |
|
| 298 | - public function register_custom_nav_menu_boxes() |
|
| 299 | - { |
|
| 300 | - add_meta_box( |
|
| 301 | - 'add-extra-nav-menu-pages', |
|
| 302 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
| 303 | - array($this, 'ee_cpt_archive_pages'), |
|
| 304 | - 'nav-menus', |
|
| 305 | - 'side', |
|
| 306 | - 'core' |
|
| 307 | - ); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
| 313 | - * |
|
| 314 | - * @since 4.3.0 |
|
| 315 | - * @param string $link the original link generated by wp |
|
| 316 | - * @param int $id post id |
|
| 317 | - * @return string the (maybe) modified link |
|
| 318 | - */ |
|
| 319 | - public function modify_edit_post_link($link, $id) |
|
| 320 | - { |
|
| 321 | - if (! $post = get_post($id)) { |
|
| 322 | - return $link; |
|
| 323 | - } |
|
| 324 | - if ($post->post_type === 'espresso_attendees') { |
|
| 325 | - $query_args = array( |
|
| 326 | - 'action' => 'edit_attendee', |
|
| 327 | - 'post' => $id, |
|
| 328 | - ); |
|
| 329 | - return EEH_URL::add_query_args_and_nonce( |
|
| 330 | - $query_args, |
|
| 331 | - admin_url('admin.php?page=espresso_registrations') |
|
| 332 | - ); |
|
| 333 | - } |
|
| 334 | - return $link; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - public function ee_cpt_archive_pages() |
|
| 339 | - { |
|
| 340 | - global $nav_menu_selected_id; |
|
| 341 | - |
|
| 342 | - $db_fields = false; |
|
| 343 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 344 | - $current_tab = 'event-archives'; |
|
| 345 | - |
|
| 346 | - /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
| 18 | + /** |
|
| 19 | + * @access private |
|
| 20 | + * @var EE_Admin $_instance |
|
| 21 | + */ |
|
| 22 | + private static $_instance; |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + *@ singleton method used to instantiate class object |
|
| 27 | + *@ access public |
|
| 28 | + *@ return class instance |
|
| 29 | + * |
|
| 30 | + * @throws \EE_Error |
|
| 31 | + */ |
|
| 32 | + public static function instance() |
|
| 33 | + { |
|
| 34 | + // check if class object is instantiated |
|
| 35 | + if (! self::$_instance instanceof EE_Admin) { |
|
| 36 | + self::$_instance = new self(); |
|
| 37 | + } |
|
| 38 | + return self::$_instance; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @return EE_Admin |
|
| 44 | + * @throws EE_Error |
|
| 45 | + */ |
|
| 46 | + public static function reset() |
|
| 47 | + { |
|
| 48 | + self::$_instance = null; |
|
| 49 | + return self::instance(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * class constructor |
|
| 55 | + * |
|
| 56 | + * @throws \EE_Error |
|
| 57 | + */ |
|
| 58 | + protected function __construct() |
|
| 59 | + { |
|
| 60 | + // define global EE_Admin constants |
|
| 61 | + $this->_define_all_constants(); |
|
| 62 | + // set autoloaders for our admin page classes based on included path information |
|
| 63 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
| 64 | + // admin hooks |
|
| 65 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
| 66 | + // load EE_Request_Handler early |
|
| 67 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
| 68 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
| 69 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
| 70 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
| 71 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
| 72 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
| 73 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 74 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 75 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
| 76 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
| 77 | + |
|
| 78 | + //reset Environment config (we only do this on admin page loads); |
|
| 79 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
| 80 | + |
|
| 81 | + do_action('AHEE__EE_Admin__loaded'); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * _define_all_constants |
|
| 87 | + * define constants that are set globally for all admin pages |
|
| 88 | + * |
|
| 89 | + * @access private |
|
| 90 | + * @return void |
|
| 91 | + */ |
|
| 92 | + private function _define_all_constants() |
|
| 93 | + { |
|
| 94 | + if (! defined('EE_ADMIN_URL')) { |
|
| 95 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 96 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 97 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
| 98 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 99 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
| 106 | + * |
|
| 107 | + * @access public |
|
| 108 | + * @param array $links |
|
| 109 | + * @param string $plugin |
|
| 110 | + * @return array |
|
| 111 | + */ |
|
| 112 | + public function filter_plugin_actions($links, $plugin) |
|
| 113 | + { |
|
| 114 | + // set $main_file in stone |
|
| 115 | + static $main_file; |
|
| 116 | + // if $main_file is not set yet |
|
| 117 | + if (! $main_file) { |
|
| 118 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
| 119 | + } |
|
| 120 | + if ($plugin === $main_file) { |
|
| 121 | + // compare current plugin to this one |
|
| 122 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 123 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
| 124 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
| 125 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
| 126 | + . '</a>'; |
|
| 127 | + array_unshift($links, $maintenance_link); |
|
| 128 | + } else { |
|
| 129 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
| 130 | + . esc_html__('Settings', 'event_espresso') |
|
| 131 | + . '</a>'; |
|
| 132 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
| 133 | + . esc_html__('Events', 'event_espresso') |
|
| 134 | + . '</a>'; |
|
| 135 | + // add before other links |
|
| 136 | + array_unshift($links, $org_settings_link, $events_link); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + return $links; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * _get_request |
|
| 145 | + * |
|
| 146 | + * @access public |
|
| 147 | + * @return void |
|
| 148 | + * @throws EE_Error |
|
| 149 | + * @throws ReflectionException |
|
| 150 | + */ |
|
| 151 | + public function get_request() |
|
| 152 | + { |
|
| 153 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 154 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * hide_admin_pages_except_maintenance_mode |
|
| 160 | + * |
|
| 161 | + * @access public |
|
| 162 | + * @param array $admin_page_folder_names |
|
| 163 | + * @return array |
|
| 164 | + */ |
|
| 165 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
| 166 | + { |
|
| 167 | + return array( |
|
| 168 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
| 169 | + 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
| 170 | + 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
| 171 | + ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
| 177 | + * EE_Front_Controller's init phases have run |
|
| 178 | + * |
|
| 179 | + * @access public |
|
| 180 | + * @return void |
|
| 181 | + * @throws EE_Error |
|
| 182 | + * @throws ReflectionException |
|
| 183 | + */ |
|
| 184 | + public function init() |
|
| 185 | + { |
|
| 186 | + //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
| 187 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 188 | + //ok so we want to enable the entire admin |
|
| 189 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
| 190 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 191 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 192 | + //at a glance dashboard widget |
|
| 193 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
| 194 | + //filter for get_edit_post_link used on comments for custom post types |
|
| 195 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
| 196 | + } |
|
| 197 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
| 198 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 199 | + try { |
|
| 200 | + //this loads the controller for the admin pages which will setup routing etc |
|
| 201 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
| 202 | + } catch (EE_Error $e) { |
|
| 203 | + $e->get_error(); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
| 207 | + //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
| 208 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
| 209 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
| 210 | + //exclude EE critical pages from all nav menus and wp_list_pages |
|
| 211 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
| 217 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
| 218 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
| 219 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
| 220 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
| 221 | + * |
|
| 222 | + * @param object $post_type WP post type object |
|
| 223 | + * @return object WP post type object |
|
| 224 | + */ |
|
| 225 | + public function remove_pages_from_nav_menu($post_type) |
|
| 226 | + { |
|
| 227 | + //if this isn't the "pages" post type let's get out |
|
| 228 | + if ($post_type->name !== 'page') { |
|
| 229 | + return $post_type; |
|
| 230 | + } |
|
| 231 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 232 | + |
|
| 233 | + $post_type->_default_query = array( |
|
| 234 | + 'post__not_in' => $critical_pages, |
|
| 235 | + ); |
|
| 236 | + return $post_type; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
| 242 | + * metaboxes get shown as well |
|
| 243 | + * |
|
| 244 | + * @access public |
|
| 245 | + * @return void |
|
| 246 | + */ |
|
| 247 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
| 248 | + { |
|
| 249 | + global $wp_meta_boxes, $pagenow; |
|
| 250 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 251 | + return; |
|
| 252 | + } |
|
| 253 | + $user = wp_get_current_user(); |
|
| 254 | + //has this been done yet? |
|
| 255 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
| 260 | + $initial_meta_boxes = apply_filters( |
|
| 261 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
| 262 | + array( |
|
| 263 | + 'nav-menu-theme-locations', |
|
| 264 | + 'add-page', |
|
| 265 | + 'add-custom-links', |
|
| 266 | + 'add-category', |
|
| 267 | + 'add-espresso_events', |
|
| 268 | + 'add-espresso_venues', |
|
| 269 | + 'add-espresso_event_categories', |
|
| 270 | + 'add-espresso_venue_categories', |
|
| 271 | + 'add-post-type-post', |
|
| 272 | + 'add-post-type-page', |
|
| 273 | + ) |
|
| 274 | + ); |
|
| 275 | + |
|
| 276 | + if (is_array($hidden_meta_boxes)) { |
|
| 277 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
| 278 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
| 279 | + unset($hidden_meta_boxes[$key]); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 285 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
| 291 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
| 292 | + * |
|
| 293 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
| 294 | + * addons etc. |
|
| 295 | + * @access public |
|
| 296 | + * @return void |
|
| 297 | + */ |
|
| 298 | + public function register_custom_nav_menu_boxes() |
|
| 299 | + { |
|
| 300 | + add_meta_box( |
|
| 301 | + 'add-extra-nav-menu-pages', |
|
| 302 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
| 303 | + array($this, 'ee_cpt_archive_pages'), |
|
| 304 | + 'nav-menus', |
|
| 305 | + 'side', |
|
| 306 | + 'core' |
|
| 307 | + ); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
| 313 | + * |
|
| 314 | + * @since 4.3.0 |
|
| 315 | + * @param string $link the original link generated by wp |
|
| 316 | + * @param int $id post id |
|
| 317 | + * @return string the (maybe) modified link |
|
| 318 | + */ |
|
| 319 | + public function modify_edit_post_link($link, $id) |
|
| 320 | + { |
|
| 321 | + if (! $post = get_post($id)) { |
|
| 322 | + return $link; |
|
| 323 | + } |
|
| 324 | + if ($post->post_type === 'espresso_attendees') { |
|
| 325 | + $query_args = array( |
|
| 326 | + 'action' => 'edit_attendee', |
|
| 327 | + 'post' => $id, |
|
| 328 | + ); |
|
| 329 | + return EEH_URL::add_query_args_and_nonce( |
|
| 330 | + $query_args, |
|
| 331 | + admin_url('admin.php?page=espresso_registrations') |
|
| 332 | + ); |
|
| 333 | + } |
|
| 334 | + return $link; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + public function ee_cpt_archive_pages() |
|
| 339 | + { |
|
| 340 | + global $nav_menu_selected_id; |
|
| 341 | + |
|
| 342 | + $db_fields = false; |
|
| 343 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 344 | + $current_tab = 'event-archives'; |
|
| 345 | + |
|
| 346 | + /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
| 347 | 347 | $current_tab = 'search'; |
| 348 | 348 | }/**/ |
| 349 | 349 | |
| 350 | - $removed_args = array( |
|
| 351 | - 'action', |
|
| 352 | - 'customlink-tab', |
|
| 353 | - 'edit-menu-item', |
|
| 354 | - 'menu-item', |
|
| 355 | - 'page-tab', |
|
| 356 | - '_wpnonce', |
|
| 357 | - ); |
|
| 350 | + $removed_args = array( |
|
| 351 | + 'action', |
|
| 352 | + 'customlink-tab', |
|
| 353 | + 'edit-menu-item', |
|
| 354 | + 'menu-item', |
|
| 355 | + 'page-tab', |
|
| 356 | + '_wpnonce', |
|
| 357 | + ); |
|
| 358 | 358 | |
| 359 | - ?> |
|
| 359 | + ?> |
|
| 360 | 360 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
| 361 | 361 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
| 362 | 362 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
| 363 | 363 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
| 364 | 364 | href="<?php if ($nav_menu_selected_id) { |
| 365 | - echo esc_url( |
|
| 366 | - add_query_arg( |
|
| 367 | - 'extra-nav-menu-pages-tab', |
|
| 368 | - 'event-archives', |
|
| 369 | - remove_query_arg($removed_args) |
|
| 370 | - ) |
|
| 371 | - ); |
|
| 372 | - } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 365 | + echo esc_url( |
|
| 366 | + add_query_arg( |
|
| 367 | + 'extra-nav-menu-pages-tab', |
|
| 368 | + 'event-archives', |
|
| 369 | + remove_query_arg($removed_args) |
|
| 370 | + ) |
|
| 371 | + ); |
|
| 372 | + } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 373 | 373 | <?php _e('Event Archive Pages', 'event_espresso'); ?> |
| 374 | 374 | </a> |
| 375 | 375 | </li> |
| 376 | 376 | |
| 377 | 377 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
| 378 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 379 | - ?>"> |
|
| 378 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 379 | + ?>"> |
|
| 380 | 380 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
| 381 | 381 | <?php |
| 382 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
| 383 | - $args['walker'] = $walker; |
|
| 384 | - echo walk_nav_menu_tree( |
|
| 385 | - array_map( |
|
| 386 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
| 387 | - $pages |
|
| 388 | - ), |
|
| 389 | - 0, |
|
| 390 | - (object) $args |
|
| 391 | - ); |
|
| 392 | - ?> |
|
| 382 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
| 383 | + $args['walker'] = $walker; |
|
| 384 | + echo walk_nav_menu_tree( |
|
| 385 | + array_map( |
|
| 386 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
| 387 | + $pages |
|
| 388 | + ), |
|
| 389 | + 0, |
|
| 390 | + (object) $args |
|
| 391 | + ); |
|
| 392 | + ?> |
|
| 393 | 393 | </ul> |
| 394 | 394 | </div><!-- /.tabs-panel --> |
| 395 | 395 | |
| 396 | 396 | <p class="button-controls"> |
| 397 | 397 | <span class="list-controls"> |
| 398 | 398 | <a href="<?php |
| 399 | - echo esc_url(add_query_arg( |
|
| 400 | - array( |
|
| 401 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
| 402 | - 'selectall' => 1, |
|
| 403 | - ), |
|
| 404 | - remove_query_arg($removed_args) |
|
| 405 | - )); |
|
| 406 | - ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
| 399 | + echo esc_url(add_query_arg( |
|
| 400 | + array( |
|
| 401 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
| 402 | + 'selectall' => 1, |
|
| 403 | + ), |
|
| 404 | + remove_query_arg($removed_args) |
|
| 405 | + )); |
|
| 406 | + ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
| 407 | 407 | </span> |
| 408 | 408 | <span class="add-to-menu"> |
| 409 | 409 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -416,485 +416,485 @@ discard block |
||
| 416 | 416 | |
| 417 | 417 | </div><!-- /.posttypediv --> |
| 418 | 418 | <?php |
| 419 | - } |
|
| 420 | - |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * Returns an array of event archive nav items. |
|
| 424 | - * |
|
| 425 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
| 426 | - * method we use for getting the extra nav menu items |
|
| 427 | - * @return array |
|
| 428 | - */ |
|
| 429 | - private function _get_extra_nav_menu_pages_items() |
|
| 430 | - { |
|
| 431 | - $menuitems[] = array( |
|
| 432 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
| 433 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
| 434 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
| 435 | - ); |
|
| 436 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
| 442 | - * the properties and converts it to the menu item object. |
|
| 443 | - * |
|
| 444 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
| 445 | - * @param $menu_item_values |
|
| 446 | - * @return stdClass |
|
| 447 | - */ |
|
| 448 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
| 449 | - { |
|
| 450 | - $menu_item = new stdClass(); |
|
| 451 | - $keys = array( |
|
| 452 | - 'ID' => 0, |
|
| 453 | - 'db_id' => 0, |
|
| 454 | - 'menu_item_parent' => 0, |
|
| 455 | - 'object_id' => -1, |
|
| 456 | - 'post_parent' => 0, |
|
| 457 | - 'type' => 'custom', |
|
| 458 | - 'object' => '', |
|
| 459 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
| 460 | - 'title' => '', |
|
| 461 | - 'url' => '', |
|
| 462 | - 'target' => '', |
|
| 463 | - 'attr_title' => '', |
|
| 464 | - 'description' => '', |
|
| 465 | - 'classes' => array(), |
|
| 466 | - 'xfn' => '', |
|
| 467 | - ); |
|
| 468 | - |
|
| 469 | - foreach ($keys as $key => $value) { |
|
| 470 | - $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
| 471 | - } |
|
| 472 | - return $menu_item; |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
| 478 | - * EE_Admin_Page route is called. |
|
| 479 | - * |
|
| 480 | - * @return void |
|
| 481 | - */ |
|
| 482 | - public function route_admin_request() |
|
| 483 | - { |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
| 489 | - * |
|
| 490 | - * @return void |
|
| 491 | - */ |
|
| 492 | - public function wp_loaded() |
|
| 493 | - { |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * admin_init |
|
| 499 | - * |
|
| 500 | - * @access public |
|
| 501 | - * @return void |
|
| 502 | - * @throws EE_Error |
|
| 503 | - * @throws ReflectionException |
|
| 504 | - */ |
|
| 505 | - public function admin_init() |
|
| 506 | - { |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
| 510 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
| 511 | - * - check if doing post processing. |
|
| 512 | - * - check if doing post processing of one of EE CPTs |
|
| 513 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
| 514 | - */ |
|
| 515 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
| 516 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
| 517 | - EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - |
|
| 521 | - /** |
|
| 522 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
| 523 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
| 524 | - * Pages" tab in the EE General Settings Admin page. |
|
| 525 | - * This is for user-proofing. |
|
| 526 | - */ |
|
| 527 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
| 533 | - * |
|
| 534 | - * @param string $output Current output. |
|
| 535 | - * @return string |
|
| 536 | - */ |
|
| 537 | - public function modify_dropdown_pages($output) |
|
| 538 | - { |
|
| 539 | - //get critical pages |
|
| 540 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 541 | - |
|
| 542 | - //split current output by line break for easier parsing. |
|
| 543 | - $split_output = explode("\n", $output); |
|
| 544 | - |
|
| 545 | - //loop through to remove any critical pages from the array. |
|
| 546 | - foreach ($critical_pages as $page_id) { |
|
| 547 | - $needle = 'value="' . $page_id . '"'; |
|
| 548 | - foreach ($split_output as $key => $haystack) { |
|
| 549 | - if (strpos($haystack, $needle) !== false) { |
|
| 550 | - unset($split_output[$key]); |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - //replace output with the new contents |
|
| 556 | - return implode("\n", $split_output); |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - |
|
| 560 | - /** |
|
| 561 | - * enqueue all admin scripts that need loaded for admin pages |
|
| 562 | - * |
|
| 563 | - * @access public |
|
| 564 | - * @return void |
|
| 565 | - */ |
|
| 566 | - public function enqueue_admin_scripts() |
|
| 567 | - { |
|
| 568 | - // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
| 569 | - // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
| 570 | - // calls. |
|
| 571 | - wp_enqueue_script( |
|
| 572 | - 'ee-inject-wp', |
|
| 573 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
| 574 | - array('jquery'), |
|
| 575 | - EVENT_ESPRESSO_VERSION, |
|
| 576 | - true |
|
| 577 | - ); |
|
| 578 | - // register cookie script for future dependencies |
|
| 579 | - wp_register_script( |
|
| 580 | - 'jquery-cookie', |
|
| 581 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
| 582 | - array('jquery'), |
|
| 583 | - '2.1', |
|
| 584 | - true |
|
| 585 | - ); |
|
| 586 | - //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
| 587 | - // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
| 588 | - if (apply_filters('FHEE_load_joyride', false)) { |
|
| 589 | - //joyride style |
|
| 590 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 591 | - wp_register_style( |
|
| 592 | - 'ee-joyride-css', |
|
| 593 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
| 594 | - array('joyride-css'), |
|
| 595 | - EVENT_ESPRESSO_VERSION |
|
| 596 | - ); |
|
| 597 | - wp_register_script( |
|
| 598 | - 'joyride-modernizr', |
|
| 599 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
| 600 | - array(), |
|
| 601 | - '2.1', |
|
| 602 | - true |
|
| 603 | - ); |
|
| 604 | - //joyride JS |
|
| 605 | - wp_register_script( |
|
| 606 | - 'jquery-joyride', |
|
| 607 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
| 608 | - array('jquery-cookie', 'joyride-modernizr'), |
|
| 609 | - '2.1', |
|
| 610 | - true |
|
| 611 | - ); |
|
| 612 | - // wanna go for a joyride? |
|
| 613 | - wp_enqueue_style('ee-joyride-css'); |
|
| 614 | - wp_enqueue_script('jquery-joyride'); |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * display_admin_notices |
|
| 621 | - * |
|
| 622 | - * @access public |
|
| 623 | - * @return string |
|
| 624 | - */ |
|
| 625 | - public function display_admin_notices() |
|
| 626 | - { |
|
| 627 | - //add non-dismissable notice for datetime changes. Only valid if EE version is greater than 4.9.46.p and the |
|
| 628 | - // site does not have a timezone_string set. |
|
| 629 | - if (EE_Register_Addon::_meets_min_core_version_requirement( |
|
| 630 | - '4.9.46.p' |
|
| 631 | - ) |
|
| 632 | - && ! get_option('timezone_string') |
|
| 633 | - ) { |
|
| 634 | - EE_Error::add_attention( |
|
| 635 | - sprintf( |
|
| 636 | - esc_html__( |
|
| 637 | - '%1$sImportant%2$s: Please note some upcoming changes to dates and times in Event Espresso that may affect your website. Read more about it %3$shere%4$s.', |
|
| 638 | - 'event_espresso' |
|
| 639 | - ), |
|
| 640 | - '<strong>', |
|
| 641 | - '</strong>', |
|
| 642 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
| 643 | - '</a>' |
|
| 644 | - ) |
|
| 645 | - ); |
|
| 646 | - } |
|
| 647 | - echo EE_Error::get_notices(); |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * get_persistent_admin_notices |
|
| 653 | - * |
|
| 654 | - * @access public |
|
| 655 | - * @return void |
|
| 656 | - */ |
|
| 657 | - public function get_persistent_admin_notices() |
|
| 658 | - { |
|
| 659 | - // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
|
| 660 | - $args = array( |
|
| 661 | - 'page' => EE_Registry::instance()->REQ->is_set('page') |
|
| 662 | - ? EE_Registry::instance()->REQ->get('page') |
|
| 663 | - : '', |
|
| 664 | - 'action' => EE_Registry::instance()->REQ->is_set('action') |
|
| 665 | - ? EE_Registry::instance()->REQ->get('action') |
|
| 666 | - : '', |
|
| 667 | - ); |
|
| 668 | - $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
| 669 | - echo EE_Error::get_persistent_admin_notices($return_url); |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * dismiss_persistent_admin_notice |
|
| 675 | - * |
|
| 676 | - * @access public |
|
| 677 | - * @return void |
|
| 678 | - */ |
|
| 679 | - public function dismiss_ee_nag_notice_callback() |
|
| 680 | - { |
|
| 681 | - EE_Error::dismiss_persistent_admin_notice(); |
|
| 682 | - } |
|
| 683 | - |
|
| 684 | - |
|
| 685 | - /** |
|
| 686 | - * @param array $elements |
|
| 687 | - * @return array |
|
| 688 | - * @throws \EE_Error |
|
| 689 | - */ |
|
| 690 | - public function dashboard_glance_items($elements) |
|
| 691 | - { |
|
| 692 | - $elements = is_array($elements) ? $elements : array($elements); |
|
| 693 | - $events = EEM_Event::instance()->count(); |
|
| 694 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 695 | - array('page' => 'espresso_events'), |
|
| 696 | - admin_url('admin.php') |
|
| 697 | - ); |
|
| 698 | - $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
| 699 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
| 700 | - $registrations = EEM_Registration::instance()->count( |
|
| 701 | - array( |
|
| 702 | - array( |
|
| 703 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
| 704 | - ), |
|
| 705 | - ) |
|
| 706 | - ); |
|
| 707 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 708 | - array('page' => 'espresso_registrations'), |
|
| 709 | - admin_url('admin.php') |
|
| 710 | - ); |
|
| 711 | - $items['registrations']['text'] = sprintf( |
|
| 712 | - _n('%s Registration', '%s Registrations', $registrations), |
|
| 713 | - number_format_i18n($registrations) |
|
| 714 | - ); |
|
| 715 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
| 716 | - |
|
| 717 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 718 | - |
|
| 719 | - foreach ($items as $type => $item_properties) { |
|
| 720 | - $elements[] = sprintf( |
|
| 721 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 722 | - $item_properties['url'], |
|
| 723 | - $item_properties['title'], |
|
| 724 | - $item_properties['text'] |
|
| 725 | - ); |
|
| 726 | - } |
|
| 727 | - return $elements; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - |
|
| 731 | - /** |
|
| 732 | - * check_for_invalid_datetime_formats |
|
| 733 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
| 734 | - * their selected format can be parsed by PHP |
|
| 735 | - * |
|
| 736 | - * @access public |
|
| 737 | - * @param $value |
|
| 738 | - * @param $option |
|
| 739 | - * @throws EE_Error |
|
| 740 | - * @return string |
|
| 741 | - */ |
|
| 742 | - public function check_for_invalid_datetime_formats($value, $option) |
|
| 743 | - { |
|
| 744 | - // check for date_format or time_format |
|
| 745 | - switch ($option) { |
|
| 746 | - case 'date_format': |
|
| 747 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 748 | - break; |
|
| 749 | - case 'time_format': |
|
| 750 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 751 | - break; |
|
| 752 | - default: |
|
| 753 | - $date_time_format = false; |
|
| 754 | - } |
|
| 755 | - // do we have a date_time format to check ? |
|
| 756 | - if ($date_time_format) { |
|
| 757 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
| 758 | - |
|
| 759 | - if (is_array($error_msg)) { |
|
| 760 | - $msg = '<p>' |
|
| 761 | - . sprintf( |
|
| 762 | - esc_html__( |
|
| 763 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
| 764 | - 'event_espresso' |
|
| 765 | - ), |
|
| 766 | - date($date_time_format), |
|
| 767 | - $date_time_format |
|
| 768 | - ) |
|
| 769 | - . '</p><p><ul>'; |
|
| 770 | - |
|
| 771 | - |
|
| 772 | - foreach ($error_msg as $error) { |
|
| 773 | - $msg .= '<li>' . $error . '</li>'; |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - $msg .= '</ul></p><p>' |
|
| 777 | - . sprintf( |
|
| 778 | - esc_html__( |
|
| 779 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
| 780 | - 'event_espresso' |
|
| 781 | - ), |
|
| 782 | - '<span style="color:#D54E21;">', |
|
| 783 | - '</span>' |
|
| 784 | - ) |
|
| 785 | - . '</p>'; |
|
| 786 | - |
|
| 787 | - // trigger WP settings error |
|
| 788 | - add_settings_error( |
|
| 789 | - 'date_format', |
|
| 790 | - 'date_format', |
|
| 791 | - $msg |
|
| 792 | - ); |
|
| 793 | - |
|
| 794 | - // set format to something valid |
|
| 795 | - switch ($option) { |
|
| 796 | - case 'date_format': |
|
| 797 | - $value = 'F j, Y'; |
|
| 798 | - break; |
|
| 799 | - case 'time_format': |
|
| 800 | - $value = 'g:i a'; |
|
| 801 | - break; |
|
| 802 | - } |
|
| 803 | - } |
|
| 804 | - } |
|
| 805 | - return $value; |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - |
|
| 809 | - /** |
|
| 810 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
| 811 | - * |
|
| 812 | - * @access public |
|
| 813 | - * @param $content |
|
| 814 | - * @return string |
|
| 815 | - */ |
|
| 816 | - public function its_eSpresso($content) |
|
| 817 | - { |
|
| 818 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
| 819 | - } |
|
| 820 | - |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * espresso_admin_footer |
|
| 824 | - * |
|
| 825 | - * @access public |
|
| 826 | - * @return string |
|
| 827 | - */ |
|
| 828 | - public function espresso_admin_footer() |
|
| 829 | - { |
|
| 830 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - |
|
| 834 | - /** |
|
| 835 | - * static method for registering ee admin page. |
|
| 836 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
| 837 | - * |
|
| 838 | - * @since 4.3.0 |
|
| 839 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
| 840 | - * @see EE_Register_Admin_Page::register() |
|
| 841 | - * @param $page_basename |
|
| 842 | - * @param $page_path |
|
| 843 | - * @param array $config |
|
| 844 | - * @return void |
|
| 845 | - * @throws EE_Error |
|
| 846 | - */ |
|
| 847 | - public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
| 848 | - { |
|
| 849 | - EE_Error::doing_it_wrong( |
|
| 850 | - __METHOD__, |
|
| 851 | - sprintf( |
|
| 852 | - esc_html__( |
|
| 853 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
| 854 | - 'event_espresso' |
|
| 855 | - ), |
|
| 856 | - $page_basename |
|
| 857 | - ), |
|
| 858 | - '4.3' |
|
| 859 | - ); |
|
| 860 | - if (class_exists('EE_Register_Admin_Page')) { |
|
| 861 | - $config['page_path'] = $page_path; |
|
| 862 | - } |
|
| 863 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - |
|
| 867 | - /** |
|
| 868 | - * @deprecated 4.8.41 |
|
| 869 | - * @access public |
|
| 870 | - * @param int $post_ID |
|
| 871 | - * @param \WP_Post $post |
|
| 872 | - * @return void |
|
| 873 | - */ |
|
| 874 | - public static function parse_post_content_on_save($post_ID, $post) |
|
| 875 | - { |
|
| 876 | - EE_Error::doing_it_wrong( |
|
| 877 | - __METHOD__, |
|
| 878 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 879 | - '4.8.41' |
|
| 880 | - ); |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * @deprecated 4.8.41 |
|
| 886 | - * @access public |
|
| 887 | - * @param $option |
|
| 888 | - * @param $old_value |
|
| 889 | - * @param $value |
|
| 890 | - * @return void |
|
| 891 | - */ |
|
| 892 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
| 893 | - { |
|
| 894 | - EE_Error::doing_it_wrong( |
|
| 895 | - __METHOD__, |
|
| 896 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 897 | - '4.8.41' |
|
| 898 | - ); |
|
| 899 | - } |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * Returns an array of event archive nav items. |
|
| 424 | + * |
|
| 425 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
| 426 | + * method we use for getting the extra nav menu items |
|
| 427 | + * @return array |
|
| 428 | + */ |
|
| 429 | + private function _get_extra_nav_menu_pages_items() |
|
| 430 | + { |
|
| 431 | + $menuitems[] = array( |
|
| 432 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
| 433 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
| 434 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
| 435 | + ); |
|
| 436 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
| 442 | + * the properties and converts it to the menu item object. |
|
| 443 | + * |
|
| 444 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
| 445 | + * @param $menu_item_values |
|
| 446 | + * @return stdClass |
|
| 447 | + */ |
|
| 448 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
| 449 | + { |
|
| 450 | + $menu_item = new stdClass(); |
|
| 451 | + $keys = array( |
|
| 452 | + 'ID' => 0, |
|
| 453 | + 'db_id' => 0, |
|
| 454 | + 'menu_item_parent' => 0, |
|
| 455 | + 'object_id' => -1, |
|
| 456 | + 'post_parent' => 0, |
|
| 457 | + 'type' => 'custom', |
|
| 458 | + 'object' => '', |
|
| 459 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
| 460 | + 'title' => '', |
|
| 461 | + 'url' => '', |
|
| 462 | + 'target' => '', |
|
| 463 | + 'attr_title' => '', |
|
| 464 | + 'description' => '', |
|
| 465 | + 'classes' => array(), |
|
| 466 | + 'xfn' => '', |
|
| 467 | + ); |
|
| 468 | + |
|
| 469 | + foreach ($keys as $key => $value) { |
|
| 470 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
| 471 | + } |
|
| 472 | + return $menu_item; |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
| 478 | + * EE_Admin_Page route is called. |
|
| 479 | + * |
|
| 480 | + * @return void |
|
| 481 | + */ |
|
| 482 | + public function route_admin_request() |
|
| 483 | + { |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
| 489 | + * |
|
| 490 | + * @return void |
|
| 491 | + */ |
|
| 492 | + public function wp_loaded() |
|
| 493 | + { |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * admin_init |
|
| 499 | + * |
|
| 500 | + * @access public |
|
| 501 | + * @return void |
|
| 502 | + * @throws EE_Error |
|
| 503 | + * @throws ReflectionException |
|
| 504 | + */ |
|
| 505 | + public function admin_init() |
|
| 506 | + { |
|
| 507 | + |
|
| 508 | + /** |
|
| 509 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
| 510 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
| 511 | + * - check if doing post processing. |
|
| 512 | + * - check if doing post processing of one of EE CPTs |
|
| 513 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
| 514 | + */ |
|
| 515 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
| 516 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
| 517 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + |
|
| 521 | + /** |
|
| 522 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
| 523 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
| 524 | + * Pages" tab in the EE General Settings Admin page. |
|
| 525 | + * This is for user-proofing. |
|
| 526 | + */ |
|
| 527 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
| 533 | + * |
|
| 534 | + * @param string $output Current output. |
|
| 535 | + * @return string |
|
| 536 | + */ |
|
| 537 | + public function modify_dropdown_pages($output) |
|
| 538 | + { |
|
| 539 | + //get critical pages |
|
| 540 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 541 | + |
|
| 542 | + //split current output by line break for easier parsing. |
|
| 543 | + $split_output = explode("\n", $output); |
|
| 544 | + |
|
| 545 | + //loop through to remove any critical pages from the array. |
|
| 546 | + foreach ($critical_pages as $page_id) { |
|
| 547 | + $needle = 'value="' . $page_id . '"'; |
|
| 548 | + foreach ($split_output as $key => $haystack) { |
|
| 549 | + if (strpos($haystack, $needle) !== false) { |
|
| 550 | + unset($split_output[$key]); |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + //replace output with the new contents |
|
| 556 | + return implode("\n", $split_output); |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + |
|
| 560 | + /** |
|
| 561 | + * enqueue all admin scripts that need loaded for admin pages |
|
| 562 | + * |
|
| 563 | + * @access public |
|
| 564 | + * @return void |
|
| 565 | + */ |
|
| 566 | + public function enqueue_admin_scripts() |
|
| 567 | + { |
|
| 568 | + // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
| 569 | + // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
| 570 | + // calls. |
|
| 571 | + wp_enqueue_script( |
|
| 572 | + 'ee-inject-wp', |
|
| 573 | + EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
| 574 | + array('jquery'), |
|
| 575 | + EVENT_ESPRESSO_VERSION, |
|
| 576 | + true |
|
| 577 | + ); |
|
| 578 | + // register cookie script for future dependencies |
|
| 579 | + wp_register_script( |
|
| 580 | + 'jquery-cookie', |
|
| 581 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
| 582 | + array('jquery'), |
|
| 583 | + '2.1', |
|
| 584 | + true |
|
| 585 | + ); |
|
| 586 | + //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
| 587 | + // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
| 588 | + if (apply_filters('FHEE_load_joyride', false)) { |
|
| 589 | + //joyride style |
|
| 590 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 591 | + wp_register_style( |
|
| 592 | + 'ee-joyride-css', |
|
| 593 | + EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
| 594 | + array('joyride-css'), |
|
| 595 | + EVENT_ESPRESSO_VERSION |
|
| 596 | + ); |
|
| 597 | + wp_register_script( |
|
| 598 | + 'joyride-modernizr', |
|
| 599 | + EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
| 600 | + array(), |
|
| 601 | + '2.1', |
|
| 602 | + true |
|
| 603 | + ); |
|
| 604 | + //joyride JS |
|
| 605 | + wp_register_script( |
|
| 606 | + 'jquery-joyride', |
|
| 607 | + EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
| 608 | + array('jquery-cookie', 'joyride-modernizr'), |
|
| 609 | + '2.1', |
|
| 610 | + true |
|
| 611 | + ); |
|
| 612 | + // wanna go for a joyride? |
|
| 613 | + wp_enqueue_style('ee-joyride-css'); |
|
| 614 | + wp_enqueue_script('jquery-joyride'); |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * display_admin_notices |
|
| 621 | + * |
|
| 622 | + * @access public |
|
| 623 | + * @return string |
|
| 624 | + */ |
|
| 625 | + public function display_admin_notices() |
|
| 626 | + { |
|
| 627 | + //add non-dismissable notice for datetime changes. Only valid if EE version is greater than 4.9.46.p and the |
|
| 628 | + // site does not have a timezone_string set. |
|
| 629 | + if (EE_Register_Addon::_meets_min_core_version_requirement( |
|
| 630 | + '4.9.46.p' |
|
| 631 | + ) |
|
| 632 | + && ! get_option('timezone_string') |
|
| 633 | + ) { |
|
| 634 | + EE_Error::add_attention( |
|
| 635 | + sprintf( |
|
| 636 | + esc_html__( |
|
| 637 | + '%1$sImportant%2$s: Please note some upcoming changes to dates and times in Event Espresso that may affect your website. Read more about it %3$shere%4$s.', |
|
| 638 | + 'event_espresso' |
|
| 639 | + ), |
|
| 640 | + '<strong>', |
|
| 641 | + '</strong>', |
|
| 642 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
| 643 | + '</a>' |
|
| 644 | + ) |
|
| 645 | + ); |
|
| 646 | + } |
|
| 647 | + echo EE_Error::get_notices(); |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * get_persistent_admin_notices |
|
| 653 | + * |
|
| 654 | + * @access public |
|
| 655 | + * @return void |
|
| 656 | + */ |
|
| 657 | + public function get_persistent_admin_notices() |
|
| 658 | + { |
|
| 659 | + // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
|
| 660 | + $args = array( |
|
| 661 | + 'page' => EE_Registry::instance()->REQ->is_set('page') |
|
| 662 | + ? EE_Registry::instance()->REQ->get('page') |
|
| 663 | + : '', |
|
| 664 | + 'action' => EE_Registry::instance()->REQ->is_set('action') |
|
| 665 | + ? EE_Registry::instance()->REQ->get('action') |
|
| 666 | + : '', |
|
| 667 | + ); |
|
| 668 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
| 669 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * dismiss_persistent_admin_notice |
|
| 675 | + * |
|
| 676 | + * @access public |
|
| 677 | + * @return void |
|
| 678 | + */ |
|
| 679 | + public function dismiss_ee_nag_notice_callback() |
|
| 680 | + { |
|
| 681 | + EE_Error::dismiss_persistent_admin_notice(); |
|
| 682 | + } |
|
| 683 | + |
|
| 684 | + |
|
| 685 | + /** |
|
| 686 | + * @param array $elements |
|
| 687 | + * @return array |
|
| 688 | + * @throws \EE_Error |
|
| 689 | + */ |
|
| 690 | + public function dashboard_glance_items($elements) |
|
| 691 | + { |
|
| 692 | + $elements = is_array($elements) ? $elements : array($elements); |
|
| 693 | + $events = EEM_Event::instance()->count(); |
|
| 694 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 695 | + array('page' => 'espresso_events'), |
|
| 696 | + admin_url('admin.php') |
|
| 697 | + ); |
|
| 698 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
| 699 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
| 700 | + $registrations = EEM_Registration::instance()->count( |
|
| 701 | + array( |
|
| 702 | + array( |
|
| 703 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
| 704 | + ), |
|
| 705 | + ) |
|
| 706 | + ); |
|
| 707 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 708 | + array('page' => 'espresso_registrations'), |
|
| 709 | + admin_url('admin.php') |
|
| 710 | + ); |
|
| 711 | + $items['registrations']['text'] = sprintf( |
|
| 712 | + _n('%s Registration', '%s Registrations', $registrations), |
|
| 713 | + number_format_i18n($registrations) |
|
| 714 | + ); |
|
| 715 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
| 716 | + |
|
| 717 | + $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 718 | + |
|
| 719 | + foreach ($items as $type => $item_properties) { |
|
| 720 | + $elements[] = sprintf( |
|
| 721 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 722 | + $item_properties['url'], |
|
| 723 | + $item_properties['title'], |
|
| 724 | + $item_properties['text'] |
|
| 725 | + ); |
|
| 726 | + } |
|
| 727 | + return $elements; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + |
|
| 731 | + /** |
|
| 732 | + * check_for_invalid_datetime_formats |
|
| 733 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
| 734 | + * their selected format can be parsed by PHP |
|
| 735 | + * |
|
| 736 | + * @access public |
|
| 737 | + * @param $value |
|
| 738 | + * @param $option |
|
| 739 | + * @throws EE_Error |
|
| 740 | + * @return string |
|
| 741 | + */ |
|
| 742 | + public function check_for_invalid_datetime_formats($value, $option) |
|
| 743 | + { |
|
| 744 | + // check for date_format or time_format |
|
| 745 | + switch ($option) { |
|
| 746 | + case 'date_format': |
|
| 747 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 748 | + break; |
|
| 749 | + case 'time_format': |
|
| 750 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 751 | + break; |
|
| 752 | + default: |
|
| 753 | + $date_time_format = false; |
|
| 754 | + } |
|
| 755 | + // do we have a date_time format to check ? |
|
| 756 | + if ($date_time_format) { |
|
| 757 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
| 758 | + |
|
| 759 | + if (is_array($error_msg)) { |
|
| 760 | + $msg = '<p>' |
|
| 761 | + . sprintf( |
|
| 762 | + esc_html__( |
|
| 763 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
| 764 | + 'event_espresso' |
|
| 765 | + ), |
|
| 766 | + date($date_time_format), |
|
| 767 | + $date_time_format |
|
| 768 | + ) |
|
| 769 | + . '</p><p><ul>'; |
|
| 770 | + |
|
| 771 | + |
|
| 772 | + foreach ($error_msg as $error) { |
|
| 773 | + $msg .= '<li>' . $error . '</li>'; |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + $msg .= '</ul></p><p>' |
|
| 777 | + . sprintf( |
|
| 778 | + esc_html__( |
|
| 779 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
| 780 | + 'event_espresso' |
|
| 781 | + ), |
|
| 782 | + '<span style="color:#D54E21;">', |
|
| 783 | + '</span>' |
|
| 784 | + ) |
|
| 785 | + . '</p>'; |
|
| 786 | + |
|
| 787 | + // trigger WP settings error |
|
| 788 | + add_settings_error( |
|
| 789 | + 'date_format', |
|
| 790 | + 'date_format', |
|
| 791 | + $msg |
|
| 792 | + ); |
|
| 793 | + |
|
| 794 | + // set format to something valid |
|
| 795 | + switch ($option) { |
|
| 796 | + case 'date_format': |
|
| 797 | + $value = 'F j, Y'; |
|
| 798 | + break; |
|
| 799 | + case 'time_format': |
|
| 800 | + $value = 'g:i a'; |
|
| 801 | + break; |
|
| 802 | + } |
|
| 803 | + } |
|
| 804 | + } |
|
| 805 | + return $value; |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
| 811 | + * |
|
| 812 | + * @access public |
|
| 813 | + * @param $content |
|
| 814 | + * @return string |
|
| 815 | + */ |
|
| 816 | + public function its_eSpresso($content) |
|
| 817 | + { |
|
| 818 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
| 819 | + } |
|
| 820 | + |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * espresso_admin_footer |
|
| 824 | + * |
|
| 825 | + * @access public |
|
| 826 | + * @return string |
|
| 827 | + */ |
|
| 828 | + public function espresso_admin_footer() |
|
| 829 | + { |
|
| 830 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + |
|
| 834 | + /** |
|
| 835 | + * static method for registering ee admin page. |
|
| 836 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
| 837 | + * |
|
| 838 | + * @since 4.3.0 |
|
| 839 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
| 840 | + * @see EE_Register_Admin_Page::register() |
|
| 841 | + * @param $page_basename |
|
| 842 | + * @param $page_path |
|
| 843 | + * @param array $config |
|
| 844 | + * @return void |
|
| 845 | + * @throws EE_Error |
|
| 846 | + */ |
|
| 847 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
| 848 | + { |
|
| 849 | + EE_Error::doing_it_wrong( |
|
| 850 | + __METHOD__, |
|
| 851 | + sprintf( |
|
| 852 | + esc_html__( |
|
| 853 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
| 854 | + 'event_espresso' |
|
| 855 | + ), |
|
| 856 | + $page_basename |
|
| 857 | + ), |
|
| 858 | + '4.3' |
|
| 859 | + ); |
|
| 860 | + if (class_exists('EE_Register_Admin_Page')) { |
|
| 861 | + $config['page_path'] = $page_path; |
|
| 862 | + } |
|
| 863 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + |
|
| 867 | + /** |
|
| 868 | + * @deprecated 4.8.41 |
|
| 869 | + * @access public |
|
| 870 | + * @param int $post_ID |
|
| 871 | + * @param \WP_Post $post |
|
| 872 | + * @return void |
|
| 873 | + */ |
|
| 874 | + public static function parse_post_content_on_save($post_ID, $post) |
|
| 875 | + { |
|
| 876 | + EE_Error::doing_it_wrong( |
|
| 877 | + __METHOD__, |
|
| 878 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 879 | + '4.8.41' |
|
| 880 | + ); |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * @deprecated 4.8.41 |
|
| 886 | + * @access public |
|
| 887 | + * @param $option |
|
| 888 | + * @param $old_value |
|
| 889 | + * @param $value |
|
| 890 | + * @return void |
|
| 891 | + */ |
|
| 892 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
| 893 | + { |
|
| 894 | + EE_Error::doing_it_wrong( |
|
| 895 | + __METHOD__, |
|
| 896 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 897 | + '4.8.41' |
|
| 898 | + ); |
|
| 899 | + } |
|
| 900 | 900 | } |
@@ -9,20 +9,20 @@ |
||
| 9 | 9 | interface LoaderDecoratorInterface |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @param string $fqcn |
|
| 14 | - * @param array $arguments |
|
| 15 | - * @param bool $shared |
|
| 16 | - * @return mixed |
|
| 17 | - */ |
|
| 18 | - public function load($fqcn, $arguments = array(), $shared = true); |
|
| 12 | + /** |
|
| 13 | + * @param string $fqcn |
|
| 14 | + * @param array $arguments |
|
| 15 | + * @param bool $shared |
|
| 16 | + * @return mixed |
|
| 17 | + */ |
|
| 18 | + public function load($fqcn, $arguments = array(), $shared = true); |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * calls reset() on loader if method exists |
|
| 24 | - */ |
|
| 25 | - public function reset(); |
|
| 22 | + /** |
|
| 23 | + * calls reset() on loader if method exists |
|
| 24 | + */ |
|
| 25 | + public function reset(); |
|
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | // End of file LoaderInterface.php |