id = $topicId; if (!$db->fetch($topic)) { http_response_code(404); msg_error(__("No topic exists with this id")); exit; } $subscription = new Subscription; $subscription->userId = $currentUser->id; $subscription->topicId = $topic->id; if ($db->fetchWhere($subscription, ["user_id", "topic_id"])) { $db->delete($subscription); } else { $subscription->id = $db->generateId(); $db->insert($subscription); } header("Location: ?_action=viewtopic&topic=" . urlencode($topic->id));