[rt-devel] Fwd: [rich+rt@lafferty.ca: [rt-users] Labeled priorities]

Bruce Campbell bc at ripe.net
Tue Feb 12 11:02:28 EST 2002


On Tue, 12 Feb 2002, Bruce Campbell wrote:

>
> On Mon, 11 Feb 2002, Peter E. Popovich wrote:
>
> > Don't laugh, but if you want to avoid re-implementing the wheel, take a look
> > at keywords.
> >
> > Keywords aren't linked to priorities, but you get a supported pulldown in
> > the UI, and don't have to tinker with the db schema. The task of synching
> > numeric priorities to the keyword label can be done by a crontab (for
> > prototyping purposes) or scrip (for final implementation).
>
> Hrm...
>
> Assuming that you'd like:
>
> 	OnSetKeyword SetPriorityFromKeyword with template KeywordPriorities
>
> then you'd need to insert_condition for OnSetKeyword to set
> ApplicableTransTypes to 'Keyword' with ExecModule of AnyTransaction, then:
>
> 	# SetPriorityFromKeyword.pm - RT ScripAction to set a priority based
> 	# on keyword
>
> 	package RT::Action::SetPriorityFromKeyword;
> 	require RT::Action::Generic;
> 	@ISA = qw(RT::Action::Generic);
>
> 	sub Prepare {
> 		# nothing really to do here
> 		my $self=shift;
>
> 		my $retval = undef;
>
> 		if( $self->TransactionObj->Type =~ /Keyword/ ){
> 			# protect against people putting this action in
> 			# a weird place
> 			$retval = 1;
> 		}
>
> 		return($retval);
> 	}
>
> 	sub Commit {
> 		my $self=shift;
>
> 		my $retval=undef;
> 		# Get the template.
> 		my @tsplit = split(/\n/, $self->$TemplateObj->Content);
> 		my %easy_chk = ();
> 		foreach my $thisline( @tsplit ){
> 			# template is ':' seperated, with 'keyword:priority'
> 			next unless( $thisline =~ /^\s*(\S+)\s*:\s*(\d+)\s*$/ );
> 			$easy_chk{"$1"} = $2;
> 		}
>
> 		# What did we set?  We check the 'Newvalue' field of our
> 		# Transaction.
> 		my $tmpval = $self->TransactionObj->NewValue();
>
> 		if( defined( $easy_chk{"$tmpval"} ) ){
> 			$retval = $self->TicketObj->SetPriority( $easy_chk{"$tmpval"} );
> 		}
>
> 		return( $retval );
> 	}
>
> 	1;
>
> The above is me rambling, and may or may not work for you.  The template
> should be a \n seperated list of 'keyword : priority_to_set'.
>
> Regards,
>
>
> --
>                              Bruce Campbell                            RIPE
>                    Systems/Network Engineer                             NCC
>                  www.ripe.net - PGP562C8B1B                      Operations
>
>
> _______________________________________________
> rt-devel mailing list
> rt-devel at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-devel
>


-- 
                             Bruce Campbell                            RIPE
                   Systems/Network Engineer                             NCC
                 www.ripe.net - PGP562C8B1B                      Operations





More information about the Rt-devel mailing list