Collections functions
General functions
Render functions
Theme permission functions
Resource functions

create_dash_tile()

Parameters

ColumnTypeDefaultDescription
$url
$link
$title
$reload_interval
$all_users
$default_order_by
$resource_count
$text ""
$delete 1
$specific_user_groups array array

Location

include/dash_functions.php lines 38 to 99

Definition

 
function create_dash_tile($url,$link,$title,$reload_interval,$all_users,$default_order_by,$resource_count,$text="",$delete=1, array $specific_user_groups = array())
    {
    
    
$rebuild_order=TRUE;

    
# Validate Parameters
    
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=append_default_position();
        
$rebuild_order=FALSE;
        }
    
$resource_count $resource_count?1:0;

    
$existing_tile_ref existing_dash_tile($url$link,$title,$text,(int) $reload_interval,$all_users,$resource_count);
    
    if(
$existing_tile_ref 0)
        {
        
$tile=$existing_tile_ref;
        
$rebuild_order=FALSE;
        }
    else
        {
        
$result ps_query("INSERT INTO dash_tile (url,link,title,reload_interval_secs,all_users,default_order_by,resource_count,allow_delete,txt) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
                            [
                            
's'$url,
                            
's'$link,
                            
's'$title,
                            
'i'$reload_interval,
                            
'i'$all_users,
                            
'i'$default_order_by,
                            
'i'$resource_count,
                            
'i'$delete,
                            
's'$text
                            
]);
        
$tile=sql_insert_id();

        foreach(
$specific_user_groups as $user_group_id)
            {
            
add_usergroup_dash_tile($user_group_id$tile$default_order_by);
            
build_usergroup_dash($user_group_id0$tile);
            }
        }

    
# If tile already existed then this no reorder
    
if($rebuild_order){reorder_default_dash();}
    
    if(
$all_users==&& empty($specific_user_groups))
        {
        
ps_query("DELETE FROM user_dash_tile WHERE dash_tile= ?", ['i'$tile]);
        
$result ps_query("INSERT user_dash_tile (user,dash_tile,order_by) SELECT user.ref,?,5 FROM user", ['i'$tile]);
        }
    
    
hook('after_create_dash_tile''', array($tile));
    
    return 
$tile;
    }

This article was last updated 3rd October 2022 12:05 Europe/London time based on the source file dated 27th September 2022 15:05 Europe/London time.