Add destination_actions type json allows adding multiple actions

This commit is contained in:
markjcrane
2022-07-15 22:38:21 -06:00
parent 4ee607eb83
commit 4f2987da2d
4 changed files with 189 additions and 96 deletions
+52 -5
View File
@@ -17,15 +17,16 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2017
Portions created by the Initial Developer are Copyright (C) 2017 - 2022
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//update the v_destinations set destination_app and destination_data
if ($domains_processed == 1) {
if ($domains_processed == 1) {
//update the v_destinations set destination_app and destination_data
$sql = "select dialplan_uuid, dialplan_detail_type as destination_app, dialplan_detail_data as destination_data\n";
$sql .= "from v_dialplan_details\n";
$sql .= "where dialplan_uuid in (select dialplan_uuid from v_destinations where destination_type = 'inbound' and destination_app is null and destination_data is null)\n";
@@ -49,7 +50,53 @@
unset($sql, $parameters);
}
}
unset($extensions, $row);
}
unset($extensions, $row, $array);
//use destinations actions to
$sql = "select * from v_destinations ";
$sql .= "where destination_actions is null ";
$database = new database;
$destinations = $database->select($sql, null, 'all');
if (is_array($destinations)) {
$z=0;
foreach ($destinations as $row) {
//prepare the actions array
if (isset($row['destination_app']) && $row['destination_data'] != '') {
$actions[0]['destination_app'] = $row['destination_app'];
$actions[0]['destination_data'] = $row['destination_data'];
}
if (isset($row['destination_alternate_data']) && $row['destination_alternate_data'] != '') {
$actions[1]['destination_app'] = $row['destination_alternate_app'];
$actions[1]['destination_data'] = $row['destination_alternate_data'];
}
//build the array of destinations
if (is_array($actions)) {
$array['destinations'][$z]['destination_uuid'] = $row['destination_uuid'];
$array['destinations'][$z]['destination_actions'] = json_encode($actions);
$z++;
}
}
if (is_array($array)) {
//add temporary permissions
$p = new permissions;
$p->add('destination_edit', 'temp');
//create the database object and save the data
$database = new database;
$database->app_name = 'destinations';
$database->app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139';
$database->save($array, false);
unset($array);
//remove the temporary permissions
$p->delete('destination_edit', 'temp');
}
}
unset($sql, $num_rows);
}
?>