Commit 583b02e4 authored by Frederic Massart's avatar Frederic Massart
Browse files

MDL-51664 external: Update usage of external_util::validate_courses

parent 4b11af96
......@@ -181,14 +181,16 @@ class mod_book_external extends external_api {
$params = self::validate_parameters(self::get_books_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the books in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
......
......@@ -523,14 +523,16 @@ class mod_chat_external extends external_api {
$params = self::validate_parameters(self::get_chats_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the chats in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
......
......@@ -480,14 +480,16 @@ class mod_choice_external extends external_api {
$params = self::validate_parameters(self::get_choices_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the choices in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
......
......@@ -60,8 +60,10 @@ class mod_forum_external extends external_api {
$params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Array to store the forums to return.
......@@ -71,7 +73,7 @@ class mod_forum_external extends external_api {
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the forums in this course. This function checks users visibility permissions.
$forums = get_all_instances_in_courses("forum", $courses);
......
......@@ -136,14 +136,16 @@ class mod_imscp_external extends external_api {
$params = self::validate_parameters(self::get_imscps_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the imscps in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
......
......@@ -640,14 +640,16 @@ class mod_scorm_external extends external_api {
$params = self::validate_parameters(self::get_scorms_by_courses_parameters(), array('courseids' => $courseids));
$courses = array();
if (empty($params['courseids'])) {
$params['courseids'] = array_keys(enrol_get_my_courses());
$courses = enrol_get_my_courses();
$params['courseids'] = array_keys($courses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
// Get the scorms in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment