Skip to content

Commit

Permalink
MDL-10906 - remove the functionality to add a local file.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijaya committed Aug 30, 2010
1 parent 372f31d commit 3385b17
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 231 deletions.
11 changes: 1 addition & 10 deletions 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';
Expand All @@ -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.';
Expand Down Expand Up @@ -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';
Expand All @@ -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>.';
Expand Down
5 changes: 5 additions & 0 deletions mod/resource/db/upgrade.php
Expand Up @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions mod/resource/settings.php
Expand Up @@ -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));
Expand Down
50 changes: 0 additions & 50 deletions mod/resource/type/file/localfile.php

This file was deleted.

57 changes: 0 additions & 57 deletions mod/resource/type/file/localpath.php

This file was deleted.

84 changes: 10 additions & 74 deletions mod/resource/type/file/resource.class.php
Expand Up @@ -149,7 +149,7 @@ function _postprocess(&$resource) {
unset($resource->windowpopup);
$resource->options = '';

} else {
} else {
if (empty($resource->framepage)) {
$resource->options = '';
} else {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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') {
Expand All @@ -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);
Expand Down Expand Up @@ -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'));
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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=\"\" />";
Expand Down Expand Up @@ -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" />';
Expand 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">';
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
Expand All @@ -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);
Expand Down

0 comments on commit 3385b17

Please sign in to comment.