예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(this.ModuleName))
        {
            // Reserve UI tabs
            DataRow sdr = SecurityHelper.ReserveSecurityLogItem("LoadUIGuide");

            // Get UI elements which represent the guide items
            DataSet ds = null;
            if (String.IsNullOrEmpty(this.ElementName))
            {
                ds = UIElementInfoProvider.GetUIMenuElements(this.ModuleName);
            }
            else
            {
                ds = UIElementInfoProvider.GetChildUIElements(this.ModuleName, this.ElementName);
            }

            // Create guide item collection
            CurrentUserInfo currentUser = CMSContext.CurrentUser;
            int             i           = 0;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                ArrayList guideParams = new ArrayList(4);

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string elementName = ValidationHelper.GetString(dr["ElementName"], "");

                    if (currentUser.IsAuthorizedPerUIElement(this.ModuleName, elementName, this.ModuleAvailabilityForSiteRequired))
                    {
                        // Get parameters of the guide item
                        object itemParams = GetGuideItemParameters(new UIElementInfo(dr));

                        // If item initialized, add it to the collection
                        if (itemParams != null)
                        {
                            guideParams.Add(itemParams);
                            i++;
                        }
                    }
                }

                // Initialize guide
                guideElem.Parameters = guideParams;
                guideElem.Columns    = this.Columns;
            }

            // Log the security
            if (sdr != null)
            {
                SecurityHelper.SetLogItemData(sdr, currentUser.UserName, this.ModuleName, this.ElementName, i, CMSContext.CurrentSiteName);
            }
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Fill the menu with UIElement data for specified module
        if (!String.IsNullOrEmpty(ModuleName) & (currentUser != null))
        {
            DataSet dsModules = UIElementInfoProvider.GetUIMenuElements(ModuleName);

            List <object[]> categoriesTmp = new List <object[]>();

            if (!DataHelper.DataSourceIsEmpty(dsModules))
            {
                foreach (DataRow drModule in dsModules.Tables[0].Rows)
                {
                    UIElementInfo moduleElement = new UIElementInfo(drModule);

                    // Proceed if user has permissions for this UI element
                    if (currentUser.IsAuthorizedPerUIElement(ModuleName, moduleElement.ElementName))
                    {
                        // Category title
                        string categoryTitle = ResHelper.LocalizeString(moduleElement.ElementDisplayName);

                        // Category name
                        string categoryName = ResHelper.LocalizeString(moduleElement.ElementName);

                        // Category URL
                        string categoryUrl = CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(moduleElement.ElementTargetURL));

                        // Category image URL
                        string categoryImageUrl = GetImagePath(moduleElement.ElementIconPath.Replace("list.png", "module.png"));
                        if (!FileHelper.FileExists(categoryImageUrl))
                        {
                            categoryImageUrl = GetImagePath("CMSModules/module.png");
                        }

                        categoryImageUrl = UIHelper.ResolveImageUrl(categoryImageUrl);

                        // Category tooltip
                        string categoryTooltip = ResHelper.LocalizeString(moduleElement.ElementDescription);

                        // Category actions
                        DataSet dsActions = UIElementInfoProvider.GetChildUIElements(moduleElement.ElementID);

                        List <string[]> actionsTmp = new List <string[]>();

                        foreach (DataRow drAction in dsActions.Tables[0].Rows)
                        {
                            UIElementInfo actionElement = new UIElementInfo(drAction);

                            // Proceed if user has permissions for this UI element
                            if (currentUser.IsAuthorizedPerUIElement(ModuleName, actionElement.ElementName))
                            {
                                actionsTmp.Add(new string[] { ResHelper.LocalizeString(actionElement.ElementDisplayName), CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(actionElement.ElementTargetURL)) });
                            }
                        }

                        int actionsCount = actionsTmp.Count;

                        string[,] categoryActions = new string[actionsCount, 2];

                        for (int i = 0; i < actionsCount; i++)
                        {
                            categoryActions[i, 0] = actionsTmp[i][0];
                            categoryActions[i, 1] = actionsTmp[i][1];
                        }

                        CategoryCreatedEventArgs args = new CategoryCreatedEventArgs(moduleElement, categoryName, categoryTitle, categoryUrl, categoryImageUrl, categoryTooltip, categoryActions);

                        // Raise additional initialization events for this category
                        if (CategoryCreated != null)
                        {
                            CategoryCreated(this, args);
                        }

                        // Add to categories, if further processing of this category was not cancelled
                        if (!args.Cancel)
                        {
                            categoriesTmp.Add(new object[] { args.CategoryTitle, args.CategoryName, args.CategoryURL, args.CategoryImageURL, args.CategoryTooltip, args.CategoryActions });
                        }
                    }
                }
            }

            int categoriesCount = categoriesTmp.Count;

            object[,] categories = new object[categoriesCount, 6];

            for (int i = 0; i < categoriesCount; i++)
            {
                categories[i, 0] = categoriesTmp[i][0];
                categories[i, 1] = categoriesTmp[i][1];
                categories[i, 2] = categoriesTmp[i][2];
                categories[i, 3] = categoriesTmp[i][3];
                categories[i, 4] = categoriesTmp[i][4];
                categories[i, 5] = categoriesTmp[i][5];
            }
            if (categoriesCount > 0)
            {
                panelMenu.Categories   = categories;
                panelMenu.ColumnsCount = ColumnsCount;
            }
            else
            {
                RedirectToUINotAvailable();
            }

            // Add editing icon in development mode
            if (SettingsKeyProvider.DevelopmentMode && currentUser.IsGlobalAdministrator)
            {
                ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(ModuleName);
                if (ri != null)
                {
                    ltlAfter.Text += "<div class=\"AlignRight\">" + UIHelper.GetResourceUIElementsLink(Page, ri.ResourceId) + "</div>";
                }
            }
        }
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this.Page);

        // Initialize TreeView
        this.treeElem.ImageSet             = TreeViewImageSet.Custom;
        this.treeElem.ExpandImageToolTip   = GetString("General.Expand");
        this.treeElem.CollapseImageToolTip = GetString("General.Collapse");
        if (CultureHelper.IsUICultureRTL())
        {
            this.treeElem.LineImagesFolder = GetImageUrl("RTL/Design/Controls/Tree", false, false);
        }
        else
        {
            this.treeElem.LineImagesFolder = GetImageUrl("Design/Controls/Tree", false, false);
        }
        this.treeElem.Nodes.Clear();

        // Create root
        TreeNode rootNode = new TreeNode();

        rootNode.Text        = "<span class=\"ContentTreeSelectedItem\" name=\"treeNode\" onclick=\"ShowDesktopContent('administration.aspx', this);\"><img src=\"" + GetImageUrl("General/DefaultRoot.png") + "\" style=\"border:none;height:10px;width:1px;\" /><span class=\"Name\">" + GetString("Administration-LeftMenu.Administration") + "</span></span>";
        rootNode.Expanded    = true;
        rootNode.NavigateUrl = "#";
        this.treeElem.Nodes.Add(rootNode);

        ArrayList items = new ArrayList();

        // Get the UIElements
        DataSet ds = UIElementInfoProvider.GetUIMenuElements("CMS.Administration");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                UIElementInfo element = new UIElementInfo(dr);
                bool          add     = CMSAdministrationPage.IsAdministrationUIElementAvailable(element);
                if (add)
                {
                    object[] itemProperties = new object[3];

                    // Ensure target URL
                    string targetUrl = URLHelper.ResolveUrl(element.ElementTargetURL);
                    targetUrl = URLHelper.RemoveParameterFromUrl(targetUrl, "siteid");

                    // Ensure icon URL
                    string iconUrl = element.ElementIconPath;
                    if (!String.IsNullOrEmpty(iconUrl))
                    {
                        if (!ValidationHelper.IsURL(iconUrl))
                        {
                            iconUrl = UIHelper.GetImagePath(this.Page, iconUrl, false, false);

                            // Try to get default icon if requested icon not found
                            if (!FileHelper.FileExists(iconUrl))
                            {
                                iconUrl = GetImageUrl("CMSModules/list.png");
                            }
                        }
                    }
                    else
                    {
                        iconUrl = GetImageUrl("CMSModules/list.png");
                    }

                    // Initialize and add element to collection
                    itemProperties[0] = targetUrl;
                    itemProperties[1] = ResHelper.LocalizeString(element.ElementCaption);
                    itemProperties[2] = URLHelper.ResolveUrl(iconUrl);

                    items.Add(itemProperties);
                }
            }
        }

        // Add permanent modules
        AddToCollection(
            GetString("Administration-LeftMenu.Avatars"),
            "~/CMSModules/Avatars/Avatar_list.aspx",
            "Objects/CMS_Avatar/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.Badges"),
            "~/CMSModules/Badges/Badges_List.aspx",
            "Objects/CMS_Badge/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.BadWords"),
            "~/CMSModules/BadWords/BadWords_List.aspx",
            "Objects/Badwords_Word/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.EmailQueue"),
            "~/CMSModules/EmailQueue/EmailQueue_Frameset.aspx",
            "CMSModules/CMS_EmailQueue/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.RecycleBin"),
            "~/CMSModules/RecycleBin/Pages/default.aspx",
            "CMSModules/CMS_RecycleBin/list.png", items);

        AddToCollection(
            GetString("srch.index.title"),
            "~/CMSModules/SmartSearch/SearchIndex_List.aspx",
            "Objects/CMS_SearchIndex/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.SMTPServers"),
            "~/CMSModules/SMTPServers/Pages/Administration/List.aspx",
            "Objects/CMS_SMTPServer/list.png", items);

        AddToCollection(
            GetString("Administration-LeftMenu.System"),
            "~/CMSModules/System/System_Frameset.aspx",
            "CMSModules/CMS_System/list.png", items);

        if (LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.IntegrationBus))
        {
            AddToCollection(
                GetString("integration.integration"),
                "~/CMSModules/Integration/Pages/Administration/Frameset.aspx",
                "CMSModules/CMS_Integration/list.png", items);
        }

        if (LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Webfarm))
        {
            AddToCollection(
                GetString("Administration-LeftMenu.WebFarm"),
                "~/CMSModules/WebFarm/Pages/WebFarm_Frameset.aspx",
                "Objects/CMS_WebFarmServer/list.png", items);
        }

        // Sort the collection
        ObjectArrayComparer comparer = new ObjectArrayComparer();

        items.Sort(comparer);

        // Build the tree
        foreach (object node in items)
        {
            object[] nodeArray = (object[])node;
            AddNodeToTree(Convert.ToString(nodeArray[1]), Convert.ToString(nodeArray[0]), Convert.ToString(nodeArray[2]), rootNode);
        }
    }