mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 01:07:50 +00:00
Add -add-user-to-group.php example program
This commit is contained in:
@@ -62,4 +62,10 @@ function PrintReturnDebugInfo($curlResult, $curlInfo)
|
||||
echo "Return code:" . $curlInfo['http_code'] . "\n";
|
||||
echo "Return data: (below)\n" . GetPrettyXML($curlResult) . "\n";
|
||||
}
|
||||
|
||||
function CheckUuid($varName, $value)
|
||||
{
|
||||
if (!IsUuid($value))
|
||||
throw new InvalidArgumentException("$varName '$value' is not a valid UUID");
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -141,6 +141,23 @@ function AddGroup(
|
||||
$responseXml = PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
function AddUserToGroup($serviceUri, $groupId, $userId, $roleId, $debug = FALSE)
|
||||
{
|
||||
CheckUuid("groupId", $groupId);
|
||||
CheckUuid("userId", $userId);
|
||||
CheckUuid("roleId", $roleId);
|
||||
|
||||
$params
|
||||
= array(
|
||||
'RequestingAgentID' => UUID_ZERO,
|
||||
'GroupID' => $groupId,
|
||||
'AgentID' => $userId,
|
||||
'RoleID' => $roleId,
|
||||
'METHOD' => 'ADDAGENTTOGROUP');
|
||||
|
||||
return PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new group.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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'];
|
||||
|
||||
// Lazily we'll just add people to the everyone role (UUID_Zero)
|
||||
AddUserToGroup($GROUPS_SERVICE_URI, $groupId, $userId, UUID_ZERO, true);
|
||||
@@ -24,12 +24,12 @@ catch (Exception $e)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$groupId = $params->args['groupName'];
|
||||
$groupName = $params->args['groupName'];
|
||||
$charter = $params->args['charter'];
|
||||
|
||||
// Unfortunately, due to current OpenSimulator limitations all data is set so we have to get first
|
||||
// and feed back the fields we don't want to change!
|
||||
$existingGroupE = GetGroupByName($GROUPS_SERVICE_URI, $groupId)->RESULT;
|
||||
$existingGroupE = GetGroupByName($GROUPS_SERVICE_URI, $groupName)->RESULT;
|
||||
|
||||
// The update change can only be performed by a user with sufficient permissions, which the founder should have.
|
||||
// Can't get around this at the moment, even though this should be a voluntary perms check for simulator purposes,
|
||||
@@ -50,4 +50,4 @@ $existingShownInList = ToBool((string)$existingGroupE->ShownInList);
|
||||
UpdateGroup(
|
||||
$GROUPS_SERVICE_URI, $existingGroupId, $existingFounderId, $charter,
|
||||
$existingGroupPictureId, $existingAllowPublish, $existingMaturePublish,
|
||||
$existingOpenEnrollment, $existingMembershipFee, $existingShownInList, TRUE);
|
||||
$existingOpenEnrollment, $existingMembershipFee, $existingShownInList, TRUE);
|
||||
|
||||
Reference in New Issue
Block a user