MDL-40250 phpunit: Add unit tests for core_files_external::upload()
[moodle.git] / enrol / externallib.php
blob64861345266352a58fb6bcbfd9da2811daba2fec
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * External course participation api.
21 * This api is mostly read only, the actual enrol and unenrol
22 * support is in each enrol plugin.
24 * @package core_enrol
25 * @category external
26 * @copyright 2010 Jerome Mouneyrac
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 defined('MOODLE_INTERNAL') || die();
32 require_once("$CFG->libdir/externallib.php");
34 /**
35 * Enrol external functions
37 * @package core_enrol
38 * @category external
39 * @copyright 2011 Jerome Mouneyrac
40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 * @since Moodle 2.2
43 class core_enrol_external extends external_api {
45 /**
46 * Returns description of method parameters
48 * @return external_function_parameters
50 public static function get_users_courses_parameters() {
51 return new external_function_parameters(
52 array(
53 'userid' => new external_value(PARAM_INT, 'user id'),
58 /**
59 * Get list of courses user is enrolled in (only active enrolments are returned).
60 * Please note the current user must be able to access the course, otherwise the course is not included.
62 * @param int $userid
63 * @return array of courses
65 public static function get_users_courses($userid) {
66 global $USER, $DB;
68 // Do basic automatic PARAM checks on incoming data, using params description
69 // If any problems are found then exceptions are thrown with helpful error messages
70 $params = self::validate_parameters(self::get_users_courses_parameters(), array('userid'=>$userid));
72 $courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible');
73 $result = array();
75 foreach ($courses as $course) {
76 $context = get_context_instance(CONTEXT_COURSE, $course->id);
77 try {
78 self::validate_context($context);
79 } catch (Exception $e) {
80 // current user can not access this course, sorry we can not disclose who is enrolled in this course!
81 continue;
84 if ($userid != $USER->id and !has_capability('moodle/course:viewparticipants', $context)) {
85 // we need capability to view participants
86 continue;
89 list($enrolledsqlselect, $enrolledparams) = get_enrolled_sql($context);
90 $enrolledsql = "SELECT COUNT('x') FROM ($enrolledsqlselect) enrolleduserids";
91 $enrolledusercount = $DB->count_records_sql($enrolledsql, $enrolledparams);
93 $result[] = array('id'=>$course->id, 'shortname'=>$course->shortname, 'fullname'=>$course->fullname, 'idnumber'=>$course->idnumber,'visible'=>$course->visible, 'enrolledusercount'=>$enrolledusercount);
96 return $result;
99 /**
100 * Returns description of method result value
102 * @return external_description
104 public static function get_users_courses_returns() {
105 return new external_multiple_structure(
106 new external_single_structure(
107 array(
108 'id' => new external_value(PARAM_INT, 'id of course'),
109 'shortname' => new external_value(PARAM_RAW, 'short name of course'),
110 'fullname' => new external_value(PARAM_RAW, 'long name of course'),
111 'enrolledusercount' => new external_value(PARAM_INT, 'Number of enrolled users in this course'),
112 'idnumber' => new external_value(PARAM_RAW, 'id number of course'),
113 'visible' => new external_value(PARAM_INT, '1 means visible, 0 means hidden course'),
120 * Returns description of method parameters
122 * @return external_function_parameters
124 public static function get_enrolled_users_parameters() {
125 return new external_function_parameters(
126 array(
127 'courseid' => new external_value(PARAM_INT, 'course id'),
128 'options' => new external_multiple_structure(
129 new external_single_structure(
130 array(
131 'name' => new external_value(PARAM_ALPHANUMEXT, 'option name'),
132 'value' => new external_value(PARAM_RAW, 'option value')
134 ), 'Option names:
135 * withcapability (string) return only users with this capability. This option requires \'moodle/role:review\' on the course context.
136 * groupid (integer) return only users in this group id. This option requires \'moodle/site:accessallgroups\' on the course context.
137 * onlyactive (integer) return only users with active enrolments and matching time restrictions. This option requires \'moodle/course:enrolreview\' on the course context.
138 * userfields (\'string, string, ...\') return only the values of these user fields.
139 * limitfrom (integer) sql limit from.
140 * limitnumber (integer) maximum number of returned users.', VALUE_DEFAULT, array()),
146 * Get course participants details
148 * @param int $courseid course id
149 * @param array $options options {
150 * 'name' => option name
151 * 'value' => option value
153 * @return array An array of users
155 public static function get_enrolled_users($courseid, $options = array()) {
156 global $CFG, $USER, $DB;
157 require_once($CFG->dirroot . "/user/lib.php");
159 $params = self::validate_parameters(
160 self::get_enrolled_users_parameters(),
161 array(
162 'courseid'=>$courseid,
163 'options'=>$options
166 $withcapability = '';
167 $groupid = 0;
168 $onlyactive = false;
169 $userfields = array();
170 $limitfrom = 0;
171 $limitnumber = 0;
172 foreach ($options as $option) {
173 switch ($option['name']) {
174 case 'withcapability':
175 $withcapability = $option['value'];
176 break;
177 case 'groupid':
178 $groupid = (int)$option['value'];
179 break;
180 case 'onlyactive':
181 $onlyactive = !empty($option['value']);
182 break;
183 case 'userfields':
184 $thefields = explode(',', $option['value']);
185 foreach ($thefields as $f) {
186 $userfields[] = clean_param($f, PARAM_ALPHANUMEXT);
188 case 'limitfrom' :
189 $limitfrom = clean_param($option['value'], PARAM_INT);
190 break;
191 case 'limitnumber' :
192 $limitnumber = clean_param($option['value'], PARAM_INT);
193 break;
197 $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
198 $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
199 if ($courseid == SITEID) {
200 $context = get_system_context();
201 } else {
202 $context = $coursecontext;
204 try {
205 self::validate_context($context);
206 } catch (Exception $e) {
207 $exceptionparam = new stdClass();
208 $exceptionparam->message = $e->getMessage();
209 $exceptionparam->courseid = $params['courseid'];
210 throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
213 if ($courseid == SITEID) {
214 require_capability('moodle/site:viewparticipants', $context);
215 } else {
216 require_capability('moodle/course:viewparticipants', $context);
218 // to overwrite this parameter, you need role:review capability
219 if ($withcapability) {
220 require_capability('moodle/role:review', $coursecontext);
222 // need accessallgroups capability if you want to overwrite this option
223 if (!empty($groupid) && groups_is_member($groupid)) {
224 require_capability('moodle/site:accessallgroups', $coursecontext);
226 // to overwrite this option, you need course:enrolereview permission
227 if ($onlyactive) {
228 require_capability('moodle/course:enrolreview', $coursecontext);
231 list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
232 list($ctxselect, $ctxjoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx');
233 $sqlparams['courseid'] = $courseid;
234 $sql = "SELECT u.* $ctxselect
235 FROM {user} u $ctxjoin
236 WHERE u.id IN ($enrolledsql)
237 ORDER BY u.id ASC";
238 $enrolledusers = $DB->get_recordset_sql($sql, $enrolledparams, $limitfrom, $limitnumber);
239 $users = array();
240 foreach ($enrolledusers as $user) {
241 context_instance_preload($user);
242 if ($userdetails = user_get_user_details($user, $course, $userfields)) {
243 $users[] = $userdetails;
246 $enrolledusers->close();
248 return $users;
252 * Returns description of method result value
254 * @return external_description
256 public static function get_enrolled_users_returns() {
257 return new external_multiple_structure(
258 new external_single_structure(
259 array(
260 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
261 'username' => new external_value(PARAM_RAW, 'Username policy is defined in Moodle security config', VALUE_OPTIONAL),
262 'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL),
263 'lastname' => new external_value(PARAM_NOTAGS, 'The family name of the user', VALUE_OPTIONAL),
264 'fullname' => new external_value(PARAM_NOTAGS, 'The fullname of the user'),
265 'email' => new external_value(PARAM_TEXT, 'An email address - allow email as root@localhost', VALUE_OPTIONAL),
266 'address' => new external_value(PARAM_MULTILANG, 'Postal address', VALUE_OPTIONAL),
267 'phone1' => new external_value(PARAM_NOTAGS, 'Phone 1', VALUE_OPTIONAL),
268 'phone2' => new external_value(PARAM_NOTAGS, 'Phone 2', VALUE_OPTIONAL),
269 'icq' => new external_value(PARAM_NOTAGS, 'icq number', VALUE_OPTIONAL),
270 'skype' => new external_value(PARAM_NOTAGS, 'skype id', VALUE_OPTIONAL),
271 'yahoo' => new external_value(PARAM_NOTAGS, 'yahoo id', VALUE_OPTIONAL),
272 'aim' => new external_value(PARAM_NOTAGS, 'aim id', VALUE_OPTIONAL),
273 'msn' => new external_value(PARAM_NOTAGS, 'msn number', VALUE_OPTIONAL),
274 'department' => new external_value(PARAM_TEXT, 'department', VALUE_OPTIONAL),
275 'institution' => new external_value(PARAM_TEXT, 'institution', VALUE_OPTIONAL),
276 'idnumber' => new external_value(PARAM_RAW, 'An arbitrary ID code number perhaps from the institution', VALUE_OPTIONAL),
277 'interests' => new external_value(PARAM_TEXT, 'user interests (separated by commas)', VALUE_OPTIONAL),
278 'firstaccess' => new external_value(PARAM_INT, 'first access to the site (0 if never)', VALUE_OPTIONAL),
279 'lastaccess' => new external_value(PARAM_INT, 'last access to the site (0 if never)', VALUE_OPTIONAL),
280 'description' => new external_value(PARAM_RAW, 'User profile description', VALUE_OPTIONAL),
281 'descriptionformat' => new external_format_value('description', VALUE_OPTIONAL),
282 'city' => new external_value(PARAM_NOTAGS, 'Home city of the user', VALUE_OPTIONAL),
283 'url' => new external_value(PARAM_URL, 'URL of the user', VALUE_OPTIONAL),
284 'country' => new external_value(PARAM_ALPHA, 'Home country code of the user, such as AU or CZ', VALUE_OPTIONAL),
285 'profileimageurlsmall' => new external_value(PARAM_URL, 'User image profile URL - small version', VALUE_OPTIONAL),
286 'profileimageurl' => new external_value(PARAM_URL, 'User image profile URL - big version', VALUE_OPTIONAL),
287 'customfields' => new external_multiple_structure(
288 new external_single_structure(
289 array(
290 'type' => new external_value(PARAM_ALPHANUMEXT, 'The type of the custom field - text field, checkbox...'),
291 'value' => new external_value(PARAM_RAW, 'The value of the custom field'),
292 'name' => new external_value(PARAM_RAW, 'The name of the custom field'),
293 'shortname' => new external_value(PARAM_RAW, 'The shortname of the custom field - to be able to build the field class in the code'),
295 ), 'User custom fields (also known as user profil fields)', VALUE_OPTIONAL),
296 'groups' => new external_multiple_structure(
297 new external_single_structure(
298 array(
299 'id' => new external_value(PARAM_INT, 'group id'),
300 'name' => new external_value(PARAM_RAW, 'group name'),
301 'description' => new external_value(PARAM_RAW, 'group description'),
302 'descriptionformat' => new external_format_value('description'),
304 ), 'user groups', VALUE_OPTIONAL),
305 'roles' => new external_multiple_structure(
306 new external_single_structure(
307 array(
308 'roleid' => new external_value(PARAM_INT, 'role id'),
309 'name' => new external_value(PARAM_RAW, 'role name'),
310 'shortname' => new external_value(PARAM_ALPHANUMEXT, 'role shortname'),
311 'sortorder' => new external_value(PARAM_INT, 'role sortorder')
313 ), 'user roles', VALUE_OPTIONAL),
314 'preferences' => new external_multiple_structure(
315 new external_single_structure(
316 array(
317 'name' => new external_value(PARAM_ALPHANUMEXT, 'The name of the preferences'),
318 'value' => new external_value(PARAM_RAW, 'The value of the custom field'),
320 ), 'User preferences', VALUE_OPTIONAL),
321 'enrolledcourses' => new external_multiple_structure(
322 new external_single_structure(
323 array(
324 'id' => new external_value(PARAM_INT, 'Id of the course'),
325 'fullname' => new external_value(PARAM_RAW, 'Fullname of the course'),
326 'shortname' => new external_value(PARAM_RAW, 'Shortname of the course')
328 ), 'Courses where the user is enrolled - limited by which courses the user is able to see', VALUE_OPTIONAL)
337 * Role external functions
339 * @package core_role
340 * @category external
341 * @copyright 2011 Jerome Mouneyrac
342 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
343 * @since Moodle 2.2
345 class core_role_external extends external_api {
348 * Returns description of method parameters
350 * @return external_function_parameters
352 public static function assign_roles_parameters() {
353 return new external_function_parameters(
354 array(
355 'assignments' => new external_multiple_structure(
356 new external_single_structure(
357 array(
358 'roleid' => new external_value(PARAM_INT, 'Role to assign to the user'),
359 'userid' => new external_value(PARAM_INT, 'The user that is going to be assigned'),
360 'contextid' => new external_value(PARAM_INT, 'The context to assign the user role in'),
369 * Manual role assignments to users
371 * @param array $assignments An array of manual role assignment
373 public static function assign_roles($assignments) {
374 global $DB;
376 // Do basic automatic PARAM checks on incoming data, using params description
377 // If any problems are found then exceptions are thrown with helpful error messages
378 $params = self::validate_parameters(self::assign_roles_parameters(), array('assignments'=>$assignments));
380 $transaction = $DB->start_delegated_transaction();
382 foreach ($params['assignments'] as $assignment) {
383 // Ensure the current user is allowed to run this function in the enrolment context
384 $context = get_context_instance_by_id($assignment['contextid']);
385 self::validate_context($context);
386 require_capability('moodle/role:assign', $context);
388 // throw an exception if user is not able to assign the role in this context
389 $roles = get_assignable_roles($context, ROLENAME_SHORT);
391 if (!array_key_exists($assignment['roleid'], $roles)) {
392 throw new invalid_parameter_exception('Can not assign roleid='.$assignment['roleid'].' in contextid='.$assignment['contextid']);
395 role_assign($assignment['roleid'], $assignment['userid'], $assignment['contextid']);
398 $transaction->allow_commit();
402 * Returns description of method result value
404 * @return null
406 public static function assign_roles_returns() {
407 return null;
412 * Returns description of method parameters
414 * @return external_function_parameters
416 public static function unassign_roles_parameters() {
417 return new external_function_parameters(
418 array(
419 'unassignments' => new external_multiple_structure(
420 new external_single_structure(
421 array(
422 'roleid' => new external_value(PARAM_INT, 'Role to assign to the user'),
423 'userid' => new external_value(PARAM_INT, 'The user that is going to be assigned'),
424 'contextid' => new external_value(PARAM_INT, 'The context to unassign the user role from'),
433 * Unassign roles from users
435 * @param array $unassignments An array of unassignment
437 public static function unassign_roles($unassignments) {
438 global $DB;
440 // Do basic automatic PARAM checks on incoming data, using params description
441 // If any problems are found then exceptions are thrown with helpful error messages
442 $params = self::validate_parameters(self::unassign_roles_parameters(), array('unassignments'=>$unassignments));
444 $transaction = $DB->start_delegated_transaction();
446 foreach ($params['unassignments'] as $unassignment) {
447 // Ensure the current user is allowed to run this function in the unassignment context
448 $context = get_context_instance_by_id($unassignment['contextid']);
449 self::validate_context($context);
450 require_capability('moodle/role:assign', $context);
452 // throw an exception if user is not able to unassign the role in this context
453 $roles = get_assignable_roles($context, ROLENAME_SHORT);
454 if (!array_key_exists($unassignment['roleid'], $roles)) {
455 throw new invalid_parameter_exception('Can not unassign roleid='.$unassignment['roleid'].' in contextid='.$unassignment['contextid']);
458 role_unassign($unassignment['roleid'], $unassignment['userid'], $unassignment['contextid']);
461 $transaction->allow_commit();
465 * Returns description of method result value
467 * @return null
469 public static function unassign_roles_returns() {
470 return null;
476 * Deprecated enrol and role external functions
478 * @package core_enrol
479 * @copyright 2010 Jerome Mouneyrac
480 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
481 * @since Moodle 2.0
482 * @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
483 * @todo MDL-31194 This will be deleted in Moodle 2.5.
484 * @see core_enrol_external
485 * @see core_role_external
487 class moodle_enrol_external extends external_api {
491 * Returns description of method parameters
493 * @return external_function_parameters
494 * @since Moodle 2.0
495 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
496 * @todo MDL-31194 This will be deleted in Moodle 2.5.
497 * @see core_enrol_external::get_enrolled_users_parameters()
499 public static function get_enrolled_users_parameters() {
500 return new external_function_parameters(
501 array(
502 'courseid' => new external_value(PARAM_INT, 'Course id'),
503 'withcapability' => new external_value(PARAM_CAPABILITY, 'User should have this capability', VALUE_DEFAULT, null),
504 'groupid' => new external_value(PARAM_INT, 'Group id, null means all groups', VALUE_DEFAULT, null),
505 'onlyactive' => new external_value(PARAM_INT, 'True means only active, false means all participants', VALUE_DEFAULT, 0),
511 * Get list of course participants.
513 * @param int $courseid
514 * @param text $withcapability
515 * @param int $groupid
516 * @param bool $onlyactive
517 * @return array of course participants
518 * @since Moodle 2.0
519 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
520 * @todo MDL-31194 This will be deleted in Moodle 2.5.
521 * @see core_enrol_external::get_enrolled_users()
523 public static function get_enrolled_users($courseid, $withcapability = null, $groupid = null, $onlyactive = false) {
524 global $DB, $CFG, $USER;
526 // Do basic automatic PARAM checks on incoming data, using params description
527 // If any problems are found then exceptions are thrown with helpful error messages
528 $params = self::validate_parameters(self::get_enrolled_users_parameters(), array(
529 'courseid'=>$courseid,
530 'withcapability'=>$withcapability,
531 'groupid'=>$groupid,
532 'onlyactive'=>$onlyactive)
535 $coursecontext = get_context_instance(CONTEXT_COURSE, $params['courseid']);
536 if ($courseid == SITEID) {
537 $context = get_context_instance(CONTEXT_SYSTEM);
538 } else {
539 $context = $coursecontext;
542 try {
543 self::validate_context($context);
544 } catch (Exception $e) {
545 $exceptionparam = new stdClass();
546 $exceptionparam->message = $e->getMessage();
547 $exceptionparam->courseid = $params['courseid'];
548 throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
551 if ($courseid == SITEID) {
552 require_capability('moodle/site:viewparticipants', $context);
553 } else {
554 require_capability('moodle/course:viewparticipants', $context);
557 if ($withcapability) {
558 require_capability('moodle/role:review', $coursecontext);
560 if ($groupid && groups_is_member($groupid)) {
561 require_capability('moodle/site:accessallgroups', $coursecontext);
563 if ($onlyactive) {
564 require_capability('moodle/course:enrolreview', $coursecontext);
567 list($sqlparams, $params) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
568 $sql = "SELECT ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id as usercontextid
569 FROM {user_enrolments} ue
570 JOIN {enrol} e ON (e.id = ue.enrolid)
571 JOIN {user} u ON (ue.userid = u.id)
572 JOIN {context} c ON (u.id = c.instanceid AND contextlevel = " . CONTEXT_USER . ")
573 WHERE e.courseid = :courseid AND ue.userid IN ($sqlparams)
574 GROUP BY ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id";
575 $params['courseid'] = $courseid;
576 $enrolledusers = $DB->get_records_sql($sql, $params);
577 $result = array();
578 $isadmin = is_siteadmin($USER);
579 $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
580 foreach ($enrolledusers as $enrolleduser) {
581 $profilimgurl = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f1');
582 $profilimgurlsmall = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f2');
583 $resultuser = array(
584 'courseid' => $enrolleduser->courseid,
585 'userid' => $enrolleduser->userid,
586 'fullname' => fullname($enrolleduser),
587 'profileimgurl' => $profilimgurl->out(false),
588 'profileimgurlsmall' => $profilimgurlsmall->out(false)
590 // check if we can return username
591 if ($isadmin) {
592 $resultuser['username'] = $enrolleduser->username;
594 // check if we can return first and last name
595 if ($isadmin or $canviewfullnames) {
596 $resultuser['firstname'] = $enrolleduser->firstname;
597 $resultuser['lastname'] = $enrolleduser->lastname;
599 $result[] = $resultuser;
602 return $result;
606 * Returns description of method result value
608 * @return external_description
609 * @since Moodle 2.0
610 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
611 * @todo MDL-31194 This will be deleted in Moodle 2.5.
612 * @see core_enrol_external::get_enrolled_users_returns()
614 public static function get_enrolled_users_returns() {
615 return new external_multiple_structure(
616 new external_single_structure(
617 array(
618 'courseid' => new external_value(PARAM_INT, 'id of course'),
619 'userid' => new external_value(PARAM_INT, 'id of user'),
620 'firstname' => new external_value(PARAM_RAW, 'first name of user', VALUE_OPTIONAL),
621 'lastname' => new external_value(PARAM_RAW, 'last name of user', VALUE_OPTIONAL),
622 'fullname' => new external_value(PARAM_RAW, 'fullname of user'),
623 'username' => new external_value(PARAM_RAW, 'username of user', VALUE_OPTIONAL),
624 'profileimgurl' => new external_value(PARAM_URL, 'url of the profile image'),
625 'profileimgurlsmall' => new external_value(PARAM_URL, 'url of the profile image (small version)')
632 * Returns description of method parameters
634 * @return external_function_parameters
635 * @since Moodle 2.1
636 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
637 * @todo MDL-31194 This will be deleted in Moodle 2.5.
638 * @see core_enrol_external::get_users_courses_parameters()
640 public static function get_users_courses_parameters() {
641 return core_enrol_external::get_users_courses_parameters();
645 * Get list of courses user is enrolled in (only active enrolments are returned).
646 * Please note the current user must be able to access the course, otherwise the course is not included.
648 * @param int $userid
649 * @return array of courses
650 * @since Moodle 2.1
651 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
652 * @todo MDL-31194 This will be deleted in Moodle 2.5.
653 * @see use core_enrol_external::get_users_courses()
655 public static function get_users_courses($userid) {
656 return core_enrol_external::get_users_courses($userid);
660 * Returns description of method result value
662 * @return external_description
663 * @since Moodle 2.1
664 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
665 * @todo MDL-31194 This will be deleted in Moodle 2.5.
666 * @see core_enrol_external::get_users_courses_returns()
668 public static function get_users_courses_returns() {
669 return core_enrol_external::get_users_courses_returns();
674 * Returns description of method parameters
676 * @return external_function_parameters
677 * @since Moodle 2.0
678 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
679 * @todo MDL-31194 This will be deleted in Moodle 2.5.
680 * @see core_role_external::assign_roles_parameters()
682 public static function role_assign_parameters() {
683 return core_role_external::assign_roles_parameters();
687 * Manual role assignments to users
689 * @param array $assignments An array of manual role assignment
690 * @since Moodle 2.0
691 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
692 * @todo MDL-31194 This will be deleted in Moodle 2.5.
693 * @see core_role_external::assign_roles()
695 public static function role_assign($assignments) {
696 return core_role_external::assign_roles($assignments);
700 * Returns description of method result value
702 * @return null
703 * @since Moodle 2.0
704 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
705 * @todo MDL-31194 This will be deleted in Moodle 2.5.
706 * @see core_role_external::assign_roles_returns()
708 public static function role_assign_returns() {
709 return core_role_external::assign_roles_returns();
714 * Returns description of method parameters
716 * @return external_function_parameters
717 * @since Moodle 2.0
718 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
719 * @todo MDL-31194 This will be deleted in Moodle 2.5.
720 * @see core_role_external::unassign_roles_parameters()
722 public static function role_unassign_parameters() {
723 return core_role_external::unassign_roles_parameters();
727 * Unassign roles from users
729 * @param array $unassignments An array of unassignment
730 * @since Moodle 2.0
731 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
732 * @todo MDL-31194 This will be deleted in Moodle 2.5.
733 * @see core_role_external::unassign_roles()
735 public static function role_unassign($unassignments) {
736 return core_role_external::unassign_roles($unassignments);
740 * Returns description of method result value
742 * @return null
743 * @since Moodle 2.0
744 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
745 * @todo MDL-31194 This will be deleted in Moodle 2.5.
746 * @see core_role_external::unassign_roles_returns()
748 public static function role_unassign_returns() {
749 return core_role_external::unassign_roles_returns();