Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 109

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
        {
        
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]);
        
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 5th December 2024 06:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.