mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-22787 Fixed XML-RPC enrol/mnet/enrol.php/available_courses returned by 2.0 MNet server
Returns defaultrolename, fixed URLs in course summary and the returned array must be indexed sequentially.
This commit is contained in:
parent
d5bd0b0169
commit
c07e728146
1 changed files with 11 additions and 3 deletions
|
@ -57,7 +57,8 @@ class enrol_mnet_mnetservice_enrol {
|
|||
* @return array
|
||||
*/
|
||||
public function available_courses() {
|
||||
global $DB;
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
if (!$client = get_mnet_remote_client()) {
|
||||
die('Callable via XML-RPC only');
|
||||
|
@ -66,7 +67,7 @@ class enrol_mnet_mnetservice_enrol {
|
|||
$sql = "SELECT c.id AS remoteid, c.fullname, c.shortname, c.idnumber, c.summary, c.summaryformat,
|
||||
c.sortorder, c.startdate, cat.id AS cat_id, cat.name AS cat_name,
|
||||
cat.description AS cat_description, cat.descriptionformat AS cat_descriptionformat,
|
||||
e.cost, e.currency, e.roleid AS defaultroleid, r.name
|
||||
e.cost, e.currency, e.roleid AS defaultroleid, r.name AS defaultrolename
|
||||
FROM {enrol} e
|
||||
INNER JOIN {course} c ON c.id = e.courseid
|
||||
INNER JOIN {course_categories} cat ON cat.id = c.category
|
||||
|
@ -76,7 +77,14 @@ class enrol_mnet_mnetservice_enrol {
|
|||
AND c.visible = 1
|
||||
ORDER BY cat.sortorder, c.sortorder, c.shortname";
|
||||
|
||||
return $DB->get_records_sql($sql, array($client->id));
|
||||
$courses = $DB->get_records_sql($sql, array($client->id));
|
||||
foreach ($courses as $course) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->remoteid);
|
||||
// Rewrite file URLs so that they are correct
|
||||
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary');
|
||||
}
|
||||
|
||||
return array_values($courses); // can not use keys for backward compatibility
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue