Example #1
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            //Get the rolename and the permissionname
            string RoleName       = cmbRoles.SelectedItem.ToString();
            string PermissionName = listBox1.SelectedItem.ToString();

            //New instance of permissionlogic and rolelogic
            PermissionLogic PLogic = new PermissionLogic();
            RoleLogic       RLogic = new RoleLogic();

            //New role and new permisson
            Role       r = new Role(RoleName, 1);
            Permission p = new Permission(1, PermissionName);

            //Empt roleid and permissionid
            int RoleID       = 0;
            int PermissionID = 0;

            //Get permissionid from the database
            var AllPermissions = PLogic.RetrieveAllPermissions();

            foreach (var SinglePermission in AllPermissions)
            {
                if (SinglePermission.PermissionName == p.PermissionName)
                {
                    PermissionID = SinglePermission.RetrievePermissionID();
                }
            }

            //Get roleid from the database
            var AllRoles = RLogic.RetrieveAllRoles();

            foreach (var SingleRole in AllRoles)
            {
                if (SingleRole.RetrieveRoleName() == r.RetrieveRoleName())
                {
                    RoleID = SingleRole.RetrieveRoleID();
                }
            }

            PLogic.DeleteRolePermission(RoleID, PermissionID);

            listBox1.Items.Clear();
            string rol = cmbRoles.SelectedItem.ToString();

            List <string> permissions = PLogic.GetAllRolePermissions(rol);

            foreach (string per in permissions)
            {
                listBox1.Items.Add(per);
            }
        }
Example #2
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            GamePlayer target = client.Player;

            switch (args[1])
            {
                #region Single
            case "single":
            {
                if (args.Length < 3)
                {
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length > 3)
                {
                    GameClient targetClient = WorldMgr.GetClientByPlayerName(args[3], true, true);

                    if (targetClient != null)
                    {
                        target = targetClient.Player;
                    }
                }

                SinglePermission.setPermission(target, args[2]);
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.AddedSinglePermission", target.Name, args[2]));

                break;
            }
                #endregion Single

                #region Single Account
            case "singleaccount":
            {
                if (args.Length < 3)
                {
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length > 3)
                {
                    GameClient targetClient = WorldMgr.GetClientByPlayerName(args[3], true, true);

                    if (targetClient != null)
                    {
                        target = targetClient.Player;
                    }
                }

                SinglePermission.setPermissionAccount(target, args[2]);
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.AddedSingleAccountPermission", target.Client.Account.Name, args[2]));

                break;
            }
                #endregion

                #region Remove
            case "remove":
            {
                if (args.Length < 2)
                {
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length > 3)
                {
                    GameClient targetClient = WorldMgr.GetClientByPlayerName(args[3], true, true);

                    if (targetClient != null)
                    {
                        target = targetClient.Player;
                    }
                }

                if (SinglePermission.removePermission(target, args[2]))
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.RemoveSinglePermission", target.Name, args[2]));
                }
                else
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.NoPermissionForCommand", target.Name, args[2]));
                }

                break;
            }
                #endregion Remove

                #region Remove Account
            case "removeaccount":
            {
                if (args.Length < 2)
                {
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length > 3)
                {
                    GameClient targetClient = WorldMgr.GetClientByPlayerName(args[3], true, true);

                    if (targetClient != null)
                    {
                        target = targetClient.Player;
                    }
                }

                if (SinglePermission.removePermissionAccount(target, args[2]))
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.RemoveSingleAccountPermission", target.Client.Account.Name, args[2]));
                }
                else
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.NoPermissionForCommand", target.Client.Account.Name, args[2]));
                }

                break;
            }
                #endregion Remove

                #region Default
            default:
            {
                uint plvl = 1;

                if (!UInt32.TryParse(args[1], out plvl))
                {
                    DisplaySyntax(client);
                    return;
                }

                if (args.Length > 2)
                {
                    GameClient targetClient = WorldMgr.GetClientByPlayerName(args[2], true, true);

                    if (targetClient != null)
                    {
                        target = targetClient.Player;
                    }
                }

                target.Client.Account.PrivLevel = plvl;
                GameServer.Database.SaveObject(target.Client.Account);
                client.Player.RefreshWorld();

                target.Client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.YourPlvlHasBeenSetted", plvl.ToString()), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

                if (target != client.Player)
                {
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.plvl.PlayerPlvlHasBeenSetted", target.Name, plvl.ToString()), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }

                break;
            }
                #endregion Default
            }
        }