- md5
- 14ab78bdd99feb19423f31e325ac452a
- sha1
- 8f278080ac2d0d8926b8ac0f899c261469eb9699
- sha256
- 6356d0bc49d1d71e4b0acc82c65b82b51570480792da95aefd0fa2e9846a11ca
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
<?php
/**
* @package Joomla.Administrator
* @subpackage com_actionlogs
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use \Joomla\CMS\MVC\Model\BaseModel;
BaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel');
/**
* Abstract Action Log Plugin
*
* @since 3.9.0
*/
abstract class ActionLogPlugin extends JPlugin
{
/**
* Application object.
*
* @var JApplicationCms
* @since 3.9.0
*/
protected $app;
/**
* Database object.
*
* @var JDatabaseDriver
* @since 3.9.0
*/
protected $db;
/**
* Load plugin language file automatically so that it can be used inside component
*
* @var boolean
* @since 3.9.0
*/
protected $autoloadLanguage = true;
/**
* Proxy for ActionlogsModelUserlog addLog method
*
* This method adds a record to #__action_logs contains (message_language_key, message, date, context, user)
*
* @param array $messages The contents of the messages to be logged
* @param string $messageLanguageKey The language key of the message
* @param string $context The context of the content passed to the plugin
* @param int $userId ID of user perform the action, usually ID of current logged in user
*
* @return void
*
* @since 3.9.0
*/
protected function addLog($messages, $messageLanguageKey, $context, $userId = null)
{
$user = JFactory::getUser();
foreach ($messages as $index => $message)
{
if (!array_key_exists('userid', $message))
{
$message['userid'] = $user->id;
}
if (!array_key_exists('username', $message))
{
$message['username'] = $user->username;
}
if (!array_key_exists('accountlink', $message))
{
$message['accountlink'] = 'index.php?option=com_users&task=user.edit&id=' . $user->id;
}
if (array_key_exists('type', $message))
{
$message['type'] = strtoupper($message['type']);
}
if (array_key_exists('app', $message))
{
$message['app'] = strtoupper($message['app']);
}
$messages[$index] = $message;
}
/** @var ActionlogsModelActionlog $model **/
$model = BaseModel::getInstance('Actionlog', 'ActionlogsModel');
$model->addLog($messages, strtoupper($messageLanguageKey), $context, $userId);
}
}
No other release has this exact content. See every version of this file.