diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5ec82c9..7a09353 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -809,7 +809,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'], 'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'], 'tftp_dialplan_path' => $this->sccpvalues['tftp_dialplan_path']['data'], - 'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data'] + 'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data'], + 'tftp_countries_path' => $this->sccpvalues['tftp_countries_path']['data'] ); $read_config = $this->cnf_read->getConfig('sccp.conf'); @@ -868,11 +869,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function deleteDialPlan($get_file) { - if (!empty($get_file)) { - $file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml'; - if (file_exists($file)) { - $res = unlink($file); - } + $file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml'; + if (file_exists($file)) { + $res = unlink($file); } return $res; } diff --git a/module.xml b/module.xml index d600f86..3e5c4c2 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 8e31d36..8186646 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -246,7 +246,8 @@ class extconfigs 'dialplan' => 'dialplan', 'softkey' => 'softkey', 'ringtones' => 'ringtones', - 'wallpapers' => 'wallpapers' + 'wallpapers' => 'wallpapers', + 'countries' => 'countries' ); $adv_tree = array('pro' => array('templates' => 'tftproot', 'firmware' => 'tftproot', @@ -257,7 +258,8 @@ class extconfigs 'dialplan' => 'tftproot', 'softkey' => 'tftproot', 'ringtones' => 'tftproot', - 'wallpapers' => 'tftproot' + 'wallpapers' => 'tftproot', + 'countries' => 'locales' ), 'def' => array('templates' => 'tftproot', 'firmware' => '', @@ -267,7 +269,8 @@ class extconfigs 'dialplan' => '', 'softkey' => '', 'ringtones' => '', - 'wallpapers' => '' + 'wallpapers' => '', + 'countries' => '' ) ); $base_tree = array('tftp_templates_path' => 'templates', @@ -277,7 +280,8 @@ class extconfigs 'tftp_dialplan_path' => 'dialplan', 'tftp_softkey_path' => 'softkey', 'tftp_ringtones_path' => 'ringtones', - 'tftp_wallpapers_path' => 'wallpapers' + 'tftp_wallpapers_path' => 'wallpapers', + 'tftp_countries_path' => 'countries' ); $baseConfig = array(); diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 198f5d2..f3a7013 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -295,16 +295,12 @@ trait ajaxHelper { return array(); } $activeDevices = $this->aminterface->sccp_get_active_device(); - if (!empty($activeDevices)) { - foreach ($lineList as $key => $lineArr) { - if (isset($activeDevices[$lineArr['mac']])) { - $actDevStat = $activeDevices[$lineArr['mac']]; - if (!empty($actDevStat)) { - $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; - } else { - $lineList[$key]['line_status'] = '|'; - } - } + foreach ($lineList as $key => $lineArr) { + if (array_key_exists($lineArr['mac'], $activeDevices)) { + $actDevStat = $activeDevices[$lineArr['mac']]; + $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; + } else { + $lineList[$key]['line_status'] = '|'; } } return $lineList; @@ -629,33 +625,60 @@ trait ajaxHelper { break; case 'locale': $locale = $request['locale']; + $totalFiles = 0; $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); $language = $langArr[$locale]['locale']; if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); } - + // Get locales $localeDir = $tftpBootXml->xpath("//Directory[@name='locales']"); $localeDir = $localeDir[0]->xpath("//Directory[@name='languages']"); $result = $localeDir[0]->xpath("//Directory[@name='{$language}']"); - $filesToGet = (array)$result[0]->FileName; + $filesToGet['languages'] = (array)$result[0]->FileName; + $totalFiles += count($filesToGet['languages']); + $languagesSrcDir = (string)$result[0]->DirectoryPath; + $languagesDstDir = "{$this->sccppath['tftp_lang_path']}/{$language}"; + + // Get countries. Country is a substring of locale with exception of korea + $country = explode('_', $language); + array_shift($country); + + $countryName = array_shift($country); + while (count($country)>=1) { + $countryName .= '_' . array_shift($country); + } + + if (!is_dir("{$this->sccppath['tftp_countries_path']}/{$countryName}")) { + mkdir("{$this->sccppath['tftp_countries_path']}/{$countryName}", 0755); + } + + $countryDir = $tftpBootXml->xpath("//Directory[@name='locales']"); + $countryDir = $countryDir[0]->xpath("//Directory[@name='countries']"); + $result = $countryDir[0]->xpath("//Directory[@name='{$countryName}']"); + $filesToGet['countries'] = (array)$result[0]->FileName; + $totalFiles += count($filesToGet['countries']); + $countriesSrcDir = (string)$result[0]->DirectoryPath; + $countriesDstDir = "{$this->sccppath['tftp_countries_path']}/{$countryName}"; - $totalFiles = count($filesToGet); $filesRetrieved = 0; - foreach ($filesToGet as $srcFile) { - file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}", - file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); - $filesRetrieved ++; - $percentComplete = $filesRetrieved *100 / $totalFiles; - $data = "{$percentComplete},"; - echo $data; - ob_flush(); - flush(); - + foreach (array('languages', 'countries') as $section){ + $srcDir = ${"{$section}SrcDir"}; + $dstDir = ${"{$section}DstDir"}; + foreach ($filesToGet[$section] as $srcFile) { + file_put_contents("{$dstDir}/{$srcFile}", + file_get_contents($provisionerUrl . $srcDir . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + $data = "{$percentComplete},"; + echo $data; + ob_flush(); + flush(); + } } - $msg = "{$locale} Locale has been successfully downloaded"; + $msg = "{$locale} Locale and Country tones have been successfully downloaded"; break; default: return false; diff --git a/views/getFileModal.html b/views/getFileModal.html index 9d965f1..30aec63 100644 --- a/views/getFileModal.html +++ b/views/getFileModal.html @@ -33,7 +33,11 @@ echo "