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) {
global $DB;
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;
}
$cminfo = new cached_cm_info();
@ -394,6 +394,7 @@ function folder_get_coursemodule_info($cm) {
// prepare folder object to store in customdata
$fdata = new stdClass();
$fdata->showexpanded = $folder->showexpanded;
$fdata->showdownloadfolder = $folder->showdownloadfolder;
if ($cm->showdescription && strlen(trim($folder->intro))) {
$fdata->intro = $folder->intro;
if ($folder->introformat != FORMAT_MOODLE) {

View File

@ -65,28 +65,35 @@ class mod_folder_renderer extends plugin_renderer_base {
'generalbox foldertree');
// 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);
if ($downloadable) {
$downloadbutton = $this->output->single_button(
new moodle_url('/mod/folder/download_folder.php', array('id' => $cm->id)),
get_string('downloadfolder', 'folder')
);
$buttons = '';
if ($downloadable) {
$downloadbutton = $this->output->single_button(
new moodle_url('/mod/folder/download_folder.php', array('id' => $cm->id)),
get_string('downloadfolder', 'folder')
);
$output .= $downloadbutton;
}
if (has_capability('mod/folder:managefiles', $context)) {
$editbutton = $this->output->single_button(
new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)),
get_string('edit')
);
$output .= $editbutton;
}
$buttons .= $downloadbutton;
}
// 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(
new moodle_url('/mod/folder/edit.php', array('id' => $cm->id)),
get_string('edit')
);
$buttons .= $editbutton;
}
if ($buttons) {
$output .= $this->output->box($buttons, 'generalbox folderbuttons');
}
return $output;
}

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

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