/** * Method to save global configuration. * * @return mixed Calls $app->redirect() for all cases except JSON * * @since 3.2 */ public function execute() { // Check for request forgeries. if (!JSession::checkToken()) { $this->app->enqueueMessage(JText::_('JINVALID_TOKEN')); $this->app->redirect('index.php'); } // Check if the user is authorized to do this. if (!JFactory::getUser()->authorise('core.admin')) { $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR')); $this->app->redirect('index.php'); } // Set FTP credentials, if given. JClientHelper::setCredentialsFromRequest('ftp'); $model = new ConfigModelApplication(); $data = $this->input->post->get('jform', array(), 'array'); // Complete data array if needed $oldData = $model->getData(); $data = array_replace($oldData, $data); // Get request type $saveFormat = JFactory::getDocument()->getType(); // Handle service requests if ($saveFormat == 'json') { return $model->save($data); } // Must load after serving service-requests $form = $model->getForm(); // Validate the posted data. $return = $model->validate($form, $data); // Check for validation errors. if ($return === false) { /* * The validate method enqueued all messages for us, so we just need to redirect back. */ // Save the data in the session. $this->app->setUserState('com_config.config.global.data', $data); // Redirect back to the edit screen. $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false)); } // Attempt to save the configuration. $data = $return; $return = $model->save($data); // Check the return value. if ($return === false) { /* * The save method enqueued all messages for us, so we just need to redirect back. */ // Save the data in the session. $this->app->setUserState('com_config.config.global.data', $data); // Save failed, go back to the screen and display a notice. $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false)); } // Set the success message. $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS')); // Set the redirect based on the task. switch ($this->options[3]) { case 'apply': $this->app->redirect(JRoute::_('index.php?option=com_config', false)); break; case 'save': default: $this->app->redirect(JRoute::_('index.php', false)); break; } }
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); }
function installComplete($sample = false) { $this->checkPermissionForTools(); if (VmConfig::get('dangeroustools', true)) { if (!class_exists('com_virtuemartInstallerScript')) { require VMPATH_ADMIN . DS . 'install' . DS . 'script.virtuemart.php'; } $updater = new com_virtuemartInstallerScript(); $updater->install(true); $model = $this->getModel('updatesMigration'); $sid = $model->setStoreOwner(); $msg = 'System and sampledata succesfull installed, user id of the mainvendor is ' . $sid; if (!class_exists('com_virtuemart_allinoneInstallerScript')) { require VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart_allinone' . DS . 'script.vmallinone.php'; } $updater = new com_virtuemart_allinoneInstallerScript(false); $updater->vmInstall(true); if ($sample) { $model->installSampleData($sid); } if (!class_exists('VmConfig')) { require_once VMPATH_ADMIN . '/models/config.php'; } VirtueMartModelConfig::installVMconfigTable(); //Now lets set some joomla variables //Caching should be enabled, set to files and for 15 minutes if (JVM_VERSION > 2) { if (!class_exists('ConfigModelCms')) { require VMPATH_ROOT . DS . 'components' . DS . 'com_config' . DS . 'model' . DS . 'cms.php'; } if (!class_exists('ConfigModelForm')) { require VMPATH_ROOT . DS . 'components' . DS . 'com_config' . DS . 'model' . DS . 'application.php'; } if (!class_exists('ConfigModelApplication')) { require VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_config' . DS . 'model' . DS . 'application.php'; } } else { if (!class_exists('ConfigModelApplication')) { require VMPATH_ROOT . DS . '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', 'installComplete')); //return false; } else { // Set the success message. //vmInfo('COM_CONFIG_SAVE_SUCCESS'); } } else { $msg = $this->_getMsgDangerousTools(); } $this->setRedirect('index.php?option=com_virtuemart&view=updatesmigration&layout=insfinished', $msg); }
public function joom_settings() { //Migrate Joomla settings //Read the old config file $configSrc = $this->getJoomConfigSrc(); if ($configSrc) { JLoader::discover('ConfigModel', JPATH_SITE . '/components/com_config/model'); JLoader::discover('ConfigModel', JPATH_ADMINISTRATOR . '/components/com_config/models'); $configModel = new ConfigModelApplication(); $currentData = $configModel->getData(); $currentData['offline'] = $configSrc->offline; $currentData['offline_message'] = $configSrc->offline_message; $currentData['sitename'] = $configSrc->sitename; //$currentData['editor'] = $config15editor; $currentData['debug'] = $configSrc->debug; $currentData['debug_lang'] = $configSrc->debug_lang; $currentData['sef'] = $configSrc->sef; $currentData['sef_rewrite'] = $configSrc->sef_rewrite; $currentData['sef_suffix'] = $configSrc->sef_suffix; $currentData['feed_limit'] = $configSrc->feed_limit; $currentData['feed_email'] = $configSrc->feed_email; $currentData['gzip'] = $configSrc->gzip; switch ($configSrc->error_reporting) { case '-1': $currentData['error_reporting'] = 'default'; break; case '0': $currentData['error_reporting'] = 'none'; break; case '7': $currentData['error_reporting'] = 'simple'; break; case '6143': $currentData['error_reporting'] = 'maximum'; break; case '30719': $currentData['error_reporting'] = 'development'; break; } $currentData['xmlrpc_server'] = $configSrc->xmlrpc_server; $currentData['force_ssl'] = $configSrc->force_ssl; $currentData['offset'] = $this->getTimeZoneName($configSrc->offset); $currentData['caching'] = $configSrc->caching; $currentData['cachetime'] = $configSrc->cachetime; $currentData['cache_handler'] = $configSrc->cache_handler; $currentData['sitename'] = $configSrc->sitename; $currentData['MetaDesc'] = $configSrc->MetaDesc; $currentData['MetaKeys'] = $configSrc->MetaKeys; $currentData['MetaTitle'] = $configSrc->MetaTitle; $currentData['MetaAuthor'] = $configSrc->MetaAuthor; $currentData['mailfrom'] = $configSrc->mailfrom; $currentData['fromname'] = $configSrc->fromname; if ($configModel->save($currentData)) { $this->logInfo(JText::_('JOOM_CONFIGURATION_COPIED')); } else { $this->logError(JText::_('JOOM_CONFIGURATION_COPIED_ERROR')); } if ($configSrc->sef_rewrite && !JFile::exists(JPATH_SITE . '/.htaccess')) { if (JFile::copy(JPATH_SITE . '/htaccess.txt', JPATH_SITE . '/.htaccess')) { $this->logInfo(JText::_('JOOM_CONFIGURATION_HTACCESS')); } else { $this->logWarning(JText::_('JOOM_CONFIGURATION_HTACCESS_ERROR')); } } } }