diff --git a/core/ext/tag_edit.ext.php b/core/ext/tag_edit.ext.php index 85161a85..ac416ea7 100644 --- a/core/ext/tag_edit.ext.php +++ b/core/ext/tag_edit.ext.php @@ -3,15 +3,23 @@ class TagEdit extends Extension { // event handling {{{ public function receive_event($event) { - if(is_a($event, 'PageRequestEvent') && ($event->page == "tags")) { + if(is_a($event, 'PageRequestEvent') && ($event->page == "tag_edit")) { global $page; if($event->get_arg(0) == "set") { - global $database; - $i_image_id = int_escape($_POST['image_id']); - $query = $_POST['query']; - $database->set_tags($i_image_id, $_POST['tags']); - $page->set_mode("redirect"); - $page->set_redirect(make_link("post/view/$i_image_id", $query)); + if($this->can_tag()) { + global $database; + $i_image_id = int_escape($_POST['image_id']); + $query = $_POST['query']; + $database->set_tags($i_image_id, $_POST['tags']); + $page->set_mode("redirect"); + $page->set_redirect(make_link("post/view/$i_image_id", $query)); + } + else { + $page->set_title("Tag Edit Denied"); + $page->set_heading("Tag Edit Denied"); + $page->add_side_block(new NavBlock()); + $page->add_main_block(new Block("Error", "Anonymous tag editing is disabled")); + } } else if($event->get_arg(0) == "replace") { global $user; @@ -48,6 +56,22 @@ class TagEdit extends Extension { if(is_a($event, 'AddAliasEvent')) { $this->mass_tag_edit($event->oldtag, $event->newtag); } + + if(is_a($event, 'SetupBuildingEvent')) { + $sb = new SetupBlock("Tag Editing"); + $sb->add_label("Allow anonymous editing: "); + $sb->add_bool_option("tag_edit_anon"); + $event->panel->add_main_block($sb); + } + if(is_a($event, 'ConfigSaveEvent')) { + $event->config->set_bool_from_post("tag_edit_anon"); + } + } +// }}} +// do things {{{ + private function can_tag() { + global $config, $user; + return $config->get_bool("tag_edit_anon") || !$user->is_anonymous(); } // }}} // edit {{{ @@ -72,7 +96,7 @@ class TagEdit extends Extension { $i_image_id = int_escape($image->id); return " -