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