add/fix CanRunScript
parent
0a5d6671ce
commit
186f0b73cd
|
@ -1612,12 +1612,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
|||
return IsAdministrator(user);
|
||||
}
|
||||
|
||||
private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene)
|
||||
private bool CanRunScript(TaskInventoryItem scriptitem, SceneObjectPart part)
|
||||
{
|
||||
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
|
||||
if (m_bypassPermissions) return m_bypassPermissionsValue;
|
||||
|
||||
if(scriptitem == null || part == null)
|
||||
return false;
|
||||
|
||||
SceneObjectGroup sog = part.ParentGroup;
|
||||
if(sog == null)
|
||||
return false;
|
||||
|
||||
Vector3 pos = sog.AbsolutePosition;
|
||||
ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
|
||||
if (parcel == null)
|
||||
return false;
|
||||
|
||||
LandData ldata = parcel.LandData;
|
||||
if(ldata == null)
|
||||
return false;
|
||||
|
||||
uint lflags = ldata.Flags;
|
||||
|
||||
if ((lflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
|
||||
return true;
|
||||
|
||||
if ((part.OwnerID == ldata.OwnerID))
|
||||
return true;
|
||||
|
||||
if (((lflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
|
||||
&& (ldata.GroupID != UUID.Zero) && (ldata.GroupID == part.GroupID))
|
||||
return true;
|
||||
|
||||
return GenericEstatePermission(part.OwnerID);
|
||||
}
|
||||
|
||||
private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene)
|
||||
|
|
|
@ -60,7 +60,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene);
|
||||
public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
|
||||
public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene);
|
||||
public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
|
||||
public delegate bool RunScriptHandlerByIDs(UUID script, UUID objectID, UUID user, Scene scene);
|
||||
public delegate bool RunScriptHandler(TaskInventoryItem item, SceneObjectPart part);
|
||||
public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene);
|
||||
public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene);
|
||||
public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene);
|
||||
|
@ -131,6 +132,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public event ViewNotecardHandler OnViewNotecard;
|
||||
public event EditScriptHandler OnEditScript;
|
||||
public event EditNotecardHandler OnEditNotecard;
|
||||
public event RunScriptHandlerByIDs OnRunScriptByIDs;
|
||||
public event RunScriptHandler OnRunScript;
|
||||
public event CompileScriptHandler OnCompileScript;
|
||||
public event StartScriptHandler OnStartScript;
|
||||
|
@ -654,11 +656,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
#region RUN SCRIPT (When Script Placed in Object)
|
||||
public bool CanRunScript(UUID script, UUID objectID, UUID user)
|
||||
{
|
||||
RunScriptHandler handler = OnRunScript;
|
||||
RunScriptHandlerByIDs handler = OnRunScriptByIDs;
|
||||
if (handler != null)
|
||||
{
|
||||
Delegate[] list = handler.GetInvocationList();
|
||||
foreach (RunScriptHandler h in list)
|
||||
foreach (RunScriptHandlerByIDs h in list)
|
||||
{
|
||||
if (h(script, objectID, user, m_scene) == false)
|
||||
return false;
|
||||
|
@ -667,6 +669,24 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool CanRunScript(TaskInventoryItem item, SceneObjectPart part)
|
||||
{
|
||||
RunScriptHandler handler = OnRunScript;
|
||||
if (handler != null)
|
||||
{
|
||||
if(item == null || part == null)
|
||||
return false;
|
||||
Delegate[] list = handler.GetInvocationList();
|
||||
foreach (RunScriptHandler h in list)
|
||||
{
|
||||
if (h(item, part) == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region COMPILE SCRIPT (When Script needs to get (re)compiled)
|
||||
|
|
|
@ -360,7 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
|
||||
// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
|
||||
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
|
||||
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item, m_part))
|
||||
{
|
||||
StoreScriptError(item.ItemID, "no permission");
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue