/**
  * 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));
 }