Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_user_dash()

Parameters

ColumnTypeDefaultDescription
$user

Location

include/dash_functions.php lines 1107 to 1287

Definition

 
function get_user_dash($user)
    {
    global 
$baseurl,$baseurl_short,$lang,$dash_tile_shadows,$help_modal$dash_tile_colour$dash_tile_colour_options;

    
#Build User Dash and recalculate order numbers on display
    
$user_tiles sql_query("SELECT dash_tile.ref AS 'tile',dash_tile.title,dash_tile.all_users,dash_tile.url,dash_tile.reload_interval_secs,dash_tile.link,user_dash_tile.ref AS 'user_tile',user_dash_tile.order_by FROM user_dash_tile JOIN dash_tile ON user_dash_tile.dash_tile = dash_tile.ref WHERE user_dash_tile.user='".$user."' ORDER BY user_dash_tile.order_by");

    
$order=10;
    foreach(
$user_tiles as $tile)
        {
        if(
$order != $tile["order_by"] || ($tile["order_by"] % 10) > 0){update_user_dash_tile_order($user,$tile["user_tile"],$order);}
        
$order+=10;

        
$tile_custom_style '';

        
$buildstring explode('?'$tile['url']);
        
parse_str(str_replace('&''&'$buildstring[1]), $buildstring);

        
$tlsize = (isset($buildstring['tlsize']) ? $buildstring['tlsize'] : '');

        if(
$dash_tile_colour)
            {
            if(isset(
$buildstring['tltype']) && allow_tile_colour_change($buildstring['tltype']) && isset($buildstring['tlstylecolour']))
                {
                
$tile_custom_style .= get_tile_custom_style($buildstring);
                }
            }
        
?>
        <a 
             
            
# Check link for external or internal
            
if(mb_strtolower(substr($tile["link"],0,4))=="http")
                {
                
$link $tile["link"];
                
$newtab true;
                }
            else
                {
                
$link $baseurl."/".htmlspecialchars($tile["link"]);
                
$newtab=false;
                }
            
?>
            href=" echo parse_dashtile_link($link)?> echo $newtab "target='_blank'" "";?> 
            onClick="if(dragging){dragging=false;return false;} if ($tile["link"] != "") {echo $newtab"""return " . ($help_modal && strpos($link,"pages/help.php")!==false?"ModalLoad(this,true);":"CentralSpaceLoad(this,true);");} else {echo "return false;";}?>
            class="HomePanel DashTile DashTileDraggable  echo ($tile['all_users']==1)? 'allUsers':'';?>  echo ('double' == $tlsize 'DoubleWidthDashTile' ''); ?>"
            tile=" echo $tile['tile']; ?>"
            id="user_tile echo htmlspecialchars($tile["user_tile"]);?>"
        >
            <div id="contents_user_tile echo htmlspecialchars($tile["user_tile"]);?>" class="HomePanelIN HomePanelDynamicDash  echo ($dash_tile_shadows)? "TileContentShadow":"";?>" style=" echo $tile_custom_style?>">
                <script>
                jQuery(function(){
                    var height = jQuery("#contents_user_tile echo htmlspecialchars($tile["user_tile"]);?>").height();
                    var width = jQuery("#contents_user_tile echo htmlspecialchars($tile["user_tile"]);?>").width();
                    jQuery('#contents_user_tile echo htmlspecialchars($tile["user_tile"]) ?>').load(" echo $baseurl."/".$tile["url"]."&tile=".htmlspecialchars($tile["tile"]);?>&user_tile= echo htmlspecialchars($tile["user_tile"]);?>&tlwidth="+width+"&tlheight="+height);
                });
                </script>
            </div>
            
        </a>
        
        
}
    
# Check Permissions to Display Deleting Dash Tiles
    
if((checkperm("h") && !checkperm("hdta")) || (checkperm("dta") && !checkperm("h")) || !checkperm("dtu"))
        {
        
render_trash("dash_tile"$lang['confirmdeleteconfigtile']);
        
?>
        <script>
            function deleteDashTile(id) {
                jQuery.post(
                    " echo $baseurl?>/pages/ajax/dash_tile.php",
                    {
                    "user_tile": id,
                    "delete": "true",
                     echo generateAjaxToken("deleteDashTile"); ?>
                    },
                    function(data){
                    jQuery("#user_tile"+id).remove();
                });
            }
            function deleteDefaultDashTile(tileid,usertileid) {
                jQuery.post(
                    " echo $baseurl?>/pages/ajax/dash_tile.php",
                    {
                    "tile": tileid,
                    "delete": "true",
                     echo generateAjaxToken("deleteDefaultDashTile"); ?>
                    },function(data){
                    jQuery("#user_tile"+usertileid).remove();
                });
            }
        
        
}
    else
        {
        echo 
"<script>";
        } 
?>
        function updateDashTileOrder(index,tile) {
            jQuery.post(
                " echo $baseurl?>/pages/ajax/dash_tile.php",
                {
                "user_tile": tile,
                "new_index": ((index*10)),
                 echo generateAjaxToken("updateDashTileOrder"); ?>
                }
            );
        }
        var dragging=false;
            jQuery(function() {
                if(is_touch_device())
                    {
                    return false;
                    }                
                 jQuery("#HomePanelContainer").sortable({
                    items: ".DashTileDraggable",
                    start: function(event,ui) {
                        jQuery("#dash_tile_bin").show();
                        dragging=true;
                    },
                    stop: function(event,ui) {
                      jQuery("#dash_tile_bin").hide();
                    },
                  update: function(event, ui) {
                      nonDraggableTiles = jQuery(".HomePanel").length - jQuery(".DashTileDraggable").length;
                      newIndex = (ui.item.index() - nonDraggableTiles) + 1;
                      var id=jQuery(ui.item).attr("id").replace("user_tile","");
                      updateDashTileOrder(newIndex,id);
                  }
                  });
            
            
# Check Permissions to Display Deleting Dash Tiles
            
if((checkperm("h") && !checkperm("hdta")) || (checkperm("dta") && !checkperm("h")) || !checkperm("dtu"))
                {
                
?>     
                jQuery("#dash_tile_bin").droppable({
                  accept: ".DashTileDraggable",
                  activeClass: "ui-state-hover",
                  hoverClass: "ui-state-active",
                  drop: function(event,ui) {
                      var usertileid=jQuery(ui.draggable).attr("id");
                      usertileid = usertileid.replace("user_tile","");
                
                
# If permission to delete all_user tiles
                
if((checkperm("h") && !checkperm("hdta")) || (checkperm("dta") && !checkperm("h")))
                    { 
?>
                    var tileid=jQuery(ui.draggable).attr("tile");
                    var usertileid=jQuery(ui.draggable).attr("id");
                    usertileid = usertileid.replace("user_tile","");
                
                      
?>

                      title = jQuery(ui.draggable).find(".title").html();
                      jQuery("#dash_tile_bin").hide();
                  
                  
# If permission to delete all_user tiles
                
if((checkperm("h") && !checkperm("hdta")) || (checkperm("dta") && !checkperm("h")))
                    {
                    
?>
                      if(jQuery(ui.draggable).hasClass("allUsers")) {
                          // This tile is set for all users so provide extra options
                         render_delete_dialog_JS(true); ?>
                    }
                    else {
                        //This tile belongs to this user only
                         render_delete_dialog_JS(false); ?>
                    }
                
                    
}
                   else 
#Only show dialog to delete for this user
                       
?>
                       var dialog =  render_delete_dialog_JS(false); 
                       } 
?>
                  }
                });
                
                

            
?>
              });

    </script>
    
    
}

This article was last updated 3rd December 2020 12:35 Europe/London time based on the source file dated 3rd November 2020 16:55 Europe/London time.