Closed joomlapl-bot closed 7 months ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41377 Poniżej zmiany w oryginale:
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41377 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/language/en-GB/plg_actionlog_joomla.ini b/administrator/language/en-GB/plg_actionlog_joomla.ini index 5bfee992e3551..c539bb7c22cfe 100644 --- a/administrator/language/en-GB/plg_actionlog_joomla.ini +++ b/administrator/language/en-GB/plg_actionlog_joomla.ini @@ -52,6 +52,8 @@ PLG_ACTIONLOG_JOOMLA_USER_REMIND="User {username} re PLG_ACTIONLOG_JOOMLA_USER_RESET_COMPLETE="User {username} completed the password reset for their account" PLG_ACTIONLOG_JOOMLA_USER_RESET_REQUEST="User {username} requested a password reset for their account" PLG_ACTIONLOG_JOOMLA_USER_UPDATE="User {username} updated Joomla from {oldversion} to {version}" +PLG_ACTIONLOG_JOOMLA_USER_BLOCK="User {username} blocked user {title}" +PLG_ACTIONLOG_JOOMLA_USER_UNBLOCK="User {username} unblocked user {title}" ; Component PLG_ACTIONLOG_JOOMLA_APPLICATION_CONFIG_UPDATED="User {username} changed settings of the application configuration" PLG_ACTIONLOG_JOOMLA_COMPONENT_CONFIG_UPDATED="User {username} changed settings of the component {extension_name}" diff --git a/plugins/actionlog/joomla/src/Extension/Joomla.php b/plugins/actionlog/joomla/src/Extension/Joomla.php index b595b0dd1d34e..f2d3c769a3f78 100644 --- a/plugins/actionlog/joomla/src/Extension/Joomla.php +++ b/plugins/actionlog/joomla/src/Extension/Joomla.php @@ -619,7 +619,31 @@ public function onUserAfterSave($user, $isnew, $success, $msg): void 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $userId, ]; + // Check if block / unblock comes from Actions on list + if ($task === 'block' || $task === 'unblock') { + $messageLanguageKey = $task === 'block' ? 'PLG_ACTIONLOG_JOOMLA_USER_BLOCK' : 'PLG_ACTIONLOG_JOOMLA_USER_UNBLOCK'; + $message['action'] = $task; + } + $this->addLog([$message], $messageLanguageKey, $context, $userId); + + // Check if on save a block / unblock has changed + if ($action === 'update') { + $session = $this->getApplication()->getSession(); + $data = $session->get('block', null); + + if ($data !== null) { + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_UNBLOCK'; + $action = 'unblock'; + if ($data === 'block') { + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_BLOCK'; + $action = 'block'; + } + + $message['action'] = $action; + $this->addLog([$message], $messageLanguageKey, $context, $userId); + } + } } /** @@ -1187,4 +1211,28 @@ public function onUserAfterResetComplete($user) $this->addLog([$message], 'PLG_ACTIONLOG_JOOMLA_USER_RESET_COMPLETE', $context, $user->id); } + + /** + * Method is called before user data is stored in the database + * + * @param array $user Holds the old user data. + * @param boolean $isNew True if a new user is stored. + * @param array $data Holds the new user data. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function onUserBeforeSave($user, $isnew, $new): void + { + $session = $this->getApplication()->getSession(); + $session->set('block', null); + + if ($user['block'] !== (int) $new['block']) { + $blockunblock = $new['block'] === '1' ? 'block' : 'unblock'; + $session->set('block', $blockunblock); + } + + return; + } } ```