mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-36985 atto: show file removal text on managefiles plugin
Shows a text warning in the manage files plugin window when an editor has set the 'removeorphaneddrafts' option to true. The text tells the user that unused files will be automatically deleted on save.
This commit is contained in:
parent
f3c2afd0e8
commit
81ed702156
@ -29,4 +29,5 @@ $string['managefiles'] = 'Manage files';
|
||||
$string['missingfiles'] = 'Missing files';
|
||||
$string['pluginname'] = 'Manage files';
|
||||
$string['unusedfilesdesc'] = 'The following embedded files are not used in the text area:';
|
||||
$string['unusedfilesremovalnotice'] = 'Any unused files will be automatically deleted when saving changes.';
|
||||
$string['unusedfilesheader'] = 'Unused files';
|
||||
|
@ -55,7 +55,8 @@ function atto_managefiles_params_for_js($elementid, $options, $fpoptions) {
|
||||
|
||||
if (!$disabled) {
|
||||
$params['usercontext'] = context_user::instance($USER->id)->id;
|
||||
foreach (array('itemid', 'context', 'areamaxbytes', 'maxbytes', 'subdirs', 'return_types') as $key) {
|
||||
foreach (array('itemid', 'context', 'areamaxbytes', 'maxbytes', 'subdirs', 'return_types',
|
||||
'removeorphaneddrafts') as $key) {
|
||||
if (isset($options[$key])) {
|
||||
if ($key === 'context' && is_object($options[$key])) {
|
||||
// Just context id is enough.
|
||||
|
@ -35,6 +35,7 @@ $return_types = optional_param('return_types', null, PARAM_INT);
|
||||
$areamaxbytes = optional_param('areamaxbytes', FILE_AREA_MAX_BYTES_UNLIMITED, PARAM_INT);
|
||||
$contextid = optional_param('context', SYSCONTEXTID, PARAM_INT);
|
||||
$elementid = optional_param('elementid', '', PARAM_TEXT);
|
||||
$removeorphaneddrafts = optional_param('removeorphaneddrafts', 0, PARAM_INT);
|
||||
|
||||
$context = context::instance_by_id($contextid);
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
@ -75,7 +76,7 @@ $options = array(
|
||||
'accepted_types' => $accepted_types,
|
||||
'areamaxbytes' => $areamaxbytes,
|
||||
'return_types' => $return_types,
|
||||
'context' => $context,
|
||||
'context' => $context
|
||||
);
|
||||
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
@ -87,8 +88,8 @@ foreach ($files as $file) {
|
||||
}
|
||||
|
||||
$mform = new atto_managefiles_manage_form(null,
|
||||
array('options' => $options, 'draftitemid' => $itemid, 'files' => $filenames, 'elementid' => $elementid),
|
||||
'post', '', array('id' => 'atto_managefiles_manageform'));
|
||||
array('options' => $options, 'draftitemid' => $itemid, 'files' => $filenames, 'elementid' => $elementid,
|
||||
'removeorphaneddrafts' => $removeorphaneddrafts), 'post', '', array('id' => 'atto_managefiles_manageform'));
|
||||
|
||||
if ($data = $mform->get_data()) {
|
||||
if (!empty($data->deletefile)) {
|
||||
|
@ -47,6 +47,7 @@ class atto_managefiles_manage_form extends moodleform {
|
||||
$elementid = $this->_customdata['elementid'];
|
||||
$options = $this->_customdata['options'];
|
||||
$files = $this->_customdata['files'];
|
||||
$removeorphaneddrafts = $this->_customdata['removeorphaneddrafts'];
|
||||
|
||||
$mform->addElement('header', 'filemanagerhdr', get_string('filemanager', 'atto_managefiles'));
|
||||
|
||||
@ -69,6 +70,12 @@ class atto_managefiles_manage_form extends moodleform {
|
||||
|
||||
$mform->addElement('filemanager', 'files_filemanager', '', null, $options);
|
||||
|
||||
// Let the user know that any drafts not referenced in the text will be removed automatically.
|
||||
if ($removeorphaneddrafts) {
|
||||
$mform->addElement('static', '', '',
|
||||
html_writer::tag('div', get_string('unusedfilesremovalnotice', 'atto_managefiles')));
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'missingfileshdr', get_string('missingfiles', 'atto_managefiles'));
|
||||
$mform->addElement('static', '', '',
|
||||
html_writer::tag('div',
|
||||
|
@ -58,7 +58,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatab
|
||||
/** @var array options provided to initalize filepicker */
|
||||
protected $_options = array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 0, 'changeformat' => 0,
|
||||
'areamaxbytes' => FILE_AREA_MAX_BYTES_UNLIMITED, 'context' => null, 'noclean' => 0, 'trusttext' => 0,
|
||||
'return_types' => 15, 'enable_filemanagement' => true);
|
||||
'return_types' => 15, 'enable_filemanagement' => true, 'removeorphaneddrafts' => false);
|
||||
// 15 is $_options['return_types'] = FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE | FILE_CONTROLLED_LINK.
|
||||
|
||||
/** @var array values for editor */
|
||||
|
Loading…
x
Reference in New Issue
Block a user