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

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 116 to 193

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?1:0;
    
$all_users=$all_users?1:0;

    if(!
is_numeric($default_order_by))
        {
        
$default_order_by=$tile["default_order_by"];
        }
    
$resource_count $resource_count?1: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_group,0,$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 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.