SimpleDesk API
Procedural File: SimpleDesk-AjaxHandler.php
Source Location: /source/SimpleDesk-AjaxHandler.phpThis file handles all the actions that can be carried out through AJAX methods, performing them and providing adequate feedback/information.
Tags:
- since
- 1.0
Contains the following functions:
shd_ajax [line 53]
void shd_ajax (
)
Receives AJAX requests and facilitates replying to them.
This function sets up and calls the AJAX handlers; it is the primary receiver for action=helpdesk;sa=ajax.
Primarily, it expects $context['ajax_return'] to be populated as an array of tags to be returned as XML items to the user, with this element being a key-value pair (e.g. $context['ajax_return']['message'] = 'Success!') to be returned as a literal tag, element message, value of Success!, wrapped in the character data block.
An AJAX handler function may also return content in $context['ajax_raw'], this is when the function has prepared its own XML block to return. In such an instance, this function simply outputs the xml headers and assumes the return value is otherwise value.
For example, if the error subarray is populated (['error'] = 'Insufficient permission'), the XML block will contain a tag called error, with a CDATA block containing 'Insufficient permission'.
Tags:
- since
- 1.0
Return value
This function has no return value.shd_ajax_privacy [line 120]
void shd_ajax_privacy (
)
Handles AJAX updates to privacy.
Receives a request via ?action=helpdesk;sa=ajax;op=privacy to flip the privacy setting.
Operations:
- silent session check; if fail, add to $context['ajax_return']['error']
- ticket id check; if fail, add to $context['ajax_return']['error']
- get enough ticket data to do this
- check if the ticket is not able to be updated (either is closed/deleted, or insufficient permissions); if fail add to $context['ajax_return']['error']
- switch privacy, update database
- clear the cache of tickets for the Helpdesk menu item
- return $context['ajax_return']['message'] as the new privacy item
Return value
This function has no return value.shd_ajax_quote [line 300]
void shd_ajax_quote (
)
Collects ticket post data for quoting posts through AJAX (i.e. inserting a quote live into the postbox)
Operations:
- Session check; failing in a regular fashion (as opposed to normal return since we're using ;xml in the URL; the SMF handler can deal with that)
- If a message id is provided, query for it. If not found (or not provided), die, otherwise continue.
- Call un_preparsecode to remove extraneous sanity encoding.
- Build the [quote] bbcode around the post body.
- Convert to SMF style BBC-to-HTML if using WYSIWYG
- Do other XML sanitising
- Return via $context['ajax_raw'] for shd_ajax() to output
Return value
This function has no return value.shd_ajax_urgency [line 205]
void shd_ajax_urgency (
)
Handles AJAX updates to ticket urgency.
Receives request through ?action=helpdesk;sa=ajax;op=urgency;change=x where x is increase or decrease.
Operations:
- silent session check; if fail, add to $context['ajax_return']['error']
- ticket id check; if fail, add to $context['ajax_return']['error']
- get enough ticket data to do this
- identify whether the new urgency needs 'urgent' styling or not and put the new urgency in $context['ajax_return']['message']
- update the database with the new urgency
- identify whether the new urgency continues to allow the current user to change urgency or not
- put the button links if appropriate into $context['ajax_return']['increase'] and $context['ajax_return']['decrease'] and return



