diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index ec7940b..87a0842 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -65,6 +65,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path private $pagedata = null; + private $sccp_driver_ver = '11.1'; private $tftpLang = array(); private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! public $sccp_model_list = array(); @@ -1672,8 +1673,22 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } $this->sccpvalues['sccp_comatable'] = $this->get_comatable_sccp(); + $driver = $this->FreePBX->Core->getAllDriversInfo(); + $driver_replace = ''; + if (empty($driver['sccp'])) { + $driver_replace = 'yes'; + } else { + if (empty($driver['sccp']['sccp_driver_ver'])) { + $driver_replace = 'yes'; + } else { + if ($driver['sccp']['sccp_driver_ver'] != $this->sccp_driver_ver){ + $driver_replace = 'yes'; + } + } + } + $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; - if (!file_exists($dst)) { + if (!file_exists($dst) || $driver_replace =='yes') { $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst).'.v'.$this->sccpvalues['sccp_comatable']; if (file_exists($src_path)) { copy($src_path, $dst); @@ -1681,6 +1696,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst); copy($src_path, $dst); } + } else { + $driver = $this->FreePBX->Core->getAllDriversInfo(); + + } if (!file_exists($this->sccppath["sccp_conf"])) { // System re Config diff --git a/conf/Sccp.class.php b/conf/Sccp.class.php index 548347a..148aafa 100644 --- a/conf/Sccp.class.php +++ b/conf/Sccp.class.php @@ -20,8 +20,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { "rawName" => "sccp", "hardware" => "sccp_custom", "prettyName" => _("Sccp Custom Driver"), - "shortName" => _("Sccp"), - "description" => _("Sccp Device") + "shortName" => "SCCP", + "description" => _("Sccp Device"), + "sccp_driver_ver" => "11.1" + ); } public function addDevice1($id, $settings) { diff --git a/conf/Sccp.class.php.v11 b/conf/Sccp.class.php.v11 index b75df5c..17d6c54 100644 --- a/conf/Sccp.class.php.v11 +++ b/conf/Sccp.class.php.v11 @@ -3,6 +3,8 @@ // Version for SCCP Manager 13.0.0.A namespace FreePBX\modules\Core\Drivers; class Sccp extends \FreePBX\modules\Core\Driver { + public $version; + private $data_fld = array("pin"=>'pin', "label" => 'label', "accountcode" => 'account', "context" =>'context',"incominglimit"=>'incominglimit', "callgroup"=>'callgroup',"pickupgroup"=>'pickupgroup', @@ -14,14 +16,20 @@ class Sccp extends \FreePBX\modules\Core\Driver { "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' ); + + public function __construct($freepbx) { + parent::__construct($freepbx); +// $this->version = $freepbx->Config->get('ASTVERSION'); + } public function getInfo() { return array( "rawName" => "sccp", "hardware" => "sccp_custom", "prettyName" => _("Sccp Custom Driver"), - "shortName" => _("Sccp"), - "description" => _("Sccp Device") + "shortName" => "SCCP", + "description" => _("Sccp Device"), + "sccp_driver_ver" => "11.1" ); } public function addDevice1($id, $settings) { @@ -109,13 +117,36 @@ class Sccp extends \FreePBX\modules\Core\Driver { return $tech; } + public function getNamedGroup() { + $sql = "select namedcallgroup from sccpline group by namedcallgroup"; + $sth = $this->database->prepare($sql); + $result = array(); + $tech = array(); +// $tech['namedcallgroup'] = ''; +// $tech['namedpickupgroup'] = ''; + try { + $sth->execute(); + $result = $sth->fetchAll(); + foreach($result as $val) { + $tech['namedcallgroup'][] = $val[0]; + } + } catch(\Exception $e) {} + $sql = "select namedpickupgroup from sccpline group by namedpickupgroup"; + $sth = $this->database->prepare($sql); + try { + $sth->execute(); + $result = $sth->fetchAll(); + foreach($result as $val) { + $tech['namedpickupgroup'][] = $val[0]; + } + } catch(\Exception $e) {} + + return $tech; + } + public function getDefaultDeviceSettings($id, $displayname, &$flag) { $dial = 'SCCP'; $settings = array( - "pin" => array( - "value" => "", - "flag" => $flag++ - ), "incominglimit" => array( "value" => "2", "flag" => $flag++ @@ -125,7 +156,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { "flag" => $flag++ ), "callgroup" => array( - "value" => "", + "value" => "from-internal", "flag" => $flag++ ), "namedcallgroup" => array( @@ -140,16 +171,20 @@ class Sccp extends \FreePBX\modules\Core\Driver { "value" => "", "flag" => $flag++ ), + "secondary_dialtone_digits" => array( + "value" => "9", + "flag" => $flag++ + ), + "secondary_dialtone_tone" => array( + "value" => "0x22", + "flag" => $flag++ + ), "transfer" => array( "value" => "yes", "flag" => $flag++ ), - "adhocNumber" => array( - "value" => "", - "flag" => $flag++ - ), "echocancel" => array( - "value" => "no", + "value" => "yes", "flag" => $flag++ ), "dnd" => array( @@ -160,12 +195,12 @@ class Sccp extends \FreePBX\modules\Core\Driver { "value" => "no", "flag" => $flag++ ), - "secondary_dialtone_digits" => array( - "value" => "9", + "musicclass" => array( + "value" => "default", "flag" => $flag++ ), - "secondary_dialtone_tone" => array( - "value" => "0x22", + "pin" => array( + "value" => "", "flag" => $flag++ ), "musicclass" => array( @@ -180,24 +215,41 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) { - $section = _("Settings"); - $category = "general"; + $section = _("SCCP Extension Details"); +// $category = "general"; +// Assigned DID/CID + $named_group = $this->getNamedGroup(); $tmparr = array(); - $tt = _("The SCCP channel number for this port. If you plaining to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls."); + $tt = _("The SCCP channel number for this port. If you plaining to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls."); // $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '2', 'tt' => $tt, 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel); - $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '', 'tt' => $tt, 'level' => 1); +// $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section, 'category' => 'general'); + $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing."); - $tmparr['context'] = array('prompttext' => _('Line context'), 'value' => 'from-internal', 'tt' => $tt, 'level' => 1); + $tmparr['context'] = array('prompttext' => _('Line context'), 'value' => 'from-internal', 'tt' => $tt, 'level' => 1, 'section' => $section); $tt = _("Phone call group callgroup=1,3-4"); - $tmparr['callgroup'] = array('prompttext' => _('Call group id'),'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['callgroup'] = array('prompttext' => _('Call group id'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); + $tt = _("Sets the named caller groups this line is a member of (ast111) : "); + if (!empty($named_group['namedcallgroup'])) { + foreach ($named_group['namedcallgroup'] as $val) { + $tt .= $val. ', '; + } + $tt .= '... '; + } + $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); +// $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section, 'category' => 'general'); $tt = _("Phone pickup group pickupgroup=1,3-4"); - $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => '', 'tt' => $tt, 'level' => 1); - $tt = _("sets the named caller groups this line is a member of (ast111)"); - $tmparr['pickupgroup'] = array('prompttext' => _('Pickup group id'),'value' => '', 'tt' => $tt, 'level' => 1); - $tt = _("Phone pincode"); - $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['pickupgroup'] = array('prompttext' => _('Pickup group id'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); + $tt = _("Name picapuroup : "); + if (!empty($named_group['namedpickupgroup'])) { + foreach ($named_group['namedpickupgroup'] as $val) { + $tt .= $val. ', '; + } + $tt .= '... '; + } + $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); +// $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section, 'category' => 'general'); $tt = _("Digits to indicate an external line to user (secondary dialtone) Sample 9 or 8 (max 9 digits)"); - $tmparr['secondary_dialtone_digits'] = array('prompttext' => _('Secondary dialtone digits'), 'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['secondary_dialtone_digits'] = array('prompttext' => _('Secondary dialtone digits'), 'value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); unset($select); $select[] = array( 'value' => '0x21', 'text' => 'Inside Dial Tone'); @@ -257,7 +309,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Outside dialtone frequency (defaul 0x22)"); - $tmparr['secondary_dialtone_tone'] = array('prompttext' => _('Secondary dialtone'), 'value' => '0x22', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'select'); + $tmparr['secondary_dialtone_tone'] = array('prompttext' => _('Secondary dialtone'), 'value' => '0x22', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'select', 'section' => $section); @@ -265,30 +317,31 @@ class Sccp extends \FreePBX\modules\Core\Driver { $select[] = array('value' => 'yes', 'text' => 'Yes'); $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Allow call transfer."); - $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio'); +// $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section, 'category' => 'general'); + $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'yes', 'text' => 'Yes'); $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Echo cancel"); - $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio'); + $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'off', 'text' => 'Off'); $select[] = array('value' => 'reject', 'text' => 'Reject'); $select[] = array('value' => 'silent', 'text' => 'Silent'); - $select[] = array('value' => '', 'text' => 'UserDefined'); - $tt = _("DND: Means how will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / UserDefined").'
'. - _("UserDefined - dnd that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
'. + $select[] = array('value' => '', 'text' => 'Cycle'); + $tt = _("DND: Means how will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / Cycle").'
'. + _("Cycle - dnd that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
'. _("Reject - Usesr can only switch off and on (in reject/busy mode)").'
'. - _("Silent - Usesr can only switch off and on (in silent mode)"); - $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => '', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio'); + _("Silent - Usesr can only switch off and on (in silent mode)"); + $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => '', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'yes', 'text' => 'Yes'); $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Silence Suppression. Asterisk Not suported"); - $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio'); + $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'default', 'text' => _('default')); @@ -302,13 +355,19 @@ class Sccp extends \FreePBX\modules\Core\Driver { } $tt = _("Music on hold"); - $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1); + $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1, 'section' => $section); $tt = _("Sets the named pickup groups this line is a member of (this phone can pickup calls from remote phones which are in this caller group (ast111)"); - $tmparr['pin'] = array('value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['pin'] = array('value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section); $devopts = $tmparr; return $devopts; } + public function getDeviceHeaders() { + return array( + 'secret' => array('identifier' => _('Secret'), 'description' => sprintf(_('Secret [Enter "%s" to regenerate]'),"REGEN")), + ); + } + } diff --git a/views/server.setting.php b/views/server.setting.php index 0deba8e..0fcbe4f 100644 --- a/views/server.setting.php +++ b/views/server.setting.php @@ -11,6 +11,13 @@ // $dev_data = $this->sccp_getdevice_info($id_name); // print_r($dev_data); +/// $sccpdriver = $this->freepbx->Config->get_conf_setting('ASTSCCPDRIVER'); +// $driver = $this->FreePBX->Core->getAllDriversInfo(); +// $driver = $this->FreePBX->Config->get_conf_setting('ASTSCCPDRIVER'); +// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); +// $tversion = $freepbx->Config; +// print_r($driver ); + ?>