/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof UserFolderCreateEvent or $event_object instanceof GroupFolderCreateEvent or $event_object instanceof OrganisationUnitFolderCreateEvent or $event_object instanceof SampleFolderCreateEvent or $event_object instanceof ProjectFolderCreateEvent) { $sample_virtual_folder = new SampleVirtualFolder(null); if (($virtual_folder_id = $sample_virtual_folder->create($event_object->get_folder_id(), "samples")) == null) { return false; } $sample_virtual_folder = new SampleVirtualFolder($virtual_folder_id); if ($sample_virtual_folder->set_sample_vfolder() == false) { return false; } } if ($event_object instanceof VirtualFolderDeleteEvent) { $sample_virtual_folder = new SampleVirtualFolder($event_object->get_virtual_folder_id()); if ($sample_virtual_folder->is_sample_vfolder() == true) { $virtual_folder_is_sample = new VirtualFolderIsSample_Access($event_object->get_virtual_folder_id()); if ($virtual_folder_is_sample->delete() == false) { return false; } } } if ($event_object instanceof SampleItemLinkEvent or $event_object instanceof ProjectItemLinkEvent) { if (($sample_id = Sample::get_entry_by_item_id($event_object->get_item_id())) != null) { $sample_folder_id = SampleFolder::get_folder_by_sample_id($sample_id); $folder = Folder::get_instance($event_object->get_folder_id()); $child_array = $folder->get_children(); if (is_array($child_array) and count($child_array) >= 1) { foreach ($child_array as $key => $value) { if (($virtual_folder_id = VirtualFolder::get_virtual_folder_id_by_data_entity_id($value)) != null) { $sample_virtual_folder = new SampleVirtualFolder($virtual_folder_id); if ($sample_virtual_folder->is_sample_vfolder() == true) { if ($sample_virtual_folder->link_folder($sample_folder_id) == false) { return false; } } } } } } } return true; }