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_user_dash()

Parameters

ColumnTypeDefaultDescription
$user

Location

include/dash_functions.php lines 1213 to 1405

Definition

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

    
#Build User Dash and recalculate order numbers on display
    
$user_tiles ps_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 = ? ORDER BY user_dash_tile.order_by asc, dash_tile.ref desc", array("i"$user));

    
$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']);
        list(
$url_page$buildstring) = $buildstring;
        
parse_str(str_replace('&''&'$buildstring), $buildstring);

        if (
$tile['all_users'] == && strpos($tile['link'], 'team_analytics_edit.php') !== false)
            {
            
// Dash tile is a graph from an analytics report. Clicking this tile should only link to the analytics report for the report owner.
            // The tile won't do anything for other users as they don't have access to view the report.
            
if (!isset($user_analytics_reports))
                {
                
$user_analytics_reports ps_array('SELECT ref AS `value` FROM user_report WHERE user = ?', array('i'$user));
                }
            
$analytics_report_id = (int) substr(strrchr($tile['link'], '='), 1);
            if (!
in_array($analytics_report_id$user_analytics_reports))
                {
                
$tile['link'] = '';
                }
            }

        
$tlsize = (isset($buildstring['tlsize']) ? $buildstring['tlsize'] : '');
        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 escape($tile["link"]);
                
$newtab true;
                }
            else
                {
                
$link $baseurl."/".escape($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'] == 'allUsers' '';?>  echo 'double' == $tlsize 'DoubleWidthDashTile' ''?>"
            tile=" echo $tile['tile']; ?>"
            id="user_tile echo escape($tile["user_tile"]);?>"
        >
            <div id="contents_user_tile echo escape($tile["user_tile"]);?>" class="HomePanelIN HomePanelDynamicDash" style=" echo $tile_custom_style?>">
                <script>
                jQuery(function(){
                    var height = jQuery("#contents_user_tile echo escape($tile["user_tile"]);?>").height();
                    var width = jQuery("#contents_user_tile echo escape($tile["user_tile"]);?>").width();
                    jQuery('#contents_user_tile echo escape($tile["user_tile"]) ?>').load(" echo generateURL($baseurl .'/'$url_pagearray_merge($buildstring, ['tile' => $tile['tile'], 'user_tile' => $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 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.