[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_actionlogs 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Actionlogs\Administrator\Plugin; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Plugin\CMSPlugin; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Abstract Action Log Plugin 22 * 23 * @since 3.9.0 24 */ 25 abstract class ActionLogPlugin extends CMSPlugin 26 { 27 /** 28 * Application object. 29 * 30 * @var \Joomla\CMS\Application\CMSApplication 31 * @since 3.9.0 32 */ 33 protected $app; 34 35 /** 36 * Database object. 37 * 38 * @var \Joomla\Database\DatabaseDriver 39 * @since 3.9.0 40 */ 41 protected $db; 42 43 /** 44 * Load plugin language file automatically so that it can be used inside component 45 * 46 * @var boolean 47 * @since 3.9.0 48 */ 49 protected $autoloadLanguage = true; 50 51 /** 52 * Proxy for ActionlogsModelUserlog addLog method 53 * 54 * This method adds a record to #__action_logs contains (message_language_key, message, date, context, user) 55 * 56 * @param array $messages The contents of the messages to be logged 57 * @param string $messageLanguageKey The language key of the message 58 * @param string $context The context of the content passed to the plugin 59 * @param int $userId ID of user perform the action, usually ID of current logged in user 60 * 61 * @return void 62 * 63 * @since 3.9.0 64 */ 65 protected function addLog($messages, $messageLanguageKey, $context, $userId = null) 66 { 67 $user = Factory::getUser(); 68 69 foreach ($messages as $index => $message) { 70 if (!\array_key_exists('userid', $message)) { 71 $message['userid'] = $user->id; 72 } 73 74 if (!\array_key_exists('username', $message)) { 75 $message['username'] = $user->username; 76 } 77 78 if (!\array_key_exists('accountlink', $message)) { 79 $message['accountlink'] = 'index.php?option=com_users&task=user.edit&id=' . $user->id; 80 } 81 82 if (\array_key_exists('type', $message)) { 83 $message['type'] = strtoupper($message['type']); 84 } 85 86 if (\array_key_exists('app', $message)) { 87 $message['app'] = strtoupper($message['app']); 88 } 89 90 $messages[$index] = $message; 91 } 92 93 /** @var \Joomla\Component\Actionlogs\Administrator\Model\ActionlogModel $model */ 94 $model = $this->app->bootComponent('com_actionlogs') 95 ->getMVCFactory()->createModel('Actionlog', 'Administrator', ['ignore_request' => true]); 96 97 $model->addLog($messages, strtoupper($messageLanguageKey), $context, $userId); 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |