Closed joomlapl-bot closed 5 months ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41064 Poniżej zmiany w oryginale:
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41064 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 768a04aa6df02..3f5cf6cb4d666 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -2346,6 +2346,10 @@ public function postflight($action, $installer) return false; } + if (!$this->migrateDeleteActionlogsConfiguration()) { + return false; + } + if (!$this->migratePrivacyconsentConfiguration()) { return false; } @@ -2355,6 +2359,75 @@ public function postflight($action, $installer) return true; } + /** + * Migrate Deleteactionlogs plugin configuration + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + private function migrateDeleteActionlogsConfiguration(): bool + { + $db = Factory::getDbo(); + + try { + // Get the ActionLogs system plugin's parameters + $row = $db->setQuery( + $db->getQuery(true) + ->select([$db->quotename('enabled'), $db->quoteName('params')]) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')) + ->where($db->quoteName('folder') . ' = ' . $db->quote('system')) + ->where($db->quoteName('element') . ' = ' . $db->quote('actionlogs')) + )->loadObject(); + } catch (Exception $e) { + echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . ''; + + return false; + } + + // If not existing or disabled there is nothing to migrate + if (!$row || !$row->enabled) { + return true; + } + + $params = new Registry($row->params); + + // If deletion of outdated logs was disabled there is nothing to migrate + if (!$params->get('logDeletePeriod', 0)) { + return true; + } + + /** @var SchedulerComponent $component */ + $component = Factory::getApplication()->bootComponent('com_scheduler'); + + /** @var TaskModel $model */ + $model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]); + $task = [ + 'title' => 'DeleteActionLogs', + 'type' => 'delete.actionlogs', + 'execution_rules' => [ + 'rule-type' => 'interval-hours', + 'interval-hours' => 24, + 'exec-time' => gmdate('H:i', $params->get('lastrun', time())), + 'exec-day' => gmdate('d'), + ], + 'state' => 1, + 'params' => [ + 'logDeletePeriod' => $params->get('logDeletePeriod', 0), + ], + ]; + + try { + $model->save($task); + } catch (Exception $e) { + echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '
'; + + return false; + } + + return true; + } /** * Migrate privacyconsents system plugin configuration * @@ -2370,7 +2443,7 @@ private function migratePrivacyconsentConfiguration(): bool // Get the PrivacyConsent system plugin's parameters $row = $db->setQuery( $db->getQuery(true) - ->select($db->quotename('enabled'), $db->quoteName('params')) + ->select([$db->quotename('enabled'), $db->quoteName('params')]) ->from($db->quoteName('#__extensions')) ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')) ->where($db->quoteName('folder') . ' = ' . $db->quote('system')) @@ -2382,14 +2455,14 @@ private function migratePrivacyconsentConfiguration(): bool return false; } - // If not existing or disbled there is nothing to migrate + // If not existing or disabled there is nothing to migrate if (!$row || !$row->enabled) { return true; } $params = new Registry($row->params); - // If consent expiration was disbled there is nothing to migrate + // If consent expiration was disabled there is nothing to migrate if (!$params->get('enabled', 0)) { return true; } diff --git a/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-09-02.sql b/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-09-02.sql index 27c020cd2fb52..4e74349940933 100644 --- a/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-09-02.sql +++ b/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-09-02.sql @@ -1,4 +1,5 @@ INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES +('plg_task_deleteactionlogs', 'plugin', 'deleteactionlogs', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_privacyconsent', 'plugin', 'privacyconsent', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_rotatelogs', 'plugin', 'rotatelogs', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-09-02.sql b/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-09-02.sql index 931f4acb15b6e..08e8541039d17 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-09-02.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-09-02.sql @@ -1,4 +1,5 @@ INSERT INTO "#__extensions" ("name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "checked_out", "checked_out_time", "ordering", "state") VALUES +('plg_task_deleteactionlogs', 'plugin', 'deleteactionlogs', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_privacyconsent', 'plugin', 'privacyconsent', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_rotatelogs', 'plugin', 'rotatelogs', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0), ('plg_task_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0); diff --git a/administrator/language/en-GB/plg_system_actionlogs.ini b/administrator/language/en-GB/plg_system_actionlogs.ini index 1b63c7b5a6acb..1f0ec95576f52 100644 --- a/administrator/language/en-GB/plg_system_actionlogs.ini +++ b/administrator/language/en-GB/plg_system_actionlogs.ini @@ -9,8 +9,6 @@ PLG_SYSTEM_ACTIONLOGS_INFO_DESC="The Action Log - Joomla plugin is disabled" PLG_SYSTEM_ACTIONLOGS_INFO_LABEL="Information" PLG_SYSTEM_ACTIONLOGS_JOOMLA_ACTIONLOG_DISABLED="Action Log - Joomla" PLG_SYSTEM_ACTIONLOGS_JOOMLA_ACTIONLOG_DISABLED_REDIRECT="The %s plugin is disabled." -PLG_SYSTEM_ACTIONLOGS_LOG_DELETE_PERIOD="Days to delete logs after" -PLG_SYSTEM_ACTIONLOGS_LOG_DELETE_PERIOD_DESC="Enter 0 if you don't want to delete the logs." PLG_SYSTEM_ACTIONLOGS_NOTIFICATIONS="Email Notifications" PLG_SYSTEM_ACTIONLOGS_OPTIONS="User Actions Log Options" PLG_SYSTEM_ACTIONLOGS_XML_DESCRIPTION="Records the actions of users on the site so they can be reviewed if required." @@ -22,3 +20,7 @@ PLG_SYSTEM_ACTIONLOGS_CONTENT_PUBLISHED="User {usernam PLG_SYSTEM_ACTIONLOGS_CONTENT_TRASHED="User {username} trashed the {type} {title}" PLG_SYSTEM_ACTIONLOGS_CONTENT_UNPUBLISHED="User {username} unpublished the {type} {title}" PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED="User {username} updated the {type} {title}" + +; All the following strings are deprecated and will be removed with 6.0 +PLG_SYSTEM_ACTIONLOGS_LOG_DELETE_PERIOD="Days to delete logs after" +PLG_SYSTEM_ACTIONLOGS_LOG_DELETE_PERIOD_DESC="Enter 0 if you don't want to delete the logs." diff --git a/administrator/language/en-GB/plg_task_deleteactionlogs.ini b/administrator/language/en-GB/plg_task_deleteactionlogs.ini new file mode 100644 index 0000000000000..30a9ede1a6fb2 --- /dev/null +++ b/administrator/language/en-GB/plg_task_deleteactionlogs.ini @@ -0,0 +1,10 @@ +; Joomla! Project +; (C) 2023 Open Source Matters, Inc.