diff --git a/ext/featured/main.php b/ext/featured/main.php index 8f684a52..a4afa117 100644 --- a/ext/featured/main.php +++ b/ext/featured/main.php @@ -18,8 +18,8 @@ class Featured extends Extension public function onPageRequest(PageRequestEvent $event): void { global $config, $page, $user; - if ($event->page_matches("featured_image/set", method: "POST", permission: Permissions::EDIT_FEATURE)) { - $id = int_escape($event->req_POST('image_id')); + if ($event->page_matches("featured_image/set/{image_id}", method: "POST", permission: Permissions::EDIT_FEATURE)) { + $id = $event->get_iarg('image_id'); $config->set_int("featured_id", $id); log_info("featured", "Featured post set to >>$id", "Featured post set"); $page->set_mode(PageMode::REDIRECT); diff --git a/ext/featured/test.php b/ext/featured/test.php index c0c82eb3..ade16eb5 100644 --- a/ext/featured/test.php +++ b/ext/featured/test.php @@ -17,10 +17,9 @@ class FeaturedTest extends ShimmiePHPUnitTestCase # FIXME: test that regular users can't feature things // Admin can feature things - // FIXME: use Event rather than modifying database - // $this->log_in_as_admin(); - // send_event(new SetFeaturedEvent($image_id)); - $config->set_int("featured_id", $image_id); + $this->log_in_as_admin(); + $page = $this->post_page("featured_image/set/$image_id"); + $this->assertEquals(302, $page->code); $this->get_page("post/list"); $this->assert_text("Featured Post");