/** * Check if there is a new Humhub Version available and sends a notification * to super admins * * @param \yii\base\Event $event */ public static function onCronDailyRun($event) { $controller = $event->sender; if (!Yii::$app->getModule('admin')->dailyCheckForNewVersion) { return; } if (!Yii::$app->params['humhub']['apiEnabled']) { return; } $controller->stdout("Checking for new HumHub version... "); $latestVersion = libs\HumHubAPI::getLatestHumHubVersion(); if ($latestVersion != "") { $adminUsers = \humhub\modules\user\models\Group::getAdminGroup()->users; $latestNotifiedVersion = Yii::$app->getModule('admin')->settings->get('lastVersionNotify'); $adminsNotified = !($latestNotifiedVersion == "" || version_compare($latestVersion, $latestNotifiedVersion, ">")); $newVersionAvailable = version_compare($latestVersion, Yii::$app->version, ">"); $updateNotification = new notifications\NewVersionAvailable(); // Cleanup existing notifications if (!$newVersionAvailable || $newVersionAvailable && !$adminsNotified) { foreach ($adminUsers as $admin) { $updateNotification->delete($admin); } } // Create new notification if ($newVersionAvailable && !$adminsNotified) { $updateNotification->sendBulk($adminUsers); Yii::$app->getModule('admin')->settings->set('lastVersionNotify', $latestVersion); } } $controller->stdout('done. ' . PHP_EOL, \yii\helpers\Console::FG_GREEN); }
/** * Check if there is a new Humhub Version available and sends a notification * to super admins * * @param \yii\base\Event $event */ public static function onCronDailyRun($event) { $controller = $event->sender; if (!Yii::$app->params['humhub']['apiEnabled']) { return; } $controller->stdout("Checking for new HumHub version... "); $latestVersion = libs\HumHubAPI::getLatestHumHubVersion(); if ($latestVersion != "" && version_compare($latestVersion, Yii::$app->version, ">")) { $notification = new notifications\NewVersionAvailable(); $notification->sendBulk(User::find()->where(['super_admin' => 1])); } $controller->stdout('done. ' . PHP_EOL, \yii\helpers\Console::FG_GREEN); }
/** * Check if there is a new Humhub Version available and sends a notification * to super admins * * @param \yii\base\Event $event */ public static function onCronDailyRun($event) { $controller = $event->sender; if (!Yii::$app->getModule('admin')->marketplaceEnabled) { return; } $controller->stdout("Checking for new HumHub version... "); $onlineModuleManager = new OnlineModuleManager(); $latestVersion = $onlineModuleManager->getLatestHumHubVersion(); if ($latestVersion != "" && version_compare($latestVersion, Yii::$app->version, ">")) { $notification = new notifications\NewVersionAvailable(); $notification->sendBulk(User::find()->where(['super_admin' => 1])); } $controller->stdout('done. ' . PHP_EOL, \yii\helpers\Console::FG_GREEN); }