diff options
author | Struan Donald <struan@exo.org.uk> | 2020-05-07 15:10:46 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-05-12 15:36:52 +0100 |
commit | c80f13eeac448e99873b690411d7f6e83b07dd06 (patch) | |
tree | abf43a53330728a1a7a02f462a8173f5e499048c /perllib/FixMyStreet/Cobrand/Default.pm | |
parent | 08f4e0171579f77165ce074e88086d1caeb7a243 (diff) |
admin interface for per category anonymous reporting
Add an interface to enable a category to accept anonymous reports, plus
the code to handle permitting this.
It's only available on single body cobrand sites in the default
configuration.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Default.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index df7e333fb..c8e11f93d 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1123,7 +1123,22 @@ pressed in the front end, rather than whenever a username is not provided. =cut -sub allow_anonymous_reports { 0; } +sub allow_anonymous_reports { + my ($self, $category_name) = @_; + + $category_name ||= $self->{c}->stash->{category}; + if ( $category_name && $self->can('body') and $self->body ) { + my $category_rs = FixMyStreet::DB->resultset("Contact")->search({ + body_id => $self->body->id, + category => $category_name + }); + if ( my $category = $category_rs->first ) { + return 'button' if $category->get_extra_metadata('anonymous_allowed'); + } + } + + return 0; +} =item anonymous_account |