X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FQueue.pm;h=b362c9f0d9b974a0d3bc71afa4d21432922c2da7;hp=1656903b36dc9f1c0b226e110df2dcba3d0d41a3;hb=ded0451e9582df33cae6099a2fb72b4ea25076cf;hpb=0ebeec96313dd7edfca340f01f8fbbbac1f4aa1d diff --git a/rt/lib/RT/Queue.pm b/rt/lib/RT/Queue.pm index 1656903b3..b362c9f0d 100755 --- a/rt/lib/RT/Queue.pm +++ b/rt/lib/RT/Queue.pm @@ -1,944 +1,371 @@ -# $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Queue.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $ +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK +# Autogenerated by DBIx::SearchBuilder factory (by ) +# WARNING: THIS FILE IS AUTOGENERATED. ALL CHANGES TO THIS FILE WILL BE LOST. +# +# !! DO NOT EDIT THIS FILE !! +# + +use strict; + =head1 NAME - RT::Queue - an RT Queue object +RT::Queue -=head1 SYNOPSIS - use RT::Queue; +=head1 SYNOPSIS =head1 DESCRIPTION - =head1 METHODS -=begin testing -use RT::TestHarness; - -use RT::Queue; - -=end testing - =cut - - package RT::Queue; -use RT::Record; - -@ISA= qw(RT::Record); - -use vars (@STATUS); - -@STATUS = qw(new open stalled resolved dead); - -=head2 StatusArray - -Returns an array of all statuses for this queue - -=cut - -sub StatusArray { - my $self = shift; - return (@STATUS); -} - - -=head2 IsValidStatus VALUE - -Returns true if VALUE is a valid status. Otherwise, returns 0 - -=for testing -my $q = new RT::Queue($RT::SystemUser); -ok($q->IsValidStatus('new')== 1, 'New is a valid status'); -ok($q->IsValidStatus('f00')== 0, 'f00 is not a valid status'); - -=cut - -sub IsValidStatus { - my $self = shift; - my $value = shift; - - my $retval = grep (/^$value$/, $self->StatusArray); - return ($retval); - -} - - - - -# {{{ sub _Init -sub _Init { - my $self = shift; - $self->{'table'} = "Queues"; - return ($self->SUPER::_Init(@_)); -} -# }}} - -# {{{ sub _Accessible - -sub _Accessible { - my $self = shift; - my %Cols = ( Name => 'read/write', - CorrespondAddress => 'read/write', - Description => 'read/write', - CommentAddress => 'read/write', - InitialPriority => 'read/write', - FinalPriority => 'read/write', - DefaultDueIn => 'read/write', - Creator => 'read/auto', - Created => 'read/auto', - LastUpdatedBy => 'read/auto', - LastUpdated => 'read/auto', - Disabled => 'read/write', - - ); - return($self->SUPER::_Accessible(@_, %Cols)); -} - -# }}} +use RT::Record; -# {{{ sub Create -=head2 Create +use vars qw( @ISA ); +@ISA= qw( RT::Record ); -Create takes the name of the new queue -If you pass the ACL check, it creates the queue and returns its queue id. +sub _Init { + my $self = shift; -=cut - -sub Create { - my $self = shift; - my %args = ( Name => undef, - CorrespondAddress => '', - Description => '', - CommentAddress => '', - InitialPriority => "0", - FinalPriority => "0", - DefaultDueIn => "0", - @_); - - unless ($self->CurrentUser->HasSystemRight('AdminQueue')) { #Check them ACLs - return (0, "No permission to create queues") - } - - unless ($self->ValidateName($args{'Name'})) { - return(0, 'Queue already exists'); - } - #TODO better input validation - - my $id = $self->SUPER::Create(%args); - unless ($id) { - return (0, 'Queue could not be created'); - } - - return ($id, "Queue $id created"); + $self->Table('Queues'); + $self->SUPER::_Init(@_); } -# }}} -# {{{ sub Delete -sub Delete { - my $self = shift; - return (0, 'Deleting this object would break referential integrity'); -} -# }}} -# {{{ sub SetDisabled +=item Create PARAMHASH -=head2 SetDisabled +Create takes a hash of values and creates a row in the database: -Takes a boolean. -1 will cause this queue to no longer be avaialble for tickets. -0 will re-enable this queue + varchar(200) 'Name'. + varchar(255) 'Description'. + varchar(120) 'CorrespondAddress'. + varchar(120) 'CommentAddress'. + int(11) 'InitialPriority'. + int(11) 'FinalPriority'. + int(11) 'DefaultDueIn'. + smallint(6) 'Disabled'. =cut -# }}} -# {{{ sub Load -=head2 Load -Takes either a numerical id or a textual Name and loads the specified queue. - -=cut - -sub Load { +sub Create { my $self = shift; - - my $identifier = shift; - if (!$identifier) { - return (undef); - } - - if ($identifier !~ /\D/) { - $self->SUPER::LoadById($identifier); - } - else { - $self->LoadByCol("Name", $identifier); - } - - return ($self->Id); + my %args = ( + Name => '', + Description => '', + CorrespondAddress => '', + CommentAddress => '', + InitialPriority => '0', + FinalPriority => '0', + DefaultDueIn => '0', + Disabled => '0', + @_); + $self->SUPER::Create( + Name => $args{'Name'}, + Description => $args{'Description'}, + CorrespondAddress => $args{'CorrespondAddress'}, + CommentAddress => $args{'CommentAddress'}, + InitialPriority => $args{'InitialPriority'}, + FinalPriority => $args{'FinalPriority'}, + DefaultDueIn => $args{'DefaultDueIn'}, + Disabled => $args{'Disabled'}, +); } -# }}} -# {{{ sub ValidateName -=head2 ValidateName NAME -Takes a queue name. Returns true if it's an ok name for -a new queue. Returns undef if there's already a queue by that name. +=item id -=cut +Returns the current value of id. +(In the database, id is stored as int(11).) -sub ValidateName { - my $self = shift; - my $name = shift; - - my $tempqueue = new RT::Queue($RT::SystemUser); - $tempqueue->Load($name); - - #If we couldn't load it :) - unless ($tempqueue->id()) { - return(1); - } - - #If this queue exists, return undef - #Avoid the ACL check. - if ($tempqueue->Name()){ - return(undef); - } - - #If the queue doesn't exist, return 1 - else { - return(1); - } - -} - - -# }}} - -# {{{ sub Templates - -=head2 Templates - -Returns an RT::Templates object of all of this queue's templates. =cut -sub Templates { - my $self = shift; - - my $templates = RT::Templates->new($self->CurrentUser); +=item Name - if ($self->CurrentUserHasRight('ShowTemplate')) { - $templates->LimitToQueue($self->id); - } - - return ($templates); -} - -# }}} +Returns the current value of Name. +(In the database, Name is stored as varchar(200).) -# {{{ Dealing with watchers -# {{{ sub Watchers -=head2 Watchers +=item SetName VALUE -Watchers returns a Watchers object preloaded with this queue\'s watchers. -=cut +Set Name to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, Name will be stored as a varchar(200).) -sub Watchers { - my $self = shift; - - require RT::Watchers; - my $watchers =RT::Watchers->new($self->CurrentUser); - - if ($self->CurrentUserHasRight('SeeQueue')) { - $watchers->LimitToQueue($self->id); - } - - return($watchers); -} - -# }}} - -# {{{ sub WatchersAsString -=head2 WatchersAsString - -Returns a string of all queue watchers email addresses concatenated with ','s. =cut -sub WatchersAsString { - my $self=shift; - return($self->Watchers->EmailsAsString()); -} - -# }}} - -# {{{ sub AdminCcAsString -=head2 AdminCcAsString +=item Description -Takes nothing. returns a string: All Ticket/Queue AdminCcs. +Returns the current value of Description. +(In the database, Description is stored as varchar(255).) -=cut -sub AdminCcAsString { - my $self=shift; - - return($self->AdminCc->EmailsAsString()); - } +=item SetDescription VALUE -# }}} -# {{{ sub CcAsString +Set Description to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, Description will be stored as a varchar(255).) -=head2 CcAsString - -B String: All Queue Ccs as a comma delimited set of email addresses. =cut -sub CcAsString { - my $self=shift; - - return ($self->Cc->EmailsAsString()); -} - -# }}} - -# {{{ sub Cc - -=head2 Cc - -Takes nothing. -Returns a watchers object which contains this queue\'s Cc watchers -=cut +=item CorrespondAddress -sub Cc { - my $self = shift; - my $cc = $self->Watchers(); - if ($self->CurrentUserHasRight('SeeQueue')) { - $cc->LimitToCc(); - } - return ($cc); -} +Returns the current value of CorrespondAddress. +(In the database, CorrespondAddress is stored as varchar(120).) -# A helper function for Cc, so that we can call it from the ACL checks -# without going through acl checks. -sub _Cc { - my $self = shift; - my $cc = $self->Watchers(); - $cc->LimitToCc(); - return($cc); - -} -# }}} +=item SetCorrespondAddress VALUE -# {{{ sub AdminCc -=head2 AdminCc +Set CorrespondAddress to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, CorrespondAddress will be stored as a varchar(120).) -Takes nothing. -Returns this queue's administrative Ccs as an RT::Watchers object =cut -sub AdminCc { - my $self = shift; - my $admin_cc = $self->Watchers(); - if ($self->CurrentUserHasRight('SeeQueue')) { - $admin_cc->LimitToAdminCc(); - } - return($admin_cc); -} - -#helper function for AdminCc so we can call it without ACLs -sub _AdminCc { - my $self = shift; - my $admin_cc = $self->Watchers(); - $admin_cc->LimitToAdminCc(); - return($admin_cc); -} -# }}} +=item CommentAddress -# {{{ IsWatcher, IsCc, IsAdminCc - -# {{{ sub IsWatcher - -# a generic routine to be called by IsRequestor, IsCc and IsAdminCc - -=head2 IsWatcher - -Takes a param hash with the attributes Type and User. User is either a user object or string containing an email address. Returns true if that user or string -is a queue watcher. Returns undef otherwise - -=cut - -sub IsWatcher { - my $self = shift; - - my %args = ( Type => 'Requestor', - Id => undef, - Email => undef, - @_ - ); - #ACL check - can't do it. we need this method for ACL checks - # unless ($self->CurrentUserHasRight('SeeQueue')) { - # return(undef); - # } - - - my %cols = ('Type' => $args{'Type'}, - 'Scope' => 'Queue', - 'Value' => $self->Id - ); - if (defined ($args{'Id'})) { - if (ref($args{'Id'})){ #If it's a ref, assume it's an RT::User object; - #Dangerous but ok for now - $cols{'Owner'} = $args{'Id'}->Id; - } - elsif ($args{'Id'} =~ /^\d+$/) { # if it's an integer, it's an RT::User obj - $cols{'Owner'} = $args{'Id'}; - } - else { - $cols{'Email'} = $args{'Id'}; - } - } - - if (defined $args{'Email'}) { - $cols{'Email'} = $args{'Email'}; - } - - my ($description); - $description = join(":",%cols); - - #If we've cached a positive match... - if (defined $self->{'watchers_cache'}->{"$description"}) { - if ($self->{'watchers_cache'}->{"$description"} == 1) { - return(1); - } - #If we've cached a negative match... - else { - return(undef); - } - } - - require RT::Watcher; - my $watcher = new RT::Watcher($self->CurrentUser); - $watcher->LoadByCols(%cols); - - - if ($watcher->id) { - $self->{'watchers_cache'}->{"$description"} = 1; - return(1); - } - else { - $self->{'watchers_cache'}->{"$description"} = 0; - return(undef); - } - -} +Returns the current value of CommentAddress. +(In the database, CommentAddress is stored as varchar(120).) -# }}} -# {{{ sub IsCc -=head2 IsCc +=item SetCommentAddress VALUE -Takes a string. Returns true if the string is a Cc watcher of the current queue -=item Bugs +Set CommentAddress to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, CommentAddress will be stored as a varchar(120).) -Should also be able to handle an RT::User object =cut -sub IsCc { - my $self = shift; - my $cc = shift; - - return ($self->IsWatcher( Type => 'Cc', Id => $cc )); - -} - -# }}} - -# {{{ sub IsAdminCc - -=head2 IsAdminCc - -Takes a string. Returns true if the string is an AdminCc watcher of the current queue +=item InitialPriority -=item Bugs +Returns the current value of InitialPriority. +(In the database, InitialPriority is stored as int(11).) -Should also be able to handle an RT::User object - -=cut - -sub IsAdminCc { - my $self = shift; - my $admincc = shift; - - return ($self->IsWatcher( Type => 'AdminCc', Id => $admincc )); - -} -# }}} -# }}} +=item SetInitialPriority VALUE -# {{{ sub AddWatcher -=head2 AddWatcher +Set InitialPriority to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, InitialPriority will be stored as a int(11).) -Takes a paramhash of Email, Owner and Type. Type is one of 'Cc' or 'AdminCc', -We need either an Email Address in Email or a userid in Owner =cut -sub AddWatcher { - my $self = shift; - my %args = ( Email => undef, - Type => undef, - Owner => 0, - @_ - ); - - # {{{ Check ACLS - #If the watcher we're trying to add is for the current user - if ( ( ( defined $args{'Email'}) && - ( $args{'Email'} eq $self->CurrentUser->EmailAddress) ) or - ($args{'Owner'} eq $self->CurrentUser->Id)) { - - # If it's an AdminCc and they don't have - # 'WatchAsAdminCc' or 'ModifyQueueWatchers', bail - if ($args{'Type'} eq 'AdminCc') { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or - $self->CurrentUserHasRight('WatchAsAdminCc')) { - return(0, 'Permission Denied'); - } - } - - # If it's a Requestor or Cc and they don't have - # 'Watch' or 'ModifyQueueWatchers', bail - elsif ($args{'Type'} eq 'Cc') { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or - $self->CurrentUserHasRight('Watch')) { - return(0, 'Permission Denied'); - } - } - else { - $RT::Logger->warn("$self -> AddWatcher hit code". - " it never should. We got passed ". - " a type of ". $args{'Type'}); - return (0,'Error in parameters to $self AddWatcher'); - } - } - # If the watcher isn't the current user - # and the current user doesn't have 'ModifyQueueWatchers' - # bail - else { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers')) { - return (0, "Permission Denied"); - } - } - # }}} - - require RT::Watcher; - my $Watcher = new RT::Watcher ($self->CurrentUser); - return ($Watcher->Create(Scope => 'Queue', - Value => $self->Id, - Email => $args{'Email'}, - Type => $args{'Type'}, - Owner => $args{'Owner'} - )); -} -# }}} +=item FinalPriority -# {{{ sub AddCc +Returns the current value of FinalPriority. +(In the database, FinalPriority is stored as int(11).) -=head2 AddCc -Add a Cc to this queue. -Takes a paramhash of Email and Owner. -We need either an Email Address in Email or a userid in Owner -=cut +=item SetFinalPriority VALUE -sub AddCc { - my $self = shift; - return ($self->AddWatcher( Type => 'Cc', @_)); -} -# }}} +Set FinalPriority to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, FinalPriority will be stored as a int(11).) -# {{{ sub AddAdminCc - -=head2 AddAdminCc - -Add an Administrative Cc to this queue. -Takes a paramhash of Email and Owner. -We need either an Email Address in Email or a userid in Owner =cut -sub AddAdminCc { - my $self = shift; - return ($self->AddWatcher( Type => 'AdminCc', @_)); -} -# }}} - -# {{{ sub DeleteWatcher - -=head2 DeleteWatcher id [type] -DeleteWatcher takes a single argument which is either an email address -or a watcher id. -If the first argument is an email address, you need to specify the watcher type you're talking -about as the second argument. Valid values are 'Cc' or 'AdminCc'. -It removes that watcher from this Queue\'s list of watchers. +=item DefaultDueIn +Returns the current value of DefaultDueIn. +(In the database, DefaultDueIn is stored as int(11).) -=cut -sub DeleteWatcher { - my $self = shift; - my $id = shift; - - my $type; - - $type = shift if (@_); - - - require RT::Watcher; - my $Watcher = new RT::Watcher($self->CurrentUser); - - #If it\'s a numeric watcherid - if ($id =~ /^(\d*)$/) { - $Watcher->Load($id); - } - - #Otherwise, we'll assume it's an email address - elsif ($type) { - my ($result, $msg) = - $Watcher->LoadByValue( Email => $id, - Scope => 'Queue', - Value => $self->id, - Type => $type); - return (0,$msg) unless ($result); - } - - else { - return(0,"Can\'t delete a watcher by email address without specifying a type"); - } - - # {{{ Check ACLS - - #If the watcher we're trying to delete is for the current user - if ($Watcher->Email eq $self->CurrentUser->EmailAddress) { - - # If it's an AdminCc and they don't have - # 'WatchAsAdminCc' or 'ModifyQueueWatchers', bail - if ($Watcher->Type eq 'AdminCc') { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or - $self->CurrentUserHasRight('WatchAsAdminCc')) { - return(0, 'Permission Denied'); - } - } - - # If it's a Cc and they don't have - # 'Watch' or 'ModifyQueueWatchers', bail - elsif ($Watcher->Type eq 'Cc') { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or - $self->CurrentUserHasRight('Watch')) { - return(0, 'Permission Denied'); - } - } - else { - $RT::Logger->warn("$self -> DeleteWatcher hit code". - " it never should. We got passed ". - " a type of ". $args{'Type'}); - return (0,'Error in parameters to $self DeleteWatcher'); - } - } - # If the watcher isn't the current user - # and the current user doesn't have 'ModifyQueueWatchers' - # bail - else { - unless ($self->CurrentUserHasRight('ModifyQueueWatchers')) { - return (0, "Permission Denied"); - } - } - - # }}} - - unless (($Watcher->Scope eq 'Queue') and - ($Watcher->Value == $self->id) ) { - return (0, "Not a watcher for this queue"); - } - - - #Clear out the watchers hash. - $self->{'watchers'} = undef; - - my $retval = $Watcher->Delete(); - - unless ($retval) { - return(0,"Watcher could not be deleted."); - } - - return(1, "Watcher deleted"); -} - -# {{{ sub DeleteCc +=item SetDefaultDueIn VALUE -=head2 DeleteCc EMAIL -Takes an email address. It calls DeleteWatcher with a preset -type of 'Cc' +Set DefaultDueIn to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, DefaultDueIn will be stored as a int(11).) =cut -sub DeleteCc { - my $self = shift; - my $id = shift; - return ($self->DeleteWatcher ($id, 'Cc')) -} - -# }}} -# {{{ sub DeleteAdminCc +=item Creator -=head2 DeleteAdminCc EMAIL - -Takes an email address. It calls DeleteWatcher with a preset -type of 'AdminCc' +Returns the current value of Creator. +(In the database, Creator is stored as int(11).) =cut -sub DeleteAdminCc { - my $self = shift; - my $id = shift; - return ($self->DeleteWatcher ($id, 'AdminCc')) -} -# }}} +=item Created +Returns the current value of Created. +(In the database, Created is stored as datetime.) -# }}} - -# }}} - -# {{{ Dealing with keyword selects - -# {{{ sub AddKeywordSelect - -=head2 AddKeywordSelect - -Takes a paramhash of Name, Keyword, Depth and Single. Adds a new KeywordSelect for -this queue with those attributes. =cut -sub AddKeywordSelect { - my $self = shift; - my %args = ( Keyword => undef, - Depth => undef, - Single => undef, - Name => undef, - @_); - - #ACLS get handled in KeywordSelect - my $NewKeywordSelect = new RT::KeywordSelect($self->CurrentUser); - - return ($NewKeywordSelect->Create (Keyword => $args{'Keyword'}, - Depth => $args{'Depth'}, - Name => $args{'Name'}, - Single => $args{'Single'}, - ObjectType => 'Ticket', - ObjectField => 'Queue', - ObjectValue => $self->Id() - ) ); -} - -# }}} - -# {{{ sub KeywordSelect +=item LastUpdatedBy -=head2 KeywordSelect([NAME]) +Returns the current value of LastUpdatedBy. +(In the database, LastUpdatedBy is stored as int(11).) -Takes the name of a keyword select for this queue or that's global. -Returns the relevant KeywordSelect object. Prefers a keywordselect that's -specific to this queue over a global one. If it can't find the proper -Keword select or the user doesn't have permission, returns an empty -KeywordSelect object =cut -sub KeywordSelect { - my $self = shift; - my $name = shift; - - require RT::KeywordSelect; - - my $select = RT::KeywordSelect->new($self->CurrentUser); - if ($self->CurrentUserHasRight('SeeQueue')) { - $select->LoadByName( Name => $name, Queue => $self->Id); - } - return ($select); -} - -# }}} +=item LastUpdated -# {{{ sub KeywordSelects +Returns the current value of LastUpdated. +(In the database, LastUpdated is stored as datetime.) -=head2 KeywordSelects - -Returns an B object containing the collection of -B objects which apply to this queue. (Both queue specific keyword selects -and global keyword selects. =cut -sub KeywordSelects { - my $self = shift; +=item Disabled - use RT::KeywordSelects; - my $KeywordSelects = new RT::KeywordSelects($self->CurrentUser); +Returns the current value of Disabled. +(In the database, Disabled is stored as smallint(6).) - if ($self->CurrentUserHasRight('SeeQueue')) { - $KeywordSelects->LimitToQueue($self->id); - $KeywordSelects->IncludeGlobals(); - } - return ($KeywordSelects); -} -# }}} -# }}} -# {{{ ACCESS CONTROL +=item SetDisabled VALUE -# {{{ sub ACL -=head2 ACL +Set Disabled to VALUE. +Returns (1, 'Status message') on success and (0, 'Error Message') on failure. +(In the database, Disabled will be stored as a smallint(6).) -#Returns an RT::ACL object of ACEs everyone who has anything to do with this queue. =cut -sub ACL { - my $self = shift; - - use RT::ACL; - my $acl = new RT::ACL($self->CurrentUser); - - if ($self->CurrentUserHasRight('ShowACL')) { - $acl->LimitToQueue($self->Id); - } - - return ($acl); -} - -# }}} - -# {{{ sub _Set -sub _Set { - my $self = shift; - unless ($self->CurrentUserHasRight('AdminQueue')) { - return(0, 'Permission Denied'); - } - return ($self->SUPER::_Set(@_)); -} -# }}} -# {{{ sub _Value +sub _ClassAccessible { + { + + id => + {read => 1, type => 'int(11)', default => ''}, + Name => + {read => 1, write => 1, type => 'varchar(200)', default => ''}, + Description => + {read => 1, write => 1, type => 'varchar(255)', default => ''}, + CorrespondAddress => + {read => 1, write => 1, type => 'varchar(120)', default => ''}, + CommentAddress => + {read => 1, write => 1, type => 'varchar(120)', default => ''}, + InitialPriority => + {read => 1, write => 1, type => 'int(11)', default => '0'}, + FinalPriority => + {read => 1, write => 1, type => 'int(11)', default => '0'}, + DefaultDueIn => + {read => 1, write => 1, type => 'int(11)', default => '0'}, + Creator => + {read => 1, auto => 1, type => 'int(11)', default => '0'}, + Created => + {read => 1, auto => 1, type => 'datetime', default => ''}, + LastUpdatedBy => + {read => 1, auto => 1, type => 'int(11)', default => '0'}, + LastUpdated => + {read => 1, auto => 1, type => 'datetime', default => ''}, + Disabled => + {read => 1, write => 1, type => 'smallint(6)', default => '0'}, -sub _Value { - my $self = shift; + } +}; - unless ($self->CurrentUserHasRight('SeeQueue')) { - return (undef); - } - return ($self->__Value(@_)); -} + eval "require RT::Queue_Overlay"; + if ($@ && $@ !~ qr{^Can't locate RT/Queue_Overlay.pm}) { + die $@; + }; -# }}} + eval "require RT::Queue_Vendor"; + if ($@ && $@ !~ qr{^Can't locate RT/Queue_Vendor.pm}) { + die $@; + }; -# {{{ sub CurrentUserHasRight + eval "require RT::Queue_Local"; + if ($@ && $@ !~ qr{^Can't locate RT/Queue_Local.pm}) { + die $@; + }; -=head2 CurrentUserHasRight -Takes one argument. A textual string with the name of the right we want to check. -Returns true if the current user has that right for this queue. -Returns undef otherwise. -=cut -sub CurrentUserHasRight { - my $self = shift; - my $right = shift; +=head1 SEE ALSO - return ($self->HasRight( Principal=> $self->CurrentUser, - Right => "$right")); +This class allows "overlay" methods to be placed +into the following files _Overlay is for a System overlay by the original author, +_Vendor is for 3rd-party vendor add-ons, while _Local is for site-local customizations. -} +These overlay files can contain new subs or subs to replace existing subs in this module. -# }}} +If you'll be working with perl 5.6.0 or greater, each of these files should begin with the line -# {{{ sub HasRight + no warnings qw(redefine); -=head2 HasRight +so that perl does not kick and scream when you redefine a subroutine or variable in your overlay. -Takes a param hash with the fields 'Right' and 'Principal'. -Principal defaults to the current user. -Returns true if the principal has that right for this queue. -Returns undef otherwise. +RT::Queue_Overlay, RT::Queue_Vendor, RT::Queue_Local =cut -# TAKES: Right and optional "Principal" which defaults to the current user -sub HasRight { - my $self = shift; - my %args = ( Right => undef, - Principal => $self->CurrentUser, - @_); - unless(defined $args{'Principal'}) { - $RT::Logger->debug("Principal undefined in Queue::HasRight"); - - } - return($args{'Principal'}->HasQueueRight(QueueObj => $self, - Right => $args{'Right'})); -} -# }}} - -# }}} 1;