From 5bfa3bc9309564076ddc4999dda3664e74e69543 Mon Sep 17 00:00:00 2001 From: PhantomVl Date: Mon, 2 Oct 2017 17:10:08 +0300 Subject: [PATCH] Prerelease 02.10.2017 Remove old SEPxxx.conf.XML fron tftpd add device from HotLine Registry. add Adv. Button Line configuration. --- !Readme.txt/SEPXML.txt | 4 +- Sccp_manager.class.php | 84 +++++++++++++++++++++- conf/SEP0000000000.cnf.xml_7940_template | 90 ++++++++++++++++++++++++ conf/sccpgeneral.xml | 44 +++++++++++- conf/sccpgeneral.xml.v0 | 45 +++++++++++- conf/sccpgeneral.xml.v11 | 70 +++++++++++++++++- views/form.adddevice.php | 11 +++ views/form.buttons.php | 9 +++ views/formShow.php | 64 +++++++++++++++-- views/hardware.phone.php | 9 ++- 10 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 conf/SEP0000000000.cnf.xml_7940_template diff --git a/!Readme.txt/SEPXML.txt b/!Readme.txt/SEPXML.txt index b8780db..04f89ce 100644 --- a/!Readme.txt/SEPXML.txt +++ b/!Readme.txt/SEPXML.txt @@ -2,4 +2,6 @@ http://usecallmanager.nz/sepmac-cnf-xml.html http://usecallmanager.nz/line-keys-xml.html http://usecallmanager.nz/user-locale.html https://www.voip-info.org/wiki/view/Asterisk+phone+cisco+79x1+xml+configuration+files+for+SIP -https://www.voip-info.org/wiki/view/Asterisk+phone+cisco+7970+SIP \ No newline at end of file +https://www.voip-info.org/wiki/view/Asterisk+phone+cisco+7970+SIP +https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/all_models/xsi/8_5_1/xsi_dev_guide/xmlobjects.html +https://habrahabr.ru/post/176019/ \ No newline at end of file diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 0e81458..f777d9c 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -20,7 +20,8 @@ * ? Dial Templates - Hoto IT Include in XML.Config ??????? * - Dial Templates in device Configuration ( Enabled / inheret / Disabled ; templet ) * - WiFi Config (Bulk Deployment Utility for Cisco 7921, 7925, 7926)????? - * - Change internal use Field to _Field (new fiture support in chan_sccp ) + * + Change internal use Field to _Field (new fiture support in chan_sccp ) + * + Delete phone XML * + Change Installer ?? (test ) * + DND Mode * - suport kvstore ????? @@ -581,12 +582,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!(strpos($idv, 'SEP') === false)) { $this->sccp_save_db('sccpdevice', array('name' => $idv), 'delete', "name"); $this->sccp_save_db("sccpbuttons", array(), 'delete', '', $idv); + $this->sccp_delete_device_XML($idv); // Концы в вводу !! } } return array('status' => true, 'table_reload' => true, 'message' => 'HW is Delete ! '); } break; case 'create_hw_tftp': + $this->sccp_delete_device_XML('all'); // Концы в вводу !! $this->sccp_create_tftp_XML(); $models = $this->get_db_SccpTableData("SccpDevice"); foreach ($models as $data) { @@ -742,12 +745,26 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_id['description'] = $staus[$id_name]['descr']; $dev_id['status'] = $staus[$id_name]['status']; $dev_id['address'] = $staus[$id_name]['address']; + $dev_id['new_hw'] = 'N'; + $staus[$id_name]['news'] ='N'; } else { $dev_id['description'] = '- -'; $dev_id['status'] = 'no connect'; $dev_id['address'] = '- -'; } } +// Array ( [name] => SEP0004F2EDCBFD [mac] => SEP0004F2EDCBFD [type] => 7937 [button] => line,7818,default ) + foreach ($staus as $dev_ids) { + $id_name = $dev_ids['name']; + if (empty($dev_ids['news'])) { + $dev_data = $this->sccp_getdevice_info($id_name); + $dev_schema = $this-> getSccp_model_information('byciscoid', false, "all", array('model' =>$dev_data['SCCP_Vendor']['model_id'])); + + $result[] = array('name' => $id_name, 'mac' => $id_name, 'button' => '---', 'type' => $dev_schema[0]['model'], 'new_hw' => 'Y', + 'description' => '*NEW* '.$dev_ids['descr'], 'status' => '*NEW* '.$dev_ids['status'], 'address' => $dev_ids['address'] ); + } + } + } return $result; break; @@ -1001,6 +1018,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $cmd_list = array('get_softkey' => array('cmd' => "sccp show softkeyssets", 'param' => ''), 'get_version' => array('cmd' => "sccp show version", 'param' => ''), 'get_device' => array('cmd' => "sccp show devices", 'param' => ''), + 'get_dev_info' => array('cmd' => "sccp show device", 'param' => 'name'), 'get_hints' => array('cmd' => "core show hints", 'param' => ''), 'sccp_reload' => array('cmd' => "sccp reload force", 'param' => ''), 'reset_phone' => array('cmd' => "sccp reset ", 'param' => 'name'), // Жесткая перезагрузка @@ -1013,7 +1031,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $id_param = $cmd_list[$id_cmd]['param']; if (!empty($id_param)) { if (!empty($params[$id_param])) { - $result = $astman->Command($cmd_list[$id_cmd]['cmd'] . $params[$id_param]); + $result = $astman->Command($cmd_list[$id_cmd]['cmd'] .' '. $params[$id_param]); } } else { $result = $astman->Command($cmd_list[$id_cmd]['cmd']); @@ -1052,6 +1070,31 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * * */ + + public function sccp_getdevice_info($dev_id) { + if (empty($dev_id)) { + return array(); + } + $res = $this->sccp_core_comands(array('cmd' => 'get_dev_info', 'name' => $dev_id)); + $res1 = str_replace(array("\r\n", "\r", "\n"), ';', strip_tags((string)$res['data'])); + if (strpos($res1,'MAC-Address')) { + $res2 = substr($res1,0,strpos($res1,'+--- Buttons ')); + $res1 = explode(';',substr($res2,strpos($res2,'MAC-Address'))); + foreach ($res1 as $data ){ + if (!empty($data)) { + $tmp = explode(':',$data); + $data_key =str_replace(array(" ", "-", "\t"), '_', trim($tmp[0])); + $res3[$data_key] =$tmp[1]; + } + } + $res1 = $res3['Skinny_Phone_Type']; + $res3['SCCP_Vendor']= Array('vendor' => strtok($res1,' '),'model' => strtok('('), 'model_id' => strtok(')')); + return $res3; + } else { + return array(); + } + } + public function sccp_list_hints() { $ast_out = $this->sccp_core_comands(array('cmd' => 'get_hints')); $ast_out = preg_split("/[\n]/", $ast_out['data']); @@ -2035,6 +2078,27 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return time(); } + function sccp_delete_device_XML($dev_id = '') { + if (empty($dev_id)) { + return false; + } + if ($dev_id =='all') { + $xml_name = $this->sccppath["tftp_path"] . '/SEP*.cnf.xml'; + array_map("unlink", glob($xml_name)); + } else { + if (!strpos($dev_id,'SEP')) { + return false; + } + $xml_name = $this->sccppath["tftp_path"] . '/' . $dev_id . '.cnf.xml'; + if (file_exists($xml_name)) { + unlink($xml_name); + } + } + } + + + + function sccp_create_sccp_init() { // Make sccp.conf data // [general] @@ -2051,6 +2115,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case "netlang": // Remove Key case "devlang": case "tftp_path": + case "sccp_comatable": break; default: $this->sccp_conf_init['general'][$key] = $value['data']; @@ -2154,6 +2219,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $sel_inf .= ", '0' as 'validate'"; } switch ($get) { + case "byciscoid": + if (!empty($filter)) { + if (!empty($filter['model'])) { + if (strpos($filter['model'],'loadInformation')) { + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`loadinformationid` =" . $filter['model'] . ") ORDER BY model "; + } else { + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`loadinformationid` ='loadInformation" . $filter['model'] . "') ORDER BY model "; + } + } else { +// $sql = "SELECT ".$filter['model']; + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel ORDER BY model "; + } + break; + } + break; case "byid": if (!empty($filter)) { if (!empty($filter['model'])) { diff --git a/conf/SEP0000000000.cnf.xml_7940_template b/conf/SEP0000000000.cnf.xml_7940_template new file mode 100644 index 0000000..b0cda34 --- /dev/null +++ b/conf/SEP0000000000.cnf.xml_7940_template @@ -0,0 +1,90 @@ + + + cisco + cisco + SCCP + + + Netherlands + D-M-YA + W. Europe Standard/Daylight Time + + + x.x.x.x + Unicast + + + + + + + + + 2000 + + x.x.x.x + + + + + + Enable + Enable + true + x.x.x.x + 2000 + + 2000 + + 2000 + + + P00308010100 + + false + false + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 1,7 + 08:30 + 11:30 + 01:00 + + + Dutch_Netherlands + nl + iso-8859-1 + + Netherlands + + + 64 + 4.0(1) + + 1 + 3600 + http://x.x.x.x/cisco_menu/authentication.php + http://x.x.x.x/cisco_menu/idle.php + http://x.x.x.x/cisco_menu/help/help.php + + + http://x.x.x.x/cisco_menu/menu.php + http://x.x.x.x/cisco_menu/directory/menu.php + 104 + 0 + 184 + 4 + 0 + + + 3804 + + + false + diff --git a/conf/sccpgeneral.xml b/conf/sccpgeneral.xml index aedd11f..bd1f29a 100644 --- a/conf/sccpgeneral.xml +++ b/conf/sccpgeneral.xml @@ -407,6 +407,30 @@ and open the template in the editor. Base Version before all crash :-) + + Help_id2 + Setting the hotline Feature on a device, will make it connect to a predefined extension as soon as the Receiver + is picked up or the "New Call" Button is pressed. No number has to be given. This works even on devices which have + no entry in the config file or realtime database. + The hotline function can be used in : + + First time configurationThis will make it easier to register new devices and assign numbers + At a doorWhere you want people to be able to only call one number + For unprovisioned phonesTo only be able to call the helpdesk to get their phone set up + + + Be careful with this function. Especially not to the internet. So i would restring the deny/permit to 'internal' by default in that case. + + Alow =Specify a list of your networks, for example: 192.168.1.0 + deny =0.0.0.0/0.0.0.0 + permit =internal + hotline_context =sccp + hotline_label = hotline + + + + + hotline_enabled no @@ -421,10 +445,18 @@ and open the template in the editor. Base Version before all crash :-) Hotline Extension: The number that gets called when a hotline is picked up. hint + + + hotline_label + Hot Line + sccp-custom + + Hotline Label: The label on the device + hotline_context - defauly + default sccp-custom Hotline Context: This is the context through which the phone will connect. It should probably match your other contest. The default is "from-internal" but "from-internal-xfer" would also make sense by limiting the options for the person using the phone. @@ -574,6 +606,16 @@ and open the template in the editor. Base Version before all crash :-) The MAC address of the phone + + + type + 7911 + + + hw_select sccp-custom + The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. + + diff --git a/conf/sccpgeneral.xml.v0 b/conf/sccpgeneral.xml.v0 index daae640..bb8f313 100644 --- a/conf/sccpgeneral.xml.v0 +++ b/conf/sccpgeneral.xml.v0 @@ -408,6 +408,30 @@ and open the template in the editor. + + Help_id2 + Setting the hotline Feature on a device, will make it connect to a predefined extension as soon as the Receiver + is picked up or the "New Call" Button is pressed. No number has to be given. This works even on devices which have + no entry in the config file or realtime database. + The hotline function can be used in : + + First time configurationThis will make it easier to register new devices and assign numbers + At a doorWhere you want people to be able to only call one number + For unprovisioned phonesTo only be able to call the helpdesk to get their phone set up + + + Be careful with this function. Especially not to the internet. So i would restring the deny/permit to 'internal' by default in that case. + + Alow =Specify a list of your networks, for example: 192.168.1.0 + deny =0.0.0.0/0.0.0.0 + permit =internal + hotline_context =sccp + hotline_label = hotline + + + + + hotline_enabled no @@ -422,10 +446,19 @@ and open the template in the editor. Hotline Extension: The number that gets called when a hotline is picked up. hint + + + hotline_label + Hot Line + sccp-custom + + Hotline Label: The label on the device + + hotline_context - defauly + default sccp-custom Hotline Context: This is the context through which the phone will connect. It should probably match your other contest. The default is "from-internal" but "from-internal-xfer" would also make sense by limiting the options for the person using the phone. @@ -575,6 +608,16 @@ and open the template in the editor. The MAC address of the phone + + + type + 7911 + + + hw_select sccp-custom + The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. + + diff --git a/conf/sccpgeneral.xml.v11 b/conf/sccpgeneral.xml.v11 index aedd11f..cca276e 100644 --- a/conf/sccpgeneral.xml.v11 +++ b/conf/sccpgeneral.xml.v11 @@ -31,7 +31,8 @@ and open the template in the editor. Base Version before all crash :-) - + + servername @@ -407,6 +408,29 @@ and open the template in the editor. Base Version before all crash :-) + + Help_id2 + Setting the hotline Feature on a device, will make it connect to a predefined extension as soon as the Receiver + is picked up or the "New Call" Button is pressed. No number has to be given. This works even on devices which have + no entry in the config file or realtime database. + The hotline function can be used in : + + First time configurationThis will make it easier to register new devices and assign numbers + At a doorWhere you want people to be able to only call one number + For unprovisioned phonesTo only be able to call the helpdesk to get their phone set up + + + Be careful with this function. Especially not to the internet. So i would restring the deny/permit to 'internal' by default in that case. + + Alow =Specify a list of your networks, for example: 192.168.1.0 + deny =0.0.0.0/0.0.0.0 + permit =internal + hotline_context =sccp + hotline_label = hotline + + + + hotline_enabled no @@ -421,10 +445,18 @@ and open the template in the editor. Base Version before all crash :-) Hotline Extension: The number that gets called when a hotline is picked up. hint + + + hotline_label + Hot Line + sccp-custom + + Hotline Label: The label on the device + hotline_context - defauly + default sccp-custom Hotline Context: This is the context through which the phone will connect. It should probably match your other contest. The default is "from-internal" but "from-internal-xfer" would also make sense by limiting the options for the person using the phone. @@ -574,6 +606,16 @@ and open the template in the editor. Base Version before all crash :-) The MAC address of the phone + + + type + 7911 + + + hw_select sccp-custom + The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. + + @@ -863,6 +905,30 @@ and open the template in the editor. Base Version before all crash :-) + + + Help_id1 + Specifies a pattern to match dialed digits against. Note: TEMPLATE must be in uppercase. + Rules: + + match:Pattern to match, consists of one or more elements + 0 1 2 3 4 5 6 7 8 9Match digit + .Match one digit, # or * + *Match zero or more digits, # or * + \*Match a literal * + ,Play secondary dial-tone specified by tone + timeout:Number of seconds to wait for more digits if this pattern matches + line:Only apply template to the specified line (optional) + rewrite:Rewrite the matched digits before dialing, consists of one or more elements (optional) + 0 1 2 3 4 5 6 7 8 9Replace with digit + %0The entire match + %1 %2 %3 %4 %5Replace with group of digits matched, grouping is done by consecutive literal digit or . elements + %%A literal % + .Each . is replaced by the digit that was matched by the corresponding . in the pattern + tone:Secondary dial-tone to play when a , is matched, up to 3 can be specified (optional) + + + dialtemplete */10/* diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 53556e0..7432429 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -6,6 +6,17 @@ */ $def_val = null; $dev_id = null; +if (!empty($_REQUEST['new_id'])) { + $dev_id = $_REQUEST['new_id']; + $val = str_replace('SEP', '', $dev_id); + $val = implode('.',sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format + $def_val['mac'] = array("keyword" => 'mac', "data" => $val, "seq" => "99"); + $val = $_REQUEST['type']; + $def_val['type'] = array("keyword" => 'type', "data" => $val, "seq" => "99"); + + +} + if (!empty($_REQUEST['id'])) { // print_r($_REQUEST); // diff --git a/views/form.buttons.php b/views/form.buttons.php index 3c3d8be..bb9af4b 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -31,6 +31,15 @@ if (!empty($_REQUEST['id'])) { } $show_buttons = $max_buttons; } +if (!empty($_REQUEST['new_id'])) { + $val = $_REQUEST['type']; + $dev_schema = $this-> getSccp_model_information('byid', false, "all", array('model' =>$val)); + +// $db_device = $this->get_db_SccpTableData('get_sccpdevice_byid', array("id" => $val)); + $max_buttons = $dev_schema[0]['buttons']; + $show_buttons = $max_buttons; +} + ?>
diff --git a/views/formShow.php b/views/formShow.php index 61e8486..4bb16da 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -15,6 +15,7 @@ * * Input element Select SLS - System Language * Input element Select SDM - Model List * SDE - Extension List + * Help elemen HLP - Help Element */ $npref = $form_prefix.'_'; @@ -494,17 +495,25 @@ foreach ($items as $child) {
class . '" id="' . $res_id . '">'; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; + echo '