else
$pkgs[$l['package']] = array_merge($pkgs[$l['package']], $l);
}
- ksort($pkgs);
+ if ($pkgs)
+ ksort($pkgs);
return $pkgs;
}
//---------------------------------------------------------------------------------------
'Name' => 'name',
'Description' => 'Descr',
'Type' => 'type',
- 'DefaultStatus'=> 'active',
+ 'DefaultStatus' => 'active',
// 'MenuTabs' => 'tabs',
// 'MenuEntries' => 'entries',
'Encoding' => 'encoding',
// else
$pkgs[$ext['package']] = array_merge($pkgs[$ext['package']], $ext);
}
- ksort($pkgs);
+ if ($pkgs)
+ ksort($pkgs);
return $pkgs;
}
//
}
}
// TODO: Add other themes from themes directory
-
- ksort($pkgs);
+ if ($pkgs)
+ ksort($pkgs);
return $pkgs;
}
//---------------------------------------------------------------------------------------
else
$pkgs[$ext['package']] = array_merge($pkgs[$ext['package']], $ext);
}
- ksort($pkgs);
+ if ($pkgs)
+ ksort($pkgs);
return $pkgs;
}
//---------------------------------------------------------------------------------------------
//
function install_extension($pkg_name)
{
- global $path_to_root, $installed_extensions, $next_extension_id, $Ajax;
+ global $path_to_root, $installed_extensions, $next_extension_id, $Ajax, $db_connections;
$pkg = get_pkg_or_list(array('extension', 'theme', 'chart'), $pkg_name);
if ($pkg) {
'package' => $pkg['Package'],
'version' => $pkg['Version'],
'type' => $pkg['Type'],
- 'active' => true,
+ 'active' => @$pkg['DefaultStatus'] == 'active' ? true : false,
'path' => $pkg['InstallPath'],
);
-// if (isset($pkg['MenuTabs']))
-// $ext['tabs'] = $pkg['MenuTabs'];
-// if (isset($pkg['MenuEntries']))
-// $ext['entries'] = $pkg['MenuEntries'];
-// if (isset($pkg['AccessExtensions']))
-// $ext['acc_file'] = $pkg['AccessExtensions'];
if (isset($pkg['SqlScript']))
$ext['sql'] = $pkg['SqlScript'];
+
$local_exts[$ext_id] = $ext;
$ret = update_extensions($local_exts);
+
+ if (($ext['active'] == true) && file_exists($path_to_root.'/'.$ext['path'].'/hooks.php'))
+ {
+ // we need to include the new hooks file to activate extension
+ include_once($path_to_root.'/'.$ext['path'].'/hooks.php');
+ foreach($db_connections as $comp => $db)
+ activate_hooks($ext['package'], $comp);
+ }
+
unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg');
$Ajax->activate('ext_tbl');
return $ret;
return get_pkg_or_list($type, $pkg, $filter, null, false);
}
-?>
\ No newline at end of file
+/*
+ Check basic extension source compatibility.
+*/
+function check_src_ext_version($ext_v)
+{
+ global $src_version;
+
+ $compat_levels = 2; // current policy is keeping compatibility on major version level.
+ $app = explode('.', substr($src_version, 0, strspn($src_version, "0123456789.")));
+ $pkg = explode('.', substr($ext_v, 0, strspn($ext_v, "0123456789.")));
+
+ for ($i=0; $i < min($compat_levels, count($app)); $i++)
+ if ($pkg[$i] < $app[$i])
+ return false;
+
+ return true;
+}
+