/** * @param string $type * @param JInstallerAdapterComponent $parent * * @return bool */ public function preFlight($type, $parent) { parent::preFlight($type, $parent); /* Uninstall the depracated plugin OSCARootCertificates. * The parent method can't be used because the old plugin * has a bug that doesn't allow to use the native uninstall method. */ jimport('joomla.filesystem.folder'); $success = false; // Remove the files $path = JPATH_SITE . '/plugins/system/oscarootcertificates'; if (JFolder::exists($path)) { $success = JFolder::delete($path); } // Remove the database row $db = JFactory::getDbo(); $queryWhere = array($db->qn('type') . ' = ' . $db->q('plugin'), $db->qn('element') . ' = ' . $db->q('oscarootcertificates'), $db->qn('folder') . ' = ' . $db->q('system')); $query = $db->getQuery(true)->select('COUNT(*)')->from('#__extensions')->where($queryWhere); $db->setQuery($query); if ((int) $db->loadResult() > 0) { $query = $db->getQuery(true)->delete('#__extensions')->where($queryWhere); $db->setQuery($query); $success = $db->execute(); } // Displays the success message if ((bool) $success) { $this->setMessage('Uninstalling system plugin OSCARootCertificates was successful'); } return true; }
/** * @param string $type * @param JInstallerAdapterComponent $parent * * @return void */ public function postFlight($type, $parent) { $this->isXmapDataFound = $this->lookForXmapData(); $this->createDefaultSitemap(); // If Xmap plugins are still available and we don't have the OSMap plugins yet, // save Xmap plugins params to re-apply after install OSMap plugins $this->saveXmapPluginParamsIfExists(); parent::postFlight($type, $parent); // Check if we have params from Xmap plugins to apply to OSMap plugins $this->moveXmapPluginsParamsToOSMapPlugins(); }
/** * Uninstall the related extensions that are useless without the component */ protected function uninstallRelated() { parent::uninstallRelated(); if ($this->relatedExtensions) { $installer = new JInstaller(); foreach ($this->relatedExtensions as $type => $folders) { foreach ($folders as $folder => $extensions) { foreach ($extensions as $element => $settings) { if ($settings[1]) { if ($current = $this->findExtension($type, $element, $folder)) { $msg = 'LIB_ALLEDIAINSTALLER_RELATED_UNINSTALL'; $msgtype = 'message'; if (!$installer->uninstall($current->type, $current->extension_id)) { $msg .= '_FAIL'; $msgtype = 'error'; } $this->setMessage(JText::sprintf($msg, $type, $element), $msgtype); } } } } } } }
/** * @param string $type * @param JInstallerAdapterComponent $parent * * @return void */ public function postFlight($type, $parent) { $this->isXmapDataFound = $this->lookForXmapData(); $this->createDefaultSitemap(); parent::postFlight($type, $parent); }
/** * Method to run after an install/update method * * @return void */ public function postFlight($type, $parent) { $db = JFactory::getDBO(); // The upload destination path has changed, so let's move the files to the new destination $this->moveCurrentUploadedFiles(); // Check if mod_osdownloads is installed to show the warning of deprecated $query = $db->getQuery(true)->select('COUNT(*)')->from('#__extensions')->where($db->qn('type') . '=' . $db->q('module'))->where($db->qn('element') . '=' . $db->q('mod_osdownloads')); $db->setQuery($query); $this->deprecatedModOSDownloadsIsInstalled = (int) $db->loadResult(); parent::postFlight($type, $parent); // Legacy database update $db->setQuery("SHOW COLUMNS FROM #__osdownloads_documents"); $rows = $db->loadObjectList(); $db_version = "1.0.0"; $has_show_email = false; $has_description_3 = false; $has_direct_field = false; $has_file_url = false; $has_parent_id = false; $has_cms_version = false; $has_picture = false; $has_external_ref = false; $has_access = false; $has_agreement_article_id = false; foreach ($rows as $row) { if ($row->Field == "show_email") { $has_show_email = true; } if ($row->Field == "description_3") { $has_description_3 = true; } if ($row->Field == "direct_page") { $has_direct_field = true; } if ($row->Field == "file_url") { $has_file_url = true; } if ($row->Field == "file_url") { $has_file_url = true; } if ($row->Field == 'parent_id') { $has_parent_id = true; } if ($row->Field == 'cms_version') { $has_cms_version = true; } if ($row->Field == 'picture') { $has_picture = true; } if ($row->Field == 'external_ref') { $has_external_ref = true; } if ($row->Field == 'access') { $has_access = true; } if ($row->Field == 'agreement_article_id') { $has_agreement_article_id = true; } } if ($has_show_email && !$has_description_3) { $db_version = "1.0.1"; } if ($has_show_email && $has_description_3) { $db_version = "1.0.2"; } if ($has_direct_field) { $db_version = "1.0.3"; } if ($db_version == "1.0.0") { echo "<div>Migrate database from version 1.0.0 to 1.0.3</div>"; $db->setQuery(file_get_contents(JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osdownloads" . DS . "sql" . DS . "update_1.0.0_1.0.3.mysql.utf8.sql")); $db->query(); } if ($db_version == "1.0.1") { echo "<div>Migrate database from version 1.0.1 to 1.0.3</div>"; $db->setQuery(file_get_contents(JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osdownloads" . DS . "sql" . DS . "update_1.0.1_1.0.3.mysql.utf8.sql")); $db->query(); } if ($db_version == "1.0.2") { echo "<div>Migrate database from version 1.0.2 to 1.0.3</div>"; $db->setQuery(file_get_contents(JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osdownloads" . DS . "sql" . DS . "update_1.0.2_1.0.3.mysql.utf8.sql")); $db->query(); } if (!$has_description_3) { // Fix database if upgrade from version 1.0.2 (new install). If upgrade from 1.0.x to 1.0.2 it still correct $db->setQuery("SHOW COLUMNS FROM #__osdownloads_documents"); $rows = $db->loadObjectList(); $has_description_3 = false; foreach ($rows as $row) { if ($row->Field == "description_3") { $has_description_3 = true; } } if (!$has_description_3) { echo "<div>Apply patch for database version 1.0.2</div>"; $db->setQuery("ALTER TABLE `#__osdownloads_documents` ADD `description_3` TEXT NOT NULL AFTER `description_2`"); $db->query(); } } if (!$has_file_url) { echo "<div>Migrate database for remote files</div>"; $sql = file_get_contents(JPATH_ADMINISTRATOR . "/components/com_osdownloads/sql/updates/mysql/1.0.17.sql"); $db->setQuery($sql); $db->query(); } // Legacy database update $columns = array('external_ref' => 'VARCHAR(100)', 'access' => 'INT(11) NOT NULL DEFAULT 1', 'agreement_article_id' => 'INT(11)'); $this->addColumnsIfNotExists('#__osdownloads_documents', $columns); $columns = array('parent_id', 'cms_version', 'picture'); $this->dropColumnsIfExists('#__osdownloads_documents', $columns); // Remove the old pkg_osdownloads, if existent $query = 'DELETE FROM `#__extensions` WHERE `type`="package" AND `element`="pkg_osdownloads"'; $db->setQuery($query); $db->execute(); $this->checkAndCreateDefaultCategory(); if ($has_show_email) { $this->removeDeprecatedFieldShowEmail(); } return true; }