Source for file application.php
Documentation is available at application.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Model for the global configuration
* @package Joomla.Administrator
* Method to get a form object.
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
public function getForm($data =
array(), $loadData =
true)
$form =
$this->loadForm('com_config.application', 'application', array('control' =>
'jform', 'load_data' =>
$loadData));
* Method to get the configuration data.
* This method will load the global configuration data straight from
* JConfig. If configuration data has been saved in the session, that
* data will be merged into the original data, overwriting it.
* @return array An array containg all global config data.
// Prime the asset_id for the rules.
// Get the text filter data
// If no filter data found, get from com_content (update of 1.6/1.7 site)
if (empty($data['filters']))
// Check for data in the session.
// Merge in the session data.
* Method to save the configuration data.
* @param array $data An array containing all global config data.
* @return boolean True on success, false on failure.
public function save($data)
if (isset
($data['rules']))
// Check that we aren't removing our Super User permission
// Need to get groups from database, since they might have changed
$myRules =
$rules->getData();
$hasSuperAdmin =
$myRules['core.admin']->allow($myGroups);
$app->enqueueMessage(JText::_('COM_CONFIG_ERROR_REMOVING_SUPER_ADMIN'), 'error');
if ($asset->loadByName('root.1'))
$asset->rules = (string)
$rules;
if (!$asset->check() ||
!$asset->store())
$app->enqueueMessage(JText::_('SOME_ERROR_CODE'), 'error');
$app->enqueueMessage(JText::_('COM_CONFIG_ERROR_ROOT_ASSET_NOT_FOUND'), 'error');
if (isset
($data['filters']))
$registry->loadArray(array('filters' =>
$data['filters']));
$extension_id =
$extension->find(array('name' =>
'com_config'));
if ($extension->load((int)
$extension_id))
$extension->params = (string)
$registry;
if (!$extension->check() ||
!$extension->store())
$app->enqueueMessage(JText::_('SOME_ERROR_CODE'), 'error');
$app->enqueueMessage(JText::_('COM_CONFIG_ERROR_CONFIG_EXTENSION_NOT_FOUND'), 'error');
// Get the previous configuration.
// Merge the new data in. We do this to preserve values that were not in the form.
* Perform miscellaneous options based on configuration settings/changes.
// Escape the offline message if present.
if (isset
($data['offline_message']))
// Purge the database session table if we are changing to the database handler.
if ($prev['session_handler'] !=
'database' &&
$data['session_handler'] ==
'database')
if (empty($data['cache_handler']))
// Clean the cache if disabled but previously enabled.
if (!$data['caching'] &&
$prev['caching'])
// Create the new configuration object.
$config->loadArray($data);
// Overwrite the old FTP credentials with the new ones.
$temp->set('ftp_enable', $data['ftp_enable']);
$temp->set('ftp_host', $data['ftp_host']);
$temp->set('ftp_port', $data['ftp_port']);
$temp->set('ftp_user', $data['ftp_user']);
$temp->set('ftp_pass', $data['ftp_pass']);
$temp->set('ftp_root', $data['ftp_root']);
// Clear cache of com_config component.
// Write the configuration file.
return $this->writeConfigFile($config);
* Method to unset the root_user value from configuration data.
* This method will load the global configuration data straight from
* JConfig and remove the root_user value for security, then save the configuration.
* @return boolean True on success, false on failure.
// Get the previous configuration.
// Create the new configuration object, and unset the root_user property
unset
($prev['root_user']);
$config->loadArray($prev);
// Write the configuration file.
return $this->writeConfigFile($config);
* Method to write the configuration to a file.
* @param JRegistry $config A JRegistry object containing all global config data.
* @return boolean True on success, false on failure.
* @throws RuntimeException
private function writeConfigFile(JRegistry $config)
// Set the configuration file path.
// Get the new FTP credentials.
// Attempt to make the file writeable if using FTP.
$app->enqueueMessage(JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'notice');
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration =
$config->toString('PHP', array('class' =>
'JConfig', 'closingtag' =>
false));
throw
new RuntimeException(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'));
// Attempt to make the file unwriteable if using FTP.
$app->enqueueMessage(JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'notice');
Documentation generated on Tue, 19 Nov 2013 14:53:48 +0100 by phpDocumentor 1.4.3