diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php
index 62bf090..cb4f5d9 100644
--- a/Sccp_manager.class.php
+++ b/Sccp_manager.class.php
@@ -93,61 +93,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
"tftp_path" => '/tftpboot'
);
public $xml_data;
- public $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,dnd,pickup,gpickup,private',
- 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert',
- 'onhold' => 'resume,newcall,endcall,transfer,conflist,select,dirtrfr,idivert,meetme',
- 'ringin' => 'answer,endcall,transvm,idivert',
- 'offhook' => 'redial,endcall,private,cfwdall,cfwdbusy,pickup,gpickup,meetme,barge',
- 'conntrans' => 'hold,endcall,transfer,conf,park,select,dirtrfr,vidmode,meetme,cfwdall,cfwdbusy',
- 'digitsfoll' => 'back,endcall,dial',
- 'connconf' => 'conflist,newcall,endcall,hold,vidmode',
- 'ringout' => 'empty,endcall,transfer,cfwdall,idivert',
- 'offhookfeat' => 'redial,endcall',
- 'onhint' => 'redial,newcall,pickup,gpickup,barge',
- 'onstealable' => 'redial,newcall,cfwdall,pickup,gpickup,dnd,intrcpt',
- 'holdconf' => 'resume,newcall,endcall,join',
- 'uriaction' => 'default');
-// Cisco Language Code / Directory
- public $sccp_lang = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia'),
- 'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria'),
- 'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic'),
- 'da_DK' => array('code' => 'da', 'language' => 'Danish', 'locale' => 'Danish_Denmark'),
- 'de_DE' => array('code' => 'de', 'language' => 'German', 'locale' => 'German_Germany'),
- 'el_GR' => array('code' => 'el', 'language' => 'Greek', 'locale' => 'Greek_Greece'),
- 'en_AU' => array('code' => 'en', 'language' => 'English', 'locale' => 'AU_English_United_States'),
- 'en_GB' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_Kingdom'),
- 'en_US' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_States'),
- 'es_ES' => array('code' => 'es', 'language' => 'Spanish', 'locale' => 'Spanish_Spain'),
- 'et_EE' => array('code' => 'et', 'language' => 'Estonian', 'locale' => 'Estonian_Estonia'),
- 'fi_FI' => array('code' => 'fi', 'language' => 'Finnish', 'locale' => 'Finnish_Finland'),
- 'fr_CA' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_Canada'),
- 'fr_FR' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_France'),
- 'he_IL' => array('code' => 'he', 'language' => 'Hebrew', 'locale' => 'Hebrew_Israel'),
- 'hr_HR' => array('code' => 'hr', 'language' => 'Croatian', 'locale' => 'Croatian_Croatia'),
- 'hu_HU' => array('code' => 'hu', 'language' => 'Hungarian', 'locale' => 'Hungarian_Hungary'),
- 'it_IT' => array('code' => 'it', 'language' => 'Italian', 'locale' => 'Italian_Italy'),
- 'ja_JP' => array('code' => 'ja', 'language' => 'Japanese', 'locale' => 'Japanese_Japan'),
- 'ko_KO' => array('code' => 'ko', 'language' => 'Korean', 'locale' => 'Korean_Korea_Republic'),
- 'lt_LT' => array('code' => 'lt', 'language' => 'Lithuanian', 'locale' => 'Lithuanian_Lithuania'),
- 'lv_LV' => array('code' => 'lv', 'language' => 'Latvian', 'locale' => 'Latvian_Latvia'),
- 'nl_NL' => array('code' => 'nl', 'language' => 'Dutch', 'locale' => 'Dutch_Netherlands'),
- 'no_NO' => array('code' => 'no', 'language' => 'Norwegian', 'locale' => 'Norwegian_Norway'),
- 'pl_PL' => array('code' => 'pl', 'language' => 'Polish', 'locale' => 'Polish_Poland'),
- 'pt_BR' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Brazil'),
- 'pt_PT' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Portugal'),
- 'ro_RO' => array('code' => 'ro', 'language' => 'Romanian', 'locale' => 'Romanian_Romania'),
- 'ru_RU' => array('code' => 'ru', 'language' => 'Russian', 'locale' => 'Russian_Russian_Federation'),
- 'sk_SK' => array('code' => 'sk', 'language' => 'Slovakian', 'locale' => 'Slovak_Slovakia'),
- 'sl_SL' => array('code' => 'sl', 'language' => 'Slovenian', 'locale' => 'Slovenian_Slovenia'),
- 'sr_ME' => array('code' => 'sr', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Montenegro'),
- 'sr_RS' => array('code' => 'rs', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Serbia'),
- 'sv_SE' => array('code' => 'sv', 'language' => 'Swedish', 'locale' => 'Swedish_Sweden'),
- 'th_TH' => array('code' => 'th', 'language' => 'Thailand', 'locale' => 'Thai_Thailand'),
- 'tr_TR' => array('code' => 'tr', 'language' => 'Turkish', 'locale' => 'Turkish_Turkey'),
- 'zh_CN' => array('code' => 'cn', 'language' => 'Chinese', 'locale' => 'Chinese_China'),
- 'zh_TW' => array('code' => 'zh', 'language' => 'Chinese', 'locale' => 'Chinese_Taiwan')
- );
-
+
public function __construct($freepbx = null) {
if ($freepbx == null) {
throw new Exception("Not given a FreePBX Object");
@@ -158,12 +104,39 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$this->cnf_wr = \FreePBX::WriteConfig();
$this->cnf_read = \FreePBX::LoadConfig();
$this->v = new \Respect\Validation\Validator();
+
+ if(!class_exists("FreePBX\modules\Sccp_manager\configs",false)) {
+ include(__DIR__."/Sccp_manager.inc/configs.class.php");
+ $driverNamespace = "\\FreePBX\\Modules\\Sccp_manager\\configs";
+ $class = $driverNamespace;
+ $this->configs = new $class();
+// $this->configs = \FreePBX\Modules\Sccp_manager\configs;
+ }
+/*
+ $driverNamespace = "\\FreePBX\\Modules\\Sccp_manager\\configs";
+ foreach(glob(__DIR__."/functions.inc/drivers/*.class.php") as $driver) {
+ if(preg_match("/\/([a-z1-9]*)\.class\.php$/i",$driver,$matches)) {
+ $name = $matches[1];
+ $class = $driverNamespace . "\\" . $name;
+ if(!class_exists($class,false)) {
+ include($driver);
+ }
+ if(class_exists($class,false)) {
+ $this->drivers[strtolower($name)] = new $class($this->freepbx);
+ } else {
+ throw new \Exception("Invalid Class inside the drivers folder");
+ }
+ }
+ }
+ *
+ */
$this->getSccpSettingsDB(false); // Overwrite Exist
// $this->getSccpSetingINI(false); // get from sccep.ini
$this->init_sccp_path();
$this->initVarfromDefs();
$this->initTftpLang();
+
// Load Advanced Form Constuctor Data
$xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v'.$this->sccpvalues['sccp_comatable'];
if (!file_exists($xml_vars)) {
@@ -201,7 +174,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
* Load config vars from base array
*/
public function initVarfromDefs() {
- foreach ($this->sccpDefaults as $key => $value) {
+ foreach ($this->$this->configs->getConfig('sccpDefaults') as $key => $value) {
if (empty($this->sccpvalues[$key])) {
$this->sccpvalues[$key] = array('keyword' => $key, 'data' => $value, 'type' => '0', 'seq' => '0');
}
@@ -740,7 +713,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if (!empty($request['id'])) {
$id_name = $request['id'];
$this->sccp_conf_init[$id_name]['type'] = "softkeyset";
- foreach ($this->keysetdefault as $keyl => $vall) {
+ foreach ($this->$this->configs->getConfig('keyset') as $keyl => $vall) {
if (!empty($request[$keyl])) {
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
}
@@ -761,7 +734,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
foreach ($this->sccp_list_keysets() as $keyl => $vall) {
$result[$i]['softkeys'] = $keyl;
if ($keyl == 'default') {
- foreach ($this->keysetdefault as $key => $value) {
+ foreach ($this->configs->getConfig('keyset') as $key => $value) {
$result[$i][$key] = str_replace(',', '
', $value);
}
} else {
@@ -1604,7 +1577,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$filename = $dir . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR . $this->SCCP_LANG_DICTIONARY;
if (file_exists($filename)) {
- foreach ($this->sccp_lang as $lang_key => $lang_value) {
+ $lang_ar = $this->configs->getConfig('sccp_lang');
+ foreach ($lang_ar as $lang_key => $lang_value) {
if ($lang_value['locale'] == $value) {
$result[$lang_key] = $value;
}
@@ -1623,7 +1597,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private function init_tftp_lang_path() {
$dir = $this->sccppath["tftp_path"];
- foreach ($this->sccp_lang as $lang_key => $lang_value) {
+ foreach ($this->configs->getConfig('sccp_lang') as $lang_key => $lang_value) {
$filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale'];
if (!file_exists($filename)) {
if (!mkdir($filename, 0777, true)) {
@@ -1981,12 +1955,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} else {
$lang = $this->sccpvalues['devlang']['data'];
}
- $xnode->name = $this->sccp_lang[$lang]['locale'];
- $xnode->langCode = $this->sccp_lang[$lang]['code'];
+// configs->getConfig('sccp_lang')
+ $lang_arr = $this->configs->getConfig('sccp_lang',$lang);
+ $xnode->name = $lang_arr['locale'];
+ $xnode->langCode = $$lang_arr['code'];
// $this -> replaceSimpleXmlNode($xml_work->$key,$xnode);
break;
case 'networkLocale':
- $xnode = $this->sccp_lang[$this->sccpvalues['netlang']['data']]['language'];
+ $lang_arr = $this->configs->getConfig('sccp_lang',$this->sccpvalues['netlang']['data']);
+ $xnode = $lang_arr['language'];
break;
}
//$this-> replaceSimpleXmlNode($xml_work->$value, $xnode );
@@ -2187,9 +2164,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if ($key == 'networkLocale') {
$xml_work->$key = $lang;
} else {
- if (!empty($this->sccp_lang[$lang])) {
- $xml_node->name = $this->sccp_lang[$lang]['locale'];
- $xml_node->langCode = $this->sccp_lang[$lang]['code'];
+ $lang_arr = $this->configs->getConfig('sccp_lang',$lang);
+ if (!empty($lang_arr)) {
+ $xml_node->name = $lang_arr['locale'];
+ $xml_node->langCode = $lang_arr['code'];
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
}
}
diff --git a/Sccp_manager.inc/configs.class.php b/Sccp_manager.inc/configs.class.php
new file mode 100644
index 0000000..6f786b8
--- /dev/null
+++ b/Sccp_manager.inc/configs.class.php
@@ -0,0 +1,93 @@
+freepbx = $freepbx;
+// $this->database = $freepbx->Database;
+ }
+ public function getConfig($id = '', $index = '') {
+ switch ($id) {
+ case 'keyset':
+ if (empty($index)) {
+ return $this->keysetdefault;
+ } else {
+ if (isset($this->keysetdefault[$index])) {
+ return $this->keysetdefault[$index];
+ } else {
+ return array('');
+ }
+ }
+ break;
+ case 'sccp_lang':
+ return $this->cisco_language;
+ break;
+
+ default:
+ return array('noId');
+ break;
+ }
+ return array();
+ }
+ private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,dnd,pickup,gpickup,private',
+ 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert',
+ 'onhold' => 'resume,newcall,endcall,transfer,conflist,select,dirtrfr,idivert,meetme',
+ 'ringin' => 'answer,endcall,transvm,idivert',
+ 'offhook' => 'redial,endcall,private,cfwdall,cfwdbusy,pickup,gpickup,meetme,barge',
+ 'conntrans' => 'hold,endcall,transfer,conf,park,select,dirtrfr,vidmode,meetme,cfwdall,cfwdbusy',
+ 'digitsfoll' => 'back,endcall,dial',
+ 'connconf' => 'conflist,newcall,endcall,hold,vidmode',
+ 'ringout' => 'empty,endcall,transfer,cfwdall,idivert',
+ 'offhookfeat' => 'redial,endcall',
+ 'onhint' => 'redial,newcall,pickup,gpickup,barge',
+ 'onstealable' => 'redial,newcall,cfwdall,pickup,gpickup,dnd,intrcpt',
+ 'holdconf' => 'resume,newcall,endcall,join',
+ 'uriaction' => 'default');
+// Cisco Language Code / Directory
+ private $cisco_language = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia'),
+ 'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria'),
+ 'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic'),
+ 'da_DK' => array('code' => 'da', 'language' => 'Danish', 'locale' => 'Danish_Denmark'),
+ 'de_DE' => array('code' => 'de', 'language' => 'German', 'locale' => 'German_Germany'),
+ 'el_GR' => array('code' => 'el', 'language' => 'Greek', 'locale' => 'Greek_Greece'),
+ 'en_AU' => array('code' => 'en', 'language' => 'English', 'locale' => 'AU_English_United_States'),
+ 'en_GB' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_Kingdom'),
+ 'en_US' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_States'),
+ 'es_ES' => array('code' => 'es', 'language' => 'Spanish', 'locale' => 'Spanish_Spain'),
+ 'et_EE' => array('code' => 'et', 'language' => 'Estonian', 'locale' => 'Estonian_Estonia'),
+ 'fi_FI' => array('code' => 'fi', 'language' => 'Finnish', 'locale' => 'Finnish_Finland'),
+ 'fr_CA' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_Canada'),
+ 'fr_FR' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_France'),
+ 'he_IL' => array('code' => 'he', 'language' => 'Hebrew', 'locale' => 'Hebrew_Israel'),
+ 'hr_HR' => array('code' => 'hr', 'language' => 'Croatian', 'locale' => 'Croatian_Croatia'),
+ 'hu_HU' => array('code' => 'hu', 'language' => 'Hungarian', 'locale' => 'Hungarian_Hungary'),
+ 'it_IT' => array('code' => 'it', 'language' => 'Italian', 'locale' => 'Italian_Italy'),
+ 'ja_JP' => array('code' => 'ja', 'language' => 'Japanese', 'locale' => 'Japanese_Japan'),
+ 'ko_KO' => array('code' => 'ko', 'language' => 'Korean', 'locale' => 'Korean_Korea_Republic'),
+ 'lt_LT' => array('code' => 'lt', 'language' => 'Lithuanian', 'locale' => 'Lithuanian_Lithuania'),
+ 'lv_LV' => array('code' => 'lv', 'language' => 'Latvian', 'locale' => 'Latvian_Latvia'),
+ 'nl_NL' => array('code' => 'nl', 'language' => 'Dutch', 'locale' => 'Dutch_Netherlands'),
+ 'no_NO' => array('code' => 'no', 'language' => 'Norwegian', 'locale' => 'Norwegian_Norway'),
+ 'pl_PL' => array('code' => 'pl', 'language' => 'Polish', 'locale' => 'Polish_Poland'),
+ 'pt_BR' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Brazil'),
+ 'pt_PT' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Portugal'),
+ 'ro_RO' => array('code' => 'ro', 'language' => 'Romanian', 'locale' => 'Romanian_Romania'),
+ 'ru_RU' => array('code' => 'ru', 'language' => 'Russian', 'locale' => 'Russian_Russian_Federation'),
+ 'sk_SK' => array('code' => 'sk', 'language' => 'Slovakian', 'locale' => 'Slovak_Slovakia'),
+ 'sl_SL' => array('code' => 'sl', 'language' => 'Slovenian', 'locale' => 'Slovenian_Slovenia'),
+ 'sr_ME' => array('code' => 'sr', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Montenegro'),
+ 'sr_RS' => array('code' => 'rs', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Serbia'),
+ 'sv_SE' => array('code' => 'sv', 'language' => 'Swedish', 'locale' => 'Swedish_Sweden'),
+ 'th_TH' => array('code' => 'th', 'language' => 'Thailand', 'locale' => 'Thai_Thailand'),
+ 'tr_TR' => array('code' => 'tr', 'language' => 'Turkish', 'locale' => 'Turkish_Turkey'),
+ 'zh_CN' => array('code' => 'cn', 'language' => 'Chinese', 'locale' => 'Chinese_China'),
+ 'zh_TW' => array('code' => 'zh', 'language' => 'Chinese', 'locale' => 'Chinese_Taiwan')
+ );
+
+
+}
\ No newline at end of file
diff --git a/install.php b/install.php
index c8d9f0a..c4c011a 100644
--- a/install.php
+++ b/install.php
@@ -1,7 +1,7 @@
array('enabled' => array('create' => "INT(2) NULL DEFAULT '0'"),
- 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'),
- 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" )
- ),
- 'sccpdevice' => array(
- '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
-// 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
-// 'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
- 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
- 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
- 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
- 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
-
- 'transfer' =>array('def_modify' => "on"),
- 'cfwdall' =>array('def_modify' => "on"),
- 'cfwdbusy' =>array('def_modify' => "on"),
- 'directrtp' =>array('def_modify' => "off"),
- 'dndFeature' =>array('def_modify' => "on"),
- 'earlyrtp' =>array('def_modify' => "on"),
- 'audio_tos'=>array('def_modify' => "0xB8"),
- 'audio_cos'=>array('def_modify' => "6"),
- 'video_tos'=>array('def_modify' => "0x88"),
- 'video_cos'=>array('def_modify' => "5"),
-
- 'mwilamp' =>array('def_modify' => "on"),
- 'mwioncall' =>array('def_modify' => "on"),
- 'private' =>array('def_modify' => "on"),
- 'privacy' =>array('def_modify' => "off"),
- 'nat' =>array('def_modify' => "auto"),
- 'softkeyset' =>array('def_modify' => "softkeyset")
- ),
-
- 'sccpline' => array('namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"),
- 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"),
- 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"),
- 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"),
- 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"),
- 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"),
- 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"),
- 'incominglimit' =>array('def_modify' => "2"),
- 'transfer' =>array('def_modify' => "on"),
- 'vmnum' =>array('def_modify' => "*97"),
- 'musicclass' =>array('def_modify' => "default"),
- 'echocancel' =>array('def_modify' => "on"),
- 'silencesuppression' =>array('def_modify' => "off"),
- 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject")
- )
- );
+//
+// Helper function to retrieve SCCPConfigMetaData via ASTMan
+// segment: ["", "general","device","line","softkey"]}
+// returns a php variable (array/set)
+//
+// Move to seperate helper file
+function astman_retrieveJSFromMetaData($astman, $segment = "") {
+ $params = array();
+ if ($segment != "") {
+ $params["Segment"] = $segment;
+ }
+ $response = $astman->send_request('SCCPConfigMetaData', $params);
+ if ($response["Response"] == "Success") {
+ //outn(_("JSON-content:").$response["JSON"]);
+ $decode=json_decode($response["JSON"], true);
+ return $decode;
+ } else {
+ return false;
+ }
+}
+$db_config_v0 = array(
+ 'sccpdevmodel' => array(
+ 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"),
+ 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'),
+ 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" )
+ ),
+ 'sccpdevice' => array(
+ '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
+ //'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
+ //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
+ 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
+ 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
+ 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
+ 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
-$db_config_v3 = array('sccpdevmodel' => array('enabled' => array('create' => "INT(2) NULL DEFAULT '0'"),
- 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'),
- 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" )
- ),
- 'sccpdevice' => array(
- 'pickupexten' => array('rename' => "directed_pickup"),
- 'directed_pickup' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"),
- 'pickupcontext' => array('rename' => "directed_pickup_context"),
- 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"),
- 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"),
- 'directed_pickup_modeanswer' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"),
- 'hwlang' => array('rename' => "_hwlang"),
- '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
- 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
-
-// 'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
- 'dtmfmode' => array('drop' => "yes"),
-
- 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
- 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
- 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
- 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
-
- 'transfer' =>array('def_modify' => "on"),
- 'cfwdall' =>array('def_modify' => "on"),
- 'cfwdbusy' =>array('def_modify' => "on"),
- 'directrtp' =>array('def_modify' => "off"),
- 'dndFeature' =>array('def_modify' => "on"),
- 'earlyrtp' =>array('def_modify' => "on"),
- 'audio_tos'=>array('def_modify' => "0xB8"),
- 'audio_cos'=>array('def_modify' => "6"),
- 'video_tos'=>array('def_modify' => "0x88"),
- 'video_cos'=>array('def_modify' => "5"),
- 'trustphoneip'=>array('drop' => "yes"),
-
- 'mwilamp' =>array('def_modify' => "on"),
- 'mwioncall' =>array('def_modify' => "on"),
- 'private' =>array('def_modify' => "on"),
- 'privacy' =>array('def_modify' => "off"),
- 'nat' =>array('def_modify' => "auto"),
- 'softkeyset' =>array('def_modify' => "softkeyset")
- ),
- 'sccpline' => array('namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"),
- 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"),
- 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"),
- 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"),
- 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"),
- 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"),
- 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"),
- 'rtptos' => array('drop' => "yes"),
- 'audio_tos' => array('drop' => "yes"),
- 'audio_cos' => array('drop' => "yes"),
- 'video_tos' => array('drop' => "yes"),
- 'video_cos' => array('drop' => "yes"),
- 'incominglimit' =>array('def_modify' => "2"),
- 'transfer' =>array('def_modify' => "on"),
- 'vmnum' =>array('def_modify' => "*97"),
- 'musicclass' =>array('def_modify' => "default"),
- 'echocancel' =>array('def_modify' => "on"),
- 'silencesuppression' =>array('def_modify' => "off"),
- 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject")
- )
- );
+ 'transfer' =>array('def_modify' => "on"),
+ 'cfwdall' =>array('def_modify' => "on"),
+ 'cfwdbusy' =>array('def_modify' => "on"),
+ 'directrtp' =>array('def_modify' => "off"),
+ 'dndFeature' =>array('def_modify' => "on"),
+ 'earlyrtp' =>array('def_modify' => "on"),
+ 'audio_tos'=>array('def_modify' => "0xB8"),
+ 'audio_cos'=>array('def_modify' => "6"),
+ 'video_tos'=>array('def_modify' => "0x88"),
+ 'video_cos'=>array('def_modify' => "5"),
+
+ 'mwilamp' =>array('def_modify' => "on"),
+ 'mwioncall' =>array('def_modify' => "on"),
+ 'private' =>array('def_modify' => "on"),
+ 'privacy' =>array('def_modify' => "off"),
+ 'nat' =>array('def_modify' => "auto"),
+ 'softkeyset' =>array('def_modify' => "softkeyset")
+ ),
+
+ 'sccpline' => array(
+ 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"),
+ 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"),
+ 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"),
+ 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"),
+ 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"),
+ 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"),
+ 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"),
+ 'incominglimit' =>array('def_modify' => "2"),
+ 'transfer' =>array('def_modify' => "on"),
+ 'vmnum' =>array('def_modify' => "*97"),
+ 'musicclass' =>array('def_modify' => "default"),
+ 'echocancel' =>array('def_modify' => "on"),
+ 'silencesuppression' =>array('def_modify' => "off"),
+ 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject")
+ )
+);
+
+$db_config_v3 = array(
+ 'sccpdevmodel' => array(
+ 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"),
+ 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'),
+ 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" )
+ ),
+ 'sccpdevice' => array(
+ 'pickupexten' => array('rename' => "directed_pickup"),
+ 'directed_pickup' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"),
+ 'pickupcontext' => array('rename' => "directed_pickup_context"),
+ 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"),
+ 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"),
+ 'directed_pickup_modeanswer' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"),
+ 'hwlang' => array('rename' => "_hwlang"),
+ '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
+ 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
+
+ //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
+ 'dtmfmode' => array('drop' => "yes"),
+
+ 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
+ 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"),
+ 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
+ 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"),
+
+ 'transfer' =>array('def_modify' => "on"),
+ 'cfwdall' =>array('def_modify' => "on"),
+ 'cfwdbusy' =>array('def_modify' => "on"),
+ 'directrtp' =>array('def_modify' => "off"),
+ 'dndFeature' =>array('def_modify' => "on"),
+ 'earlyrtp' =>array('def_modify' => "on"),
+ 'audio_tos'=>array('def_modify' => "0xB8"),
+ 'audio_cos'=>array('def_modify' => "6"),
+ 'video_tos'=>array('def_modify' => "0x88"),
+ 'video_cos'=>array('def_modify' => "5"),
+ 'trustphoneip'=>array('drop' => "yes"),
+
+ 'mwilamp' =>array('def_modify' => "on"),
+ 'mwioncall' =>array('def_modify' => "on"),
+ 'private' =>array('def_modify' => "on"),
+ 'privacy' =>array('def_modify' => "off"),
+ 'nat' =>array('def_modify' => "auto"),
+ 'softkeyset' =>array('def_modify' => "softkeyset")
+ ),
+ 'sccpline' => array(
+ 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"),
+ 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"),
+ 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"),
+ 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"),
+ 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"),
+ 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"),
+ 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"),
+ 'rtptos' => array('drop' => "yes"),
+ 'audio_tos' => array('drop' => "yes"),
+ 'audio_cos' => array('drop' => "yes"),
+ 'video_tos' => array('drop' => "yes"),
+ 'video_cos' => array('drop' => "yes"),
+ 'incominglimit' =>array('def_modify' => "2"),
+ 'transfer' =>array('def_modify' => "on"),
+ 'vmnum' =>array('def_modify' => "*97"),
+ 'musicclass' =>array('def_modify' => "default"),
+ 'echocancel' =>array('def_modify' => "on"),
+ 'silencesuppression' =>array('def_modify' => "off"),
+ 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject")
+ )
+);
$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT";
$table_req = array('sccpdevice', 'sccpline', 'buttonconfig');
-
$ss = FreePBX::create()->Sccp_manager;
-
-outn(_("checking for Sccp_manager database tables.."));
-foreach ($table_req as $value) {
- $check = $db->getRow("SELECT 1 FROM `$value` LIMIT 0", DB_FETCHMODE_ASSOC);
- if (DB::IsError($check)) {
-// print_r("none, creating table :". $value);
- out(_("none, Can't find table: " . $value));
- out(_("none, Please goto the chan-sccp/conf directory and create the DB schema (See wiki)"));
- die("!!!! Installation error: Can not find required ".$value." table !!!!!!\n");
-// die_freepbx("!!!! Instalation error. Can not find required ".$value." table !!!!!!\n");
- }
-}
-
-
-$version = FreePBX::Config()->get('ASTVERSION');
-outn(_("checking Version : ").$version);
-
-$dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views';
-if (fileowner($_SERVER['DOCUMENT_ROOT']) != fileowner($dst)){
- die('Please (re-)check permissions by running "amportal chown"');
-}
-
-if (!empty($version)) {
- // Woo, we have a version
- if (version_compare($version, "12.2.0", ">=")) {
- $ver_compatable = true;
- }
-} else {
- // Well. I don't know what version of Asterisk I'm running.
- // Assume less than 12.
-
- $ver_compatable = false;
- die('Versin is not comapable');
-}
-
-// Should be replaced by a function to check the AMI:SCCPConfigMetaData
-// JSON: {"Name":"Chan-sccp-b","Branch":"issues/394_1","Version":"4.3.0","Revision":"8d9d74fM","ConfigRevision":"0","ConfigureEnabled": ["park","pickup","realtime","video","conferenence","dirtrfr","feature_monitor","functions","manager_events","devstate_feature","dynamic_speeddial","dynamic_speeddial_cid","experimental","debug"],"Segments":["general","device","line","softkey"]}
-$ast_out = $astman->Command("sccp show version");
+$astman = FreePBX::create()->astman;
+$sccp_ver = 0;
$db_config = $db_config_v0;
-if (preg_match("/Release.*\(/", $ast_out['data'] , $matches)) {
- $ast_out = explode(' ', substr($matches[0],9,-1));
- $sccp_ver = 0;
- if ($ast_out[0] >= '4.3.0'){
- $sccp_ver = 1;
+
+function CheckSCCPManagerDBTables($table_req) {
+ global $db;
+ outn("