Files
itflow/admin/settings_module.php
johnnyq 3b5c11c552 Add managed mode, so one ITFlow can manage others - Admin > Managed Instances adds an instance and gives a one-time connection code (a week) that the other ITFlow pastes into the new Admin > Managed By, after which it checks in every minute from the new Manager Check-in cron job with a health report (versions, update waiting and whether it has security fixes, cron, last backup, errors today, agents against the seat limit, clients, storage) and takes back what the manager sets; the manager lists each instance's version, health, seats and last check-in with a page per instance showing what needs a look, its requests and everything it reported, can update it by hand or automatically after a set number of days (security releases straight away, not retried for six hours after a failure), set its seat limit and white-label key (locked on the instance while set), make it read-only (look, export and download only, across agents, portal, guest links and the API) or suspended (a notice with the manager's message and contact, 503 for the API) with other cron jobs paused until it is active again, sign in to it as support through a signed one-time two-minute link into a two-hour session that takes no seat, can't open the vault and can't set passwords or make API keys, and remove it, while the new Managed Instances job notifies when one stops checking in and closes requests never answered; instances only call the manager, can disconnect unless config.php sets $config_manager_required, and the Update page and queue_update defer to the manager; database 3.5.8 adds managed_instances, managed_instance_commands, settings.config_manager_keys and settings.config_managed, the logic is in the new functions/managed.php with api/managed/enroll.php, api/managed/checkin.php, login_support.php and includes/managed_blocked.php, cronJobClaim() takes a paused reason that leaves a due job due, getAgentUserLimit() and getActiveAgentUserCount() honour the manager's limit and leave out the support user, the vault helpers read a missing session key as empty, the audit log knows the new types and actions, and the email parser no longer logs an App Logs error every minute while parsing is switched off; changelog updated
2026-11-05 15:22:41 -05:00

82 lines
4.9 KiB
PHP

<?php
/*
* Admin > Settings > Modules - the parts of ITFlow in use: IT documentation,
* ticketing, invoicing and the client portal, each switched off hiding it
* (nothing is deleted); and white-labelling the client portal with a key.
* Saved by edit_module_settings (admin/post/settings_module.php).
*/
require_once "includes/inc_all_admin.php";
// The white-label key as it stands - good, in its week's grace after it ran out, or not a key
$whitelabel_key = trim((string) $config_whitelabel_key);
$whitelabel = $whitelabel_key !== '' ? validateWhitelabelKey($whitelabel_key) : false;
$whitelabel_expires = $whitelabel ? strtotime((string) $whitelabel['expires']) : 0;
// A managed instance whose manager sets the key - shown, not changed here (functions/managed.php)
$whitelabel_managed = managedLocks()['white_label'];
$modules = [
'config_module_enable_itdoc' => [$config_module_enable_itdoc, 'fa-laptop', 'A client\'s assets, credentials, documents, networks, domains, certificates and the rest of their IT documentation.'],
'config_module_enable_ticketing' => [$config_module_enable_ticketing, 'fa-life-ring', 'Tickets, recurring tickets and projects - and their settings.'],
'config_module_enable_accounting' => [$config_module_enable_accounting, 'fa-file-invoice-dollar', 'Quotes, invoices, payments, expenses, accounts and the money reports - and their settings.'],
'config_client_portal_enable' => [$config_client_portal_enable, 'fa-user-shield', 'Where your clients\' contacts sign in to raise tickets, see their invoices and pay.'],
];
echo settingsPageStart('module');
?>
<form action="post.php" method="post" autocomplete="off" data-settings-form>
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="card itflow-settings-card">
<div class="card-body">
<?= settingsSectionStart('modules', 'Modules', 'Switching one off takes it out of the menus for everyone. Nothing in it is deleted - switched back on, it is all there.') ?>
<?php foreach ($modules as $name => [$on, $icon, $about]) { ?>
<div class="itflow-settings-module d-flex gap-3 align-items-start">
<span class="itflow-settings-tile-icon"><i class="fas fa-fw <?= $icon ?>"></i></span>
<div class="flex-grow-1 min-w-0">
<?= settingsSwitch($name, $on, ['help' => $about]) ?>
</div>
</div>
<?php } ?>
<?= settingsSectionEnd() ?>
<?= settingsSectionStart('whitelabel', 'White-label', 'A key from the ITFlow project takes "Powered by ITFlow" off the sign-in page, the client portal, shared links and client exports.') ?>
<?php if ($whitelabel && $whitelabel_expires >= time()) { ?>
<div class="alert alert-success d-flex gap-2 py-2" data-whitelabel-state="active">
<i class="fas fa-check-circle mt-1"></i>
<div>
<strong>White-labelled - thank you for supporting ITFlow.</strong>
<div class="small"><?= escapeHtml((string) ($whitelabel['description'] ?? '')) ?> · <?= escapeHtml((string) ($whitelabel['organisation'] ?? '')) ?> · until <?= escapeHtml(date('M j, Y', $whitelabel_expires)) ?></div>
</div>
</div>
<?php } elseif ($whitelabel) { ?>
<div class="alert alert-warning d-flex gap-2 py-2" data-whitelabel-state="grace">
<i class="fas fa-exclamation-triangle mt-1"></i>
<div><strong>The key ran out on <?= escapeHtml(date('M j, Y', $whitelabel_expires)) ?>.</strong> White-labelling stops a week after - put a new key in to keep it.</div>
</div>
<?php } elseif ($whitelabel_key !== '') { ?>
<div class="alert alert-secondary d-flex gap-2 py-2" data-whitelabel-state="expired">
<i class="fas fa-info-circle mt-1"></i>
<div>The key below has run out, so "Powered by ITFlow" is back.</div>
</div>
<?php } ?>
<?php if ($whitelabel_managed) { ?>
<p class="small text-body-secondary mb-0" data-whitelabel-state="managed"><i class="fas fa-fw fa-lock me-1"></i>The key is set by <strong><?= escapeHtml(managedManagerName()) ?></strong>, who manages this ITFlow - it can't be changed here.</p>
<?php } else { ?>
<?= settingsTextarea('config_whitelabel_key', $whitelabel_key, ['rows' => 3, 'placeholder' => 'Paste the key here', 'help' => 'Left empty, "Powered by ITFlow" shows.']) ?>
<?php } ?>
<?= settingsSectionEnd() ?>
<?= settingsSaveBar('edit_module_settings') ?>
</div>
</div>
</form>
<?php
require_once "../includes/footer.php";