Ejemplo n.º 1
0
 /**
  * Check the version and return the available updates.
  *
  * @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
  * @param bool $force_update Ignores cached data. Defaults to false.
  * @param bool $force_cache Force the use of the cache. Override $force_update.
  * @return string
  * @throws RuntimeException
  */
 public static function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
 {
     $cache = objects::$cache;
     $config = objects::$config;
     $user = objects::$user;
     $meta = $md_manager->get_metadata('all');
     if (!isset($meta['extra']['version-check'])) {
         throw new \RuntimeException($user->lang('NO_VERSIONCHECK'), 1);
     }
     $version_check = $meta['extra']['version-check'];
     if (version_compare($config['version'], '3.1.1', '>')) {
         $version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader(), $user);
     } else {
         $version_helper = new \phpbb\version_helper($cache, $config, $user);
     }
     $version_helper->set_current_version($meta['version']);
     $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
     $version_helper->force_stability($config['extension_force_unstable'] ? 'unstable' : null);
     return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
 }
Ejemplo n.º 2
0
 /**
  * Check the version and return the available updates.
  *
  * @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
  * @param bool $force_update Ignores cached data. Defaults to false.
  * @param bool $force_cache Force the use of the cache. Override $force_update.
  * @return string
  * @throws RuntimeException
  */
 protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
 {
     $meta = $md_manager->get_metadata('all');
     if (!isset($meta['extra']['version-check'])) {
         throw new \RuntimeException($this->user->lang('NO_VERSIONCHECK'), 1);
     }
     $version_check = $meta['extra']['version-check'];
     $version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), $this->user);
     $version_helper->set_current_version($meta['version']);
     $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
     $version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
     return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
 }
 /**
  * Obtain the last version for this extension
  *
  * @return null
  * @access private
  */
 private function obtain_last_version()
 {
     try {
         if (!isset($this->ext_meta['extra']['version-check'])) {
             throw new \RuntimeException($this->user->lang('PPDE_NO_VERSIONCHECK'), 1);
         }
         $version_check = $this->ext_meta['extra']['version-check'];
         $version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), $this->user);
         $version_helper->set_current_version($this->ext_meta['version']);
         $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
         $version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
         $recheck = $this->request->variable('versioncheck_force', false);
         $s_up_to_date = $version_helper->get_suggested_updates($recheck);
         $this->template->assign_vars(array('S_UP_TO_DATE' => empty($s_up_to_date), 'S_VERSIONCHECK' => true, 'UP_TO_DATE_MSG' => $this->user->lang('PPDE_NOT_UP_TO_DATE', $this->ext_meta['extra']['display-name'])));
     } catch (\RuntimeException $e) {
         $this->template->assign_vars(array('S_VERSIONCHECK_STATUS' => $e->getCode(), 'VERSIONCHECK_FAIL_REASON' => $e->getMessage() !== $this->user->lang('VERSIONCHECK_FAIL') ? $e->getMessage() : ''));
     }
 }