JoomlaPolska / jezyk-J4

Język polski dla Joomla 4
GNU General Public License v2.0
3 stars 5 forks source link

[5] add2scheduler-updatenotification #413

Closed joomlapl-bot closed 7 months ago

joomlapl-bot commented 1 year ago

PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/40788 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 6c8246fc5e99e..fd7b8c35a357a 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -11,6 +11,7 @@ */ use Joomla\CMS\Application\ApplicationHelper; +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Extension\ExtensionHelper; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\File; @@ -21,6 +22,7 @@ use Joomla\CMS\Table\Table; use Joomla\CMS\Uri\Uri; use Joomla\Database\ParameterType; +use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -234,6 +236,7 @@ protected function uninstallExtensions() ['type' => 'plugin', 'element' => 'demotasks', 'folder' => 'task', 'client_id' => 0, 'pre_function' => null], ['type' => 'plugin', 'element' => 'compat', 'folder' => 'system', 'client_id' => 0, 'pre_function' => 'migrateCompatPlugin'], ['type' => 'plugin', 'element' => 'recaptcha', 'folder' => 'captcha', 'client_id' => 0, 'pre_function' => null], + ['type' => 'plugin', 'element' => 'updatenotification', 'folder' => 'system', 'client_id' => 0, 'pre_function' => 'migrateUpdatenotificationPlugin'], ]; $db = Factory::getDbo(); @@ -313,6 +316,51 @@ private function migrateCompatPlugin($rowOld) )->execute(); } + /** + * This method is for migration for old updatenotification system plugin migration to task. + * + * @param \stdClass $data Object with the extension's record in the `#__extensions` table + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function migrateUpdatenotificationPlugin($data) + { + if (!$data->enabled) { + return; + } + + // Get the timeout for Joomla! updates, as configured in com_installer's component parameters + $component = ComponentHelper::getComponent('com_installer'); + $paramsc = $component->getParams(); + $cachetimeout = (int) $paramsc->get('cachetimeout', 6); + $params = new Registry($data->params); + $lastrun = (int) $params->get('lastrun', time()); + + /** @var SchedulerComponent $component */ + $component = Factory::getApplication()->bootComponent('com_scheduler'); + + /** @var TaskModel $model */ + $model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]); + $task = [ + 'title' => 'UpdateNotification', + 'type' => 'update.notification', + 'execution_rules' => [ + 'rule-type' => 'interval-hours', + 'interval-hours' => $cachetimeout, + 'exec-time' => gmdate('H:i', $lastrun), + 'exec-day' => gmdate('d'), + ], + 'state' => 1, + 'params' => [ + 'email' => $params->get('email', ''), + 'language_override' => $params->get('language_override', ''), + ], + ]; + $model->save($task); + } + /** * Update the manifest caches * 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 new file mode 100644 index 0000000000000..fedce0a7dfaf3 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-09-02.sql @@ -0,0 +1,6 @@ +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_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0); +INSERT INTO `#__mail_templates` (`template_id`, `extension`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES +('plg_task_updatenotification.mail', 'plg_task_updatenotification', '', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +DELETE FROM `#__mail_templates` WHERE `template_id` = 'plg_system_updatenotification.mail'; +DELETE FROM `#__postinstall_messages` WHERE `condition_file` = 'site://plugins/system/updatenotification/postinstall/updatecachetime.php'; 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 new file mode 100644 index 0000000000000..276d7d87668d6 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-09-02.sql @@ -0,0 +1,6 @@ +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_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', NULL, NULL, 0, 0); +INSERT INTO "#__mail_templates" ("template_id", "extension", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES +('plg_task_updatenotification.mail', 'plg_task_updatenotification', '', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +DELETE FROM "#__mail_templates" WHERE "template_id" = 'plg_system_updatenotification.mail'; +DELETE FROM "#__postinstall_messages" WHERE "condition_file" = 'site://plugins/system/updatenotification/postinstall/updatecachetime.php'; diff --git a/administrator/language/en-GB/plg_system_updatenotification.ini b/administrator/language/en-GB/plg_system_updatenotification.ini deleted file mode 100644 index cb889bdb5f931..0000000000000 --- a/administrator/language/en-GB/plg_system_updatenotification.ini +++ /dev/null @@ -1,27 +0,0 @@ -; Joomla! Project -; (C) 2015 Open Source Matters, Inc. -; License GNU General Public License version 2 or later; see LICENSE.txt -; Note : All ini files need to be saved as UTF-8 - -PLG_SYSTEM_UPDATENOTIFICATION="System - Joomla! Update Notification" -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by the Joomla! project. It is sent automatically by your own site,\n{SITENAME} - {URL} \n\n================================================================================\nUPDATE INFORMATION\n================================================================================\n\nYour site has discovered that there is an updated version of Joomla! available.\n\nJoomla! version currently installed: {CURVERSION}\nJoomla! version available for installation: {NEWVERSION}\n\nThis email is sent to you by your site to remind you of this fact.\nThe Joomla! project will never contact you directly about available updates of Joomla! on your site.\n\n================================================================================\nUPDATE INSTRUCTIONS\n================================================================================\n\nTo install the update on {SITENAME} please select the following link. (If the URL is not a link, copy & paste it to your browser).\n\nUpdate link: {LINK}\n\nRelease News can be found here: {RELEASENEWS}\n\n================================================================================\nWHY AM I RECEIVING THIS EMAIL?\n================================================================================\n\nThis email has been automatically sent by a plugin provided by Joomla!, the software which powers your site.\nThis plugin looks for updated versions of Joomla! and sends an email notification to its administrators.\nYou will receive several similar emails from your site until you either update the software or disable these emails.\n\nTo disable these emails, please unpublish the 'System - Joomla! Update Notification' plugin in the Plugin Manager on your site.\n\nIf you do not understand what Joomla! is and what you need to do please do not contact the Joomla! project.\nThey are NOT sending you this email and they cannot help you. Instead, please contact the person who built or manages your site.\n\nIf you are the person who built or manages your website, please note that this plugin may have been activated automatically when you installed or updated Joomla! on your site.\n\n================================================================================\nWHO SENT ME THIS EMAIL?\n================================================================================\n\nThis email is sent to you by your own site, {SITENAME}" -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_DESC="A comma separated list of the email addresses which will receive the update notification emails. The addresses in the list MUST belong to existing users of your site who have the Super User privilege. If none of the listed emails belongs to Super Users, or if it's left blank, all Super Users of this site will receive the update notification email." -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_LBL="Super User Emails" -; You can use the following merge codes: -; {NEWVERSION} New Joomla! version, e.g. 1.2.3 -; {CURVERSION} Currently installed Joomla! version, e.g. 1.2.0 -; {SITENAME} Site name, as set in Global Configuration. -; {URL} URL of the site's frontend page. -; {LINK} Update URL (link to com_joomlaupdate, will request login if the Super User isn't already logged in). -; {RELEASENEWS} URL to the release news on joomla.org -; \n Newline character. Use it to start a new line in the email. -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT="Joomla! Update available for {SITENAME} – {URL}" -PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_DESC="Select a language for the update notification emails. Set to Auto to send them in the site language at the time." -PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_LBL="Email Language" -PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_NONE="Auto" -PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_DESC="Sent to the site administrators when the "Joomla! Update Notification" system plugin detects an update." -PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_TITLE="Joomla: Update Notification" -PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME="The Joomla! Update Notification will not run in this configuration" -PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_ACTION="Set it back to the default setting (6 Hours)" -PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_BODY="

In your Installer Configuration you have set the Option Update Cache (in Hours) to 0 this means that Joomla is not caching the Update. This means an email should be sent on every page visit but this is not possible. Please increase the value (6 is default) or confirm that the Joomla! Update Notification will never send you mails.

" -PLG_SYSTEM_UPDATENOTIFICATION_XML_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update. You can customise the email at System → Mail Templates." diff --git a/administrator/language/en-GB/plg_system_updatenotification.sys.ini b/administrator/language/en-GB/plg_system_updatenotification.sys.ini deleted file mode 100644 index 705dcc576acc3..0000000000000 --- a/administrator/language/en-GB/plg_system_updatenotification.sys.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Joomla! Project -; (C) 2015 Open Source Matters, Inc. -; License GNU General Public License version 2 or later; see LICENSE.txt -; Note : All ini files need to be saved as UTF-8 - -PLG_SYSTEM_UPDATENOTIFICATION="System - Joomla! Update Notification" -PLG_SYSTEM_UPDATENOTIFICATION_XML_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update. You can customise the email at System → Mail Templates." diff --git a/administrator/language/en-GB/plg_task_updatenotification.ini b/administrator/language/en-GB/plg_task_updatenotification.ini new file mode 100644 index 0000000000000..49a91ff4e443b --- /dev/null +++ b/administrator/language/en-GB/plg_task_updatenotification.ini @@ -0,0 +1,26 @@ +; Joomla! Project +; (C) 2023 Open Source Matters, Inc. +; License GNU General Public License version 2 or later; see LICENSE.txt +; Note : All ini files need to be saved as UTF-8 + +PLG_TASK_UPDATENOTIFICATION="Task - Joomla! Update Notification" +PLG_TASK_UPDATENOTIFICATION_EMAIL_DESC="A comma separated list of the email addresses which will receive the update notification emails. The addresses in the list MUST belong to existing users of your site who have the Super User privilege. If none of the listed emails belongs to Super Users, or if it's left blank, all Super Users of this site will receive the update notification email." +PLG_TASK_UPDATENOTIFICATION_EMAIL_LBL="Super User Emails" +PLG_TASK_UPDATENOTIFICATION_SEND_TITLE="Joomla! Update Notification" +PLG_TASK_UPDATENOTIFICATION_SEND_DESC="This task periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update. You can customise the email at System → Mail Templates." +PLG_TASK_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_DESC="Select a language for the update notification emails. Set to Auto to send them in the site language at the time." +PLG_TASK_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_LBL="Email Language" +PLG_TASK_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_NONE="Auto" +PLG_TASK_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by the Joomla! project. It is sent automatically by your own site,\n{SITENAME} - {URL} \n\n================================================================================\nUPDATE INFORMATION\n================================================================================\n\nYour site has discovered that there is an updated version of Joomla! available.\n\nJoomla! version currently installed: {CURVERSION}\nJoomla! version available for installation: {NEWVERSION}\n\nThis email is sent to you by your site to remind you of this fact.\nThe Joomla! project will never contact you directly about available updates of Joomla! on your site.\n\n================================================================================\nUPDATE INSTRUCTIONS\n================================================================================\n\nTo install the update on {SITENAME} please select the following link. (If the URL is not a link, copy & paste it to your browser).\n\nUpdate link: {LINK}\n\nRelease News can be found here: {RELEASENEWS}\n\n================================================================================\nWHY AM I RECEIVING THIS EMAIL?\n================================================================================\n\nThis email has been automatically sent by a plugin provided by Joomla!, the software which powers your site.\nThis plugin looks for updated versions of Joomla! and sends an email notification to its administrators.\nYou will receive several similar emails from your site until you either update the software or disable these emails.\n\nTo disable these emails, please unpublish the 'Task - Joomla! Update Notification' plugin in the Plugin Manager on your site.\n\nIf you do not understand what Joomla! is and what you need to do please do not contact the Joomla! project.\nThey are NOT sending you this email and they cannot help you. Instead, please contact the person who built or manages your site.\n\nIf you are the person who built or manages your website, please note that this plugin may have been activated automatically when you installed or updated Joomla! on your site.\n\n================================================================================\nWHO SENT ME THIS EMAIL?\n================================================================================\n\nThis email is sent to you by your own site, {SITENAME}" +; You can use the following merge codes: +; {NEWVERSION} New Joomla! version, e.g. 1.2.3 +; {CURVERSION} Currently installed Joomla! version, e.g. 1.2.0 +; {SITENAME} Site name, as set in Global Configuration. +; {URL} URL of the site's frontend page. +; {LINK} Update URL (link to com_joomlaupdate, will request login if the Super User isn't already logged in). +; {RELEASENEWS} URL to the release news on joomla.org +; \n Newline character. Use it to start a new line in the email. +PLG_TASK_UPDATENOTIFICATION_EMAIL_SUBJECT="Joomla! Update available for {SITENAME} – {URL}" +PLG_TASK_UPDATENOTIFICATION_MAIL_MAIL_DESC="Sent to the site administrators when the "Joomla! Update Notification" task plugin detects an update." +PLG_TASK_UPDATENOTIFICATION_MAIL_MAIL_TITLE="Joomla: Update Notification" +PLG_TASK_UPDATENOTIFICATION_XML_DESCRIPTION="This task periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update. You can customise the email at System → Mail Templates." \ No newline at end of file diff --git a/administrator/language/en-GB/plg_task_updatenotification.sys.ini b/administrator/language/en-GB/plg_task_updatenotification.sys.ini new file mode 100644 index 0000000000000..f954af8812658 --- /dev/null +++ b/administrator/language/en-GB/plg_task_updatenotification.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; (C) 2023 Open Source Matters, Inc. +; License GNU General Public License version 2 or later; see LICENSE.txt +; Note : All ini files need to be saved as UTF-8 + +PLG_TASK_UPDATENOTIFICATION="Task - Joomla! Update Notification" +PLG_TASK_UPDATENOTIFICATION_XML_DESCRIPTION="This task periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update. You can customise the email at System → Mail Templates." diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index 3db88b22cebe0..4fe6d63f26514 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS `#__assets` ( -- INSERT INTO `#__assets` (`id`, `parent_id`, `lft`, `rgt`, `level`, `name`, `title`, `rules`) VALUES -(1, 0, 0, 177, 0, 'root.1', 'Root Asset', '{"core.login.site":{"6":1,"2":1},"core.login.admin":{"6":1},"core.login.api":{"8":1},"core.login.offline":{"6":1},"core.admin":{"8":1},"core.manage":{"7":1},"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'), +(1, 0, 0, 179, 0, 'root.1', 'Root Asset', '{"core.login.site":{"6":1,"2":1},"core.login.admin":{"6":1},"core.login.api":{"8":1},"core.login.offline":{"6":1},"core.admin":{"8":1},"core.manage":{"7":1},"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'), (2, 1, 1, 2, 1, 'com_admin', 'com_admin', '{}'), (3, 1, 3, 6, 1, 'com_banners', 'com_banners', '{"core.admin":{"7":1},"core.manage":{"6":1}}'), (4, 1, 7, 8, 1, 'com_cache', 'com_cache', '{"core.admin":{"7":1},"core.manage":{"7":1}}'), @@ -113,7 +113,8 @@ INSERT INTO `#__assets` (`id`, `parent_id`, `lft`, `rgt`, `level`, `name`, `titl (93, 1, 171, 172, 1, 'com_fields', 'com_fields', '{}'), (94, 1, 173, 174, 1, 'com_workflow', 'com_workflow', '{}'), (95, 1, 175, 176, 1, 'com_guidedtours', 'com_guidedtours', '{}'), -(96, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'); +(96, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'), +(97, 1, 177, 178, 1, 'com_scheduler.task.1', 'com_scheduler.task.1', '{}'); -- -------------------------------------------------------- @@ -361,12 +362,12 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0), (0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0), (0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 24, 0), -(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 25, 0), (0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 26, 0), (0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_task_globalcheckin', 'plugin', 'globalcheckin', 'task', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), (0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0), (0, 'plg_task_sitestatus', 'plugin', 'sitestatus', 'task', 0, 1, 1, 0, 1, '', '{}', '', 4, 0), +(0, 'plg_task_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', 5, 0), (0, 'plg_multifactorauth_totp', 'plugin', 'totp', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 1, 0), (0, 'plg_multifactorauth_yubikey', 'plugin', 'yubikey', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 2, 0), (0, 'plg_multifactorauth_webauthn', 'plugin', 'webauthn', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 3, 0), diff --git a/installation/sql/mysql/extensions.sql b/installation/sql/mysql/extensions.sql index 4d74452f77c97..187b1cddebf3d 100644 --- a/installation/sql/mysql/extensions.sql +++ b/installation/sql/mysql/extensions.sql @@ -925,6 +925,9 @@ CREATE TABLE IF NOT EXISTS `#__scheduler_tasks` ( KEY `idx_checked_out` (`checked_out`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci; +INSERT INTO `#__scheduler_tasks` (`id`, `asset_id`, `title`, `type`, `execution_rules`, `cron_rules`, `state`, `last_execution`, `next_execution`, `locked`, `params`, `created`) +VALUES (1, 97, 'UpdateNotification', 'update.notification', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TIME_FORMAT(NOW(), '%H:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, DATE_FORMAT(NOW() + INTERVAL 24 HOUR, '%Y-%m-%d %H:00:00'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"email":"","language_override":""}', NOW()); + -- -------------------------------------------------------- -- diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 034682c5a2bfc..f7252db7465a9 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -275,8 +275,6 @@ SELECT `extension_id`, 'COM_CPANEL_WELCOME_BEGINNERS_TITLE', 'COM_CPANEL_WELCOME INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`) SELECT `extension_id`, 'COM_CPANEL_MSG_STATS_COLLECTION_TITLE', 'COM_CPANEL_MSG_STATS_COLLECTION_BODY', '', 'com_cpanel', 1, 'message', '', '', 'admin://components/com_admin/postinstall/statscollection.php', 'admin_postinstall_statscollection_condition', '3.5.0', 1 FROM `#__extensions` WHERE `name` = 'files_joomla'; INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`) -SELECT `extension_id`, 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME', 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_BODY', 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_ACTION', 'plg_system_updatenotification', 1, 'action', 'site://plugins/system/updatenotification/postinstall/updatecachetime.php', 'updatecachetime_postinstall_action', 'site://plugins/system/updatenotification/postinstall/updatecachetime.php', 'updatecachetime_postinstall_condition', '3.6.3', 1 FROM `#__extensions` WHERE `name` = 'files_joomla'; -INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`) SELECT `extension_id`, 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_TITLE', 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_BODY', 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_ACTION', 'plg_system_httpheaders', 1, 'action', 'site://plugins/system/httpheaders/postinstall/introduction.php', 'httpheaders_postinstall_action', 'site://plugins/system/httpheaders/postinstall/introduction.php', 'httpheaders_postinstall_condition', '4.0.0', 1 FROM `#__extensions` WHERE `name` = 'files_joomla'; INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`) SELECT `extension_id`, 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_TITLE', 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_BODY', 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_ACTION', 'com_users', 1, 'action', 'admin://components/com_users/postinstall/multifactorauth.php', 'com_users_postinstall_mfa_action', 'admin://components/com_users/postinstall/multifactorauth.php', 'com_users_postinstall_mfa_condition', '4.2.0', 1 FROM `#__extensions` WHERE `name` = 'files_joomla'; @@ -416,7 +414,7 @@ INSERT INTO `#__mail_templates` (`template_id`, `extension`, `language`, `subjec ('com_users.massmail.mail', 'com_users', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.password_reset', 'com_users', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), ('com_users.reminder', 'com_users','', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), -('plg_system_updatenotification.mail', 'plg_system_updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_task_updatenotification.mail', 'plg_task_updatenotification', '', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('plg_user_joomla.mail', 'plg_user_joomla', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_actionlogs.notification', 'com_actionlogs', '', 'COM_ACTIONLOGS_EMAIL_SUBJECT', 'COM_ACTIONLOGS_EMAIL_BODY', 'COM_ACTIONLOGS_EMAIL_HTMLBODY', '', '{"tags":["message","date","extension","username"]}'), ('com_privacy.userdataexport', 'com_privacy', '', 'COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_SUBJECT', 'COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_BODY', '', '', '{"tags":["sitename","url"]}'), diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index 94e4e7a0de1b5..9ce505797c40f 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -31,7 +31,7 @@ COMMENT ON COLUMN "#__assets"."rules" IS 'JSON encoded access control.'; -- INSERT INTO "#__assets" ("id", "parent_id", "lft", "rgt", "level", "name", "title", "rules") VALUES -(1, 0, 0, 177, 0, 'root.1', 'Root Asset', '{"core.login.site":{"6":1,"2":1},"core.login.admin":{"6":1},"core.login.api":{"8":1},"core.login.offline":{"6":1},"core.admin":{"8":1},"core.manage":{"7":1},"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'), +(1, 0, 0, 179, 0, 'root.1', 'Root Asset', '{"core.login.site":{"6":1,"2":1},"core.login.admin":{"6":1},"core.login.api":{"8":1},"core.login.offline":{"6":1},"core.admin":{"8":1},"core.manage":{"7":1},"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'), (2, 1, 1, 2, 1, 'com_admin', 'com_admin', '{}'), (3, 1, 3, 6, 1, 'com_banners', 'com_banners', '{"core.admin":{"7":1},"core.manage":{"6":1}}'), (4, 1, 7, 8, 1, 'com_cache', 'com_cache', '{"core.admin":{"7":1},"core.manage":{"7":1}}'), @@ -119,9 +119,10 @@ INSERT INTO "#__assets" ("id", "parent_id", "lft", "rgt", "level", "name", "titl (93, 1, 171, 172, 1, 'com_fields', 'com_fields', '{}'), (94, 1, 173, 174, 1, 'com_workflow', 'com_workflow', '{}'), (95, 1, 175, 176, 1, 'com_guidedtours', 'com_guidedtours', '{}'), -(96, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'); +(96, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'), +(97, 1, 177, 178, 1, 'com_scheduler.task.1', 'com_scheduler.task.1', '{}'); -SELECT setval('#__assets_id_seq', 97, false); +SELECT setval('#__assets_id_seq', 98, false); -- -- Table structure for table `#__extensions` @@ -367,12 +368,12 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0), (0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0), (0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 24, 0), -(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 25, 0), (0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 26, 0), (0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0), (0, 'plg_task_globalcheckin', 'plugin', 'globalcheckin', 'task', 0, 1, 1, 0, 0, '', '{}', '', 2, 0), (0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0), (0, 'plg_task_sitestatus', 'plugin', 'sitestatus', 'task', 0, 1, 1, 0, 1, '', '{}', '', 4, 0), +(0, 'plg_task_updatenotification', 'plugin', 'updatenotification', 'task', 0, 1, 1, 0, 1, '', '{}', '', 5, 0), (0, 'plg_multifactorauth_totp', 'plugin', 'totp', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 1, 0), (0, 'plg_multifactorauth_yubikey', 'plugin', 'yubikey', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 2, 0), (0, 'plg_multifactorauth_webauthn', 'plugin', 'webauthn', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 3, 0), diff --git a/installation/sql/postgresql/extensions.sql b/installation/sql/postgresql/extensions.sql index ac21cf339121e..9b6fb607ded30 100644 --- a/installation/sql/postgresql/extensions.sql +++ b/installation/sql/postgresql/extensions.sql @@ -889,6 +889,11 @@ CREATE INDEX "#__scheduler_tasks_idx_priority" ON "#__scheduler_tasks" ("priorit CREATE INDEX "#__scheduler_tasks_idx_cli_exclusive" ON "#__scheduler_tasks" ("cli_exclusive"); CREATE INDEX "#__scheduler_tasks_idx_checked_out" ON "#__scheduler_tasks" ("checked_out"); +INSERT INTO "#__scheduler_tasks" ("id", "asset_id", "title", "type", "execution_rules", "cron_rules", "state", "last_execution", "next_execution", "locked", "params", "created") +VALUES (1, 97, 'UpdateNotification', 'update.notification', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'HH24:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '24 hours', 'YYYY-MM-DD HH24:00:00'), 'YYYY-MM-DD HH24:MI:SS'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"email":"","language_override":""}', CURRENT_TIMESTAMP AT TIME ZONE 'UTC'); + +SELECT setval('#__scheduler_tasks_id_seq', 2, false); + -- -------------------------------------------------------- -- diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 8a00c79fff6c7..1ad64316c3c23 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -286,8 +286,6 @@ SELECT "extension_id", 'COM_CPANEL_WELCOME_BEGINNERS_TITLE', 'COM_CPANEL_WELCOME INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled") SELECT "extension_id", 'COM_CPANEL_MSG_STATS_COLLECTION_TITLE', 'COM_CPANEL_MSG_STATS_COLLECTION_BODY', '', 'com_cpanel', 1, 'message', '', '', 'admin://components/com_admin/postinstall/statscollection.php', 'admin_postinstall_statscollection_condition', '3.5.0', 1 FROM "#__extensions" WHERE "name" = 'files_joomla'; INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled") -SELECT "extension_id", 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME', 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_BODY', 'PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_ACTION', 'plg_system_updatenotification', 1, 'action', 'site://plugins/system/updatenotification/postinstall/updatecachetime.php', 'updatecachetime_postinstall_action', 'site://plugins/system/updatenotification/postinstall/updatecachetime.php', 'updatecachetime_postinstall_condition', '3.6.3', 1 FROM "#__extensions" WHERE "name" = 'files_joomla'; -INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled") SELECT "extension_id", 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_TITLE', 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_BODY', 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_ACTION', 'plg_system_httpheaders', 1, 'action', 'site://plugins/system/httpheaders/postinstall/introduction.php', 'httpheaders_postinstall_action', 'site://plugins/system/httpheaders/postinstall/introduction.php', 'httpheaders_postinstall_condition', '4.0.0', 1 FROM "#__extensions" WHERE "name" = 'files_joomla'; INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled") SELECT "extension_id", 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_TITLE', 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_BODY', 'COM_USERS_POSTINSTALL_MULTIFACTORAUTH_ACTION', 'com_users', 1, 'action', 'admin://components/com_users/postinstall/multifactorauth.php', 'com_users_postinstall_mfa_action', 'admin://components/com_users/postinstall/multifactorauth.php', 'com_users_postinstall_mfa_condition', '4.2.0', 1 FROM "#__extensions" WHERE "name" = 'files_joomla'; @@ -427,7 +425,7 @@ INSERT INTO "#__mail_templates" ("template_id", "extension", "language", "subjec ('com_users.massmail.mail', 'com_users', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.password_reset', 'com_users', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), ('com_users.reminder', 'com_users', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), -('plg_system_updatenotification.mail', 'plg_system_updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_task_updatenotification.mail', 'plg_task_updatenotification', '', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_TASK_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('plg_user_joomla.mail', 'plg_user_joomla', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_actionlogs.notification', 'com_actionlogs', '', 'COM_ACTIONLOGS_EMAIL_SUBJECT', 'COM_ACTIONLOGS_EMAIL_BODY', 'COM_ACTIONLOGS_EMAIL_HTMLBODY', '', '{"tags":["message","date","extension","username"]}'), ('com_privacy.userdataexport', 'com_privacy', '', 'COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_SUBJECT', 'COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_BODY', '', '', '{"tags":["sitename","url"]}'), diff --git a/installation/src/Model/ConfigurationModel.php b/installation/src/Model/ConfigurationModel.php index dd89d93970271..257eab32816ee 100644 --- a/installation/src/Model/ConfigurationModel.php +++ b/installation/src/Model/ConfigurationModel.php @@ -277,9 +277,10 @@ protected function updateUserIds($db) // Update all core tables created_by fields of the tables with the random user id. $updatesArray = [ - '#__categories' => ['created_user_id', 'modified_user_id'], - '#__tags' => ['created_user_id', 'modified_user_id'], - '#__workflows' => ['created_by', 'modified_by'], + '#__categories' => ['created_user_id', 'modified_user_id'], + '#__scheduler_tasks' => ['created_by'], + '#__tags' => ['created_user_id', 'modified_user_id'], + '#__workflows' => ['created_by', 'modified_by'], ]; foreach ($updatesArray as $table => $fields) { diff --git a/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php index a48c06decb91f..5a316e1aac37d 100644 --- a/libraries/src/Extension/ExtensionHelper.php +++ b/libraries/src/Extension/ExtensionHelper.php @@ -315,7 +315,6 @@ class ExtensionHelper ['plugin', 'skipto', 'system', 0], ['plugin', 'stats', 'system', 0], ['plugin', 'tasknotification', 'system', 0], - ['plugin', 'updatenotification', 'system', 0], ['plugin', 'webauthn', 'system', 0], // Core plugin extensions - task scheduler @@ -323,6 +322,7 @@ class ExtensionHelper ['plugin', 'globalcheckin', 'task', 0], ['plugin', 'requests', 'task', 0], ['plugin', 'sitestatus', 'task', 0], + ['plugin', 'updatenotification', 'task', 0], // Core plugin extensions - user ['plugin', 'contactcreator', 'user', 0], diff --git a/plugins/system/updatenotification/postinstall/updatecachetime.php b/plugins/system/updatenotification/postinstall/updatecachetime.php deleted file mode 100644 index b020125158fdd..0000000000000 --- a/plugins/system/updatenotification/postinstall/updatecachetime.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Factory; -use Joomla\CMS\Plugin\PluginHelper; -use Joomla\CMS\Table\Table; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * Checks if the com_installer config for the cache Hours are eq 0 and the updatenotification Plugin is enabled - * - * @return boolean - * - * @since 3.6.3 - */ -function updatecachetime_postinstall_condition() -{ - $cacheTimeout = (int) ComponentHelper::getComponent('com_installer')->params->get('cachetimeout', 6); - - // Check if cachetimeout is eq zero - if ($cacheTimeout === 0 && PluginHelper::isEnabled('system', 'updatenotification')) { - return true; - } - - return false; -} - -/** - * Sets the cachetimeout back to the default (6 hours) - * - * @return void - * - * @since 3.6.3 - */ -function updatecachetime_postinstall_action() -{ - $installer = ComponentHelper::getComponent('com_installer'); - - // Sets the cachetimeout back to the default (6 hours) - $installer->params->set('cachetimeout', 6); - - // Save the new parameters back to com_installer - $table = Table::getInstance('extension'); - $table->load($installer->id); - $table->bind(['params' => $installer->params->toString()]); - - // Store the changes - if (!$table->store()) { - // If there is an error show it to the admin - Factory::getApplication()->enqueueMessage($table->getError(), 'error'); - } -} diff --git a/plugins/system/updatenotification/updatenotification.xml b/plugins/system/updatenotification/updatenotification.xml deleted file mode 100644 index b293ea5505a5e..0000000000000 --- a/plugins/system/updatenotification/updatenotification.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - plg_system_updatenotification - Joomla! Project - 2015-05 - (C) 2015 Open Source Matters, Inc. - GNU General Public License version 2 or later; see LICENSE.txt - admin@joomla.org - www.joomla.org - 3.5.0 - PLG_SYSTEM_UPDATENOTIFICATION_XML_DESCRIPTION - Joomla\Plugin\System\UpdateNotification - - postinstall - services - src - - - language/en-GB/plg_system_updatenotification.ini - language/en-GB/plg_system_updatenotification.sys.ini - - - -
- - - - - - - -
-
-
-
diff --git a/plugins/task/updatenotification/forms/sendForm.xml b/plugins/task/updatenotification/forms/sendForm.xml new file mode 100644 index 0000000000000..47fe0c72d808c --- /dev/null +++ b/plugins/task/updatenotification/forms/sendForm.xml @@ -0,0 +1,24 @@ + +
+ +
+ + + + +
+
+
diff --git a/plugins/system/updatenotification/services/provider.php b/plugins/task/updatenotification/services/provider.php similarity index 80% rename from plugins/system/updatenotification/services/provider.php rename to plugins/task/updatenotification/services/provider.php index 7ce2a0ebf0062..ee30840167ba3 100644 --- a/plugins/system/updatenotification/services/provider.php +++ b/plugins/task/updatenotification/services/provider.php @@ -2,7 +2,7 @@ /** * @package Joomla.Plugin - * @subpackage System.updatenotification + * @subpackage Task.updatenotification * * @copyright (C) 2023 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt @@ -17,7 +17,7 @@ use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use Joomla\Event\DispatcherInterface; -use Joomla\Plugin\System\UpdateNotification\Extension\UpdateNotification; +use Joomla\Plugin\Task\UpdateNotification\Extension\UpdateNotification; return new class () implements ServiceProviderInterface { /** @@ -27,16 +27,16 @@ * * @return void * - * @since 4.4.0 + * @since __DEPLOY_VERSION__ */ public function register(Container $container): void { $container->set( PluginInterface::class, function (Container $container) { - $plugin = new UpdateNotification( + $plugin = new UpdateNotification( $container->get(DispatcherInterface::class), - (array) PluginHelper::getPlugin('system', 'updatenotification') + (array) PluginHelper::getPlugin('task', 'updatenotification') ); $plugin->setApplication(Factory::getApplication()); $plugin->setDatabase($container->get(DatabaseInterface::class)); diff --git a/plugins/system/updatenotification/src/Extension/UpdateNotification.php b/plugins/task/updatenotification/src/Extension/UpdateNotification.php similarity index 60% rename from plugins/system/updatenotification/src/Extension/UpdateNotification.php rename to plugins/task/updatenotification/src/Extension/UpdateNotification.php index b6f600676e3c6..3817abead9b8b 100644 --- a/plugins/system/updatenotification/src/Extension/UpdateNotification.php +++ b/plugins/task/updatenotification/src/Extension/UpdateNotification.php @@ -2,19 +2,16 @@ /** * @package Joomla.Plugin - * @subpackage System.updatenotification + * @subpackage Task.updatenotification * - * @copyright (C) 2015 Open Source Matters, Inc. + * @copyright (C) 2023 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -namespace Joomla\Plugin\System\UpdateNotification\Extension; +namespace Joomla\Plugin\Task\UpdateNotification\Extension; use Joomla\CMS\Access\Access; -use Joomla\CMS\Cache\Cache; -use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Extension\ExtensionHelper; -use Joomla\CMS\Log\Log; use Joomla\CMS\Mail\Exception\MailDisabledException; use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\Plugin\CMSPlugin; @@ -22,135 +19,101 @@ use Joomla\CMS\Updater\Updater; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Version; +use Joomla\Component\Scheduler\Administrator\Event\ExecuteTaskEvent; +use Joomla\Component\Scheduler\Administrator\Task\Status; +use Joomla\Component\Scheduler\Administrator\Traits\TaskPluginTrait; use Joomla\Database\DatabaseAwareTrait; use Joomla\Database\ParameterType; +use Joomla\Event\SubscriberInterface; use PHPMailer\PHPMailer\Exception as phpMailerException; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects -// Uncomment the following line to enable debug mode (update notification email sent every single time) -// define('PLG_SYSTEM_UPDATENOTIFICATION_DEBUG', 1); - /** - * Joomla! Update Notification plugin - * - * Sends out an email to all Super Users or a predefined list of email addresses of Super Users when a new - * Joomla! version is available. + * A task plugin. Offers 2 task routines Invalidate Expired Consents and Remind Expired Consents + * {@see ExecuteTaskEvent}. * - * This plugin is a direct adaptation of the corresponding plugin in Akeeba Ltd's Admin Tools. The author has - * consented to relicensing their plugin's code under GPLv2 or later (the original version was licensed under - * GPLv3 or later) to allow its inclusion in the Joomla! CMS. - * - * @since 3.5 + * @since __DEPLOY_VERSION__ */ -final class UpdateNotification extends CMSPlugin +final class UpdateNotification extends CMSPlugin implements SubscriberInterface { use DatabaseAwareTrait; + use TaskPluginTrait; /** - * Load plugin language files automatically - * - * @var boolean - * @since 3.6.3 + * @var string[] + * @since __DEPLOY_VERSION__ + */ + private const TASKS_MAP = [ + 'update.notification' => [ + 'langConstPrefix' => 'PLG_TASK_UPDATENOTIFICATION_SEND', + 'method' => 'sendNotification', + 'form' => 'sendForm', + ], + ]; + + /** + * @var boolean + * @since __DEPLOY_VERSION__ */ protected $autoloadLanguage = true; /** - * The update check and notification email code is triggered after the page has fully rendered. + * @inheritDoc * - * @return void + * @return string[] * - * @since 3.5 + * @since __DEPLOY_VERSION__ */ - public function onAfterRender() + public static function getSubscribedEvents(): array { - // Get the timeout for Joomla! updates, as configured in com_installer's component parameters - $component = ComponentHelper::getComponent('com_installer'); - - /** @var \Joomla\Registry\Registry $params */ - $params = $component->getParams(); - $cache_timeout = (int) $params->get('cachetimeout', 6); - $cache_timeout = 3600 * $cache_timeout; - - // Do we need to run? Compare the last run timestamp stored in the plugin's options with the current - // timestamp. If the difference is greater than the cache timeout we shall not execute again. - $now = time(); - $last = (int) $this->params->get('lastrun', 0); - - if (!defined('PLG_SYSTEM_UPDATENOTIFICATION_DEBUG') && (abs($now - $last) < $cache_timeout)) { - return; - } - - // Update last run status - // If I have the time of the last run, I can update, otherwise insert - $this->params->set('lastrun', $now); - - $db = $this->getDatabase(); - $paramsJson = $this->params->toString('JSON'); - - $query = $db->getQuery(true) - ->update($db->quoteName('#__extensions')) - ->set($db->quoteName('params') . ' = :params') - ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')) - ->where($db->quoteName('folder') . ' = ' . $db->quote('system')) - ->where($db->quoteName('element') . ' = ' . $db->quote('updatenotification')) - ->bind(':params', $paramsJson); - - try { - // Lock the tables to prevent multiple plugin executions causing a race condition - $db->lockTable('#__extensions'); - } catch (\Exception $e) { - // If we can't lock the tables it's too risky to continue execution - return; - } - - try { - // Update the plugin parameters - $result = $db->setQuery($query)->execute(); - - $this->clearCacheGroups(['com_plugins']); - } catch (\Exception $exc) { - // If we failed to execute - $db->unlockTables(); - $result = false; - } - - try { - // Unlock the tables after writing - $db->unlockTables(); - } catch (\Exception $e) { - // If we can't lock the tables assume we have somehow failed - $result = false; - } + return [ + 'onTaskOptionsList' => 'advertiseRoutines', + 'onExecuteTask' => 'standardRoutineHandler', + 'onContentPrepareForm' => 'enhanceTaskItemForm', + ]; + } - // Stop on failure - if (!$result) { - return; - } + /** + * Method to send the update notification. + * + * @param ExecuteTaskEvent $event The `onExecuteTask` event. + * + * @return integer The routine exit code. + * + * @since __DEPLOY_VERSION__ + * @throws \Exception + */ + private function sendNotification(ExecuteTaskEvent $event): int + { + // Load the parameters. + $specificEmail = $event->getArgument('params')->email ?? ''; + $forcedLanguage = $event->getArgument('params')->language_override ?? ''; // This is the extension ID for Joomla! itself $eid = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id; // Get any available updates $updater = Updater::getInstance(); - $results = $updater->findUpdates([$eid], $cache_timeout); + $results = $updater->findUpdates([$eid], 0); // If there are no updates our job is done. We need BOTH this check AND the one below. if (!$results) { - return; + return Status::OK; } // Get the update model and retrieve the Joomla! core updates $model = $this->getApplication()->bootComponent('com_installer') ->getMVCFactory()->createModel('Update', 'Administrator', ['ignore_request' => true]); + $model->setState('filter.extension_id', $eid); $updates = $model->getItems(); // If there are no updates we don't have to notify anyone about anything. This is NOT a duplicate check. if (empty($updates)) { - return; + return Status::OK; } // Get the available update @@ -158,7 +121,7 @@ public function onAfterRender() // Check the available version. If it's the same or less than the installed version we have no updates to notify about. if (version_compare($update->version, JVERSION, 'le')) { - return; + return Status::OK; } // If we're here, we have updates. First, get a link to the Joomla! Update component. @@ -183,8 +146,7 @@ public function onAfterRender() $this->getApplication()->triggerEvent('onBuildAdministratorLoginURL', [&$uri]); // Let's find out the email addresses to notify - $superUsers = []; - $specificEmail = $this->params->get('email', ''); + $superUsers = []; if (!empty($specificEmail)) { $superUsers = $this->getSuperUsers($specificEmail); @@ -195,7 +157,7 @@ public function onAfterRender() } if (empty($superUsers)) { - return; + return Status::KNOCKOUT; } /* @@ -206,14 +168,12 @@ public function onAfterRender() * solution! */ $jLanguage = $this->getApplication()->getLanguage(); - $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, 'en-GB', true, true); - $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, null, true, false); + $jLanguage->load('plg_task_updatenotification', JPATH_ADMINISTRATOR, 'en-GB', true, true); + $jLanguage->load('plg_task_updatenotification', JPATH_ADMINISTRATOR, null, true, false); // Then try loading the preferred (forced) language - $forcedLanguage = $this->params->get('language_override', ''); - if (!empty($forcedLanguage)) { - $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, $forcedLanguage, true, false); + $jLanguage->load('plg_task_updatenotification', JPATH_ADMINISTRATOR, $forcedLanguage, true, false); } // Replace merge codes with their values @@ -236,18 +196,22 @@ public function onAfterRender() // Send the emails to the Super Users foreach ($superUsers as $superUser) { try { - $mailer = new MailTemplate('plg_system_updatenotification.mail', $jLanguage->getTag()); + $mailer = new MailTemplate('plg_task_updatenotification.mail', $jLanguage->getTag()); $mailer->addRecipient($superUser->email); $mailer->addTemplateData($substitutions); $mailer->send(); } catch (MailDisabledException | phpMailerException $exception) { try { - Log::add($this->getApplication()->getLanguage()->_($exception->getMessage()), Log::WARNING, 'jerror'); + $this->logTask($jLanguage->_($exception->getMessage())); } catch (\RuntimeException $exception) { - $this->getApplication()->enqueueMessage($this->getApplication()->getLanguage()->_($exception->errorMessage()), 'warning'); + return Status::KNOCKOUT; } } } + + $this->logTask('UpdateNotification end'); + + return Status::OK; } /** @@ -342,30 +306,4 @@ private function getSuperUsers($email = null) return $ret; } - - /** - * Clears cache groups. We use it to clear the plugins cache after we update the last run timestamp. - * - * @param array $clearGroups The cache groups to clean - * - * @return void - * - * @since 3.5 - */ - private function clearCacheGroups(array $clearGroups) - { - foreach ($clearGroups as $group) { - try { - $options = [ - 'defaultgroup' => $group, - 'cachebase' => $this->getApplication()->get('cache_path', JPATH_CACHE), - ]; - - $cache = Cache::getInstance('callback', $options); - $cache->clean(); - } catch (\Exception $e) { - // Ignore it - } - } - } } diff --git a/plugins/task/updatenotification/updatenotification.xml b/plugins/task/updatenotification/updatenotification.xml new file mode 100644 index 0000000000000..125144ab7a8e9 --- /dev/null +++ b/plugins/task/updatenotification/updatenotification.xml @@ -0,0 +1,22 @@ + + + plg_task_updatenotification + Joomla! Project + 2023-07 + (C) 2023 Open Source Matters, Inc. + GNU General Public License version 2 or later; see LICENSE.txt + admin@joomla.org + www.joomla.org + 5.0.0 + PLG_TASK_UPDATENOTIFICATION_XML_DESCRIPTION + Joomla\Plugin\Task\UpdateNotification + + forms + services + src + + + language/en-GB/plg_task_updatenotification.ini + language/en-GB/plg_task_updatenotification.sys.ini + + ```