Skip to content

Commit

Permalink
MDL-37455 mod_folder can display content inline. Coding style correct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
marinaglancy committed Feb 23, 2013
1 parent ec62d8b commit c553530
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mod/folder/edit.php
Expand Up @@ -52,7 +52,7 @@
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));
Expand Down
8 changes: 3 additions & 5 deletions mod/folder/lang/en/folder.php
Expand Up @@ -45,11 +45,9 @@
$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';
15 changes: 9 additions & 6 deletions mod/folder/lib.php
Expand Up @@ -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.
Expand All @@ -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();
}
}
Expand All @@ -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;
Expand Down

0 comments on commit c553530

Please sign in to comment.