update_dash_tile()

Parameters

ColumnTypeDefaultDescription
$tile
$url
$link
$title
$reload_interval
$all_users
$tile_audience
$current_specific_user_groups
$specific_user_groups
$default_order_by
$resource_count
$text ""
$delete 1

Location

include/dash_functions.php lines 113 to 188

Definition

 
function update_dash_tile($tile$url$link$title$reload_interval$all_users$tile_audience$current_specific_user_groups$specific_user_groups$default_order_by$resource_count$text ""$delete 1)
{
    global 
$userref;

    if (!
is_array($tile)) {
        
$tile get_tile($tile);
    }

    
#Sensible Defaults for insertion to Database
    
if (empty($reload_interval) || !is_numeric($reload_interval)) {
        
$reload_interval 0;
    }

    
$delete $delete 0;
    
$all_users $all_users 0;

    if (!
is_numeric($default_order_by)) {
        
$default_order_by $tile["default_order_by"];
    }

    
$resource_count $resource_count 0;

    
ps_query(
        
"UPDATE dash_tile SET url= ?, link= ?, title= ?, reload_interval_secs= ?, all_users= ?, default_order_by= ?, resource_count= ?, allow_delete= ?, txt= ? WHERE ref= ?",
        [
            
's'$url,
            
's'$link,
            
's'$title,
            
'i'$reload_interval,
            
'i'$all_users,
            
'i'$default_order_by,
            
'i'$resource_count,
            
'i'$delete,
            
's'$text,
            
'i'$tile['ref']
            ]
    );

    if (
$tile_audience == 'true') { // All users tile
        // Check if this was a specific usergroup tile
        
if (count($current_specific_user_groups) > || $tile["all_users"] == 0) {
            
#Delete the users existing record to ensure they don't get a duplicate.
            
ps_query("DELETE FROM user_dash_tile WHERE dash_tile= ?", ['i'$tile['ref']]);
            
ps_query("INSERT user_dash_tile (user,dash_tile,order_by) SELECT user.ref, ?,5 FROM user", ['i'$tile['ref']]);
        }

        
// This is an all users dash tile, delete any existing usergroup entries
        
ps_query("DELETE FROM usergroup_dash_tile WHERE dash_tile = ?", ['i'$tile['ref']]);
    } elseif (
$tile_audience == 'specific_user_groups') { // Specific usergroups tile
        // This is a usergroup specific dash tile
        // As is not meant for a specific user group, remove it from the users immediately
        
if (count($current_specific_user_groups) == 0) {
            
// This was an all users/usergroup dash tile, delete any existing user entries
            
ps_query("DELETE FROM user_dash_tile WHERE dash_tile = ?", ['i'$tile['ref']]);
        }

        
// Remove tile from old user groups
        
foreach (array_diff($current_specific_user_groups$specific_user_groups) as $remove_group) {
            
delete_usergroup_dash_tile($tile['ref'], $remove_group);
        }

        
// Newly selected user groups.
        
foreach (array_diff($specific_user_groups$current_specific_user_groups) as $add_group) {
            
add_usergroup_dash_tile($add_group$tile['ref'], $default_order_by);
            
build_usergroup_dash($add_group0$tile['ref']);
        }
    } else 
// Tile is now just for the current user
        
{
        
// This was an all users/usergroup dash tile, delete any existing user entries and add just for this user
        
ps_query("DELETE FROM usergroup_dash_tile WHERE dash_tile = ?", ['i'$tile['ref']]);
        
ps_query("DELETE FROM user_dash_tile WHERE dash_tile = ?", ['i'$tile['ref']]);
        
add_user_dash_tile($userref$tile['ref'], $default_order_by);
    }

    
hook('after_update_dash_tile');
}

This article was last updated 24th April 2025 12:05 Europe/London time based on the source file dated 17th April 2025 17:40 Europe/London time.