diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index aa4290f8..80c5da51 100755 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -82,8 +82,9 @@ class ReportImage extends Extension { public function onDisplayingImage(DisplayingImageEvent $event) { global $config, $user, $page; - if($config->get_bool('report_image_anon') || !$user->is_anonymous()) { - $this->theme->display_image_banner($page, $event->image); + if($user->can('report_image')) { + $reps = $this->get_reporters($event->image); + $this->theme->display_image_banner($event->image, $reps); } } @@ -122,6 +123,16 @@ class ReportImage extends Extension { } } + public function get_reporters(Image $image) { + global $database; + return $database->get_col(" + SELECT users.name + FROM image_reports + JOIN users ON reporter_id = users.id + WHERE image_reports.image_id = :image_id + ", array("image_id" => $image->id)); + } + public function get_reported_images() { global $config, $database; $all_reports = $database->get_all(" diff --git a/contrib/report_image/theme.php b/contrib/report_image/theme.php index d05cb5bf..23df44fb 100755 --- a/contrib/report_image/theme.php +++ b/contrib/report_image/theme.php @@ -68,11 +68,15 @@ class ReportImageTheme extends Themelet { } - public function display_image_banner(Page $page, Image $image) { - global $config; + public function display_image_banner(Image $image, /*array*/ $reporters) { + global $config, $page; $i_image = int_escape($image->id); - $html = " + $html = ""; + if(count($reporters) > 0) { + $html .= "Image reported by ".html_escape(implode(", ", $reporters))."
"; + } + $html .= " ".make_form(make_link("image_report/add"))." diff --git a/core/user.class.php b/core/user.class.php index c36f96a9..0f7b7c8a 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -115,6 +115,7 @@ class User { "edit_image_source" => $config->get_bool("source_edit_anon"), "edit_image_owner" => False, "mass_tag_edit" => False, + "report_image" => $config->get_bool('report_image_anon'), ), "user" => array( "change_setting" => False, @@ -136,6 +137,7 @@ class User { "edit_image_source" => True, "edit_image_owner" => False, "mass_tag_edit" => False, + "report_image" => True, ), "admin" => array( "change_setting" => True, @@ -156,6 +158,7 @@ class User { "edit_image_source" => True, "edit_image_owner" => True, "mass_tag_edit" => True, + "report_image" => True, ), );