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

get_default_dash()

Parameters

ColumnTypeDefaultDescription
$user_group_id null
$edit_mode false

Location

include/dash_functions.php lines 435 to 634

Definition

 
function get_default_dash($user_group_id null$edit_mode false)
    {
    global 
$baseurl,$baseurl_short,$lang,$anonymous_login,$username;

    
#Build Tile Templates
    
$tiles ps_query("SELECT dash_tile.ref AS 'tile',dash_tile.title,dash_tile.url,dash_tile.reload_interval_secs,dash_tile.link,dash_tile.default_order_by as 'order_by',dash_tile.allow_delete FROM dash_tile WHERE dash_tile.all_users = 1 AND dash_tile.ref NOT IN (SELECT dash_tile FROM usergroup_dash_tile) AND (dash_tile.allow_delete=1 OR (dash_tile.allow_delete=0 AND dash_tile.ref IN (SELECT DISTINCT user_dash_tile.dash_tile FROM user_dash_tile))) ORDER BY default_order_by");

    
// In edit_mode, as a super admin, we want to see all user dash tiles otherwise re-ordering will be broken
    // due to tiles that are not visible but still being taken into account
    
$hidden_tiles      = array();
    
$hidden_tile_class '';

    if(
$edit_mode)
        {
        
$managed_tiles      $tiles;
        
$tiles              get_alluser_available_tiles();
        
$hidden_tile_class  ' HiddenTile';

        foreach(
$tiles as $all_user_available_tile)
            {
            if(
false === array_search($all_user_available_tile['ref'], array_column($managed_tiles'tile')))
                {
                
$hidden_tiles[] = $all_user_available_tile['ref'];
                }
            }
        }
    
    if(!
is_null($user_group_id))
        {
        
$tiles get_usergroup_available_tiles($user_group_id);
        }

    
$order=10;
    if(
count($tiles)==0){echo escape($lang["nodashtilefound"]);exit;}
    foreach(
$tiles as $tile)
        {
        
$contents_tile_class '';

        if((
$order != $tile["order_by"] || ($tile["order_by"] % 10) > 0) && is_null($user_group_id))
            {
            
update_default_dash_tile_order($tile["tile"],$order);
            }
        elseif((!isset(
$tile['default_order_by']) || $order != $tile['default_order_by'] || ($tile['default_order_by'] % 10) > 0) && !is_null($user_group_id))
            {
            
update_usergroup_dash_tile_order($user_group_id$tile['tile'], $order);
            }

        
$order+=10;

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

        if(isset(
$buildstring['tltype']) && allow_tile_colour_change($buildstring['tltype']) && isset($buildstring['tlstylecolour']))
            {
            
$tile_custom_style .= get_tile_custom_style($buildstring);
            }

        if(
in_array($tile['tile'], $hidden_tiles))
            {
            
$contents_tile_class .= $hidden_tile_class;
            }
            
?>
        <a 
             
            
# Check link for external or internal
            
if(mb_strtolower(substr($tile["link"],0,4))=="http")
                {
                
$link $tile["link"];
                
$newtab true;
                }
            else
                {
                
$link $baseurl."/".escape($tile["link"]);
                
$newtab=false;
                }
            
?>
            href=" echo $link?> echo $newtab "target='_blank'" "";?>
            onClick="if(dragging){dragging=false;return false;}" 
            class="HomePanel DashTile DashTileDraggable  echo $tile["allow_delete"]? "":"conftile";?>
            id="tile echo escape($tile["tile"]);?>"
        >
            <div id="contents_tile echo escape($tile["tile"]);?>" class="HomePanelIN HomePanelDynamicDash  echo $contents_tile_class?>" style=" echo $tile_custom_style?>">
                
                
if (strpos($tile["url"],"dash_tile.php")!==false)
                    {
                    
# Only pre-render the title if using a "standard" tile and therefore we know the H2 will be in the target data.
                    
?>
                    <h2 class="title"> echo escape($tile["title"]);?></h2>
 
                    
}
                    
?>
                <p>Loading...</p>
                <script>
                    height = jQuery("#contents_tile echo escape($tile["tile"]);?>").height();
                    width = jQuery("#contents_tile echo escape($tile["tile"]);?>").width();
                    jQuery("#contents_tile echo escape($tile["tile"]);?>").load(" echo $baseurl."/".$tile["url"]."&tile=".escape($tile["tile"]);?>&tlwidth="+width+"&tlheight="+height);
                </script>
            </div>
            
        </a>
        
        
}
        
        
render_trash("dash_tile"$lang['confirmdeleteconfigtile']);
        
?>
        <script>
            function deleteDefaultDashTile(id)
                {
                jQuery.post(
                    " echo $baseurl?>/pages/ajax/dash_tile.php",
                    {
                    "tile": id,
                    "delete": "true",
                     echo generateAjaxToken("deleteDefaultDashTile"); ?>
                    },
                    function(data)
                        {
                        jQuery("#tile"+id).remove();
                        });
                }

            function updateDashTileOrder(index,tile) {
                jQuery.post(
                    " echo $baseurl?>/pages/ajax/dash_tile.php",
                    {
                    "tile": tile,
                    "new_index": ((index*10)) if(!is_null($user_group_id)) { echo ", \"selected_user_group\": {$user_group_id}";} ?>,
                     echo generateAjaxToken("updateDashTileOrder"); ?>
                    }
                );
            }

            var dragging=false;
                jQuery(function() {
                    if(is_touch_device())
                        {
                        jQuery("#HomePanelContainer").prepend("<p> echo escape($lang["dashtilesmalldevice"]);?></p>");
                        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("tile","");
                          updateDashTileOrder(newIndex,id);
                      }
                      });
                    jQuery("#dash_tile_bin").droppable({
                        accept: ".DashTileDraggable",
                        activeClass: "ui-state-hover",
                        hoverClass: "ui-state-active",
                        drop: function(event,ui) {
                            var id=jQuery(ui.draggable).attr("id");
                            id = id.replace("tile","");
                            title = jQuery(ui.draggable).find(".title").html();
                            jQuery("#dash_tile_bin").hide();
                            if(jQuery("#tile"+id).hasClass("conftile")) {
                                jQuery("#delete_permanent_dialog").dialog({
                                    title:' echo escape($lang["dashtiledelete"]); ?>',
                                    modal: true,
                                    resizable: false,
                                    dialogClass: 'delete-dialog no-close',
                                    buttons: {
                                        " echo escape($lang['confirmdefaultdashtiledelete']); ?>": function() {
                                                jQuery(this).dialog("close");
                                                deleteDefaultDashTile(id);
                                            },    
                                        " echo escape($lang['cancel']); ?>": function() { 
                                                jQuery(this).dialog('close');
                                            }
                                    }
                                });
                                return;
                            }
                            jQuery("#trash_bin_delete_dialog").dialog({
                                title:' echo escape($lang["dashtiledelete"]); ?>',
                                modal: true,
                                resizable: false,
                                dialogClass: 'delete-dialog no-close',
                                buttons: {
                                    " echo escape($lang['confirmdefaultdashtiledelete']); ?>": function() {jQuery(this).dialog("close");deleteDefaultDashTile(id); },    
                                    " echo escape($lang['cancel']); ?>": function() { jQuery(this).dialog('close'); }
                                }
                            });
                        }
                    });
                  });
        </script>
    <div class="clearerleft"></div>
    
    
}

This article was last updated 9th November 2024 15:35 Europe/London time based on the source file dated 7th November 2024 17:40 Europe/London time.