weekly release 2.3dev
[moodle.git] / group / externallib.php
CommitLineData
9a0df45a 1<?php
9a0df45a 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.
13//
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/>.
16
4615817d 17
9a0df45a 18/**
19 * External groups API
20 *
4d8e2417 21 * @package core_group
4615817d
JM
22 * @category external
23 * @copyright 2009 Petr Skodak
9a0df45a 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27require_once("$CFG->libdir/externallib.php");
28
5d1017e1 29/**
4615817d 30 * Group external functions
4d8e2417
AG
31 *
32 * @package core_group
4615817d
JM
33 * @category external
34 * @copyright 2011 Jerome Mouneyrac
4d8e2417 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4615817d 36 * @since Moodle 2.2
5d1017e1
JM
37 */
38class core_group_external extends external_api {
9a0df45a 39
0c96468c 40 /**
41 * Returns description of method parameters
4615817d 42 *
f5072177 43 * @return external_function_parameters
4615817d 44 * @since Moodle 2.2
0c96468c 45 */
46 public static function create_groups_parameters() {
f5072177 47 return new external_function_parameters(
48 array(
49 'groups' => new external_multiple_structure(
50 new external_single_structure(
51 array(
52 'courseid' => new external_value(PARAM_INT, 'id of course'),
53 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
54 'description' => new external_value(PARAM_RAW, 'group description text'),
55 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
56 )
d4c6ef70 57 ), 'List of group object. A group has a courseid, a name, a description and an enrolment key.'
f5072177 58 )
59 )
60 );
0c96468c 61 }
62
63 /**
9a0df45a 64 * Create groups
4615817d 65 *
b4c1a34e 66 * @param array $groups array of group description arrays (with keys groupname and courseid)
f5072177 67 * @return array of newly created groups
4615817d 68 * @since Moodle 2.2
9a0df45a 69 */
b4c1a34e 70 public static function create_groups($groups) {
f5072177 71 global $CFG, $DB;
9a0df45a 72 require_once("$CFG->dirroot/group/lib.php");
73
c9c5cc81 74 $params = self::validate_parameters(self::create_groups_parameters(), array('groups'=>$groups));
0c96468c 75
d5a8d9aa
PS
76 $transaction = $DB->start_delegated_transaction();
77
78 $groups = array();
79
80 foreach ($params['groups'] as $group) {
81 $group = (object)$group;
82
83 if (trim($group->name) == '') {
84 throw new invalid_parameter_exception('Invalid group name');
85 }
86 if ($DB->get_record('groups', array('courseid'=>$group->courseid, 'name'=>$group->name))) {
87 throw new invalid_parameter_exception('Group with the same name already exists in the course');
ab9a01f2 88 }
d5a8d9aa
PS
89
90 // now security checks
91 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 92 try {
93 self::validate_context($context);
94 } catch (Exception $e) {
95 $exceptionparam = new stdClass();
96 $exceptionparam->message = $e->getMessage();
97 $exceptionparam->courseid = $group->courseid;
98 throw new moodle_exception(
99 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
100 }
d5a8d9aa
PS
101 require_capability('moodle/course:managegroups', $context);
102
103 // finally create the group
104 $group->id = groups_create_group($group, false);
105 $groups[] = (array)$group;
9a0df45a 106 }
d5a8d9aa
PS
107
108 $transaction->allow_commit();
9a0df45a 109
2e13b916 110 return $groups;
9a0df45a 111 }
112
4d8e2417 113 /**
0c96468c 114 * Returns description of method result value
4615817d
JM
115 *
116 * @return external_description
117 * @since Moodle 2.2
0c96468c 118 */
119 public static function create_groups_returns() {
f5072177 120 return new external_multiple_structure(
121 new external_single_structure(
122 array(
123 'id' => new external_value(PARAM_INT, 'group record id'),
124 'courseid' => new external_value(PARAM_INT, 'id of course'),
125 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
126 'description' => new external_value(PARAM_RAW, 'group description text'),
127 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
128 )
d4c6ef70 129 ), 'List of group object. A group has an id, a courseid, a name, a description and an enrolment key.'
f5072177 130 );
0c96468c 131 }
132
f5072177 133 /**
134 * Returns description of method parameters
4615817d 135 *
f5072177 136 * @return external_function_parameters
4615817d 137 * @since Moodle 2.2
f5072177 138 */
0c96468c 139 public static function get_groups_parameters() {
8c772ad7 140 return new external_function_parameters(
141 array(
d4c6ef70 142 'groupids' => new external_multiple_structure(new external_value(PARAM_INT, 'Group ID')
143 ,'List of group id. A group id is an integer.'),
8c772ad7 144 )
145 );
0c96468c 146 }
147
9a0df45a 148 /**
246f6da2 149 * Get groups definition specified by ids
4615817d 150 *
b4c1a34e 151 * @param array $groupids arrays of group ids
9a0df45a 152 * @return array of group objects (id, courseid, name, enrolmentkey)
4615817d 153 * @since Moodle 2.2
9a0df45a 154 */
b4c1a34e 155 public static function get_groups($groupids) {
c9c5cc81 156 $params = self::validate_parameters(self::get_groups_parameters(), array('groupids'=>$groupids));
0c96468c 157
246f6da2 158 $groups = array();
0c96468c 159 foreach ($params['groupids'] as $groupid) {
ab9a01f2 160 // validate params
ab9a01f2 161 $group = groups_get_group($groupid, 'id, courseid, name, description, enrolmentkey', MUST_EXIST);
162
9a0df45a 163 // now security checks
164 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 165 try {
166 self::validate_context($context);
167 } catch (Exception $e) {
168 $exceptionparam = new stdClass();
169 $exceptionparam->message = $e->getMessage();
170 $exceptionparam->courseid = $group->courseid;
171 throw new moodle_exception(
172 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
173 }
9a0df45a 174 require_capability('moodle/course:managegroups', $context);
175
2e13b916 176 $groups[] = (array)$group;
9a0df45a 177 }
178
179 return $groups;
180 }
181
4d8e2417 182 /**
f5072177 183 * Returns description of method result value
4615817d
JM
184 *
185 * @return external_description
186 * @since Moodle 2.2
f5072177 187 */
0c96468c 188 public static function get_groups_returns() {
246f6da2 189 return new external_multiple_structure(
190 new external_single_structure(
191 array(
192 'id' => new external_value(PARAM_INT, 'group record id'),
193 'courseid' => new external_value(PARAM_INT, 'id of course'),
194 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
195 'description' => new external_value(PARAM_RAW, 'group description text'),
196 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
197 )
198 )
199 );
200 }
201
202 /**
203 * Returns description of method parameters
4615817d 204 *
246f6da2 205 * @return external_function_parameters
4615817d 206 * @since Moodle 2.2
246f6da2 207 */
208 public static function get_course_groups_parameters() {
209 return new external_function_parameters(
210 array(
211 'courseid' => new external_value(PARAM_INT, 'id of course'),
212 )
213 );
214 }
215
216 /**
217 * Get all groups in the specified course
4615817d 218 *
246f6da2 219 * @param int $courseid id of course
220 * @return array of group objects (id, courseid, name, enrolmentkey)
4615817d 221 * @since Moodle 2.2
246f6da2 222 */
223 public static function get_course_groups($courseid) {
224 $params = self::validate_parameters(self::get_course_groups_parameters(), array('courseid'=>$courseid));
225
226 // now security checks
227 $context = get_context_instance(CONTEXT_COURSE, $params['courseid']);
41e962ff 228 try {
229 self::validate_context($context);
230 } catch (Exception $e) {
231 $exceptionparam = new stdClass();
232 $exceptionparam->message = $e->getMessage();
233 $exceptionparam->courseid = $params['courseid'];
234 throw new moodle_exception(
235 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
236 }
246f6da2 237 require_capability('moodle/course:managegroups', $context);
238
239 $gs = groups_get_all_groups($params['courseid'], 0, 0, 'g.id, g.courseid, g.name, g.description, g.enrolmentkey');
240
241 $groups = array();
242 foreach ($gs as $group) {
243 $groups[] = (array)$group;
244 }
245
246 return $groups;
247 }
248
4d8e2417 249 /**
246f6da2 250 * Returns description of method result value
4615817d
JM
251 *
252 * @return external_description
253 * @since Moodle 2.2
246f6da2 254 */
255 public static function get_course_groups_returns() {
8c772ad7 256 return new external_multiple_structure(
257 new external_single_structure(
258 array(
f5072177 259 'id' => new external_value(PARAM_INT, 'group record id'),
260 'courseid' => new external_value(PARAM_INT, 'id of course'),
04d212ce 261 'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
f5072177 262 'description' => new external_value(PARAM_RAW, 'group description text'),
263 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
8c772ad7 264 )
265 )
266 );
0c96468c 267 }
268
0f4e72de
PS
269 /**
270 * Returns description of method parameters
4615817d 271 *
0f4e72de 272 * @return external_function_parameters
4615817d 273 * @since Moodle 2.2
0f4e72de 274 */
0c96468c 275 public static function delete_groups_parameters() {
0f4e72de
PS
276 return new external_function_parameters(
277 array(
278 'groupids' => new external_multiple_structure(new external_value(PARAM_INT, 'Group ID')),
279 )
280 );
0c96468c 281 }
282
9a0df45a 283 /**
284 * Delete groups
4615817d 285 *
b4c1a34e 286 * @param array $groupids array of group ids
4615817d 287 * @since Moodle 2.2
9a0df45a 288 */
b4c1a34e 289 public static function delete_groups($groupids) {
2cb1ee78 290 global $CFG, $DB;
9a0df45a 291 require_once("$CFG->dirroot/group/lib.php");
292
c9c5cc81 293 $params = self::validate_parameters(self::delete_groups_parameters(), array('groupids'=>$groupids));
0c96468c 294
d5a8d9aa
PS
295 $transaction = $DB->start_delegated_transaction();
296
d5a8d9aa
PS
297 foreach ($params['groupids'] as $groupid) {
298 // validate params
299 $groupid = validate_param($groupid, PARAM_INTEGER);
300 if (!$group = groups_get_group($groupid, 'id, courseid', IGNORE_MISSING)) {
301 // silently ignore attempts to delete nonexisting groups
302 continue;
0f4e72de 303 }
d5a8d9aa
PS
304
305 // now security checks
306 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 307 try {
308 self::validate_context($context);
309 } catch (Exception $e) {
310 $exceptionparam = new stdClass();
311 $exceptionparam->message = $e->getMessage();
312 $exceptionparam->courseid = $group->courseid;
313 throw new moodle_exception(
314 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
315 }
d5a8d9aa
PS
316 require_capability('moodle/course:managegroups', $context);
317
318 groups_delete_group($group);
9a0df45a 319 }
d5a8d9aa
PS
320
321 $transaction->allow_commit();
9a0df45a 322 }
323
4d8e2417 324 /**
0f4e72de 325 * Returns description of method result value
4615817d
JM
326 *
327 * @return null
328 * @since Moodle 2.2
0f4e72de 329 */
0c96468c 330 public static function delete_groups_returns() {
0f4e72de 331 return null;
0c96468c 332 }
333
334
0f4e72de
PS
335 /**
336 * Returns description of method parameters
4615817d 337 *
0f4e72de 338 * @return external_function_parameters
4615817d 339 * @since Moodle 2.2
0f4e72de 340 */
5d1017e1 341 public static function get_group_members_parameters() {
0f4e72de
PS
342 return new external_function_parameters(
343 array(
344 'groupids' => new external_multiple_structure(new external_value(PARAM_INT, 'Group ID')),
345 )
346 );
0c96468c 347 }
9a0df45a 348
349 /**
350 * Return all members for a group
4615817d 351 *
b4c1a34e 352 * @param array $groupids array of group ids
9a0df45a 353 * @return array with group id keys containing arrays of user ids
4615817d 354 * @since Moodle 2.2
9a0df45a 355 */
5d1017e1 356 public static function get_group_members($groupids) {
0f4e72de 357 $members = array();
9a0df45a 358
5d1017e1 359 $params = self::validate_parameters(self::get_group_members_parameters(), array('groupids'=>$groupids));
0c96468c 360
361 foreach ($params['groupids'] as $groupid) {
ab9a01f2 362 // validate params
9a0df45a 363 $group = groups_get_group($groupid, 'id, courseid, name, enrolmentkey', MUST_EXIST);
364 // now security checks
365 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 366 try {
367 self::validate_context($context);
368 } catch (Exception $e) {
369 $exceptionparam = new stdClass();
370 $exceptionparam->message = $e->getMessage();
371 $exceptionparam->courseid = $group->courseid;
372 throw new moodle_exception(
373 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
374 }
9a0df45a 375 require_capability('moodle/course:managegroups', $context);
376
377 $groupmembers = groups_get_members($group->id, 'u.id', 'lastname ASC, firstname ASC');
378
0f4e72de 379 $members[] = array('groupid'=>$groupid, 'userids'=>array_keys($groupmembers));
9a0df45a 380 }
381
0f4e72de 382 return $members;
9a0df45a 383 }
384
4d8e2417 385 /**
0f4e72de 386 * Returns description of method result value
4615817d 387 *
0f4e72de 388 * @return external_description
4615817d 389 * @since Moodle 2.2
0f4e72de 390 */
5d1017e1 391 public static function get_group_members_returns() {
0f4e72de
PS
392 return new external_multiple_structure(
393 new external_single_structure(
394 array(
395 'groupid' => new external_value(PARAM_INT, 'group record id'),
396 'userids' => new external_multiple_structure(new external_value(PARAM_INT, 'user id')),
397 )
398 )
399 );
0c96468c 400 }
401
402
0f4e72de
PS
403 /**
404 * Returns description of method parameters
4615817d 405 *
0f4e72de 406 * @return external_function_parameters
4615817d 407 * @since Moodle 2.2
0f4e72de 408 */
5d1017e1 409 public static function add_group_members_parameters() {
4efa2483
PS
410 return new external_function_parameters(
411 array(
412 'members'=> new external_multiple_structure(
413 new external_single_structure(
414 array(
415 'groupid' => new external_value(PARAM_INT, 'group record id'),
416 'userid' => new external_value(PARAM_INT, 'user id'),
417 )
418 )
0f4e72de
PS
419 )
420 )
421 );
0c96468c 422 }
9a0df45a 423
424 /**
425 * Add group members
4615817d 426 *
b4c1a34e 427 * @param array $members of arrays with keys userid, groupid
4615817d 428 * @since Moodle 2.2
9a0df45a 429 */
5d1017e1 430 public static function add_group_members($members) {
2cb1ee78 431 global $CFG, $DB;
9a0df45a 432 require_once("$CFG->dirroot/group/lib.php");
433
5d1017e1 434 $params = self::validate_parameters(self::add_group_members_parameters(), array('members'=>$members));
9a0df45a 435
d5a8d9aa 436 $transaction = $DB->start_delegated_transaction();
d5a8d9aa
PS
437 foreach ($params['members'] as $member) {
438 // validate params
439 $groupid = $member['groupid'];
440 $userid = $member['userid'];
0c96468c 441
d5a8d9aa
PS
442 $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
443 $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0, 'mnethostid'=>$CFG->mnet_localhost_id), '*', MUST_EXIST);
9a0df45a 444
d5a8d9aa
PS
445 // now security checks
446 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 447 try {
448 self::validate_context($context);
449 } catch (Exception $e) {
450 $exceptionparam = new stdClass();
451 $exceptionparam->message = $e->getMessage();
452 $exceptionparam->courseid = $group->courseid;
453 throw new moodle_exception(
454 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
455 }
d5a8d9aa 456 require_capability('moodle/course:managegroups', $context);
9a0df45a 457
d5a8d9aa 458 // now make sure user is enrolled in course - this is mandatory requirement,
4f0c2d00
PS
459 // unfortunately this is slow
460 if (!is_enrolled($context, $userid)) {
461 throw new invalid_parameter_exception('Only enrolled users may be members of groups');
462 }
4efa2483 463
d5a8d9aa 464 groups_add_member($group, $user);
9a0df45a 465 }
d5a8d9aa
PS
466
467 $transaction->allow_commit();
9a0df45a 468 }
469
4d8e2417 470 /**
0f4e72de 471 * Returns description of method result value
4615817d 472 *
5d1017e1 473 * @return null
4615817d 474 * @since Moodle 2.2
0f4e72de 475 */
5d1017e1 476 public static function add_group_members_returns() {
0f4e72de 477 return null;
0c96468c 478 }
479
480
0f4e72de
PS
481 /**
482 * Returns description of method parameters
4615817d 483 *
0f4e72de 484 * @return external_function_parameters
4615817d 485 * @since Moodle 2.2
0f4e72de 486 */
5d1017e1 487 public static function delete_group_members_parameters() {
4efa2483
PS
488 return new external_function_parameters(
489 array(
490 'members'=> new external_multiple_structure(
491 new external_single_structure(
492 array(
493 'groupid' => new external_value(PARAM_INT, 'group record id'),
494 'userid' => new external_value(PARAM_INT, 'user id'),
495 )
496 )
0f4e72de
PS
497 )
498 )
499 );
0c96468c 500 }
9a0df45a 501
502 /**
503 * Delete group members
4615817d 504 *
b4c1a34e 505 * @param array $members of arrays with keys userid, groupid
4615817d 506 * @since Moodle 2.2
9a0df45a 507 */
5d1017e1 508 public static function delete_group_members($members) {
2cb1ee78 509 global $CFG, $DB;
9a0df45a 510 require_once("$CFG->dirroot/group/lib.php");
511
5d1017e1 512 $params = self::validate_parameters(self::delete_group_members_parameters(), array('members'=>$members));
9a0df45a 513
d5a8d9aa
PS
514 $transaction = $DB->start_delegated_transaction();
515
0c96468c 516 foreach ($params['members'] as $member) {
d5a8d9aa
PS
517 // validate params
518 $groupid = $member['groupid'];
519 $userid = $member['userid'];
0c96468c 520
d5a8d9aa
PS
521 $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
522 $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0, 'mnethostid'=>$CFG->mnet_localhost_id), '*', MUST_EXIST);
9a0df45a 523
d5a8d9aa
PS
524 // now security checks
525 $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
41e962ff 526 try {
527 self::validate_context($context);
528 } catch (Exception $e) {
529 $exceptionparam = new stdClass();
530 $exceptionparam->message = $e->getMessage();
531 $exceptionparam->courseid = $group->courseid;
532 throw new moodle_exception(
533 get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
534 }
d5a8d9aa 535 require_capability('moodle/course:managegroups', $context);
9a0df45a 536
d5a8d9aa 537 groups_remove_member($group, $user);
9a0df45a 538 }
d5a8d9aa
PS
539
540 $transaction->allow_commit();
9a0df45a 541 }
542
4d8e2417 543 /**
0f4e72de 544 * Returns description of method result value
4615817d 545 *
5d1017e1 546 * @return null
4615817d 547 * @since Moodle 2.2
0f4e72de 548 */
5d1017e1 549 public static function delete_group_members_returns() {
0f4e72de 550 return null;
0c96468c 551 }
552
4ca6cfbf 553}
5d1017e1
JM
554
555/**
4615817d
JM
556 * Deprecated group external functions
557 *
558 * @package core_group
559 * @copyright 2009 Petr Skodak
560 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
561 * @since Moodle 2.0
562 * @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
563 * @todo MDL-31194 This will be deleted in Moodle 2.5.
564 * @see core_group_external
5d1017e1
JM
565 */
566class moodle_group_external extends external_api {
567
568 /**
569 * Returns description of method parameters
4615817d 570 *
5d1017e1 571 * @return external_function_parameters
4615817d
JM
572 * @since Moodle 2.0
573 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
574 * @todo MDL-31194 This will be deleted in Moodle 2.5.
575 * @see core_group_external::create_groups_parameters()
5d1017e1
JM
576 */
577 public static function create_groups_parameters() {
578 return core_group_external::create_groups_parameters();
579 }
580
581 /**
582 * Create groups
4615817d 583 *
5d1017e1
JM
584 * @param array $groups array of group description arrays (with keys groupname and courseid)
585 * @return array of newly created groups
4615817d
JM
586 * @since Moodle 2.0
587 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
588 * @todo MDL-31194 This will be deleted in Moodle 2.5.
589 * @see use core_group_external::create_groups()
5d1017e1
JM
590 */
591 public static function create_groups($groups) {
592 return core_group_external::create_groups($groups);
593 }
594
e757f518
EL
595 /**
596 * Returns description of method result value
4615817d 597 *
e757f518 598 * @return external_description
4615817d
JM
599 * @since Moodle 2.0
600 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
601 * @todo MDL-31194 This will be deleted in Moodle 2.5.
602 * @see core_group_external::create_groups_returns()
e757f518 603 */
5d1017e1
JM
604 public static function create_groups_returns() {
605 return core_group_external::create_groups_returns();
606 }
607
608 /**
609 * Returns description of method parameters
4615817d 610 *
5d1017e1 611 * @return external_function_parameters
4615817d
JM
612 * @since Moodle 2.0
613 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
614 * @todo MDL-31194 This will be deleted in Moodle 2.5.
615 * @see core_group_external::get_groups_parameters()
5d1017e1
JM
616 */
617 public static function get_groups_parameters() {
618 return core_group_external::get_groups_parameters();
619 }
620
621 /**
622 * Get groups definition specified by ids
4615817d 623 *
5d1017e1
JM
624 * @param array $groupids arrays of group ids
625 * @return array of group objects (id, courseid, name, enrolmentkey)
4615817d
JM
626 * @since Moodle 2.0
627 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
628 * @todo MDL-31194 This will be deleted in Moodle 2.5.
629 * @see core_group_external::get_groups()
5d1017e1
JM
630 */
631 public static function get_groups($groupids) {
632 return core_group_external::get_groups($groupids);
633 }
634
e757f518
EL
635 /**
636 * Returns description of method result value
4615817d 637 *
e757f518 638 * @return external_description
4615817d
JM
639 * @since Moodle 2.0
640 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
641 * @todo MDL-31194 This will be deleted in Moodle 2.5.
642 * @see core_group_external::get_groups_returns()
e757f518 643 */
5d1017e1
JM
644 public static function get_groups_returns() {
645 return core_group_external::get_groups_returns();
646 }
647
e757f518
EL
648 /**
649 * Returns description of method parameters
4615817d 650 *
e757f518 651 * @return external_function_parameters
4615817d
JM
652 * @since Moodle 2.0
653 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
654 * @todo MDL-31194 This will be deleted in Moodle 2.5.
655 * @see core_group_external::get_course_groups_parameters()
e757f518 656 */
5d1017e1
JM
657 public static function get_course_groups_parameters() {
658 return core_group_external::get_course_groups_parameters();
659 }
660
e757f518
EL
661 /**
662 * Get all groups in the specified course
4615817d 663 *
e757f518
EL
664 * @param int $courseid id of course
665 * @return array of group objects (id, courseid, name, enrolmentkey)
4615817d
JM
666 * @since Moodle 2.0
667 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
668 * @todo MDL-31194 This will be deleted in Moodle 2.5.
669 * @see core_group_external::get_course_groups()
e757f518 670 */
5d1017e1
JM
671 public static function get_course_groups($courseid) {
672 return core_group_external::get_course_groups($courseid);
673 }
674
e757f518
EL
675 /**
676 * Returns description of method result value
4615817d 677 *
e757f518 678 * @return external_description
4615817d
JM
679 * @since Moodle 2.0
680 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
681 * @todo MDL-31194 This will be deleted in Moodle 2.5.
682 * @see core_group_external::get_course_groups_returns()
e757f518 683 */
5d1017e1
JM
684 public static function get_course_groups_returns() {
685 return core_group_external::get_course_groups_returns();
686 }
687
688 /**
689 * Returns description of method parameters
4615817d 690 *
5d1017e1 691 * @return external_function_parameters
4615817d
JM
692 * @since Moodle 2.0
693 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
694 * @todo MDL-31194 This will be deleted in Moodle 2.5.
695 * @see core_group_external::delete_group_members_parameters()
5d1017e1
JM
696 */
697 public static function delete_groups_parameters() {
698 return core_group_external::delete_group_members_parameters();
699 }
700
701 /**
702 * Delete groups
4615817d 703 *
5d1017e1 704 * @param array $groupids array of group ids
4615817d
JM
705 * @since Moodle 2.0
706 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
707 * @todo MDL-31194 This will be deleted in Moodle 2.5.
708 * @see core_group_external::delete_groups()
5d1017e1
JM
709 */
710 public static function delete_groups($groupids) {
711 return core_group_external::delete_groups($groupids);
712 }
713
e757f518
EL
714 /**
715 * Returns description of method result value
4615817d
JM
716 *
717 * @return null
718 * @since Moodle 2.0
719 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
720 * @todo MDL-31194 This will be deleted in Moodle 2.5.
e757f518 721 * @see core_group_external::delete_group_members_returns()
e757f518 722 */
5d1017e1
JM
723 public static function delete_groups_returns() {
724 return core_group_external::delete_group_members_returns();
725 }
726
727
728 /**
729 * Returns description of method parameters
4615817d 730 *
5d1017e1 731 * @return external_function_parameters
4615817d
JM
732 * @since Moodle 2.0
733 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
734 * @todo MDL-31194 This will be deleted in Moodle 2.5.
735 * @see core_group_external::get_group_members_parameters()
5d1017e1
JM
736 */
737 public static function get_groupmembers_parameters() {
738 return core_group_external::get_group_members_parameters();
739 }
740
741 /**
742 * Return all members for a group
4615817d 743 *
5d1017e1
JM
744 * @param array $groupids array of group ids
745 * @return array with group id keys containing arrays of user ids
4615817d
JM
746 * @since Moodle 2.0
747 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
748 * @todo MDL-31194 This will be deleted in Moodle 2.5.
749 * @see core_group_external::get_group_members()
5d1017e1
JM
750 */
751 public static function get_groupmembers($groupids) {
752 return core_group_external::get_group_members($groupids);
753 }
754
e757f518
EL
755 /**
756 * Returns description of method result value
4615817d 757 *
e757f518 758 * @return external_description
4615817d
JM
759 * @since Moodle 2.0
760 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
761 * @todo MDL-31194 This will be deleted in Moodle 2.5.
762 * @see core_group_external::get_group_members_returns()
e757f518 763 */
5d1017e1
JM
764 public static function get_groupmembers_returns() {
765 return core_group_external::get_group_members_returns();
766 }
767
768
769 /**
770 * Returns description of method parameters
4615817d 771 *
5d1017e1 772 * @return external_function_parameters
4615817d
JM
773 * @since Moodle 2.0
774 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
775 * @todo MDL-31194 This will be deleted in Moodle 2.5.
776 * @see core_group_external::add_group_members_parameters()
5d1017e1
JM
777 */
778 public static function add_groupmembers_parameters() {
779 return core_group_external::add_group_members_parameters();
780 }
781
782 /**
783 * Add group members
4615817d 784 *
5d1017e1 785 * @param array $members of arrays with keys userid, groupid
4615817d
JM
786 * @since Moodle 2.0
787 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
788 * @todo MDL-31194 This will be deleted in Moodle 2.5.
789 * @see use core_group_external::add_group_members()
5d1017e1
JM
790 */
791 public static function add_groupmembers($members) {
792 return core_group_external::add_group_members($members);
793 }
794
e757f518
EL
795 /**
796 * Returns description of method result value
4615817d 797 *
e757f518 798 * @return external_description
4615817d
JM
799 * @since Moodle 2.0
800 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
801 * @todo MDL-31194 This will be deleted in Moodle 2.5.
802 * @see core_group_external::add_group_members_returns()
e757f518 803 */
5d1017e1
JM
804 public static function add_groupmembers_returns() {
805 return core_group_external::add_group_members_returns();
806 }
807
808
809 /**
810 * Returns description of method parameters
4615817d 811 *
5d1017e1 812 * @return external_function_parameters
4615817d
JM
813 * @since Moodle 2.0
814 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
815 * @todo MDL-31194 This will be deleted in Moodle 2.5.
816 * @see core_group_external::delete_group_members_parameters()
5d1017e1
JM
817 */
818 public static function delete_groupmembers_parameters() {
819 return core_group_external::delete_group_members_parameters();
820 }
821
822 /**
823 * Delete group members
4615817d 824 *
5d1017e1 825 * @param array $members of arrays with keys userid, groupid
4615817d
JM
826 * @since Moodle 2.0
827 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
828 * @todo MDL-31194 This will be deleted in Moodle 2.5.
829 * @see core_group_external::delete_group_members()
5d1017e1
JM
830 */
831 public static function delete_groupmembers($members) {
832 return core_group_external::delete_group_members($members);
833 }
834
e757f518
EL
835 /**
836 * Returns description of method result value
4615817d 837 *
e757f518 838 * @return external_description
4615817d
JM
839 * @since Moodle 2.0
840 * @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
841 * @todo MDL-31194 This will be deleted in Moodle 2.5.
842 * @see core_group_external::delete_group_members_returns()
e757f518 843 */
5d1017e1
JM
844 public static function delete_groupmembers_returns() {
845 return core_group_external::delete_group_members_returns();
846 }
847
e757f518 848}