/// <summary>
    /// Removes selected operator from the ACL.
    /// </summary>
    protected void btnRemoveOperator_Click(Object sender, EventArgs e)
    {
        // Check permission
        CheckPermissions(true);

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

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

        if (operatorID.StartsWith("U", StringComparison.InvariantCulture))
        {
            int      userId = int.Parse(operatorID.Substring(1));
            UserInfo ui     = UserInfo.Provider.Get(userId);
            AclItemInfoProvider.RemoveUser(Node.NodeID, ui);
            message = "security.documentuserpermissionremoved";
        }
        else
        {
            RoleInfo ri = RoleInfo.Provider.Get(int.Parse(operatorID.Substring(1)));
            AclItemInfoProvider.RemoveRole(Node.NodeID, ri);
            message = "security.documentrolepermissionremoved";
        }

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

        // Insert information about this event to eventlog.
        if (Tree.LogEvents)
        {
            var logData = new EventLogData(EventTypeEnum.Information, "Content", "DOCPERMISSIONSMODIFIED")
            {
                EventDescription = String.Format(ResHelper.GetAPIString(message, "Operator '{0}' has been removed from the page permissions."), operatorName),
                EventUrl         = eventUrl,
                UserID           = Tree.UserInfo.UserID,
                UserName         = Tree.UserInfo.UserName,
                NodeID           = Node.NodeID,
                DocumentName     = Node.GetDocumentName(),
                IPAddress        = ipAddress,
                SiteID           = Node.NodeSiteID
            };

            Service.Resolve <IEventLogService>().LogEvent(logData);
        }

        dsAclItems = null;
        LoadOperators(true);

        CheckButtonsActiveState();
    }
    /// <summary>
    /// Removes selected operator from the ACL.
    /// </summary>
    protected void btnRemoveOperator_Click(Object sender, EventArgs e)
    {
        // Check permission
        CheckPermissions(true);

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

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

        if (operatorID.StartsWithCSafe("U"))
        {
            int      userId = int.Parse(operatorID.Substring(1));
            UserInfo ui     = UserInfoProvider.GetUserInfo(userId);
            AclItemInfoProvider.RemoveUser(Node.NodeID, ui);
            message = "security.documentuserpermissionremoved";
        }
        else
        {
            RoleInfo ri = RoleInfoProvider.GetRoleInfo(int.Parse(operatorID.Substring(1)));
            AclItemInfoProvider.RemoveRole(Node.NodeID, ri);
            message = "security.documentrolepermissionremoved";
        }

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

        // Insert information about this event to eventlog.
        if (Tree.LogEvents)
        {
            EventLogProvider.LogEvent(EventType.INFORMATION, "Content", "DOCPERMISSIONSMODIFIED", string.Format(ResHelper.GetAPIString(message, "Operator '{0}' has been removed from the document permissions."), operatorName), eventUrl, Tree.UserInfo.UserID, Tree.UserInfo.UserName, Node.NodeID, DocumentName, ipAddress, Node.NodeSiteID);
        }

        dsAclItems = null;
        LoadOperators(true);

        CheckButtonsActiveState();
    }
    /// <summary>
    /// On items selected event handling.
    /// </summary>
    private void usRoles_OnItemsSelected(object sender, EventArgs e)
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usRoles.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, CurrentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int roleID = ValidationHelper.GetInteger(item, 0);

                    if (PollID > 0)
                    {
                        // Remove role from poll
                        ModuleCommands.PollsRemoveRoleFromPoll(roleID, PollID);
                    }
                    else if (FormID > 0)
                    {
                        // Remove role from form
                        BizFormRoleInfoProvider.DeleteBizFormRoleInfo(roleID, FormID);
                    }
                    else if (BoardID > 0)
                    {
                        // Check permissions
                        if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.messageboards", CMSAdminControl.PERMISSION_MODIFY))
                        {
                            // Remove message board from board
                            ModuleCommands.MessageBoardRemoveRoleFromBoard(roleID, BoardID);
                        }
                    }
                    else if (Node != null)
                    {
                        RoleInfo ri = RoleInfoProvider.GetRoleInfo(roleID);
                        // Remove role from treenode
                        AclItemInfoProvider.RemoveRole(NodeID, ri);
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(CurrentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int roleID = ValidationHelper.GetInteger(item, 0);

                    if (PollID > 0)
                    {
                        // Add poll role
                        ModuleCommands.PollsAddRoleToPoll(roleID, PollID);
                    }
                    else if (FormID > 0)
                    {
                        // Add BizForm role
                        BizFormRoleInfoProvider.SetBizFormRoleInfo(roleID, FormID);
                    }
                    else if (BoardID > 0)
                    {
                        // Add role to the message board
                        ModuleCommands.MessageBoardAddRoleToBoard(roleID, BoardID);
                    }
                    else if (Node != null)
                    {
                        RoleInfo ri = RoleInfoProvider.GetRoleInfo(roleID);
                        // Add role to treenode
                        AclItemInfoProvider.SetRolePermissions(Node, 0, 0, ri);
                    }
                }
            }
        }

        // Log synchronization task
        if (Node != null)
        {
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Node.TreeProvider);
        }

        RaiseOnChanged();
    }
Exemple #4
0
    /// <summary>
    /// On items selected event handling.
    /// </summary>
    private void usRoles_OnItemsSelected(object sender, EventArgs e)
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usRoles.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, CurrentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            // Add all new items to site
            foreach (string item in newItems)
            {
                int roleID = ValidationHelper.GetInteger(item, 0);

                if (FormID > 0)
                {
                    // Remove role from form
                    BizFormRoleInfo.Provider.Remove(roleID, FormID);
                }
                else if (Node != null)
                {
                    RoleInfo ri = RoleInfo.Provider.Get(roleID);
                    // Remove role from treenode
                    AclItemInfoProvider.RemoveRole(NodeID, ri);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(CurrentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            // Add all new items to site
            foreach (string item in newItems)
            {
                int roleID = ValidationHelper.GetInteger(item, 0);

                if (FormID > 0)
                {
                    // Add BizForm role
                    BizFormRoleInfo.Provider.Add(roleID, FormID);
                }
                else if (Node != null)
                {
                    RoleInfo ri = RoleInfo.Provider.Get(roleID);
                    // Add role to treenode
                    AclItemInfoProvider.SetRolePermissions(Node, 0, 0, ri);
                }
            }
        }

        // Log synchronization task
        if (Node != null)
        {
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Node.TreeProvider);
        }

        RaiseOnChanged();
    }