4b9a675d0f
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Generic: Project CI / Lint & Validate (push) Successful in 36s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 40s
Generic: Project CI / Tests (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
All Joomla element names, PHP classes, language files, folder structure, and manifest references renamed from mokosuite to mokosuiteclient. This repo is now the client-facing tracker for the MokoSuite platform.
97 lines
2.0 KiB
PHP
97 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* @package MokoSuiteClient
|
|
* @subpackage plg_system_mokosuiteclient
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
*/
|
|
|
|
namespace Moko\Plugin\System\MokoSuiteClient\Helper;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\Plugin\PluginHelper;
|
|
use Joomla\Registry\Registry;
|
|
|
|
/**
|
|
* Shared utility class for MokoSuiteClient feature plugins.
|
|
*
|
|
* Provides master-user detection and core plugin parameter access
|
|
* so that feature plugins do not need to duplicate obfuscated constants.
|
|
*
|
|
* @since 02.32.00
|
|
*/
|
|
final class MokoSuiteClientHelper
|
|
{
|
|
private const MASTER_KEYS = ['NzUxNTk1NCkvNi4zND0='];
|
|
private const MK = 0x5A;
|
|
|
|
/** @var array|null Decoded master usernames cache. */
|
|
private static ?array $masterNames = null;
|
|
|
|
/**
|
|
* Check whether the current user is a master user.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function isMasterUser(): bool
|
|
{
|
|
$user = Factory::getApplication()->getIdentity();
|
|
|
|
if (!$user || $user->guest)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return \in_array($user->username, self::getMasterUsernames(), true);
|
|
}
|
|
|
|
/**
|
|
* Get the decoded list of master usernames.
|
|
*
|
|
* @return array
|
|
*/
|
|
private static function getMasterUsernames(): array
|
|
{
|
|
if (self::$masterNames !== null)
|
|
{
|
|
return self::$masterNames;
|
|
}
|
|
|
|
self::$masterNames = [];
|
|
|
|
foreach (self::MASTER_KEYS as $encoded)
|
|
{
|
|
$raw = base64_decode($encoded);
|
|
$decoded = '';
|
|
|
|
for ($i = 0, $len = \strlen($raw); $i < $len; $i++)
|
|
{
|
|
$decoded .= \chr(\ord($raw[$i]) ^ self::MK);
|
|
}
|
|
|
|
self::$masterNames[] = $decoded;
|
|
}
|
|
|
|
return self::$masterNames;
|
|
}
|
|
|
|
/**
|
|
* Get the core system plugin parameters as a Registry.
|
|
*
|
|
* @return Registry
|
|
*/
|
|
public static function getCoreParams(): Registry
|
|
{
|
|
$plugin = PluginHelper::getPlugin('system', 'mokosuiteclient');
|
|
|
|
if (!$plugin)
|
|
{
|
|
return new Registry();
|
|
}
|
|
|
|
return new Registry($plugin->params ?? '{}');
|
|
}
|
|
}
|