groups work, with inheritance, still need to remove order by
This commit is contained in:
parent
7bac787aa5
commit
cfcc0e7276
3 changed files with 22 additions and 19 deletions
|
|
@ -107,7 +107,7 @@ namespace TShockAPI.DB
|
||||||
comms = comms + ",";
|
comms = comms + ",";
|
||||||
comms = comms + info[i].Trim();
|
comms = comms + info[i].Trim();
|
||||||
}
|
}
|
||||||
com.AddParameter("@groupname", info[0].Trim());
|
com.AddParameter("@groupname", info[0].Trim().ToString());
|
||||||
com.AddParameter("@commands", comms);
|
com.AddParameter("@commands", comms);
|
||||||
com.AddParameter("@order", hasOrder ? info[info.Length-1] : "0");
|
com.AddParameter("@order", hasOrder ? info[info.Length-1] : "0");
|
||||||
com.ExecuteNonQuery();
|
com.ExecuteNonQuery();
|
||||||
|
|
@ -123,8 +123,6 @@ namespace TShockAPI.DB
|
||||||
File.Delete(file2);
|
File.Delete(file2);
|
||||||
File.Move(file, file2);
|
File.Move(file, file2);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadPermisions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,6 +131,7 @@ namespace TShockAPI.DB
|
||||||
if (group == "superadmin")
|
if (group == "superadmin")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var com = database.CreateCommand())
|
using (var com = database.CreateCommand())
|
||||||
|
|
@ -171,23 +170,19 @@ namespace TShockAPI.DB
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Group group = null;
|
Group group = null;
|
||||||
string groupname = reader.Get<string>("GroupName");
|
string groupname = reader.Get<String>("GroupName");
|
||||||
int order = Int32.Parse(reader.Get<string>("OrderBy"));
|
|
||||||
group = new Group(groupname);
|
group = new Group(groupname);
|
||||||
group.Order = order;
|
|
||||||
|
|
||||||
//Inherit Given commands
|
//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);
|
groups.Add(group);
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** ORDER BY IS DUMB
|
||||||
//Inherit all commands from group below in order, unless Order is 0 (unique groups anyone)
|
//Inherit all commands from group below in order, unless Order is 0 (unique groups anyone)
|
||||||
foreach (Group group in groups)
|
foreach (Group group in groups)
|
||||||
{
|
{
|
||||||
|
|
@ -201,7 +196,7 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -55,20 +55,27 @@ namespace TShockAPI
|
||||||
|
|
||||||
public void AddPermission(string permission)
|
public void AddPermission(string permission)
|
||||||
{
|
{
|
||||||
recursePermissions(permission);
|
recursePermissions(permission, new List<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recursePermissions( string permission ){
|
public void recursePermissions( string permission, List<String> used){
|
||||||
if( TShock.Groups.GroupExists( permission ) )
|
if (used.Contains(permission))
|
||||||
{
|
{
|
||||||
Group g = Tools.GetGroup( permission );
|
return;
|
||||||
foreach( string perm in g.permissions )
|
}
|
||||||
|
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
|
else
|
||||||
|
{
|
||||||
permissions.Add(permission);
|
permissions.Add(permission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ namespace TShockAPI
|
||||||
Warps = new WarpManager(DB);
|
Warps = new WarpManager(DB);
|
||||||
Regions = new RegionManager(DB);
|
Regions = new RegionManager(DB);
|
||||||
Groups = new GroupManager(DB);
|
Groups = new GroupManager(DB);
|
||||||
|
Groups.LoadPermisions();
|
||||||
Users = new UserManager(DB);
|
Users = new UserManager(DB);
|
||||||
Itembans = new ItemManager(DB);
|
Itembans = new ItemManager(DB);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue