From e200200938063567feaba70f0c04e1e304991b91 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 2 Aug 2016 12:30:10 +0200 Subject: [PATCH] MDL-55415 webservice: Allow validate_courses to return contexts --- lib/externallib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/externallib.php b/lib/externallib.php index ab3346c48be..c05009da85e 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -1098,9 +1098,10 @@ class external_util { * * @param array $courseids A list of course ids * @param array $courses An array of courses already pre-fetched, indexed by course id. + * @param bool $addcontext True if the returned course object should include the full context object. * @return array An array of courses and the validation warnings */ - public static function validate_courses($courseids, $courses = array()) { + public static function validate_courses($courseids, $courses = array(), $addcontext = false) { // Delete duplicates. $courseids = array_unique($courseids); $warnings = array(); @@ -1117,6 +1118,9 @@ class external_util { if (!isset($courses[$cid])) { $courses[$cid] = get_course($cid); } + if ($addcontext) { + $courses[$cid]->context = $context; + } } catch (Exception $e) { unset($courses[$cid]); $warnings[] = array( -- 2.43.0