Skip to content

Commit 4078c9f

Browse files
committed
Merge pull request joomla#42 from Buddhima/gsoc_com_services
GSOC Project: com_services or front end website administration
2 parents 5db845f + e255478 commit 4078c9f

File tree

196 files changed

+5285
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5285
-212
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<access component="com_config">
3+
<section name="component">
4+
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
5+
</section>
6+
</access>

administrator/components/com_config/config.php

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,46 @@
77
* @license GNU General Public License version 2 or later; see LICENSE.txt
88
*/
99

10-
defined('_JEXEC') or die;
10+
// No direct access
11+
defined('_JEXEC') or die('Restricted access');
1112

12-
// Access checks are done internally because of different requirements for the two controllers.
13+
// Sessions
14+
jimport('joomla.session.session');
15+
16+
// Load classes
17+
JLoader::registerPrefix('Config', JPATH_COMPONENT);
1318

1419
// Tell the browser not to cache this page.
1520
JResponse::setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true);
1621

17-
$controller = JControllerLegacy::getInstance('Config');
18-
$controller->execute(JFactory::getApplication()->input->get('task'));
19-
$controller->redirect();
22+
// Application
23+
$app = JFactory::getApplication();
24+
25+
if ($controllerTask = $app->input->get('controller'))
26+
// Checking for new MVC controller
27+
$array = explode(".", $controllerTask);
28+
else
29+
{
30+
// Checking for old MVC task
31+
$task = $app->input->get('task');
32+
$array = explode(".", $task);
33+
}
34+
35+
if (empty($array[1]))
36+
$activity = 'display';
37+
elseif ($array[1] == 'apply')
38+
$activity = 'save';
39+
else $activity = $array[1];
40+
41+
// Create the controller
42+
// if ($array[0]=='application')
43+
// For Application
44+
$classname = 'ConfigControllerApplication' . ucfirst($activity);// only for applications
45+
if ($array[0] == 'component')
46+
// For Component
47+
$classname = 'ConfigControllerComponent' . ucfirst($activity); // if task=component.* etc
48+
49+
$controller = new $classname;
50+
51+
// Perform the Request task
52+
$controller->execute();
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<extension type="component" version="3.1" method="upgrade">
2+
<extension type="component" version="3.0" method="upgrade">
33
<name>com_config</name>
44
<author>Joomla! Project</author>
5-
<creationDate>April 2006</creationDate>
5+
<creationDate>June 2013</creationDate>
66
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved. </copyright>
77
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
88
<authorEmail>[email protected]</authorEmail>
99
<authorUrl>www.joomla.org</authorUrl>
10-
<version>3.0.0</version>
10+
<version>3.1.0</version>
1111
<description>COM_CONFIG_XML_DESCRIPTION</description>
1212
<administration>
1313
<files folder="admin">
1414
<filename>config.php</filename>
15-
<filename>controller.php</filename>
15+
<filename>access.xml</filename>
1616
<filename>index.html</filename>
17-
<folder>controllers</folder>
18-
<folder>models</folder>
19-
<folder>views</folder>
17+
<folder>controller</folder>
18+
<folder>model</folder>
19+
<folder>view</folder>
2020
</files>
2121
<languages folder="admin">
22-
<language tag="en-GB">language/en-GB.com_config.ini</language>
23-
<language tag="en-GB">language/en-GB.com_config.sys.ini</language>
22+
<language tag="en-GB">language/en-GB.com_config.ini
23+
</language>
2424
</languages>
2525
</administration>
2626
</extension>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
10+
defined('_JEXEC') or die('Restricted access');
11+
12+
/**
13+
* Cancel Controller for global configuration
14+
*
15+
* @package Joomla.Administrator
16+
* @subpackage com_config
17+
* @since 3.2
18+
*/
19+
class ConfigControllerApplicationCancel extends JControllerBase
20+
{
21+
22+
/**
23+
* Method to cancel global configuration.
24+
*
25+
* @return bool True on success.
26+
*
27+
* @since 3.2
28+
*/
29+
public function execute()
30+
{
31+
// Check if the user is authorized to do this.
32+
if (!JFactory::getUser()->authorise('core.admin', 'com_config'))
33+
{
34+
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'));
35+
36+
return;
37+
}
38+
39+
// Set FTP credentials, if given
40+
JClientHelper::setCredentialsFromRequest('ftp');
41+
42+
// Clean the session data.
43+
$app = JFactory::getApplication();
44+
$app->setUserState('com_config.config.global.data', null);
45+
46+
$app->redirect(JRoute::_('index.php', false));
47+
48+
return true;
49+
}
50+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
10+
defined('_JEXEC') or die('Restricted access');
11+
12+
/**
13+
* Display Controller for global configuration
14+
*
15+
* @package Joomla.Administrator
16+
* @subpackage com_config
17+
* @since 3.2
18+
*/
19+
class ConfigControllerApplicationDisplay extends JControllerBase
20+
{
21+
/**
22+
* Method to display global configuration.
23+
*
24+
* @return bool True on success, false on failure.
25+
*
26+
* @since 3.2
27+
*/
28+
public function execute()
29+
{
30+
31+
// Get the application
32+
$app = $this->getApplication();
33+
34+
// Get the document object.
35+
$document = JFactory::getDocument();
36+
37+
$viewName = $app->input->getWord('view', 'application');
38+
$viewFormat = $document->getType();
39+
$layoutName = $app->input->getWord('layout', 'default');
40+
41+
$app->input->set('view', $viewName);
42+
43+
// Register the layout paths for the view
44+
$paths = new SplPriorityQueue;
45+
$paths->insert(JPATH_COMPONENT . '/view/' . 'application' . '/tmpl', 'normal');
46+
47+
$viewClass = 'ConfigView' . ucfirst($viewName) . ucfirst($viewFormat);
48+
$modelClass = 'ConfigModel' . ucfirst($viewName);
49+
50+
if ($view = new $viewClass)
51+
{
52+
53+
if ($viewName != 'close')
54+
{
55+
$model = new $modelClass;
56+
57+
// Access check.
58+
if (!JFactory::getUser()->authorise('core.admin', $model->getState('component.option')))
59+
{
60+
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
61+
}
62+
63+
// Set model
64+
$view->setModel($model, true);
65+
}
66+
67+
$view->setLayout($layoutName);
68+
69+
// Push document object into the view.
70+
$view->document = $document;
71+
72+
// Reply for service requests
73+
if ($viewFormat == 'json')
74+
{
75+
return $view->render();
76+
}
77+
78+
// Render view.
79+
echo $view->render();
80+
}
81+
return true;
82+
}
83+
84+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
10+
defined('_JEXEC') or die('Restricted access');
11+
12+
/**
13+
* Refresh Help Controller for global configuration
14+
*
15+
* @package Joomla.Administrator
16+
* @subpackage com_config
17+
* @since 3.2
18+
*/
19+
class ConfigControllerApplicationRefreshhelp extends JControllerBase
20+
{
21+
22+
/**
23+
* Method to refresh help in global configuration.
24+
*
25+
* @return bool True on success.
26+
*
27+
* @since 3.2
28+
*/
29+
public function execute()
30+
{
31+
jimport('joomla.filesystem.file');
32+
33+
// Set FTP credentials, if given
34+
JClientHelper::setCredentialsFromRequest('ftp');
35+
36+
// Get application instance
37+
$app = JFactory::getApplication();
38+
39+
if (($data = file_get_contents('http://help.joomla.org/helpsites.xml')) === false)
40+
{
41+
$app->redirect(JRoute::_('index.php?option=com_config', false), JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 'error');
42+
}
43+
elseif (!JFile::write(JPATH_BASE . '/help/helpsites.xml', $data))
44+
{
45+
$app->redirect(JRoute::_('index.php?option=com_config', false), JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 'error');
46+
}
47+
else
48+
{
49+
$app->redirect(JRoute::_('index.php?option=com_config', false), JText::_('COM_CONFIG_HELPREFRESH_SUCCESS'));
50+
}
51+
}
52+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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('Restricted access');
10+
11+
/**
12+
* Remove Root Controller for global configuration
13+
*
14+
* @package Joomla.Administrator
15+
* @subpackage com_config
16+
* @since 3.2
17+
*/
18+
class ConfigControllerApplicationRemoveroot extends JControllerBase
19+
{
20+
21+
/**
22+
* Method to remove root in global configuration.
23+
*
24+
* @return bool True on success.
25+
*
26+
* @since 3.2
27+
*/
28+
public function execute()
29+
{
30+
// Check for request forgeries.
31+
JSession::checkToken('get') or die('Invalid Token');
32+
33+
// Check if the user is authorized to do this.
34+
if (!JFactory::getUser()->authorise('core.admin'))
35+
{
36+
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'));
37+
38+
return;
39+
}
40+
41+
// Initialise model.
42+
$model = new ConfigModelsApplication;
43+
44+
// Attempt to save the configuration and remove root.
45+
$return = $model->removeroot();
46+
47+
// Check the return value.
48+
if ($return === false)
49+
{
50+
// Save failed, go back to the screen and display a notice.
51+
JFactory::getApplication()->redirect(JRoute::_('index.php', false), JText::sprintf('JERROR_SAVE_FAILED', $model->getError()), 'error');
52+
53+
return false;
54+
}
55+
56+
// Set the success message.
57+
$message = JText::_('COM_CONFIG_SAVE_SUCCESS');
58+
59+
// Set the redirect based on the task.
60+
JFactory::getApplication()->redirect(JRoute::_('index.php', false), $message);
61+
62+
return true;
63+
}
64+
}

0 commit comments

Comments
 (0)