Cron leaves alone the jobs with nothing to do on an install: a job can declare not_in_use in includes/cron_jobs.php, the same check its script stops on, and cron.php skips it before its lock and claim unless it is asked to Run Now, registering its row the first time (cronJobRegister()); checks for AI Triage, Text Messages, RMM Sync, RMM Alerts, the Ticket Email Parser, Mail Queue, Payment Provider Fees, Update Check, Manager Check-in and Managed Instances; AI Triage no longer runs with triage off or no AI model (aiTriageNotInUse()); Maintenance > Cron shows them as Not in use with the reason, Cron Watch doesn't expect them to run, and CONTRIBUTING.md has the rule; 26.12.5 changelog

This commit is contained in:
johnnyq
2026-12-02 18:02:56 -05:00
parent bd38983abb
commit 9e74c0240a
8 changed files with 182 additions and 13 deletions

View File

@@ -10,11 +10,17 @@ Update from Maintenance > Update as usual. There are no database changes.
### New Features & Updates
- Cron leaves alone the jobs that have nothing to do on your ITFlow - what they work with is switched off or isn't set up: AI Triage, Text Messages, RMM Sync and RMM Alerts, the Ticket Email Parser with email to ticket off or no mailbox, the Mail Queue with no mail server, Payment Provider Fees without Stripe, the Update Check on an install that isn't a git checkout, and Manager Check-in and Managed Instances when there's nothing connected. Before, each one started every minute only to stop itself. Maintenance > Cron shows them as **Not in use**, with why under each; they start by themselves once that changes, and **Run Now** still runs them. Cron Watch doesn't email about them falling behind.
- An API / service account no longer takes a seat on the agent user limit - the one your hosting provider sets, or one set for your installation. Nobody signs in as it: it's the login an integration's API keys act as. You can add one, enable one or restore one when every seat is taken, and Admin > Users shows the seats without them. Turning one back into an agent who signs in takes a seat, so there has to be one free. A hosted instance's manager sees it the same way: its seats taken leave API accounts out, and its list of agents marks them.
### Bug Fixes
- AI Triage no longer runs every minute when AI triage is off in Settings > Tickets or there's no AI model to ask - before, it ran anyway and showed **Completed** every minute with nothing done.
### Developer Updates
- `getActiveAgentUserCount()` (`functions/app.php`) leaves out `users.user_service_account = 1` with `serviceAccountsOutSql()`, so `getAgentSeatsTaken()`, `agentUserLimitReached()` and the managed report's `agents.active` do too (the report's list still carries them, with `service` set). `admin/post/users.php` skips `agentUserLimitReached()` for an API / service account in `add_user`, `activate_user`, `restore_user` and `bulk_activate_users`, and `edit_user` refuses turning an active one into an agent at the limit before changing anything (`serviceAccountLeavingNeedsSeat()`, `functions/service_account.php`). Admin > Users keeps New User open at the limit when service accounts are available, and the New User window says one can still be added.
- Cron jobs can declare `'not_in_use' => function () { ... }` in `includes/cron_jobs.php`, returning why the job has nothing to do on this install or `''` (`cronJobNotInUse()`, which counts a check that throws as in use; `cronJobSettings()` reads the settings the checks need once a request). `cron/cron.php` reads every job's row and Run Now flag once a cycle and skips a job not in use before its lock and claim - registering its row the first time (`cronJobRegister()`, split out of `cronJobClaim()`) - unless it is asked to Run Now. `cronHealthJobs()` leaves such jobs out, so Cron Watch neither waits on nor flags them, and `admin/cron.php` shows them in a new `unused` state. Checks added for `manager_checkin`, `mail_queue`, `sms_queue`, `rmm_sync`, `rmm_alerts`, `ticket_email_parser`, `ai_triage`, `managed_instances`, `payment_provider_fees` and `update_check`, each the same condition its script stops on. `aiTriageNotInUse()` (`functions/ai_ticket.php`) is new, and `cron/ai_triage.php` now stops on it too. CONTRIBUTING.md has the rule.
## [26.12.4]

View File

@@ -108,6 +108,8 @@ A job can also ship switched off with `'enabled' => 0` in the registry. The row
### The master switch
A job whose work hangs on a feature that can be off or not set up - texting, an RMM provider, AI triage, a mailbox - declares `'not_in_use' => function () { ... }` in `includes/cron_jobs.php`, returning why it has nothing to do or `''` when it has. The dispatcher then doesn't lock, claim or load it at all, Maintenance > Cron shows it as **Not in use** with the reason, and Cron Watch doesn't expect it to run. Make it the same check the script stops on - cheap, and the database only, never the network - so leaving the job out never leaves its work undone; the script keeps its own check, for Run Now and for running it by hand.
`config_enable_cron` is a second, coarser switch that sits above the per-job ones. It is **not** enforced by the dispatcher — every job checks it in its own header and stops itself with `cronJobStop()`. A new job has to make that check too; one that skips it keeps running on an install that believes cron is off, which is exactly the trap `ticket_email_parser` and `ticket_sla` sat in until 26.08.
Be precise about what it does, because it is easy to oversell. It is **not** a guard on restored data: a full backup dumps the `settings` table, so a restored copy comes back with `config_enable_cron = 1` alongside every enabled `cron_jobs` row, exactly as production had them. What it gives you is one reversible bit — the fastest way to stop an install acting on live data once you have noticed, and the only way to stop everything without editing seven rows.

View File

@@ -74,7 +74,8 @@ while ($job_row = mysqli_fetch_assoc($sql)) {
* Each job the registry lists, with what its row says. How its last run went is one of:
* queued (Run now, not picked up yet), running, lost (still Running hours later - it was cut
* off, and nothing recorded how), completed, failed, skipped (it stopped itself early, and
* says why), paused (by a manager), never.
* says why), paused (by a manager), never - or unused: it has nothing to do here, its feature
* off or not set up, so cron leaves it alone until that changes (cronJobNotInUse()).
*/
$jobs = [];
foreach (cronJobRegistry() as $position => $entry) {
@@ -98,6 +99,7 @@ foreach (cronJobRegistry() as $position => $entry) {
'last_error' => trim((string) ($job_row['cron_job_last_error'] ?? '')),
'last_error_at' => $job_row['cron_job_last_error_at'] ?? null,
'reason' => '',
'not_in_use' => cronJobNotInUse($entry),
];
$job['schedule_text'] = cronJobScheduleDescription($job['schedule'], $job['interval_minutes'], $job['daily_at']);
$job['every_minute'] = $job['schedule'] !== 'Daily' && $job['interval_minutes'] === 1;
@@ -122,8 +124,14 @@ foreach (cronJobRegistry() as $position => $entry) {
}
}
// Nothing to do here - whatever its last run said, unless it's asked for or going now
if ($job['not_in_use'] !== '' && !in_array($job['state'], ['queued', 'running'], true)) {
$job['state'] = 'unused';
$job['reason'] = $job['not_in_use'];
}
// When it runs next - nothing to say while cron isn't running, is switched off, or holds this job back
$dispatched = $cron_heard && $cron_on && ($managed_mode === 'active' || in_array($job['name'], $managed_kept, true));
$dispatched = $cron_heard && $cron_on && $job['state'] !== 'unused' && ($managed_mode === 'active' || in_array($job['name'], $managed_kept, true));
$job['next_run'] = $job_row && $job['enabled'] && $dispatched ? cronJobNextRun($job_row) : null;
$jobs[$job['name']] = $job;
@@ -131,6 +139,8 @@ foreach (cronJobRegistry() as $position => $entry) {
$jobs_on = array_filter($jobs, function ($job) { return $job['enabled']; });
$jobs_off = count($jobs) - count($jobs_on);
// On, with nothing to do here yet
$jobs_unused = count(array_filter($jobs_on, function ($job) { return $job['state'] === 'unused'; }));
// Failed on its last run - with an error, or cut off without a word
$jobs_failed = array_filter($jobs, function ($job) { return in_array($job['state'], ['failed', 'lost'], true); });
// Failed before and has run since - its error stays until somebody dismisses it
@@ -223,7 +233,7 @@ $sort_keys = [
'schedule' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; },
'last_run' => function ($job) { return $job['last_run_at'] ? strtotime($job['last_run_at']) : 0; },
// What needs a look first
'status' => function ($job) { return array_search($job['state'], ['failed', 'lost', 'queued', 'running', 'paused', 'skipped', 'never', 'completed'], true); },
'status' => function ($job) { return array_search($job['state'], ['failed', 'lost', 'queued', 'running', 'paused', 'skipped', 'never', 'completed', 'unused'], true); },
];
if (!isset($sort_keys[$sort])) {
$sort = 'schedule';
@@ -247,6 +257,7 @@ $status_looks = [
'skipped' => ['label' => 'Skipped', 'tone' => 'secondary'],
'paused' => ['label' => 'Paused', 'tone' => 'warning'],
'never' => ['label' => 'Not run yet', 'tone' => 'secondary'],
'unused' => ['label' => 'Not in use', 'tone' => 'secondary', 'title' => "It has nothing to do here, so cron doesn't run it - it starts by itself once that changes. Run now still works."],
];
?>
@@ -299,7 +310,7 @@ $status_looks = [
<?php } else { ?>
<p class="mb-0 text-body-secondary">
It last ran <?= $ago($cron_last_dispatch_at) ?>. <?= count($jobs_on) ?> job<?= count($jobs_on) === 1 ? ' is' : 's are' ?> on<?= $jobs_off ? ", $jobs_off off" : '' ?>, and none failed on its last run.
It last ran <?= $ago($cron_last_dispatch_at) ?>. <?= count($jobs_on) ?> job<?= count($jobs_on) === 1 ? ' is' : 's are' ?> on<?= $jobs_unused ? " ($jobs_unused with nothing to do here yet)" : '' ?><?= $jobs_off ? ", $jobs_off off" : '' ?>, and none failed on its last run.
<?php if ($next_job) { ?>
Next is <?= $job_names([$next_job]) ?>, <?= $next_job['next_run'] <= date('Y-m-d H:i:s') ? 'within a minute' : $ago($next_job['next_run']) ?>.
<?php } ?>
@@ -352,7 +363,7 @@ $status_looks = [
<?php foreach ($jobs as $job) {
$look = $status_looks[$job['state']];
$failing = in_array($job['state'], ['failed', 'lost'], true);
$icon_tone = $failing ? 'bg-danger-subtle text-danger-emphasis' : ($job['enabled'] ? 'itflow-asset-tone-peripheral' : 'itflow-asset-tone-other opacity-50');
$icon_tone = $failing ? 'bg-danger-subtle text-danger-emphasis' : ($job['enabled'] && $job['state'] !== 'unused' ? 'itflow-asset-tone-peripheral' : 'itflow-asset-tone-other opacity-50');
// Why a skipped run was skipped - but not the switch, twelve times over, while the top of the page is saying it
$reason = $job['reason'] === 'Cron is switched off' && !$cron_on ? '' : $job['reason'];
?>
@@ -384,7 +395,7 @@ $status_looks = [
<?php } ?>
</td>
<td class="border-bottom-0 pt-3 pb-1">
<span class="badge rounded-pill bg-<?= $look['tone'] ?>-subtle text-<?= $look['tone'] ?>-emphasis"><?php if ($job['state'] === 'running') { ?><i class="fas fa-circle-notch fa-spin me-1"></i><?php } ?><?= escapeHtml($look['label']) ?></span>
<span class="badge rounded-pill bg-<?= $look['tone'] ?>-subtle text-<?= $look['tone'] ?>-emphasis"<?= isset($look['title']) ? ' title="' . escapeHtml($look['title']) . '"' : '' ?>><?php if ($job['state'] === 'running') { ?><i class="fas fa-circle-notch fa-spin me-1"></i><?php } ?><?= escapeHtml($look['label']) ?></span>
</td>
<td class="border-bottom-0 pt-3 pb-1 text-end pe-3">
<?php if ($job['id']) { ?>

View File

@@ -32,6 +32,12 @@ if (intval($row['config_enable_cron'] ?? 0) === 0) {
cronJobStop("Cron: is not enabled -- Quitting..");
}
// Triage off, or no AI model to ask - nothing to do (functions/ai_ticket.php)
$ai_triage_not_in_use = aiTriageNotInUse();
if ($ai_triage_not_in_use !== '') {
cronJobStop($ai_triage_not_in_use);
}
// Development mode: no AI calls on production's key, and no changes to the tickets (functions/dev_mode.php)
if (devModeOn()) {
cronJobStop("Development mode - AI Triage doesn't run");

View File

@@ -71,13 +71,13 @@ require_once "../includes/cron_jobs.php";
* With $paused (why), the job is not claimed: if it is due, its status says why it hasn't run,
* and it is left due - a Run Now request standing - so it runs as soon as it isn't paused.
*/
function cronJobClaim($mysqli, array $job, string $paused = ''): bool
/*
* Register the job the first time it is seen, seeded with the schedule it ships with. From here on
* the row is what runs - Maintenance > Cron writes to it.
*/
function cronJobRegister($mysqli, array $job): void
{
$name = escapeSql($job['name']);
$now = date('Y-m-d H:i:s');
// Register the job the first time it is seen, seeded with the schedule it ships with.
// From here on the row is what runs - Maintenance > Cron writes to it.
$default_schedule = escapeSql($job['schedule']);
$default_interval = intval($job['interval_minutes'] ?? 1);
$default_daily_at = isset($job['daily_at']) ? "'" . escapeSql($job['daily_at']) . ":00'" : 'NULL';
@@ -90,6 +90,14 @@ function cronJobClaim($mysqli, array $job, string $paused = ''): bool
cron_job_schedule = '$default_schedule',
cron_job_interval_minutes = $default_interval,
cron_job_daily_at = $default_daily_at");
}
function cronJobClaim($mysqli, array $job, string $paused = ''): bool
{
$name = escapeSql($job['name']);
$now = date('Y-m-d H:i:s');
cronJobRegister($mysqli, $job);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT cron_job_daily_at, cron_job_enabled, cron_job_interval_minutes, cron_job_schedule FROM cron_jobs WHERE cron_job_name = '$name' LIMIT 1"));
@@ -221,6 +229,17 @@ $cron_dispatch_started = null;
*/
$cron_dispatch_stop_cycle = false;
/*
* The jobs with a row, and those asked to Run Now - read once, for the jobs not in use: one of those
* isn't locked, claimed or loaded (includes/cron_jobs.php), only given its row the first time, so
* Maintenance > Cron can change it, and run when somebody asks.
*/
$cron_dispatch_rows = [];
$cron_dispatch_result = mysqli_query($mysqli, "SELECT cron_job_name, cron_job_run_now FROM cron_jobs");
while ($cron_dispatch_result && ($cron_dispatch_row = mysqli_fetch_assoc($cron_dispatch_result))) {
$cron_dispatch_rows[$cron_dispatch_row['cron_job_name']] = intval($cron_dispatch_row['cron_job_run_now']);
}
register_shutdown_function(function () use (&$cron_dispatch_running, &$cron_dispatch_started, $mysqli) {
if ($cron_dispatch_running === null) {
return;
@@ -243,6 +262,14 @@ foreach (cronJobRegistry() as $cron_dispatch_job) {
continue;
}
// Nothing to do here - its feature is off or not set up - so it isn't run at all, unless asked to
if (empty($cron_dispatch_rows[$cron_dispatch_job['name']]) && cronJobNotInUse($cron_dispatch_job) !== '') {
if (!isset($cron_dispatch_rows[$cron_dispatch_job['name']])) {
cronJobRegister($mysqli, $cron_dispatch_job);
}
continue;
}
// Locked before the schedule is consulted: if the previous run of this job is still
// going there is nothing to decide, and its claim already stands.
$cron_dispatch_lock = cronLockAcquire($cron_dispatch_path);

View File

@@ -335,6 +335,21 @@ function aiTriageMode() {
return max(0, min(2, intval($row[0] ?? 0)));
}
/*
* Why AI Triage has nothing to do here - it is off, or there is no AI model it could ask - or '' when it
* has. The cron job stops on it, and the dispatcher doesn't run the job at all while it says so
* (includes/cron_jobs.php).
*/
function aiTriageNotInUse() {
if (aiTriageMode() === 0) {
return 'AI triage is off in Settings > Tickets';
}
if (getAiModel('Tickets') === null) {
return 'No AI model to ask - add one in Admin > AI Models';
}
return '';
}
/* The ways new tickets can be triaged, for Settings > Tickets. */
function aiTriageModes() {
return [

View File

@@ -60,7 +60,8 @@ function cronHealthSaveState(array $state) {
/*
* The switched-on jobs cron is expected to run, with their rows: name => row + label.
* A job a manager has paused (a read-only or suspended managed instance) isn't expected to.
* A job a manager has paused (a read-only or suspended managed instance) isn't expected to,
* nor one with nothing to do here (cronJobNotInUse(), includes/cron_jobs.php).
*/
function cronHealthJobs() {
global $mysqli;
@@ -75,7 +76,7 @@ function cronHealthJobs() {
}
$jobs = [];
foreach (cronJobRegistry() as $entry) {
if (!isset($rows[$entry['name']]) || ($kept !== null && !in_array($entry['name'], $kept, true))) {
if (!isset($rows[$entry['name']]) || ($kept !== null && !in_array($entry['name'], $kept, true)) || cronJobNotInUse($entry) !== '') {
continue;
}
$jobs[$entry['name']] = $rows[$entry['name']] + ['label' => $entry['label']];

View File

@@ -29,6 +29,14 @@
* until somebody turns it on in Maintenance > Cron. Used for work an install should opt into
* rather than inherit from an upgrade, like the backup job filling a disk overnight.
*
* 'not_in_use' => function () { ... } says why the job has nothing to do on this install - its
* feature is off or not set up - or '' when it has (cronJobNotInUse()). The dispatcher doesn't run
* such a job at all: no lock, no claim, no script loaded and nothing written every minute, until
* the answer changes - a Run Now still runs it. Maintenance > Cron shows it as Not in use with the
* reason, and Cron Watch doesn't expect it to run. Make it the same check the job's script stops
* on, cheap and offline (the database, never the network), so nothing the job would have done is
* left undone.
*
* 'interval_safe' => false marks a job whose work repeats if the day repeats - nightly's
* late fees and overdue reminders fire again on a second run of the same day. Maintenance >
* Cron only offers the daily schedule for such a job, and the dispatcher refuses to run
@@ -73,6 +81,9 @@ function cronJobRegistry(): array
'description' => 'For an ITFlow managed by another (Admin > Managed By): reports how it is doing and takes what its manager sets. Stops straight away when it isn\'t managed.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
return managedIsManaged() ? '' : 'Not managed by another ITFlow';
},
],
[
'name' => 'mail_queue',
@@ -82,6 +93,13 @@ function cronJobRegistry(): array
'description' => 'Sends everything ITFlow has queued - invoices, quotes, ticket replies, notifications.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
// Development mode with no test inbox still cancels what's queued (cron/mail_queue.php)
if (trim((string) (cronJobSettings()['config_smtp_provider'] ?? '')) === '' && !(devModeOn() && devModeMailTo() === '')) {
return 'No mail server is set up to send through - Admin > Settings > Mail';
}
return '';
},
],
[
'name' => 'sms_queue',
@@ -91,6 +109,9 @@ function cronJobRegistry(): array
'description' => 'Sends the texts waiting to go, a second apart, texts reminders of visits and calls coming up, and tidies the text log - once texting is set up in Admin > Text Messaging.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
return smsProvider() ? '' : "Texting isn't set up - Admin > Text Messaging";
},
],
[
'name' => 'rmm_sync',
@@ -100,6 +121,14 @@ function cronJobRegistry(): array
'description' => 'Brings in the devices of the RMM clients linked in Admin > RMM Providers, and of the network platforms\' sites linked in Admin > Network Platforms, as assets, and keeps up whether each is online - once one is set up there.',
'schedule' => 'Interval',
'interval_minutes' => 15,
'not_in_use' => function () {
foreach (rmmProviders(true) as $provider) {
if (rmmProviderUsable($provider)) {
return '';
}
}
return 'No RMM provider or network platform is set up and on';
},
],
[
'name' => 'rmm_alerts',
@@ -109,6 +138,17 @@ function cronJobRegistry(): array
'description' => 'Opens a ticket for each new alert from an RMM provider whose alerts open tickets in Admin > RMM Providers, or for each device that goes offline on a network platform in Admin > Network Platforms, and resolves it when the alert clears.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
if (intval(cronJobSettings()['config_module_enable_ticketing'] ?? 0) === 0) {
return 'Ticketing is turned off';
}
foreach (rmmProviders(true) as $provider) {
if (rmmAlertsOn($provider)) {
return '';
}
}
return 'No RMM provider or network platform opens tickets for its alerts';
},
],
[
'name' => 'ticket_email_parser',
@@ -118,6 +158,16 @@ function cronJobRegistry(): array
'description' => 'Reads the support mailbox and turns incoming mail into tickets and replies.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
$settings = cronJobSettings();
if (intval($settings['config_ticket_email_parse'] ?? 0) === 0) {
return 'Email to ticket is off in Settings > Tickets';
}
if (trim((string) ($settings['config_imap_provider'] ?? '')) === '') {
return 'No mailbox is set up to read - Admin > Settings > Mail';
}
return '';
},
],
[
'name' => 'ticket_sla',
@@ -145,6 +195,9 @@ function cronJobRegistry(): array
'description' => 'Gives new tickets from email, the portal and the API a category and priority by AI, when Settings > Tickets says to. Up to 5 a run.',
'schedule' => 'Interval',
'interval_minutes' => 1,
'not_in_use' => function () {
return aiTriageNotInUse();
},
],
[
'name' => 'managed_instances',
@@ -154,6 +207,15 @@ function cronJobRegistry(): array
'description' => 'For an ITFlow that manages others (Admin > Managed Instances): notifies when one stops checking in, opens tickets for their problems when set to, and closes requests that were never answered.',
'schedule' => 'Interval',
'interval_minutes' => 5,
'not_in_use' => function () {
global $mysqli;
if (!settingsColumnExists($mysqli, 'config_manager_keys')) {
return '';
}
$connected = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM managed_instances
WHERE managed_instance_archived_at IS NULL AND managed_instance_secret_hash IS NOT NULL"))[0] ?? 0);
return $connected ? '' : 'No instances connected';
},
],
[
'name' => 'payment_provider_fees',
@@ -163,6 +225,10 @@ function cronJobRegistry(): array
'description' => 'Records what Stripe charged on each card payment as an expense, once Stripe has settled it - while Admin > Payment Providers records its fees.',
'schedule' => 'Interval',
'interval_minutes' => 15,
'not_in_use' => function () {
global $mysqli;
return mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM payment_providers WHERE payment_provider_name = 'Stripe' LIMIT 1")) ? '' : 'No Stripe payment provider - Admin > Payment Providers';
},
],
[
'name' => 'ticket_pictures',
@@ -220,6 +286,9 @@ function cronJobRegistry(): array
'description' => 'Asks the git remote whether a newer release exists and stores the answer for Maintenance > Update.',
'schedule' => 'Daily',
'daily_at' => '02:30',
'not_in_use' => function () {
return file_exists(dirname(__DIR__) . '/.git') ? '' : 'Not a git checkout - there is no remote to check against';
},
],
[
'name' => 'cron_watch',
@@ -328,3 +397,35 @@ function cronJobNextRun(array $row): ?string
return date('Y-m-d H:i:s', max($next, time()));
}
/*
* Why a job has nothing to do here - its 'not_in_use' answer - or '' when it has, or has no such
* check. A check that throws (a table the update hasn't made yet, say) counts as in use: the job runs
* and says for itself what's wrong.
*/
function cronJobNotInUse(array $job): string
{
if (!isset($job['not_in_use']) || !is_callable($job['not_in_use'])) {
return '';
}
try {
return trim((string) ($job['not_in_use'])());
} catch (Throwable $e) {
return '';
}
}
/*
* The settings the 'not_in_use' checks read, once a request - the dispatcher asks every minute, and
* cron reads none of config.php's globals for them.
*/
function cronJobSettings(): array
{
global $mysqli;
static $settings = null;
if ($settings === null) {
$settings = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_smtp_provider, config_imap_provider, config_ticket_email_parse,
config_module_enable_ticketing FROM settings WHERE company_id = 1")) ?: [];
}
return $settings;
}