diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php
index db1837d..42d3433 100644
--- a/Sccp_manager.class.php
+++ b/Sccp_manager.class.php
@@ -624,7 +624,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$result = array();
if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) {
- if (!$this->getFileListFromProvisioner($this->sccppath['tftp_path'])) {
+ if (!$this->getFileListFromProvisioner($this->sccpvalues['tftp_path']['data'])) {
// File does not exist and cannot get from internet.
return $result;
};
@@ -695,7 +695,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/
function initializeSccpPath() {
-
$this->sccppath = array(
'asterisk' => $this->sccpvalues['asterisk_etc_path']['data'],
'tftp_path' => $this->sccpvalues['tftp_path']['data'],
@@ -923,7 +922,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$hw_addon = explode(',', $dev_config['addon']);
foreach ($hw_addon as $key) {
$hw_data = $this->getSccpModelInformation('byid', false, "all", array('model' => $key));
- $dev_config['addon_info'][$key] = $hw_data[0]['loadimage'];
+ $dev_config['addon_info'][$key] = $hw_data[$key]['loadimage'];
}
}
if (!$sccp_native) {
diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js
index 373d103..8052d27 100644
--- a/assets/js/sccp_manager.js
+++ b/assets/js/sccp_manager.js
@@ -114,10 +114,6 @@ $(document).ready(function () {
});
});
- $(".input-js-add").click(function () {
- add_dynamic_input($(this), $(this).data('for'), "", "");
- });
-
$(".table").on('click', '.table-js-add', function (e) {
add_dynamic_table($(this), $(this).data('for'), "", "");
});
@@ -934,32 +930,51 @@ function load_oncliсk(e, data)
}
}
+// call from here not document.ready as have dynamic content
+$(document).on('click', ".input-js-remove" , function () {
+ // delete the current row
+ var pname = $(this).data('id');
+ $('#' + pname).remove();
+});
-function add_dynamic_input(pe, pclass, vdefault)
-{
- // We'd like a new one, please.
- pcls = pe.data('for');
- pname = pe.data('id');
- pmax = pe.data('max');
- jdata = JSON.parse(hex2bin(pe.data('json')));
+$(document).on('click', ".input-js-add" , function () {
+ // Add new row to networks or ip array
+ var pcls = $(this).data('for'),
+ pname = $(this).data('id'),
+ pmax = $(this).data('max'),
+ prow = $(this).data('row'),
+ pcount = $("." + pcls).length;
+ if (pcount == pmax){
+ //already reached max elements
+ return;
+ }
- var last = $("." + pcls + ":last"),
- ourid = last.data('nextid'),
- nextid = ourid + 1;
- var html = "
";
+ jdata = JSON.parse(hex2bin($(this).data('json')));
+
+ var last = $("." + pcls).last(),
+ ourid = last.data('nextid'),
+ nextid = ourid + 1,
+ html = "
";
for (var key in jdata) {
html_opt = '';
- html_calss = jdata[key]['class'];
for (var skey in jdata[key]['options']) {
html_opt += ' ' + skey + '="' + jdata[key]['options'][skey] + '"';
}
- html += " " + jdata[key]['nameseparator'] + " ";
+ html += " " + jdata[key]['nameseparator'] + " ";
}
+ // add remove button
+ html += "";
+ // add plus button
+ html += "";
html += "
\n";
- if (pmax >= nextid) {
- last.after(html);
- }
-}
+
+ last.after(html);
+
+ $('#' + pname + prow + '-btn-add').remove();
+});
function del_dynamic_table(pe, pclass, vdefault)
{
diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433
index 3a53000..7cfe35e 100644
--- a/conf/sccpgeneral.xml.v433
+++ b/conf/sccpgeneral.xml.v433
@@ -166,6 +166,23 @@ and open the template in the editor. Base Version before all crash :-)
+
+
+ deny
+ 0.0.0.0/0.0.0.0
+
+
+
+
+
+
+
+
+ +
+ 5
+ Add Deny network
+ All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.
+ permit
@@ -178,6 +195,7 @@ and open the template in the editor. Base Version before all crash :-)
+
+ 5Add Allow RangeAllow network settings. Blank fields will be ignored used Network 0.0.0.0/0.0.0.0 to resolve any existing connections. You can use the 'internal' connections only from the networks connected to the server.
@@ -195,30 +213,13 @@ and open the template in the editor. Base Version before all crash :-)
+
+ 5Add Internal RangeLocal network settings. Blank fields will be ignored used Network 0.0.0.0.
-
-
- deny
- 0.0.0.0/0.0.0.0
-
-
-
-
-
-
-
-
- +
- Add Deny network
- All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.
- ccm_address
- Internal
- 0.0.0.0:2000
@@ -228,6 +229,7 @@ and open the template in the editor. Base Version before all crash :-)
+
+ 5Add AddressThis function is useful when the server has many interfaces, but devices must connect only to some interfaces.
@@ -712,7 +714,7 @@ and open the template in the editor. Base Version before all crash :-)
srst_ip3/
-
+
@@ -1683,6 +1685,7 @@ and open the template in the editor. Base Version before all crash :-)
+
+ 5Add Deny networkAll RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.
@@ -1690,11 +1693,7 @@ and open the template in the editor. Base Version before all crash :-)
permitNONE
- Inherit
- false
- sccp_hw-ar_permit-grinternal
-
sccp_hw_net_inherit
@@ -1703,6 +1702,7 @@ and open the template in the editor. Base Version before all crash :-)
+
+ 5Add Allow networkAllow network settings. Blank fields will be ignored used Network 0.0.0.0.
@@ -2022,6 +2022,7 @@ and open the template in the editor. Base Version before all crash :-)
col-md-9+
+ 3
diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php
index 0c564da..ef42b59 100644
--- a/sccpManClasses/dbinterface.class.php
+++ b/sccpManClasses/dbinterface.class.php
@@ -266,7 +266,7 @@ class dbinterface
$this->db->prepare('TRUNCATE sccpsettings')->execute();
$stmt = $this->db->prepare('INSERT INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)');
} else {
- $stmt = $this->db->prepare('REPLACE INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)');
+ $stmt = $this->db->prepare('REPLACE INTO sccpsettings (keyword, seq, type, data, systemdefault) VALUES (:keyword,:seq,:type,:data,:systemdefault)');
}
foreach ($save_value as $key => $dataArr) {
if (empty($dataArr)) {
diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php
index 65c2419..7b0726d 100644
--- a/sccpManClasses/formcreate.class.php
+++ b/sccpManClasses/formcreate.class.php
@@ -4,6 +4,8 @@ namespace FreePBX\modules\Sccp_manager;
class formcreate
{
+ use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions;
+
public function __construct($parent_class = null) {
$this->buttonDefLabel = 'chan-sccp';
$this->buttonHelpLabel = 'site';
@@ -174,6 +176,8 @@ class formcreate
}
function addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref) {
+ //$Sccp_manager = \FreePBX::create()->Sccp_manager;
+ // IED fields are arrays of networks and masks, or ip and ports.
$res_input = '';
$res_value = '';
$opt_at = array();
@@ -187,20 +191,27 @@ class formcreate
// $res_value
$lnhtm = '';
$res_id = $napref.$child->name;
- $i = 0;
+ //$i = 0;
$max_row = 255;
if (!empty($child->max_row)) {
$max_row = $child->max_row;
}
+ // fvalues are current settings - the encoding depends on where the data is
+ // coming from: IED fields in sccpsettings are json, elsewhere they are ; delimited.
if (!empty($fvalues[$res_n])) {
if (!empty($fvalues[$res_n]['data'])) {
- $res_value = explode(';', $fvalues[$res_n]['data']);
+ $res_value = $this->convertCsvToArray($fvalues[$res_n]['data']);
}
}
+
+ if ($res_n == 'srst_ip') {
+ $res_value = $this->convertCsvToArray($sccp_defaults[$res_n]['data']);
+ }
if (empty($res_value)) {
$res_value = array((string) $child->default);
}
+
?>
@@ -218,15 +229,21 @@ class formcreate
echo '
';
foreach ($child->xpath('cbutton') as $value) {
$res_n = $res_id.'[0]['.$value['field'].']';
- $res_vf = '';
+ // res_vf sets the state of the checkbox internal. This is always
+ // the first array element in $res_value if set
+ $res_vf = false;
if ($value['value']=='NONE' && empty($res_value)) {
- $res_vf = 'active';
+ $res_vf = true;
}
- $ch_key = array_search($value['value'], $res_value);
- if ($ch_key !== false) {
- unset($res_value[$ch_key]);
- $res_vf = 'active';
- $res_value = explode(';', implode(';', $res_value));
+ if ((isset($res_value[0]['internal'])) || ($res_value[0] == 'internal')) {
+ $res_vf = true;
+ // Remove the value from $res_value so that do not add empty row for internal
+ array_shift($res_value);
+ // If now have an empty array, add a new empty element
+ if (count($res_value) == 0) {
+ // although handle also ip, internal is never set for those arrays
+ $res_value[0] = array('net'=>"", 'mask' =>"");
+ }
}
$opt_hide ='';
$opt_class="button-checkbox";
@@ -250,9 +267,9 @@ class formcreate
$opt_class .= " ".(string)$value->class;
}
- echo '';
+ echo '';
}
echo '