diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 75701cb..6e8669d 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -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,47 +1034,39 @@ 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; - switch ($search_mode) { - case 'pro': - case 'on': - case 'internal': - if (in_array($raw_settings['loadimage'], $dir_list, true)) { - $raw_settings['fwFound'] = true; - } - break; - case 'internal2': - break; - case 'off': - default: // Place in root TFTP dir - if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) { - $raw_settings['fwFound'] = true; - } - 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'] .= '-'; - //} + foreach ($modelList as &$raw_settings) { + 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'] = 'yes'; + } + break; + case 'internal2': + break; + case 'off': + default: // Place in root TFTP dir + if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) { + $raw_settings['fwfound'] = 'yes'; + } + break; + } + } + if (!empty($raw_settings['nametemplate'])) { + $file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings['nametemplate']; + if (file_exists($file)) { + $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; } diff --git a/install.php b/install.php index 5d1d33d..dc23e5b 100644 --- a/install.php +++ b/install.php @@ -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") @@ -289,7 +289,7 @@ function Get_DB_config($sccp_compatible) '_description' => array('rename' => 'description'), '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)"), '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')"), @@ -303,9 +303,13 @@ function Get_DB_config($sccp_compatible) '_backgroundImageAccess' => array('rename' => 'backgroundImageAccess'), '_callLogBlfEnabled' => array('rename' => 'callLogBlfEnabled') ), - 'sccpsettings' => array ( + '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')") + ) ); 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['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; } diff --git a/module.xml b/module.xml index 9922d6d..586b195 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 16.0.0.1 + 16.0.0.2 setup SCCP Connectivity Steve Lad, Alex GP @@ -9,8 +9,8 @@ SCCP Phone and Extension Manager Server Config - System Parameters - Phones Manager + Phone Types + Lines and Devices * Version 13.0.0.1 * - Alfa Release tested on freepbx v.13.0.192.16, v.14.0.1.5 @@ -250,6 +250,8 @@ + + diff --git a/page.sccp_adv.php b/page.sccp_adv.php index 889526b..0eb8ef5 100644 --- a/page.sccp_adv.php +++ b/page.sccp_adv.php @@ -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"); diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 39ecc25..e847bf1 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -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': diff --git a/sccpManTraits/bmoFunctions.php b/sccpManTraits/bmoFunctions.php index 4dc88b8..ed3c428 100644 --- a/sccpManTraits/bmoFunctions.php +++ b/sccpManTraits/bmoFunctions.php @@ -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; @@ -33,7 +32,7 @@ trait bmoFunctions { } function getPhoneGrid(string $type, $activeDevices =array()){ - + $dbDevices = array(); // Find all devices defined in the database. $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $type)); diff --git a/views/advserver.model.php b/views/advserver.model.php index 3f06356..cddf08d 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -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
" + 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
" + 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"; diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 25ea83a..415b4dc 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -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)) {