load($configFileName); $cmsAddress = ""; $item0 = $configFile->getElementsByTagName("system-data-structure"); foreach($item0 as $item) foreach($item->childNodes as $item2) if ($item2->nodeName==="cmsAddress") $cmsAddress = $item2->nodeValue; // Get current users from CMS $cmsAddress = $cmsAddress."/ws/services/AssetOperationService?wsdl"; $username = "_system_all_groups"; $password = "systemuser"; $client = new SoapClient($cmsAddress, array('trace' => 1)); $groups = getUserGroups($username); $xmlContent = ""; for($i = 0; $i"; else $xmlContent.=""; $xmlContent.=$groups[$i]; $xmlContent.=""; } $xmlContent.=""; editMetadataSet($xmlContent); echo "done"; exit; function editMetadataSet($xml) { global $username; global $password; global $client; $create_params = array ( 'authentication' => array( 'password' => $password, 'username' => $username ), 'asset' => array( 'metadataSet' => array( 'name' => "Intranet", 'parentContainerPath' => "/General", 'path' => "/General/Intranet", 'displayNameFieldVisibility' => "inline", 'titleFieldVisibility' => "inline", 'summaryFieldVisibility' => "inline", 'keywordsFieldVisibility' => "inline", 'dynamicFields' => array( 'dynamicMetadataFieldDefinition' => array( 'name' => 'User Groups which will have rights to view this page', 'fieldType' => 'dropdown', 'required' => 'false', 'visibility' => 'inline', 'configurationXML' => $xml))))); $response = $client->edit($create_params); } function getUserGroups($usernameToGet) { global $username; global $password; global $client; $create_params = array ( 'authentication' => array( 'password' => $password, 'username' => $username ), 'identifier' => array( 'id' =>$usernameToGet, 'type' => "user" )); $client->read($create_params); $xml = $client->__getLastResponse(); $xmlFile = new domDocument(); $xmlFile->loadXML($xml); $answer = array(); $XMLuser = $xmlFile->getElementsByTagName("groups"); foreach($XMLuser as $XMLuserValues) { $groupsString = $XMLuserValues->nodeValue; while(strpos($groupsString, ";")!=NULL) { array_push($answer,substr($groupsString,0,strpos($groupsString, ";"))); $groupsString=substr($groupsString, strpos($groupsString, ";")+1); } array_push($answer,$groupsString); } return $answer; } ?>