get_usergroup_available_tiles()

Description

Retrieve dashboard tiles available to a specific user group.

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.

- '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.

@throws \Exception If $user_group_id is not a numeric value.

Parameters

ColumnTypeDefaultDescription
$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.

Return

array An array of associative arrays, each representing a dashboard tile with keys:

Location

include/dash_functions.php lines 935 to 974

Definition

 
function get_usergroup_available_tiles($user_group_id$tile '')
{
    if (!
is_numeric($user_group_id)) {
        
trigger_error('$user_group_id has to be a number');
    }

    
$tile_sql '';
    
$params = [];

    if (
'' != $tile) {
        
$tile_sql "AND dt.ref = ?";
        
$params = ['i'$tile];
    }

    
$params[] = 'i';
    
$params[] = $user_group_id;

    return 
ps_query(
        
"SELECT
            dt.ref,
            dt.ref AS `tile`,
            dt.title,
            dt.txt,
            dt.link,
            dt.url,
            dt.reload_interval_secs,
            dt.resource_count,
            dt.all_users,
            dt.allow_delete,
            dt.default_order_by,
            udt.order_by,
            1 AS 'dash_tile'
        FROM dash_tile AS dt
        LEFT JOIN usergroup_dash_tile AS udt ON dt.ref = udt.dash_tile
        WHERE dt.all_users = 1
        AND udt.usergroup = ? 
{$tile_sql}
        ORDER BY udt.default_order_by ASC"
,
        
$params
    
);
}

This article was last updated 20th April 2025 21:35 Europe/London time based on the source file dated 17th April 2025 17:40 Europe/London time.