Exemple #1
0
    /// <summary>
    /// Filters the dataset with UI Elements according to UI Profile of current user by default and according to custom event (if defined).
    /// </summary>
    protected void FilterElements(DataSet dsElements)
    {
        // For all tables in dataset
        foreach (DataTable dt in dsElements.Tables)
        {
            ArrayList deleteRows = new ArrayList();

            // Find rows to filter out
            foreach (DataRow dr in dt.Rows)
            {
                UIElementInfo uiElement = new UIElementInfo(dr);
                bool          allowed   = MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement(ModuleName, uiElement.ElementName);
                allowed = allowed && RaiseOnGroupFiltered(this, new UniMenuArgs {
                    UIElement = uiElement
                });

                if (!allowed || !UIContextHelper.CheckElementAvailabilityInUI(uiElement))
                {
                    deleteRows.Add(dr);
                }
            }

            // Delete the filtered rows
            foreach (DataRow dr in deleteRows)
            {
                dt.Rows.Remove(dr);
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// Filters the dataset with UI Elements according to UI Profile of current user by default and according to custom event (if defined).
    /// </summary>
    private IEnumerable <UIElementInfo> FilterElements(IEnumerable <UIElementInfo> elements)
    {
        foreach (var uiElement in elements)
        {
            bool allowed = MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement(uiElement.ElementResourceID, uiElement.ElementName);

            if (OnButtonFiltered != null)
            {
                allowed = allowed && OnButtonFiltered(this, new UniMenuArgs {
                    UIElement = uiElement
                });
            }

            if (allowed && UIContextHelper.CheckElementAvailabilityInUI(uiElement))
            {
                yield return(uiElement);
            }
        }
    }
    protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        if (itemData != null)
        {
            UIElementInfo uiElement = new UIElementInfo(itemData);

            if (!UIContextHelper.CheckElementAvailabilityInUI(uiElement))
            {
                return(null);
            }

            // Check permissions
            if (MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement(uiElement.ElementResourceID, uiElement.ElementName, ModuleAvailabilityForSiteRequired))
            {
                defaultNode = RaiseOnNodeCreated(uiElement, defaultNode);

                String url = UIContextHelper.GetElementUrl(uiElement, UIContext);
                if (uiElement.ElementType != UIElementTypeEnum.PageTemplate)
                {
                    url = URLHelper.RemoveParameterFromUrl(url, "displaytitle");
                }

                // If url is empty -> don't show
                if (defaultNode == null || String.IsNullOrEmpty(url))
                {
                    return(null);
                }

                // Prepare node info
                string caption     = UIElementInfoProvider.GetElementCaption(uiElement);
                string targetFrame = !String.IsNullOrEmpty(defaultNode.Target) ? defaultNode.Target : TargetFrame;
                string codeName    = uiElement.ElementName.Replace(".", String.Empty).ToLowerCSafe();

                UIElementInfo sel = UIContextHelper.CheckSelectedElement(uiElement, UIContext);
                if (sel != null)
                {
                    SelectedNode = uiElement.ElementName;

                    String selectionSuffix = ValidationHelper.GetString(UIContext["selectionSuffix"], String.Empty);
                    String spUrl           = UIContextHelper.GetElementUrl(sel, UIContext);
                    spUrl = URLHelper.AppendQuery(spUrl, selectionSuffix);

                    // Append object ID
                    url = URLHelper.UpdateParameterInUrl(url, "objectid", UIContext.ObjectID.ToString());

                    StartingPage = URLHelper.UpdateParameterInUrl(spUrl, "displaytitle", "true");
                }

                // Set node
                defaultNode.Target      = targetFrame;
                defaultNode.NavigateUrl = GetUrl(url);
                defaultNode.Text        = defaultNode.Text.Replace(NODE_CODENAME_MACRO, codeName);

                totalNodes++;

                // Set first child node to be selected if root cant be selected
                if (!EnableRootSelect && string.IsNullOrEmpty(SelectedNode))
                {
                    // Is a page node (with page url)
                    if (url != ApplicationUrlHelper.COLLAPSIBLE_EMPTY_PARENT_ELEMENT_URL)
                    {
                        SelectedNode = uiElement.ElementName;
                    }
                    else
                    {
                        // Try to display a child element
                        if (uiElement.ElementChildCount > 0)
                        {
                            defaultNode.Expanded = true;
                        }
                    }
                }

                // If url is '@' don't redirect, only collapse children
                if (uiElement.ElementTargetURL == ApplicationUrlHelper.COLLAPSIBLE_EMPTY_PARENT_ELEMENT_URL)
                {
                    // Onclick simulates click on '+' or '-' button
                    const string onClick = "onClick=\"var js = $cmsj(this).parents('tr').find('a').attr('href');eval(js);return false; \"";
                    defaultNode.Text = "<span id=\"node_" + uiElement.ElementName + "\" class=\"ContentTreeItem \"" + onClick + " ><span class=\"Name\">" + ResHelper.LocalizeString(caption) + "</span></span>";
                }

                return(defaultNode);
            }
        }

        return(null);
    }
Exemple #4
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        TreeNode     node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            // Hide Properties for wireframe
            plcProperties.Visible &= !node.IsWireframe();
            if (plcProperties.Visible)
            {
                // Properties menu
                var elements = UIElementInfoProvider.GetChildUIElements("CMS.Content", "Properties");
                if (!DataHelper.DataSourceIsEmpty(elements))
                {
                    var      index = 0;
                    UserInfo user  = MembershipContext.AuthenticatedUser;

                    foreach (var elem in elements)
                    {
                        // If UI element is available and user has permission to show it then add it
                        if (UIContextHelper.CheckElementAvailabilityInUI(elem) && user.IsAuthorizedPerUIElement(elem.ElementResourceID, elem.ElementName))
                        {
                            var elementName = elem.ElementName;

                            switch (elementName.ToLower())
                            {
                            case "properties.languages":
                                if (!CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName) || !CultureSiteInfoProvider.LicenseVersionCheck())
                                {
                                    continue;
                                }
                                break;

                            case "properties.wireframe":
                                if (node.NodeWireframeTemplateID <= 0)
                                {
                                    continue;
                                }
                                break;

                            case "properties.variants":
                                if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleName.ONLINEMARKETING) ||
                                    !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", SiteContext.CurrentSiteName) ||
                                    !PortalContext.ContentPersonalizationEnabled ||
                                    (VariantHelper.GetVariantID(VariantModeEnum.ContentPersonalization, node.GetUsedPageTemplateId(), String.Empty) <= 0))
                                {
                                    continue;
                                }
                                break;

                            case "properties.workflow":
                            case "properties.versions":
                                if (node.GetWorkflow() == null)
                                {
                                    continue;
                                }
                                break;
                            }


                            var item = new ContextMenuItem();
                            item.ID = "p" + index;
                            item.Attributes.Add("onclick", String.Format("Properties(GetContextMenuParameter('nodeMenu'), '{0}');", elementName));
                            item.Text = ResHelper.LocalizeString(elem.ElementDisplayName);

                            pnlPropertiesMenu.Controls.Add(item);

                            index++;
                        }
                    }

                    if (index == 0)
                    {
                        // Hide 'Properties' menu if user has no permission for at least one properties section
                        plcProperties.Visible = false;
                    }
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }
Exemple #5
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        var node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            if (node.IsLink)
            {
                cmcNew.Visible = false;
            }

            if (plcProperties.Visible)
            {
                // Properties menu
                var elements = UIElementInfoProvider.GetChildUIElements("CMS.Content", "Properties");
                if (!DataHelper.DataSourceIsEmpty(elements))
                {
                    var      index = 0;
                    UserInfo user  = MembershipContext.AuthenticatedUser;

                    foreach (var element in elements)
                    {
                        // Skip elements not relevant for given node
                        if (DocumentUIHelper.IsElementHiddenForNode(element, node))
                        {
                            continue;
                        }

                        var elementName = element.ElementName.ToLowerInvariant();

                        // If UI element is available and user has permission to show it then add it
                        if (UIContextHelper.CheckElementAvailabilityInUI(element) && user.IsAuthorizedPerUIElement(element.ElementResourceID, elementName))
                        {
                            var item = new ContextMenuItem();
                            item.ID = "p" + index;
                            item.Attributes.Add("onclick", String.Format("Properties(GetContextMenuParameter('nodeMenu'), '{0}');", elementName));

                            item.Text = ResHelper.LocalizeString(element.ElementDisplayName);

                            pnlPropertiesMenu.Controls.Add(item);

                            index++;
                        }
                    }

                    if (index == 0)
                    {
                        // Hide 'Properties' menu if user has no permission for at least one properties section
                        plcProperties.Visible = false;
                    }
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }