/** * 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); }
public function actionIndex() { $isNewVersionAvailable = false; $isUpToDate = false; $latestVersion = HumHubAPI::getLatestHumHubVersion(); if ($latestVersion) { $isNewVersionAvailable = version_compare($latestVersion, Yii::$app->version, ">"); $isUpToDate = !$isNewVersionAvailable; } return $this->render('index', array('currentVersion' => Yii::$app->version, 'latestVersion' => $latestVersion, 'isNewVersionAvailable' => $isNewVersionAvailable, 'isUpToDate' => $isUpToDate)); }
public function actionAbout() { $this->appendPageTitle(Yii::t('AdminModule.base', 'About')); $isNewVersionAvailable = false; $isUpToDate = false; $latestVersion = HumHubAPI::getLatestHumHubVersion(); if ($latestVersion) { $isNewVersionAvailable = version_compare($latestVersion, Yii::$app->version, ">"); $isUpToDate = !$isNewVersionAvailable; } return $this->render('about', array('currentVersion' => Yii::$app->version, 'latestVersion' => $latestVersion, 'isNewVersionAvailable' => $isNewVersionAvailable, 'isUpToDate' => $isUpToDate)); }
/** * 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); }
/** * Returns all available updates for a given version * * @param type $version */ public static function getAvailableUpdate() { $info = []; if (class_exists('\\humhub\\modules\\admin\\libs\\HumHubAPI')) { $info = \humhub\modules\admin\libs\HumHubAPI::request('v1/modules/getHumHubUpdates', ['updaterVersion' => Yii::$app->getModule('updater')->version]); } else { // older Versions try { $url = Yii::$app->getModule('admin')->marketplaceApiUrl . "getHumHubUpdates?version=" . Yii::$app->version . "&updaterVersion=" . Yii::$app->getModule('updater')->version . "&installId=" . Setting::Get('installationId', 'admin'); $http = new \Zend\Http\Client($url, array('adapter' => '\\Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => Yii::$app->getModule('updater')->getCurlOptions(), 'timeout' => 30)); $response = $http->send(); $info = Json::decode($response->getBody()); } catch (Exception $ex) { throw new Exception(Yii::t('UpdaterModule.base', 'Could not get update info online! (%error%)', array('%error%' => $ex->getMessage()))); } } if (!isset($info['fromVersion'])) { return null; } $package = new UpdatePackage($info['fileName'], $info['fromVersion'], $info['toVersion']); $package->md5 = $info['md5']; $package->downloadUrl = $info['downloadUrl']; return $package; }
/** * Returns an array of informations about a module */ public function getModuleInfo($moduleId) { return HumHubAPI::request('v1/modules/info', ['id' => $moduleId]); }
/** * Complete list of all modules */ public function actionListPurchases() { $hasError = false; $message = ""; $licenceKey = Yii::$app->request->post('licenceKey', ""); if ($licenceKey != "") { $result = \humhub\modules\admin\libs\HumHubAPI::request('v1/modules/registerPaid', ['licenceKey' => $licenceKey]); if (!isset($result['status'])) { $hasError = true; $message = 'Could not connect to HumHub API!'; } elseif ($result['status'] == 'ok' || $result['status'] == 'created') { $message = 'Module licence added!'; $licenceKey = ""; } else { $hasError = true; $message = 'Invalid module licence key!'; } } // Only showed purchased modules $onlineModules = $this->getOnlineModuleManager(); $modules = $onlineModules->getModules(false); foreach ($modules as $i => $module) { if (!isset($module['purchased']) || !$module['purchased']) { unset($modules[$i]); } } return $this->render('listPurchases', array('modules' => $modules, 'licenceKey' => $licenceKey, 'hasError' => $hasError, 'message' => $message)); }
public function getLatestHumHubVersion() { return \humhub\modules\admin\libs\HumHubAPI::getLatestHumHubVersion(); }