Skip to content

Commit

Permalink
Dev: Test pushing notification from new extension version available
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 2, 2018
1 parent 44860ea commit bee3dee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
18 changes: 16 additions & 2 deletions application/controllers/admin/ExtensionUpdaterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ public function checkAll()

foreach ($updaters as $updater) {
try {
$updates = $updater->getAvailableUpdates();
echo '<pre>'; var_dump($updates); echo '</pre>';
list($extensionName, $extensionType, $updates) = $updater->getAvailableUpdates();
if ($updates) {
$superadmins = User::model()->getSuperAdmins();
Notification::broadcast(
[
'title' => gT('Updates available'),
'message' => sprintf(
gT('There are updates available for %s %s, new version number(s): %s.'),
$extensionType,
$extensionName,
implode(', ', $updates)
)
],
$superadmins
);
}
} catch (\Exception $ex) {
echo $ex->getMessage() . '<br/>';
}
Expand Down
12 changes: 10 additions & 2 deletions application/libraries/ExtensionInstaller/PluginUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,27 @@ public function getAvailableUpdates()
return [];
}

$allowUnstable = getGlobalSetting('allow_unstable_extension_update');

$versions = [];
foreach ($this->versionFetchers as $fetcher) {
$fetcher->setExtensionName($this->getExtensionName());
$fetcher->setExtensionType($this->getExtensionType());
$newVersion = $fetcher->getLatestVersion();

// If this version is unstable and we're not allowed to use it, continue.
if (!$allowUnstable && !$this->versionIsStable($newVersion)) {
continue;
}

if (version_compare($newVersion, $this->model->version, '>')) {
$versions[] = $newVersion;
} else {
// Ignore.
}
}
echo $this->model->version;

return $versions;
return [$this->model->name, 'plugin', $versions];
}

/**
Expand Down
4 changes: 4 additions & 0 deletions application/libraries/ExtensionInstaller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Extension installer library documentation
-----------------------------------------


0 comments on commit bee3dee

Please sign in to comment.