/** * Save the configuration record * * @author Max Milbers * @return boolean True is successful, false otherwise */ function store(&$data, $replace = FALSE) { vRequest::vmCheckToken(); //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_')); //ATM we want to ensure that only one config is used $config = VmConfig::loadConfig(TRUE); if (!self::checkConfigTableExists()) { VmConfig::installVMconfig(false); } $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); vmInfo('Corrected safe path, replaced / by ' . DS); 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')); } } } if (!$config->get('active_languages', false)) { $confData['active_languages'] = array(VmConfig::$langTag); } $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(); /* 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; }
function installComplete($sample = false) { $data = JRequest::get('get'); JRequest::setVar($data['token'], '1', 'post'); JRequest::checkToken() or jexit('Invalid Token, in ' . JRequest::getWord('task')); $this->checkPermissionForTools(); if (VmConfig::get('dangeroustools', true)) { if (!class_exists('com_virtuemartInstallerScript')) { require JPATH_VM_ADMINISTRATOR . DS . 'install' . DS . 'script.virtuemart.php'; } $updater = new com_virtuemartInstallerScript(); $updater->install(true); $model = $this->getModel('updatesMigration'); $sid = $model->setStoreOwner(); $model->setUserToPermissionGroup($sid); $msg = ''; if (empty($errors)) { $msg = 'System succesfull restored and sampledata installed, user id of the mainvendor is ' . $sid; } else { foreach ($errors as $error) { $msg .= $error . '<br />'; } } if (!class_exists('com_virtuemart_allinoneInstallerScript')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart_allinone' . DS . 'script.vmallinone.php'; } $updater = new com_virtuemart_allinoneInstallerScript(); $updater->vmInstall(true); if ($sample) { $model->installSampleData($sid); } VmConfig::installVMconfig(); //Now lets set some joomla variables //Caching should be enabled, set to files and for 15 minutes if (!class_exists('ConfigModelApplication')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_config' . DS . 'models' . DS . 'application.php'; } $jConfModel = new ConfigModelApplication(); $jConfig = $jConfModel->getData(); $jConfig['caching'] = 0; $jConfig['lifetime'] = 60; $jConfig['list_limit'] = 25; $jConfig['MetaDesc'] = 'VirtueMart works with Joomla! - the dynamic portal engine and content management system'; $jConfig['MetaKeys'] = 'virtuemart, vm2, joomla, Joomla'; $app = JFactory::getApplication(); $return = $jConfModel->save($jConfig); // Check the return value. if ($return === false) { // Save the data in the session. $app->setUserState('com_config.config.global.data', $jConfig); vmError(vmText::sprintf('JERROR_SAVE_FAILED', $model->getError())); //return false; } else { // Set the success message. //vmInfo('COM_CONFIG_SAVE_SUCCESS'); } } else { $msg = $this->_getMsgDangerousTools(); } $this->setRedirect($this->redirectPath, $msg); }