Exemplo n.º 1
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>";
 }
Exemplo n.º 2
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;
     }
 }