protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { bool showMainSection = PersonalizationManager.DefaultInstance.GetGlobalValue(GlobalSettingConstants.ShowMainSection, true); if (showMainSection) { hintsPanel.DataBind(); //Now we have inject the hide script for the bottom hide link HyperLink lnkHideMain = (HyperLink)hintsPanel.FindControl("lnkHideMain"); string script = string.Format("javascript:Personalization.hideDashboardMainSection('{0}')", pnlMainSection.ClientID); lnkHideMain.Attributes.Add("onclick", script); pnlMainSection.Visible = true; } else { pnlMainSection.Visible = false; } InTrayInfo inTrayInfo; // Dashboard box 1 - Pages CmsManager manager = new CmsManager(); Telerik.Cms.Security.PagePermission viewPerm = new Telerik.Cms.Security.PagePermission(manager.GetRootPage(), Telerik.Cms.Security.PageRights.View); if (viewPerm.CheckDemand()) { IList pages = manager.GetPages(); inTrayInfo = new PagesInTrayInfo((string)this.GetLocalResourceObject("Pages"), (string)this.GetLocalResourceObject("RecentlyModified")); inTrayInfo.SortBy = "DateModified"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbPages.DataSource = inTrayInfo.GetAsDataSource(); dbbPages.DataBind(); } else { dbbPages.Visible = false; } // Dashboard box 2 - Modules inTrayInfo = new InTrayInfo(new ArrayList(), (string)this.GetLocalResourceObject("ModuleItems"), (string)this.GetLocalResourceObject("RecentlyModified")); inTrayInfo.SortBy = "DateModified"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbModules.DataSource = inTrayInfo.GetAsDataSource(); dbbModules.DataBind(); // Dashboard box 4 - Files inTrayInfo = new InTrayInfo(new ArrayList(), (string)this.GetLocalResourceObject("UploadFiles"), (string)this.GetLocalResourceObject("RecentlyUploaded")); inTrayInfo.SortBy = "UploadDate"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbFiles.DataSource = inTrayInfo.GetAsDataSource(); dbbFiles.DataBind(); Telerik.Cms.Security.GlobalPermission perm = new Telerik.Cms.Security.GlobalPermission(Telerik.Cms.Security.GlobalRights.ManageUsers); if (perm.CheckDemand()) { // Dashboard box 3 - Users inTrayInfo = new UsersInTrayInfo((string)this.GetLocalResourceObject("Users"), (string)this.GetLocalResourceObject("RecentlyRegistered")); inTrayInfo.SortBy = "CreationDate"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbUsers.DataSource = inTrayInfo.GetAsDataSource(); dbbUsers.DataBind(); } else { dbbUsers.Visible = false; this.addUserLink.Visible = false; } Telerik.Cms.Security.PagePermission rootPerm = new Telerik.Cms.Security.PagePermission(manager.GetRootPage(), Telerik.Cms.Security.PageRights.Create); if (!rootPerm.CheckDemand()) { this.createPageLink.Visible = false; HyperLink newPageLink = dbbPages.FindControl("linkNewPage") as HyperLink; if (newPageLink != null) newPageLink.Visible = false; } List<IWebModule> webModules = new List<IWebModule>(); foreach (IWebModule module in ModuleManager.GetWebModulesValues()) { if (module is SecuredModule && ((SecuredModule)module).CanCreate()) webModules.Add(module); } if (webModules.Count > 0) { repeaterModules.DataSource = webModules; repeaterModules.DataBind(); } else if (webModules.Count == 0 && !createPageLink.Visible && !addUserLink.Visible) { dashToLiteral.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { bool showMainSection = PersonalizationManager.DefaultInstance.GetGlobalValue(GlobalSettingConstants.ShowMainSection, true); if (showMainSection) { hintsPanel.DataBind(); //Now we have inject the hide script for the bottom hide link HyperLink lnkHideMain = (HyperLink)hintsPanel.FindControl("lnkHideMain"); string script = string.Format("javascript:Personalization.hideDashboardMainSection('{0}')", pnlMainSection.ClientID); lnkHideMain.Attributes.Add("onclick", script); pnlMainSection.Visible = true; } else { pnlMainSection.Visible = false; } InTrayInfo inTrayInfo; // Dashboard box 1 - Pages CmsManager manager = new CmsManager(); Telerik.Cms.Security.PagePermission viewPerm = new Telerik.Cms.Security.PagePermission(manager.GetRootPage(), Telerik.Cms.Security.PageRights.View); if (viewPerm.CheckDemand()) { inTrayInfo = new PagesInTrayInfo((string)this.GetLocalResourceObject("Pages"), (string)this.GetLocalResourceObject("RecentlyModified")); inTrayInfo.SortBy = "DateModified"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbPages.DataSource = inTrayInfo.GetAsDataSource(); dbbPages.DataBind(); } else { dbbPages.Visible = false; } // Dashboard box 2 - Modules inTrayInfo = new InTrayInfo(new ArrayList(), (string)this.GetLocalResourceObject("ModuleItems"), (string)this.GetLocalResourceObject("RecentlyModified")); inTrayInfo.SortBy = "DateModified"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbModules.DataSource = inTrayInfo.GetAsDataSource(); dbbModules.DataBind(); // Dashboard box 4 - Files inTrayInfo = new InTrayInfo(new ArrayList(), (string)this.GetLocalResourceObject("UploadFiles"), (string)this.GetLocalResourceObject("RecentlyUploaded")); inTrayInfo.SortBy = "UploadDate"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbFiles.DataSource = inTrayInfo.GetAsDataSource(); dbbFiles.DataBind(); Telerik.Cms.Security.GlobalPermission perm = new Telerik.Cms.Security.GlobalPermission(Telerik.Cms.Security.GlobalRights.ManageUsers); if (perm.CheckDemand()) { // Dashboard box 3 - Users inTrayInfo = new UsersInTrayInfo((string)this.GetLocalResourceObject("Users"), (string)this.GetLocalResourceObject("RecentlyRegistered")); inTrayInfo.SortBy = "CreationDate"; inTrayInfo.SortDirection = System.ComponentModel.ListSortDirection.Descending; dbbUsers.DataSource = inTrayInfo.GetAsDataSource(); dbbUsers.DataBind(); } else { dbbUsers.Visible = false; this.addUserLink.Visible = false; } Telerik.Cms.Security.PagePermission rootPerm = new Telerik.Cms.Security.PagePermission(manager.GetRootPage(), Telerik.Cms.Security.PageRights.Create); if (!rootPerm.CheckDemand()) { this.createPageLink.Visible = false; HyperLink newPageLink = dbbPages.FindControl("linkNewPage") as HyperLink; if (newPageLink != null) { newPageLink.Visible = false; } } List <IWebModule> webModules = new List <IWebModule>(); foreach (IWebModule module in ModuleManager.GetWebModulesValues()) { //if (module is SecuredModule && ((SecuredModule)module).CanCreate()) // webModules.Add(module); try { if (module is SecuredModule && ((SecuredModule)module).CanCreate()) { webModules.Add(module); } } catch (Exception) { } } if (webModules.Count > 0) { repeaterModules.DataSource = webModules; repeaterModules.DataBind(); } else if (webModules.Count == 0 && !createPageLink.Visible && !addUserLink.Visible) { dashToLiteral.Visible = false; } } }