private bool DisplayDownloadHyperlink(Asset asset) { if (ShowButtons.IsSet(Buttons.Download)) { // Only display download link for users who can download the asset // when the direct download feature is enabled. if (WebsiteBrandManager.GetBrand().DirectDownloadEnabled) { return(!EntitySecurityManager.IsAssetRestricted(CurrentUser, asset)); } // Super-admins can always download assets if (CurrentUser.UserRole.Equals(UserRole.SuperAdministrator)) { return(true); } // Upload users can always download their own assets if (asset.UploadedByUserId.Equals(CurrentUser.UserId)) { return(true); } } return(false); }
/// <summary> /// Initialises the asset buttons control with the specified asset /// </summary> public void Initialise(Asset asset) { m_AssetId = asset.AssetId.GetValueOrDefault(); // Get the URL to be used for the asset popup string showAssetInfoUrl = SiteUtils.GetShowAssetInfoUrl(m_AssetId); // Setup info button InfoHyperlink.Visible = ShowButtons.IsSet(Buttons.Info); InfoHyperlink.NavigateUrl = showAssetInfoUrl; InfoHyperlink.ImageUrl = SiteUtils.GetIconPath("info0.gif"); // Setup download button DownloadHyperLink.Visible = DisplayDownloadHyperlink(asset); DownloadHyperLink.NavigateUrl = AssetFileUrlHelper.GetDownloadUrl(m_AssetId); DownloadHyperLink.ImageUrl = SiteUtils.GetIconPath("download0.gif"); // Setup lightbox button AddToLightboxImageButton.Visible = (ShowButtons.IsSet(Buttons.Lightbox)); AddToLightboxImageButton.CommandArgument = m_AssetId.ToString(); InitialiseLightboxButton(m_AssetId); // Setup cart button AddToCartImageButton.Visible = (ShowButtons.IsSet(Buttons.Cart)); AddToCartImageButton.CommandArgument = m_AssetId.ToString(); InitialiseCartButton(m_AssetId); // Setup restricted icon RestrictedImageIcon.Visible = (EntitySecurityManager.IsAssetRestricted(CurrentUser, asset) && ShowButtons.IsSet(Buttons.Restricted)); RestrictedImageIcon.ImageUrl = SiteUtils.GetIconPath("restricted0.gif"); }