Skip to content

Commit

Permalink
Merge branch 'MDL-30775-24' of git://github.com/mouneyrac/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_24_STABLE

Conflicts:
	course/externallib.php
  • Loading branch information
Damyon Wiese committed May 2, 2013
2 parents eb244d3 + e2bceb5 commit ccd8763
Showing 1 changed file with 48 additions and 45 deletions.
93 changes: 48 additions & 45 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static function get_course_contents($courseid, $options = array()) {
$sections = $modinfo->get_section_info_all();

//for each sections (first displayed to last displayed)
$modinfosections = $modinfo->get_sections();
foreach ($sections as $key => $section) {

if (!$section->uservisible) {
Expand All @@ -125,64 +126,66 @@ public static function get_course_contents($courseid, $options = array()) {
$sectioncontents = array();

//for each module of the section
foreach ($modinfo->sections[$section->section] as $cmid) { //matching /course/lib.php:print_section() logic
$cm = $modinfo->cms[$cmid];
if (!empty($modinfosections[$section->section])) {
foreach ($modinfosections[$section->section] as $cmid) {
$cm = $modinfo->cms[$cmid];

// stop here if the module is not visible to the user
if (!$cm->uservisible) {
continue;
}
// stop here if the module is not visible to the user
if (!$cm->uservisible) {
continue;
}

$module = array();
$module = array();

//common info (for people being able to see the module or availability dates)
$module['id'] = $cm->id;
$module['name'] = format_string($cm->name, true);
$module['modname'] = $cm->modname;
$module['modplural'] = $cm->modplural;
$module['modicon'] = $cm->get_icon_url()->out(false);
$module['indent'] = $cm->indent;
//common info (for people being able to see the module or availability dates)
$module['id'] = $cm->id;
$module['name'] = format_string($cm->name, true);
$module['modname'] = $cm->modname;
$module['modplural'] = $cm->modplural;
$module['modicon'] = $cm->get_icon_url()->out(false);
$module['indent'] = $cm->indent;

$modcontext = context_module::instance($cm->id);
$modcontext = context_module::instance($cm->id);

if (!empty($cm->showdescription) or $cm->modname == 'label') {
// We want to use the external format. However from reading get_formatted_content(), get_content() format is always FORMAT_HTML.
list($module['description'], $descriptionformat) = external_format_text($cm->get_content(),
FORMAT_HTML, $modcontext->id, $cm->modname, 'intro', $cm->id);
}
if (!empty($cm->showdescription) or $cm->modname == 'label') {
// We want to use the external format. However from reading get_formatted_content(), get_content() format is always FORMAT_HTML.
list($module['description'], $descriptionformat) = external_format_text($cm->get_content(),
FORMAT_HTML, $modcontext->id, $cm->modname, 'intro', $cm->id);
}

//url of the module
$url = $cm->get_url();
if ($url) { //labels don't have url
$module['url'] = $cm->get_url()->out();
}
//url of the module
$url = $cm->get_url();
if ($url) { //labels don't have url
$module['url'] = $cm->get_url()->out();
}

$canviewhidden = has_capability('moodle/course:viewhiddenactivities',
context_module::instance($cm->id));
//user that can view hidden module should know about the visibility
$module['visible'] = $cm->visible;
$canviewhidden = has_capability('moodle/course:viewhiddenactivities',
context_module::instance($cm->id));
//user that can view hidden module should know about the visibility
$module['visible'] = $cm->visible;

//availability date (also send to user who can see hidden module when the showavailabilyt is ON)
if ($canupdatecourse or ($CFG->enableavailability && $canviewhidden && $cm->showavailability)) {
$module['availablefrom'] = $cm->availablefrom;
$module['availableuntil'] = $cm->availableuntil;
}
//availability date (also send to user who can see hidden module when the showavailabilyt is ON)
if ($canupdatecourse or ($CFG->enableavailability && $canviewhidden && $cm->showavailability)) {
$module['availablefrom'] = $cm->availablefrom;
$module['availableuntil'] = $cm->availableuntil;
}

$baseurl = 'webservice/pluginfile.php';
$baseurl = 'webservice/pluginfile.php';

//call $modulename_export_contents
//(each module callback take care about checking the capabilities)
require_once($CFG->dirroot . '/mod/' . $cm->modname . '/lib.php');
$getcontentfunction = $cm->modname.'_export_contents';
if (function_exists($getcontentfunction)) {
if ($contents = $getcontentfunction($cm, $baseurl)) {
$module['contents'] = $contents;
//call $modulename_export_contents
//(each module callback take care about checking the capabilities)
require_once($CFG->dirroot . '/mod/' . $cm->modname . '/lib.php');
$getcontentfunction = $cm->modname.'_export_contents';
if (function_exists($getcontentfunction)) {
if ($contents = $getcontentfunction($cm, $baseurl)) {
$module['contents'] = $contents;
}
}
}

//assign result to $sectioncontents
$sectioncontents[] = $module;
//assign result to $sectioncontents
$sectioncontents[] = $module;

}
}
$sectionvalues['modules'] = $sectioncontents;

Expand Down

0 comments on commit ccd8763

Please sign in to comment.