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:
stevenA 2022-01-18 16:05:49 +01:00
parent e9a3bf34df
commit 485ce3fe3a
8 changed files with 69 additions and 56 deletions

View file

@ -1005,10 +1005,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
return $filename; return $filename;
} }
function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { 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'); $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin', '.SBN', '.LOADS');
$dir = $this->sccpvalues['tftp_firmware_path']['data']; $dir = $this->sccpvalues['tftp_firmware_path']['data'];
$search_mode = $this->sccpvalues['tftp_rewrite']['data']; $search_mode = $this->sccpvalues['tftp_rewrite']['data'];
switch ($search_mode) { switch ($search_mode) {
case 'pro': case 'pro':
case 'on': case 'on':
@ -1020,47 +1034,39 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$dir_list = $this->findAllFiles($dir, $file_ext, 'dirFileBaseName'); $dir_list = $this->findAllFiles($dir, $file_ext, 'dirFileBaseName');
break; break;
} }
$modelList = $this->dbinterface->getModelInfoFromDb($get, $format_list, $filter); foreach ($modelList as &$raw_settings) {
//dbug($modelList); if ((!empty($raw_settings['loadimage'])) && ($raw_settings['fwfound'] === 'no')) {
if ($validate) { switch ($search_mode) {
foreach ($modelList as &$raw_settings) { case 'pro':
if (!empty($raw_settings['loadimage'])) { case 'on':
$raw_settings['fwFound'] = false; case 'internal':
switch ($search_mode) { if (in_array($raw_settings['loadimage'], $dir_list, true)) {
case 'pro': $raw_settings['fwfound'] = 'yes';
case 'on': }
case 'internal': break;
if (in_array($raw_settings['loadimage'], $dir_list, true)) { case 'internal2':
$raw_settings['fwFound'] = true; break;
} case 'off':
break; default: // Place in root TFTP dir
case 'internal2': if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) {
break; $raw_settings['fwfound'] = 'yes';
case 'off': }
default: // Place in root TFTP dir break;
if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) { }
$raw_settings['fwFound'] = true; }
} if (!empty($raw_settings['nametemplate'])) {
break; $file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings['nametemplate'];
} if (file_exists($file)) {
} //else { $raw_settings['templatefound'] = 'yes';
//$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'] .= '-';
//}
} }
} }
unset($raw_settings); // passed as reference so must unset. 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; return $modelList;
} }

View file

@ -182,7 +182,7 @@ function Get_DB_config($sccp_compatible)
'modify' => "enum('sccpdevice', 'sipdevice', 'sccpuser')" ), 'modify' => "enum('sccpdevice', 'sipdevice', 'sccpuser')" ),
) )
); );
// Hardware Mobile. Can switch Softwate to Hardware // Hardware Mobile. Can switch Software to Hardware
$db_config_v4M = array( $db_config_v4M = array(
'sccpdevmodel' => array( 'sccpdevmodel' => array(
'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL") 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL")
@ -289,7 +289,7 @@ function Get_DB_config($sccp_compatible)
'_description' => array('rename' => 'description'), '_description' => array('rename' => 'description'),
'keepalive' => array('create' => "INT(11) DEFAULT '60'", 'modify' => 'INT(11)', 'def_modify' => "60") 'keepalive' => array('create' => "INT(11) DEFAULT '60'", 'modify' => 'INT(11)', 'def_modify' => "60")
), ),
'sccpline' => array ( 'sccpline' => array(
'regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), 'regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"),
'transfer_on_hangup' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), 'transfer_on_hangup' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
'autoselectline_enabled' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), 'autoselectline_enabled' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
@ -303,9 +303,13 @@ function Get_DB_config($sccp_compatible)
'_backgroundImageAccess' => array('rename' => 'backgroundImageAccess'), '_backgroundImageAccess' => array('rename' => 'backgroundImageAccess'),
'_callLogBlfEnabled' => array('rename' => 'callLogBlfEnabled') '_callLogBlfEnabled' => array('rename' => 'callLogBlfEnabled')
), ),
'sccpsettings' => array ( 'sccpsettings' => array(
'systemdefault' => array('create' => "VARCHAR(255) NULL default ''") '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')")
)
); );
if ($sccp_compatible >= 433) { if ($sccp_compatible >= 433) {
@ -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['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['sccpline'] = array_merge($db_config_v4['sccpline'],$db_config_v5['sccpline']);
$db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings']; $db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings'];
$db_config_v4['sccpdevmodel'] = $db_config_v5['sccpdevmodel'];
} }
return $db_config_v4; return $db_config_v4;
} }

View file

@ -1,7 +1,7 @@
<module> <module>
<rawname>sccp_manager</rawname> <rawname>sccp_manager</rawname>
<name>SCCP Manager</name> <name>SCCP Manager</name>
<version>16.0.0.1</version> <version>16.0.0.2</version>
<type>setup</type> <type>setup</type>
<category>SCCP Connectivity</category> <category>SCCP Connectivity</category>
<publisher>Steve Lad, Alex GP</publisher> <publisher>Steve Lad, Alex GP</publisher>
@ -9,8 +9,8 @@
<description>SCCP Phone and Extension Manager</description> <description>SCCP Phone and Extension Manager</description>
<menuitems> <menuitems>
<sccpsettings sort="1">Server Config</sccpsettings> <sccpsettings sort="1">Server Config</sccpsettings>
<sccp_adv sort="2">System Parameters</sccp_adv> <sccp_adv sort="2">Phone Types</sccp_adv>
<sccp_phone sort="3">Phones Manager</sccp_phone> <sccp_phone sort="3">Lines and Devices</sccp_phone>
</menuitems> </menuitems>
<changelog> <changelog>
* Version 13.0.0.1 * - Alfa Release tested on freepbx v.13.0.192.16, v.14.0.1.5 * 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="loadinformationid" type="string" length="30" notnull="false"/>
<field name="enabled" type="integer" default="0" notnull="false"/> <field name="enabled" type="integer" default="0" notnull="false"/>
<field name="nametemplate" type="string" length="50" 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"> <key name="model" type="index">
<column name="model"/> <column name="model"/>
</key> </key>

View file

@ -17,7 +17,7 @@ if (!defined('FREEPBX_IS_AUTH')) {
$spage = FreePBX::create()->Sccp_manager; $spage = FreePBX::create()->Sccp_manager;
if (empty($spage->class_error)) { if (empty($spage->class_error)) {
$display_page = $spage->advServerShowPage(); $display_page = $spage->advServerShowPage();
$display_info = _("SCCP Advance Server Configuration"); $display_info = _("Phone Management");
} else { } else {
$display_page = $spage->infoServerShowPage(); $display_page = $spage->infoServerShowPage();
$display_info = _("SCCP Server Configuration"); $display_info = _("SCCP Server Configuration");

View file

@ -202,9 +202,9 @@ class dbinterface
function getModelInfoFromDb($get = 'all', $format_list = 'all', $filter = array()) 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') { if ($format_list === 'model') {
$sel_inf = "model, vendor, dns, buttons, false as fwFound, false as templateFound"; $sel_inf = "model, vendor, dns, buttons";
} }
switch ($get) { switch ($get) {
case 'byciscoid': case 'byciscoid':

View file

@ -25,7 +25,6 @@ trait bmoFunctions {
$this->dialTemplateData = json_encode($this->getDialTemplate()); $this->dialTemplateData = json_encode($this->getDialTemplate());
$this->softKeyData = json_encode($this->getSoftKey()); $this->softKeyData = json_encode($this->getSoftKey());
$this->deviceModelData = json_encode($this->ajaxHandler($_REQUEST = array('command'=>'getDeviceModel', 'type'=>'enabled'))); $this->deviceModelData = json_encode($this->ajaxHandler($_REQUEST = array('command'=>'getDeviceModel', 'type'=>'enabled')));
dbug($this->deviceModelData);
break; break;
default: default:
break; break;
@ -33,7 +32,7 @@ trait bmoFunctions {
} }
function getPhoneGrid(string $type, $activeDevices =array()){ function getPhoneGrid(string $type, $activeDevices =array()){
$dbDevices = array(); $dbDevices = array();
// Find all devices defined in the database. // Find all devices defined in the database.
$dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $type)); $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $type));

View file

@ -302,14 +302,14 @@ include($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views/getFileModa
function SetColFirmNf(value, row, index) { function SetColFirmNf(value, row, index) {
//if (row['validate'].split(';')[0] === 'no') { //if (row['validate'].split(';')[0] === 'no') {
if (!row['fwFound']) { if (row['fwfound'] === 'no') {
return "File not found<br />" + value; return "File not found<br />" + value;
} }
return value; return value;
} }
function SetColTemplNf(value, row, index) { function SetColTemplNf(value, row, index) {
//if (row['validate'].split(';')[1] === 'no') { //if (row['validate'].split(';')[1] === 'no') {
if (!row['templateFound']) { if (row['templatefound'] === 'no') {
return "File not found<br /> " + value ; return "File not found<br /> " + value ;
} }
return value; return value;
@ -320,7 +320,7 @@ include($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views/getFileModa
if (row['enabled'] === 1) { if (row['enabled'] === 1) {
tclass = (index % 2 === 0) ? "info" : "info"; tclass = (index % 2 === 0) ? "info" : "info";
} }
if (row['fwFound']) { if (row['fwfound'] === 'yes') {
// tclass = (row['enabled'] === '1') ? "danger" : "warning"; // tclass = (row['enabled'] === '1') ? "danger" : "warning";
} else { } else {
tclass = (row['enabled'] === '1') ? "danger" : "warning"; tclass = (row['enabled'] === '1') ? "danger" : "warning";

View file

@ -56,6 +56,7 @@ if (!empty($_REQUEST['id'])) {
} }
} }
} }
// TODO: dev_id should always be set so do not need this??
if (empty($dev_id)) { if (empty($dev_id)) {
$dev_id = 'new'; $dev_id = 'new';
} else { } else {
@ -69,10 +70,10 @@ if (!empty($def_val['type']['data'])) {
if (isset($tmp_raw[$def_val['type']['data']])) { if (isset($tmp_raw[$def_val['type']['data']])) {
$tmp_raw = $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']); $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']); $device_warning['Template'] = array('Missing device configuration template : '. $tmp_raw['nametemplate']);
} }
if (!empty($device_warning)) { if (!empty($device_warning)) {