feat: auto-create default scheduled task on install, fix AkeebaImporter constants
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
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (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
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
- Create "Monthly Full Backup" scheduled task (30-day interval, profile 1, 03:00 execution) on fresh install via com_scheduler - Skips if any MokoJoomBackup task already exists - Failure notifications enabled to Super Users group by default - Replace hardcoded backup dir paths in AkeebaImporter with BackupDirectory::DEFAULT_RELATIVE constant
This commit is contained in:
@@ -211,6 +211,9 @@ class Pkg_MokoJoomBackupInstallerScript
|
||||
file_put_contents($index, '<!DOCTYPE html><title></title>');
|
||||
}
|
||||
}
|
||||
|
||||
// Create default scheduled task — every 30 days, profile 1
|
||||
$this->createDefaultScheduledTask();
|
||||
}
|
||||
|
||||
if ($type === 'uninstall') {
|
||||
@@ -270,6 +273,66 @@ class Pkg_MokoJoomBackupInstallerScript
|
||||
}
|
||||
}
|
||||
|
||||
private function createDefaultScheduledTask(): void
|
||||
{
|
||||
try {
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Check if a MokoJoomBackup task already exists
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__scheduler_tasks'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('mokojoombackup.run_profile'));
|
||||
$db->setQuery($query);
|
||||
|
||||
if ((int) $db->loadResult() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
$task = (object) [
|
||||
'title' => 'MokoJoomBackup — Monthly Full Backup',
|
||||
'type' => 'mokojoombackup.run_profile',
|
||||
'execution_rules' => json_encode([
|
||||
'rule-type' => 'interval-days',
|
||||
'interval-days' => '30',
|
||||
'exec-day' => '1',
|
||||
'exec-time' => '03:00:00',
|
||||
]),
|
||||
'cron_rules' => json_encode([
|
||||
'type' => 'interval',
|
||||
'exp' => 'P30D',
|
||||
]),
|
||||
'state' => 1,
|
||||
'params' => json_encode([
|
||||
'profile_id' => 1,
|
||||
'individual_log' => true,
|
||||
'log_file' => '',
|
||||
'notifications' => [
|
||||
'success_mail' => '0',
|
||||
'failure_mail' => '1',
|
||||
'notification_failure_groups' => ['8'],
|
||||
'fatal_failure_mail' => '1',
|
||||
'notification_fatal_groups' => ['8'],
|
||||
'orphan_mail' => '0',
|
||||
],
|
||||
]),
|
||||
'priority' => 0,
|
||||
'ordering' => 0,
|
||||
'cli_exclusive' => 0,
|
||||
'note' => '',
|
||||
'created' => $now,
|
||||
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
||||
'next_execution' => date('Y-m-d 03:00:00', strtotime('+1 day')),
|
||||
];
|
||||
|
||||
$db->insertObject('#__scheduler_tasks', $task);
|
||||
} catch (\Throwable $e) {
|
||||
error_log('MokoJoomBackup: createDefaultScheduledTask() failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function syncMenuIcons(): void
|
||||
{
|
||||
$iconMap = [
|
||||
|
||||
Reference in New Issue
Block a user