Added the option to display thumbnails, moved the reported image list to it's own page, and checked to make sure the user is an admin before letting them delete / view reported images.
git-svn-id: file:///home/shish/svn/shimmie2/trunk@612 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
ac2af2d1c0
commit
8c78ca64f6
4 changed files with 82 additions and 37 deletions
|
@ -5,10 +5,10 @@
|
||||||
* Link: http://atravelinggeek.com/
|
* Link: http://atravelinggeek.com/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Report images as dupes/illegal/etc
|
* Description: Report images as dupes/illegal/etc
|
||||||
* Version 0.2c - See changelog in main.php
|
* Version 0.3 - See changelog in main.php
|
||||||
* October 27, 2007
|
* November 06, 2007
|
||||||
*
|
*
|
||||||
* NOTE: This is for Shimmie2 SVN Trunk. Use the other main.php.use... for Shimmie2 RC2.
|
* NOTE: This is for Shimmie2 SVN Trunk. Use the other main.php.use... for Shimmie2 RCx.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ class AddReportedImageEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
class report_image extends Extension {
|
class report_image extends Extension {
|
||||||
|
var $theme;
|
||||||
|
|
||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("report_image", "ReportImageTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("report_image", "ReportImageTheme");
|
||||||
|
@ -57,20 +59,28 @@ class report_image extends Extension {
|
||||||
}
|
}
|
||||||
else if($event->get_arg(0) == "remove") {
|
else if($event->get_arg(0) == "remove") {
|
||||||
if(isset($_POST['id'])) {
|
if(isset($_POST['id'])) {
|
||||||
send_event(new RemoveReportedImageEvent($_POST['id']));
|
if($event->user->is_admin()) {
|
||||||
|
send_event(new RemoveReportedImageEvent($_POST['id']));
|
||||||
|
global $page;
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link("ReportImage/list"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($event->get_arg(0) == "list") {
|
||||||
|
if($event->user->is_admin()) {
|
||||||
global $page;
|
global $page;
|
||||||
$page->set_mode("redirect");
|
$this->theme->display_reported_images($page, $this->get_reported_images());
|
||||||
$page->set_redirect(make_link("admin"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'AdminBuildingEvent')) {
|
// if(is_a($event, 'AdminBuildingEvent')) {
|
||||||
global $page;
|
// global $page;
|
||||||
$this->theme->display_reported_images($page, $this->get_reported_images());
|
// $this->theme->display_reported_images($page, $this->get_reported_images());
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(is_a($event, 'AddReportedImageEvent')) {
|
if(is_a($event, 'AddReportedImageEvent')) {
|
||||||
$this->add_reported_image($event->image_id, $event->reporter_name, $event->reason_type, $event->reason);
|
$this->add_reported_image($event->image_id, $event->reporter_name, $event->reason_type, $event->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +101,17 @@ class report_image extends Extension {
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
if(is_a($event, 'SetupBuildingEvent')) {
|
||||||
$sb = new SetupBlock("Report Image Options");
|
$sb = new SetupBlock("Report Image Options");
|
||||||
$sb->add_bool_option("report_image_anon", "Allow anonymous image reporting: ");
|
$sb->add_bool_option("report_image_anon", "Allow anonymous image reporting: ");
|
||||||
// I'll add this feature in soonish if anyone wants it.
|
$sb->add_label("<br>");
|
||||||
// $sb->add_label("<br>");
|
$sb->add_bool_option("report_image_show_thumbs", "Show thumbnails in admin panel: ");
|
||||||
// $sb->add_bool_option("report_image_sgow_thumbs", "Show thumbnails in admin panel: ");
|
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'UserBlockBuildingEvent')) {
|
||||||
|
if($event->user->is_admin()) {
|
||||||
|
$event->add_link("Reported Images", make_link("ReportImage/list"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function install() {
|
protected function install() {
|
||||||
|
@ -147,6 +162,8 @@ class report_image extends Extension {
|
||||||
add_event_listener(new report_image(), 29); // Not sure what I'm in before.
|
add_event_listener(new report_image(), 29); // Not sure what I'm in before.
|
||||||
|
|
||||||
// ===== Changelog =====
|
// ===== Changelog =====
|
||||||
|
// * Version 0.3 / 0.3_rc - 11/06/07 - Added the option to display thumbnails, moved the reported image list to it's
|
||||||
|
// own page, and checked to make sure the user is an admin before letting them delete / view reported images.
|
||||||
// * Version 0.2c_rc2 - 10/27/07 - Now (really!) supports Shimmie2 RC2!
|
// * Version 0.2c_rc2 - 10/27/07 - Now (really!) supports Shimmie2 RC2!
|
||||||
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
|
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
|
||||||
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
|
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* Link: http://atravelinggeek.com/
|
* Link: http://atravelinggeek.com/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Report images as dupes/illegal/etc
|
* Description: Report images as dupes/illegal/etc
|
||||||
* Version 0.2c_rc - See changelog in main.php
|
* Version 0.3_rc - See changelog in main.php
|
||||||
* October 27, 2007
|
* November 06, 2007
|
||||||
*
|
*
|
||||||
* NOTE: This is for Shimmie2 RC2. Rename this file to main.php and delete the other file.
|
* NOTE: This is for Shimmie2 SVN Trunk. Use the other main.php.use... for Shimmie2 RCx.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ class AddReportedImageEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
class report_image extends Extension {
|
class report_image extends Extension {
|
||||||
|
var $theme;
|
||||||
|
|
||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("report_image", "ReportImageTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("report_image", "ReportImageTheme");
|
||||||
|
@ -57,20 +59,28 @@ class report_image extends Extension {
|
||||||
}
|
}
|
||||||
else if($event->get_arg(0) == "remove") {
|
else if($event->get_arg(0) == "remove") {
|
||||||
if(isset($_POST['id'])) {
|
if(isset($_POST['id'])) {
|
||||||
send_event(new RemoveReportedImageEvent($_POST['id']));
|
if($event->user->is_admin()) {
|
||||||
|
send_event(new RemoveReportedImageEvent($_POST['id']));
|
||||||
|
global $page;
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link("ReportImage/list"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($event->get_arg(0) == "list") {
|
||||||
|
if($event->user->is_admin()) {
|
||||||
global $page;
|
global $page;
|
||||||
$page->set_mode("redirect");
|
$this->theme->display_reported_images($page, $this->get_reported_images());
|
||||||
$page->set_redirect(make_link("admin"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'AdminBuildingEvent')) {
|
// if(is_a($event, 'AdminBuildingEvent')) {
|
||||||
global $page;
|
// global $page;
|
||||||
$this->theme->display_reported_images($page, $this->get_reported_images());
|
// $this->theme->display_reported_images($page, $this->get_reported_images());
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(is_a($event, 'AddReportedImageEvent')) {
|
if(is_a($event, 'AddReportedImageEvent')) {
|
||||||
$this->add_reported_image($event->image_id, $event->reporter_name, $event->reason_type, $event->reason);
|
$this->add_reported_image($event->image_id, $event->reporter_name, $event->reason_type, $event->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +101,17 @@ class report_image extends Extension {
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
if(is_a($event, 'SetupBuildingEvent')) {
|
||||||
$sb = new SetupBlock("Report Image Options");
|
$sb = new SetupBlock("Report Image Options");
|
||||||
$sb->add_bool_option("report_image_anon", "Allow anonymous image reporting: ");
|
$sb->add_bool_option("report_image_anon", "Allow anonymous image reporting: ");
|
||||||
// I'll add this feature in soonish if anyone wants it.
|
$sb->add_label("<br>");
|
||||||
// $sb->add_label("<br>");
|
$sb->add_bool_option("report_image_show_thumbs", "Show thumbnails in admin panel: ");
|
||||||
// $sb->add_bool_option("report_image_sgow_thumbs", "Show thumbnails in admin panel: ");
|
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'UserBlockBuildingEvent')) {
|
||||||
|
if($event->user->is_admin()) {
|
||||||
|
$event->add_link("Reported Images", make_link("ReportImage/list"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function install() {
|
protected function install() {
|
||||||
|
@ -147,6 +162,8 @@ class report_image extends Extension {
|
||||||
add_event_listener(new report_image(), 29); // Not sure what I'm in before.
|
add_event_listener(new report_image(), 29); // Not sure what I'm in before.
|
||||||
|
|
||||||
// ===== Changelog =====
|
// ===== Changelog =====
|
||||||
|
// * Version 0.3 - 11/06/07 - Added the option to display thumbnails, moved the reported image list to it's
|
||||||
|
// own page, and checked to make sure the user is an admin before letting them delete / view reported images.
|
||||||
// * Version 0.2c_rc2 - 10/27/07 - Now (really!) supports Shimmie2 RC2!
|
// * Version 0.2c_rc2 - 10/27/07 - Now (really!) supports Shimmie2 RC2!
|
||||||
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
|
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
|
||||||
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
|
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* Link: http://atravelinggeek.com/
|
* Link: http://atravelinggeek.com/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Report images as dupes/illegal/etc
|
* Description: Report images as dupes/illegal/etc
|
||||||
* Version 0.2b - See changelog in main.php
|
* Version 0.3 - See changelog in main.php
|
||||||
* October 27, 2007
|
* November 06, 2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function validate_report()
|
function validate_report()
|
||||||
|
|
|
@ -6,28 +6,31 @@
|
||||||
* Link: http://atravelinggeek.com/
|
* Link: http://atravelinggeek.com/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Report images as dupes/illegal/etc
|
* Description: Report images as dupes/illegal/etc
|
||||||
* Version 0.2b - See changelog in main.php
|
* Version 0.3 - See changelog in main.php
|
||||||
* October 27, 2007
|
* November 06, 2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ReportImageTheme extends Themelet {
|
class ReportImageTheme extends Themelet {
|
||||||
public function display_reported_images($page, $reportedimages) {
|
public function display_reported_images($page, $reportedimages) {
|
||||||
$h_reportedimages = "";
|
$h_reportedimages = "";
|
||||||
foreach($reportedimages as $reportedimage) {
|
foreach($reportedimages as $reportedimage) {
|
||||||
|
|
||||||
// If the reason is 'Duplicate' make the 'reason' field a link to the reported image
|
// If the reason is 'Duplicate' make the 'reason' field a link to the reported image
|
||||||
if ($reportedimage['reason_type'] == "Duplicate")
|
if ($reportedimage['reason_type'] == "Duplicate")
|
||||||
{
|
{
|
||||||
$reason = "<a href=\"".make_link("post/view/{$reportedimage['reason']}")."\">".$reportedimage['reason']."</a>";
|
$reason = "<a href=\"".make_link("post/view/{$reportedimage['reason']}")."\">".$reportedimage['reason']."</a>";
|
||||||
|
$reason .= $this->make_thumbnail_html($reportedimage['reason']);
|
||||||
} else {
|
} else {
|
||||||
$reason = $reportedimage['reason'];
|
$reason = $reportedimage['reason'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$image_link = "<a href=\"".make_link("post/view/{$reportedimage['image_id']}")."\">".$reportedimage['image_id']."</a>";
|
$image_link = "<a href=\"".make_link("post/view/{$reportedimage['image_id']}")."\">".$reportedimage['image_id']."</a>";
|
||||||
|
$image_link .= $this->make_thumbnail_html($reportedimage['image_id']);
|
||||||
$userlink = "<a href='".make_link("user/{$reportedimage['reporter_name']}")."'>{$reportedimage['reporter_name']}</a>";
|
$userlink = "<a href='".make_link("user/{$reportedimage['reporter_name']}")."'>{$reportedimage['reporter_name']}</a>";
|
||||||
|
|
||||||
$h_reportedimages .= "
|
$h_reportedimages .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$image_link}</td>
|
<td>{$image_link}{$image_reported_thumb_html}</td>
|
||||||
<td>{$userlink}</td>
|
<td>{$userlink}</td>
|
||||||
<td>{$reportedimage['reason_type']}</td>
|
<td>{$reportedimage['reason_type']}</td>
|
||||||
<td>{$reason}</td>
|
<td>{$reason}</td>
|
||||||
|
@ -47,15 +50,23 @@ class ReportImageTheme extends Themelet {
|
||||||
</table>
|
</table>
|
||||||
";
|
";
|
||||||
|
|
||||||
$page->add_block(new Block("Reported Images", $html));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function display_page($page) {
|
|
||||||
$page->set_title("Reported Images");
|
$page->set_title("Reported Images");
|
||||||
$page->set_heading("Reported Images");
|
$page->set_heading("Reported Images");
|
||||||
$page->add_block(new NavBlock());
|
$page->add_block(new NavBlock());
|
||||||
|
$page->add_block(new Block("Reported Images", $html));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function make_thumbnail_html($image_id) {
|
||||||
|
global $config;
|
||||||
|
global $database;
|
||||||
|
|
||||||
|
if($config->get_bool('report_image_show_thumbs')) {
|
||||||
|
$image_obj_reported = $database->get_image($image_id);
|
||||||
|
return "<br>" . $this->build_thumb_html($image_obj_reported);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function display_image_banner($page, $image) {
|
public function display_image_banner($page, $image) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
Reference in a new issue