Blesta Source Documentation

SupportManagerTickets extends SupportManagerModel

SupportManagerTickets model

Table of Contents

Properties

$system_staff_id The system-level staff ID

Methods

__construct() Constructor
add() Adds a support ticket
addReply() Adds a reply to a ticket. If ticket data (e.g. department_id, status, priority, summary) have changed then this will also invoke SupportManagerTickets::edit() to update the ticket, and record any log entries.
checkLoopBack() Checks whether a particular email address has received more than $count emails in the last $time_limit seconds
close() Closes a ticket and logs that it has been closed
closeAllByDepartment() Closes all open tickets (not "in_progress") based on the department settings
delete() Permanently deletes the given tickets and everything associated with them
deleteAllByDepartment() Deletes all trash ticket based on the department settings
edit() Updates a support ticket
editMultiple() Updates multiple support tickets at once
generateReplyCode() Generates a pseudo-random reply code from an sha256 HMAC of the ticket ID code
generateReplyHash() Generates a pseudo-random hash from an sha256 HMAC of the ticket ID
generateReplyNumber() Generates a pseudo-random reply code from an sha256 HMAC of the ticket ID code and concatenates it with the ticket ID
get() Retrieves a specific ticket
getAttachment() Retrieves a specific attachment
getAttachments() Retrieves a list of attachments for a given ticket
getClientByEmail() Fetches the client for the given company using the given email address.
getContactByEmail() Fetches a client's contact given the contact's email address
getContactEmails() Retrieves a list of all contact email addresses that have replied to the given ticket.
getList() Retrieve a list of tickets
getListCount() Retrieves the total number of tickets
getPriorities() Retrieves a list of priorities and their language
getReplyTypes() Retrieves a list of reply types and their language
getSearchCount() Returns the total number of tickets returned from SupportManagerTickets::search(), useful in constructing pagination
getStatusCount() Retrieves the total number of tickets in the given status assigned to the given staff/client
getStatuses() Retrieves a list of statuses and their language
getTicketByCode() Retrieves a specific ticket
makeFileName() Converts the given file name into an appropriate file name to store to disk
merge() Merges a set of tickets into another
notifyAllByDepartment() Sends all tickets a reminder based on the department settings
notifyFeedbackAllByDepartment() Sends all tickets a feedback reminder based on the department settings
parseTicketInfo() Returns the ticket info if any exists
reassignTickets() Reassigns tickets to the given client
search() Search tickets
searchByCode() Seaches for tickets, specifically by ticket code of a given status
sendEmail() Sends ticket updated/received emails
sendFeedbackReminder() Sends a reminder for the given tickets
sendReminder() Sends a reminder for the given tickets
sendTicketAssignedEmail() Sends a notice to the ticket's assigned staff member to notify them that the ticket has been assigned to them
setFeedback() Updates the feedback for a given ticket
split() Splits the given ticket with the given replies, notes, into a new ticket
validateClientContact() Validates whether the given contact can reply to the given ticket for the ticket's client
validateClientService() Validates that the given service ID is assigned to the given client ID
validateClientTicket() Validates whether the given client can reply to the given ticket
validateDateClosed() Validates the date closed for support tickets
validateDepartmentsMatchTickets() Validates that all of the given tickets can be updated to the associated department
validateEmail() Validates the email address given for support tickets
validateReplies() Validates that the given replies belong to the given ticket and that they are of the reply/note type.
validateReplyCode() Validates that the given reply code is correct for the ticket ID code
validateServicesMatchTickets() Validates that all of the given tickets can be updated to the associated service
validateSplitReplies() Validates that the given replies belong to the given ticket, that they are of the reply/note type, and that they are not all only note types.
validateStaffExists() Validates that the given staff ID exists when adding/editing tickets
validateTicketsMergeable() Validates that the given open tickets can be merged into the given ticket
validateTicketUnassigned() Validates that the given client can be assigned to the given ticket
addCustomFields() Adds the custom field values associated with the ticket
editCustomFields() Updates the custom field values associated with the ticket
generateCode() Generates a ticket number
getCustomFieldsEmailTags() Returns an array containing the email tags from the custom fields of a given ticket
getFeedbackTicketUrl() Forms a link for a customer ticket
getReplies() Gets all replies to a specific ticket
getReplyRules() Retrieves a list of rules for adding/editing support ticket replies
getRules() Retrieves a list of rules for adding/editing support tickets
getStaffDepartments() Retrieves a list of department IDs for a given staff member
getTicketReplyContact() Retrieves the client contact that replied to this ticket, otherwise the client contact this ticket is assigned to if available
getTickets() Returns a Record object for fetching tickets
getUpdateTicketUrl() Forms a link for a customer ticket
getValidTicketReplies() Retrieves a list of ticket replies of the "reply" and "note" type belonging to the given ticket
searchTickets() Partially constructs the query for searching tickets
sendTicketByClientEmail() Sends the ticket updated email to staff regarding a ticket created/updated by a client.
sendTicketByStaffEmail() Sends the ticket email to a client regarding a ticket created/updated by a staff member
sendTicketEmail() Sends ticket emails
sendTicketReceived() Sends a ticket received notice to a client for a new ticket
setContacts() Sets the contacts for the given ticket
setRecipients() Sets the recipients for the given ticket
staffReplyEmail() Replies to a ticket and sends a ticket updated email
Properties
Methods

add()

Adds a support ticket

public add(array<string|int, mixed> $vars[, bool $require_email = false ]) : mixed
Parameters
$vars : array<string|int, mixed>

A list of ticket vars, including:

  • department_id The ID of the department to assign this ticket
  • staff_id The ID of the staff member this ticket is assigned to (optional)
  • service_id The ID of the service this ticket is related to (optional)
  • client_id The ID of the client this ticket is assigned to (optional)
  • email The email address that a ticket was emailed in from (optional)
  • summary A brief title/summary of the ticket issue
  • priority The ticket priority (i.e. "emergency", "critical", "high", "medium", "low") (optional, default "low")
  • status The status of the ticket (i.e. "open", "awaiting_reply", "in_progress", "on_hold", "closed", "trash") (optional, default "open")
  • custom_fields An array containing the ticket custom fields, where the key is the field id
  • recipients An array containing the email recipients
$require_email : bool = false

True to require the email field be given, false otherwise (optional, default false)

Return values
mixed

The ticket ID, or null on error

addReply()

Adds a reply to a ticket. If ticket data (e.g. department_id, status, priority, summary) have changed then this will also invoke SupportManagerTickets::edit() to update the ticket, and record any log entries.

public addReply(int $ticket_id, array<string|int, mixed> $vars[, array<string|int, mixed> $files = null ][, bool $new_ticket = false ]) : int

Because of this functionality, this method is assumed to (and should) already be in a transaction when called, and SupportManagerTickets::edit() should not be called separately.

Parameters
$ticket_id : int

The ID of the ticket to reply to

$vars : array<string|int, mixed>

A list of reply vars, including:

  • staff_id The ID of the staff member this reply is from (optional)
  • client_id The ID of the client this reply is from (optional)
  • contact_id The ID of a client's contact that this reply is from (optional)
  • type The type of reply (i.e. "reply, "note", "log") (optional, default "reply")
  • details The details of the ticket (optional)
  • department_id The ID of the ticket department (optional)
  • summary The ticket summary (optional)
  • priority The ticket priority (optional)
  • status The ticket status (optional)
  • ticket_staff_id The ID of the staff member the ticket is assigned to (optional)
  • custom_fields An array containing the ticket custom fields, where the key is the field id
$files : array<string|int, mixed> = null

A list of file attachments that matches the global FILES array, which contains an array of "attachment" files

$new_ticket : bool = false

True if this reply is apart of ticket being created, false otherwise (default false)

Return values
int

The ID of the ticket reply on success, void on error

checkLoopBack()

Checks whether a particular email address has received more than $count emails in the last $time_limit seconds

public checkLoopBack(string $email, int $count, string $time_limit) : bool
Parameters
$email : string

The email address to check

$count : int

The maximum number of allowed emails within the time limit

$time_limit : string

The time length in the past (e.g. "5 minutes")

Return values
bool

True if the email has received <= $count emails since $time_limit, false otherwise

close()

Closes a ticket and logs that it has been closed

public close(int $ticket_id[, int $staff_id = null ]) : mixed
Parameters
$ticket_id : int

The ID of the ticket to close

$staff_id : int = null

The ID of the staff that closed the ticket (optional, default null if client closed the ticket)

closeAllByDepartment()

Closes all open tickets (not "in_progress") based on the department settings

public closeAllByDepartment(int $department_id) : mixed
Parameters
$department_id : int

The ID of the department whose tickets to close

delete()

Permanently deletes the given tickets and everything associated with them

public delete(array<string|int, mixed> $ticket_ids) : mixed
Parameters
$ticket_ids : array<string|int, mixed>

A list of tickets to delete

deleteAllByDepartment()

Deletes all trash ticket based on the department settings

public deleteAllByDepartment(int $department_id) : mixed
Parameters
$department_id : int

The ID of the department whose tickets to close

edit()

Updates a support ticket

public edit(int $ticket_id, array<string|int, mixed> $vars[, bool $log = true ]) : stdClass
Parameters
$ticket_id : int

The ID of the ticket to update

$vars : array<string|int, mixed>

A list of ticket vars, including (all optional):

  • department_id The department to reassign the ticket to
  • staff_id The ID of the staff member to assign the ticket to
  • service_id The ID of the client service this ticket relates to
  • client_id The ID of the client this ticket is to be assigned to (can only be set if it is currently null)
  • summary A brief title/summary of the ticket issue
  • priority The ticket priority (i.e. "emergency", "critical", "high", "medium", "low")
  • status The status of the ticket (i.e. "open", "awaiting_reply", "in_progress", "on_hold", "closed", "trash")
  • by_staff_id The ID of the staff member performing the edit (optional, defaults to null to signify the edit is performed by the client)
  • custom_fields An array containing the ticket custom fields, where the key is the field id
  • recipients An array containing the email recipients
$log : bool = true

True to update the ticket for any loggable changes, false to explicitly not log changes (optional, default true)

Return values
stdClass

An stdClass object representing the ticket (without replies)

editMultiple()

Updates multiple support tickets at once

public editMultiple(array<string|int, mixed> $ticket_ids, array<string|int, mixed> $vars) : mixed
Parameters
$ticket_ids : array<string|int, mixed>

An array of ticket IDs to update

$vars : array<string|int, mixed>

An array consisting of arrays of ticket vars whose index refers to the index of the $ticket_ids array representing the vars of the specific ticket to update; or an array of vars to apply to all tickets; each including (all optional):

  • department_id The department to reassign the ticket to
  • staff_id The ID of the staff member to assign the ticket to
  • service_id The ID of the client service this ticket relates to
  • client_id The ID of the client this ticket is to be assigned to (can only be set if it is currently null)
  • summary A brief title/summary of the ticket issue
  • priority The ticket priority (i.e. "emergency", "critical", "high", "medium", "low")
  • status The status of the ticket (i.e. "open", "awaiting_reply", "in_progress", "on_hold", "closed", "trash")
  • by_staff_id The ID of the staff member performing the edit (optional, defaults to null to signify the edit is performed by the client)
Tags
see
SupportManagerTickets::edit()

generateReplyCode()

Generates a pseudo-random reply code from an sha256 HMAC of the ticket ID code

public generateReplyCode(int $ticket_code[, int $length = 4 ]) : string
Parameters
$ticket_code : int

The ticket code to generate the reply code from

$length : int = 4

The length of the reply code between 4 and 64 characters (optional, default 4)

Return values
string

A hexadecimal reply code of the given length

generateReplyHash()

Generates a pseudo-random hash from an sha256 HMAC of the ticket ID

public generateReplyHash(int $ticket_id, mixed $key) : string
Parameters
$ticket_id : int

The ID of the ticket to generate the hash for

$key : mixed

A key to include in the hash

Return values
string

A hexadecimal hash of the given length

generateReplyNumber()

Generates a pseudo-random reply code from an sha256 HMAC of the ticket ID code and concatenates it with the ticket ID

public generateReplyNumber(int $ticket_code[, int $length = 4 ]) : string
Parameters
$ticket_code : int

The ticket code to generate the reply code from

$length : int = 4

The length of the reply code between 4 and 64 characters

Return values
string

A formatted reply number (e.g. "#504928 -efa3-")

get()

Retrieves a specific ticket

public get(int $ticket_id[, bool $get_replies = true ][, array<string|int, mixed> $reply_types = null ][, int $staff_id = null ]) : mixed
Parameters
$ticket_id : int

The ID of the ticket to fetch

$get_replies : bool = true

True to include the ticket replies, false not to

$reply_types : array<string|int, mixed> = null

A list of reply types to include (optional, default null for all)

  • "reply", "note", "log"
$staff_id : int = null

The ID of the staff member assigned to the tickets or associated departments (optional)

Return values
mixed

An stdClass object representing the ticket, or false if none exist

getAttachment()

Retrieves a specific attachment

public getAttachment(int $attachment_id) : mixed
Parameters
$attachment_id : int

The ID of the attachment to fetch

Return values
mixed

An stdClass object representing the attachment, or false if none exist

getAttachments()

Retrieves a list of attachments for a given ticket

public getAttachments(int $ticket_id[, int $reply_id = null ]) : array<string|int, mixed>
Parameters
$ticket_id : int

The ID of the ticket to fetch attachments for

$reply_id : int = null

The ID of the reply belonging to this ticket to fetch attachments for

Return values
array<string|int, mixed>

A list of attachments

getClientByEmail()

Fetches the client for the given company using the given email address.

public getClientByEmail(int $company_id, string $email) : mixed

Searches first the primary contact of each client, and if no results found then any contact for the clients in the given company. Returns the first client found.

Parameters
$company_id : int

The ID of the company to fetch a client for

$email : string

The email address to fetch clients on

Return values
mixed

A stdClass object representing the client whose contact matches the email address, false if no client found

getContactByEmail()

Fetches a client's contact given the contact's email address

public getContactByEmail(int $client_id, string $email) : mixed
Parameters
$client_id : int

The ID of the client whose contact the email address is presumed to be from

$email : string

The email address

Return values
mixed

An stdClass object representing the contact with the given email address, or false if none exist

getContactEmails()

Retrieves a list of all contact email addresses that have replied to the given ticket.

public getContactEmails(int $ticket_id) : array<string|int, mixed>

This does not include the client's primary contact email.

Parameters
$ticket_id : int

The ID of the ticket whose contact emails to fetch

Return values
array<string|int, mixed>

A numerically indexed array of email addresses of each contact that has replied to this ticket. May be an empty array if no contact, or only the primary client contact, has replied.

getList()

Retrieve a list of tickets

public getList(string $status[, int $staff_id = null ][, int $client_id = null ][, int $page = 1 ][, array<string|int, mixed> $order_by = ['last_reply_date' => 'desc'] ][, bool $get_replies = true ][, array<string|int, mixed> $reply_types = null ][, array<string|int, mixed> $filters = [] ]) : array<string|int, mixed>
Parameters
$status : string

The status of the support tickets ('open', 'awaiting_reply', 'in_progress', 'on_hold', 'closed', 'trash', 'not_closed')

$staff_id : int = null

The ID of the staff member assigned to the tickets or associated departments (optional)

$client_id : int = null

The ID of the client assigned to the tickets (optional)

$page : int = 1

The page number of results to fetch

$order_by : array<string|int, mixed> = ['last_reply_date' => 'desc']

A list of sort=>order options

$get_replies : bool = true

True to include the ticket replies, false not to

$reply_types : array<string|int, mixed> = null

A list of reply types to include (optional, default null for all)

  • "reply", "note", "log"
$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • ticket_number The (partial) ticket number on which to filter tickets
  • priority The priority on which to filter tickets
  • department_id The department on which to filter tickets
  • summary The (partial) summary of the ticket line on which to filter tickets
  • assigned_staff The assigned staff member on which to filter tickets
  • last_reply The elapsed time from the last reply on which to filter tickets
Return values
array<string|int, mixed>

A list of stdClass objects representing tickets

getListCount()

Retrieves the total number of tickets

public getListCount(string $status[, int $staff_id = null ][, int $client_id = null ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
$status : string

The status of the support tickets ('open', 'awaiting_reply', 'in_progress', 'on_hold', 'closed', 'trash', 'not_closed')

$staff_id : int = null

The ID of the staff member assigned to the tickets or associated departments (optional)

$client_id : int = null

The ID of the client assigned to the tickets (optional)

$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • ticket_number The (partial) ticket number on which to filter tickets
  • priority The priority on which to filter tickets
  • department_id The department on which to filter tickets
  • summary The (partial) summary of the ticket line on which to filter tickets
  • assigned_staff The assigned staff member on which to filter tickets
  • last_reply The elapsed time from the last reply on which to filter tickets
Return values
int

The total number of tickets

getPriorities()

Retrieves a list of priorities and their language

public getPriorities() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of priority => language priorities

getReplyTypes()

Retrieves a list of reply types and their language

public getReplyTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of type => language reply types

getSearchCount()

Returns the total number of tickets returned from SupportManagerTickets::search(), useful in constructing pagination

public getSearchCount(string $query[, int $staff_id = null ]) : mixed
Parameters
$query : string

The value to search tickets for

$staff_id : int = null

The ID of the staff member searching tickets (optional)

Tags
see
SupportManagerTickets::search()

getStatusCount()

Retrieves the total number of tickets in the given status assigned to the given staff/client

public getStatusCount(string $status[, int $staff_id = null ][, int $client_id = null ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
$status : string

The status of the support tickets ('open', 'awaiting_reply', 'in_progress', 'on_hold', 'closed', 'trash')

$staff_id : int = null

The ID of the staff member assigned to the tickets or associated departments (optional)

$client_id : int = null

The ID of the client assigned to the tickets (optional)

$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • staff_id The ID of the staff member assigned to the tickets or associated departments (optional)
  • client_id The ID of the client assigned to the tickets (optional)
  • ticket_id The ID of a specific ticket to fetch
  • ticket_number The (partial) ticket number on which to filter tickets
  • priority The priority on which to filter tickets
  • department_id The department ID on which to filter tickets
  • summary The (partial) summary of the ticket line on which to filter tickets
  • last_reply The elapsed time from the last reply on which to filter tickets
  • status The status of the support tickets ('open', 'awaiting_reply', 'in_progress', 'on_hold', 'closed', 'trash', 'not_closed')
Return values
int

The total number of tickets in the given status

getStatuses()

Retrieves a list of statuses and their language

public getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of status => language statuses

getTicketByCode()

Retrieves a specific ticket

public getTicketByCode(int $code[, bool $get_replies = true ][, array<string|int, mixed> $reply_types = null ]) : mixed
Parameters
$code : int

The code of the ticket to fetch

$get_replies : bool = true

True to include the ticket replies, false not to

$reply_types : array<string|int, mixed> = null

A list of reply types to include (optional, default null for all)

  • "reply", "note", "log"
Return values
mixed

An stdClass object representing the ticket, or false if none exist

makeFileName()

Converts the given file name into an appropriate file name to store to disk

public makeFileName(string $file_name) : string
Parameters
$file_name : string

The name of the file to rename

Return values
string

The rewritten file name in the format of YmdTHisO_[hash] (e.g. 20121009T154802+0000_1f3870be274f6c49b3e31a0c6728957f)

merge()

Merges a set of tickets into another

public merge(int $ticket_id, array<string|int, mixed> $tickets) : mixed
Parameters
$ticket_id : int

The ID of the ticket that will receive the merges

$tickets : array<string|int, mixed>

A list of ticket IDs to be merged

notifyAllByDepartment()

Sends all tickets a reminder based on the department settings

public notifyAllByDepartment(int $department_id) : mixed
Parameters
$department_id : int

The ID of the department whose tickets to notify

notifyFeedbackAllByDepartment()

Sends all tickets a feedback reminder based on the department settings

public notifyFeedbackAllByDepartment(int $department_id) : mixed
Parameters
$department_id : int

The ID of the department whose tickets to notify

parseTicketInfo()

Returns the ticket info if any exists

public parseTicketInfo(mixed $str) : mixed
Parameters
$str : mixed
Return values
mixed

Null if no ticket info exists, an array otherwise containing:

  • ticket_code The ticket code number
  • code The validation code that can be used to verify the ticket number
  • valid Whether or not the code is valid for this ticket_code

reassignTickets()

Reassigns tickets to the given client

public reassignTickets(array<string|int, mixed> $vars) : mixed
Parameters
$vars : array<string|int, mixed>

A list of input variables including:

  • ticket_ids An array of ticket IDs to reassign
  • client_id The client to reassign the ticket to
  • staff_id The staff performing this action

Search tickets

public search(string $query[, int $staff_id = null ][, int $page = 1 ][, array<string|int, mixed> $order_by = ['last_reply_date' => 'desc'] ]) : array<string|int, mixed>
Parameters
$query : string

The value to search tickets for

$staff_id : int = null

The ID of the staff member searching tickets (optional)

$page : int = 1

The page number of results to fetch (optional, default 1)

$order_by : array<string|int, mixed> = ['last_reply_date' => 'desc']

The sort=>$order options

Return values
array<string|int, mixed>

An array of tickets that match the search criteria

searchByCode()

Seaches for tickets, specifically by ticket code of a given status

public searchByCode(string $query[, int $staff_id = null ][, mixed $status = null ][, int $page = 1 ][, array<string|int, mixed> $order_by = ['last_reply_date' => 'desc'] ]) : array<string|int, mixed>
Parameters
$query : string

The value to search ticket codes for

$staff_id : int = null

The ID of the staff member searching tickets (optional)

$status : mixed = null

The status of tickets to search (optional, default null for all)

$page : int = 1

The page number of results to fetch (optional, default 1)

$order_by : array<string|int, mixed> = ['last_reply_date' => 'desc']

The sort=>$order options

Return values
array<string|int, mixed>

An array of tickets that match the search criteria

sendEmail()

Sends ticket updated/received emails

public sendEmail(int $reply_id[, array<string|int, mixed> $additional_tags = [] ]) : mixed
Parameters
$reply_id : int

The ID of the ticket reply that the email is to use

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_received' => array('tag' => "value"))

sendFeedbackReminder()

Sends a reminder for the given tickets

public sendFeedbackReminder(array<string|int, mixed> $ticket_ids) : mixed
Parameters
$ticket_ids : array<string|int, mixed>

A list of tickets for which to send a reminder

sendReminder()

Sends a reminder for the given tickets

public sendReminder(array<string|int, mixed> $ticket_ids) : mixed
Parameters
$ticket_ids : array<string|int, mixed>

A list of tickets for which to send a reminder

sendTicketAssignedEmail()

Sends a notice to the ticket's assigned staff member to notify them that the ticket has been assigned to them

public sendTicketAssignedEmail(int $ticket_id) : mixed
Parameters
$ticket_id : int

The ID of the ticket that a staff member has been assigned

setFeedback()

Updates the feedback for a given ticket

public setFeedback(int $ticket_id, array<string|int, mixed> $vars) : void
Parameters
$ticket_id : int

The ID of the ticket to update

$vars : array<string|int, mixed>

A key/value array containing:

  • rating The rating given to the ticket, from 1 to 5
  • rating_comment The feedback comment given to the ticket (optional)

split()

Splits the given ticket with the given replies, notes, into a new ticket

public split(int $ticket_id, array<string|int, mixed> $replies) : int
Parameters
$ticket_id : int

The ID of the ticket to split

$replies : array<string|int, mixed>

A list of reply IDs belonging to the given ticket, which should be assigned to a new ticket

Return values
int

The ID of the newly-created ticket on success, or void on error

validateClientContact()

Validates whether the given contact can reply to the given ticket for the ticket's client

public validateClientContact(int $contact_id, int $ticket_id[, int $client_id = null ]) : bool
Parameters
$contact_id : int

The ID of the contact

$ticket_id : int

The ID of the ticket

$client_id : int = null

The ID of the client assigned to the ticket if the ticket is not known (optional, default null)

Return values
bool

True if the contact can reply to the ticket, false otherwise

validateClientService()

Validates that the given service ID is assigned to the given client ID

public validateClientService(int $service_id, int $client_id) : bool
Parameters
$service_id : int

The ID of the service

$client_id : int

The ID of the client

Return values
bool

True if the service ID belongs to the client ID, false otherwise

validateClientTicket()

Validates whether the given client can reply to the given ticket

public validateClientTicket(int $client_id, int $ticket_id) : bool
Parameters
$client_id : int

The ID of the client

$ticket_id : int

The ID of the ticket

Return values
bool

True if the client can reply to the ticket, false otherwise

validateDateClosed()

Validates the date closed for support tickets

public validateDateClosed(string $date_closed) : bool
Parameters
$date_closed : string

The date a ticket is closed

Return values
bool

True if the date is in a valid format, false otherwise

validateDepartmentsMatchTickets()

Validates that all of the given tickets can be updated to the associated department

public validateDepartmentsMatchTickets(array<string|int, mixed> $vars, array<string|int, mixed> $ticket_ids) : bool
Parameters
$vars : array<string|int, mixed>

An array consisting of arrays of ticket vars whose index refers to the index of the $ticket_ids array representing the vars of the specific ticket to update; or an array of vars to apply to all tickets; each including:

  • department_id The department to reassign the ticket to
$ticket_ids : array<string|int, mixed>

An array of ticket IDs to update

Return values
bool

True if the department(s) match the tickets, or false otherwise

validateEmail()

Validates the email address given for support tickets

public validateEmail(string $email[, bool $require_email = false ]) : bool
Parameters
$email : string

The support ticket email address

$require_email : bool = false

True to require the email field be given, false otherwise (optional, default false)

Return values
bool

True if the email address is valid, false otherwise

validateReplies()

Validates that the given replies belong to the given ticket and that they are of the reply/note type.

public validateReplies(array<string|int, mixed> $replies, int $ticket_id[, bool $all = false ]) : bool
Parameters
$replies : array<string|int, mixed>

A list of IDs representing ticket replies

$ticket_id : int

The ID of the ticket to which the replies belong

$all : bool = false

False to require that at least 1 ticket reply not be given for this ticket, or true to allow all (optional, default false)

Return values
bool

True if all of the given replies are valid; false otherwise

validateReplyCode()

Validates that the given reply code is correct for the ticket ID code

public validateReplyCode(int $ticket_code, mixed $code) : bool
Parameters
$ticket_code : int

The ticket code to validate the reply code for

$code : mixed
Return values
bool

True if the reply code is valid, false otherwise

validateServicesMatchTickets()

Validates that all of the given tickets can be updated to the associated service

public validateServicesMatchTickets(array<string|int, mixed> $vars, array<string|int, mixed> $ticket_ids) : bool
Parameters
$vars : array<string|int, mixed>

An array consisting of arrays of ticket vars whose index refers to the index of the $ticket_ids array representing the vars of the specific ticket to update; or an array of vars to apply to all tickets; each including:

  • service_id The ID of the client service this ticket relates to
$ticket_ids : array<string|int, mixed>

An array of ticket IDs to update

Return values
bool

True if the service(s) match the tickets, or false otherwise

validateSplitReplies()

Validates that the given replies belong to the given ticket, that they are of the reply/note type, and that they are not all only note types.

public validateSplitReplies(array<string|int, mixed> $replies, int $ticket_id) : bool

i.e. In addition to replies of the 'note' type, at least one 'reply' type must be included

Parameters
$replies : array<string|int, mixed>

A list of IDs representing ticket replies

$ticket_id : int

The ID of the ticket to which the replies belong

Return values
bool

True if no replies are given, or at least one is of the 'reply' type; false otherwise

validateStaffExists()

Validates that the given staff ID exists when adding/editing tickets

public validateStaffExists(int $staff_id) : bool
Parameters
$staff_id : int

The ID of the staff member

Return values
bool

True if the staff ID exists, false otherwise

validateTicketsMergeable()

Validates that the given open tickets can be merged into the given ticket

public validateTicketsMergeable(array<string|int, mixed> $tickets, int $ticket_id) : bool
Parameters
$tickets : array<string|int, mixed>

A list of ticket IDs

$ticket_id : int

The ID of the ticket the tickets are to be merged into

Return values
bool

True if all of the given tickets can be merged into the ticket, or false otherwise

validateTicketUnassigned()

Validates that the given client can be assigned to the given ticket

public validateTicketUnassigned(int $client_id, int $ticket_id) : bool
Parameters
$client_id : int

The ID of the client to assign to the ticket

$ticket_id : int

The ID of the ticket

Return values
bool

True if the client may be assigned to the ticket, false otherwise

addCustomFields()

Adds the custom field values associated with the ticket

private addCustomFields(int $ticket_id, array<string|int, mixed> $custom_fields) : mixed
Parameters
$ticket_id : int

The ID of the ticket to associate with the custom fields

$custom_fields : array<string|int, mixed>

An array containing the ticket custom fields, where the key is the field id

editCustomFields()

Updates the custom field values associated with the ticket

private editCustomFields(int $ticket_id, array<string|int, mixed> $custom_fields) : mixed
Parameters
$ticket_id : int

The ID of the ticket to associate with the custom fields

$custom_fields : array<string|int, mixed>

An array containing the ticket custom fields, where the key is the field id

generateCode()

Generates a ticket number

private generateCode() : int
Return values
int

A ticket number

getCustomFieldsEmailTags()

Returns an array containing the email tags from the custom fields of a given ticket

private getCustomFieldsEmailTags(int $ticket_id) : array<string|int, mixed>
Parameters
$ticket_id : int
Return values
array<string|int, mixed>

An array containing "custom_fields", which contains the ticket custom fields where the key is the ID of the field or the snake_case version of the field label

getFeedbackTicketUrl()

Forms a link for a customer ticket

private getFeedbackTicketUrl(int $ticket_id, string $hostname) : mixed
Parameters
$ticket_id : int

The ID of the ticket to link

$hostname : string

The company hostname to link

getReplies()

Gets all replies to a specific ticket

private getReplies(mixed $ticket_id[, array<string|int, mixed> $types = null ]) : array<string|int, mixed>
Parameters
$ticket_id : mixed

The ID of the ticket whose replies to fetch

$types : array<string|int, mixed> = null

A list of reply types to include (optional, default null for all)

  • "reply", "note", "log"
Return values
array<string|int, mixed>

A list of replies to the given ticket

getReplyRules()

Retrieves a list of rules for adding/editing support ticket replies

private getReplyRules(array<string|int, mixed> &$vars[, bool $new_ticket = false ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

A list of input vars

$new_ticket : bool = false

True to get the rules if this ticket is in the process of being created, false otherwise (optional, default false)

Return values
array<string|int, mixed>

A list of ticket reply rules

getRules()

Retrieves a list of rules for adding/editing support tickets

private getRules(array<string|int, mixed> &$vars[, bool $edit = false ][, bool $require_email = false ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

A list of input vars

$edit : bool = false

True to get the edit rules, false for the add rules (optional, default false)

$require_email : bool = false

True to require the email field be given, false otherwise (optional, default false)

Return values
array<string|int, mixed>

A list of support ticket rules

getStaffDepartments()

Retrieves a list of department IDs for a given staff member

private getStaffDepartments(int $staff_id) : array<string|int, mixed>
Parameters
$staff_id : int

The ID of the staff member whose departments to fetch

Return values
array<string|int, mixed>

A list of department IDs that this staff member belongs to

getTicketReplyContact()

Retrieves the client contact that replied to this ticket, otherwise the client contact this ticket is assigned to if available

private getTicketReplyContact(stdClass $ticket) : stdClass
Parameters
$ticket : stdClass

An object representing the given ticket

Tags
see

::sendTicketByClientEmail, ::sendTicketReceived

Return values
stdClass

An object representing the contact assigned to this ticket

getTickets()

Returns a Record object for fetching tickets

private getTickets([array<string|int, mixed> $filters = [] ]) : Record
Parameters
$filters : array<string|int, mixed> = []

A list of parameters to filter by, including:

  • staff_id The ID of the staff member assigned to the tickets or associated departments (optional)
  • client_id The ID of the client assigned to the tickets (optional)
  • ticket_id The ID of a specific ticket to fetch
  • ticket_number The (partial) ticket number on which to filter tickets
  • priority The priority on which to filter tickets
  • department_id The department ID on which to filter tickets
  • summary The (partial) summary of the ticket line on which to filter tickets
  • last_reply The elapsed time from the last reply on which to filter tickets
  • status The status of the support tickets ('open', 'awaiting_reply', 'in_progress', 'on_hold', 'closed', 'trash', 'not_closed')
  • type The reply type to fetch ('reply', 'note', 'all')
Return values
Record

A partially-constructed Record object for fetching tickets

getUpdateTicketUrl()

Forms a link for a customer ticket

private getUpdateTicketUrl(int $ticket_id, string $hostname) : mixed
Parameters
$ticket_id : int

The ID of the ticket to link

$hostname : string

The company hostname to link

getValidTicketReplies()

Retrieves a list of ticket replies of the "reply" and "note" type belonging to the given ticket

private getValidTicketReplies(int $ticket_id) : array<string|int, mixed>
Parameters
$ticket_id : int

The ID of the ticket

Return values
array<string|int, mixed>

An array of stdClass objects representing each reply, keyed by the reply ID

searchTickets()

Partially constructs the query for searching tickets

private searchTickets(string $query[, int $staff_id = null ]) : Record
Parameters
$query : string

The value to search tickets for

$staff_id : int = null

The ID of the staff member searching tickets

Tags
see

SupportManagerTickets::search(), SupportManagerTickets::getSearchCount()

Return values
Record

The partially constructed query Record object

sendTicketByClientEmail()

Sends the ticket updated email to staff regarding a ticket created/updated by a client.

private sendTicketByClientEmail(stdClass $ticket, bool $new_ticket[, array<string|int, mixed> $additional_tags = [] ]) : mixed

In the case $new_ticket is true, a ticket received notice is also sent to the client.

Parameters
$ticket : stdClass

An stdClass object representing the ticket

$new_ticket : bool

True if this is the first ticket reply, false if it is a reply to an existing ticket

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_received' => array('tag' => "value"))

sendTicketByStaffEmail()

Sends the ticket email to a client regarding a ticket created/updated by a staff member

private sendTicketByStaffEmail(stdClass $ticket[, array<string|int, mixed> $additional_tags = [] ]) : mixed
Parameters
$ticket : stdClass

An stdClass object representing the ticket

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_received' => array('tag' => "value"))

sendTicketEmail()

Sends ticket emails

private sendTicketEmail(stdClass $ticket, bool $new_ticket[, array<string|int, mixed> $additional_tags = [] ]) : mixed
Parameters
$ticket : stdClass

An stdClass object representing the ticket

$new_ticket : bool

True if this is the first ticket reply, false if it is a reply to an existing ticket

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_received' => array('tag' => "value"))

sendTicketReceived()

Sends a ticket received notice to a client for a new ticket

private sendTicketReceived(stdClass $ticket[, array<string|int, mixed> $additional_tags = [] ]) : mixed
Parameters
$ticket : stdClass

An stdClass object representing the ticket

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_received' => array('tag' => "value"))

setContacts()

Sets the contacts for the given ticket

private setContacts(int $ticket_id, array<string|int, mixed> $contacts) : mixed
Parameters
$ticket_id : int

The ID of the ticket to set the contacts

$contacts : array<string|int, mixed>

An array containing IDs of the contacts

setRecipients()

Sets the recipients for the given ticket

private setRecipients(int $ticket_id, array<string|int, mixed> $recipients) : mixed
Parameters
$ticket_id : int

The ID of the ticket to set the recipients

$recipients : array<string|int, mixed>

An array containing the email addresses of the recipients

staffReplyEmail()

Replies to a ticket and sends a ticket updated email

private staffReplyEmail(string $reply, int $ticket_id, string $hostname[, int $staff_id = 0 ][, array<string|int, mixed> $additional_tags = [] ]) : mixed
Parameters
$reply : string

The details to include in the reply

$ticket_id : int

The ID of the ticket to reply to

$hostname : string

The hostname of the company to which this ticket belongs

$staff_id : int = 0

The ID of the staff member replying to the ticket (optional, default 0 for system reply)

$additional_tags : array<string|int, mixed> = []

A key=>value list of the email_action=>tags array to send e.g. array('SupportManager.ticket_updated' => array('tag' => "value"))

Tags
subpackage

plugins.supportmanager

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results