From e970ee29553562b08bde2027c5f59a5f4301071f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Aug 2007 01:08:53 +0000 Subject: * More work on PermissionManager - going AFK for a bit. --- OpenSim/Region/Environment/PermissionManager.cs | 117 ++++++++++++++++-------- 1 file changed, 79 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region/Environment/PermissionManager.cs') diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index e768d7f..3f1ba18 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -44,69 +44,75 @@ namespace OpenSim.Region.Environment return true; } - /// - /// Permissions check - can user delete an object? - /// - /// User attempting the delete - /// Target object - /// Has permission? - public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) + + #region Object Permissions + + protected virtual bool GenericObjectPermission(LLUUID user, LLUUID obj) { // Default: deny - bool canDeRez = false; + bool permission = false; - // If it's not an object, we cant derez it. + // If it's not an object, we cant edit it. if (!(m_scene.Entities[obj] is SceneObject)) return false; SceneObject task = (SceneObject)m_scene.Entities[obj]; LLUUID taskOwner = null; // Since we dont have a 'owner' property on task yet - // Object owners should be able to delete their own content + // Object owners should be able to edit their own content if (user == taskOwner) - canDeRez = true; + permission = true; - // Users should be able to delete what is over their land. + // Users should be able to edit what is over their land. if (m_scene.LandManager.getLandObject(task.Pos.X, task.Pos.Y).landData.ownerID == user) - canDeRez = true; + permission = true; - // Estate users should be able to delete anything in the sim + // Estate users should be able to edit anything in the sim if (IsEstateManager(user)) - canDeRez = true; + permission = true; - // Admin objects should not be deletable by the above + // Admin objects should not be editable by the above if (IsAdministrator(taskOwner)) - canDeRez = false; + permission = false; - // Admin should be able to delete anything in the sim (including admin objects) + // Admin should be able to edit anything in the sim (including admin objects) if (IsAdministrator(user)) - canDeRez = true; + permission = true; - return canDeRez; + return permission; + } + + /// + /// Permissions check - can user delete an object? + /// + /// User attempting the delete + /// Target object + /// Has permission? + public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); } public virtual bool CanEditObject(LLUUID user, LLUUID obj) { - // Permissions for editing fall into the same category as deleting - // May need to add check for "no-mod" items. - return CanDeRezObject(user, obj); + return GenericObjectPermission(user, obj); } - public virtual bool CanEditScript(LLUUID user, LLUUID script) + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) { - return false; + return GenericObjectPermission(user, obj); } - public virtual bool CanRunScript(LLUUID user, LLUUID script) + #endregion + + public virtual bool CanEditScript(LLUUID user, LLUUID script) { return false; } - public virtual bool CanReturnObject(LLUUID user, LLUUID obj) + public virtual bool CanRunScript(LLUUID user, LLUUID script) { - // Same category as deleting, but eventually will need seperate check - // as sometimes it's better to allow returning only. - return CanDeRezObject(user, obj); + return false; } public virtual bool CanTerraform(LLUUID user, LLUUID position) @@ -114,35 +120,70 @@ namespace OpenSim.Region.Environment return false; } - public virtual bool CanEditEstateSettings(LLUUID user) + #region Estate Permissions + + protected virtual bool GenericEstatePermission(LLUUID user) { // Default: deny - bool canEdit = false; + bool permission = false; // Estate admins should be able to use estate tools if (IsEstateManager(user)) - canEdit = true; + permission = true; // Administrators always have permission if (IsAdministrator(user)) - canEdit = true; + permission = true; + + return permission; + } + + public virtual bool CanEditEstateTerrain(LLUUID user) + { + return GenericEstatePermission(user); + } + + #endregion + + #region Parcel Permissions + + protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) + { + bool permission = false; + + if (parcel.landData.ownerID == user) + permission = true; + + if (parcel.landData.isGroupOwned) + { + // TODO: Need to do some extra checks here. Requires group code. + } + + if(IsEstateManager(user)) + permission = true; + + if (IsAdministrator(user)) + permission = true; - return canEdit; + return permission; } public virtual bool CanEditParcel(LLUUID user, Land parcel) { - return false; + return GenericParcelPermission(user, parcel); } public virtual bool CanSellParcel(LLUUID user, Land parcel) { - return false; + return GenericParcelPermission(user, parcel); } public virtual bool CanAbandonParcel(LLUUID user, Land parcel) { - return false; + return GenericParcelPermission(user, parcel); } + + #endregion + } } -- cgit v1.1