diff options
| author | Murtaza Sultani <sultani@data-quest.de> | 2026-01-15 17:10:04 +0100 |
|---|---|---|
| committer | Murtaza Sultani <sultani@data-quest.de> | 2026-01-15 17:10:04 +0100 |
| commit | c3e07e221b0bef64d3ad4da48c6371c75ca12cc3 (patch) | |
| tree | a2da9becb70c334b38cdf429f77257167d37993b /app | |
| parent | 083da68644d230b8a4b1d8201ed832a5206d3d5c (diff) | |
Resolve "Neues Forum Polishing", #6064, #6063, #6151
Closes #6165
Merge request studip/studip!4671
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/course/forum/categories.php | 22 | ||||
| -rw-r--r-- | app/controllers/course/forum/configs.php | 6 | ||||
| -rw-r--r-- | app/controllers/course/forum/discussion_types.php | 18 | ||||
| -rw-r--r-- | app/controllers/course/forum/discussions.php | 40 | ||||
| -rw-r--r-- | app/controllers/course/forum/recent.php | 6 | ||||
| -rw-r--r-- | app/controllers/course/forum/search.php | 8 | ||||
| -rw-r--r-- | app/controllers/course/forum/subscriptions.php | 4 | ||||
| -rw-r--r-- | app/controllers/course/forum/topics.php | 28 |
8 files changed, 63 insertions, 69 deletions
diff --git a/app/controllers/course/forum/categories.php b/app/controllers/course/forum/categories.php index df86089..ff1ddfa 100644 --- a/app/controllers/course/forum/categories.php +++ b/app/controllers/course/forum/categories.php @@ -4,7 +4,7 @@ use Forum\Category; class Course_Forum_CategoriesController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); @@ -15,19 +15,17 @@ class Course_Forum_CategoriesController extends Forum\BaseController } } - public function index_action() + public function index_action(): void { $this->render_vue_app( Studip\VueApp::create('forum/categories/Index') ); } - public function show_action($category_id) + public function show_action(Category $category): void { - $category = Category::find($category_id); - if (!$category) { - throw new AccessDeniedException(); + throw new NotFoundException(); } PageLayout::setTitle($category->name); @@ -45,7 +43,7 @@ class Course_Forum_CategoriesController extends Forum\BaseController ); } - public function edit_action($category_id = null) + public function edit_action($category_id = null): void { if (!$this->is_moderator) { throw new AccessDeniedException(); @@ -71,7 +69,7 @@ class Course_Forum_CategoriesController extends Forum\BaseController ); } - public function save_action($category_id = null) + public function save_action($category_id = null): void { if (!$this->is_moderator) { throw new AccessDeniedException(); @@ -100,16 +98,16 @@ class Course_Forum_CategoriesController extends Forum\BaseController $this->relocate('course/forum/categories'); } - public function delete_action($category_id) + public function delete_action(Category $category): void { + CSRFProtection::verifyUnsafeRequest(); + if (!$this->is_moderator) { throw new AccessDeniedException(); } - $category = Category::findOneBySQL("range_id = ? AND category_id = ?", [$this->range_id, $category_id]); - if (!$category) { - throw new AccessDeniedException(); + throw new NotFoundException(); } $category->delete(); diff --git a/app/controllers/course/forum/configs.php b/app/controllers/course/forum/configs.php index a065a6a..03c0951 100644 --- a/app/controllers/course/forum/configs.php +++ b/app/controllers/course/forum/configs.php @@ -2,7 +2,7 @@ class Course_Forum_ConfigsController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); @@ -15,7 +15,7 @@ class Course_Forum_ConfigsController extends Forum\BaseController } } - public function edit_action() + public function edit_action(): void { $config = Context::get()->getConfiguration(); @@ -30,7 +30,7 @@ class Course_Forum_ConfigsController extends Forum\BaseController ); } - public function save_action() + public function save_action(): void { CSRFProtection::verifyUnsafeRequest(); diff --git a/app/controllers/course/forum/discussion_types.php b/app/controllers/course/forum/discussion_types.php index bdfd480..0f0f772 100644 --- a/app/controllers/course/forum/discussion_types.php +++ b/app/controllers/course/forum/discussion_types.php @@ -24,16 +24,16 @@ class Course_Forum_DiscussionTypesController extends AuthenticatedController Sidebar::Get()->addWidget($actions); } - public function index_action() + public function index_action(): void { $this->render_vue_app( Studip\VueApp::create('forum/discussions_types/Index') ); } - public function edit_action(?DiscussionType $discussion_type = null) + public function edit_action(?DiscussionType $discussionType = null): void { - if ($discussion_type->isNew()) { + if ($discussionType->isNew()) { PageLayout::setTitle(_('Neuen Diskussionstyp anlegen')); } else { PageLayout::setTitle(_('Diskussionstyp bearbeiten')); @@ -56,21 +56,21 @@ class Course_Forum_DiscussionTypesController extends AuthenticatedController Studip\VueApp::create('forum/discussions_types/Edit') ->withProps([ 'icons' => array_unique($icons), - 'discussionType' => $discussion_type->transformData() + 'discussionType' => $discussionType->transformData() ]) ); } - public function save_action(?DiscussionType $discussion_type = null) + public function save_action(?DiscussionType $discussionType = null): void { CSRFProtection::verifyUnsafeRequest(); - $discussion_type->name = Request::get('name'); - $discussion_type->icon = Request::get('icon'); + $discussionType->name = Request::get('name'); + $discussionType->icon = Request::get('icon'); - $discussion_type->store(); + $discussionType->store(); - PageLayout::postSuccess(sprintf(_('Der Diskussionstyp „%s“ wurde gespeichert.'), $discussion_type->name)); + PageLayout::postSuccess(sprintf(_('Der Diskussionstyp „%s“ wurde gespeichert.'), $discussionType->name)); $this->relocate('course/forum/discussion_types/index'); } diff --git a/app/controllers/course/forum/discussions.php b/app/controllers/course/forum/discussions.php index 91ba8d6..7cf3243 100644 --- a/app/controllers/course/forum/discussions.php +++ b/app/controllers/course/forum/discussions.php @@ -12,7 +12,7 @@ use Forum\Topic; class Course_Forum_DiscussionsController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); @@ -23,8 +23,8 @@ class Course_Forum_DiscussionsController extends Forum\BaseController } } - public function index_action() { - + public function index_action(): void + { $metadata = DBManager::get()->fetchOne( "SELECT COUNT(posting_id) as 'postings_count', @@ -48,12 +48,10 @@ class Course_Forum_DiscussionsController extends Forum\BaseController ); } - public function show_action($discussion_id) + public function show_action(Discussion $discussion): void { - $discussion = Discussion::find($discussion_id); - if (!$discussion) { - throw new AccessDeniedException(); + throw new NotFoundException(); } PageLayout::setTitle($discussion->title); @@ -98,7 +96,7 @@ class Course_Forum_DiscussionsController extends Forum\BaseController $this->render_vue_app( Studip\VueApp::create('forum/discussions/Show') ->withProps([ - 'auth_user' => $auth_user, + 'authUser' => $auth_user, 'discussion' => [ ...$discussion->transformData(), 'topic' => $discussion->topic->toRawArray(), @@ -107,14 +105,14 @@ class Course_Forum_DiscussionsController extends Forum\BaseController 'type' => !empty($discussion->discussion_type) ? $discussion->discussion_type->toRawArray() : [] ], 'category' => $category ? $category->toRawArray() : [], - 'read_index' => (int) ($posting_read ? $posting_read->read_index : 0), + 'readIndex' => (int) ($posting_read ? $posting_read->read_index : 0), 'redirect' => Request::option('redirect'), - 'search_keyword' => Request::get('q', $_SESSION['forum'][$this->range_id]['search_filter']['keyword'] ?? '') + 'searchKeyword' => Request::get('q', $_SESSION['forum'][$this->range_id]['search_filter']['keyword'] ?? '') ]) ); } - public function edit_action(?Discussion $discussion = null) + public function edit_action(?Discussion $discussion = null): void { if ($discussion->isNew()) { PageLayout::setTitle(_('Neue Diskussion starten')); @@ -134,9 +132,9 @@ class Course_Forum_DiscussionsController extends Forum\BaseController ['range_id' => $this->range_id] ); - $all_tags = array_map(fn(TagDTO $tag) => $tag->toRawArray(), TagDTO::getForumTags()); - $discussion_tags = array_map(fn(TagDTO $tag) => $tag->toRawArray(), $discussion->tags); - $discussion_types = array_map(fn(DiscussionType $discussion_type) => $discussion_type->toRawArray(), DiscussionType::getAll()); + $allTags = array_map(fn(TagDTO $tag) => $tag->toRawArray(), TagDTO::getForumTags()); + $discussionTags = array_map(fn(TagDTO $tag) => $tag->toRawArray(), $discussion->tags); + $discussionTypes = array_map(fn(DiscussionType $discussion_type) => $discussion_type->toRawArray(), DiscussionType::getAll()); $this->render_vue_app( Studip\VueApp::create('forum/discussions/Edit') @@ -144,16 +142,16 @@ class Course_Forum_DiscussionsController extends Forum\BaseController 'discussion' => [ ...$discussion->transformData(), 'topic_id' => !empty($discussion->topic_id) ? $discussion->topic_id : Request::option('topic_id'), - 'tags' => $discussion_tags + 'tags' => $discussionTags ], 'topics' => $topics, - 'tags' => $all_tags, - 'discussion_types' => $discussion_types + 'tags' => $allTags, + 'discussionTypes' => $discussionTypes ]) ); } - public function save_action($discussion_id = null) + public function save_action($discussion_id = null): void { CSRFProtection::verifyUnsafeRequest(); @@ -223,12 +221,12 @@ class Course_Forum_DiscussionsController extends Forum\BaseController ); } - public function delete_action($discussion_id) + public function delete_action(Discussion $discussion): void { - $discussion = Discussion::find($discussion_id); + CSRFProtection::verifyUnsafeRequest(); if (!$discussion) { - throw new AccessDeniedException(); + throw new NotFoundException(); } if (!$this->is_moderator && $discussion->user_id !== $this->user_id) { diff --git a/app/controllers/course/forum/recent.php b/app/controllers/course/forum/recent.php index 3585c2c..46f6acc 100644 --- a/app/controllers/course/forum/recent.php +++ b/app/controllers/course/forum/recent.php @@ -2,21 +2,21 @@ class Course_Forum_RecentController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); Navigation::activateItem('course/forum/topics'); } - public function index_action() + public function index_action(): void { PageLayout::setTitle(_('Neueste Beiträge')); $this->render_vue_app( Studip\VueApp::create('forum/recent/Index') ->withProps([ - 'last_visit' => Request::int('last_visit') + 'lastVisit' => Request::int('last_visit') ]) ); } diff --git a/app/controllers/course/forum/search.php b/app/controllers/course/forum/search.php index 988ca87..8cb8824 100644 --- a/app/controllers/course/forum/search.php +++ b/app/controllers/course/forum/search.php @@ -5,14 +5,14 @@ use Forum\DTO\Tag as TagDTO; class Course_Forum_SearchController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); Navigation::activateItem('course/forum'); } - public function index_action() + public function index_action(): void { $topics = DBManager::get()->fetchAll( "SELECT @@ -43,9 +43,9 @@ class Course_Forum_SearchController extends Forum\BaseController ->withProps([ 'filter' => $this->getForumFilter(), 'topics' => $topics, - 'discussion_types' => $discussion_types, + 'discussionTypes' => $discussion_types, 'tags' => $tags, - 'course_members' => $course_members, + 'courseMembers' => $course_members, ]) ); } diff --git a/app/controllers/course/forum/subscriptions.php b/app/controllers/course/forum/subscriptions.php index 13df712..77b5e0f 100644 --- a/app/controllers/course/forum/subscriptions.php +++ b/app/controllers/course/forum/subscriptions.php @@ -2,7 +2,7 @@ class Course_Forum_SubscriptionsController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); @@ -13,7 +13,7 @@ class Course_Forum_SubscriptionsController extends Forum\BaseController Navigation::activateItem('course/forum/subscriptions'); } - public function index_action() + public function index_action(): void { $this->render_vue_app( Studip\VueApp::create('forum/subscriptions/Index') diff --git a/app/controllers/course/forum/topics.php b/app/controllers/course/forum/topics.php index ca22f89..56ffeee 100644 --- a/app/controllers/course/forum/topics.php +++ b/app/controllers/course/forum/topics.php @@ -6,7 +6,7 @@ use Forum\Topic; class Course_Forum_TopicsController extends Forum\BaseController { - public function before_filter(&$action, &$args) + public function before_filter(&$action, &$args): void { parent::before_filter($action, $args); @@ -15,19 +15,17 @@ class Course_Forum_TopicsController extends Forum\BaseController Navigation::activateItem('course/forum/topics'); } - public function index_action() + public function index_action(): void { $this->render_vue_app( Studip\VueApp::create('forum/topics/Index') ); } - public function show_action($topic_id) + public function show_action(Topic $topic): void { - $topic = Topic::find($topic_id); - if (!$topic) { - throw new AccessDeniedException(); + throw new NotFoundException(); } PageLayout::setTitle($topic->name); @@ -49,7 +47,7 @@ class Course_Forum_TopicsController extends Forum\BaseController ->withProps([ 'topic' => $topic->transformData(), 'category' => $topic->category ? $topic->category->transformData() : [], - 'user_subscription' => $user_subscription ? $user_subscription->toRawArray() : [], + 'userSubscription' => $user_subscription ? $user_subscription->toRawArray() : [], 'metadata' => [ 'postings_count' => (int) $topic->metadata['postings_count'], 'users_count' => (int) $topic->metadata['users_count'], @@ -59,7 +57,7 @@ class Course_Forum_TopicsController extends Forum\BaseController ); } - public function edit_action($topic_id = null) + public function edit_action($topic_id = null): void { if (!$this->is_moderator) { throw new AccessDeniedException(); @@ -92,7 +90,7 @@ class Course_Forum_TopicsController extends Forum\BaseController ); } - public function save_action($topic_id = null) + public function save_action($topic_id = null): void { if (!$this->is_moderator) { throw new AccessDeniedException(); @@ -138,15 +136,15 @@ class Course_Forum_TopicsController extends Forum\BaseController $this->relocate('course/forum/topics/show/' . $topic->topic_id); } - public function delete_action($topic_id) + public function delete_action(Topic $topic): void { - if (!$this->is_moderator) { - throw new AccessDeniedException(); - } - - $topic = Topic::getCourseTopic($this->range_id, $topic_id); + CSRFProtection::verifyUnsafeRequest(); if (!$topic) { + throw new NotFoundException(); + } + + if (!$this->is_moderator) { throw new AccessDeniedException(); } |
