[rt-users] scrip action - currentUser
vinita vigine MURUGIAH
vinita at cs.mu.OZ.AU
Fri Apr 30 02:14:36 EDT 2004
HI
I'm trying to auto open tickets only for users who don't have ticket
modification rights
if I remove
$self->TicketObj->CurrentUserHasRight('ModifyTicket')
it works, otherwise I get following error in rt.log
[Fri Apr 30 05:57:34 2004] [info]: RT::Scrip=HASH(0x9606ec8): Couldn't prepare Open Tickets for Users (/usr/local/apps/rt-3.0.8//lib/RT/Scrip_Overlay.pm:346)
Is it possible to access the current users from the scrip action???
Thanks
--------------------------------------------------------------------------------------
package RT::Action::AutoOpenForUsers;
require RT::Action::Generic;
use strict;
use vars qw/@ISA/;
@ISA=qw(RT::Action::Generic);
#Do what we need to do and send it out.
#What does this type of Action does
# {{{ sub Describe
sub Describe {
my $self = shift;
return (ref $self );
}
# }}}
# {{{ sub Prepare
sub Prepare {
my $self = shift;
# if the user has status change right don't auto change it for them
# if the ticket is already open or new then don't (re)open either.
if ( ($self->TicketObj->CurrentUserHasRight('ModifyTicket'))
|| ( $self->TicketObj->Status eq 'open' )
|| ( $self->TicketObj->Status eq 'new' ) ) {
return undef;
}
else {
return (1);
}
}
# }}}
sub Commit {
my $self = shift;
my $oldstatus = $self->TicketObj->Status();
my $newstatus = ($oldstatus eq 'stalled') ? 'open' : 'new';
$self->TicketObj->__Set( Field => 'Status', Value => $newstatus );
$self->TicketObj->_NewTransaction(
Type => 'Status',
Field => 'Status',
OldValue => $oldstatus,
NewValue => $newstatus,
Data => 'Ticket auto-opened ticket for users'
);
return(1);
}
eval "require RT::Action::AutoOpenForUsers_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/AutoOpenForUsers_Vendor.pm});
eval "require RT::Action::AutoOpenForUsers_Local";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/AutoOpenForUsers_Local.pm});
1;
mysql> select * from ScripActions where id=16;
+----+------------------------+--------------------------------+------------------+----------+---------+---------+---------------+-------------+
| id | Name | Description | ExecModule | Argument | Creator | Created | LastUpdatedBy | LastUpdated |
+----+------------------------+--------------------------------+------------------+----------+---------+---------+---------------+-------------+
| 16 | Open Tickets for Users | Open tickets on correspondence | AutoOpenForUsers | NULL | 0 | NULL | 0 | NULL |
+----+------------------------+--------------------------------+------------------+----------+---------+---------+---------------+-------------+
--
warm regards
Vinita Vigine Murugiah
Email : vinita at cs.mu.oz.au Ph : (03) 8344 1273
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20040430/068f2800/attachment.htm>
More information about the rt-users
mailing list