Example #1
0
            static bool HandleRBACPermListCommand(StringArguments args, CommandHandler handler)
            {
                RBACCommandData command = ReadParams(args, handler, false);

                if (command == null)
                {
                    return(false);
                }

                handler.SendSysMessage(CypherStrings.RbacListHeaderGranted, command.rbac.GetId(), command.rbac.GetName());
                var granted = command.rbac.GetGrantedPermissions();

                if (granted.Empty())
                {
                    handler.SendSysMessage(CypherStrings.RbacListEmpty);
                }
                else
                {
                    foreach (var id in granted)
                    {
                        RBACPermission permission = Global.AccountMgr.GetRBACPermission(id);
                        handler.SendSysMessage(CypherStrings.RbacListElement, permission.GetId(), permission.GetName());
                    }
                }

                handler.SendSysMessage(CypherStrings.RbacListHeaderDenied, command.rbac.GetId(), command.rbac.GetName());
                var denied = command.rbac.GetDeniedPermissions();

                if (denied.Empty())
                {
                    handler.SendSysMessage(CypherStrings.RbacListEmpty);
                }
                else
                {
                    foreach (var id in denied)
                    {
                        RBACPermission permission = Global.AccountMgr.GetRBACPermission(id);
                        handler.SendSysMessage(CypherStrings.RbacListElement, permission.GetId(), permission.GetName());
                    }
                }
                handler.SendSysMessage(CypherStrings.RbacListHeaderBySecLevel, command.rbac.GetId(), command.rbac.GetName(), command.rbac.GetSecurityLevel());
                var defaultPermissions = Global.AccountMgr.GetRBACDefaultPermissions(command.rbac.GetSecurityLevel());

                if (defaultPermissions.Empty())
                {
                    handler.SendSysMessage(CypherStrings.RbacListEmpty);
                }
                else
                {
                    foreach (var id in defaultPermissions)
                    {
                        RBACPermission permission = Global.AccountMgr.GetRBACPermission(id);
                        handler.SendSysMessage(CypherStrings.RbacListElement, permission.GetId(), permission.GetName());
                    }
                }

                return(true);
            }
Example #2
0
        static bool HandleRBACListPermissionsCommand(StringArguments args, CommandHandler handler)
        {
            uint id = args.NextUInt32();

            if (id == 0)
            {
                var permissions = Global.AccountMgr.GetRBACPermissionList();
                handler.SendSysMessage(CypherStrings.RbacListPermissionsHeader);
                foreach (var permission in permissions.Values)
                {
                    handler.SendSysMessage(CypherStrings.RbacListElement, permission.GetId(), permission.GetName());
                }
            }
            else
            {
                RBACPermission permission = Global.AccountMgr.GetRBACPermission(id);
                if (permission == null)
                {
                    handler.SendSysMessage(CypherStrings.RbacWrongParameterId, id);
                    return(false);
                }

                handler.SendSysMessage(CypherStrings.RbacListPermissionsHeader);
                handler.SendSysMessage(CypherStrings.RbacListElement, permission.GetId(), permission.GetName());
                handler.SendSysMessage(CypherStrings.RbacListPermsLinkedHeader);
                var permissions = permission.GetLinkedPermissions();
                foreach (var permissionId in permissions)
                {
                    RBACPermission rbacPermission = Global.AccountMgr.GetRBACPermission(permissionId);
                    if (rbacPermission != null)
                    {
                        handler.SendSysMessage(CypherStrings.RbacListElement, rbacPermission.GetId(), rbacPermission.GetName());
                    }
                }
            }

            return(true);
        }