dash_functions.php
Table of Contents
Functions
- existing_dash_tile() : int
- returns a ref for an existing dash tile in dash_tile table, returns 0 if no existing dash tile
- create_dash_tile() : mixed
- update_dash_tile() : mixed
- delete_dash_tile() : mixed
- revoke_all_users_flag_cascade_delete() : mixed
- append_default_position() : mixed
- reorder_default_dash() : mixed
- update_default_dash_tile_order() : mixed
- get_tile() : mixed
- all_user_dash_tile_active() : mixed
- existing_tile() : mixed
- cleanup_dash_tiles() : mixed
- checkTileConfig() : mixed
- checkConfigCustomHomePanels() : mixed
- get_alluser_available_tiles() : mixed
- get_default_dash() : mixed
- get_managed_dash() : mixed
- add_usergroup_dash_tile() : mixed
- append_usergroup_position() : mixed
- reorder_usergroup_dash() : void
- Reorder dashboard tiles for a specific user group.
- update_usergroup_dash_tile_order() : void
- Update the display order of a specific dashboard tile for a user group.
- build_usergroup_dash() : void
- build_usergroup_dash - rebuild the usergroup tiles for either a specific user or all users.
- get_tile_user_groups() : array<string|int, mixed>
- Retrieve user group IDs associated with a specific dashboard tile.
- get_usergroup_available_tiles() : array<string|int, mixed>
- Retrieve dashboard tiles available to a specific user group.
- get_usergroup_tile() : array<string|int, mixed>
- Get usergroup_dash_tile record
- add_user_dash_tile() : mixed
- get_user_tile() : mixed
- create_new_user_dash() : mixed
- update_user_dash_tile_order() : mixed
- delete_user_dash_tile() : mixed
- empty_user_dash() : mixed
- reorder_user_dash() : mixed
- append_user_position() : mixed
- get_user_available_tiles() : mixed
- get_user_dash() : mixed
- render_delete_dialog_JS() : void
- Render JavaScript for the dashboard tile delete dialog.
- parse_dashtile_link() : mixed
- build_dash_tile_list() : mixed
- delete_usergroup_dash_tile() : mixed
- allowPromotedResources() : bool
- Confirms whether a dash tile type allows for promoted resources
- render_upgrade_available_tile() : void
- Render "Upgrade available" tile for Administrators and Super Admins. This tile cannot be deleted or removed unless ResourceSpace version is up to date
- generate_dash_tile_toolbar() : void
- Generate HTML and JavaScript for the dashboard tile toolbar.
- dash_tile_featured_collection_get_resources() : array<string|int, mixed>
- Build list of resources that can be shown on a dash tile as a background image. Helper function.
- dash_tile_featured_collection_get_top_resources() : mixed
- validate_tile_style() : string
- Validate the type of dash tile and check that the style provided is valid for it.
- validate_build_url() : string
- Sanitise the url provided when saving a dash tile. This function will take the value obtained by the form and pass it through if valid.
- tltype_srch_generate_js_for_background_and_count() : mixed
- Generate client side logic for doing expensive computation async for retrieving the tile background and total results count.
- get_dash_search_data() : array<string|int, mixed>
- Get images and resource count for search dash tile.
- can_edit_tile() : bool
- Check if current user can edit dash tile. Users shouldn't be able to edit tiles that they can't view and only dash admins should be able to edit shared tiles.
Functions
existing_dash_tile()
returns a ref for an existing dash tile in dash_tile table, returns 0 if no existing dash tile
existing_dash_tile([string $url = "" ][, string $link = "" ][, string $title = "" ][, string $text = "" ][, int $reload_interval = 0 ][, int $all_users = 0 ][, int $resource_count = 0 ]) : int
Parameters
- $url : string = ""
- $link : string = ""
- $title : string = ""
- $text : string = ""
- $reload_interval : int = 0
- $all_users : int = 0
- $resource_count : int = 0
Return values
intcreate_dash_tile()
create_dash_tile(mixed $url, mixed $link, mixed $title, mixed $reload_interval, mixed $all_users, mixed $default_order_by, mixed $resource_count[, mixed $text = "" ][, mixed $delete = 1 ][, array<string|int, mixed> $specific_user_groups = array() ]) : mixed
Parameters
- $url : mixed
- $link : mixed
- $title : mixed
- $reload_interval : mixed
- $all_users : mixed
- $default_order_by : mixed
- $resource_count : mixed
- $text : mixed = ""
- $delete : mixed = 1
- $specific_user_groups : array<string|int, mixed> = array()
update_dash_tile()
update_dash_tile(mixed $tile, mixed $url, mixed $link, mixed $title, mixed $reload_interval, mixed $all_users, mixed $tile_audience, mixed $current_specific_user_groups, mixed $specific_user_groups, mixed $default_order_by, mixed $resource_count[, mixed $text = "" ][, mixed $delete = 1 ]) : mixed
Parameters
- $tile : mixed
- $url : mixed
- $link : mixed
- $title : mixed
- $reload_interval : mixed
- $all_users : mixed
- $tile_audience : mixed
- $current_specific_user_groups : mixed
- $specific_user_groups : mixed
- $default_order_by : mixed
- $resource_count : mixed
- $text : mixed = ""
- $delete : mixed = 1
delete_dash_tile()
delete_dash_tile(mixed $tile[, mixed $cascade = true ][, mixed $force = false ]) : mixed
Parameters
- $tile : mixed
- $cascade : mixed = true
- $force : mixed = false
revoke_all_users_flag_cascade_delete()
revoke_all_users_flag_cascade_delete(mixed $tile) : mixed
Parameters
- $tile : mixed
append_default_position()
append_default_position() : mixed
reorder_default_dash()
reorder_default_dash() : mixed
update_default_dash_tile_order()
update_default_dash_tile_order(mixed $tile, mixed $order_by) : mixed
Parameters
- $tile : mixed
- $order_by : mixed
get_tile()
get_tile(mixed $tile) : mixed
Parameters
- $tile : mixed
all_user_dash_tile_active()
all_user_dash_tile_active(mixed $tile) : mixed
Parameters
- $tile : mixed
existing_tile()
existing_tile(mixed $title, mixed $all_users, mixed $url, mixed $link, mixed $reload_interval, mixed $resource_count[, mixed $text = "" ]) : mixed
Parameters
- $title : mixed
- $all_users : mixed
- $url : mixed
- $link : mixed
- $reload_interval : mixed
- $resource_count : mixed
- $text : mixed = ""
cleanup_dash_tiles()
cleanup_dash_tiles() : mixed
checkTileConfig()
checkTileConfig(mixed $tile, mixed $tile_style) : mixed
Parameters
- $tile : mixed
- $tile_style : mixed
checkConfigCustomHomePanels()
checkConfigCustomHomePanels(mixed $tile, mixed $tile_style) : mixed
Parameters
- $tile : mixed
- $tile_style : mixed
get_alluser_available_tiles()
get_alluser_available_tiles([mixed $tile = "null" ]) : mixed
Parameters
- $tile : mixed = "null"
get_default_dash()
get_default_dash([mixed $user_group_id = null ][, mixed $edit_mode = false ]) : mixed
Parameters
- $user_group_id : mixed = null
- $edit_mode : mixed = false
get_managed_dash()
get_managed_dash() : mixed
add_usergroup_dash_tile()
add_usergroup_dash_tile(mixed $usergroup, mixed $tile, mixed $default_order_by) : mixed
Parameters
- $usergroup : mixed
- $tile : mixed
- $default_order_by : mixed
append_usergroup_position()
append_usergroup_position(mixed $usergroup) : mixed
Parameters
- $usergroup : mixed
reorder_usergroup_dash()
Reorder dashboard tiles for a specific user group.
reorder_usergroup_dash(int $usergroup) : void
This function retrieves all dashboard tiles assigned to a user group and updates each tile's order in increments of 10.
Parameters
- $usergroup : int
-
The user group ID for which dashboard tiles should be reordered.
update_usergroup_dash_tile_order()
Update the display order of a specific dashboard tile for a user group.
update_usergroup_dash_tile_order(int $usergroup, int $tile, int $default_order_by) : void
Parameters
- $usergroup : int
-
The user group ID to which the dashboard tile belongs.
- $tile : int
-
The ID of the dashboard tile to update.
- $default_order_by : int
-
The new default order position for the tile within the user group's dashboard.
build_usergroup_dash()
build_usergroup_dash - rebuild the usergroup tiles for either a specific user or all users.
build_usergroup_dash(int $user_group[, int $user_id = 0 ][, int $newtileid = "" ]) : void
If a specific tile is passed e.g. if called from create_dash_tile then we just add it to the end
Parameters
- $user_group : int
-
ID of group to add tile(s) to
- $user_id : int = 0
-
ID of individual user to add tile(s) to
- $newtileid : int = ""
-
ID of a single tile to add on the end
get_tile_user_groups()
Retrieve user group IDs associated with a specific dashboard tile.
get_tile_user_groups(int $tile_id) : array<string|int, mixed>
This function fetches the IDs of all user groups that have access to a given dashboard tile. Each user group ID is returned as a value in the resulting array.
Parameters
- $tile_id : int
-
The ID of the dashboard tile for which to retrieve associated user groups.
Return values
array<string|int, mixed> —An array of user group IDs that are linked to the specified dashboard tile.
get_usergroup_available_tiles()
Retrieve dashboard tiles available to a specific user group.
get_usergroup_available_tiles(int $user_group_id[, int|string $tile = '' ]) : array<string|int, mixed>
This function returns the tiles that are accessible by a particular user group, optionally filtered by a specific tile ID. The function ensures that the user group ID is numeric and fetches the tiles that are either available to all users or specifically assigned to the provided user group.
Parameters
- $user_group_id : int
-
The ID of the user group for which to retrieve available tiles.
- $tile : int|string = ''
-
(optional) Specific tile ID to filter by; if omitted, all available tiles for the user group are returned.
Tags
Return values
array<string|int, mixed> —An array of associative arrays, each representing a dashboard tile with keys:
- 'ref' (int): Unique reference ID of the tile.
- 'tile' (int): Same as 'ref', included for compatibility.
- 'title' (string): The title of the tile.
- 'txt' (string): Text content of the tile.
- 'link' (string): Link associated with the tile.
- 'url' (string): URL of an external resource, if any.
- 'reload_interval_secs' (int): Time interval for reloading the tile content in seconds.
- 'resource_count' (int): Resource count, if applicable.
- 'all_users' (int): Flag indicating if the tile is available to all users.
- 'allow_delete' (int): Flag indicating if the tile can be deleted.
- 'default_order_by' (int): Default order for the tile.
- 'order_by' (int|null): Order for the tile within the user group; may be null if not explicitly set.
- 'dash_tile' (int): Always set to 1, indicating it is a dashboard tile.
get_usergroup_tile()
Get usergroup_dash_tile record
get_usergroup_tile(int $tile_id, int $user_group_id) : array<string|int, mixed>
Parameters
- $tile_id : int
- $user_group_id : int
Return values
array<string|int, mixed>add_user_dash_tile()
add_user_dash_tile(mixed $user, mixed $tile, mixed $order_by[, mixed $reorder = true ]) : mixed
Parameters
- $user : mixed
- $tile : mixed
- $order_by : mixed
- $reorder : mixed = true
get_user_tile()
get_user_tile(mixed $usertile, mixed $user) : mixed
Parameters
- $usertile : mixed
- $user : mixed
create_new_user_dash()
create_new_user_dash(mixed $user) : mixed
Parameters
- $user : mixed
update_user_dash_tile_order()
update_user_dash_tile_order(mixed $user, mixed $tile, mixed $order_by) : mixed
Parameters
- $user : mixed
- $tile : mixed
- $order_by : mixed
delete_user_dash_tile()
delete_user_dash_tile(mixed $usertile, mixed $user) : mixed
Parameters
- $usertile : mixed
- $user : mixed
empty_user_dash()
empty_user_dash(mixed $user[, mixed $purge = true ]) : mixed
Parameters
- $user : mixed
- $purge : mixed = true
reorder_user_dash()
reorder_user_dash(mixed $user) : mixed
Parameters
- $user : mixed
append_user_position()
append_user_position(mixed $user) : mixed
Parameters
- $user : mixed
get_user_available_tiles()
get_user_available_tiles(mixed $user[, mixed $tile = "null" ]) : mixed
Parameters
- $user : mixed
- $tile : mixed = "null"
get_user_dash()
get_user_dash(mixed $user) : mixed
Parameters
- $user : mixed
render_delete_dialog_JS()
Render JavaScript for the dashboard tile delete dialog.
render_delete_dialog_JS([bool $all_users = false ]) : void
This function outputs JavaScript to create and display a jQuery UI dialog for deleting dashboard tiles.
Depending on the $all_users parameter, the dialog may include additional options for deleting default tiles
or managing default dashboard tiles.
Parameters
- $all_users : bool = false
-
(optional) If set to
true, additional options are displayed for managing tiles that are accessible by all users. Default isfalse.
Return values
void —Outputs JavaScript directly to the page to render the dialog.
parse_dashtile_link()
parse_dashtile_link(mixed $link) : mixed
Parameters
- $link : mixed
build_dash_tile_list()
build_dash_tile_list(mixed $dtiles_available) : mixed
Parameters
- $dtiles_available : mixed
delete_usergroup_dash_tile()
delete_usergroup_dash_tile(mixed $tile, mixed $group) : mixed
Parameters
- $tile : mixed
- $group : mixed
allowPromotedResources()
Confirms whether a dash tile type allows for promoted resources
allowPromotedResources(string $tile_type) : bool
Parameters
- $tile_type : string
Return values
boolrender_upgrade_available_tile()
Render "Upgrade available" tile for Administrators and Super Admins. This tile cannot be deleted or removed unless ResourceSpace version is up to date
render_upgrade_available_tile(int $user) : void
Parameters
- $user : int
-
User ID, normally this is the $userref
generate_dash_tile_toolbar()
Generate HTML and JavaScript for the dashboard tile toolbar.
generate_dash_tile_toolbar(array<string|int, mixed> $tile, string $tile_id[, bool $display_counter = false ]) : void
This function renders a toolbar for a dashboard tile, providing options to delete or edit the tile, based on the user's permissions. The toolbar appears on hover and includes JavaScript functionality to manage tile interactions, including preventing accidental clicks on the tile itself when using the toolbar.
Parameters
- $tile : array<string|int, mixed>
-
An associative array containing information about the dashboard tile, including:
- 'ref' (int): Tile reference ID.
- 'all_users' (int): Flag indicating if the tile is accessible by all users.
- 'no_edit' (bool): Flag indicating if the tile is non-editable.
- 'url' (string|null): Optional URL for the tile's link.
- $tile_id : string
-
The unique HTML ID of the tile used for identifying elements in the toolbar.
- $display_counter : bool = false
-
If true then a counter pill will be rendered opposite the dash tile actions
dash_tile_featured_collection_get_resources()
Build list of resources that can be shown on a dash tile as a background image. Helper function.
dash_tile_featured_collection_get_resources(array<string|int, mixed>|int $c, array<string|int, mixed> $ctx) : array<string|int, mixed>
Parameters
- $c : array<string|int, mixed>|int
-
Collection ref -or- collection data as returned by get_collection()
- $ctx : array<string|int, mixed>
-
Contextual data
Return values
array<string|int, mixed>dash_tile_featured_collection_get_top_resources()
dash_tile_featured_collection_get_top_resources() : mixed
validate_tile_style()
Validate the type of dash tile and check that the style provided is valid for it.
validate_tile_style(string $type, string $style) : string
Parameters
- $type : string
-
Tile type name.
- $style : string
-
Tile style name.
Return values
string —Will return the style value provided if correct, the first defined style or blank if no styles defined.
validate_build_url()
Sanitise the url provided when saving a dash tile. This function will take the value obtained by the form and pass it through if valid.
validate_build_url(string $buildurl) : string
If the url supplied is invalid, a blank value will be returned allowing the default standard tile type to be used.
Parameters
- $buildurl : string
-
url supplied when dash tile is edited, containing a number of optional parameters.
Return values
string —A valid url or empty string if invalid.
tltype_srch_generate_js_for_background_and_count()
Generate client side logic for doing expensive computation async for retrieving the tile background and total results count.
tltype_srch_generate_js_for_background_and_count(array<string|int, mixed> $tile, string $tile_id, int $tile_width, int $tile_height, int $promoted_image) : mixed
Parameters
- $tile : array<string|int, mixed>
-
Tile information pages/ajax/dash_tile.php
- $tile_id : string
-
HTML ID for the container div
- $tile_width : int
-
Tile width pages/ajax/dash_tile.php
- $tile_height : int
-
Tile height pages/ajax/dash_tile.php
- $promoted_image : int
-
ID of the promoted resource (for background)
get_dash_search_data()
Get images and resource count for search dash tile.
get_dash_search_data([string $link = '' ][, int $promimg = 0 ]) : array<string|int, mixed>
This has to work on a string because the dash tile does not yet exist when on dash creation page For performance this function will return a maximum of 4 images
Parameters
- $link : string = ''
-
Tile link URL
- $promimg : int = 0
-
Promoted image ref
Return values
array<string|int, mixed> —$searchdata Array containing the count of resources and details of preview images.
can_edit_tile()
Check if current user can edit dash tile. Users shouldn't be able to edit tiles that they can't view and only dash admins should be able to edit shared tiles.
can_edit_tile(int $tileref, int $audience, int $user) : bool
Parameters
- $tileref : int
- $audience : int
-
0 for tile available to one user, 1 for all users. Typically obtained from get_tile()
- $user : int
-
Ref of the user editing the tile.
Return values
bool —Will return true if editing is allowed else will return false.