aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm34
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm24
-rw-r--r--perllib/FixMyStreet/Cobrand/Westminster.pm11
3 files changed, 58 insertions, 11 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;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index b59c8990b..9f4610143 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -372,6 +372,30 @@ sub contact_email {
return $self->feature('contact_email') || $self->next::method();
}
+# Allow cobrands to disallow updates on some things.
+# Note this only ever locks down more than the default.
+sub updates_disallowed {
+ my $self = shift;
+ my ($problem) = @_;
+ my $c = $self->{c};
+
+ my $cfg = $self->feature('updates_allowed') || '';
+ if ($cfg eq 'none') {
+ return 1;
+ } elsif ($cfg eq 'staff') {
+ # Only staff and superusers can leave updates
+ my $staff = $c->user_exists && $c->user->from_body && $c->user->from_body->name eq $self->council_name;
+ my $superuser = $c->user_exists && $c->user->is_superuser;
+ return 1 unless $staff || $superuser;
+ } elsif ($cfg eq 'reporter') {
+ return 1 if !$c->user_exists || $c->user->id != $problem->user->id;
+ } elsif ($cfg eq 'open') {
+ return 1 if $problem->is_fixed || $problem->is_closed;
+ }
+
+ return $self->next::method(@_);
+}
+
sub extra_contact_validation {
my $self = shift;
my $c = shift;
diff --git a/perllib/FixMyStreet/Cobrand/Westminster.pm b/perllib/FixMyStreet/Cobrand/Westminster.pm
index 95da0c5aa..b3ab35b7b 100644
--- a/perllib/FixMyStreet/Cobrand/Westminster.pm
+++ b/perllib/FixMyStreet/Cobrand/Westminster.pm
@@ -32,17 +32,6 @@ sub enter_postcode_text {
sub send_questionnaires { 0 }
-sub updates_disallowed {
- my $self = shift;
- my $c = $self->{c};
-
- # Only WCC staff and superusers can leave updates
- my $staff = $c->user_exists && $c->user->from_body && $c->user->from_body->name eq $self->council_name;
- my $superuser = $c->user_exists && $c->user->is_superuser;
-
- return ( $staff || $superuser ) ? 0 : 1;
- }
-
sub suppress_reporter_alerts { 1 }
sub report_age { '3 months' }