From efed19ef1c21175519bd5a0ff2c9f65cb1c962e5 Mon Sep 17 00:00:00 2001 From: emak-Corey Date: Sat, 22 Mar 2025 17:43:58 -0400 Subject: [PATCH] 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. --- app/sip_status/sip_status.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php index 364023a108..369d275272 100644 --- a/app/sip_status/sip_status.php +++ b/app/sip_status/sip_status.php @@ -85,6 +85,28 @@ $xml_response = trim(event_socket::api($cmd)); if ($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 = ""; + foreach ($profilesA as $node) { + $xmlStringRow = $node -> saveXML(); + $xmlString = $xmlString . $xmlStringRow; + } + $xmlString = $xmlString . ""; + + $xml = simplexml_load_string($xmlString); } } catch(Exception $e) {