diff --git a/mod/scorm/classes/external.php b/mod/scorm/classes/external.php index 2457ac3c35c..cae7a1c3d69 100644 --- a/mod/scorm/classes/external.php +++ b/mod/scorm/classes/external.php @@ -679,6 +679,8 @@ class mod_scorm_external extends external_api { } } + $module['protectpackagedownloads'] = get_config('scorm', 'protectpackagedownloads'); + $viewablefields = array('version', 'maxgrade', 'grademethod', 'whatgrade', 'maxattempt', 'forcecompleted', 'forcenewattempt', 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure', 'sha1hash', 'md5hash', 'revision', 'launch', 'skipview', 'hidebrowse', 'hidetoc', 'nav', @@ -766,6 +768,8 @@ class mod_scorm_external extends external_api { VALUE_OPTIONAL), 'scormtype' => new external_value(PARAM_ALPHA, 'SCORM type', VALUE_OPTIONAL), 'reference' => new external_value(PARAM_NOTAGS, 'Reference to the package', VALUE_OPTIONAL), + 'protectpackagedownloads' => new external_value(PARAM_BOOL, 'Protect package downloads?', + VALUE_OPTIONAL), 'updatefreq' => new external_value(PARAM_INT, 'Auto-update frequency for remote packages', VALUE_OPTIONAL), 'options' => new external_value(PARAM_RAW, 'Additional options', VALUE_OPTIONAL), diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index bd7897b0aaa..49b6ea36ef8 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -311,6 +311,8 @@ $string['position_error'] = 'The {$a->tag} tag can\'t be child of {$a->parent} t $string['preferencesuser'] = 'Preferences for this report'; $string['preferencespage'] = 'Preferences just for this page'; $string['prev'] = 'Previous'; +$string['protectpackagedownloads'] = 'Protect package downloads'; +$string['protectpackagedownloads_desc'] = 'If enabled, SCORM packages can be downloaded only if the user has the course:manageactivities capability. If disabled, SCORM packages can always be downloaded (by mobile or other means).'; $string['raw'] = 'Raw score'; $string['regular'] = 'Regular manifest'; $string['report'] = 'Report'; diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 1e2164ffcc9..bafc6d35d8c 100644 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -947,7 +947,9 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo // TODO: add any other access restrictions here if needed! } else if ($filearea === 'package') { - if (!has_capability('moodle/course:manageactivities', $context)) { + // Check if the global setting for disabling package downloads is enabled. + $protectpackagedownloads = get_config('scorm', 'protectpackagedownloads'); + if ($protectpackagedownloads and !has_capability('moodle/course:manageactivities', $context)) { return false; } $revision = (int)array_shift($args); // Prevents caching problems - ignored here. diff --git a/mod/scorm/settings.php b/mod/scorm/settings.php index 5287a3754b0..9dbc57effec 100644 --- a/mod/scorm/settings.php +++ b/mod/scorm/settings.php @@ -157,4 +157,7 @@ if ($ADMIN->fulltree) { $settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '.*')); + $settings->add(new admin_setting_configcheckbox('scorm/protectpackagedownloads', get_string('protectpackagedownloads', 'scorm'), + get_string('protectpackagedownloads_desc', 'scorm'), 0)); + } diff --git a/mod/scorm/version.php b/mod/scorm/version.php index 09fc251f045..ff2b6caef74 100644 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2015092200; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2015092201; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2015050500; // Requires this Moodle version. $plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics). $plugin->cron = 300;