Example #1
0
 public function reset_data()
 {
     $resetall = count($this->steps) == 1 && $this->steps[0] == 'reset_data';
     $sql = array();
     if (in_array('acepolls_polls', $this->steps) || $resetall) {
         $sql[] = 'TRUNCATE TABLE #__acepolls_polls;';
         $sql[] = 'TRUNCATE TABLE #__acepolls_options;';
         $sql[] = 'TRUNCATE TABLE #__acepolls_votes;';
     }
     if (in_array('acepolls_votes', $this->steps) || $resetall) {
         $sql[] = 'TRUNCATE TABLE #__acepolls_votes;';
     }
     $valid = true;
     foreach ($sql as $query) {
         $this->destination_db->setQuery($query);
         $result = $this->destination_db->query();
         if (!$result) {
             $valid = false;
         }
     }
     if (VMMigrateHelperDatabase::queryBatch($this->destination_db, $sql)) {
         $this->logInfo(JText::_('DATA_RESETED'));
     } else {
         $this->logError(JText::_('DATA_RESET_ERROR'));
     }
 }
Example #2
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->canDo = VMMigrateHelperVMMigrate::getActions();
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_vmmigrate');
     $jversion = new JVersion();
     $joomla_version_dest = $jversion->getShortVersion();
     if ($params->get('show_spash_config', 1)) {
         $app->enqueueMessage(JText::_('VMMIGRATE_PLEASE_CONFIGURE'), 'warning');
     } else {
         //print_a($helper->isValidConnection());
         $valid_database_connection = VMMigrateHelperDatabase::isValidConnection();
         if (!$valid_database_connection) {
             if (version_compare($joomla_version_dest, 3, 'gt')) {
             } else {
                 $app->enqueueMessage(JText::_('VMMIGRATE_SOURCE_DATABASE_CONNECTION_WARNING'), 'warning');
             }
             //$exception = new JException(JText::_('VMMIGRATE_SOURCE_DATABASE_CONNECTION_WARNING'),100,E_WARNING);
             //JError::throwError($exception);
         } else {
             //$readonlyuser = VMMigrateHelperDatabase::isReadonlyUser();
             //if (!$readonlyuser) {
             //	$exception = new JException(JText::_('VMMIGRATE_SOURCE_DATABASE_RIGHTS_WARNING'),100,E_NOTICE);
             //	JError::throwError($exception);
             //}
             $validPrefix = VMMigrateHelperDatabase::isValidPrefix();
             if (!$validPrefix) {
                 $app->enqueueMessage(JText::_('VMMIGRATE_SOURCE_DATABASE_PREFIX_WARNING'), 'warning');
                 //$exception = new JException(JText::_('VMMIGRATE_SOURCE_DATABASE_PREFIX_WARNING'),100,E_WARNING);
                 //JError::throwError($exception);
             }
         }
         $valid_source_path = VMMigrateHelperFilesystem::isValidConnection();
         if (!$valid_source_path) {
             $app->enqueueMessage(JText::_('VMMIGRATE_SOURCE_PATH_STATUS_WARNING'), 'warning');
             //$exception = new JException(JText::_('VMMIGRATE_SOURCE_PATH_STATUS_WARNING'),100,E_WARNING);
             //JError::throwError($exception);
         }
         if (JDEBUG) {
             $app->enqueueMessage(JText::_('VMMIGRATE_TURN_OFF_DEBUG'), 'warning');
             //$exception = new JException(JText::_('VMMIGRATE_TURN_OFF_DEBUG'),100,E_NOTICE);
             //JError::throwError($exception);
         }
     }
     VMMigrateHelperVMMigrate::loadCssJs();
     $this->extensions = VMMigrateHelperVMMigrate::GetMigrators();
     $this->steps = VMMigrateHelperVMMigrate::GetMigratorsSteps($this->extensions);
     if ($params->get('show_not_pro', 0)) {
         $this->demoextensions = VMMigrateHelperVMMigrate::GetMigratorsDemo();
         $this->demosteps = VMMigrateHelperVMMigrate::GetMigratorsDemoSteps();
     }
     $this->demoextensions = array();
     $this->isPro = VMMigrateHelperVMMigrate::GetMigratorsPro($this->extensions);
     $this->addToolbar();
     VMMigrateHelperVMMigrate::setJoomlaVersionLayout($this);
     $this->extensionsFeed = VMMigrateHelperVMMigrate::getExtensionsRssFeed();
     parent::display($tpl);
 }
Example #3
0
 public static function upgradeSchema()
 {
     $errorMsg = '';
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "id", "int(10) unsigned NOT NULL AUTO_INCREMENT");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "extension", "VARCHAR( 50 ) NOT NULL");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "task", "VARCHAR( 50 ) NOT NULL");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "note", "mediumtext NOT NULL");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "source_id", "VARCHAR( 10 ) NOT NULL");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "state", "int(4) unsigned NOT NULL DEFAULT '1'");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "destination_id", "int(10) unsigned NOT NULL DEFAULT '1'");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_log", "created", "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_temp", "id", "int(10) unsigned NOT NULL AUTO_INCREMENT");
     VMMigrateHelperDatabase::AddColumnIfNotExists($errorMsg, "#__vmmigrate_temp", "path", "varchar(255) NOT NULL");
     echo "<br>" . JText::_('UPGRADING_TABLE') . "....<span style='color:green'>OK</span>";
 }
Example #4
0
 public static function isInstalledSource($element, $type = 'component', $folder = '')
 {
     if (!VMMigrateHelperDatabase::isValidConnection()) {
         return false;
     }
     if (!VMMigrateHelperDatabase::isValidPrefix()) {
         return false;
     }
     $source_db = VMMigrateHelperDatabase::getSourceDb();
     $params = JComponentHelper::getParams('com_vmmigrate');
     $params->get('joomla_version', '1.5');
     $joomla_version_src = self::getJoomlaVersionSource();
     //Test if the extension is installed on the source website
     $query = $source_db->getQuery(true);
     if (version_compare($joomla_version_src, '1.6', 'ge')) {
         $query->select('extension_id')->from('#__extensions')->where("element = " . $source_db->q($element))->where("type = " . $source_db->q($type));
     } else {
         switch ($type) {
             case 'plugin':
                 $query->select('id')->from('#__plugins')->where("element = " . $source_db->q($element));
                 if ($folder) {
                     $query->where("folder = " . $source_db->q($folder));
                 }
                 break;
             case 'module':
                 $query->select('id')->from('#__modules')->where("module = " . $source_db->q($element));
                 break;
             case 'component':
             default:
                 $query->select('id')->from('#__components')->where($source_db->qn('option') . " = " . $source_db->q($element));
         }
     }
     $source_db->setQuery($query);
     $extension_id = $source_db->loadResult();
     if ($extension_id) {
         return true;
     } else {
         return false;
     }
 }
Example #5
0
 public function vm_userfield()
 {
     $pk = 'fieldid';
     $destination_table =& JTable::getInstance('userfields', 'Table');
     //Load destination Table
     $excludeids = $this->getAlreadyTransferedIds();
     // Load already transfered items
     $where = 'sys <> 1';
     $items = $this->getItems2BTransfered($this->vmTablePrefix . '_userfield', $pk, $excludeids, $where);
     //Get a list of source objects to be transfered
     if (!$items) {
         $this->logInfo(JText::_('NOTHING_TO_TRANSFER'));
         return false;
     }
     foreach ($items as $i => $item) {
         $srcid = $item[$pk];
         //Set the primary key
         $srccode = $item['name'];
         $record = new stdClass();
         //$record->virtuemart_userfield_id = 0;
         $record->virtuemart_vendor_id = $item['vendor_id'];
         $record->userfield_jplugin_id = 0;
         $record->name = $item['name'];
         $title = $item['title'];
         //Transform some labels that were updated in VM2
         if (strpos($title, 'PHPSHOP_') === 0) {
             $title = str_replace('PHPSHOP_', 'COM_VIRTUEMART_', $title);
         }
         $record->title = $title;
         $record->description = $item['description'];
         $record->type = $item['type'];
         $record->maxlength = $item['maxlength'];
         $record->size = $item['size'];
         $record->required = $item['required'];
         $record->cols = $item['cols'];
         $record->rows = $item['rows'];
         $record->value = $item['value'];
         $record->default = $item['default'];
         $record->published = $item['published'];
         $record->registration = $item['registration'];
         $record->shipment = $item['shipping'];
         $record->account = $item['account'];
         $record->readonly = $item['readonly'];
         $record->calculated = $item['calculated'];
         $record->sys = $item['sys'];
         //$record->params = $item['params'];
         $record->ordering = $item['ordering'];
         $record->shared = 0;
         $record_values = new stdClass();
         try {
             $this->destination_db->transactionStart();
             $this->insertOrReplace('#__virtuemart_userfields', $record, 'name');
             if ($record->type != 'delimiter') {
                 $type = $destination_table->formatFieldType(JArrayHelper::fromObject($record));
                 VMMigrateHelperDatabase::AddColumnIfNotExists('#__virtuemart_userinfos', $srccode, $type);
                 VMMigrateHelperDatabase::AddColumnIfNotExists('#__virtuemart_order_userinfos', $srccode, $type);
                 VMMigrateHelperDatabase::AlterColumnIfExists('#__virtuemart_userinfos', $srccode, $srccode, $type);
                 VMMigrateHelperDatabase::AlterColumnIfExists('#__virtuemart_order_userinfos', $srccode, $srccode, $type);
                 $this->insert_field_values($item['fieldid'], $record);
             }
             $this->destination_db->transactionCommit();
             $this->logRow($srcid, $item['title']);
         } catch (Exception $e) {
             $this->destination_db->transactionRollback();
             $this->logError($e->getMessage(), $srcid);
         }
     }
     if ($this->moreResults) {
         return true;
     }
 }
Example #6
0
 public function reset_data()
 {
     $resetall = count($this->steps) == 1 && $this->steps[0] == 'reset_data';
     $sql = '';
     if (in_array('joom_menu_types', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__menu_types;";
     }
     if (in_array('joom_menus', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__menu WHERE client_id = 0 and id<>1;";
     }
     if (in_array('joom_users', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__users;";
         $sql .= "TRUNCATE TABLE #__messages_cfg;";
     }
     if (in_array('joom_sections', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_content';";
         $sql .= "DELETE FROM #__assets WHERE `name` like 'com_content.category%';";
     }
     if (in_array('joom_articles', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__content;";
         $sql .= "TRUNCATE TABLE #__content_frontpage;";
         $sql .= "DELETE FROM #__assets WHERE `name` like 'com_content.article%';";
     }
     if (in_array('joom_contact_categories', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_contact';";
         $sql .= "DELETE FROM #__assets WHERE `name` like 'com_contact.category%';";
     }
     if (in_array('joom_contact', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__contact_details;";
     }
     if (in_array('joom_weblinks_categories', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_weblinks';";
         $sql .= "DELETE FROM #__assets WHERE `name` like 'com_weblinks.category%';";
     }
     if (in_array('joom_weblinks', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__weblinks;";
     }
     if (in_array('joom_newsfeeds_categories', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_newsfeeds';";
     }
     if (in_array('joom_newsfeeds', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__newsfeeds;";
     }
     if (in_array('joom_banners_categories', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__categories WHERE `extension` = 'com_banners';";
         $sql .= "DELETE FROM #__assets WHERE `name` like 'com_banners.category%';";
     }
     if (in_array('joom_banners_clients', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__banner_clients;";
     }
     if (in_array('joom_banners', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__banners;";
         $sql .= "TRUNCATE TABLE #__banner_tracks;";
     }
     if (in_array('joom_banners_tracks', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__banner_tracks;";
     }
     if (in_array('joom_search', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__core_log_searches;";
     }
     if (in_array('joom_messages', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__messages;";
     }
     if (in_array('joom_modules', $this->steps) || $resetall) {
         $sql .= "DELETE FROM #__modules WHERE client_id = 0;";
         $sql .= "DELETE FROM #__modules_menu WHERE moduleid NOT IN (SELECT id from #__modules);";
     }
     if (in_array('joom_images', $this->steps) || $resetall) {
         $sql .= "TRUNCATE TABLE #__vmmigrate_temp";
     }
     if (!$sql) {
         return;
     }
     if (VMMigrateHelperDatabase::queryBatch($this->destination_db, $sql)) {
         foreach ($this->steps as $step) {
             $this->logInfo(JText::sprintf('DATA_RESETED', JText::_($step)));
         }
         $this->resetAutoIncrements();
     } else {
         $this->logError(JText::_('DATA_RESET_ERROR') . '<br/>' . $this->destination_db->getErrorMsg());
     }
 }
Example #7
0
 public static function isValidPrefix()
 {
     try {
         $source_db = VMMigrateHelperDatabase::getSourceDb();
         $query = $source_db->getQuery(true);
         //$query->select('count(*)')->from('#__components');
         $query->select('count(*)')->from('#__users');
         $source_db->setQuery($query);
         $found_extensions = $source_db->loadResult();
         if ($found_extensions) {
             return true;
         } else {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
 }