This file handles key functions for SimpleDesk that can be called on every page load, such as the custom query function to handle ticket visibility, the counter for active tickets in the menu header, or the action log.
This function initialises certain key constructs for SimpleDesk, such as constants, that are used throughout SimpleDesk. It should be called first right up in Load.php anyway. Calling multiple times is not significantly detrimental to performance; the function is aware if it has been called previously.
This function provides a basic wrapper around SMF's internal $smcFunc['db_query'] function, adding the parameter {query_see_ticket} to it, specifically so that ticket visibility can be enforced in a query without being aware of the specific rules for the user. If not previously loaded, user permissions are loaded with {@link}.
Parameter: $identifier
Expected type: string
SMF-style query identifier for database backend-specific replacements
Parameter: $db_string
Expected type: string
Standard SMF 2.0 style database query, including {query_see_ticket} if appropriate
Parameter: $db_values
Expected type: array
Default: array()
Standard SMF 2.0 style hash map of parameters to inject into the query
Parameter: $connection
Expected type: resource|null
Default: null
A database connection variable, if supplied, to override the one used by SMF by default
Identifies the number of tickets that a user might be interested in, and generates the menu text for the main menu to include this; note that the value should be cached through SMF's functions. The cache is also clearable, through the {@link} function.
{@link} generates the number of active tickets for the user display, and caches it for 180 seconds normally. This function clears the cache and should be called whenever any operation modifies the state of a ticket.
Parameter: $dept
Expected type: int
The department that is being affected by this change. Users who cannot see this department will not be affected.
This function deals with adding items to the action log maintained by the helpdesk.
Parameter: $action
Expected type: string
Specifies the name of the action to log, which implies the image and language string (log_$action is the name of the image, and $txt['shd_log_$action'] is the string used to express the action, as listed in {@link}. Note that since 1.1, the list of actions is looked up against the options in Admin / Helpdesk / Options / Action Log Options as to whether they should be logged or not
Parameter: $params
Expected type: array
This is a list of named parameters in a hash array to be used in the language string later.
Parameter: $do_last_update
Expected type: mixed
Default: true
This function identifies whether the current user can raise or lower the urgency of a ticket based on the current urgency of the ticket and whether it is their ticket; this is used in the ticket display as well as the actions linked directly to modifying urgency (both AJAXively and non AJAXively)
Parameter: $urgency
Expected type: int
The current urgency of a ticket as an integer
Parameter: $ticket_starter
Expected type: bool
Whether the user in question is the starter of the ticket (instead of querying to establish that, that detail should already be known to the calling function)
Parameter: $closed
Expected type: bool
Whether the ticket is currently closed or not
Parameter: $deleted
Expected type: bool
Whether the ticket is currently closed or not
Parameter: $dept
Expected type: mixed
This function collects counts for the different states of tickets (new, with staff, with user, etc) of all the tickets visible to the user, and returns a selection of that dataset based on the values provided to $status and $is_staff.
Parameter: $status
Expected type: string
Default: ''
The relevant count of tickets to return:
Parameter: $is_staff
Expected type: bool
Default: false
If the user in question is staff or not.
This function permission-checks, and throws appropriate errors if no ticket is specified either directly or through URL, or if the ticket is not accessible either through deletion or lack of permissions.
Parameter: $ticket
Expected type: int
The ticket to use; if none is specified, use the one from $_REQUEST['ticket'], which will have been processed into $context['ticket_id'] if it is available.
Formatting is done according to the supplied settings and the master administration settings.
Parameter: $text
Expected type: string
Raw text with optional bbcode formatting
Parameter: $smileys
Expected type: bool
Default: true
Whether smileys should be used; this is not an override to the master administration setting of whether to use smileys or not, and that takes precedence.
Parameter: $cache
Expected type: string
Default: ''
If specified, this will provide the cache'd id that SMF should use to cache the output if it is suitably large.
Processes the incoming message for wiki-links.
Parameter: $message
Expected type: string
The message to be parsed.
Parameter: $smileys
Expected type: string
Default: array()
The Smileys sets.
Parameter: $cache_id
Expected type: array
Default: array()
Cache ids used by messages, currently not used.
Parameter: $parse_tags
Expected type: array
Default: array()
Tags to parse, currently not used.
SMF itself has loadMemberData() and loadMemberContext to perform this act, however those two functions are much larger and more complex than we need more often than not, especially when all we want/need is member name (and subsequently profile link) Since profile links should be based on the view profile permission, we will need to establish that.
Parameter: $name
Expected type: string
The name to display. This should be a standard SMF type name, which means already sanitised for HTML.
Parameter: $id
Expected type: int
The numeric id of the user we are linking to.
As of 2.0, images can live either in the main Themes/default/images/simpledesk folder, or additionally in Themes/default/images/sd_plugins, the latter of which is intended for plugins (the former is removed on SD uninstall, the latter is not) It should only be used in cases where there is ambiguity over where the image may live, e.g. preferences, permissions UIs. If there is no ambiguity (e.g. SD core, or plugins themselves, where they know where the image will be referenced from), it is recommended to avoid this function.
Parameter: $filename
Expected type: string
An image filename, e.g. image.png
Tickets invariably have multiple changes of status during their life. All actions that could change a ticket's status should call here, even if it is a straight forward, one-route-only change of status since it is possible we could end up giving the user a choice one day over how statuses work, so we should route everything through here all the time.
Parameter: $action
Expected type: string
(required), represents the action carried out by the calling function Known values: new, resolve, unresolve, deleteticket, restoreticket, deletereply, restorereply, reply, topictoticket (new is default)
Parameter: $starter_id
Expected type: int
Numeric id of the ticket's starter (should be provided)
Parameter: $replier_id
Expected type: int
Numeric id of the ticket's last reply author (should be provided)
Parameter: $replies
Expected type: int
Default: -1
Number of replies in the ticket (should be provided)
Parameter: $dept
Expected type: mixed
Default: -1
SimpleDesk uses SMF's core page index function in numerous places, but unlike SMF, it often places it in containers that have backgrounds driven by menu_block.png, meaning that they are often fixed in height. Under some circumstances layout can be broken, so this function forcibly ensures the block can never expand to force wrapping.
Parameter: $base_url
Expected type: string
Form of URL pageindex links should take, using $1%d to represent the start point identifier.
Parameter: $start
Expected type: int
Position to start. If not a multiple of the number per page, it will be forced to become a multiple.
Parameter: $max_value
Expected type: int
Number of items in total to paginate for.
Parameter: $num_per_page
Expected type: int
Number of items to be shown on a page.
Parameter: $flexible_start
Expected type: bool
Default: false
Whether a more flexible % option is to be used in the base URL.
As of 2.0 RC2, there is detection code in SMF to ensure the Modifications language file is always loaded, but the same detection is not applied to all language files. This ensures it will be for SD files.
Parameter: $langfile
Expected type: string
Name of a language file to load, typically SimpleDesk prefixed, though could be used for any SMF language file.
Parameter: $override_lang
Expected type: string
Default: ''
Name of a language to load as an override, rather than just the user's default.
Operations: - Identify how many deleted and non deleted replies there are in the ticket. - Identify the last non deleted reply in the ticket (if there are no undeleted replies, use the ticket post itself for cohesion) - Update the ticket's record with the first and last posters, as well as the correct number of active and deleted replies, and whether there are any deleted replies on the ticket generally Prior to SimpleDesk 1.1, this function was located in Sources/SimpleDesk-Delete.php.
Parameter: $ticket
Expected type: int
The ticket id to recalculate.
Load the user preferences for the given user.
Parameter: $user
Expected type: int|bool
Normally, an int being the user id of the user whose preferences should be attempted to be loaded. If === false, return the list of default prefs (for the pref UI), or if 0 or omitted, load the current user.
Loads any source files directed by integration hooks.
Parameter: $hook
Expected type: mixed
Default: ''
Loads any language files directed by integration hooks.
Parameter: $hook
Expected type: mixed
Default: ''
This explicitly relies on the display template hook for such things. If the theme does not provide it, the theme author needs to update their theme.
Parameter: $normal_buttons
Expected type: mixed
All scheduled tasks have to have the name prefix scheduled_ and must be defined by the time we get to running AutoTask() in Scheduled.php. Short of modifying that file, we can define a placeholder here (which will exist for AutoTask) and have that be called.
Load the CSS file for the icons.
Parameter: $current_action
Expected type: array
The current action.
Adds the SimpleDesk action to the action list, and also handles most of the shutting down of forum items in helpdesk-only mode.
Parameter: $actionArray
Expected type: array
The master list of actions from index.php
Last-minute buffer replacements to be made, e.g. removing unwanted content in helpdesk-only mode.
Parameter: $buffer
Expected type: mixed
Add the SimpleDesk options to the main site menu.
Parameter: $menu_buttons
Expected type: array
The main menu buttons as provided by Subs.php.
Adds to the Admin Center menu the helpdesk section buttons.
Parameter: $helpdesk_admin
Expected type: mixed
Add the SimpleDesk options to the profile popup menu.
Parameter: $profile_items
Expected type: mixed
Detect a SHD error and move it to the proper error type.
Parameter: $other_error_types
Expected type: array
Additional error types. @param string $error_type The type of error @param string $error_message The message to log @param string $file The name of the file where this error occurred @param int $line The line where the error occurred
Parameter: $error_type
Expected type: mixed
Parameter: $error_message
Expected type: mixed
Parameter: $file
Expected type: mixed
Parameter: $line
Expected type: mixed
Add our Quote BBC in.
Parameter: $codes
Expected type: array
Current BBCodes list. @param array $no_autolink_tags Tags we should not autolink
Parameter: $no_autolink_tags
Expected type: mixed
Works the same way as SMF, but allows customizing and overriding.
Parameter: $error
Expected type: mixed
Parameter: $log
Expected type: mixed
Default: 'simpledesk'
Parameter: $sprintf
Expected type: mixed
Default: array()
Parameter: $status
Expected type: mixed
Default: 403
Works the same way as SMF, but allows customizing and overriding.
Parameter: $error
Expected type: string
The error message
Parameter: $log
Expected type: string|bool
Default: 'general'
= 'general' What type of error to log this as (false to not log it))
Parameter: $status
Expected type: int
Default: 500
The HTTP status code associated with this error
Page created in 0.016 seconds with 11 queries.