Skip to content

Commit

Permalink
web service MDL-12886 remove single operation group functions (=> our…
Browse files Browse the repository at this point in the history
… REST clients/server won't work till our REST implementation supports array)
  • Loading branch information
jerome committed Mar 9, 2009
1 parent 6d1c1a6 commit 499dc41
Showing 1 changed file with 5 additions and 107 deletions.
112 changes: 5 additions & 107 deletions group/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,6 @@
*/
final class group_external {

/**
* Creates a group
* @param array|struct $params
* @subparam string $params->groupname
* @subparam integer $params->courseid
* @return integer groupid
*/
static function tmp_create_group($params) {
global $USER;

if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_SYSTEM))) {
$group = new stdClass;
$group->courseid = $params['courseid'];
$group->name = $params['groupname'];

// @TODO: groups_create_group() does not check courseid
return groups_create_group($group, false);
}
else {
throw new moodle_exception('wscouldnotcreategroup');
}
}

/**
* Create some groups
* @param array|struct $params
Expand Down Expand Up @@ -104,50 +81,6 @@ static function tmp_get_groups($params){

}

/**
* Get a group
* @param array|struct $params
* @subparam integer $params->groupid
* @return object $return
* @subreturn integer $return->group->id
* @subreturn integer $return->group->courseid
* @subreturn string $return->group->name
* @subreturn string $return->group->enrolmentkey
*/
static function tmp_get_group($params){

// @TODO: any capability to check?
$group = groups_get_group($params['groupid']);

$ret = new StdClass();
$ret->id = $group->id;
$ret->courseid = $group->courseid;
$ret->name = $group->name;
$ret->enrolmentkey = $group->enrolmentkey;

return $ret;

}


/**
*
* @param array|struct $params
* @subparam integer $params->groupid
* @return boolean result
*/
static function tmp_delete_group($params){

if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_SYSTEM))) {

// @TODO groups_add_member() does not check userid
return groups_delete_group($params['groupid']);
}
else {
throw new moodle_exception('wscouldnotdeletegroup');
}
}

/**
* Delete some groups
* @param array|struct $params
Expand All @@ -171,32 +104,13 @@ static function tmp_delete_groups($params){
}

/**
*
* Return all internal members for a group id (do not return remotely registered user)
* @param array|struct $params
* @subparam integer $params->groupid
* @subparam integer $params->userid
* @return boolean result
*/
static function tmp_get_groupmember($params){
}

/**
* Add a member to a group
* @param array|struct $params
* @subparam integer $params->groupid
* @subparam integer $params->userid
* @return boolean result
* @subparam integer $params:member->groupid
* @return array $return
* $subparam string $return:username
*/
static function tmp_add_groupmember($params){

if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_SYSTEM))) {

// @TODO groups_add_member() does not check userid
return groups_add_member($params['groupid'], $params['userid']);
}
else {
throw new moodle_exception('wscouldnotaddgroupmember');
}
static function tmp_get_groupmembers($params){
}

/**
Expand Down Expand Up @@ -224,22 +138,6 @@ static function tmp_add_groupmembers($params){
}
}

/**
*
* @param array|struct $params
* @subparam integer $params->groupid
* @subparam integer $params->userid
* @return boolean result
*/
static function tmp_delete_groupmember($params){
if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_SYSTEM))) {

return groups_remove_member($params['groupid'], $params['userid']);
} else {
throw new moodle_exception('wscouldnotremovegroupmember');
}
}

/**
* Delete some members from some groups
* @param array|struct $params
Expand Down

0 comments on commit 499dc41

Please sign in to comment.