mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
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:
@@ -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 = "<?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) {
|
||||
|
||||
Reference in New Issue
Block a user