MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-
+include($path_to_root."/includes/packages.inc");
//
// Utility class contains basic database upgrade routines.
//
return false;
}
+ /*
+ Check and disable incompatible extensions.
+ */
+ function update_extensions()
+ {
+ global $version;
+
+ $mods = get_company_extensions();
+ $exts = get_company_extensions($this->cur_company);
+
+ $fixed = false;
+ foreach($mods as $key => $ins) {
+ foreach($exts as $ext)
+ if ($ext['name'] == $ins['name'] && (!check_src_ext_version($ins['version']))) {
+ $mods[$key]['active'] = false;
+ $this->log_error(sprintf(_("Uncompatible extension '%s' disabled for company %d."), $ins['name'], $this->cur_company));
+ $fixed = true;
+ continue 2;
+ }
+ }
+ if ($fixed)
+ write_extensions($mods, $this->cur_company);
+ }
+
/*
Pre-install maintenance: login to company, open upgrade log, make a backup
*/
return $this->log_error(sprintf(_("Cannot upgrade company %s: database version is incompatible ('%s' instead of '%s')."),
$this->cur_company, $cur_ver, $this->previous));
+ $this->update_extensions(); // disable uncompatible extensions
+
if (!$this->prepare()) // fetch params, perform additional checks (if any)
return false;
$result = true;
foreach($exts as $i => $ext) {
if ($ext['package'] && ($ext['active'] ^ check_value('Active'.$i))) {
+ if (check_value('Active'.$i) && !check_src_ext_version($ext['version']))
+ {
+ display_warning(sprintf(_("Package '%s' is incompatible with current application version and cannot be activated.\n")
+ . _("Check Install/Activate page for newer package version."), $ext['name']));
+ continue;
+ }
if (!$ext['active'])
$activated = activate_hooks($ext['package'], $comp);
else
return get_pkg_or_list($type, $pkg, $filter, null, false);
}
+/*
+ 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('.', strspn($src_version, "0123456789."));
+ $pkg = explode('.', strspn($ext_v, "0123456789."));
+
+ for ($i=0; $i < min($compat_levels, count($app)); $i++)
+ if ($pkg[$i] < $app[$i])
+ return false;
+
+ return true;
+}
+
// Settings in this file can be automatically updated at any time during software update.
//
-// Internal database version compatibility check. Do not change.
+// Versions used by source/database version compatibility checks. Do not change.
$db_version = "2.4.0";
+$src_version = "2.4.0";
// application version - can be overriden in config.php
if (!isset($version))
- $version = "2.4 alpha";
+ $version = $src_version;
//======================================================================
// Extension packages repository settings