use RT::Ticket; my $ticket = new RT::Ticket($CurrentUser); $ticket->Load($ticket_id);
This module lets you manipulate RT\'s ticket object.
Takes a single argument. This can be a ticket id, ticket alias or local ticket uri. If the ticket can't be loaded, returns undef. Otherwise, returns the ticket id.
Given a local ticket URI, loads the specified ticket.
Arguments: ARGS is a hash of named parameters. Valid parameters are:
id Queue - Either a Queue object or a Queue Name Requestor - A reference to a list of RT::User objects, email addresses or RT user Names Cc - A reference to a list of RT::User objects, email addresses or Names AdminCc - A reference to a list of RT::User objects, email addresses or Names Type -- The ticket\'s type. ignore this for now Owner -- This ticket\'s owner. either an RT::User object or this user\'s id Subject -- A string describing the subject of the ticket InitialPriority -- an integer from 0 to 99 FinalPriority -- an integer from 0 to 99 Status -- any valid status (Defined in RT::Queue) TimeEstimated -- an integer. estimated time for this task in minutes TimeWorked -- an integer. time worked so far in minutes TimeLeft -- an integer. time remaining in minutes Starts -- an ISO date describing the ticket\'s start date and time in GMT Due -- an ISO date describing the ticket\'s due date and time in GMT MIMEObj -- a MIME::Entity object with the content of the initial ticket request. CustomField-<n> -- a scalar or array of values for the customfield with the id <n>
Returns: TICKETID, Transaction Object, Error Message
This code replaces what was once a large part of the email gateway. It takes an email message as a parameter, parses out the sender, subject and a MIME object. It then creates a ticket based on those attributes
CreateTickets uses the template as a template for an ordered set of tickets to create. The basic format is as follows:
===Create-Ticket: identifier Param: Value Param2: Value Param3: Value Content: Blah blah blah ENDOFCONTENT =head2 Acceptable fields
A complete list of acceptable fields for this beastie:
* Queue => Name or id# of a queue Subject => A text string Status => A valid status. defaults to 'new'
Due => Dates can be specified in seconds since the epoch to be handled literally or in a semi-free textual format which RT will attempt to parse. Starts => Started => Resolved => Owner => Username or id of an RT user who can and should own this ticket + Requestor => Email address + Cc => Email address + AdminCc => Email address TimeWorked => TimeEstimated => TimeLeft => InitialPriority => FinalPriority => Type => + DependsOn => + DependedOnBy => + RefersTo => + ReferredToBy => + Members => + MemberOf => Content => content. Can extend to multiple lines. Everything within a template after a Content: header is treated as content until we hit a line containing only ENDOFCONTENT ContentType => the content-type of the Content field CustomField-<id#> => custom field value
Fields marked with an * are required.
Fields marked with a + man have multiple values, simply by repeating the fieldname on a new line with an additional value.
When parsed, field names are converted to lowercase and have -s stripped. Refers-To, RefersTo, refersto, refers-to and r-e-f-er-s-tO will all be treated as the same thing.
Takes an RFC822 format message as a string and uses it to make a bunch of changes to a ticket. Returns an um. ask me again when the code exists
Takes an RFC822 style message and parses its attributes into a hash.
Import a ticket. Doesn\'t create a transaction. Doesn\'t supply queue defaults, etc.
Returns: TICKETID
Create the ticket groups and relationships for this ticket. This routine expects to be called from Ticket->Create _inside of a transaction_
It will create four groups for this ticket: Requestor, Cc, AdminCc and Owner.
It will return true on success and undef on failure.
A constructor which returns an RT::Group object containing the owner of this ticket.
AddWatcher takes a parameter hash. The keys are as follows:
Type One of Requestor, Cc, AdminCc
PrinicpalId The RT::Principal id of the user or group that's being added as a watcher
Email The email address of the new watcher. If a user with this email address can't be found, a new nonprivileged user will be created.
If the watcher you\'re trying to set has an RT account, set the Owner paremeter to their User Id. Otherwise, set the Email parameter to their Email address.
Deletes a Ticket watcher. Takes two arguments:
Type (one of Requestor,Cc,AdminCc)
and one of
PrincipalId (an RT::Principal Id of the watcher you want to remove) OR Email (the email address of an existing wathcer)
B<Returns> String: All Ticket Requestor email addresses as a string.
returns String: All Ticket AdminCc email addresses as a string
returns String: All Ticket Ccs as a string of email addresses
Takes nothing. Returns this ticket's Requestors as an RT::Group object
Takes nothing. Returns an RT::Group object which contains this ticket's Ccs. If the user doesn't have "ShowTicket" permission, returns an empty group
Takes nothing. Returns an RT::Group object which contains this ticket's AdminCcs. If the user doesn't have "ShowTicket" permission, returns an empty group
Takes a param hash with the attributes Type and either PrincipalId or Email
Type is one of Requestor, Cc, AdminCc and Owner
PrincipalId is an RT::Principal id, and Email is an email address.
Returns true if the specified principal (or the one corresponding to the specified address) is a member of the group Type for this ticket.
Takes an RT::Principal id. Returns true if the principal is a requestor of the current ticket.
Takes an RT::Principal id. Returns true if the principal is a requestor of the current ticket.
Takes an RT::User object. Returns true if that user is this ticket's owner. returns undef otherwise
Takes nothing. returns this ticket's queue object
Returns an RT::Date object containing this ticket's due date
Returns this ticket's due date as a human readable string
Returns an RT::Date object of this ticket's 'resolved' time.
Takes a date in ISO format or undef Returns a transaction id and a message The client calls "Start" to note that the project was started on the date in $date. A null date means "now"
Returns an RT::Date object which contains this ticket's 'Started' time.
Returns an RT::Date object which contains this ticket's 'Starts' time.
Returns an RT::Date object which contains this ticket's 'Told' time.
A convenience method that returns ToldObj->AsString
TODO: This should be deprecated
Returns the amount of time worked on this ticket as a Text String
Comment on this ticket. Takes a hashref with the following attributes: If MIMEObj is undefined, Content will be used to build a MIME::Entity for this commentl
MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content.
Correspond on this ticket. Takes a hashref with the following attributes:
MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content
if there's no MIMEObj, Content is used to build a MIME::Entity object
This returns an RT::Links object which references all the tickets which are 'MembersOf' this ticket
This returns an RT::Links object which references all the tickets that this ticket is a 'MemberOf'
This returns an RT::Links object which shows all references for which this ticket is a base
This returns an RT::Links object which shows all references for which this ticket is a target
This returns an RT::Links object which references all the tickets that depend on this one
Takes a paramhash of Type (default to '__any'). Returns true if $self->UnresolvedDependencies returns an object with one or more members of that type. Returns false otherwise
Returns an RT::Tickets object of tickets which this ticket depends on and which have a status of new, open or stalled. (That list comes from RT::Queue->ActiveStatusArray
Returns an array of RT::Ticket objects which (directly or indirectly) depends on this ticket; takes an optional 'Type' argument in the param hash, which will limit returned tickets to that type, as well as cause tickets with that type to serve as 'leaf' nodes that stops the recursive dependency search.
This returns an RT::Links object which references all the tickets that this ticket depends on
Delete a link. takes a paramhash of Base, Target and Type. Either Base or Target must be null. The null value will be replaced with this ticket\'s id
Takes a paramhash of Type and one of Base or Target. Adds that link to this ticket.
Returns this ticket's URI
Takes nothing and returns an RT::User object of this ticket's owner
Returns the owner's email address
Takes two arguments: the Id or Name of the owner and (optionally) the type of the SetOwner Transaction. It defaults to 'Give'. 'Steal' is also a valid option.
A convenince method to set the ticket's owner to the current user
Convenience method to set the owner to 'nobody' if the current user is the owner.
A convenience method to change the owner of the current ticket to the current user. Even if it's owned by another user.
Takes a string. Returns true if that status is a valid status for this ticket. Returns false otherwise.
Set this ticket\'s status. STATUS can be one of: new, open, stalled, resolved, rejected or deleted.
Alternatively, you can pass in a list of named parameters (Status => STATUS, Force => FORCE). If FORCE is true, ignore unresolved dependencies and force a status change.
Takes no arguments. Marks this ticket for garbage collection
Sets this ticket's status to stalled
Sets this ticket's status to rejected
Sets this ticket\'s status to Open
Sets this ticket\'s status to Resolved
Return the content of the first value of CustomField FIELD for this ticket Takes a field id or name
Return a TicketCustomFieldValues object of all values of CustomField FIELD for this ticket. Takes a field id or name.
VALUE should be a string. FIELD can be a CustomField object OR a CustomField ID.
Adds VALUE as a value of CustomField FIELD. If this is a single-value custom field, deletes the old value. If VALUE isn't a valid value for the custom field, returns (0, 'Error message' ) otherwise, returns (1, 'Success Message')
Deletes VALUE as a value of CustomField FIELD.
VALUE can be a string, a CustomFieldValue or a TicketCustomFieldValue.
If VALUE isn't a valid value for the custom field, returns (0, 'Error message' ) otherwise, returns (1, 'Success Message')
Updates the told and records a transaction
Updates the told without a transaction or acl check. Useful when we're sending replies.
Returns an RT::Transactions object of all transactions on this ticket
Returns an array reference of all transactions created on this ticket during this ticket object's lifetime, or undef if there were none.
Only works when the $RT::UseTransactionBatch config variable is set to true.
Takes the name of a table column. Returns its value as a string, if the user passes an ACL check
This routine will increment the timeworked counter. it should only be called from _NewTransaction
Takes the textual name of a Ticket scoped right (from RT::ACE) and returns 1 if the user has that right. It returns 0 if the user doesn't have that right.
Takes a paramhash with the attributes 'Right' and 'Principal' 'Right' is a ticket-scoped textual right from RT::ACE 'Principal' is an RT::User object
Returns 1 if the principal has the right. Returns undef if not.
Jesse Vincent, jesse@bestpractical.com
RT