Skip to content

Commit

Permalink
MDL-48371 editors: Option for removing managefiles
Browse files Browse the repository at this point in the history
We want to remove the managefiles button from the
editors in the wiki so that students don't delete
each others files.
  • Loading branch information
abgreeve authored and danpoltawski committed Sep 7, 2015
1 parent a64e1f3 commit 037e05e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/editor/atto/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public function use_editor($elementid, array $options=null, $fpoptions=null) {
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();
Expand Down
7 changes: 7 additions & 0 deletions lib/editor/tinymce/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ protected function get_init_params($elementid, array $options=null) {
$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;
Expand Down
2 changes: 1 addition & 1 deletion lib/form/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===

Expand Down
7 changes: 6 additions & 1 deletion mod/wiki/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 037e05e

Please sign in to comment.