예제 #1
0
        public static bool Orb_Command_Maintenence_Group_Remove_Method(Server.NetObject NetObj, CommandReader Command)
        {
            Database.GroupDB.Group TargetGroup = Database.GroupDB.NoGroup;
            if (Command._CmdArguments.Count() < 1)
            {
                NetObj.ClientObject.SendMessage("Please specify a group name when adding a new group.");
                return(false);
            }
            string NewGroupName = Command._CmdArguments[0];

            #region FindTargetGroup
            TargetGroup = Database.GroupDB.FindGroup(Command._CmdArguments[0]);
            if (TargetGroup != Database.GroupDB.NoGroup)
            {
                NetObj.ClientObject.SendMessage("Group: \"" + TargetGroup + "\" already exists. You cannot make duplicate groups.");
                return(false);
            }
            #endregion
            #region Test Permissions
            if (NetObj.UserObject == Database.UserDB.SuperUser || NetObj.UserObject == TargetGroup.Founder)
            {
                //continue
            }
            else
            {
                NetObj.ClientObject.SendMessage("Unable to remove Group: \"" + TargetGroup.Name + "\" as you do not have permission to manage the server.");
                return(false);
            }
            #endregion

            #region Remove Group
            NetObj.ClientObject.SendMessage("You are about to remove Group: \"" + TargetGroup.Name + "\".");
            NetObj.ClientObject.SendMessage("THIS IS NOT REVERSABLE!");
            NetObj.ClientObject.SendMessage("Please confirm this action by typing \"/OK\".");
            if (!NetObj.GetCommandConfirmation(5000))
            {
                NetObj.ClientObject.SendMessage("No response, command cancelled.");
                return(false);
            }
            string GroupName = TargetGroup.Name;
            Database.GroupDB.Delete(TargetGroup);
            Server.EmptyClientList.Include(NetObj.UserObject).SendMessage("You successfully removed Group: \"" + GroupName + "\".");
            Server.AllClients.Except(NetObj.UserObject).SendMessage("User: \"" + NetObj.UserObject.Name + "\" removed Group: \"" + GroupName + "\".");
            return(true);

            #endregion
        }
예제 #2
0
파일: Remove.cs 프로젝트: OfficerFlake/Orb
        public static bool Orb_Command_Maintenence_Group_Ranks_Remove_Method(Server.NetObject NetObj, CommandReader Command)
        {
            Database.GroupDB.Group      TargetGroup = Database.GroupDB.NoGroup;
            Database.GroupDB.Group.Rank TargetRank  = Database.GroupDB.NoRank;
            string TargetRankName = "";

            #region FindTargetGroup
            if (Command._CmdElements()[1] == "-")
            {
                if (NetObj.CommandHandling.PreviousGroup == Database.GroupDB.NoGroup)
                {
                    NetObj.ClientObject.SendMessage("No previous groups iterated over.");
                    return(false);
                }
                else
                {
                    TargetGroup = NetObj.CommandHandling.PreviousGroup;
                }
            }
            else
            {
                if (Database.GroupDB.FindGroup(Command._CmdElements()[1]) == Database.GroupDB.NoGroup)
                {
                    NetObj.ClientObject.SendMessage("Group not found: \"" + Command._CmdElements()[1] + "\".");
                    return(false);
                }
                TargetGroup = Database.GroupDB.FindGroup(Command._CmdElements()[1]);
            }
            #endregion
            #region FindTargetRank
            if (Command._CmdArguments.Count() < 1)
            {
                NetObj.ClientObject.SendMessage("No rank specified to be removed from the group.");
                return(false);
            }
            else
            {
                if (TargetGroup.Ranks.Select(x => x.Name.ToUpperInvariant()).Contains(Command._CmdArguments[0].ToUpperInvariant()))
                {
                    TargetRank = TargetGroup.Ranks.First(x => x.Name.ToUpperInvariant() == Command._CmdArguments[0].ToUpperInvariant());
                }
                else
                {
                    NetObj.ClientObject.SendMessage("Rank not found: \"" + Command._CmdArguments[0] + "\".");
                    return(false);
                }
            }
            #endregion
            #region SuperUser Override
            if (NetObj.UserObject == Database.UserDB.SuperUser || NetObj.UserObject == TargetGroup.Founder)
            {
                //continue
            }
            #endregion
            #region Standard Testing
            if (NetObj.UserObject.Groups.Select(x => x.Group).Contains(TargetGroup))
            {
                //THIS User is a member of the group. (Required to be able to modify the group.
                Database.UserDB.User.GroupReference ThisGroupReference = NetObj.UserObject.Groups.Where(x => x.Group == TargetGroup).ToArray()[0];
                if (ThisGroupReference.Rank.Permissions.Group_ManageMembers <= 0)
                {
                    NetObj.ClientObject.SendMessage("Your rank does not have permission to manage group ranks in this group.");
                    return(false);
                }
                //continue
            }
            else
            {
                NetObj.ClientObject.SendMessage("You need to be a member of the group yourself in order to remove ranks. (Group founders are excepted from this rule.)");
                return(false);
            }
            #endregion

            TargetRankName = TargetRank.Name;
            if (!(TargetGroup.Ranks.Contains(TargetRank)))
            {
                NetObj.ClientObject.SendMessage("Rank: \"" + TargetRank.Name + "\" not found in Group: \"" + TargetGroup.Name + "\".");
                return(false);
            }
            NetObj.ClientObject.SendMessage("You are about to remove Rank: \"" + TargetRank.Name + "\" from Group: \"" + TargetGroup.Name + "\".");
            NetObj.ClientObject.SendMessage("THIS IS NOT REVERSABLE!");
            NetObj.ClientObject.SendMessage("Please confirm this action by typing \"/OK\".");
            if (!NetObj.GetCommandConfirmation(5000))
            {
                NetObj.ClientObject.SendMessage("No response, command cancelled.");
                return(false);
            }
            TargetGroup.RemoveRankFromGroup(TargetRank);
            TargetGroup.SaveAll();
            Server.EmptyClientList.Include(NetObj).SendMessage("You removed Rank: \"" + TargetRankName + "\" from Group: \"" + TargetGroup.Name + "\".");
            Server.AllClients.Except(NetObj).SendMessage("Rank: \"" + TargetRankName + "\" was removed from Group: \"" + TargetGroup.Name + "\" by \"" + NetObj.UserObject.Name + "\".");
            return(true);
        }
예제 #3
0
        public static bool Orb_Command_Maintenence_Group_Owner_Method(Server.NetObject NetObj, CommandReader Command)
        {
            Database.UserDB.User   TargetUser  = Database.UserDB.Nobody;
            Database.GroupDB.Group TargetGroup = Database.GroupDB.NoGroup;
            #region FindTargetUser
            if (Command._CmdArguments.Count() < 1)
            {
                NetObj.ClientObject.SendMessage("No user specified to change group ownership to.");
                return(false);
            }
            if (Command._CmdArguments[0] == "-")
            {
                if (NetObj.CommandHandling.PreviousUser == Database.UserDB.Nobody)
                {
                    NetObj.ClientObject.SendMessage("No previous users iterated over.");
                    return(false);
                }
                else
                {
                    TargetUser = NetObj.CommandHandling.PreviousUser;
                }
            }
            else
            {
                if (Database.UserDB.Find(Command._CmdArguments[0]) != Database.UserDB.Nobody)
                {
                    TargetUser = Database.UserDB.Find(Command._CmdArguments[0]);
                }
                else
                {
                    NetObj.ClientObject.SendMessage("User not found: \"" + Command._CmdArguments[0] + "\".");
                    return(false);
                }
            }
            #endregion
            #region FindTargetGroup
            if (Command._CmdElements()[1] == "-")
            {
                if (NetObj.CommandHandling.PreviousGroup == Database.GroupDB.NoGroup)
                {
                    NetObj.ClientObject.SendMessage("No previous groups iterated over.");
                    return(false);
                }
                else
                {
                    TargetGroup = NetObj.CommandHandling.PreviousGroup;
                }
            }
            else
            {
                if (Database.GroupDB.FindGroup(Command._CmdElements()[1]) == Database.GroupDB.NoGroup)
                {
                    NetObj.ClientObject.SendMessage("Group not found: \"" + Command._CmdElements()[1] + "\".");
                    return(false);
                }
                TargetGroup = Database.GroupDB.FindGroup(Command._CmdElements()[1]);
            }
            #endregion
            #region SuperUser Override
            if (NetObj.UserObject == Database.UserDB.SuperUser || NetObj.UserObject == TargetGroup.Founder)
            {
                //Continue.
            }
            #endregion
            #region Standard Testing
            else
            {
                NetObj.ClientObject.SendMessage("Only Group Owners are able to change ownership of the group. Please contact " + TargetGroup.Founder.Name + " if you wish to take over this group.");
                return(false);
            }
            #endregion

            if (NetObj.UserObject == TargetUser)
            {
                NetObj.ClientObject.SendMessage("You already ARE the founder of this group!");
                return(false);
            }
            else
            {
                NetObj.ClientObject.SendMessage("You are about to relinquish ownership of Group: \"" + TargetGroup.Name + "\" to \"" + TargetUser.Name + "\".");
                NetObj.ClientObject.SendMessage("THIS IS NOT REVERSABLE!");
                NetObj.ClientObject.SendMessage("Please confirm this action by typing \"/OK\".");
                if (!NetObj.GetCommandConfirmation(5000))
                {
                    NetObj.ClientObject.SendMessage("No response, command cancelled.");
                    return(false);
                }
            }
            TargetGroup.Founder = TargetUser;
            TargetGroup.SaveAll();
            NetObj.ClientObject.SendMessage("You have relinquished ownership of Group: \"" + TargetGroup.Name + "\" to \"" + TargetUser.Name + "\".");
            Server.EmptyClientList.Include(TargetUser).SendMessage("You have been assigned ownership of Group: \"" + TargetGroup.Name + "\" by \"" + NetObj.UserObject.Name + "\".");
            Server.AllClients.Except(TargetUser).SendMessage("User: \"" + TargetUser.Name + "\" was assigned ownership of Group: \"" + TargetGroup.Name + "\" by \"" + NetObj.UserObject.Name + "\".");
            return(true);
        }