From 7400bb0c849a6ae44dbb584a3fae52e1acaea246 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 6 Aug 2019 19:40:21 -0600 Subject: [PATCH] Update app_defaults.php --- app/devices/app_defaults.php | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/app/devices/app_defaults.php b/app/devices/app_defaults.php index eda27503a6..40a60a6e76 100644 --- a/app/devices/app_defaults.php +++ b/app/devices/app_defaults.php @@ -66,8 +66,6 @@ if ($domains_processed == 1) { $sql = "select count(*) from v_device_vendors; "; $database = new database; $num_rows = $database->select($sql, null, 'column'); - unset($sql); - if ($num_rows == 0) { //get the vendor array @@ -86,38 +84,46 @@ if ($domains_processed == 1) { //build the array if (is_array($vendors) && @sizeof($vendors) != 0) { - foreach ($vendors as $index_1 => $vendor) { + $x = 0; $y = 0; $z = 0; + foreach ($vendors as $vendor) { //insert the data into the database $device_vendor_uuid = uuid(); - $array['device_vendors'][$index_1]['device_vendor_uuid'] = $device_vendor_uuid; - $array['device_vendors'][$index_1]['name'] = $vendor['name']; - $array['device_vendors'][$index_1]['enabled'] = 'true'; + $array['device_vendors'][$x]['device_vendor_uuid'] = $device_vendor_uuid; + $array['device_vendors'][$x]['name'] = $vendor['name']; + $array['device_vendors'][$x]['enabled'] = 'true'; //add the vendor functions - if (is_array($vendor['functions']) && @sizeof($vendor['functions']) != 0) { - foreach ($vendor['functions'] as $index_2 => $function) { + if (is_array($vendor['functions']) && @sizeof($vendor['functions'])) { + + foreach ($vendor['functions'] as $function) { //add the device vendor function $device_vendor_function_uuid = uuid(); - $array['device_vendor_functions'][$index_2]['device_vendor_uuid'] = $device_vendor_uuid; - $array['device_vendor_functions'][$index_2]['device_vendor_function_uuid'] = $device_vendor_function_uuid; - $array['device_vendor_functions'][$index_2]['name'] = $function['name']; - $array['device_vendor_functions'][$index_2]['value'] = $function['value']; - $array['device_vendor_functions'][$index_2]['enabled'] = 'true'; - $array['device_vendor_functions'][$index_2]['description'] = $function['description']; + $array['device_vendor_functions'][$y]['device_vendor_uuid'] = $device_vendor_uuid; + $array['device_vendor_functions'][$y]['device_vendor_function_uuid'] = $device_vendor_function_uuid; + $array['device_vendor_functions'][$y]['name'] = $function['name']; + $array['device_vendor_functions'][$y]['value'] = $function['value']; + $array['device_vendor_functions'][$y]['enabled'] = 'true'; + $array['device_vendor_functions'][$y]['description'] = $function['description']; //add the device vendor function groups if (is_array($function['groups']) && @sizeof($function['groups']) != 0) { - foreach ($function['groups'] as $index_3 => $group_name) { - $device_vendor_function_group_uuid = uuid(); - $array['device_vendor_function_groups'][$index_3]['device_vendor_function_group_uuid'] = $device_vendor_function_group_uuid; - $array['device_vendor_function_groups'][$index_3]['device_vendor_function_uuid'] = $device_vendor_function_uuid; - $array['device_vendor_function_groups'][$index_3]['device_vendor_uuid'] = $device_vendor_uuid; - $array['device_vendor_function_groups'][$index_3]['group_name'] = $group_name; - $array['device_vendor_function_groups'][$index_3]['group_uuid'] = $group_uuids[$group_name]; + foreach ($function['groups'] as $group_name) { + $array['device_vendor_function_groups'][$z]['device_vendor_function_group_uuid'] = uuid(); + $array['device_vendor_function_groups'][$z]['device_vendor_function_uuid'] = $device_vendor_function_uuid; + $array['device_vendor_function_groups'][$z]['device_vendor_uuid'] = $device_vendor_uuid; + $array['device_vendor_function_groups'][$z]['group_name'] = $group_name; + $array['device_vendor_function_groups'][$z]['group_uuid'] = $group_uuids[$group_name]; + $z++; } } + + //increment the device vendor function index + $y++; } } + + //increment the devic vendor index + $x++; } } @@ -143,4 +149,5 @@ if ($domains_processed == 1) { unset($num_rows); } -?> \ No newline at end of file + +?>