See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
include_once($path_to_root. "/includes/archive.inc");
+include_once($path_to_root. "/includes/remote_url.inc");
define('PKG_CACHE_PATH', $path_to_root.'/modules/_cache');
define('PUBKEY_PATH', $path_to_root);
//
$loclist = PKG_CACHE_PATH.'/Release.gz';
- if ($type!=null && !is_array($type)) {
+ if (isset($type) && !is_array($type)) {
$type = array($type);
}
$refresh = true;
do{
if (!file_exists($loclist)) {
- copy(REPO_URL.'/Release.gz', $loclist);
+ url_copy(REPO_URL.'/Release.gz', $loclist);
$refresh = false;
}
- $sig = file_get_contents(REPO_URL.'/Release.sig', 'rb');
+ $sig = url_get_contents(REPO_URL.'/Release.sig');
$data = file_get_contents($loclist);
$cert = file_get_contents(PUBKEY_PATH.'/FA.pem');
if (!openssl_verify($data, $sig, $cert)) {
} while($refresh);
$Release = get_control_file($loclist, 'Filename');
-
// download and check all indexes containing given package types
// then complete package list or seek for pkg
$Packages = array();
$refresh = true;
do{
if (!file_exists($locindex)) {
- copy($remoteindex, $locindex);
+ url_copy($remoteindex, $locindex);
$refresh = false;
}
if ($parms['SHA1sum'] != sha1_file($locindex)) { // check subdir index consistency
$pkglist = get_control_file($locindex, 'Package');
foreach($pkglist as $name => $pkg) {
$pkgfullname = REPO_URL.'/'.$parms['Path']."/".$pkg['Filename'].'.pkg';
- if ($type==null || in_array($pkg['Type'], $type)) {
+ if (!isset($type) || in_array($pkg['Type'], $type)) {
if (empty($filter))
$p = $pkg;
else {
//download package to temp directory
if ($download) {
$locname = "$path_to_root/tmp/".$pkg['Filename'].'.pkg';
- copy($pkgfullname, $locname);
+ url_copy($pkgfullname, $locname);
// checking sha1 hash is expensive proces, so chekc the package
// consistency just before downloading
if ($pkg['SHA1sum'] != sha1_file($locname)) {
}
}
}
-
+
return $Packages;
}
// Return merged list of available and installed extensions as a local
// configuration array supplemented with installed versions information.
//
-function get_extensions_list()
+function get_extensions_list($type = null)
{
- $pkgs = get_pkg_or_list('extension', null, array(
+
+ if (isset($type) && !is_array($type)) {
+ $type = array($type);
+ }
+
+ $pkgs = get_pkg_or_list($type, null, array(
'Package' => 'package',
'Version' => 'available',
'Name' => 'name',
'DefaultStatus'=> 'active',
'MenuTabs' => 'tabs',
'MenuEntries' => 'entries',
+ 'Encoding' => 'encoding',
'AccessExtensions' => 'acc_file',
'InstallPath' => 'path'
));
//
$local = get_company_extensions();
foreach($local as $extno => $ext) {
- if ($ext['type'] != 'extension') continue;
+ if (!in_array($ext['type'], $type)) continue;
$ext['local_id'] = $extno;
if (!isset($pkgs[$ext['package']]) || $ext['package'] == '')
$pkgs[] = $ext;
'Description' => 'Descr',
'Type' => 'type',
'InstallPath' => 'path',
+ 'Encoding' => 'encoding',
'SqlScript' => 'sql'
));
write_lang($installed_languages);
unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg');
$Ajax->activate('lang_tbl');
+ } else {
+ display_error(implode('<br>', $package->error));
+ return false;
}
-
+ } else {
+ display_error(sprintf(_("Package '%s' not found."), $pkg_name));
+ return false;
}
-
+ return true;
}
//---------------------------------------------------------------------------------------------
// Install/update extension or theme package from repository
//
function install_extension($pkg_name)
{
- global $path_to_root, $next_extension_id, $Ajax;
+ global $path_to_root, $installed_extensions, $next_extension_id, $Ajax;
$pkg = get_pkg_or_list(array('extension', 'theme', 'chart'), $pkg_name);
if ($pkg) {
$ext_id = array_search_key($pkg['Package'], $local_exts, 'package');
if ($ext_id === null)
$ext_id = $next_extension_id++;
+ else { // remove another already installed package for this language
+ $old_pkg = $installed_extensions[$ext_id]['package'];
+ if ($old_pkg)
+ uninstall_package($old_pkg);
+ }
$ext = array(
'name' => $pkg['Name'],
'package' => $pkg['Package'],
display_error(implode('<br>', $package->error));
return false;
}
+ } else {
+ display_error(sprintf(_("Package '%s' not found."), $pkg_name));
+ return false;
}
return true;
}