Replace Hint Function

This commit is contained in:
PhantomVl 2018-10-22 18:45:07 +03:00
parent f28ad11cc8
commit 1db698f3e4
5 changed files with 82 additions and 16 deletions

View file

@ -5,7 +5,7 @@
* [Installation](https://github.com/PhantomVl/sccp_manager#installation)
* [Prerequisites](https://github.com/PhantomVl/sccp_manager#prerequisites)
* [Links](https://github.com/PhantomVl/sccp_manager/#link),
* [Links](https://github.com/PhantomVl/sccp_manager#link)
* [Wiki](https://github.com/PhantomVl/sccp_manager/wiki)
## Link

View file

@ -93,7 +93,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private $pagedata = null;
private $sccp_driver_ver = '11.3';
private $tftpLang = array();
private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
// private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $val_null = 'NONE'; /// REPLACE to null Field
public $sccp_model_list = array();
private $cnf_wr = null;
@ -360,8 +362,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
if (!empty(($this->sccpvalues['displayconfig']))) {
if (!empty(($this->sccpvalues['displayconfig']['data'] == 'sccpsimple'))) {
if (!empty($this->sccpvalues['displayconfig'])) {
if (!empty($this->sccpvalues['displayconfig']['data']) && ($this->sccpvalues['displayconfig']['data'] == 'sccpsimple')) {
$this->pagedata = array(
"general" => array(
"name" => _("General SCCP Settings"),
@ -1061,7 +1063,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$btn_opt = (string) $get_settings['button' . $it . '_line'];
$db_res = $this->dbinterface->get_db_SccpTableData('SccpExtension', array('name' => $btn_opt));
$btn_n = $db_res[0]['label'];
$btn_opt .= ',' . $btn_opt . $this->hint_context;
$btn_opt .= ',' . $btn_opt . $this->hint_context['default'];
break;
case 'speeddial':
if (!empty($get_settings['button' . $it . '_input'])) {
@ -1081,7 +1083,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$btn_n = $get_settings['button' . $it . '_hline'] . '!silent';
$btn_opt = '';
} else {
$btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context;
// $btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context['default'];
$btn_opt .= ',' . $get_settings['button' . $it . '_hline'];
}
}
}
@ -1503,7 +1506,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
}
}
$hint = $this->srvinterface->sccp_list_hints();
foreach ($hint as $key => $value) {
if ($this->hint_context['default'] != $value) {
$this->hint_context[$key] = $value;
}
}
}
/*
@ -1790,6 +1799,33 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
return $raw_settings;
}
function get_hint_info($get = "all", $format_list = "all", $filter = array()) {
$res = array();
$default_hint = '@ext-local';
// get all hints [101@ext-local] => 101@ext-local
$tmp_data = $this->srvinterface->sccp_list_all_hints();
foreach ($tmp_data as $value) {
/* !TODO!: Add Hint Filtred List */
$res[$value] = array('hint' => $value, 'name' => before('@', $value), 'label' => $value );
}
// Update info from sccp_db
$tmp_data = $this->dbinterface->get_db_SccpTableData('SccpExtension');
foreach ($tmp_data as $value) {
$name_l = $value['name'];
if (!empty($res[$name_l.$default_hint])) {
$res[$name_l.$default_hint]['name'] = $name_l;
$res[$name_l.$default_hint]['label'] = $value['label'];
} else { // if not exist in system hints ..... ???????
$res[$name_l.$default_hint] = array('hint' => $name_l.$default_hint, 'name' => $name_l, 'label' => $value['label'] );
}
}
// Update info from sip DB
/* !TODO!: Update Hint info from sip DB ??? */
return $res;
}
function getIP_information() {
$interfaces['auto'] = array('0.0.0.0', 'All', '0');

View file

@ -26,6 +26,10 @@ class srvinterface {
Core Access Function
*/
/*
* Replace or dublicate to AMI interface
*/
public function sccp_core_commands($params = array()) {
global $astman;
$cmd_list = array('get_softkey' => array('cmd' => "sccp show softkeyssets", 'param' => ''),
@ -118,8 +122,20 @@ class srvinterface {
/*
* A function should be used in the form of buttons for getting all hint. Not working. I don't know how to use properly.
*/
public function sccp_list_hints() {
$hint_key = array();
$hint_all = $this->sccp_list_all_hints();
foreach ($hint_all as $value) {
$res = $this->loc_after('@', $value);
// array_search($res, $hint_key)) != NULL)
if (!isset($hint_key[$res])) {
$hint_key[$res] = '@'.$res;
}
}
return $hint_key;
}
public function sccp_list_all_hints() {
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_hints'));
$ast_out = preg_split("/[\n]/", $ast_out['data']);
$ast_key = array();
@ -379,7 +395,14 @@ class srvinterface {
return strpos($haystack, $needles);
}
return FALSE;
}
}
private function loc_after($value, $inthat)
{
if (!is_bool(strpos($inthat, $value)))
return substr($inthat, strpos($inthat, $value) + strlen($value));
}
}

View file

@ -15,8 +15,9 @@ $buttons_type= array("empty","line","silent","monitor","speeddial","feature","a
$feature_list= array('parkinglot'=>'Park Slots','monitor'=> "Record Calls",'devstate'=> "Change Status");
$lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
$hint_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
//$hint_list = $this->sccp_list_hints();
//$hint_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
$hint_list = $this->get_hint_info();
$line_id =0;
$max_buttons =56;
$show_buttons =1;
@ -84,6 +85,7 @@ if (!empty($_REQUEST['new_id'])) {
$defaul_tv = (empty($db_buttons[$line_id])) ? "empty": $db_buttons[$line_id]['type'];
$defaul_btn = (empty($db_buttons[$line_id])) ? "": $db_buttons[$line_id]['name'];
$defaul_opt = (empty($db_buttons[$line_id])) ? array(''): explode(',',$db_buttons[$line_id]['options']);
print_r($defaul_opt);
$show_form_mode = $defaul_tv;
@ -107,6 +109,7 @@ if (!empty($_REQUEST['new_id'])) {
if ($defaul_tv == "feature") {
$defaul_ftr = $defaul_opt[0];
$defaul_fcod = (empty($defaul_opt[1])) ? '': $defaul_opt[1];
print_r($defaul_fcod);
}
foreach ($defaul_opt as $data_i) {
if (strpos($data_i,'@') >0) {
@ -115,7 +118,10 @@ if (!empty($_REQUEST['new_id'])) {
if ($defaul_btn == $defaul_opt[0]) {
$show_form_mode = 'line';
$defaul_tv = 'monitor';
} else {
$defaul_btn = $data_i;
}
}
}
@ -187,8 +193,8 @@ if (!empty($_REQUEST['new_id'])) {
echo '<select class="form-control" name="'.$forminfo[1]['name'].$line_id.'_hline" >';
foreach ($hint_list as $data){
$select = (($data['name']==$defaul_btn)?"selected":"");
echo '<option value="'.$data['name'].'" '.$select.' >'.$data['name'].' / '.$data['label'].'</option>';
$select = (($data['hint']==$defaul_btn)?"selected":"");
echo '<option value="'.$data['hint'].'" '.$select.' >'.$data['name'].' / '.$data['label'].'</option>';
}
echo '</select>';
echo '</div>';
@ -202,7 +208,7 @@ if (!empty($_REQUEST['new_id'])) {
</div>
<div class="col-xs-5">
<?php
echo '<input class="form-control" type="text" id="'.$forminfo[1]['name'].$line_id.'_fvalue" name="'.$forminfo[1]['name'].$line_id.'_fvalue" placeholder="code" value="'.$defaul_opt.'" >';
echo '<input class="form-control" type="text" id="'.$forminfo[1]['name'].$line_id.'_fvalue" name="'.$forminfo[1]['name'].$line_id.'_fvalue" placeholder="code" value="'.$defaul_fcod.'" >';
?>
</div>
</div>

View file

@ -29,8 +29,9 @@ if (!empty($this->sccpvalues['tftp_rewrite'])) {
$info['Сompatible'] = array('Version' => $this->srvinterface->get_compatible_sccp(), 'about'=> '');
//print_r("<br> Request:<br><pre>");
//$asss = $this->extconfigs->validate_init_path($this->sccppath["asterisk"],$this->sccpvalues,$driver_ver);
//print_r($asss);
//print("</pre>");
//$hint_list = $this->get_hint_info();
//print_r($hint_list);
//print("</pre>");
// $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK');
// print_r('<br>');