- md5
- 9119efd85db03587c5bc1cf54a8decec
- sha1
- 9653d93bcd466d297a6421adb81f24ca6f02efc0
- sha256
- 5dcf7901eca2ac88a06d8108999939d8c7dc79e2d3f15df26b3e5848350ac998
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Config\Site\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
/**
* Component Controller
*
* @since 1.5
*/
class ConfigController extends BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 1.6
* @see \JControllerLegacy
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
// Apply, Save & New, and Save As copy should be standard on forms.
$this->registerTask('apply', 'save');
}
/**
* Method to handle cancel
*
* @return boolean True on success.
*
* @since 3.2
*/
public function cancel()
{
// Redirect back to home(base) page
$this->setRedirect(\JUri::base());
}
/**
* Method to save global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function save()
{
// 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 \Joomla\Component\Config\Site\Model\ConfigModel;
$form = $model->getForm();
$data = $this->app->input->post->get('jform', array(), 'array');
// 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&view=config', false));
}
// Attempt to save the configuration.
$data = $return;
// Access backend com_config
\JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
$saveClass = new \Joomla\Component\Config\Administrator\Controller\Application;
// Get a document object
$document = \JFactory::getDocument();
// Set backend required params
$document->setType('json');
// Execute backend controller
$return = $saveClass->save();
// Reset params back after requesting from service
$document->setType('html');
// 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&view=config', false));
}
// Redirect back to com_config display
$this->app->enqueueMessage(\JText::_('COM_CONFIG_SAVE_SUCCESS'));
$this->app->redirect(\JRoute::_('index.php?option=com_config&view=config', false));
return true;
}
}
No other release has this exact content. See every version of this file.