Update provision.php
Add if is_array statements before using the array to prevent warnings if the array isn't defined.
This commit is contained in:
@@ -753,17 +753,21 @@ include "root.php";
|
|||||||
|
|
||||||
//update the device keys by replacing variables with their values
|
//update the device keys by replacing variables with their values
|
||||||
foreach($variables as $name => $value) {
|
foreach($variables as $name => $value) {
|
||||||
foreach($device_keys as $k => $field) {
|
if (is_array($device_keys)) {
|
||||||
if (strlen($field['device_key_uuid']) > 0) {
|
foreach($device_keys as $k => $field) {
|
||||||
$device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']);
|
if (strlen($field['device_key_uuid']) > 0) {
|
||||||
$device_keys[$k]['device_key_extension'] = str_replace("\${".$name."}", $value, $field['device_key_extension']);
|
$device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']);
|
||||||
$device_keys[$k]['device_key_label'] = str_replace("\${".$name."}", $value, $field['device_key_label']);
|
$device_keys[$k]['device_key_extension'] = str_replace("\${".$name."}", $value, $field['device_key_extension']);
|
||||||
}
|
$device_keys[$k]['device_key_label'] = str_replace("\${".$name."}", $value, $field['device_key_label']);
|
||||||
else {
|
}
|
||||||
foreach($field as $key => $row) {
|
else {
|
||||||
$device_keys[$k][$key]['device_key_value'] = str_replace("\${".$name."}", $value, $row['device_key_value']);
|
if (is_array($field)) {
|
||||||
$device_keys[$k][$key]['device_key_extension'] = str_replace("\${".$name."}", $value, $row['device_key_extension']);
|
foreach($field as $key => $row) {
|
||||||
$device_keys[$k][$key]['device_key_label'] = str_replace("\${".$name."}", $value, $row['device_key_label']);
|
$device_keys[$k][$key]['device_key_value'] = str_replace("\${".$name."}", $value, $row['device_key_value']);
|
||||||
|
$device_keys[$k][$key]['device_key_extension'] = str_replace("\${".$name."}", $value, $row['device_key_extension']);
|
||||||
|
$device_keys[$k][$key]['device_key_label'] = str_replace("\${".$name."}", $value, $row['device_key_label']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -775,76 +779,78 @@ include "root.php";
|
|||||||
//set the variables
|
//set the variables
|
||||||
$types = array("line", "memory", "expansion", "programmable");
|
$types = array("line", "memory", "expansion", "programmable");
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
foreach($device_keys[$type] as $row) {
|
if (is_array($device_keys)) {
|
||||||
//set the variables
|
foreach($device_keys[$type] as $row) {
|
||||||
$device_key_category = $row['device_key_category'];
|
//set the variables
|
||||||
$device_key_id = $row['device_key_id']; //1
|
$device_key_category = $row['device_key_category'];
|
||||||
$device_key_type = $row['device_key_type']; //line
|
$device_key_id = $row['device_key_id']; //1
|
||||||
$device_key_line = $row['device_key_line'];
|
$device_key_type = $row['device_key_type']; //line
|
||||||
$device_key_value = $row['device_key_value']; //1
|
$device_key_line = $row['device_key_line'];
|
||||||
$device_key_extension = $row['device_key_extension'];
|
$device_key_value = $row['device_key_value']; //1
|
||||||
$device_key_label = $row['device_key_label']; //label
|
$device_key_extension = $row['device_key_extension'];
|
||||||
|
$device_key_label = $row['device_key_label']; //label
|
||||||
//add general variables
|
|
||||||
$device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value);
|
//add general variables
|
||||||
$device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension);
|
$device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value);
|
||||||
$device_key_label = str_replace("\${domain_name}", $domain_name, $device_key_label);
|
$device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension);
|
||||||
|
$device_key_label = str_replace("\${domain_name}", $domain_name, $device_key_label);
|
||||||
//grandstream modes are different based on the category
|
|
||||||
if ($device_vendor == "grandstream") {
|
//grandstream modes are different based on the category
|
||||||
if ($device_key_category == "line") {
|
if ($device_vendor == "grandstream") {
|
||||||
switch ($device_key_type) {
|
if ($device_key_category == "line") {
|
||||||
case "line": $device_key_type = "0"; break;
|
switch ($device_key_type) {
|
||||||
case "shared line": $device_key_type = "1"; break;
|
case "line": $device_key_type = "0"; break;
|
||||||
case "speed dial": $device_key_type = "10"; break;
|
case "shared line": $device_key_type = "1"; break;
|
||||||
case "blf": $device_key_type = "11"; break;
|
case "speed dial": $device_key_type = "10"; break;
|
||||||
case "presence watcher": $device_key_type = "12"; break;
|
case "blf": $device_key_type = "11"; break;
|
||||||
case "eventlist blf": $device_key_type = "13"; break;
|
case "presence watcher": $device_key_type = "12"; break;
|
||||||
case "speed dial active": $device_key_type = "14"; break;
|
case "eventlist blf": $device_key_type = "13"; break;
|
||||||
case "dial dtmf": $device_key_type = "15"; break;
|
case "speed dial active": $device_key_type = "14"; break;
|
||||||
case "voicemail": $device_key_type = "16"; break;
|
case "dial dtmf": $device_key_type = "15"; break;
|
||||||
case "call return": $device_key_type = "17"; break;
|
case "voicemail": $device_key_type = "16"; break;
|
||||||
case "transfer": $device_key_type = "18"; break;
|
case "call return": $device_key_type = "17"; break;
|
||||||
case "call park": $device_key_type = "19"; break;
|
case "transfer": $device_key_type = "18"; break;
|
||||||
case "intercom": $device_key_type = "20"; break;
|
case "call park": $device_key_type = "19"; break;
|
||||||
case "ldap search": $device_key_type = "21"; break;
|
case "intercom": $device_key_type = "20"; break;
|
||||||
|
case "ldap search": $device_key_type = "21"; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($device_key_category == "memory" || $device_key_category == "expansion") {
|
||||||
|
switch ($device_key_type) {
|
||||||
|
case "speed dial": $device_key_type = "0"; break;
|
||||||
|
case "blf": $device_key_type = "1"; break;
|
||||||
|
case "presence watcher": $device_key_type = "2"; break;
|
||||||
|
case "eventlist blf": $device_key_type = "3"; break;
|
||||||
|
case "speed dial active": $device_key_type = "4"; break;
|
||||||
|
case "dial dtmf": $device_key_type = "5"; break;
|
||||||
|
case "voicemail": $device_key_type = "6"; break;
|
||||||
|
case "call return": $device_key_type = "7"; break;
|
||||||
|
case "transfer": $device_key_type = "8"; break;
|
||||||
|
case "call park": $device_key_type = "9"; break;
|
||||||
|
case "intercom": $device_key_type = "10"; break;
|
||||||
|
case "ldap search": $device_key_type = "11"; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($device_key_category == "memory" || $device_key_category == "expansion") {
|
|
||||||
switch ($device_key_type) {
|
//assign the variables
|
||||||
case "speed dial": $device_key_type = "0"; break;
|
if (strlen($device_key_category) == 0) {
|
||||||
case "blf": $device_key_type = "1"; break;
|
$view->assign("key_id_".$device_key_id, $device_key_id);
|
||||||
case "presence watcher": $device_key_type = "2"; break;
|
$view->assign("key_type_".$device_key_id, $device_key_type);
|
||||||
case "eventlist blf": $device_key_type = "3"; break;
|
$view->assign("key_line_".$device_key_id, $device_key_line);
|
||||||
case "speed dial active": $device_key_type = "4"; break;
|
$view->assign("key_value_".$device_key_id, $device_key_value);
|
||||||
case "dial dtmf": $device_key_type = "5"; break;
|
$view->assign("key_extension_".$device_key_id, $device_key_extension);
|
||||||
case "voicemail": $device_key_type = "6"; break;
|
$view->assign("key_label_".$device_key_id, $device_key_label);
|
||||||
case "call return": $device_key_type = "7"; break;
|
|
||||||
case "transfer": $device_key_type = "8"; break;
|
|
||||||
case "call park": $device_key_type = "9"; break;
|
|
||||||
case "intercom": $device_key_type = "10"; break;
|
|
||||||
case "ldap search": $device_key_type = "11"; break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
$view->assign($device_key_category."_key_id_".$device_key_id, $device_key_id);
|
||||||
//assign the variables
|
$view->assign($device_key_category."_key_type_".$device_key_id, $device_key_type);
|
||||||
if (strlen($device_key_category) == 0) {
|
$view->assign($device_key_category."_key_line_".$device_key_id, $device_key_line);
|
||||||
$view->assign("key_id_".$device_key_id, $device_key_id);
|
$view->assign($device_key_category."_key_value_".$device_key_id, $device_key_value);
|
||||||
$view->assign("key_type_".$device_key_id, $device_key_type);
|
$view->assign($device_key_category."_key_extension_".$device_key_id, $device_key_extension);
|
||||||
$view->assign("key_line_".$device_key_id, $device_key_line);
|
$view->assign($device_key_category."_key_label_".$device_key_id, $device_key_label);
|
||||||
$view->assign("key_value_".$device_key_id, $device_key_value);
|
}
|
||||||
$view->assign("key_extension_".$device_key_id, $device_key_extension);
|
}
|
||||||
$view->assign("key_label_".$device_key_id, $device_key_label);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$view->assign($device_key_category."_key_id_".$device_key_id, $device_key_id);
|
|
||||||
$view->assign($device_key_category."_key_type_".$device_key_id, $device_key_type);
|
|
||||||
$view->assign($device_key_category."_key_line_".$device_key_id, $device_key_line);
|
|
||||||
$view->assign($device_key_category."_key_value_".$device_key_id, $device_key_value);
|
|
||||||
$view->assign($device_key_category."_key_extension_".$device_key_id, $device_key_extension);
|
|
||||||
$view->assign($device_key_category."_key_label_".$device_key_id, $device_key_label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset ($prep_statement);
|
unset ($prep_statement);
|
||||||
|
|||||||
Reference in New Issue
Block a user