Add FW and Template availability to sccpdevmodel
Rename menu items Add new fields to sccpdevmodel to show existence of firmware and template files, thereby reducing load times.
This commit is contained in:
parent
e9a3bf34df
commit
485ce3fe3a
|
@ -1005,10 +1005,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
return $filename;
|
||||
}
|
||||
function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) {
|
||||
$modelList = $this->dbinterface->getModelInfoFromDb($get, $format_list, $filter);
|
||||
|
||||
if (!$validate) {
|
||||
return $modelList;
|
||||
}
|
||||
// Here so want to see if FW and template files exist on TFTP server.
|
||||
|
||||
$needToCheckFw = array_search('no', array_column($modelList, 'fwfound'), true);
|
||||
$needToCheckTemp = array_search('no', array_column($modelList, 'templatefound'), true);
|
||||
|
||||
if (!$needToCheckFw && !$needToCheckTemp) {
|
||||
// in modellist, all firmware shows as being available (no not found for either)
|
||||
return $modelList;
|
||||
}
|
||||
$file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin', '.SBN', '.LOADS');
|
||||
$dir = $this->sccpvalues['tftp_firmware_path']['data'];
|
||||
|
||||
$search_mode = $this->sccpvalues['tftp_rewrite']['data'];
|
||||
|
||||
switch ($search_mode) {
|
||||
case 'pro':
|
||||
case 'on':
|
||||
|
@ -1020,18 +1034,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$dir_list = $this->findAllFiles($dir, $file_ext, 'dirFileBaseName');
|
||||
break;
|
||||
}
|
||||
$modelList = $this->dbinterface->getModelInfoFromDb($get, $format_list, $filter);
|
||||
//dbug($modelList);
|
||||
if ($validate) {
|
||||
foreach ($modelList as &$raw_settings) {
|
||||
if (!empty($raw_settings['loadimage'])) {
|
||||
$raw_settings['fwFound'] = false;
|
||||
if ((!empty($raw_settings['loadimage'])) && ($raw_settings['fwfound'] === 'no')) {
|
||||
switch ($search_mode) {
|
||||
case 'pro':
|
||||
case 'on':
|
||||
case 'internal':
|
||||
if (in_array($raw_settings['loadimage'], $dir_list, true)) {
|
||||
$raw_settings['fwFound'] = true;
|
||||
$raw_settings['fwfound'] = 'yes';
|
||||
}
|
||||
break;
|
||||
case 'internal2':
|
||||
|
@ -1039,28 +1049,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
case 'off':
|
||||
default: // Place in root TFTP dir
|
||||
if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) {
|
||||
$raw_settings['fwFound'] = true;
|
||||
$raw_settings['fwfound'] = 'yes';
|
||||
}
|
||||
break;
|
||||
}
|
||||
} //else {
|
||||
//$raw_settings['validate'] = '-;';
|
||||
//}
|
||||
$raw_settings['templateFound'] = false;
|
||||
}
|
||||
if (!empty($raw_settings['nametemplate'])) {
|
||||
$file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings['nametemplate'];
|
||||
if (file_exists($file)) {
|
||||
$raw_settings['templateFound'] = true;
|
||||
} //else {
|
||||
//$raw_settings['templateFound'] .= 'no';
|
||||
//}
|
||||
} //else {
|
||||
//$raw_settings['validate'] .= '-';
|
||||
//}
|
||||
$raw_settings['templatefound'] = 'yes';
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($raw_settings); // passed as reference so must unset.
|
||||
dbug($modelList);
|
||||
// Now need to update database to avoid checks in future
|
||||
// // TODO: First pass - need to refine.
|
||||
foreach ($modelList as $key => $value) {
|
||||
$this->dbinterface->write('sccpdevmodel', $value, 'replace');
|
||||
}
|
||||
return $modelList;
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ function Get_DB_config($sccp_compatible)
|
|||
'modify' => "enum('sccpdevice', 'sipdevice', 'sccpuser')" ),
|
||||
)
|
||||
);
|
||||
// Hardware Mobile. Can switch Softwate to Hardware
|
||||
// Hardware Mobile. Can switch Software to Hardware
|
||||
$db_config_v4M = array(
|
||||
'sccpdevmodel' => array(
|
||||
'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL")
|
||||
|
@ -305,6 +305,10 @@ function Get_DB_config($sccp_compatible)
|
|||
),
|
||||
'sccpsettings' => array(
|
||||
'systemdefault' => array('create' => "VARCHAR(255) NULL default ''")
|
||||
),
|
||||
'sccpdevmodel' => array(
|
||||
'fwfound' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')"),
|
||||
'templatefound' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')")
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -318,6 +322,7 @@ function Get_DB_config($sccp_compatible)
|
|||
$db_config_v4['sccpdevice'] = array_merge($db_config_v4['sccpdevice'],$db_config_v5['sccpdevice']);
|
||||
$db_config_v4['sccpline'] = array_merge($db_config_v4['sccpline'],$db_config_v5['sccpline']);
|
||||
$db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings'];
|
||||
$db_config_v4['sccpdevmodel'] = $db_config_v5['sccpdevmodel'];
|
||||
}
|
||||
return $db_config_v4;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<module>
|
||||
<rawname>sccp_manager</rawname>
|
||||
<name>SCCP Manager</name>
|
||||
<version>16.0.0.1</version>
|
||||
<version>16.0.0.2</version>
|
||||
<type>setup</type>
|
||||
<category>SCCP Connectivity</category>
|
||||
<publisher>Steve Lad, Alex GP</publisher>
|
||||
|
@ -9,8 +9,8 @@
|
|||
<description>SCCP Phone and Extension Manager</description>
|
||||
<menuitems>
|
||||
<sccpsettings sort="1">Server Config</sccpsettings>
|
||||
<sccp_adv sort="2">System Parameters</sccp_adv>
|
||||
<sccp_phone sort="3">Phones Manager</sccp_phone>
|
||||
<sccp_adv sort="2">Phone Types</sccp_adv>
|
||||
<sccp_phone sort="3">Lines and Devices</sccp_phone>
|
||||
</menuitems>
|
||||
<changelog>
|
||||
* Version 13.0.0.1 * - Alfa Release tested on freepbx v.13.0.192.16, v.14.0.1.5
|
||||
|
@ -250,6 +250,8 @@
|
|||
<field name="loadinformationid" type="string" length="30" notnull="false"/>
|
||||
<field name="enabled" type="integer" default="0" notnull="false"/>
|
||||
<field name="nametemplate" type="string" length="50" notnull="false"/>
|
||||
<field name="fwfound" type="string" length="50" notnull="false"/>
|
||||
<field name="templatefound" type="string" length="50" notnull="false"/>
|
||||
<key name="model" type="index">
|
||||
<column name="model"/>
|
||||
</key>
|
||||
|
|
|
@ -17,7 +17,7 @@ if (!defined('FREEPBX_IS_AUTH')) {
|
|||
$spage = FreePBX::create()->Sccp_manager;
|
||||
if (empty($spage->class_error)) {
|
||||
$display_page = $spage->advServerShowPage();
|
||||
$display_info = _("SCCP Advance Server Configuration");
|
||||
$display_info = _("Phone Management");
|
||||
} else {
|
||||
$display_page = $spage->infoServerShowPage();
|
||||
$display_info = _("SCCP Server Configuration");
|
||||
|
|
|
@ -202,9 +202,9 @@ class dbinterface
|
|||
|
||||
function getModelInfoFromDb($get = 'all', $format_list = 'all', $filter = array())
|
||||
{
|
||||
$sel_inf = "*, model, false as fwFound, false as templateFound";
|
||||
$sel_inf = "*, model";
|
||||
if ($format_list === 'model') {
|
||||
$sel_inf = "model, vendor, dns, buttons, false as fwFound, false as templateFound";
|
||||
$sel_inf = "model, vendor, dns, buttons";
|
||||
}
|
||||
switch ($get) {
|
||||
case 'byciscoid':
|
||||
|
|
|
@ -25,7 +25,6 @@ trait bmoFunctions {
|
|||
$this->dialTemplateData = json_encode($this->getDialTemplate());
|
||||
$this->softKeyData = json_encode($this->getSoftKey());
|
||||
$this->deviceModelData = json_encode($this->ajaxHandler($_REQUEST = array('command'=>'getDeviceModel', 'type'=>'enabled')));
|
||||
dbug($this->deviceModelData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -302,14 +302,14 @@ include($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views/getFileModa
|
|||
|
||||
function SetColFirmNf(value, row, index) {
|
||||
//if (row['validate'].split(';')[0] === 'no') {
|
||||
if (!row['fwFound']) {
|
||||
if (row['fwfound'] === 'no') {
|
||||
return "File not found<br />" + value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function SetColTemplNf(value, row, index) {
|
||||
//if (row['validate'].split(';')[1] === 'no') {
|
||||
if (!row['templateFound']) {
|
||||
if (row['templatefound'] === 'no') {
|
||||
return "File not found<br /> " + value ;
|
||||
}
|
||||
return value;
|
||||
|
@ -320,7 +320,7 @@ include($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views/getFileModa
|
|||
if (row['enabled'] === 1) {
|
||||
tclass = (index % 2 === 0) ? "info" : "info";
|
||||
}
|
||||
if (row['fwFound']) {
|
||||
if (row['fwfound'] === 'yes') {
|
||||
// tclass = (row['enabled'] === '1') ? "danger" : "warning";
|
||||
} else {
|
||||
tclass = (row['enabled'] === '1') ? "danger" : "warning";
|
||||
|
|
|
@ -56,6 +56,7 @@ if (!empty($_REQUEST['id'])) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// TODO: dev_id should always be set so do not need this??
|
||||
if (empty($dev_id)) {
|
||||
$dev_id = 'new';
|
||||
} else {
|
||||
|
@ -69,10 +70,10 @@ if (!empty($def_val['type']['data'])) {
|
|||
if (isset($tmp_raw[$def_val['type']['data']])) {
|
||||
$tmp_raw = $tmp_raw[$def_val['type']['data']];
|
||||
}
|
||||
if (!$tmp_raw['fwFound']) {
|
||||
if ($tmp_raw['fwfound'] === 'no') {
|
||||
$device_warning['Image'] = array('Device firmware not found : '.$tmp_raw['loadimage']);
|
||||
}
|
||||
if (!$tmp_raw['templateFound']) {
|
||||
if ($tmp_raw['templatefound'] === 'no') {
|
||||
$device_warning['Template'] = array('Missing device configuration template : '. $tmp_raw['nametemplate']);
|
||||
}
|
||||
if (!empty($device_warning)) {
|
||||
|
|
Loading…
Reference in a new issue