@@ -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 | * Class Datetime Model |
@@ -11,595 +11,595 @@ discard block |
||
| 11 | 11 | class EEM_Datetime extends EEM_Soft_Delete_Base |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var EEM_Datetime $_instance |
|
| 16 | - */ |
|
| 17 | - protected static $_instance; |
|
| 18 | - |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * private constructor to prevent direct creation |
|
| 23 | - * |
|
| 24 | - * @Constructor |
|
| 25 | - * @access private |
|
| 26 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 27 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 28 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 29 | - * timezone in the 'timezone_string' wp option) |
|
| 30 | - * @throws \EE_Error |
|
| 31 | - */ |
|
| 32 | - protected function __construct($timezone) |
|
| 33 | - { |
|
| 34 | - $this->singular_item = __('Datetime', 'event_espresso'); |
|
| 35 | - $this->plural_item = __('Datetimes', 'event_espresso'); |
|
| 36 | - $this->_tables = array( |
|
| 37 | - 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
| 38 | - ); |
|
| 39 | - $this->_fields = array( |
|
| 40 | - 'Datetime' => array( |
|
| 41 | - 'DTT_ID' => new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
| 42 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
| 43 | - 'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event' |
|
| 44 | - ), |
|
| 45 | - 'DTT_name' => new EE_Plain_Text_Field( |
|
| 46 | - 'DTT_name', __('Datetime Name', 'event_espresso'), false, '' |
|
| 47 | - ), |
|
| 48 | - 'DTT_description' => new EE_Post_Content_Field( |
|
| 49 | - 'DTT_description', __('Description for Datetime', 'event_espresso'), false, '' |
|
| 50 | - ), |
|
| 51 | - 'DTT_EVT_start' => new EE_Datetime_Field( |
|
| 52 | - 'DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 53 | - $timezone |
|
| 54 | - ), |
|
| 55 | - 'DTT_EVT_end' => new EE_Datetime_Field( |
|
| 56 | - 'DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 57 | - $timezone |
|
| 58 | - ), |
|
| 59 | - 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
| 60 | - 'DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
| 61 | - 'DTT_sold' => new EE_Integer_Field( |
|
| 62 | - 'DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 |
|
| 63 | - ), |
|
| 64 | - 'DTT_reserved' => new EE_Integer_Field('DTT_reserved', |
|
| 65 | - __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), false, 0 |
|
| 66 | - ), |
|
| 67 | - 'DTT_is_primary' => new EE_Boolean_Field( |
|
| 68 | - 'DTT_is_primary', __('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 69 | - false, false |
|
| 70 | - ), |
|
| 71 | - 'DTT_order' => new EE_Integer_Field( |
|
| 72 | - 'DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0 |
|
| 73 | - ), |
|
| 74 | - 'DTT_parent' => new EE_Integer_Field( |
|
| 75 | - 'DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 |
|
| 76 | - ), |
|
| 77 | - 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
| 78 | - 'DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false |
|
| 79 | - ), |
|
| 80 | - ), |
|
| 81 | - ); |
|
| 82 | - $this->_model_relations = array( |
|
| 83 | - 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
| 84 | - 'Event' => new EE_Belongs_To_Relation(), |
|
| 85 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
| 86 | - ); |
|
| 87 | - $this->_model_chain_to_wp_user = 'Event'; |
|
| 88 | - //this model is generally available for reading |
|
| 89 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
| 90 | - $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
| 91 | - $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
| 92 | - $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', |
|
| 93 | - EEM_Base::caps_edit); |
|
| 94 | - parent::__construct($timezone); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * create new blank datetime |
|
| 101 | - * |
|
| 102 | - * @access public |
|
| 103 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
| 104 | - * @throws \EE_Error |
|
| 105 | - */ |
|
| 106 | - public function create_new_blank_datetime() |
|
| 107 | - { |
|
| 108 | - //makes sure timezone is always set. |
|
| 109 | - $timezone_string = $this->get_timezone(); |
|
| 110 | - $blank_datetime = EE_Datetime::new_instance( |
|
| 111 | - array( |
|
| 112 | - 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS, |
|
| 113 | - 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS, |
|
| 114 | - 'DTT_order' => 1, |
|
| 115 | - 'DTT_reg_limit' => EE_INF, |
|
| 116 | - ), |
|
| 117 | - $timezone_string |
|
| 118 | - ); |
|
| 119 | - $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', |
|
| 120 | - $timezone_string)); |
|
| 121 | - $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $timezone_string)); |
|
| 122 | - return array($blank_datetime); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * get event start date from db |
|
| 129 | - * |
|
| 130 | - * @access public |
|
| 131 | - * @param int $EVT_ID |
|
| 132 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
| 133 | - * @throws \EE_Error |
|
| 134 | - */ |
|
| 135 | - public function get_all_event_dates($EVT_ID = 0) |
|
| 136 | - { |
|
| 137 | - if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 138 | - return $this->create_new_blank_datetime(); |
|
| 139 | - } |
|
| 140 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
| 141 | - if (empty($results)) { |
|
| 142 | - return $this->create_new_blank_datetime(); |
|
| 143 | - } |
|
| 144 | - return $results; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * get all datetimes attached to an event ordered by the DTT_order field |
|
| 151 | - * |
|
| 152 | - * @public |
|
| 153 | - * @param int $EVT_ID event id |
|
| 154 | - * @param boolean $include_expired |
|
| 155 | - * @param boolean $include_deleted |
|
| 156 | - * @param int $limit If included then limit the count of results by |
|
| 157 | - * the given number |
|
| 158 | - * @return EE_Datetime[] |
|
| 159 | - * @throws \EE_Error |
|
| 160 | - */ |
|
| 161 | - public function get_datetimes_for_event_ordered_by_DTT_order( |
|
| 162 | - $EVT_ID, |
|
| 163 | - $include_expired = true, |
|
| 164 | - $include_deleted = true, |
|
| 165 | - $limit = null |
|
| 166 | - ) { |
|
| 167 | - //sanitize EVT_ID |
|
| 168 | - $EVT_ID = absint($EVT_ID); |
|
| 169 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 170 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 171 | - $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
| 172 | - $query_params = ! empty($limit) |
|
| 173 | - ? array( |
|
| 174 | - $where_params, |
|
| 175 | - 'limit' => $limit, |
|
| 176 | - 'order_by' => array('DTT_order' => 'ASC'), |
|
| 177 | - 'default_where_conditions' => 'none', |
|
| 178 | - ) |
|
| 179 | - : array( |
|
| 180 | - $where_params, |
|
| 181 | - 'order_by' => array('DTT_order' => 'ASC'), |
|
| 182 | - 'default_where_conditions' => 'none', |
|
| 183 | - ); |
|
| 184 | - if ( ! $include_expired) { |
|
| 185 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 186 | - } |
|
| 187 | - if ($include_deleted) { |
|
| 188 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 189 | - } |
|
| 190 | - /** @var EE_Datetime[] $result */ |
|
| 191 | - $result = $this->get_all($query_params); |
|
| 192 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 193 | - return $result; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Gets the datetimes for the event (with the given limit), and orders them by "importance". By importance, we mean |
|
| 200 | - * that the primary datetimes are most important (DEPRECATED FOR NOW), and then the earlier datetimes are the most |
|
| 201 | - * important. Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
| 202 | - * |
|
| 203 | - * @param int $EVT_ID |
|
| 204 | - * @param int $limit |
|
| 205 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
| 206 | - * @throws \EE_Error |
|
| 207 | - */ |
|
| 208 | - public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null) |
|
| 209 | - { |
|
| 210 | - return $this->get_all( |
|
| 211 | - array( |
|
| 212 | - array('Event.EVT_ID' => $EVT_ID), |
|
| 213 | - 'limit' => $limit, |
|
| 214 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 215 | - 'default_where_conditions' => 'none', |
|
| 216 | - ) |
|
| 217 | - ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @param int $EVT_ID |
|
| 224 | - * @param boolean $include_expired |
|
| 225 | - * @param boolean $include_deleted |
|
| 226 | - * @return EE_Datetime |
|
| 227 | - * @throws \EE_Error |
|
| 228 | - */ |
|
| 229 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) |
|
| 230 | - { |
|
| 231 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
| 232 | - if ($results) { |
|
| 233 | - return array_shift($results); |
|
| 234 | - } else { |
|
| 235 | - return null; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Gets the 'primary' datetime for an event. |
|
| 243 | - * |
|
| 244 | - * @param int $EVT_ID |
|
| 245 | - * @param bool $try_to_exclude_expired |
|
| 246 | - * @param bool $try_to_exclude_deleted |
|
| 247 | - * @return \EE_Datetime |
|
| 248 | - * @throws \EE_Error |
|
| 249 | - */ |
|
| 250 | - public function get_primary_datetime_for_event( |
|
| 251 | - $EVT_ID, |
|
| 252 | - $try_to_exclude_expired = true, |
|
| 253 | - $try_to_exclude_deleted = true |
|
| 254 | - ) { |
|
| 255 | - if ($try_to_exclude_expired) { |
|
| 256 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
| 257 | - if ($non_expired) { |
|
| 258 | - return $non_expired; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - if ($try_to_exclude_deleted) { |
|
| 262 | - $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
| 263 | - if ($expired_even) { |
|
| 264 | - return $expired_even; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
| 274 | - * only by start date |
|
| 275 | - * |
|
| 276 | - * @param int $EVT_ID |
|
| 277 | - * @param boolean $include_expired |
|
| 278 | - * @param boolean $include_deleted |
|
| 279 | - * @param int $limit |
|
| 280 | - * @return EE_Datetime[] |
|
| 281 | - * @throws \EE_Error |
|
| 282 | - */ |
|
| 283 | - public function get_datetimes_for_event_ordered_by_start_time( |
|
| 284 | - $EVT_ID, |
|
| 285 | - $include_expired = true, |
|
| 286 | - $include_deleted = true, |
|
| 287 | - $limit = null |
|
| 288 | - ) { |
|
| 289 | - //sanitize EVT_ID |
|
| 290 | - $EVT_ID = absint($EVT_ID); |
|
| 291 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 292 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 293 | - $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 294 | - if ( ! $include_expired) { |
|
| 295 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 296 | - } |
|
| 297 | - if ($include_deleted) { |
|
| 298 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 299 | - } |
|
| 300 | - if ($limit) { |
|
| 301 | - $query_params['limit'] = $limit; |
|
| 302 | - } |
|
| 303 | - /** @var EE_Datetime[] $result */ |
|
| 304 | - $result = $this->get_all($query_params); |
|
| 305 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 306 | - return $result; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
| 313 | - * only by start date |
|
| 314 | - * |
|
| 315 | - * @param int $TKT_ID |
|
| 316 | - * @param boolean $include_expired |
|
| 317 | - * @param boolean $include_deleted |
|
| 318 | - * @param int $limit |
|
| 319 | - * @return EE_Datetime[] |
|
| 320 | - * @throws \EE_Error |
|
| 321 | - */ |
|
| 322 | - public function get_datetimes_for_ticket_ordered_by_start_time( |
|
| 323 | - $TKT_ID, |
|
| 324 | - $include_expired = true, |
|
| 325 | - $include_deleted = true, |
|
| 326 | - $limit = null |
|
| 327 | - ) { |
|
| 328 | - //sanitize TKT_ID |
|
| 329 | - $TKT_ID = absint($TKT_ID); |
|
| 330 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 331 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 332 | - $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 333 | - if ( ! $include_expired) { |
|
| 334 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 335 | - } |
|
| 336 | - if ($include_deleted) { |
|
| 337 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 338 | - } |
|
| 339 | - if ($limit) { |
|
| 340 | - $query_params['limit'] = $limit; |
|
| 341 | - } |
|
| 342 | - /** @var EE_Datetime[] $result */ |
|
| 343 | - $result = $this->get_all($query_params); |
|
| 344 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 345 | - return $result; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
| 352 | - * datetimes. |
|
| 353 | - * |
|
| 354 | - * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
| 355 | - * @param boolean $include_expired whether to include expired datetimes or not |
|
| 356 | - * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
| 357 | - * @param int|null $limit if null, no limit, if int then limit results by |
|
| 358 | - * that number |
|
| 359 | - * @return EE_Datetime[] |
|
| 360 | - * @throws \EE_Error |
|
| 361 | - */ |
|
| 362 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
| 363 | - $TKT_ID, |
|
| 364 | - $include_expired = true, |
|
| 365 | - $include_deleted = true, |
|
| 366 | - $limit = null |
|
| 367 | - ) { |
|
| 368 | - //sanitize id. |
|
| 369 | - $TKT_ID = absint($TKT_ID); |
|
| 370 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 371 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 372 | - $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
| 373 | - $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
| 374 | - if ( ! $include_expired) { |
|
| 375 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 376 | - } |
|
| 377 | - if ($include_deleted) { |
|
| 378 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 379 | - } |
|
| 380 | - if ($limit) { |
|
| 381 | - $query_params['limit'] = $limit; |
|
| 382 | - } |
|
| 383 | - /** @var EE_Datetime[] $result */ |
|
| 384 | - $result = $this->get_all($query_params); |
|
| 385 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 386 | - return $result; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
| 393 | - * reason it doesn't exist, we consider the earliest event the most important) |
|
| 394 | - * |
|
| 395 | - * @param int $EVT_ID |
|
| 396 | - * @return EE_Datetime |
|
| 397 | - * @throws \EE_Error |
|
| 398 | - */ |
|
| 399 | - public function get_most_important_datetime_for_event($EVT_ID) |
|
| 400 | - { |
|
| 401 | - $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
| 402 | - if ($results) { |
|
| 403 | - return array_shift($results); |
|
| 404 | - } else { |
|
| 405 | - return null; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
| 413 | - * grouped by month and year. |
|
| 414 | - * |
|
| 415 | - * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
| 416 | - * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
| 417 | - * Can be: |
|
| 418 | - * - '' = no filter |
|
| 419 | - * - upcoming = Published events with at least one upcoming datetime. |
|
| 420 | - * - expired = Events with all datetimes expired. |
|
| 421 | - * - active = Events that are published and have at least one datetime that |
|
| 422 | - * starts before now and ends after now. |
|
| 423 | - * - inactive = Events that are either not published. |
|
| 424 | - * @return EE_Base_Class[] |
|
| 425 | - * @throws \EE_Error |
|
| 426 | - */ |
|
| 427 | - public function get_dtt_months_and_years($where_params, $evt_active_status = '') |
|
| 428 | - { |
|
| 429 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
| 430 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
| 431 | - switch ($evt_active_status) { |
|
| 432 | - case 'upcoming' : |
|
| 433 | - $where_params['Event.status'] = 'publish'; |
|
| 434 | - //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 435 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 436 | - $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
| 437 | - } |
|
| 438 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
| 439 | - break; |
|
| 440 | - case 'expired' : |
|
| 441 | - if (isset($where_params['Event.status'])) { |
|
| 442 | - unset($where_params['Event.status']); |
|
| 443 | - } |
|
| 444 | - //get events to exclude |
|
| 445 | - $exclude_query[0] = array_merge($where_params, |
|
| 446 | - array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
| 447 | - //first get all events that have datetimes where its not expired. |
|
| 448 | - $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
| 449 | - $event_ids = array_keys($event_ids); |
|
| 450 | - if (isset($where_params['DTT_EVT_end'])) { |
|
| 451 | - $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 452 | - } |
|
| 453 | - $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
| 454 | - $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
| 455 | - break; |
|
| 456 | - case 'active' : |
|
| 457 | - $where_params['Event.status'] = 'publish'; |
|
| 458 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 459 | - $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
| 460 | - } |
|
| 461 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 462 | - $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
| 463 | - } |
|
| 464 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
| 465 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
| 466 | - break; |
|
| 467 | - case 'inactive' : |
|
| 468 | - if (isset($where_params['Event.status'])) { |
|
| 469 | - unset($where_params['Event.status']); |
|
| 470 | - } |
|
| 471 | - if (isset($where_params['OR'])) { |
|
| 472 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
| 473 | - } |
|
| 474 | - if (isset($where_params['DTT_EVT_end'])) { |
|
| 475 | - $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 476 | - unset($where_params['DTT_EVT_end']); |
|
| 477 | - } |
|
| 478 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 479 | - $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
| 480 | - unset($where_params['DTT_EVT_start']); |
|
| 481 | - } |
|
| 482 | - $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
| 483 | - break; |
|
| 484 | - } |
|
| 485 | - $query_params[0] = $where_params; |
|
| 486 | - $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
|
| 487 | - $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
| 488 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
| 489 | - $columns_to_select = array( |
|
| 490 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
| 491 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
| 492 | - 'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'), |
|
| 493 | - ); |
|
| 494 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
| 501 | - * for the tickets for each datetime) |
|
| 502 | - * |
|
| 503 | - * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
| 504 | - * @throws \EE_Error |
|
| 505 | - */ |
|
| 506 | - public function update_sold($datetimes) |
|
| 507 | - { |
|
| 508 | - EE_Error::doing_it_wrong( |
|
| 509 | - __FUNCTION__, |
|
| 510 | - esc_html__( |
|
| 511 | - 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
| 512 | - 'event_espresso' |
|
| 513 | - ), |
|
| 514 | - '4.9.32.rc.005' |
|
| 515 | - ); |
|
| 516 | - foreach ($datetimes as $datetime) { |
|
| 517 | - $datetime->update_sold(); |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - |
|
| 522 | - |
|
| 523 | - /** |
|
| 524 | - * Gets the total number of tickets available at a particular datetime |
|
| 525 | - * (does NOT take into account the datetime's spaces available) |
|
| 526 | - * |
|
| 527 | - * @param int $DTT_ID |
|
| 528 | - * @param array $query_params |
|
| 529 | - * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
| 530 | - * tickets attached to datetime then FALSE is returned. |
|
| 531 | - */ |
|
| 532 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array()) |
|
| 533 | - { |
|
| 534 | - $datetime = $this->get_one_by_ID($DTT_ID); |
|
| 535 | - if ($datetime instanceof EE_Datetime) { |
|
| 536 | - return $datetime->tickets_remaining($query_params); |
|
| 537 | - } |
|
| 538 | - return 0; |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
| 545 | - * |
|
| 546 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
| 547 | - * stati you want counts for as values in the array. An empty array returns counts |
|
| 548 | - * for all valid stati. |
|
| 549 | - * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
| 550 | - * only for Datetimes connected to a specific event, or specific ticket. |
|
| 551 | - * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
| 552 | - * @throws \EE_Error |
|
| 553 | - * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming EE_Datetime::expired |
|
| 554 | - */ |
|
| 555 | - public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array()) |
|
| 556 | - { |
|
| 557 | - //only accept where conditions for this query. |
|
| 558 | - $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 559 | - $status_query_args = array( |
|
| 560 | - EE_Datetime::active => array_merge( |
|
| 561 | - $_where, |
|
| 562 | - array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
| 563 | - ), |
|
| 564 | - EE_Datetime::upcoming => array_merge( |
|
| 565 | - $_where, |
|
| 566 | - array('DTT_EVT_start' => array('>', time())) |
|
| 567 | - ), |
|
| 568 | - EE_Datetime::expired => array_merge( |
|
| 569 | - $_where, |
|
| 570 | - array('DTT_EVT_end' => array('<', time())) |
|
| 571 | - ), |
|
| 572 | - ); |
|
| 573 | - if ( ! empty($stati_to_include)) { |
|
| 574 | - foreach (array_keys($status_query_args) as $status) { |
|
| 575 | - if ( ! in_array($status, $stati_to_include, true)) { |
|
| 576 | - unset($status_query_args[$status]); |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - //loop through and query counts for each stati. |
|
| 581 | - $status_query_results = array(); |
|
| 582 | - foreach ($status_query_args as $status => $status_where_conditions) { |
|
| 583 | - $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
| 584 | - } |
|
| 585 | - return $status_query_results; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * Returns the specific count for a given Datetime status matching any given query_params. |
|
| 592 | - * |
|
| 593 | - * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
| 594 | - * @param array $query_params |
|
| 595 | - * @return int |
|
| 596 | - * @throws \EE_Error |
|
| 597 | - */ |
|
| 598 | - public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array()) |
|
| 599 | - { |
|
| 600 | - $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
| 601 | - return ! empty($count[$status]) ? $count[$status] : 0; |
|
| 602 | - } |
|
| 14 | + /** |
|
| 15 | + * @var EEM_Datetime $_instance |
|
| 16 | + */ |
|
| 17 | + protected static $_instance; |
|
| 18 | + |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * private constructor to prevent direct creation |
|
| 23 | + * |
|
| 24 | + * @Constructor |
|
| 25 | + * @access private |
|
| 26 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
| 27 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
| 28 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
| 29 | + * timezone in the 'timezone_string' wp option) |
|
| 30 | + * @throws \EE_Error |
|
| 31 | + */ |
|
| 32 | + protected function __construct($timezone) |
|
| 33 | + { |
|
| 34 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
| 35 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
| 36 | + $this->_tables = array( |
|
| 37 | + 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
| 38 | + ); |
|
| 39 | + $this->_fields = array( |
|
| 40 | + 'Datetime' => array( |
|
| 41 | + 'DTT_ID' => new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
| 42 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
| 43 | + 'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event' |
|
| 44 | + ), |
|
| 45 | + 'DTT_name' => new EE_Plain_Text_Field( |
|
| 46 | + 'DTT_name', __('Datetime Name', 'event_espresso'), false, '' |
|
| 47 | + ), |
|
| 48 | + 'DTT_description' => new EE_Post_Content_Field( |
|
| 49 | + 'DTT_description', __('Description for Datetime', 'event_espresso'), false, '' |
|
| 50 | + ), |
|
| 51 | + 'DTT_EVT_start' => new EE_Datetime_Field( |
|
| 52 | + 'DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 53 | + $timezone |
|
| 54 | + ), |
|
| 55 | + 'DTT_EVT_end' => new EE_Datetime_Field( |
|
| 56 | + 'DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, |
|
| 57 | + $timezone |
|
| 58 | + ), |
|
| 59 | + 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
| 60 | + 'DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
| 61 | + 'DTT_sold' => new EE_Integer_Field( |
|
| 62 | + 'DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 |
|
| 63 | + ), |
|
| 64 | + 'DTT_reserved' => new EE_Integer_Field('DTT_reserved', |
|
| 65 | + __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), false, 0 |
|
| 66 | + ), |
|
| 67 | + 'DTT_is_primary' => new EE_Boolean_Field( |
|
| 68 | + 'DTT_is_primary', __('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 69 | + false, false |
|
| 70 | + ), |
|
| 71 | + 'DTT_order' => new EE_Integer_Field( |
|
| 72 | + 'DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0 |
|
| 73 | + ), |
|
| 74 | + 'DTT_parent' => new EE_Integer_Field( |
|
| 75 | + 'DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 |
|
| 76 | + ), |
|
| 77 | + 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
| 78 | + 'DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false |
|
| 79 | + ), |
|
| 80 | + ), |
|
| 81 | + ); |
|
| 82 | + $this->_model_relations = array( |
|
| 83 | + 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
| 84 | + 'Event' => new EE_Belongs_To_Relation(), |
|
| 85 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
| 86 | + ); |
|
| 87 | + $this->_model_chain_to_wp_user = 'Event'; |
|
| 88 | + //this model is generally available for reading |
|
| 89 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
| 90 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
| 91 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
| 92 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', |
|
| 93 | + EEM_Base::caps_edit); |
|
| 94 | + parent::__construct($timezone); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * create new blank datetime |
|
| 101 | + * |
|
| 102 | + * @access public |
|
| 103 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
| 104 | + * @throws \EE_Error |
|
| 105 | + */ |
|
| 106 | + public function create_new_blank_datetime() |
|
| 107 | + { |
|
| 108 | + //makes sure timezone is always set. |
|
| 109 | + $timezone_string = $this->get_timezone(); |
|
| 110 | + $blank_datetime = EE_Datetime::new_instance( |
|
| 111 | + array( |
|
| 112 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS, |
|
| 113 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS, |
|
| 114 | + 'DTT_order' => 1, |
|
| 115 | + 'DTT_reg_limit' => EE_INF, |
|
| 116 | + ), |
|
| 117 | + $timezone_string |
|
| 118 | + ); |
|
| 119 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', |
|
| 120 | + $timezone_string)); |
|
| 121 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $timezone_string)); |
|
| 122 | + return array($blank_datetime); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * get event start date from db |
|
| 129 | + * |
|
| 130 | + * @access public |
|
| 131 | + * @param int $EVT_ID |
|
| 132 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
| 133 | + * @throws \EE_Error |
|
| 134 | + */ |
|
| 135 | + public function get_all_event_dates($EVT_ID = 0) |
|
| 136 | + { |
|
| 137 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 138 | + return $this->create_new_blank_datetime(); |
|
| 139 | + } |
|
| 140 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
| 141 | + if (empty($results)) { |
|
| 142 | + return $this->create_new_blank_datetime(); |
|
| 143 | + } |
|
| 144 | + return $results; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * get all datetimes attached to an event ordered by the DTT_order field |
|
| 151 | + * |
|
| 152 | + * @public |
|
| 153 | + * @param int $EVT_ID event id |
|
| 154 | + * @param boolean $include_expired |
|
| 155 | + * @param boolean $include_deleted |
|
| 156 | + * @param int $limit If included then limit the count of results by |
|
| 157 | + * the given number |
|
| 158 | + * @return EE_Datetime[] |
|
| 159 | + * @throws \EE_Error |
|
| 160 | + */ |
|
| 161 | + public function get_datetimes_for_event_ordered_by_DTT_order( |
|
| 162 | + $EVT_ID, |
|
| 163 | + $include_expired = true, |
|
| 164 | + $include_deleted = true, |
|
| 165 | + $limit = null |
|
| 166 | + ) { |
|
| 167 | + //sanitize EVT_ID |
|
| 168 | + $EVT_ID = absint($EVT_ID); |
|
| 169 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 170 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 171 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
| 172 | + $query_params = ! empty($limit) |
|
| 173 | + ? array( |
|
| 174 | + $where_params, |
|
| 175 | + 'limit' => $limit, |
|
| 176 | + 'order_by' => array('DTT_order' => 'ASC'), |
|
| 177 | + 'default_where_conditions' => 'none', |
|
| 178 | + ) |
|
| 179 | + : array( |
|
| 180 | + $where_params, |
|
| 181 | + 'order_by' => array('DTT_order' => 'ASC'), |
|
| 182 | + 'default_where_conditions' => 'none', |
|
| 183 | + ); |
|
| 184 | + if ( ! $include_expired) { |
|
| 185 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 186 | + } |
|
| 187 | + if ($include_deleted) { |
|
| 188 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 189 | + } |
|
| 190 | + /** @var EE_Datetime[] $result */ |
|
| 191 | + $result = $this->get_all($query_params); |
|
| 192 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 193 | + return $result; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Gets the datetimes for the event (with the given limit), and orders them by "importance". By importance, we mean |
|
| 200 | + * that the primary datetimes are most important (DEPRECATED FOR NOW), and then the earlier datetimes are the most |
|
| 201 | + * important. Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
| 202 | + * |
|
| 203 | + * @param int $EVT_ID |
|
| 204 | + * @param int $limit |
|
| 205 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
| 206 | + * @throws \EE_Error |
|
| 207 | + */ |
|
| 208 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null) |
|
| 209 | + { |
|
| 210 | + return $this->get_all( |
|
| 211 | + array( |
|
| 212 | + array('Event.EVT_ID' => $EVT_ID), |
|
| 213 | + 'limit' => $limit, |
|
| 214 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 215 | + 'default_where_conditions' => 'none', |
|
| 216 | + ) |
|
| 217 | + ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @param int $EVT_ID |
|
| 224 | + * @param boolean $include_expired |
|
| 225 | + * @param boolean $include_deleted |
|
| 226 | + * @return EE_Datetime |
|
| 227 | + * @throws \EE_Error |
|
| 228 | + */ |
|
| 229 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) |
|
| 230 | + { |
|
| 231 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
| 232 | + if ($results) { |
|
| 233 | + return array_shift($results); |
|
| 234 | + } else { |
|
| 235 | + return null; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Gets the 'primary' datetime for an event. |
|
| 243 | + * |
|
| 244 | + * @param int $EVT_ID |
|
| 245 | + * @param bool $try_to_exclude_expired |
|
| 246 | + * @param bool $try_to_exclude_deleted |
|
| 247 | + * @return \EE_Datetime |
|
| 248 | + * @throws \EE_Error |
|
| 249 | + */ |
|
| 250 | + public function get_primary_datetime_for_event( |
|
| 251 | + $EVT_ID, |
|
| 252 | + $try_to_exclude_expired = true, |
|
| 253 | + $try_to_exclude_deleted = true |
|
| 254 | + ) { |
|
| 255 | + if ($try_to_exclude_expired) { |
|
| 256 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
| 257 | + if ($non_expired) { |
|
| 258 | + return $non_expired; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + if ($try_to_exclude_deleted) { |
|
| 262 | + $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
| 263 | + if ($expired_even) { |
|
| 264 | + return $expired_even; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
| 274 | + * only by start date |
|
| 275 | + * |
|
| 276 | + * @param int $EVT_ID |
|
| 277 | + * @param boolean $include_expired |
|
| 278 | + * @param boolean $include_deleted |
|
| 279 | + * @param int $limit |
|
| 280 | + * @return EE_Datetime[] |
|
| 281 | + * @throws \EE_Error |
|
| 282 | + */ |
|
| 283 | + public function get_datetimes_for_event_ordered_by_start_time( |
|
| 284 | + $EVT_ID, |
|
| 285 | + $include_expired = true, |
|
| 286 | + $include_deleted = true, |
|
| 287 | + $limit = null |
|
| 288 | + ) { |
|
| 289 | + //sanitize EVT_ID |
|
| 290 | + $EVT_ID = absint($EVT_ID); |
|
| 291 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 292 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 293 | + $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 294 | + if ( ! $include_expired) { |
|
| 295 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 296 | + } |
|
| 297 | + if ($include_deleted) { |
|
| 298 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 299 | + } |
|
| 300 | + if ($limit) { |
|
| 301 | + $query_params['limit'] = $limit; |
|
| 302 | + } |
|
| 303 | + /** @var EE_Datetime[] $result */ |
|
| 304 | + $result = $this->get_all($query_params); |
|
| 305 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 306 | + return $result; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
| 313 | + * only by start date |
|
| 314 | + * |
|
| 315 | + * @param int $TKT_ID |
|
| 316 | + * @param boolean $include_expired |
|
| 317 | + * @param boolean $include_deleted |
|
| 318 | + * @param int $limit |
|
| 319 | + * @return EE_Datetime[] |
|
| 320 | + * @throws \EE_Error |
|
| 321 | + */ |
|
| 322 | + public function get_datetimes_for_ticket_ordered_by_start_time( |
|
| 323 | + $TKT_ID, |
|
| 324 | + $include_expired = true, |
|
| 325 | + $include_deleted = true, |
|
| 326 | + $limit = null |
|
| 327 | + ) { |
|
| 328 | + //sanitize TKT_ID |
|
| 329 | + $TKT_ID = absint($TKT_ID); |
|
| 330 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 331 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 332 | + $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 333 | + if ( ! $include_expired) { |
|
| 334 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 335 | + } |
|
| 336 | + if ($include_deleted) { |
|
| 337 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 338 | + } |
|
| 339 | + if ($limit) { |
|
| 340 | + $query_params['limit'] = $limit; |
|
| 341 | + } |
|
| 342 | + /** @var EE_Datetime[] $result */ |
|
| 343 | + $result = $this->get_all($query_params); |
|
| 344 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 345 | + return $result; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
| 352 | + * datetimes. |
|
| 353 | + * |
|
| 354 | + * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
| 355 | + * @param boolean $include_expired whether to include expired datetimes or not |
|
| 356 | + * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
| 357 | + * @param int|null $limit if null, no limit, if int then limit results by |
|
| 358 | + * that number |
|
| 359 | + * @return EE_Datetime[] |
|
| 360 | + * @throws \EE_Error |
|
| 361 | + */ |
|
| 362 | + public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
| 363 | + $TKT_ID, |
|
| 364 | + $include_expired = true, |
|
| 365 | + $include_deleted = true, |
|
| 366 | + $limit = null |
|
| 367 | + ) { |
|
| 368 | + //sanitize id. |
|
| 369 | + $TKT_ID = absint($TKT_ID); |
|
| 370 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 371 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 372 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
| 373 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
| 374 | + if ( ! $include_expired) { |
|
| 375 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 376 | + } |
|
| 377 | + if ($include_deleted) { |
|
| 378 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 379 | + } |
|
| 380 | + if ($limit) { |
|
| 381 | + $query_params['limit'] = $limit; |
|
| 382 | + } |
|
| 383 | + /** @var EE_Datetime[] $result */ |
|
| 384 | + $result = $this->get_all($query_params); |
|
| 385 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 386 | + return $result; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
| 393 | + * reason it doesn't exist, we consider the earliest event the most important) |
|
| 394 | + * |
|
| 395 | + * @param int $EVT_ID |
|
| 396 | + * @return EE_Datetime |
|
| 397 | + * @throws \EE_Error |
|
| 398 | + */ |
|
| 399 | + public function get_most_important_datetime_for_event($EVT_ID) |
|
| 400 | + { |
|
| 401 | + $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
| 402 | + if ($results) { |
|
| 403 | + return array_shift($results); |
|
| 404 | + } else { |
|
| 405 | + return null; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
| 413 | + * grouped by month and year. |
|
| 414 | + * |
|
| 415 | + * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
| 416 | + * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
| 417 | + * Can be: |
|
| 418 | + * - '' = no filter |
|
| 419 | + * - upcoming = Published events with at least one upcoming datetime. |
|
| 420 | + * - expired = Events with all datetimes expired. |
|
| 421 | + * - active = Events that are published and have at least one datetime that |
|
| 422 | + * starts before now and ends after now. |
|
| 423 | + * - inactive = Events that are either not published. |
|
| 424 | + * @return EE_Base_Class[] |
|
| 425 | + * @throws \EE_Error |
|
| 426 | + */ |
|
| 427 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') |
|
| 428 | + { |
|
| 429 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
| 430 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
| 431 | + switch ($evt_active_status) { |
|
| 432 | + case 'upcoming' : |
|
| 433 | + $where_params['Event.status'] = 'publish'; |
|
| 434 | + //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 435 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 436 | + $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
| 437 | + } |
|
| 438 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
| 439 | + break; |
|
| 440 | + case 'expired' : |
|
| 441 | + if (isset($where_params['Event.status'])) { |
|
| 442 | + unset($where_params['Event.status']); |
|
| 443 | + } |
|
| 444 | + //get events to exclude |
|
| 445 | + $exclude_query[0] = array_merge($where_params, |
|
| 446 | + array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
| 447 | + //first get all events that have datetimes where its not expired. |
|
| 448 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
| 449 | + $event_ids = array_keys($event_ids); |
|
| 450 | + if (isset($where_params['DTT_EVT_end'])) { |
|
| 451 | + $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 452 | + } |
|
| 453 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
| 454 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
| 455 | + break; |
|
| 456 | + case 'active' : |
|
| 457 | + $where_params['Event.status'] = 'publish'; |
|
| 458 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 459 | + $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
| 460 | + } |
|
| 461 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 462 | + $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
| 463 | + } |
|
| 464 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
| 465 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
| 466 | + break; |
|
| 467 | + case 'inactive' : |
|
| 468 | + if (isset($where_params['Event.status'])) { |
|
| 469 | + unset($where_params['Event.status']); |
|
| 470 | + } |
|
| 471 | + if (isset($where_params['OR'])) { |
|
| 472 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
| 473 | + } |
|
| 474 | + if (isset($where_params['DTT_EVT_end'])) { |
|
| 475 | + $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 476 | + unset($where_params['DTT_EVT_end']); |
|
| 477 | + } |
|
| 478 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 479 | + $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
| 480 | + unset($where_params['DTT_EVT_start']); |
|
| 481 | + } |
|
| 482 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
| 483 | + break; |
|
| 484 | + } |
|
| 485 | + $query_params[0] = $where_params; |
|
| 486 | + $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
|
| 487 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
| 488 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
| 489 | + $columns_to_select = array( |
|
| 490 | + 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
| 491 | + 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
| 492 | + 'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'), |
|
| 493 | + ); |
|
| 494 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
| 501 | + * for the tickets for each datetime) |
|
| 502 | + * |
|
| 503 | + * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
| 504 | + * @throws \EE_Error |
|
| 505 | + */ |
|
| 506 | + public function update_sold($datetimes) |
|
| 507 | + { |
|
| 508 | + EE_Error::doing_it_wrong( |
|
| 509 | + __FUNCTION__, |
|
| 510 | + esc_html__( |
|
| 511 | + 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
| 512 | + 'event_espresso' |
|
| 513 | + ), |
|
| 514 | + '4.9.32.rc.005' |
|
| 515 | + ); |
|
| 516 | + foreach ($datetimes as $datetime) { |
|
| 517 | + $datetime->update_sold(); |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + |
|
| 522 | + |
|
| 523 | + /** |
|
| 524 | + * Gets the total number of tickets available at a particular datetime |
|
| 525 | + * (does NOT take into account the datetime's spaces available) |
|
| 526 | + * |
|
| 527 | + * @param int $DTT_ID |
|
| 528 | + * @param array $query_params |
|
| 529 | + * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
| 530 | + * tickets attached to datetime then FALSE is returned. |
|
| 531 | + */ |
|
| 532 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array()) |
|
| 533 | + { |
|
| 534 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
| 535 | + if ($datetime instanceof EE_Datetime) { |
|
| 536 | + return $datetime->tickets_remaining($query_params); |
|
| 537 | + } |
|
| 538 | + return 0; |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
| 545 | + * |
|
| 546 | + * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
| 547 | + * stati you want counts for as values in the array. An empty array returns counts |
|
| 548 | + * for all valid stati. |
|
| 549 | + * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
| 550 | + * only for Datetimes connected to a specific event, or specific ticket. |
|
| 551 | + * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
| 552 | + * @throws \EE_Error |
|
| 553 | + * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming EE_Datetime::expired |
|
| 554 | + */ |
|
| 555 | + public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array()) |
|
| 556 | + { |
|
| 557 | + //only accept where conditions for this query. |
|
| 558 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 559 | + $status_query_args = array( |
|
| 560 | + EE_Datetime::active => array_merge( |
|
| 561 | + $_where, |
|
| 562 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
| 563 | + ), |
|
| 564 | + EE_Datetime::upcoming => array_merge( |
|
| 565 | + $_where, |
|
| 566 | + array('DTT_EVT_start' => array('>', time())) |
|
| 567 | + ), |
|
| 568 | + EE_Datetime::expired => array_merge( |
|
| 569 | + $_where, |
|
| 570 | + array('DTT_EVT_end' => array('<', time())) |
|
| 571 | + ), |
|
| 572 | + ); |
|
| 573 | + if ( ! empty($stati_to_include)) { |
|
| 574 | + foreach (array_keys($status_query_args) as $status) { |
|
| 575 | + if ( ! in_array($status, $stati_to_include, true)) { |
|
| 576 | + unset($status_query_args[$status]); |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + //loop through and query counts for each stati. |
|
| 581 | + $status_query_results = array(); |
|
| 582 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
| 583 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
| 584 | + } |
|
| 585 | + return $status_query_results; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * Returns the specific count for a given Datetime status matching any given query_params. |
|
| 592 | + * |
|
| 593 | + * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
| 594 | + * @param array $query_params |
|
| 595 | + * @return int |
|
| 596 | + * @throws \EE_Error |
|
| 597 | + */ |
|
| 598 | + public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array()) |
|
| 599 | + { |
|
| 600 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
| 601 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | 604 | |
| 605 | 605 | |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @param array $props_n_values incoming values |
|
| 66 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 67 | - * used.) |
|
| 68 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 69 | - * date_format and the second value is the time format |
|
| 70 | - * @return EE_Ticket |
|
| 71 | - * @throws \EE_Error |
|
| 72 | - */ |
|
| 64 | + /** |
|
| 65 | + * @param array $props_n_values incoming values |
|
| 66 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 67 | + * used.) |
|
| 68 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 69 | + * date_format and the second value is the time format |
|
| 70 | + * @return EE_Ticket |
|
| 71 | + * @throws \EE_Error |
|
| 72 | + */ |
|
| 73 | 73 | public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
| 74 | 74 | $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
| 75 | 75 | return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
@@ -77,36 +77,36 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param array $props_n_values incoming values from the database |
|
| 82 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 83 | - * the website will be used. |
|
| 84 | - * @return EE_Ticket |
|
| 85 | - * @throws \EE_Error |
|
| 86 | - */ |
|
| 80 | + /** |
|
| 81 | + * @param array $props_n_values incoming values from the database |
|
| 82 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 83 | + * the website will be used. |
|
| 84 | + * @return EE_Ticket |
|
| 85 | + * @throws \EE_Error |
|
| 86 | + */ |
|
| 87 | 87 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
| 88 | 88 | return new self( $props_n_values, TRUE, $timezone ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return bool |
|
| 95 | - * @throws \EE_Error |
|
| 96 | - */ |
|
| 93 | + /** |
|
| 94 | + * @return bool |
|
| 95 | + * @throws \EE_Error |
|
| 96 | + */ |
|
| 97 | 97 | public function parent() { |
| 98 | 98 | return $this->get( 'TKT_parent' ); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * return if a ticket has quantities available for purchase |
|
| 105 | - * |
|
| 106 | - * @param int $DTT_ID the primary key for a particular datetime |
|
| 107 | - * @return boolean |
|
| 108 | - * @throws \EE_Error |
|
| 109 | - */ |
|
| 103 | + /** |
|
| 104 | + * return if a ticket has quantities available for purchase |
|
| 105 | + * |
|
| 106 | + * @param int $DTT_ID the primary key for a particular datetime |
|
| 107 | + * @return boolean |
|
| 108 | + * @throws \EE_Error |
|
| 109 | + */ |
|
| 110 | 110 | public function available( $DTT_ID = 0 ) { |
| 111 | 111 | // are we checking availability for a particular datetime ? |
| 112 | 112 | if ( $DTT_ID ) { |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired |
|
| 128 | - * |
|
| 129 | - * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const |
|
| 130 | - * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing |
|
| 131 | - * @return mixed status int if the display string isn't requested |
|
| 132 | - * @throws \EE_Error |
|
| 133 | - */ |
|
| 126 | + /** |
|
| 127 | + * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired |
|
| 128 | + * |
|
| 129 | + * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const |
|
| 130 | + * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing |
|
| 131 | + * @return mixed status int if the display string isn't requested |
|
| 132 | + * @throws \EE_Error |
|
| 133 | + */ |
|
| 134 | 134 | public function ticket_status( $display = FALSE, $remaining = null ) { |
| 135 | 135 | $remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining(); |
| 136 | 136 | if ( ! $remaining ) { |
@@ -153,14 +153,14 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out. |
|
| 158 | - * |
|
| 159 | - * @access public |
|
| 160 | - * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
|
| 161 | - * @return boolean true = tickets remaining, false not. |
|
| 162 | - * @throws \EE_Error |
|
| 163 | - */ |
|
| 156 | + /** |
|
| 157 | + * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out. |
|
| 158 | + * |
|
| 159 | + * @access public |
|
| 160 | + * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
|
| 161 | + * @return boolean true = tickets remaining, false not. |
|
| 162 | + * @throws \EE_Error |
|
| 163 | + */ |
|
| 164 | 164 | public function is_remaining( $DTT_ID = 0 ) { |
| 165 | 165 | $num_remaining = $this->remaining( $DTT_ID ); |
| 166 | 166 | if ( $num_remaining === 0 ) { |
@@ -174,76 +174,76 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * return the total number of tickets available for purchase |
|
| 179 | - * |
|
| 180 | - * @param int $DTT_ID the primary key for a particular datetime. |
|
| 181 | - * set to 0 for all related datetimes |
|
| 182 | - * @return int |
|
| 183 | - * @throws \EE_Error |
|
| 184 | - */ |
|
| 177 | + /** |
|
| 178 | + * return the total number of tickets available for purchase |
|
| 179 | + * |
|
| 180 | + * @param int $DTT_ID the primary key for a particular datetime. |
|
| 181 | + * set to 0 for all related datetimes |
|
| 182 | + * @return int |
|
| 183 | + * @throws \EE_Error |
|
| 184 | + */ |
|
| 185 | 185 | public function remaining( $DTT_ID = 0 ) { |
| 186 | 186 | return $this->real_quantity_on_ticket('saleable', $DTT_ID ); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Gets min |
|
| 193 | - * |
|
| 194 | - * @return int |
|
| 195 | - * @throws \EE_Error |
|
| 196 | - */ |
|
| 191 | + /** |
|
| 192 | + * Gets min |
|
| 193 | + * |
|
| 194 | + * @return int |
|
| 195 | + * @throws \EE_Error |
|
| 196 | + */ |
|
| 197 | 197 | public function min() { |
| 198 | 198 | return $this->get( 'TKT_min' ); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * return if a ticket is no longer available cause its available dates have expired. |
|
| 205 | - * |
|
| 206 | - * @return boolean |
|
| 207 | - * @throws \EE_Error |
|
| 208 | - */ |
|
| 203 | + /** |
|
| 204 | + * return if a ticket is no longer available cause its available dates have expired. |
|
| 205 | + * |
|
| 206 | + * @return boolean |
|
| 207 | + * @throws \EE_Error |
|
| 208 | + */ |
|
| 209 | 209 | public function is_expired() { |
| 210 | 210 | return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Return if a ticket is yet to go on sale or not |
|
| 217 | - * |
|
| 218 | - * @return boolean |
|
| 219 | - * @throws \EE_Error |
|
| 220 | - */ |
|
| 215 | + /** |
|
| 216 | + * Return if a ticket is yet to go on sale or not |
|
| 217 | + * |
|
| 218 | + * @return boolean |
|
| 219 | + * @throws \EE_Error |
|
| 220 | + */ |
|
| 221 | 221 | public function is_pending() { |
| 222 | 222 | return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Return if a ticket is on sale or not |
|
| 229 | - * |
|
| 230 | - * @return boolean |
|
| 231 | - * @throws \EE_Error |
|
| 232 | - */ |
|
| 227 | + /** |
|
| 228 | + * Return if a ticket is on sale or not |
|
| 229 | + * |
|
| 230 | + * @return boolean |
|
| 231 | + * @throws \EE_Error |
|
| 232 | + */ |
|
| 233 | 233 | public function is_on_sale() { |
| 234 | 234 | return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * This returns the chronologically last datetime that this ticket is associated with |
|
| 241 | - * |
|
| 242 | - * @param string $dt_frmt |
|
| 243 | - * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
| 244 | - * @return string |
|
| 245 | - * @throws \EE_Error |
|
| 246 | - */ |
|
| 239 | + /** |
|
| 240 | + * This returns the chronologically last datetime that this ticket is associated with |
|
| 241 | + * |
|
| 242 | + * @param string $dt_frmt |
|
| 243 | + * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
| 244 | + * @return string |
|
| 245 | + * @throws \EE_Error |
|
| 246 | + */ |
|
| 247 | 247 | public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
| 248 | 248 | $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
| 249 | 249 | $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * This returns the chronologically first datetime that this ticket is associated with |
|
| 258 | - * |
|
| 259 | - * @return EE_Datetime |
|
| 260 | - * @throws \EE_Error |
|
| 261 | - */ |
|
| 256 | + /** |
|
| 257 | + * This returns the chronologically first datetime that this ticket is associated with |
|
| 258 | + * |
|
| 259 | + * @return EE_Datetime |
|
| 260 | + * @throws \EE_Error |
|
| 261 | + */ |
|
| 262 | 262 | public function first_datetime() { |
| 263 | 263 | $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
| 264 | 264 | return reset( $datetimes ); |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | |
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Gets all the datetimes this ticket can be used for attending. |
|
| 271 | - * Unless otherwise specified, orders datetimes by start date. |
|
| 272 | - * |
|
| 273 | - * @param array $query_params see EEM_Base::get_all() |
|
| 274 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
| 275 | - * @throws \EE_Error |
|
| 276 | - */ |
|
| 269 | + /** |
|
| 270 | + * Gets all the datetimes this ticket can be used for attending. |
|
| 271 | + * Unless otherwise specified, orders datetimes by start date. |
|
| 272 | + * |
|
| 273 | + * @param array $query_params see EEM_Base::get_all() |
|
| 274 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
| 275 | + * @throws \EE_Error |
|
| 276 | + */ |
|
| 277 | 277 | public function datetimes( $query_params = array() ) { |
| 278 | 278 | if ( ! isset( $query_params[ 'order_by' ] ) ) { |
| 279 | 279 | $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | |
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * This returns the chronologically last datetime that this ticket is associated with |
|
| 288 | - * |
|
| 289 | - * @return EE_Datetime |
|
| 290 | - * @throws \EE_Error |
|
| 291 | - */ |
|
| 286 | + /** |
|
| 287 | + * This returns the chronologically last datetime that this ticket is associated with |
|
| 288 | + * |
|
| 289 | + * @return EE_Datetime |
|
| 290 | + * @throws \EE_Error |
|
| 291 | + */ |
|
| 292 | 292 | public function last_datetime() { |
| 293 | 293 | $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
| 294 | 294 | return end( $datetimes ); |
@@ -296,19 +296,19 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * This returns the total tickets sold depending on the given parameters. |
|
| 301 | - * |
|
| 302 | - * @param string $what Can be one of two options: 'ticket', 'datetime'. |
|
| 303 | - * 'ticket' = total ticket sales for all datetimes this ticket is related to |
|
| 304 | - * 'datetime' = total ticket sales for a specified datetime (required $dtt_id) |
|
| 305 | - * 'datetime' = total ticket sales in the datetime_ticket table. |
|
| 306 | - * If $dtt_id is not given then we return an array of sales indexed by datetime. |
|
| 307 | - * If $dtt_id IS given then we return the tickets sold for that given datetime. |
|
| 308 | - * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
|
| 309 | - * @return mixed (array|int) how many tickets have sold |
|
| 310 | - * @throws \EE_Error |
|
| 311 | - */ |
|
| 299 | + /** |
|
| 300 | + * This returns the total tickets sold depending on the given parameters. |
|
| 301 | + * |
|
| 302 | + * @param string $what Can be one of two options: 'ticket', 'datetime'. |
|
| 303 | + * 'ticket' = total ticket sales for all datetimes this ticket is related to |
|
| 304 | + * 'datetime' = total ticket sales for a specified datetime (required $dtt_id) |
|
| 305 | + * 'datetime' = total ticket sales in the datetime_ticket table. |
|
| 306 | + * If $dtt_id is not given then we return an array of sales indexed by datetime. |
|
| 307 | + * If $dtt_id IS given then we return the tickets sold for that given datetime. |
|
| 308 | + * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
|
| 309 | + * @return mixed (array|int) how many tickets have sold |
|
| 310 | + * @throws \EE_Error |
|
| 311 | + */ |
|
| 312 | 312 | public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
| 313 | 313 | $total = 0; |
| 314 | 314 | $tickets_sold = $this->_all_tickets_sold(); |
@@ -333,12 +333,12 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | |
| 335 | 335 | |
| 336 | - /** |
|
| 337 | - * This returns an array indexed by datetime_id for tickets sold with this ticket. |
|
| 338 | - * |
|
| 339 | - * @return EE_Ticket[] |
|
| 340 | - * @throws \EE_Error |
|
| 341 | - */ |
|
| 336 | + /** |
|
| 337 | + * This returns an array indexed by datetime_id for tickets sold with this ticket. |
|
| 338 | + * |
|
| 339 | + * @return EE_Ticket[] |
|
| 340 | + * @throws \EE_Error |
|
| 341 | + */ |
|
| 342 | 342 | protected function _all_tickets_sold() { |
| 343 | 343 | $datetimes = $this->get_many_related( 'Datetime' ); |
| 344 | 344 | $tickets_sold = array(); |
@@ -354,29 +354,29 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * This returns the base price object for the ticket. |
|
| 359 | - * |
|
| 360 | - * @param bool $return_array whether to return as an array indexed by price id or just the object. |
|
| 361 | - * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
|
| 362 | - * @throws \EE_Error |
|
| 363 | - */ |
|
| 357 | + /** |
|
| 358 | + * This returns the base price object for the ticket. |
|
| 359 | + * |
|
| 360 | + * @param bool $return_array whether to return as an array indexed by price id or just the object. |
|
| 361 | + * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
|
| 362 | + * @throws \EE_Error |
|
| 363 | + */ |
|
| 364 | 364 | public function base_price( $return_array = FALSE ) { |
| 365 | 365 | $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
| 366 | 366 | return $return_array |
| 367 | - ? $this->get_many_related( 'Price', array( $_where ) ) |
|
| 368 | - : $this->get_first_related( 'Price', array( $_where ) ); |
|
| 367 | + ? $this->get_many_related( 'Price', array( $_where ) ) |
|
| 368 | + : $this->get_first_related( 'Price', array( $_where ) ); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price) |
|
| 375 | - * |
|
| 376 | - * @access public |
|
| 377 | - * @return EE_Price[] |
|
| 378 | - * @throws \EE_Error |
|
| 379 | - */ |
|
| 373 | + /** |
|
| 374 | + * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price) |
|
| 375 | + * |
|
| 376 | + * @access public |
|
| 377 | + * @return EE_Price[] |
|
| 378 | + * @throws \EE_Error |
|
| 379 | + */ |
|
| 380 | 380 | public function price_modifiers() { |
| 381 | 381 | $query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) ); |
| 382 | 382 | return $this->prices( $query_params ); |
@@ -384,132 +384,132 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * Gets all the prices that combine to form the final price of this ticket |
|
| 389 | - * |
|
| 390 | - * @param array $query_params like EEM_Base::get_all |
|
| 391 | - * @return EE_Price[]|EE_Base_Class[] |
|
| 392 | - * @throws \EE_Error |
|
| 393 | - */ |
|
| 387 | + /** |
|
| 388 | + * Gets all the prices that combine to form the final price of this ticket |
|
| 389 | + * |
|
| 390 | + * @param array $query_params like EEM_Base::get_all |
|
| 391 | + * @return EE_Price[]|EE_Base_Class[] |
|
| 392 | + * @throws \EE_Error |
|
| 393 | + */ |
|
| 394 | 394 | public function prices( $query_params = array() ) { |
| 395 | 395 | return $this->get_many_related( 'Price', $query_params ); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | |
| 400 | - /** |
|
| 401 | - * Gets all the ticket applicabilities (ie, relations between datetimes and tickets) |
|
| 402 | - * |
|
| 403 | - * @param array $query_params see EEM_Base::get_all() |
|
| 404 | - * @return EE_Datetime_Ticket|EE_Base_Class[] |
|
| 405 | - * @throws \EE_Error |
|
| 406 | - */ |
|
| 400 | + /** |
|
| 401 | + * Gets all the ticket applicabilities (ie, relations between datetimes and tickets) |
|
| 402 | + * |
|
| 403 | + * @param array $query_params see EEM_Base::get_all() |
|
| 404 | + * @return EE_Datetime_Ticket|EE_Base_Class[] |
|
| 405 | + * @throws \EE_Error |
|
| 406 | + */ |
|
| 407 | 407 | public function datetime_tickets( $query_params = array() ) { |
| 408 | 408 | return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Gets all the datetimes from the db ordered by DTT_order |
|
| 415 | - * |
|
| 416 | - * @param boolean $show_expired |
|
| 417 | - * @param boolean $show_deleted |
|
| 418 | - * @return EE_Datetime[] |
|
| 419 | - * @throws \EE_Error |
|
| 420 | - */ |
|
| 413 | + /** |
|
| 414 | + * Gets all the datetimes from the db ordered by DTT_order |
|
| 415 | + * |
|
| 416 | + * @param boolean $show_expired |
|
| 417 | + * @param boolean $show_deleted |
|
| 418 | + * @return EE_Datetime[] |
|
| 419 | + * @throws \EE_Error |
|
| 420 | + */ |
|
| 421 | 421 | public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
| 422 | 422 | return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * Gets ID |
|
| 429 | - * |
|
| 430 | - * @return string |
|
| 431 | - * @throws \EE_Error |
|
| 432 | - */ |
|
| 427 | + /** |
|
| 428 | + * Gets ID |
|
| 429 | + * |
|
| 430 | + * @return string |
|
| 431 | + * @throws \EE_Error |
|
| 432 | + */ |
|
| 433 | 433 | public function ID() { |
| 434 | 434 | return $this->get( 'TKT_ID' ); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * get the author of the ticket. |
|
| 441 | - * |
|
| 442 | - * @since 4.5.0 |
|
| 443 | - * @return int |
|
| 444 | - * @throws \EE_Error |
|
| 445 | - */ |
|
| 439 | + /** |
|
| 440 | + * get the author of the ticket. |
|
| 441 | + * |
|
| 442 | + * @since 4.5.0 |
|
| 443 | + * @return int |
|
| 444 | + * @throws \EE_Error |
|
| 445 | + */ |
|
| 446 | 446 | public function wp_user() { |
| 447 | 447 | return $this->get('TKT_wp_user'); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * Gets the template for the ticket |
|
| 454 | - * |
|
| 455 | - * @return EE_Ticket_Template|EE_Base_Class |
|
| 456 | - * @throws \EE_Error |
|
| 457 | - */ |
|
| 452 | + /** |
|
| 453 | + * Gets the template for the ticket |
|
| 454 | + * |
|
| 455 | + * @return EE_Ticket_Template|EE_Base_Class |
|
| 456 | + * @throws \EE_Error |
|
| 457 | + */ |
|
| 458 | 458 | public function template() { |
| 459 | 459 | return $this->get_first_related( 'Ticket_Template' ); |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
| 463 | 463 | |
| 464 | - /** |
|
| 465 | - * Simply returns an array of EE_Price objects that are taxes. |
|
| 466 | - * |
|
| 467 | - * @return EE_Price[] |
|
| 468 | - * @throws \EE_Error |
|
| 469 | - */ |
|
| 464 | + /** |
|
| 465 | + * Simply returns an array of EE_Price objects that are taxes. |
|
| 466 | + * |
|
| 467 | + * @return EE_Price[] |
|
| 468 | + * @throws \EE_Error |
|
| 469 | + */ |
|
| 470 | 470 | public function get_ticket_taxes_for_admin() { |
| 471 | 471 | return EE_Taxes::get_taxes_for_admin(); |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * @return float |
|
| 478 | - * @throws \EE_Error |
|
| 479 | - */ |
|
| 476 | + /** |
|
| 477 | + * @return float |
|
| 478 | + * @throws \EE_Error |
|
| 479 | + */ |
|
| 480 | 480 | public function ticket_price() { |
| 481 | 481 | return $this->get( 'TKT_price' ); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | |
| 485 | 485 | |
| 486 | - /** |
|
| 487 | - * @return mixed |
|
| 488 | - * @throws \EE_Error |
|
| 489 | - */ |
|
| 486 | + /** |
|
| 487 | + * @return mixed |
|
| 488 | + * @throws \EE_Error |
|
| 489 | + */ |
|
| 490 | 490 | public function pretty_price() { |
| 491 | 491 | return $this->get_pretty( 'TKT_price' ); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * @return bool |
|
| 498 | - * @throws \EE_Error |
|
| 499 | - */ |
|
| 496 | + /** |
|
| 497 | + * @return bool |
|
| 498 | + * @throws \EE_Error |
|
| 499 | + */ |
|
| 500 | 500 | public function is_free() { |
| 501 | 501 | return $this->get_ticket_total_with_taxes() === (float) 0; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | |
| 506 | - /** |
|
| 507 | - * get_ticket_total_with_taxes |
|
| 508 | - * |
|
| 509 | - * @param bool $no_cache |
|
| 510 | - * @return float |
|
| 511 | - * @throws \EE_Error |
|
| 512 | - */ |
|
| 506 | + /** |
|
| 507 | + * get_ticket_total_with_taxes |
|
| 508 | + * |
|
| 509 | + * @param bool $no_cache |
|
| 510 | + * @return float |
|
| 511 | + * @throws \EE_Error |
|
| 512 | + */ |
|
| 513 | 513 | public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
| 514 | 514 | if ($this->_ticket_total_with_taxes === null || $no_cache ) { |
| 515 | 515 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
@@ -526,201 +526,201 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | |
| 529 | - /** |
|
| 530 | - * @return float |
|
| 531 | - * @throws \EE_Error |
|
| 532 | - */ |
|
| 529 | + /** |
|
| 530 | + * @return float |
|
| 531 | + * @throws \EE_Error |
|
| 532 | + */ |
|
| 533 | 533 | public function get_ticket_subtotal() { |
| 534 | 534 | return EE_Taxes::get_subtotal_for_admin( $this ); |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * Returns the total taxes applied to this ticket |
|
| 541 | - * |
|
| 542 | - * @return float |
|
| 543 | - * @throws \EE_Error |
|
| 544 | - */ |
|
| 539 | + /** |
|
| 540 | + * Returns the total taxes applied to this ticket |
|
| 541 | + * |
|
| 542 | + * @return float |
|
| 543 | + * @throws \EE_Error |
|
| 544 | + */ |
|
| 545 | 545 | public function get_ticket_taxes_total_for_admin() { |
| 546 | 546 | return EE_Taxes::get_total_taxes_for_admin( $this ); |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | |
| 550 | 550 | |
| 551 | - /** |
|
| 552 | - * Sets name |
|
| 553 | - * |
|
| 554 | - * @param string $name |
|
| 555 | - * @throws \EE_Error |
|
| 556 | - */ |
|
| 551 | + /** |
|
| 552 | + * Sets name |
|
| 553 | + * |
|
| 554 | + * @param string $name |
|
| 555 | + * @throws \EE_Error |
|
| 556 | + */ |
|
| 557 | 557 | public function set_name( $name ) { |
| 558 | 558 | $this->set( 'TKT_name', $name ); |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
| 562 | 562 | |
| 563 | - /** |
|
| 564 | - * Gets description |
|
| 565 | - * |
|
| 566 | - * @return string |
|
| 567 | - * @throws \EE_Error |
|
| 568 | - */ |
|
| 563 | + /** |
|
| 564 | + * Gets description |
|
| 565 | + * |
|
| 566 | + * @return string |
|
| 567 | + * @throws \EE_Error |
|
| 568 | + */ |
|
| 569 | 569 | public function description() { |
| 570 | 570 | return $this->get( 'TKT_description' ); |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | |
| 574 | 574 | |
| 575 | - /** |
|
| 576 | - * Sets description |
|
| 577 | - * |
|
| 578 | - * @param string $description |
|
| 579 | - * @throws \EE_Error |
|
| 580 | - */ |
|
| 575 | + /** |
|
| 576 | + * Sets description |
|
| 577 | + * |
|
| 578 | + * @param string $description |
|
| 579 | + * @throws \EE_Error |
|
| 580 | + */ |
|
| 581 | 581 | public function set_description( $description ) { |
| 582 | 582 | $this->set( 'TKT_description', $description ); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
| 586 | 586 | |
| 587 | - /** |
|
| 588 | - * Gets start_date |
|
| 589 | - * |
|
| 590 | - * @param string $dt_frmt |
|
| 591 | - * @param string $tm_frmt |
|
| 592 | - * @return string |
|
| 593 | - * @throws \EE_Error |
|
| 594 | - */ |
|
| 587 | + /** |
|
| 588 | + * Gets start_date |
|
| 589 | + * |
|
| 590 | + * @param string $dt_frmt |
|
| 591 | + * @param string $tm_frmt |
|
| 592 | + * @return string |
|
| 593 | + * @throws \EE_Error |
|
| 594 | + */ |
|
| 595 | 595 | public function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
| 596 | 596 | return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | |
| 600 | 600 | |
| 601 | - /** |
|
| 602 | - * Sets start_date |
|
| 603 | - * |
|
| 604 | - * @param string $start_date |
|
| 605 | - * @return void |
|
| 606 | - * @throws \EE_Error |
|
| 607 | - */ |
|
| 601 | + /** |
|
| 602 | + * Sets start_date |
|
| 603 | + * |
|
| 604 | + * @param string $start_date |
|
| 605 | + * @return void |
|
| 606 | + * @throws \EE_Error |
|
| 607 | + */ |
|
| 608 | 608 | public function set_start_date( $start_date ) { |
| 609 | 609 | $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | |
| 613 | 613 | |
| 614 | - /** |
|
| 615 | - * Gets end_date |
|
| 616 | - * |
|
| 617 | - * @param string $dt_frmt |
|
| 618 | - * @param string $tm_frmt |
|
| 619 | - * @return string |
|
| 620 | - * @throws \EE_Error |
|
| 621 | - */ |
|
| 614 | + /** |
|
| 615 | + * Gets end_date |
|
| 616 | + * |
|
| 617 | + * @param string $dt_frmt |
|
| 618 | + * @param string $tm_frmt |
|
| 619 | + * @return string |
|
| 620 | + * @throws \EE_Error |
|
| 621 | + */ |
|
| 622 | 622 | public function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
| 623 | 623 | return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | |
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Sets end_date |
|
| 630 | - * |
|
| 631 | - * @param string $end_date |
|
| 632 | - * @return void |
|
| 633 | - * @throws \EE_Error |
|
| 634 | - */ |
|
| 628 | + /** |
|
| 629 | + * Sets end_date |
|
| 630 | + * |
|
| 631 | + * @param string $end_date |
|
| 632 | + * @return void |
|
| 633 | + * @throws \EE_Error |
|
| 634 | + */ |
|
| 635 | 635 | public function set_end_date( $end_date ) { |
| 636 | 636 | $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | |
| 640 | 640 | |
| 641 | - /** |
|
| 642 | - * Sets sell until time |
|
| 643 | - * |
|
| 644 | - * @since 4.5.0 |
|
| 645 | - * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
|
| 646 | - * @throws \EE_Error |
|
| 647 | - */ |
|
| 641 | + /** |
|
| 642 | + * Sets sell until time |
|
| 643 | + * |
|
| 644 | + * @since 4.5.0 |
|
| 645 | + * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
|
| 646 | + * @throws \EE_Error |
|
| 647 | + */ |
|
| 648 | 648 | public function set_end_time( $time ) { |
| 649 | 649 | $this->_set_time_for( $time, 'TKT_end_date' ); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | |
| 653 | 653 | |
| 654 | - /** |
|
| 655 | - * Sets min |
|
| 656 | - * |
|
| 657 | - * @param int $min |
|
| 658 | - * @return void |
|
| 659 | - * @throws \EE_Error |
|
| 660 | - */ |
|
| 654 | + /** |
|
| 655 | + * Sets min |
|
| 656 | + * |
|
| 657 | + * @param int $min |
|
| 658 | + * @return void |
|
| 659 | + * @throws \EE_Error |
|
| 660 | + */ |
|
| 661 | 661 | public function set_min( $min ) { |
| 662 | 662 | $this->set( 'TKT_min', $min ); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
| 666 | 666 | |
| 667 | - /** |
|
| 668 | - * Gets max |
|
| 669 | - * |
|
| 670 | - * @return int |
|
| 671 | - * @throws \EE_Error |
|
| 672 | - */ |
|
| 667 | + /** |
|
| 668 | + * Gets max |
|
| 669 | + * |
|
| 670 | + * @return int |
|
| 671 | + * @throws \EE_Error |
|
| 672 | + */ |
|
| 673 | 673 | public function max() { |
| 674 | 674 | return $this->get( 'TKT_max' ); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
| 678 | 678 | |
| 679 | - /** |
|
| 680 | - * Sets max |
|
| 681 | - * |
|
| 682 | - * @param int $max |
|
| 683 | - * @return void |
|
| 684 | - * @throws \EE_Error |
|
| 685 | - */ |
|
| 679 | + /** |
|
| 680 | + * Sets max |
|
| 681 | + * |
|
| 682 | + * @param int $max |
|
| 683 | + * @return void |
|
| 684 | + * @throws \EE_Error |
|
| 685 | + */ |
|
| 686 | 686 | public function set_max( $max ) { |
| 687 | 687 | $this->set( 'TKT_max', $max ); |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | |
| 691 | 691 | |
| 692 | - /** |
|
| 693 | - * Sets price |
|
| 694 | - * |
|
| 695 | - * @param float $price |
|
| 696 | - * @return void |
|
| 697 | - * @throws \EE_Error |
|
| 698 | - */ |
|
| 692 | + /** |
|
| 693 | + * Sets price |
|
| 694 | + * |
|
| 695 | + * @param float $price |
|
| 696 | + * @return void |
|
| 697 | + * @throws \EE_Error |
|
| 698 | + */ |
|
| 699 | 699 | public function set_price( $price ) { |
| 700 | 700 | $this->set( 'TKT_price', $price ); |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
| 704 | 704 | |
| 705 | - /** |
|
| 706 | - * Gets sold |
|
| 707 | - * |
|
| 708 | - * @return int |
|
| 709 | - * @throws \EE_Error |
|
| 710 | - */ |
|
| 705 | + /** |
|
| 706 | + * Gets sold |
|
| 707 | + * |
|
| 708 | + * @return int |
|
| 709 | + * @throws \EE_Error |
|
| 710 | + */ |
|
| 711 | 711 | public function sold() { |
| 712 | 712 | return $this->get_raw( 'TKT_sold' ); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | |
| 716 | 716 | |
| 717 | - /** |
|
| 718 | - * Sets sold |
|
| 719 | - * |
|
| 720 | - * @param int $sold |
|
| 721 | - * @return void |
|
| 722 | - * @throws \EE_Error |
|
| 723 | - */ |
|
| 717 | + /** |
|
| 718 | + * Sets sold |
|
| 719 | + * |
|
| 720 | + * @param int $sold |
|
| 721 | + * @return void |
|
| 722 | + * @throws \EE_Error |
|
| 723 | + */ |
|
| 724 | 724 | public function set_sold( $sold ) { |
| 725 | 725 | // sold can not go below zero |
| 726 | 726 | $sold = max( 0, $sold ); |
@@ -729,13 +729,13 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | |
| 731 | 731 | |
| 732 | - /** |
|
| 733 | - * increments sold by amount passed by $qty |
|
| 734 | - * |
|
| 735 | - * @param int $qty |
|
| 736 | - * @return void |
|
| 737 | - * @throws \EE_Error |
|
| 738 | - */ |
|
| 732 | + /** |
|
| 733 | + * increments sold by amount passed by $qty |
|
| 734 | + * |
|
| 735 | + * @param int $qty |
|
| 736 | + * @return void |
|
| 737 | + * @throws \EE_Error |
|
| 738 | + */ |
|
| 739 | 739 | public function increase_sold( $qty = 1 ) { |
| 740 | 740 | $sold = $this->sold() + $qty; |
| 741 | 741 | // remove ticket reservation, but don't adjust datetime reservations, because that will happen |
@@ -747,13 +747,13 @@ discard block |
||
| 747 | 747 | |
| 748 | 748 | |
| 749 | 749 | |
| 750 | - /** |
|
| 751 | - * Increases sold on related datetimes |
|
| 752 | - * |
|
| 753 | - * @param int $qty |
|
| 754 | - * @return void |
|
| 755 | - * @throws \EE_Error |
|
| 756 | - */ |
|
| 750 | + /** |
|
| 751 | + * Increases sold on related datetimes |
|
| 752 | + * |
|
| 753 | + * @param int $qty |
|
| 754 | + * @return void |
|
| 755 | + * @throws \EE_Error |
|
| 756 | + */ |
|
| 757 | 757 | protected function _increase_sold_for_datetimes( $qty = 1 ) { |
| 758 | 758 | $datetimes = $this->datetimes(); |
| 759 | 759 | if ( is_array( $datetimes ) ) { |
@@ -768,13 +768,13 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | |
| 770 | 770 | |
| 771 | - /** |
|
| 772 | - * decrements (subtracts) sold by amount passed by $qty |
|
| 773 | - * |
|
| 774 | - * @param int $qty |
|
| 775 | - * @return void |
|
| 776 | - * @throws \EE_Error |
|
| 777 | - */ |
|
| 771 | + /** |
|
| 772 | + * decrements (subtracts) sold by amount passed by $qty |
|
| 773 | + * |
|
| 774 | + * @param int $qty |
|
| 775 | + * @return void |
|
| 776 | + * @throws \EE_Error |
|
| 777 | + */ |
|
| 778 | 778 | public function decrease_sold( $qty = 1 ) { |
| 779 | 779 | $sold = $this->sold() - $qty; |
| 780 | 780 | $this->_decrease_sold_for_datetimes( $qty ); |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | |
| 785 | 785 | |
| 786 | - /** |
|
| 787 | - * Decreases sold on related datetimes |
|
| 788 | - * |
|
| 789 | - * @param int $qty |
|
| 790 | - * @return void |
|
| 791 | - * @throws \EE_Error |
|
| 792 | - */ |
|
| 786 | + /** |
|
| 787 | + * Decreases sold on related datetimes |
|
| 788 | + * |
|
| 789 | + * @param int $qty |
|
| 790 | + * @return void |
|
| 791 | + * @throws \EE_Error |
|
| 792 | + */ |
|
| 793 | 793 | protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
| 794 | 794 | $datetimes = $this->datetimes(); |
| 795 | 795 | if ( is_array( $datetimes ) ) { |
@@ -804,25 +804,25 @@ discard block |
||
| 804 | 804 | |
| 805 | 805 | |
| 806 | 806 | |
| 807 | - /** |
|
| 808 | - * Gets qty of reserved tickets |
|
| 809 | - * |
|
| 810 | - * @return int |
|
| 811 | - * @throws \EE_Error |
|
| 812 | - */ |
|
| 807 | + /** |
|
| 808 | + * Gets qty of reserved tickets |
|
| 809 | + * |
|
| 810 | + * @return int |
|
| 811 | + * @throws \EE_Error |
|
| 812 | + */ |
|
| 813 | 813 | public function reserved() { |
| 814 | 814 | return $this->get_raw( 'TKT_reserved' ); |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | |
| 818 | 818 | |
| 819 | - /** |
|
| 820 | - * Sets reserved |
|
| 821 | - * |
|
| 822 | - * @param int $reserved |
|
| 823 | - * @return void |
|
| 824 | - * @throws \EE_Error |
|
| 825 | - */ |
|
| 819 | + /** |
|
| 820 | + * Sets reserved |
|
| 821 | + * |
|
| 822 | + * @param int $reserved |
|
| 823 | + * @return void |
|
| 824 | + * @throws \EE_Error |
|
| 825 | + */ |
|
| 826 | 826 | public function set_reserved( $reserved ) { |
| 827 | 827 | // reserved can not go below zero |
| 828 | 828 | $reserved = max( 0, (int) $reserved ); |
@@ -831,13 +831,13 @@ discard block |
||
| 831 | 831 | |
| 832 | 832 | |
| 833 | 833 | |
| 834 | - /** |
|
| 835 | - * increments reserved by amount passed by $qty |
|
| 836 | - * |
|
| 837 | - * @param int $qty |
|
| 838 | - * @return void |
|
| 839 | - * @throws \EE_Error |
|
| 840 | - */ |
|
| 834 | + /** |
|
| 835 | + * increments reserved by amount passed by $qty |
|
| 836 | + * |
|
| 837 | + * @param int $qty |
|
| 838 | + * @return void |
|
| 839 | + * @throws \EE_Error |
|
| 840 | + */ |
|
| 841 | 841 | public function increase_reserved( $qty = 1 ) { |
| 842 | 842 | $qty = absint( $qty ); |
| 843 | 843 | $reserved = $this->reserved() + $qty; |
@@ -847,13 +847,13 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | |
| 849 | 849 | |
| 850 | - /** |
|
| 851 | - * Increases sold on related datetimes |
|
| 852 | - * |
|
| 853 | - * @param int $qty |
|
| 854 | - * @return void |
|
| 855 | - * @throws \EE_Error |
|
| 856 | - */ |
|
| 850 | + /** |
|
| 851 | + * Increases sold on related datetimes |
|
| 852 | + * |
|
| 853 | + * @param int $qty |
|
| 854 | + * @return void |
|
| 855 | + * @throws \EE_Error |
|
| 856 | + */ |
|
| 857 | 857 | protected function _increase_reserved_for_datetimes( $qty = 1 ) { |
| 858 | 858 | $datetimes = $this->datetimes(); |
| 859 | 859 | if ( is_array( $datetimes ) ) { |
@@ -868,14 +868,14 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | |
| 870 | 870 | |
| 871 | - /** |
|
| 872 | - * decrements (subtracts) reserved by amount passed by $qty |
|
| 873 | - * |
|
| 874 | - * @param int $qty |
|
| 875 | - * @param bool $adjust_datetimes |
|
| 876 | - * @return void |
|
| 877 | - * @throws \EE_Error |
|
| 878 | - */ |
|
| 871 | + /** |
|
| 872 | + * decrements (subtracts) reserved by amount passed by $qty |
|
| 873 | + * |
|
| 874 | + * @param int $qty |
|
| 875 | + * @param bool $adjust_datetimes |
|
| 876 | + * @return void |
|
| 877 | + * @throws \EE_Error |
|
| 878 | + */ |
|
| 879 | 879 | public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) { |
| 880 | 880 | $reserved = $this->reserved() - absint( $qty ); |
| 881 | 881 | if ( $adjust_datetimes ) { |
@@ -886,13 +886,13 @@ discard block |
||
| 886 | 886 | |
| 887 | 887 | |
| 888 | 888 | |
| 889 | - /** |
|
| 890 | - * Increases sold on related datetimes |
|
| 891 | - * |
|
| 892 | - * @param int $qty |
|
| 893 | - * @return void |
|
| 894 | - * @throws \EE_Error |
|
| 895 | - */ |
|
| 889 | + /** |
|
| 890 | + * Increases sold on related datetimes |
|
| 891 | + * |
|
| 892 | + * @param int $qty |
|
| 893 | + * @return void |
|
| 894 | + * @throws \EE_Error |
|
| 895 | + */ |
|
| 896 | 896 | protected function _decrease_reserved_for_datetimes( $qty = 1 ) { |
| 897 | 897 | $datetimes = $this->datetimes(); |
| 898 | 898 | if ( is_array( $datetimes ) ) { |
@@ -907,18 +907,18 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | |
| 909 | 909 | |
| 910 | - /** |
|
| 911 | - * Gets ticket quantity |
|
| 912 | - * |
|
| 913 | - * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
| 914 | - * therefore $context can be one of three values: '', 'reg_limit', or 'saleable' |
|
| 915 | - * '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects |
|
| 916 | - * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
| 917 | - * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
| 918 | - * is therefore the truest measure of tickets that can be purchased at the moment |
|
| 919 | - * @return int |
|
| 920 | - * @throws \EE_Error |
|
| 921 | - */ |
|
| 910 | + /** |
|
| 911 | + * Gets ticket quantity |
|
| 912 | + * |
|
| 913 | + * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
| 914 | + * therefore $context can be one of three values: '', 'reg_limit', or 'saleable' |
|
| 915 | + * '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects |
|
| 916 | + * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
| 917 | + * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
| 918 | + * is therefore the truest measure of tickets that can be purchased at the moment |
|
| 919 | + * @return int |
|
| 920 | + * @throws \EE_Error |
|
| 921 | + */ |
|
| 922 | 922 | public function qty( $context = '' ) { |
| 923 | 923 | switch ( $context ) { |
| 924 | 924 | case 'reg_limit' : |
@@ -932,19 +932,19 @@ discard block |
||
| 932 | 932 | |
| 933 | 933 | |
| 934 | 934 | |
| 935 | - /** |
|
| 936 | - * Gets ticket quantity |
|
| 937 | - * |
|
| 938 | - * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
| 939 | - * therefore $context can be one of two values: 'reg_limit', or 'saleable' |
|
| 940 | - * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
| 941 | - * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
| 942 | - * is therefore the truest measure of tickets that can be purchased at the moment |
|
| 943 | - * @param int $DTT_ID the primary key for a particular datetime. |
|
| 944 | - * set to 0 for all related datetimes |
|
| 945 | - * @return int |
|
| 946 | - * @throws \EE_Error |
|
| 947 | - */ |
|
| 935 | + /** |
|
| 936 | + * Gets ticket quantity |
|
| 937 | + * |
|
| 938 | + * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
| 939 | + * therefore $context can be one of two values: 'reg_limit', or 'saleable' |
|
| 940 | + * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
| 941 | + * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
| 942 | + * is therefore the truest measure of tickets that can be purchased at the moment |
|
| 943 | + * @param int $DTT_ID the primary key for a particular datetime. |
|
| 944 | + * set to 0 for all related datetimes |
|
| 945 | + * @return int |
|
| 946 | + * @throws \EE_Error |
|
| 947 | + */ |
|
| 948 | 948 | public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) { |
| 949 | 949 | $raw = $this->get_raw( 'TKT_qty' ); |
| 950 | 950 | // return immediately if it's zero |
@@ -1027,212 +1027,212 @@ discard block |
||
| 1027 | 1027 | |
| 1028 | 1028 | |
| 1029 | 1029 | |
| 1030 | - /** |
|
| 1031 | - * Gets uses |
|
| 1032 | - * |
|
| 1033 | - * @return int |
|
| 1034 | - * @throws \EE_Error |
|
| 1035 | - */ |
|
| 1030 | + /** |
|
| 1031 | + * Gets uses |
|
| 1032 | + * |
|
| 1033 | + * @return int |
|
| 1034 | + * @throws \EE_Error |
|
| 1035 | + */ |
|
| 1036 | 1036 | public function uses() { |
| 1037 | 1037 | return $this->get( 'TKT_uses' ); |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | |
| 1041 | 1041 | |
| 1042 | - /** |
|
| 1043 | - * Sets uses |
|
| 1044 | - * |
|
| 1045 | - * @param int $uses |
|
| 1046 | - * @return void |
|
| 1047 | - * @throws \EE_Error |
|
| 1048 | - */ |
|
| 1042 | + /** |
|
| 1043 | + * Sets uses |
|
| 1044 | + * |
|
| 1045 | + * @param int $uses |
|
| 1046 | + * @return void |
|
| 1047 | + * @throws \EE_Error |
|
| 1048 | + */ |
|
| 1049 | 1049 | public function set_uses( $uses ) { |
| 1050 | 1050 | $this->set( 'TKT_uses', $uses ); |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | |
| 1054 | 1054 | |
| 1055 | - /** |
|
| 1056 | - * returns whether ticket is required or not. |
|
| 1057 | - * |
|
| 1058 | - * @return boolean |
|
| 1059 | - * @throws \EE_Error |
|
| 1060 | - */ |
|
| 1055 | + /** |
|
| 1056 | + * returns whether ticket is required or not. |
|
| 1057 | + * |
|
| 1058 | + * @return boolean |
|
| 1059 | + * @throws \EE_Error |
|
| 1060 | + */ |
|
| 1061 | 1061 | public function required() { |
| 1062 | 1062 | return $this->get( 'TKT_required' ); |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | |
| 1066 | 1066 | |
| 1067 | - /** |
|
| 1068 | - * sets the TKT_required property |
|
| 1069 | - * |
|
| 1070 | - * @param boolean $required |
|
| 1071 | - * @return void |
|
| 1072 | - * @throws \EE_Error |
|
| 1073 | - */ |
|
| 1067 | + /** |
|
| 1068 | + * sets the TKT_required property |
|
| 1069 | + * |
|
| 1070 | + * @param boolean $required |
|
| 1071 | + * @return void |
|
| 1072 | + * @throws \EE_Error |
|
| 1073 | + */ |
|
| 1074 | 1074 | public function set_required( $required ) { |
| 1075 | 1075 | $this->set( 'TKT_required', $required ); |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | 1079 | |
| 1080 | - /** |
|
| 1081 | - * Gets taxable |
|
| 1082 | - * |
|
| 1083 | - * @return boolean |
|
| 1084 | - * @throws \EE_Error |
|
| 1085 | - */ |
|
| 1080 | + /** |
|
| 1081 | + * Gets taxable |
|
| 1082 | + * |
|
| 1083 | + * @return boolean |
|
| 1084 | + * @throws \EE_Error |
|
| 1085 | + */ |
|
| 1086 | 1086 | public function taxable() { |
| 1087 | 1087 | return $this->get( 'TKT_taxable' ); |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | - /** |
|
| 1093 | - * Sets taxable |
|
| 1094 | - * |
|
| 1095 | - * @param boolean $taxable |
|
| 1096 | - * @return void |
|
| 1097 | - * @throws \EE_Error |
|
| 1098 | - */ |
|
| 1092 | + /** |
|
| 1093 | + * Sets taxable |
|
| 1094 | + * |
|
| 1095 | + * @param boolean $taxable |
|
| 1096 | + * @return void |
|
| 1097 | + * @throws \EE_Error |
|
| 1098 | + */ |
|
| 1099 | 1099 | public function set_taxable( $taxable ) { |
| 1100 | 1100 | $this->set( 'TKT_taxable', $taxable ); |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | - /** |
|
| 1106 | - * Gets is_default |
|
| 1107 | - * |
|
| 1108 | - * @return boolean |
|
| 1109 | - * @throws \EE_Error |
|
| 1110 | - */ |
|
| 1105 | + /** |
|
| 1106 | + * Gets is_default |
|
| 1107 | + * |
|
| 1108 | + * @return boolean |
|
| 1109 | + * @throws \EE_Error |
|
| 1110 | + */ |
|
| 1111 | 1111 | public function is_default() { |
| 1112 | 1112 | return $this->get( 'TKT_is_default' ); |
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | |
| 1116 | 1116 | |
| 1117 | - /** |
|
| 1118 | - * Sets is_default |
|
| 1119 | - * |
|
| 1120 | - * @param boolean $is_default |
|
| 1121 | - * @return void |
|
| 1122 | - * @throws \EE_Error |
|
| 1123 | - */ |
|
| 1117 | + /** |
|
| 1118 | + * Sets is_default |
|
| 1119 | + * |
|
| 1120 | + * @param boolean $is_default |
|
| 1121 | + * @return void |
|
| 1122 | + * @throws \EE_Error |
|
| 1123 | + */ |
|
| 1124 | 1124 | public function set_is_default( $is_default ) { |
| 1125 | 1125 | $this->set( 'TKT_is_default', $is_default ); |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | |
| 1129 | 1129 | |
| 1130 | - /** |
|
| 1131 | - * Gets order |
|
| 1132 | - * |
|
| 1133 | - * @return int |
|
| 1134 | - * @throws \EE_Error |
|
| 1135 | - */ |
|
| 1130 | + /** |
|
| 1131 | + * Gets order |
|
| 1132 | + * |
|
| 1133 | + * @return int |
|
| 1134 | + * @throws \EE_Error |
|
| 1135 | + */ |
|
| 1136 | 1136 | public function order() { |
| 1137 | 1137 | return $this->get( 'TKT_order' ); |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | |
| 1141 | 1141 | |
| 1142 | - /** |
|
| 1143 | - * Sets order |
|
| 1144 | - * |
|
| 1145 | - * @param int $order |
|
| 1146 | - * @return void |
|
| 1147 | - * @throws \EE_Error |
|
| 1148 | - */ |
|
| 1142 | + /** |
|
| 1143 | + * Sets order |
|
| 1144 | + * |
|
| 1145 | + * @param int $order |
|
| 1146 | + * @return void |
|
| 1147 | + * @throws \EE_Error |
|
| 1148 | + */ |
|
| 1149 | 1149 | public function set_order( $order ) { |
| 1150 | 1150 | $this->set( 'TKT_order', $order ); |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | |
| 1154 | 1154 | |
| 1155 | - /** |
|
| 1156 | - * Gets row |
|
| 1157 | - * |
|
| 1158 | - * @return int |
|
| 1159 | - * @throws \EE_Error |
|
| 1160 | - */ |
|
| 1155 | + /** |
|
| 1156 | + * Gets row |
|
| 1157 | + * |
|
| 1158 | + * @return int |
|
| 1159 | + * @throws \EE_Error |
|
| 1160 | + */ |
|
| 1161 | 1161 | public function row() { |
| 1162 | 1162 | return $this->get( 'TKT_row' ); |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | |
| 1166 | 1166 | |
| 1167 | - /** |
|
| 1168 | - * Sets row |
|
| 1169 | - * |
|
| 1170 | - * @param int $row |
|
| 1171 | - * @return void |
|
| 1172 | - * @throws \EE_Error |
|
| 1173 | - */ |
|
| 1167 | + /** |
|
| 1168 | + * Sets row |
|
| 1169 | + * |
|
| 1170 | + * @param int $row |
|
| 1171 | + * @return void |
|
| 1172 | + * @throws \EE_Error |
|
| 1173 | + */ |
|
| 1174 | 1174 | public function set_row( $row ) { |
| 1175 | 1175 | $this->set( 'TKT_row', $row ); |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | |
| 1179 | 1179 | |
| 1180 | - /** |
|
| 1181 | - * Gets deleted |
|
| 1182 | - * |
|
| 1183 | - * @return boolean |
|
| 1184 | - * @throws \EE_Error |
|
| 1185 | - */ |
|
| 1180 | + /** |
|
| 1181 | + * Gets deleted |
|
| 1182 | + * |
|
| 1183 | + * @return boolean |
|
| 1184 | + * @throws \EE_Error |
|
| 1185 | + */ |
|
| 1186 | 1186 | public function deleted() { |
| 1187 | 1187 | return $this->get( 'TKT_deleted' ); |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | |
| 1191 | 1191 | |
| 1192 | - /** |
|
| 1193 | - * Sets deleted |
|
| 1194 | - * |
|
| 1195 | - * @param boolean $deleted |
|
| 1196 | - * @return void |
|
| 1197 | - * @throws \EE_Error |
|
| 1198 | - */ |
|
| 1192 | + /** |
|
| 1193 | + * Sets deleted |
|
| 1194 | + * |
|
| 1195 | + * @param boolean $deleted |
|
| 1196 | + * @return void |
|
| 1197 | + * @throws \EE_Error |
|
| 1198 | + */ |
|
| 1199 | 1199 | public function set_deleted( $deleted ) { |
| 1200 | 1200 | $this->set( 'TKT_deleted', $deleted ); |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | |
| 1204 | 1204 | |
| 1205 | - /** |
|
| 1206 | - * Gets parent |
|
| 1207 | - * |
|
| 1208 | - * @return int |
|
| 1209 | - * @throws \EE_Error |
|
| 1210 | - */ |
|
| 1205 | + /** |
|
| 1206 | + * Gets parent |
|
| 1207 | + * |
|
| 1208 | + * @return int |
|
| 1209 | + * @throws \EE_Error |
|
| 1210 | + */ |
|
| 1211 | 1211 | public function parent_ID() { |
| 1212 | 1212 | return $this->get( 'TKT_parent' ); |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | |
| 1216 | 1216 | |
| 1217 | - /** |
|
| 1218 | - * Sets parent |
|
| 1219 | - * |
|
| 1220 | - * @param int $parent |
|
| 1221 | - * @return void |
|
| 1222 | - * @throws \EE_Error |
|
| 1223 | - */ |
|
| 1217 | + /** |
|
| 1218 | + * Sets parent |
|
| 1219 | + * |
|
| 1220 | + * @param int $parent |
|
| 1221 | + * @return void |
|
| 1222 | + * @throws \EE_Error |
|
| 1223 | + */ |
|
| 1224 | 1224 | public function set_parent_ID( $parent ) { |
| 1225 | 1225 | $this->set( 'TKT_parent', $parent ); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | |
| 1229 | 1229 | |
| 1230 | - /** |
|
| 1231 | - * Gets a string which is handy for showing in gateways etc that describes the ticket. |
|
| 1232 | - * |
|
| 1233 | - * @return string |
|
| 1234 | - * @throws \EE_Error |
|
| 1235 | - */ |
|
| 1230 | + /** |
|
| 1231 | + * Gets a string which is handy for showing in gateways etc that describes the ticket. |
|
| 1232 | + * |
|
| 1233 | + * @return string |
|
| 1234 | + * @throws \EE_Error |
|
| 1235 | + */ |
|
| 1236 | 1236 | public function name_and_info() { |
| 1237 | 1237 | $times = array(); |
| 1238 | 1238 | foreach ( $this->datetimes() as $datetime ) { |
@@ -1243,67 +1243,67 @@ discard block |
||
| 1243 | 1243 | |
| 1244 | 1244 | |
| 1245 | 1245 | |
| 1246 | - /** |
|
| 1247 | - * Gets name |
|
| 1248 | - * |
|
| 1249 | - * @return string |
|
| 1250 | - * @throws \EE_Error |
|
| 1251 | - */ |
|
| 1246 | + /** |
|
| 1247 | + * Gets name |
|
| 1248 | + * |
|
| 1249 | + * @return string |
|
| 1250 | + * @throws \EE_Error |
|
| 1251 | + */ |
|
| 1252 | 1252 | public function name() { |
| 1253 | 1253 | return $this->get( 'TKT_name' ); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | |
| 1257 | 1257 | |
| 1258 | - /** |
|
| 1259 | - * Gets price |
|
| 1260 | - * |
|
| 1261 | - * @return float |
|
| 1262 | - * @throws \EE_Error |
|
| 1263 | - */ |
|
| 1258 | + /** |
|
| 1259 | + * Gets price |
|
| 1260 | + * |
|
| 1261 | + * @return float |
|
| 1262 | + * @throws \EE_Error |
|
| 1263 | + */ |
|
| 1264 | 1264 | public function price() { |
| 1265 | 1265 | return $this->get( 'TKT_price' ); |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | 1269 | |
| 1270 | - /** |
|
| 1271 | - * Gets all the registrations for this ticket |
|
| 1272 | - * |
|
| 1273 | - * @param array $query_params like EEM_Base::get_all's |
|
| 1274 | - * @return EE_Registration[]|EE_Base_Class[] |
|
| 1275 | - * @throws \EE_Error |
|
| 1276 | - */ |
|
| 1270 | + /** |
|
| 1271 | + * Gets all the registrations for this ticket |
|
| 1272 | + * |
|
| 1273 | + * @param array $query_params like EEM_Base::get_all's |
|
| 1274 | + * @return EE_Registration[]|EE_Base_Class[] |
|
| 1275 | + * @throws \EE_Error |
|
| 1276 | + */ |
|
| 1277 | 1277 | public function registrations( $query_params = array() ) { |
| 1278 | 1278 | return $this->get_many_related( 'Registration', $query_params ); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | |
| 1282 | 1282 | |
| 1283 | - /** |
|
| 1284 | - * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket. |
|
| 1285 | - * into account |
|
| 1286 | - * |
|
| 1287 | - * @return int |
|
| 1288 | - * @throws \EE_Error |
|
| 1289 | - */ |
|
| 1283 | + /** |
|
| 1284 | + * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket. |
|
| 1285 | + * into account |
|
| 1286 | + * |
|
| 1287 | + * @return int |
|
| 1288 | + * @throws \EE_Error |
|
| 1289 | + */ |
|
| 1290 | 1290 | public function update_tickets_sold() { |
| 1291 | - $count_regs_for_this_ticket = $this->count_registrations( |
|
| 1292 | - array( |
|
| 1293 | - array( |
|
| 1294 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1295 | - 'REG_deleted' => 0, |
|
| 1296 | - ), |
|
| 1297 | - ) |
|
| 1298 | - ); |
|
| 1299 | - $sold = $this->sold(); |
|
| 1300 | - if ($count_regs_for_this_ticket > $sold) { |
|
| 1301 | - $this->increase_sold($count_regs_for_this_ticket - $sold); |
|
| 1302 | - $this->save(); |
|
| 1303 | - } else if ($count_regs_for_this_ticket < $sold) { |
|
| 1304 | - $this->decrease_sold($count_regs_for_this_ticket - $sold); |
|
| 1305 | - $this->save(); |
|
| 1306 | - } |
|
| 1291 | + $count_regs_for_this_ticket = $this->count_registrations( |
|
| 1292 | + array( |
|
| 1293 | + array( |
|
| 1294 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1295 | + 'REG_deleted' => 0, |
|
| 1296 | + ), |
|
| 1297 | + ) |
|
| 1298 | + ); |
|
| 1299 | + $sold = $this->sold(); |
|
| 1300 | + if ($count_regs_for_this_ticket > $sold) { |
|
| 1301 | + $this->increase_sold($count_regs_for_this_ticket - $sold); |
|
| 1302 | + $this->save(); |
|
| 1303 | + } else if ($count_regs_for_this_ticket < $sold) { |
|
| 1304 | + $this->decrease_sold($count_regs_for_this_ticket - $sold); |
|
| 1305 | + $this->save(); |
|
| 1306 | + } |
|
| 1307 | 1307 | return $count_regs_for_this_ticket; |
| 1308 | 1308 | } |
| 1309 | 1309 | |
@@ -1331,21 +1331,21 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | |
| 1333 | 1333 | |
| 1334 | - /** |
|
| 1335 | - * Implementation of the EEI_Event_Relation interface method |
|
| 1336 | - * |
|
| 1337 | - * @see EEI_Event_Relation for comments |
|
| 1338 | - * @return EE_Event |
|
| 1339 | - * @throws \EE_Error |
|
| 1340 | - * @throws UnexpectedEntityException |
|
| 1341 | - */ |
|
| 1334 | + /** |
|
| 1335 | + * Implementation of the EEI_Event_Relation interface method |
|
| 1336 | + * |
|
| 1337 | + * @see EEI_Event_Relation for comments |
|
| 1338 | + * @return EE_Event |
|
| 1339 | + * @throws \EE_Error |
|
| 1340 | + * @throws UnexpectedEntityException |
|
| 1341 | + */ |
|
| 1342 | 1342 | public function get_related_event() { |
| 1343 | 1343 | //get one datetime to use for getting the event |
| 1344 | 1344 | $datetime = $this->first_datetime(); |
| 1345 | 1345 | if ( ! $datetime instanceof \EE_Datetime ) { |
| 1346 | 1346 | throw new UnexpectedEntityException( |
| 1347 | 1347 | $datetime, |
| 1348 | - 'EE_Datetime', |
|
| 1348 | + 'EE_Datetime', |
|
| 1349 | 1349 | sprintf( |
| 1350 | 1350 | __( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
| 1351 | 1351 | $this->name() |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | if ( ! $event instanceof \EE_Event ) { |
| 1357 | 1357 | throw new UnexpectedEntityException( |
| 1358 | 1358 | $event, |
| 1359 | - 'EE_Event', |
|
| 1359 | + 'EE_Event', |
|
| 1360 | 1360 | sprintf( |
| 1361 | 1361 | __( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
| 1362 | 1362 | $this->name() |
@@ -1368,14 +1368,14 @@ discard block |
||
| 1368 | 1368 | |
| 1369 | 1369 | |
| 1370 | 1370 | |
| 1371 | - /** |
|
| 1372 | - * Implementation of the EEI_Event_Relation interface method |
|
| 1373 | - * |
|
| 1374 | - * @see EEI_Event_Relation for comments |
|
| 1375 | - * @return string |
|
| 1376 | - * @throws UnexpectedEntityException |
|
| 1377 | - * @throws \EE_Error |
|
| 1378 | - */ |
|
| 1371 | + /** |
|
| 1372 | + * Implementation of the EEI_Event_Relation interface method |
|
| 1373 | + * |
|
| 1374 | + * @see EEI_Event_Relation for comments |
|
| 1375 | + * @return string |
|
| 1376 | + * @throws UnexpectedEntityException |
|
| 1377 | + * @throws \EE_Error |
|
| 1378 | + */ |
|
| 1379 | 1379 | public function get_event_name() { |
| 1380 | 1380 | $event = $this->get_related_event(); |
| 1381 | 1381 | return $event instanceof EE_Event ? $event->name() : ''; |
@@ -1383,14 +1383,14 @@ discard block |
||
| 1383 | 1383 | |
| 1384 | 1384 | |
| 1385 | 1385 | |
| 1386 | - /** |
|
| 1387 | - * Implementation of the EEI_Event_Relation interface method |
|
| 1388 | - * |
|
| 1389 | - * @see EEI_Event_Relation for comments |
|
| 1390 | - * @return int |
|
| 1391 | - * @throws UnexpectedEntityException |
|
| 1392 | - * @throws \EE_Error |
|
| 1393 | - */ |
|
| 1386 | + /** |
|
| 1387 | + * Implementation of the EEI_Event_Relation interface method |
|
| 1388 | + * |
|
| 1389 | + * @see EEI_Event_Relation for comments |
|
| 1390 | + * @return int |
|
| 1391 | + * @throws UnexpectedEntityException |
|
| 1392 | + * @throws \EE_Error |
|
| 1393 | + */ |
|
| 1394 | 1394 | public function get_event_ID() { |
| 1395 | 1395 | $event = $this->get_related_event(); |
| 1396 | 1396 | return $event instanceof EE_Event ? $event->ID() : 0; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\exceptions\UnexpectedEntityException; |
| 2 | 2 | |
| 3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | /** |
| 7 | 7 | * Event Espresso |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * @return EE_Ticket |
| 71 | 71 | * @throws \EE_Error |
| 72 | 72 | */ |
| 73 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
| 74 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
| 75 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
| 73 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
| 74 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 75 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * @return EE_Ticket |
| 85 | 85 | * @throws \EE_Error |
| 86 | 86 | */ |
| 87 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
| 88 | - return new self( $props_n_values, TRUE, $timezone ); |
|
| 87 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
| 88 | + return new self($props_n_values, TRUE, $timezone); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @throws \EE_Error |
| 96 | 96 | */ |
| 97 | 97 | public function parent() { |
| 98 | - return $this->get( 'TKT_parent' ); |
|
| 98 | + return $this->get('TKT_parent'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | * @return boolean |
| 108 | 108 | * @throws \EE_Error |
| 109 | 109 | */ |
| 110 | - public function available( $DTT_ID = 0 ) { |
|
| 110 | + public function available($DTT_ID = 0) { |
|
| 111 | 111 | // are we checking availability for a particular datetime ? |
| 112 | - if ( $DTT_ID ) { |
|
| 112 | + if ($DTT_ID) { |
|
| 113 | 113 | // get that datetime object |
| 114 | - $datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
| 114 | + $datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID))); |
|
| 115 | 115 | // if ticket sales for this datetime have exceeded the reg limit... |
| 116 | - if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) { |
|
| 116 | + if ($datetime instanceof EE_Datetime && $datetime->sold_out()) { |
|
| 117 | 117 | return FALSE; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -131,22 +131,22 @@ discard block |
||
| 131 | 131 | * @return mixed status int if the display string isn't requested |
| 132 | 132 | * @throws \EE_Error |
| 133 | 133 | */ |
| 134 | - public function ticket_status( $display = FALSE, $remaining = null ) { |
|
| 135 | - $remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining(); |
|
| 136 | - if ( ! $remaining ) { |
|
| 137 | - return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out; |
|
| 134 | + public function ticket_status($display = FALSE, $remaining = null) { |
|
| 135 | + $remaining = is_bool($remaining) ? $remaining : $this->is_remaining(); |
|
| 136 | + if ( ! $remaining) { |
|
| 137 | + return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out; |
|
| 138 | 138 | } |
| 139 | - if ( $this->get( 'TKT_deleted' ) ) { |
|
| 140 | - return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived; |
|
| 139 | + if ($this->get('TKT_deleted')) { |
|
| 140 | + return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived; |
|
| 141 | 141 | } |
| 142 | - if ( $this->is_expired() ) { |
|
| 143 | - return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired; |
|
| 142 | + if ($this->is_expired()) { |
|
| 143 | + return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired; |
|
| 144 | 144 | } |
| 145 | - if ( $this->is_pending() ) { |
|
| 146 | - return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending; |
|
| 145 | + if ($this->is_pending()) { |
|
| 146 | + return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending; |
|
| 147 | 147 | } |
| 148 | - if ( $this->is_on_sale() ) { |
|
| 149 | - return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale; |
|
| 148 | + if ($this->is_on_sale()) { |
|
| 149 | + return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale; |
|
| 150 | 150 | } |
| 151 | 151 | return ''; |
| 152 | 152 | } |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | * @return boolean true = tickets remaining, false not. |
| 162 | 162 | * @throws \EE_Error |
| 163 | 163 | */ |
| 164 | - public function is_remaining( $DTT_ID = 0 ) { |
|
| 165 | - $num_remaining = $this->remaining( $DTT_ID ); |
|
| 166 | - if ( $num_remaining === 0 ) { |
|
| 164 | + public function is_remaining($DTT_ID = 0) { |
|
| 165 | + $num_remaining = $this->remaining($DTT_ID); |
|
| 166 | + if ($num_remaining === 0) { |
|
| 167 | 167 | return FALSE; |
| 168 | 168 | } |
| 169 | - if ( $num_remaining > 0 && $num_remaining < $this->min() ) { |
|
| 169 | + if ($num_remaining > 0 && $num_remaining < $this->min()) { |
|
| 170 | 170 | return FALSE; |
| 171 | 171 | } |
| 172 | 172 | return TRUE; |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | * @return int |
| 183 | 183 | * @throws \EE_Error |
| 184 | 184 | */ |
| 185 | - public function remaining( $DTT_ID = 0 ) { |
|
| 186 | - return $this->real_quantity_on_ticket('saleable', $DTT_ID ); |
|
| 185 | + public function remaining($DTT_ID = 0) { |
|
| 186 | + return $this->real_quantity_on_ticket('saleable', $DTT_ID); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @throws \EE_Error |
| 196 | 196 | */ |
| 197 | 197 | public function min() { |
| 198 | - return $this->get( 'TKT_min' ); |
|
| 198 | + return $this->get('TKT_min'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @throws \EE_Error |
| 208 | 208 | */ |
| 209 | 209 | public function is_expired() { |
| 210 | - return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
|
| 210 | + return ($this->get_raw('TKT_end_date') < time()); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @throws \EE_Error |
| 220 | 220 | */ |
| 221 | 221 | public function is_pending() { |
| 222 | - return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
|
| 222 | + return ($this->get_raw('TKT_start_date') > time()); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @throws \EE_Error |
| 232 | 232 | */ |
| 233 | 233 | public function is_on_sale() { |
| 234 | - return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
|
| 234 | + return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time()); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | * @return string |
| 245 | 245 | * @throws \EE_Error |
| 246 | 246 | */ |
| 247 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
| 248 | - $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
|
| 249 | - $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
|
| 247 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
| 248 | + $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : ''; |
|
| 249 | + $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : ''; |
|
| 250 | 250 | |
| 251 | - return $first_date && $last_date ? $first_date . $conjunction . $last_date : ''; |
|
| 251 | + return $first_date && $last_date ? $first_date.$conjunction.$last_date : ''; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | * @throws \EE_Error |
| 261 | 261 | */ |
| 262 | 262 | public function first_datetime() { |
| 263 | - $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
|
| 264 | - return reset( $datetimes ); |
|
| 263 | + $datetimes = $this->datetimes(array('limit' => 1)); |
|
| 264 | + return reset($datetimes); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | * @return EE_Datetime[]|EE_Base_Class[] |
| 275 | 275 | * @throws \EE_Error |
| 276 | 276 | */ |
| 277 | - public function datetimes( $query_params = array() ) { |
|
| 278 | - if ( ! isset( $query_params[ 'order_by' ] ) ) { |
|
| 279 | - $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
|
| 277 | + public function datetimes($query_params = array()) { |
|
| 278 | + if ( ! isset($query_params['order_by'])) { |
|
| 279 | + $query_params['order_by']['DTT_order'] = 'ASC'; |
|
| 280 | 280 | } |
| 281 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
| 281 | + return $this->get_many_related('Datetime', $query_params); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | * @throws \EE_Error |
| 291 | 291 | */ |
| 292 | 292 | public function last_datetime() { |
| 293 | - $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
|
| 294 | - return end( $datetimes ); |
|
| 293 | + $datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC'))); |
|
| 294 | + return end($datetimes); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -309,22 +309,22 @@ discard block |
||
| 309 | 309 | * @return mixed (array|int) how many tickets have sold |
| 310 | 310 | * @throws \EE_Error |
| 311 | 311 | */ |
| 312 | - public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
|
| 312 | + public function tickets_sold($what = 'ticket', $dtt_id = NULL) { |
|
| 313 | 313 | $total = 0; |
| 314 | 314 | $tickets_sold = $this->_all_tickets_sold(); |
| 315 | - switch ( $what ) { |
|
| 315 | + switch ($what) { |
|
| 316 | 316 | case 'ticket' : |
| 317 | - return $tickets_sold[ 'ticket' ]; |
|
| 317 | + return $tickets_sold['ticket']; |
|
| 318 | 318 | break; |
| 319 | 319 | case 'datetime' : |
| 320 | - if ( empty( $tickets_sold[ 'datetime' ] ) ) { |
|
| 320 | + if (empty($tickets_sold['datetime'])) { |
|
| 321 | 321 | return $total; |
| 322 | 322 | } |
| 323 | - if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) { |
|
| 324 | - EE_Error::add_error( __( 'You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 323 | + if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) { |
|
| 324 | + EE_Error::add_error(__('You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 325 | 325 | return $total; |
| 326 | 326 | } |
| 327 | - return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ]; |
|
| 327 | + return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id]; |
|
| 328 | 328 | break; |
| 329 | 329 | default: |
| 330 | 330 | return $total; |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | * @throws \EE_Error |
| 341 | 341 | */ |
| 342 | 342 | protected function _all_tickets_sold() { |
| 343 | - $datetimes = $this->get_many_related( 'Datetime' ); |
|
| 343 | + $datetimes = $this->get_many_related('Datetime'); |
|
| 344 | 344 | $tickets_sold = array(); |
| 345 | - if ( ! empty( $datetimes ) ) { |
|
| 346 | - foreach ( $datetimes as $datetime ) { |
|
| 347 | - $tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' ); |
|
| 345 | + if ( ! empty($datetimes)) { |
|
| 346 | + foreach ($datetimes as $datetime) { |
|
| 347 | + $tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold'); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | //Tickets sold |
| 351 | - $tickets_sold[ 'ticket' ] = $this->sold(); |
|
| 351 | + $tickets_sold['ticket'] = $this->sold(); |
|
| 352 | 352 | return $tickets_sold; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
| 362 | 362 | * @throws \EE_Error |
| 363 | 363 | */ |
| 364 | - public function base_price( $return_array = FALSE ) { |
|
| 365 | - $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
|
| 364 | + public function base_price($return_array = FALSE) { |
|
| 365 | + $_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price); |
|
| 366 | 366 | return $return_array |
| 367 | - ? $this->get_many_related( 'Price', array( $_where ) ) |
|
| 368 | - : $this->get_first_related( 'Price', array( $_where ) ); |
|
| 367 | + ? $this->get_many_related('Price', array($_where)) |
|
| 368 | + : $this->get_first_related('Price', array($_where)); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | * @throws \EE_Error |
| 379 | 379 | */ |
| 380 | 380 | public function price_modifiers() { |
| 381 | - $query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) ); |
|
| 382 | - return $this->prices( $query_params ); |
|
| 381 | + $query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax)))); |
|
| 382 | + return $this->prices($query_params); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | * @return EE_Price[]|EE_Base_Class[] |
| 392 | 392 | * @throws \EE_Error |
| 393 | 393 | */ |
| 394 | - public function prices( $query_params = array() ) { |
|
| 395 | - return $this->get_many_related( 'Price', $query_params ); |
|
| 394 | + public function prices($query_params = array()) { |
|
| 395 | + return $this->get_many_related('Price', $query_params); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @return EE_Datetime_Ticket|EE_Base_Class[] |
| 405 | 405 | * @throws \EE_Error |
| 406 | 406 | */ |
| 407 | - public function datetime_tickets( $query_params = array() ) { |
|
| 408 | - return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
|
| 407 | + public function datetime_tickets($query_params = array()) { |
|
| 408 | + return $this->get_many_related('Datetime_Ticket', $query_params); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | * @return EE_Datetime[] |
| 419 | 419 | * @throws \EE_Error |
| 420 | 420 | */ |
| 421 | - public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
|
| 422 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
|
| 421 | + public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) { |
|
| 422 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * @throws \EE_Error |
| 432 | 432 | */ |
| 433 | 433 | public function ID() { |
| 434 | - return $this->get( 'TKT_ID' ); |
|
| 434 | + return $this->get('TKT_ID'); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @throws \EE_Error |
| 457 | 457 | */ |
| 458 | 458 | public function template() { |
| 459 | - return $this->get_first_related( 'Ticket_Template' ); |
|
| 459 | + return $this->get_first_related('Ticket_Template'); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @throws \EE_Error |
| 479 | 479 | */ |
| 480 | 480 | public function ticket_price() { |
| 481 | - return $this->get( 'TKT_price' ); |
|
| 481 | + return $this->get('TKT_price'); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @throws \EE_Error |
| 489 | 489 | */ |
| 490 | 490 | public function pretty_price() { |
| 491 | - return $this->get_pretty( 'TKT_price' ); |
|
| 491 | + return $this->get_pretty('TKT_price'); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
@@ -510,8 +510,8 @@ discard block |
||
| 510 | 510 | * @return float |
| 511 | 511 | * @throws \EE_Error |
| 512 | 512 | */ |
| 513 | - public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
|
| 514 | - if ($this->_ticket_total_with_taxes === null || $no_cache ) { |
|
| 513 | + public function get_ticket_total_with_taxes($no_cache = FALSE) { |
|
| 514 | + if ($this->_ticket_total_with_taxes === null || $no_cache) { |
|
| 515 | 515 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
| 516 | 516 | } |
| 517 | 517 | return (float) $this->_ticket_total_with_taxes; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | |
| 521 | 521 | |
| 522 | 522 | public function ensure_TKT_Price_correct() { |
| 523 | - $this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) ); |
|
| 523 | + $this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this)); |
|
| 524 | 524 | $this->save(); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * @throws \EE_Error |
| 532 | 532 | */ |
| 533 | 533 | public function get_ticket_subtotal() { |
| 534 | - return EE_Taxes::get_subtotal_for_admin( $this ); |
|
| 534 | + return EE_Taxes::get_subtotal_for_admin($this); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @throws \EE_Error |
| 544 | 544 | */ |
| 545 | 545 | public function get_ticket_taxes_total_for_admin() { |
| 546 | - return EE_Taxes::get_total_taxes_for_admin( $this ); |
|
| 546 | + return EE_Taxes::get_total_taxes_for_admin($this); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | |
@@ -554,8 +554,8 @@ discard block |
||
| 554 | 554 | * @param string $name |
| 555 | 555 | * @throws \EE_Error |
| 556 | 556 | */ |
| 557 | - public function set_name( $name ) { |
|
| 558 | - $this->set( 'TKT_name', $name ); |
|
| 557 | + public function set_name($name) { |
|
| 558 | + $this->set('TKT_name', $name); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | * @throws \EE_Error |
| 568 | 568 | */ |
| 569 | 569 | public function description() { |
| 570 | - return $this->get( 'TKT_description' ); |
|
| 570 | + return $this->get('TKT_description'); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | |
@@ -578,8 +578,8 @@ discard block |
||
| 578 | 578 | * @param string $description |
| 579 | 579 | * @throws \EE_Error |
| 580 | 580 | */ |
| 581 | - public function set_description( $description ) { |
|
| 582 | - $this->set( 'TKT_description', $description ); |
|
| 581 | + public function set_description($description) { |
|
| 582 | + $this->set('TKT_description', $description); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
@@ -592,8 +592,8 @@ discard block |
||
| 592 | 592 | * @return string |
| 593 | 593 | * @throws \EE_Error |
| 594 | 594 | */ |
| 595 | - public function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
| 596 | - return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
|
| 595 | + public function start_date($dt_frmt = '', $tm_frmt = '') { |
|
| 596 | + return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | |
@@ -605,8 +605,8 @@ discard block |
||
| 605 | 605 | * @return void |
| 606 | 606 | * @throws \EE_Error |
| 607 | 607 | */ |
| 608 | - public function set_start_date( $start_date ) { |
|
| 609 | - $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
|
| 608 | + public function set_start_date($start_date) { |
|
| 609 | + $this->_set_date_time('B', $start_date, 'TKT_start_date'); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | * @return string |
| 620 | 620 | * @throws \EE_Error |
| 621 | 621 | */ |
| 622 | - public function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
| 623 | - return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
|
| 622 | + public function end_date($dt_frmt = '', $tm_frmt = '') { |
|
| 623 | + return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | |
@@ -632,8 +632,8 @@ discard block |
||
| 632 | 632 | * @return void |
| 633 | 633 | * @throws \EE_Error |
| 634 | 634 | */ |
| 635 | - public function set_end_date( $end_date ) { |
|
| 636 | - $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
|
| 635 | + public function set_end_date($end_date) { |
|
| 636 | + $this->_set_date_time('B', $end_date, 'TKT_end_date'); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | |
@@ -645,8 +645,8 @@ discard block |
||
| 645 | 645 | * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
| 646 | 646 | * @throws \EE_Error |
| 647 | 647 | */ |
| 648 | - public function set_end_time( $time ) { |
|
| 649 | - $this->_set_time_for( $time, 'TKT_end_date' ); |
|
| 648 | + public function set_end_time($time) { |
|
| 649 | + $this->_set_time_for($time, 'TKT_end_date'); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | |
@@ -658,8 +658,8 @@ discard block |
||
| 658 | 658 | * @return void |
| 659 | 659 | * @throws \EE_Error |
| 660 | 660 | */ |
| 661 | - public function set_min( $min ) { |
|
| 662 | - $this->set( 'TKT_min', $min ); |
|
| 661 | + public function set_min($min) { |
|
| 662 | + $this->set('TKT_min', $min); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | * @throws \EE_Error |
| 672 | 672 | */ |
| 673 | 673 | public function max() { |
| 674 | - return $this->get( 'TKT_max' ); |
|
| 674 | + return $this->get('TKT_max'); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | * @return void |
| 684 | 684 | * @throws \EE_Error |
| 685 | 685 | */ |
| 686 | - public function set_max( $max ) { |
|
| 687 | - $this->set( 'TKT_max', $max ); |
|
| 686 | + public function set_max($max) { |
|
| 687 | + $this->set('TKT_max', $max); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | * @return void |
| 697 | 697 | * @throws \EE_Error |
| 698 | 698 | */ |
| 699 | - public function set_price( $price ) { |
|
| 700 | - $this->set( 'TKT_price', $price ); |
|
| 699 | + public function set_price($price) { |
|
| 700 | + $this->set('TKT_price', $price); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | * @throws \EE_Error |
| 710 | 710 | */ |
| 711 | 711 | public function sold() { |
| 712 | - return $this->get_raw( 'TKT_sold' ); |
|
| 712 | + return $this->get_raw('TKT_sold'); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | |
@@ -721,10 +721,10 @@ discard block |
||
| 721 | 721 | * @return void |
| 722 | 722 | * @throws \EE_Error |
| 723 | 723 | */ |
| 724 | - public function set_sold( $sold ) { |
|
| 724 | + public function set_sold($sold) { |
|
| 725 | 725 | // sold can not go below zero |
| 726 | - $sold = max( 0, $sold ); |
|
| 727 | - $this->set( 'TKT_sold', $sold ); |
|
| 726 | + $sold = max(0, $sold); |
|
| 727 | + $this->set('TKT_sold', $sold); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | |
@@ -736,13 +736,13 @@ discard block |
||
| 736 | 736 | * @return void |
| 737 | 737 | * @throws \EE_Error |
| 738 | 738 | */ |
| 739 | - public function increase_sold( $qty = 1 ) { |
|
| 739 | + public function increase_sold($qty = 1) { |
|
| 740 | 740 | $sold = $this->sold() + $qty; |
| 741 | 741 | // remove ticket reservation, but don't adjust datetime reservations, because that will happen |
| 742 | 742 | // via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called |
| 743 | - $this->decrease_reserved( $qty, false ); |
|
| 744 | - $this->_increase_sold_for_datetimes( $qty ); |
|
| 745 | - $this->set_sold( $sold ); |
|
| 743 | + $this->decrease_reserved($qty, false); |
|
| 744 | + $this->_increase_sold_for_datetimes($qty); |
|
| 745 | + $this->set_sold($sold); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | |
@@ -754,12 +754,12 @@ discard block |
||
| 754 | 754 | * @return void |
| 755 | 755 | * @throws \EE_Error |
| 756 | 756 | */ |
| 757 | - protected function _increase_sold_for_datetimes( $qty = 1 ) { |
|
| 757 | + protected function _increase_sold_for_datetimes($qty = 1) { |
|
| 758 | 758 | $datetimes = $this->datetimes(); |
| 759 | - if ( is_array( $datetimes ) ) { |
|
| 760 | - foreach ( $datetimes as $datetime ) { |
|
| 761 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 762 | - $datetime->increase_sold( $qty ); |
|
| 759 | + if (is_array($datetimes)) { |
|
| 760 | + foreach ($datetimes as $datetime) { |
|
| 761 | + if ($datetime instanceof EE_Datetime) { |
|
| 762 | + $datetime->increase_sold($qty); |
|
| 763 | 763 | $datetime->save(); |
| 764 | 764 | } |
| 765 | 765 | } |
@@ -775,10 +775,10 @@ discard block |
||
| 775 | 775 | * @return void |
| 776 | 776 | * @throws \EE_Error |
| 777 | 777 | */ |
| 778 | - public function decrease_sold( $qty = 1 ) { |
|
| 778 | + public function decrease_sold($qty = 1) { |
|
| 779 | 779 | $sold = $this->sold() - $qty; |
| 780 | - $this->_decrease_sold_for_datetimes( $qty ); |
|
| 781 | - $this->set_sold( $sold ); |
|
| 780 | + $this->_decrease_sold_for_datetimes($qty); |
|
| 781 | + $this->set_sold($sold); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | |
@@ -790,12 +790,12 @@ discard block |
||
| 790 | 790 | * @return void |
| 791 | 791 | * @throws \EE_Error |
| 792 | 792 | */ |
| 793 | - protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
|
| 793 | + protected function _decrease_sold_for_datetimes($qty = 1) { |
|
| 794 | 794 | $datetimes = $this->datetimes(); |
| 795 | - if ( is_array( $datetimes ) ) { |
|
| 796 | - foreach ( $datetimes as $datetime ) { |
|
| 797 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 798 | - $datetime->decrease_sold( $qty ); |
|
| 795 | + if (is_array($datetimes)) { |
|
| 796 | + foreach ($datetimes as $datetime) { |
|
| 797 | + if ($datetime instanceof EE_Datetime) { |
|
| 798 | + $datetime->decrease_sold($qty); |
|
| 799 | 799 | $datetime->save(); |
| 800 | 800 | } |
| 801 | 801 | } |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | * @throws \EE_Error |
| 812 | 812 | */ |
| 813 | 813 | public function reserved() { |
| 814 | - return $this->get_raw( 'TKT_reserved' ); |
|
| 814 | + return $this->get_raw('TKT_reserved'); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | |
@@ -823,10 +823,10 @@ discard block |
||
| 823 | 823 | * @return void |
| 824 | 824 | * @throws \EE_Error |
| 825 | 825 | */ |
| 826 | - public function set_reserved( $reserved ) { |
|
| 826 | + public function set_reserved($reserved) { |
|
| 827 | 827 | // reserved can not go below zero |
| 828 | - $reserved = max( 0, (int) $reserved ); |
|
| 829 | - $this->set( 'TKT_reserved', $reserved ); |
|
| 828 | + $reserved = max(0, (int) $reserved); |
|
| 829 | + $this->set('TKT_reserved', $reserved); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | |
@@ -838,11 +838,11 @@ discard block |
||
| 838 | 838 | * @return void |
| 839 | 839 | * @throws \EE_Error |
| 840 | 840 | */ |
| 841 | - public function increase_reserved( $qty = 1 ) { |
|
| 842 | - $qty = absint( $qty ); |
|
| 841 | + public function increase_reserved($qty = 1) { |
|
| 842 | + $qty = absint($qty); |
|
| 843 | 843 | $reserved = $this->reserved() + $qty; |
| 844 | - $this->_increase_reserved_for_datetimes( $qty ); |
|
| 845 | - $this->set_reserved( $reserved ); |
|
| 844 | + $this->_increase_reserved_for_datetimes($qty); |
|
| 845 | + $this->set_reserved($reserved); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | |
@@ -854,12 +854,12 @@ discard block |
||
| 854 | 854 | * @return void |
| 855 | 855 | * @throws \EE_Error |
| 856 | 856 | */ |
| 857 | - protected function _increase_reserved_for_datetimes( $qty = 1 ) { |
|
| 857 | + protected function _increase_reserved_for_datetimes($qty = 1) { |
|
| 858 | 858 | $datetimes = $this->datetimes(); |
| 859 | - if ( is_array( $datetimes ) ) { |
|
| 860 | - foreach ( $datetimes as $datetime ) { |
|
| 861 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 862 | - $datetime->increase_reserved( $qty ); |
|
| 859 | + if (is_array($datetimes)) { |
|
| 860 | + foreach ($datetimes as $datetime) { |
|
| 861 | + if ($datetime instanceof EE_Datetime) { |
|
| 862 | + $datetime->increase_reserved($qty); |
|
| 863 | 863 | $datetime->save(); |
| 864 | 864 | } |
| 865 | 865 | } |
@@ -876,12 +876,12 @@ discard block |
||
| 876 | 876 | * @return void |
| 877 | 877 | * @throws \EE_Error |
| 878 | 878 | */ |
| 879 | - public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) { |
|
| 880 | - $reserved = $this->reserved() - absint( $qty ); |
|
| 881 | - if ( $adjust_datetimes ) { |
|
| 882 | - $this->_decrease_reserved_for_datetimes( $qty ); |
|
| 879 | + public function decrease_reserved($qty = 1, $adjust_datetimes = true) { |
|
| 880 | + $reserved = $this->reserved() - absint($qty); |
|
| 881 | + if ($adjust_datetimes) { |
|
| 882 | + $this->_decrease_reserved_for_datetimes($qty); |
|
| 883 | 883 | } |
| 884 | - $this->set_reserved( $reserved ); |
|
| 884 | + $this->set_reserved($reserved); |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | |
@@ -893,12 +893,12 @@ discard block |
||
| 893 | 893 | * @return void |
| 894 | 894 | * @throws \EE_Error |
| 895 | 895 | */ |
| 896 | - protected function _decrease_reserved_for_datetimes( $qty = 1 ) { |
|
| 896 | + protected function _decrease_reserved_for_datetimes($qty = 1) { |
|
| 897 | 897 | $datetimes = $this->datetimes(); |
| 898 | - if ( is_array( $datetimes ) ) { |
|
| 899 | - foreach ( $datetimes as $datetime ) { |
|
| 900 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 901 | - $datetime->decrease_reserved( $qty ); |
|
| 898 | + if (is_array($datetimes)) { |
|
| 899 | + foreach ($datetimes as $datetime) { |
|
| 900 | + if ($datetime instanceof EE_Datetime) { |
|
| 901 | + $datetime->decrease_reserved($qty); |
|
| 902 | 902 | $datetime->save(); |
| 903 | 903 | } |
| 904 | 904 | } |
@@ -919,14 +919,14 @@ discard block |
||
| 919 | 919 | * @return int |
| 920 | 920 | * @throws \EE_Error |
| 921 | 921 | */ |
| 922 | - public function qty( $context = '' ) { |
|
| 923 | - switch ( $context ) { |
|
| 922 | + public function qty($context = '') { |
|
| 923 | + switch ($context) { |
|
| 924 | 924 | case 'reg_limit' : |
| 925 | 925 | return $this->real_quantity_on_ticket(); |
| 926 | 926 | case 'saleable' : |
| 927 | - return $this->real_quantity_on_ticket( 'saleable' ); |
|
| 927 | + return $this->real_quantity_on_ticket('saleable'); |
|
| 928 | 928 | default: |
| 929 | - return $this->get_raw( 'TKT_qty' ); |
|
| 929 | + return $this->get_raw('TKT_qty'); |
|
| 930 | 930 | } |
| 931 | 931 | } |
| 932 | 932 | |
@@ -945,15 +945,15 @@ discard block |
||
| 945 | 945 | * @return int |
| 946 | 946 | * @throws \EE_Error |
| 947 | 947 | */ |
| 948 | - public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) { |
|
| 949 | - $raw = $this->get_raw( 'TKT_qty' ); |
|
| 948 | + public function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) { |
|
| 949 | + $raw = $this->get_raw('TKT_qty'); |
|
| 950 | 950 | // return immediately if it's zero |
| 951 | - if ( $raw === 0 ) { |
|
| 951 | + if ($raw === 0) { |
|
| 952 | 952 | return $raw; |
| 953 | 953 | } |
| 954 | 954 | //echo "\n\n<br />Ticket: " . $this->name() . '<br />'; |
| 955 | 955 | // ensure qty doesn't exceed raw value for THIS ticket |
| 956 | - $qty = min( EE_INF, $raw ); |
|
| 956 | + $qty = min(EE_INF, $raw); |
|
| 957 | 957 | //echo "\n . qty: " . $qty . '<br />'; |
| 958 | 958 | // calculate this ticket's total sales and reservations |
| 959 | 959 | $sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved(); |
@@ -962,23 +962,23 @@ discard block |
||
| 962 | 962 | //echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />'; |
| 963 | 963 | // first we need to calculate the maximum number of tickets available for the datetime |
| 964 | 964 | // do we want data for one datetime or all of them ? |
| 965 | - $query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array(); |
|
| 966 | - $datetimes = $this->datetimes( $query_params ); |
|
| 967 | - if ( is_array( $datetimes ) && ! empty( $datetimes ) ) { |
|
| 968 | - foreach ( $datetimes as $datetime ) { |
|
| 969 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 965 | + $query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array(); |
|
| 966 | + $datetimes = $this->datetimes($query_params); |
|
| 967 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
| 968 | + foreach ($datetimes as $datetime) { |
|
| 969 | + if ($datetime instanceof EE_Datetime) { |
|
| 970 | 970 | $datetime->refresh_from_db(); |
| 971 | 971 | //echo "\n . . datetime name: " . $datetime->name() . '<br />'; |
| 972 | 972 | //echo "\n . . datetime ID: " . $datetime->ID() . '<br />'; |
| 973 | 973 | // initialize with no restrictions for each datetime |
| 974 | 974 | // but adjust datetime qty based on datetime reg limit |
| 975 | - $datetime_qty = min( EE_INF, $datetime->reg_limit() ); |
|
| 975 | + $datetime_qty = min(EE_INF, $datetime->reg_limit()); |
|
| 976 | 976 | //echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />'; |
| 977 | 977 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
| 978 | 978 | // if we want the actual saleable amount, then we need to consider OTHER ticket sales |
| 979 | 979 | // and reservations for this datetime, that do NOT include sales and reservations |
| 980 | 980 | // for this ticket (so we add $this->sold() and $this->reserved() back in) |
| 981 | - if ( $context === 'saleable' ) { |
|
| 981 | + if ($context === 'saleable') { |
|
| 982 | 982 | $datetime_qty = max( |
| 983 | 983 | $datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket, |
| 984 | 984 | 0 |
@@ -990,16 +990,16 @@ discard block |
||
| 990 | 990 | $datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0; |
| 991 | 991 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
| 992 | 992 | } |
| 993 | - $qty = min( $datetime_qty, $qty ); |
|
| 993 | + $qty = min($datetime_qty, $qty); |
|
| 994 | 994 | //echo "\n . . qty: " . $qty . '<br />'; |
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | 998 | // NOW that we know the maximum number of tickets available for the datetime |
| 999 | 999 | // we can finally factor in the details for this specific ticket |
| 1000 | - if ( $qty > 0 && $context === 'saleable' ) { |
|
| 1000 | + if ($qty > 0 && $context === 'saleable') { |
|
| 1001 | 1001 | // and subtract the sales for THIS ticket |
| 1002 | - $qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 ); |
|
| 1002 | + $qty = max($qty - $sold_and_reserved_for_this_ticket, 0); |
|
| 1003 | 1003 | //echo "\n . qty: " . $qty . '<br />'; |
| 1004 | 1004 | } |
| 1005 | 1005 | //echo "\nFINAL QTY: " . $qty . "<br /><br />"; |
@@ -1015,14 +1015,14 @@ discard block |
||
| 1015 | 1015 | * @return void |
| 1016 | 1016 | * @throws \EE_Error |
| 1017 | 1017 | */ |
| 1018 | - public function set_qty( $qty ) { |
|
| 1018 | + public function set_qty($qty) { |
|
| 1019 | 1019 | $datetimes = $this->datetimes(); |
| 1020 | - foreach ( $datetimes as $datetime ) { |
|
| 1021 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 1022 | - $qty = min( $qty, $datetime->reg_limit() ); |
|
| 1020 | + foreach ($datetimes as $datetime) { |
|
| 1021 | + if ($datetime instanceof EE_Datetime) { |
|
| 1022 | + $qty = min($qty, $datetime->reg_limit()); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | - $this->set( 'TKT_qty', $qty ); |
|
| 1025 | + $this->set('TKT_qty', $qty); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | * @throws \EE_Error |
| 1035 | 1035 | */ |
| 1036 | 1036 | public function uses() { |
| 1037 | - return $this->get( 'TKT_uses' ); |
|
| 1037 | + return $this->get('TKT_uses'); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | |
@@ -1046,8 +1046,8 @@ discard block |
||
| 1046 | 1046 | * @return void |
| 1047 | 1047 | * @throws \EE_Error |
| 1048 | 1048 | */ |
| 1049 | - public function set_uses( $uses ) { |
|
| 1050 | - $this->set( 'TKT_uses', $uses ); |
|
| 1049 | + public function set_uses($uses) { |
|
| 1050 | + $this->set('TKT_uses', $uses); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | * @throws \EE_Error |
| 1060 | 1060 | */ |
| 1061 | 1061 | public function required() { |
| 1062 | - return $this->get( 'TKT_required' ); |
|
| 1062 | + return $this->get('TKT_required'); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | |
@@ -1071,8 +1071,8 @@ discard block |
||
| 1071 | 1071 | * @return void |
| 1072 | 1072 | * @throws \EE_Error |
| 1073 | 1073 | */ |
| 1074 | - public function set_required( $required ) { |
|
| 1075 | - $this->set( 'TKT_required', $required ); |
|
| 1074 | + public function set_required($required) { |
|
| 1075 | + $this->set('TKT_required', $required); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | * @throws \EE_Error |
| 1085 | 1085 | */ |
| 1086 | 1086 | public function taxable() { |
| 1087 | - return $this->get( 'TKT_taxable' ); |
|
| 1087 | + return $this->get('TKT_taxable'); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | |
@@ -1096,8 +1096,8 @@ discard block |
||
| 1096 | 1096 | * @return void |
| 1097 | 1097 | * @throws \EE_Error |
| 1098 | 1098 | */ |
| 1099 | - public function set_taxable( $taxable ) { |
|
| 1100 | - $this->set( 'TKT_taxable', $taxable ); |
|
| 1099 | + public function set_taxable($taxable) { |
|
| 1100 | + $this->set('TKT_taxable', $taxable); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | * @throws \EE_Error |
| 1110 | 1110 | */ |
| 1111 | 1111 | public function is_default() { |
| 1112 | - return $this->get( 'TKT_is_default' ); |
|
| 1112 | + return $this->get('TKT_is_default'); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | |
@@ -1121,8 +1121,8 @@ discard block |
||
| 1121 | 1121 | * @return void |
| 1122 | 1122 | * @throws \EE_Error |
| 1123 | 1123 | */ |
| 1124 | - public function set_is_default( $is_default ) { |
|
| 1125 | - $this->set( 'TKT_is_default', $is_default ); |
|
| 1124 | + public function set_is_default($is_default) { |
|
| 1125 | + $this->set('TKT_is_default', $is_default); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | * @throws \EE_Error |
| 1135 | 1135 | */ |
| 1136 | 1136 | public function order() { |
| 1137 | - return $this->get( 'TKT_order' ); |
|
| 1137 | + return $this->get('TKT_order'); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | |
@@ -1146,8 +1146,8 @@ discard block |
||
| 1146 | 1146 | * @return void |
| 1147 | 1147 | * @throws \EE_Error |
| 1148 | 1148 | */ |
| 1149 | - public function set_order( $order ) { |
|
| 1150 | - $this->set( 'TKT_order', $order ); |
|
| 1149 | + public function set_order($order) { |
|
| 1150 | + $this->set('TKT_order', $order); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | * @throws \EE_Error |
| 1160 | 1160 | */ |
| 1161 | 1161 | public function row() { |
| 1162 | - return $this->get( 'TKT_row' ); |
|
| 1162 | + return $this->get('TKT_row'); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | |
@@ -1171,8 +1171,8 @@ discard block |
||
| 1171 | 1171 | * @return void |
| 1172 | 1172 | * @throws \EE_Error |
| 1173 | 1173 | */ |
| 1174 | - public function set_row( $row ) { |
|
| 1175 | - $this->set( 'TKT_row', $row ); |
|
| 1174 | + public function set_row($row) { |
|
| 1175 | + $this->set('TKT_row', $row); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | * @throws \EE_Error |
| 1185 | 1185 | */ |
| 1186 | 1186 | public function deleted() { |
| 1187 | - return $this->get( 'TKT_deleted' ); |
|
| 1187 | + return $this->get('TKT_deleted'); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | |
@@ -1196,8 +1196,8 @@ discard block |
||
| 1196 | 1196 | * @return void |
| 1197 | 1197 | * @throws \EE_Error |
| 1198 | 1198 | */ |
| 1199 | - public function set_deleted( $deleted ) { |
|
| 1200 | - $this->set( 'TKT_deleted', $deleted ); |
|
| 1199 | + public function set_deleted($deleted) { |
|
| 1200 | + $this->set('TKT_deleted', $deleted); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | * @throws \EE_Error |
| 1210 | 1210 | */ |
| 1211 | 1211 | public function parent_ID() { |
| 1212 | - return $this->get( 'TKT_parent' ); |
|
| 1212 | + return $this->get('TKT_parent'); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | * @return void |
| 1222 | 1222 | * @throws \EE_Error |
| 1223 | 1223 | */ |
| 1224 | - public function set_parent_ID( $parent ) { |
|
| 1225 | - $this->set( 'TKT_parent', $parent ); |
|
| 1224 | + public function set_parent_ID($parent) { |
|
| 1225 | + $this->set('TKT_parent', $parent); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | |
@@ -1235,10 +1235,10 @@ discard block |
||
| 1235 | 1235 | */ |
| 1236 | 1236 | public function name_and_info() { |
| 1237 | 1237 | $times = array(); |
| 1238 | - foreach ( $this->datetimes() as $datetime ) { |
|
| 1238 | + foreach ($this->datetimes() as $datetime) { |
|
| 1239 | 1239 | $times[] = $datetime->start_date_and_time(); |
| 1240 | 1240 | } |
| 1241 | - return $this->name() . ' @ ' . implode( ', ', $times ) . ' for ' . $this->pretty_price(); |
|
| 1241 | + return $this->name().' @ '.implode(', ', $times).' for '.$this->pretty_price(); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | * @throws \EE_Error |
| 1251 | 1251 | */ |
| 1252 | 1252 | public function name() { |
| 1253 | - return $this->get( 'TKT_name' ); |
|
| 1253 | + return $this->get('TKT_name'); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | * @throws \EE_Error |
| 1263 | 1263 | */ |
| 1264 | 1264 | public function price() { |
| 1265 | - return $this->get( 'TKT_price' ); |
|
| 1265 | + return $this->get('TKT_price'); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | |
@@ -1274,8 +1274,8 @@ discard block |
||
| 1274 | 1274 | * @return EE_Registration[]|EE_Base_Class[] |
| 1275 | 1275 | * @throws \EE_Error |
| 1276 | 1276 | */ |
| 1277 | - public function registrations( $query_params = array() ) { |
|
| 1278 | - return $this->get_many_related( 'Registration', $query_params ); |
|
| 1277 | + public function registrations($query_params = array()) { |
|
| 1278 | + return $this->get_many_related('Registration', $query_params); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | * @param array $query_params like EEM_Base::get_all's |
| 1315 | 1315 | * @return int |
| 1316 | 1316 | */ |
| 1317 | - public function count_registrations( $query_params = array() ) { |
|
| 1317 | + public function count_registrations($query_params = array()) { |
|
| 1318 | 1318 | return $this->count_related('Registration', $query_params); |
| 1319 | 1319 | } |
| 1320 | 1320 | |
@@ -1342,23 +1342,23 @@ discard block |
||
| 1342 | 1342 | public function get_related_event() { |
| 1343 | 1343 | //get one datetime to use for getting the event |
| 1344 | 1344 | $datetime = $this->first_datetime(); |
| 1345 | - if ( ! $datetime instanceof \EE_Datetime ) { |
|
| 1345 | + if ( ! $datetime instanceof \EE_Datetime) { |
|
| 1346 | 1346 | throw new UnexpectedEntityException( |
| 1347 | 1347 | $datetime, |
| 1348 | 1348 | 'EE_Datetime', |
| 1349 | 1349 | sprintf( |
| 1350 | - __( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
|
| 1350 | + __('The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
|
| 1351 | 1351 | $this->name() |
| 1352 | 1352 | ) |
| 1353 | 1353 | ); |
| 1354 | 1354 | } |
| 1355 | 1355 | $event = $datetime->event(); |
| 1356 | - if ( ! $event instanceof \EE_Event ) { |
|
| 1356 | + if ( ! $event instanceof \EE_Event) { |
|
| 1357 | 1357 | throw new UnexpectedEntityException( |
| 1358 | 1358 | $event, |
| 1359 | 1359 | 'EE_Event', |
| 1360 | 1360 | sprintf( |
| 1361 | - __( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
|
| 1361 | + __('The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
|
| 1362 | 1362 | $this->name() |
| 1363 | 1363 | ) |
| 1364 | 1364 | ); |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * get event start date. Provide either the date format, or NULL to re-use the |
|
| 363 | - * last-used format, or '' to use the default date format |
|
| 364 | - * |
|
| 365 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 366 | - * @return mixed string on success, FALSE on fail |
|
| 367 | - */ |
|
| 361 | + /** |
|
| 362 | + * get event start date. Provide either the date format, or NULL to re-use the |
|
| 363 | + * last-used format, or '' to use the default date format |
|
| 364 | + * |
|
| 365 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 366 | + * @return mixed string on success, FALSE on fail |
|
| 367 | + */ |
|
| 368 | 368 | public function start_date( $dt_frmt = '' ) { |
| 369 | 369 | return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
| 370 | 370 | } |
@@ -381,13 +381,13 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | |
| 384 | - /** |
|
| 385 | - * get end date. Provide either the date format, or NULL to re-use the |
|
| 386 | - * last-used format, or '' to use the default date format |
|
| 387 | - * |
|
| 388 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 389 | - * @return mixed string on success, FALSE on fail |
|
| 390 | - */ |
|
| 384 | + /** |
|
| 385 | + * get end date. Provide either the date format, or NULL to re-use the |
|
| 386 | + * last-used format, or '' to use the default date format |
|
| 387 | + * |
|
| 388 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 389 | + * @return mixed string on success, FALSE on fail |
|
| 390 | + */ |
|
| 391 | 391 | public function end_date( $dt_frmt = '' ) { |
| 392 | 392 | return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
| 393 | 393 | } |
@@ -509,23 +509,23 @@ discard block |
||
| 509 | 509 | /** |
| 510 | 510 | * This returns a range representation of the date and times. |
| 511 | 511 | * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end. |
| 512 | - * Also, the return value is localized. |
|
| 513 | - * |
|
| 514 | - * @param string $dt_format |
|
| 512 | + * Also, the return value is localized. |
|
| 513 | + * |
|
| 514 | + * @param string $dt_format |
|
| 515 | 515 | * @param string $tm_format |
| 516 | 516 | * @param string $conjunction used between two different dates or times. |
| 517 | - * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
| 518 | - * @param string $separator used between the date and time formats. |
|
| 519 | - * ex: Dec 1, 2016{$separator}2pm |
|
| 517 | + * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
| 518 | + * @param string $separator used between the date and time formats. |
|
| 519 | + * ex: Dec 1, 2016{$separator}2pm |
|
| 520 | 520 | * @return string |
| 521 | 521 | * @throws \EE_Error |
| 522 | 522 | */ |
| 523 | 523 | public function date_and_time_range( |
| 524 | - $dt_format = '', |
|
| 525 | - $tm_format = '', |
|
| 526 | - $conjunction = ' - ' , |
|
| 527 | - $separator = ' ' |
|
| 528 | - ) { |
|
| 524 | + $dt_format = '', |
|
| 525 | + $tm_format = '', |
|
| 526 | + $conjunction = ' - ' , |
|
| 527 | + $separator = ' ' |
|
| 528 | + ) { |
|
| 529 | 529 | $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
| 530 | 530 | $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
| 531 | 531 | $full_format = $dt_format . $separator . $tm_format; |
@@ -539,14 +539,14 @@ discard block |
||
| 539 | 539 | //start and end date are the same but times are different |
| 540 | 540 | case ( $this->start_date() === $this->end_date() ) : |
| 541 | 541 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
| 542 | - . $conjunction |
|
| 543 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 542 | + . $conjunction |
|
| 543 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 544 | 544 | break; |
| 545 | 545 | //all other conditions |
| 546 | 546 | default : |
| 547 | 547 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
| 548 | - . $conjunction |
|
| 549 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 548 | + . $conjunction |
|
| 549 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 550 | 550 | break; |
| 551 | 551 | } |
| 552 | 552 | return $output; |
@@ -630,13 +630,13 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | - * get end date and time |
|
| 634 | - * |
|
| 635 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 636 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
| 637 | - * @return mixed string on success, FALSE on fail |
|
| 638 | - */ |
|
| 639 | - public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 633 | + * get end date and time |
|
| 634 | + * |
|
| 635 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
| 636 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
| 637 | + * @return mixed string on success, FALSE on fail |
|
| 638 | + */ |
|
| 639 | + public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 640 | 640 | return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
| 641 | 641 | } |
| 642 | 642 | |
@@ -905,13 +905,13 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | |
| 907 | 907 | |
| 908 | - /** |
|
| 909 | - * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime (via the tickets). |
|
| 910 | - * into account |
|
| 911 | - * |
|
| 912 | - * @return int |
|
| 913 | - * @throws \EE_Error |
|
| 914 | - */ |
|
| 908 | + /** |
|
| 909 | + * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime (via the tickets). |
|
| 910 | + * into account |
|
| 911 | + * |
|
| 912 | + * @return int |
|
| 913 | + * @throws \EE_Error |
|
| 914 | + */ |
|
| 915 | 915 | public function update_sold() { |
| 916 | 916 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
| 917 | 917 | array( array( |
@@ -920,14 +920,14 @@ discard block |
||
| 920 | 920 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
| 921 | 921 | ) ) |
| 922 | 922 | ); |
| 923 | - $sold = $this->sold(); |
|
| 924 | - if ($count_regs_for_this_datetime > $sold) { |
|
| 925 | - $this->increase_sold($count_regs_for_this_datetime - $sold); |
|
| 926 | - $this->save(); |
|
| 927 | - } else if ($count_regs_for_this_datetime < $sold) { |
|
| 928 | - $this->decrease_sold($count_regs_for_this_datetime - $sold); |
|
| 929 | - $this->save(); |
|
| 930 | - } |
|
| 923 | + $sold = $this->sold(); |
|
| 924 | + if ($count_regs_for_this_datetime > $sold) { |
|
| 925 | + $this->increase_sold($count_regs_for_this_datetime - $sold); |
|
| 926 | + $this->save(); |
|
| 927 | + } else if ($count_regs_for_this_datetime < $sold) { |
|
| 928 | + $this->decrease_sold($count_regs_for_this_datetime - $sold); |
|
| 929 | + $this->save(); |
|
| 930 | + } |
|
| 931 | 931 | return $count_regs_for_this_datetime; |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * date_format and the second value is the time format |
| 75 | 75 | * @return EE_Datetime |
| 76 | 76 | */ |
| 77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
| 78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
| 79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
| 77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
| 78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * the website will be used. |
| 88 | 88 | * @return EE_Datetime |
| 89 | 89 | */ |
| 90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
| 91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
| 90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
| 91 | + return new self($props_n_values, TRUE, $timezone); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * @param $name |
| 98 | 98 | */ |
| 99 | - public function set_name( $name ) { |
|
| 100 | - $this->set( 'DTT_name', $name ); |
|
| 99 | + public function set_name($name) { |
|
| 100 | + $this->set('DTT_name', $name); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * @param $description |
| 107 | 107 | */ |
| 108 | - public function set_description( $description ) { |
|
| 109 | - $this->set( 'DTT_description', $description ); |
|
| 108 | + public function set_description($description) { |
|
| 109 | + $this->set('DTT_description', $description); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
| 120 | 120 | */ |
| 121 | - public function set_start_date( $date ) { |
|
| 122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
| 121 | + public function set_start_date($date) { |
|
| 122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
| 133 | 133 | */ |
| 134 | - public function set_start_time( $time ) { |
|
| 135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
| 134 | + public function set_start_time($time) { |
|
| 135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
| 146 | 146 | */ |
| 147 | - public function set_end_date( $date ) { |
|
| 148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
| 147 | + public function set_end_date($date) { |
|
| 148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
| 159 | 159 | */ |
| 160 | - public function set_end_time( $time ) { |
|
| 161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
| 160 | + public function set_end_time($time) { |
|
| 161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param int $reg_limit |
| 172 | 172 | */ |
| 173 | - public function set_reg_limit( $reg_limit ) { |
|
| 174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
| 173 | + public function set_reg_limit($reg_limit) { |
|
| 174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @return mixed int on success, FALSE on fail |
| 184 | 184 | */ |
| 185 | 185 | public function sold() { |
| 186 | - return $this->get_raw( 'DTT_sold' ); |
|
| 186 | + return $this->get_raw('DTT_sold'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param int $sold |
| 195 | 195 | */ |
| 196 | - public function set_sold( $sold ) { |
|
| 196 | + public function set_sold($sold) { |
|
| 197 | 197 | // sold can not go below zero |
| 198 | - $sold = max( 0, $sold ); |
|
| 199 | - $this->set( 'DTT_sold', $sold ); |
|
| 198 | + $sold = max(0, $sold); |
|
| 199 | + $this->set('DTT_sold', $sold); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | * increments sold by amount passed by $qty |
| 206 | 206 | * @param int $qty |
| 207 | 207 | */ |
| 208 | - public function increase_sold( $qty = 1 ) { |
|
| 208 | + public function increase_sold($qty = 1) { |
|
| 209 | 209 | $sold = $this->sold() + $qty; |
| 210 | 210 | // remove ticket reservation |
| 211 | - $this->decrease_reserved( $qty ); |
|
| 212 | - $this->set_sold( $sold ); |
|
| 211 | + $this->decrease_reserved($qty); |
|
| 212 | + $this->set_sold($sold); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | * decrements (subtracts) sold amount passed by $qty |
| 219 | 219 | * @param int $qty |
| 220 | 220 | */ |
| 221 | - public function decrease_sold( $qty = 1 ) { |
|
| 221 | + public function decrease_sold($qty = 1) { |
|
| 222 | 222 | $sold = $this->sold() - $qty; |
| 223 | - $this->set_sold( $sold ); |
|
| 223 | + $this->set_sold($sold); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @return int |
| 232 | 232 | */ |
| 233 | 233 | public function reserved() { |
| 234 | - return $this->get_raw( 'DTT_reserved' ); |
|
| 234 | + return $this->get_raw('DTT_reserved'); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param int $reserved |
| 243 | 243 | */ |
| 244 | - public function set_reserved( $reserved ) { |
|
| 244 | + public function set_reserved($reserved) { |
|
| 245 | 245 | // reserved can not go below zero |
| 246 | - $reserved = max( 0, (int) $reserved ); |
|
| 247 | - $this->set( 'DTT_reserved', $reserved ); |
|
| 246 | + $reserved = max(0, (int) $reserved); |
|
| 247 | + $this->set('DTT_reserved', $reserved); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | * @param int $qty |
| 256 | 256 | * @return boolean |
| 257 | 257 | */ |
| 258 | - public function increase_reserved( $qty = 1 ) { |
|
| 259 | - $reserved = $this->reserved() + absint( $qty ); |
|
| 260 | - return $this->set_reserved( $reserved ); |
|
| 258 | + public function increase_reserved($qty = 1) { |
|
| 259 | + $reserved = $this->reserved() + absint($qty); |
|
| 260 | + return $this->set_reserved($reserved); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * @param int $qty |
| 269 | 269 | * @return boolean |
| 270 | 270 | */ |
| 271 | - public function decrease_reserved( $qty = 1 ) { |
|
| 272 | - $reserved = $this->reserved() - absint( $qty ); |
|
| 273 | - return $this->set_reserved( $reserved ); |
|
| 271 | + public function decrease_reserved($qty = 1) { |
|
| 272 | + $reserved = $this->reserved() - absint($qty); |
|
| 273 | + return $this->set_reserved($reserved); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @return string |
| 292 | 292 | */ |
| 293 | 293 | public function name() { |
| 294 | - return $this->get( 'DTT_name' ); |
|
| 294 | + return $this->get('DTT_name'); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @return string |
| 302 | 302 | */ |
| 303 | 303 | public function description() { |
| 304 | - return $this->get( 'DTT_description' ); |
|
| 304 | + return $this->get('DTT_description'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @return boolean TRUE if is primary, FALSE if not. |
| 312 | 312 | */ |
| 313 | 313 | public function is_primary() { |
| 314 | - return $this->get( 'DTT_is_primary' ); |
|
| 314 | + return $this->get('DTT_is_primary'); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return int The order of the datetime for this event. |
| 322 | 322 | */ |
| 323 | 323 | public function order() { |
| 324 | - return $this->get( 'DTT_order' ); |
|
| 324 | + return $this->get('DTT_order'); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @return int |
| 332 | 332 | */ |
| 333 | 333 | public function parent() { |
| 334 | - return $this->get( 'DTT_parent' ); |
|
| 334 | + return $this->get('DTT_parent'); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
@@ -347,10 +347,10 @@ discard block |
||
| 347 | 347 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
| 348 | 348 | * @return string|bool string on success, FALSE on fail |
| 349 | 349 | */ |
| 350 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
| 350 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
| 351 | 351 | $field_name = "DTT_EVT_{$start_or_end}"; |
| 352 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
| 353 | - if ( ! $echo ) { |
|
| 352 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
| 353 | + if ( ! $echo) { |
|
| 354 | 354 | return $dtt; |
| 355 | 355 | } |
| 356 | 356 | return ''; |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
| 366 | 366 | * @return mixed string on success, FALSE on fail |
| 367 | 367 | */ |
| 368 | - public function start_date( $dt_frmt = '' ) { |
|
| 369 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
| 368 | + public function start_date($dt_frmt = '') { |
|
| 369 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * Echoes start_date() |
| 376 | 376 | * @param string $dt_frmt |
| 377 | 377 | */ |
| 378 | - public function e_start_date( $dt_frmt = '' ) { |
|
| 379 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
| 378 | + public function e_start_date($dt_frmt = '') { |
|
| 379 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
| 389 | 389 | * @return mixed string on success, FALSE on fail |
| 390 | 390 | */ |
| 391 | - public function end_date( $dt_frmt = '' ) { |
|
| 392 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
| 391 | + public function end_date($dt_frmt = '') { |
|
| 392 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | * Echoes the end date. See end_date() |
| 399 | 399 | * @param string $dt_frmt |
| 400 | 400 | */ |
| 401 | - public function e_end_date( $dt_frmt = '' ) { |
|
| 402 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
| 401 | + public function e_end_date($dt_frmt = '') { |
|
| 402 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | * @return mixed string on success, FALSE on fail |
| 415 | 415 | * @throws \EE_Error |
| 416 | 416 | */ |
| 417 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
| 418 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
| 419 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
| 420 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
| 421 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
| 417 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
| 418 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
| 419 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
| 420 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
| 421 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | * @param string $conjunction |
| 429 | 429 | * @throws \EE_Error |
| 430 | 430 | */ |
| 431 | - public function e_date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
| 432 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
| 431 | + public function e_date_range($dt_frmt = '', $conjunction = ' - ') { |
|
| 432 | + echo $this->date_range($dt_frmt, $conjunction); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 441 | 441 | * @return mixed string on success, FALSE on fail |
| 442 | 442 | */ |
| 443 | - public function start_time( $tm_format = '' ) { |
|
| 444 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
| 443 | + public function start_time($tm_format = '') { |
|
| 444 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | /** |
| 450 | 450 | * @param string $tm_format |
| 451 | 451 | */ |
| 452 | - public function e_start_time( $tm_format = '' ) { |
|
| 453 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
| 452 | + public function e_start_time($tm_format = '') { |
|
| 453 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 462 | 462 | * @return mixed string on success, FALSE on fail |
| 463 | 463 | */ |
| 464 | - public function end_time( $tm_format = '' ) { |
|
| 465 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
| 464 | + public function end_time($tm_format = '') { |
|
| 465 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | |
@@ -470,8 +470,8 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * @param string $tm_format |
| 472 | 472 | */ |
| 473 | - public function e_end_time( $tm_format = '' ) { |
|
| 474 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
| 473 | + public function e_end_time($tm_format = '') { |
|
| 474 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | |
@@ -486,11 +486,11 @@ discard block |
||
| 486 | 486 | * @return mixed string on success, FALSE on fail |
| 487 | 487 | * @throws \EE_Error |
| 488 | 488 | */ |
| 489 | - public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
| 490 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
| 491 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
| 492 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
| 493 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
| 489 | + public function time_range($tm_format = '', $conjunction = ' - ') { |
|
| 490 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
| 491 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
| 492 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
| 493 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param string $conjunction |
| 501 | 501 | * @throws \EE_Error |
| 502 | 502 | */ |
| 503 | - public function e_time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
| 504 | - echo $this->time_range( $tm_format, $conjunction ); |
|
| 503 | + public function e_time_range($tm_format = '', $conjunction = ' - ') { |
|
| 504 | + echo $this->time_range($tm_format, $conjunction); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | |
@@ -523,30 +523,30 @@ discard block |
||
| 523 | 523 | public function date_and_time_range( |
| 524 | 524 | $dt_format = '', |
| 525 | 525 | $tm_format = '', |
| 526 | - $conjunction = ' - ' , |
|
| 526 | + $conjunction = ' - ', |
|
| 527 | 527 | $separator = ' ' |
| 528 | 528 | ) { |
| 529 | - $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
|
| 530 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
| 531 | - $full_format = $dt_format . $separator . $tm_format; |
|
| 529 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
| 530 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
| 531 | + $full_format = $dt_format.$separator.$tm_format; |
|
| 532 | 532 | |
| 533 | 533 | //the range output depends on various conditions |
| 534 | - switch ( true ) { |
|
| 534 | + switch (true) { |
|
| 535 | 535 | //start date timestamp and end date timestamp are the same. |
| 536 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
| 537 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
| 536 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
| 537 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
| 538 | 538 | break; |
| 539 | 539 | //start and end date are the same but times are different |
| 540 | - case ( $this->start_date() === $this->end_date() ) : |
|
| 541 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
| 540 | + case ($this->start_date() === $this->end_date()) : |
|
| 541 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
| 542 | 542 | . $conjunction |
| 543 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
| 543 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
| 544 | 544 | break; |
| 545 | 545 | //all other conditions |
| 546 | 546 | default : |
| 547 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
| 547 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
| 548 | 548 | . $conjunction |
| 549 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
| 549 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
| 550 | 550 | break; |
| 551 | 551 | } |
| 552 | 552 | return $output; |
@@ -564,8 +564,8 @@ discard block |
||
| 564 | 564 | * @return void |
| 565 | 565 | * @throws \EE_Error |
| 566 | 566 | */ |
| 567 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
| 568 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
| 567 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
| 568 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -577,8 +577,8 @@ discard block |
||
| 577 | 577 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
| 578 | 578 | * @return mixed string on success, FALSE on fail |
| 579 | 579 | */ |
| 580 | - public function start_date_and_time( $dt_format = '', $tm_format = '' ) { |
|
| 581 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
| 580 | + public function start_date_and_time($dt_format = '', $tm_format = '') { |
|
| 581 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
@@ -587,8 +587,8 @@ discard block |
||
| 587 | 587 | * @param string $dt_frmt |
| 588 | 588 | * @param string $tm_format |
| 589 | 589 | */ |
| 590 | - public function e_start_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
| 591 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
| 590 | + public function e_start_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 591 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | |
@@ -602,11 +602,11 @@ discard block |
||
| 602 | 602 | * @param bool $round_up |
| 603 | 603 | * @return float|int|mixed |
| 604 | 604 | */ |
| 605 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
| 606 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
| 607 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
| 605 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
| 606 | + $start = $this->get_raw('DTT_EVT_start'); |
|
| 607 | + $end = $this->get_raw('DTT_EVT_end'); |
|
| 608 | 608 | $length_in_units = $end - $start; |
| 609 | - switch ( $units ) { |
|
| 609 | + switch ($units) { |
|
| 610 | 610 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
| 611 | 611 | /** @noinspection PhpMissingBreakStatementInspection */ |
| 612 | 612 | case 'days': |
@@ -619,10 +619,10 @@ discard block |
||
| 619 | 619 | $length_in_units /= 60; |
| 620 | 620 | case 'seconds': |
| 621 | 621 | default: |
| 622 | - $length_in_units = ceil( $length_in_units ); |
|
| 622 | + $length_in_units = ceil($length_in_units); |
|
| 623 | 623 | } |
| 624 | - if ( $round_up ) { |
|
| 625 | - $length_in_units = max( $length_in_units, 1 ); |
|
| 624 | + if ($round_up) { |
|
| 625 | + $length_in_units = max($length_in_units, 1); |
|
| 626 | 626 | } |
| 627 | 627 | return $length_in_units; |
| 628 | 628 | } |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | * @return mixed string on success, FALSE on fail |
| 638 | 638 | */ |
| 639 | 639 | public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
| 640 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
| 640 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * @param string $dt_frmt |
| 647 | 647 | * @param string $tm_format |
| 648 | 648 | */ |
| 649 | - public function e_end_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
| 650 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
| 649 | + public function e_end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
| 650 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | * @return int |
| 659 | 659 | */ |
| 660 | 660 | public function start() { |
| 661 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
| 661 | + return $this->get_raw('DTT_EVT_start'); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | * @return int |
| 670 | 670 | */ |
| 671 | 671 | public function end() { |
| 672 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
| 672 | + return $this->get_raw('DTT_EVT_end'); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | * @return mixed int on success, FALSE on fail |
| 681 | 681 | */ |
| 682 | 682 | public function reg_limit() { |
| 683 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
| 683 | + return $this->get_raw('DTT_reg_limit'); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | |
@@ -708,15 +708,15 @@ discard block |
||
| 708 | 708 | * the spaces remaining for this particular datetime, hence the flag. |
| 709 | 709 | * @return int |
| 710 | 710 | */ |
| 711 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
| 711 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
| 712 | 712 | // tickets remaining available for purchase |
| 713 | 713 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
| 714 | 714 | $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
| 715 | - if ( ! $consider_tickets ) { |
|
| 715 | + if ( ! $consider_tickets) { |
|
| 716 | 716 | return $dtt_remaining; |
| 717 | 717 | } |
| 718 | 718 | $tickets_remaining = $this->tickets_remaining(); |
| 719 | - return min( $dtt_remaining, $tickets_remaining ); |
|
| 719 | + return min($dtt_remaining, $tickets_remaining); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | |
@@ -727,19 +727,19 @@ discard block |
||
| 727 | 727 | * @param array $query_params like EEM_Base::get_all's |
| 728 | 728 | * @return int |
| 729 | 729 | */ |
| 730 | - public function tickets_remaining( $query_params = array() ) { |
|
| 730 | + public function tickets_remaining($query_params = array()) { |
|
| 731 | 731 | $sum = 0; |
| 732 | - $tickets = $this->tickets( $query_params ); |
|
| 733 | - if ( ! empty( $tickets ) ) { |
|
| 734 | - foreach ( $tickets as $ticket ) { |
|
| 735 | - if ( $ticket instanceof EE_Ticket ) { |
|
| 732 | + $tickets = $this->tickets($query_params); |
|
| 733 | + if ( ! empty($tickets)) { |
|
| 734 | + foreach ($tickets as $ticket) { |
|
| 735 | + if ($ticket instanceof EE_Ticket) { |
|
| 736 | 736 | // get the actual amount of tickets that can be sold |
| 737 | - $qty = $ticket->qty( 'saleable' ); |
|
| 738 | - if ( $qty === EE_INF ) { |
|
| 737 | + $qty = $ticket->qty('saleable'); |
|
| 738 | + if ($qty === EE_INF) { |
|
| 739 | 739 | return EE_INF; |
| 740 | 740 | } |
| 741 | 741 | // no negative ticket quantities plz |
| 742 | - if ( $qty > 0 ) { |
|
| 742 | + if ($qty > 0) { |
|
| 743 | 743 | $sum += $qty; |
| 744 | 744 | } |
| 745 | 745 | } |
@@ -756,8 +756,8 @@ discard block |
||
| 756 | 756 | * @param array $query_params like EEM_Base::get_all's |
| 757 | 757 | * @return int |
| 758 | 758 | */ |
| 759 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
| 760 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
| 759 | + public function sum_tickets_initially_available($query_params = array()) { |
|
| 760 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * @return int |
| 770 | 770 | */ |
| 771 | 771 | public function total_tickets_available_at_this_datetime() { |
| 772 | - return $this->spaces_remaining( true ); |
|
| 772 | + return $this->spaces_remaining(true); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @return boolean |
| 781 | 781 | */ |
| 782 | 782 | public function is_upcoming() { |
| 783 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
| 783 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @return boolean |
| 791 | 791 | */ |
| 792 | 792 | public function is_active() { |
| 793 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
| 793 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * @return boolean |
| 801 | 801 | */ |
| 802 | 802 | public function is_expired() { |
| 803 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
| 803 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | |
@@ -811,16 +811,16 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | public function get_active_status() { |
| 813 | 813 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
| 814 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
| 814 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
| 815 | 815 | return EE_Datetime::sold_out; |
| 816 | 816 | } |
| 817 | - if ( $this->is_expired() ) { |
|
| 817 | + if ($this->is_expired()) { |
|
| 818 | 818 | return EE_Datetime::expired; |
| 819 | 819 | } |
| 820 | - if ( $this->is_upcoming() ) { |
|
| 820 | + if ($this->is_upcoming()) { |
|
| 821 | 821 | return EE_Datetime::upcoming; |
| 822 | 822 | } |
| 823 | - if ( $this->is_active() ) { |
|
| 823 | + if ($this->is_active()) { |
|
| 824 | 824 | return EE_Datetime::active; |
| 825 | 825 | } |
| 826 | 826 | return NULL; |
@@ -834,24 +834,24 @@ discard block |
||
| 834 | 834 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
| 835 | 835 | * @return string |
| 836 | 836 | */ |
| 837 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
| 838 | - if ( $use_dtt_name ) { |
|
| 837 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
| 838 | + if ($use_dtt_name) { |
|
| 839 | 839 | $dtt_name = $this->name(); |
| 840 | - if ( !empty( $dtt_name ) ) { |
|
| 840 | + if ( ! empty($dtt_name)) { |
|
| 841 | 841 | return $dtt_name; |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | //first condition is to see if the months are different |
| 845 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
| 846 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
| 845 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
| 846 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
| 847 | 847 | //next condition is if its the same month but different day |
| 848 | 848 | } |
| 849 | 849 | else { |
| 850 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
| 851 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
| 850 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
| 851 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
| 852 | 852 | } |
| 853 | 853 | else { |
| 854 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
| 854 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | return $display_date; |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | *@param array $query_params see EEM_Base::get_all() |
| 866 | 866 | * @return EE_Ticket[] |
| 867 | 867 | */ |
| 868 | - public function tickets( $query_params = array() ) { |
|
| 869 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
| 868 | + public function tickets($query_params = array()) { |
|
| 869 | + return $this->get_many_related('Ticket', $query_params); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | |
@@ -876,21 +876,21 @@ discard block |
||
| 876 | 876 | * @param array $query_params like EEM_Base::get_all's |
| 877 | 877 | * @return EE_Ticket[] |
| 878 | 878 | */ |
| 879 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
| 879 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
| 880 | 880 | // first check if datetime is valid |
| 881 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
| 881 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
| 882 | 882 | return array(); |
| 883 | 883 | } |
| 884 | - if ( empty( $query_params ) ) { |
|
| 884 | + if (empty($query_params)) { |
|
| 885 | 885 | $query_params = array( |
| 886 | 886 | array( |
| 887 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
| 888 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
| 887 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
| 888 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
| 889 | 889 | 'TKT_deleted' => false |
| 890 | 890 | ) |
| 891 | 891 | ); |
| 892 | 892 | } |
| 893 | - return $this->tickets( $query_params ); |
|
| 893 | + return $this->tickets($query_params); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * @return EE_Event |
| 901 | 901 | */ |
| 902 | 902 | public function event() { |
| 903 | - return $this->get_first_related( 'Event' ); |
|
| 903 | + return $this->get_first_related('Event'); |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | |
@@ -914,11 +914,11 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | public function update_sold() { |
| 916 | 916 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
| 917 | - array( array( |
|
| 917 | + array(array( |
|
| 918 | 918 | 'STS_ID' => EEM_Registration::status_id_approved, |
| 919 | 919 | 'REG_deleted' => 0, |
| 920 | 920 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
| 921 | - ) ) |
|
| 921 | + )) |
|
| 922 | 922 | ); |
| 923 | 923 | $sold = $this->sold(); |
| 924 | 924 | if ($count_regs_for_this_datetime > $sold) { |
@@ -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 | /** |
@@ -12,165 +12,165 @@ discard block |
||
| 12 | 12 | class EE_Cron_Tasks extends EE_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
| 17 | - * so we'll set our retry time for just over 10 minutes to avoid that |
|
| 18 | - */ |
|
| 19 | - const reschedule_timeout = 605; |
|
| 20 | - |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var EE_Cron_Tasks |
|
| 24 | - */ |
|
| 25 | - private static $_instance; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @return EE_Cron_Tasks |
|
| 30 | - */ |
|
| 31 | - public static function instance() |
|
| 32 | - { |
|
| 33 | - if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
| 34 | - self::$_instance = new self(); |
|
| 35 | - } |
|
| 36 | - return self::$_instance; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @access private |
|
| 42 | - */ |
|
| 43 | - private function __construct() |
|
| 44 | - { |
|
| 45 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 46 | - // verify that WP Cron is enabled |
|
| 47 | - if ( |
|
| 48 | - defined('DISABLE_WP_CRON') |
|
| 49 | - && DISABLE_WP_CRON |
|
| 50 | - && is_admin() |
|
| 51 | - && ! get_option('ee_disabled_wp_cron_check') |
|
| 52 | - ) { |
|
| 53 | - /** |
|
| 54 | - * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
| 55 | - * config is loaded. |
|
| 56 | - * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
| 57 | - * wanting to not have this functionality can just register its own action at a priority after this one to |
|
| 58 | - * reverse any changes. |
|
| 59 | - */ |
|
| 60 | - add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
| 61 | - EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
| 62 | - EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
| 63 | - add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
| 64 | - }); |
|
| 65 | - } |
|
| 66 | - // UPDATE TRANSACTION WITH PAYMENT |
|
| 67 | - add_action( |
|
| 68 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
| 69 | - array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
| 70 | - 10, 2 |
|
| 71 | - ); |
|
| 72 | - // FINALIZE ABANDONED TRANSACTIONS |
|
| 73 | - add_action( |
|
| 74 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 75 | - array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
| 76 | - 10, 1 |
|
| 77 | - ); |
|
| 15 | + /** |
|
| 16 | + * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
| 17 | + * so we'll set our retry time for just over 10 minutes to avoid that |
|
| 18 | + */ |
|
| 19 | + const reschedule_timeout = 605; |
|
| 20 | + |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var EE_Cron_Tasks |
|
| 24 | + */ |
|
| 25 | + private static $_instance; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @return EE_Cron_Tasks |
|
| 30 | + */ |
|
| 31 | + public static function instance() |
|
| 32 | + { |
|
| 33 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
| 34 | + self::$_instance = new self(); |
|
| 35 | + } |
|
| 36 | + return self::$_instance; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @access private |
|
| 42 | + */ |
|
| 43 | + private function __construct() |
|
| 44 | + { |
|
| 45 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 46 | + // verify that WP Cron is enabled |
|
| 47 | + if ( |
|
| 48 | + defined('DISABLE_WP_CRON') |
|
| 49 | + && DISABLE_WP_CRON |
|
| 50 | + && is_admin() |
|
| 51 | + && ! get_option('ee_disabled_wp_cron_check') |
|
| 52 | + ) { |
|
| 53 | + /** |
|
| 54 | + * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
| 55 | + * config is loaded. |
|
| 56 | + * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
| 57 | + * wanting to not have this functionality can just register its own action at a priority after this one to |
|
| 58 | + * reverse any changes. |
|
| 59 | + */ |
|
| 60 | + add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
| 61 | + EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
| 62 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
| 63 | + add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
| 64 | + }); |
|
| 65 | + } |
|
| 66 | + // UPDATE TRANSACTION WITH PAYMENT |
|
| 67 | + add_action( |
|
| 68 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
| 69 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
| 70 | + 10, 2 |
|
| 71 | + ); |
|
| 72 | + // FINALIZE ABANDONED TRANSACTIONS |
|
| 73 | + add_action( |
|
| 74 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 75 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
| 76 | + 10, 1 |
|
| 77 | + ); |
|
| 78 | 78 | // EXPIRED TRANSACTION CHECK |
| 79 | 79 | add_action( |
| 80 | 80 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
| 81 | 81 | array( 'EE_Cron_Tasks', 'expired_transaction_check' ), |
| 82 | 82 | 10, 1 |
| 83 | 83 | ); |
| 84 | - // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
| 85 | - add_action( |
|
| 86 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
| 87 | - array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
| 88 | - ); |
|
| 89 | - // logging |
|
| 90 | - add_action( |
|
| 91 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
| 92 | - array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
| 93 | - ); |
|
| 94 | - EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
| 95 | - //clean out old gateway logs |
|
| 96 | - add_action( |
|
| 97 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
| 98 | - array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @access protected |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - public static function log_scheduled_ee_crons() |
|
| 108 | - { |
|
| 109 | - $ee_crons = array( |
|
| 110 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
| 111 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 112 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
| 113 | - ); |
|
| 114 | - $crons = (array) get_option('cron'); |
|
| 115 | - if ( ! is_array($crons)) { |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - foreach ($crons as $timestamp => $cron) { |
|
| 119 | - foreach ($ee_crons as $ee_cron) { |
|
| 120 | - if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
| 121 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
| 122 | - foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
| 123 | - if ( ! empty($ee_cron_details['args'])) { |
|
| 124 | - do_action( |
|
| 125 | - 'AHEE_log', |
|
| 126 | - __CLASS__, |
|
| 127 | - __FUNCTION__, |
|
| 128 | - print_r($ee_cron_details['args'], true), |
|
| 129 | - "{$ee_cron} args" |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * reschedule_cron_for_transactions_if_maintenance_mode |
|
| 142 | - * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
| 143 | - * |
|
| 144 | - * @param string $cron_task |
|
| 145 | - * @param array $TXN_IDs |
|
| 146 | - * @return bool |
|
| 147 | - * @throws \DomainException |
|
| 148 | - */ |
|
| 84 | + // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
| 85 | + add_action( |
|
| 86 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
| 87 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
| 88 | + ); |
|
| 89 | + // logging |
|
| 90 | + add_action( |
|
| 91 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
| 92 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
| 93 | + ); |
|
| 94 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
| 95 | + //clean out old gateway logs |
|
| 96 | + add_action( |
|
| 97 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
| 98 | + array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @access protected |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + public static function log_scheduled_ee_crons() |
|
| 108 | + { |
|
| 109 | + $ee_crons = array( |
|
| 110 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
| 111 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 112 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
| 113 | + ); |
|
| 114 | + $crons = (array) get_option('cron'); |
|
| 115 | + if ( ! is_array($crons)) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + foreach ($crons as $timestamp => $cron) { |
|
| 119 | + foreach ($ee_crons as $ee_cron) { |
|
| 120 | + if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
| 121 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
| 122 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
| 123 | + if ( ! empty($ee_cron_details['args'])) { |
|
| 124 | + do_action( |
|
| 125 | + 'AHEE_log', |
|
| 126 | + __CLASS__, |
|
| 127 | + __FUNCTION__, |
|
| 128 | + print_r($ee_cron_details['args'], true), |
|
| 129 | + "{$ee_cron} args" |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * reschedule_cron_for_transactions_if_maintenance_mode |
|
| 142 | + * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
| 143 | + * |
|
| 144 | + * @param string $cron_task |
|
| 145 | + * @param array $TXN_IDs |
|
| 146 | + * @return bool |
|
| 147 | + * @throws \DomainException |
|
| 148 | + */ |
|
| 149 | 149 | public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) { |
| 150 | - if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
| 151 | - throw new \DomainException( |
|
| 152 | - sprintf( |
|
| 153 | - __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
| 154 | - $cron_task |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 150 | + if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
| 151 | + throw new \DomainException( |
|
| 152 | + sprintf( |
|
| 153 | + __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
| 154 | + $cron_task |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | 158 | // reschedule the cron if we can't hit the db right now |
| 159 | 159 | if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
| 160 | 160 | foreach( $TXN_IDs as $TXN_ID => $additional_vars ) { |
| 161 | - // ensure $additional_vars is an array |
|
| 162 | - $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
| 161 | + // ensure $additional_vars is an array |
|
| 162 | + $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
| 163 | 163 | // reset cron job for the TXN |
| 164 | - call_user_func_array( |
|
| 165 | - array('EE_Cron_Tasks', $cron_task), |
|
| 166 | - array_merge( |
|
| 167 | - array( |
|
| 168 | - time() + (10 * MINUTE_IN_SECONDS), |
|
| 169 | - $TXN_ID |
|
| 170 | - ), |
|
| 171 | - $additional_vars |
|
| 172 | - ) |
|
| 173 | - ); |
|
| 164 | + call_user_func_array( |
|
| 165 | + array('EE_Cron_Tasks', $cron_task), |
|
| 166 | + array_merge( |
|
| 167 | + array( |
|
| 168 | + time() + (10 * MINUTE_IN_SECONDS), |
|
| 169 | + $TXN_ID |
|
| 170 | + ), |
|
| 171 | + $additional_vars |
|
| 172 | + ) |
|
| 173 | + ); |
|
| 174 | 174 | } |
| 175 | 175 | return true; |
| 176 | 176 | } |
@@ -180,85 +180,85 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * array of TXN IDs and the payment |
|
| 188 | - * |
|
| 189 | - * @var array |
|
| 190 | - */ |
|
| 191 | - protected static $_update_transactions_with_payment = array(); |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * schedule_update_transaction_with_payment |
|
| 196 | - * sets a wp_schedule_single_event() for updating any TXNs that may |
|
| 197 | - * require updating due to recently received payments |
|
| 198 | - * |
|
| 199 | - * @param int $timestamp |
|
| 200 | - * @param int $TXN_ID |
|
| 201 | - * @param int $PAY_ID |
|
| 202 | - */ |
|
| 203 | - public static function schedule_update_transaction_with_payment( |
|
| 204 | - $timestamp, |
|
| 205 | - $TXN_ID, |
|
| 206 | - $PAY_ID |
|
| 207 | - ) { |
|
| 208 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 209 | - // validate $TXN_ID and $timestamp |
|
| 210 | - $TXN_ID = absint($TXN_ID); |
|
| 211 | - $timestamp = absint($timestamp); |
|
| 212 | - if ($TXN_ID && $timestamp) { |
|
| 213 | - wp_schedule_single_event( |
|
| 214 | - $timestamp, |
|
| 215 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
| 216 | - array($TXN_ID, $PAY_ID) |
|
| 217 | - ); |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * setup_update_for_transaction_with_payment |
|
| 224 | - * this is the callback for the action hook: |
|
| 225 | - * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
| 226 | - * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
| 227 | - * The passed TXN_ID and associated payment gets added to an array, and then |
|
| 228 | - * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
| 229 | - * 'shutdown' which will actually handle the processing of any |
|
| 230 | - * transactions requiring updating, because doing so now would be too early |
|
| 231 | - * and the required resources may not be available |
|
| 232 | - * |
|
| 233 | - * @param int $TXN_ID |
|
| 234 | - * @param int $PAY_ID |
|
| 235 | - */ |
|
| 236 | - public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
| 237 | - { |
|
| 238 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 239 | - if (absint($TXN_ID)) { |
|
| 240 | - self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
| 241 | - add_action( |
|
| 242 | - 'shutdown', |
|
| 243 | - array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
| 244 | - 5 |
|
| 245 | - ); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * update_transaction_with_payment |
|
| 252 | - * loops through the self::$_abandoned_transactions array |
|
| 253 | - * and attempts to finalize any TXNs that have not been completed |
|
| 254 | - * but have had their sessions expired, most likely due to a user not |
|
| 255 | - * returning from an off-site payment gateway |
|
| 256 | - * |
|
| 257 | - * @throws \EE_Error |
|
| 258 | - */ |
|
| 259 | - public static function update_transaction_with_payment() |
|
| 260 | - { |
|
| 261 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 183 | + /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * array of TXN IDs and the payment |
|
| 188 | + * |
|
| 189 | + * @var array |
|
| 190 | + */ |
|
| 191 | + protected static $_update_transactions_with_payment = array(); |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * schedule_update_transaction_with_payment |
|
| 196 | + * sets a wp_schedule_single_event() for updating any TXNs that may |
|
| 197 | + * require updating due to recently received payments |
|
| 198 | + * |
|
| 199 | + * @param int $timestamp |
|
| 200 | + * @param int $TXN_ID |
|
| 201 | + * @param int $PAY_ID |
|
| 202 | + */ |
|
| 203 | + public static function schedule_update_transaction_with_payment( |
|
| 204 | + $timestamp, |
|
| 205 | + $TXN_ID, |
|
| 206 | + $PAY_ID |
|
| 207 | + ) { |
|
| 208 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 209 | + // validate $TXN_ID and $timestamp |
|
| 210 | + $TXN_ID = absint($TXN_ID); |
|
| 211 | + $timestamp = absint($timestamp); |
|
| 212 | + if ($TXN_ID && $timestamp) { |
|
| 213 | + wp_schedule_single_event( |
|
| 214 | + $timestamp, |
|
| 215 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
| 216 | + array($TXN_ID, $PAY_ID) |
|
| 217 | + ); |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * setup_update_for_transaction_with_payment |
|
| 224 | + * this is the callback for the action hook: |
|
| 225 | + * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
| 226 | + * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
| 227 | + * The passed TXN_ID and associated payment gets added to an array, and then |
|
| 228 | + * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
| 229 | + * 'shutdown' which will actually handle the processing of any |
|
| 230 | + * transactions requiring updating, because doing so now would be too early |
|
| 231 | + * and the required resources may not be available |
|
| 232 | + * |
|
| 233 | + * @param int $TXN_ID |
|
| 234 | + * @param int $PAY_ID |
|
| 235 | + */ |
|
| 236 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
| 237 | + { |
|
| 238 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 239 | + if (absint($TXN_ID)) { |
|
| 240 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
| 241 | + add_action( |
|
| 242 | + 'shutdown', |
|
| 243 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
| 244 | + 5 |
|
| 245 | + ); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * update_transaction_with_payment |
|
| 252 | + * loops through the self::$_abandoned_transactions array |
|
| 253 | + * and attempts to finalize any TXNs that have not been completed |
|
| 254 | + * but have had their sessions expired, most likely due to a user not |
|
| 255 | + * returning from an off-site payment gateway |
|
| 256 | + * |
|
| 257 | + * @throws \EE_Error |
|
| 258 | + */ |
|
| 259 | + public static function update_transaction_with_payment() |
|
| 260 | + { |
|
| 261 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 262 | 262 | if ( |
| 263 | 263 | // are there any TXNs that need cleaning up ? |
| 264 | 264 | empty( self::$_update_transactions_with_payment ) |
@@ -268,119 +268,119 @@ discard block |
||
| 268 | 268 | self::$_update_transactions_with_payment |
| 269 | 269 | ) |
| 270 | 270 | ) { |
| 271 | - return; |
|
| 272 | - } |
|
| 273 | - /** @type EE_Payment_Processor $payment_processor */ |
|
| 274 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 275 | - // set revisit flag for payment processor |
|
| 276 | - $payment_processor->set_revisit(false); |
|
| 277 | - // load EEM_Transaction |
|
| 278 | - EE_Registry::instance()->load_model('Transaction'); |
|
| 279 | - foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
| 280 | - // reschedule the cron if we can't hit the db right now |
|
| 281 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 282 | - // reset cron job for updating the TXN |
|
| 283 | - EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
| 284 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
| 285 | - $TXN_ID, |
|
| 286 | - $PAY_ID |
|
| 287 | - ); |
|
| 288 | - continue; |
|
| 289 | - } |
|
| 290 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 291 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
| 292 | - // verify transaction |
|
| 293 | - if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
| 294 | - // now try to update the TXN with any payments |
|
| 295 | - $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
| 296 | - } |
|
| 297 | - unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * array of TXN IDs |
|
| 311 | - * |
|
| 312 | - * @var array |
|
| 313 | - */ |
|
| 314 | - protected static $_abandoned_transactions = array(); |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * schedule_finalize_abandoned_transactions_check |
|
| 319 | - * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
| 320 | - * have been abandoned during the registration process |
|
| 321 | - * |
|
| 322 | - * @param int $timestamp |
|
| 323 | - * @param int $TXN_ID |
|
| 324 | - */ |
|
| 325 | - public static function schedule_finalize_abandoned_transactions_check( |
|
| 326 | - $timestamp, |
|
| 327 | - $TXN_ID |
|
| 328 | - ) { |
|
| 329 | - // validate $TXN_ID and $timestamp |
|
| 330 | - $TXN_ID = absint($TXN_ID); |
|
| 331 | - $timestamp = absint($timestamp); |
|
| 332 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 333 | - if ($TXN_ID && $timestamp) { |
|
| 334 | - wp_schedule_single_event( |
|
| 335 | - $timestamp, |
|
| 336 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 337 | - array($TXN_ID) |
|
| 338 | - ); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * check_for_abandoned_transactions |
|
| 345 | - * this is the callback for the action hook: |
|
| 346 | - * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
| 347 | - * which is utilized by wp_schedule_single_event() |
|
| 348 | - * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
| 349 | - * The passed TXN_ID gets added to an array, and then the |
|
| 350 | - * espresso_finalize_abandoned_transactions() function is hooked into |
|
| 351 | - * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
| 352 | - * processing of any abandoned transactions, because doing so now would be |
|
| 353 | - * too early and the required resources may not be available |
|
| 354 | - * |
|
| 355 | - * @param int $TXN_ID |
|
| 356 | - */ |
|
| 357 | - public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
| 358 | - { |
|
| 359 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 360 | - if (absint($TXN_ID)) { |
|
| 361 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
| 362 | - add_action( |
|
| 363 | - 'shutdown', |
|
| 364 | - array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
| 365 | - 5 |
|
| 366 | - ); |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * finalize_abandoned_transactions |
|
| 373 | - * loops through the self::$_abandoned_transactions array |
|
| 374 | - * and attempts to finalize any TXNs that have not been completed |
|
| 375 | - * but have had their sessions expired, most likely due to a user not |
|
| 376 | - * returning from an off-site payment gateway |
|
| 377 | - * |
|
| 378 | - * @throws \EE_Error |
|
| 379 | - */ |
|
| 380 | - public static function finalize_abandoned_transactions() |
|
| 381 | - { |
|
| 382 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 383 | - if ( |
|
| 271 | + return; |
|
| 272 | + } |
|
| 273 | + /** @type EE_Payment_Processor $payment_processor */ |
|
| 274 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 275 | + // set revisit flag for payment processor |
|
| 276 | + $payment_processor->set_revisit(false); |
|
| 277 | + // load EEM_Transaction |
|
| 278 | + EE_Registry::instance()->load_model('Transaction'); |
|
| 279 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
| 280 | + // reschedule the cron if we can't hit the db right now |
|
| 281 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 282 | + // reset cron job for updating the TXN |
|
| 283 | + EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
| 284 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
| 285 | + $TXN_ID, |
|
| 286 | + $PAY_ID |
|
| 287 | + ); |
|
| 288 | + continue; |
|
| 289 | + } |
|
| 290 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 291 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
| 292 | + // verify transaction |
|
| 293 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
| 294 | + // now try to update the TXN with any payments |
|
| 295 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
| 296 | + } |
|
| 297 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * array of TXN IDs |
|
| 311 | + * |
|
| 312 | + * @var array |
|
| 313 | + */ |
|
| 314 | + protected static $_abandoned_transactions = array(); |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * schedule_finalize_abandoned_transactions_check |
|
| 319 | + * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
| 320 | + * have been abandoned during the registration process |
|
| 321 | + * |
|
| 322 | + * @param int $timestamp |
|
| 323 | + * @param int $TXN_ID |
|
| 324 | + */ |
|
| 325 | + public static function schedule_finalize_abandoned_transactions_check( |
|
| 326 | + $timestamp, |
|
| 327 | + $TXN_ID |
|
| 328 | + ) { |
|
| 329 | + // validate $TXN_ID and $timestamp |
|
| 330 | + $TXN_ID = absint($TXN_ID); |
|
| 331 | + $timestamp = absint($timestamp); |
|
| 332 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 333 | + if ($TXN_ID && $timestamp) { |
|
| 334 | + wp_schedule_single_event( |
|
| 335 | + $timestamp, |
|
| 336 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
| 337 | + array($TXN_ID) |
|
| 338 | + ); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * check_for_abandoned_transactions |
|
| 345 | + * this is the callback for the action hook: |
|
| 346 | + * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
| 347 | + * which is utilized by wp_schedule_single_event() |
|
| 348 | + * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
| 349 | + * The passed TXN_ID gets added to an array, and then the |
|
| 350 | + * espresso_finalize_abandoned_transactions() function is hooked into |
|
| 351 | + * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
| 352 | + * processing of any abandoned transactions, because doing so now would be |
|
| 353 | + * too early and the required resources may not be available |
|
| 354 | + * |
|
| 355 | + * @param int $TXN_ID |
|
| 356 | + */ |
|
| 357 | + public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
| 358 | + { |
|
| 359 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 360 | + if (absint($TXN_ID)) { |
|
| 361 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
| 362 | + add_action( |
|
| 363 | + 'shutdown', |
|
| 364 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
| 365 | + 5 |
|
| 366 | + ); |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * finalize_abandoned_transactions |
|
| 373 | + * loops through the self::$_abandoned_transactions array |
|
| 374 | + * and attempts to finalize any TXNs that have not been completed |
|
| 375 | + * but have had their sessions expired, most likely due to a user not |
|
| 376 | + * returning from an off-site payment gateway |
|
| 377 | + * |
|
| 378 | + * @throws \EE_Error |
|
| 379 | + */ |
|
| 380 | + public static function finalize_abandoned_transactions() |
|
| 381 | + { |
|
| 382 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
| 383 | + if ( |
|
| 384 | 384 | // are there any TXNs that need cleaning up ? |
| 385 | 385 | empty( self::$_abandoned_transactions ) |
| 386 | 386 | // reschedule the cron if we can't hit the db right now |
@@ -389,45 +389,45 @@ discard block |
||
| 389 | 389 | self::$_abandoned_transactions |
| 390 | 390 | ) |
| 391 | 391 | ) { |
| 392 | - return; |
|
| 393 | - } |
|
| 394 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 395 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 396 | - // set revisit flag for txn processor |
|
| 397 | - $transaction_processor->set_revisit(false); |
|
| 398 | - /** @type EE_Payment_Processor $payment_processor */ |
|
| 399 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 400 | - // load EEM_Transaction |
|
| 401 | - EE_Registry::instance()->load_model('Transaction'); |
|
| 402 | - foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
| 403 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 404 | - // reschedule the cron if we can't hit the db right now |
|
| 405 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 406 | - // reset cron job for finalizing the TXN |
|
| 407 | - EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
| 408 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
| 409 | - $TXN_ID |
|
| 410 | - ); |
|
| 411 | - continue; |
|
| 412 | - } |
|
| 413 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 414 | - // verify transaction |
|
| 415 | - if ($transaction instanceof EE_Transaction) { |
|
| 416 | - // don't finalize the TXN if it has already been completed |
|
| 417 | - if ($transaction->all_reg_steps_completed() === true) { |
|
| 418 | - continue; |
|
| 419 | - } |
|
| 420 | - // let's simulate an IPN here which will trigger any notifications that need to go out |
|
| 421 | - $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true); |
|
| 422 | - do_action('AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', $transaction); |
|
| 423 | - } |
|
| 424 | - unset(self::$_abandoned_transactions[$TXN_ID]); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
| 392 | + return; |
|
| 393 | + } |
|
| 394 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 395 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 396 | + // set revisit flag for txn processor |
|
| 397 | + $transaction_processor->set_revisit(false); |
|
| 398 | + /** @type EE_Payment_Processor $payment_processor */ |
|
| 399 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 400 | + // load EEM_Transaction |
|
| 401 | + EE_Registry::instance()->load_model('Transaction'); |
|
| 402 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
| 403 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
| 404 | + // reschedule the cron if we can't hit the db right now |
|
| 405 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 406 | + // reset cron job for finalizing the TXN |
|
| 407 | + EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
| 408 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
| 409 | + $TXN_ID |
|
| 410 | + ); |
|
| 411 | + continue; |
|
| 412 | + } |
|
| 413 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 414 | + // verify transaction |
|
| 415 | + if ($transaction instanceof EE_Transaction) { |
|
| 416 | + // don't finalize the TXN if it has already been completed |
|
| 417 | + if ($transaction->all_reg_steps_completed() === true) { |
|
| 418 | + continue; |
|
| 419 | + } |
|
| 420 | + // let's simulate an IPN here which will trigger any notifications that need to go out |
|
| 421 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true); |
|
| 422 | + do_action('AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', $transaction); |
|
| 423 | + } |
|
| 424 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | /***************** EXPIRED TRANSACTION CHECK *****************/ |
@@ -496,12 +496,12 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | |
| 498 | 498 | |
| 499 | - /** |
|
| 500 | - * process_expired_transactions |
|
| 501 | - * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
| 502 | - * |
|
| 503 | - * @throws \EE_Error |
|
| 504 | - */ |
|
| 499 | + /** |
|
| 500 | + * process_expired_transactions |
|
| 501 | + * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
| 502 | + * |
|
| 503 | + * @throws \EE_Error |
|
| 504 | + */ |
|
| 505 | 505 | public static function process_expired_transactions() { |
| 506 | 506 | if ( |
| 507 | 507 | // are there any TXNs that need cleaning up ? |
@@ -512,58 +512,58 @@ discard block |
||
| 512 | 512 | self::$_expired_transactions |
| 513 | 513 | ) |
| 514 | 514 | ) { |
| 515 | - return; |
|
| 516 | - } |
|
| 517 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 518 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 519 | - // set revisit flag for txn processor |
|
| 520 | - $transaction_processor->set_revisit( false ); |
|
| 521 | - // load EEM_Transaction |
|
| 522 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
| 523 | - foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
| 524 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
| 525 | - // verify transaction and whether it is failed or not |
|
| 526 | - if ( $transaction instanceof EE_Transaction) { |
|
| 527 | - switch( $transaction->status_ID() ) { |
|
| 528 | - // Completed TXNs |
|
| 529 | - case EEM_Transaction::complete_status_code : |
|
| 530 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
| 531 | - break; |
|
| 532 | - // Overpaid TXNs |
|
| 533 | - case EEM_Transaction::overpaid_status_code : |
|
| 534 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
| 535 | - break; |
|
| 536 | - // Incomplete TXNs |
|
| 537 | - case EEM_Transaction::incomplete_status_code : |
|
| 538 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
| 539 | - // todo : merge the finalize_abandoned_transactions cron into this one... |
|
| 540 | - // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
| 541 | - break; |
|
| 542 | - // Failed TXNs |
|
| 543 | - case EEM_Transaction::failed_status_code : |
|
| 544 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
| 545 | - // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
| 546 | - //$registrations = $transaction->registrations(); |
|
| 547 | - //if ( ! empty( $registrations ) ) { |
|
| 548 | - // foreach ( $registrations as $registration ) { |
|
| 549 | - // if ( $registration instanceof EE_Registration ) { |
|
| 550 | - //$delete_registration = true; |
|
| 551 | - //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
| 552 | - // $delete_registration = false; |
|
| 553 | - //} |
|
| 554 | - //if ( $delete_registration ) { |
|
| 555 | - // $registration->delete_permanently(); |
|
| 556 | - // $registration->delete_related_permanently(); |
|
| 557 | - //} |
|
| 558 | - // } |
|
| 559 | - // } |
|
| 560 | - //} |
|
| 561 | - break; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - } |
|
| 565 | - unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
| 566 | - } |
|
| 515 | + return; |
|
| 516 | + } |
|
| 517 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 518 | + $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 519 | + // set revisit flag for txn processor |
|
| 520 | + $transaction_processor->set_revisit( false ); |
|
| 521 | + // load EEM_Transaction |
|
| 522 | + EE_Registry::instance()->load_model( 'Transaction' ); |
|
| 523 | + foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
| 524 | + $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
| 525 | + // verify transaction and whether it is failed or not |
|
| 526 | + if ( $transaction instanceof EE_Transaction) { |
|
| 527 | + switch( $transaction->status_ID() ) { |
|
| 528 | + // Completed TXNs |
|
| 529 | + case EEM_Transaction::complete_status_code : |
|
| 530 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
| 531 | + break; |
|
| 532 | + // Overpaid TXNs |
|
| 533 | + case EEM_Transaction::overpaid_status_code : |
|
| 534 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
| 535 | + break; |
|
| 536 | + // Incomplete TXNs |
|
| 537 | + case EEM_Transaction::incomplete_status_code : |
|
| 538 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
| 539 | + // todo : merge the finalize_abandoned_transactions cron into this one... |
|
| 540 | + // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
| 541 | + break; |
|
| 542 | + // Failed TXNs |
|
| 543 | + case EEM_Transaction::failed_status_code : |
|
| 544 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
| 545 | + // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
| 546 | + //$registrations = $transaction->registrations(); |
|
| 547 | + //if ( ! empty( $registrations ) ) { |
|
| 548 | + // foreach ( $registrations as $registration ) { |
|
| 549 | + // if ( $registration instanceof EE_Registration ) { |
|
| 550 | + //$delete_registration = true; |
|
| 551 | + //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
| 552 | + // $delete_registration = false; |
|
| 553 | + //} |
|
| 554 | + //if ( $delete_registration ) { |
|
| 555 | + // $registration->delete_permanently(); |
|
| 556 | + // $registration->delete_related_permanently(); |
|
| 557 | + //} |
|
| 558 | + // } |
|
| 559 | + // } |
|
| 560 | + //} |
|
| 561 | + break; |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + } |
|
| 565 | + unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
| 566 | + } |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
@@ -571,33 +571,33 @@ discard block |
||
| 571 | 571 | /************* END OF EXPIRED TRANSACTION CHECK *************/ |
| 572 | 572 | |
| 573 | 573 | |
| 574 | - /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
| 575 | - |
|
| 576 | - //when a transaction is initially made, schedule this check. |
|
| 577 | - //if it has NO REG data by the time it has expired, forget about it |
|
| 578 | - public static function clean_out_junk_transactions() |
|
| 579 | - { |
|
| 580 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 581 | - EEM_Transaction::instance('')->delete_junk_transactions(); |
|
| 582 | - EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
| 583 | - EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
| 584 | - } |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
| 591 | - */ |
|
| 592 | - public static function clean_out_old_gateway_logs(){ |
|
| 593 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 594 | - $time_diff_for_comparison = apply_filters( |
|
| 595 | - 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
| 596 | - "-1 week" |
|
| 597 | - ); |
|
| 598 | - EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
| 599 | - } |
|
| 600 | - } |
|
| 574 | + /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
| 575 | + |
|
| 576 | + //when a transaction is initially made, schedule this check. |
|
| 577 | + //if it has NO REG data by the time it has expired, forget about it |
|
| 578 | + public static function clean_out_junk_transactions() |
|
| 579 | + { |
|
| 580 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 581 | + EEM_Transaction::instance('')->delete_junk_transactions(); |
|
| 582 | + EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
| 583 | + EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
| 591 | + */ |
|
| 592 | + public static function clean_out_old_gateway_logs(){ |
|
| 593 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 594 | + $time_diff_for_comparison = apply_filters( |
|
| 595 | + 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
| 596 | + "-1 week" |
|
| 597 | + ); |
|
| 598 | + EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
| 599 | + } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | } |
@@ -16,234 +16,234 @@ |
||
| 16 | 16 | class Registry |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $jsdata = array(); |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Registry constructor. |
|
| 28 | - * Hooking into WP actions for script registry. |
|
| 29 | - */ |
|
| 30 | - public function __construct() |
|
| 31 | - { |
|
| 32 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 100); |
|
| 33 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 100); |
|
| 34 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
| 35 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Callback for the WP script actions. |
|
| 41 | - * Used to register globally accessible core scripts. |
|
| 42 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
| 43 | - */ |
|
| 44 | - public function scripts() |
|
| 45 | - { |
|
| 46 | - global $wp_version; |
|
| 47 | - wp_register_script( |
|
| 48 | - 'eejs-core', |
|
| 49 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
| 50 | - array(), |
|
| 51 | - espresso_version(), |
|
| 52 | - true |
|
| 53 | - ); |
|
| 54 | - //only run this if WordPress 4.4.0 > is in use. |
|
| 55 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
| 56 | - //js.api |
|
| 57 | - wp_register_script( |
|
| 58 | - 'eejs-api', |
|
| 59 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
| 60 | - array('underscore', 'eejs-core'), |
|
| 61 | - espresso_version(), |
|
| 62 | - true |
|
| 63 | - ); |
|
| 64 | - $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
| 65 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Call back for the script print in frontend and backend. |
|
| 72 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hookpoint. |
|
| 73 | - * @since 4.9.31.rc.015 |
|
| 74 | - */ |
|
| 75 | - public function enqueueData() |
|
| 76 | - { |
|
| 77 | - wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Used to add data to eejs.data object. |
|
| 83 | - * |
|
| 84 | - * Note: Overriding existing data is not allowed. |
|
| 85 | - * |
|
| 86 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
| 87 | - * If the data you add is something like this: |
|
| 88 | - * |
|
| 89 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
| 90 | - * |
|
| 91 | - * It will be exposed in the page source as: |
|
| 92 | - * |
|
| 93 | - * eejs.data.my_plugin_data.foo == gar |
|
| 94 | - * |
|
| 95 | - * @param string $key Key used to access your data |
|
| 96 | - * @param string|array $value Value to attach to key |
|
| 97 | - * @throws InvalidArgumentException |
|
| 98 | - */ |
|
| 99 | - public function addData($key, $value) |
|
| 100 | - { |
|
| 101 | - if ($this->verifyDataNotExisting($key)) { |
|
| 102 | - $this->jsdata[$key] = $value; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
| 109 | - * elements in an array. |
|
| 110 | - * |
|
| 111 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
| 112 | - * |
|
| 113 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object |
|
| 114 | - * like this, |
|
| 115 | - * |
|
| 116 | - * eejs.data.test = [ |
|
| 117 | - * my_data, |
|
| 118 | - * ] |
|
| 119 | - * |
|
| 120 | - * If there has already been a scalar value attached to the data object given key, then |
|
| 121 | - * this will throw an exception. |
|
| 122 | - * |
|
| 123 | - * @param string $key Key to attach data to. |
|
| 124 | - * @param string|array $value Value being registered. |
|
| 125 | - * @throws InvalidArgumentException |
|
| 126 | - */ |
|
| 127 | - public function pushData($key, $value) |
|
| 128 | - { |
|
| 129 | - if (isset($this->jsdata[$key]) |
|
| 130 | - && ! is_array($this->jsdata[$key]) |
|
| 131 | - ) { |
|
| 132 | - throw new invalidArgumentException( |
|
| 133 | - sprintf( |
|
| 134 | - __( |
|
| 135 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
| 19 | + /** |
|
| 20 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $jsdata = array(); |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Registry constructor. |
|
| 28 | + * Hooking into WP actions for script registry. |
|
| 29 | + */ |
|
| 30 | + public function __construct() |
|
| 31 | + { |
|
| 32 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 100); |
|
| 33 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 100); |
|
| 34 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
| 35 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Callback for the WP script actions. |
|
| 41 | + * Used to register globally accessible core scripts. |
|
| 42 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
| 43 | + */ |
|
| 44 | + public function scripts() |
|
| 45 | + { |
|
| 46 | + global $wp_version; |
|
| 47 | + wp_register_script( |
|
| 48 | + 'eejs-core', |
|
| 49 | + EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
| 50 | + array(), |
|
| 51 | + espresso_version(), |
|
| 52 | + true |
|
| 53 | + ); |
|
| 54 | + //only run this if WordPress 4.4.0 > is in use. |
|
| 55 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
| 56 | + //js.api |
|
| 57 | + wp_register_script( |
|
| 58 | + 'eejs-api', |
|
| 59 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
| 60 | + array('underscore', 'eejs-core'), |
|
| 61 | + espresso_version(), |
|
| 62 | + true |
|
| 63 | + ); |
|
| 64 | + $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
| 65 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Call back for the script print in frontend and backend. |
|
| 72 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hookpoint. |
|
| 73 | + * @since 4.9.31.rc.015 |
|
| 74 | + */ |
|
| 75 | + public function enqueueData() |
|
| 76 | + { |
|
| 77 | + wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Used to add data to eejs.data object. |
|
| 83 | + * |
|
| 84 | + * Note: Overriding existing data is not allowed. |
|
| 85 | + * |
|
| 86 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
| 87 | + * If the data you add is something like this: |
|
| 88 | + * |
|
| 89 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
| 90 | + * |
|
| 91 | + * It will be exposed in the page source as: |
|
| 92 | + * |
|
| 93 | + * eejs.data.my_plugin_data.foo == gar |
|
| 94 | + * |
|
| 95 | + * @param string $key Key used to access your data |
|
| 96 | + * @param string|array $value Value to attach to key |
|
| 97 | + * @throws InvalidArgumentException |
|
| 98 | + */ |
|
| 99 | + public function addData($key, $value) |
|
| 100 | + { |
|
| 101 | + if ($this->verifyDataNotExisting($key)) { |
|
| 102 | + $this->jsdata[$key] = $value; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
| 109 | + * elements in an array. |
|
| 110 | + * |
|
| 111 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
| 112 | + * |
|
| 113 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object |
|
| 114 | + * like this, |
|
| 115 | + * |
|
| 116 | + * eejs.data.test = [ |
|
| 117 | + * my_data, |
|
| 118 | + * ] |
|
| 119 | + * |
|
| 120 | + * If there has already been a scalar value attached to the data object given key, then |
|
| 121 | + * this will throw an exception. |
|
| 122 | + * |
|
| 123 | + * @param string $key Key to attach data to. |
|
| 124 | + * @param string|array $value Value being registered. |
|
| 125 | + * @throws InvalidArgumentException |
|
| 126 | + */ |
|
| 127 | + public function pushData($key, $value) |
|
| 128 | + { |
|
| 129 | + if (isset($this->jsdata[$key]) |
|
| 130 | + && ! is_array($this->jsdata[$key]) |
|
| 131 | + ) { |
|
| 132 | + throw new invalidArgumentException( |
|
| 133 | + sprintf( |
|
| 134 | + __( |
|
| 135 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
| 136 | 136 | push values to this data element when it is an array.', |
| 137 | - 'event_espresso' |
|
| 138 | - ), |
|
| 139 | - $key, |
|
| 140 | - __METHOD__ |
|
| 141 | - ) |
|
| 142 | - ); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - $this->jsdata[$key][] = $value; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Used to set content used by javascript for a template. |
|
| 151 | - * Note: Overrides of existing registered templates are not allowed. |
|
| 152 | - * |
|
| 153 | - * @param string $template_reference |
|
| 154 | - * @param string $template_content |
|
| 155 | - * @throws InvalidArgumentException |
|
| 156 | - */ |
|
| 157 | - public function addTemplate($template_reference, $template_content) |
|
| 158 | - { |
|
| 159 | - if (! isset($this->jsdata['templates'])) { |
|
| 160 | - $this->jsdata['templates'] = array(); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - //no overrides allowed. |
|
| 164 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
| 165 | - throw new invalidArgumentException( |
|
| 166 | - sprintf( |
|
| 167 | - __( |
|
| 168 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
| 169 | - 'event_espresso' |
|
| 170 | - ), |
|
| 171 | - $template_reference |
|
| 172 | - ) |
|
| 173 | - ); |
|
| 174 | - } else { |
|
| 175 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Retrieve the template content already registered for the given reference. |
|
| 182 | - * @param string $template_reference |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - public function getTemplate($template_reference) |
|
| 186 | - { |
|
| 187 | - return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
| 188 | - ? $this->jsdata['templates'][$template_reference] |
|
| 189 | - : ''; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Retrieve registered data. |
|
| 195 | - * |
|
| 196 | - * @param string $key Name of key to attach data to. |
|
| 197 | - * @return mixed If there is no for the given key, then false is returned. |
|
| 198 | - */ |
|
| 199 | - public function getData($key) |
|
| 200 | - { |
|
| 201 | - return isset($this->jsdata[$key]) |
|
| 202 | - ? $this->jsdata[$key] |
|
| 203 | - : false; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Verifies whether the given data exists already on the jsdata array. |
|
| 211 | - * |
|
| 212 | - * Overriding data is not allowed. |
|
| 213 | - * |
|
| 214 | - * @param string $key Index for data. |
|
| 215 | - * @return bool If valid then return true. |
|
| 216 | - * @throws InvalidArgumentException if data already exists. |
|
| 217 | - */ |
|
| 218 | - protected function verifyDataNotExisting($key) |
|
| 219 | - { |
|
| 220 | - if (isset($this->jsdata[$key])) { |
|
| 221 | - if (is_array($this->jsdata[$key])) { |
|
| 222 | - throw new InvalidArgumentException( |
|
| 223 | - sprintf( |
|
| 224 | - __( |
|
| 225 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
| 137 | + 'event_espresso' |
|
| 138 | + ), |
|
| 139 | + $key, |
|
| 140 | + __METHOD__ |
|
| 141 | + ) |
|
| 142 | + ); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + $this->jsdata[$key][] = $value; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Used to set content used by javascript for a template. |
|
| 151 | + * Note: Overrides of existing registered templates are not allowed. |
|
| 152 | + * |
|
| 153 | + * @param string $template_reference |
|
| 154 | + * @param string $template_content |
|
| 155 | + * @throws InvalidArgumentException |
|
| 156 | + */ |
|
| 157 | + public function addTemplate($template_reference, $template_content) |
|
| 158 | + { |
|
| 159 | + if (! isset($this->jsdata['templates'])) { |
|
| 160 | + $this->jsdata['templates'] = array(); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + //no overrides allowed. |
|
| 164 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
| 165 | + throw new invalidArgumentException( |
|
| 166 | + sprintf( |
|
| 167 | + __( |
|
| 168 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
| 169 | + 'event_espresso' |
|
| 170 | + ), |
|
| 171 | + $template_reference |
|
| 172 | + ) |
|
| 173 | + ); |
|
| 174 | + } else { |
|
| 175 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Retrieve the template content already registered for the given reference. |
|
| 182 | + * @param string $template_reference |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + public function getTemplate($template_reference) |
|
| 186 | + { |
|
| 187 | + return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
| 188 | + ? $this->jsdata['templates'][$template_reference] |
|
| 189 | + : ''; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Retrieve registered data. |
|
| 195 | + * |
|
| 196 | + * @param string $key Name of key to attach data to. |
|
| 197 | + * @return mixed If there is no for the given key, then false is returned. |
|
| 198 | + */ |
|
| 199 | + public function getData($key) |
|
| 200 | + { |
|
| 201 | + return isset($this->jsdata[$key]) |
|
| 202 | + ? $this->jsdata[$key] |
|
| 203 | + : false; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Verifies whether the given data exists already on the jsdata array. |
|
| 211 | + * |
|
| 212 | + * Overriding data is not allowed. |
|
| 213 | + * |
|
| 214 | + * @param string $key Index for data. |
|
| 215 | + * @return bool If valid then return true. |
|
| 216 | + * @throws InvalidArgumentException if data already exists. |
|
| 217 | + */ |
|
| 218 | + protected function verifyDataNotExisting($key) |
|
| 219 | + { |
|
| 220 | + if (isset($this->jsdata[$key])) { |
|
| 221 | + if (is_array($this->jsdata[$key])) { |
|
| 222 | + throw new InvalidArgumentException( |
|
| 223 | + sprintf( |
|
| 224 | + __( |
|
| 225 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
| 226 | 226 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
| 227 | 227 | %2$s method to push your value to the array.', |
| 228 | - 'event_espresso' |
|
| 229 | - ), |
|
| 230 | - $key, |
|
| 231 | - 'pushData()' |
|
| 232 | - ) |
|
| 233 | - ); |
|
| 234 | - } else { |
|
| 235 | - throw new InvalidArgumentException( |
|
| 236 | - sprintf( |
|
| 237 | - __( |
|
| 238 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
| 228 | + 'event_espresso' |
|
| 229 | + ), |
|
| 230 | + $key, |
|
| 231 | + 'pushData()' |
|
| 232 | + ) |
|
| 233 | + ); |
|
| 234 | + } else { |
|
| 235 | + throw new InvalidArgumentException( |
|
| 236 | + sprintf( |
|
| 237 | + __( |
|
| 238 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
| 239 | 239 | allowed. Consider attaching your value to a different key', |
| 240 | - 'event_espresso' |
|
| 241 | - ), |
|
| 242 | - $key |
|
| 243 | - ) |
|
| 244 | - ); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - return true; |
|
| 248 | - } |
|
| 240 | + 'event_espresso' |
|
| 241 | + ), |
|
| 242 | + $key |
|
| 243 | + ) |
|
| 244 | + ); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + return true; |
|
| 248 | + } |
|
| 249 | 249 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -28,633 +28,633 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - public function __construct($routing = true) |
|
| 32 | - { |
|
| 33 | - parent::__construct($routing); |
|
| 34 | - } |
|
| 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 | - ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - protected function _set_page_config() |
|
| 146 | - { |
|
| 147 | - $this->_page_config = array( |
|
| 148 | - 'default' => array( |
|
| 149 | - 'nav' => array( |
|
| 150 | - 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 151 | - 'order' => 10, |
|
| 152 | - ), |
|
| 153 | - 'require_nonce' => false, |
|
| 154 | - ), |
|
| 155 | - 'data_reset' => array( |
|
| 156 | - 'nav' => array( |
|
| 157 | - 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 158 | - 'order' => 20, |
|
| 159 | - ), |
|
| 160 | - 'require_nonce' => false, |
|
| 161 | - ), |
|
| 162 | - 'system_status' => array( |
|
| 163 | - 'nav' => array( |
|
| 164 | - 'label' => esc_html__("System Information", "event_espresso"), |
|
| 165 | - 'order' => 30, |
|
| 166 | - ), |
|
| 167 | - 'require_nonce' => false, |
|
| 168 | - ), |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 176 | - * the migration scripts and all that UI. |
|
| 177 | - */ |
|
| 178 | - public function _maintenance() |
|
| 179 | - { |
|
| 180 | - //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 181 | - //level 2 (everything except maintenance page) |
|
| 182 | - try { |
|
| 183 | - //get the current maintenance level and check if |
|
| 184 | - //we are removed |
|
| 185 | - $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 186 | - $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 187 | - if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 188 | - //we just took the site out of maintenance mode, so notify the user. |
|
| 189 | - //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 190 | - //oh well, we should really be checking for this on addon deactivation anyways |
|
| 191 | - EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 192 | - 'event_espresso')); |
|
| 193 | - $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 194 | - } |
|
| 195 | - //in case an exception is thrown while trying to handle migrations |
|
| 196 | - switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 197 | - case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 198 | - case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 199 | - $show_maintenance_switch = true; |
|
| 200 | - $show_backup_db_text = false; |
|
| 201 | - $show_migration_progress = false; |
|
| 202 | - $script_names = array(); |
|
| 203 | - $addons_should_be_upgraded_first = false; |
|
| 204 | - break; |
|
| 205 | - case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 206 | - $show_maintenance_switch = false; |
|
| 207 | - $show_migration_progress = true; |
|
| 208 | - if (isset($this->_req_data['continue_migration'])) { |
|
| 209 | - $show_backup_db_text = false; |
|
| 210 | - } else { |
|
| 211 | - $show_backup_db_text = true; |
|
| 212 | - } |
|
| 213 | - $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 214 | - ->check_for_applicable_data_migration_scripts(); |
|
| 215 | - $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 216 | - $script_names = array(); |
|
| 217 | - $current_script = null; |
|
| 218 | - foreach ($scripts_needing_to_run as $script) { |
|
| 219 | - if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 220 | - if ( ! $current_script) { |
|
| 221 | - $current_script = $script; |
|
| 222 | - $current_script->migration_page_hooks(); |
|
| 223 | - } |
|
| 224 | - $script_names[] = $script->pretty_name(); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - break; |
|
| 228 | - } |
|
| 229 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 230 | - $exception_thrown = false; |
|
| 231 | - } catch (EE_Error $e) { |
|
| 232 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 233 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 234 | - //and also put the error on it. It only persists for the duration of this request |
|
| 235 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 236 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 237 | - $exception_thrown = true; |
|
| 238 | - } |
|
| 239 | - $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 240 | - $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 241 | - if ($exception_thrown |
|
| 242 | - || ($most_recent_migration |
|
| 243 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 244 | - && $most_recent_migration->is_broken() |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 248 | - $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 249 | - $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 250 | - 'success' => '0', |
|
| 251 | - ), EE_MAINTENANCE_ADMIN_URL); |
|
| 252 | - } elseif ($addons_should_be_upgraded_first) { |
|
| 253 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | - } else { |
|
| 255 | - if ($most_recent_migration |
|
| 256 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 257 | - && $most_recent_migration->can_continue() |
|
| 258 | - ) { |
|
| 259 | - $show_backup_db_text = false; |
|
| 260 | - $show_continue_current_migration_script = true; |
|
| 261 | - $show_most_recent_migration = true; |
|
| 262 | - } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 263 | - $show_most_recent_migration = true; |
|
| 264 | - $show_continue_current_migration_script = false; |
|
| 265 | - } else { |
|
| 266 | - $show_most_recent_migration = false; |
|
| 267 | - $show_continue_current_migration_script = false; |
|
| 268 | - } |
|
| 269 | - if (isset($current_script)) { |
|
| 270 | - $migrates_to = $current_script->migrates_to_version(); |
|
| 271 | - $plugin_slug = $migrates_to['slug']; |
|
| 272 | - $new_version = $migrates_to['version']; |
|
| 273 | - $this->_template_args = array_merge($this->_template_args, array( |
|
| 274 | - 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 275 | - isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 276 | - 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 277 | - $new_version, $plugin_slug) : null, |
|
| 278 | - )); |
|
| 279 | - } |
|
| 280 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 281 | - $this->_template_args = array_merge( |
|
| 282 | - $this->_template_args, |
|
| 283 | - array( |
|
| 284 | - 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 285 | - //flag for showing the most recent migration's status and/or errors |
|
| 286 | - 'show_migration_progress' => $show_migration_progress, |
|
| 287 | - //flag for showing the option to run migrations and see their progress |
|
| 288 | - 'show_backup_db_text' => $show_backup_db_text, |
|
| 289 | - //flag for showing text telling the user to backup their DB |
|
| 290 | - 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 291 | - //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 292 | - 'script_names' => $script_names, |
|
| 293 | - //array of names of scripts that have run |
|
| 294 | - 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 295 | - //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 296 | - 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 297 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 298 | - 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 299 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 300 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 301 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 302 | - 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 303 | - espresso_version()), |
|
| 304 | - ) |
|
| 305 | - ); |
|
| 306 | - //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 307 | - //localize script stuff |
|
| 308 | - wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 309 | - 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 310 | - 'next' => esc_html__("Next", "event_espresso"), |
|
| 311 | - 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 312 | - 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 313 | - "event_espresso"), |
|
| 314 | - 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 315 | - 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 316 | - 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 317 | - )); |
|
| 318 | - } |
|
| 319 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 320 | - //now render the migration options part, and put it in a variable |
|
| 321 | - $migration_options_template_file = apply_filters( |
|
| 322 | - 'FHEE__ee_migration_page__migration_options_template', |
|
| 323 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 324 | - ); |
|
| 325 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 326 | - $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 327 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 328 | - $this->_template_args, true); |
|
| 329 | - $this->display_admin_page_with_sidebar(); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 336 | - */ |
|
| 337 | - public function migration_step() |
|
| 338 | - { |
|
| 339 | - $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 340 | - $this->_return_json(); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * Can be used by js when it notices a response with HTML in it in order |
|
| 347 | - * to log the malformed response |
|
| 348 | - */ |
|
| 349 | - public function add_error_to_migrations_ran() |
|
| 350 | - { |
|
| 351 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 352 | - $this->_template_args['data'] = array('ok' => true); |
|
| 353 | - $this->_return_json(); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 360 | - */ |
|
| 361 | - public function _change_maintenance_level() |
|
| 362 | - { |
|
| 363 | - $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 364 | - if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 365 | - EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 366 | - $success = true; |
|
| 367 | - } else { |
|
| 368 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 369 | - $success = false; |
|
| 370 | - } |
|
| 371 | - $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * a tab with options for resetting and/or deleting EE data |
|
| 378 | - * |
|
| 379 | - * @throws \EE_Error |
|
| 380 | - * @throws \DomainException |
|
| 381 | - */ |
|
| 382 | - public function _data_reset_and_delete() |
|
| 383 | - { |
|
| 384 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 385 | - $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 386 | - 'reset_reservations', |
|
| 387 | - 'reset_reservations', |
|
| 388 | - array(), |
|
| 389 | - 'button button-primary', |
|
| 390 | - '', |
|
| 391 | - false |
|
| 392 | - ); |
|
| 393 | - $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 394 | - 'reset_capabilities', |
|
| 395 | - 'reset_capabilities', |
|
| 396 | - array(), |
|
| 397 | - 'button button-primary', |
|
| 398 | - '', |
|
| 399 | - false |
|
| 400 | - ); |
|
| 401 | - $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 402 | - array('action' => 'delete_db'), |
|
| 403 | - EE_MAINTENANCE_ADMIN_URL |
|
| 404 | - ); |
|
| 405 | - $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 406 | - array('action' => 'reset_db'), |
|
| 407 | - EE_MAINTENANCE_ADMIN_URL |
|
| 408 | - ); |
|
| 409 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 410 | - $this->_template_path, |
|
| 411 | - $this->_template_args, |
|
| 412 | - true |
|
| 413 | - ); |
|
| 414 | - $this->display_admin_page_with_sidebar(); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - protected function _reset_reservations() |
|
| 420 | - { |
|
| 421 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 422 | - EE_Error::add_success( |
|
| 423 | - __( |
|
| 424 | - 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 425 | - 'event_espresso' |
|
| 426 | - ) |
|
| 427 | - ); |
|
| 428 | - } else { |
|
| 429 | - EE_Error::add_success( |
|
| 430 | - __( |
|
| 431 | - 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 432 | - 'event_espresso' |
|
| 433 | - ) |
|
| 434 | - ); |
|
| 435 | - } |
|
| 436 | - $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - |
|
| 441 | - protected function _reset_capabilities() |
|
| 442 | - { |
|
| 443 | - EE_Registry::instance()->CAP->init_caps(true); |
|
| 444 | - EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 445 | - 'event_espresso')); |
|
| 446 | - $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 453 | - * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 454 | - * the fatal error in teh first place) |
|
| 455 | - */ |
|
| 456 | - protected function _reattempt_migration() |
|
| 457 | - { |
|
| 458 | - EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 459 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * shows the big ol' System Information page |
|
| 466 | - */ |
|
| 467 | - public function _system_status() |
|
| 468 | - { |
|
| 469 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 470 | - $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 471 | - $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 472 | - array( |
|
| 473 | - 'action' => 'download_system_status', |
|
| 474 | - ), |
|
| 475 | - EE_MAINTENANCE_ADMIN_URL |
|
| 476 | - ); |
|
| 477 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 478 | - $this->_template_args, true); |
|
| 479 | - $this->display_admin_page_with_sidebar(); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 484 | - */ |
|
| 485 | - public function _download_system_status() |
|
| 486 | - { |
|
| 487 | - $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 488 | - header( 'Content-Disposition: attachment' ); |
|
| 489 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 490 | - echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 491 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 492 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 493 | - die; |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - |
|
| 497 | - |
|
| 498 | - public function _send_migration_crash_report() |
|
| 499 | - { |
|
| 500 | - $from = $this->_req_data['from']; |
|
| 501 | - $from_name = $this->_req_data['from_name']; |
|
| 502 | - $body = $this->_req_data['body']; |
|
| 503 | - try { |
|
| 504 | - $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 505 | - 'Migration Crash Report', |
|
| 506 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 507 | - array( |
|
| 508 | - "from:$from_name<$from>", |
|
| 509 | - // 'content-type:text/html charset=UTF-8' |
|
| 510 | - )); |
|
| 511 | - } catch (Exception $e) { |
|
| 512 | - $success = false; |
|
| 513 | - } |
|
| 514 | - $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 515 | - esc_html__("sent", "event_espresso"), |
|
| 516 | - array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - |
|
| 521 | - public function _confirm_migration_crash_report_sent() |
|
| 522 | - { |
|
| 523 | - try { |
|
| 524 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 525 | - } catch (EE_Error $e) { |
|
| 526 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 527 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 528 | - //and also put the error on it. It only persists for the duration of this request |
|
| 529 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 530 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 531 | - } |
|
| 532 | - $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 533 | - $this->_template_args['success'] = $success; |
|
| 534 | - $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 535 | - $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 536 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 537 | - $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 538 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 539 | - $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 540 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 541 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 542 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 543 | - $this->_template_args, true); |
|
| 544 | - $this->display_admin_page_with_sidebar(); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * Resets the entire EE4 database. |
|
| 551 | - * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 552 | - * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 553 | - * |
|
| 554 | - * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 555 | - * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 556 | - */ |
|
| 557 | - public function _reset_db($nuke_old_ee4_data = true) |
|
| 558 | - { |
|
| 559 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 560 | - if ($nuke_old_ee4_data) { |
|
| 561 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 562 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 563 | - EEH_Activation::remove_cron_tasks(); |
|
| 564 | - } |
|
| 565 | - //make sure when we reset the registry's config that it |
|
| 566 | - //switches to using the new singleton |
|
| 567 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 568 | - EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 569 | - EE_System::instance()->redirect_to_about_ee(); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Deletes ALL EE tables, Records, and Options from the database. |
|
| 576 | - */ |
|
| 577 | - public function _delete_db() |
|
| 578 | - { |
|
| 579 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 580 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 581 | - EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 582 | - EEH_Activation::remove_cron_tasks(); |
|
| 583 | - EEH_Activation::deactivate_event_espresso(); |
|
| 584 | - wp_safe_redirect(admin_url('plugins.php')); |
|
| 585 | - exit; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 592 | - */ |
|
| 593 | - public function _rerun_migration_from_ee3() |
|
| 594 | - { |
|
| 595 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 596 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 597 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 598 | - //set the db state to something that will require migrations |
|
| 599 | - update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 600 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 601 | - $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - |
|
| 605 | - |
|
| 606 | - //none of the below group are currently used for Gateway Settings |
|
| 607 | - protected function _add_screen_options() |
|
| 608 | - { |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - protected function _add_feature_pointers() |
|
| 614 | - { |
|
| 615 | - } |
|
| 616 | - |
|
| 31 | + public function __construct($routing = true) |
|
| 32 | + { |
|
| 33 | + parent::__construct($routing); |
|
| 34 | + } |
|
| 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 | + ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + protected function _set_page_config() |
|
| 146 | + { |
|
| 147 | + $this->_page_config = array( |
|
| 148 | + 'default' => array( |
|
| 149 | + 'nav' => array( |
|
| 150 | + 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 151 | + 'order' => 10, |
|
| 152 | + ), |
|
| 153 | + 'require_nonce' => false, |
|
| 154 | + ), |
|
| 155 | + 'data_reset' => array( |
|
| 156 | + 'nav' => array( |
|
| 157 | + 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 158 | + 'order' => 20, |
|
| 159 | + ), |
|
| 160 | + 'require_nonce' => false, |
|
| 161 | + ), |
|
| 162 | + 'system_status' => array( |
|
| 163 | + 'nav' => array( |
|
| 164 | + 'label' => esc_html__("System Information", "event_espresso"), |
|
| 165 | + 'order' => 30, |
|
| 166 | + ), |
|
| 167 | + 'require_nonce' => false, |
|
| 168 | + ), |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 176 | + * the migration scripts and all that UI. |
|
| 177 | + */ |
|
| 178 | + public function _maintenance() |
|
| 179 | + { |
|
| 180 | + //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 181 | + //level 2 (everything except maintenance page) |
|
| 182 | + try { |
|
| 183 | + //get the current maintenance level and check if |
|
| 184 | + //we are removed |
|
| 185 | + $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 186 | + $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 187 | + if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 188 | + //we just took the site out of maintenance mode, so notify the user. |
|
| 189 | + //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 190 | + //oh well, we should really be checking for this on addon deactivation anyways |
|
| 191 | + EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 192 | + 'event_espresso')); |
|
| 193 | + $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 194 | + } |
|
| 195 | + //in case an exception is thrown while trying to handle migrations |
|
| 196 | + switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 197 | + case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 198 | + case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 199 | + $show_maintenance_switch = true; |
|
| 200 | + $show_backup_db_text = false; |
|
| 201 | + $show_migration_progress = false; |
|
| 202 | + $script_names = array(); |
|
| 203 | + $addons_should_be_upgraded_first = false; |
|
| 204 | + break; |
|
| 205 | + case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 206 | + $show_maintenance_switch = false; |
|
| 207 | + $show_migration_progress = true; |
|
| 208 | + if (isset($this->_req_data['continue_migration'])) { |
|
| 209 | + $show_backup_db_text = false; |
|
| 210 | + } else { |
|
| 211 | + $show_backup_db_text = true; |
|
| 212 | + } |
|
| 213 | + $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 214 | + ->check_for_applicable_data_migration_scripts(); |
|
| 215 | + $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 216 | + $script_names = array(); |
|
| 217 | + $current_script = null; |
|
| 218 | + foreach ($scripts_needing_to_run as $script) { |
|
| 219 | + if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 220 | + if ( ! $current_script) { |
|
| 221 | + $current_script = $script; |
|
| 222 | + $current_script->migration_page_hooks(); |
|
| 223 | + } |
|
| 224 | + $script_names[] = $script->pretty_name(); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + break; |
|
| 228 | + } |
|
| 229 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 230 | + $exception_thrown = false; |
|
| 231 | + } catch (EE_Error $e) { |
|
| 232 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 233 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 234 | + //and also put the error on it. It only persists for the duration of this request |
|
| 235 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 236 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 237 | + $exception_thrown = true; |
|
| 238 | + } |
|
| 239 | + $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 240 | + $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 241 | + if ($exception_thrown |
|
| 242 | + || ($most_recent_migration |
|
| 243 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 244 | + && $most_recent_migration->is_broken() |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 248 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 249 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 250 | + 'success' => '0', |
|
| 251 | + ), EE_MAINTENANCE_ADMIN_URL); |
|
| 252 | + } elseif ($addons_should_be_upgraded_first) { |
|
| 253 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | + } else { |
|
| 255 | + if ($most_recent_migration |
|
| 256 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 257 | + && $most_recent_migration->can_continue() |
|
| 258 | + ) { |
|
| 259 | + $show_backup_db_text = false; |
|
| 260 | + $show_continue_current_migration_script = true; |
|
| 261 | + $show_most_recent_migration = true; |
|
| 262 | + } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 263 | + $show_most_recent_migration = true; |
|
| 264 | + $show_continue_current_migration_script = false; |
|
| 265 | + } else { |
|
| 266 | + $show_most_recent_migration = false; |
|
| 267 | + $show_continue_current_migration_script = false; |
|
| 268 | + } |
|
| 269 | + if (isset($current_script)) { |
|
| 270 | + $migrates_to = $current_script->migrates_to_version(); |
|
| 271 | + $plugin_slug = $migrates_to['slug']; |
|
| 272 | + $new_version = $migrates_to['version']; |
|
| 273 | + $this->_template_args = array_merge($this->_template_args, array( |
|
| 274 | + 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 275 | + isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 276 | + 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 277 | + $new_version, $plugin_slug) : null, |
|
| 278 | + )); |
|
| 279 | + } |
|
| 280 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 281 | + $this->_template_args = array_merge( |
|
| 282 | + $this->_template_args, |
|
| 283 | + array( |
|
| 284 | + 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 285 | + //flag for showing the most recent migration's status and/or errors |
|
| 286 | + 'show_migration_progress' => $show_migration_progress, |
|
| 287 | + //flag for showing the option to run migrations and see their progress |
|
| 288 | + 'show_backup_db_text' => $show_backup_db_text, |
|
| 289 | + //flag for showing text telling the user to backup their DB |
|
| 290 | + 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 291 | + //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 292 | + 'script_names' => $script_names, |
|
| 293 | + //array of names of scripts that have run |
|
| 294 | + 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 295 | + //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 296 | + 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 297 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 298 | + 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 299 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 300 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 301 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 302 | + 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 303 | + espresso_version()), |
|
| 304 | + ) |
|
| 305 | + ); |
|
| 306 | + //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 307 | + //localize script stuff |
|
| 308 | + wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 309 | + 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 310 | + 'next' => esc_html__("Next", "event_espresso"), |
|
| 311 | + 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 312 | + 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 313 | + "event_espresso"), |
|
| 314 | + 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 315 | + 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 316 | + 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 317 | + )); |
|
| 318 | + } |
|
| 319 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 320 | + //now render the migration options part, and put it in a variable |
|
| 321 | + $migration_options_template_file = apply_filters( |
|
| 322 | + 'FHEE__ee_migration_page__migration_options_template', |
|
| 323 | + EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 324 | + ); |
|
| 325 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 326 | + $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 327 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 328 | + $this->_template_args, true); |
|
| 329 | + $this->display_admin_page_with_sidebar(); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 336 | + */ |
|
| 337 | + public function migration_step() |
|
| 338 | + { |
|
| 339 | + $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 340 | + $this->_return_json(); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * Can be used by js when it notices a response with HTML in it in order |
|
| 347 | + * to log the malformed response |
|
| 348 | + */ |
|
| 349 | + public function add_error_to_migrations_ran() |
|
| 350 | + { |
|
| 351 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 352 | + $this->_template_args['data'] = array('ok' => true); |
|
| 353 | + $this->_return_json(); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 360 | + */ |
|
| 361 | + public function _change_maintenance_level() |
|
| 362 | + { |
|
| 363 | + $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 364 | + if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 365 | + EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 366 | + $success = true; |
|
| 367 | + } else { |
|
| 368 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 369 | + $success = false; |
|
| 370 | + } |
|
| 371 | + $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * a tab with options for resetting and/or deleting EE data |
|
| 378 | + * |
|
| 379 | + * @throws \EE_Error |
|
| 380 | + * @throws \DomainException |
|
| 381 | + */ |
|
| 382 | + public function _data_reset_and_delete() |
|
| 383 | + { |
|
| 384 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 385 | + $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 386 | + 'reset_reservations', |
|
| 387 | + 'reset_reservations', |
|
| 388 | + array(), |
|
| 389 | + 'button button-primary', |
|
| 390 | + '', |
|
| 391 | + false |
|
| 392 | + ); |
|
| 393 | + $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 394 | + 'reset_capabilities', |
|
| 395 | + 'reset_capabilities', |
|
| 396 | + array(), |
|
| 397 | + 'button button-primary', |
|
| 398 | + '', |
|
| 399 | + false |
|
| 400 | + ); |
|
| 401 | + $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 402 | + array('action' => 'delete_db'), |
|
| 403 | + EE_MAINTENANCE_ADMIN_URL |
|
| 404 | + ); |
|
| 405 | + $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 406 | + array('action' => 'reset_db'), |
|
| 407 | + EE_MAINTENANCE_ADMIN_URL |
|
| 408 | + ); |
|
| 409 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 410 | + $this->_template_path, |
|
| 411 | + $this->_template_args, |
|
| 412 | + true |
|
| 413 | + ); |
|
| 414 | + $this->display_admin_page_with_sidebar(); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + protected function _reset_reservations() |
|
| 420 | + { |
|
| 421 | + if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 422 | + EE_Error::add_success( |
|
| 423 | + __( |
|
| 424 | + 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 425 | + 'event_espresso' |
|
| 426 | + ) |
|
| 427 | + ); |
|
| 428 | + } else { |
|
| 429 | + EE_Error::add_success( |
|
| 430 | + __( |
|
| 431 | + 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 432 | + 'event_espresso' |
|
| 433 | + ) |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + |
|
| 441 | + protected function _reset_capabilities() |
|
| 442 | + { |
|
| 443 | + EE_Registry::instance()->CAP->init_caps(true); |
|
| 444 | + EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 445 | + 'event_espresso')); |
|
| 446 | + $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 453 | + * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 454 | + * the fatal error in teh first place) |
|
| 455 | + */ |
|
| 456 | + protected function _reattempt_migration() |
|
| 457 | + { |
|
| 458 | + EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 459 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * shows the big ol' System Information page |
|
| 466 | + */ |
|
| 467 | + public function _system_status() |
|
| 468 | + { |
|
| 469 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 470 | + $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 471 | + $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 472 | + array( |
|
| 473 | + 'action' => 'download_system_status', |
|
| 474 | + ), |
|
| 475 | + EE_MAINTENANCE_ADMIN_URL |
|
| 476 | + ); |
|
| 477 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 478 | + $this->_template_args, true); |
|
| 479 | + $this->display_admin_page_with_sidebar(); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 484 | + */ |
|
| 485 | + public function _download_system_status() |
|
| 486 | + { |
|
| 487 | + $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 488 | + header( 'Content-Disposition: attachment' ); |
|
| 489 | + header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 490 | + echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 491 | + echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 492 | + echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 493 | + die; |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + |
|
| 497 | + |
|
| 498 | + public function _send_migration_crash_report() |
|
| 499 | + { |
|
| 500 | + $from = $this->_req_data['from']; |
|
| 501 | + $from_name = $this->_req_data['from_name']; |
|
| 502 | + $body = $this->_req_data['body']; |
|
| 503 | + try { |
|
| 504 | + $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 505 | + 'Migration Crash Report', |
|
| 506 | + $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 507 | + array( |
|
| 508 | + "from:$from_name<$from>", |
|
| 509 | + // 'content-type:text/html charset=UTF-8' |
|
| 510 | + )); |
|
| 511 | + } catch (Exception $e) { |
|
| 512 | + $success = false; |
|
| 513 | + } |
|
| 514 | + $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 515 | + esc_html__("sent", "event_espresso"), |
|
| 516 | + array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + |
|
| 521 | + public function _confirm_migration_crash_report_sent() |
|
| 522 | + { |
|
| 523 | + try { |
|
| 524 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 525 | + } catch (EE_Error $e) { |
|
| 526 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 527 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 528 | + //and also put the error on it. It only persists for the duration of this request |
|
| 529 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 530 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 531 | + } |
|
| 532 | + $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 533 | + $this->_template_args['success'] = $success; |
|
| 534 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 535 | + $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 536 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 537 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 538 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 539 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 540 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 541 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 542 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 543 | + $this->_template_args, true); |
|
| 544 | + $this->display_admin_page_with_sidebar(); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * Resets the entire EE4 database. |
|
| 551 | + * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 552 | + * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 553 | + * |
|
| 554 | + * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 555 | + * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 556 | + */ |
|
| 557 | + public function _reset_db($nuke_old_ee4_data = true) |
|
| 558 | + { |
|
| 559 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 560 | + if ($nuke_old_ee4_data) { |
|
| 561 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 562 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 563 | + EEH_Activation::remove_cron_tasks(); |
|
| 564 | + } |
|
| 565 | + //make sure when we reset the registry's config that it |
|
| 566 | + //switches to using the new singleton |
|
| 567 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 568 | + EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 569 | + EE_System::instance()->redirect_to_about_ee(); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Deletes ALL EE tables, Records, and Options from the database. |
|
| 576 | + */ |
|
| 577 | + public function _delete_db() |
|
| 578 | + { |
|
| 579 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 580 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 581 | + EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 582 | + EEH_Activation::remove_cron_tasks(); |
|
| 583 | + EEH_Activation::deactivate_event_espresso(); |
|
| 584 | + wp_safe_redirect(admin_url('plugins.php')); |
|
| 585 | + exit; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 592 | + */ |
|
| 593 | + public function _rerun_migration_from_ee3() |
|
| 594 | + { |
|
| 595 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 596 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 597 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 598 | + //set the db state to something that will require migrations |
|
| 599 | + update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 600 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 601 | + $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + |
|
| 605 | + |
|
| 606 | + //none of the below group are currently used for Gateway Settings |
|
| 607 | + protected function _add_screen_options() |
|
| 608 | + { |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + protected function _add_feature_pointers() |
|
| 614 | + { |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | - public function admin_init() |
|
| 620 | - { |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - |
|
| 624 | - |
|
| 625 | - public function admin_notices() |
|
| 626 | - { |
|
| 627 | - } |
|
| 628 | - |
|
| 619 | + public function admin_init() |
|
| 620 | + { |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + |
|
| 624 | + |
|
| 625 | + public function admin_notices() |
|
| 626 | + { |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | 629 | |
| 630 | 630 | |
| 631 | - public function admin_footer_scripts() |
|
| 632 | - { |
|
| 633 | - } |
|
| 631 | + public function admin_footer_scripts() |
|
| 632 | + { |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | |
| 637 | - public function load_scripts_styles() |
|
| 638 | - { |
|
| 639 | - wp_enqueue_script('ee_admin_js'); |
|
| 637 | + public function load_scripts_styles() |
|
| 638 | + { |
|
| 639 | + wp_enqueue_script('ee_admin_js'); |
|
| 640 | 640 | // wp_enqueue_media(); |
| 641 | 641 | // wp_enqueue_script('media-upload'); |
| 642 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 643 | - EVENT_ESPRESSO_VERSION, true); |
|
| 644 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 645 | - EVENT_ESPRESSO_VERSION); |
|
| 646 | - wp_enqueue_style('espresso_maintenance'); |
|
| 647 | - } |
|
| 642 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 643 | + EVENT_ESPRESSO_VERSION, true); |
|
| 644 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 645 | + EVENT_ESPRESSO_VERSION); |
|
| 646 | + wp_enqueue_style('espresso_maintenance'); |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | 649 | |
| 650 | 650 | |
| 651 | - public function load_scripts_styles_default() |
|
| 652 | - { |
|
| 653 | - //styles |
|
| 651 | + public function load_scripts_styles_default() |
|
| 652 | + { |
|
| 653 | + //styles |
|
| 654 | 654 | // wp_enqueue_style('ee-text-links'); |
| 655 | 655 | // //scripts |
| 656 | 656 | // wp_enqueue_script('ee-text-links'); |
| 657 | - } |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | 659 | |
| 660 | 660 | |
@@ -244,13 +244,13 @@ discard block |
||
| 244 | 244 | && $most_recent_migration->is_broken() |
| 245 | 245 | ) |
| 246 | 246 | ) { |
| 247 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 247 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php'; |
|
| 248 | 248 | $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
| 249 | 249 | $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
| 250 | 250 | 'success' => '0', |
| 251 | 251 | ), EE_MAINTENANCE_ADMIN_URL); |
| 252 | 252 | } elseif ($addons_should_be_upgraded_first) { |
| 253 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 253 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | 254 | } else { |
| 255 | 255 | if ($most_recent_migration |
| 256 | 256 | && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $new_version, $plugin_slug) : null, |
| 278 | 278 | )); |
| 279 | 279 | } |
| 280 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 280 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php'; |
|
| 281 | 281 | $this->_template_args = array_merge( |
| 282 | 282 | $this->_template_args, |
| 283 | 283 | array( |
@@ -316,13 +316,13 @@ discard block |
||
| 316 | 316 | 'status_completed' => EE_Data_Migration_Manager::status_completed, |
| 317 | 317 | )); |
| 318 | 318 | } |
| 319 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 319 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration |
|
| 320 | 320 | //now render the migration options part, and put it in a variable |
| 321 | 321 | $migration_options_template_file = apply_filters( |
| 322 | 322 | 'FHEE__ee_migration_page__migration_options_template', |
| 323 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 323 | + EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php' |
|
| 324 | 324 | ); |
| 325 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 325 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true); |
|
| 326 | 326 | $this->_template_args['migration_options_html'] = $migration_options_html; |
| 327 | 327 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 328 | 328 | $this->_template_args, true); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | public function _data_reset_and_delete() |
| 383 | 383 | { |
| 384 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 384 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php'; |
|
| 385 | 385 | $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
| 386 | 386 | 'reset_reservations', |
| 387 | 387 | 'reset_reservations', |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | protected function _reset_reservations() |
| 420 | 420 | { |
| 421 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 421 | + if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 422 | 422 | EE_Error::add_success( |
| 423 | 423 | __( |
| 424 | 424 | 'Ticket and datetime reserved counts have been successfully reset.', |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | public function _system_status() |
| 468 | 468 | { |
| 469 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 469 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php'; |
|
| 470 | 470 | $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
| 471 | 471 | $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
| 472 | 472 | array( |
@@ -485,11 +485,11 @@ discard block |
||
| 485 | 485 | public function _download_system_status() |
| 486 | 486 | { |
| 487 | 487 | $status_info = EEM_System_Status::instance()->get_system_stati(); |
| 488 | - header( 'Content-Disposition: attachment' ); |
|
| 489 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 488 | + header('Content-Disposition: attachment'); |
|
| 489 | + header("Content-Disposition: attachment; filename=system_status_".sanitize_key(site_url()).".html"); |
|
| 490 | 490 | echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
| 491 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 492 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 491 | + echo "<h1>System Information for ".site_url()."</h1>"; |
|
| 492 | + echo EEH_Template::layout_array_as_table($status_info); |
|
| 493 | 493 | die; |
| 494 | 494 | } |
| 495 | 495 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | try { |
| 504 | 504 | $success = wp_mail(EE_SUPPORT_EMAIL, |
| 505 | 505 | 'Migration Crash Report', |
| 506 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 506 | + $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 507 | 507 | array( |
| 508 | 508 | "from:$from_name<$from>", |
| 509 | 509 | // 'content-type:text/html charset=UTF-8' |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | EE_MAINTENANCE_ADMIN_URL); |
| 539 | 539 | $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
| 540 | 540 | EE_MAINTENANCE_ADMIN_URL); |
| 541 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 541 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 542 | 542 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 543 | 543 | $this->_template_args, true); |
| 544 | 544 | $this->display_admin_page_with_sidebar(); |
@@ -639,9 +639,9 @@ discard block |
||
| 639 | 639 | wp_enqueue_script('ee_admin_js'); |
| 640 | 640 | // wp_enqueue_media(); |
| 641 | 641 | // wp_enqueue_script('media-upload'); |
| 642 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 642 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), |
|
| 643 | 643 | EVENT_ESPRESSO_VERSION, true); |
| 644 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 644 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), |
|
| 645 | 645 | EVENT_ESPRESSO_VERSION); |
| 646 | 646 | wp_enqueue_style('espresso_maintenance'); |
| 647 | 647 | } |
@@ -25,120 +25,120 @@ |
||
| 25 | 25 | class JsonModelSchema |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var \EEM_Base |
|
| 30 | - */ |
|
| 31 | - protected $model; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * JsonModelSchema constructor. |
|
| 35 | - * |
|
| 36 | - * @param \EEM_Base $model |
|
| 37 | - */ |
|
| 38 | - public function __construct(EEM_Base $model) |
|
| 39 | - { |
|
| 40 | - $this->model = $model; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Return the schema for a given model from a given model. |
|
| 45 | - * @param \EEM_Base $model |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - public function getModelSchema() |
|
| 49 | - { |
|
| 50 | - return $this->getModelSchemaForRelations( |
|
| 51 | - $this->model->relation_settings(), |
|
| 52 | - $this->getModelSchemaForFields( |
|
| 53 | - $this->model->field_settings(), |
|
| 54 | - $this->getInitialSchemaStructure() |
|
| 55 | - ) |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Get the schema for a given set of model fields. |
|
| 62 | - * @param \EE_Model_Field_Base[] $model_fields |
|
| 63 | - * @return array |
|
| 64 | - */ |
|
| 65 | - public function getModelSchemaForFields(array $model_fields, array $schema) |
|
| 66 | - { |
|
| 67 | - foreach ($model_fields as $field => $model_field) { |
|
| 68 | - if (! $model_field instanceof EE_Model_Field_Base) { |
|
| 69 | - continue; |
|
| 70 | - } |
|
| 71 | - $schema['properties'][$field] = $model_field->getSchema(); |
|
| 72 | - |
|
| 73 | - //if this is a primary key field add the primary key item |
|
| 74 | - if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
| 75 | - $schema['properties'][$field]['primary_key'] = true; |
|
| 76 | - if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
| 77 | - $schema['properties'][$field]['readonly'] = true; |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - //if this is a foreign key field add the foreign key item |
|
| 82 | - if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
| 83 | - $schema['properties'][$field]['foreign_key'] = array( |
|
| 84 | - 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
| 85 | - 'type' => 'array', |
|
| 86 | - 'enum' => $model_field->get_model_class_names_pointed_to() |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - return $schema; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Get the schema for a given set of model relations |
|
| 96 | - * @param EE_Model_Relation_Base[] $relations_on_model |
|
| 97 | - * @return array |
|
| 98 | - */ |
|
| 99 | - public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
| 100 | - { |
|
| 101 | - foreach ($relations_on_model as $model_name => $relation) { |
|
| 102 | - if (! $relation instanceof EE_Model_Relation_Base) { |
|
| 103 | - continue; |
|
| 104 | - } |
|
| 105 | - $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
| 106 | - ? strtolower($model_name) |
|
| 107 | - : EEH_Inflector::pluralize_and_lower($model_name); |
|
| 108 | - $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
| 109 | - $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
| 110 | - } |
|
| 111 | - return $schema; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Outputs the schema header for a model. |
|
| 117 | - * @param \EEM_Base $model |
|
| 118 | - * @return array |
|
| 119 | - */ |
|
| 120 | - public function getInitialSchemaStructure() |
|
| 121 | - { |
|
| 122 | - return array( |
|
| 123 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 124 | - 'title' => $this->model->get_this_model_name(), |
|
| 125 | - 'type' => 'object', |
|
| 126 | - 'properties' => array() |
|
| 127 | - ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Allows one to just use the object as a string to get the json. |
|
| 133 | - * eg. |
|
| 134 | - * |
|
| 135 | - * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
| 136 | - * echo $json_schema; //outputs the schema as a json formatted string. |
|
| 137 | - * |
|
| 138 | - * @return bool|false|mixed|string |
|
| 139 | - */ |
|
| 140 | - public function __toString() |
|
| 141 | - { |
|
| 142 | - return wp_json_encode($this->getModelSchema()); |
|
| 143 | - } |
|
| 28 | + /** |
|
| 29 | + * @var \EEM_Base |
|
| 30 | + */ |
|
| 31 | + protected $model; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * JsonModelSchema constructor. |
|
| 35 | + * |
|
| 36 | + * @param \EEM_Base $model |
|
| 37 | + */ |
|
| 38 | + public function __construct(EEM_Base $model) |
|
| 39 | + { |
|
| 40 | + $this->model = $model; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Return the schema for a given model from a given model. |
|
| 45 | + * @param \EEM_Base $model |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + public function getModelSchema() |
|
| 49 | + { |
|
| 50 | + return $this->getModelSchemaForRelations( |
|
| 51 | + $this->model->relation_settings(), |
|
| 52 | + $this->getModelSchemaForFields( |
|
| 53 | + $this->model->field_settings(), |
|
| 54 | + $this->getInitialSchemaStructure() |
|
| 55 | + ) |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Get the schema for a given set of model fields. |
|
| 62 | + * @param \EE_Model_Field_Base[] $model_fields |
|
| 63 | + * @return array |
|
| 64 | + */ |
|
| 65 | + public function getModelSchemaForFields(array $model_fields, array $schema) |
|
| 66 | + { |
|
| 67 | + foreach ($model_fields as $field => $model_field) { |
|
| 68 | + if (! $model_field instanceof EE_Model_Field_Base) { |
|
| 69 | + continue; |
|
| 70 | + } |
|
| 71 | + $schema['properties'][$field] = $model_field->getSchema(); |
|
| 72 | + |
|
| 73 | + //if this is a primary key field add the primary key item |
|
| 74 | + if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
| 75 | + $schema['properties'][$field]['primary_key'] = true; |
|
| 76 | + if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
| 77 | + $schema['properties'][$field]['readonly'] = true; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + //if this is a foreign key field add the foreign key item |
|
| 82 | + if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
| 83 | + $schema['properties'][$field]['foreign_key'] = array( |
|
| 84 | + 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
| 85 | + 'type' => 'array', |
|
| 86 | + 'enum' => $model_field->get_model_class_names_pointed_to() |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + return $schema; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Get the schema for a given set of model relations |
|
| 96 | + * @param EE_Model_Relation_Base[] $relations_on_model |
|
| 97 | + * @return array |
|
| 98 | + */ |
|
| 99 | + public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
| 100 | + { |
|
| 101 | + foreach ($relations_on_model as $model_name => $relation) { |
|
| 102 | + if (! $relation instanceof EE_Model_Relation_Base) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 105 | + $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
| 106 | + ? strtolower($model_name) |
|
| 107 | + : EEH_Inflector::pluralize_and_lower($model_name); |
|
| 108 | + $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
| 109 | + $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
| 110 | + } |
|
| 111 | + return $schema; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Outputs the schema header for a model. |
|
| 117 | + * @param \EEM_Base $model |
|
| 118 | + * @return array |
|
| 119 | + */ |
|
| 120 | + public function getInitialSchemaStructure() |
|
| 121 | + { |
|
| 122 | + return array( |
|
| 123 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
| 124 | + 'title' => $this->model->get_this_model_name(), |
|
| 125 | + 'type' => 'object', |
|
| 126 | + 'properties' => array() |
|
| 127 | + ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Allows one to just use the object as a string to get the json. |
|
| 133 | + * eg. |
|
| 134 | + * |
|
| 135 | + * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
| 136 | + * echo $json_schema; //outputs the schema as a json formatted string. |
|
| 137 | + * |
|
| 138 | + * @return bool|false|mixed|string |
|
| 139 | + */ |
|
| 140 | + public function __toString() |
|
| 141 | + { |
|
| 142 | + return wp_json_encode($this->getModelSchema()); |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -362,22 +362,22 @@ |
||
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | |
| 365 | - /** |
|
| 366 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
| 367 | - * @throws \EE_Error |
|
| 368 | - */ |
|
| 369 | - public function get_total_line_items_just_added_to_cart() |
|
| 370 | - { |
|
| 371 | - return $this->get_all(array( |
|
| 372 | - array( |
|
| 373 | - 'TXN_ID' => 0, |
|
| 374 | - 'LIN_type' => 'total', |
|
| 375 | - 'LIN_timestamp' => array( |
|
| 376 | - '>', |
|
| 377 | - time() - EE_Registry::instance()->SSN->lifespan() |
|
| 378 | - ), ) |
|
| 379 | - )); |
|
| 380 | - } |
|
| 365 | + /** |
|
| 366 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
| 367 | + * @throws \EE_Error |
|
| 368 | + */ |
|
| 369 | + public function get_total_line_items_just_added_to_cart() |
|
| 370 | + { |
|
| 371 | + return $this->get_all(array( |
|
| 372 | + array( |
|
| 373 | + 'TXN_ID' => 0, |
|
| 374 | + 'LIN_type' => 'total', |
|
| 375 | + 'LIN_timestamp' => array( |
|
| 376 | + '>', |
|
| 377 | + time() - EE_Registry::instance()->SSN->lifespan() |
|
| 378 | + ), ) |
|
| 379 | + )); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | |
@@ -105,41 +105,41 @@ discard block |
||
| 105 | 105 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
| 106 | 106 | * @return \EEM_Line_Item |
| 107 | 107 | */ |
| 108 | - protected function __construct( $timezone ) { |
|
| 109 | - $this->singular_item = __('Line Item','event_espresso'); |
|
| 110 | - $this->plural_item = __('Line Items','event_espresso'); |
|
| 108 | + protected function __construct($timezone) { |
|
| 109 | + $this->singular_item = __('Line Item', 'event_espresso'); |
|
| 110 | + $this->plural_item = __('Line Items', 'event_espresso'); |
|
| 111 | 111 | |
| 112 | 112 | $this->_tables = array( |
| 113 | - 'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID') |
|
| 113 | + 'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID') |
|
| 114 | 114 | ); |
| 115 | - $line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) ); |
|
| 115 | + $line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event')); |
|
| 116 | 116 | $this->_fields = array( |
| 117 | 117 | 'Line_Item' => array( |
| 118 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ), |
|
| 119 | - 'LIN_code' => new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ), |
|
| 120 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ), |
|
| 121 | - 'LIN_name' => new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ), |
|
| 122 | - 'LIN_desc' => new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ), |
|
| 123 | - 'LIN_unit_price' => new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ), |
|
| 124 | - 'LIN_percent' => new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ), |
|
| 125 | - 'LIN_is_taxable' => new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ), |
|
| 126 | - 'LIN_order' => new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ), |
|
| 127 | - 'LIN_total' => new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ), |
|
| 128 | - 'LIN_quantity' => new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ), |
|
| 129 | - 'LIN_parent' => new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ), |
|
| 130 | - 'LIN_type' => new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array( |
|
| 118 | + 'LIN_ID' => new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")), |
|
| 119 | + 'LIN_code' => new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE), |
|
| 120 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'), |
|
| 121 | + 'LIN_name' => new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''), |
|
| 122 | + 'LIN_desc' => new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE), |
|
| 123 | + 'LIN_unit_price' => new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0), |
|
| 124 | + 'LIN_percent' => new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0), |
|
| 125 | + 'LIN_is_taxable' => new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE), |
|
| 126 | + 'LIN_order' => new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1), |
|
| 127 | + 'LIN_total' => new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0), |
|
| 128 | + 'LIN_quantity' => new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1), |
|
| 129 | + 'LIN_parent' => new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL), |
|
| 130 | + 'LIN_type' => new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array( |
|
| 131 | 131 | self::type_line_item => __("Line Item", "event_espresso"), |
| 132 | 132 | self::type_sub_line_item => __("Sub-Item", "event_espresso"), |
| 133 | 133 | self::type_sub_total => __("Subtotal", "event_espresso"), |
| 134 | 134 | self::type_tax_sub_total => __("Tax Subtotal", "event_espresso"), |
| 135 | 135 | self::type_tax => __("Tax", "event_espresso"), |
| 136 | 136 | self::type_total => __("Total", "event_espresso"), |
| 137 | - self::type_cancellation => __( 'Cancellation', 'event_espresso' ) |
|
| 137 | + self::type_cancellation => __('Cancellation', 'event_espresso') |
|
| 138 | 138 | ) |
| 139 | 139 | ), |
| 140 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ), |
|
| 141 | - 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ), |
|
| 142 | - 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
| 140 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for), |
|
| 141 | + 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for), |
|
| 142 | + 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
| 143 | 143 | ) |
| 144 | 144 | ); |
| 145 | 145 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | ); |
| 151 | 151 | $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
| 152 | 152 | $this->_caps_slug = 'transactions'; |
| 153 | - parent::__construct( $timezone ); |
|
| 153 | + parent::__construct($timezone); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | * @param EE_Transaction|int $transaction |
| 162 | 162 | * @return EE_Line_Item[] |
| 163 | 163 | */ |
| 164 | - public function get_all_of_type_for_transaction( $line_item_type, $transaction ){ |
|
| 165 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
| 166 | - return $this->get_all( array( array( |
|
| 164 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) { |
|
| 165 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
| 166 | + return $this->get_all(array(array( |
|
| 167 | 167 | 'LIN_type' => $line_item_type, |
| 168 | 168 | 'TXN_ID' => $transaction |
| 169 | 169 | ))); |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | * @param EE_Transaction|int $transaction |
| 178 | 178 | * @return EE_Line_Item[] |
| 179 | 179 | */ |
| 180 | - public function get_all_non_ticket_line_items_for_transaction( $transaction ) { |
|
| 181 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
| 182 | - return $this->get_all( array( array( |
|
| 180 | + public function get_all_non_ticket_line_items_for_transaction($transaction) { |
|
| 181 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
| 182 | + return $this->get_all(array(array( |
|
| 183 | 183 | 'LIN_type' => self::type_line_item, |
| 184 | 184 | 'TXN_ID' => $transaction, |
| 185 | 185 | 'OR' => array( |
| 186 | - 'OBJ_type*notticket' => array( '!=', 'Ticket'), |
|
| 187 | - 'OBJ_type*null' => array( 'IS_NULL' )) |
|
| 186 | + 'OBJ_type*notticket' => array('!=', 'Ticket'), |
|
| 187 | + 'OBJ_type*null' => array('IS_NULL')) |
|
| 188 | 188 | ))); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * because if there are spam bots afoot there will be LOTS of line items |
| 195 | 195 | * @return int count of how many deleted |
| 196 | 196 | */ |
| 197 | - public function delete_line_items_with_no_transaction(){ |
|
| 197 | + public function delete_line_items_with_no_transaction() { |
|
| 198 | 198 | /** @type WPDB $wpdb */ |
| 199 | 199 | global $wpdb; |
| 200 | 200 | $time_to_leave_alone = apply_filters( |
@@ -202,13 +202,13 @@ discard block |
||
| 202 | 202 | ); |
| 203 | 203 | $query = $wpdb->prepare( |
| 204 | 204 | 'DELETE li |
| 205 | - FROM ' . $this->table() . ' li |
|
| 206 | - LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID |
|
| 205 | + FROM ' . $this->table().' li |
|
| 206 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
| 207 | 207 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
| 208 | 208 | // use GMT time because that's what TXN_timestamps are in |
| 209 | - date( 'Y-m-d H:i:s', time() - $time_to_leave_alone ) |
|
| 209 | + date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
| 210 | 210 | ); |
| 211 | - return $wpdb->query( $query ); |
|
| 211 | + return $wpdb->query($query); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | * @param \EE_Base_Class $object |
| 222 | 222 | * @return EE_Line_Item[] |
| 223 | 223 | */ |
| 224 | - public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){ |
|
| 225 | - return $this->get_all( array( array( |
|
| 224 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) { |
|
| 225 | + return $this->get_all(array(array( |
|
| 226 | 226 | 'TXN_ID' => $TXN_ID, |
| 227 | - 'OBJ_type' => str_replace( 'EE_', '', get_class( $object )), |
|
| 227 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
| 228 | 228 | 'OBJ_ID' => $object->ID() |
| 229 | 229 | ))); |
| 230 | 230 | } |
@@ -240,16 +240,16 @@ discard block |
||
| 240 | 240 | * @param array $OBJ_IDs |
| 241 | 241 | * @return EE_Line_Item[] |
| 242 | 242 | */ |
| 243 | - public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){ |
|
| 243 | + public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) { |
|
| 244 | 244 | $query_params = array( |
| 245 | 245 | 'OBJ_type' => $OBJ_type, |
| 246 | 246 | // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
| 247 | - 'OBJ_ID' => is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs |
|
| 247 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs |
|
| 248 | 248 | ); |
| 249 | - if ( $TXN_ID ) { |
|
| 249 | + if ($TXN_ID) { |
|
| 250 | 250 | $query_params['TXN_ID'] = $TXN_ID; |
| 251 | 251 | } |
| 252 | - return $this->get_all( array( $query_params )); |
|
| 252 | + return $this->get_all(array($query_params)); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | * @param EE_Transaction $transaction |
| 261 | 261 | * @return EE_Line_Item[] |
| 262 | 262 | */ |
| 263 | - public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) { |
|
| 264 | - return $this->get_all( array( |
|
| 263 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) { |
|
| 264 | + return $this->get_all(array( |
|
| 265 | 265 | array( |
| 266 | 266 | 'TXN_ID' => $transaction->ID(), |
| 267 | 267 | 'OBJ_type' => 'Ticket', |
| 268 | 268 | ) |
| 269 | - ) ); |
|
| 269 | + )); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
@@ -278,14 +278,14 @@ discard block |
||
| 278 | 278 | * @param int $TKT_ID |
| 279 | 279 | * @return \EE_Line_Item |
| 280 | 280 | */ |
| 281 | - public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) { |
|
| 282 | - return $this->get_one( array( |
|
| 281 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) { |
|
| 282 | + return $this->get_one(array( |
|
| 283 | 283 | array( |
| 284 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ), |
|
| 284 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
| 285 | 285 | 'OBJ_ID' => $TKT_ID, |
| 286 | 286 | 'OBJ_type' => 'Ticket', |
| 287 | 287 | ) |
| 288 | - ) ); |
|
| 288 | + )); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | * @param EE_Promotion $promotion |
| 301 | 301 | * @return EE_Line_Item |
| 302 | 302 | */ |
| 303 | - public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) { |
|
| 304 | - return $this->get_one( array( |
|
| 303 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) { |
|
| 304 | + return $this->get_one(array( |
|
| 305 | 305 | array( |
| 306 | 306 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
| 307 | 307 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @param EE_Line_Item $parent_line_item |
| 323 | 323 | * @return EE_Line_Item[] |
| 324 | 324 | */ |
| 325 | - public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) { |
|
| 326 | - return $this->get_all( array( |
|
| 325 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) { |
|
| 326 | + return $this->get_all(array( |
|
| 327 | 327 | array( |
| 328 | 328 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
| 329 | 329 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -340,8 +340,8 @@ discard block |
||
| 340 | 340 | * @param EE_Registration $registration |
| 341 | 341 | * @return EE_Line_ITem |
| 342 | 342 | */ |
| 343 | - public function get_line_item_for_registration( EE_Registration $registration ) { |
|
| 344 | - return $this->get_one( $this->line_item_for_registration_query_params( $registration )); |
|
| 343 | + public function get_line_item_for_registration(EE_Registration $registration) { |
|
| 344 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | * @param array $original_query_params any extra query params you'd like to be merged with |
| 351 | 351 | * @return array like EEM_Base::get_all()'s $query_params |
| 352 | 352 | */ |
| 353 | - public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) { |
|
| 354 | - return array_replace_recursive( $original_query_params, array( |
|
| 353 | + public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) { |
|
| 354 | + return array_replace_recursive($original_query_params, array( |
|
| 355 | 355 | array( |
| 356 | 356 | 'OBJ_ID' => $registration->ticket_ID(), |
| 357 | 357 | 'OBJ_type' => 'Ticket', |
| 358 | 358 | 'TXN_ID' => $registration->transaction_ID() |
| 359 | 359 | ) |
| 360 | - ) ); |
|
| 360 | + )); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | 'LIN_timestamp' => array( |
| 376 | 376 | '>', |
| 377 | 377 | time() - EE_Registry::instance()->SSN->lifespan() |
| 378 | - ), ) |
|
| 378 | + ),) |
|
| 379 | 379 | )); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -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,1844 +23,1844 @@ 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 = __('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' => __('Add New Registration', 'event_espresso'), |
|
| 139 | - 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
| 140 | - 'edit' => __('Edit Contact', 'event_espresso'), |
|
| 141 | - 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | - 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | - 'report_filtered' => __('Filtered CSV Report', 'event_espresso'), |
|
| 144 | - 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
| 145 | - 'contact_list_export' => __("Export Data", "event_espresso"), |
|
| 146 | - ), |
|
| 147 | - 'publishbox' => array( |
|
| 148 | - 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
| 149 | - 'edit_attendee' => __("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 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | - ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
| 172 | - : $att_id; |
|
| 173 | - $this->_page_routes = array( |
|
| 174 | - 'default' => array( |
|
| 175 | - 'func' => '_registrations_overview_list_table', |
|
| 176 | - 'capability' => 'ee_read_registrations', |
|
| 177 | - ), |
|
| 178 | - 'view_registration' => array( |
|
| 179 | - 'func' => '_registration_details', |
|
| 180 | - 'capability' => 'ee_read_registration', |
|
| 181 | - 'obj_id' => $reg_id, |
|
| 182 | - ), |
|
| 183 | - 'edit_registration' => array( |
|
| 184 | - 'func' => '_update_attendee_registration_form', |
|
| 185 | - 'noheader' => true, |
|
| 186 | - 'headers_sent_route' => 'view_registration', |
|
| 187 | - 'capability' => 'ee_edit_registration', |
|
| 188 | - 'obj_id' => $reg_id, |
|
| 189 | - '_REG_ID' => $reg_id, |
|
| 190 | - ), |
|
| 191 | - 'trash_registrations' => array( |
|
| 192 | - 'func' => '_trash_or_restore_registrations', |
|
| 193 | - 'args' => array('trash' => true), |
|
| 194 | - 'noheader' => true, |
|
| 195 | - 'capability' => 'ee_delete_registrations', |
|
| 196 | - ), |
|
| 197 | - 'restore_registrations' => array( |
|
| 198 | - 'func' => '_trash_or_restore_registrations', |
|
| 199 | - 'args' => array('trash' => false), |
|
| 200 | - 'noheader' => true, |
|
| 201 | - 'capability' => 'ee_delete_registrations', |
|
| 202 | - ), |
|
| 203 | - 'delete_registrations' => array( |
|
| 204 | - 'func' => '_delete_registrations', |
|
| 205 | - 'noheader' => true, |
|
| 206 | - 'capability' => 'ee_delete_registrations', |
|
| 207 | - ), |
|
| 208 | - 'new_registration' => array( |
|
| 209 | - 'func' => 'new_registration', |
|
| 210 | - 'capability' => 'ee_edit_registrations', |
|
| 211 | - ), |
|
| 212 | - 'process_reg_step' => array( |
|
| 213 | - 'func' => 'process_reg_step', |
|
| 214 | - 'noheader' => true, |
|
| 215 | - 'capability' => 'ee_edit_registrations', |
|
| 216 | - ), |
|
| 217 | - 'redirect_to_txn' => array( |
|
| 218 | - 'func' => 'redirect_to_txn', |
|
| 219 | - 'noheader' => true, |
|
| 220 | - 'capability' => 'ee_edit_registrations', |
|
| 221 | - ), |
|
| 222 | - 'change_reg_status' => array( |
|
| 223 | - 'func' => '_change_reg_status', |
|
| 224 | - 'noheader' => true, |
|
| 225 | - 'capability' => 'ee_edit_registration', |
|
| 226 | - 'obj_id' => $reg_id, |
|
| 227 | - ), |
|
| 228 | - 'approve_registration' => array( |
|
| 229 | - 'func' => 'approve_registration', |
|
| 230 | - 'noheader' => true, |
|
| 231 | - 'capability' => 'ee_edit_registration', |
|
| 232 | - 'obj_id' => $reg_id, |
|
| 233 | - ), |
|
| 234 | - 'approve_and_notify_registration' => array( |
|
| 235 | - 'func' => 'approve_registration', |
|
| 236 | - 'noheader' => true, |
|
| 237 | - 'args' => array(true), |
|
| 238 | - 'capability' => 'ee_edit_registration', |
|
| 239 | - 'obj_id' => $reg_id, |
|
| 240 | - ), |
|
| 241 | - 'decline_registration' => array( |
|
| 242 | - 'func' => 'decline_registration', |
|
| 243 | - 'noheader' => true, |
|
| 244 | - 'capability' => 'ee_edit_registration', |
|
| 245 | - 'obj_id' => $reg_id, |
|
| 246 | - ), |
|
| 247 | - 'decline_and_notify_registration' => array( |
|
| 248 | - 'func' => 'decline_registration', |
|
| 249 | - 'noheader' => true, |
|
| 250 | - 'args' => array(true), |
|
| 251 | - 'capability' => 'ee_edit_registration', |
|
| 252 | - 'obj_id' => $reg_id, |
|
| 253 | - ), |
|
| 254 | - 'pending_registration' => array( |
|
| 255 | - 'func' => 'pending_registration', |
|
| 256 | - 'noheader' => true, |
|
| 257 | - 'capability' => 'ee_edit_registration', |
|
| 258 | - 'obj_id' => $reg_id, |
|
| 259 | - ), |
|
| 260 | - 'pending_and_notify_registration' => array( |
|
| 261 | - 'func' => 'pending_registration', |
|
| 262 | - 'noheader' => true, |
|
| 263 | - 'args' => array(true), |
|
| 264 | - 'capability' => 'ee_edit_registration', |
|
| 265 | - 'obj_id' => $reg_id, |
|
| 266 | - ), |
|
| 267 | - 'no_approve_registration' => array( |
|
| 268 | - 'func' => 'not_approve_registration', |
|
| 269 | - 'noheader' => true, |
|
| 270 | - 'capability' => 'ee_edit_registration', |
|
| 271 | - 'obj_id' => $reg_id, |
|
| 272 | - ), |
|
| 273 | - 'no_approve_and_notify_registration' => array( |
|
| 274 | - 'func' => 'not_approve_registration', |
|
| 275 | - 'noheader' => true, |
|
| 276 | - 'args' => array(true), |
|
| 277 | - 'capability' => 'ee_edit_registration', |
|
| 278 | - 'obj_id' => $reg_id, |
|
| 279 | - ), |
|
| 280 | - 'cancel_registration' => array( |
|
| 281 | - 'func' => 'cancel_registration', |
|
| 282 | - 'noheader' => true, |
|
| 283 | - 'capability' => 'ee_edit_registration', |
|
| 284 | - 'obj_id' => $reg_id, |
|
| 285 | - ), |
|
| 286 | - 'cancel_and_notify_registration' => array( |
|
| 287 | - 'func' => 'cancel_registration', |
|
| 288 | - 'noheader' => true, |
|
| 289 | - 'args' => array(true), |
|
| 290 | - 'capability' => 'ee_edit_registration', |
|
| 291 | - 'obj_id' => $reg_id, |
|
| 292 | - ), |
|
| 293 | - 'contact_list' => array( |
|
| 294 | - 'func' => '_attendee_contact_list_table', |
|
| 295 | - 'capability' => 'ee_read_contacts', |
|
| 296 | - ), |
|
| 297 | - 'add_new_attendee' => array( |
|
| 298 | - 'func' => '_create_new_cpt_item', |
|
| 299 | - 'args' => array( |
|
| 300 | - 'new_attendee' => true, |
|
| 301 | - 'capability' => 'ee_edit_contacts', |
|
| 302 | - ), |
|
| 303 | - ), |
|
| 304 | - 'edit_attendee' => array( |
|
| 305 | - 'func' => '_edit_cpt_item', |
|
| 306 | - 'capability' => 'ee_edit_contacts', |
|
| 307 | - 'obj_id' => $att_id, |
|
| 308 | - ), |
|
| 309 | - 'duplicate_attendee' => array( |
|
| 310 | - 'func' => '_duplicate_attendee', |
|
| 311 | - 'noheader' => true, |
|
| 312 | - 'capability' => 'ee_edit_contacts', |
|
| 313 | - 'obj_id' => $att_id, |
|
| 314 | - ), |
|
| 315 | - 'insert_attendee' => array( |
|
| 316 | - 'func' => '_insert_or_update_attendee', |
|
| 317 | - 'args' => array( |
|
| 318 | - 'new_attendee' => true, |
|
| 319 | - ), |
|
| 320 | - 'noheader' => true, |
|
| 321 | - 'capability' => 'ee_edit_contacts', |
|
| 322 | - ), |
|
| 323 | - 'update_attendee' => array( |
|
| 324 | - 'func' => '_insert_or_update_attendee', |
|
| 325 | - 'args' => array( |
|
| 326 | - 'new_attendee' => false, |
|
| 327 | - ), |
|
| 328 | - 'noheader' => true, |
|
| 329 | - 'capability' => 'ee_edit_contacts', |
|
| 330 | - 'obj_id' => $att_id, |
|
| 331 | - ), |
|
| 332 | - 'trash_attendees' => array( |
|
| 333 | - 'func' => '_trash_or_restore_attendees', |
|
| 334 | - 'args' => array( |
|
| 335 | - 'trash' => true, |
|
| 336 | - ), |
|
| 337 | - 'noheader' => true, |
|
| 338 | - 'capability' => 'ee_delete_contacts', |
|
| 339 | - 'obj_id' => $att_id, |
|
| 340 | - ), |
|
| 341 | - 'restore_attendees' => array( |
|
| 342 | - 'func' => '_trash_or_restore_attendees', |
|
| 343 | - 'args' => array( |
|
| 344 | - 'trash' => false, |
|
| 345 | - ), |
|
| 346 | - 'noheader' => true, |
|
| 347 | - 'capability' => 'ee_delete_contacts', |
|
| 348 | - 'obj_id' => $att_id, |
|
| 349 | - ), |
|
| 350 | - 'resend_registration' => array( |
|
| 351 | - 'func' => '_resend_registration', |
|
| 352 | - 'noheader' => true, |
|
| 353 | - 'capability' => 'ee_send_message', |
|
| 354 | - ), |
|
| 355 | - 'registrations_report' => array( |
|
| 356 | - 'func' => '_registrations_report', |
|
| 357 | - 'noheader' => true, |
|
| 358 | - 'capability' => 'ee_read_registrations', |
|
| 359 | - ), |
|
| 360 | - 'contact_list_export' => array( |
|
| 361 | - 'func' => '_contact_list_export', |
|
| 362 | - 'noheader' => true, |
|
| 363 | - 'capability' => 'export', |
|
| 364 | - ), |
|
| 365 | - 'contact_list_report' => array( |
|
| 366 | - 'func' => '_contact_list_report', |
|
| 367 | - 'noheader' => true, |
|
| 368 | - 'capability' => 'ee_read_contacts', |
|
| 369 | - ), |
|
| 370 | - ); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - |
|
| 374 | - protected function _set_page_config() |
|
| 375 | - { |
|
| 376 | - $this->_page_config = array( |
|
| 377 | - 'default' => array( |
|
| 378 | - 'nav' => array( |
|
| 379 | - 'label' => __('Overview', 'event_espresso'), |
|
| 380 | - 'order' => 5, |
|
| 381 | - ), |
|
| 382 | - 'help_tabs' => array( |
|
| 383 | - 'registrations_overview_help_tab' => array( |
|
| 384 | - 'title' => __('Registrations Overview', 'event_espresso'), |
|
| 385 | - 'filename' => 'registrations_overview', |
|
| 386 | - ), |
|
| 387 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 388 | - 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
| 389 | - 'filename' => 'registrations_overview_table_column_headings', |
|
| 390 | - ), |
|
| 391 | - 'registrations_overview_filters_help_tab' => array( |
|
| 392 | - 'title' => __('Registration Filters', 'event_espresso'), |
|
| 393 | - 'filename' => 'registrations_overview_filters', |
|
| 394 | - ), |
|
| 395 | - 'registrations_overview_views_help_tab' => array( |
|
| 396 | - 'title' => __('Registration Views', 'event_espresso'), |
|
| 397 | - 'filename' => 'registrations_overview_views', |
|
| 398 | - ), |
|
| 399 | - 'registrations_regoverview_other_help_tab' => array( |
|
| 400 | - 'title' => __('Registrations Other', 'event_espresso'), |
|
| 401 | - 'filename' => 'registrations_overview_other', |
|
| 402 | - ), |
|
| 403 | - ), |
|
| 404 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 405 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 406 | - 'list_table' => 'EE_Registrations_List_Table', |
|
| 407 | - 'require_nonce' => false, |
|
| 408 | - ), |
|
| 409 | - 'view_registration' => array( |
|
| 410 | - 'nav' => array( |
|
| 411 | - 'label' => __('REG Details', 'event_espresso'), |
|
| 412 | - 'order' => 15, |
|
| 413 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
| 414 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 415 | - : $this->_admin_base_url, |
|
| 416 | - 'persistent' => false, |
|
| 417 | - ), |
|
| 418 | - 'help_tabs' => array( |
|
| 419 | - 'registrations_details_help_tab' => array( |
|
| 420 | - 'title' => __('Registration Details', 'event_espresso'), |
|
| 421 | - 'filename' => 'registrations_details', |
|
| 422 | - ), |
|
| 423 | - 'registrations_details_table_help_tab' => array( |
|
| 424 | - 'title' => __('Registration Details Table', 'event_espresso'), |
|
| 425 | - 'filename' => 'registrations_details_table', |
|
| 426 | - ), |
|
| 427 | - 'registrations_details_form_answers_help_tab' => array( |
|
| 428 | - 'title' => __('Registration Form Answers', 'event_espresso'), |
|
| 429 | - 'filename' => 'registrations_details_form_answers', |
|
| 430 | - ), |
|
| 431 | - 'registrations_details_registrant_details_help_tab' => array( |
|
| 432 | - 'title' => __('Contact Details', 'event_espresso'), |
|
| 433 | - 'filename' => 'registrations_details_registrant_details', |
|
| 434 | - ), |
|
| 435 | - ), |
|
| 436 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 437 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 438 | - array('_registration_details_metaboxes')), |
|
| 439 | - 'require_nonce' => false, |
|
| 440 | - ), |
|
| 441 | - 'new_registration' => array( |
|
| 442 | - 'nav' => array( |
|
| 443 | - 'label' => __('Add New Registration', 'event_espresso'), |
|
| 444 | - 'url' => '#', |
|
| 445 | - 'order' => 15, |
|
| 446 | - 'persistent' => false, |
|
| 447 | - ), |
|
| 448 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 449 | - 'labels' => array( |
|
| 450 | - 'publishbox' => __('Save Registration', 'event_espresso'), |
|
| 451 | - ), |
|
| 452 | - 'require_nonce' => false, |
|
| 453 | - ), |
|
| 454 | - 'add_new_attendee' => array( |
|
| 455 | - 'nav' => array( |
|
| 456 | - 'label' => __('Add Contact', 'event_espresso'), |
|
| 457 | - 'order' => 15, |
|
| 458 | - 'persistent' => false, |
|
| 459 | - ), |
|
| 460 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 461 | - array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
| 462 | - 'require_nonce' => false, |
|
| 463 | - ), |
|
| 464 | - 'edit_attendee' => array( |
|
| 465 | - 'nav' => array( |
|
| 466 | - 'label' => __('Edit Contact', 'event_espresso'), |
|
| 467 | - 'order' => 15, |
|
| 468 | - 'persistent' => false, |
|
| 469 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
| 470 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 471 | - : $this->_admin_base_url, |
|
| 472 | - ), |
|
| 473 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 474 | - 'require_nonce' => false, |
|
| 475 | - ), |
|
| 476 | - 'contact_list' => array( |
|
| 477 | - 'nav' => array( |
|
| 478 | - 'label' => __('Contact List', 'event_espresso'), |
|
| 479 | - 'order' => 20, |
|
| 480 | - ), |
|
| 481 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 482 | - 'help_tabs' => array( |
|
| 483 | - 'registrations_contact_list_help_tab' => array( |
|
| 484 | - 'title' => __('Registrations Contact List', 'event_espresso'), |
|
| 485 | - 'filename' => 'registrations_contact_list', |
|
| 486 | - ), |
|
| 487 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 488 | - 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
| 489 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 490 | - ), |
|
| 491 | - 'registrations_contact_list_views_help_tab' => array( |
|
| 492 | - 'title' => __('Contact List Views', 'event_espresso'), |
|
| 493 | - 'filename' => 'registrations_contact_list_views', |
|
| 494 | - ), |
|
| 495 | - 'registrations_contact_list_other_help_tab' => array( |
|
| 496 | - 'title' => __('Contact List Other', 'event_espresso'), |
|
| 497 | - 'filename' => 'registrations_contact_list_other', |
|
| 498 | - ), |
|
| 499 | - ), |
|
| 500 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 501 | - 'metaboxes' => array(), |
|
| 502 | - 'require_nonce' => false, |
|
| 503 | - ), |
|
| 504 | - //override default cpt routes |
|
| 505 | - 'create_new' => '', |
|
| 506 | - 'edit' => '', |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * The below methods aren't used by this class currently |
|
| 513 | - */ |
|
| 514 | - protected function _add_screen_options() |
|
| 515 | - { |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - |
|
| 519 | - protected function _add_feature_pointers() |
|
| 520 | - { |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - public function admin_init() |
|
| 525 | - { |
|
| 526 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
| 527 | - 'event_espresso'); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - public function admin_notices() |
|
| 532 | - { |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - public function admin_footer_scripts() |
|
| 537 | - { |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * get list of registration statuses |
|
| 543 | - * |
|
| 544 | - * @access private |
|
| 545 | - * @return void |
|
| 546 | - */ |
|
| 547 | - private function _get_registration_status_array() |
|
| 548 | - { |
|
| 549 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - |
|
| 553 | - protected function _add_screen_options_default() |
|
| 554 | - { |
|
| 555 | - $this->_per_page_screen_option(); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - protected function _add_screen_options_contact_list() |
|
| 560 | - { |
|
| 561 | - $page_title = $this->_admin_page_title; |
|
| 562 | - $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
| 563 | - $this->_per_page_screen_option(); |
|
| 564 | - $this->_admin_page_title = $page_title; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - public function load_scripts_styles() |
|
| 569 | - { |
|
| 570 | - //style |
|
| 571 | - //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 572 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | - EVENT_ESPRESSO_VERSION); |
|
| 574 | - wp_enqueue_style('espresso_reg'); |
|
| 575 | - //script |
|
| 576 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 577 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
| 578 | - wp_enqueue_script('espresso_reg'); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - public function load_scripts_styles_edit_attendee() |
|
| 583 | - { |
|
| 584 | - //stuff to only show up on our attendee edit details page. |
|
| 585 | - $attendee_details_translations = array( |
|
| 586 | - 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 587 | - $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
| 588 | - ); |
|
| 589 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 590 | - wp_enqueue_script('jquery-validate'); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - public function load_scripts_styles_view_registration() |
|
| 595 | - { |
|
| 596 | - //styles |
|
| 597 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 598 | - //scripts |
|
| 599 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 600 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - |
|
| 604 | - public function load_scripts_styles_contact_list() |
|
| 605 | - { |
|
| 606 | - wp_deregister_style('espresso_reg'); |
|
| 607 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | - EVENT_ESPRESSO_VERSION); |
|
| 609 | - wp_enqueue_style('espresso_att'); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - public function load_scripts_styles_new_registration() |
|
| 614 | - { |
|
| 615 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | - EVENT_ESPRESSO_VERSION, true); |
|
| 617 | - wp_enqueue_script('ee-spco-for-admin'); |
|
| 618 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 619 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 620 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 621 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - |
|
| 625 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 626 | - { |
|
| 627 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - |
|
| 631 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 632 | - { |
|
| 633 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - |
|
| 637 | - protected function _set_list_table_views_default() |
|
| 638 | - { |
|
| 639 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 640 | - EED_Messages::set_autoloaders(); |
|
| 641 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 642 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 643 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 644 | - //key= bulk_action_slug, value= message type. |
|
| 645 | - $match_array = array( |
|
| 646 | - 'approve_registration' => 'registration', |
|
| 647 | - 'decline_registration' => 'declined_registration', |
|
| 648 | - 'pending_registration' => 'pending_approval', |
|
| 649 | - 'no_approve_registration' => 'not_approved_registration', |
|
| 650 | - 'cancel_registration' => 'cancelled_registration', |
|
| 651 | - ); |
|
| 652 | - /** setup reg status bulk actions **/ |
|
| 653 | - $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
| 654 | - if (in_array($match_array['approve_registration'], $active_mts) |
|
| 655 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 656 | - ) { |
|
| 657 | - $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
| 658 | - 'event_espresso'); |
|
| 659 | - } |
|
| 660 | - $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
| 661 | - if (in_array($match_array['decline_registration'], $active_mts) |
|
| 662 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 663 | - ) { |
|
| 664 | - $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
| 665 | - 'event_espresso'); |
|
| 666 | - } |
|
| 667 | - $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
| 668 | - if (in_array($match_array['pending_registration'], $active_mts) |
|
| 669 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 670 | - ) { |
|
| 671 | - $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
| 672 | - 'event_espresso'); |
|
| 673 | - } |
|
| 674 | - $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
| 675 | - if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 676 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 677 | - ) { |
|
| 678 | - $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
| 679 | - 'event_espresso'); |
|
| 680 | - } |
|
| 681 | - $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
| 682 | - if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 683 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 684 | - ) { |
|
| 685 | - $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
| 686 | - 'event_espresso'); |
|
| 687 | - } |
|
| 688 | - $this->_views = array( |
|
| 689 | - 'all' => array( |
|
| 690 | - 'slug' => 'all', |
|
| 691 | - 'label' => __('View All Registrations', 'event_espresso'), |
|
| 692 | - 'count' => 0, |
|
| 693 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 694 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 695 | - )), |
|
| 696 | - ), |
|
| 697 | - 'month' => array( |
|
| 698 | - 'slug' => 'month', |
|
| 699 | - 'label' => __('This Month', 'event_espresso'), |
|
| 700 | - 'count' => 0, |
|
| 701 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 702 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 703 | - )), |
|
| 704 | - ), |
|
| 705 | - 'today' => array( |
|
| 706 | - 'slug' => 'today', |
|
| 707 | - 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
| 708 | - 'count' => 0, |
|
| 709 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 710 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 711 | - )), |
|
| 712 | - ), |
|
| 713 | - ); |
|
| 714 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 715 | - 'espresso_registrations_delete_registration') |
|
| 716 | - ) { |
|
| 717 | - $this->_views['incomplete'] = array( |
|
| 718 | - 'slug' => 'incomplete', |
|
| 719 | - 'label' => __('Incomplete', 'event_espresso'), |
|
| 720 | - 'count' => 0, |
|
| 721 | - 'bulk_action' => array( |
|
| 722 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 723 | - ), |
|
| 724 | - ); |
|
| 725 | - $this->_views['trash'] = array( |
|
| 726 | - 'slug' => 'trash', |
|
| 727 | - 'label' => __('Trash', 'event_espresso'), |
|
| 728 | - 'count' => 0, |
|
| 729 | - 'bulk_action' => array( |
|
| 730 | - 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
| 731 | - 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
| 732 | - ), |
|
| 733 | - ); |
|
| 734 | - } |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - |
|
| 738 | - protected function _set_list_table_views_contact_list() |
|
| 739 | - { |
|
| 740 | - $this->_views = array( |
|
| 741 | - 'in_use' => array( |
|
| 742 | - 'slug' => 'in_use', |
|
| 743 | - 'label' => __('In Use', 'event_espresso'), |
|
| 744 | - 'count' => 0, |
|
| 745 | - 'bulk_action' => array( |
|
| 746 | - 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
| 747 | - ), |
|
| 748 | - ), |
|
| 749 | - ); |
|
| 750 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 751 | - 'espresso_registrations_trash_attendees') |
|
| 752 | - ) { |
|
| 753 | - $this->_views['trash'] = array( |
|
| 754 | - 'slug' => 'trash', |
|
| 755 | - 'label' => __('Trash', 'event_espresso'), |
|
| 756 | - 'count' => 0, |
|
| 757 | - 'bulk_action' => array( |
|
| 758 | - 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
| 759 | - ), |
|
| 760 | - ); |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - |
|
| 765 | - protected function _registration_legend_items() |
|
| 766 | - { |
|
| 767 | - $fc_items = array( |
|
| 768 | - 'star-icon' => array( |
|
| 769 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 770 | - 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
| 771 | - ), |
|
| 772 | - 'view_details' => array( |
|
| 773 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 774 | - 'desc' => __('View Registration Details', 'event_espresso'), |
|
| 775 | - ), |
|
| 776 | - 'edit_attendee' => array( |
|
| 777 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 778 | - 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
| 779 | - ), |
|
| 780 | - 'view_transaction' => array( |
|
| 781 | - 'class' => 'dashicons dashicons-cart', |
|
| 782 | - 'desc' => __('View Transaction Details', 'event_espresso'), |
|
| 783 | - ), |
|
| 784 | - 'view_invoice' => array( |
|
| 785 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 786 | - 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
| 787 | - ), |
|
| 788 | - ); |
|
| 789 | - if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 790 | - 'espresso_registrations_resend_registration') |
|
| 791 | - ) { |
|
| 792 | - $fc_items['resend_registration'] = array( |
|
| 793 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 794 | - 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
| 795 | - ); |
|
| 796 | - } else { |
|
| 797 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 798 | - } |
|
| 799 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 800 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 801 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 802 | - $fc_items['view_related_messages'] = array( |
|
| 803 | - 'class' => $related_for_icon['css_class'], |
|
| 804 | - 'desc' => $related_for_icon['label'], |
|
| 805 | - ); |
|
| 806 | - } |
|
| 807 | - } |
|
| 808 | - $sc_items = array( |
|
| 809 | - 'approved_status' => array( |
|
| 810 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 811 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 812 | - ), |
|
| 813 | - 'pending_status' => array( |
|
| 814 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 815 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 816 | - ), |
|
| 817 | - 'wait_list' => array( |
|
| 818 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 819 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 820 | - ), |
|
| 821 | - 'incomplete_status' => array( |
|
| 822 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 823 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
| 824 | - ), |
|
| 825 | - 'not_approved' => array( |
|
| 826 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 827 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 828 | - ), |
|
| 829 | - 'declined_status' => array( |
|
| 830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 831 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 832 | - ), |
|
| 833 | - 'cancelled_status' => array( |
|
| 834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 835 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 836 | - ), |
|
| 837 | - ); |
|
| 838 | - return array_merge($fc_items, $sc_items); |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - |
|
| 842 | - |
|
| 843 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 844 | - /** |
|
| 845 | - * @throws \EE_Error |
|
| 846 | - */ |
|
| 847 | - protected function _registrations_overview_list_table() |
|
| 848 | - { |
|
| 849 | - $this->_template_args['admin_page_header'] = ''; |
|
| 850 | - $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
| 851 | - if ($EVT_ID) { |
|
| 852 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
| 853 | - 'espresso_registrations_new_registration', $EVT_ID) |
|
| 854 | - ) { |
|
| 855 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | - array('event_id' => $EVT_ID), 'add-new-h2'); |
|
| 857 | - } |
|
| 858 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 859 | - if ($event instanceof EE_Event) { |
|
| 860 | - $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
| 861 | - 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
| 862 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | - 'action' => 'edit', |
|
| 864 | - 'post' => $event->ID(), |
|
| 865 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 866 | - } |
|
| 867 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 868 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 869 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 870 | - $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
| 871 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 872 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 873 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 874 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 875 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 879 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - |
|
| 883 | - /** |
|
| 884 | - * This sets the _registration property for the registration details screen |
|
| 885 | - * |
|
| 886 | - * @access private |
|
| 887 | - * @return bool |
|
| 888 | - */ |
|
| 889 | - private function _set_registration_object() |
|
| 890 | - { |
|
| 891 | - //get out if we've already set the object |
|
| 892 | - if (is_object($this->_registration)) { |
|
| 893 | - return true; |
|
| 894 | - } |
|
| 895 | - $REG = EEM_Registration::instance(); |
|
| 896 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 897 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 898 | - return true; |
|
| 899 | - } else { |
|
| 900 | - $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 901 | - 'event_espresso'), $REG_ID); |
|
| 902 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 903 | - $this->_registration = null; |
|
| 904 | - return false; |
|
| 905 | - } |
|
| 906 | - } |
|
| 907 | - |
|
| 908 | - |
|
| 909 | - /** |
|
| 910 | - * Used to retrieve registrations for the list table. |
|
| 911 | - * |
|
| 912 | - * @param int $per_page |
|
| 913 | - * @param bool $count |
|
| 914 | - * @param bool $this_month |
|
| 915 | - * @param bool $today |
|
| 916 | - * @return \EE_Registration[]|int |
|
| 917 | - */ |
|
| 918 | - public function get_registrations( |
|
| 919 | - $per_page = 10, |
|
| 920 | - $count = false, |
|
| 921 | - $this_month = false, |
|
| 922 | - $today = false |
|
| 923 | - ) { |
|
| 924 | - if( $this_month ) { |
|
| 925 | - $this->_req_data['status'] = 'month'; |
|
| 926 | - } |
|
| 927 | - if( $today ) { |
|
| 928 | - $this->_req_data['status'] = 'today'; |
|
| 929 | - } |
|
| 930 | - $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 931 | - /** |
|
| 932 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 933 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 934 | - * @see EEM_Base::get_all() |
|
| 935 | - */ |
|
| 936 | - $query_params['group_by'] = ''; |
|
| 937 | - |
|
| 938 | - return $count |
|
| 939 | - ? EEM_Registration::instance()->count($query_params) |
|
| 940 | - /** @type EE_Registration[] */ |
|
| 941 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 948 | - * Note: this listens to values on the request for some of the query parameters. |
|
| 949 | - * |
|
| 950 | - * @param array $request |
|
| 951 | - * @param int $per_page |
|
| 952 | - * @param bool $count |
|
| 953 | - * @return array |
|
| 954 | - */ |
|
| 955 | - protected function _get_registration_query_parameters( |
|
| 956 | - $request = array(), |
|
| 957 | - $per_page = 10, |
|
| 958 | - $count = false |
|
| 959 | - ) { |
|
| 960 | - |
|
| 961 | - $query_params = array( |
|
| 962 | - 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 963 | - $request |
|
| 964 | - ), |
|
| 965 | - 'caps' => EEM_Registration::caps_read_admin, |
|
| 966 | - 'default_where_conditions' => 'this_model_only', |
|
| 967 | - ); |
|
| 968 | - if ( ! $count) { |
|
| 969 | - $query_params = array_merge( |
|
| 970 | - $query_params, |
|
| 971 | - $this->_get_orderby_for_registrations_query(), |
|
| 972 | - $this->_get_limit($per_page) |
|
| 973 | - ); |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - return $query_params; |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - |
|
| 980 | - /** |
|
| 981 | - * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 982 | - * |
|
| 983 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 984 | - * @return array |
|
| 985 | - */ |
|
| 986 | - protected function _add_event_id_to_where_conditions(array $request) |
|
| 987 | - { |
|
| 988 | - $where = array(); |
|
| 989 | - if ( ! empty($request['event_id'])) { |
|
| 990 | - $where['EVT_ID'] = absint($request['event_id']); |
|
| 991 | - } |
|
| 992 | - return $where; |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 998 | - * |
|
| 999 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1000 | - * @return array |
|
| 1001 | - */ |
|
| 1002 | - protected function _add_category_id_to_where_conditions(array $request) |
|
| 1003 | - { |
|
| 1004 | - $where = array(); |
|
| 1005 | - if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1006 | - $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1007 | - } |
|
| 1008 | - return $where; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - |
|
| 1012 | - /** |
|
| 1013 | - * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1014 | - * |
|
| 1015 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1016 | - * @return array |
|
| 1017 | - */ |
|
| 1018 | - protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1019 | - { |
|
| 1020 | - $where = array(); |
|
| 1021 | - if ( ! empty($request['datetime_id'])) { |
|
| 1022 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1023 | - } |
|
| 1024 | - if( ! empty($request['DTT_ID'])){ |
|
| 1025 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1026 | - } |
|
| 1027 | - return $where; |
|
| 1028 | - } |
|
| 1029 | - |
|
| 1030 | - |
|
| 1031 | - /** |
|
| 1032 | - * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1033 | - * |
|
| 1034 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1035 | - * @return array |
|
| 1036 | - */ |
|
| 1037 | - protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1038 | - { |
|
| 1039 | - $where = array(); |
|
| 1040 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1041 | - $registration_status = ! empty($request['_reg_status']) |
|
| 1042 | - ? sanitize_text_field($request['_reg_status']) |
|
| 1043 | - : ''; |
|
| 1044 | - |
|
| 1045 | - /* |
|
| 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 = __('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' => __('Add New Registration', 'event_espresso'), |
|
| 139 | + 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
| 140 | + 'edit' => __('Edit Contact', 'event_espresso'), |
|
| 141 | + 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | + 'report_filtered' => __('Filtered CSV Report', 'event_espresso'), |
|
| 144 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
| 145 | + 'contact_list_export' => __("Export Data", "event_espresso"), |
|
| 146 | + ), |
|
| 147 | + 'publishbox' => array( |
|
| 148 | + 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
| 149 | + 'edit_attendee' => __("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 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | + ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
| 172 | + : $att_id; |
|
| 173 | + $this->_page_routes = array( |
|
| 174 | + 'default' => array( |
|
| 175 | + 'func' => '_registrations_overview_list_table', |
|
| 176 | + 'capability' => 'ee_read_registrations', |
|
| 177 | + ), |
|
| 178 | + 'view_registration' => array( |
|
| 179 | + 'func' => '_registration_details', |
|
| 180 | + 'capability' => 'ee_read_registration', |
|
| 181 | + 'obj_id' => $reg_id, |
|
| 182 | + ), |
|
| 183 | + 'edit_registration' => array( |
|
| 184 | + 'func' => '_update_attendee_registration_form', |
|
| 185 | + 'noheader' => true, |
|
| 186 | + 'headers_sent_route' => 'view_registration', |
|
| 187 | + 'capability' => 'ee_edit_registration', |
|
| 188 | + 'obj_id' => $reg_id, |
|
| 189 | + '_REG_ID' => $reg_id, |
|
| 190 | + ), |
|
| 191 | + 'trash_registrations' => array( |
|
| 192 | + 'func' => '_trash_or_restore_registrations', |
|
| 193 | + 'args' => array('trash' => true), |
|
| 194 | + 'noheader' => true, |
|
| 195 | + 'capability' => 'ee_delete_registrations', |
|
| 196 | + ), |
|
| 197 | + 'restore_registrations' => array( |
|
| 198 | + 'func' => '_trash_or_restore_registrations', |
|
| 199 | + 'args' => array('trash' => false), |
|
| 200 | + 'noheader' => true, |
|
| 201 | + 'capability' => 'ee_delete_registrations', |
|
| 202 | + ), |
|
| 203 | + 'delete_registrations' => array( |
|
| 204 | + 'func' => '_delete_registrations', |
|
| 205 | + 'noheader' => true, |
|
| 206 | + 'capability' => 'ee_delete_registrations', |
|
| 207 | + ), |
|
| 208 | + 'new_registration' => array( |
|
| 209 | + 'func' => 'new_registration', |
|
| 210 | + 'capability' => 'ee_edit_registrations', |
|
| 211 | + ), |
|
| 212 | + 'process_reg_step' => array( |
|
| 213 | + 'func' => 'process_reg_step', |
|
| 214 | + 'noheader' => true, |
|
| 215 | + 'capability' => 'ee_edit_registrations', |
|
| 216 | + ), |
|
| 217 | + 'redirect_to_txn' => array( |
|
| 218 | + 'func' => 'redirect_to_txn', |
|
| 219 | + 'noheader' => true, |
|
| 220 | + 'capability' => 'ee_edit_registrations', |
|
| 221 | + ), |
|
| 222 | + 'change_reg_status' => array( |
|
| 223 | + 'func' => '_change_reg_status', |
|
| 224 | + 'noheader' => true, |
|
| 225 | + 'capability' => 'ee_edit_registration', |
|
| 226 | + 'obj_id' => $reg_id, |
|
| 227 | + ), |
|
| 228 | + 'approve_registration' => array( |
|
| 229 | + 'func' => 'approve_registration', |
|
| 230 | + 'noheader' => true, |
|
| 231 | + 'capability' => 'ee_edit_registration', |
|
| 232 | + 'obj_id' => $reg_id, |
|
| 233 | + ), |
|
| 234 | + 'approve_and_notify_registration' => array( |
|
| 235 | + 'func' => 'approve_registration', |
|
| 236 | + 'noheader' => true, |
|
| 237 | + 'args' => array(true), |
|
| 238 | + 'capability' => 'ee_edit_registration', |
|
| 239 | + 'obj_id' => $reg_id, |
|
| 240 | + ), |
|
| 241 | + 'decline_registration' => array( |
|
| 242 | + 'func' => 'decline_registration', |
|
| 243 | + 'noheader' => true, |
|
| 244 | + 'capability' => 'ee_edit_registration', |
|
| 245 | + 'obj_id' => $reg_id, |
|
| 246 | + ), |
|
| 247 | + 'decline_and_notify_registration' => array( |
|
| 248 | + 'func' => 'decline_registration', |
|
| 249 | + 'noheader' => true, |
|
| 250 | + 'args' => array(true), |
|
| 251 | + 'capability' => 'ee_edit_registration', |
|
| 252 | + 'obj_id' => $reg_id, |
|
| 253 | + ), |
|
| 254 | + 'pending_registration' => array( |
|
| 255 | + 'func' => 'pending_registration', |
|
| 256 | + 'noheader' => true, |
|
| 257 | + 'capability' => 'ee_edit_registration', |
|
| 258 | + 'obj_id' => $reg_id, |
|
| 259 | + ), |
|
| 260 | + 'pending_and_notify_registration' => array( |
|
| 261 | + 'func' => 'pending_registration', |
|
| 262 | + 'noheader' => true, |
|
| 263 | + 'args' => array(true), |
|
| 264 | + 'capability' => 'ee_edit_registration', |
|
| 265 | + 'obj_id' => $reg_id, |
|
| 266 | + ), |
|
| 267 | + 'no_approve_registration' => array( |
|
| 268 | + 'func' => 'not_approve_registration', |
|
| 269 | + 'noheader' => true, |
|
| 270 | + 'capability' => 'ee_edit_registration', |
|
| 271 | + 'obj_id' => $reg_id, |
|
| 272 | + ), |
|
| 273 | + 'no_approve_and_notify_registration' => array( |
|
| 274 | + 'func' => 'not_approve_registration', |
|
| 275 | + 'noheader' => true, |
|
| 276 | + 'args' => array(true), |
|
| 277 | + 'capability' => 'ee_edit_registration', |
|
| 278 | + 'obj_id' => $reg_id, |
|
| 279 | + ), |
|
| 280 | + 'cancel_registration' => array( |
|
| 281 | + 'func' => 'cancel_registration', |
|
| 282 | + 'noheader' => true, |
|
| 283 | + 'capability' => 'ee_edit_registration', |
|
| 284 | + 'obj_id' => $reg_id, |
|
| 285 | + ), |
|
| 286 | + 'cancel_and_notify_registration' => array( |
|
| 287 | + 'func' => 'cancel_registration', |
|
| 288 | + 'noheader' => true, |
|
| 289 | + 'args' => array(true), |
|
| 290 | + 'capability' => 'ee_edit_registration', |
|
| 291 | + 'obj_id' => $reg_id, |
|
| 292 | + ), |
|
| 293 | + 'contact_list' => array( |
|
| 294 | + 'func' => '_attendee_contact_list_table', |
|
| 295 | + 'capability' => 'ee_read_contacts', |
|
| 296 | + ), |
|
| 297 | + 'add_new_attendee' => array( |
|
| 298 | + 'func' => '_create_new_cpt_item', |
|
| 299 | + 'args' => array( |
|
| 300 | + 'new_attendee' => true, |
|
| 301 | + 'capability' => 'ee_edit_contacts', |
|
| 302 | + ), |
|
| 303 | + ), |
|
| 304 | + 'edit_attendee' => array( |
|
| 305 | + 'func' => '_edit_cpt_item', |
|
| 306 | + 'capability' => 'ee_edit_contacts', |
|
| 307 | + 'obj_id' => $att_id, |
|
| 308 | + ), |
|
| 309 | + 'duplicate_attendee' => array( |
|
| 310 | + 'func' => '_duplicate_attendee', |
|
| 311 | + 'noheader' => true, |
|
| 312 | + 'capability' => 'ee_edit_contacts', |
|
| 313 | + 'obj_id' => $att_id, |
|
| 314 | + ), |
|
| 315 | + 'insert_attendee' => array( |
|
| 316 | + 'func' => '_insert_or_update_attendee', |
|
| 317 | + 'args' => array( |
|
| 318 | + 'new_attendee' => true, |
|
| 319 | + ), |
|
| 320 | + 'noheader' => true, |
|
| 321 | + 'capability' => 'ee_edit_contacts', |
|
| 322 | + ), |
|
| 323 | + 'update_attendee' => array( |
|
| 324 | + 'func' => '_insert_or_update_attendee', |
|
| 325 | + 'args' => array( |
|
| 326 | + 'new_attendee' => false, |
|
| 327 | + ), |
|
| 328 | + 'noheader' => true, |
|
| 329 | + 'capability' => 'ee_edit_contacts', |
|
| 330 | + 'obj_id' => $att_id, |
|
| 331 | + ), |
|
| 332 | + 'trash_attendees' => array( |
|
| 333 | + 'func' => '_trash_or_restore_attendees', |
|
| 334 | + 'args' => array( |
|
| 335 | + 'trash' => true, |
|
| 336 | + ), |
|
| 337 | + 'noheader' => true, |
|
| 338 | + 'capability' => 'ee_delete_contacts', |
|
| 339 | + 'obj_id' => $att_id, |
|
| 340 | + ), |
|
| 341 | + 'restore_attendees' => array( |
|
| 342 | + 'func' => '_trash_or_restore_attendees', |
|
| 343 | + 'args' => array( |
|
| 344 | + 'trash' => false, |
|
| 345 | + ), |
|
| 346 | + 'noheader' => true, |
|
| 347 | + 'capability' => 'ee_delete_contacts', |
|
| 348 | + 'obj_id' => $att_id, |
|
| 349 | + ), |
|
| 350 | + 'resend_registration' => array( |
|
| 351 | + 'func' => '_resend_registration', |
|
| 352 | + 'noheader' => true, |
|
| 353 | + 'capability' => 'ee_send_message', |
|
| 354 | + ), |
|
| 355 | + 'registrations_report' => array( |
|
| 356 | + 'func' => '_registrations_report', |
|
| 357 | + 'noheader' => true, |
|
| 358 | + 'capability' => 'ee_read_registrations', |
|
| 359 | + ), |
|
| 360 | + 'contact_list_export' => array( |
|
| 361 | + 'func' => '_contact_list_export', |
|
| 362 | + 'noheader' => true, |
|
| 363 | + 'capability' => 'export', |
|
| 364 | + ), |
|
| 365 | + 'contact_list_report' => array( |
|
| 366 | + 'func' => '_contact_list_report', |
|
| 367 | + 'noheader' => true, |
|
| 368 | + 'capability' => 'ee_read_contacts', |
|
| 369 | + ), |
|
| 370 | + ); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + |
|
| 374 | + protected function _set_page_config() |
|
| 375 | + { |
|
| 376 | + $this->_page_config = array( |
|
| 377 | + 'default' => array( |
|
| 378 | + 'nav' => array( |
|
| 379 | + 'label' => __('Overview', 'event_espresso'), |
|
| 380 | + 'order' => 5, |
|
| 381 | + ), |
|
| 382 | + 'help_tabs' => array( |
|
| 383 | + 'registrations_overview_help_tab' => array( |
|
| 384 | + 'title' => __('Registrations Overview', 'event_espresso'), |
|
| 385 | + 'filename' => 'registrations_overview', |
|
| 386 | + ), |
|
| 387 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 388 | + 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
| 389 | + 'filename' => 'registrations_overview_table_column_headings', |
|
| 390 | + ), |
|
| 391 | + 'registrations_overview_filters_help_tab' => array( |
|
| 392 | + 'title' => __('Registration Filters', 'event_espresso'), |
|
| 393 | + 'filename' => 'registrations_overview_filters', |
|
| 394 | + ), |
|
| 395 | + 'registrations_overview_views_help_tab' => array( |
|
| 396 | + 'title' => __('Registration Views', 'event_espresso'), |
|
| 397 | + 'filename' => 'registrations_overview_views', |
|
| 398 | + ), |
|
| 399 | + 'registrations_regoverview_other_help_tab' => array( |
|
| 400 | + 'title' => __('Registrations Other', 'event_espresso'), |
|
| 401 | + 'filename' => 'registrations_overview_other', |
|
| 402 | + ), |
|
| 403 | + ), |
|
| 404 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 405 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 406 | + 'list_table' => 'EE_Registrations_List_Table', |
|
| 407 | + 'require_nonce' => false, |
|
| 408 | + ), |
|
| 409 | + 'view_registration' => array( |
|
| 410 | + 'nav' => array( |
|
| 411 | + 'label' => __('REG Details', 'event_espresso'), |
|
| 412 | + 'order' => 15, |
|
| 413 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
| 414 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 415 | + : $this->_admin_base_url, |
|
| 416 | + 'persistent' => false, |
|
| 417 | + ), |
|
| 418 | + 'help_tabs' => array( |
|
| 419 | + 'registrations_details_help_tab' => array( |
|
| 420 | + 'title' => __('Registration Details', 'event_espresso'), |
|
| 421 | + 'filename' => 'registrations_details', |
|
| 422 | + ), |
|
| 423 | + 'registrations_details_table_help_tab' => array( |
|
| 424 | + 'title' => __('Registration Details Table', 'event_espresso'), |
|
| 425 | + 'filename' => 'registrations_details_table', |
|
| 426 | + ), |
|
| 427 | + 'registrations_details_form_answers_help_tab' => array( |
|
| 428 | + 'title' => __('Registration Form Answers', 'event_espresso'), |
|
| 429 | + 'filename' => 'registrations_details_form_answers', |
|
| 430 | + ), |
|
| 431 | + 'registrations_details_registrant_details_help_tab' => array( |
|
| 432 | + 'title' => __('Contact Details', 'event_espresso'), |
|
| 433 | + 'filename' => 'registrations_details_registrant_details', |
|
| 434 | + ), |
|
| 435 | + ), |
|
| 436 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 437 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 438 | + array('_registration_details_metaboxes')), |
|
| 439 | + 'require_nonce' => false, |
|
| 440 | + ), |
|
| 441 | + 'new_registration' => array( |
|
| 442 | + 'nav' => array( |
|
| 443 | + 'label' => __('Add New Registration', 'event_espresso'), |
|
| 444 | + 'url' => '#', |
|
| 445 | + 'order' => 15, |
|
| 446 | + 'persistent' => false, |
|
| 447 | + ), |
|
| 448 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 449 | + 'labels' => array( |
|
| 450 | + 'publishbox' => __('Save Registration', 'event_espresso'), |
|
| 451 | + ), |
|
| 452 | + 'require_nonce' => false, |
|
| 453 | + ), |
|
| 454 | + 'add_new_attendee' => array( |
|
| 455 | + 'nav' => array( |
|
| 456 | + 'label' => __('Add Contact', 'event_espresso'), |
|
| 457 | + 'order' => 15, |
|
| 458 | + 'persistent' => false, |
|
| 459 | + ), |
|
| 460 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 461 | + array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
| 462 | + 'require_nonce' => false, |
|
| 463 | + ), |
|
| 464 | + 'edit_attendee' => array( |
|
| 465 | + 'nav' => array( |
|
| 466 | + 'label' => __('Edit Contact', 'event_espresso'), |
|
| 467 | + 'order' => 15, |
|
| 468 | + 'persistent' => false, |
|
| 469 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
| 470 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 471 | + : $this->_admin_base_url, |
|
| 472 | + ), |
|
| 473 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 474 | + 'require_nonce' => false, |
|
| 475 | + ), |
|
| 476 | + 'contact_list' => array( |
|
| 477 | + 'nav' => array( |
|
| 478 | + 'label' => __('Contact List', 'event_espresso'), |
|
| 479 | + 'order' => 20, |
|
| 480 | + ), |
|
| 481 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 482 | + 'help_tabs' => array( |
|
| 483 | + 'registrations_contact_list_help_tab' => array( |
|
| 484 | + 'title' => __('Registrations Contact List', 'event_espresso'), |
|
| 485 | + 'filename' => 'registrations_contact_list', |
|
| 486 | + ), |
|
| 487 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 488 | + 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
| 489 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 490 | + ), |
|
| 491 | + 'registrations_contact_list_views_help_tab' => array( |
|
| 492 | + 'title' => __('Contact List Views', 'event_espresso'), |
|
| 493 | + 'filename' => 'registrations_contact_list_views', |
|
| 494 | + ), |
|
| 495 | + 'registrations_contact_list_other_help_tab' => array( |
|
| 496 | + 'title' => __('Contact List Other', 'event_espresso'), |
|
| 497 | + 'filename' => 'registrations_contact_list_other', |
|
| 498 | + ), |
|
| 499 | + ), |
|
| 500 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 501 | + 'metaboxes' => array(), |
|
| 502 | + 'require_nonce' => false, |
|
| 503 | + ), |
|
| 504 | + //override default cpt routes |
|
| 505 | + 'create_new' => '', |
|
| 506 | + 'edit' => '', |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * The below methods aren't used by this class currently |
|
| 513 | + */ |
|
| 514 | + protected function _add_screen_options() |
|
| 515 | + { |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + |
|
| 519 | + protected function _add_feature_pointers() |
|
| 520 | + { |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + public function admin_init() |
|
| 525 | + { |
|
| 526 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
| 527 | + 'event_espresso'); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + public function admin_notices() |
|
| 532 | + { |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + public function admin_footer_scripts() |
|
| 537 | + { |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * get list of registration statuses |
|
| 543 | + * |
|
| 544 | + * @access private |
|
| 545 | + * @return void |
|
| 546 | + */ |
|
| 547 | + private function _get_registration_status_array() |
|
| 548 | + { |
|
| 549 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + |
|
| 553 | + protected function _add_screen_options_default() |
|
| 554 | + { |
|
| 555 | + $this->_per_page_screen_option(); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + protected function _add_screen_options_contact_list() |
|
| 560 | + { |
|
| 561 | + $page_title = $this->_admin_page_title; |
|
| 562 | + $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
| 563 | + $this->_per_page_screen_option(); |
|
| 564 | + $this->_admin_page_title = $page_title; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + public function load_scripts_styles() |
|
| 569 | + { |
|
| 570 | + //style |
|
| 571 | + //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 572 | + wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | + EVENT_ESPRESSO_VERSION); |
|
| 574 | + wp_enqueue_style('espresso_reg'); |
|
| 575 | + //script |
|
| 576 | + wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 577 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
| 578 | + wp_enqueue_script('espresso_reg'); |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + public function load_scripts_styles_edit_attendee() |
|
| 583 | + { |
|
| 584 | + //stuff to only show up on our attendee edit details page. |
|
| 585 | + $attendee_details_translations = array( |
|
| 586 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 587 | + $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
| 588 | + ); |
|
| 589 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 590 | + wp_enqueue_script('jquery-validate'); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + public function load_scripts_styles_view_registration() |
|
| 595 | + { |
|
| 596 | + //styles |
|
| 597 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 598 | + //scripts |
|
| 599 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 600 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + |
|
| 604 | + public function load_scripts_styles_contact_list() |
|
| 605 | + { |
|
| 606 | + wp_deregister_style('espresso_reg'); |
|
| 607 | + wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | + EVENT_ESPRESSO_VERSION); |
|
| 609 | + wp_enqueue_style('espresso_att'); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + public function load_scripts_styles_new_registration() |
|
| 614 | + { |
|
| 615 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | + EVENT_ESPRESSO_VERSION, true); |
|
| 617 | + wp_enqueue_script('ee-spco-for-admin'); |
|
| 618 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 619 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 620 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 621 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + |
|
| 625 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 626 | + { |
|
| 627 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + |
|
| 631 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 632 | + { |
|
| 633 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + |
|
| 637 | + protected function _set_list_table_views_default() |
|
| 638 | + { |
|
| 639 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 640 | + EED_Messages::set_autoloaders(); |
|
| 641 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 642 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 643 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 644 | + //key= bulk_action_slug, value= message type. |
|
| 645 | + $match_array = array( |
|
| 646 | + 'approve_registration' => 'registration', |
|
| 647 | + 'decline_registration' => 'declined_registration', |
|
| 648 | + 'pending_registration' => 'pending_approval', |
|
| 649 | + 'no_approve_registration' => 'not_approved_registration', |
|
| 650 | + 'cancel_registration' => 'cancelled_registration', |
|
| 651 | + ); |
|
| 652 | + /** setup reg status bulk actions **/ |
|
| 653 | + $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
| 654 | + if (in_array($match_array['approve_registration'], $active_mts) |
|
| 655 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 656 | + ) { |
|
| 657 | + $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
| 658 | + 'event_espresso'); |
|
| 659 | + } |
|
| 660 | + $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
| 661 | + if (in_array($match_array['decline_registration'], $active_mts) |
|
| 662 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 663 | + ) { |
|
| 664 | + $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
| 665 | + 'event_espresso'); |
|
| 666 | + } |
|
| 667 | + $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
| 668 | + if (in_array($match_array['pending_registration'], $active_mts) |
|
| 669 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 670 | + ) { |
|
| 671 | + $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
| 672 | + 'event_espresso'); |
|
| 673 | + } |
|
| 674 | + $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
| 675 | + if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 676 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 677 | + ) { |
|
| 678 | + $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
| 679 | + 'event_espresso'); |
|
| 680 | + } |
|
| 681 | + $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
| 682 | + if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 683 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 684 | + ) { |
|
| 685 | + $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
| 686 | + 'event_espresso'); |
|
| 687 | + } |
|
| 688 | + $this->_views = array( |
|
| 689 | + 'all' => array( |
|
| 690 | + 'slug' => 'all', |
|
| 691 | + 'label' => __('View All Registrations', 'event_espresso'), |
|
| 692 | + 'count' => 0, |
|
| 693 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 694 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 695 | + )), |
|
| 696 | + ), |
|
| 697 | + 'month' => array( |
|
| 698 | + 'slug' => 'month', |
|
| 699 | + 'label' => __('This Month', 'event_espresso'), |
|
| 700 | + 'count' => 0, |
|
| 701 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 702 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 703 | + )), |
|
| 704 | + ), |
|
| 705 | + 'today' => array( |
|
| 706 | + 'slug' => 'today', |
|
| 707 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
| 708 | + 'count' => 0, |
|
| 709 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 710 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 711 | + )), |
|
| 712 | + ), |
|
| 713 | + ); |
|
| 714 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 715 | + 'espresso_registrations_delete_registration') |
|
| 716 | + ) { |
|
| 717 | + $this->_views['incomplete'] = array( |
|
| 718 | + 'slug' => 'incomplete', |
|
| 719 | + 'label' => __('Incomplete', 'event_espresso'), |
|
| 720 | + 'count' => 0, |
|
| 721 | + 'bulk_action' => array( |
|
| 722 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 723 | + ), |
|
| 724 | + ); |
|
| 725 | + $this->_views['trash'] = array( |
|
| 726 | + 'slug' => 'trash', |
|
| 727 | + 'label' => __('Trash', 'event_espresso'), |
|
| 728 | + 'count' => 0, |
|
| 729 | + 'bulk_action' => array( |
|
| 730 | + 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
| 731 | + 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
| 732 | + ), |
|
| 733 | + ); |
|
| 734 | + } |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + |
|
| 738 | + protected function _set_list_table_views_contact_list() |
|
| 739 | + { |
|
| 740 | + $this->_views = array( |
|
| 741 | + 'in_use' => array( |
|
| 742 | + 'slug' => 'in_use', |
|
| 743 | + 'label' => __('In Use', 'event_espresso'), |
|
| 744 | + 'count' => 0, |
|
| 745 | + 'bulk_action' => array( |
|
| 746 | + 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
| 747 | + ), |
|
| 748 | + ), |
|
| 749 | + ); |
|
| 750 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 751 | + 'espresso_registrations_trash_attendees') |
|
| 752 | + ) { |
|
| 753 | + $this->_views['trash'] = array( |
|
| 754 | + 'slug' => 'trash', |
|
| 755 | + 'label' => __('Trash', 'event_espresso'), |
|
| 756 | + 'count' => 0, |
|
| 757 | + 'bulk_action' => array( |
|
| 758 | + 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
| 759 | + ), |
|
| 760 | + ); |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + |
|
| 765 | + protected function _registration_legend_items() |
|
| 766 | + { |
|
| 767 | + $fc_items = array( |
|
| 768 | + 'star-icon' => array( |
|
| 769 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 770 | + 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
| 771 | + ), |
|
| 772 | + 'view_details' => array( |
|
| 773 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 774 | + 'desc' => __('View Registration Details', 'event_espresso'), |
|
| 775 | + ), |
|
| 776 | + 'edit_attendee' => array( |
|
| 777 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 778 | + 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
| 779 | + ), |
|
| 780 | + 'view_transaction' => array( |
|
| 781 | + 'class' => 'dashicons dashicons-cart', |
|
| 782 | + 'desc' => __('View Transaction Details', 'event_espresso'), |
|
| 783 | + ), |
|
| 784 | + 'view_invoice' => array( |
|
| 785 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 786 | + 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
| 787 | + ), |
|
| 788 | + ); |
|
| 789 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 790 | + 'espresso_registrations_resend_registration') |
|
| 791 | + ) { |
|
| 792 | + $fc_items['resend_registration'] = array( |
|
| 793 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 794 | + 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
| 795 | + ); |
|
| 796 | + } else { |
|
| 797 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 798 | + } |
|
| 799 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 800 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 801 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 802 | + $fc_items['view_related_messages'] = array( |
|
| 803 | + 'class' => $related_for_icon['css_class'], |
|
| 804 | + 'desc' => $related_for_icon['label'], |
|
| 805 | + ); |
|
| 806 | + } |
|
| 807 | + } |
|
| 808 | + $sc_items = array( |
|
| 809 | + 'approved_status' => array( |
|
| 810 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 811 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 812 | + ), |
|
| 813 | + 'pending_status' => array( |
|
| 814 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 815 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 816 | + ), |
|
| 817 | + 'wait_list' => array( |
|
| 818 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 819 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 820 | + ), |
|
| 821 | + 'incomplete_status' => array( |
|
| 822 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 823 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
| 824 | + ), |
|
| 825 | + 'not_approved' => array( |
|
| 826 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 827 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 828 | + ), |
|
| 829 | + 'declined_status' => array( |
|
| 830 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 832 | + ), |
|
| 833 | + 'cancelled_status' => array( |
|
| 834 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 836 | + ), |
|
| 837 | + ); |
|
| 838 | + return array_merge($fc_items, $sc_items); |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + |
|
| 842 | + |
|
| 843 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 844 | + /** |
|
| 845 | + * @throws \EE_Error |
|
| 846 | + */ |
|
| 847 | + protected function _registrations_overview_list_table() |
|
| 848 | + { |
|
| 849 | + $this->_template_args['admin_page_header'] = ''; |
|
| 850 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
| 851 | + if ($EVT_ID) { |
|
| 852 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
| 853 | + 'espresso_registrations_new_registration', $EVT_ID) |
|
| 854 | + ) { |
|
| 855 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | + array('event_id' => $EVT_ID), 'add-new-h2'); |
|
| 857 | + } |
|
| 858 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 859 | + if ($event instanceof EE_Event) { |
|
| 860 | + $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
| 861 | + 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
| 862 | + '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | + 'action' => 'edit', |
|
| 864 | + 'post' => $event->ID(), |
|
| 865 | + ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 866 | + } |
|
| 867 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 868 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 869 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 870 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
| 871 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 872 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 873 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 874 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 875 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 879 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + |
|
| 883 | + /** |
|
| 884 | + * This sets the _registration property for the registration details screen |
|
| 885 | + * |
|
| 886 | + * @access private |
|
| 887 | + * @return bool |
|
| 888 | + */ |
|
| 889 | + private function _set_registration_object() |
|
| 890 | + { |
|
| 891 | + //get out if we've already set the object |
|
| 892 | + if (is_object($this->_registration)) { |
|
| 893 | + return true; |
|
| 894 | + } |
|
| 895 | + $REG = EEM_Registration::instance(); |
|
| 896 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 897 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 898 | + return true; |
|
| 899 | + } else { |
|
| 900 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 901 | + 'event_espresso'), $REG_ID); |
|
| 902 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 903 | + $this->_registration = null; |
|
| 904 | + return false; |
|
| 905 | + } |
|
| 906 | + } |
|
| 907 | + |
|
| 908 | + |
|
| 909 | + /** |
|
| 910 | + * Used to retrieve registrations for the list table. |
|
| 911 | + * |
|
| 912 | + * @param int $per_page |
|
| 913 | + * @param bool $count |
|
| 914 | + * @param bool $this_month |
|
| 915 | + * @param bool $today |
|
| 916 | + * @return \EE_Registration[]|int |
|
| 917 | + */ |
|
| 918 | + public function get_registrations( |
|
| 919 | + $per_page = 10, |
|
| 920 | + $count = false, |
|
| 921 | + $this_month = false, |
|
| 922 | + $today = false |
|
| 923 | + ) { |
|
| 924 | + if( $this_month ) { |
|
| 925 | + $this->_req_data['status'] = 'month'; |
|
| 926 | + } |
|
| 927 | + if( $today ) { |
|
| 928 | + $this->_req_data['status'] = 'today'; |
|
| 929 | + } |
|
| 930 | + $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 931 | + /** |
|
| 932 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 933 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 934 | + * @see EEM_Base::get_all() |
|
| 935 | + */ |
|
| 936 | + $query_params['group_by'] = ''; |
|
| 937 | + |
|
| 938 | + return $count |
|
| 939 | + ? EEM_Registration::instance()->count($query_params) |
|
| 940 | + /** @type EE_Registration[] */ |
|
| 941 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 948 | + * Note: this listens to values on the request for some of the query parameters. |
|
| 949 | + * |
|
| 950 | + * @param array $request |
|
| 951 | + * @param int $per_page |
|
| 952 | + * @param bool $count |
|
| 953 | + * @return array |
|
| 954 | + */ |
|
| 955 | + protected function _get_registration_query_parameters( |
|
| 956 | + $request = array(), |
|
| 957 | + $per_page = 10, |
|
| 958 | + $count = false |
|
| 959 | + ) { |
|
| 960 | + |
|
| 961 | + $query_params = array( |
|
| 962 | + 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 963 | + $request |
|
| 964 | + ), |
|
| 965 | + 'caps' => EEM_Registration::caps_read_admin, |
|
| 966 | + 'default_where_conditions' => 'this_model_only', |
|
| 967 | + ); |
|
| 968 | + if ( ! $count) { |
|
| 969 | + $query_params = array_merge( |
|
| 970 | + $query_params, |
|
| 971 | + $this->_get_orderby_for_registrations_query(), |
|
| 972 | + $this->_get_limit($per_page) |
|
| 973 | + ); |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + return $query_params; |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + |
|
| 980 | + /** |
|
| 981 | + * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 982 | + * |
|
| 983 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 984 | + * @return array |
|
| 985 | + */ |
|
| 986 | + protected function _add_event_id_to_where_conditions(array $request) |
|
| 987 | + { |
|
| 988 | + $where = array(); |
|
| 989 | + if ( ! empty($request['event_id'])) { |
|
| 990 | + $where['EVT_ID'] = absint($request['event_id']); |
|
| 991 | + } |
|
| 992 | + return $where; |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 998 | + * |
|
| 999 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1000 | + * @return array |
|
| 1001 | + */ |
|
| 1002 | + protected function _add_category_id_to_where_conditions(array $request) |
|
| 1003 | + { |
|
| 1004 | + $where = array(); |
|
| 1005 | + if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1006 | + $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1007 | + } |
|
| 1008 | + return $where; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + |
|
| 1012 | + /** |
|
| 1013 | + * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1014 | + * |
|
| 1015 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1016 | + * @return array |
|
| 1017 | + */ |
|
| 1018 | + protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1019 | + { |
|
| 1020 | + $where = array(); |
|
| 1021 | + if ( ! empty($request['datetime_id'])) { |
|
| 1022 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1023 | + } |
|
| 1024 | + if( ! empty($request['DTT_ID'])){ |
|
| 1025 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1026 | + } |
|
| 1027 | + return $where; |
|
| 1028 | + } |
|
| 1029 | + |
|
| 1030 | + |
|
| 1031 | + /** |
|
| 1032 | + * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1033 | + * |
|
| 1034 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1035 | + * @return array |
|
| 1036 | + */ |
|
| 1037 | + protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1038 | + { |
|
| 1039 | + $where = array(); |
|
| 1040 | + $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1041 | + $registration_status = ! empty($request['_reg_status']) |
|
| 1042 | + ? sanitize_text_field($request['_reg_status']) |
|
| 1043 | + : ''; |
|
| 1044 | + |
|
| 1045 | + /* |
|
| 1046 | 1046 | * If filtering by registration status, then we show registrations matching that status. |
| 1047 | 1047 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations UNLESS |
| 1048 | 1048 | * viewing trashed registrations. |
| 1049 | 1049 | */ |
| 1050 | - if ( ! empty($registration_status)) { |
|
| 1051 | - $where['STS_ID'] = $registration_status; |
|
| 1052 | - } else { |
|
| 1053 | - //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1054 | - if ($view === 'trash') { |
|
| 1055 | - $where['REG_deleted'] = true; |
|
| 1056 | - } else if ($view === 'incomplete') { |
|
| 1057 | - $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1058 | - } else { |
|
| 1059 | - $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1060 | - } |
|
| 1061 | - } |
|
| 1062 | - return $where; |
|
| 1063 | - } |
|
| 1064 | - |
|
| 1065 | - |
|
| 1066 | - /** |
|
| 1067 | - * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1068 | - * |
|
| 1069 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1070 | - * @return array |
|
| 1071 | - */ |
|
| 1072 | - protected function _add_date_to_where_conditions(array $request) |
|
| 1073 | - { |
|
| 1074 | - $where = array(); |
|
| 1075 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1076 | - $month_range = ! empty($request['month_range']) |
|
| 1077 | - ? sanitize_text_field($request['month_range']) |
|
| 1078 | - : ''; |
|
| 1079 | - $retrieve_for_today = $view === 'today'; |
|
| 1080 | - $retrieve_for_this_month = $view === 'month'; |
|
| 1081 | - |
|
| 1082 | - if ($retrieve_for_today) { |
|
| 1083 | - $now = date('Y-m-d', current_time('timestamp')); |
|
| 1084 | - $where['REG_date'] = array( |
|
| 1085 | - 'BETWEEN', |
|
| 1086 | - array( |
|
| 1087 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1088 | - 'REG_date', |
|
| 1089 | - $now . ' 00:00:00', |
|
| 1090 | - 'Y-m-d H:i:s' |
|
| 1091 | - ), |
|
| 1092 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1093 | - 'REG_date', |
|
| 1094 | - $now . ' 23:59:59', |
|
| 1095 | - 'Y-m-d H:i:s' |
|
| 1096 | - ), |
|
| 1097 | - ), |
|
| 1098 | - ); |
|
| 1099 | - } elseif ($retrieve_for_this_month) { |
|
| 1100 | - $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1101 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 1102 | - $where['REG_date'] = array( |
|
| 1103 | - 'BETWEEN', |
|
| 1104 | - array( |
|
| 1105 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1106 | - 'REG_date', |
|
| 1107 | - $current_year_and_month . '-01 00:00:00', |
|
| 1108 | - 'Y-m-d H:i:s' |
|
| 1109 | - ), |
|
| 1110 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1111 | - 'REG_date', |
|
| 1112 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1113 | - 'Y-m-d H:i:s' |
|
| 1114 | - ), |
|
| 1115 | - ), |
|
| 1116 | - ); |
|
| 1117 | - } elseif ($month_range) { |
|
| 1118 | - $pieces = explode(' ', $month_range, 3); |
|
| 1119 | - $month_requested = ! empty($pieces[0]) |
|
| 1120 | - ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1121 | - : ''; |
|
| 1122 | - $year_requested = ! empty($pieces[1]) |
|
| 1123 | - ? $pieces[1] |
|
| 1124 | - : ''; |
|
| 1125 | - //if there is not a month or year then we can't go further |
|
| 1126 | - if ($month_requested && $year_requested) { |
|
| 1127 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1128 | - $where['REG_date'] = array( |
|
| 1129 | - 'BETWEEN', |
|
| 1130 | - array( |
|
| 1131 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1132 | - 'REG_date', |
|
| 1133 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1134 | - 'Y-m-d H:i:s' |
|
| 1135 | - ), |
|
| 1136 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1137 | - 'REG_date', |
|
| 1138 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1139 | - 'Y-m-d H:i:s' |
|
| 1140 | - ), |
|
| 1141 | - ), |
|
| 1142 | - ); |
|
| 1143 | - } |
|
| 1144 | - } |
|
| 1145 | - return $where; |
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - |
|
| 1149 | - /** |
|
| 1150 | - * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1151 | - * |
|
| 1152 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1153 | - * @return array |
|
| 1154 | - */ |
|
| 1155 | - protected function _add_search_to_where_conditions(array $request) |
|
| 1156 | - { |
|
| 1157 | - $where = array(); |
|
| 1158 | - if ( ! empty($request['s'])) { |
|
| 1159 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1160 | - $where['OR'] = array( |
|
| 1161 | - 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1162 | - 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1163 | - 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1164 | - 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1165 | - 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1166 | - 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1167 | - 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1168 | - 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1169 | - 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1170 | - 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1171 | - 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1172 | - 'REG_final_price' => array('LIKE', $search_string), |
|
| 1173 | - 'REG_code' => array('LIKE', $search_string), |
|
| 1174 | - 'REG_count' => array('LIKE', $search_string), |
|
| 1175 | - 'REG_group_size' => array('LIKE', $search_string), |
|
| 1176 | - 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1177 | - 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1178 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1179 | - ); |
|
| 1180 | - } |
|
| 1181 | - return $where; |
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - |
|
| 1185 | - /** |
|
| 1186 | - * Sets up the where conditions for the registrations query. |
|
| 1187 | - * |
|
| 1188 | - * @param array $request |
|
| 1189 | - * @return array |
|
| 1190 | - */ |
|
| 1191 | - protected function _get_where_conditions_for_registrations_query($request) |
|
| 1192 | - { |
|
| 1193 | - return array_merge( |
|
| 1194 | - $this->_add_event_id_to_where_conditions($request), |
|
| 1195 | - $this->_add_category_id_to_where_conditions($request), |
|
| 1196 | - $this->_add_datetime_id_to_where_conditions($request), |
|
| 1197 | - $this->_add_registration_status_to_where_conditions($request), |
|
| 1198 | - $this->_add_date_to_where_conditions($request), |
|
| 1199 | - $this->_add_search_to_where_conditions($request) |
|
| 1200 | - ); |
|
| 1201 | - } |
|
| 1202 | - |
|
| 1203 | - |
|
| 1204 | - /** |
|
| 1205 | - * Sets up the orderby for the registrations query. |
|
| 1206 | - * |
|
| 1207 | - * @return array |
|
| 1208 | - */ |
|
| 1209 | - protected function _get_orderby_for_registrations_query() |
|
| 1210 | - { |
|
| 1211 | - $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1212 | - ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1213 | - : ''; |
|
| 1214 | - switch ($orderby_field) { |
|
| 1215 | - case '_REG_ID': |
|
| 1216 | - $orderby_field = 'REG_ID'; |
|
| 1217 | - break; |
|
| 1218 | - case '_Reg_status': |
|
| 1219 | - $orderby_field = 'STS_ID'; |
|
| 1220 | - break; |
|
| 1221 | - case 'ATT_fname': |
|
| 1222 | - $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1223 | - break; |
|
| 1224 | - case 'ATT_lname' : |
|
| 1225 | - $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1226 | - break; |
|
| 1227 | - case 'event_name': |
|
| 1228 | - $orderby_field = 'Event.EVT_name'; |
|
| 1229 | - break; |
|
| 1230 | - case 'DTT_EVT_start': |
|
| 1231 | - $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1232 | - break; |
|
| 1233 | - default: //'REG_date' |
|
| 1234 | - $orderby_field = 'REG_date'; |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - //order |
|
| 1238 | - $order = ! empty($this->_req_data['order']) |
|
| 1239 | - ? sanitize_text_field($this->_req_data['order']) |
|
| 1240 | - : 'DESC'; |
|
| 1241 | - |
|
| 1242 | - //mutate orderby_field |
|
| 1243 | - $orderby_field = array_combine( |
|
| 1244 | - (array) $orderby_field, |
|
| 1245 | - array_fill(0, count($orderby_field), $order) |
|
| 1246 | - ); |
|
| 1247 | - return array('order_by' => $orderby_field); |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - |
|
| 1251 | - /** |
|
| 1252 | - * Sets up the limit for the registrations query. |
|
| 1253 | - * |
|
| 1254 | - * @param $per_page |
|
| 1255 | - * @return array |
|
| 1256 | - */ |
|
| 1257 | - protected function _get_limit($per_page) |
|
| 1258 | - { |
|
| 1259 | - $current_page = ! empty($this->_req_data['paged']) |
|
| 1260 | - ? absint($this->_req_data['paged']) |
|
| 1261 | - : 1; |
|
| 1262 | - $per_page = ! empty($this->_req_data['perpage']) |
|
| 1263 | - ? $this->_req_data['perpage'] |
|
| 1264 | - : $per_page; |
|
| 1265 | - |
|
| 1266 | - //-1 means return all results so get out if that's set. |
|
| 1267 | - if ((int)$per_page === -1) { |
|
| 1268 | - return array(); |
|
| 1269 | - } |
|
| 1270 | - $per_page = absint($per_page); |
|
| 1271 | - $offset = ($current_page - 1) * $per_page; |
|
| 1272 | - return array('limit' => array($offset, $per_page)); |
|
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - |
|
| 1276 | - public function get_registration_status_array() |
|
| 1277 | - { |
|
| 1278 | - return self::$_reg_status; |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - |
|
| 1282 | - |
|
| 1283 | - |
|
| 1284 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1285 | - /** |
|
| 1286 | - * generates HTML for the View Registration Details Admin page |
|
| 1287 | - * |
|
| 1288 | - * @access protected |
|
| 1289 | - * @return void |
|
| 1290 | - */ |
|
| 1291 | - protected function _registration_details() |
|
| 1292 | - { |
|
| 1293 | - $this->_template_args = array(); |
|
| 1294 | - $this->_set_registration_object(); |
|
| 1295 | - if (is_object($this->_registration)) { |
|
| 1296 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1297 | - : EE_Transaction::new_instance(); |
|
| 1298 | - $this->_session = $transaction->session_data(); |
|
| 1299 | - $event_id = $this->_registration->event_ID(); |
|
| 1300 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1301 | - $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
| 1302 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1303 | - $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 1304 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1305 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1306 | - // link back to overview |
|
| 1307 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1308 | - $this->_template_args['registration'] = $this->_registration; |
|
| 1309 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1310 | - 'action' => 'default', |
|
| 1311 | - 'event_id' => $event_id, |
|
| 1312 | - ), REG_ADMIN_URL); |
|
| 1313 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1314 | - 'action' => 'default', |
|
| 1315 | - 'EVT_ID' => $event_id, |
|
| 1316 | - 'page' => 'espresso_transactions', |
|
| 1317 | - ), admin_url('admin.php')); |
|
| 1318 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1319 | - 'page' => 'espresso_events', |
|
| 1320 | - 'action' => 'edit', |
|
| 1321 | - 'post' => $event_id, |
|
| 1322 | - ), admin_url('admin.php')); |
|
| 1323 | - //next and previous links |
|
| 1324 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
| 1325 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1326 | - ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1327 | - 'action' => 'view_registration', |
|
| 1328 | - '_REG_ID' => $next_reg['REG_ID'], |
|
| 1329 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
| 1330 | - $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
| 1331 | - $this->_template_args['previous_registration'] = $previous_reg |
|
| 1332 | - ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1333 | - 'action' => 'view_registration', |
|
| 1334 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1335 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
| 1336 | - // grab header |
|
| 1337 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1338 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1339 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 1340 | - $this->_template_args, true); |
|
| 1341 | - } else { |
|
| 1342 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1343 | - } |
|
| 1344 | - // the details template wrapper |
|
| 1345 | - $this->display_admin_page_with_sidebar(); |
|
| 1346 | - } |
|
| 1347 | - |
|
| 1348 | - |
|
| 1349 | - protected function _registration_details_metaboxes() |
|
| 1350 | - { |
|
| 1351 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1352 | - $this->_set_registration_object(); |
|
| 1353 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1354 | - add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
| 1355 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1356 | - add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
| 1357 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1358 | - if ($attendee instanceof EE_Attendee |
|
| 1359 | - && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
| 1360 | - ) { |
|
| 1361 | - add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
| 1362 | - array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1363 | - } |
|
| 1364 | - add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
| 1365 | - array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
| 1366 | - if ($this->_registration->group_size() > 1) { |
|
| 1367 | - add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1368 | - array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1369 | - } |
|
| 1370 | - } |
|
| 1371 | - |
|
| 1372 | - |
|
| 1373 | - /** |
|
| 1374 | - * set_reg_status_buttons_metabox |
|
| 1375 | - * |
|
| 1376 | - * @access protected |
|
| 1377 | - * @return string |
|
| 1378 | - * @throws \EE_Error |
|
| 1379 | - */ |
|
| 1380 | - public function set_reg_status_buttons_metabox() |
|
| 1381 | - { |
|
| 1382 | - $this->_set_registration_object(); |
|
| 1383 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1384 | - echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
| 1385 | - 'action' => 'change_reg_status', |
|
| 1386 | - ), REG_ADMIN_URL)); |
|
| 1387 | - echo $change_reg_status_form->get_html(); |
|
| 1388 | - echo $change_reg_status_form->form_close(); |
|
| 1389 | - } |
|
| 1390 | - |
|
| 1391 | - |
|
| 1392 | - /** |
|
| 1393 | - * @return EE_Form_Section_Proper |
|
| 1394 | - */ |
|
| 1395 | - protected function _generate_reg_status_change_form() |
|
| 1396 | - { |
|
| 1397 | - return new EE_Form_Section_Proper(array( |
|
| 1398 | - 'name' => 'reg_status_change_form', |
|
| 1399 | - 'html_id' => 'reg-status-change-form', |
|
| 1400 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1401 | - 'subsections' => array( |
|
| 1402 | - 'return' => new EE_Hidden_Input(array( |
|
| 1403 | - 'name' => 'return', |
|
| 1404 | - 'default' => 'view_registration', |
|
| 1405 | - )), |
|
| 1406 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1407 | - 'name' => 'REG_ID', |
|
| 1408 | - 'default' => $this->_registration->ID(), |
|
| 1409 | - )), |
|
| 1410 | - 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
| 1411 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1412 | - '', 'status-' . $this->_registration->status_ID(), |
|
| 1413 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
| 1414 | - 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
| 1415 | - 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
| 1416 | - 'default' => $this->_registration->status_ID(), |
|
| 1417 | - )), |
|
| 1418 | - 'send_notifications' => new EE_Yes_No_Input(array( |
|
| 1419 | - 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
| 1420 | - 'default' => false, |
|
| 1421 | - 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1422 | - 'event_espresso'), |
|
| 1423 | - )), |
|
| 1424 | - 'submit' => new EE_Submit_Input(array( |
|
| 1425 | - 'html_class' => 'button-primary', |
|
| 1426 | - 'html_label_text' => ' ', |
|
| 1427 | - 'default' => __('Update Registration Status', 'event_espresso'), |
|
| 1428 | - )), |
|
| 1429 | - ), |
|
| 1430 | - )); |
|
| 1431 | - } |
|
| 1432 | - |
|
| 1433 | - |
|
| 1434 | - |
|
| 1435 | - /** |
|
| 1436 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1437 | - * |
|
| 1438 | - * @return array |
|
| 1439 | - */ |
|
| 1440 | - protected function _get_reg_statuses() |
|
| 1441 | - { |
|
| 1442 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1443 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1444 | - // get current reg status |
|
| 1445 | - $current_status = $this->_registration->status_ID(); |
|
| 1446 | - // is registration for free event? This will determine whether to display the pending payment option |
|
| 1447 | - if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1448 | - && $this->_registration->transaction() |
|
| 1449 | - ->is_free() |
|
| 1450 | - ) { |
|
| 1451 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1452 | - } |
|
| 1453 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1454 | - } |
|
| 1455 | - |
|
| 1456 | - |
|
| 1457 | - /** |
|
| 1458 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1459 | - * |
|
| 1460 | - * @param bool $status REG status given for changing registrations to. |
|
| 1461 | - * @param bool $notify Whether to send messages notifications or not. |
|
| 1462 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1463 | - */ |
|
| 1464 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1465 | - { |
|
| 1466 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1467 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1468 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1469 | - } else { |
|
| 1470 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1471 | - } |
|
| 1472 | - $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1473 | - //notify? |
|
| 1474 | - if ($success |
|
| 1475 | - && $notify |
|
| 1476 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1477 | - 'espresso_registrations_resend_registration') |
|
| 1478 | - ) { |
|
| 1479 | - $this->_process_resend_registration(); |
|
| 1480 | - } |
|
| 1481 | - return $success; |
|
| 1482 | - } |
|
| 1483 | - |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1487 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1488 | - * |
|
| 1489 | - * @param array $REG_IDs |
|
| 1490 | - * @param bool $status |
|
| 1491 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1492 | - * the array of updated registrations). |
|
| 1493 | - */ |
|
| 1494 | - protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1495 | - { |
|
| 1496 | - $success = false; |
|
| 1497 | - // typecast $REG_IDs |
|
| 1498 | - $REG_IDs = (array)$REG_IDs; |
|
| 1499 | - if ( ! empty($REG_IDs)) { |
|
| 1500 | - $success = true; |
|
| 1501 | - // set default status if none is passed |
|
| 1502 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1503 | - // sanitize $REG_IDs |
|
| 1504 | - $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1505 | - //loop through REG_ID's and change status |
|
| 1506 | - foreach ($REG_IDs as $REG_ID) { |
|
| 1507 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1508 | - if ($registration instanceof EE_Registration) { |
|
| 1509 | - $registration->set_status($status); |
|
| 1510 | - $result = $registration->save(); |
|
| 1511 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1512 | - $success = $result !== false ? $success : false; |
|
| 1513 | - } |
|
| 1514 | - } |
|
| 1515 | - } |
|
| 1516 | - //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1517 | - $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1518 | - //return $success and processed registrations |
|
| 1519 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1520 | - } |
|
| 1521 | - |
|
| 1522 | - |
|
| 1523 | - /** |
|
| 1524 | - * Common logic for setting up success message and redirecting to appropriate route |
|
| 1525 | - * |
|
| 1526 | - * @param string $STS_ID status id for the registration changed to |
|
| 1527 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1528 | - * @return void |
|
| 1529 | - */ |
|
| 1530 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1531 | - { |
|
| 1532 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1533 | - : array('success' => false); |
|
| 1534 | - $success = isset($result['success']) && $result['success']; |
|
| 1535 | - //setup success message |
|
| 1536 | - if ($success) { |
|
| 1537 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1538 | - $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
| 1539 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1540 | - } else { |
|
| 1541 | - $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1542 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1543 | - } |
|
| 1544 | - EE_Error::add_success($msg); |
|
| 1545 | - } else { |
|
| 1546 | - EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
| 1547 | - __LINE__, __FUNCTION__); |
|
| 1548 | - } |
|
| 1549 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1550 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1551 | - } else { |
|
| 1552 | - $route = array('action' => 'default'); |
|
| 1553 | - } |
|
| 1554 | - //unset nonces |
|
| 1555 | - foreach ($this->_req_data as $ref => $value) { |
|
| 1556 | - if (strpos($ref, 'nonce') !== false) { |
|
| 1557 | - unset($this->_req_data[$ref]); |
|
| 1558 | - continue; |
|
| 1559 | - } |
|
| 1560 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1561 | - $this->_req_data[$ref] = $value; |
|
| 1562 | - } |
|
| 1563 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1564 | - $route = array_merge($this->_req_data, $route); |
|
| 1565 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - |
|
| 1569 | - /** |
|
| 1570 | - * incoming reg status change from reg details page. |
|
| 1571 | - * |
|
| 1572 | - * @return void |
|
| 1573 | - */ |
|
| 1574 | - protected function _change_reg_status() |
|
| 1575 | - { |
|
| 1576 | - $this->_req_data['return'] = 'view_registration'; |
|
| 1577 | - //set notify based on whether the send notifications toggle is set or not |
|
| 1578 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1579 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1580 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1581 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1582 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1583 | - case EEM_Registration::status_id_approved : |
|
| 1584 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1585 | - $this->approve_registration($notify); |
|
| 1586 | - break; |
|
| 1587 | - case EEM_Registration::status_id_pending_payment : |
|
| 1588 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1589 | - $this->pending_registration($notify); |
|
| 1590 | - break; |
|
| 1591 | - case EEM_Registration::status_id_not_approved : |
|
| 1592 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1593 | - $this->not_approve_registration($notify); |
|
| 1594 | - break; |
|
| 1595 | - case EEM_Registration::status_id_declined : |
|
| 1596 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1597 | - $this->decline_registration($notify); |
|
| 1598 | - break; |
|
| 1599 | - case EEM_Registration::status_id_cancelled : |
|
| 1600 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1601 | - $this->cancel_registration($notify); |
|
| 1602 | - break; |
|
| 1603 | - case EEM_Registration::status_id_wait_list : |
|
| 1604 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1605 | - $this->waitlist_registration($notify); |
|
| 1606 | - break; |
|
| 1607 | - case EEM_Registration::status_id_incomplete : |
|
| 1608 | - default : |
|
| 1609 | - $result['success'] = false; |
|
| 1610 | - unset($this->_req_data['return']); |
|
| 1611 | - $this->_reg_status_change_return('', false); |
|
| 1612 | - break; |
|
| 1613 | - } |
|
| 1614 | - } |
|
| 1615 | - |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * approve_registration |
|
| 1619 | - * |
|
| 1620 | - * @access protected |
|
| 1621 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1622 | - * @return void |
|
| 1623 | - */ |
|
| 1624 | - protected function approve_registration($notify = false) |
|
| 1625 | - { |
|
| 1626 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - |
|
| 1630 | - /** |
|
| 1631 | - * decline_registration |
|
| 1632 | - * |
|
| 1633 | - * @access protected |
|
| 1634 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1635 | - * @return void |
|
| 1636 | - */ |
|
| 1637 | - protected function decline_registration($notify = false) |
|
| 1638 | - { |
|
| 1639 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - |
|
| 1643 | - /** |
|
| 1644 | - * cancel_registration |
|
| 1645 | - * |
|
| 1646 | - * @access protected |
|
| 1647 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1648 | - * @return void |
|
| 1649 | - */ |
|
| 1650 | - protected function cancel_registration($notify = false) |
|
| 1651 | - { |
|
| 1652 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - |
|
| 1656 | - /** |
|
| 1657 | - * not_approve_registration |
|
| 1658 | - * |
|
| 1659 | - * @access protected |
|
| 1660 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1661 | - * @return void |
|
| 1662 | - */ |
|
| 1663 | - protected function not_approve_registration($notify = false) |
|
| 1664 | - { |
|
| 1665 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * decline_registration |
|
| 1671 | - * |
|
| 1672 | - * @access protected |
|
| 1673 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1674 | - * @return void |
|
| 1675 | - */ |
|
| 1676 | - protected function pending_registration($notify = false) |
|
| 1677 | - { |
|
| 1678 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1679 | - } |
|
| 1680 | - |
|
| 1681 | - |
|
| 1682 | - /** |
|
| 1683 | - * waitlist_registration |
|
| 1684 | - * |
|
| 1685 | - * @access protected |
|
| 1686 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1687 | - * @return void |
|
| 1688 | - */ |
|
| 1689 | - protected function waitlist_registration($notify = false) |
|
| 1690 | - { |
|
| 1691 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - |
|
| 1695 | - /** |
|
| 1696 | - * generates HTML for the Registration main meta box |
|
| 1697 | - * |
|
| 1698 | - * @access public |
|
| 1699 | - * @return void |
|
| 1700 | - */ |
|
| 1701 | - public function _reg_details_meta_box() |
|
| 1702 | - { |
|
| 1703 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1704 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1705 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1706 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1707 | - : EE_Transaction::new_instance(); |
|
| 1708 | - $this->_session = $transaction->session_data(); |
|
| 1709 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1710 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1711 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1712 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1713 | - $transaction->total_line_item()); |
|
| 1714 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1715 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1716 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1717 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
| 1718 | - array('EE_Registration' => $this->_registration)); |
|
| 1719 | - $attendee = $this->_registration->attendee(); |
|
| 1720 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 1721 | - 'espresso_transactions_view_transaction') |
|
| 1722 | - ) { |
|
| 1723 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1724 | - 'action' => 'view_transaction', |
|
| 1725 | - 'TXN_ID' => $transaction->ID(), |
|
| 1726 | - ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
| 1727 | - 'dashicons dashicons-cart'); |
|
| 1728 | - } else { |
|
| 1729 | - $this->_template_args['view_transaction_button'] = ''; |
|
| 1730 | - } |
|
| 1731 | - if ($attendee instanceof EE_Attendee |
|
| 1732 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1733 | - 'espresso_registrations_resend_registration') |
|
| 1734 | - ) { |
|
| 1735 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1736 | - 'action' => 'resend_registration', |
|
| 1737 | - '_REG_ID' => $this->_registration->ID(), |
|
| 1738 | - 'redirect_to' => 'view_registration', |
|
| 1739 | - ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
| 1740 | - 'dashicons dashicons-email-alt'); |
|
| 1741 | - } else { |
|
| 1742 | - $this->_template_args['resend_registration_button'] = ''; |
|
| 1743 | - } |
|
| 1744 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1745 | - $payment = $transaction->get_first_related('Payment'); |
|
| 1746 | - $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
| 1747 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1748 | - $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
| 1749 | - : $payment_method; |
|
| 1750 | - $reg_details = array( |
|
| 1751 | - 'payment_method' => $payment_method->name(), |
|
| 1752 | - 'response_msg' => $payment->gateway_response(), |
|
| 1753 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1754 | - 'registration_session' => $this->_registration->session_ID(), |
|
| 1755 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1756 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1757 | - ); |
|
| 1758 | - if (isset($reg_details['registration_id'])) { |
|
| 1759 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1760 | - $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
| 1761 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 1762 | - } |
|
| 1763 | - if (isset($reg_details['payment_method'])) { |
|
| 1764 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 1765 | - $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
| 1766 | - 'event_espresso'); |
|
| 1767 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 1768 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 1769 | - $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
| 1770 | - 'event_espresso'); |
|
| 1771 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 1772 | - } |
|
| 1773 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 1774 | - $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
| 1775 | - 'event_espresso'); |
|
| 1776 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 1777 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 1778 | - $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
| 1779 | - 'event_espresso'); |
|
| 1780 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 1781 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 1782 | - $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', |
|
| 1783 | - 'event_espresso'); |
|
| 1784 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 1785 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1786 | - 'action' => 'default', |
|
| 1787 | - 'event_id' => $this->_registration->event_ID(), |
|
| 1788 | - ), REG_ADMIN_URL); |
|
| 1789 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1790 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 1791 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1792 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1793 | - } |
|
| 1794 | - |
|
| 1795 | - |
|
| 1796 | - /** |
|
| 1797 | - * generates HTML for the Registration Questions meta box. |
|
| 1798 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 1799 | - * otherwise uses new forms system |
|
| 1800 | - * |
|
| 1801 | - * @access public |
|
| 1802 | - * @return void |
|
| 1803 | - */ |
|
| 1804 | - public function _reg_questions_meta_box() |
|
| 1805 | - { |
|
| 1806 | - //allow someone to override this method entirely |
|
| 1807 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 1808 | - $this->_registration)) { |
|
| 1809 | - $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 1810 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
| 1811 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 1812 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1813 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1814 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1815 | - } |
|
| 1816 | - } |
|
| 1817 | - |
|
| 1818 | - |
|
| 1819 | - /** |
|
| 1820 | - * form_before_question_group |
|
| 1821 | - * |
|
| 1822 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1823 | - * @access public |
|
| 1824 | - * @param string $output |
|
| 1825 | - * @return string |
|
| 1826 | - */ |
|
| 1827 | - public function form_before_question_group($output) |
|
| 1828 | - { |
|
| 1829 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1830 | - __('This method would have been protected but was used on a filter callback' |
|
| 1831 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1832 | - '4.8.32.rc.000'); |
|
| 1833 | - return ' |
|
| 1050 | + if ( ! empty($registration_status)) { |
|
| 1051 | + $where['STS_ID'] = $registration_status; |
|
| 1052 | + } else { |
|
| 1053 | + //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1054 | + if ($view === 'trash') { |
|
| 1055 | + $where['REG_deleted'] = true; |
|
| 1056 | + } else if ($view === 'incomplete') { |
|
| 1057 | + $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1058 | + } else { |
|
| 1059 | + $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1062 | + return $where; |
|
| 1063 | + } |
|
| 1064 | + |
|
| 1065 | + |
|
| 1066 | + /** |
|
| 1067 | + * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1068 | + * |
|
| 1069 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1070 | + * @return array |
|
| 1071 | + */ |
|
| 1072 | + protected function _add_date_to_where_conditions(array $request) |
|
| 1073 | + { |
|
| 1074 | + $where = array(); |
|
| 1075 | + $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1076 | + $month_range = ! empty($request['month_range']) |
|
| 1077 | + ? sanitize_text_field($request['month_range']) |
|
| 1078 | + : ''; |
|
| 1079 | + $retrieve_for_today = $view === 'today'; |
|
| 1080 | + $retrieve_for_this_month = $view === 'month'; |
|
| 1081 | + |
|
| 1082 | + if ($retrieve_for_today) { |
|
| 1083 | + $now = date('Y-m-d', current_time('timestamp')); |
|
| 1084 | + $where['REG_date'] = array( |
|
| 1085 | + 'BETWEEN', |
|
| 1086 | + array( |
|
| 1087 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1088 | + 'REG_date', |
|
| 1089 | + $now . ' 00:00:00', |
|
| 1090 | + 'Y-m-d H:i:s' |
|
| 1091 | + ), |
|
| 1092 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1093 | + 'REG_date', |
|
| 1094 | + $now . ' 23:59:59', |
|
| 1095 | + 'Y-m-d H:i:s' |
|
| 1096 | + ), |
|
| 1097 | + ), |
|
| 1098 | + ); |
|
| 1099 | + } elseif ($retrieve_for_this_month) { |
|
| 1100 | + $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1101 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1102 | + $where['REG_date'] = array( |
|
| 1103 | + 'BETWEEN', |
|
| 1104 | + array( |
|
| 1105 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1106 | + 'REG_date', |
|
| 1107 | + $current_year_and_month . '-01 00:00:00', |
|
| 1108 | + 'Y-m-d H:i:s' |
|
| 1109 | + ), |
|
| 1110 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1111 | + 'REG_date', |
|
| 1112 | + $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1113 | + 'Y-m-d H:i:s' |
|
| 1114 | + ), |
|
| 1115 | + ), |
|
| 1116 | + ); |
|
| 1117 | + } elseif ($month_range) { |
|
| 1118 | + $pieces = explode(' ', $month_range, 3); |
|
| 1119 | + $month_requested = ! empty($pieces[0]) |
|
| 1120 | + ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1121 | + : ''; |
|
| 1122 | + $year_requested = ! empty($pieces[1]) |
|
| 1123 | + ? $pieces[1] |
|
| 1124 | + : ''; |
|
| 1125 | + //if there is not a month or year then we can't go further |
|
| 1126 | + if ($month_requested && $year_requested) { |
|
| 1127 | + $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1128 | + $where['REG_date'] = array( |
|
| 1129 | + 'BETWEEN', |
|
| 1130 | + array( |
|
| 1131 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1132 | + 'REG_date', |
|
| 1133 | + $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1134 | + 'Y-m-d H:i:s' |
|
| 1135 | + ), |
|
| 1136 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1137 | + 'REG_date', |
|
| 1138 | + $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1139 | + 'Y-m-d H:i:s' |
|
| 1140 | + ), |
|
| 1141 | + ), |
|
| 1142 | + ); |
|
| 1143 | + } |
|
| 1144 | + } |
|
| 1145 | + return $where; |
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + |
|
| 1149 | + /** |
|
| 1150 | + * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1151 | + * |
|
| 1152 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1153 | + * @return array |
|
| 1154 | + */ |
|
| 1155 | + protected function _add_search_to_where_conditions(array $request) |
|
| 1156 | + { |
|
| 1157 | + $where = array(); |
|
| 1158 | + if ( ! empty($request['s'])) { |
|
| 1159 | + $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1160 | + $where['OR'] = array( |
|
| 1161 | + 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1162 | + 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1163 | + 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1164 | + 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1165 | + 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1166 | + 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1167 | + 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1168 | + 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1169 | + 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1170 | + 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1171 | + 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1172 | + 'REG_final_price' => array('LIKE', $search_string), |
|
| 1173 | + 'REG_code' => array('LIKE', $search_string), |
|
| 1174 | + 'REG_count' => array('LIKE', $search_string), |
|
| 1175 | + 'REG_group_size' => array('LIKE', $search_string), |
|
| 1176 | + 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1177 | + 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1178 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1179 | + ); |
|
| 1180 | + } |
|
| 1181 | + return $where; |
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + |
|
| 1185 | + /** |
|
| 1186 | + * Sets up the where conditions for the registrations query. |
|
| 1187 | + * |
|
| 1188 | + * @param array $request |
|
| 1189 | + * @return array |
|
| 1190 | + */ |
|
| 1191 | + protected function _get_where_conditions_for_registrations_query($request) |
|
| 1192 | + { |
|
| 1193 | + return array_merge( |
|
| 1194 | + $this->_add_event_id_to_where_conditions($request), |
|
| 1195 | + $this->_add_category_id_to_where_conditions($request), |
|
| 1196 | + $this->_add_datetime_id_to_where_conditions($request), |
|
| 1197 | + $this->_add_registration_status_to_where_conditions($request), |
|
| 1198 | + $this->_add_date_to_where_conditions($request), |
|
| 1199 | + $this->_add_search_to_where_conditions($request) |
|
| 1200 | + ); |
|
| 1201 | + } |
|
| 1202 | + |
|
| 1203 | + |
|
| 1204 | + /** |
|
| 1205 | + * Sets up the orderby for the registrations query. |
|
| 1206 | + * |
|
| 1207 | + * @return array |
|
| 1208 | + */ |
|
| 1209 | + protected function _get_orderby_for_registrations_query() |
|
| 1210 | + { |
|
| 1211 | + $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1212 | + ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1213 | + : ''; |
|
| 1214 | + switch ($orderby_field) { |
|
| 1215 | + case '_REG_ID': |
|
| 1216 | + $orderby_field = 'REG_ID'; |
|
| 1217 | + break; |
|
| 1218 | + case '_Reg_status': |
|
| 1219 | + $orderby_field = 'STS_ID'; |
|
| 1220 | + break; |
|
| 1221 | + case 'ATT_fname': |
|
| 1222 | + $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1223 | + break; |
|
| 1224 | + case 'ATT_lname' : |
|
| 1225 | + $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1226 | + break; |
|
| 1227 | + case 'event_name': |
|
| 1228 | + $orderby_field = 'Event.EVT_name'; |
|
| 1229 | + break; |
|
| 1230 | + case 'DTT_EVT_start': |
|
| 1231 | + $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1232 | + break; |
|
| 1233 | + default: //'REG_date' |
|
| 1234 | + $orderby_field = 'REG_date'; |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + //order |
|
| 1238 | + $order = ! empty($this->_req_data['order']) |
|
| 1239 | + ? sanitize_text_field($this->_req_data['order']) |
|
| 1240 | + : 'DESC'; |
|
| 1241 | + |
|
| 1242 | + //mutate orderby_field |
|
| 1243 | + $orderby_field = array_combine( |
|
| 1244 | + (array) $orderby_field, |
|
| 1245 | + array_fill(0, count($orderby_field), $order) |
|
| 1246 | + ); |
|
| 1247 | + return array('order_by' => $orderby_field); |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + |
|
| 1251 | + /** |
|
| 1252 | + * Sets up the limit for the registrations query. |
|
| 1253 | + * |
|
| 1254 | + * @param $per_page |
|
| 1255 | + * @return array |
|
| 1256 | + */ |
|
| 1257 | + protected function _get_limit($per_page) |
|
| 1258 | + { |
|
| 1259 | + $current_page = ! empty($this->_req_data['paged']) |
|
| 1260 | + ? absint($this->_req_data['paged']) |
|
| 1261 | + : 1; |
|
| 1262 | + $per_page = ! empty($this->_req_data['perpage']) |
|
| 1263 | + ? $this->_req_data['perpage'] |
|
| 1264 | + : $per_page; |
|
| 1265 | + |
|
| 1266 | + //-1 means return all results so get out if that's set. |
|
| 1267 | + if ((int)$per_page === -1) { |
|
| 1268 | + return array(); |
|
| 1269 | + } |
|
| 1270 | + $per_page = absint($per_page); |
|
| 1271 | + $offset = ($current_page - 1) * $per_page; |
|
| 1272 | + return array('limit' => array($offset, $per_page)); |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + |
|
| 1276 | + public function get_registration_status_array() |
|
| 1277 | + { |
|
| 1278 | + return self::$_reg_status; |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + |
|
| 1282 | + |
|
| 1283 | + |
|
| 1284 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1285 | + /** |
|
| 1286 | + * generates HTML for the View Registration Details Admin page |
|
| 1287 | + * |
|
| 1288 | + * @access protected |
|
| 1289 | + * @return void |
|
| 1290 | + */ |
|
| 1291 | + protected function _registration_details() |
|
| 1292 | + { |
|
| 1293 | + $this->_template_args = array(); |
|
| 1294 | + $this->_set_registration_object(); |
|
| 1295 | + if (is_object($this->_registration)) { |
|
| 1296 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1297 | + : EE_Transaction::new_instance(); |
|
| 1298 | + $this->_session = $transaction->session_data(); |
|
| 1299 | + $event_id = $this->_registration->event_ID(); |
|
| 1300 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1301 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
| 1302 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1303 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 1304 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1305 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1306 | + // link back to overview |
|
| 1307 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1308 | + $this->_template_args['registration'] = $this->_registration; |
|
| 1309 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1310 | + 'action' => 'default', |
|
| 1311 | + 'event_id' => $event_id, |
|
| 1312 | + ), REG_ADMIN_URL); |
|
| 1313 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1314 | + 'action' => 'default', |
|
| 1315 | + 'EVT_ID' => $event_id, |
|
| 1316 | + 'page' => 'espresso_transactions', |
|
| 1317 | + ), admin_url('admin.php')); |
|
| 1318 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1319 | + 'page' => 'espresso_events', |
|
| 1320 | + 'action' => 'edit', |
|
| 1321 | + 'post' => $event_id, |
|
| 1322 | + ), admin_url('admin.php')); |
|
| 1323 | + //next and previous links |
|
| 1324 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
| 1325 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1326 | + ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1327 | + 'action' => 'view_registration', |
|
| 1328 | + '_REG_ID' => $next_reg['REG_ID'], |
|
| 1329 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
| 1330 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
| 1331 | + $this->_template_args['previous_registration'] = $previous_reg |
|
| 1332 | + ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1333 | + 'action' => 'view_registration', |
|
| 1334 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1335 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
| 1336 | + // grab header |
|
| 1337 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1338 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1339 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 1340 | + $this->_template_args, true); |
|
| 1341 | + } else { |
|
| 1342 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1343 | + } |
|
| 1344 | + // the details template wrapper |
|
| 1345 | + $this->display_admin_page_with_sidebar(); |
|
| 1346 | + } |
|
| 1347 | + |
|
| 1348 | + |
|
| 1349 | + protected function _registration_details_metaboxes() |
|
| 1350 | + { |
|
| 1351 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1352 | + $this->_set_registration_object(); |
|
| 1353 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1354 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
| 1355 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1356 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
| 1357 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1358 | + if ($attendee instanceof EE_Attendee |
|
| 1359 | + && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
| 1360 | + ) { |
|
| 1361 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
| 1362 | + array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1363 | + } |
|
| 1364 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
| 1365 | + array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
| 1366 | + if ($this->_registration->group_size() > 1) { |
|
| 1367 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1368 | + array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1369 | + } |
|
| 1370 | + } |
|
| 1371 | + |
|
| 1372 | + |
|
| 1373 | + /** |
|
| 1374 | + * set_reg_status_buttons_metabox |
|
| 1375 | + * |
|
| 1376 | + * @access protected |
|
| 1377 | + * @return string |
|
| 1378 | + * @throws \EE_Error |
|
| 1379 | + */ |
|
| 1380 | + public function set_reg_status_buttons_metabox() |
|
| 1381 | + { |
|
| 1382 | + $this->_set_registration_object(); |
|
| 1383 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1384 | + echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
| 1385 | + 'action' => 'change_reg_status', |
|
| 1386 | + ), REG_ADMIN_URL)); |
|
| 1387 | + echo $change_reg_status_form->get_html(); |
|
| 1388 | + echo $change_reg_status_form->form_close(); |
|
| 1389 | + } |
|
| 1390 | + |
|
| 1391 | + |
|
| 1392 | + /** |
|
| 1393 | + * @return EE_Form_Section_Proper |
|
| 1394 | + */ |
|
| 1395 | + protected function _generate_reg_status_change_form() |
|
| 1396 | + { |
|
| 1397 | + return new EE_Form_Section_Proper(array( |
|
| 1398 | + 'name' => 'reg_status_change_form', |
|
| 1399 | + 'html_id' => 'reg-status-change-form', |
|
| 1400 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1401 | + 'subsections' => array( |
|
| 1402 | + 'return' => new EE_Hidden_Input(array( |
|
| 1403 | + 'name' => 'return', |
|
| 1404 | + 'default' => 'view_registration', |
|
| 1405 | + )), |
|
| 1406 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1407 | + 'name' => 'REG_ID', |
|
| 1408 | + 'default' => $this->_registration->ID(), |
|
| 1409 | + )), |
|
| 1410 | + 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
| 1411 | + 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1412 | + '', 'status-' . $this->_registration->status_ID(), |
|
| 1413 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
| 1414 | + 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
| 1415 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
| 1416 | + 'default' => $this->_registration->status_ID(), |
|
| 1417 | + )), |
|
| 1418 | + 'send_notifications' => new EE_Yes_No_Input(array( |
|
| 1419 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
| 1420 | + 'default' => false, |
|
| 1421 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1422 | + 'event_espresso'), |
|
| 1423 | + )), |
|
| 1424 | + 'submit' => new EE_Submit_Input(array( |
|
| 1425 | + 'html_class' => 'button-primary', |
|
| 1426 | + 'html_label_text' => ' ', |
|
| 1427 | + 'default' => __('Update Registration Status', 'event_espresso'), |
|
| 1428 | + )), |
|
| 1429 | + ), |
|
| 1430 | + )); |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + |
|
| 1434 | + |
|
| 1435 | + /** |
|
| 1436 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1437 | + * |
|
| 1438 | + * @return array |
|
| 1439 | + */ |
|
| 1440 | + protected function _get_reg_statuses() |
|
| 1441 | + { |
|
| 1442 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1443 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1444 | + // get current reg status |
|
| 1445 | + $current_status = $this->_registration->status_ID(); |
|
| 1446 | + // is registration for free event? This will determine whether to display the pending payment option |
|
| 1447 | + if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1448 | + && $this->_registration->transaction() |
|
| 1449 | + ->is_free() |
|
| 1450 | + ) { |
|
| 1451 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1452 | + } |
|
| 1453 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1454 | + } |
|
| 1455 | + |
|
| 1456 | + |
|
| 1457 | + /** |
|
| 1458 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1459 | + * |
|
| 1460 | + * @param bool $status REG status given for changing registrations to. |
|
| 1461 | + * @param bool $notify Whether to send messages notifications or not. |
|
| 1462 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1463 | + */ |
|
| 1464 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1465 | + { |
|
| 1466 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1467 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1468 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1469 | + } else { |
|
| 1470 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1471 | + } |
|
| 1472 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1473 | + //notify? |
|
| 1474 | + if ($success |
|
| 1475 | + && $notify |
|
| 1476 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1477 | + 'espresso_registrations_resend_registration') |
|
| 1478 | + ) { |
|
| 1479 | + $this->_process_resend_registration(); |
|
| 1480 | + } |
|
| 1481 | + return $success; |
|
| 1482 | + } |
|
| 1483 | + |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1487 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1488 | + * |
|
| 1489 | + * @param array $REG_IDs |
|
| 1490 | + * @param bool $status |
|
| 1491 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1492 | + * the array of updated registrations). |
|
| 1493 | + */ |
|
| 1494 | + protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1495 | + { |
|
| 1496 | + $success = false; |
|
| 1497 | + // typecast $REG_IDs |
|
| 1498 | + $REG_IDs = (array)$REG_IDs; |
|
| 1499 | + if ( ! empty($REG_IDs)) { |
|
| 1500 | + $success = true; |
|
| 1501 | + // set default status if none is passed |
|
| 1502 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1503 | + // sanitize $REG_IDs |
|
| 1504 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1505 | + //loop through REG_ID's and change status |
|
| 1506 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1507 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1508 | + if ($registration instanceof EE_Registration) { |
|
| 1509 | + $registration->set_status($status); |
|
| 1510 | + $result = $registration->save(); |
|
| 1511 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1512 | + $success = $result !== false ? $success : false; |
|
| 1513 | + } |
|
| 1514 | + } |
|
| 1515 | + } |
|
| 1516 | + //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1517 | + $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1518 | + //return $success and processed registrations |
|
| 1519 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + |
|
| 1523 | + /** |
|
| 1524 | + * Common logic for setting up success message and redirecting to appropriate route |
|
| 1525 | + * |
|
| 1526 | + * @param string $STS_ID status id for the registration changed to |
|
| 1527 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1528 | + * @return void |
|
| 1529 | + */ |
|
| 1530 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1531 | + { |
|
| 1532 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1533 | + : array('success' => false); |
|
| 1534 | + $success = isset($result['success']) && $result['success']; |
|
| 1535 | + //setup success message |
|
| 1536 | + if ($success) { |
|
| 1537 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1538 | + $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
| 1539 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1540 | + } else { |
|
| 1541 | + $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1542 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1543 | + } |
|
| 1544 | + EE_Error::add_success($msg); |
|
| 1545 | + } else { |
|
| 1546 | + EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
| 1547 | + __LINE__, __FUNCTION__); |
|
| 1548 | + } |
|
| 1549 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1550 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1551 | + } else { |
|
| 1552 | + $route = array('action' => 'default'); |
|
| 1553 | + } |
|
| 1554 | + //unset nonces |
|
| 1555 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1556 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1557 | + unset($this->_req_data[$ref]); |
|
| 1558 | + continue; |
|
| 1559 | + } |
|
| 1560 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1561 | + $this->_req_data[$ref] = $value; |
|
| 1562 | + } |
|
| 1563 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1564 | + $route = array_merge($this->_req_data, $route); |
|
| 1565 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1566 | + } |
|
| 1567 | + |
|
| 1568 | + |
|
| 1569 | + /** |
|
| 1570 | + * incoming reg status change from reg details page. |
|
| 1571 | + * |
|
| 1572 | + * @return void |
|
| 1573 | + */ |
|
| 1574 | + protected function _change_reg_status() |
|
| 1575 | + { |
|
| 1576 | + $this->_req_data['return'] = 'view_registration'; |
|
| 1577 | + //set notify based on whether the send notifications toggle is set or not |
|
| 1578 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1579 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1580 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1581 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1582 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1583 | + case EEM_Registration::status_id_approved : |
|
| 1584 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1585 | + $this->approve_registration($notify); |
|
| 1586 | + break; |
|
| 1587 | + case EEM_Registration::status_id_pending_payment : |
|
| 1588 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1589 | + $this->pending_registration($notify); |
|
| 1590 | + break; |
|
| 1591 | + case EEM_Registration::status_id_not_approved : |
|
| 1592 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1593 | + $this->not_approve_registration($notify); |
|
| 1594 | + break; |
|
| 1595 | + case EEM_Registration::status_id_declined : |
|
| 1596 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1597 | + $this->decline_registration($notify); |
|
| 1598 | + break; |
|
| 1599 | + case EEM_Registration::status_id_cancelled : |
|
| 1600 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1601 | + $this->cancel_registration($notify); |
|
| 1602 | + break; |
|
| 1603 | + case EEM_Registration::status_id_wait_list : |
|
| 1604 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1605 | + $this->waitlist_registration($notify); |
|
| 1606 | + break; |
|
| 1607 | + case EEM_Registration::status_id_incomplete : |
|
| 1608 | + default : |
|
| 1609 | + $result['success'] = false; |
|
| 1610 | + unset($this->_req_data['return']); |
|
| 1611 | + $this->_reg_status_change_return('', false); |
|
| 1612 | + break; |
|
| 1613 | + } |
|
| 1614 | + } |
|
| 1615 | + |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * approve_registration |
|
| 1619 | + * |
|
| 1620 | + * @access protected |
|
| 1621 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1622 | + * @return void |
|
| 1623 | + */ |
|
| 1624 | + protected function approve_registration($notify = false) |
|
| 1625 | + { |
|
| 1626 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + |
|
| 1630 | + /** |
|
| 1631 | + * decline_registration |
|
| 1632 | + * |
|
| 1633 | + * @access protected |
|
| 1634 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1635 | + * @return void |
|
| 1636 | + */ |
|
| 1637 | + protected function decline_registration($notify = false) |
|
| 1638 | + { |
|
| 1639 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + |
|
| 1643 | + /** |
|
| 1644 | + * cancel_registration |
|
| 1645 | + * |
|
| 1646 | + * @access protected |
|
| 1647 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1648 | + * @return void |
|
| 1649 | + */ |
|
| 1650 | + protected function cancel_registration($notify = false) |
|
| 1651 | + { |
|
| 1652 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + |
|
| 1656 | + /** |
|
| 1657 | + * not_approve_registration |
|
| 1658 | + * |
|
| 1659 | + * @access protected |
|
| 1660 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1661 | + * @return void |
|
| 1662 | + */ |
|
| 1663 | + protected function not_approve_registration($notify = false) |
|
| 1664 | + { |
|
| 1665 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * decline_registration |
|
| 1671 | + * |
|
| 1672 | + * @access protected |
|
| 1673 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1674 | + * @return void |
|
| 1675 | + */ |
|
| 1676 | + protected function pending_registration($notify = false) |
|
| 1677 | + { |
|
| 1678 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1679 | + } |
|
| 1680 | + |
|
| 1681 | + |
|
| 1682 | + /** |
|
| 1683 | + * waitlist_registration |
|
| 1684 | + * |
|
| 1685 | + * @access protected |
|
| 1686 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1687 | + * @return void |
|
| 1688 | + */ |
|
| 1689 | + protected function waitlist_registration($notify = false) |
|
| 1690 | + { |
|
| 1691 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + |
|
| 1695 | + /** |
|
| 1696 | + * generates HTML for the Registration main meta box |
|
| 1697 | + * |
|
| 1698 | + * @access public |
|
| 1699 | + * @return void |
|
| 1700 | + */ |
|
| 1701 | + public function _reg_details_meta_box() |
|
| 1702 | + { |
|
| 1703 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1704 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1705 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1706 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1707 | + : EE_Transaction::new_instance(); |
|
| 1708 | + $this->_session = $transaction->session_data(); |
|
| 1709 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1710 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1711 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1712 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1713 | + $transaction->total_line_item()); |
|
| 1714 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1715 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1716 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1717 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
| 1718 | + array('EE_Registration' => $this->_registration)); |
|
| 1719 | + $attendee = $this->_registration->attendee(); |
|
| 1720 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 1721 | + 'espresso_transactions_view_transaction') |
|
| 1722 | + ) { |
|
| 1723 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1724 | + 'action' => 'view_transaction', |
|
| 1725 | + 'TXN_ID' => $transaction->ID(), |
|
| 1726 | + ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
| 1727 | + 'dashicons dashicons-cart'); |
|
| 1728 | + } else { |
|
| 1729 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 1730 | + } |
|
| 1731 | + if ($attendee instanceof EE_Attendee |
|
| 1732 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1733 | + 'espresso_registrations_resend_registration') |
|
| 1734 | + ) { |
|
| 1735 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1736 | + 'action' => 'resend_registration', |
|
| 1737 | + '_REG_ID' => $this->_registration->ID(), |
|
| 1738 | + 'redirect_to' => 'view_registration', |
|
| 1739 | + ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
| 1740 | + 'dashicons dashicons-email-alt'); |
|
| 1741 | + } else { |
|
| 1742 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 1743 | + } |
|
| 1744 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1745 | + $payment = $transaction->get_first_related('Payment'); |
|
| 1746 | + $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
| 1747 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1748 | + $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
| 1749 | + : $payment_method; |
|
| 1750 | + $reg_details = array( |
|
| 1751 | + 'payment_method' => $payment_method->name(), |
|
| 1752 | + 'response_msg' => $payment->gateway_response(), |
|
| 1753 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1754 | + 'registration_session' => $this->_registration->session_ID(), |
|
| 1755 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1756 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1757 | + ); |
|
| 1758 | + if (isset($reg_details['registration_id'])) { |
|
| 1759 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1760 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
| 1761 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 1762 | + } |
|
| 1763 | + if (isset($reg_details['payment_method'])) { |
|
| 1764 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 1765 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
| 1766 | + 'event_espresso'); |
|
| 1767 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 1768 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 1769 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
| 1770 | + 'event_espresso'); |
|
| 1771 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 1772 | + } |
|
| 1773 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 1774 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
| 1775 | + 'event_espresso'); |
|
| 1776 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 1777 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 1778 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
| 1779 | + 'event_espresso'); |
|
| 1780 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 1781 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 1782 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', |
|
| 1783 | + 'event_espresso'); |
|
| 1784 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 1785 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1786 | + 'action' => 'default', |
|
| 1787 | + 'event_id' => $this->_registration->event_ID(), |
|
| 1788 | + ), REG_ADMIN_URL); |
|
| 1789 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1790 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 1791 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1792 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1793 | + } |
|
| 1794 | + |
|
| 1795 | + |
|
| 1796 | + /** |
|
| 1797 | + * generates HTML for the Registration Questions meta box. |
|
| 1798 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 1799 | + * otherwise uses new forms system |
|
| 1800 | + * |
|
| 1801 | + * @access public |
|
| 1802 | + * @return void |
|
| 1803 | + */ |
|
| 1804 | + public function _reg_questions_meta_box() |
|
| 1805 | + { |
|
| 1806 | + //allow someone to override this method entirely |
|
| 1807 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 1808 | + $this->_registration)) { |
|
| 1809 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 1810 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
| 1811 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 1812 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1813 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1814 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1815 | + } |
|
| 1816 | + } |
|
| 1817 | + |
|
| 1818 | + |
|
| 1819 | + /** |
|
| 1820 | + * form_before_question_group |
|
| 1821 | + * |
|
| 1822 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1823 | + * @access public |
|
| 1824 | + * @param string $output |
|
| 1825 | + * @return string |
|
| 1826 | + */ |
|
| 1827 | + public function form_before_question_group($output) |
|
| 1828 | + { |
|
| 1829 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1830 | + __('This method would have been protected but was used on a filter callback' |
|
| 1831 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1832 | + '4.8.32.rc.000'); |
|
| 1833 | + return ' |
|
| 1834 | 1834 | <table class="form-table ee-width-100"> |
| 1835 | 1835 | <tbody> |
| 1836 | 1836 | '; |
| 1837 | - } |
|
| 1838 | - |
|
| 1839 | - |
|
| 1840 | - /** |
|
| 1841 | - * form_after_question_group |
|
| 1842 | - * |
|
| 1843 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1844 | - * @access public |
|
| 1845 | - * @param string $output |
|
| 1846 | - * @return string |
|
| 1847 | - */ |
|
| 1848 | - public function form_after_question_group($output) |
|
| 1849 | - { |
|
| 1850 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1851 | - __('This method would have been protected but was used on a filter callback' |
|
| 1852 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1853 | - '4.8.32.rc.000'); |
|
| 1854 | - return ' |
|
| 1837 | + } |
|
| 1838 | + |
|
| 1839 | + |
|
| 1840 | + /** |
|
| 1841 | + * form_after_question_group |
|
| 1842 | + * |
|
| 1843 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1844 | + * @access public |
|
| 1845 | + * @param string $output |
|
| 1846 | + * @return string |
|
| 1847 | + */ |
|
| 1848 | + public function form_after_question_group($output) |
|
| 1849 | + { |
|
| 1850 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1851 | + __('This method would have been protected but was used on a filter callback' |
|
| 1852 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1853 | + '4.8.32.rc.000'); |
|
| 1854 | + return ' |
|
| 1855 | 1855 | <tr class="hide-if-no-js"> |
| 1856 | 1856 | <th> </th> |
| 1857 | 1857 | <td class="reg-admin-edit-attendee-question-td"> |
| 1858 | 1858 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
| 1859 | - . esc_attr__('click to edit question', 'event_espresso') |
|
| 1860 | - . '"> |
|
| 1859 | + . esc_attr__('click to edit question', 'event_espresso') |
|
| 1860 | + . '"> |
|
| 1861 | 1861 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
| 1862 | - . __('edit the above question group', 'event_espresso') |
|
| 1863 | - . '</span> |
|
| 1862 | + . __('edit the above question group', 'event_espresso') |
|
| 1863 | + . '</span> |
|
| 1864 | 1864 | <div class="dashicons dashicons-edit"></div> |
| 1865 | 1865 | </a> |
| 1866 | 1866 | </td> |
@@ -1868,490 +1868,490 @@ discard block |
||
| 1868 | 1868 | </tbody> |
| 1869 | 1869 | </table> |
| 1870 | 1870 | '; |
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - |
|
| 1874 | - /** |
|
| 1875 | - * form_form_field_label_wrap |
|
| 1876 | - * |
|
| 1877 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1878 | - * @access public |
|
| 1879 | - * @param string $label |
|
| 1880 | - * @return string |
|
| 1881 | - */ |
|
| 1882 | - public function form_form_field_label_wrap($label) |
|
| 1883 | - { |
|
| 1884 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1885 | - __('This method would have been protected but was used on a filter callback' |
|
| 1886 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1887 | - '4.8.32.rc.000'); |
|
| 1888 | - return ' |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + |
|
| 1874 | + /** |
|
| 1875 | + * form_form_field_label_wrap |
|
| 1876 | + * |
|
| 1877 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1878 | + * @access public |
|
| 1879 | + * @param string $label |
|
| 1880 | + * @return string |
|
| 1881 | + */ |
|
| 1882 | + public function form_form_field_label_wrap($label) |
|
| 1883 | + { |
|
| 1884 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1885 | + __('This method would have been protected but was used on a filter callback' |
|
| 1886 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1887 | + '4.8.32.rc.000'); |
|
| 1888 | + return ' |
|
| 1889 | 1889 | <tr> |
| 1890 | 1890 | <th> |
| 1891 | 1891 | ' . $label . ' |
| 1892 | 1892 | </th>'; |
| 1893 | - } |
|
| 1894 | - |
|
| 1895 | - |
|
| 1896 | - /** |
|
| 1897 | - * form_form_field_input__wrap |
|
| 1898 | - * |
|
| 1899 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1900 | - * @access public |
|
| 1901 | - * @param string $input |
|
| 1902 | - * @return string |
|
| 1903 | - */ |
|
| 1904 | - public function form_form_field_input__wrap($input) |
|
| 1905 | - { |
|
| 1906 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1907 | - __('This method would have been protected but was used on a filter callback' |
|
| 1908 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1909 | - '4.8.32.rc.000'); |
|
| 1910 | - return ' |
|
| 1893 | + } |
|
| 1894 | + |
|
| 1895 | + |
|
| 1896 | + /** |
|
| 1897 | + * form_form_field_input__wrap |
|
| 1898 | + * |
|
| 1899 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1900 | + * @access public |
|
| 1901 | + * @param string $input |
|
| 1902 | + * @return string |
|
| 1903 | + */ |
|
| 1904 | + public function form_form_field_input__wrap($input) |
|
| 1905 | + { |
|
| 1906 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1907 | + __('This method would have been protected but was used on a filter callback' |
|
| 1908 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1909 | + '4.8.32.rc.000'); |
|
| 1910 | + return ' |
|
| 1911 | 1911 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 1912 | 1912 | ' . $input . ' |
| 1913 | 1913 | </td> |
| 1914 | 1914 | </tr>'; |
| 1915 | - } |
|
| 1916 | - |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 1920 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 1921 | - * to display the page |
|
| 1922 | - * |
|
| 1923 | - * @access protected |
|
| 1924 | - * @return void |
|
| 1925 | - */ |
|
| 1926 | - protected function _update_attendee_registration_form() |
|
| 1927 | - { |
|
| 1928 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 1929 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 1930 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1931 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 1932 | - if ($success) { |
|
| 1933 | - $what = __('Registration Form', 'event_espresso'); |
|
| 1934 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 1935 | - : array('action' => 'default'); |
|
| 1936 | - $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 1937 | - } |
|
| 1938 | - } |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - |
|
| 1942 | - /** |
|
| 1943 | - * Gets the form for saving registrations custom questions (if done |
|
| 1944 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
| 1945 | - * |
|
| 1946 | - * @param int $REG_ID |
|
| 1947 | - * @return EE_Registration_Custom_Questions_Form |
|
| 1948 | - */ |
|
| 1949 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
| 1950 | - { |
|
| 1951 | - if ( ! $this->_reg_custom_questions_form) { |
|
| 1952 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1953 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 1954 | - EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 1955 | - ); |
|
| 1956 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 1957 | - } |
|
| 1958 | - return $this->_reg_custom_questions_form; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - |
|
| 1962 | - /** |
|
| 1963 | - * Saves |
|
| 1964 | - * |
|
| 1965 | - * @access private |
|
| 1966 | - * @param bool $REG_ID |
|
| 1967 | - * @return bool |
|
| 1968 | - */ |
|
| 1969 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 1970 | - { |
|
| 1971 | - if ( ! $REG_ID) { |
|
| 1972 | - EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
| 1973 | - __FUNCTION__, __LINE__); |
|
| 1974 | - } |
|
| 1975 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 1976 | - $form->receive_form_submission($this->_req_data); |
|
| 1977 | - $success = false; |
|
| 1978 | - if ($form->is_valid()) { |
|
| 1979 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 1980 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 1981 | - $where_conditions = array( |
|
| 1982 | - 'QST_ID' => $question_id, |
|
| 1983 | - 'REG_ID' => $REG_ID, |
|
| 1984 | - ); |
|
| 1985 | - $possibly_new_values = array( |
|
| 1986 | - 'ANS_value' => $input->normalized_value(), |
|
| 1987 | - ); |
|
| 1988 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 1989 | - if ($answer instanceof EE_Answer) { |
|
| 1990 | - $success = $answer->save($possibly_new_values); |
|
| 1991 | - } else { |
|
| 1992 | - //insert it then |
|
| 1993 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 1994 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 1995 | - $success = $answer->save(); |
|
| 1996 | - } |
|
| 1997 | - } |
|
| 1998 | - } |
|
| 1999 | - } else { |
|
| 2000 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2001 | - } |
|
| 2002 | - return $success; |
|
| 2003 | - } |
|
| 2004 | - |
|
| 2005 | - |
|
| 2006 | - /** |
|
| 2007 | - * generates HTML for the Registration main meta box |
|
| 2008 | - * |
|
| 2009 | - * @access public |
|
| 2010 | - * @return void |
|
| 2011 | - */ |
|
| 2012 | - public function _reg_attendees_meta_box() |
|
| 2013 | - { |
|
| 2014 | - $REG = EEM_Registration::instance(); |
|
| 2015 | - //get all other registrations on this transaction, and cache |
|
| 2016 | - //the attendees for them so we don't have to run another query using force_join |
|
| 2017 | - $registrations = $REG->get_all(array( |
|
| 2018 | - array( |
|
| 2019 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2020 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2021 | - ), |
|
| 2022 | - 'force_join' => array('Attendee'), |
|
| 2023 | - )); |
|
| 2024 | - $this->_template_args['attendees'] = array(); |
|
| 2025 | - $this->_template_args['attendee_notice'] = ''; |
|
| 2026 | - if (empty($registrations) |
|
| 2027 | - || (is_array($registrations) |
|
| 2028 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2029 | - ) { |
|
| 2030 | - EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2031 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2032 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2033 | - } else { |
|
| 2034 | - $att_nmbr = 1; |
|
| 2035 | - foreach ($registrations as $registration) { |
|
| 2036 | - /* @var $registration EE_Registration */ |
|
| 2037 | - $attendee = $registration->attendee() |
|
| 2038 | - ? $registration->attendee() |
|
| 2039 | - : EEM_Attendee::instance() |
|
| 2040 | - ->create_default_object(); |
|
| 2041 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2042 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2043 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2044 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2045 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2046 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
| 2047 | - $attendee->full_address_as_array()); |
|
| 2048 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
| 2049 | - 'action' => 'edit_attendee', |
|
| 2050 | - 'post' => $attendee->ID(), |
|
| 2051 | - ), REG_ADMIN_URL); |
|
| 2052 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2053 | - $att_nmbr++; |
|
| 2054 | - } |
|
| 2055 | - //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
| 2056 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2057 | - // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
| 2058 | - } |
|
| 2059 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2060 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2061 | - } |
|
| 2062 | - |
|
| 2063 | - |
|
| 2064 | - /** |
|
| 2065 | - * generates HTML for the Edit Registration side meta box |
|
| 2066 | - * |
|
| 2067 | - * @access public |
|
| 2068 | - * @return void |
|
| 2069 | - */ |
|
| 2070 | - public function _reg_registrant_side_meta_box() |
|
| 2071 | - { |
|
| 2072 | - /*@var $attendee EE_Attendee */ |
|
| 2073 | - $att_check = $this->_registration->attendee(); |
|
| 2074 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2075 | - //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
| 2076 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2077 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2078 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2079 | - : null; |
|
| 2080 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2081 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
| 2082 | - $primary_registration = null; |
|
| 2083 | - } |
|
| 2084 | - } else { |
|
| 2085 | - $primary_registration = null; |
|
| 2086 | - } |
|
| 2087 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2088 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2089 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2090 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2091 | - $this->_template_args['phone'] = $attendee->phone(); |
|
| 2092 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2093 | - //edit link |
|
| 2094 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2095 | - 'action' => 'edit_attendee', |
|
| 2096 | - 'post' => $attendee->ID(), |
|
| 2097 | - ), REG_ADMIN_URL); |
|
| 2098 | - $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
| 2099 | - //create link |
|
| 2100 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2101 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2102 | - 'action' => 'duplicate_attendee', |
|
| 2103 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2104 | - ), REG_ADMIN_URL) : ''; |
|
| 2105 | - $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
| 2106 | - $this->_template_args['att_check'] = $att_check; |
|
| 2107 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2108 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2109 | - } |
|
| 2110 | - |
|
| 2111 | - |
|
| 2112 | - |
|
| 2113 | - /** |
|
| 2114 | - * trash or restore registrations |
|
| 2115 | - * |
|
| 2116 | - * @param boolean $trash whether to archive or restore |
|
| 2117 | - * @access protected |
|
| 2118 | - * @return void |
|
| 2119 | - * @throws \EE_Error |
|
| 2120 | - */ |
|
| 2121 | - protected function _trash_or_restore_registrations($trash = true) |
|
| 2122 | - { |
|
| 2123 | - //if empty _REG_ID then get out because there's nothing to do |
|
| 2124 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2125 | - EE_Error::add_error( |
|
| 2126 | - sprintf( |
|
| 2127 | - esc_html__( |
|
| 2128 | - 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2129 | - 'event_espresso' |
|
| 2130 | - ), |
|
| 2131 | - $trash ? 'trash' : 'restore' |
|
| 2132 | - ), |
|
| 2133 | - __FILE__, __LINE__, __FUNCTION__ |
|
| 2134 | - ); |
|
| 2135 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2136 | - } |
|
| 2137 | - $success = 0; |
|
| 2138 | - $overwrite_msgs = false; |
|
| 2139 | - //Checkboxes |
|
| 2140 | - if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2141 | - $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2142 | - } |
|
| 2143 | - $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2144 | - // cycle thru checkboxes |
|
| 2145 | - foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2146 | - /** @var EE_Registration $REG */ |
|
| 2147 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2148 | - $payments = $REG->registration_payments(); |
|
| 2149 | - if (! empty($payments)) { |
|
| 2150 | - $name = $REG->attendee() instanceof EE_Attendee |
|
| 2151 | - ? $REG->attendee()->full_name() |
|
| 2152 | - : __('Unknown Attendee', 'event_espresso'); |
|
| 2153 | - $overwrite_msgs = true; |
|
| 2154 | - EE_Error::add_error( |
|
| 2155 | - sprintf( |
|
| 2156 | - __( |
|
| 2157 | - '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.', |
|
| 2158 | - 'event_espresso' |
|
| 2159 | - ), |
|
| 2160 | - $name |
|
| 2161 | - ), |
|
| 2162 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2163 | - ); |
|
| 2164 | - //can't trash this registration because it has payments. |
|
| 2165 | - continue; |
|
| 2166 | - } |
|
| 2167 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2168 | - if ($updated) { |
|
| 2169 | - $success++; |
|
| 2170 | - } |
|
| 2171 | - } |
|
| 2172 | - $this->_redirect_after_action( |
|
| 2173 | - $success === $reg_count, // were ALL registrations affected? |
|
| 2174 | - $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'), |
|
| 2175 | - $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'), |
|
| 2176 | - array('action' => 'default'), |
|
| 2177 | - $overwrite_msgs |
|
| 2178 | - ); |
|
| 2179 | - } |
|
| 2180 | - |
|
| 2181 | - |
|
| 2182 | - /** |
|
| 2183 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2184 | - * registration but also. |
|
| 2185 | - * 1. Removing relations to EE_Attendee |
|
| 2186 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2187 | - * ALSO trashed. |
|
| 2188 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2189 | - * 4. Removing relationships between all tickets and the related registrations |
|
| 2190 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2191 | - * 6. Deleting permanently any related Checkins. |
|
| 2192 | - * |
|
| 2193 | - * @return void |
|
| 2194 | - */ |
|
| 2195 | - protected function _delete_registrations() |
|
| 2196 | - { |
|
| 2197 | - $REG_MDL = EEM_Registration::instance(); |
|
| 2198 | - $success = 1; |
|
| 2199 | - //Checkboxes |
|
| 2200 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2201 | - // if array has more than one element than success message should be plural |
|
| 2202 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2203 | - // cycle thru checkboxes |
|
| 2204 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2205 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2206 | - if ( ! $REG instanceof EE_Registration) { |
|
| 2207 | - continue; |
|
| 2208 | - } |
|
| 2209 | - $deleted = $this->_delete_registration($REG); |
|
| 2210 | - if ( ! $deleted) { |
|
| 2211 | - $success = 0; |
|
| 2212 | - } |
|
| 2213 | - } |
|
| 2214 | - } else { |
|
| 2215 | - // grab single id and delete |
|
| 2216 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2217 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2218 | - $deleted = $this->_delete_registration($REG); |
|
| 2219 | - if ( ! $deleted) { |
|
| 2220 | - $success = 0; |
|
| 2221 | - } |
|
| 2222 | - } |
|
| 2223 | - $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2224 | - $action_desc = __('permanently deleted.', 'event_espresso'); |
|
| 2225 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
| 2226 | - } |
|
| 2227 | - |
|
| 2228 | - |
|
| 2229 | - /** |
|
| 2230 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2231 | - * models get affected. |
|
| 2232 | - * |
|
| 2233 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2234 | - * @return boolean true = successful deletion, false = fail. |
|
| 2235 | - */ |
|
| 2236 | - protected function _delete_registration(EE_Registration $REG) |
|
| 2237 | - { |
|
| 2238 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
| 2239 | - $TXN = $REG->get_first_related('Transaction'); |
|
| 2240 | - $REGS = $TXN->get_many_related('Registration'); |
|
| 2241 | - $all_trashed = true; |
|
| 2242 | - foreach ($REGS as $registration) { |
|
| 2243 | - if ( ! $registration->get('REG_deleted')) { |
|
| 2244 | - $all_trashed = false; |
|
| 2245 | - } |
|
| 2246 | - } |
|
| 2247 | - if ( ! $all_trashed) { |
|
| 2248 | - EE_Error::add_error(__('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.', |
|
| 2249 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2250 | - return false; |
|
| 2251 | - } |
|
| 2252 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
| 2253 | - foreach ($REGS as $registration) { |
|
| 2254 | - //delete related answers |
|
| 2255 | - $registration->delete_related_permanently('Answer'); |
|
| 2256 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2257 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 2258 | - if ($attendee instanceof EE_Attendee) { |
|
| 2259 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2260 | - } |
|
| 2261 | - //now remove relationships to tickets on this registration. |
|
| 2262 | - $registration->_remove_relations('Ticket'); |
|
| 2263 | - //now delete permanently the checkins related to this registration. |
|
| 2264 | - $registration->delete_related_permanently('Checkin'); |
|
| 2265 | - if ($registration->ID() === $REG->ID()) { |
|
| 2266 | - continue; |
|
| 2267 | - } //we don't want to delete permanently the existing registration just yet. |
|
| 2268 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2269 | - $registration->_remove_relations('Transaction'); |
|
| 2270 | - //delete permanently any related messages. |
|
| 2271 | - $registration->delete_related_permanently('Message'); |
|
| 2272 | - //now delete this registration permanently |
|
| 2273 | - $registration->delete_permanently(); |
|
| 2274 | - } |
|
| 2275 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
| 2276 | - //delete the line items related to the transaction for this registration. |
|
| 2277 | - $TXN->delete_related_permanently('Line_Item'); |
|
| 2278 | - //we need to remove all the relationships on the transaction |
|
| 2279 | - $TXN->delete_related_permanently('Payment'); |
|
| 2280 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2281 | - $TXN->delete_related_permanently('Message'); |
|
| 2282 | - //now we can delete this REG permanently (and the transaction of course) |
|
| 2283 | - $REG->delete_related_permanently('Transaction'); |
|
| 2284 | - return $REG->delete_permanently(); |
|
| 2285 | - } |
|
| 2286 | - |
|
| 2287 | - |
|
| 2288 | - /** |
|
| 2289 | - * generates HTML for the Register New Attendee Admin page |
|
| 2290 | - * |
|
| 2291 | - * @access private |
|
| 2292 | - * @throws \EE_Error |
|
| 2293 | - * @return void |
|
| 2294 | - */ |
|
| 2295 | - public function new_registration() |
|
| 2296 | - { |
|
| 2297 | - if ( ! $this->_set_reg_event()) { |
|
| 2298 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
| 2299 | - 'event_espresso')); |
|
| 2300 | - } |
|
| 2301 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2302 | - // gotta start with a clean slate if we're not coming here via ajax |
|
| 2303 | - if ( ! defined('DOING_AJAX') |
|
| 2304 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2305 | - ) { |
|
| 2306 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2307 | - } |
|
| 2308 | - $this->_template_args['event_name'] = ''; |
|
| 2309 | - // event name |
|
| 2310 | - if ($this->_reg_event) { |
|
| 2311 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2312 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2313 | - 'action' => 'edit', |
|
| 2314 | - 'post' => $this->_reg_event->ID(), |
|
| 2315 | - ), EVENTS_ADMIN_URL); |
|
| 2316 | - $edit_event_lnk = '<a href="' |
|
| 2317 | - . $edit_event_url |
|
| 2318 | - . '" title="' |
|
| 2319 | - . esc_attr__('Edit ', 'event_espresso') |
|
| 2320 | - . $this->_reg_event->name() |
|
| 2321 | - . '">' |
|
| 2322 | - . __('Edit Event', 'event_espresso') |
|
| 2323 | - . '</a>'; |
|
| 2324 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2325 | - . $edit_event_lnk |
|
| 2326 | - . '</span>'; |
|
| 2327 | - } |
|
| 2328 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2329 | - if (defined('DOING_AJAX')) { |
|
| 2330 | - $this->_return_json(); |
|
| 2331 | - } |
|
| 2332 | - // grab header |
|
| 2333 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2334 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2335 | - $this->_template_args, true); |
|
| 2336 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2337 | - // the details template wrapper |
|
| 2338 | - $this->display_admin_page_with_sidebar(); |
|
| 2339 | - } |
|
| 2340 | - |
|
| 2341 | - |
|
| 2342 | - /** |
|
| 2343 | - * This returns the content for a registration step |
|
| 2344 | - * |
|
| 2345 | - * @access protected |
|
| 2346 | - * @return string html |
|
| 2347 | - */ |
|
| 2348 | - protected function _get_registration_step_content() |
|
| 2349 | - { |
|
| 2350 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2351 | - $warning_msg = sprintf(__('%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', |
|
| 2352 | - 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
| 2353 | - '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
| 2354 | - return ' |
|
| 1915 | + } |
|
| 1916 | + |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 1920 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 1921 | + * to display the page |
|
| 1922 | + * |
|
| 1923 | + * @access protected |
|
| 1924 | + * @return void |
|
| 1925 | + */ |
|
| 1926 | + protected function _update_attendee_registration_form() |
|
| 1927 | + { |
|
| 1928 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 1929 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 1930 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1931 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 1932 | + if ($success) { |
|
| 1933 | + $what = __('Registration Form', 'event_espresso'); |
|
| 1934 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 1935 | + : array('action' => 'default'); |
|
| 1936 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 1937 | + } |
|
| 1938 | + } |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + |
|
| 1942 | + /** |
|
| 1943 | + * Gets the form for saving registrations custom questions (if done |
|
| 1944 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
| 1945 | + * |
|
| 1946 | + * @param int $REG_ID |
|
| 1947 | + * @return EE_Registration_Custom_Questions_Form |
|
| 1948 | + */ |
|
| 1949 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
| 1950 | + { |
|
| 1951 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 1952 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1953 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 1954 | + EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 1955 | + ); |
|
| 1956 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 1957 | + } |
|
| 1958 | + return $this->_reg_custom_questions_form; |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + |
|
| 1962 | + /** |
|
| 1963 | + * Saves |
|
| 1964 | + * |
|
| 1965 | + * @access private |
|
| 1966 | + * @param bool $REG_ID |
|
| 1967 | + * @return bool |
|
| 1968 | + */ |
|
| 1969 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 1970 | + { |
|
| 1971 | + if ( ! $REG_ID) { |
|
| 1972 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
| 1973 | + __FUNCTION__, __LINE__); |
|
| 1974 | + } |
|
| 1975 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 1976 | + $form->receive_form_submission($this->_req_data); |
|
| 1977 | + $success = false; |
|
| 1978 | + if ($form->is_valid()) { |
|
| 1979 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 1980 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 1981 | + $where_conditions = array( |
|
| 1982 | + 'QST_ID' => $question_id, |
|
| 1983 | + 'REG_ID' => $REG_ID, |
|
| 1984 | + ); |
|
| 1985 | + $possibly_new_values = array( |
|
| 1986 | + 'ANS_value' => $input->normalized_value(), |
|
| 1987 | + ); |
|
| 1988 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 1989 | + if ($answer instanceof EE_Answer) { |
|
| 1990 | + $success = $answer->save($possibly_new_values); |
|
| 1991 | + } else { |
|
| 1992 | + //insert it then |
|
| 1993 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 1994 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 1995 | + $success = $answer->save(); |
|
| 1996 | + } |
|
| 1997 | + } |
|
| 1998 | + } |
|
| 1999 | + } else { |
|
| 2000 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2001 | + } |
|
| 2002 | + return $success; |
|
| 2003 | + } |
|
| 2004 | + |
|
| 2005 | + |
|
| 2006 | + /** |
|
| 2007 | + * generates HTML for the Registration main meta box |
|
| 2008 | + * |
|
| 2009 | + * @access public |
|
| 2010 | + * @return void |
|
| 2011 | + */ |
|
| 2012 | + public function _reg_attendees_meta_box() |
|
| 2013 | + { |
|
| 2014 | + $REG = EEM_Registration::instance(); |
|
| 2015 | + //get all other registrations on this transaction, and cache |
|
| 2016 | + //the attendees for them so we don't have to run another query using force_join |
|
| 2017 | + $registrations = $REG->get_all(array( |
|
| 2018 | + array( |
|
| 2019 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2020 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2021 | + ), |
|
| 2022 | + 'force_join' => array('Attendee'), |
|
| 2023 | + )); |
|
| 2024 | + $this->_template_args['attendees'] = array(); |
|
| 2025 | + $this->_template_args['attendee_notice'] = ''; |
|
| 2026 | + if (empty($registrations) |
|
| 2027 | + || (is_array($registrations) |
|
| 2028 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2029 | + ) { |
|
| 2030 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2031 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2032 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2033 | + } else { |
|
| 2034 | + $att_nmbr = 1; |
|
| 2035 | + foreach ($registrations as $registration) { |
|
| 2036 | + /* @var $registration EE_Registration */ |
|
| 2037 | + $attendee = $registration->attendee() |
|
| 2038 | + ? $registration->attendee() |
|
| 2039 | + : EEM_Attendee::instance() |
|
| 2040 | + ->create_default_object(); |
|
| 2041 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2042 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2043 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2044 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2045 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2046 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
| 2047 | + $attendee->full_address_as_array()); |
|
| 2048 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
| 2049 | + 'action' => 'edit_attendee', |
|
| 2050 | + 'post' => $attendee->ID(), |
|
| 2051 | + ), REG_ADMIN_URL); |
|
| 2052 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2053 | + $att_nmbr++; |
|
| 2054 | + } |
|
| 2055 | + //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
| 2056 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2057 | + // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
| 2058 | + } |
|
| 2059 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2060 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + |
|
| 2064 | + /** |
|
| 2065 | + * generates HTML for the Edit Registration side meta box |
|
| 2066 | + * |
|
| 2067 | + * @access public |
|
| 2068 | + * @return void |
|
| 2069 | + */ |
|
| 2070 | + public function _reg_registrant_side_meta_box() |
|
| 2071 | + { |
|
| 2072 | + /*@var $attendee EE_Attendee */ |
|
| 2073 | + $att_check = $this->_registration->attendee(); |
|
| 2074 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2075 | + //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
| 2076 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2077 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2078 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2079 | + : null; |
|
| 2080 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2081 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
| 2082 | + $primary_registration = null; |
|
| 2083 | + } |
|
| 2084 | + } else { |
|
| 2085 | + $primary_registration = null; |
|
| 2086 | + } |
|
| 2087 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2088 | + $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2089 | + $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2090 | + $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2091 | + $this->_template_args['phone'] = $attendee->phone(); |
|
| 2092 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2093 | + //edit link |
|
| 2094 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2095 | + 'action' => 'edit_attendee', |
|
| 2096 | + 'post' => $attendee->ID(), |
|
| 2097 | + ), REG_ADMIN_URL); |
|
| 2098 | + $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
| 2099 | + //create link |
|
| 2100 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2101 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2102 | + 'action' => 'duplicate_attendee', |
|
| 2103 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2104 | + ), REG_ADMIN_URL) : ''; |
|
| 2105 | + $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
| 2106 | + $this->_template_args['att_check'] = $att_check; |
|
| 2107 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2108 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + |
|
| 2112 | + |
|
| 2113 | + /** |
|
| 2114 | + * trash or restore registrations |
|
| 2115 | + * |
|
| 2116 | + * @param boolean $trash whether to archive or restore |
|
| 2117 | + * @access protected |
|
| 2118 | + * @return void |
|
| 2119 | + * @throws \EE_Error |
|
| 2120 | + */ |
|
| 2121 | + protected function _trash_or_restore_registrations($trash = true) |
|
| 2122 | + { |
|
| 2123 | + //if empty _REG_ID then get out because there's nothing to do |
|
| 2124 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2125 | + EE_Error::add_error( |
|
| 2126 | + sprintf( |
|
| 2127 | + esc_html__( |
|
| 2128 | + 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2129 | + 'event_espresso' |
|
| 2130 | + ), |
|
| 2131 | + $trash ? 'trash' : 'restore' |
|
| 2132 | + ), |
|
| 2133 | + __FILE__, __LINE__, __FUNCTION__ |
|
| 2134 | + ); |
|
| 2135 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2136 | + } |
|
| 2137 | + $success = 0; |
|
| 2138 | + $overwrite_msgs = false; |
|
| 2139 | + //Checkboxes |
|
| 2140 | + if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2141 | + $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2142 | + } |
|
| 2143 | + $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2144 | + // cycle thru checkboxes |
|
| 2145 | + foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2146 | + /** @var EE_Registration $REG */ |
|
| 2147 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2148 | + $payments = $REG->registration_payments(); |
|
| 2149 | + if (! empty($payments)) { |
|
| 2150 | + $name = $REG->attendee() instanceof EE_Attendee |
|
| 2151 | + ? $REG->attendee()->full_name() |
|
| 2152 | + : __('Unknown Attendee', 'event_espresso'); |
|
| 2153 | + $overwrite_msgs = true; |
|
| 2154 | + EE_Error::add_error( |
|
| 2155 | + sprintf( |
|
| 2156 | + __( |
|
| 2157 | + '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.', |
|
| 2158 | + 'event_espresso' |
|
| 2159 | + ), |
|
| 2160 | + $name |
|
| 2161 | + ), |
|
| 2162 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2163 | + ); |
|
| 2164 | + //can't trash this registration because it has payments. |
|
| 2165 | + continue; |
|
| 2166 | + } |
|
| 2167 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2168 | + if ($updated) { |
|
| 2169 | + $success++; |
|
| 2170 | + } |
|
| 2171 | + } |
|
| 2172 | + $this->_redirect_after_action( |
|
| 2173 | + $success === $reg_count, // were ALL registrations affected? |
|
| 2174 | + $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'), |
|
| 2175 | + $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'), |
|
| 2176 | + array('action' => 'default'), |
|
| 2177 | + $overwrite_msgs |
|
| 2178 | + ); |
|
| 2179 | + } |
|
| 2180 | + |
|
| 2181 | + |
|
| 2182 | + /** |
|
| 2183 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2184 | + * registration but also. |
|
| 2185 | + * 1. Removing relations to EE_Attendee |
|
| 2186 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2187 | + * ALSO trashed. |
|
| 2188 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2189 | + * 4. Removing relationships between all tickets and the related registrations |
|
| 2190 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2191 | + * 6. Deleting permanently any related Checkins. |
|
| 2192 | + * |
|
| 2193 | + * @return void |
|
| 2194 | + */ |
|
| 2195 | + protected function _delete_registrations() |
|
| 2196 | + { |
|
| 2197 | + $REG_MDL = EEM_Registration::instance(); |
|
| 2198 | + $success = 1; |
|
| 2199 | + //Checkboxes |
|
| 2200 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2201 | + // if array has more than one element than success message should be plural |
|
| 2202 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2203 | + // cycle thru checkboxes |
|
| 2204 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2205 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2206 | + if ( ! $REG instanceof EE_Registration) { |
|
| 2207 | + continue; |
|
| 2208 | + } |
|
| 2209 | + $deleted = $this->_delete_registration($REG); |
|
| 2210 | + if ( ! $deleted) { |
|
| 2211 | + $success = 0; |
|
| 2212 | + } |
|
| 2213 | + } |
|
| 2214 | + } else { |
|
| 2215 | + // grab single id and delete |
|
| 2216 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2217 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2218 | + $deleted = $this->_delete_registration($REG); |
|
| 2219 | + if ( ! $deleted) { |
|
| 2220 | + $success = 0; |
|
| 2221 | + } |
|
| 2222 | + } |
|
| 2223 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2224 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
| 2225 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
| 2226 | + } |
|
| 2227 | + |
|
| 2228 | + |
|
| 2229 | + /** |
|
| 2230 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2231 | + * models get affected. |
|
| 2232 | + * |
|
| 2233 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2234 | + * @return boolean true = successful deletion, false = fail. |
|
| 2235 | + */ |
|
| 2236 | + protected function _delete_registration(EE_Registration $REG) |
|
| 2237 | + { |
|
| 2238 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
| 2239 | + $TXN = $REG->get_first_related('Transaction'); |
|
| 2240 | + $REGS = $TXN->get_many_related('Registration'); |
|
| 2241 | + $all_trashed = true; |
|
| 2242 | + foreach ($REGS as $registration) { |
|
| 2243 | + if ( ! $registration->get('REG_deleted')) { |
|
| 2244 | + $all_trashed = false; |
|
| 2245 | + } |
|
| 2246 | + } |
|
| 2247 | + if ( ! $all_trashed) { |
|
| 2248 | + EE_Error::add_error(__('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.', |
|
| 2249 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2250 | + return false; |
|
| 2251 | + } |
|
| 2252 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
| 2253 | + foreach ($REGS as $registration) { |
|
| 2254 | + //delete related answers |
|
| 2255 | + $registration->delete_related_permanently('Answer'); |
|
| 2256 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2257 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 2258 | + if ($attendee instanceof EE_Attendee) { |
|
| 2259 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2260 | + } |
|
| 2261 | + //now remove relationships to tickets on this registration. |
|
| 2262 | + $registration->_remove_relations('Ticket'); |
|
| 2263 | + //now delete permanently the checkins related to this registration. |
|
| 2264 | + $registration->delete_related_permanently('Checkin'); |
|
| 2265 | + if ($registration->ID() === $REG->ID()) { |
|
| 2266 | + continue; |
|
| 2267 | + } //we don't want to delete permanently the existing registration just yet. |
|
| 2268 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2269 | + $registration->_remove_relations('Transaction'); |
|
| 2270 | + //delete permanently any related messages. |
|
| 2271 | + $registration->delete_related_permanently('Message'); |
|
| 2272 | + //now delete this registration permanently |
|
| 2273 | + $registration->delete_permanently(); |
|
| 2274 | + } |
|
| 2275 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
| 2276 | + //delete the line items related to the transaction for this registration. |
|
| 2277 | + $TXN->delete_related_permanently('Line_Item'); |
|
| 2278 | + //we need to remove all the relationships on the transaction |
|
| 2279 | + $TXN->delete_related_permanently('Payment'); |
|
| 2280 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2281 | + $TXN->delete_related_permanently('Message'); |
|
| 2282 | + //now we can delete this REG permanently (and the transaction of course) |
|
| 2283 | + $REG->delete_related_permanently('Transaction'); |
|
| 2284 | + return $REG->delete_permanently(); |
|
| 2285 | + } |
|
| 2286 | + |
|
| 2287 | + |
|
| 2288 | + /** |
|
| 2289 | + * generates HTML for the Register New Attendee Admin page |
|
| 2290 | + * |
|
| 2291 | + * @access private |
|
| 2292 | + * @throws \EE_Error |
|
| 2293 | + * @return void |
|
| 2294 | + */ |
|
| 2295 | + public function new_registration() |
|
| 2296 | + { |
|
| 2297 | + if ( ! $this->_set_reg_event()) { |
|
| 2298 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
| 2299 | + 'event_espresso')); |
|
| 2300 | + } |
|
| 2301 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2302 | + // gotta start with a clean slate if we're not coming here via ajax |
|
| 2303 | + if ( ! defined('DOING_AJAX') |
|
| 2304 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2305 | + ) { |
|
| 2306 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2307 | + } |
|
| 2308 | + $this->_template_args['event_name'] = ''; |
|
| 2309 | + // event name |
|
| 2310 | + if ($this->_reg_event) { |
|
| 2311 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2312 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2313 | + 'action' => 'edit', |
|
| 2314 | + 'post' => $this->_reg_event->ID(), |
|
| 2315 | + ), EVENTS_ADMIN_URL); |
|
| 2316 | + $edit_event_lnk = '<a href="' |
|
| 2317 | + . $edit_event_url |
|
| 2318 | + . '" title="' |
|
| 2319 | + . esc_attr__('Edit ', 'event_espresso') |
|
| 2320 | + . $this->_reg_event->name() |
|
| 2321 | + . '">' |
|
| 2322 | + . __('Edit Event', 'event_espresso') |
|
| 2323 | + . '</a>'; |
|
| 2324 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2325 | + . $edit_event_lnk |
|
| 2326 | + . '</span>'; |
|
| 2327 | + } |
|
| 2328 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2329 | + if (defined('DOING_AJAX')) { |
|
| 2330 | + $this->_return_json(); |
|
| 2331 | + } |
|
| 2332 | + // grab header |
|
| 2333 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2334 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2335 | + $this->_template_args, true); |
|
| 2336 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2337 | + // the details template wrapper |
|
| 2338 | + $this->display_admin_page_with_sidebar(); |
|
| 2339 | + } |
|
| 2340 | + |
|
| 2341 | + |
|
| 2342 | + /** |
|
| 2343 | + * This returns the content for a registration step |
|
| 2344 | + * |
|
| 2345 | + * @access protected |
|
| 2346 | + * @return string html |
|
| 2347 | + */ |
|
| 2348 | + protected function _get_registration_step_content() |
|
| 2349 | + { |
|
| 2350 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2351 | + $warning_msg = sprintf(__('%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', |
|
| 2352 | + 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
| 2353 | + '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
| 2354 | + return ' |
|
| 2355 | 2355 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
| 2356 | 2356 | <script > |
| 2357 | 2357 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2364,658 +2364,658 @@ discard block |
||
| 2364 | 2364 | } |
| 2365 | 2365 | }, 800 ); |
| 2366 | 2366 | </script >'; |
| 2367 | - } |
|
| 2368 | - $template_args = array( |
|
| 2369 | - 'title' => '', |
|
| 2370 | - 'content' => '', |
|
| 2371 | - 'step_button_text' => '', |
|
| 2372 | - 'show_notification_toggle' => false, |
|
| 2373 | - ); |
|
| 2374 | - //to indicate we're processing a new registration |
|
| 2375 | - $hidden_fields = array( |
|
| 2376 | - 'processing_registration' => array( |
|
| 2377 | - 'type' => 'hidden', |
|
| 2378 | - 'value' => 0, |
|
| 2379 | - ), |
|
| 2380 | - 'event_id' => array( |
|
| 2381 | - 'type' => 'hidden', |
|
| 2382 | - 'value' => $this->_reg_event->ID(), |
|
| 2383 | - ), |
|
| 2384 | - ); |
|
| 2385 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2386 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2387 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2388 | - switch ($step) { |
|
| 2389 | - case 'ticket' : |
|
| 2390 | - $hidden_fields['processing_registration']['value'] = 1; |
|
| 2391 | - $template_args['title'] = __('Step One: Select the Ticket for this registration', |
|
| 2392 | - 'event_espresso'); |
|
| 2393 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2394 | - $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
| 2395 | - 'event_espresso'); |
|
| 2396 | - $template_args['show_notification_toggle'] = false; |
|
| 2397 | - break; |
|
| 2398 | - case 'questions' : |
|
| 2399 | - $hidden_fields['processing_registration']['value'] = 2; |
|
| 2400 | - $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
| 2401 | - 'event_espresso'); |
|
| 2402 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
| 2403 | - $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2404 | - $template_args['step_button_text'] = __('Save Registration and Continue to Details', |
|
| 2405 | - 'event_espresso'); |
|
| 2406 | - $template_args['show_notification_toggle'] = true; |
|
| 2407 | - break; |
|
| 2408 | - } |
|
| 2409 | - $this->_set_add_edit_form_tags('process_reg_step', |
|
| 2410 | - $hidden_fields); //we come back to the process_registration_step route. |
|
| 2411 | - return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
| 2412 | - . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2413 | - $template_args, true); |
|
| 2414 | - } |
|
| 2415 | - |
|
| 2416 | - |
|
| 2417 | - /** |
|
| 2418 | - * set_reg_event |
|
| 2419 | - * |
|
| 2420 | - * @access private |
|
| 2421 | - * @return boolean |
|
| 2422 | - */ |
|
| 2423 | - private function _set_reg_event() |
|
| 2424 | - { |
|
| 2425 | - if (is_object($this->_reg_event)) { |
|
| 2426 | - return true; |
|
| 2427 | - } |
|
| 2428 | - $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2429 | - if ( ! $EVT_ID) { |
|
| 2430 | - return false; |
|
| 2431 | - } |
|
| 2432 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2433 | - return true; |
|
| 2434 | - } |
|
| 2435 | - |
|
| 2436 | - |
|
| 2437 | - /** |
|
| 2438 | - * process_reg_step |
|
| 2439 | - * |
|
| 2440 | - * @access public |
|
| 2441 | - * @return string |
|
| 2442 | - * @throws \RuntimeException |
|
| 2443 | - * @throws \EE_Error |
|
| 2444 | - */ |
|
| 2445 | - public function process_reg_step() |
|
| 2446 | - { |
|
| 2447 | - EE_System::do_not_cache(); |
|
| 2448 | - $this->_set_reg_event(); |
|
| 2449 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2450 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2451 | - //what step are we on? |
|
| 2452 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2453 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2454 | - //if doing ajax then we need to verify the nonce |
|
| 2455 | - if (defined('DOING_AJAX')) { |
|
| 2456 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2457 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2458 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2459 | - } |
|
| 2460 | - switch ($step) { |
|
| 2461 | - case 'ticket' : |
|
| 2462 | - //process ticket selection |
|
| 2463 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2464 | - if ($success) { |
|
| 2465 | - EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
| 2466 | - 'event_espresso')); |
|
| 2467 | - } else { |
|
| 2468 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2469 | - } |
|
| 2470 | - if (defined('DOING_AJAX')) { |
|
| 2471 | - $this->new_registration(); //display next step |
|
| 2472 | - } else { |
|
| 2473 | - $query_args = array( |
|
| 2474 | - 'action' => 'new_registration', |
|
| 2475 | - 'processing_registration' => 1, |
|
| 2476 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2477 | - 'uts' => time(), |
|
| 2478 | - ); |
|
| 2479 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2480 | - } |
|
| 2481 | - break; |
|
| 2482 | - case 'questions' : |
|
| 2483 | - if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
| 2484 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2485 | - } |
|
| 2486 | - //process registration |
|
| 2487 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2488 | - if ($cart instanceof EE_Cart) { |
|
| 2489 | - $grand_total = $cart->get_cart_grand_total(); |
|
| 2490 | - if ($grand_total instanceof EE_Line_Item) { |
|
| 2491 | - $grand_total->save_this_and_descendants_to_txn(); |
|
| 2492 | - } |
|
| 2493 | - } |
|
| 2494 | - if ( ! $transaction instanceof EE_Transaction) { |
|
| 2495 | - $query_args = array( |
|
| 2496 | - 'action' => 'new_registration', |
|
| 2497 | - 'processing_registration' => 2, |
|
| 2498 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2499 | - 'uts' => time(), |
|
| 2500 | - ); |
|
| 2501 | - if (defined('DOING_AJAX')) { |
|
| 2502 | - //display registration form again because there are errors (maybe validation?) |
|
| 2503 | - $this->new_registration(); |
|
| 2504 | - return; |
|
| 2505 | - } else { |
|
| 2506 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2507 | - return; |
|
| 2508 | - } |
|
| 2509 | - } |
|
| 2510 | - // maybe update status, and make sure to save transaction if not done already |
|
| 2511 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2512 | - $transaction->save(); |
|
| 2513 | - } |
|
| 2514 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2515 | - $this->_req_data = array(); |
|
| 2516 | - $query_args = array( |
|
| 2517 | - 'action' => 'redirect_to_txn', |
|
| 2518 | - 'TXN_ID' => $transaction->ID(), |
|
| 2519 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2520 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2521 | - 'redirect_from' => 'new_registration', |
|
| 2522 | - ); |
|
| 2523 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2524 | - break; |
|
| 2525 | - } |
|
| 2526 | - //what are you looking here for? Should be nothing to do at this point. |
|
| 2527 | - } |
|
| 2528 | - |
|
| 2529 | - |
|
| 2530 | - /** |
|
| 2531 | - * redirect_to_txn |
|
| 2532 | - * |
|
| 2533 | - * @access public |
|
| 2534 | - * @return void |
|
| 2535 | - */ |
|
| 2536 | - public function redirect_to_txn() |
|
| 2537 | - { |
|
| 2538 | - EE_System::do_not_cache(); |
|
| 2539 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2540 | - $query_args = array( |
|
| 2541 | - 'action' => 'view_transaction', |
|
| 2542 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2543 | - 'page' => 'espresso_transactions', |
|
| 2544 | - ); |
|
| 2545 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2546 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2547 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2548 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2549 | - } |
|
| 2550 | - EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2551 | - 'event_espresso')); |
|
| 2552 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2553 | - } |
|
| 2554 | - |
|
| 2555 | - |
|
| 2556 | - /** |
|
| 2557 | - * generates HTML for the Attendee Contact List |
|
| 2558 | - * |
|
| 2559 | - * @access protected |
|
| 2560 | - * @return void |
|
| 2561 | - */ |
|
| 2562 | - protected function _attendee_contact_list_table() |
|
| 2563 | - { |
|
| 2564 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2565 | - $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
| 2566 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2567 | - } |
|
| 2568 | - |
|
| 2569 | - |
|
| 2570 | - /** |
|
| 2571 | - * get_attendees |
|
| 2572 | - * |
|
| 2573 | - * @param bool $count whether to return count or data. |
|
| 2574 | - * @access public |
|
| 2575 | - * @return array |
|
| 2576 | - */ |
|
| 2577 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2578 | - { |
|
| 2579 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2580 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2581 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 2582 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2583 | - switch ($this->_req_data['orderby']) { |
|
| 2584 | - case 'ATT_ID': |
|
| 2585 | - $orderby = 'ATT_ID'; |
|
| 2586 | - break; |
|
| 2587 | - case 'ATT_fname': |
|
| 2588 | - $orderby = 'ATT_fname'; |
|
| 2589 | - break; |
|
| 2590 | - case 'ATT_email': |
|
| 2591 | - $orderby = 'ATT_email'; |
|
| 2592 | - break; |
|
| 2593 | - case 'ATT_city': |
|
| 2594 | - $orderby = 'ATT_city'; |
|
| 2595 | - break; |
|
| 2596 | - case 'STA_ID': |
|
| 2597 | - $orderby = 'STA_ID'; |
|
| 2598 | - break; |
|
| 2599 | - case 'CNT_ID': |
|
| 2600 | - $orderby = 'CNT_ID'; |
|
| 2601 | - break; |
|
| 2602 | - default: |
|
| 2603 | - $orderby = 'ATT_lname'; |
|
| 2604 | - } |
|
| 2605 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
| 2606 | - : 'ASC'; |
|
| 2607 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2608 | - ? $this->_req_data['paged'] : 1; |
|
| 2609 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2610 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2611 | - ? $this->_req_data['perpage'] : $per_page; |
|
| 2612 | - $_where = array(); |
|
| 2613 | - if ( ! empty($this->_req_data['s'])) { |
|
| 2614 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2615 | - $_where['OR'] = array( |
|
| 2616 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2617 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2618 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2619 | - 'ATT_fname' => array('LIKE', $sstr), |
|
| 2620 | - 'ATT_lname' => array('LIKE', $sstr), |
|
| 2621 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 2622 | - 'ATT_email' => array('LIKE', $sstr), |
|
| 2623 | - 'ATT_address' => array('LIKE', $sstr), |
|
| 2624 | - 'ATT_address2' => array('LIKE', $sstr), |
|
| 2625 | - 'ATT_city' => array('LIKE', $sstr), |
|
| 2626 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 2627 | - 'State.STA_name' => array('LIKE', $sstr), |
|
| 2628 | - 'ATT_phone' => array('LIKE', $sstr), |
|
| 2629 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 2630 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 2631 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 2632 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 2633 | - ); |
|
| 2634 | - } |
|
| 2635 | - $offset = ($current_page - 1) * $per_page; |
|
| 2636 | - $limit = $count ? null : array($offset, $per_page); |
|
| 2637 | - if ($trash) { |
|
| 2638 | - $_where['status'] = array('!=', 'publish'); |
|
| 2639 | - $all_attendees = $count |
|
| 2640 | - ? $ATT_MDL->count(array( |
|
| 2641 | - $_where, |
|
| 2642 | - 'order_by' => array($orderby => $sort), |
|
| 2643 | - 'limit' => $limit, |
|
| 2644 | - ), 'ATT_ID', true) |
|
| 2645 | - : $ATT_MDL->get_all(array( |
|
| 2646 | - $_where, |
|
| 2647 | - 'order_by' => array($orderby => $sort), |
|
| 2648 | - 'limit' => $limit, |
|
| 2649 | - )); |
|
| 2650 | - } else { |
|
| 2651 | - $_where['status'] = array('IN', array('publish')); |
|
| 2652 | - $all_attendees = $count |
|
| 2653 | - ? $ATT_MDL->count(array( |
|
| 2654 | - $_where, |
|
| 2655 | - 'order_by' => array($orderby => $sort), |
|
| 2656 | - 'limit' => $limit, |
|
| 2657 | - ), 'ATT_ID', true) |
|
| 2658 | - : $ATT_MDL->get_all(array( |
|
| 2659 | - $_where, |
|
| 2660 | - 'order_by' => array($orderby => $sort), |
|
| 2661 | - 'limit' => $limit, |
|
| 2662 | - )); |
|
| 2663 | - } |
|
| 2664 | - return $all_attendees; |
|
| 2665 | - } |
|
| 2666 | - |
|
| 2667 | - |
|
| 2668 | - /** |
|
| 2669 | - * This is just taking care of resending the registration confirmation |
|
| 2670 | - * |
|
| 2671 | - * @access protected |
|
| 2672 | - * @return void |
|
| 2673 | - */ |
|
| 2674 | - protected function _resend_registration() |
|
| 2675 | - { |
|
| 2676 | - $this->_process_resend_registration(); |
|
| 2677 | - $query_args = isset($this->_req_data['redirect_to']) |
|
| 2678 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 2679 | - : array( |
|
| 2680 | - 'action' => 'default', |
|
| 2681 | - ); |
|
| 2682 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2683 | - } |
|
| 2684 | - |
|
| 2685 | - /** |
|
| 2686 | - * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 2687 | - * to use when selecting registrations |
|
| 2688 | - * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 2689 | - * the query parameters from the request |
|
| 2690 | - * @return void ends the request with a redirect or download |
|
| 2691 | - */ |
|
| 2692 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2693 | - { |
|
| 2694 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2695 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2696 | - 'page' => 'espresso_batch', |
|
| 2697 | - 'batch' => 'file', |
|
| 2698 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2699 | - 'filters' => urlencode( |
|
| 2700 | - serialize( |
|
| 2701 | - call_user_func( |
|
| 2702 | - array( $this, $method_name_for_getting_query_params ), |
|
| 2703 | - EEH_Array::is_set( |
|
| 2704 | - $this->_req_data, |
|
| 2705 | - 'filters', |
|
| 2706 | - array() |
|
| 2707 | - ) |
|
| 2708 | - ) |
|
| 2709 | - ) |
|
| 2710 | - ), |
|
| 2711 | - 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 2712 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 2713 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2714 | - ))); |
|
| 2715 | - } else { |
|
| 2716 | - $new_request_args = array( |
|
| 2717 | - 'export' => 'report', |
|
| 2718 | - 'action' => 'registrations_report_for_event', |
|
| 2719 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2720 | - ); |
|
| 2721 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 2722 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2723 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2724 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2725 | - $EE_Export->export(); |
|
| 2726 | - } |
|
| 2727 | - } |
|
| 2728 | - } |
|
| 2729 | - |
|
| 2730 | - |
|
| 2731 | - |
|
| 2732 | - /** |
|
| 2733 | - * Creates a registration report using only query parameters in the request |
|
| 2734 | - * @return void |
|
| 2735 | - */ |
|
| 2736 | - public function _registrations_report() |
|
| 2737 | - { |
|
| 2738 | - $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2739 | - } |
|
| 2740 | - |
|
| 2741 | - |
|
| 2742 | - public function _contact_list_export() |
|
| 2743 | - { |
|
| 2744 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2745 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2746 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2747 | - $EE_Export->export_attendees(); |
|
| 2748 | - } |
|
| 2749 | - } |
|
| 2750 | - |
|
| 2751 | - |
|
| 2752 | - public function _contact_list_report() |
|
| 2753 | - { |
|
| 2754 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2755 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2756 | - 'page' => 'espresso_batch', |
|
| 2757 | - 'batch' => 'file', |
|
| 2758 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 2759 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2760 | - ))); |
|
| 2761 | - } else { |
|
| 2762 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2763 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2764 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2765 | - $EE_Export->report_attendees(); |
|
| 2766 | - } |
|
| 2767 | - } |
|
| 2768 | - } |
|
| 2769 | - |
|
| 2770 | - |
|
| 2771 | - |
|
| 2772 | - |
|
| 2773 | - |
|
| 2774 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 2775 | - /** |
|
| 2776 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 2777 | - * |
|
| 2778 | - * @return void |
|
| 2779 | - */ |
|
| 2780 | - protected function _duplicate_attendee() |
|
| 2781 | - { |
|
| 2782 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 2783 | - //verify we have necessary info |
|
| 2784 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2785 | - EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 2786 | - 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
| 2787 | - $query_args = array('action' => $action); |
|
| 2788 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2789 | - } |
|
| 2790 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 2791 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 2792 | - $attendee = $registration->attendee(); |
|
| 2793 | - //remove relation of existing attendee on registration |
|
| 2794 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2795 | - //new attendee |
|
| 2796 | - $new_attendee = clone $attendee; |
|
| 2797 | - $new_attendee->set('ATT_ID', 0); |
|
| 2798 | - $new_attendee->save(); |
|
| 2799 | - //add new attendee to reg |
|
| 2800 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 2801 | - EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 2802 | - 'event_espresso')); |
|
| 2803 | - //redirect to edit page for attendee |
|
| 2804 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 2805 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2806 | - } |
|
| 2807 | - |
|
| 2808 | - |
|
| 2809 | - //related to cpt routes |
|
| 2810 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 2811 | - { |
|
| 2812 | - $success = true; |
|
| 2813 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 2814 | - //for attendee updates |
|
| 2815 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 2816 | - //note we should only be UPDATING attendees at this point. |
|
| 2817 | - $updated_fields = array( |
|
| 2818 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 2819 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 2820 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2821 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 2822 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 2823 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 2824 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 2825 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2826 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 2827 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 2828 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 2829 | - ); |
|
| 2830 | - foreach ($updated_fields as $field => $value) { |
|
| 2831 | - $attendee->set($field, $value); |
|
| 2832 | - } |
|
| 2833 | - $success = $attendee->save(); |
|
| 2834 | - $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 2835 | - array()); |
|
| 2836 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
| 2837 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 2838 | - throw new EE_Error(sprintf(__('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.', |
|
| 2839 | - 'event_espresso'), $a_callback)); |
|
| 2840 | - } |
|
| 2841 | - } |
|
| 2842 | - } |
|
| 2843 | - if ($success === false) { |
|
| 2844 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
| 2845 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2846 | - } |
|
| 2847 | - } |
|
| 2848 | - |
|
| 2849 | - |
|
| 2850 | - public function trash_cpt_item($post_id) |
|
| 2851 | - { |
|
| 2852 | - } |
|
| 2853 | - |
|
| 2854 | - |
|
| 2855 | - public function delete_cpt_item($post_id) |
|
| 2856 | - { |
|
| 2857 | - } |
|
| 2858 | - |
|
| 2859 | - |
|
| 2860 | - public function restore_cpt_item($post_id) |
|
| 2861 | - { |
|
| 2862 | - } |
|
| 2863 | - |
|
| 2864 | - |
|
| 2865 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 2866 | - { |
|
| 2867 | - } |
|
| 2868 | - |
|
| 2869 | - |
|
| 2870 | - public function attendee_editor_metaboxes() |
|
| 2871 | - { |
|
| 2872 | - $this->verify_cpt_object(); |
|
| 2873 | - remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 2874 | - 'normal', 'core'); |
|
| 2875 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2876 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 2877 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
| 2878 | - $this->_cpt_routes[$this->_req_action], 'normal'); |
|
| 2879 | - } |
|
| 2880 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 2881 | - add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
| 2882 | - $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2883 | - } |
|
| 2884 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
| 2885 | - array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
| 2886 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
| 2887 | - array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2888 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
| 2889 | - array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2890 | - } |
|
| 2891 | - |
|
| 2892 | - |
|
| 2893 | - /** |
|
| 2894 | - * Metabox for attendee contact info |
|
| 2895 | - * |
|
| 2896 | - * @param WP_Post $post wp post object |
|
| 2897 | - * @return string attendee contact info ( and form ) |
|
| 2898 | - */ |
|
| 2899 | - public function attendee_contact_info($post) |
|
| 2900 | - { |
|
| 2901 | - //get attendee object ( should already have it ) |
|
| 2902 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2903 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2904 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2905 | - } |
|
| 2906 | - |
|
| 2907 | - |
|
| 2908 | - /** |
|
| 2909 | - * Metabox for attendee details |
|
| 2910 | - * |
|
| 2911 | - * @param WP_Post $post wp post object |
|
| 2912 | - * @return string attendee address details (and form) |
|
| 2913 | - */ |
|
| 2914 | - public function attendee_address_details($post) |
|
| 2915 | - { |
|
| 2916 | - //get attendee object (should already have it) |
|
| 2917 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2918 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2919 | - 'QST_ID' => 0, |
|
| 2920 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 2921 | - 'QST_system' => 'admin-state', |
|
| 2922 | - )), EE_Answer::new_instance(array( |
|
| 2923 | - 'ANS_ID' => 0, |
|
| 2924 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 2925 | - )), array( |
|
| 2926 | - 'input_id' => 'STA_ID', |
|
| 2927 | - 'input_name' => 'STA_ID', |
|
| 2928 | - 'input_prefix' => '', |
|
| 2929 | - 'append_qstn_id' => false, |
|
| 2930 | - ))); |
|
| 2931 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2932 | - 'QST_ID' => 0, |
|
| 2933 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 2934 | - 'QST_system' => 'admin-country', |
|
| 2935 | - )), EE_Answer::new_instance(array( |
|
| 2936 | - 'ANS_ID' => 0, |
|
| 2937 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 2938 | - )), array( |
|
| 2939 | - 'input_id' => 'CNT_ISO', |
|
| 2940 | - 'input_name' => 'CNT_ISO', |
|
| 2941 | - 'input_prefix' => '', |
|
| 2942 | - 'append_qstn_id' => false, |
|
| 2943 | - ))); |
|
| 2944 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2945 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2946 | - } |
|
| 2947 | - |
|
| 2948 | - |
|
| 2949 | - /** |
|
| 2950 | - * _attendee_details |
|
| 2951 | - * |
|
| 2952 | - * @access protected |
|
| 2953 | - * @return void |
|
| 2954 | - */ |
|
| 2955 | - public function attendee_registrations_meta_box($post) |
|
| 2956 | - { |
|
| 2957 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2958 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 2959 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2960 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2961 | - } |
|
| 2962 | - |
|
| 2963 | - |
|
| 2964 | - /** |
|
| 2965 | - * add in the form fields for the attendee edit |
|
| 2966 | - * |
|
| 2967 | - * @param WP_Post $post wp post object |
|
| 2968 | - * @return string html for new form. |
|
| 2969 | - */ |
|
| 2970 | - public function after_title_form_fields($post) |
|
| 2971 | - { |
|
| 2972 | - if ($post->post_type == 'espresso_attendees') { |
|
| 2973 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2974 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2975 | - EEH_Template::display_template($template, $template_args); |
|
| 2976 | - } |
|
| 2977 | - } |
|
| 2978 | - |
|
| 2979 | - |
|
| 2980 | - /** |
|
| 2981 | - * _trash_or_restore_attendee |
|
| 2982 | - * |
|
| 2983 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2984 | - * @access protected |
|
| 2985 | - * @return void |
|
| 2986 | - */ |
|
| 2987 | - protected function _trash_or_restore_attendees($trash = true) |
|
| 2988 | - { |
|
| 2989 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2990 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 2991 | - $success = 1; |
|
| 2992 | - //Checkboxes |
|
| 2993 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2994 | - // if array has more than one element than success message should be plural |
|
| 2995 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 2996 | - // cycle thru checkboxes |
|
| 2997 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 2998 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 2999 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3000 | - if ( ! $updated) { |
|
| 3001 | - $success = 0; |
|
| 3002 | - } |
|
| 3003 | - } |
|
| 3004 | - } else { |
|
| 3005 | - // grab single id and delete |
|
| 3006 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3007 | - //get attendee |
|
| 3008 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3009 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3010 | - $updated = $att->save(); |
|
| 3011 | - if ( ! $updated) { |
|
| 3012 | - $success = 0; |
|
| 3013 | - } |
|
| 3014 | - } |
|
| 3015 | - $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
| 3016 | - $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 3017 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3018 | - } |
|
| 2367 | + } |
|
| 2368 | + $template_args = array( |
|
| 2369 | + 'title' => '', |
|
| 2370 | + 'content' => '', |
|
| 2371 | + 'step_button_text' => '', |
|
| 2372 | + 'show_notification_toggle' => false, |
|
| 2373 | + ); |
|
| 2374 | + //to indicate we're processing a new registration |
|
| 2375 | + $hidden_fields = array( |
|
| 2376 | + 'processing_registration' => array( |
|
| 2377 | + 'type' => 'hidden', |
|
| 2378 | + 'value' => 0, |
|
| 2379 | + ), |
|
| 2380 | + 'event_id' => array( |
|
| 2381 | + 'type' => 'hidden', |
|
| 2382 | + 'value' => $this->_reg_event->ID(), |
|
| 2383 | + ), |
|
| 2384 | + ); |
|
| 2385 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2386 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2387 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2388 | + switch ($step) { |
|
| 2389 | + case 'ticket' : |
|
| 2390 | + $hidden_fields['processing_registration']['value'] = 1; |
|
| 2391 | + $template_args['title'] = __('Step One: Select the Ticket for this registration', |
|
| 2392 | + 'event_espresso'); |
|
| 2393 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2394 | + $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
| 2395 | + 'event_espresso'); |
|
| 2396 | + $template_args['show_notification_toggle'] = false; |
|
| 2397 | + break; |
|
| 2398 | + case 'questions' : |
|
| 2399 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2400 | + $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
| 2401 | + 'event_espresso'); |
|
| 2402 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
| 2403 | + $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2404 | + $template_args['step_button_text'] = __('Save Registration and Continue to Details', |
|
| 2405 | + 'event_espresso'); |
|
| 2406 | + $template_args['show_notification_toggle'] = true; |
|
| 2407 | + break; |
|
| 2408 | + } |
|
| 2409 | + $this->_set_add_edit_form_tags('process_reg_step', |
|
| 2410 | + $hidden_fields); //we come back to the process_registration_step route. |
|
| 2411 | + return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
| 2412 | + . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2413 | + $template_args, true); |
|
| 2414 | + } |
|
| 2415 | + |
|
| 2416 | + |
|
| 2417 | + /** |
|
| 2418 | + * set_reg_event |
|
| 2419 | + * |
|
| 2420 | + * @access private |
|
| 2421 | + * @return boolean |
|
| 2422 | + */ |
|
| 2423 | + private function _set_reg_event() |
|
| 2424 | + { |
|
| 2425 | + if (is_object($this->_reg_event)) { |
|
| 2426 | + return true; |
|
| 2427 | + } |
|
| 2428 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2429 | + if ( ! $EVT_ID) { |
|
| 2430 | + return false; |
|
| 2431 | + } |
|
| 2432 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2433 | + return true; |
|
| 2434 | + } |
|
| 2435 | + |
|
| 2436 | + |
|
| 2437 | + /** |
|
| 2438 | + * process_reg_step |
|
| 2439 | + * |
|
| 2440 | + * @access public |
|
| 2441 | + * @return string |
|
| 2442 | + * @throws \RuntimeException |
|
| 2443 | + * @throws \EE_Error |
|
| 2444 | + */ |
|
| 2445 | + public function process_reg_step() |
|
| 2446 | + { |
|
| 2447 | + EE_System::do_not_cache(); |
|
| 2448 | + $this->_set_reg_event(); |
|
| 2449 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2450 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2451 | + //what step are we on? |
|
| 2452 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2453 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2454 | + //if doing ajax then we need to verify the nonce |
|
| 2455 | + if (defined('DOING_AJAX')) { |
|
| 2456 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2457 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2458 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2459 | + } |
|
| 2460 | + switch ($step) { |
|
| 2461 | + case 'ticket' : |
|
| 2462 | + //process ticket selection |
|
| 2463 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2464 | + if ($success) { |
|
| 2465 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
| 2466 | + 'event_espresso')); |
|
| 2467 | + } else { |
|
| 2468 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2469 | + } |
|
| 2470 | + if (defined('DOING_AJAX')) { |
|
| 2471 | + $this->new_registration(); //display next step |
|
| 2472 | + } else { |
|
| 2473 | + $query_args = array( |
|
| 2474 | + 'action' => 'new_registration', |
|
| 2475 | + 'processing_registration' => 1, |
|
| 2476 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2477 | + 'uts' => time(), |
|
| 2478 | + ); |
|
| 2479 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2480 | + } |
|
| 2481 | + break; |
|
| 2482 | + case 'questions' : |
|
| 2483 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
| 2484 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2485 | + } |
|
| 2486 | + //process registration |
|
| 2487 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2488 | + if ($cart instanceof EE_Cart) { |
|
| 2489 | + $grand_total = $cart->get_cart_grand_total(); |
|
| 2490 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 2491 | + $grand_total->save_this_and_descendants_to_txn(); |
|
| 2492 | + } |
|
| 2493 | + } |
|
| 2494 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 2495 | + $query_args = array( |
|
| 2496 | + 'action' => 'new_registration', |
|
| 2497 | + 'processing_registration' => 2, |
|
| 2498 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2499 | + 'uts' => time(), |
|
| 2500 | + ); |
|
| 2501 | + if (defined('DOING_AJAX')) { |
|
| 2502 | + //display registration form again because there are errors (maybe validation?) |
|
| 2503 | + $this->new_registration(); |
|
| 2504 | + return; |
|
| 2505 | + } else { |
|
| 2506 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2507 | + return; |
|
| 2508 | + } |
|
| 2509 | + } |
|
| 2510 | + // maybe update status, and make sure to save transaction if not done already |
|
| 2511 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2512 | + $transaction->save(); |
|
| 2513 | + } |
|
| 2514 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2515 | + $this->_req_data = array(); |
|
| 2516 | + $query_args = array( |
|
| 2517 | + 'action' => 'redirect_to_txn', |
|
| 2518 | + 'TXN_ID' => $transaction->ID(), |
|
| 2519 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2520 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2521 | + 'redirect_from' => 'new_registration', |
|
| 2522 | + ); |
|
| 2523 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2524 | + break; |
|
| 2525 | + } |
|
| 2526 | + //what are you looking here for? Should be nothing to do at this point. |
|
| 2527 | + } |
|
| 2528 | + |
|
| 2529 | + |
|
| 2530 | + /** |
|
| 2531 | + * redirect_to_txn |
|
| 2532 | + * |
|
| 2533 | + * @access public |
|
| 2534 | + * @return void |
|
| 2535 | + */ |
|
| 2536 | + public function redirect_to_txn() |
|
| 2537 | + { |
|
| 2538 | + EE_System::do_not_cache(); |
|
| 2539 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2540 | + $query_args = array( |
|
| 2541 | + 'action' => 'view_transaction', |
|
| 2542 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2543 | + 'page' => 'espresso_transactions', |
|
| 2544 | + ); |
|
| 2545 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2546 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2547 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2548 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2549 | + } |
|
| 2550 | + EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2551 | + 'event_espresso')); |
|
| 2552 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2553 | + } |
|
| 2554 | + |
|
| 2555 | + |
|
| 2556 | + /** |
|
| 2557 | + * generates HTML for the Attendee Contact List |
|
| 2558 | + * |
|
| 2559 | + * @access protected |
|
| 2560 | + * @return void |
|
| 2561 | + */ |
|
| 2562 | + protected function _attendee_contact_list_table() |
|
| 2563 | + { |
|
| 2564 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2565 | + $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
| 2566 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2567 | + } |
|
| 2568 | + |
|
| 2569 | + |
|
| 2570 | + /** |
|
| 2571 | + * get_attendees |
|
| 2572 | + * |
|
| 2573 | + * @param bool $count whether to return count or data. |
|
| 2574 | + * @access public |
|
| 2575 | + * @return array |
|
| 2576 | + */ |
|
| 2577 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2578 | + { |
|
| 2579 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2580 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2581 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 2582 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2583 | + switch ($this->_req_data['orderby']) { |
|
| 2584 | + case 'ATT_ID': |
|
| 2585 | + $orderby = 'ATT_ID'; |
|
| 2586 | + break; |
|
| 2587 | + case 'ATT_fname': |
|
| 2588 | + $orderby = 'ATT_fname'; |
|
| 2589 | + break; |
|
| 2590 | + case 'ATT_email': |
|
| 2591 | + $orderby = 'ATT_email'; |
|
| 2592 | + break; |
|
| 2593 | + case 'ATT_city': |
|
| 2594 | + $orderby = 'ATT_city'; |
|
| 2595 | + break; |
|
| 2596 | + case 'STA_ID': |
|
| 2597 | + $orderby = 'STA_ID'; |
|
| 2598 | + break; |
|
| 2599 | + case 'CNT_ID': |
|
| 2600 | + $orderby = 'CNT_ID'; |
|
| 2601 | + break; |
|
| 2602 | + default: |
|
| 2603 | + $orderby = 'ATT_lname'; |
|
| 2604 | + } |
|
| 2605 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
| 2606 | + : 'ASC'; |
|
| 2607 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2608 | + ? $this->_req_data['paged'] : 1; |
|
| 2609 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2610 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2611 | + ? $this->_req_data['perpage'] : $per_page; |
|
| 2612 | + $_where = array(); |
|
| 2613 | + if ( ! empty($this->_req_data['s'])) { |
|
| 2614 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2615 | + $_where['OR'] = array( |
|
| 2616 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2617 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2618 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2619 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 2620 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 2621 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 2622 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 2623 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 2624 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 2625 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 2626 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 2627 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 2628 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 2629 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 2630 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 2631 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 2632 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 2633 | + ); |
|
| 2634 | + } |
|
| 2635 | + $offset = ($current_page - 1) * $per_page; |
|
| 2636 | + $limit = $count ? null : array($offset, $per_page); |
|
| 2637 | + if ($trash) { |
|
| 2638 | + $_where['status'] = array('!=', 'publish'); |
|
| 2639 | + $all_attendees = $count |
|
| 2640 | + ? $ATT_MDL->count(array( |
|
| 2641 | + $_where, |
|
| 2642 | + 'order_by' => array($orderby => $sort), |
|
| 2643 | + 'limit' => $limit, |
|
| 2644 | + ), 'ATT_ID', true) |
|
| 2645 | + : $ATT_MDL->get_all(array( |
|
| 2646 | + $_where, |
|
| 2647 | + 'order_by' => array($orderby => $sort), |
|
| 2648 | + 'limit' => $limit, |
|
| 2649 | + )); |
|
| 2650 | + } else { |
|
| 2651 | + $_where['status'] = array('IN', array('publish')); |
|
| 2652 | + $all_attendees = $count |
|
| 2653 | + ? $ATT_MDL->count(array( |
|
| 2654 | + $_where, |
|
| 2655 | + 'order_by' => array($orderby => $sort), |
|
| 2656 | + 'limit' => $limit, |
|
| 2657 | + ), 'ATT_ID', true) |
|
| 2658 | + : $ATT_MDL->get_all(array( |
|
| 2659 | + $_where, |
|
| 2660 | + 'order_by' => array($orderby => $sort), |
|
| 2661 | + 'limit' => $limit, |
|
| 2662 | + )); |
|
| 2663 | + } |
|
| 2664 | + return $all_attendees; |
|
| 2665 | + } |
|
| 2666 | + |
|
| 2667 | + |
|
| 2668 | + /** |
|
| 2669 | + * This is just taking care of resending the registration confirmation |
|
| 2670 | + * |
|
| 2671 | + * @access protected |
|
| 2672 | + * @return void |
|
| 2673 | + */ |
|
| 2674 | + protected function _resend_registration() |
|
| 2675 | + { |
|
| 2676 | + $this->_process_resend_registration(); |
|
| 2677 | + $query_args = isset($this->_req_data['redirect_to']) |
|
| 2678 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 2679 | + : array( |
|
| 2680 | + 'action' => 'default', |
|
| 2681 | + ); |
|
| 2682 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2683 | + } |
|
| 2684 | + |
|
| 2685 | + /** |
|
| 2686 | + * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 2687 | + * to use when selecting registrations |
|
| 2688 | + * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 2689 | + * the query parameters from the request |
|
| 2690 | + * @return void ends the request with a redirect or download |
|
| 2691 | + */ |
|
| 2692 | + public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2693 | + { |
|
| 2694 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2695 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2696 | + 'page' => 'espresso_batch', |
|
| 2697 | + 'batch' => 'file', |
|
| 2698 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2699 | + 'filters' => urlencode( |
|
| 2700 | + serialize( |
|
| 2701 | + call_user_func( |
|
| 2702 | + array( $this, $method_name_for_getting_query_params ), |
|
| 2703 | + EEH_Array::is_set( |
|
| 2704 | + $this->_req_data, |
|
| 2705 | + 'filters', |
|
| 2706 | + array() |
|
| 2707 | + ) |
|
| 2708 | + ) |
|
| 2709 | + ) |
|
| 2710 | + ), |
|
| 2711 | + 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 2712 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 2713 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2714 | + ))); |
|
| 2715 | + } else { |
|
| 2716 | + $new_request_args = array( |
|
| 2717 | + 'export' => 'report', |
|
| 2718 | + 'action' => 'registrations_report_for_event', |
|
| 2719 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2720 | + ); |
|
| 2721 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 2722 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2723 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2724 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2725 | + $EE_Export->export(); |
|
| 2726 | + } |
|
| 2727 | + } |
|
| 2728 | + } |
|
| 2729 | + |
|
| 2730 | + |
|
| 2731 | + |
|
| 2732 | + /** |
|
| 2733 | + * Creates a registration report using only query parameters in the request |
|
| 2734 | + * @return void |
|
| 2735 | + */ |
|
| 2736 | + public function _registrations_report() |
|
| 2737 | + { |
|
| 2738 | + $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2739 | + } |
|
| 2740 | + |
|
| 2741 | + |
|
| 2742 | + public function _contact_list_export() |
|
| 2743 | + { |
|
| 2744 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2745 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2746 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2747 | + $EE_Export->export_attendees(); |
|
| 2748 | + } |
|
| 2749 | + } |
|
| 2750 | + |
|
| 2751 | + |
|
| 2752 | + public function _contact_list_report() |
|
| 2753 | + { |
|
| 2754 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2755 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2756 | + 'page' => 'espresso_batch', |
|
| 2757 | + 'batch' => 'file', |
|
| 2758 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 2759 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2760 | + ))); |
|
| 2761 | + } else { |
|
| 2762 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2763 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2764 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2765 | + $EE_Export->report_attendees(); |
|
| 2766 | + } |
|
| 2767 | + } |
|
| 2768 | + } |
|
| 2769 | + |
|
| 2770 | + |
|
| 2771 | + |
|
| 2772 | + |
|
| 2773 | + |
|
| 2774 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 2775 | + /** |
|
| 2776 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 2777 | + * |
|
| 2778 | + * @return void |
|
| 2779 | + */ |
|
| 2780 | + protected function _duplicate_attendee() |
|
| 2781 | + { |
|
| 2782 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 2783 | + //verify we have necessary info |
|
| 2784 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2785 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 2786 | + 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
| 2787 | + $query_args = array('action' => $action); |
|
| 2788 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2789 | + } |
|
| 2790 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 2791 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 2792 | + $attendee = $registration->attendee(); |
|
| 2793 | + //remove relation of existing attendee on registration |
|
| 2794 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2795 | + //new attendee |
|
| 2796 | + $new_attendee = clone $attendee; |
|
| 2797 | + $new_attendee->set('ATT_ID', 0); |
|
| 2798 | + $new_attendee->save(); |
|
| 2799 | + //add new attendee to reg |
|
| 2800 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 2801 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 2802 | + 'event_espresso')); |
|
| 2803 | + //redirect to edit page for attendee |
|
| 2804 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 2805 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2806 | + } |
|
| 2807 | + |
|
| 2808 | + |
|
| 2809 | + //related to cpt routes |
|
| 2810 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 2811 | + { |
|
| 2812 | + $success = true; |
|
| 2813 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 2814 | + //for attendee updates |
|
| 2815 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 2816 | + //note we should only be UPDATING attendees at this point. |
|
| 2817 | + $updated_fields = array( |
|
| 2818 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 2819 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 2820 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2821 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 2822 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 2823 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 2824 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 2825 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2826 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 2827 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 2828 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 2829 | + ); |
|
| 2830 | + foreach ($updated_fields as $field => $value) { |
|
| 2831 | + $attendee->set($field, $value); |
|
| 2832 | + } |
|
| 2833 | + $success = $attendee->save(); |
|
| 2834 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 2835 | + array()); |
|
| 2836 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 2837 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 2838 | + throw new EE_Error(sprintf(__('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.', |
|
| 2839 | + 'event_espresso'), $a_callback)); |
|
| 2840 | + } |
|
| 2841 | + } |
|
| 2842 | + } |
|
| 2843 | + if ($success === false) { |
|
| 2844 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
| 2845 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2846 | + } |
|
| 2847 | + } |
|
| 2848 | + |
|
| 2849 | + |
|
| 2850 | + public function trash_cpt_item($post_id) |
|
| 2851 | + { |
|
| 2852 | + } |
|
| 2853 | + |
|
| 2854 | + |
|
| 2855 | + public function delete_cpt_item($post_id) |
|
| 2856 | + { |
|
| 2857 | + } |
|
| 2858 | + |
|
| 2859 | + |
|
| 2860 | + public function restore_cpt_item($post_id) |
|
| 2861 | + { |
|
| 2862 | + } |
|
| 2863 | + |
|
| 2864 | + |
|
| 2865 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 2866 | + { |
|
| 2867 | + } |
|
| 2868 | + |
|
| 2869 | + |
|
| 2870 | + public function attendee_editor_metaboxes() |
|
| 2871 | + { |
|
| 2872 | + $this->verify_cpt_object(); |
|
| 2873 | + remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 2874 | + 'normal', 'core'); |
|
| 2875 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2876 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 2877 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
| 2878 | + $this->_cpt_routes[$this->_req_action], 'normal'); |
|
| 2879 | + } |
|
| 2880 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 2881 | + add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
| 2882 | + $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2883 | + } |
|
| 2884 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
| 2885 | + array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
| 2886 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
| 2887 | + array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2888 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
| 2889 | + array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2890 | + } |
|
| 2891 | + |
|
| 2892 | + |
|
| 2893 | + /** |
|
| 2894 | + * Metabox for attendee contact info |
|
| 2895 | + * |
|
| 2896 | + * @param WP_Post $post wp post object |
|
| 2897 | + * @return string attendee contact info ( and form ) |
|
| 2898 | + */ |
|
| 2899 | + public function attendee_contact_info($post) |
|
| 2900 | + { |
|
| 2901 | + //get attendee object ( should already have it ) |
|
| 2902 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2903 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2904 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2905 | + } |
|
| 2906 | + |
|
| 2907 | + |
|
| 2908 | + /** |
|
| 2909 | + * Metabox for attendee details |
|
| 2910 | + * |
|
| 2911 | + * @param WP_Post $post wp post object |
|
| 2912 | + * @return string attendee address details (and form) |
|
| 2913 | + */ |
|
| 2914 | + public function attendee_address_details($post) |
|
| 2915 | + { |
|
| 2916 | + //get attendee object (should already have it) |
|
| 2917 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2918 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2919 | + 'QST_ID' => 0, |
|
| 2920 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 2921 | + 'QST_system' => 'admin-state', |
|
| 2922 | + )), EE_Answer::new_instance(array( |
|
| 2923 | + 'ANS_ID' => 0, |
|
| 2924 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 2925 | + )), array( |
|
| 2926 | + 'input_id' => 'STA_ID', |
|
| 2927 | + 'input_name' => 'STA_ID', |
|
| 2928 | + 'input_prefix' => '', |
|
| 2929 | + 'append_qstn_id' => false, |
|
| 2930 | + ))); |
|
| 2931 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2932 | + 'QST_ID' => 0, |
|
| 2933 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 2934 | + 'QST_system' => 'admin-country', |
|
| 2935 | + )), EE_Answer::new_instance(array( |
|
| 2936 | + 'ANS_ID' => 0, |
|
| 2937 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 2938 | + )), array( |
|
| 2939 | + 'input_id' => 'CNT_ISO', |
|
| 2940 | + 'input_name' => 'CNT_ISO', |
|
| 2941 | + 'input_prefix' => '', |
|
| 2942 | + 'append_qstn_id' => false, |
|
| 2943 | + ))); |
|
| 2944 | + $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2945 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2946 | + } |
|
| 2947 | + |
|
| 2948 | + |
|
| 2949 | + /** |
|
| 2950 | + * _attendee_details |
|
| 2951 | + * |
|
| 2952 | + * @access protected |
|
| 2953 | + * @return void |
|
| 2954 | + */ |
|
| 2955 | + public function attendee_registrations_meta_box($post) |
|
| 2956 | + { |
|
| 2957 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2958 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 2959 | + $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2960 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2961 | + } |
|
| 2962 | + |
|
| 2963 | + |
|
| 2964 | + /** |
|
| 2965 | + * add in the form fields for the attendee edit |
|
| 2966 | + * |
|
| 2967 | + * @param WP_Post $post wp post object |
|
| 2968 | + * @return string html for new form. |
|
| 2969 | + */ |
|
| 2970 | + public function after_title_form_fields($post) |
|
| 2971 | + { |
|
| 2972 | + if ($post->post_type == 'espresso_attendees') { |
|
| 2973 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2974 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2975 | + EEH_Template::display_template($template, $template_args); |
|
| 2976 | + } |
|
| 2977 | + } |
|
| 2978 | + |
|
| 2979 | + |
|
| 2980 | + /** |
|
| 2981 | + * _trash_or_restore_attendee |
|
| 2982 | + * |
|
| 2983 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2984 | + * @access protected |
|
| 2985 | + * @return void |
|
| 2986 | + */ |
|
| 2987 | + protected function _trash_or_restore_attendees($trash = true) |
|
| 2988 | + { |
|
| 2989 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2990 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 2991 | + $success = 1; |
|
| 2992 | + //Checkboxes |
|
| 2993 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2994 | + // if array has more than one element than success message should be plural |
|
| 2995 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 2996 | + // cycle thru checkboxes |
|
| 2997 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 2998 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 2999 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3000 | + if ( ! $updated) { |
|
| 3001 | + $success = 0; |
|
| 3002 | + } |
|
| 3003 | + } |
|
| 3004 | + } else { |
|
| 3005 | + // grab single id and delete |
|
| 3006 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3007 | + //get attendee |
|
| 3008 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3009 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3010 | + $updated = $att->save(); |
|
| 3011 | + if ( ! $updated) { |
|
| 3012 | + $success = 0; |
|
| 3013 | + } |
|
| 3014 | + } |
|
| 3015 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
| 3016 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 3017 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3018 | + } |
|
| 3019 | 3019 | |
| 3020 | 3020 | } |
| 3021 | 3021 | |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | { |
| 570 | 570 | //style |
| 571 | 571 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
| 572 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 572 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | 573 | EVENT_ESPRESSO_VERSION); |
| 574 | 574 | wp_enqueue_style('espresso_reg'); |
| 575 | 575 | //script |
| 576 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 576 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', |
|
| 577 | 577 | array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
| 578 | 578 | wp_enqueue_script('espresso_reg'); |
| 579 | 579 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | public function load_scripts_styles_contact_list() |
| 605 | 605 | { |
| 606 | 606 | wp_deregister_style('espresso_reg'); |
| 607 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 607 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | 608 | EVENT_ESPRESSO_VERSION); |
| 609 | 609 | wp_enqueue_style('espresso_att'); |
| 610 | 610 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | public function load_scripts_styles_new_registration() |
| 614 | 614 | { |
| 615 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 615 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | 616 | EVENT_ESPRESSO_VERSION, true); |
| 617 | 617 | wp_enqueue_script('ee-spco-for-admin'); |
| 618 | 618 | add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
| 723 | 723 | ), |
| 724 | 724 | ); |
| 725 | - $this->_views['trash'] = array( |
|
| 725 | + $this->_views['trash'] = array( |
|
| 726 | 726 | 'slug' => 'trash', |
| 727 | 727 | 'label' => __('Trash', 'event_espresso'), |
| 728 | 728 | 'count' => 0, |
@@ -807,31 +807,31 @@ discard block |
||
| 807 | 807 | } |
| 808 | 808 | $sc_items = array( |
| 809 | 809 | 'approved_status' => array( |
| 810 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 810 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 811 | 811 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
| 812 | 812 | ), |
| 813 | 813 | 'pending_status' => array( |
| 814 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 814 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 815 | 815 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
| 816 | 816 | ), |
| 817 | 817 | 'wait_list' => array( |
| 818 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 818 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 819 | 819 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
| 820 | 820 | ), |
| 821 | 821 | 'incomplete_status' => array( |
| 822 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 822 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
| 823 | 823 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
| 824 | 824 | ), |
| 825 | 825 | 'not_approved' => array( |
| 826 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 826 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 827 | 827 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
| 828 | 828 | ), |
| 829 | 829 | 'declined_status' => array( |
| 830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 831 | 831 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
| 832 | 832 | ), |
| 833 | 833 | 'cancelled_status' => array( |
| 834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 835 | 835 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
| 836 | 836 | ), |
| 837 | 837 | ); |
@@ -852,17 +852,17 @@ discard block |
||
| 852 | 852 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
| 853 | 853 | 'espresso_registrations_new_registration', $EVT_ID) |
| 854 | 854 | ) { |
| 855 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 855 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | 856 | array('event_id' => $EVT_ID), 'add-new-h2'); |
| 857 | 857 | } |
| 858 | 858 | $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
| 859 | 859 | if ($event instanceof EE_Event) { |
| 860 | 860 | $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
| 861 | 861 | 'event_espresso'), '<h3 style="line-height:1.5em;">', |
| 862 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 862 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | 863 | 'action' => 'edit', |
| 864 | 864 | 'post' => $event->ID(), |
| 865 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 865 | + ), EVENTS_ADMIN_URL).'"> '.$event->get('EVT_name').' </a> ', '</h3>'); |
|
| 866 | 866 | } |
| 867 | 867 | $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
| 868 | 868 | $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
| 872 | 872 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 873 | 873 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
| 874 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 874 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
| 875 | 875 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
| 876 | 876 | } |
| 877 | 877 | } |
@@ -921,10 +921,10 @@ discard block |
||
| 921 | 921 | $this_month = false, |
| 922 | 922 | $today = false |
| 923 | 923 | ) { |
| 924 | - if( $this_month ) { |
|
| 924 | + if ($this_month) { |
|
| 925 | 925 | $this->_req_data['status'] = 'month'; |
| 926 | 926 | } |
| 927 | - if( $today ) { |
|
| 927 | + if ($today) { |
|
| 928 | 928 | $this->_req_data['status'] = 'today'; |
| 929 | 929 | } |
| 930 | 930 | $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | protected function _add_category_id_to_where_conditions(array $request) |
| 1003 | 1003 | { |
| 1004 | 1004 | $where = array(); |
| 1005 | - if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1005 | + if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) { |
|
| 1006 | 1006 | $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
| 1007 | 1007 | } |
| 1008 | 1008 | return $where; |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | if ( ! empty($request['datetime_id'])) { |
| 1022 | 1022 | $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
| 1023 | 1023 | } |
| 1024 | - if( ! empty($request['DTT_ID'])){ |
|
| 1024 | + if ( ! empty($request['DTT_ID'])) { |
|
| 1025 | 1025 | $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
| 1026 | 1026 | } |
| 1027 | 1027 | return $where; |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | protected function _add_registration_status_to_where_conditions(array $request) |
| 1038 | 1038 | { |
| 1039 | 1039 | $where = array(); |
| 1040 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1040 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1041 | 1041 | $registration_status = ! empty($request['_reg_status']) |
| 1042 | 1042 | ? sanitize_text_field($request['_reg_status']) |
| 1043 | 1043 | : ''; |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | protected function _add_date_to_where_conditions(array $request) |
| 1073 | 1073 | { |
| 1074 | 1074 | $where = array(); |
| 1075 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1075 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1076 | 1076 | $month_range = ! empty($request['month_range']) |
| 1077 | 1077 | ? sanitize_text_field($request['month_range']) |
| 1078 | 1078 | : ''; |
@@ -1086,12 +1086,12 @@ discard block |
||
| 1086 | 1086 | array( |
| 1087 | 1087 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1088 | 1088 | 'REG_date', |
| 1089 | - $now . ' 00:00:00', |
|
| 1089 | + $now.' 00:00:00', |
|
| 1090 | 1090 | 'Y-m-d H:i:s' |
| 1091 | 1091 | ), |
| 1092 | 1092 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1093 | 1093 | 'REG_date', |
| 1094 | - $now . ' 23:59:59', |
|
| 1094 | + $now.' 23:59:59', |
|
| 1095 | 1095 | 'Y-m-d H:i:s' |
| 1096 | 1096 | ), |
| 1097 | 1097 | ), |
@@ -1104,12 +1104,12 @@ discard block |
||
| 1104 | 1104 | array( |
| 1105 | 1105 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1106 | 1106 | 'REG_date', |
| 1107 | - $current_year_and_month . '-01 00:00:00', |
|
| 1107 | + $current_year_and_month.'-01 00:00:00', |
|
| 1108 | 1108 | 'Y-m-d H:i:s' |
| 1109 | 1109 | ), |
| 1110 | 1110 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1111 | 1111 | 'REG_date', |
| 1112 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1112 | + $current_year_and_month.'-'.$days_this_month.' 23:59:59', |
|
| 1113 | 1113 | 'Y-m-d H:i:s' |
| 1114 | 1114 | ), |
| 1115 | 1115 | ), |
@@ -1124,18 +1124,18 @@ discard block |
||
| 1124 | 1124 | : ''; |
| 1125 | 1125 | //if there is not a month or year then we can't go further |
| 1126 | 1126 | if ($month_requested && $year_requested) { |
| 1127 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1127 | + $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01')); |
|
| 1128 | 1128 | $where['REG_date'] = array( |
| 1129 | 1129 | 'BETWEEN', |
| 1130 | 1130 | array( |
| 1131 | 1131 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1132 | 1132 | 'REG_date', |
| 1133 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1133 | + $year_requested.'-'.$month_requested.'-01 00:00:00', |
|
| 1134 | 1134 | 'Y-m-d H:i:s' |
| 1135 | 1135 | ), |
| 1136 | 1136 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1137 | 1137 | 'REG_date', |
| 1138 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1138 | + $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59', |
|
| 1139 | 1139 | 'Y-m-d H:i:s' |
| 1140 | 1140 | ), |
| 1141 | 1141 | ), |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | { |
| 1157 | 1157 | $where = array(); |
| 1158 | 1158 | if ( ! empty($request['s'])) { |
| 1159 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1159 | + $search_string = '%'.sanitize_text_field($request['s']).'%'; |
|
| 1160 | 1160 | $where['OR'] = array( |
| 1161 | 1161 | 'Event.EVT_name' => array('LIKE', $search_string), |
| 1162 | 1162 | 'Event.EVT_desc' => array('LIKE', $search_string), |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | : $per_page; |
| 1265 | 1265 | |
| 1266 | 1266 | //-1 means return all results so get out if that's set. |
| 1267 | - if ((int)$per_page === -1) { |
|
| 1267 | + if ((int) $per_page === -1) { |
|
| 1268 | 1268 | return array(); |
| 1269 | 1269 | } |
| 1270 | 1270 | $per_page = absint($per_page); |
@@ -1310,12 +1310,12 @@ discard block |
||
| 1310 | 1310 | 'action' => 'default', |
| 1311 | 1311 | 'event_id' => $event_id, |
| 1312 | 1312 | ), REG_ADMIN_URL); |
| 1313 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1313 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1314 | 1314 | 'action' => 'default', |
| 1315 | 1315 | 'EVT_ID' => $event_id, |
| 1316 | 1316 | 'page' => 'espresso_transactions', |
| 1317 | 1317 | ), admin_url('admin.php')); |
| 1318 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1318 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1319 | 1319 | 'page' => 'espresso_events', |
| 1320 | 1320 | 'action' => 'edit', |
| 1321 | 1321 | 'post' => $event_id, |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | '_REG_ID' => $previous_reg['REG_ID'], |
| 1335 | 1335 | ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
| 1336 | 1336 | // grab header |
| 1337 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1337 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
| 1338 | 1338 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1339 | 1339 | $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
| 1340 | 1340 | $this->_template_args, true); |
@@ -1408,8 +1408,8 @@ discard block |
||
| 1408 | 1408 | 'default' => $this->_registration->ID(), |
| 1409 | 1409 | )), |
| 1410 | 1410 | 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
| 1411 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1412 | - '', 'status-' . $this->_registration->status_ID(), |
|
| 1411 | + 'event_espresso')))).EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1412 | + '', 'status-'.$this->_registration->status_ID(), |
|
| 1413 | 1413 | 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
| 1414 | 1414 | 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
| 1415 | 1415 | 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
@@ -1465,9 +1465,9 @@ discard block |
||
| 1465 | 1465 | { |
| 1466 | 1466 | if (isset($this->_req_data['reg_status_change_form'])) { |
| 1467 | 1467 | $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
| 1468 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1468 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1469 | 1469 | } else { |
| 1470 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1470 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | $success = $this->_set_registration_status($REG_IDs, $status); |
| 1473 | 1473 | //notify? |
@@ -1495,7 +1495,7 @@ discard block |
||
| 1495 | 1495 | { |
| 1496 | 1496 | $success = false; |
| 1497 | 1497 | // typecast $REG_IDs |
| 1498 | - $REG_IDs = (array)$REG_IDs; |
|
| 1498 | + $REG_IDs = (array) $REG_IDs; |
|
| 1499 | 1499 | if ( ! empty($REG_IDs)) { |
| 1500 | 1500 | $success = true; |
| 1501 | 1501 | // set default status if none is passed |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | ), REG_ADMIN_URL); |
| 1789 | 1789 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1790 | 1790 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
| 1791 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1791 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1792 | 1792 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 1793 | 1793 | } |
| 1794 | 1794 | |
@@ -1810,7 +1810,7 @@ discard block |
||
| 1810 | 1810 | $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
| 1811 | 1811 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
| 1812 | 1812 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1813 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1813 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1814 | 1814 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 1815 | 1815 | } |
| 1816 | 1816 | } |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | */ |
| 1827 | 1827 | public function form_before_question_group($output) |
| 1828 | 1828 | { |
| 1829 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1829 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1830 | 1830 | __('This method would have been protected but was used on a filter callback' |
| 1831 | 1831 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1832 | 1832 | '4.8.32.rc.000'); |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | public function form_after_question_group($output) |
| 1849 | 1849 | { |
| 1850 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1850 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1851 | 1851 | __('This method would have been protected but was used on a filter callback' |
| 1852 | 1852 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1853 | 1853 | '4.8.32.rc.000'); |
@@ -1881,14 +1881,14 @@ discard block |
||
| 1881 | 1881 | */ |
| 1882 | 1882 | public function form_form_field_label_wrap($label) |
| 1883 | 1883 | { |
| 1884 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1884 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1885 | 1885 | __('This method would have been protected but was used on a filter callback' |
| 1886 | 1886 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1887 | 1887 | '4.8.32.rc.000'); |
| 1888 | 1888 | return ' |
| 1889 | 1889 | <tr> |
| 1890 | 1890 | <th> |
| 1891 | - ' . $label . ' |
|
| 1891 | + ' . $label.' |
|
| 1892 | 1892 | </th>'; |
| 1893 | 1893 | } |
| 1894 | 1894 | |
@@ -1903,13 +1903,13 @@ discard block |
||
| 1903 | 1903 | */ |
| 1904 | 1904 | public function form_form_field_input__wrap($input) |
| 1905 | 1905 | { |
| 1906 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1906 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1907 | 1907 | __('This method would have been protected but was used on a filter callback' |
| 1908 | 1908 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1909 | 1909 | '4.8.32.rc.000'); |
| 1910 | 1910 | return ' |
| 1911 | 1911 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 1912 | - ' . $input . ' |
|
| 1912 | + ' . $input.' |
|
| 1913 | 1913 | </td> |
| 1914 | 1914 | </tr>'; |
| 1915 | 1915 | } |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | protected function _get_reg_custom_questions_form($REG_ID) |
| 1950 | 1950 | { |
| 1951 | 1951 | if ( ! $this->_reg_custom_questions_form) { |
| 1952 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1952 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1953 | 1953 | $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
| 1954 | 1954 | EEM_Registration::instance()->get_one_by_ID($REG_ID) |
| 1955 | 1955 | ); |
@@ -1978,7 +1978,7 @@ discard block |
||
| 1978 | 1978 | if ($form->is_valid()) { |
| 1979 | 1979 | foreach ($form->subforms() as $question_group_id => $question_group_form) { |
| 1980 | 1980 | foreach ($question_group_form->inputs() as $question_id => $input) { |
| 1981 | - $where_conditions = array( |
|
| 1981 | + $where_conditions = array( |
|
| 1982 | 1982 | 'QST_ID' => $question_id, |
| 1983 | 1983 | 'REG_ID' => $REG_ID, |
| 1984 | 1984 | ); |
@@ -2014,7 +2014,7 @@ discard block |
||
| 2014 | 2014 | $REG = EEM_Registration::instance(); |
| 2015 | 2015 | //get all other registrations on this transaction, and cache |
| 2016 | 2016 | //the attendees for them so we don't have to run another query using force_join |
| 2017 | - $registrations = $REG->get_all(array( |
|
| 2017 | + $registrations = $REG->get_all(array( |
|
| 2018 | 2018 | array( |
| 2019 | 2019 | 'TXN_ID' => $this->_registration->transaction_ID(), |
| 2020 | 2020 | 'REG_ID' => array('!=', $this->_registration->ID()), |
@@ -2034,29 +2034,29 @@ discard block |
||
| 2034 | 2034 | $att_nmbr = 1; |
| 2035 | 2035 | foreach ($registrations as $registration) { |
| 2036 | 2036 | /* @var $registration EE_Registration */ |
| 2037 | - $attendee = $registration->attendee() |
|
| 2037 | + $attendee = $registration->attendee() |
|
| 2038 | 2038 | ? $registration->attendee() |
| 2039 | 2039 | : EEM_Attendee::instance() |
| 2040 | 2040 | ->create_default_object(); |
| 2041 | 2041 | $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
| 2042 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2043 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2044 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2045 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2042 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2043 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2044 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2045 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2046 | 2046 | $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
| 2047 | 2047 | $attendee->full_address_as_array()); |
| 2048 | 2048 | $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
| 2049 | 2049 | 'action' => 'edit_attendee', |
| 2050 | 2050 | 'post' => $attendee->ID(), |
| 2051 | 2051 | ), REG_ADMIN_URL); |
| 2052 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2052 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2053 | 2053 | $att_nmbr++; |
| 2054 | 2054 | } |
| 2055 | 2055 | //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
| 2056 | 2056 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 2057 | 2057 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
| 2058 | 2058 | } |
| 2059 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2059 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2060 | 2060 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2061 | 2061 | } |
| 2062 | 2062 | |
@@ -2085,26 +2085,26 @@ discard block |
||
| 2085 | 2085 | $primary_registration = null; |
| 2086 | 2086 | } |
| 2087 | 2087 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
| 2088 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2089 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2090 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2088 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
| 2089 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
| 2090 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
| 2091 | 2091 | $this->_template_args['phone'] = $attendee->phone(); |
| 2092 | 2092 | $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
| 2093 | 2093 | //edit link |
| 2094 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2094 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2095 | 2095 | 'action' => 'edit_attendee', |
| 2096 | 2096 | 'post' => $attendee->ID(), |
| 2097 | 2097 | ), REG_ADMIN_URL); |
| 2098 | 2098 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
| 2099 | 2099 | //create link |
| 2100 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2100 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2101 | 2101 | ? EE_Admin_Page::add_query_args_and_nonce(array( |
| 2102 | 2102 | 'action' => 'duplicate_attendee', |
| 2103 | 2103 | '_REG_ID' => $this->_registration->ID(), |
| 2104 | 2104 | ), REG_ADMIN_URL) : ''; |
| 2105 | 2105 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
| 2106 | 2106 | $this->_template_args['att_check'] = $att_check; |
| 2107 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2107 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2108 | 2108 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2109 | 2109 | } |
| 2110 | 2110 | |
@@ -2146,7 +2146,7 @@ discard block |
||
| 2146 | 2146 | /** @var EE_Registration $REG */ |
| 2147 | 2147 | $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
| 2148 | 2148 | $payments = $REG->registration_payments(); |
| 2149 | - if (! empty($payments)) { |
|
| 2149 | + if ( ! empty($payments)) { |
|
| 2150 | 2150 | $name = $REG->attendee() instanceof EE_Attendee |
| 2151 | 2151 | ? $REG->attendee()->full_name() |
| 2152 | 2152 | : __('Unknown Attendee', 'event_espresso'); |
@@ -2313,7 +2313,7 @@ discard block |
||
| 2313 | 2313 | 'action' => 'edit', |
| 2314 | 2314 | 'post' => $this->_reg_event->ID(), |
| 2315 | 2315 | ), EVENTS_ADMIN_URL); |
| 2316 | - $edit_event_lnk = '<a href="' |
|
| 2316 | + $edit_event_lnk = '<a href="' |
|
| 2317 | 2317 | . $edit_event_url |
| 2318 | 2318 | . '" title="' |
| 2319 | 2319 | . esc_attr__('Edit ', 'event_espresso') |
@@ -2330,7 +2330,7 @@ discard block |
||
| 2330 | 2330 | $this->_return_json(); |
| 2331 | 2331 | } |
| 2332 | 2332 | // grab header |
| 2333 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2333 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
| 2334 | 2334 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
| 2335 | 2335 | $this->_template_args, true); |
| 2336 | 2336 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
@@ -2352,7 +2352,7 @@ discard block |
||
| 2352 | 2352 | 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
| 2353 | 2353 | '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
| 2354 | 2354 | return ' |
| 2355 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
| 2355 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
| 2356 | 2356 | <script > |
| 2357 | 2357 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
| 2358 | 2358 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2577,7 +2577,7 @@ discard block |
||
| 2577 | 2577 | public function get_attendees($per_page, $count = false, $trash = false) |
| 2578 | 2578 | { |
| 2579 | 2579 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 2580 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2580 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2581 | 2581 | $ATT_MDL = EEM_Attendee::instance(); |
| 2582 | 2582 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 2583 | 2583 | switch ($this->_req_data['orderby']) { |
@@ -2611,7 +2611,7 @@ discard block |
||
| 2611 | 2611 | ? $this->_req_data['perpage'] : $per_page; |
| 2612 | 2612 | $_where = array(); |
| 2613 | 2613 | if ( ! empty($this->_req_data['s'])) { |
| 2614 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2614 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2615 | 2615 | $_where['OR'] = array( |
| 2616 | 2616 | 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
| 2617 | 2617 | 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
@@ -2689,7 +2689,7 @@ discard block |
||
| 2689 | 2689 | * the query parameters from the request |
| 2690 | 2690 | * @return void ends the request with a redirect or download |
| 2691 | 2691 | */ |
| 2692 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2692 | + public function _registrations_report_base($method_name_for_getting_query_params) |
|
| 2693 | 2693 | { |
| 2694 | 2694 | if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
| 2695 | 2695 | wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
@@ -2699,7 +2699,7 @@ discard block |
||
| 2699 | 2699 | 'filters' => urlencode( |
| 2700 | 2700 | serialize( |
| 2701 | 2701 | call_user_func( |
| 2702 | - array( $this, $method_name_for_getting_query_params ), |
|
| 2702 | + array($this, $method_name_for_getting_query_params), |
|
| 2703 | 2703 | EEH_Array::is_set( |
| 2704 | 2704 | $this->_req_data, |
| 2705 | 2705 | 'filters', |
@@ -2719,8 +2719,8 @@ discard block |
||
| 2719 | 2719 | 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
| 2720 | 2720 | ); |
| 2721 | 2721 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
| 2722 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2723 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2722 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2723 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2724 | 2724 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2725 | 2725 | $EE_Export->export(); |
| 2726 | 2726 | } |
@@ -2735,14 +2735,14 @@ discard block |
||
| 2735 | 2735 | */ |
| 2736 | 2736 | public function _registrations_report() |
| 2737 | 2737 | { |
| 2738 | - $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2738 | + $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 2739 | 2739 | } |
| 2740 | 2740 | |
| 2741 | 2741 | |
| 2742 | 2742 | public function _contact_list_export() |
| 2743 | 2743 | { |
| 2744 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2745 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2744 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2745 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2746 | 2746 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2747 | 2747 | $EE_Export->export_attendees(); |
| 2748 | 2748 | } |
@@ -2759,8 +2759,8 @@ discard block |
||
| 2759 | 2759 | 'return_url' => urlencode($this->_req_data['return_url']), |
| 2760 | 2760 | ))); |
| 2761 | 2761 | } else { |
| 2762 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2763 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2762 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2763 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2764 | 2764 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2765 | 2765 | $EE_Export->report_attendees(); |
| 2766 | 2766 | } |
@@ -2817,7 +2817,7 @@ discard block |
||
| 2817 | 2817 | $updated_fields = array( |
| 2818 | 2818 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
| 2819 | 2819 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
| 2820 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2820 | + 'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
| 2821 | 2821 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
| 2822 | 2822 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
| 2823 | 2823 | 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
@@ -2900,7 +2900,7 @@ discard block |
||
| 2900 | 2900 | { |
| 2901 | 2901 | //get attendee object ( should already have it ) |
| 2902 | 2902 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2903 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2903 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
| 2904 | 2904 | EEH_Template::display_template($template, $this->_template_args); |
| 2905 | 2905 | } |
| 2906 | 2906 | |
@@ -2941,7 +2941,7 @@ discard block |
||
| 2941 | 2941 | 'input_prefix' => '', |
| 2942 | 2942 | 'append_qstn_id' => false, |
| 2943 | 2943 | ))); |
| 2944 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2944 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
| 2945 | 2945 | EEH_Template::display_template($template, $this->_template_args); |
| 2946 | 2946 | } |
| 2947 | 2947 | |
@@ -2956,7 +2956,7 @@ discard block |
||
| 2956 | 2956 | { |
| 2957 | 2957 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2958 | 2958 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
| 2959 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2959 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
| 2960 | 2960 | EEH_Template::display_template($template, $this->_template_args); |
| 2961 | 2961 | } |
| 2962 | 2962 | |
@@ -2970,7 +2970,7 @@ discard block |
||
| 2970 | 2970 | public function after_title_form_fields($post) |
| 2971 | 2971 | { |
| 2972 | 2972 | if ($post->post_type == 'espresso_attendees') { |
| 2973 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2973 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
| 2974 | 2974 | $template_args['attendee'] = $this->_cpt_model_obj; |
| 2975 | 2975 | EEH_Template::display_template($template, $template_args); |
| 2976 | 2976 | } |