forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from joomla-projects/feature/logging
[Action logs] - component+plugin+module
- Loading branch information
Showing
60 changed files
with
3,883 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<access component="com_actionlogs"> | ||
<section name="component"> | ||
<action name="core.viewlogs" title="COM_ACTIONLOGS_ACTION_VIEWLOGS" description="COM_ACTIONLOGS_ACTION_VIEWLOGS_DESC" /> | ||
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> | ||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" /> | ||
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" /> | ||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> | ||
</section> | ||
</access> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_actionlogs | ||
* | ||
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
if (!JFactory::getUser()->authorise('core.manage', 'com_actionlogs')) | ||
{ | ||
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); | ||
} | ||
|
||
$controller = JControllerLegacy::getInstance('Actionlogs'); | ||
$controller->execute(JFactory::getApplication()->input->get('task')); | ||
$controller->redirect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<extension version="3.9" type="component" method="upgrade"> | ||
<name>com_actionlogs</name> | ||
<author>Joomla! Project</author> | ||
<creationDate>May 2018</creationDate> | ||
<copyright>Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<version>__DEPLOY_VERSION__</version> | ||
<description>COM_ACTIONLOGS_XML_DESCRIPTION</description> | ||
<administration> | ||
<menu>COM_ACTIONLOGS</menu> | ||
<files folder="admin"> | ||
<file>actionlogs.php</file> | ||
<file>config.xml</file> | ||
<file>access.xml</file> | ||
<file>controller.php</file> | ||
<folder>controllers</folder> | ||
<folder>helpers</folder> | ||
<folder>models</folder> | ||
<folder>views</folder> | ||
</files> | ||
<languages folder="admin"> | ||
<language tag="en-GB">language/en-GB.com_actionlogs.ini</language> | ||
<language tag="en-GB">language/en-GB.com_actionlogs.sys.ini</language> | ||
</languages> | ||
</administration> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<config> | ||
<fieldset name="actionlogs" label="COM_ACTIONLOGS_OPTIONS" addfieldpath="/administrator/components/com_actionlogs/models/fields"> | ||
<field | ||
name="ip_logging" | ||
type="radio" | ||
label="COM_ACTIONLOGS_IP_LOGGING" | ||
description="COM_ACTIONLOGS_IP_LOGGING_DESC" | ||
class="btn-group btn-group-yesno" | ||
default="0" | ||
> | ||
<option value="1">JYES</option> | ||
<option value="0">JNO</option> | ||
</field> | ||
<field | ||
name="csv_delimiter" | ||
type="list" | ||
label="COM_ACTIONLOGS_CSV_DELIMITER" | ||
description="COM_ACTIONLOGS_CSV_DELIMITER_DESC" | ||
default="," | ||
> | ||
<option value=",">COM_ACTIONLOGS_COMMA</option> | ||
<option value=";">COM_ACTIONLOGS_SEMICOLON</option> | ||
</field> | ||
<field | ||
name="loggable_extensions" | ||
type="logtype" | ||
label="COM_ACTIONLOGS_LOG_EXTENSIONS" | ||
description="COM_ACTIONLOGS_LOG_EXTENSIONS_DESC" | ||
multiple="true" | ||
default="com_banners,com_cache,com_categories,com_config,com_contact,com_content,com_installer,com_media,com_menus,com_messages,com_modules,com_newsfeeds,com_plugins,com_redirect,com_tags,com_templates,com_users" | ||
/> | ||
</fieldset> | ||
<fieldset | ||
name="permissions" | ||
label="JCONFIG_PERMISSIONS_LABEL" | ||
description="JCONFIG_PERMISSIONS_DESC" | ||
> | ||
<field | ||
name="rules" | ||
type="rules" | ||
label="JCONFIG_PERMISSIONS_LABEL" | ||
class="inputbox" | ||
validate="rules" | ||
filter="rules" | ||
component="com_actionlogs" | ||
section="component" | ||
/> | ||
</fieldset> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_actionlogs | ||
* | ||
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Actionlogs Controller | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class ActionlogsController extends JControllerLegacy | ||
{ | ||
/** | ||
* Method to display a view. | ||
* | ||
* @param boolean $cachable If true, the view output will be cached | ||
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}. | ||
* | ||
* @return ActionlogsController This object to support chaining. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function display($cachable = false, $urlparams = array()) | ||
{ | ||
$view = $this->input->get('view', 'actionlogs'); | ||
|
||
switch ($view) | ||
{ | ||
case 'actionlogs': | ||
if (!JFactory::getUser()->authorise('core.viewlogs', 'com_actionlogs')) | ||
{ | ||
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); | ||
} | ||
break; | ||
} | ||
|
||
return parent::display(); | ||
} | ||
} |
145 changes: 145 additions & 0 deletions
145
administrator/components/com_actionlogs/controllers/actionlogs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_actionlogs | ||
* | ||
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
JLoader::register('ActionlogsHelper', JPATH_COMPONENT . '/helpers/actionlogs.php'); | ||
|
||
use Joomla\CMS\Component\ComponentHelper; | ||
use Joomla\Utilities\ArrayHelper; | ||
|
||
/** | ||
* Actionlogs list controller class. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class ActionlogsControllerActionlogs extends JControllerAdmin | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param array $config An optional associative array of configuration settings. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function __construct(array $config = array()) | ||
{ | ||
parent::__construct($config); | ||
|
||
$this->registerTask('exportSelectedLogs', 'exportLogs'); | ||
} | ||
|
||
/** | ||
* Method to get a model object, loading it if required. | ||
* | ||
* @param string $name The model name. Optional. | ||
* @param string $prefix The class prefix. Optional. | ||
* @param array $config Configuration array for model. Optional. | ||
* | ||
* @return object The model. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getModel($name = 'Actionlogs', $prefix = 'ActionlogsModel', | ||
$config = array('ignore_request' => true)) | ||
{ | ||
|
||
// Return the model | ||
return parent::getModel($name, $prefix, $config); | ||
} | ||
|
||
/** | ||
* Method to export logs | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function exportLogs() | ||
{ | ||
// Check for request forgeries. | ||
JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); | ||
|
||
// Get selected logs | ||
$pks = ArrayHelper::toInteger($this->input->post->get('cid', array(), 'array')); | ||
|
||
// Get the logs data | ||
$data = $this->getModel()->getLogsData($pks); | ||
|
||
if (count($data)) | ||
{ | ||
$rows = ActionlogsHelper::getCsvData($data); | ||
$filename = "logs_" . JFactory::getDate(); | ||
$csvDelimiter = ComponentHelper::getComponent('com_actionlogs')->getParams()->get('csv_delimiter', ','); | ||
|
||
$app = JFactory::getApplication(); | ||
$app->setHeader('Content-Type', 'application/csv', true) | ||
->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '.csv"', true) | ||
->setHeader('Cache-Control', 'must-revalidate', true) | ||
->sendHeaders(); | ||
|
||
$output = fopen("php://output", "w"); | ||
|
||
foreach ($rows as $row) | ||
{ | ||
fputcsv($output, $row, $csvDelimiter); | ||
} | ||
|
||
fclose($output); | ||
|
||
$app->close(); | ||
} | ||
else | ||
{ | ||
$this->setMessage(JText::_('COM_ACTIONLOGS_NO_LOGS_TO_EXPORT')); | ||
$this->setRedirect(JRoute::_('index.php?option=com_actionlogs&view=actionlogs', false)); | ||
} | ||
} | ||
|
||
/** | ||
* Method to delete logs | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function delete() | ||
{ | ||
if (!JFactory::getUser()->authorise('core.delete', $this->option)) | ||
{ | ||
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED')); | ||
|
||
return; | ||
} | ||
|
||
parent::delete(); | ||
} | ||
|
||
/** | ||
* Clean out the logs | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function purge() | ||
{ | ||
$model = $this->getModel(); | ||
|
||
if ($model->purge()) | ||
{ | ||
$message = JText::_('COM_ACTIONLOGS_PURGE_SUCCESS'); | ||
} | ||
else | ||
{ | ||
$message = JText::_('COM_ACTIONLOGS_PURGE_FAIL'); | ||
} | ||
|
||
$this->setRedirect(JRoute::_('index.php?option=com_actionlogs&view=actionlogs', false), $message); | ||
} | ||
} |
Oops, something went wrong.