Ejemplo n.º 1
0
	/**
	 * Detect FireBoard version.
	 *
	 * @return  string  FireBoard version or null.
	 */
	public function detect()
	{
		// Check if FireBoard can be found from the Joomla installation.
		if (KunenaInstaller::detectTable('fb_version'))
		{
			// Get installed version.
			$db = JFactory::getDBO();
			$db->setQuery("SELECT version, versiondate AS date FROM #__fb_version ORDER BY id DESC", 0, 1);
			$version = $db->loadRow();

			// Do not detect Kunena 1.x.
			if ($version && version_compare($version->version, '1.0.5', '>'))
			{
				return null;
			}
			// Return FireBoard version.
			if ($version->version)
			{
				return $version->version;
			}
		}
		foreach ($this->versions as $version)
		{
			if (KunenaInstaller::getTableColumn($version['table'], $version['column']))
			{
				return $version->version;
			}
		}

		return null;
	}
Ejemplo n.º 2
0
 /**
  * Detect JoomlaBoard version.
  *
  * @return  string  JoomlaBoard version or null.
  */
 public function detect()
 {
     foreach ($this->versions as $version) {
         if (KunenaInstaller::getTableColumn($version['table'], $version['column'])) {
             return $version->version;
         }
     }
     return null;
 }
Ejemplo n.º 3
0
	/**
	 * Detect if table exists in the database.
	 *
	 * @param string  $table   Table name to be found.
	 * @param string  $prefix  Database prefix.
	 * @param bool    $reload  Reload all tables.
	 *
	 * @return boolean  True if the table exists in the database.
	 */
	public static function detectTable($table, $prefix = '#__', $reload = false) {
		$db = JFactory::getDBO();
		if (self::$tables === null || $reload) {
			$list = $db->getTableList();

			self::$tables = array();
			foreach ($list as $item) {
				self::$tables[$item] = false;
			}
		}

		if ($prefix == '#__') $prefix = $db->getPrefix();
		$table = $prefix . $table;

		return isset(self::$tables[$table]);
	}
Ejemplo n.º 4
0
 /**
  * Detect Kunena 1.x version.
  *
  * @return  string  Kunena version or null.
  */
 public function detect()
 {
     // Check if Kunena 1.x can be found from the Joomla installation.
     if (KunenaInstaller::detectTable('fb_version')) {
         // Get installed version.
         $db = JFactory::getDBO();
         $db->setQuery("SELECT version, versiondate AS date FROM #__fb_version ORDER BY id DESC", 0, 1);
         $version = $db->loadRow();
         // Do not detect FireBoard 1.0.5 RC1 / RC2.
         if ($version && version_compare($version->version, '1.0.5', '<=')) {
             return null;
         }
         // Return FireBoard version.
         if ($version->version) {
             return $version->version;
         }
     }
     return null;
 }
Ejemplo n.º 5
0
 /**
  * Prevent downgrades to Kunena 1.7 and older releases
  */
 public function onExtensionBeforeUpdate($type, $manifest)
 {
     if ($type != 'component') {
         return true;
     }
     // Generate component name
     $name = strtolower(JFilterInput::getInstance()->clean((string) $manifest->name, 'cmd'));
     $element = substr($name, 0, 4) == "com_" ? $name : "com_{$name}";
     if ($element != 'com_kunena') {
         return true;
     }
     // Kunena 2.0.0-BETA2 and later support this feature in their installer
     if (version_compare($manifest->version, '2.0.0', '>=')) {
         return true;
     }
     // Check if we can downgrade to the current version
     if (class_exists('KunenaInstaller') && KunenaInstaller::canDowngrade($manifest->version)) {
         return true;
     }
     // Old version detected: emulate failed installation
     $app = JFactory::getApplication();
     $app->enqueueMessage(sprintf('Sorry, it is not possible to downgrade Kunena %s to version %s.', KunenaForum::version(), $manifest->version), 'warning');
     $app->enqueueMessage(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'), 'error');
     $app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($type))));
     $app->redirect('index.php?option=com_installer');
     return true;
 }
Ejemplo n.º 6
0
 protected function checkKunena($version)
 {
     $app = JFactory::getApplication();
     // Always load Kunena API if it exists.
     $api = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
     if (file_exists($api)) {
         require_once $api;
     }
     // Do not install over Git repository (K1.6+).
     if (class_exists('Kunena') && method_exists('Kunena', 'isSvn') && Kunena::isSvn() || class_exists('KunenaForum') && method_exists('KunenaForum', 'isDev') && KunenaForum::isDev()) {
         $app->enqueueMessage('Oops! You should not install Kunena over your Git reporitory!', 'notice');
         return false;
     }
     $db = JFactory::getDBO();
     // Check if Kunena can be found from the database
     $table = $db->getPrefix() . 'kunena_version';
     $db->setQuery("SHOW TABLES LIKE {$db->quote($table)}");
     if ($db->loadResult() != $table) {
         return true;
     }
     // Get installed Kunena version
     $db->setQuery("SELECT version FROM {$db->quoteName($table)} ORDER BY `id` DESC", 0, 1);
     $installed = $db->loadResult();
     if (!$installed) {
         return true;
     }
     // Always allow upgrade to the newer version
     if (version_compare($version, $installed, '>=')) {
         return true;
     }
     // Check if we can downgrade to the current version
     if (class_exists('KunenaInstaller')) {
         if (KunenaInstaller::canDowngrade($version)) {
             return true;
         }
     } else {
         // Workaround when Kunena files were removed to allow downgrade between bugfix versions.
         $major = preg_replace('/(\\d+.\\d+)\\..*$/', '\\1', $version);
         if (version_compare($installed, $major, '>')) {
             return true;
         }
     }
     $app->enqueueMessage(sprintf('Sorry, it is not possible to downgrade Kunena %s to version %s.', $installed, $version), 'notice');
     return false;
 }