public function actionIndex() { $isNewVersionAvailable = false; $isUpToDate = false; $latestVersion = ""; if ($this->getModule()->marketplaceEnabled) { $onlineModuleManager = new OnlineModuleManager(); $latestVersion = $onlineModuleManager->getLatestHumHubVersion(); if ($latestVersion) { $isNewVersionAvailable = version_compare($latestVersion, HVersion::VERSION, ">"); $isUpToDate = !$isNewVersionAvailable; } } $this->render('index', array('currentVersion' => HVersion::VERSION, 'latestVersion' => $latestVersion, 'isNewVersionAvailable' => $isNewVersionAvailable, 'isUpToDate' => $isUpToDate)); }
/** * Check if there is a new Humhub Version available * * @param type $event */ public static function onCronDailyRun($event) { Yii::import('application.modules_core.admin.libs.*'); $cron = $event->sender; if (!Yii::app()->getModule('admin')->marketplaceEnabled) { return; } $onlineModuleManager = new OnlineModuleManager(); $latestVersion = $onlineModuleManager->getLatestHumHubVersion(); if ($latestVersion != "" && version_compare($latestVersion, HVersion::VERSION, ">")) { foreach (User::model()->findAllByAttributes(array('super_admin' => 1)) as $user) { $notification = Notification::model()->findByAttributes(array('class' => 'HumHubUpdateNotification', 'user_id' => $user->id)); if ($notification === null) { $notification = new Notification(); $notification->class = "HumHubUpdateNotification"; $notification->user_id = $user->id; $notification->save(); } } } }
/** * Installs a given moduleId from marketplace */ public function actionInstall() { $this->forcePostRequest(); $moduleId = Yii::app()->request->getQuery('moduleId'); if (!Yii::app()->moduleManager->isInstalled($moduleId)) { $onlineModules = new OnlineModuleManager(); $onlineModules->install($moduleId); } // Redirect to Module Install? $this->redirect(Yii::app()->createUrl('admin/module/list')); }
public function getLatestHumHubVersion() { Yii::import('application.modules_core.admin.libs.*'); $onlineModuleManager = new OnlineModuleManager(); return $onlineModuleManager->getLatestHumHubVersion(); }
/** * Updates a module * * @param type $args * @return type */ public function actionUpdate($args, $force = false) { if (!isset($args[0])) { print "Error: Module Id required!\n\n"; print $this->getHelp(); return; } $moduleId = $args[0]; if (!Yii::app()->moduleManager->isInstalled($moduleId)) { print "\nModule " . $moduleId . " is not installed!\n"; return; } // Look online for module $onlineModules = new OnlineModuleManager(); $moduleInfo = $onlineModules->getModuleInfo($moduleId); if (!isset($moduleInfo['latestCompatibleVersion'])) { print "No compatible version for " . $moduleId . " found online!\n"; return; } if (!$force) { $module = Yii::app()->moduleManager->getModule($moduleId); if ($moduleInfo['latestCompatibleVersion']['version'] == $module->getVersion()) { print "Module " . $moduleId . " already up to date!\n"; return; } } $onlineModules->update($moduleId); print "Module " . $moduleId . " successfully updated!\n"; }