Skip to content
Permalink
Browse files

MDL-41940 files Option to limit legacy course files

Adding an option that prevents users from adding new files
or directories to legacy course files. Helps with weaning
users from them.
  • Loading branch information...
merrill-oakland committed Sep 24, 2013
1 parent 56cc9b3 commit cc0bb815ad639415ccb132de39a2f0666208de4c
Showing with 51 additions and 1 deletion.
  1. +1 −0 admin/settings/plugins.php
  2. +10 −1 files/coursefilesedit_form.php
  3. +38 −0 files/tests/behat/course_files.feature
  4. +2 −0 lang/en/admin.php
@@ -251,6 +251,7 @@
$temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
$temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
$temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
$ADMIN->add('repositorysettings', $temp);
$ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
@@ -19,9 +19,18 @@
class coursefiles_edit_form extends moodleform {
function definition() {
global $CFG;
$maxfiles = 0;
$subdirs = 0;
if ($CFG->legacyfilesaddallowed) {
$maxfiles = -1;
$subdirs = 1;
}
$mform =& $this->_form;
$contextid = $this->_customdata['contextid'];
$options = array('subdirs'=>1, 'maxfiles'=>-1, 'accepted_types'=>'*');
$options = array('subdirs' => $subdirs, 'maxfiles' => $maxfiles, 'accepted_types'=>'*');
$mform->addElement('filemanager', 'files_filemanager', '', null, $options);
$mform->addElement('hidden', 'contextid', $this->_customdata['contextid']);
$mform->setType('contextid', PARAM_INT);
@@ -0,0 +1,38 @@
@files @files_course @_only_local
Feature: Course files
In order to add legacy files
As a user
I need to upload files

@javascript
Scenario: Add legacy files
Given the following "courses" exists:
| fullname | shortname | category | legacyfiles |
| Course 1 | C1 | 0 | 2 |
And I log in as "admin"
And I set the following administration settings values:
| Legacy course files in new courses | 1 |
And I follow "Home"
And I follow "Course 1"
Then I should see "Legacy course files"
And I follow "Legacy course files"
And I press "Edit legacy course files"
Then I should see "Add..."
Then I should see "Create folder"

@javascript
Scenario: Add legacy file disabled
Given the following "courses" exists:
| fullname | shortname | category | legacyfiles |
| Course 1 | C1 | 0 | 2 |
And I log in as "admin"
And I set the following administration settings values:
| Legacy course files in new courses | 1 |
| Allow adding to legacy course files | 1 |
And I follow "Home"
And I follow "Course 1"
Then I should see "Legacy course files"
And I follow "Legacy course files"
And I press "Edit legacy course files"
Then I should not see "Add..."
Then I should not see "Create folder"
@@ -621,6 +621,8 @@
$string['latexpreamble'] = 'LaTeX preamble';
$string['latexsettings'] = 'LaTeX renderer Settings';
$string['latinexcelexport'] = 'Excel encoding';
$string['legacyfilesaddallowed'] = 'Allow adding to legacy course files';
$string['legacyfilesaddallowed_help'] = 'If a course has legacy course files, allow new files and folders to be added to it.';
$string['legacyfilesinnewcourses'] = 'Legacy course files in new courses';
$string['legacyfilesinnewcourses_help'] = 'By default legacy course files areas are available only in upgraded courses. Please note some features like single activity backup/restore are not compatible with this settings.';
$string['licensesettings'] = 'Licence settings';

0 comments on commit cc0bb81

Please sign in to comment.
You can’t perform that action at this time.