Destinations - List: Show all selected Actions, including Other actions.

This commit is contained in:
fusionate
2024-01-19 20:28:28 +00:00
parent ec934c3895
commit 08659badc0

View File

@@ -87,26 +87,42 @@
$destination = new destinations; $destination = new destinations;
$destination_array = $destination->all('dialplan'); $destination_array = $destination->all('dialplan');
//add a function to return the action_name //function to return the action names in the order defined
function action_name($destination_array, $detail_action) { function action_name($destination_array, $destination_actions) {
$result = ''; $actions = [];
if (!empty($destination_array)) { if (!empty($destination_array) && is_array($destination_array)) {
foreach($destination_array as $group => $row) { if (!empty($destination_actions) && is_array($destination_actions)) {
if (!empty($row)) { foreach ($destination_actions as $destination_action) {
foreach ($row as $key => $value) { if (!empty($destination_action)) {
if ($value == $detail_action) { foreach ($destination_array as $group => $row) {
//add multi-lingual support if (!empty($row) && is_array($row)) {
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { foreach ($row as $key => $value) {
$language2 = new text; if ($destination_action == $value) {
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$group); if ($group == 'other') {
$result = trim($text2['title-'.$group].' '.$key); 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 //set the type
@@ -302,19 +318,14 @@
if (!empty($destinations)) { if (!empty($destinations)) {
$x = 0; $x = 0;
foreach($destinations as $row) { foreach ($destinations as $row) {
//define variables with an empty string
$destination_app = '';
$destination_data = '';
//prepare the destination actions //prepare the destination actions
if (!empty($row['destination_actions'])) { if (!empty($row['destination_actions'])) {
$destination_actions = json_decode($row['destination_actions'], true); $destination_actions = json_decode($row['destination_actions'], true);
if (!empty($destination_actions)) { if (!empty($destination_actions)) {
foreach ($destination_actions as $action) { foreach ($destination_actions as $action) {
$destination_app = $action['destination_app']; $destination_app_data[] = $action['destination_app'].':'.$action['destination_data'];
$destination_data = $action['destination_data'];
} }
} }
} }
@@ -361,7 +372,8 @@
echo " </td>\n"; echo " </td>\n";
if (!$show == "all") { if (!$show == "all") {
echo " <td class='overflow' style='min-width: 125px;'>".action_name($destination_array, $destination_app.':'.$destination_data)."&nbsp;</td>\n"; $actions = action_name($destination_array, $destination_app_data);
echo " <td class='overflow' style='min-width: 125px;'>".(!empty($actions) ? implode(', ', $actions) : null)."&nbsp;</td>\n";
} }
if (permission_exists("destination_context")) { if (permission_exists("destination_context")) {
echo " <td>".escape($row['destination_context'])."&nbsp;</td>\n"; echo " <td>".escape($row['destination_context'])."&nbsp;</td>\n";
@@ -379,8 +391,8 @@
} }
echo "</tr>\n"; echo "</tr>\n";
//unset the destination app and data //unset the destination app and data array
unset($destination_app, $destination_data); unset($destination_app_data);
//increment the id //increment the id
$x++; $x++;
@@ -399,4 +411,4 @@
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>