1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
51 RT::Queue - an RT Queue object
70 use base 'RT::Record';
72 use Role::Basic 'with';
73 with "RT::Record::Role::Lifecycle",
74 "RT::Record::Role::Links" => { -excludes => ["_AddLinksOnCreate"] },
75 "RT::Record::Role::Roles",
76 "RT::Record::Role::Rights";
80 sub LifecycleType { "ticket" }
82 sub ModifyLinkRight { "AdminQueue" }
85 RT::ACE->RegisterCacheHandler(sub {
92 return unless $args{Action} =~ /^(Grant|Revoke)$/i
93 and $args{RightName} =~ /^(SeeQueue|CreateTicket)$/;
95 RT->System->QueueCacheNeedsUpdate(1);
100 use RT::Interface::Email;
102 __PACKAGE__->AddRight( General => SeeQueue => 'View queue' ); # loc
103 __PACKAGE__->AddRight( Admin => AdminQueue => 'Create, modify and delete queue' ); # loc
104 __PACKAGE__->AddRight( Admin => ShowACL => 'Display Access Control List' ); # loc
105 __PACKAGE__->AddRight( Admin => ModifyACL => 'Create, modify and delete Access Control List entries' ); # loc
106 __PACKAGE__->AddRight( Admin => ModifyQueueWatchers => 'Modify queue watchers' ); # loc
107 __PACKAGE__->AddRight( General => SeeCustomField => 'View custom field values' ); # loc
108 __PACKAGE__->AddRight( Staff => ModifyCustomField => 'Modify custom field values' ); # loc
109 __PACKAGE__->AddRight( Admin => AssignCustomFields => 'Assign and remove queue custom fields' ); # loc
110 __PACKAGE__->AddRight( Admin => ModifyTemplate => 'Modify Scrip templates' ); # loc
111 __PACKAGE__->AddRight( Admin => ShowTemplate => 'View Scrip templates' ); # loc
113 __PACKAGE__->AddRight( Admin => ModifyScrips => 'Modify Scrips' ); # loc
114 __PACKAGE__->AddRight( Admin => ShowScrips => 'View Scrips' ); # loc
116 __PACKAGE__->AddRight( General => ShowTicket => 'View ticket summaries' ); # loc
117 __PACKAGE__->AddRight( Staff => ShowTicketComments => 'View ticket private commentary' ); # loc
118 __PACKAGE__->AddRight( Staff => ShowOutgoingEmail => 'View exact outgoing email messages and their recipients' ); # loc
120 __PACKAGE__->AddRight( General => Watch => 'Sign up as a ticket Requestor or ticket or queue Cc' ); # loc
121 __PACKAGE__->AddRight( Staff => WatchAsAdminCc => 'Sign up as a ticket or queue AdminCc' ); # loc
122 __PACKAGE__->AddRight( General => CreateTicket => 'Create tickets' ); # loc
123 __PACKAGE__->AddRight( General => ReplyToTicket => 'Reply to tickets' ); # loc
124 __PACKAGE__->AddRight( General => CommentOnTicket => 'Comment on tickets' ); # loc
125 __PACKAGE__->AddRight( Staff => OwnTicket => 'Own tickets' ); # loc
126 __PACKAGE__->AddRight( Staff => ModifyTicket => 'Modify tickets' ); # loc
127 __PACKAGE__->AddRight( Staff => DeleteTicket => 'Delete tickets' ); # loc
128 __PACKAGE__->AddRight( Staff => TakeTicket => 'Take tickets' ); # loc
129 __PACKAGE__->AddRight( Staff => StealTicket => 'Steal tickets' ); # loc
130 __PACKAGE__->AddRight( Staff => ReassignTicket => 'Modify ticket owner on owned tickets' ); # loc
132 __PACKAGE__->AddRight( Staff => ForwardMessage => 'Forward messages outside of RT' ); # loc
136 Arguments: ARGS is a hash of named parameters. Valid parameters are:
146 If you pass the ACL check, it creates the queue and returns its queue id.
156 CorrespondAddress => '',
157 CommentAddress => '',
158 Lifecycle => 'default',
160 InitialPriority => 0,
166 _RecordTransaction => 1,
170 unless ( $self->CurrentUser->HasRight(Right => 'AdminQueue', Object => $RT::System) )
172 return ( 0, $self->loc("No permission to create queues") );
176 my ($val, $msg) = $self->_ValidateName( $args{'Name'} );
177 return ($val, $msg) unless $val;
180 $args{'Lifecycle'} ||= 'default';
182 return ( 0, $self->loc('[_1] is not a valid lifecycle', $args{'Lifecycle'} ) )
183 unless $self->ValidateLifecycle( $args{'Lifecycle'} );
185 my %attrs = map {$_ => 1} $self->ReadableAttributes;
187 #TODO better input validation
188 $RT::Handle->BeginTransaction();
189 my $id = $self->SUPER::Create( map { $_ => $args{$_} } grep exists $args{$_}, keys %attrs );
191 $RT::Handle->Rollback();
192 return ( 0, $self->loc('Queue could not be created') );
195 my $create_ret = $self->_CreateRoleGroups();
196 unless ($create_ret) {
197 $RT::Handle->Rollback();
198 return ( 0, $self->loc('Queue could not be created') );
200 if ( $args{'_RecordTransaction'} ) {
201 $self->_NewTransaction( Type => "Create" );
205 for my $attr (qw/Sign SignAuto Encrypt/) {
206 next unless defined $args{$attr};
207 my $set = "Set" . $attr;
208 my ($status, $msg) = $self->$set( $args{$attr} );
209 $RT::Logger->error("Couldn't set attribute '$attr': $msg")
213 RT->System->QueueCacheNeedsUpdate(1);
215 return ( $id, $self->loc("Queue created") );
223 $self->loc('Deleting this object would break referential integrity') );
228 Takes either a numerical id or a textual Name and loads the specified queue.
235 my $identifier = shift;
236 if ( !$identifier ) {
240 if ( $identifier =~ /^(\d+)$/ ) {
241 $self->SUPER::LoadById($identifier);
244 $self->LoadByCols( Name => $identifier );
247 return ( $self->Id );
253 =head2 ValidateName NAME
255 Takes a queue name. Returns true if it's an ok name for
256 a new queue. Returns undef if there's already a queue by that name.
264 my ($ok, $msg) = $self->_ValidateName($name);
273 return (undef, "Queue name is required") unless length $name;
275 # Validate via the superclass first
276 # Case: short circuit if it's an integer so we don't have
277 # fale negatives when loading a temp queue
278 unless ( my $q = $self->SUPER::ValidateName($name) ) {
279 return ($q, $self->loc("'[_1]' is not a valid name.", $name));
282 my $tempqueue = RT::Queue->new(RT->SystemUser);
283 $tempqueue->Load($name);
285 #If this queue exists, return undef
286 if ( $tempqueue->Name() && $tempqueue->id != $self->id) {
287 return (undef, $self->loc("Queue already exists") );
302 return undef unless $self->CurrentUserHasRight('SeeQueue');
303 my $attr = $self->FirstAttribute('Sign') or return 0;
304 return $attr->Content;
311 return ( 0, $self->loc('Permission Denied') )
312 unless $self->CurrentUserHasRight('AdminQueue');
314 my ($status, $msg) = $self->SetAttribute(
316 Description => 'Sign outgoing messages by default',
319 return ($status, $msg) unless $status;
321 my ( undef, undef, $TransObj ) = $self->_NewTransaction(
322 Field => 'Signing', #loc
323 Type => $value ? "Enabled" : "Disabled"
326 return ($status, scalar $TransObj->BriefDescription);
333 return undef unless $self->CurrentUserHasRight('SeeQueue');
334 my $attr = $self->FirstAttribute('SignAuto') or return 0;
335 return $attr->Content;
342 return ( 0, $self->loc('Permission Denied') )
343 unless $self->CurrentUserHasRight('AdminQueue');
345 my ($status, $msg) = $self->SetAttribute(
347 Description => 'Sign auto-generated outgoing messages',
350 return ($status, $msg) unless $status;
352 my ( undef, undef, $TransObj ) = $self->_NewTransaction(
353 Field => 'AutoSigning', #loc
354 Type => $value ? "Enabled" : "Disabled"
357 return ($status, scalar $TransObj->BriefDescription);
364 return undef unless $self->CurrentUserHasRight('SeeQueue');
365 my $attr = $self->FirstAttribute('Encrypt') or return 0;
366 return $attr->Content;
373 return ( 0, $self->loc('Permission Denied') )
374 unless $self->CurrentUserHasRight('AdminQueue');
376 my ($status, $msg) = $self->SetAttribute(
378 Description => 'Encrypt outgoing messages by default',
381 return ($status, $msg) unless $status;
383 my ( undef, undef, $TransObj ) = $self->_NewTransaction(
384 Field => 'Encrypting', #loc
385 Type => $value ? "Enabled" : "Disabled"
388 return ($status, scalar $TransObj->BriefDescription);
393 Returns an RT::Templates object of all of this queue's templates.
400 my $templates = RT::Templates->new( $self->CurrentUser );
402 if ( $self->CurrentUserHasRight('ShowTemplate') ) {
403 $templates->LimitToQueue( $self->id );
412 =head2 CustomField NAME
414 Load the Ticket Custom Field applied to this Queue named NAME.
415 Does not load Global custom fields.
422 my $cf = RT::CustomField->new($self->CurrentUser);
425 LookupType => RT::Ticket->CustomFieldLookupType,
426 ObjectId => $self->id,
433 =head2 TicketCustomFields
435 Returns an L<RT::CustomFields> object containing all global and
436 queue-specific B<ticket> custom fields.
440 sub TicketCustomFields {
443 my $cfs = RT::CustomFields->new( $self->CurrentUser );
444 if ( $self->CurrentUserHasRight('SeeQueue') ) {
445 $cfs->SetContextObject( $self );
446 $cfs->LimitToGlobalOrObjectId( $self->Id );
447 $cfs->LimitToLookupType( 'RT::Queue-RT::Ticket' );
448 $cfs->ApplySortOrder;
455 =head2 TicketTransactionCustomFields
457 Returns an L<RT::CustomFields> object containing all global and
458 queue-specific B<transaction> custom fields.
462 sub TicketTransactionCustomFields {
465 my $cfs = RT::CustomFields->new( $self->CurrentUser );
466 if ( $self->CurrentUserHasRight('SeeQueue') ) {
467 $cfs->SetContextObject( $self );
468 $cfs->LimitToGlobalOrObjectId( $self->Id );
469 $cfs->LimitToLookupType( 'RT::Queue-RT::Ticket-RT::Transaction' );
470 $cfs->ApplySortOrder;
479 =head2 AllRoleGroupTypes
481 B<DEPRECATED> and will be removed in a future release. Use L</Roles>
484 Returns a list of the names of the various role group types for Queues,
485 including roles used only for ACLs like Requestor and Owner. If you don't want
486 them, see L</ManageableRoleGroupTypes>.
490 sub AllRoleGroupTypes {
493 Instead => "RT::Queue->Roles",
498 =head2 IsRoleGroupType
500 B<DEPRECATED> and will be removed in a future release. Use L</HasRole> instead.
502 Returns whether the passed-in type is a role group type.
506 sub IsRoleGroupType {
509 Instead => "RT::Queue->HasRole",
514 =head2 ManageableRoleGroupTypes
516 Returns a list of the names of the various role group types for Queues,
517 excluding ones used only for ACLs such as Requestor and Owner. If you want
522 sub ManageableRoleGroupTypes {
523 shift->Roles( ACLOnly => 0 )
526 =head2 IsManageableRoleGroupType
528 Returns whether the passed-in type is a manageable role group type.
532 sub IsManageableRoleGroupType {
535 return( $self->HasRole($type) and not $self->Role($type)->{ACLOnly} );
539 sub _HasModifyWatcherRight {
541 my ($type, $principal) = @_;
543 # ModifyQueueWatchers works in any case
544 return 1 if $self->CurrentUserHasRight('ModifyQueueWatchers');
545 # If the watcher isn't the current user then the current user has no right
546 return 0 unless $self->CurrentUser->PrincipalId == $principal->id;
547 # If it's an AdminCc and they don't have 'WatchAsAdminCc', bail
548 return 0 if $type eq 'AdminCc' and not $self->CurrentUserHasRight('WatchAsAdminCc');
549 # If it's a Requestor or Cc and they don't have 'Watch', bail
550 return 0 if ($type eq "Cc" or $type eq 'Requestor')
551 and not $self->CurrentUserHasRight('Watch');
558 Applies access control checking, then calls
559 L<RT::Record::Role::Roles/AddRoleMember>. Additionally, C<Email> is
560 accepted as an alternative argument name for C<User>.
562 Returns a tuple of (status, message).
570 PrincipalId => undef,
575 $args{ACL} = sub { $self->_HasModifyWatcherRight( @_ ) };
576 $args{User} ||= delete $args{Email};
577 my ($principal, $msg) = $self->AddRoleMember( %args );
578 return ( 0, $msg) unless $principal;
580 return ( 1, $self->loc("Added [_1] to members of [_2] for this queue.",
581 $principal->Object->Name, $self->loc($args{'Type'}) ));
587 Applies access control checking, then calls
588 L<RT::Record::Role::Roles/DeleteRoleMember>. Additionally, C<Email> is
589 accepted as an alternative argument name for C<User>.
591 Returns a tuple of (status, message).
600 PrincipalId => undef,
605 $args{ACL} = sub { $self->_HasModifyWatcherRight( @_ ) };
606 $args{User} ||= delete $args{Email};
607 my ($principal, $msg) = $self->DeleteRoleMember( %args );
608 return ( 0, $msg) unless $principal;
610 return ( 1, $self->loc("Removed [_1] from members of [_2] for this queue.",
611 $principal->Object->Name, $self->loc($args{'Type'}) ));
616 =head2 AdminCcAddresses
618 returns String: All queue AdminCc email addresses as a string
622 sub AdminCcAddresses {
625 unless ( $self->CurrentUserHasRight('SeeQueue') ) {
629 return ( $self->AdminCc->MemberEmailAddressesAsString )
637 returns String: All queue Ccs as a string of email addresses
644 unless ( $self->CurrentUserHasRight('SeeQueue') ) {
648 return ( $self->Cc->MemberEmailAddressesAsString);
657 Returns an RT::Group object which contains this Queue's Ccs.
658 If the user doesn't have "ShowQueue" permission, returns an empty group
665 return RT::Group->new($self->CurrentUser)
666 unless $self->CurrentUserHasRight('SeeQueue');
667 return $self->RoleGroup( 'Cc' );
675 Returns an RT::Group object which contains this Queue's AdminCcs.
676 If the user doesn't have "ShowQueue" permission, returns an empty group
683 return RT::Group->new($self->CurrentUser)
684 unless $self->CurrentUserHasRight('SeeQueue');
685 return $self->RoleGroup( 'AdminCc' );
690 # a generic routine to be called by IsRequestor, IsCc and IsAdminCc
692 =head2 IsWatcher { Type => TYPE, PrincipalId => PRINCIPAL_ID }
694 Takes a param hash with the attributes Type and PrincipalId
696 Type is one of Requestor, Cc, AdminCc and Owner
698 PrincipalId is an RT::Principal id
700 Returns true if that principal is a member of the group Type for this queue
708 my %args = ( Type => 'Cc',
709 PrincipalId => undef,
713 # Load the relevant group.
714 my $group = $self->RoleGroup( $args{'Type'} );
715 # Ask if it has the member in question
717 my $principal = RT::Principal->new($self->CurrentUser);
718 $principal->Load($args{'PrincipalId'});
719 unless ($principal->Id) {
723 return ($group->HasMemberRecursively($principal));
729 =head2 IsCc PRINCIPAL_ID
731 Takes an RT::Principal id.
732 Returns true if the principal is a requestor of the current queue.
741 return ( $self->IsWatcher( Type => 'Cc', PrincipalId => $cc ) );
747 =head2 IsAdminCc PRINCIPAL_ID
749 Takes an RT::Principal id.
750 Returns true if the principal is a requestor of the current queue.
758 return ( $self->IsWatcher( Type => 'AdminCc', PrincipalId => $person ) );
777 TransactionType => 'Set',
778 RecordTransaction => 1,
782 unless ( $self->CurrentUserHasRight('AdminQueue') ) {
783 return ( 0, $self->loc('Permission Denied') );
786 my $Old = $self->SUPER::_Value("$args{'Field'}");
788 my ($ret, $msg) = $self->SUPER::_Set(
789 Field => $args{'Field'},
790 Value => $args{'Value'},
793 if ( $ret == 0 ) { return ( 0, $msg ); }
795 RT->System->QueueCacheNeedsUpdate(1);
797 if ( $args{'RecordTransaction'} == 1 ) {
798 if ($args{'Field'} eq 'Disabled') {
799 $args{'TransactionType'} = ($args{'Value'} == 1) ? "Disabled" : "Enabled";
800 delete $args{'Field'};
802 my ( undef, undef, $TransObj ) = $self->_NewTransaction(
803 Type => $args{'TransactionType'},
804 Field => $args{'Field'},
805 NewValue => $args{'Value'},
807 TimeTaken => $args{'TimeTaken'},
811 return ( $ret, $msg );
819 unless ( $self->CurrentUserHasRight('SeeQueue') ) {
823 return ( $self->__Value(@_) );
826 =head2 CurrentUserCanSee
828 Returns true if the current user can see the queue, using SeeQueue
832 sub CurrentUserCanSee {
835 return $self->CurrentUserHasRight('SeeQueue');
840 Returns the current value of id.
841 (In the database, id is stored as int(11).)
849 Returns the current value of Name.
850 (In the database, Name is stored as varchar(200).)
858 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
859 (In the database, Name will be stored as a varchar(200).)
867 Returns the current value of Description.
868 (In the database, Description is stored as varchar(255).)
872 =head2 SetDescription VALUE
875 Set Description to VALUE.
876 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
877 (In the database, Description will be stored as a varchar(255).)
883 =head2 CorrespondAddress
885 Returns the current value of CorrespondAddress.
886 (In the database, CorrespondAddress is stored as varchar(120).)
890 =head2 SetCorrespondAddress VALUE
893 Set CorrespondAddress to VALUE.
894 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
895 (In the database, CorrespondAddress will be stored as a varchar(120).)
901 =head2 CommentAddress
903 Returns the current value of CommentAddress.
904 (In the database, CommentAddress is stored as varchar(120).)
908 =head2 SetCommentAddress VALUE
911 Set CommentAddress to VALUE.
912 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
913 (In the database, CommentAddress will be stored as a varchar(120).)
921 Returns the current value of Lifecycle.
922 (In the database, Lifecycle is stored as varchar(32).)
926 =head2 SetLifecycle VALUE
929 Set Lifecycle to VALUE.
930 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
931 (In the database, Lifecycle will be stored as a varchar(32).)
938 Returns the current value of SubjectTag.
939 (In the database, SubjectTag is stored as varchar(120).)
943 =head2 SetSubjectTag VALUE
946 Set SubjectTag to VALUE.
947 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
948 (In the database, SubjectTag will be stored as a varchar(120).)
954 =head2 InitialPriority
956 Returns the current value of InitialPriority.
957 (In the database, InitialPriority is stored as int(11).)
961 =head2 SetInitialPriority VALUE
964 Set InitialPriority to VALUE.
965 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
966 (In the database, InitialPriority will be stored as a int(11).)
974 Returns the current value of FinalPriority.
975 (In the database, FinalPriority is stored as int(11).)
979 =head2 SetFinalPriority VALUE
982 Set FinalPriority to VALUE.
983 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
984 (In the database, FinalPriority will be stored as a int(11).)
992 Returns the current value of DefaultDueIn.
993 (In the database, DefaultDueIn is stored as int(11).)
997 =head2 SetDefaultDueIn VALUE
1000 Set DefaultDueIn to VALUE.
1001 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
1002 (In the database, DefaultDueIn will be stored as a int(11).)
1010 Returns the current value of Creator.
1011 (In the database, Creator is stored as int(11).)
1019 Returns the current value of Created.
1020 (In the database, Created is stored as datetime.)
1026 =head2 LastUpdatedBy
1028 Returns the current value of LastUpdatedBy.
1029 (In the database, LastUpdatedBy is stored as int(11).)
1037 Returns the current value of LastUpdated.
1038 (In the database, LastUpdated is stored as datetime.)
1046 Returns the current value of Disabled.
1047 (In the database, Disabled is stored as smallint(6).)
1051 =head2 SetDisabled VALUE
1054 Set Disabled to VALUE.
1055 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
1056 (In the database, Disabled will be stored as a smallint(6).)
1063 sub _CoreAccessible {
1067 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
1069 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
1071 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
1072 CorrespondAddress =>
1073 {read => 1, write => 1, sql_type => 12, length => 120, is_blob => 0, is_numeric => 0, type => 'varchar(120)', default => ''},
1075 {read => 1, write => 1, sql_type => 12, length => 120, is_blob => 0, is_numeric => 0, type => 'varchar(120)', default => ''},
1077 {read => 1, write => 1, sql_type => 12, length => 120, is_blob => 0, is_numeric => 0, type => 'varchar(120)', default => ''},
1079 {read => 1, write => 1, sql_type => 12, length => 32, is_blob => 0, is_numeric => 0, type => 'varchar(32)', default => 'default'},
1081 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1083 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1085 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1087 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1089 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
1091 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1093 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
1095 {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
1100 sub FindDependencies {
1102 my ($walker, $deps) = @_;
1104 $self->SUPER::FindDependencies($walker, $deps);
1106 # Queue role groups( Cc, AdminCc )
1107 my $objs = RT::Groups->new( $self->CurrentUser );
1108 $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
1109 $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
1110 $deps->Add( in => $objs );
1113 $objs = RT::ObjectScrips->new( $self->CurrentUser );
1114 $objs->Limit( FIELD => 'ObjectId',
1117 ENTRYAGGREGATOR => 'OR' );
1118 $objs->Limit( FIELD => 'ObjectId',
1121 ENTRYAGGREGATOR => 'OR' );
1122 $deps->Add( in => $objs );
1124 # Templates (global ones have already been dealt with)
1125 $objs = RT::Templates->new( $self->CurrentUser );
1126 $objs->Limit( FIELD => 'Queue', VALUE => $self->Id);
1127 $deps->Add( in => $objs );
1129 # Custom Fields on things _in_ this queue (CFs on the queue itself
1130 # have already been dealt with)
1131 $objs = RT::ObjectCustomFields->new( $self->CurrentUser );
1132 $objs->Limit( FIELD => 'ObjectId',
1135 ENTRYAGGREGATOR => 'OR' );
1136 $objs->Limit( FIELD => 'ObjectId',
1139 ENTRYAGGREGATOR => 'OR' );
1140 my $cfs = $objs->Join(
1142 FIELD1 => 'CustomField',
1143 TABLE2 => 'CustomFields',
1146 $objs->Limit( ALIAS => $cfs,
1147 FIELD => 'LookupType',
1148 OPERATOR => 'STARTSWITH',
1149 VALUE => 'RT::Queue-' );
1150 $deps->Add( in => $objs );
1153 $objs = RT::Tickets->new( $self->CurrentUser );
1154 $objs->Limit( FIELD => "Queue", VALUE => $self->Id );
1155 $objs->{allow_deleted_search} = 1;
1156 $deps->Add( in => $objs );
1163 Dependencies => undef,
1166 my $deps = $args{'Dependencies'};
1170 my $objs = RT::Tickets->new( $self->CurrentUser );
1171 $objs->{'allow_deleted_search'} = 1;
1172 $objs->Limit( FIELD => 'Queue', VALUE => $self->Id );
1173 push( @$list, $objs );
1175 # Queue role groups( Cc, AdminCc )
1176 $objs = RT::Groups->new( $self->CurrentUser );
1177 $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
1178 $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
1179 push( @$list, $objs );
1182 $objs = RT::Scrips->new( $self->CurrentUser );
1183 $objs->LimitToQueue( $self->id );
1184 push( @$list, $objs );
1187 $objs = $self->Templates;
1188 push( @$list, $objs );
1191 $objs = RT::CustomFields->new( $self->CurrentUser );
1192 $objs->SetContextObject( $self );
1193 $objs->LimitToQueue( $self->id );
1194 push( @$list, $objs );
1196 $deps->_PushDependencies(
1197 BaseObject => $self,
1198 Flags => RT::Shredder::Constants::DEPENDS_ON,
1199 TargetObjects => $list,
1200 Shredder => $args{'Shredder'}
1202 return $self->SUPER::__DependsOn( %args );
1208 my ($importer, $uid, $data) = @_;
1210 $class->SUPER::PreInflate( $importer, $uid, $data );
1212 $data->{Name} = $importer->Qualify($data->{Name})
1213 if $data->{Name} ne "___Approvals";
1215 return if $importer->MergeBy( "Name", $class, $uid, $data );
1222 RT::Base->_ImportOverlays();