diff --git a/config/migrations/007_add_tick_delete_hours_settings_column.sql b/config/migrations/007_add_tick_delete_hours_settings_column.sql
new file mode 100644
index 0000000..479bae0
--- /dev/null
+++ b/config/migrations/007_add_tick_delete_hours_settings_column.sql
@@ -0,0 +1,2 @@
+ALTER TABLE settings
+ADD COLUMN tick_delete_hours INTEGER NULL;
\ No newline at end of file
diff --git a/public/index.php b/public/index.php
index 8214dee..eb1a8a0 100644
--- a/public/index.php
+++ b/public/index.php
@@ -42,6 +42,12 @@ if (!$prerequisites->validateApplication()) {
// Get the working database connection from prerequisites
$db = $prerequisites->getDatabase();
+// Apply any pending database migrations
+if (!$prerequisites->applyMigrations($db)){
+ $prerequisites->generateWebSummary();
+ exit;
+}
+
// Check if setup is complete (user exists and URL is configured)
if (!(preg_match('/tkr-setup$/', $path))) {
try {
diff --git a/src/Controller/AdminController/AdminController.php b/src/Controller/AdminController/AdminController.php
index 91d0fad..05fe63a 100644
--- a/src/Controller/AdminController/AdminController.php
+++ b/src/Controller/AdminController/AdminController.php
@@ -91,6 +91,7 @@ class AdminController extends Controller {
$itemsPerPage = (int) ($postData['items_per_page'] ?? 25);
$strictAccessibility = isset($postData['strict_accessibility']);
$logLevel = (int) ($postData['log_level'] ?? 0);
+ $tickDeleteHours = (int) ($postData['tick_delete_hours'] ?? 1);
// Password
$password = $postData['password'] ?? '';
@@ -152,6 +153,7 @@ class AdminController extends Controller {
$app['settings']->itemsPerPage = $itemsPerPage;
$app['settings']->strictAccessibility = $strictAccessibility;
$app['settings']->logLevel = $logLevel;
+ $app['settings']->tickDeleteHours = $tickDeleteHours;
// Save site settings and reload config from database
$app['settings'] = $app['settings']->save();
diff --git a/src/Framework/Prerequisites/Prerequisites.php b/src/Framework/Prerequisites/Prerequisites.php
index 181c945..27b31d9 100644
--- a/src/Framework/Prerequisites/Prerequisites.php
+++ b/src/Framework/Prerequisites/Prerequisites.php
@@ -442,7 +442,7 @@ class Prerequisites {
}
}
- private function applyMigrations($db) {
+ public function applyMigrations($db) {
try {
$migrator = new Migrator($db);
$migrator->migrate();
diff --git a/src/Model/SettingsModel/SettingsModel.php b/src/Model/SettingsModel/SettingsModel.php
index a9b714b..2a6bfc7 100644
--- a/src/Model/SettingsModel/SettingsModel.php
+++ b/src/Model/SettingsModel/SettingsModel.php
@@ -12,8 +12,7 @@ class SettingsModel {
public ?int $cssId = null;
public bool $strictAccessibility = true;
public ?int $logLevel = null;
- // not currently configurable
- public int $tickDeleteHours = 1;
+ public ?int $tickDeleteHours = null;
public function __construct(private PDO $db) {}
@@ -28,7 +27,8 @@ class SettingsModel {
items_per_page,
css_id,
strict_accessibility,
- log_level
+ log_level,
+ tick_delete_hours
FROM settings WHERE id=1");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -41,7 +41,8 @@ class SettingsModel {
$c->itemsPerPage = (int) $row['items_per_page'];
$c->cssId = (int) $row['css_id'];
$c->strictAccessibility = (bool) $row['strict_accessibility'];
- $c->logLevel = $row['log_level'];
+ $c->logLevel = (int) ($row['log_level'] ?? 2);
+ $c->tickDeleteHours = (int) ($row['tick_delete_hours'] ?? 1);
}
return $c;
@@ -51,6 +52,7 @@ class SettingsModel {
$settingsCount = (int) $this->db->query("SELECT COUNT(*) FROM settings")->fetchColumn();
if ($settingsCount === 0){
+ Log::debug('Initializing settings');
$stmt = $this->db->prepare("INSERT INTO settings (
id,
site_title,
@@ -60,10 +62,12 @@ class SettingsModel {
items_per_page,
css_id,
strict_accessibility,
- log_level
+ log_level,
+ tick_delete_hours
)
- VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?)");
+ VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
} else {
+ Log::debug('Updating settings');
$stmt = $this->db->prepare("UPDATE settings SET
site_title=?,
site_description=?,
@@ -72,10 +76,21 @@ class SettingsModel {
items_per_page=?,
css_id=?,
strict_accessibility=?,
- log_level=?
+ log_level=?,
+ tick_delete_hours=?
WHERE id=1");
}
+ Log::debug("Site title: " . $this->siteTitle);
+ Log::debug("Site description: " . $this->siteDescription);
+ Log::debug("Base URL: " . $this->baseUrl);
+ Log::debug("Base path: " . $this->basePath);
+ Log::debug("Items per page: " . $this->itemsPerPage);
+ Log::debug("CSS ID: " . $this->cssId);
+ Log::debug("Strict accessibility: " . $this->strictAccessibility);
+ Log::debug("Log level: " . $this->logLevel);
+ Log::debug("Tick delete window: " . $this->tickDeleteHours);
+
$stmt->execute([$this->siteTitle,
$this->siteDescription,
$this->baseUrl,
@@ -83,7 +98,8 @@ class SettingsModel {
$this->itemsPerPage,
$this->cssId,
$this->strictAccessibility,
- $this->logLevel
+ $this->logLevel,
+ $this->tickDeleteHours
]);
return $this->get();
diff --git a/templates/partials/admin.php b/templates/partials/admin.php
index 557470b..387ffe0 100644
--- a/templates/partials/admin.php
+++ b/templates/partials/admin.php
@@ -61,13 +61,18 @@
name="items_per_page"
value="= $settings->itemsPerPage ?>" min="1" max="50"
required>
+
+
strictAccessibility): ?> checked >
-
+