MDL-56841 mod_folder: Display edit and download buttons inline

This commit is contained in:
Andrew Hancox 2017-01-03 08:53:34 +00:00
parent f99313477d
commit 26ca6df76a
3 changed files with 31 additions and 20 deletions

View file

@ -385,7 +385,7 @@ function folder_dndupload_handle($uploadinfo) {
function folder_get_coursemodule_info($cm) { function folder_get_coursemodule_info($cm) {
global $DB; global $DB;
if (!($folder = $DB->get_record('folder', array('id' => $cm->instance), if (!($folder = $DB->get_record('folder', array('id' => $cm->instance),
'id, name, display, showexpanded, intro, introformat'))) { 'id, name, display, showexpanded, showdownloadfolder, intro, introformat'))) {
return NULL; return NULL;
} }
$cminfo = new cached_cm_info(); $cminfo = new cached_cm_info();
@ -394,6 +394,7 @@ function folder_get_coursemodule_info($cm) {
// prepare folder object to store in customdata // prepare folder object to store in customdata
$fdata = new stdClass(); $fdata = new stdClass();
$fdata->showexpanded = $folder->showexpanded; $fdata->showexpanded = $folder->showexpanded;
$fdata->showdownloadfolder = $folder->showdownloadfolder;
if ($cm->showdescription && strlen(trim($folder->intro))) { if ($cm->showdescription && strlen(trim($folder->intro))) {
$fdata->intro = $folder->intro; $fdata->intro = $folder->intro;
if ($folder->introformat != FORMAT_MOODLE) { if ($folder->introformat != FORMAT_MOODLE) {

View file

@ -65,28 +65,35 @@ class mod_folder_renderer extends plugin_renderer_base {
'generalbox foldertree'); 'generalbox foldertree');
// Do not append the edit button on the course page. // Do not append the edit button on the course page.
if ($folder->display != FOLDER_DISPLAY_INLINE) {
$containercontents = '';
$downloadable = folder_archive_available($folder, $cm); $downloadable = folder_archive_available($folder, $cm);
$buttons = '';
if ($downloadable) { if ($downloadable) {
$downloadbutton = $this->output->single_button( $downloadbutton = $this->output->single_button(
new moodle_url('/mod/folder/download_folder.php', array('id' => $cm->id)), new moodle_url('/mod/folder/download_folder.php', array('id' => $cm->id)),
get_string('downloadfolder', 'folder') get_string('downloadfolder', 'folder')
); );
$output .= $downloadbutton; $buttons .= $downloadbutton;
} }
if (has_capability('mod/folder:managefiles', $context)) { // Display the "Edit" button if current user can edit folder contents.
// Do not display it on the course page for the teachers because there
// is an "Edit settings" button right next to it with the same functionality.
if (has_capability('mod/folder:managefiles', $context) &&
($folder->display != FOLDER_DISPLAY_INLINE || !has_capability('moodle/course:manageactivities', $context))) {
$editbutton = $this->output->single_button( $editbutton = $this->output->single_button(
new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)), new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)),
get_string('edit') get_string('edit')
); );
$output .= $editbutton; $buttons .= $editbutton;
} }
if ($buttons) {
$output .= $this->output->box($buttons, 'generalbox folderbuttons');
} }
return $output; return $output;
} }

3
mod/folder/styles.css Normal file
View file

@ -0,0 +1,3 @@
div.course-content div.generalbox.folderbuttons {
padding-left: 35px;
}