Exemplo n.º 1
0
Arquivo: API.php Projeto: piwik/piwik
 private function setLicenseKey($licenseKey)
 {
     $key = new LicenseKey();
     $key->set($licenseKey);
     $this->marketplaceClient->clearAllCacheEntries();
     $this->expired->clearCache();
 }
Exemplo n.º 2
0
 public function render()
 {
     $isAdminPage = Common::getRequestVar('isAdminPage', 0, 'int');
     if (!empty($isAdminPage)) {
         $template = 'getNewPluginsAdmin';
     } else {
         $template = 'getNewPlugins';
     }
     $plugins = $this->marketplaceApiClient->searchForPlugins('', '', Sort::METHOD_LAST_UPDATED, '');
     return $this->renderTemplate($template, array('plugins' => array_splice($plugins, 0, 3)));
 }
Exemplo n.º 3
0
 /**
  * @param bool $themesOnly
  * @return array
  */
 public function getPluginsHavingUpdate()
 {
     $this->pluginManager->loadAllPluginsAndGetTheirInfo();
     $loadedPlugins = $this->pluginManager->getLoadedPlugins();
     try {
         $pluginsHavingUpdate = $this->marketplaceClient->getInfoOfPluginsHavingUpdate($loadedPlugins);
     } catch (\Exception $e) {
         $pluginsHavingUpdate = array();
     }
     foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
         foreach ($loadedPlugins as $loadedPlugin) {
             if (!empty($updatePlugin['name']) && $loadedPlugin->getPluginName() == $updatePlugin['name']) {
                 $updatePlugin['currentVersion'] = $loadedPlugin->getVersion();
                 $updatePlugin['isActivated'] = $this->pluginManager->isPluginActivated($updatePlugin['name']);
                 $pluginsHavingUpdate[$key] = $this->addMissingRequirements($updatePlugin);
                 break;
             }
         }
     }
     // remove plugins that have updates but for some reason are not loaded
     foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
         if (empty($updatePlugin['currentVersion'])) {
             unset($pluginsHavingUpdate[$key]);
         }
     }
     return $pluginsHavingUpdate;
 }
Exemplo n.º 4
0
 private function getLoginLink()
 {
     $info = $this->client->getInfo();
     if (empty($info['loginUrl'])) {
         return '';
     }
     return '<a href="' . $info['loginUrl'] . '" target="_blank" rel="noreferrer">';
 }
Exemplo n.º 5
0
 /**
  * @throws PluginInstallerException
  */
 private function makeSurePluginNameIsValid()
 {
     try {
         $pluginDetails = $this->marketplaceClient->getPluginInfo($this->pluginName);
     } catch (\Exception $e) {
         throw new PluginInstallerException($e->getMessage());
     }
     if (empty($pluginDetails)) {
         throw new PluginInstallerException('This plugin was not found in the Marketplace.');
     }
 }
Exemplo n.º 6
0
 public function download()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->dieIfPluginsAdminIsDisabled();
     $pluginName = new PluginName();
     $pluginName = $pluginName->getPluginName();
     Nonce::checkNonce($pluginName);
     $filename = $pluginName . '.zip';
     try {
         $pathToPlugin = $this->marketplaceApi->download($pluginName);
         ProxyHttp::serverStaticFile($pathToPlugin, 'application/zip', $expire = 0, $start = false, $end = false, $filename);
     } catch (Exception $e) {
         Common::sendResponseCode(500);
         Log::warning('Could not download file . ' . $e->getMessage());
     }
     if (!empty($pathToPlugin)) {
         Filesystem::deleteFileIfExists($pathToPlugin);
     }
 }