From 901d58dfd358cc58939cb28da4930c8fba0ddcb1 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 23 Feb 2012 11:20:16 +0800 Subject: [PATCH] MDL-29086 - data - Fix for allowing the deletion of database activity presets. Thank you to Matthias Hunstock for providing the patch for this. --- mod/data/lib.php | 2 ++ mod/data/preset.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mod/data/lib.php b/mod/data/lib.php index 7b95e18a59e..cb67011b46f 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -3121,6 +3121,7 @@ function data_extend_settings_navigation(settings_navigation $settings, navigati * @return bool */ function data_presets_save($course, $cm, $data, $path) { + global $USER; $fs = get_file_storage(); $filerecord = new stdClass; $filerecord->contextid = DATA_PRESET_CONTEXT; @@ -3128,6 +3129,7 @@ function data_presets_save($course, $cm, $data, $path) { $filerecord->filearea = DATA_PRESET_FILEAREA; $filerecord->itemid = 0; $filerecord->filepath = '/'.$path.'/'; + $filerecord->userid = $USER->id; $filerecord->filename = 'preset.xml'; $fs->create_file_from_string($filerecord, data_presets_generate_xml($course, $cm, $data)); diff --git a/mod/data/preset.php b/mod/data/preset.php index b9dd65bacc9..86cc0668c40 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -183,8 +183,7 @@ if (optional_param('sesskey', false, PARAM_BOOL) && confirm_sesskey()) { print_error('invalidrequest'); } - $presetpath = data_preset_path($course, $userid, $shortname); - fulldelete($presetpath); + data_delete_site_preset($shortname); $strdeleted = get_string('deleted', 'data'); echo $OUTPUT->notification("$shortname $strdeleted", 'notifysuccess');