@@ 401-414 (lines=14) @@ | ||
398 | $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes; |
|
399 | if (is_array($old_datetimes)) { |
|
400 | $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
401 | foreach ($datetimes_to_delete as $id) { |
|
402 | $id = absint($id); |
|
403 | if (empty($id)) { |
|
404 | continue; |
|
405 | } |
|
406 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
|
407 | // remove tkt relationships. |
|
408 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
|
409 | foreach ($related_tickets as $tkt) { |
|
410 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
|
411 | } |
|
412 | $event->_remove_relation_to($id, 'Datetime'); |
|
413 | $dtt_to_remove->refresh_cache_of_related_objects(); |
|
414 | } |
|
415 | } |
|
416 | return $saved_dtt_objs; |
|
417 | } |
@@ 1339-1352 (lines=14) @@ | ||
1336 | // however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1337 | $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1338 | $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1339 | foreach ($tickets_removed as $id) { |
|
1340 | $id = absint($id); |
|
1341 | // get the ticket for this id |
|
1342 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1343 | // need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1344 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1345 | foreach ($dtts as $dtt) { |
|
1346 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1347 | } |
|
1348 | // need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1349 | $tkt_to_remove->delete_related_permanently('Price'); |
|
1350 | // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1351 | $tkt_to_remove->delete_permanently(); |
|
1352 | } |
|
1353 | return array($saved_dtt, $saved_tickets); |
|
1354 | } |
|
1355 |