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));
$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.<br />'.
- '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.<br />
+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';
$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.
* @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();
}
}
*/
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;