Skip to content

Commit

Permalink
[featured] fix feature button
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Apr 7, 2024
1 parent 07a3b5d commit 06a7ae5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ext/featured/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function onInitExt(InitExtEvent $event): void
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);
Expand Down
7 changes: 3 additions & 4 deletions ext/featured/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public function testFeatured(): void
# 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");
Expand Down

0 comments on commit 06a7ae5

Please sign in to comment.