summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elm/User/Edit.elm3
-rw-r--r--lib/VNWeb/Auth.pm2
-rw-r--r--lib/VNWeb/Docs/Lib.pm2
-rw-r--r--lib/VNWeb/Images/Vote.pm8
-rw-r--r--sql/perms.sql8
-rw-r--r--sql/schema.sql3
-rw-r--r--util/updates/2020-04-26-perm-imgmod.sql3
7 files changed, 18 insertions, 11 deletions
diff --git a/elm/User/Edit.elm b/elm/User/Edit.elm
index 5d6b8cea..c31d20a3 100644
--- a/elm/User/Edit.elm
+++ b/elm/User/Edit.elm
@@ -54,6 +54,7 @@ type Data
| PermBoardmod Bool
| PermEdit Bool
| PermImgvote Bool
+ | PermImgmod Bool
| PermTag Bool
| PermDbmod Bool
| PermTagmod Bool
@@ -84,6 +85,7 @@ updateData msg model =
PermBoardmod b -> { model | perm_boardmod = b }
PermEdit b -> { model | perm_edit = b }
PermImgvote b -> { model | perm_imgvote = b }
+ PermImgmod b -> { model | perm_imgmod = b }
PermTag b -> { model | perm_tag = b }
PermDbmod b -> { model | perm_dbmod = b }
PermTagmod b -> { model | perm_tagmod = b }
@@ -158,6 +160,7 @@ view model =
, label [] [ inputCheck "" data.perm_boardmod (Set << PermBoardmod), text (" boardmod") ], br_ 1
, label [] [ inputCheck "" data.perm_edit (Set << PermEdit), text (" edit (default)") ], br_ 1
, label [] [ inputCheck "" data.perm_imgvote (Set << PermImgvote), text (" imgvote (default - existing votes will stop counting when unset)") ], br_ 1
+ , label [] [ inputCheck "" data.perm_imgmod (Set << PermImgmod), text (" imgmod") ], br_ 1
, label [] [ inputCheck "" data.perm_tag (Set << PermTag), text (" tag (default)") ], br_ 1
, label [] [ inputCheck "" data.perm_dbmod (Set << PermDbmod), text (" dbmod") ], br_ 1
, label [] [ inputCheck "" data.perm_tagmod (Set << PermTagmod), text (" tagmod") ], br_ 1
diff --git a/lib/VNWeb/Auth.pm b/lib/VNWeb/Auth.pm
index b5d7070b..0837fdd9 100644
--- a/lib/VNWeb/Auth.pm
+++ b/lib/VNWeb/Auth.pm
@@ -70,7 +70,7 @@ sub token { shift->{token} }
-my @perms = qw/board boardmod edit imgvote tag dbmod tagmod usermod/;
+my @perms = qw/board boardmod edit imgvote imgmod tag dbmod tagmod usermod/;
sub listPerms { @perms }
diff --git a/lib/VNWeb/Docs/Lib.pm b/lib/VNWeb/Docs/Lib.pm
index aeb4f172..19097adf 100644
--- a/lib/VNWeb/Docs/Lib.pm
+++ b/lib/VNWeb/Docs/Lib.pm
@@ -5,7 +5,7 @@ use VNWeb::Prelude;
our @EXPORT = qw/enrich_html/;
-my @special_perms = qw/boardmod dbmod usermod tagmod/;
+my @special_perms = qw/boardmod dbmod usermod imgmod tagmod/;
sub _moderators {
my $cols = sql_comma map "perm_$_", @special_perms;
diff --git a/lib/VNWeb/Images/Vote.pm b/lib/VNWeb/Images/Vote.pm
index f66781d8..db8bf83f 100644
--- a/lib/VNWeb/Images/Vote.pm
+++ b/lib/VNWeb/Images/Vote.pm
@@ -135,10 +135,10 @@ elm_api ImageVote => undef, {
# Find out if any of these images are being overruled
enrich_merge id => sub { sql 'SELECT id, bool_or(ignore) AS overruled FROM image_votes WHERE id IN', $_, 'GROUP BY id' }, $data->{votes};
enrich_merge id => sql('SELECT id, NOT ignore AS my_overrule FROM image_votes WHERE uid =', \auth->uid, 'AND id IN'),
- grep $_->{overruled}, $data->{votes}->@* if auth->permDbmod;
+ grep $_->{overruled}, $data->{votes}->@* if auth->permImgmod;
for($data->{votes}->@*) {
- $_->{overrule} = 0 if !auth->permDbmod;
+ $_->{overrule} = 0 if !auth->permImgmod;
my $d = {
id => $_->{id},
uid => auth->uid(),
@@ -163,7 +163,7 @@ sub imgflag_ {
elm_ 'ImageFlagging', $SEND, {
my_votes => my_votes(),
nsfw_token => viewset(show_nsfw => 1),
- mod => auth->permDbmod()||0,
+ mod => auth->permImgmod()||0,
@_
};
}
@@ -189,7 +189,7 @@ TUWF::get qr{/img/$RE{imgid}}, sub {
enrich_image $l;
return tuwf->resNotFound if !defined $l->[0]{width};
- enrich_token defined($l->[0]{my_sexual}) || auth->permDbmod(), $l; # XXX: permImgmod?
+ enrich_token defined($l->[0]{my_sexual}) || auth->permImgmod(), $l;
framework_ title => "Image flagging for $id", sub {
imgflag_ images => $l, single => 1, warn => !tuwf->samesite();
diff --git a/sql/perms.sql b/sql/perms.sql
index 3c68ccf6..103b3561 100644
--- a/sql/perms.sql
+++ b/sql/perms.sql
@@ -68,7 +68,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON ulist_vns_labels TO vndb_site;
-- users table is special; The 'perm_usermod', 'passwd' and 'mail' columns are
-- protected and can only be accessed through the user_* functions.
GRANT SELECT ( id, username, registered, ip, ign_votes, email_confirmed
- , perm_board, perm_boardmod, perm_dbmod, perm_edit, perm_imgvote, perm_tag, perm_tagmod, perm_usermod
+ , perm_board, perm_boardmod, perm_dbmod, perm_edit, perm_imgvote, perm_tag, perm_tagmod, perm_usermod, perm_imgmod
, skin, customcss, show_nsfw, notify_dbedit, notify_announce
, tags_all, tags_cont, tags_ero, tags_tech, spoilers, traits_sexual
, filter_vn, filter_release, vn_list_own, vn_list_wish
@@ -77,7 +77,7 @@ GRANT SELECT ( id, username, registered, ip, ign_votes, email_confirmed
, c_vns, c_wish, c_votes, c_changes, c_imgvotes, c_tags),
INSERT ( username, mail, ip),
UPDATE ( username, ign_votes, email_confirmed
- , perm_board, perm_boardmod, perm_dbmod, perm_edit, perm_imgvote, perm_tag, perm_tagmod
+ , perm_board, perm_boardmod, perm_dbmod, perm_edit, perm_imgvote, perm_tag, perm_tagmod, perm_imgmod
, skin, customcss, show_nsfw, notify_dbedit, notify_announce
, tags_all, tags_cont, tags_ero, tags_tech, spoilers, traits_sexual
, filter_vn, filter_release, vn_list_own, vn_list_wish
@@ -162,8 +162,8 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON ulist_labels TO vndb_multi;
GRANT SELECT, INSERT, UPDATE, DELETE ON ulist_vns TO vndb_multi;
GRANT SELECT, INSERT, UPDATE, DELETE ON ulist_vns_labels TO vndb_multi;
-GRANT SELECT (id, username, registered, ign_votes, email_confirmed, notify_dbedit, notify_announce, c_vns, c_wish, c_votes, c_changes, c_imgvotes, c_tags),
- UPDATE ( c_vns, c_wish, c_votes, c_changes, c_imgvotes, c_tags) ON users TO vndb_multi;
+GRANT SELECT (id, username, registered, ign_votes, email_confirmed, notify_dbedit, notify_announce, c_vns, c_wish, c_votes, c_changes, c_imgvotes, c_tags, perm_imgvote),
+ UPDATE ( c_vns, c_wish, c_votes, c_changes, c_imgvotes, c_tags ) ON users TO vndb_multi;
GRANT DELETE ON users TO vndb_multi;
GRANT SELECT, UPDATE ON vn TO vndb_multi;
diff --git a/sql/schema.sql b/sql/schema.sql
index 03c9e218..13e3e781 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -812,7 +812,8 @@ CREATE TABLE users (
perm_imgvote boolean NOT NULL DEFAULT true, -- [pub] (public because this is used in calculating image flagging scores)
perm_tag boolean NOT NULL DEFAULT true,
perm_tagmod boolean NOT NULL DEFAULT false,
- perm_usermod boolean NOT NULL DEFAULT false
+ perm_usermod boolean NOT NULL DEFAULT false,
+ perm_imgmod boolean NOT NULL DEFAULT false
);
-- vn
diff --git a/util/updates/2020-04-26-perm-imgmod.sql b/util/updates/2020-04-26-perm-imgmod.sql
new file mode 100644
index 00000000..dabe3dfd
--- /dev/null
+++ b/util/updates/2020-04-26-perm-imgmod.sql
@@ -0,0 +1,3 @@
+ALTER TABLE users ADD COLUMN perm_imgmod boolean NOT NULL DEFAULT false;
+UPDATE users SET perm_imgmod = perm_dbmod;
+\i sql/perms.sql