/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof FileDeleteEvent) { $file_version_array = FileVersion_Access::list_entries_by_toid($event_object->get_file_id()); if (is_array($file_version_array)) { foreach ($file_version_array as $key => $value) { if (self::delete_file_version_entries($value) == false) { return false; } } } } if ($event_object instanceof FileVersionDeleteEvent) { if (self::delete_file_version_entries($event_object->get_file_version_id()) == false) { return false; } } if ($event_object instanceof CronEvent) { if ($event_object->get_daily() == true) { $max_cached_images = (int) Registry::get_value("data_max_cached_images"); $outdated_files = FileImageCache_Access::get_outdated_files_by_number($max_cached_images); if (is_array($outdated_files) and count($max_cached_images) >= 1) { foreach ($outdated_files as $key => $value) { if (file_exists(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".jpg")) { if (unlink(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".jpg") == false) { return false; } } elseif (file_exists(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".png")) { if (unlink(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".png") == false) { return false; } } $file_image_cache = new FileImageCache_Access($value['id']); if ($file_image_cache->delete() == false) { return false; } } } } } return true; }
/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof UserDeleteEvent) { if (FileVersion_Access::set_owner_id_on_null($event_object->get_user_id()) == false) { return false; } } return true; }