- md5
- 2b487152794a1247b86be0ebd572ac69
- sha1
- 9482eaa3ebd63343fdf45ce42102dde27ffdfdd8
- sha256
- a7878e1b56ed50dc0e11c55230588bc3a6db069a6ad38d31b0a498cfcd1b8b55
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
/**
* The Users Configuration Controller
*
* @package Joomla.Administrator
* @subpackage com_users
* @version 1.0
*/
class UsersControllerConfig extends JController
{
/**
* Method to import the configuration via string or upload.
*
* @return bool True on success, false on failure.
* @since 1.0
*/
public function import()
{
// Check for request forgeries.
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the configuration values from the Request.
$string = JRequest::getVar('configString', '', 'post', 'string', JREQUEST_ALLOWHTML);
$file = JRequest::getVar('configFile', array(), 'files', 'array');
$return = null;
// Handle the possible import methods.
if (!empty($file) && ($file['error'] == 0) && ($file['size'] > 0) && (is_readable($file['tmp_name'])))
{
// Handle import via uploaded file.
$string = implode("\n", file($file['tmp_name']));
$model = $this->getModel('Config');
$return = $model->import($string);
}
elseif (strlen($string) > 1)
{
// Handle import via pasted string.
$model = $this->getModel('Config');
$return = $model->import($string);
}
// Handle the response.
if ($return === false)
{
$message = JText::sprintf('COM_USERS_CONFIG_IMPORT_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_users&view=config&layout=import&tmpl=component', $message, 'notice');
return false;
}
else
{
$this->setRedirect('index.php?option=com_users&view=config&layout=close&tmpl=component');
return true;
}
}
/**
* Method to export the configuration via download.
*
* @return void
* @since 1.0
*/
public function export()
{
// Check for request forgeries.
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the component configuration values.
$app = JFactory::getApplication();
$config = JComponentHelper::getParams('com_users');
$string = (string)$config;
// Send file headers.
header('Content-type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-length: '.strlen($string));
header('Content-disposition: attachment; filename="users.config.ini"');
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
// Print the configuration values.
echo $string;
$app->close();
}
/**
* Method to save the configuration.
*
* @return bool True on success, false on failure.
* @since 1.0
*/
public function save()
{
// Check for request forgeries.
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Save the configuration.
$model = $this->getModel('Config');
$return = $model->save();
if ($return === false) {
$message = JText::sprintf('COM_USERS_CONFIG_SAVE_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_users&view=config&tmpl=component', $message, 'notice');
return false;
}
else {
$this->setRedirect('index.php?option=com_users&view=config&layout=close&tmpl=component');
return true;
}
}
}
The same content is in 4 releases, Joomla 2.5.0 to 2.5.3. See them all, or every version of this file.