Skip to content

Commit

Permalink
Merge pull request #80 from mundry/version-detection-fix
Browse files Browse the repository at this point in the history
fix version detection for backwards compatability
  • Loading branch information
creecros authored Apr 4, 2023
2 parents 8e22bf0 + 5c1a2d3 commit 6cc5967
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,28 @@ public function initialize()
$this->helper->register('newTaskHelper', '\Kanboard\Plugin\Group_assign\Helper\NewTaskHelper');
$this->helper->register('sizeAvatarHelperExtend', '\Kanboard\Plugin\Group_assign\Helper\SizeAvatarHelperExtend');


//Models and backward compatibility
$load_new_classes = true;
$applications_version = str_replace('v', '', APP_VERSION);
if ((strpos(APP_VERSION, 'master') !== false || strpos(APP_VERSION, 'main') !== false) && file_exists('ChangeLog')) {
$applications_version = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' ');

if (strpos(APP_VERSION, 'master') !== false || strpos(APP_VERSION, 'main') !== false) {
if (file_exists('ChangeLog')) {
$applications_version = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' ');
$clean_appversion = preg_replace('/\s+/', '', $applications_version);
$load_new_classes = version_compare($clean_appversion, '1.2.6', '<');
}
} else {
$load_new_classes = version_compare($applications_version, '1.2.5', '>');
}
$clean_appversion = preg_replace('/\s+/', '', $applications_version);

if (version_compare($clean_appversion, '1.2.6', '<')) {
if ($load_new_classes) {
if (file_exists('plugins/MetaMagik')) {
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
return new OldMetaMagikSubquery($c);
return new NewMetaMagikSubquery($c);
});
} else {
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
return new OldTaskFinderModel($c);
return new NewTaskFinderModel($c);
});
}
$this->container['taskDuplicationModel'] = $this->container->factory(function ($c) {
Expand All @@ -79,11 +85,11 @@ public function initialize()
} else {
if (file_exists('plugins/MetaMagik')) {
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
return new NewMetaMagikSubquery($c);
return new OldMetaMagikSubquery($c);
});
} else {
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
return new NewTaskFinderModel($c);
return new OldTaskFinderModel($c);
});
}
$this->container['taskDuplicationModel'] = $this->container->factory(function ($c) {
Expand Down

0 comments on commit 6cc5967

Please sign in to comment.