Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

reorder_user_dash()

Parameters

ColumnTypeDefaultDescription
$user

Location

include/dash_functions.php lines 1029 to 1048

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)) + 10# Begin ordering at 10 for first position, not 0.
    
    
$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 19th March 2024 11:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.