Functions

Add a ticket type.

add_ticket_type(\SHORT_TEXT $ticket_type_name, \BINARY $guest_emails_mandatory = 0, \BINARY $search_faq = 0) : \AUTO_LINK
package tickets

Parameters

$ticket_type_name

\SHORT_TEXT

The ticket type name

$guest_emails_mandatory

\BINARY

Whether guest e-mail addresses are mandatory for new tickets

$search_faq

\BINARY

Whether the FAQ should be searched before submitting a new ticket

Returns

\AUTO_LINKThe ticket type ID

Build a list of ticket types.

build_types_list(\?AUTO_LINK $selected_ticket_type_id, \?array $ticket_types_to_let_through = null) : array
package tickets

Parameters

$selected_ticket_type_id

\?AUTO_LINK

The current selected ticket type (null: none)

$ticket_types_to_let_through

\?array

List of ticket types to show regardless of access permissions (null: none)

Returns

arrayA map between ticket types, and template-ready details about them

Checks the ticket ID is valid, and there is access for the current member to view it. Bombs out if there's a problem.

check_ticket_access(string $id) : \MEMBER
package tickets

Parameters

$id

string

The ticket ID to check

Returns

\MEMBERThe ticket owner

Remove a ticket from the database. This does not remove the associated forum topic.

delete_ticket_by_topic_id(\AUTO_LINK $topic_id) 
package tickets

Parameters

$topic_id

\AUTO_LINK

The associated topic ID

Delete a ticket type.

delete_ticket_type(\AUTO_LINK $ticket_type_id) 
package tickets

Parameters

$ticket_type_id

\AUTO_LINK

The ticket type ID

Edit a ticket type, keeping the integer ID the same.

edit_ticket_type(\AUTO_LINK $ticket_type_id, \?SHORT_TEXT $ticket_type_name, \BINARY $guest_emails_mandatory, \BINARY $search_faq) 
package tickets

Parameters

$ticket_type_id

\AUTO_LINK

The ticket type ID

$ticket_type_name

\?SHORT_TEXT

The new ticket type text (null: do not change)

$guest_emails_mandatory

\BINARY

Whether guest e-mail addresses are mandatory for new tickets

$search_faq

\BINARY

Whether the FAQ should be searched before submitting a new ticket

Convert e-mail HTML to Comcode.

email_comcode_from_html(string $body) : string
package tickets

Parameters

$body

string

HTML body

Returns

stringComcode version

Convert e-mail text to Comcode.

email_comcode_from_text(string $body) : string
package tickets

Parameters

$body

string

Text body

Returns

stringComcode version

Build a list of ticket types.

find_ticket_assigned_to(\ID_TEXT $ticket_id) : array
package tickets

Parameters

$ticket_id

\ID_TEXT

Ticket ID

Returns

arrayMap of assigned members (member ID to display name)

Get ticket details.

get_ticket_details(string $ticket_id, boolean $hard_error = true) : \?array
package tickets

Parameters

$ticket_id

string

The ticket ID

$hard_error

boolean

Exit with an error message if it cannot find the ticket

Returns

\?arrayA tuple: The ticket title, the topic ID, the ticket type ID, the ticket owner (null: not found)

Get the forum ID for a given ticket type and member, taking the ticket_member_forums and ticket_type_forums options into account.

get_ticket_forum_id(\?AUTO_LINK $member = null, \?integer $ticket_type_id = null, boolean $create = false, boolean $silent_error_handling = false) : \?AUTO_LINK
package tickets

Parameters

$member

\?AUTO_LINK

The member ID (null: no member)

$ticket_type_id

\?integer

The ticket type (null: all ticket types)

$create

boolean

Create the forum if it's missing

$silent_error_handling

boolean

Whether to skip showing errors, returning NULL instead

Returns

\?AUTO_LINKForum ID (null: not found)

Get the posts from a given ticket, and also return the IDs of the forum and topic containing it. The return value is the same as that of get_forum_topic_posts(), except in error conditions

get_ticket_posts(string $ticket_id, \AUTO_LINK $forum, \AUTO_LINK $topic_id, \AUTO_LINK $ticket_type, integer $start = 0, \?integer $max = null) : mixed
package tickets

Parameters

$ticket_id

string

The ticket ID

$forum

\AUTO_LINK

Return location for the forum ID

$topic_id

\AUTO_LINK

Return location for the topic ID

$ticket_type

\AUTO_LINK

Return location for the ticket type

$start

integer

Start offset in pagination

$max

\?integer

Max per page in pagination (null: no limit)

Returns

mixedThe array of maps (Each map is: title, message, member, date) (null: no such ticket)

Get a map of properties for the given ticket type.

get_ticket_type(\?AUTO_LINK $ticket_type_id) : \?array
package tickets

Parameters

$ticket_type_id

\?AUTO_LINK

The ticket type (null: fallback for old tickets)

Returns

\?arrayArray of properties (null: ticket type not found)

Get an array of tickets for the given member and ticket type. If the member has permission to see others' tickets, it will be a list of all tickets in the system, restricted by ticket type as appropriate. Otherwise, it will be a list of that member's tickets, as restricted by ticket type.

get_tickets(\AUTO_LINK $member, \?AUTO_LINK $ticket_type_id = null, boolean $override_view_others_tickets = false, boolean $silent_error_handling = false, boolean $open_only = false, boolean $include_first_posts = false) : array
package tickets

Parameters

$member

\AUTO_LINK

The member ID

$ticket_type_id

\?AUTO_LINK

The ticket type (null: all ticket types)

$override_view_others_tickets

boolean

Don't view others' tickets, even if the member has permission to

$silent_error_handling

boolean

Whether to skip showing errors, returning NULL instead

$open_only

boolean

Open tickets only

$include_first_posts

boolean

Whether to include first posts

Returns

arrayArray of tickets, empty on failure

Script to read in an e-mailed ticket/reply.

incoming_ticket_email_script() 
package tickets

See if we need to skip over an e-mail message, due to it not being from a human.

is_non_human_email(string $subject, string $body, string $full_header) : boolean
package tickets

Parameters

$subject

string

Subject line

$body

string

Message body

$full_header

string

Message headers

Returns

booleanWhether it should not be processed

Returns whether the given forum ID is for a ticket forum (subforum of the root ticket forum).

is_ticket_forum(\?AUTO_LINK $forum_id) : boolean
package tickets

Parameters

$forum_id

\?AUTO_LINK

The forum ID (null: private topics forum)

Returns

booleanWhether the given forum is a ticket forum

Is the given ticket post intended for staff only? Works only on Conversr.

is_ticket_post_staff_only(array $post) : boolean
package tickets

Parameters

$post

array

Array of data for the post

Returns

booleanWhether the post's staff only

Send an e-mail notification for a new post in a support ticket, either to the staff or to the ticket's owner.

send_ticket_email(string $ticket_id, \LONG_TEXT $title, \LONG_TEXT $post, mixed $ticket_url, \EMAIL $uid_email, integer $ticket_type_id_if_new, \?MEMBER $new_poster = null, boolean $auto_created = false
package tickets

Parameters

$ticket_id

string

The ticket ID

$title

\LONG_TEXT

The ticket title

$post

\LONG_TEXT

The ticket post's content

$ticket_url

mixed

The home URL (to view the ticket) (URLPATH or Tempcode URL)

$uid_email

\EMAIL

Ticket owner's e-mail address, in the case of a new ticket

$ticket_type_id_if_new

integer

The new ticket type, or -1 if it is a reply to an existing ticket

$new_poster

\?MEMBER

Posting member (null: current member)

$auto_created

boolean

Whether the ticket was auto-created

Add a new post to a ticket, or create a new ticket if a ticket with the given ID doesn't exist.

ticket_add_post(\AUTO_LINK $member, string $ticket_id, integer $ticket_type_id, \LONG_TEXT $title, \LONG_TEXT $post, string $ticket_url, boolean $staff_only = false, \?TIME $time_post = null

It has the same return value as make_post_forum_topic().

package tickets

Parameters

$member

\AUTO_LINK

The member ID

$ticket_id

string

The ticket ID (doesn't have to exist)

$ticket_type_id

integer

The ticket type (-1 reply to ticket)

$title

\LONG_TEXT

The post title

$post

\LONG_TEXT

The post content in Comcode format

$ticket_url

string

The home URL

$staff_only

boolean

Whether the reply is staff only (invisible to ticket owner, only on Conversr)

$time_post

\?TIME

The post time (null: use current time)

Send out an e-mail about us not recognising an e-mail address for a ticket.

ticket_email_cannot_bind(string $subject, string $body, string $email, string $email_bounce_to) 
package tickets

Parameters

$subject

string

Subject line of original message

$body

string

Body of original message

$email

string

E-mail address we tried to bind to

$email_bounce_to

string

E-mail address of sender (usually the same as $email, but not if it was a forwarded e-mail)

Process an e-mail found, sent to the support ticket system.

ticket_incoming_message(\EMAIL $from_email, string $subject, string $body, array $attachments) 
package tickets

Parameters

$from_email

\EMAIL

From e-mail

$subject

string

E-mail subject

$body

string

E-mail body

$attachments

array

Map of attachments (name to file data); only populated if $mime_type is APPLICATION/OCTET-STREAM

Scan for new e-mails in the support inbox.

ticket_incoming_scan() 
package tickets

Send out an e-mail message for a ticket / ticket reply.

ticket_outgoing_message(\ID_TEXT $ticket_id, mixed $ticket_url, string $ticket_type_name, string $subject, string $message, string $to_name, \EMAIL $to_email, string $from_displayname, boolean $new = false
package tickets

Parameters

$ticket_id

\ID_TEXT

Ticket ID

$ticket_url

mixed

URL to the ticket (URLPATH or Tempcode)

$ticket_type_name

string

The ticket type's label

$subject

string

Ticket subject

$message

string

Ticket message

$to_name

string

Display name of ticket owner

$to_email

\EMAIL

E-mail address of ticket owner

$from_displayname

string

Display name of staff poster

$new

boolean

Whether this is a new ticket, just created by the ticket owner

Update the cache of ticket type lead times (average time taken for a response to tickets of that type) in the database.

update_ticket_type_lead_times() 

This is a query-intensive function, so should only be run occasionally.

package tickets