mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
commiting delete groupmember function
MDL-12886
This commit is contained in:
parent
bec1878021
commit
39b99c6af5
3 changed files with 100 additions and 15 deletions
|
@ -43,6 +43,10 @@ final class group_external extends moodle_external {
|
||||||
'optionalparams' => array( ),
|
'optionalparams' => array( ),
|
||||||
'return' => array('result' => PARAM_BOOL));
|
'return' => array('result' => PARAM_BOOL));
|
||||||
|
|
||||||
|
$this->descriptions['tmp_delete_groupmember'] = array( 'params' => array('groupid'=> PARAM_INT, 'userid'=> PARAM_INT),
|
||||||
|
'optionalparams' => array( ),
|
||||||
|
'return' => array('result' => PARAM_BOOL));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,18 +72,6 @@ final class group_external extends moodle_external {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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_group($params){
|
static function tmp_get_group($params){
|
||||||
|
|
||||||
// @TODO: any capability to check?
|
// @TODO: any capability to check?
|
||||||
|
@ -105,9 +97,32 @@ final class group_external extends moodle_external {
|
||||||
else {
|
else {
|
||||||
throw new moodle_exception('wscouldnotdeletegroup');
|
throw new moodle_exception('wscouldnotdeletegroup');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function tmp_get_groupmember($params){
|
||||||
|
}
|
||||||
|
|
||||||
|
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_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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -45,6 +45,7 @@ if ($groupid) {
|
||||||
$data['groupid'] = $groupid;
|
$data['groupid'] = $groupid;
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_delete_group');
|
curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_delete_group');
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
|
69
webservice/rest/testclient/deletegroupmember.php
Normal file
69
webservice/rest/testclient/deletegroupmember.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Rest Test Client
|
||||||
|
*
|
||||||
|
* @author David Castro Garcia
|
||||||
|
* @author Ferran Recio Calderó
|
||||||
|
* @author Jordi Piguillem
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once ('config_rest.php');
|
||||||
|
|
||||||
|
$params = array('groupid', 'userid');
|
||||||
|
|
||||||
|
foreach ($params as $param) {
|
||||||
|
$$param = (isset($_POST[$param]))?$_POST[$param]:'';
|
||||||
|
}
|
||||||
|
|
||||||
|
start_interface("Delete group member from a group");
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="deletegroupmember.php" method="post">
|
||||||
|
<table border="0">
|
||||||
|
<tr><td>Group id: </td><td><input type="text" name="groupid" value="<?php echo $groupid; ?>"/></td></tr>
|
||||||
|
<tr><td>User id: </td><td><input type="text" name="userid" value="<?php echo $userid; ?>"/></td></tr>
|
||||||
|
<tr><td></td><td><input type="submit" value="Delete"></td></tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($groupid && $userid) {
|
||||||
|
|
||||||
|
var_dump($CFG->serverurl.'/group/tmp_delete_groupmember');
|
||||||
|
|
||||||
|
|
||||||
|
//we are asking for a token
|
||||||
|
$connectiondata['username'] = 'wsuser';
|
||||||
|
$connectiondata['password'] = 'wspassword';
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token');
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata));
|
||||||
|
$token = curl_exec($ch);
|
||||||
|
|
||||||
|
$data['token'] = $token;
|
||||||
|
$data['groupid'] = $groupid;
|
||||||
|
$data['userid'] = $userid;
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_delete_groupmember');
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data));
|
||||||
|
$out = curl_exec($ch);
|
||||||
|
|
||||||
|
$res = basicxml_xml_to_object($out);
|
||||||
|
|
||||||
|
show_object($res->result);
|
||||||
|
|
||||||
|
show_xml ($out);
|
||||||
|
} else {
|
||||||
|
echo "<p>Fill the form first</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
end_interface();
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue