comment_anon bool -> create_comment perm
This commit is contained in:
parent
bca3dd919d
commit
ee4b223f65
@ -54,6 +54,7 @@ new UserClass("base", null, array(
|
|||||||
"edit_user_info" => False, # email address, etc
|
"edit_user_info" => False, # email address, etc
|
||||||
"delete_user" => False,
|
"delete_user" => False,
|
||||||
|
|
||||||
|
"create_comment" => False,
|
||||||
"delete_comment" => False,
|
"delete_comment" => False,
|
||||||
|
|
||||||
"replace_image" => False,
|
"replace_image" => False,
|
||||||
@ -76,6 +77,7 @@ new UserClass("anonymous", "base", array(
|
|||||||
new UserClass("user", "base", array(
|
new UserClass("user", "base", array(
|
||||||
"big_search" => True,
|
"big_search" => True,
|
||||||
"create_image" => True,
|
"create_image" => True,
|
||||||
|
"create_comment" => True,
|
||||||
"edit_image_tag" => True,
|
"edit_image_tag" => True,
|
||||||
"edit_image_source" => True,
|
"edit_image_source" => True,
|
||||||
"create_image_report" => True,
|
"create_image_report" => True,
|
||||||
@ -93,6 +95,7 @@ new UserClass("admin", "base", array(
|
|||||||
"delete_user" => True,
|
"delete_user" => True,
|
||||||
"create_image" => True,
|
"create_image" => True,
|
||||||
"delete_image" => True,
|
"delete_image" => True,
|
||||||
|
"create_comment" => True,
|
||||||
"delete_comment" => True,
|
"delete_comment" => True,
|
||||||
"replace_image" => True,
|
"replace_image" => True,
|
||||||
"manage_extension_list" => True,
|
"manage_extension_list" => True,
|
||||||
|
@ -63,7 +63,6 @@ class Comment {
|
|||||||
class CommentList extends Extension {
|
class CommentList extends Extension {
|
||||||
public function onInitExt(InitExtEvent $event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
$config->set_default_bool('comment_anon', true);
|
|
||||||
$config->set_default_int('comment_window', 5);
|
$config->set_default_int('comment_window', 5);
|
||||||
$config->set_default_int('comment_limit', 10);
|
$config->set_default_int('comment_limit', 10);
|
||||||
$config->set_default_int('comment_list_count', 10);
|
$config->set_default_int('comment_list_count', 10);
|
||||||
@ -187,10 +186,11 @@ class CommentList extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
|
global $user;
|
||||||
$this->theme->display_image_comments(
|
$this->theme->display_image_comments(
|
||||||
$event->image,
|
$event->image,
|
||||||
$this->get_comments($event->image->id),
|
$this->get_comments($event->image->id),
|
||||||
$this->can_comment()
|
$user->can("create_comment")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +207,7 @@ class CommentList extends Extension {
|
|||||||
|
|
||||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Comment Options");
|
$sb = new SetupBlock("Comment Options");
|
||||||
$sb->add_bool_option("comment_anon", "Allow anonymous comments: ");
|
$sb->add_bool_option("comment_captcha", "Require CAPTCHA for anonymous comments: ");
|
||||||
$sb->add_bool_option("comment_captcha", "<br>Require CAPTCHA for anonymous comments: ");
|
|
||||||
$sb->add_label("<br>Limit to ");
|
$sb->add_label("<br>Limit to ");
|
||||||
$sb->add_int_option("comment_limit");
|
$sb->add_int_option("comment_limit");
|
||||||
$sb->add_label(" comments per ");
|
$sb->add_label(" comments per ");
|
||||||
@ -250,12 +249,9 @@ class CommentList extends Extension {
|
|||||||
|
|
||||||
// page building {{{
|
// page building {{{
|
||||||
private function build_page(/*int*/ $current_page) {
|
private function build_page(/*int*/ $current_page) {
|
||||||
global $page;
|
global $page, $config, $database, $user;
|
||||||
global $config;
|
|
||||||
global $database;
|
|
||||||
|
|
||||||
if(class_exists("Ratings")) {
|
if(class_exists("Ratings")) {
|
||||||
global $user;
|
|
||||||
$user_ratings = Ratings::get_user_privs($user);
|
$user_ratings = Ratings::get_user_privs($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +290,7 @@ class CommentList extends Extension {
|
|||||||
if(!is_null($image)) $images[] = array($image, $comments);
|
if(!is_null($image)) $images[] = array($image, $comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->theme->display_comment_list($images, $current_page, $total_pages, $this->can_comment());
|
$this->theme->display_comment_list($images, $current_page, $total_pages, $user->can("create_comment"));
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// get comments {{{
|
// get comments {{{
|
||||||
@ -439,12 +435,6 @@ class CommentList extends Extension {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function can_comment() {
|
|
||||||
global $config;
|
|
||||||
global $user;
|
|
||||||
return ($config->get_bool('comment_anon') || !$user->is_anonymous());
|
|
||||||
}
|
|
||||||
|
|
||||||
private function is_dupe(/*int*/ $image_id, /*string*/ $comment) {
|
private function is_dupe(/*int*/ $image_id, /*string*/ $comment) {
|
||||||
global $database;
|
global $database;
|
||||||
return ($database->get_row("SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment", array("image_id"=>$image_id, "comment"=>$comment)));
|
return ($database->get_row("SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment", array("image_id"=>$image_id, "comment"=>$comment)));
|
||||||
@ -455,7 +445,7 @@ class CommentList extends Extension {
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// basic sanity checks
|
// basic sanity checks
|
||||||
if(!$config->get_bool('comment_anon') && $user->is_anonymous()) {
|
if(!$user->can("create_comment")) {
|
||||||
throw new CommentPostingException("Anonymous posting has been disabled");
|
throw new CommentPostingException("Anonymous posting has been disabled");
|
||||||
}
|
}
|
||||||
else if(is_null(Image::by_id($image_id))) {
|
else if(is_null(Image::by_id($image_id))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user