/**
	 * @return string
	 */
	public function getVmPluginCreateTableSQL () {

		$db = JFactory::getDBO();
		$query = 'SHOW TABLES LIKE "%' . str_replace('#__', '', $this->_tablename) . '"';
		$db->setQuery($query);
		$result = $db->loadResult();
		$app = JFactory::getApplication();
		$tablesFields = 0;
		if ($result) {
			$SQLfields = $this->getTableSQLFields();
			$loggablefields = $this->getTableSQLLoggablefields();
			$tablesFields = array_merge($SQLfields, $loggablefields);
			$update[$this->_tablename] = array($tablesFields, array(), array());
			vmdebug(get_class($this) . ':: VirtueMart2 update ' . $this->_tablename);
			if (!class_exists('GenericTableUpdater')) {
				require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php');
			}
			$updater = new GenericTableUpdater();
			$updater->updateMyVmTables($update);
			//	return FALSE;   //TODO enable this, when using vm version higher than 2.0.8F
		} else {
			return $this->createTableSQL('Userfield Realex Realvault Table', $tablesFields);
		}

	}
Example #2
0
 /**
  * Create the table for this plugin if it does not yet exist.
  * Or updates the table, if it exists. Please be aware that this function is slowing and is only called
  * storing a method or installing/udpating a plugin.
  *
  * @param string $psType shipment,payment,custom
  * @author Valérie Isaksen
  * @author Max Milbers
  */
 public function onStoreInstallPluginTable($psType, $name = FALSE)
 {
     if (!empty($name) and $name != $this->_name) {
         vmdebug('onStoreInstallPluginTable return false, given $name ' . $name . ' plg name ' . $this->_name);
         return false;
     }
     //Todo the psType should be name of the plugin.
     if ($psType == $this->_psType) {
         $SQLfields = $this->getTableSQLFields();
         if (empty($SQLfields)) {
             return false;
         }
         $loggablefields = $this->getTableSQLLoggablefields();
         $tablesFields = array_merge($SQLfields, $loggablefields);
         $db = JFactory::getDBO();
         $query = 'SHOW TABLES LIKE "%' . str_replace('#__', $db->getPrefix(), $this->_tablename) . '"';
         $db->setQuery($query);
         $result = $db->loadResult();
         vmdebug('onStoreInstallPluginTable result of table already exists? ', $result);
         if ($result) {
             $update[$this->_tablename] = array($tablesFields, array(), array());
             vmdebug(get_class($this) . ':: tsmart2 update ' . $this->_tablename);
             if (!class_exists('GenericTableUpdater')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
             }
             $updater = new GenericTableUpdater();
             $updater->updateMyVmTables($update);
         } else {
             $query = $this->createTableSQL($name, $tablesFields);
             if (empty($query)) {
                 return false;
             } else {
                 $db->setQuery($query);
                 if (!$db->execute()) {
                     vmWarn($this->_name . '::onStoreInstallPluginTable: ' . tsmText::_('com_tsmart_SQL_ERROR') . ' ' . $db->stderr(TRUE));
                     echo $this->_name . '::onStoreInstallPluginTable: ' . tsmText::_('com_tsmart_SQL_ERROR') . ' ' . $db->stderr(TRUE);
                 } else {
                     return true;
                 }
             }
         }
     }
     vmdebug('onStoreInstallPluginTable return false, given $psType ' . $psType . ' plg name ' . $this->_psType);
     return false;
 }
Example #3
0
 public function updatePluginTable($name, $type, $element, $group, $dst)
 {
     $app = JFactory::getApplication();
     //Update Tables
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     if (class_exists('VmConfig')) {
         $pluginfilename = $dst . DS . $element . '.php';
         if (file_exists($pluginfilename)) {
             require_once $pluginfilename;
             //require_once cause is more failproof and is just for install
         } else {
             $app = JFactory::getApplication();
             $app->enqueueMessage(get_class($this) . ':: VirtueMart3 could not find file ' . $pluginfilename);
             return false;
         }
         //plgVmpaymentPaypal
         $pluginClassname = 'plg' . ucfirst($group) . ucfirst($element);
         //Let's get the global dispatcher
         $dispatcher = JDispatcher::getInstance();
         $config = array('type' => $group, 'name' => $element, 'params' => '');
         $plugin = new $pluginClassname($dispatcher, $config);
         $_psType = substr($group, 2);
         $tablename = '#__virtuemart_' . $_psType . '_plg_' . $element;
         $db = JFactory::getDBO();
         $prefix = $db->getPrefix();
         $query = 'SHOW TABLES LIKE "' . str_replace('#__', $prefix, $tablename) . '"';
         $db->setQuery($query);
         $result = $db->loadResult();
         if ($result) {
             $SQLfields = $plugin->getTableSQLFields();
             $loggablefields = $plugin->getTableSQLLoggablefields();
             $tablesFields = array_merge($SQLfields, $loggablefields);
             $update[$tablename] = array($tablesFields, array(), array());
             vmdebug('install plugin', $update);
             $app->enqueueMessage(get_class($this) . ':: VirtueMart2 update ' . $tablename);
             if (!class_exists('GenericTableUpdater')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
             }
             $updater = new GenericTableUpdater();
             $updater->updateMyVmTables($update);
         }
     } else {
         $app = JFactory::getApplication();
         $app->enqueueMessage(get_class($this) . ':: VirtueMart2 must be installed, or the tables cant be updated ');
     }
 }
 /**
  * This is executing the update table commands to adjust joomla tables to the latest layout
  * @author Max Milbers
  */
 function updateDatabaseJoomla()
 {
     vRequest::vmCheckToken();
     if (JVM_VERSION < 3) {
         $p = VMPATH_ADMIN . DS . 'install' . DS . 'joomla2.sql';
     } else {
         $p = '';
     }
     //$p = VMPATH_ROOT.DS.'installation'.DS.'sql'.DS.'mysql'.DS.'joomla.sql';
     $msg = 'You are using joomla 3, or File ' . $p . ' not found';
     if (file_exists($p)) {
         if (!class_exists('GenericTableUpdater')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
         }
         $updater = new GenericTableUpdater();
         $updater->updateMyVmTables($p, '_');
         $msg = 'Joomla Database updated';
     }
     $this->setRedirect($this->redirectPath, $msg);
 }
 /**
  * Update script
  * Triggers after database processing
  *
  * @param object JInstallerComponent parent
  * @return boolean True on success
  */
 public function update($loadVm = true)
 {
     if ($loadVm) {
         $this->loadVm();
     }
     if (!$this->checkIfUpdate()) {
         return $this->install($loadVm);
     }
     if (!class_exists('JFile')) {
         require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
     }
     if (!class_exists('JFolder')) {
         require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     //Delete Cache
     $cache = JFactory::getCache();
     $cache->clean();
     $this->_db = JFactory::getDBO();
     if (empty($this->path)) {
         $this->path = VMPATH_ADMIN;
     }
     $params = JComponentHelper::getParams('com_languages');
     $lang = $params->get('site', 'en-GB');
     //use default joomla
     $lang = strtolower(strtr($lang, '-', '_'));
     if (!class_exists('VmModel')) {
         require $this->path . DS . 'helpers' . DS . 'vmmodel.php';
     }
     if (!class_exists('VirtueMartModelUpdatesMigration')) {
         require $this->path . DS . 'models' . DS . 'updatesmigration.php';
     }
     $model = VmModel::getModel('updatesmigration');
     //$model = new VirtueMartModelUpdatesMigration(); //JModel::getInstance('updatesmigration', 'VirtueMartModel');
     $model->execSQLFile($this->path . DS . 'install' . DS . 'install.sql');
     $this->joomlaSessionDBToMediumText();
     $this->updateToVm3 = $this->isUpdateToVm3();
     $this->alterTable('#__virtuemart_product_prices', array('product_price_vdate' => '`product_price_publish_up` DATETIME NULL DEFAULT NULL AFTER `product_currency`', 'product_price_edate' => '`product_price_publish_down` DATETIME NULL DEFAULT NULL AFTER `product_price_publish_up`'));
     $this->alterTable('#__virtuemart_customs', array('custom_field_desc' => '`custom_desc` char(255) COMMENT \'description or unit\''));
     $this->alterTable('#__virtuemart_product_customfields', array('custom_value' => ' `customfield_value` varchar(2500) COMMENT \'field value\'', 'custom_price' => ' `customfield_price` DECIMAL(15,6) COMMENT \'price\'', 'custom_param' => ' `customfield_params` varchar(17000) NULL DEFAULT NULL', 'idx_custom_value' => ' INDEX `idx_published` (`published`)'));
     $this->alterTable('#__virtuemart_userfields', array('params' => '`userfield_params` varchar(17500) NOT NULL DEFAULT "" COMMENT \'userfield params\''));
     $this->alterTable('#__virtuemart_orders', array('customer_note' => '`oc_note` varchar(20000) NOT NULL DEFAULT "" COMMENT \'old customer notes\''));
     if (!class_exists('GenericTableUpdater')) {
         require $this->path . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->updateMyVmTables();
     $result = $updater->createLanguageTables();
     $this->checkAddDefaultShoppergroups();
     //$this->adjustDefaultOrderStates();
     $this->fixOrdersVendorId();
     $this->updateAdminMenuEntries();
     if ($this->updateToVm3) {
         $this->migrateCustoms();
         $this->checkUserfields();
     }
     //copy sampel media
     $src = $this->path . DS . 'assets' . DS . 'images' . DS . 'vmsampleimages';
     if (JFolder::exists($src)) {
         $dst = VMPATH_ROOT . DS . 'images' . DS . 'stories' . DS . 'virtuemart';
         $this->recurse_copy($src, $dst);
     }
     $model->updateJoomlaUpdateServer('component', 'com_virtuemart', $this->path . DS . 'virtuemart.xml');
     //fix joomla BE menu
     //$model = VmModel::getModel('updatesmigration');
     //$model->checkFixJoomlaBEMenuEntries();
     $this->deleteSwfUploader();
     if ($loadVm) {
         $this->displayFinished(true);
     }
     return true;
 }
Example #6
0
 /**
  * Update script
  * Triggers after database processing
  *
  * @param object JInstallerComponent parent
  * @return boolean True on success
  */
 public function update($loadVm = true)
 {
     if ($loadVm) {
         $this->loadVm();
     }
     if (!$this->checkIfUpdate()) {
         return $this->install($loadVm);
     }
     if (!class_exists('JFile')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
     }
     if (!class_exists('JFolder')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     //Delete Cache
     $cache = JFactory::getCache();
     $cache->clean();
     $this->_db = JFactory::getDBO();
     if (empty($this->path)) {
         $this->path = JPATH_VM_ADMINISTRATOR;
     }
     $params = JComponentHelper::getParams('com_languages');
     $lang = $params->get('site', 'en-GB');
     //use default joomla
     $lang = strtolower(strtr($lang, '-', '_'));
     if (!class_exists('VmModel')) {
         require $this->path . DS . 'helpers' . DS . 'vmmodel.php';
     }
     if (!class_exists('VirtueMartModelUpdatesMigration')) {
         require $this->path . DS . 'models' . DS . 'updatesmigration.php';
     }
     $model = new VirtueMartModelUpdatesMigration();
     //JModel::getInstance('updatesmigration', 'VirtueMartModel');
     $model->execSQLFile($this->path . DS . 'install' . DS . 'install.sql');
     $this->joomlaSessionDBToMediumText();
     $this->alterTable('#__virtuemart_product_prices', array('product_price_vdate' => '`product_price_publish_up` DATETIME NULL DEFAULT NULL AFTER `product_currency`', 'product_price_edate' => '`product_price_publish_down` DATETIME NULL DEFAULT NULL AFTER `product_price_publish_up`'));
     $this->alterTable('#__virtuemart_customs', array('custom_field_desc' => '`custom_desc` char(255) COMMENT \'description or unit\''));
     $this->alterTable('#__virtuemart_product_customfields', array('custom_value' => ' `customfield_value` text NULL DEFAULT NULL', 'custom_price' => ' `customfield_price` DECIMAL(15,6) NULL DEFAULT NULL COMMENT \'price\'', 'custom_param' => ' `customfield_params` text NULL DEFAULT NULL', 'idx_custom_value' => ' INDEX `idx_published` (`published`)'));
     $this->alterTable('#__virtuemart_medias', array('file_url' => '`file_url` varchar(900) NOT NULL DEFAULT ""', 'file_params' => '`file_params` varchar(17500)', 'file_url_thumb' => '`file_url_thumb` varchar(900) NOT NULL DEFAULT ""'));
     $this->alterTable('#__virtuemart_userfields', array('params' => '`userfield_params` varchar(17500) NOT NULL DEFAULT "" COMMENT \'userfield params\''));
     //todo Maik, please take a look, this should not be anylonger necessary
     /*$this->alterTable('#__virtuemart_order_items',
     			array(
     				'product_discountedPriceWithoutTax' => '',
     			),
     			'DROP'
     		);*/
     if (!class_exists('GenericTableUpdater')) {
         require $this->path . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->updateMyVmTables();
     $result = $updater->createLanguageTables();
     $this->checkAddDefaultShoppergroups();
     $this->adjustDefaultOrderStates();
     $this->fixOrdersVendorId();
     $this->updateAdminMenuEntries();
     $this->migrateCustoms();
     //copy sampel media
     $src = $this->path . DS . 'assets' . DS . 'images' . DS . 'vmsampleimages';
     if (JFolder::exists($src)) {
         $dst = JPATH_ROOT . DS . 'images' . DS . 'stories' . DS . 'virtuemart';
         $this->recurse_copy($src, $dst);
     }
     //fix joomla BE menu
     //$model = VmModel::getModel('updatesmigration');
     //$model->checkFixJoomlaBEMenuEntries();
     if ($loadVm) {
         $this->displayFinished(true);
     }
     return true;
 }
 /**
  * Update script
  * Triggers after database processing
  *
  * @param object JInstallerComponent parent
  * @return boolean True on success
  */
 public function update($loadVm = true)
 {
     if ($loadVm) {
         $this->loadVm();
     }
     if (!$this->checkIfUpdate()) {
         return $this->install($loadVm);
     }
     $this->_db = JFactory::getDBO();
     if (empty($this->path)) {
         $this->path = JPATH_VM_ADMINISTRATOR;
     }
     $params = JComponentHelper::getParams('com_languages');
     $lang = $params->get('site', 'en-GB');
     //use default joomla
     $lang = strtolower(strtr($lang, '-', '_'));
     if (!class_exists('VirtueMartModelUpdatesMigration')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'updatesmigration.php';
     }
     $model = new VirtueMartModelUpdatesMigration();
     //JModelLegacy ::getInstance('updatesmigration', 'VirtueMartModel');
     $model->execSQLFile($this->path . DS . 'install' . DS . 'install.sql', $lang);
     // 			$this->displayFinished(true);
     //return false;
     $this->joomlaSessionDBToMediumText();
     // 			$this->portOverwritePrices();
     /*			$table = '#__virtuemart_customs';
     			$fieldname = 'field_type';
     			$fieldvalue = 'G';
     			$this->addToRequired($table,$fieldname,$fieldvalue,"INSERT INTO `#__virtuemart_customs`
     					(`custom_parent_id`, `admin_only`, `custom_title`, `custom_tip`, `custom_value`, `custom_field_desc`,
     					 `field_type`, `is_list`, `is_hidden`, `is_cart_attribute`, `published`) VALUES
     						(0, 0, 'COM_VIRTUEMART_STOCKABLE_PRODUCT', 'COM_VIRTUEMART_STOCKABLE_PRODUCT_TIP', NULL,
     					'COM_VIRTUEMART_STOCKABLE_PRODUCT_DESC', 'G', 0, 0, 0, 1 );");
     */
     $this->alterTable('#__virtuemart_product_prices', array('product_price_vdate' => ' `product_price_publish_up` DATETIME NULL DEFAULT NULL AFTER `product_currency`', 'product_price_edate' => ' `product_price_publish_down` DATETIME NULL DEFAULT NULL AFTER `product_price_publish_up`'));
     $this->alterTable('#__virtuemart_medias', array('file_url' => '`file_url` varchar(900) NOT NULL DEFAULT ""', 'file_params' => '`file_params` varchar(17500)', 'file_url_thumb' => '`file_url_thumb` varchar(900) NOT NULL DEFAULT ""'));
     $this->alterTable('#__virtuemart_order_items', array('product_discountedPriceWithoutTax' => ''), 'DROP');
     $this->deleteReCreatePrimaryKey('#__virtuemart_userinfos', 'virtuemart_userinfo_id');
     //$this->renameVdateToPublishDown();
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->updateMyVmTables();
     $result = $updater->createLanguageTables();
     $this->checkAddDefaultShoppergroups();
     $this->adjustDefaultOrderStates();
     $this->fixOrdersVendorId();
     $this->fixConfigValues();
     if ($loadVm) {
         $this->displayFinished(true);
     }
     return true;
 }
Example #8
0
 /**
  * Create the table for this plugin if it does not yet exist.
  * Or updates the table, if it exists. Please be aware that this function is slowing and is only called
  * storing a method or installing/udpating a plugin.
  *
  * @param string $psType shipment,payment,custom
  * @author Valérie Isaksen
  * @author Max Milbers
  */
 protected function onStoreInstallPluginTableVM3($psType, $name = FALSE)
 {
     vmdebug('Executing onStoreInstallPluginTable ');
     if (!empty($name) and $name != $this->_name) {
         return false;
     }
     //Todo the psType should be name of the plugin.
     if ($psType == $this->_psType) {
         $SQLfields = $this->getTableSQLFields();
         if (empty($SQLfields)) {
             return false;
         }
         $loggablefields = $this->getTableSQLLoggablefields();
         $tablesFields = array_merge($SQLfields, $loggablefields);
         $db = JFactory::getDBO();
         $query = 'SHOW TABLES LIKE "%' . str_replace('#__', '', $this->_tablename) . '"';
         $db->setQuery($query);
         $result = $db->loadResult();
         if ($result) {
             $update[$this->_tablename] = array($tablesFields, array(), array());
             $app = JFactory::getApplication();
             $app->enqueueMessage(get_class($this) . ':: VirtueMart2 update ' . $this->_tablename);
             if (!class_exists('GenericTableUpdater')) {
                 require JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'tableupdater.php';
             }
             $updater = new GenericTableUpdater();
             $updater->updateMyVmTables($update);
         } else {
             $query = $this->createTableSQL($name, $tablesFields);
             if (empty($query)) {
                 return false;
             } else {
                 $db->setQuery($query);
                 if (!$db->execute()) {
                     vmWarn($this->_name . '::onStoreInstallPluginTable: ' . vmText::_('COM_VIRTUEMART_SQL_ERROR') . ' ' . $db->stderr(TRUE));
                     echo $this->_name . '::onStoreInstallPluginTable: ' . vmText::_('COM_VIRTUEMART_SQL_ERROR') . ' ' . $db->stderr(TRUE);
                 } else {
                     return true;
                 }
             }
         }
         /*$query = $this->getVmPluginCreateTableSQL ();
         
         			if(!class_exists('GenericTableUpdater')) require(JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'tableupdater.php');
         			$updater = new GenericTableUpdater();
         
         			if(empty($query)){
         				return false;
         			} else {
         			//if ($query !== 0) {
         				// 				vmdebug('onStoreInstallPluginTable '.$query);
         				$db = JFactory::getDBO ();
         				$db->setQuery ($query);
         				if (!$db->execute ()) {
         					vmWarn($this->_name . '::onStoreInstallPluginTable: ' . vmText::_ ('COM_VIRTUEMART_SQL_ERROR') . ' ' . $db->stderr (TRUE));
         					echo $this->_name . '::onStoreInstallPluginTable: ' . vmText::_ ('COM_VIRTUEMART_SQL_ERROR') . ' ' . $db->stderr (TRUE);
         				} else {
         					return true;
         				}
         			}*/
     }
     return false;
 }
 /**
  * Update script
  * Triggers after database processing
  *
  * @param object JInstallerComponent parent
  * @return boolean True on success
  */
 public function update($loadVm = true)
 {
     if ($loadVm) {
         $this->loadVm();
     }
     if (!$this->checkIfUpdate()) {
         return $this->install($loadVm);
     }
     $this->_db = JFactory::getDBO();
     if (empty($this->path)) {
         $this->path = JPATH_VM_ADMINISTRATOR;
     }
     $params = JComponentHelper::getParams('com_languages');
     $lang = $params->get('site', 'en-GB');
     //use default joomla
     $lang = strtolower(strtr($lang, '-', '_'));
     if (!class_exists('VirtueMartModelUpdatesMigration')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'updatesmigration.php';
     }
     $model = new VirtueMartModelUpdatesMigration();
     //JModel::getInstance('updatesmigration', 'VirtueMartModel');
     $model->execSQLFile($this->path . DS . 'install' . DS . 'install.sql', $lang);
     $this->joomlaSessionDBToMediumText();
     $this->alterTable('#__virtuemart_product_prices', array('product_price_vdate' => ' `product_price_publish_up` DATETIME NULL DEFAULT NULL AFTER `product_currency`', 'product_price_edate' => ' `product_price_publish_down` DATETIME NULL DEFAULT NULL AFTER `product_price_publish_up`'));
     $this->alterTable('#__virtuemart_medias', array('file_url' => '`file_url` varchar(900) NOT NULL DEFAULT ""', 'file_params' => '`file_params` varchar(17500)', 'file_url_thumb' => '`file_url_thumb` varchar(900) NOT NULL DEFAULT ""'));
     $this->deleteReCreatePrimaryKey('#__virtuemart_userinfos', 'virtuemart_userinfo_id');
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->updateMyVmTables();
     $result = $updater->createLanguageTables();
     $this->checkAddDefaultShoppergroups();
     $this->adjustDefaultOrderStates();
     $this->fixOrdersVendorId();
     $this->fixConfigValues();
     if ($loadVm) {
         $this->displayFinished(true);
     }
     return true;
 }
 /**
  * Update script
  * Triggers after database processing
  *
  * @param object JInstallerComponent parent
  * @return boolean True on success
  */
 public function update($loadVm = true)
 {
     if ($loadVm) {
         $this->loadVm();
     }
     if (!$this->checkIfUpdate()) {
         return $this->install($loadVm);
     }
     $this->_db = JFactory::getDBO();
     if (empty($this->path)) {
         $this->path = JPATH_VM_ADMINISTRATOR;
     }
     $params = JComponentHelper::getParams('com_languages');
     $lang = $params->get('site', 'en-GB');
     //use default joomla
     $lang = strtolower(strtr($lang, '-', '_'));
     if (!class_exists('VirtueMartModelUpdatesMigration')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'updatesmigration.php';
     }
     $model = new VirtueMartModelUpdatesMigration();
     //JModel::getInstance('updatesmigration', 'VirtueMartModel');
     $model->execSQLFile($this->path . DS . 'install' . DS . 'install.sql', $lang);
     // 			$this->displayFinished(true);
     //return false;
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $fields = array('data' => '`data` text NULL AFTER `time`');
         $this->alterTable('#__session', $fields);
     }
     // 			$this->portOverwritePrices();
     /*			$table = '#__virtuemart_customs';
     			$fieldname = 'field_type';
     			$fieldvalue = 'G';
     			$this->addToRequired($table,$fieldname,$fieldvalue,"INSERT INTO `#__virtuemart_customs`
     					(`custom_parent_id`, `admin_only`, `custom_title`, `custom_tip`, `custom_value`, `custom_field_desc`,
     					 `field_type`, `is_list`, `is_hidden`, `is_cart_attribute`, `published`) VALUES
     						(0, 0, 'COM_VIRTUEMART_STOCKABLE_PRODUCT', 'COM_VIRTUEMART_STOCKABLE_PRODUCT_TIP', NULL,
     					'COM_VIRTUEMART_STOCKABLE_PRODUCT_DESC', 'G', 0, 0, 0, 1 );");
     */
     $this->deleteReCreatePrimaryKey('#__virtuemart_userinfos', 'virtuemart_userinfo_id');
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->updateMyVmTables();
     $result = $updater->createLanguageTables();
     $this->checkAddDefaultShoppergroups();
     $this->adjustDefaultOrderStates();
     $this->fixOrdersVendorId();
     if ($loadVm) {
         $this->displayFinished(true);
     }
     return true;
 }
 public function updatePluginTable($name, $type, $element, $group, $dst)
 {
     $app = JFactory::getApplication();
     //Update Tables
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     if (class_exists('VmConfig')) {
         $pluginfilename = $dst . DS . $element . '.php';
         require $pluginfilename;
         //plgVmpaymentPaypal
         $pluginClassname = 'plg' . ucfirst($group) . ucfirst($element);
         //Let's get the global dispatcher
         $dispatcher = JDispatcher::getInstance();
         $config = array('type' => $group, 'name' => $group, 'params' => '');
         $plugin = new $pluginClassname($dispatcher, $config);
         // 				$updateString = $plugin->getVmPluginCreateTableSQL();
         //if(function_exists($plugin->getTableSQLFields)){
         $_psType = substr($group, 2);
         $tablename = '#__virtuemart_' . $_psType . '_plg_' . $element;
         $app = JFactory::getApplication();
         $dbPrefix = $app->getCfg('dbprefix', '');
         $db = JFactory::getDbo();
         $tableNamePrefix = str_replace('#__', $dbPrefix, $tablename);
         $query = 'SHOW TABLES LIKE "' . $tableNamePrefix . '"';
         $db->setQuery($query);
         $result = $db->loadResult();
         //$app -> enqueueMessage( get_class( $this ).'::  '.$query.' '.$result);
         if ($result) {
             $SQLfields = $plugin->getTableSQLFields();
             $loggablefields = $plugin->getTableSQLLoggablefields();
             $tablesFields = array_merge($SQLfields, $loggablefields);
             $update[$tablename] = array($tablesFields, array(), array());
             $app->enqueueMessage(get_class($this) . ':: VirtueMart2 update ' . $tableNamePrefix);
             if (!class_exists('GenericTableUpdater')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
             }
             $updater = new GenericTableUpdater();
             $updater->updateMyVmTables($update);
         }
         //}
         // 				} else {
         // 					$app = JFactory::getApplication();
         // 					$app -> enqueueMessage( get_class( $plugin ).':: VirtueMart2 function getTableSQLFields not found');
         // 				}
     } else {
         $app = JFactory::getApplication();
         $app->enqueueMessage(get_class($this) . ':: VirtueMart2 must be installed, or the tables cant be updated ');
     }
 }