コード例 #1
0
    public void Save()
    {
        CheckPermissions(true);

        int allowed = 0;
        int denied  = 0;

        if (lstOperators.SelectedItem == null)
        {
            return;
        }

        string operatorID = lstOperators.SelectedValue;

        allowed += GetCheckBoxValue(chkReadAllow, NodePermissionsEnum.Read);
        allowed += GetCheckBoxValue(chkModifyAllow, NodePermissionsEnum.Modify);
        allowed += GetCheckBoxValue(chkCreateAllow, NodePermissionsEnum.Create);
        allowed += GetCheckBoxValue(chkDeleteAllow, NodePermissionsEnum.Delete);
        allowed += GetCheckBoxValue(chkDestroyAllow, NodePermissionsEnum.Destroy);
        allowed += GetCheckBoxValue(chkExploreTreeAllow, NodePermissionsEnum.ExploreTree);
        allowed += GetCheckBoxValue(chkManagePermissionsAllow, NodePermissionsEnum.ModifyPermissions);
        denied  += GetCheckBoxValue(chkReadDeny, NodePermissionsEnum.Read);
        denied  += GetCheckBoxValue(chkModifyDeny, NodePermissionsEnum.Modify);
        denied  += GetCheckBoxValue(chkCreateDeny, NodePermissionsEnum.Create);
        denied  += GetCheckBoxValue(chkDeleteDeny, NodePermissionsEnum.Delete);
        denied  += GetCheckBoxValue(chkDestroyDeny, NodePermissionsEnum.Destroy);
        denied  += GetCheckBoxValue(chkExploreTreeDeny, NodePermissionsEnum.ExploreTree);
        denied  += GetCheckBoxValue(chkManagePermissionsDeny, NodePermissionsEnum.ModifyPermissions);

        string message;
        string operatorName = lstOperators.SelectedItem.Text;

        if (operatorID.StartsWithCSafe("U"))
        {
            int      userId = int.Parse(operatorID.Substring(1));
            UserInfo ui     = UserInfoProvider.GetUserInfo(userId);
            AclItemInfoProvider.SetUserPermissions(Node, allowed, denied, ui);
            message = "security.documentuserpermissionschange";
        }
        else
        {
            RoleInfo ri = RoleInfoProvider.GetRoleInfo(int.Parse(operatorID.Substring(1)));
            AclItemInfoProvider.SetRolePermissions(Node, allowed, denied, ri);
            message = "security.documentrolepermissionschange";
        }

        ShowChangesSaved();

        // Log synchronization task and flush cache
        DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Node.TreeProvider);
        CacheHelper.TouchKeys(TreeProvider.GetDependencyCacheKeys(Node, Node.NodeSiteName));

        // Insert information about this event to event log.
        if (Tree.LogEvents)
        {
            EventLogProvider.LogEvent(EventType.INFORMATION, "Content", "DOCPERMISSIONSMODIFIED", string.Format(ResHelper.GetAPIString(message, "Permissions of the operator '{0}' have been modified for the document."), operatorName), eventUrl, Tree.UserInfo.UserID, Tree.UserInfo.UserName, Node.NodeID, DocumentName, ipAddress, Node.NodeSiteID);
        }

        if (Node != null)
        {
            // Invalidate permission data in current request
            TreeSecurityProvider.InvalidateTreeNodeAuthorizationResults(MembershipContext.AuthenticatedUser, NodeID, Node.DocumentCulture);
            AclItemInfoProvider.ClearRequestCache(Node, MembershipContext.AuthenticatedUser.UserID);
        }
        CheckPermissions(false, true);
        pnlUpdate.Update();
    }
コード例 #2
0
    public void Save()
    {
        CheckPermissions(true);

        int allowed = 0;
        int denied  = 0;

        if (lstOperators.SelectedItem == null)
        {
            return;
        }

        string operatorID = lstOperators.SelectedValue;

        allowed += GetCheckBoxValue(chkReadAllow, NodePermissionsEnum.Read);
        allowed += GetCheckBoxValue(chkModifyAllow, NodePermissionsEnum.Modify);
        allowed += GetCheckBoxValue(chkCreateAllow, NodePermissionsEnum.Create);
        allowed += GetCheckBoxValue(chkDeleteAllow, NodePermissionsEnum.Delete);
        allowed += GetCheckBoxValue(chkDestroyAllow, NodePermissionsEnum.Destroy);
        allowed += GetCheckBoxValue(chkExploreTreeAllow, NodePermissionsEnum.ExploreTree);
        allowed += GetCheckBoxValue(chkManagePermissionsAllow, NodePermissionsEnum.ModifyPermissions);
        denied  += GetCheckBoxValue(chkReadDeny, NodePermissionsEnum.Read);
        denied  += GetCheckBoxValue(chkModifyDeny, NodePermissionsEnum.Modify);
        denied  += GetCheckBoxValue(chkCreateDeny, NodePermissionsEnum.Create);
        denied  += GetCheckBoxValue(chkDeleteDeny, NodePermissionsEnum.Delete);
        denied  += GetCheckBoxValue(chkDestroyDeny, NodePermissionsEnum.Destroy);
        denied  += GetCheckBoxValue(chkExploreTreeDeny, NodePermissionsEnum.ExploreTree);
        denied  += GetCheckBoxValue(chkManagePermissionsDeny, NodePermissionsEnum.ModifyPermissions);

        var originalValues = hdnOriginalValues.Value.Split('|');

        if ((originalValues.Length != 2) || (allowed == ValidationHelper.GetInteger(originalValues[0], 0)) && (denied == ValidationHelper.GetInteger(originalValues[1], 0)))
        {
            // Don't modify an ACL item without any change or when hidden field value is removed
            return;
        }

        // Update values for next saving
        hdnOriginalValues.Value = allowed + "|" + denied;

        string message;
        string operatorName = lstOperators.SelectedItem.Text;

        if (operatorID.StartsWith("U", StringComparison.InvariantCulture))
        {
            int      userId = int.Parse(operatorID.Substring(1));
            UserInfo ui     = UserInfoProvider.GetUserInfo(userId);
            AclItemInfoProvider.SetUserPermissions(Node, allowed, denied, ui);
            message = "security.documentuserpermissionschange";
        }
        else
        {
            RoleInfo ri = RoleInfoProvider.GetRoleInfo(int.Parse(operatorID.Substring(1)));
            AclItemInfoProvider.SetRolePermissions(Node, allowed, denied, ri);
            message = "security.documentrolepermissionschange";
        }

        ShowChangesSaved();

        // Log synchronization task and flush cache
        DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Node.TreeProvider);
        Node.ClearCache();

        // Insert information about this event to event log.
        if (Tree.LogEvents)
        {
            EventLogProvider.LogEvent(EventType.INFORMATION, "Content", "DOCPERMISSIONSMODIFIED", string.Format(ResHelper.GetAPIString(message, "Permissions of the operator '{0}' have been modified for the document."), operatorName), eventUrl, Tree.UserInfo.UserID, Tree.UserInfo.UserName, Node.NodeID, DocumentName, ipAddress, Node.NodeSiteID);
        }

        if (Node != null)
        {
            // Invalidate permission data in current request
            TreeSecurityProvider.InvalidateTreeNodeAuthorizationResults(MembershipContext.AuthenticatedUser, NodeID, Node.DocumentCulture);
            AclItemInfoProvider.ClearRequestCache(Node, MembershipContext.AuthenticatedUser.UserID);
        }
        CheckPermissions(false, true);
        pnlUpdate.Update();
    }