当前位置: 首页>>代码示例>>C#>>正文


C# CurrentUserInfo.IsAuthorizedPerDocument方法代码示例

本文整理汇总了C#中CurrentUserInfo.IsAuthorizedPerDocument方法的典型用法代码示例。如果您正苦于以下问题:C# CurrentUserInfo.IsAuthorizedPerDocument方法的具体用法?C# CurrentUserInfo.IsAuthorizedPerDocument怎么用?C# CurrentUserInfo.IsAuthorizedPerDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CurrentUserInfo的用法示例。


在下文中一共展示了CurrentUserInfo.IsAuthorizedPerDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanModifyPermission

    /// <summary>
    /// Checks if current use can moddify  the perrmission.
    /// </summary>
    /// <param name="redirect">If true and can't moddify the user is redirected to denied page</param>
    /// <param name="currentNode">Node to examine</param>
    /// <param name="currentUser">Current user</param>    
    private bool CanModifyPermission(bool redirect, TreeNode currentNode, CurrentUserInfo currentUser)
    {
        bool hasPermission = false;
        if (currentNode != null)
        {
            hasPermission = (currentUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed);

            // If hasn't permission and resirect enabled
            if (!hasPermission)
            {
                if (redirect)
                {
                    RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), currentNode.NodeAliasPath));
                }
                else
                {
                    pnlAccessPart.Enabled = false;
                    btnRadOk.Enabled = false;
                    pnlInheritance.Enabled = false;
                    lnkInheritance.Visible = false;
                    // Display message
                    lblPermission.Visible = true;
                    lblPermission.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath);
                }
            }
        }
        return hasPermission;
    }
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:34,代码来源:Security.aspx.cs

示例2: Page_Load

    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterScriptFile(this, @"~/CMSModules/Content/CMSDesk/View/Listing.js");

        currentSiteName = CMSContext.CurrentSiteName;
        currentUserInfo = CMSContext.CurrentUser;

        // Current Node ID
        nodeId = QueryHelper.GetInteger("nodeid", 0);

        // Setup page title text and image
        CurrentMaster.Title.TitleText = GetString("Content.ListingTitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/Listing.png");

        CurrentMaster.Title.HelpName = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "list_tab";

        string[,] actions = new string[1, 6];
        actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1] = GetString("Listing.ParentDirectory");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/Listing/parent.png");
        CurrentMaster.HeaderActions.Actions = actions;

        if (nodeId > 0)
        {
            tree = new TreeProvider(currentUserInfo);
            checkPermissions = tree.CheckDocumentUIPermissions(currentSiteName);
            node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
            // Set edited document
            EditedDocument = node;

            if (node != null)
            {
                if (currentUserInfo.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) != AuthorizationResultEnum.Allowed)
                {
                    RedirectToCMSDeskAccessDenied("CMS.Content", "exploretree");
                }

                aliasPath = node.NodeAliasPath;

                // Setup the link to the parent document
                if ((node.NodeClassName.ToLower() != "cms.root") && (currentUserInfo.UserStartingAliasPath.ToLower() != node.NodeAliasPath.ToLower()))
                {
                    CurrentMaster.HeaderActions.Actions[0, 3] = "javascript:SelectItem(" + node.NodeParentID + ");";
                }
                else
                {
                    CurrentMaster.HeaderActions.Visible = false;
                    CurrentMaster.PanelBody.FindControl("pnlActions").Visible = false;
                }
            }

            ScriptHelper.RegisterProgress(this);
            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterJQuery(this);

            InitDropdowLists();

            cultureElem.DropDownCultures.Width = 222;

            // Prepare JavaScript for actions
            StringBuilder actionScript = new StringBuilder();
            actionScript.Append(
        @"function PerformAction(selectionFunction, selectionField, dropId){
        var label = document.getElementById('" + lblInfo.ClientID + @"');
        var whatDrp = document.getElementById('" + drpWhat.ClientID + @"');
        var action = document.getElementById(dropId).value;
        var selectionFieldElem = document.getElementById(selectionField);
        var allSelected = " + (int)What.SelectedDocuments + @";
        if (action == '" + (int)Action.SelectAction + @"'){
        label.innerHTML = '" + GetString("massaction.selectsomeaction") + @"';
        return false;
        }
        if(whatDrp.value == '" + (int)What.AllDocuments + @"'){
        allSelected = " + (int)What.AllDocuments + @";
        }
        var items = selectionFieldElem.value;
        if(!eval(selectionFunction) || whatDrp.value == '" + (int)What.AllDocuments + @"'){
        var argument = '|' + allSelected + '|' + items;
        switch(action){
            case '" + (int)Action.Move + @"':
                argument = '" + Action.Move + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Copy + @"':
                argument = '" + Action.Copy + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Link + @"':
                argument = '" + Action.Link + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "OpenModal", string.Empty) + @";
                break;

            case '" + (int)Action.Delete + @"':
                argument = '" + Action.Delete + "' + argument;" + ClientScript.GetCallbackEventReference(this, "argument", "Redirect", string.Empty) + @";
                break;

            case '" + (int)Action.Publish + @"':
//.........这里部分代码省略.........
开发者ID:KuduApps,项目名称:Kentico,代码行数:101,代码来源:Listing.aspx.cs


注:本文中的CurrentUserInfo.IsAuthorizedPerDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。