Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-10906 - remove the functionality to add a local file.

  • Loading branch information...
commit 3385b1702e0d4af54b02f3cdcc1e85112ad28fc5 1 parent 372f31d
Rossiani Wijaya authored
View
11 lang/en_utf8/resource.php
@@ -1,10 +1,9 @@
-<?PHP // $Id$
+<?PHP // $Id$
// resource.php - created with Moodle 1.7 beta + (2006101003)
$string['addresource'] = 'Add a resource';
$string['affectedresources'] = 'Affected resources';
-$string['allowlocalfiles'] = 'Allow local files';
$string['autofilerename'] = 'Update link if file renamed';
$string['back'] = 'Back';
$string['blockdeletingfile'] = 'Block deleting of referenced files';
@@ -13,7 +12,6 @@
$string['chooseafile'] = 'Choose or upload a file';
$string['chooseparameter'] = 'Choose parameter';
$string['clicktoopen'] = 'To open this document, click on this link: ';
-$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.';
@@ -56,12 +54,6 @@
$string['imspackageloaded'] = 'Package loaded';
$string['keepnavigationvisible'] = 'Show navigation';
$string['keepnavigationvisiblewarning'] = 'Note: some media files may ignore this setting';
-$string['localfile'] = 'Local file';
-$string['localfilechoose'] = 'Choose a local file (CD-ROM)';
-$string['localfilehelp'] = 'Help displaying local files';
-$string['localfileinfo'] = '<p>Choose a local file from your computer. The file will not be uploaded to the web site, but Moodle will look for the same file on the computer of anyone viewing this resource.</p><p>This is mostly useful when you have large media files stored on a standard CD-ROM that you distribute to all participants. Each participant is able to choose their own local path for such files, by <a href=\"$a\" target=\"_blank\">editing their user profile</a>.</p>';
-$string['localfilepath'] = 'To set your own local path for this resource, choose any file from the drive (usually a CD_ROM) on your computer where the resource exists. The file will not be uploaded but the drive information will be stored and used for any local file resources';
-$string['localfileselect'] = 'Choose this file path.';
$string['maindirectory'] = 'Main files directory';
$string['modulename'] = 'Resource';
$string['modulenameplural'] = 'Resources';
@@ -85,7 +77,6 @@
$string['newwindow'] = 'New window';
$string['newwindowopen'] = 'Display this resource in a new popup window';
$string['next'] = 'Next';
-$string['notallowedlocalfileaccess'] = 'Access to local files is currently disabled, so this resource is not available.';
$string['notdeployed'] = 'Not deployed';
$string['note'] = 'Note';
$string['notefile'] = 'To upload more files into the course (so they appear in this list) use the <a href=\"$a\">File Manager</a>.';
View
5 mod/resource/db/upgrade.php
@@ -77,6 +77,11 @@ function xmldb_resource_upgrade($oldversion=0) {
$result = $result && execute_sql($sql);
}
+ // MDL-10906. Removing resource_allowlocalfiles setting.
+ if ($result && $oldversion < 2007101511) {
+ $result = $result && unset_config('resource_allowlocalfiles');
+ }
+
//===== 1.9.0 upgrade line ======//
return $result;
}
View
3  mod/resource/settings.php
@@ -18,9 +18,6 @@
$settings->add(new admin_setting_configpasswordunmask('resource_secretphrase', get_string('password'),
get_string('configsecretphrase', 'resource'), random_string(20)));
-$settings->add(new admin_setting_configcheckbox('resource_allowlocalfiles', get_string('allowlocalfiles', 'resource'),
- get_string('configallowlocalfiles', 'resource'), 0));
-
$woptions = array('' => get_string('pagewindow', 'resource'), 'checked' => get_string('newwindow', 'resource'));
$settings->add(new admin_setting_configselect('resource_popup', get_string('display', 'resource'),
get_string('configpopup', 'resource'), '', $woptions));
View
50 mod/resource/type/file/localfile.php
@@ -1,50 +0,0 @@
-<?php // $Id$
-
- require('../../../../config.php');
- require('../../lib.php');
-
- $choose = required_param('choose', PARAM_FILE);
-
- require_login();
-
- if (!$CFG->resource_allowlocalfiles) {
- error('You cannot access this script');
- }
-
- print_header(get_string('localfilechoose', 'resource'));
-
- print_simple_box(get_string('localfileinfo', 'resource'), 'center');
-
- ?>
- <script type="text/javascript">
- //<![CDATA[
- function set_value(txt) {
- if (txt.indexOf('/') > -1) {
- path = txt.substring(txt.indexOf('/'),txt.length);
- } else if (txt.indexOf('\\') > -1) {
- path = txt.substring(txt.indexOf('\\'),txt.length);
- } else {
- window.close();
- }
- opener.document.getElementById('<?php echo $choose ?>').value = '<?php p(RESOURCE_LOCALPATH) ?>'+path;
- window.close();
- }
- //]]>
- </script>
-
- <br />
- <div class="form mdl-align">
- <form id="myform">
- <fieldset class="invisiblefieldset">
- <input type="file" size="60" name="myfile" /><br />
- <input type="button" value="<?php print_string('localfileselect','resource') ?>"
- onClick="return set_value(getElementById('myform').myfile.value)">
- <input type="button" value="<?php print_string('cancel') ?>"
- onClick="window.close()">
- </fieldset>
- </form>
- </div>
-
-<?php
- print_footer('empty');
-?>
View
57 mod/resource/type/file/localpath.php
@@ -1,57 +0,0 @@
-<?php // $Id$
-
- require('../../../../config.php');
- require('../../lib.php');
-
- $pathname = optional_param('pathname', '');
-
- if ($pathname) {
- if (confirm_sesskey()) {
- set_user_preference('resource_localpath', $pathname);
- }
- ?>
- <script type="text/javascript">
- //<![CDATA[
- window.close();
- //]]>
- </script>
- <?php
- exit;
- }
-
- print_header(get_string('localfilechoose', 'resource'));
-
- print_simple_box(get_string('localfilepath', 'resource', $CFG->wwwroot.'/user/edit.php?course='.SITEID), 'center');
-
- ?>
- <script type="text/javascript">
- //<![CDATA[
- function set_value(txt) {
- if (txt.indexOf('/') > -1) {
- txt = txt.substring(0,txt.lastIndexOf('/'));
- } else if (txt.indexOf('\\') > -1) {
- txt = txt.substring(0,txt.lastIndexOf('\\'));
- }
- getElementById('myform').pathname.value = txt;
- getElementById('myform').submit();
- }
- //]]>
- </script>
-
- <br />
- <div class="form mdl-align">
- <form id="myform" action="localpath.php" method="post">
- <fieldset class="invisiblefieldset">
- <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>">
- <input type="hidden" name="pathname" value="" />
- <input type="file" size="60" name="myfile" /><br />
- <input type="button" value="<?php print_string('localfileselect','resource') ?>"
- onClick="return set_value(getElementById('myform').myfile.value)">
- <input type="button" value="<?php print_string('cancel') ?>"
- onClick="window.close()">
- </fieldset>
- </form>
- </div>
-<?php
- print_footer('empty');
-?>
View
84 mod/resource/type/file/resource.class.php
@@ -149,7 +149,7 @@ function _postprocess(&$resource) {
unset($resource->windowpopup);
$resource->options = '';
- } else {
+ } else {
if (empty($resource->framepage)) {
$resource->options = '';
} else {
@@ -266,12 +266,12 @@ function display() {
} else if ($mimetype == 'application/pdf' || $mimetype == 'application/x-pdf') {
$resourcetype = "pdf";
//no need embedded, html file types behave like unknown file type
-
+
} else if ($mimetype == "audio/x-pn-realaudio-plugin") { // It's a realmedia file
$resourcetype = "rm";
$embedded = true;
}
- }
+ }
$isteamspeak = (stripos($resource->reference, 'teamspeak://') === 0);
@@ -307,20 +307,6 @@ function display() {
$fullurl .= '&amp;'.$querystring;
}
}
-
- } else if ($CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) { // Localpath
- $localpath = get_user_preferences('resource_localpath', 'D:');
- $relativeurl = str_replace(RESOURCE_LOCALPATH, $localpath, $resource->reference);
-
- if ($querystring) {
- $relativeurl .= '?'.$querystring;
- }
-
- $relativeurl = str_replace('\\', '/', $relativeurl);
- $relativeurl = str_replace(' ', '%20', $relativeurl);
- $fullurl = 'file:///'.htmlentities($relativeurl);
- $localpath = true;
-
} else { // Normal uploaded file
$forcedownloadsep = '?';
if ($resource->options == 'forcedownload') {
@@ -329,25 +315,6 @@ function display() {
$fullurl = get_file_url($course->id.'/'.$resource->reference, $querys);
}
- /// Print a notice and redirect if we are trying to access a file on a local file system
- /// and the config setting has been disabled
- if (!$CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) {
- if ($inpopup) {
- print_header($pagetitle, $course->fullname);
- } else {
- $navigation = build_navigation($this->navlinks, $cm);
- print_header($pagetitle, $course->fullname, $navigation,
- "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
- }
- notify(get_string('notallowedlocalfileaccess', 'resource', ''));
- if ($inpopup) {
- close_window_button();
- }
- print_footer('none');
- die;
- }
-
-
/// Check whether this is supposed to be a popup, but was called directly
if ($resource->popup and !$inpopup) { /// Make a page and a pop-up window
$navigation = build_navigation($this->navlinks, $cm);
@@ -382,7 +349,7 @@ function display() {
$frameset = optional_param('frameset', '', PARAM_ALPHA);
if (empty($frameset) and !$embedded and !$inpopup and ($resource->options == "frame" || $resource->options == "objectframe") and empty($USER->screenreader)) {
- /// display the resource into a object tag
+ /// display the resource into a object tag
if ($resource->options == "objectframe") {
/// Yahoo javascript libaries for updating embedded object size
require_js(array('yui_utilities'));
@@ -396,11 +363,6 @@ function display() {
print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
$options = new object();
$options->para = false;
- if (!empty($localpath)) { // Show some help
- echo '<div class="mdl-right helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- }
echo '</div></div>';
/// embedded file into iframe if the resource is on another domain
@@ -462,11 +424,7 @@ function resizeEmbeddedHtml() {
echo "<title>" . format_string($course->shortname) . ": ".strip_tags(format_string($resource->name,true))."</title></head>\n";
echo "<frameset rows=\"$CFG->resource_framesize,*\">";
echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"".get_string('modulename','resource')."\"/>";
- if (!empty($localpath)) { // Show it like this so we interpose some HTML
- echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"".get_string('modulename','resource')."\"/>";
- } else {
- echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
- }
+ echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
echo "</frameset>";
echo "</html>";
exit;
@@ -493,12 +451,6 @@ function resizeEmbeddedHtml() {
$options = new object();
$options->para = false;
echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $options).'</div>';
- if (!empty($localpath)) { // Show some help
- echo '<div class="mdl-right helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'),
- get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- }
print_footer('empty');
exit;
}
@@ -516,7 +468,7 @@ function resizeEmbeddedHtml() {
update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
}
-
+
if ($resourcetype == "image") {
echo '<div class="resourcecontent resourceimg">';
echo "<img title=\"".strip_tags(format_string($resource->name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />";
@@ -630,7 +582,7 @@ function resizeEmbeddedHtml() {
echo '</div>';
} else if ($resourcetype == "rm") {
- echo '<div class="resourcecontent resourcerm">';
+ echo '<div class="resourcecontent resourcerm">';
echo '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="320" height="240">';
echo '<param name="src" value="' . $fullurl . '" />';
echo '<param name="controls" value="All" />';
@@ -641,7 +593,7 @@ function resizeEmbeddedHtml() {
echo '</object>';
echo '<!--<![endif]-->';
echo '</object>';
- echo '</div>';
+ echo '</div>';
} else if ($resourcetype == "quicktime") {
echo '<div class="resourcecontent resourceqt">';
@@ -710,13 +662,6 @@ function resizeEmbeddedHtml() {
}
} else { // Display the resource on it's own
- if (!empty($localpath)) { // Show a link to help work around browser security
- echo '<div class="mdl-right helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'),
- get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- echo "<div class=\"popupnotice\">(<a href=\"$fullurl\">$fullurl</a>)</div>";
- }
redirect($fullurl);
}
@@ -759,7 +704,7 @@ function setup_preprocessing(&$defaults){
if (array_key_exists('options', $defaults)) {
if ($defaults['options']=='frame') {
$defaults['framepage'] = 1;
- } else if ($defaults['options']=='objectframe') {
+ } else if ($defaults['options']=='objectframe') {
$defaults['framepage'] = 2;
} else {
$defaults['framepage'] = 0;
@@ -800,15 +745,6 @@ function setup_elements(&$mform) {
$searchbutton->updateAttributes($buttonattributes);
}
- if (!empty($CFG->resource_allowlocalfiles)) {
- $lfbutton = $mform->addElement('button', 'localfilesbutton', get_string('localfilechoose', 'resource').'...');
- $options = 'menubar=0,location=0,scrollbars,resizable,width=600,height=400';
- $url = '/mod/resource/type/file/localfile.php?choose=id_reference_value';
- $buttonattributes = array('title'=>get_string('localfilechoose', 'resource'), 'onclick'=>"return openpopup('$url', '"
- . $lfbutton->getName()."', '$options', 0);");
- $lfbutton->updateAttributes($buttonattributes);
- }
-
$mform->addElement('header', 'displaysettings', get_string('display', 'resource'));
$mform->addElement('checkbox', 'forcedownload', get_string('forcedownload', 'resource'));
@@ -822,7 +758,7 @@ function setup_elements(&$mform) {
$navoptions = array(0 => get_string('keepnavigationvisibleno','resource'), 1 => get_string('keepnavigationvisibleyesframe','resource'), 2 => get_string('keepnavigationvisibleyesobject','resource'));
$mform->addElement('select', 'framepage', get_string('keepnavigationvisible', 'resource'), $navoptions);
-
+
$mform->setHelpButton('framepage', array('frameifpossible', get_string('keepnavigationvisible', 'resource'), 'resource'));
$mform->setDefault('framepage', 0);
$mform->disabledIf('framepage', 'windowpopup', 'eq', 1);
View
37 mod/resource/type/repository/resource.class.php
@@ -289,25 +289,6 @@ function display() {
}
/// MW END
-
- /// Print a notice and redirect if we are trying to access a file on a local file system
- /// and the config setting has been disabled
- if (!$CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) {
- if ($inpopup) {
- print_header($pagetitle, $course->fullname);
- } else {
- print_header($pagetitle, $course->fullname, $navigation, "", "", true,
- update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
- }
- notify(get_string('notallowedlocalfileaccess', 'resource', ''));
- if ($inpopup) {
- close_window_button();
- }
- print_footer('none');
- die;
- }
-
-
/// Check whether this is supposed to be a popup, but was called directly
if ($resource->popup and !$inpopup) { /// Make a page and a pop-up window
@@ -351,11 +332,7 @@ function display() {
echo "<title>" . format_string($course->shortname) . ": ".strip_tags(format_string($resource->name,true))."</title></head>\n";
echo "<frameset rows=\"$CFG->resource_framesize,*\">";
echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"".get_string('modulename','resource')."\"/>";
- if (!empty($localpath)) { // Show it like this so we interpose some HTML
- echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"".get_string('modulename','resource')."\"/>";
- } else {
- echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
- }
+ echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
echo "</frameset>";
echo "</html>";
exit;
@@ -374,16 +351,10 @@ function display() {
update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $formatoptions).'</div>';
- if (!empty($localpath)) { // Show some help
- echo '<div class="mdl-right helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- }
echo '</body></html>';
exit;
}
-
/// Display the actual resource
if ($embedded) { // Display resource embedded in page
@@ -488,12 +459,6 @@ function display() {
}
} else { // Display the resource on it's own
- if (!empty($localpath)) { // Show a link to help work around browser security
- echo '<div class="mdl-right helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- echo "<center><p>(<a href=\"$fullurl\">$fullurl</a>)</p></center>";
- }
redirect($fullurl);
}
View
2  mod/resource/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2007101510;
+$module->version = 2007101511;
$module->requires = 2007101510; // Requires this Moodle version
$module->cron = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.