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.
This commit is contained in:
Eric Merrill
2013-10-04 13:56:57 -04:00
parent 56cc9b387e
commit cc0bb815ad
4 changed files with 51 additions and 1 deletions
+1
View File
@@ -251,6 +251,7 @@ if ($hassiteconfig) {
$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));
+10 -1
View File
@@ -19,9 +19,18 @@ require_once($CFG->libdir.'/formslib.php');
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);
+38
View File
@@ -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"
+2
View File
@@ -621,6 +621,8 @@ $string['languagesettings'] = 'Language settings';
$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';