Commit f7a09efe authored by Shawn M Moore's avatar Shawn M Moore
Browse files

More access control for Full templates

parent df4eb51c
......@@ -566,4 +566,45 @@ sub CurrentUserHasQueueRight {
return ( $self->QueueObj->CurrentUserHasRight(@_) );
}
=head2 SetType
If setting Type to Full, require the FullTemplates right on the queue.
=cut
sub SetType {
my $self = shift;
my $NewType = shift;
if ($NewType eq 'Full' && !$self->CurrentUser->HasRight(Right => 'FullTemplates', Object => $self->QueueObj) ) {
return ( undef, $self->loc('Permission Denied') );
}
return $self->_Set( Field => 'Type', Value => $NewType );
}
=head2 SetQueue
When changing the queue, make sure the current user has FullTemplates on the
new queue if the type is Full.
Templates can't change Queue in the UI (yet?).
=cut
sub SetQueue {
my $self = shift;
my $NewQueue = shift;
my $NewQueueObj = RT::Queue->new( $self->CurrentUser );
$NewQueueObj->Load($NewQueue);
if ( $self->Type eq 'Full' && !$self->CurrentUser->HasRight(Right => 'FullTemplates', Object => $NewQueueObj) ) {
return ( undef, $self->loc('Permission Denied. You do not have FullTemplate on the new queue.') );
}
return $self->_Set( Field => 'Queue', Value => $NewQueueObj->id );
}
1;
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