//void tutLink_Command(object sender, CommandEventArgs e)
    //{
    //    if ((HttpContext.Current.Session != null) && (HttpContext.Current.Session.Mode != System.Web.SessionState.SessionStateMode.Off))
    //    {
    //        this.Page.Session["showTutorial"] = true;
    //    }
    //}
    void hintsPanel_DataBound(object sender, EventArgs e)
    {
        CmsManager manager = new CmsManager();

        HtmlGenericControl pagesLi = GetLi("pagesLi", this.hintsPanel);
        HtmlAnchor pagesLink = GetLink("pagesLink", this.hintsPanel);
        HtmlGenericControl modulesLi = GetLi("modulesLi", this.hintsPanel);
        HtmlAnchor modulesLink = GetLink("modulesLink", this.hintsPanel);
        HtmlGenericControl filesLi = GetLi("filesLi", this.hintsPanel);
        HtmlAnchor filesLink = GetLink("filesLink", this.hintsPanel);
        HtmlGenericControl administrationLi = GetLi("administrationLi", this.hintsPanel);
        HtmlAnchor administrationLink = GetLink("administrationLink", this.hintsPanel);

        bool hasPerm = false;
        foreach (ICmsPage page in manager.GetPages())
        {
            Telerik.Cms.Security.PagePermission testPerm = new Telerik.Cms.Security.PagePermission(page);

            if (testPerm.CheckDemand(PageRights.View))
            {
                hasPerm = true;
                break;
            }
        }

        Telerik.Cms.Security.GlobalPermission perm = new Telerik.Cms.Security.GlobalPermission(GlobalRights.ManageUsers);
        bool canEditTemplates = perm.CheckDemand(GlobalRights.EditTemplates);

        PagePermission pagePerm = new PagePermission(manager.GetRootPage(), PageRights.View);
        bool canViewPages = pagePerm.CheckDemand();

        if (!canViewPages)
        {
            int totalRows;
            if (manager.GetPages(0, 1, "", System.ComponentModel.ListSortDirection.Ascending, out totalRows, true).Count > 0)
                canViewPages = true;
        }

        if (canViewPages)
            pagesLink.HRef = "~/Sitefinity/Admin/Pages.aspx";
        else if (canEditTemplates)
            pagesLink.HRef = "~/Sitefinity/Admin/Templates.aspx";
        else if (pagesLi != null && pagesLink != null)
        {
            pagesLi.Attributes["class"] += " dis";
            pagesLink.Attributes["href"] = "#";
        }

        bool canManageServices = false;
        foreach (IWebModule module in Telerik.Framework.ServiceHost.GetServiceModules())
        {
            if (Util.CheckMinimalServicePermissions(new ServicesPermissions(module.GetType())))
            {
                canManageServices = true;
                break;
            }
        }

        perm = new Telerik.Cms.Security.GlobalPermission(Telerik.Cms.Security.GlobalRights.ManageUsers | GlobalRights.ManagePermissions);
        if (administrationLi != null && administrationLink != null && (!perm.CheckDemand() && !canManageServices))
        {
            administrationLi.Attributes["class"] += " dis";
            administrationLink.Attributes["href"] = "#";
        }

        perm = new Telerik.Cms.Security.GlobalPermission(Telerik.Cms.Security.GlobalRights.ManageFiles);
        if (filesLi != null && filesLink != null && !perm.CheckDemand())
        {
            filesLi.Attributes["class"] += " dis";
            filesLink.Attributes["href"] = "#";
        }

        bool showModules = false;
        List<IWebModule> webModules = new List<IWebModule>();
        foreach (IWebModule module in ModuleManager.GetWebModulesValues())
        {
            if (module is IModule)
                showModules = Util.CheckMinimalPermissions(module as IModule);
            if (showModules)
                break;
        }

        if (modulesLi != null && modulesLink != null && !showModules)
        {
            modulesLi.Attributes["class"] += " dis";
            modulesLink.Attributes["href"] = "#";
        }
    }
    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;
            }
        }
    }
Example #3
0
    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;
            }
        }
    }