diff --git a/files/index.php b/files/index.php
index 0c5e131a33e..b78af78f643 100644
--- a/files/index.php
+++ b/files/index.php
@@ -223,27 +223,19 @@
print_simple_box_end();
echo "
";
- $resourcelist = false;
- foreach ($USER->filelist as $file) {
- // If file is specified in a resource, then delete that too.
- $clean_name = substr($file, 1);
- if (record_exists('resource', 'reference', $clean_name)) {
- if (!$resourcelist) {
- print_simple_box_start("center");
- $resourcelist = true;
- }
- $resource_id = files_get_cm_from_resource_name($clean_name);
- echo '
'.get_string('warningdeleteresource', '', $file)." ".get_string('update')."
"; - } - } - if ($resourcelist) { - print_simple_box_end(); - echo "Error: could not rename $oldname to $name
"; - } - - //if file is part of resource then update resource table as well - //this line only catch the root directory - if (record_exists('resource', 'reference', $oldname)) { - set_field('resource', 'reference', $name, 'reference', $oldname); - } - - if (get_dir_name_from_resource($oldname)) { - $resources = get_dir_name_from_resource($oldname); - print_simple_box_start("center"); - echo "The following files might be referenced as a resource :'. "$resource->reference :"." ".get_string('update').""; - } - print_simple_box_end(); + } else { + //file was renamed now update resources if needed + require_once($CFG->dirroot.'/mod/resource/lib.php'); + resource_renamefiles($course, $wdir, $oldname, $name); } displaydir($wdir); @@ -867,23 +846,4 @@ function displaydir ($wdir) { } -function files_get_cm_from_resource_name($clean_name) { - global $CFG; - - $SQL = 'SELECT a.id FROM '.$CFG->prefix.'course_modules a, '.$CFG->prefix.'resource b - WHERE a.instance = b.id AND b.reference = "'.$clean_name.'"'; - $resource = get_record_sql($SQL); - return $resource->id; -} - -function get_dir_name_from_resource($clean_name) { - global $CFG; - - $LIKE = sql_ilike(); - - $SQL = 'SELECT * FROM '.$CFG->prefix.'resource WHERE reference '.$LIKE. "\"%$clean_name%\""; - $resource = get_records_sql($SQL); - return $resource; -} - ?> diff --git a/lang/en_utf8/resource.php b/lang/en_utf8/resource.php index 01bb57ca9ae..852c9dd3c73 100644 --- a/lang/en_utf8/resource.php +++ b/lang/en_utf8/resource.php @@ -3,12 +3,15 @@ $string['addresource'] = 'Add a resource'; +$string['affectedresources'] = 'Affected resources'; $string['back'] = 'Back'; $string['browserepository'] = 'Browse repository'; $string['choose'] = 'Choose'; $string['chooseafile'] = 'Choose or upload a file'; $string['chooseparameter'] = 'Choose parameter'; $string['configallowlocalfiles'] = 'When creating a new file resource, allow links to files on a local file system such as a CD drive or a hard drive. This may be useful in a classroom where all students have access to a common network drive or where files on a CD need to be accessed. Use of this feature may require changes to your browser\'s security settings.'; +$string['configautofilerenamesettings'] = 'Automatically update references to files and directories when renamed in file manager.'; +$string['configblockdeletingfilesettings'] = 'Block deleting of files and directories referenced by resources. Please note that images and other files referenced from html are not protected.'; $string['configdefaulturl'] = 'This value is used to prefill the URL form when creating a new URL-based resource.'; $string['configfilterexternalpages'] = 'Enabling this setting will cause all external resources (web pages, uploaded HTML files) to be processed by the currently defined site filters (such as glossary autolinks, for example). Turning this option on may cause your course pages to slow down significantly - use with caution and only if you really need it.'; $string['configframesize'] = 'When a web page or an uploaded file is displayed within a frame, this value is the size (in pixels) of the top frame (which contains the navigation).'; @@ -116,5 +119,7 @@ $string['upbutton'] = 'Up'; $string['variablename'] = 'Variable name'; $string['viewims'] = 'View IMS Content Package'; $string['vol'] = 'Vol'; +$string['warningblockingdelete'] = 'Warning: Delete operation is blocked by existing resource. Either update your resources first or disable this safety mechanism in global Resource configuration.'; +$string['warningdisabledrename'] = 'Warning: The automatic renaming of references in resources is disabled. Please update affected resources manually if needed. Automatic renaming can be enabled in global Resource configuration.'; ?> diff --git a/mod/resource/config.html b/mod/resource/config.html index 0bf8ea37e6f..1f4d91806b0 100644 --- a/mod/resource/config.html +++ b/mod/resource/config.html @@ -125,6 +125,34 @@ +
'.get_string('affectedresources', 'resource').':
'.get_string('affectedresources', 'resource').':