Sort the 'sofia xmlstatus' profiles alphabetically (#6091)

* Sort the 'sofia xmlstatus' profiles alphabetically

Added function to sort the 'sofia xmlstatus' SIP profiles alphabetically to match the sort order lower down in the page.
This commit is contained in:
emak-Corey 2025-03-22 17:43:58 -04:00 committed by GitHub
parent 0e2b083807
commit efed19ef1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 0 deletions

View File

@ -85,6 +85,28 @@
$xml_response = trim(event_socket::api($cmd)); $xml_response = trim(event_socket::api($cmd));
if ($xml_response) { if ($xml_response) {
$xml = new SimpleXMLElement($xml_response); $xml = new SimpleXMLElement($xml_response);
//turn into array
$profilesA = array();
foreach($xml->profile as $profile) {
$profilesA[] = $profile;
}
//sort the array
function sortXML($a, $b) {
return strnatcmp($a->name, $b->name);
}
usort($profilesA, 'sortXML');
//convert array back to SimpleXMLElement
$xmlString = "<?xml version='1.0'?><profiles>";
foreach ($profilesA as $node) {
$xmlStringRow = $node -> saveXML();
$xmlString = $xmlString . $xmlStringRow;
}
$xmlString = $xmlString . "</profiles>";
$xml = simplexml_load_string($xmlString);
} }
} }
catch(Exception $e) { catch(Exception $e) {