- md5
- 40cb1beca04189ddad1680744ca0b2c2
- sha1
- cb832b46d679b084307f56ccb46c8d2889785897
- sha256
- 0b8054001befce2355cd503b3d2677f66738bb75877beb19c6699b75d784539e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Save Controller for global configuration
*
* @since 3.2
*/
class ConfigControllerApplicationSave extends JControllerBase
{
/**
* Application object - Redeclared for proper typehinting
*
* @var JApplicationCms
* @since 3.2
*/
protected $app;
/**
* 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'), 'error');
$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'), 'error');
$this->app->redirect('index.php');
}
// Clear the data from the session.
$this->app->setUserState('com_config.config.global.data', null);
// 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')
{
$form = $model->getForm();
$return = $model->validate($form, $data);
if ($return === false)
{
$this->app->setHeader('Status', 422, true);
return false;
}
return $model->save($return);
}
// 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 posted 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 validated 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'), 'message');
// 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;
}
}
}
The same content is in 23 releases, Joomla 3.10.0 to 3.10.12. See them all, or every version of this file.