Source for file removeroot.php

Documentation is available at removeroot.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  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;
  10.  
  11. /**
  12.  * Remove Root Controller for global configuration
  13.  *
  14.  * @package     Joomla.Administrator
  15.  * @subpackage  com_config
  16.  * @since       3.2
  17. */
  18. {
  19.     /**
  20.      * Application object - Redeclared for proper typehinting
  21.      *
  22.      * @var    JApplicationCms 
  23.      * @since  3.2
  24.      */
  25.     protected $app;
  26.  
  27.     /**
  28.      * Method to remove root in global configuration.
  29.      *
  30.      * @return  boolean  True on success.
  31.      *
  32.      * @since   3.2
  33.      */
  34.     public function execute()
  35.     {
  36.         // Check for request forgeries.
  37.         if (!JSession::checkToken('get'))
  38.         {
  39.             $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
  40.             $this->app->redirect('index.php');
  41.         }
  42.  
  43.         // Check if the user is authorized to do this.
  44.         if (!JFactory::getUser()->authorise('core.admin'))
  45.         {
  46.             $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
  47.             $this->app->redirect('index.php');
  48.         }
  49.  
  50.         // Initialise model.
  51.         $model new ConfigModelApplication;
  52.  
  53.         // Attempt to save the configuration and remove root.
  54.         try
  55.         {
  56.             $model->removeroot();
  57.         }
  58.         catch (RuntimeException $e)
  59.         {
  60.             // Save failed, go back to the screen and display a notice.
  61.             $this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED'$e->getMessage())'error');
  62.             $this->app->redirect(JRoute::_('index.php'false));
  63.         }
  64.  
  65.         // Set the redirect based on the task.
  66.         $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
  67.         $this->app->redirect(JRoute::_('index.php'false));
  68.     }
  69. }

Documentation generated on Tue, 19 Nov 2013 15:11:48 +0100 by phpDocumentor 1.4.3