$record) { $rid = tgid_record_id($record); if ($action === 'edit' && $rid === $orig) { continue; } if ($rid === $id) { $dup = true; break; } } if ($dup) { $msg = 'Talkgroup already exists.'; } elseif ($action === 'add') { $records[] = tgid_new_record($id, $callsign); if (!tgid_save($records, $tg)) { $msg = 'Save failed.'; } else { header('Location: tgmanager.php'); exit; } } else { $found = false; foreach ($records as $i => $record) { if (tgid_record_id($record) === $orig) { $records[$i] = tgid_apply_record($record, $id, $callsign); $found = true; break; } } if (!$found) { $msg = 'Talkgroup not found.'; } elseif (!tgid_save($records, $tg)) { $msg = 'Save failed.'; } else { header('Location: tgmanager.php'); exit; } } } if ($action === 'edit') { $edit_id = $orig ? $orig : $id; } } elseif ($action === 'delete') { $id = isset($_POST['id']) ? intval($_POST['id']) : 0; $next = array(); foreach ($records as $record) { if (tgid_record_id($record) !== $id) { $next[] = $record; } } if (count($next) === count($records)) { $msg = 'Talkgroup not found.'; } elseif (!tgid_save($next, $tg)) { $msg = 'Save failed.'; } else { header('Location: tgmanager.php'); exit; } } } } $logged_in = tgmanager_logged_in(); if (!$logged_in && $msg === '' && !tgmanager_has_users()) { $msg = 'No users configured.'; } $csrf = htmlspecialchars(tgmanager_csrf_token()); $tg = tgid_load(true); $edit_name = ''; if ($edit_id > 0) { $found = false; foreach ($tg['records'] as $record) { if (tgid_record_id($record) === $edit_id) { $edit_name = tgid_record_callsign($record); $found = true; break; } } if (!$found) { $edit_id = 0; } } ?>
true)); ?>Dashboard Version: