groups work, with inheritance, still need to remove order by

This commit is contained in:
Zack Piispanen 2011-07-20 20:55:49 -04:00
parent 7bac787aa5
commit cfcc0e7276
3 changed files with 22 additions and 19 deletions

View file

@ -107,7 +107,7 @@ namespace TShockAPI.DB
comms = comms + ",";
comms = comms + info[i].Trim();
}
com.AddParameter("@groupname", info[0].Trim());
com.AddParameter("@groupname", info[0].Trim().ToString());
com.AddParameter("@commands", comms);
com.AddParameter("@order", hasOrder ? info[info.Length-1] : "0");
com.ExecuteNonQuery();
@ -123,8 +123,6 @@ namespace TShockAPI.DB
File.Delete(file2);
File.Move(file, file2);
}
LoadPermisions();
}
}
@ -133,6 +131,7 @@ namespace TShockAPI.DB
if (group == "superadmin")
return true;
try
{
using (var com = database.CreateCommand())
@ -171,23 +170,19 @@ namespace TShockAPI.DB
while (reader.Read())
{
Group group = null;
string groupname = reader.Get<string>("GroupName");
int order = Int32.Parse(reader.Get<string>("OrderBy"));
string groupname = reader.Get<String>("GroupName");
group = new Group(groupname);
group.Order = order;
//Inherit Given commands
foreach (string perm in reader.Get<string>("Commands").Split(','))
String[] commands = reader.Get<String>("Commands").Split(',');
for( int i = 0; i < commands.Length; i++ )
{
group.AddPermission(perm);
group.AddPermission(commands[i].Trim());
}
groups.Add(group);
reader.Close();
}
}
/** ORDER BY IS DUMB
//Inherit all commands from group below in order, unless Order is 0 (unique groups anyone)
foreach (Group group in groups)
{
@ -201,7 +196,7 @@ namespace TShockAPI.DB
}
}
}
}
}*/
}
}
catch (Exception ex)

View file

@ -55,22 +55,29 @@ namespace TShockAPI
public void AddPermission(string permission)
{
recursePermissions(permission);
recursePermissions(permission, new List<String>());
}
public void recursePermissions( string permission ){
if( TShock.Groups.GroupExists( permission ) )
public void recursePermissions( string permission, List<String> used){
if (used.Contains(permission))
{
return;
}
else if( TShock.Groups.GroupExists( permission ) )
{
used.Add(permission);
Group g = Tools.GetGroup(permission);
foreach (string perm in g.permissions)
{
recursePermissions( perm );
recursePermissions(perm, used);
}
}
else
{
permissions.Add(permission);
}
}
}
public class SuperAdminGroup : Group
{

View file

@ -172,6 +172,7 @@ namespace TShockAPI
Warps = new WarpManager(DB);
Regions = new RegionManager(DB);
Groups = new GroupManager(DB);
Groups.LoadPermisions();
Users = new UserManager(DB);
Itembans = new ItemManager(DB);