mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 09:12:07 +00:00
Split GetGroup() function into GetGroupById() and GetGroupByName() in common with functions in existing connectors
This commit is contained in:
@@ -14,22 +14,27 @@ function FindGroups($serviceUri, $query, $debug = FALSE)
|
||||
return PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
function GetGroup($serviceUri, $groupUuid = NULL, $groupName = NULL, $debug = FALSE)
|
||||
function GetGroupById($serviceUri, $groupId, $debug = FALSE)
|
||||
{
|
||||
if ($groupUuid != NULL && $groupName != NULL)
|
||||
throw new Exception("Cannot specify both group ID and name.");
|
||||
else if ($groupUuid == NULL && $groupName == NULL)
|
||||
throw new Exception("Either group ID or group name must be specified.");
|
||||
|
||||
if (!IsUuid($groupId))
|
||||
throw new InvalidArgumentException("$groupId '$groupId' is not a UUID");
|
||||
|
||||
$params
|
||||
= array(
|
||||
'RequestingAgentID' => UUID_ZERO,
|
||||
'RequestingAgentID' => UUID_ZERO,
|
||||
'GroupID' => $groupId,
|
||||
'METHOD' => 'GETGROUP');
|
||||
|
||||
return PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
function GetGroupByName($serviceUri, $groupName, $debug = FALSE)
|
||||
{
|
||||
$params
|
||||
= array(
|
||||
'RequestingAgentID' => UUID_ZERO,
|
||||
'Name' => $groupName,
|
||||
'METHOD' => 'GETGROUP');
|
||||
|
||||
if ($groupUuid != NULL)
|
||||
$params['GroupID'] = $groupUuid;
|
||||
else
|
||||
$params['Name'] = $groupName;
|
||||
|
||||
return PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
@@ -136,4 +141,81 @@ function AddGroup(
|
||||
$responseXml = PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new group.
|
||||
*
|
||||
* @param string $serviceURI
|
||||
* Inventory service URI
|
||||
* @param string $groupName
|
||||
* Name of the group. Ignored if the group already exists.
|
||||
* @param UUID $founderID
|
||||
* UUID of the user account of the founder of the group.
|
||||
* @param string $charter
|
||||
* Charter information (description) for the group.
|
||||
* @param UUID $insigniaID
|
||||
* Texture asset to use as the picture for the group. If UUID.Zero then no picture will be available.
|
||||
* @param boolean $allowPublish
|
||||
* In Linden Lab probably governs whether this group is published to search.
|
||||
* Very probably currently ignored in core OpenSimulator.
|
||||
* @param boolean $maturePublish
|
||||
* In Linden Lab probably stops this group being shown to users in search unless they have Mature set in their preferences.
|
||||
* Very probably currently ignored in core OpenSimulator.
|
||||
* @param int $membershipFee
|
||||
* The amount of virtual currency users will have to pay to join this group. In OpenSimulator, unless you have
|
||||
* a currency module active you will normally want to set this to zero.
|
||||
* @param bool $shownInList
|
||||
* Governs whether the group is shown to the user when they do a general search for groups. Unfortunately, this
|
||||
* also governs whether it shows up in the FindGroups call. Currently, set to true whenever possible, otherwise
|
||||
* the group information can only be retrieved via GetGroup.
|
||||
*
|
||||
* @return SimpleXmlElement folder XML element
|
||||
*/
|
||||
function UpdateGroup(
|
||||
$serviceUri, $groupID, $charter, $groupPictureID,
|
||||
$allowPublish, $maturePublish, $openEnrollment, $membershipFee, $shownInList = TRUE,
|
||||
$debug = FALSE)
|
||||
{
|
||||
if (!IsUuid($groupID))
|
||||
throw new InvalidArgumentException("allowPublish '$allowPublish' is not a bool");
|
||||
|
||||
if (!is_bool($allowPublish))
|
||||
throw new InvalidArgumentException("allowPublish '$allowPublish' is not a bool");
|
||||
|
||||
if (!is_bool($maturePublish))
|
||||
throw new InvalidArgumentException("maturePublish '$maturePublish' is not a bool");
|
||||
|
||||
if (!IsUuid($groupPictureID))
|
||||
throw new InvalidArgumentException("groupPictureID '$groupPictureID' is not a valid UUID");
|
||||
|
||||
if (!is_bool($openEnrollment))
|
||||
throw new InvalidArgumentException("openEnrollment '$openEnrollment' is not a bool");
|
||||
|
||||
if (!is_int($membershipFee) || $membershipFee < 0)
|
||||
throw new InvalidArgumentException("membershipFee '$membershipFee' is not a positive or zero integer");
|
||||
|
||||
if (!is_bool($shownInList))
|
||||
throw new InvalidArgumentException("shownInList '$shownInList' is not a bool");
|
||||
|
||||
$params
|
||||
= array(
|
||||
'RequestingAgentID' => UUID_ZERO,
|
||||
'GroupID' => $groupID,
|
||||
'AllowPublish' => $allowPublish ? "true" : "false",
|
||||
'MaturePublish' => $maturePublish ? "true" : "false",
|
||||
'OpenEnrollment' => $openEnrollment ? "true" : "false",
|
||||
'MembershipFee' => $membershipFee,
|
||||
'Charter' => $charter,
|
||||
'InsigniaID' => $groupPictureID,
|
||||
'ShownInList' => $shownInList ? "true" : "false",
|
||||
// We need this to get around a bug in OpenSimulator 0.8 and before where not specifying some ServiceLocation
|
||||
// would set GroupName to "". This is only used in Hypergrid so we can safely set this to a space.
|
||||
'ServiceLocation' => " ",
|
||||
'METHOD' => 'PUTGROUP',
|
||||
'OP' => 'UPDATE');
|
||||
|
||||
$responseXml = PostToService($serviceUri, http_build_query($params), $debug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -30,8 +30,6 @@ $groupName = NULL;
|
||||
# For the purposes of this example program, we will assume that if the argument is a UUID then we always intend to
|
||||
# use it as a UUID in the query.
|
||||
if (IsUuid($group))
|
||||
$groupId = $group;
|
||||
GetGroupById($GROUPS_SERVICE_URI, $group, TRUE);
|
||||
else
|
||||
$groupName = $group;
|
||||
|
||||
GetGroup($GROUPS_SERVICE_URI, $groupId, $groupName, TRUE);
|
||||
GetGroupByName($GROUPS_SERVICE_URI, $group, TRUE);
|
||||
Reference in New Issue
Block a user