From 8945dff16e2e6208051bae25617c9f76d62a8e0b Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 26 Dec 2024 20:18:57 +0100 Subject: Automatically subscribe to topic when creating it --- src/application/actions/newtopic/post.php | 7 +++++++ src/application/appdef.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/application') diff --git a/src/application/actions/newtopic/post.php b/src/application/actions/newtopic/post.php index ca79599..79110eb 100644 --- a/src/application/actions/newtopic/post.php +++ b/src/application/actions/newtopic/post.php @@ -2,6 +2,7 @@ use mystic\forum\orm\Attachment; use mystic\forum\orm\Post; +use mystic\forum\orm\Subscription; use mystic\forum\orm\Topic; use mystic\forum\utils\RequestUtils; @@ -65,4 +66,10 @@ foreach ($attachments as $att) { $db->insert($attachment); } +$subscription = new Subscription(); +$subscription->id = $db->generateId(); +$subscription->userId = $currentUser->id; +$subscription->topicId = $topic->id; +$db->insert($subscription); + header("Location: ?_action=viewtopic&topic=" . urlencode($topic->id)); diff --git a/src/application/appdef.php b/src/application/appdef.php index d623cd1..1e36a07 100644 --- a/src/application/appdef.php +++ b/src/application/appdef.php @@ -1,3 +1,3 @@