From 79ac068bc44f299f2593120b3cd7d67cf35fb88f Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 4 Jun 2026 14:04:02 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20MokoWaaS=20guided=20tours=20=E2=80=94?= =?UTF-8?q?=20hijack=20Joomla's=20system,=20rebrand=20to=20MokoWaaS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Unpublish all default Joomla guided tours (joomla-* UIDs) - Create 4 MokoWaaS tours: Welcome, Firewall Setup, Helpdesk, Extensions - Re-enable mod_guidedtours with title "MokoWaaS Tours" - Add language override MOD_GUIDEDTOURS → "MokoWaaS Tours" - Re-enable guided tours plugin if disabled Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- src/script.php | 173 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/src/script.php b/src/script.php index c75c8044..941b3683 100644 --- a/src/script.php +++ b/src/script.php @@ -89,6 +89,9 @@ class Pkg_MokowaasInstallerScript // Set menu_icon params on submenu items (Joomla only renders img on level 1) $this->fixMenuIcons(); + // Set up MokoWaaS guided tours and unpublish Joomla defaults + $this->setupGuidedTours(); + // Mark MokoWaaS extensions as protected (prevents disable/uninstall at framework level) $this->protectExtensions(); @@ -1001,6 +1004,176 @@ class Pkg_MokowaasInstallerScript } } + /** + * Unpublish default Joomla guided tours and create MokoWaaS tours. + * Re-enables the guided tours plugin if disabled. + */ + private function setupGuidedTours(): void + { + try + { + $db = Factory::getDbo(); + + // Re-enable guided tours plugin (may have been disabled) + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__extensions')) + ->set($db->quoteName('enabled') . ' = 1') + ->where($db->quoteName('element') . ' = ' . $db->quote('guidedtours')) + ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')) + )->execute(); + + // Re-enable the guided tours module (shows our tours, not Joomla's) + $db->setQuery( + "UPDATE " . $db->quoteName('#__modules') + . " SET published = 1, title = 'MokoWaaS Tours'" + . " WHERE module = 'mod_guidedtours'" + ); + $db->execute(); + + // Override the guided tours module language string + $overridePath = JPATH_ADMINISTRATOR . '/language/overrides/en-GB.override.ini'; + $overrides = file_exists($overridePath) ? parse_ini_file($overridePath) : []; + + if (empty($overrides['MOD_GUIDEDTOURS'])) + { + $overrides['MOD_GUIDEDTOURS'] = 'MokoWaaS Tours'; + $overrides['MOD_GUIDEDTOURS_TITLE'] = 'MokoWaaS Tours'; + + $lines = []; + foreach ($overrides as $k => $v) + { + $lines[] = $k . '="' . str_replace('"', '\"', $v) . '"'; + } + file_put_contents($overridePath, implode("\n", $lines) . "\n"); + } + + // Unpublish all default Joomla tours + $db->setQuery( + "UPDATE " . $db->quoteName('#__guidedtours') + . " SET published = 0" + . " WHERE " . $db->quoteName('uid') . " LIKE 'joomla-%'" + ); + $db->execute(); + + // Define MokoWaaS tours + $tours = [ + [ + 'uid' => 'mokowaas-welcome', + 'title' => 'Welcome to MokoWaaS', + 'desc' => 'Get started with the MokoWaaS Admin Tools Suite. This tour shows you the key areas of your admin dashboard.', + 'url' => 'administrator/index.php?option=com_mokowaas', + 'steps' => [ + ['title' => 'MokoWaaS Dashboard', 'desc' => 'This is your MokoWaaS control center. You can see site info, feature plugins, WAF activity, and quick actions all in one place.', 'target' => '#mokowaas-dashboard', 'type' => 0], + ['title' => 'Site Information', 'desc' => 'The info bar shows your Joomla version, PHP version, database type, and debug/offline status at a glance.', 'target' => '.mokowaas-info-bar', 'type' => 0], + ['title' => 'Quick Actions', 'desc' => 'Use these buttons to clear cache, check updates, manage extensions, and perform common admin tasks with one click.', 'target' => '#mokowaas-btn-cache', 'type' => 0], + ['title' => 'Feature Plugins', 'desc' => 'MokoWaaS features are split into toggleable plugins. Enable or disable security, tenant restrictions, developer tools, and more from here.', 'target' => '.mokowaas-plugin-grid', 'type' => 0], + ['title' => 'MokoWaaS Menu', 'desc' => 'The MokoWaaS sidebar menu gives you quick access to all admin tools — Helpdesk, Extensions, WAF Log, Database Tools, and more.', 'target' => '.mokowaas-admin-menu, [class*="mokowaas"]', 'type' => 0], + ], + ], + [ + 'uid' => 'mokowaas-firewall', + 'title' => 'MokoWaaS Firewall Setup', + 'desc' => 'Configure the Web Application Firewall to protect your site from common attacks.', + 'url' => 'administrator/index.php?option=com_plugins&task=plugin.edit&filter[search]=mokowaas_firewall', + 'steps' => [ + ['title' => 'Firewall Plugin', 'desc' => 'The MokoWaaS Firewall provides 10 security shields including SQL injection, XSS, and malicious user agent detection.', 'target' => '', 'type' => 0], + ['title' => 'WAF Shields', 'desc' => 'Enable or disable individual WAF shields. Each shield protects against a specific attack vector. All shields are enabled by default.', 'target' => '', 'type' => 0], + ['title' => 'Security Headers', 'desc' => 'Configure HTTP security headers like X-Frame-Options, Content-Security-Policy, and HSTS to harden your site against browser-based attacks.', 'target' => '', 'type' => 0], + ['title' => 'IP Blocklist', 'desc' => 'Block specific IP addresses, CIDR ranges, or wildcard patterns. The auto-ban feature automatically blocks IPs that trigger too many WAF alerts.', 'target' => '', 'type' => 0], + ], + ], + [ + 'uid' => 'mokowaas-helpdesk', + 'title' => 'MokoWaaS Helpdesk', + 'desc' => 'Learn how to manage support tickets, categories, and automation rules.', + 'url' => 'administrator/index.php?option=com_mokowaas&view=tickets', + 'steps' => [ + ['title' => 'Ticket List', 'desc' => 'View all support tickets with status, priority, SLA tracking, and assignment. Filter by status or search to find specific tickets.', 'target' => '', 'type' => 0], + ['title' => 'Create a Ticket', 'desc' => 'Click the New button to create a support ticket. Assign a category, priority, and optional SLA deadline.', 'target' => '', 'type' => 0], + ['title' => 'Ticket Automation', 'desc' => 'Set up automation rules that trigger on ticket events (new ticket, status change) or Joomla events (user login, registration). Automate assignment, notifications, and status changes.', 'target' => '', 'type' => 0], + ], + ], + [ + 'uid' => 'mokowaas-extensions', + 'title' => 'Moko Extensions Manager', + 'desc' => 'Browse and install Moko Consulting extensions from the built-in catalog.', + 'url' => 'administrator/index.php?option=com_mokowaas&view=extensions', + 'steps' => [ + ['title' => 'Extension Catalog', 'desc' => 'Browse all available Moko Consulting extensions. Each card shows the extension name, description, install status, and current version.', 'target' => '', 'type' => 0], + ['title' => 'Install Extensions', 'desc' => 'Click Install to add an extension from the Moko Consulting repository. Updates are handled through Joomla\'s standard update system.', 'target' => '', 'type' => 0], + ], + ], + ]; + + foreach ($tours as $tourDef) + { + // Check if tour already exists + $db->setQuery( + $db->getQuery(true) + ->select('id') + ->from($db->quoteName('#__guidedtours')) + ->where($db->quoteName('uid') . ' = ' . $db->quote($tourDef['uid'])) + ); + + if ($db->loadResult()) + { + continue; + } + + $tour = (object) [ + 'title' => $tourDef['title'], + 'uid' => $tourDef['uid'], + 'description' => $tourDef['desc'], + 'extensions' => '', + 'url' => $tourDef['url'], + 'created' => date('Y-m-d H:i:s'), + 'created_by' => 0, + 'modified' => date('Y-m-d H:i:s'), + 'modified_by' => 0, + 'published' => 1, + 'language' => '*', + 'note' => 'MokoWaaS', + 'access' => 3, + 'ordering' => 0, + 'autostart' => 0, + ]; + + $db->insertObject('#__guidedtours', $tour, 'id'); + $tourId = (int) $tour->id; + + foreach ($tourDef['steps'] as $i => $stepDef) + { + $step = (object) [ + 'tour_id' => $tourId, + 'title' => $stepDef['title'], + 'description' => $stepDef['desc'], + 'target' => $stepDef['target'], + 'type' => $stepDef['type'], + 'interactive_type' => 1, + 'url' => '', + 'position' => 'bottom', + 'ordering' => $i + 1, + 'published' => 1, + 'created' => date('Y-m-d H:i:s'), + 'created_by' => 0, + 'modified' => date('Y-m-d H:i:s'), + 'modified_by' => 0, + 'language' => '*', + 'note' => '', + 'params' => '{}', + ]; + + $db->insertObject('#__guidedtour_steps', $step, 'id'); + } + } + } + catch (\Throwable $e) + { + Log::add('Guided tours setup error: ' . $e->getMessage(), Log::WARNING, 'mokowaas'); + } + } + /** * Create a "Support" menu item on the frontend main menu. */