SimpleDesk API
Procedural File: Subs-SimpleDeskPost.php
Source Location: /source/Subs-SimpleDeskPost.phpThis file handles probably the two most critical functions in SimpleDesk: the one that adds new posts to the database and one that saves updated posts; also contains miscellaneous code that applies generally in posting.
Tags:
- since
- 1.0
Contains the following functions:
shd_create_ticket_post [line 79]
bool shd_create_ticket_post (
array &$msgOptions, array &$ticketOptions, array &$posterOptions )
Creates a new ticket or reply in the database.
This function handles all of the creation of posts and tickets within SimpleDesk, even with respect to managing tickets spawned from forum topics being moved, as well as newly deleted tickets (formed as a split when replies are deleted). New tickets' contents as well as replies to tickets generally hold the same format.
All three parameters are by reference meaning they WILL be updated if things change. Note that this function is not validating that they are sensible values; it is up to the calling function to ascertain that.
Tags:
- since
- 1.0
Parameters
- array &$msgOptions
- A hash array by reference, containing details of the post you wish to add.
- id: Not required on input (and is ignored) - and will be overwritten with the new message id when the function completes.
- body: Required string, the principle body content of the message to post. Assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and preparsecode)
- smileys_enabled: Optional, boolean denoting whether smileys should be active on this post; defaults to false
- time: Optional, timestamp of the post. If omitted, time() will be used instead (for "now" based on server clock)
- modified: Optional, hash array containing items relating to modification (if 'modified' key exists, all of these should be set)
- time: Unsigned int timestamp of the change
- name: String; user name of the user making the change; if omitted, modified will be ignored
- id: Unsigned int user id of the user making the change; if not provided, id MUST be. If id isn't, or it doesn't exist, modified will be ignored entirely
- attachments: Optional, array of attachment ids that need attaching to this message; if omitted no changes will occur
- array &$ticketOptions
- A hash array by reference, containing details of the ticket as a whole.
- id: Required if replying to a ticket, 0 if a new ticket (will default to 0 if not specified)
- mark_as_read: Optional boolean, whether to mark the ticket as read by the person posting it ($posterOptions['id'] is required to use this)
- subject: Semi-optional string with the new subject in; required for a new ticket, ignored if adding a reply. If set, assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and strtr)
- private: Semi-optional boolean with ticket privacy (true = private); required for a new ticket, ignored if adding a reply.
- status: Integer to denote new status of the ticket, defaults to TICKET_STATUS_NEW. Calling function to determine new status.
- urgency: Semi-optional integer with the ticket urgency; required for a new ticket, ignored if adding a reply. If not stated on a new ticket, TICKET_URGENCY_LOW will be used.
- assigned: Optional integer of user id, used to create a ticket with assignment, ignored if not a new ticket.
- array &$posterOptions
- A hash array by reference, containing details of the person the reply is written by.
- id: User id to credit the post to. Uses 0 if not specified.
- ip: IP address the post came from. Uses the current user's IP address if not specified.
- name: Name to credit against the post. If not specified, and a user id was supplied, look that up in the member table, otherwise just use 'Guest'.
- email: Email address to list against the post. If not specified, and a user id was supplied, look that up in the member table, otherwise just use ''.
Return value
Returns a type bool. True on success, false on failure.shd_get_urgency_options [line 479]
void shd_get_urgency_options (
[bool $self_ticket = false] )
Identifies the range of options that a user could have for ticket urgency and updates $context['ticket_form'] accordingly.
Ticket urgency permissions are checked, and an array is built suitable for $context['ticket_form'], which is the principle format used in the ticket posting/reply posting functions in SimpleDesk-Post.php.
There is no return function; $context['ticket_form']['urgency'] is updated, both the ['options'] and ['can_change'] keys may be modified.
Tags:
- see
- SimpleDesk-Display.php
- since
- 1.0
Parameters
- bool $self_ticket
- (default false) Permissions will be different for many users depending on whether it is one of their own tickets or not. This allows the code to state whether it is a ticket owned by the current user or not.
Return value
This function has no return value.shd_modify_ticket_post [line 354]
bool shd_modify_ticket_post (
array &$msgOptions, array &$ticketOptions, array &$posterOptions )
Updates a ticket/reply item in the database.
This function allows modification of all post/ticket details - and can be used independently; it is possible (and even done in SimpleDesk) to update just a ticket or just a post from this function. All three parameters are by reference meaning they WILL be updated if things change. Note that this function is not validating that they are sensible values; it is up to the calling function to ascertain that.
Tags:
- since
- 1.0
Parameters
- array &$msgOptions
- - a hash array by reference, stating zero or more details to change on a message (if the change is strictly ticket-only, the entire $msgOptions array can be an empty array):
- id: Required if changing a message; the principle numeric id of the message to modify
- body: Optional, the principle body content of the message to change; if omitted, no change will occur. If set, assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and preparsecode)
- modified: Optional, hash array containing items relating to modification (if 'modified' key exists, all of these should be set)
- time: Unsigned int timestamp of the change
- name: String; user name of the user making the change
- id: Unsigned int user id of the user making the change
- smileys_enabled: Optional, boolean denoting whether smileys should be active on this post; if omitted no change will occur
- attachments: Optional, array of attachment ids that need attaching to this message; if omitted no changes will occur
- array &$ticketOptions
- - a hash array by reference, stating one or more details necessary to change on a ticket:
- id: Required in all cases, numeric ticket id that the edit relates to
- subject: Optional string with the new subject in; if omitted no change will occur. If set, assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and strtr)
- urgency: Optional integer with the new urgency in; if omitted no change will occur
- status: Optional integer with the new status in; if omitted no change will occur
- ssigned: Optional integer with the user id of assigned user; if omitted no change will occur (note, you would declare this as 0 to unassign a ticket - set to 0 is not omitted)
- private: Optional boolean as to privacy of ticket: true = private, false = not private (note, you still declare this to change it)
- array &$posterOptions
- - a hash array by reference of details to change on the poster of a message:
- name: Optional string, name of credited poster (in absence of id, this will be used); if omitted no change will occur
- email: Optional string, email address of poster; if omitted no change will occur



