Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

build_usergroup_dash()

Description

build_usergroup_dash - rebuild the usergroup tiles for either a specific user or all users.
If a specific tile is passed e.g. if called from create_dash_tile then we just add it to the end

Parameters

ColumnTypeDefaultDescription
$user_group integer ID of group to add tile(s) to
$user_id integer 0 ID of individual user to add tile(s) to
$newtileid integer "" ID of a single tile to add on the end

Return

void

Location

include/dash_functions.php lines 761 to 813

Definition

 
function build_usergroup_dash($user_group$user_id 0$newtileid="")
    {
    if(
$newtileid!="" && is_numeric($newtileid))
        {
        
$user_group_tiles = array($newtileid);
        }
    else
        {
        
$user_group_tiles sql_array"SELECT 
                                            dash_tile.ref AS `value`
                                        FROM
                                            usergroup_dash_tile
                                                JOIN
                                            dash_tile ON usergroup_dash_tile.dash_tile = dash_tile.ref
                                        WHERE
                                            usergroup_dash_tile.usergroup = '
{$user_group}'
                                                AND dash_tile.all_users = 1
                                                AND (dash_tile.allow_delete = 1
                                                OR (dash_tile.allow_delete = 0
                                                AND dash_tile.ref IN (SELECT DISTINCT
                                                    user_dash_tile.dash_tile
                                                FROM
                                                    user_dash_tile)))
                                        ORDER BY usergroup_dash_tile.default_order_by;"
);
        }

    
// If client code has specified a user ID, then just add the tiles for it
    
if(is_numeric($user_id) && $user_id)
        {
        
$starting_order 99999;

        foreach(
$user_group_tiles as $tile)
            {
            
add_user_dash_tile($user_id$tile$starting_orderfalse); // No need to reorder as we have already set the position
            
$starting_order += 10;
            }

        return;
        }

    
$user_list sql_array("SELECT ref AS `value` FROM user WHERE usergroup = '{$user_group}'");
    foreach(
$user_list as $user)
        {
        
$starting_order  99999;
        foreach(
$user_group_tiles as $tile)
            {
            
add_user_dash_tile($user$tile$starting_orderfalse); // No need to reorder as we have already set the position
            
$starting_order += 10;
            }
        }

    return;
    }

This article was last updated 14th July 2020 04:05 Europe/London time based on the source file dated 24th June 2020 14:38 Europe/London time.