/**
	 * @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);
		}

	}
 /**
  * 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 #3
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 #5
0
 /**
  * Save the configuration record
  *
  * @author RickG
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     JRequest::checkToken() or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig();
     unset($config->_params['pdf_invoice']);
     // parameter remove and replaced by inv_os
     $config->setParams($data);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     /*		$path = trim($config->get('forSale_path'));
     		$length = strlen($path);
     		if(strrpos($url,DS)!=($length-1)){
     			if(is_dir()){
     				$config->set('forSale_path',$path.DS);
     				vmInfo('Corrected safe path added missing '.DS);
     			} else {
     
     			}
     		}
     */
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             $config->set('forSale_path', $safePath);
             vmInfo('Corrected safe path added missing ' . DS);
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toString();
     // 		vmdebug('config to store',$confData);
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     return true;
 }
Example #6
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;
 }
 function restoreSystemTablesCompletly()
 {
     $this->removeAllVMTables();
     $filename = VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'install' . DS . 'install.sql';
     $this->execSQLFile($filename);
     $filename = VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'install' . DS . 'install_essential_data.sql';
     $this->execSQLFile($filename);
     $filename = VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'install' . DS . 'install_required_data.sql';
     $this->execSQLFile($filename);
     if (!class_exists('GenericTableUpdater')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $updater->createLanguageTables();
     JPluginHelper::importPlugin('vmextended');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onVmSqlRestore', $this);
 }
 /**
  * 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;
 }
Example #9
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data, $replace = FALSE)
 {
     JRequest::checkToken() or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig(TRUE);
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $config->setParams($data, $replace);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmdebug('$safePath', $safePath);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path added missing ' . DS);
         }
         $config->set('forSale_path', $safePath);
     } else {
         $safePath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'vmfiles';
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $created = JFolder::create($safePath);
             $safePath = $safePath . DS;
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED', $safePath);
                 /* create htaccess file */
                 $fileData = "order deny, allow\ndeny from all\nallow from none";
                 JLoader::import('joomla.filesystem.file');
                 $fileName = $safePath . DS . '.htaccess';
                 $result = JFile::write($fileName, $fileData);
                 if (!$result) {
                     VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED', $safePath, $fileData);
                 }
                 $config->set('forSale_path', $safePath);
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     $newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     if ($browse_cat_orderby_field != $newbrowse_cat_orderby_field or $newcat_brws_orderby_dir != $cat_brws_orderby_dir) {
         $cache = JFactory::getCache('com_virtuemart_cats', 'callback');
         $cache->clean();
     }
     return true;
 }
 /**
  * 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);
     }
     $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;
 }
Example #12
0
 private function createLanguageTables()
 {
     if ($this->joomfishInstalled) {
         if (!class_exists('GenericTableUpdater')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
         }
         $updater = new GenericTableUpdater();
         $result = $updater->createLanguageTables();
     }
 }
 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 ');
     }
 }
Example #14
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     vRequest::vmCheckToken();
     if (!vmAccess::manager('config')) {
         vmWarn('Insufficient permissions to delete product');
         return false;
     }
     //We create a fresh config
     $config = tsmConfig::loadConfig(false, true);
     //We load the config file
     $_raw = self::readConfigFile(FALSE);
     $_value = join('|', $_raw);
     //We set the config file values as parameters into the config
     $config->setParams($_value);
     //We merge the array from the file with the array from the form
     //in case it the form has the same key as the file, the value is taken from the form
     $config->_params = array_merge($config->_params, $data);
     //We need this to know if we should delete the cache
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if ($length <= 1) {
             vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]);
             unset($config->_params[$urlkey]);
             continue;
         }
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     if (!class_exists('JFolder')) {
         require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmInfo('Corrected safe path, replaced / by ' . DS);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path, added missing ' . DS);
         }
         $p = VMPATH_ROOT . DS;
         if (strtolower($safePath) == strtolower($p)) {
             $safePath = '';
             vmError('Do not use as safepath your tsmart root folder');
         }
         $config->set('forSale_path', $safePath);
     } else {
         VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         /*	$safePath = VMPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_tsmart'.DS.'vmfiles';
         
         			$exists = JFolder::exists($safePath);
         			if(!$exists){
         				$created = JFolder::create($safePath);
         				$safePath = $safePath.DS;
         				if($created){
         					vmInfo('com_tsmart_SAFE_PATH_DEFAULT_CREATED',$safePath);
         					// create htaccess file
         					$fileData = "order deny, allow\ndeny from all\nallow from none";
         					JLoader::import('joomla.filesystem.file');
         					$fileName = $safePath.DS.'.htaccess';
         					$result = JFile::write($fileName, $fileData);
         					if (!$result) {
         						VmWarn('com_tsmart_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData);
         					}
         					$config->set('forSale_path',$safePath);
         				} else {
         					VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE',vmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         				}
         			}*/
     }
     if (!class_exists('shopfunctions')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('com_tsmart_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $active_langs = $config->get('active_languages');
     if (empty($active_langs)) {
         $config->set('active_languages', array(tsmConfig::$vmlangTag));
     }
     //ATM we want to ensure that only one config is used
     $confData = array();
     $confData['tsmart_config_id'] = 1;
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     $confTable->bindChecknStore($confData);
     tsmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     $cache = JFactory::getCache();
     $cache->clean('com_tsmart_cats');
     $cache->clean('mod_tsmart_product');
     $cache->clean('mod_tsmart_category');
     $cache->clean('com_tsmart_rss');
     $cache->clean('com_tsmart_cat_manus');
     $cache->clean('convertECB');
     $cache->clean('_tsmart');
     $cache->clean('com_plugins');
     $cache->clean('_system');
     $cache->clean('page');
     return true;
 }
Example #15
0
 function reOrderChilds()
 {
     $this->checkPermissionForTools();
     if (!VmConfig::get('dangeroustools', true)) {
         $msg = $this->_getMsgDangerousTools();
         $this->setRedirect($this->redirectPath, $msg);
         return false;
     }
     $this->storeMigrationOptionsInSession();
     if (!class_exists('GenericTableUpdater')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->reOrderChilds();
     $this->setRedirect($this->redirectPath, $result);
 }
 function reOrderChilds()
 {
     JRequest::checkToken() or jexit('Invalid Token, in ' . JRequest::getWord('task'));
     $this->checkPermissionForTools();
     if (!VmConfig::get('dangeroustools', true)) {
         $msg = $this->_getMsgDangerousTools();
         $this->setRedirect($this->redirectPath, $msg);
         return false;
     }
     $this->storeMigrationOptionsInSession();
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->reOrderChilds();
     //$msg = 'reOrderDone';
     $this->setRedirect($this->redirectPath, $result);
 }
Example #17
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 ');
     }
 }
Example #18
0
 /**
  * Save the configuration record
  *
  * @author Max Milbers
  * @return boolean True is successful, false otherwise
  */
 function store(&$data)
 {
     vRequest::vmCheckToken();
     //We create a fresh config
     $config = VmConfig::loadConfig(false, true);
     //We load the config file
     $_raw = self::readConfigFile(FALSE);
     $_value = join('|', $_raw);
     //We set the config file values as parameters into the config
     $config->setParams($_value);
     //We merge the array from the file with the array from the form
     //in case it the form has the same key as the file, the value is taken from the form
     $config->_params = array_merge($config->_params, $data);
     //We need this to know if we should delete the cache
     $browse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if ($length <= 1) {
             vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]);
             unset($config->_params[$urlkey]);
             continue;
         }
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     if (!class_exists('JFolder')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         if (DS != '/' and strpos($safePath, '/') !== false) {
             $safePath = str_replace('/', DS, $safePath);
             vmInfo('Corrected safe path, replaced / by ' . DS);
         }
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             vmInfo('Corrected safe path, added missing ' . DS);
         }
         $config->set('forSale_path', $safePath);
     } else {
         VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         /*	$safePath = JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'vmfiles';
         
         			$exists = JFolder::exists($safePath);
         			if(!$exists){
         				$created = JFolder::create($safePath);
         				$safePath = $safePath.DS;
         				if($created){
         					vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED',$safePath);
         					// create htaccess file
         					$fileData = "order deny, allow\ndeny from all\nallow from none";
         					JLoader::import('joomla.filesystem.file');
         					$fileName = $safePath.DS.'.htaccess';
         					$result = JFile::write($fileName, $fileData);
         					if (!$result) {
         						VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData);
         					}
         					$config->set('forSale_path',$safePath);
         				} else {
         					VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE',vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
         				}
         			}*/
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $active_langs = $config->get('active_languages');
     if (empty($active_langs)) {
         $config->set('active_languages', array(VmConfig::$vmlangTag));
     }
     //ATM we want to ensure that only one config is used
     $confData = array();
     $confData['virtuemart_config_id'] = 1;
     $confData['config'] = $config->toString();
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     /* This conditions is not enough, if the language changes we need to recall the cache.
     		$newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field');
     		$newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir');
     		if($browse_cat_orderby_field!=$newbrowse_cat_orderby_field or $newcat_brws_orderby_dir!=$cat_brws_orderby_dir){
     			$cache = JFactory::getCache('com_virtuemart_cats','callback');
     			$cache->clean();
     		}*/
     $cache = JFactory::getCache('com_virtuemart_cats', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('com_virtuemart_rss', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('convertECB', 'callback');
     $cache->clean();
     $cache = JFactory::getCache('_virtuemart');
     $cache->clean();
     $cache = JFactory::getCache('com_plugins');
     $cache->clean();
     $cache = JFactory::getCache('_system');
     $cache->clean();
     $cache = JFactory::getCache('page');
     $cache->clean();
     return true;
 }
Example #19
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;
 }
 /**
  * Save the configuration record
  *
  * @author RickG
  * @return boolean True is successful, false otherwise
  */
 function store(&$data, $replace = FALSE)
 {
     JSession::checkToken() or JSession::checkToken('get') or jexit('Invalid Token, in store config');
     //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_'));
     //ATM we want to ensure that only one config is used
     $config = VmConfig::loadConfig(TRUE);
     unset($config->_params['pdf_invoice']);
     // parameter remove and replaced by inv_os
     $config->setParams($data, $replace);
     $confData = array();
     $query = 'SELECT * FROM `#__virtuemart_configs`';
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $confData['virtuemart_config_id'] = 1;
     } else {
         $confData['virtuemart_config_id'] = 0;
     }
     $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
     foreach ($urls as $urlkey) {
         $url = trim($config->get($urlkey));
         $length = strlen($url);
         if (strrpos($url, '/') != $length - 1) {
             $config->set($urlkey, $url . '/');
             vmInfo('Corrected media url ' . $urlkey . ' added missing /');
         }
     }
     //If empty it is not sent by the form, other forms do it by using a table to store,
     //the config is like a big xparams and so we check some values for this form manually
     /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s');
     		foreach($toSetEmpty as $item){
     			if(!isset($data[$item])) {
     				$config->set($item,array());
     			}
     		}*/
     $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5');
     foreach ($checkCSVInput as $csValueKey) {
         $csValue = $config->get($csValueKey);
         if (!empty($csValue)) {
             $sequenceArray = explode(',', $csValue);
             foreach ($sequenceArray as &$csV) {
                 $csV = (int) trim($csV);
             }
             $csValue = implode(',', $sequenceArray);
             $config->set($csValueKey, $csValue);
         }
     }
     $safePath = trim($config->get('forSale_path'));
     if (!empty($safePath)) {
         $length = strlen($safePath);
         if (strrpos($safePath, DS) != $length - 1) {
             $safePath = $safePath . DS;
             $config->set('forSale_path', $safePath);
             vmInfo('Corrected safe path added missing ' . DS);
         }
     }
     if (!class_exists('shopfunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $safePath = shopFunctions::checkSafePath($safePath);
     if (!empty($safePath)) {
         $exists = JFolder::exists($safePath . 'invoices');
         if (!$exists) {
             $created = JFolder::create($safePath . 'invoices');
             if ($created) {
                 vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED');
             } else {
                 VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'));
             }
         }
     }
     $confData['config'] = $config->toJson();
     // 		vmdebug('config to store',$confData);
     $confTable = $this->getTable('configs');
     if (!$confTable->bindChecknStore($confData)) {
         vmError($confTable->getError());
     }
     // Load the newly saved values into the session.
     $config = VmConfig::loadConfig(true);
     if (!class_exists('GenericTableUpdater')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php';
     }
     $updater = new GenericTableUpdater();
     $result = $updater->createLanguageTables();
     return true;
 }