SimpleDesk API
Procedural File: SimpleDesk-Display.php
Source Location: /source/SimpleDesk-Display.phpThis file sets up the regular ticket view, including the menu of operations that can be applied to a ticket. It is also resposible for setting up the AJAX items for modifying privacy and urgency from the ticket view itself, as well as all the handling responsible for Quick Reply including the 'Go Advanced' mode.
Tags:
- since
- 1.0
Contains the following functions:
shd_display_load_attachments [line 656]
array shd_display_load_attachments (
)
Loads data on all the attachments that will be displayed in a ticket's view.
Queries the {db_prefix}helpdesk_attachments table for the current ticket, or the messages that will be displayed (previously identified by shd_view_ticket()) and loads the id, name and size of them for display purposes. Differentiation between "attach to ticket" and "attach to reply" is made here; the data is loaded differently depending on the context; "attach to ticket" is simply loaded into an indexed array stored in $context['ticket_attach']['ticket'], while "attach to reply" is loaded into an indexed array subset in $context['ticket_attach']['reply'][msg_id] to retain the association.
Tags:
- since
- 1.0
Return value
Returns a type array. Builds an array within $contxt['ticket_attach'], as noted above. The individual data items per attachment are:- id: Numeric id for attachment itself
- name: HTML sanitised name of the attachment's filename
- size: string listing the size of the attachment, converted to kilobytes and rounded to two decimal places
- byte_size: integer of raw size of attachment
- href: the URL that would be used to access the attachment (required $context['ticket_id'] to be available, which it would anyway)
- link: full HTML "a" element linking to the attachment, using the filename as the link text
shd_prepare_ticket_context [line 577]
mixed shd_prepare_ticket_context (
)
Callback function for the template to load messages.
The process set up by shd_view_ticket() and invoked within template_view_replies() is reasonably complex. shd_view_ticket() identifies what messages should be displayed on the current page of the ticket, and performs a query to load the ticket data. Instead, however, of retrieving every row directly into memory before passing to the template, it passes the query result, and the name of a handler function into $context, so the template can call to get an individual row at a time, which saves memory amongst other things.
With respect to shd_view_ticket(), the relevant items are $reply_request being defined and $context['get_replies'] being defined as the name of this function, and in template_view_replies(), the reference is $reply = $context['get_replies']()
Tags:
- see
- shd_view_ticket()
- since
- 1.0
Return value
Returns a type mixed. The function returns the "next" message reply's details, or simply false if no replies were available, or no further replies are available. Assuming a reply can be returned, it will be a hash array in the following format:- id: numeric message id
- member: hash array containing details of the poster; normally the return value from SMF's loadMemberContext() function. A minimal set of details is prepared if the poster holds no current SMF account. Common values:
- name: User's name (falls back to the poster name specified in the replies table)
- id: User's id
- group: Name of the assigned group/post count group of the user
- link: HTML for a hyperlink to their profile
- email: Email address of the poster
- ip: IP address of the poster
- body: censored, parsed for smileys and bbcode (in shd_format_text())
- time: string of the time the reply was posted
- timestamp: internal stored timestamp attached to the reply
- is_team: boolean value of whether the posting member is currently helpdesk staff
- can_edit: boolean value reflecting if this reply can be edited
- can_delete: boolean value reflecting if this reply can be deleted
- can_restore: boolean value reflecting if this reply can be restored
- ip_address: IP address used to post the message (not necessarily the user's normal IP address); if the user has moderate_forum_members permission, this returns a link to the track IP area, with the IP address as the link text, alternatively simply the IP address if not (is only displayed to helpdesk staff)
- modified: may not be declared, if it is, the message was modified some time after posting, and the following data items are in the hash array within:
- id: user id who edited the reply (not always available)
- time: formatted string of the time the post was edited
- timestamp: raw timestamp of the time the post was edited
- name: user name of the editing user; if we have a definite user id, this should contain the current name, falling back to the previously stored name
- link: if we have a known, valid user id for the post's editor, this will contain a link to their profile, with the link text using their current display name; alternatively it will contain a regular string which is the username stored with the edit.
shd_view_ticket [line 120]
void shd_view_ticket (
)
Loads all the data and sets all the options for displaying a ticket.
This function does a lot of work in setting up a ticket to be displayed:
- Invokes shd_load_ticket() to get the principle data
- Creates $context['ticket'] to hold the data block, some of which is derived from the return of shd_load_ticket():
- id: regular numeric ticket id
- display_id: zero padded ticket id (e.g. 00001)
- subject: censored version of the subject
- first_msg: id of the opening post that forms the ticket body
- body: formatted (parsed for smileys and bbcode) version of the ticket post
- id_member: user id of the ticket's poster
- id_member_assigned: user id of the ticket's assigned user
- member: hash array of the ticket poster's details:
- id: their user id
- name: the name stated in the ticket post for that use
- link: link to the profile of the user
- assigned: hash array of the assignee of the ticket:
- id: their user id
- name: name of the assignee, or 'Unassigned'
- link: a full HTML link to their profile, or 'Unassigned' in red text
- assigned_self: boolean, whether the ticket is assigned to the current user or not
- ticket_opener: boolean, whether the current user is the user who opened this ticket
- urgency: hash array
- level: numeric identifier of current ticket urgency
- label: the HTML label of the urgency, including being in red for "Very High" or above
- increase: Boolean, whether the current ticket urgency can be increased given the current ticket state and user permissions
- decrease: Boolean, whether the current ticket urgency can be increased given the current ticket state and user permissions
- status: hash array
- level: numeric, current status identifier
- label: string representing the current status
- num_replies: the number of replies to the ticket so far
- deleted_replies: how many deleted replies in this ticket
- poster_time: formatted string containing the time the ticket was opened
- privacy: hash array
- label: current label to be used with the privacy item
- can_change: Boolean, whether the user's permission with this ticket allows us to edit the ticket privacy
- closed: Boolean, represents whether this ticket is closed (used a lot with the navigation menu)
- deleted: Boolean, represents whether this ticket is deleted (used a lot with the navigation menu)
- ip_address: IP address logged at the time the ticket was opened; if moderate_forum_members permission is available, this will be a link to the track IP area
- modified: if the ticket has been modified, also get the modified details:
- id: user id who edited the ticket (not always available)
- time: formatted string of the time the post was edited
- timestamp: raw timestamp of the time the post was edited
- name: user name of the editing user; if we have a definite user id, this should contain the current name, falling back to the previously stored name
- link: if we have a known, valid user id for the post's editor, this will contain a link to their profile, with the link text using their current display name; alternatively it will contain a regular string which is the username stored with the edit.
- display_recycle: Either holds the $txt identifier of the message to apply as a warning, or false if displaying of recycling stuff in this ticket isn't appropriate (either for permissions or just because of no deleted replies, or we're just in regular ticket view)
- define the page index with SMF's constructPageIndex
- query for all the ids of messages we might display, followed by querying for the message details themselves, pushing that query resource to $reply_request so we can use it in shd_view_replies() later
- load details of all the users applicable for posts in this page
- request all the visible attachments from shd_display_load_attachments()
- since we are viewing this ticket, mark it read
- set up the breadcrumb trail
- set up the ticket navigation menu
- call in the editor component from SimpleDesk-Post.php and friends, ready for Quick Reply
- invoke the different Javascript objects that are applicable on the page:
- privacy changer
- urgency changer
- quick reply / quote / go advanced
Tags:
- see
- shd_prepare_ticket_context()
- since
- 1.0



