This commit is contained in:
Christopher Cookman 2024-12-05 17:38:49 -07:00
parent 39ac99c600
commit df51d2b46d
10 changed files with 42 additions and 42 deletions

View file

@ -11,7 +11,7 @@ If you add/enable the 'callLogBlfEnabled' xml entry in SEPXXX.cnf.xml under comm
and you have added hints for your local extension in your dialplan, like:
exten => _XX.,hint,SCCP/${EXTEN}
exten => _XX.,hint,SCCP/{$EXTEN}
Then the placed calls list will include the status of the remote extension, like this:

View file

@ -90,7 +90,7 @@ $(document).ready(function () {
}
var newLocation = location.href;
newLocation = ('path' in data && data.path !== '') ? data.path : location.pathname;
newLocation += ('search' in data && data.search !== '') ? `${data.search}` : `${location.search}`;
newLocation += ('search' in data && data.search !== '') ? `{$data.search}` : `{$location.search}`;
// location.hash is set by (".change-tab") at line 198 for settings
newLocation += ('hash' in data && data.hash !== '' ) ? data.hash : location.hash;
if (data.message) {

View file

@ -38,7 +38,7 @@ foreach ($requiredClasses as $className) {
include(__DIR__ . "/sccpManClasses/$className.class.php");
}
if (class_exists($class, false)) {
${$className} = new $class();
{$$className} = new $class();
}
}
@ -356,36 +356,36 @@ function InstallDB_updateSchema($db_config)
foreach ($priorSchemaFields as $table => $fieldsArr) {
// First get any data in columns to be deleted ( _Column)
$sqlMatch = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} ${column} IS NOT NULL OR";
return "{$carry} {$column} IS NOT NULL OR";
});
unset($column);
$sqlFields = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} ${column} AS " . ltrim($column,"_") .",";
return "{$carry} {$column} AS " . ltrim($column,"_") .",";
});
$sqlMatch = rtrim($sqlMatch, "OR");
$sqlFields = rtrim($sqlFields, ",");
$stmt = $db->prepare("SELECT name, ${sqlFields} FROM ${table} WHERE ${sqlMatch}");
$stmt = $db->prepare("SELECT name, {$sqlFields} FROM {$table} WHERE {$sqlMatch}");
$stmt->execute();
$dbResult = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
// Now move any data found from _Column to Column. This is safe as the two should not exist.
if (!empty($dbResult)) {
foreach ($dbResult as $name => $columnArr) {
$sqlVar = array_reduce(array_keys($columnArr), function($carry, $key) use ($columnArr){
$carry .= (isset($columnArr[$key])) ? "${key} = '${columnArr[$key]}'," : "";
$carry .= (isset($columnArr[$key])) ? "{$key} = '{$columnArr[$key]}'," : "";
return $carry;
});
$sqlVar = rtrim($sqlVar, ",");
$stmt = $db->prepare("UPDATE ${table} SET ${sqlVar} WHERE name = '${name}'");
$stmt = $db->prepare("UPDATE {$table} SET {$sqlVar} WHERE name = '{$name}'");
$stmt->execute();
}
}
// Processed all _Column names; now safe to delete them
$sqlDrop = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} DROP COLUMN ${column},";
return "{$carry} DROP COLUMN {$column},";
});
$sqlDrop = rtrim($sqlDrop, ", ");
$stmt = $db->prepare("ALTER TABLE ${table} ${sqlDrop}");
$stmt = $db->prepare("ALTER TABLE {$table} {$sqlDrop}");
$stmt->execute();
}
@ -1007,7 +1007,7 @@ function checkTftpServer() {
// TODO: Depending on distro, do we have write permissions
foreach ($possibleFtpDirs as $dirToTest) {
if (is_dir($dirToTest) && is_writable($dirToTest)) {
$tempFile = "${dirToTest}/{$remoteFileName}";
$tempFile = "{$dirToTest}/{$remoteFileName}";
file_put_contents($tempFile, $remoteFileContent);
// try to pull the written file through tftp.
@ -1233,11 +1233,11 @@ function cleanUpSccpSettings() {
$db_result = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
foreach ($db_result as $key => $value) {
if (!empty($settingsFromDb[$key]['data'])) {
$sql_modify .= "ALTER COLUMN ${key} SET DEFAULT '{$settingsFromDb[$key]['data']}', ";
$sql_modify .= "ALTER COLUMN {$key} SET DEFAULT '{$settingsFromDb[$key]['data']}', ";
}
}
$sql_modify = rtrim($sql_modify, ', ');
$stmt = $db->prepare("ALTER TABLE {$table} ${sql_modify}");
$stmt = $db->prepare("ALTER TABLE {$table} {$sql_modify}");
$stmt->execute();
}

View file

@ -209,10 +209,10 @@ class Sccp extends \FreePBX\modules\Core\Driver {
//when called from extensions as delete, id can be a list of ids
// TODO: Could be other buttons that refer this id (by name rather than id) - need to clear these as well.
foreach (array($id) as $clearId) {
$this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${clearId}%' AND buttontype = 'line'");
$this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '{$clearId}%' AND buttontype = 'line'");
$this->delId[] = $clearId;
// Delete the line as requested - if edit will add again in addDevice
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${clearId}");
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = {$clearId}");
$sth->execute();
}
return true;

View file

@ -212,43 +212,43 @@ class dbinterface
if (!strpos($filter['model'], 'loadInformation')) {
$filter['model'] = 'loadInformation' . $filter['model'];
}
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model");
$stmt->bindParam(':model', $filter['model'], \PDO::PARAM_STR);
} else {
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
}
break;
case 'byid':
if (isset($filter['model'])) {
$stmtU = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model");
$stmtU = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model");
$stmtU->bindParam(':model', $filter['model'],\PDO::PARAM_STR);
} else {
$stmtU = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model");
$stmtU = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
}
$stmtU->execute();
return $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
break;
case 'expansion':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model");
break;
case 'enabled':
//$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones.
//break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones.
case 'phones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model");
break;
case 'disabled':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 0) ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 0) ORDER BY model");
break;
case 'ciscophones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) != '-sip' ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) != '-sip' ORDER BY model");
break;
case 'sipphones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) = '-sip' ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) = '-sip' ORDER BY model");
break;
case 'all': // Fall through to default
default:
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model");
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
break;
}
$stmt->execute();
@ -288,7 +288,7 @@ class dbinterface
$formattedSQL = array_reduce(
array_keys($save_value), // pass in the array_keys instead of the array here
function ($carry, $key) use ($save_value) { // ... then 'use' the actual array here
return "${carry}${key} = '${save_value[$key]}', ";
return "{$carry}{$key} = '{$save_value[$key]}', ";
},
);
if (isset($formattedSQL)) { // if array is empty returns null
@ -296,13 +296,13 @@ class dbinterface
switch ($mode) {
case 'delete':
if (array_key_exists($key_fld, $save_value)) {
$sql_key = "${key_fld} = '${save_value[$key_fld]}'"; //quote data as normally is string
$sql_key = "{$key_fld} = '{$save_value[$key_fld]}'"; //quote data as normally is string
$stmt = $this->db->prepare("DELETE FROM {$table_name} WHERE {$sql_key}");
}
break;
case 'update':
if (array_key_exists($key_fld, $save_value)) {
$sql_key = "${key_fld} = '${save_value[$key_fld]}'"; //quote data as normally is string
$sql_key = "{$key_fld} = '{$save_value[$key_fld]}'"; //quote data as normally is string
$stmt = $this->db->prepare("UPDATE {$table_name} SET {$formattedSQL} WHERE {$sql_key}");
}
break;
@ -364,7 +364,7 @@ class dbinterface
switch ($dataid) {
case "DeviceById":
// TODO: This needs to be rewritten
$stmt = $this->db->prepare("SELECT keyword,data FROM sip WHERE id = '${line}'");
$stmt = $this->db->prepare("SELECT keyword,data FROM sip WHERE id = '{$line}'");
$stmt->execute();
$tech = $stmt->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP);
foreach ($tech as &$value) {

View file

@ -473,9 +473,9 @@ class formcreate
if (isset($currentValue[$i])) {
$val_check = (($valToCheck == strtolower($currentValue[$i])) || ($valToCheck == '' && $currentValue[$i] == '' )) ? 'checked' : '';
}
echo "<input type=checkbox name= ${res_id}_{$i} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
echo "<input type=checkbox name= {$res_id}_{$i} id={$res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
} else {
echo "<input type=radio name= {$res_id} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
echo "<input type=radio name= {$res_id} id={$res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
}
echo "<label for= {$res_id}_{$i}>{$value}</label>";
$i++;

View file

@ -256,9 +256,9 @@ class xmlinterface
//Now have an array of srst addresses - maybe empty
foreach ($srst_addrs as $netKey => $netValue) {
$nodeName = "ipAddr${netKey}";
$nodeName = "ipAddr{$netKey}";
$xnode->$nodeName = $netValue['ip'];
$nodeName = "port${netKey}";
$nodeName = "port{$netKey}";
$xnode->$nodeName = $netValue['port'];
}
break;

View file

@ -373,7 +373,7 @@ trait ajaxHelper {
}
// Have default to be saved to db table default
$tableName_def = "{$tableName}_def";
if ((array_key_exists($key, ${$tableName_def})) && (${$tableName_def}[$key]['data'] == $value)) {
if ((array_key_exists($key, {$$tableName_def})) && ({$$tableName_def}[$key]['data'] == $value)) {
// Value unchanged so ignore
} else {
$dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value);
@ -556,7 +556,7 @@ trait ajaxHelper {
case 'daysdisplaynotactive' :
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
foreach ($searchArr as $settingsVal) {
$value .= (isset($get_settings["sccpdevice_${settingsVal}"])) ? $get_settings["sccpdevice_${settingsVal}"] . ',' : '';
$value .= (isset($get_settings["sccpdevice_{$settingsVal}"])) ? $get_settings["sccpdevice_{$settingsVal}"] . ',' : '';
}
$value = rtrim($value,',');
break;
@ -618,16 +618,16 @@ trait ajaxHelper {
break;
default:
// handle vendor prefix
if (!empty($get_settings["${hdr_vendPrefix}${key}"])) {
$value = $get_settings["${hdr_vendPrefix}${key}"];
if (!empty($get_settings["{$hdr_vendPrefix}{$key}"])) {
$value = $get_settings["{$hdr_vendPrefix}{$key}"];
}
// handle array prefix
if (!empty($get_settings["${hdr_arprefix}${key}"])) {
if (!empty($get_settings["{$hdr_arprefix}{$key}"])) {
// Only 3 types of array returned permit,deny, setvar
$arr_data = '';
$arr_clear = false;
$output = array();
foreach ($get_settings["${hdr_arprefix}${key}"] as $netValue) {
foreach ($get_settings["{$hdr_arprefix}{$key}"] as $netValue) {
switch ($key) {
case 'permit':
case 'deny';

View file

@ -160,7 +160,7 @@ trait helperfunctions {
private function getTableEnums($table) {
$enumFields = array();
$sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_${table}");
$sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}");
foreach ($sccpTableDesc as $key => $data) {
$typeArray = explode('(', $data['Type']);
if ($typeArray[0] == 'enum') {
@ -301,7 +301,7 @@ trait helperfunctions {
// write a sentinel to a tftp subdirectory to see if mapping is working
if (is_dir($testFtpDir) && is_writable($testFtpDir)) {
$tempFile = "${testFtpDir}/{$remoteFileName}";
$tempFile = "{$testFtpDir}/{$remoteFileName}";
file_put_contents($tempFile, $remoteFileContent);
// try to pull the written file through tftp.
// this way we can determine if mapping is active and using sccp_manager maps

View file

@ -44,7 +44,7 @@ if (!empty($_REQUEST['id'])) {
if (array_key_exists($key, $enumFields)){
// This field is (now) an enum. Check the current value is acceptable.
// Quote value as enum values are quoted.
if (in_array("'${val}'", $enumFields[$key])) {
if (in_array("'{$val}'", $enumFields[$key])) {
// The value is valid so will keep
$def_val[$key] = array('keyword' => $key, 'data' => $val, 'seq' => 99);
}