diff --git a/administrator/components/com_admin/sql/updates/mysql/3.10.0-2021-05-28.sql b/administrator/components/com_admin/sql/updates/mysql/3.10.0-2021-05-28.sql new file mode 100644 index 0000000000000..29e9dfaa491b0 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.10.0-2021-05-28.sql @@ -0,0 +1,2 @@ +INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.10.0-2021-05-28.sql b/administrator/components/com_admin/sql/updates/postgresql/3.10.0-2021-05-28.sql new file mode 100644 index 0000000000000..4f40b5fcdfb35 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.10.0-2021-05-28.sql @@ -0,0 +1,2 @@ +INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/sqlazure/3.10.0-2021-05-28.sql b/administrator/components/com_admin/sql/updates/sqlazure/3.10.0-2021-05-28.sql new file mode 100644 index 0000000000000..bd9bc32545511 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/sqlazure/3.10.0-2021-05-28.sql @@ -0,0 +1,6 @@ +SET IDENTITY_INSERT "#__extensions" ON; + +INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '1900-01-01 00:00:00', 0, 0); + +SET IDENTITY_INSERT "#__extensions" OFF; diff --git a/administrator/language/en-GB/en-GB.plg_quickicon_eos310.ini b/administrator/language/en-GB/en-GB.plg_quickicon_eos310.ini new file mode 100644 index 0000000000000..e66fe7064635a --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_quickicon_eos310.ini @@ -0,0 +1,21 @@ +; Joomla! Project +; (C) 2021 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_QUICKICON_EOS310="Quick Icon - Joomla 3.10 End Of Support Notification" +PLG_QUICKICON_EOS310_GROUPNAME_EOS="End Of Support" +PLG_QUICKICON_EOS310_GROUPNAME_INFO="Upgrade Information" +PLG_QUICKICON_EOS310_GROUPNAME_WARNING="Support Status" +PLG_QUICKICON_EOS310_MESSAGE_ERROR_SUPPORT_ENDED="

Support has ended for your version of Joomla 3.10. Migrate to Joomla 4 as soon as possible.

" +PLG_QUICKICON_EOS310_MESSAGE_ERROR_SUPPORT_ENDED_SHORT="Support has ended for Joomla 3.10 " +PLG_QUICKICON_EOS310_MESSAGE_INFO_01="

Joomla 4 has arrived! Find out all that Joomla 4 has to offer you. Check the landing page for Joomla 4 features and improvements.

" +PLG_QUICKICON_EOS310_MESSAGE_INFO_01_SHORT="Joomla 4 has arrived! " +PLG_QUICKICON_EOS310_MESSAGE_INFO_02="

When is the time to migrate to Joomla 4? Once the extensions your site needs are compatible. Learn how to use the Pre-Update Checker.

" +PLG_QUICKICON_EOS310_MESSAGE_INFO_02_SHORT="Use Pre-Update Check for extension compatibility " +PLG_QUICKICON_EOS310_MESSAGE_WARNING_SECURITY_ONLY="

Joomla 3.10 has entered security only mode. Support ends %1$s. Start planning to migrate to Joomla 4 today.

" +PLG_QUICKICON_EOS310_MESSAGE_WARNING_SECURITY_ONLY_SHORT="Joomla 3.10 to end support on %1$s. " +PLG_QUICKICON_EOS310_MESSAGE_WARNING_SUPPORT_ENDING="

Support ends on %1$s for Joomla 3.10. Migrate to Joomla 4 as soon as possible.

" +PLG_QUICKICON_EOS310_MESSAGE_WARNING_SUPPORT_ENDING_SHORT="End of support for Joomla 3.10 on %1$s. " +PLG_QUICKICON_EOS310_SNOOZE_BUTTON="Snooze this message for all users" +PLG_QUICKICON_EOS310_XML_DESCRIPTION="Checks for the end of support status of Joomla 3.10 and notifies you when visiting the Control Panel page." diff --git a/administrator/language/en-GB/en-GB.plg_quickicon_eos310.sys.ini b/administrator/language/en-GB/en-GB.plg_quickicon_eos310.sys.ini new file mode 100644 index 0000000000000..8333666513be5 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_quickicon_eos310.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; (C) 2021 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_QUICKICON_EOS310="Quick Icon - Joomla! 3.10 End Of Support Notification" +PLG_QUICKICON_EOS310_XML_DESCRIPTION="Checks for the end of support status of Joomla 3.10 and notifies you when visiting the Control Panel page." diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index b57e610e46e6d..4f835c7e4756a 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -668,6 +668,7 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem (493, 0, 'plg_privacy_actionlogs', 'plugin', 'actionlogs', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (494, 0, 'plg_captcha_recaptcha_invisible', 'plugin', 'recaptcha_invisible', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"clean"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (495, 0, 'plg_privacy_consents', 'plugin', 'consents', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index 37e683a3ed310..1832f41baf729 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -681,6 +681,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (493, 0, 'plg_privacy_actionlogs', 'plugin', 'actionlogs', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (494, 0, 'plg_captcha_recaptcha_invisible', 'plugin', 'recaptcha_invisible', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"clean"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (495, 0, 'plg_privacy_consents', 'plugin', 'consents', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0), +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '1970-01-01 00:00:00', 0, 0), diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index e984c8c6d9fb3..c4b843eb2c646 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -896,6 +896,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (493, 0, 'plg_privacy_actionlogs', 'plugin', 'actionlogs', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (494, 0, 'plg_captcha_recaptcha_invisible', 'plugin', 'recaptcha_invisible', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"clean"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (495, 0, 'plg_privacy_consents', 'plugin', 'consents', 'privacy', 0, 1, 1, 0, '', '{}', '', '', 0, '1900-01-01 00:00:00', 0, 0), +(496, 0, 'plg_quickicon_eos310', 'plugin', 'eos310', 'quickicon', 0, 1, 1, 0, '', '{}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (503, 0, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (504, 0, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (506, 0, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '1900-01-01 00:00:00', 0, 0), diff --git a/layouts/joomla/links/link.php b/layouts/joomla/links/link.php index ff9b2068666f8..c49d451c08c59 100644 --- a/layouts/joomla/links/link.php +++ b/layouts/joomla/links/link.php @@ -11,13 +11,14 @@ $id = empty($displayData['id']) ? '' : (' id="' . $displayData['id'] . '"'); $target = empty($displayData['target']) ? '' : (' target="' . $displayData['target'] . '"'); +$rel = empty($displayData['rel']) ? '' : (' rel="' . $displayData['rel'] . '"'); $onclick = empty($displayData['onclick']) ? '' : (' onclick="' . $displayData['onclick'] . '"'); $title = empty($displayData['title']) ? '' : (' title="' . $this->escape($displayData['title']) . '"'); $text = empty($displayData['text']) ? '' : ('' . $displayData['text'] . '') ?> > - > + > diff --git a/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php index 7ad4b457eb3cf..236fc0253c74c 100644 --- a/libraries/src/Extension/ExtensionHelper.php +++ b/libraries/src/Extension/ExtensionHelper.php @@ -218,6 +218,7 @@ class ExtensionHelper array('plugin', 'joomlaupdate', 'quickicon', 0), array('plugin', 'phpversioncheck', 'quickicon', 0), array('plugin', 'privacycheck', 'quickicon', 0), + array('plugin', 'eos310', 'quickicon', 0), // Core plugin extensions - sample data array('plugin', 'blog', 'sampledata', 0), diff --git a/media/plg_quickicon_eos310/js/snooze.js b/media/plg_quickicon_eos310/js/snooze.js new file mode 100644 index 0000000000000..caa5360f12c00 --- /dev/null +++ b/media/plg_quickicon_eos310/js/snooze.js @@ -0,0 +1,31 @@ +/** + * @copyright (C) 2021 Open Source Matters, Inc. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + + (function ($) + { + $(document).ready(function () + { + var ajaxData = { + 'option' : 'com_ajax', + 'group' : 'quickicon', + 'plugin' : 'SnoozeEOS', + 'format' : 'json' + } + + $('#system-message-container').on('click', '.eosnotify-snooze-btn', function(e) + { + var button=$(this); + $.getJSON('index.php', ajaxData, function(response) + { + if (response.success) + { + button.closest('.alert').find('[data-dismiss="alert"]').click(); + } + } + ); + e.preventDefault(); + }); + }); + })(jQuery); diff --git a/media/plg_quickicon_eos310/js/snooze.min.js b/media/plg_quickicon_eos310/js/snooze.min.js new file mode 100644 index 0000000000000..b99abadaf26c5 --- /dev/null +++ b/media/plg_quickicon_eos310/js/snooze.min.js @@ -0,0 +1 @@ +!function(n){n(document).ready(function(){var o={option:"com_ajax",group:"quickicon",plugin:"SnoozeEOS",format:"json"};n("#system-message-container").on("click",".eosnotify-snooze-btn",function(e){var t=n(this);n.getJSON("index.php",o,function(n){n.success&&t.closest(".alert").find('[data-dismiss="alert"]').click()}),e.preventDefault()})})}(jQuery); diff --git a/plugins/quickicon/eos310/eos310.php b/plugins/quickicon/eos310/eos310.php new file mode 100644 index 0000000000000..23429fb1fe670 --- /dev/null +++ b/plugins/quickicon/eos310/eos310.php @@ -0,0 +1,438 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Plugin\CMSPlugin; + +/** + * Joomla! end of support notification plugin + * + * @since __DEPLOY_VERSION__ + */ +class PlgQuickiconEos310 extends CMSPlugin +{ + /** + * The EOS date for 3.10 + * @todo The date is just for testing and is to be updated on release + * + * @var string + * @since __DEPLOY_VERSION__ + */ + const EOS_DATE = '2024-07-06'; + + /** + * Application object + * + * @var CMSApplication + * @since __DEPLOY_VERSION__ + */ + protected $app; + + /** + * Database object + * + * @var DatabaseDriver + * @since __DEPLOY_VERSION__ + */ + protected $db; + + /** + * Load the language file on instantiation. + * + * @var boolean + * @since __DEPLOY_VERSION__ + */ + protected $autoloadLanguage = true; + + /** + * Holding the current valid message to be shown + * + * @var boolean + * @since __DEPLOY_VERSION__ + */ + private $currentMessage = false; + + /** + * Constructor. + * + * @param object &$subject The object to observe. + * @param array $config An optional associative array of configuration settings. + * + * @since __DEPLOY_VERSION__ + */ + public function __construct(&$subject, $config) + { + parent::__construct($subject, $config); + + $diff = Factory::getDate()->diff(Factory::getDate(static::EOS_DATE)); + $monthsUntilEOS = floor($diff->days / 30.417); + + $this->currentMessage = $this->getMessageInfo($monthsUntilEOS, $diff->invert); + } + + /** + * Check and show the the alert and quickicon message + * + * @param string $context The calling context + * + * @return array|void A list of icon definition associative arrays, consisting of the + * keys link, image, text and access, or void. + * + * @since __DEPLOY_VERSION__ + */ + public function onGetIcons($context) + { + if (!$this->shouldDisplayMessage()) + { + return; + } + + // No messages yet + if (!$this->currentMessage) + { + return; + } + + // Show this only when not snoozed + if ($this->params->get('last_snoozed_id', 0) < $this->currentMessage['id']) + { + // Load the snooze scripts. + HTMLHelper::_('jquery.framework'); + HTMLHelper::_('script', 'plg_quickicon_eos310/snooze.js', array('version' => 'auto', 'relative' => true)); + + // Build the message to be displayed in the cpanel + $messageText = Text::sprintf( + $this->currentMessage['messageText'], + HTMLHelper::_('date', static::EOS_DATE, Text::_('DATE_FORMAT_LC3')), + $this->currentMessage['messageLink'], + ); + + if ($this->currentMessage['snoozable']) + { + $messageText .= + '

'; + } + + $this->app->enqueueMessage( + $messageText, + $this->currentMessage['messageType'], + ); + } + + // The message as quickicon + $messageTextQuickIcon = Text::sprintf( + $this->currentMessage['quickiconText'], + HTMLHelper::_( + 'date', + static::EOS_DATE, + Text::_('DATE_FORMAT_LC3') + ), + ); + + // The message as quickicon + return array(array( + 'link' => $this->currentMessage['messageLink'], + 'target' => '_blank', + 'rel' => 'noopener noreferrer', + 'image' => $this->currentMessage['image'], + 'text' => $messageTextQuickIcon, + 'id' => 'plg_quickicon_eos310', + 'group' => $this->currentMessage['groupText'], + )); + } + + /** + * User hit the snooze button + * + * @return void + * + * @since __DEPLOY_VERSION__ + * + * @throws JAccessExceptionNotallowed If user is not allowed. + */ + public function onAjaxSnoozeEOS() + { + // No messages yet so nothing to snooze + if (!$this->currentMessage) + { + return; + } + + if (!$this->isAllowedUser() || !$this->isAjaxRequest()) + { + throw new JAccessExceptionNotallowed(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'), 403); + } + + // Make sure only snoozable messages can be snoozed + if ($this->currentMessage['snoozable']) + { + $this->params->set('last_snoozed_id', $this->currentMessage['id']); + + $this->saveParams(); + } + } + + /** + * Return the texts to be displayed based on the time until we reach EOS + * + * @param integer $monthsUntilEOS The months until we reach EOS + * @param integer $inverted Have we surpassed the EOS date + * + * @return array|bool An array with the message to be displayed or false + * + * @since __DEPLOY_VERSION__ + */ + private function getMessageInfo($monthsUntilEOS, $inverted) + { + // The EOS date has passed - Support has ended + if ($inverted === 1) + { + return array( + 'id' => 5, + 'messageText' => 'PLG_QUICKICON_EOS310_MESSAGE_ERROR_SUPPORT_ENDED', + 'quickiconText' => 'PLG_QUICKICON_EOS310_MESSAGE_ERROR_SUPPORT_ENDED_SHORT', + 'messageType' => 'error', + 'image' => 'minus-circle', + 'messageLink' => 'https://docs.joomla.org/Special:MyLanguage/Planning_for_Mini-Migration_-_Joomla_3.10.x_to_4.x', + 'groupText' => Text::_('PLG_QUICKICON_EOS310_GROUPNAME_EOS'), + 'snoozable' => false, + ); + } + + // The security support is ending in 6 months + if ($monthsUntilEOS <= 6) + { + return array( + 'id' => 4, + 'messageText' => 'PLG_QUICKICON_EOS310_MESSAGE_WARNING_SUPPORT_ENDING', + 'quickiconText' => 'PLG_QUICKICON_EOS310_MESSAGE_WARNING_SUPPORT_ENDING_SHORT', + 'messageType' => 'warning', + 'image' => 'warning-circle', + 'messageLink' => 'https://docs.joomla.org/Special:MyLanguage/Planning_for_Mini-Migration_-_Joomla_3.10.x_to_4.x', + 'groupText' => Text::_('PLG_QUICKICON_EOS310_GROUPNAME_WARNING'), + 'snoozable' => true, + ); + } + + // We are in security only mode now, 12 month to go from now on + if ($monthsUntilEOS <= 12) + { + return array( + 'id' => 3, + 'messageText' => 'PLG_QUICKICON_EOS310_MESSAGE_WARNING_SECURITY_ONLY', + 'quickiconText' => 'PLG_QUICKICON_EOS310_MESSAGE_WARNING_SECURITY_ONLY_SHORT', + 'messageType' => 'warning', + 'image' => 'warning-circle', + 'messageLink' => 'https://docs.joomla.org/Special:MyLanguage/Planning_for_Mini-Migration_-_Joomla_3.10.x_to_4.x', + 'groupText' => Text::_('PLG_QUICKICON_EOS310_GROUPNAME_WARNING'), + 'snoozable' => true, + ); + } + + // We still have 16 month to go, lets remind our users about the pre upgrade checker + if ($monthsUntilEOS <= 16) + { + return array( + 'id' => 2, + 'messageText' => 'PLG_QUICKICON_EOS310_MESSAGE_INFO_02', + 'quickiconText' => 'PLG_QUICKICON_EOS310_MESSAGE_INFO_02_SHORT', + 'messageType' => 'info', + 'image' => 'info-circle', + 'messageLink' => 'https://docs.joomla.org/Special:MyLanguage/Pre-Update_Check', + 'groupText' => Text::_('PLG_QUICKICON_EOS310_GROUPNAME_INFO'), + 'snoozable' => true, + ); + } + + // Lets start our messages 2 month after the initial release, still 22 month to go + if ($monthsUntilEOS <= 22) + { + return array( + 'id' => 1, + 'messageText' => 'PLG_QUICKICON_EOS310_MESSAGE_INFO_01', + 'quickiconText' => 'PLG_QUICKICON_EOS310_MESSAGE_INFO_01_SHORT', + 'messageType' => 'info', + 'image' => 'info-circle', + 'messageLink' => 'https://joomla.org/4', + 'groupText' => Text::_('PLG_QUICKICON_EOS310_GROUPNAME_INFO'), + 'snoozable' => true, + ); + } + + return false; + } + + /** + * Determines if the message and quickicon should be displayed + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + private function shouldDisplayMessage() + { + // Only on admin app + if (!$this->app->isClient('administrator')) + { + return false; + } + + // Only if authenticated + if (Factory::getUser()->guest) + { + return false; + } + + // Only on HTML documents + if ($this->app->getDocument()->getType() !== 'html') + { + return false; + } + + // Only on full page requests + if ($this->app->input->getCmd('tmpl', 'index') === 'component') + { + return false; + } + + // Only to com_cpanel + if ($this->app->input->get('option') !== 'com_cpanel') + { + return false; + } + + // Don't show anything in 4.0 + if (version_compare(JVERSION, '4.0', '>=')) + { + return false; + } + + return true; + } + + /** + * Check valid AJAX request + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + private function isAjaxRequest() + { + return strtolower($this->app->input->server->get('HTTP_X_REQUESTED_WITH', '')) === 'xmlhttprequest'; + } + + /** + * Check if current user is allowed to send the data + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + private function isAllowedUser() + { + return Factory::getUser()->authorise('core.login.admin'); + } + + /** + * Save the plugin parameters + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + private function saveParams() + { + $query = $this->db->getQuery(true) + ->update($this->db->quoteName('#__extensions')) + ->set($this->db->quoteName('params') . ' = ' . $this->db->quote($this->params->toString('JSON'))) + ->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin')) + ->where($this->db->quoteName('folder') . ' = ' . $this->db->quote('quickicon')) + ->where($this->db->quoteName('element') . ' = ' . $this->db->quote('eos310')); + + try + { + // Lock the tables to prevent multiple plugin executions causing a race condition + $this->db->lockTable('#__extensions'); + } + catch (Exception $e) + { + // If we can't lock the tables it's too risky to continue execution + return false; + } + + try + { + // Update the plugin parameters + $result = $this->db->setQuery($query)->execute(); + + $this->clearCacheGroups(array('com_plugins'), array(0, 1)); + } + catch (Exception $exc) + { + // If we failed to execute + $this->db->unlockTables(); + + $result = false; + } + + try + { + // Unlock the tables after writing + $this->db->unlockTables(); + } + catch (Exception $e) + { + // If we can't lock the tables assume we have somehow failed + $result = false; + } + + return $result; + } + + /** + * 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 + * @param array $cacheClients The cache clients (site, admin) to clean + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function clearCacheGroups(array $clearGroups, array $cacheClients = array(0, 1)) + { + foreach ($clearGroups as $group) + { + foreach ($cacheClients as $client_id) + { + try + { + $options = array( + 'defaultgroup' => $group, + 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $this->app->get('cache_path', JPATH_SITE . '/cache') + ); + + $cache = JCache::getInstance('callback', $options); + $cache->clean(); + } + catch (Exception $e) + { + // Ignore it + } + } + } + } +} diff --git a/plugins/quickicon/eos310/eos310.xml b/plugins/quickicon/eos310/eos310.xml new file mode 100644 index 0000000000000..e9ee670324a1e --- /dev/null +++ b/plugins/quickicon/eos310/eos310.xml @@ -0,0 +1,29 @@ + + + plg_quickicon_eos310 + Joomla! Project + June 2021 + (C) 2021 Open Source Matters, Inc. + GNU General Public License version 2 or later; see LICENSE.txt + admin@joomla.org + www.joomla.org + __DEPLOY_VERSION__ + PLG_QUICKICON_EOS310_XML_DESCRIPTION + + eos310.php + + + en-GB.plg_quickicon_eos310.ini + en-GB.plg_quickicon_eos310.sys.ini + + + +
+ +
+
+
+