Source for file save.php

Documentation is available at save.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_config
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9. defined('_JEXEC'or die('Restricted access');
  10.  
  11. /**
  12.  * Save Controller for global configuration
  13.  *
  14.  * @package     Joomla.Site
  15.  * @subpackage  com_config
  16.  * @since       3.2
  17. */
  18. {
  19.     /**
  20.      * Method to save global configuration.
  21.      *
  22.      * @return  boolean  True on success.
  23.      *
  24.      * @since   3.2
  25.      */
  26.     public function execute()
  27.     {
  28.         // Check for request forgeries.
  29.         if (!JSession::checkToken())
  30.         {
  31.             JFactory::getApplication()->redirect('index.php'JText::_('JINVALID_TOKEN'));
  32.         }
  33.  
  34.         // Check if the user is authorized to do this.
  35.         if (!JFactory::getUser()->authorise('core.admin'))
  36.         {
  37.             JFactory::getApplication()->redirect('index.php'JText::_('JERROR_ALERTNOAUTHOR'));
  38.  
  39.             return;
  40.         }
  41.  
  42.         // Set FTP credentials, if given.
  43.         JClientHelper::setCredentialsFromRequest('ftp');
  44.  
  45.         $app JFactory::getApplication();
  46.  
  47.         // Access back-end com_templates
  48.         JLoader::register('TemplatesControllerStyle'JPATH_ADMINISTRATOR '/components/com_templates/controllers/style.php');
  49.         JLoader::register('TemplatesModelStyle'JPATH_ADMINISTRATOR '/components/com_templates/models/style.php');
  50.         JLoader::register('TemplatesTableStyle'JPATH_ADMINISTRATOR '/components/com_templates/tables/style.php');
  51.         $controllerClass new TemplatesControllerStyle;
  52.  
  53.         // Get a document object
  54.         $document JFactory::getDocument();
  55.  
  56.         // Set back-end required params
  57.         $document->setType('json');
  58.         $this->input->set('id'$app->getTemplate('template')->id);
  59.  
  60.         // Execute back-end controller
  61.         $return $controllerClass->save();
  62.  
  63.         // Reset params back after requesting from service
  64.         $document->setType('html');
  65.  
  66.         // Check the return value.
  67.         if ($return === false)
  68.         {
  69.             // Save the data in the session.
  70.             $app->setUserState('com_config.config.global.data'$data);
  71.  
  72.             // Save failed, go back to the screen and display a notice.
  73.             $message JText::sprintf('JERROR_SAVE_FAILED');
  74.  
  75.             $app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.templates'false)$message'error');
  76.  
  77.             return false;
  78.         }
  79.  
  80.         // Set the success message.
  81.         $message JText::_('COM_CONFIG_SAVE_SUCCESS');
  82.  
  83.         // Redirect back to com_config display
  84.         $app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.templates'false)$message);
  85.  
  86.         return true;
  87.     }
  88. }

Documentation generated on Tue, 19 Nov 2013 15:12:36 +0100 by phpDocumentor 1.4.3