MDL-28666 repository - Switch usefilereference to PARAM_BOOL
authorDan Poltawski <dan@moodle.com>
Wed, 16 May 2012 07:39:56 +0000 (15:39 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 21 May 2012 10:21:31 +0000 (18:21 +0800)
repository/filepicker.js
repository/repository_ajax.php

index 9c37b03..6993bbc 100644 (file)
@@ -1067,7 +1067,7 @@ M.core_filepicker.init = function(Y, options) {
                 } else if ((return_types & 4/*FILE_REFERENCE*/) &&
                         (this.options.return_types & 4/*FILE_REFERENCE*/) &&
                         selectnode.one('.fp-linktype-4 input').get('checked')) {
-                    params['usefilereference'] = 'yes';
+                    params['usefilereference'] = '1';
                 }
 
                 selectnode.addClass('loading');
index c004388..aa1e434 100644 (file)
@@ -49,7 +49,7 @@ $saveas_filename = optional_param('title', '', PARAM_FILE);     // save as file
 $saveas_path   = optional_param('savepath', '/', PARAM_PATH);   // save as file path
 $search_text   = optional_param('s', '', PARAM_CLEANHTML);
 $linkexternal  = optional_param('linkexternal', '', PARAM_ALPHA);
-$usefilereference  = optional_param('usefilereference', '', PARAM_ALPHA);
+$usefilereference  = optional_param('usefilereference', false, PARAM_BOOL);
 
 list($context, $course, $cm) = get_context_info_array($contextid);
 require_login($course, false, $cm);
@@ -212,7 +212,7 @@ switch ($action) {
             // Some repository plugins are hosting moodle internal files, we cannot use get_file
             // method, so we use copy_to_area method
             // (local, user, coursefiles, recent)
-            if ($repo->has_moodle_files() && ($usefilereference != 'yes')) {
+            if ($repo->has_moodle_files() && !$usefilereference) {
                 // check filesize against max allowed size
                 $filesize = $repo->get_file_size($source);
                 if (empty($filesize)) {
@@ -268,7 +268,7 @@ switch ($action) {
             $record->userid       = $USER->id;
 
 
-            if ($usefilereference == 'yes') {
+            if ($usefilereference) {
                 $reference = $repo->get_file_reference($source);
                 // get reference life time from repo
                 $record->referencelifetime = $repo->get_reference_file_lifetime($reference);