aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/FixMyStreet.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm34
1 files changed, 34 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 5c2aa2be1..015da5e0b 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -166,4 +166,38 @@ sub about_hook {
}
}
+sub updates_disallowed {
+ my $self = shift;
+ my ($problem) = @_;
+ my $c = $self->{c};
+
+ # This is a hash of council name to match, and what to do
+ my $cfg = $self->feature('updates_allowed') || {};
+
+ my $type = '';
+ my $body;
+ foreach (keys %$cfg) {
+ if ($problem->to_body_named($_)) {
+ $type = $cfg->{$_};
+ $body = $_;
+ last;
+ }
+ }
+
+ if ($type eq 'none') {
+ return 1;
+ } elsif ($type eq 'staff') {
+ # Only staff and superusers can leave updates
+ my $staff = $c->user_exists && $c->user->from_body && $c->user->from_body->name =~ /$body/;
+ my $superuser = $c->user_exists && $c->user->is_superuser;
+ return 1 unless $staff || $superuser;
+ } elsif ($type eq 'reporter') {
+ return 1 if !$c->user_exists || $c->user->id != $problem->user->id;
+ } elsif ($type eq 'open') {
+ return 1 if $problem->is_fixed || $problem->is_closed;
+ }
+
+ return $self->next::method(@_);
+}
+
1;