Blesta Source Documentation

SupportManagerDepartments extends SupportManagerModel

SupportManagerDepartments model

Table of Contents

Methods

__construct() Constructor
add() Adds a department
delete() Attempts to delete a support department
edit() Edits a department
get() Fetches a support department
getAll() Fetches a list of all departments
getBoxName() Gets the box name to use for the support department based on input
getByEmail() Fetches the support department with the given email address and (optionally) method
getByMethod() Fetches a list of all departments by given methods
getFieldTypes() Retrieves a list of field types
getList() Retrieves a list of departments
getListCount() Retrieves the total number of departments
getMessageTypes() Retrieves a list of message types
getMethods() Retrieves a list of department methods
getPriorities() Retrieves a list of department priorities
getProviders() Retrieves a list of department OAuth 2.0 providers
getReminderIntervals() Retrieve a list of reminder intervals (in minutes)
getSecurityTypes() Retrieves a list of security types
getStaffByEmail() Fetches staff info for the staff member assigned to the given support department and who has the given email address set as their email or mobile email address
getStatuses() Retrieves a list of department statuses
getTicketIntervals() Retrieves a list of department intervals (in minutes)
getVisibilityOptions() Retrieves a list of visibility options
validateEmailCredential() Validates the username or password based on the method
validateHasTickets() Validates whether the given department has tickets assigned to it
validateHost() Validates the host based on the method
validateImapRequired() Validates that the imap extension exists
validateMailparseRequired() Validates that the mailparse extension exists
validateMessageType() Validates the mark_messages type based on the method
validatePopMessageType() Validates the mark_messages type to ensure it is a valid type based on the method
validatePort() Validates the port based on the method
validatePredefinedResponse() Validates that the given predefined response can be used for this company
validateSecurityType() Validates the security based on the method
addFields() Adds the given custom fields to an existing department
addPriorities() Adds the given priorities to an existing department
editFields() Updates the custom fields from an existing department
editPriorities() Updates the priorities to an existing department
getDepartments() Retrieves a partially-constructed Record object for fetching departments
getRules() Fetches a list of rules for adding/editing a department
updateTicketFeedbackReminderFlag() Marks all open tickets for a given department to either request feedback or not
Methods

add()

Adds a department

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

A list of input vars including:

  • company_id The company ID
  • name The department's name
  • description The department's description
  • email The department email address
  • method The method for sending email ('pipe' 'pop3', 'imap', 'none')
  • default_priority The default department ticket priority ('emergency', 'critical', 'high', 'medium', 'low')
  • priorities A list ticket priorities available for this department ('emergency', 'critical', 'high', 'medium', 'low')
  • host The email hostname (optional, required if method is not 'pipe')
  • user The email user (optional, required if method is not 'pipe')
  • pass The email pass (optional, required if method is not 'pipe')
  • port The email port (optional, required if method is not 'pipe')
  • security The security type (optional, required if method is not 'pipe')
  • box_name The box name type (optional)
  • mark_messages The message type (optional, required if method is not 'pipe')
  • clients_only (optional, defaults to '1')
  • enable_related_services Whether to allow clients to connect a related service to the ticket (optional, defaults to '0')
  • require_captcha Whether to require human verification for unauthenticated users (optional, defaults to '1')
  • override_from_email Whether or not to use the department's email address as the from address in email templates (optional, defaults to '1')
  • close_ticket_interval The number of minutes since the last reply to a ticket at which point the ticket can be closed automatically (optional, default null for never)
  • feedback_ticket_interval The number of minutes since the ticket has been closed at which point a feedback notification should be sent (optional, default null for never)
  • reminder_ticket_interval The number of minutes since the last reply to a ticket at which point a reminder should be sent (optional, default null for never)
  • reminder_ticket_status An array containing the statuses of the tickets to send a reminder
  • reminder_ticket_priority An array containing the priorities of the tickets to send a reminder
  • automatic_transition Whether or not to automatically change the status of tickets in this department to awaiting_reply after an admin replies to it
  • include_attachments Whether to include attachment in ticket notices
  • attachment_types A comma separated list of mime types allowable for attachments
  • max_attachment_size The maximum allowable size for attachments
  • response_id The ID of the predefined response to use when a ticket is auto-closed
  • status The department status ('hidden' or 'visible')
  • fields A multi-dimensional array containing the custom fields for the department:
    • label An array containing the custom fields labels
    • description An array containing the custom fields description
    • visibility An array containing the custom fields visibility status
    • type An array containing the custom fields type
    • encrypted An array containing the custom fields encrypt status
Return values
stdClass

The stdClass object representing the newly-created department, or void on error

delete()

Attempts to delete a support department

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

The ID of the department to delete

edit()

Edits a department

public edit(int $department_id, array<string|int, mixed> $vars) : stdClass
Parameters
$department_id : int

The ID of the department to update

$vars : array<string|int, mixed>

A list of input vars including:

  • name The department's name
  • description The department's description
  • email The department email address
  • method The method for sending email ('pipe' 'pop3', 'imap', 'none')
  • default_priority The default department ticket priority ('emergency', 'critical', 'high', 'medium', 'low')
  • host The email hostname (optional, required if method is not 'pipe')
  • user The email user (optional, required if method is not 'pipe')
  • pass The email pass (optional, required if method is not 'pipe')
  • port The email port (optional, required if method is not 'pipe')
  • security The security type (optional, required if method is not 'pipe')
  • box_name The box name type (optional)
  • mark_messages The message type (optional, required if method is not 'pipe')
  • clients_only (optional, defaults to '1')
  • enable_related_services Whether to allow clients to connect a related service to the ticket (optional, defaults to '0')
  • require_captcha Whether to require human verification for unauthenticated users (optional, defaults to '1')
  • override_from_email Whether or not to use the department's email address as the from address in email templates (optional, defaults to '1')
  • close_ticket_interval The number of minutes since the last reply to a ticket at which point the ticket can be closed automatically (optional, default null for never)
  • feedback_ticket_interval The number of minutes since the ticket has been closed at which point a feedback notification should be sent (optional, default null for never)
  • reminder_ticket_interval The number of minutes since the last reply to a ticket at which point a reminder should be sent (optional, default null for never)
  • reminder_ticket_status An array containing the statuses of the tickets to send a reminder
  • reminder_ticket_priority An array containing the priorities of the tickets to send a reminder
  • automatic_transition Whether or not to automatically change the status of tickets in this department to awaiting_reply after an admin replies to it
  • include_attachments Whether to include attachment in ticket notices
  • attachment_types A comma separated list of mime types allowable for attachments
  • max_attachment_size The maximum allowable size for attachments
  • response_id The ID of the predefined response to use when a ticket is auto-closed
  • status The department status ('hidden' or 'visible')
  • fields A multi-dimensional array containing the custom fields for the department:
    • label An array containing the custom fields labels
    • description An array containing the custom fields description
    • visibility An array containing the custom fields visibility status
    • type An array containing the custom fields type
    • encrypted An array containing the custom fields encrypt status
Return values
stdClass

The stdClass object representing the newly-created department, or void on error

get()

Fetches a support department

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

The ID of the department to fetch

Return values
mixed

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

getAll()

Fetches a list of all departments

public getAll(int $company_id[, string $status = null ][, bool $clients_only = null ][, array<string|int, mixed> $criteria = [] ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the company whose departments to fetch

$status : string = null

The status of the support department (i.e. "visible", "hidden") (optional, default null for all)

$clients_only : bool = null

True to fetch only those departments for logged-in clients, false to fetch departments not for logged-in clients, or null for all (optional, default null)

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

A list of filtering criteria including:

  • staff_id
Return values
array<string|int, mixed>

A list of stdClass objects, each representing a department

getBoxName()

Gets the box name to use for the support department based on input

public getBoxName(mixed $box_name[, string $default_box = 'INBOX' ]) : string
Parameters
$box_name : mixed

The box name to use for the department

$default_box : string = 'INBOX'

The default box name to use if $box_name is empty

Return values
string

The box name to use for the department

getByEmail()

Fetches the support department with the given email address and (optionally) method

public getByEmail(int $company_id, string $email[, string $method = null ]) : mixed
Parameters
$company_id : int

The ID of the company whose departments to fetch

$email : string

The email address of the department to fetch

$method : string = null

The method of the support department, null for any:

  • pipe
  • pop3
  • imap
  • none
Return values
mixed

A stdClass object representing the support department, false if no such department found

getByMethod()

Fetches a list of all departments by given methods

public getByMethod(int $company_id[, array<string|int, mixed> $methods = null ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the compane whose departments to fetch

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

A list of method types to filter on (optional, null for all)

Return values
array<string|int, mixed>

A list of stdClass objects, each representing a department

getFieldTypes()

Retrieves a list of field types

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

A list of field types and their language

getList()

Retrieves a list of departments

public getList(int $company_id[, int $page = 1 ][, array<string|int, mixed> $order_by = ['name' => 'ASC'] ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the company whose department list to fetch

$page : int = 1

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

$order_by : array<string|int, mixed> = ['name' => 'ASC']

A key/value pair array of fields to order the results by

Return values
array<string|int, mixed>

A list of stdClass objects, each representing a department

getListCount()

Retrieves the total number of departments

public getListCount(int $company_id) : int
Parameters
$company_id : int

The ID of the company

Return values
int

The total number of departments

getMessageTypes()

Retrieves a list of message types

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

A list of message types and their language

getMethods()

Retrieves a list of department methods

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

A list of methods and their language

getPriorities()

Retrieves a list of department priorities

public getPriorities([int $department_id = null ]) : array<string|int, mixed>
Parameters
$department_id : int = null

The ID of the department to filter priorities by (optional)

Return values
array<string|int, mixed>

A list of priorities and their language

getProviders()

Retrieves a list of department OAuth 2.0 providers

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

A list of providers and their language

getReminderIntervals()

Retrieve a list of reminder intervals (in minutes)

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

A list of intervals

getSecurityTypes()

Retrieves a list of security types

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

A list of security types and their language

getStaffByEmail()

Fetches staff info for the staff member assigned to the given support department and who has the given email address set as their email or mobile email address

public getStaffByEmail(int $department_id, string $email) : mixed
Parameters
$department_id : int

The support department ID the staff member must belong to

$email : string

The email address the staff member must be assigned

Return values
mixed

A stdClass object representing the staff member, false if the staff member does not exist, is not active, or does not belong to the department

getStatuses()

Retrieves a list of department statuses

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

A list of statuses and their language

getTicketIntervals()

Retrieves a list of department intervals (in minutes)

public getTicketIntervals(int $days) : array<string|int, mixed>
Parameters
$days : int

Number of day intervals to fetch

Return values
array<string|int, mixed>

A list of minutes and their language

getVisibilityOptions()

Retrieves a list of visibility options

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

A list of visibility options and their language

validateEmailCredential()

Validates the username or password based on the method

public validateEmailCredential(string $field, string $method) : bool
Parameters
$field : string

The field to validate

$method : string

The email method

Return values
bool

True if the field validates, false otherwise

validateHasTickets()

Validates whether the given department has tickets assigned to it

public validateHasTickets(int $department_id) : bool
Parameters
$department_id : int

The ID of the department

Return values
bool

True if the department has tickets assigned to it, false otherwise

validateHost()

Validates the host based on the method

public validateHost(string $host, string $method) : bool
Parameters
$host : string

The hostname

$method : string

The email method

Return values
bool

True if the host validates, false otherwise

validateImapRequired()

Validates that the imap extension exists

public validateImapRequired(string $method) : bool
Parameters
$method : string

The email handling method ('none', 'pipe', 'imap', 'pop3', 'oauth2')

Return values
bool

True if the imap extension exists or is not required for the given $method

validateMailparseRequired()

Validates that the mailparse extension exists

public validateMailparseRequired(string $method) : bool
Parameters
$method : string

The email handling method ('none', 'pipe', 'imap', 'pop3', 'oauth2')

Return values
bool

True if the mailparse extension exists or is not required for the given $method

validateMessageType()

Validates the mark_messages type based on the method

public validateMessageType(string $mark_messages, string $method) : bool
Parameters
$mark_messages : string

The status of messages

$method : string

The email method

Return values
bool

True if the message type validates, false otherwise

validatePopMessageType()

Validates the mark_messages type to ensure it is a valid type based on the method

public validatePopMessageType(string $mark_messages, string $method) : bool
Parameters
$mark_messages : string

The status of messages

$method : string

The method type

Return values
bool

True if the message type validates, false otherwise

validatePort()

Validates the port based on the method

public validatePort(string $port, string $method) : bool
Parameters
$port : string

The port number

$method : string

The email method

Return values
bool

True if the port validates, false otherwise

validatePredefinedResponse()

Validates that the given predefined response can be used for this company

public validatePredefinedResponse(int $response_id[, int $company_id = null ][, bool $edit = false ][, int $department_id = null ]) : mixed
Parameters
$response_id : int

The ID of the predefined response to validate

$company_id : int = null

The ID of the company being assigned the response (optional, required if $edit is false)

$edit : bool = false

True if editing an existing department, false otherwise

$department_id : int = null

The ID of the department the response is being assigned to (optional, required if $edit is true)

validateSecurityType()

Validates the security based on the method

public validateSecurityType(string $security, string $method) : bool
Parameters
$security : string

The security type

$method : string

The email method

Return values
bool

True if the security type validates, false otherwise

addFields()

Adds the given custom fields to an existing department

private addFields(int $department_id, array<string|int, mixed> $fields) : mixed
Parameters
$department_id : int

The ID of the department where the fields must be added

$fields : array<string|int, mixed>

A multi-dimensional array containing the custom fields for the department:

  • label An array containing the custom fields labels
  • description An array containing the custom fields description
  • visibility An array containing the custom fields visibility status
  • type An array containing the custom fields type
  • encrypted An array containing the custom fields encrypt status

addPriorities()

Adds the given priorities to an existing department

private addPriorities(int $department_id, array<string|int, mixed> $priorities) : mixed
Parameters
$department_id : int

The ID of the department where the priorities must be added

$priorities : array<string|int, mixed>

A list ticket priorities available for this department

editFields()

Updates the custom fields from an existing department

private editFields(int $department_id, array<string|int, mixed> $fields) : mixed
Parameters
$department_id : int

The ID of the department where the fields must be added

$fields : array<string|int, mixed>

A multi-dimensional array containing the custom fields for the department:

  • id The ID of the field to be edited, if false a new field will be added
  • label An array containing the custom fields labels
  • description An array containing the custom fields description
  • visibility An array containing the custom fields visibility status
  • type An array containing the custom fields type
  • encrypted An array containing the custom fields encrypt status

editPriorities()

Updates the priorities to an existing department

private editPriorities(int $department_id, array<string|int, mixed> $priorities) : mixed
Parameters
$department_id : int

The ID of the department where the priorities must be updated

$priorities : array<string|int, mixed>

A list ticket priorities available for this department

getDepartments()

Retrieves a partially-constructed Record object for fetching departments

private getDepartments(int $company_id[, array<string|int, mixed> $criteria = [] ]) : Record
Parameters
$company_id : int

The ID of the company whose departments to fetch

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

A list of filtering criteria including:

  • staff_id
  • status
  • clients_only
Return values
Record

A partially-constructed Record object

getRules()

Fetches a list of rules for adding/editing a department

private getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : 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)

updateTicketFeedbackReminderFlag()

Marks all open tickets for a given department to either request feedback or not

private updateTicketFeedbackReminderFlag(type $department_id, type $request_feedback) : mixed
Parameters
$department_id : type

The department for which to update tickets

$request_feedback : type

Whether or not to request feedback for the tickets

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