[featured] fix feature button

This commit is contained in:
Shish 2024-04-07 10:25:58 +01:00 committed by Shish
parent 4a5d30e0bf
commit 4807064a65
2 changed files with 5 additions and 6 deletions

View file

@ -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);

View file

@ -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");