Add remove-user-from-group example code and required connector

This commit is contained in:
Justin Clark-Casey
2014-07-31 21:31:40 +01:00
parent b754ed3357
commit 914bf6afc1
2 changed files with 52 additions and 0 deletions
@@ -158,6 +158,22 @@ function AddUserToGroup($serviceUri, $groupId, $userId, $roleId, $debug = FALSE)
return PostToService($serviceUri, http_build_query($params), $debug);
}
function RemoveUserFromGroup($serviceUri, $groupId, $requestingUserId, $userId, $debug = FALSE)
{
CheckUuid("groupId", $groupId);
CheckUuid("requestingUserId", $requestingUserId);
CheckUuid("userId", $userId);
$params
= array(
'RequestingAgentID' => UUID_ZERO,
'GroupID' => $groupId,
'AgentID' => $userId,
'METHOD' => 'REMOVEAGENTFROMGROUP');
return PostToService($serviceUri, http_build_query($params), $debug);
}
/*
* Add a new group.
*
@@ -0,0 +1,36 @@
<?php
require_once 'Console/CommandLine.php';
require_once "../../config.php";
require_once "../../utils.php";
require_once "$IP/connectors/groups-service-connector.php";
############
### MAIN ###
############
$parser = new Console_CommandLine();
$parser->addArgument('groupID');
$parser->addArgument('userID');
try
{
$params = $parser->parse();
}
catch (Exception $e)
{
$parser->displayError($e->getMessage());
exit(1);
}
$groupId = $params->args['groupID'];
$userId = $params->args['userID'];
// Unfortunately, due to current OpenSimulator limitations we have to supply a user with perms to this operation.
// We'll use the founder.
$existingGroupE = GetGroupById($GROUPS_SERVICE_URI, $groupId)->RESULT;
$founderId = (string)$existingGroupE->FounderID;
// Lazily we'll just add people to the everyone role (UUID_Zero)
RemoveUserFromGroup($GROUPS_SERVICE_URI, $groupId, $founderId, $userId, true);