Update app_defaults.php

Add default device function group permissions.
This commit is contained in:
FusionPBX 2016-08-06 16:19:58 -06:00 committed by GitHub
parent 67d48eecfa
commit 33945a7dec
1 changed files with 68 additions and 26 deletions

View File

@ -57,9 +57,22 @@ if ($domains_processed == 1) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) { if ($row['num_rows'] == 0) {
//get the vendor array //get the vendor array
require_once $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/devices/app_config.php'; require_once $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/app/devices/app_config.php';
//get the groups and create an array to use the name to get the uuid
$sql = "select * from v_groups; ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$groups = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset($prep_statement);
foreach ($groups as $row) {
if ($row['domain_uuid'] == '') {
$group_uuids[$row['group_name']] = $row['group_uuid'];
}
}
//process the array //process the array
foreach ($vendors as $vendor) { foreach ($vendors as $vendor) {
@ -83,34 +96,63 @@ if ($domains_processed == 1) {
//add the vendor functions //add the vendor functions
foreach ($vendor['functions'] as $function) { foreach ($vendor['functions'] as $function) {
$device_vendor_function_uuid = uuid(); //get the id
$sql = "insert into v_device_vendor_functions "; $device_vendor_function_uuid = uuid();
$sql .= "(";
$sql .= "device_vendor_uuid, "; //add the device vendor funtction
$sql .= "device_vendor_function_uuid, "; $sql = "insert into v_device_vendor_functions ";
//$sql .= "label, "; $sql .= "(";
$sql .= "name, "; $sql .= "device_vendor_uuid, ";
$sql .= "value, "; $sql .= "device_vendor_function_uuid, ";
$sql .= "enabled, "; //$sql .= "label, ";
$sql .= "description "; $sql .= "name, ";
$sql .= ") "; $sql .= "value, ";
$sql .= "values "; $sql .= "enabled, ";
$sql .= "( "; $sql .= "description ";
$sql .= "'".$device_vendor_uuid."', "; $sql .= ") ";
$sql .= "'".$device_vendor_function_uuid."', "; $sql .= "values ";
//$sql .= "'".$function['label']."', "; $sql .= "( ";
$sql .= "'".$function['name']."', "; $sql .= "'".$device_vendor_uuid."', ";
$sql .= "'".$function['value']."', "; $sql .= "'".$device_vendor_function_uuid."', ";
$sql .= "'true', "; //$sql .= "'".$function['label']."', ";
$sql .= "'".$function['description']."' "; $sql .= "'".$function['name']."', ";
$sql .= ");"; $sql .= "'".$function['value']."', ";
//echo $sql."\n"; $sql .= "'true', ";
$db->exec(check_sql($sql)); $sql .= "'".$function['description']."' ";
unset($sql); $sql .= ");";
//echo $sql."\n";
$db->exec(check_sql($sql));
unset($sql);
//add the device vendor function groups
if (is_array($function['groups'])) {
$sql = "insert into v_device_vendor_function_groups ";
$sql .= "(";
$sql .= "device_vendor_function_group_uuid, ";
$sql .= "device_vendor_function_uuid, ";
$sql .= "device_vendor_uuid, ";
$sql .= "group_name, ";
$sql .= "group_uuid ";
$sql .= ") ";
$sql .= "values ";
$i = 0;
foreach ($function['groups'] as $group_name) {
if ($i == 0) { $sql .= "("; } else { $sql .= ",("; }
$sql .= "'".uuid()."', ";
$sql .= "'".$device_vendor_function_uuid."', ";
$sql .= "'".$device_vendor_uuid."', ";
$sql .= "'$group_name', ";
$sql .= "'".$group_uuids[$group_name]."' ";
$sql .= ")";
$i++;
}
$db->exec($sql);
}
} }
} }
} //if num_rows } //if num_rows
} //if prep_statement } // if prep_statement
} }
?> ?>