Add NFC chore submission feature and enhance family settings
- Introduced NFC support for chore submissions, allowing specific person credit after Head of Household approval. - Updated family settings to include NFC base URL, scan cooldown, and confirmation page options. - Enhanced chore management with options for anyone to complete chores and NFC link generation. - Improved API endpoints for handling NFC tokens and chore submissions. - Updated readme to reflect new NFC features and settings.
This commit is contained in:
@@ -34,6 +34,9 @@ function familySettingsDefaultsRaw(): array {
|
||||
'week_starts_on' => 0,
|
||||
'calendar_two_way_google' => false,
|
||||
'calendar_bill_days' => [],
|
||||
'nfc_base_url' => '',
|
||||
'nfc_show_confirmation' => true,
|
||||
'nfc_scan_cooldown_seconds' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -80,6 +83,11 @@ function normalizeLoadedFamilySettings(array $s): array {
|
||||
$v = $s['calendar_two_way_google'] ?? false;
|
||||
$s['calendar_two_way_google'] = $v === true || $v === 1 || $v === '1' || $v === 'true';
|
||||
$s['calendar_bill_days'] = normalizeCalendarBillDaysRaw($s['calendar_bill_days'] ?? []);
|
||||
$s['nfc_base_url'] = trim((string) ($s['nfc_base_url'] ?? ''));
|
||||
$showConfirmation = $s['nfc_show_confirmation'] ?? true;
|
||||
$s['nfc_show_confirmation'] = $showConfirmation === true || $showConfirmation === 1 || $showConfirmation === '1' || $showConfirmation === 'true';
|
||||
$cooldown = (int) ($s['nfc_scan_cooldown_seconds'] ?? 0);
|
||||
$s['nfc_scan_cooldown_seconds'] = max(0, min(600, $cooldown));
|
||||
return $s;
|
||||
}
|
||||
|
||||
@@ -96,6 +104,28 @@ function loadFamilySettings(): array {
|
||||
return normalizeLoadedFamilySettings($merged);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base app URL (without trailing slash) used for externally shared links.
|
||||
*/
|
||||
function familyHubAppUrl(array $familySettings): string {
|
||||
$base = trim((string) ($familySettings['nfc_base_url'] ?? ''));
|
||||
if ($base !== '') {
|
||||
return rtrim($base, '/');
|
||||
}
|
||||
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
|
||||
$scheme = $https ? 'https' : 'http';
|
||||
$host = trim((string) ($_SERVER['HTTP_HOST'] ?? 'localhost'));
|
||||
$script = trim((string) ($_SERVER['SCRIPT_NAME'] ?? '/index.php'));
|
||||
$dir = rtrim(str_replace('\\', '/', dirname($script)), '/');
|
||||
if ($dir === '' || $dir === '.') {
|
||||
$dir = '';
|
||||
}
|
||||
if (substr($dir, -4) === '/api') {
|
||||
$dir = substr($dir, 0, -4);
|
||||
}
|
||||
return $scheme . '://' . $host . $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab label: symbol + name (e.g. "★ Stars").
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user