public static function deletePresentationsByUserBySession($usr_id, $ses_id) { // Load the existing presentation for the user for this session. $existingPresentation = Presentation::getPresentationByUserBySession($usr_id, $ses_id); // If the user has any existing presentations during the same session time, delete them. if ($existingPresentation != null) { $existingPresentation->delete_presentation_for_user($usr_id); if ($existingPresentation->pres_paired_pres_id != null) { $pairedExistingPresentation = Presentation::getPresentation($existingPresentation->pres_paired_pres_id); // iterate through a change of presentation ids until we get back to where we started. // for each one, delete the associated presentations while ($pairedExistingPresentation->pres_id != $existingPresentation->pres_id) { $pairedExistingPresentation->delete_presentation_for_user($usr_id); $pairedExistingPresentation = Presentation::getPresentation($pairedExistingPresentation->pres_paired_pres_id); } } } }