From 914bf6afc1588334121af671e91678495cb7f96d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Thu, 31 Jul 2014 21:31:40 +0100 Subject: [PATCH] Add remove-user-from-group example code and required connector --- .../connectors/groups-service-connector.php | 16 +++++++++ .../groups/remove-user-from-group.php | 36 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 integration/php/src/programs/groups/remove-user-from-group.php diff --git a/integration/php/src/connectors/groups-service-connector.php b/integration/php/src/connectors/groups-service-connector.php index a173d21..a8b6709 100644 --- a/integration/php/src/connectors/groups-service-connector.php +++ b/integration/php/src/connectors/groups-service-connector.php @@ -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. * diff --git a/integration/php/src/programs/groups/remove-user-from-group.php b/integration/php/src/programs/groups/remove-user-from-group.php new file mode 100644 index 0000000..6a88f8a --- /dev/null +++ b/integration/php/src/programs/groups/remove-user-from-group.php @@ -0,0 +1,36 @@ +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); \ No newline at end of file