From c553530a8e73d21434e9cc1ee39a63f205fffa40 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 15 Feb 2013 20:12:31 +1100 Subject: [PATCH] MDL-37455 mod_folder can display content inline. Coding style corrections --- mod/folder/edit.php | 2 +- mod/folder/lang/en/folder.php | 8 +++----- mod/folder/lib.php | 15 +++++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mod/folder/edit.php b/mod/folder/edit.php index 33f219fbdd7..687181f02ac 100644 --- a/mod/folder/edit.php +++ b/mod/folder/edit.php @@ -52,7 +52,7 @@ $options = array('subdirs'=>1, 'maxbytes'=>$CFG->maxbytes, 'maxfiles'=>-1, 'acce file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_folder', 'content', 0); $mform = new mod_folder_edit_form(null, array('data'=>$data, 'options'=>$options)); -if (!empty($folder->display) && $folder->display == FOLDER_DISPLAY_INLINE) { +if ($folder->display == FOLDER_DISPLAY_INLINE) { $redirecturl = course_get_url($cm->course, $cm->sectionnum); } else { $redirecturl = new moodle_url('/mod/folder/view.php', array('id' => $cm->id)); diff --git a/mod/folder/lang/en/folder.php b/mod/folder/lang/en/folder.php index c499be331eb..1e9f751cb70 100644 --- a/mod/folder/lang/en/folder.php +++ b/mod/folder/lang/en/folder.php @@ -45,11 +45,9 @@ $string['page-mod-folder-view'] = 'Folder module main page'; $string['pluginadministration'] = 'Folder administration'; $string['pluginname'] = 'Folder'; $string['display'] = 'Display folder contents'; -$string['display_help'] = 'If you choose to display the folder contents on a course page, there '. - 'will be no link to a separate page and the title will not be displayed. The '. - 'description will be displayed only if "Display description on course page" '. - 'is checked.
'. - 'Also note that participants view actions can not be logged in this case.'; +$string['display_help'] = 'If you choose to display the folder contents on a course page, there will be no link to a separate page and the title will not be displayed. +The description will be displayed only if "Display description on course page" is checked.
+Also note that participants view actions can not be logged in this case.'; $string['displaypage'] = 'On a separate page'; $string['displayinline'] = 'Inline on a course page'; $string['noautocompletioninline'] = 'Automatic completion on viewing of activity can not be selected together with "Display inline" option'; diff --git a/mod/folder/lib.php b/mod/folder/lib.php index c09ce2edfe9..7e602cb9bd2 100644 --- a/mod/folder/lib.php +++ b/mod/folder/lib.php @@ -433,14 +433,14 @@ function folder_get_coursemodule_info($cm) { $cminfo->name = $folder->name; if ($folder->display == FOLDER_DISPLAY_INLINE) { // prepare folder object to store in customdata - $fdata = new stdClass; + $fdata = new stdClass(); if ($cm->showdescription && strlen(trim($folder->intro))) { $fdata->intro = $folder->intro; if ($folder->introformat != FORMAT_MOODLE) { $fdata->introformat = $folder->introformat; } } - $cminfo->customdata = json_encode($fdata); + $cminfo->customdata = $fdata; } else { if ($cm->showdescription) { // Convert intro to html. Do not filter cached version, filters run at display time. @@ -459,7 +459,8 @@ function folder_get_coursemodule_info($cm) { * @param cm_info $cm */ function folder_cm_info_dynamic(cm_info $cm) { - if (strlen($cm->get_custom_data())) { + if ($cm->get_custom_data()) { + // the field 'customdata' is not empty IF AND ONLY IF we display contens inline $cm->set_no_view_link(); } } @@ -472,10 +473,12 @@ function folder_cm_info_dynamic(cm_info $cm) { */ function folder_cm_info_view(cm_info $cm) { global $PAGE; - if ($cm->uservisible && strlen($cm->get_custom_data()) && + if ($cm->uservisible && $cm->get_custom_data() && has_capability('mod/folder:view', $cm->context)) { - // restore folder object from customdata - $folder = json_decode($cm->get_custom_data()); + // Restore folder object from customdata. + // Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline. + // Otherwise the content is default. + $folder = $cm->get_custom_data(); $folder->id = (int)$cm->instance; $folder->course = (int)$cm->course; $folder->display = FOLDER_DISPLAY_INLINE;