From 037e05e8b266bff4835f0d2eea33ef86fb71d585 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 25 Aug 2015 12:57:43 +0800 Subject: [PATCH] MDL-48371 editors: Option for removing managefiles We want to remove the managefiles button from the editors in the wiki so that students don't delete each others files. --- lib/editor/atto/lib.php | 5 +++++ lib/editor/tinymce/lib.php | 7 +++++++ lib/form/editor.php | 2 +- lib/upgrade.txt | 1 + mod/wiki/pagelib.php | 7 ++++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/editor/atto/lib.php b/lib/editor/atto/lib.php index a4509177179..f09653d9549 100644 --- a/lib/editor/atto/lib.php +++ b/lib/editor/atto/lib.php @@ -103,6 +103,11 @@ class atto_texteditor extends texteditor { continue; } + // Remove manage files if requested. + if ($plugin == 'managefiles' && isset($options['enable_filemanagement']) && !$options['enable_filemanagement']) { + continue; + } + $jsplugin = array(); $jsplugin['name'] = $plugin; $jsplugin['params'] = array(); diff --git a/lib/editor/tinymce/lib.php b/lib/editor/tinymce/lib.php index 6aaab943c8c..e82709296b7 100644 --- a/lib/editor/tinymce/lib.php +++ b/lib/editor/tinymce/lib.php @@ -108,6 +108,13 @@ class tinymce_texteditor extends texteditor { $config->disabledsubplugins = ''; } + // Remove the manage files button if requested. + if (isset($options['enable_filemanagement']) && !$options['enable_filemanagement']) { + if (!strpos($config->disabledsubplugins, 'managefiles')) { + $config->disabledsubplugins .= ',managefiles'; + } + } + $fontselectlist = empty($config->fontselectlist) ? '' : $config->fontselectlist; $langrev = -1; diff --git a/lib/form/editor.php b/lib/form/editor.php index 76e534b2493..0c18b2122d0 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -53,7 +53,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { /** @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' => 7); + 'return_types' => 7, 'enable_filemanagement' => true); // $_options['return_types'] = FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE /** @var array values for editor */ diff --git a/lib/upgrade.txt b/lib/upgrade.txt index a7cd12b55b2..d53582eb98d 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -7,6 +7,7 @@ information provided here is intended especially for developers. i.e. a call to M.core.actionmenu.instance.hideMenu() can be changed to M.core.actionmenu.instance.hideMenu(e) to ensure good behaviour when using custom action menus. * Users of the text editor API to manually create a text editor should call set_text before calling use_editor. See MDL-51179. +* In the html_editors (tinyMCE, Atto), the manage files button can be hidden by changing the 'enable_filemanagement' option to false. === 2.9.1 === diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 5acd88f4718..e6a840c099f 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -381,7 +381,12 @@ class page_wiki_edit extends page_wiki { function __construct($wiki, $subwiki, $cm) { global $CFG, $PAGE; parent::__construct($wiki, $subwiki, $cm); - self::$attachmentoptions = array('subdirs' => false, 'maxfiles' => - 1, 'maxbytes' => $CFG->maxbytes, 'accepted_types' => '*'); + $showfilemanager = false; + if (has_capability('mod/wiki:managefiles', context_module::instance($cm->id))) { + $showfilemanager = true; + } + self::$attachmentoptions = array('subdirs' => false, 'maxfiles' => - 1, 'maxbytes' => $CFG->maxbytes, + 'accepted_types' => '*', 'enable_filemanagement' => $showfilemanager); $PAGE->requires->js_init_call('M.mod_wiki.renew_lock', null, true); }