mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 01:07:50 +00:00
Add remove-user-from-group example code and required connector
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user