protected function create_file($newrecord) {
        global $DB;
        $newrecord->id = $DB->insert_record('files', $newrecord);

        if ($newrecord->filename !== '.') {
            // Callback for file created.
            if ($pluginsfunction = get_plugins_with_function('after_file_created')) {
                foreach ($pluginsfunction as $plugintype => $plugins) {
                    foreach ($plugins as $pluginfunction) {
                        $pluginfunction($newrecord);
                    }
                }
            }
        }
    }