예제 #1
0
 public function upgrade(&$errors, $eucaInstall, $eucaInstalldb)
 {
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     // Overall Variables
     $tables = $db->getTableList();
     $incpath = JPATH_SITE . '/administrator/components/com_acctexp/install/inc';
     // Upgrade ancient settings
     include_once $incpath . '/settings_oldupgrade.inc.php';
     // Upgrade Settings to 0.12.6 status
     include_once $incpath . '/settings_0_12_6_upgrade.inc.php';
     // Load Class (and thus aecConfig)
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $aecConfig = new aecConfig();
     if (!empty($aecConfig->cfg)) {
         $this->new = false;
     }
     $aecConfig->initParams();
     $document = JFactory::getDocument();
     $document->addCustomTag('<link rel="stylesheet" type="text/css" media="all" href="' . JURI::root() . 'media/com_acctexp/css/admin.css?rev=' . _AEC_REVISION . '" />');
     if (isset($aecConfig->cfg['aec_version'])) {
         $oldversion = $aecConfig->cfg['aec_version'];
     } else {
         $oldversion = '0.0.1';
         if (!$eucaInstalldb->ColumninTable('ordering', 'coupons')) {
             $oldversion = '1.0.0';
         } else {
             $db->setQuery("SHOW INDEXES FROM #__acctexp_subscr");
             $indexes = $db->loadObjectList();
             foreach ($indexes as $index) {
                 if (strpos($index->Key_name, 'userid') !== false) {
                     $oldversion = '0.14.6';
                 }
             }
         }
     }
     if ($this->new) {
         return;
     }
     // Check if we are upgrading from before 0.12.6RC2j - then we need to check everything before that
     if (empty($oldversion) || version_compare($oldversion, '0.12.6RC2j') === 0) {
         if (version_compare($oldversion, '0.12.6RC2j') === 0) {
             $oldupdates = array('0_12_6RC2j');
         } else {
             $oldupdates = array('0_6_0', '0_8_0', '0_10_0', '0_12_0', '0_12_6RC2j');
         }
         foreach ($oldupdates as $upd) {
             require_once $incpath . '/upgrade_' . $upd . '.inc.php';
         }
     }
     $incfiles = xJUtility::getFileArray($incpath, 'inc.php', false, true);
     $versions = array();
     foreach ($incfiles as $filename) {
         if (strpos($filename, 'upgrade_') === false) {
             continue;
         } else {
             $versions[] = str_replace(array('upgrade_', '.inc.php'), array('', ''), $filename);
         }
     }
     $versions = xJUtility::versionSort($versions);
     $old = xJUtility::normVersionName($oldversion);
     foreach ($versions as $version) {
         $new = xJUtility::normVersionName($version);
         if (version_compare($new, $old, '>=')) {
             require_once $incpath . '/upgrade_' . $version . '.inc.php';
         }
     }
     $aecConfig->cfg['aec_version'] = _AEC_VERSION;
     $aecConfig->saveSettings();
 }