add update-group.php integration example and required connector method

This commit is contained in:
Justin Clark-Casey
2014-07-31 02:29:00 +01:00
parent ccebe02ddb
commit fc1f8365da
3 changed files with 76 additions and 6 deletions
@@ -171,12 +171,15 @@ function AddGroup(
* @return SimpleXmlElement folder XML element
*/
function UpdateGroup(
$serviceUri, $groupID, $charter, $groupPictureID,
$serviceUri, $groupID, $requestingUserId, $charter, $groupPictureID,
$allowPublish, $maturePublish, $openEnrollment, $membershipFee, $shownInList = TRUE,
$debug = FALSE)
{
if (!IsUuid($groupID))
throw new InvalidArgumentException("allowPublish '$allowPublish' is not a bool");
throw new InvalidArgumentException("groupID '$groupID' is not a UUID");
if (!IsUuid($requestingUserId))
throw new InvalidArgumentException("requestingUserId '$requestingUserId' is not a UUID");
if (!is_bool($allowPublish))
throw new InvalidArgumentException("allowPublish '$allowPublish' is not a bool");
@@ -185,7 +188,7 @@ function UpdateGroup(
throw new InvalidArgumentException("maturePublish '$maturePublish' is not a bool");
if (!IsUuid($groupPictureID))
throw new InvalidArgumentException("groupPictureID '$groupPictureID' is not a valid UUID");
throw new InvalidArgumentException("groupPictureID '$groupPictureID' is not a UUID");
if (!is_bool($openEnrollment))
throw new InvalidArgumentException("openEnrollment '$openEnrollment' is not a bool");
@@ -198,7 +201,7 @@ function UpdateGroup(
$params
= array(
'RequestingAgentID' => UUID_ZERO,
'RequestingAgentID' => $requestingUserId,
'GroupID' => $groupID,
'AllowPublish' => $allowPublish ? "true" : "false",
'MaturePublish' => $maturePublish ? "true" : "false",
@@ -216,6 +219,4 @@ function UpdateGroup(
$responseXml = PostToService($serviceUri, http_build_query($params), $debug);
}
?>
@@ -0,0 +1,50 @@
<?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('groupName');
$parser->addArgument('charter');
try
{
$params = $parser->parse();
}
catch (Exception $e)
{
$parser->displayError($e->getMessage());
exit(1);
}
$groupId = $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;
$existingFounderId = (string)$existingGroupE->FounderID;
$existingGroupId = (string)$existingGroupE->GroupID;
$existingGroupPictureId = (string)$existingGroupE->InsigniaID;
$existingAllowPublish = ToBool((string)$existingGroupE->AllowPublish);
$existingMaturePublish = ToBool((string)$existingGroupE->MaturePublish);
$existingOpenEnrollment = ToBool((string)$existingGroupE->OpenEnrollment);
$existingMembershipFee = (int)$existingGroupE->MembershipFee;
$existingShownInList = ToBool((string)$existingGroupE->ShownInList);
echo "existingGroupId '$existingGroupId'\n";
echo "existingGroupPictureId '$existingGroupPictureId'\n";
echo "existingAllowPublish '$existingAllowPublish'\n";
UpdateGroup(
$GROUPS_SERVICE_URI, $existingGroupId, $existingFounderId, $charter,
$existingGroupPictureId, $existingAllowPublish, $existingMaturePublish,
$existingOpenEnrollment, $existingMembershipFee, $existingShownInList, TRUE);
+19
View File
@@ -26,6 +26,25 @@ function IsUuid($data)
return preg_match('/^[a-f\d]{8}-(?:[a-f\d]{4}-){3}[a-f\d]{12}$/i', $data);
}
function ToBool($var)
{
//echo "Got '$var' ", is_string($var), "\n";
if (!is_string($var))
return (bool) $var;
switch (strtolower($var))
{
case '1':
case 'true':
case 'on':
case 'yes':
case 'y':
return true;
default:
return false;
}
}
function GetPrettyXML($xml)
{
$dom = new DOMDocument();