diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Contact.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Contact.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index affc6d480..69f8886eb 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -113,9 +113,11 @@ sub category_display { $self->get_extra_metadata('display_name') || $self->translate_column('category'); } +# Returns an arrayref of groups this Contact is in; if it is +# not in any group, returns an arrayref of the empty string. sub groups { my $self = shift; - my $groups = $self->get_extra_metadata('group') || []; + my $groups = $self->get_extra_metadata('group') || ['']; $groups = [ $groups ] unless ref $groups eq 'ARRAY'; return $groups; } @@ -175,4 +177,31 @@ sub disable_form_field { return $field; } +sub sent_by_open311 { + my $self = shift; + my $body = $self->body; + my $method = $self->send_method || ''; + my $body_method = $body->send_method || ''; + return 1 if + (!$body->can_be_devolved && $body_method eq 'Open311') + || ($body->can_be_devolved && $body_method eq 'Open311' && !$method) + || ($body->can_be_devolved && $method eq 'Open311'); + return 0; +} + +# We do not want to allow editing of a category's name +# if it's Open311, unless it's marked as protected +# Also prevent editing of hardcoded categories +sub category_uneditable { + my $self = shift; + return 1 if + $self->in_storage + && !$self->get_extra_metadata('open311_protect') + && $self->sent_by_open311; + return 1 if + $self->in_storage + && $self->get_extra_metadata('hardcoded'); + return 0; +} + 1; |