protected function onBeforeBrowse() { $db = JFactory::getDbo(); $config = J2Store::config(); $installation_complete = $config->get('installation_complete', 0); if (!$installation_complete) { //installation not completed JFactory::getApplication()->redirect('index.php?option=com_j2store&view=postconfig'); } //first check if the currency table has a default records at least. $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList(); if (count($rows) < 1) { //no records found. Dumb default data F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->create_currency_by_code('USD', 'USD'); } //update schema $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_j2store/sql/xml')); $dbInstaller->updateSchema(); //update cart table $cols = $db->getTableColumns('#__j2store_carts'); $cols_to_delete = array('product_id', 'vendor_id', 'variant_id', 'product_type', 'product_options', 'product_qty'); foreach ($cols_to_delete as $key) { if (array_key_exists($key, $cols)) { $db->setQuery('ALTER TABLE #__j2store_carts DROP COLUMN ' . $key); try { $db->execute(); } catch (Exception $e) { echo $e->getMessage(); } } } return parent::onBeforeBrowse(); }
/** * Make sure the #__akeeba_common table exists or create it from scratch * * @return $this */ public function checkAndFixCommonTables() { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_akeeba/sql/common')); $dbInstaller->updateSchema(); return $this; }
/** * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing * or updating your component. This is the last chance you've got to perform any additional installations, clean-up, * database updates and similar housekeeping functions. * * @param string $type install, update or discover_update * @param JInstaller $parent Parent object */ public function postflight($type, $parent) { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => ($this->schemaXmlPathRelative ? JPATH_ADMINISTRATOR . '/components/' . $this->componentName : '') . '/' . $this->schemaXmlPath)); $dbInstaller->updateSchema(); // Install subextensions $status = $this->installSubextensions($parent); // Install FOF $fofInstallationStatus = $this->installFOF($parent); // Install Akeeba Straper $strapperInstallationStatus = $this->installStrapper($parent); // Make sure menu items are installed $this->_createAdminMenus($parent); // Make sure menu items are published (surprise goal in the 92' by JInstaller wins the cup for "most screwed up // bug in the history of Joomla!") $this->_reallyPublishAdminMenuItems($parent); // Which files should I remove? if ($this->isPaid) { // This is the paid version, only remove the removeFilesAllVersions files $removeFiles = $this->removeFilesAllVersions; } else { // This is the free version, remove the removeFilesAllVersions and removeFilesFree files $removeFiles = array('files' => array(), 'folders' => array()); if (isset($this->removeFilesAllVersions['files'])) { if (isset($this->removeFilesFree['files'])) { $removeFiles['files'] = array_merge($this->removeFilesAllVersions['files'], $this->removeFilesFree['files']); } else { $removeFiles['files'] = $this->removeFilesAllVersions['files']; } } elseif (isset($this->removeFilesFree['files'])) { $removeFiles['files'] = $this->removeFilesFree['files']; } if (isset($this->removeFilesAllVersions['folders'])) { if (isset($this->removeFilesFree['folders'])) { $removeFiles['folders'] = array_merge($this->removeFilesAllVersions['folders'], $this->removeFilesFree['folders']); } else { $removeFiles['folders'] = $this->removeFilesAllVersions['folders']; } } elseif (isset($this->removeFilesFree['folders'])) { $removeFiles['folders'] = $this->removeFilesFree['folders']; } } // Remove obsolete files and folders $this->removeFilesAndFolders($removeFiles); // Copy the CLI files (if any) $this->copyCliFiles($parent); // Show the post-installation page $this->renderPostInstallation($status, $fofInstallationStatus, $strapperInstallationStatus, $parent); // Uninstall obsolete subextensions $uninstall_status = $this->uninstallObsoleteSubextensions($parent); // Clear the FOF cache $platform = F0FPlatform::getInstance(); if (method_exists($platform, 'clearCache')) { F0FPlatform::getInstance()->clearCache(); } // Make sure the Joomla! menu structure is correct $this->_rebuildMenu(); // Add post-installation messages on Joomla! 3.2 and later $this->_applyPostInstallationMessages(); }
/** * Checks the database for missing / outdated tables using the $dbChecks * data and runs the appropriate SQL scripts if necessary. * * @return AdmintoolsModelCpanels */ public function checkAndFixDatabase() { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_admintools/sql/xml')); $dbInstaller->updateSchema(); // Let's check and fix common tables, too F0FModel::getTmpInstance('Stats', 'AdmintoolsModel')->checkAndFixCommonTables(); return $this; }
/** * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing * or updating your component. This is the last chance you've got to perform any additional installations, clean-up, * database updates and similar housekeeping functions. * * @param string $type install, update or discover_update * @param JInstaller $parent Parent object */ public function postflight($type, $parent) { // Install or update database $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => ($this->schemaXmlPathRelative ? JPATH_ADMINISTRATOR . '/components/' . $this->componentName : '') . '/' . $this->schemaXmlPath)); $dbInstaller->updateSchema(); // Install subextensions $status = $this->installSubextensions($parent); // Uninstall obsolete subextensions $uninstall_status = $this->uninstallObsoleteSubextensions($parent); // Install FOF $fofInstallationStatus = $this->installFOF($parent); // Install Akeeba Straper $strapperInstallationStatus = $this->installStrapper($parent); // Which files should I remove? if ($this->isPaid) { // This is the paid version, only remove the removeFilesAllVersions files $removeFiles = $this->removeFilesAllVersions; } else { // This is the free version, remove the removeFilesAllVersions and removeFilesFree files $removeFiles = array('files' => array(), 'folders' => array()); if (isset($this->removeFilesAllVersions['files'])) { if (isset($this->removeFilesFree['files'])) { $removeFiles['files'] = array_merge($this->removeFilesAllVersions['files'], $this->removeFilesFree['files']); } else { $removeFiles['files'] = $this->removeFilesAllVersions['files']; } } elseif (isset($this->removeFilesFree['files'])) { $removeFiles['files'] = $this->removeFilesFree['files']; } if (isset($this->removeFilesAllVersions['folders'])) { if (isset($this->removeFilesFree['folders'])) { $removeFiles['folders'] = array_merge($this->removeFilesAllVersions['folders'], $this->removeFilesFree['folders']); } else { $removeFiles['folders'] = $this->removeFilesAllVersions['folders']; } } elseif (isset($this->removeFilesFree['folders'])) { $removeFiles['folders'] = $this->removeFilesFree['folders']; } } $this->removeFilesAndFolders($removeFiles); // Copy the CLI files (if any) $this->copyCliFiles($parent); // Show the post-installation page $this->renderPostInstallation($status, $fofInstallationStatus, $strapperInstallationStatus, $parent); // Clear the FOF cache $platform = F0FPlatform::getInstance(); if (method_exists($platform, 'clearCache')) { F0FPlatform::getInstance()->clearCache(); } }