diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index a13aa5ada6..a3b965b2f1 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -87,26 +87,42 @@ $destination = new destinations; $destination_array = $destination->all('dialplan'); -//add a function to return the action_name - function action_name($destination_array, $detail_action) { - $result = ''; - if (!empty($destination_array)) { - foreach($destination_array as $group => $row) { - if (!empty($row)) { - foreach ($row as $key => $value) { - if ($value == $detail_action) { - //add multi-lingual support - if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { - $language2 = new text; - $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$group); - $result = trim($text2['title-'.$group].' '.$key); +//function to return the action names in the order defined + function action_name($destination_array, $destination_actions) { + $actions = []; + if (!empty($destination_array) && is_array($destination_array)) { + if (!empty($destination_actions) && is_array($destination_actions)) { + foreach ($destination_actions as $destination_action) { + if (!empty($destination_action)) { + foreach ($destination_array as $group => $row) { + if (!empty($row) && is_array($row)) { + foreach ($row as $key => $value) { + if ($destination_action == $value) { + if ($group == 'other') { + if (!isset($language2) && !isset($text2)) { + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_languages.php")) { + $language2 = new text; + $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans'); + } + } + $actions[] = trim($text2['title-other'].' › '.$text2['option-'.str_replace('_','_',$key)]); + } + else { + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { + $language3 = new text; + $text3 = $language3->get($_SESSION['domain']['language']['code'], 'app/'.$group); + $actions[] = trim($text3['title-'.$group].' › '.$key); + } + } + } + } } - return $result; } } } } } + return $actions; } //set the type @@ -302,19 +318,14 @@ if (!empty($destinations)) { $x = 0; - foreach($destinations as $row) { - - //define variables with an empty string - $destination_app = ''; - $destination_data = ''; + foreach ($destinations as $row) { //prepare the destination actions if (!empty($row['destination_actions'])) { $destination_actions = json_decode($row['destination_actions'], true); if (!empty($destination_actions)) { foreach ($destination_actions as $action) { - $destination_app = $action['destination_app']; - $destination_data = $action['destination_data']; + $destination_app_data[] = $action['destination_app'].':'.$action['destination_data']; } } } @@ -361,7 +372,8 @@ echo " \n"; if (!$show == "all") { - echo " ".action_name($destination_array, $destination_app.':'.$destination_data)." \n"; + $actions = action_name($destination_array, $destination_app_data); + echo " ".(!empty($actions) ? implode(', ', $actions) : null)." \n"; } if (permission_exists("destination_context")) { echo " ".escape($row['destination_context'])." \n"; @@ -379,8 +391,8 @@ } echo "\n"; - //unset the destination app and data - unset($destination_app, $destination_data); + //unset the destination app and data array + unset($destination_app_data); //increment the id $x++; @@ -399,4 +411,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file