Commit 503eeafb authored by Shawn M Moore's avatar Shawn M Moore
Browse files

Really forbid updating Type to Perl and Content without ExecuteCode at once

parent 18c534fc
......@@ -611,21 +611,23 @@ sub SetType {
return $self->_Set( Field => 'Type', Value => $NewType );
}
=head2 SetContent
If setting Content, require the ExecuteCode right.
=cut
sub _UpdateAttributes {
my $self = shift;
my %args = (
NewValues => {},
@_,
);
sub SetContent {
my $self = shift;
my $content = shift;
my $type = $args{NewValues}{Type} || $self->Type;
if ($self->Type eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
return ( undef, $self->loc('Permission Denied') );
# forbid updating content when the (possibly new) value of Type is Perl
if ($type eq 'Perl' && exists $args{NewValues}{Content}) {
if (!$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
return $self->loc('Permission Denied');
}
}
return $self->_Set( Field => 'Content', Value => $content );
return $self->SUPER::_UpdateAttributes(%args);
}
=head2 CompileCheck
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment