Beispiel #1
0
 /**
  * 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));
 }
Beispiel #4
0
 /**
  * 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);
 }
 public function getLatestHumHubVersion()
 {
     return \humhub\modules\admin\libs\HumHubAPI::getLatestHumHubVersion();
 }