Collections functions
General functions
Render functions
Theme permission functions
Resource functions

reorder_user_dash()

Parameters

ColumnTypeDefaultDescription
$user

Location

include/dash_functions.php lines 1040 to 1059

Definition

 
function reorder_user_dash($user)
    {
    
$user_tiles ps_query("SELECT user_dash_tile.ref FROM user_dash_tile LEFT JOIN dash_tile ON user_dash_tile.dash_tile = dash_tile.ref WHERE user_dash_tile.user= ? ORDER BY user_dash_tile.order_by", ['i'$user]);
    if (
count($user_tiles) < 2)
        {
        return;    
        }
    
$order_by=10 count($user_tiles);
    
    
$sql="UPDATE user_dash_tile SET order_by = (CASE ";
    
$params = [];
    for(
$i=count($user_tiles)-1;$i>=0;$i--)
        {
        
$sql.=" WHEN ref= ? THEN ? ";
        
$order_by-=10;
        
$params array_merge($params, ['i'$user_tiles[$i]["ref"], 'i'$order_by]);
        }
    
$sql.=" END) WHERE user='" $user "'";
    
ps_query($sql$params);
    }

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