diff --git a/mod/folder/lib.php b/mod/folder/lib.php index 3700dec4f0b..eba3377ee7d 100644 --- a/mod/folder/lib.php +++ b/mod/folder/lib.php @@ -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) { diff --git a/mod/folder/renderer.php b/mod/folder/renderer.php index 7b695e1bfdd..421d96d90cf 100644 --- a/mod/folder/renderer.php +++ b/mod/folder/renderer.php @@ -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; } diff --git a/mod/folder/styles.css b/mod/folder/styles.css new file mode 100644 index 00000000000..328b63ea341 --- /dev/null +++ b/mod/folder/styles.css @@ -0,0 +1,3 @@ +div.course-content div.generalbox.folderbuttons { + padding-left: 35px; +}