From 5d0d006ccde901dcafb633236ce53ecb02f47bc5 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:39:08 -0500 Subject: [PATCH] feat: email notification on install/update, allow super user uninstall - Send email to webmaster@mokoconsulting.tech on every install/update with site name, version, PHP, Joomla version - Changed locked=0 (allows uninstall by super users) but kept protected=1 (prevents disabling) Co-Authored-By: Claude Opus 4.6 (1M context) --- src/script.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/script.php b/src/script.php index 8666e90b..b324b4ba 100644 --- a/src/script.php +++ b/src/script.php @@ -128,6 +128,7 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface $this->updateLoginSupportUrls(); $this->updateAtumBranding(); $this->registerActionLogExtension(); + $this->sendInstallNotification($type); } return true; @@ -195,7 +196,7 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface $db->getQuery(true) ->update($db->quoteName('#__extensions')) ->set($db->quoteName('enabled') . ' = 1') - ->set($db->quoteName('locked') . ' = 1') + ->set($db->quoteName('locked') . ' = 0') ->set($db->quoteName('protected') . ' = 1') ->where($db->quoteName('element') . ' = ' . $db->quote('mokowaas')) @@ -388,6 +389,56 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface * * @since 02.01.01 */ + /** + * Send email notification on install or update. + * + * @param string $type install or update + * + * @return void + * + * @since 02.01.02 + */ + private function sendInstallNotification($type) + { + try + { + $config = Factory::getApplication()->getConfig(); + $siteName = $config->get('sitename', 'Joomla Site'); + $siteUrl = \Joomla\CMS\Uri\Uri::root(); + $version = '02.01.02'; + + $mailer = Factory::getMailer(); + $mailer->addRecipient('webmaster@mokoconsulting.tech'); + $mailer->setSubject( + sprintf('[%s] MokoWaaS %s — %s', + $siteName, $type, $version) + ); + $mailer->setBody( + sprintf( + "MokoWaaS plugin was %sd on %s\n\n" + . "Version: %s\n" + . "Site: %s\n" + . "Time: %s\n" + . "PHP: %s\n" + . "Joomla: %s\n", + $type, + $siteName, + $version, + $siteUrl, + date('Y-m-d H:i:s T'), + PHP_VERSION, + JVERSION + ) + ); + $mailer->isHtml(false); + $mailer->Send(); + } + catch (\Exception $e) + { + // Don't break install if email fails + } + } + private function getDownloadUrlFromUpdates($updatesUrl) { try