Scene.Permissions.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using System.Text;
  31. using log4net;
  32. using OpenMetaverse;
  33. using OpenSim.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. namespace OpenSim.Region.Framework.Scenes
  36. {
  37. #region Delegates
  38. public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID);
  39. public delegate void SetBypassPermissionsHandler(bool value);
  40. public delegate bool BypassPermissionsHandler();
  41. public delegate bool PropagatePermissionsHandler();
  42. public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
  43. public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene);
  44. public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene);
  45. public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene);
  46. public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene);
  47. public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
  48. public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene);
  49. public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
  50. public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
  51. public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
  52. public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene);
  53. public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
  54. public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene);
  55. public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  56. public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene);
  57. public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  58. public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene);
  59. public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  60. public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene);
  61. public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene);
  62. public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene);
  63. public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene);
  64. public delegate bool TerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene);
  65. public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
  66. public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
  67. public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
  68. public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene);
  69. public delegate bool IsAdministratorHandler(UUID user);
  70. public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
  71. public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene);
  72. public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene);
  73. public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
  74. public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene);
  75. public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene);
  76. public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene);
  77. public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene);
  78. public delegate bool LinkObjectHandler(UUID user, UUID objectID);
  79. public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
  80. public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
  81. public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  82. public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  83. public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  84. public delegate bool CreateUserInventoryHandler(int invType, UUID userID);
  85. public delegate bool EditUserInventoryHandler(UUID itemID, UUID userID);
  86. public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID);
  87. public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
  88. public delegate bool TransferUserInventoryHandler(UUID itemID, UUID userID, UUID recipientID);
  89. public delegate bool TeleportHandler(UUID userID, Scene scene);
  90. public delegate bool ControlPrimMediaHandler(UUID userID, UUID primID, int face);
  91. public delegate bool InteractWithPrimMediaHandler(UUID userID, UUID primID, int face);
  92. #endregion
  93. public class ScenePermissions
  94. {
  95. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  96. private Scene m_scene;
  97. public ScenePermissions(Scene scene)
  98. {
  99. m_scene = scene;
  100. }
  101. #region Events
  102. public event GenerateClientFlagsHandler OnGenerateClientFlags;
  103. public event SetBypassPermissionsHandler OnSetBypassPermissions;
  104. public event BypassPermissionsHandler OnBypassPermissions;
  105. public event PropagatePermissionsHandler OnPropagatePermissions;
  106. public event RezObjectHandler OnRezObject;
  107. public event DeleteObjectHandler OnDeleteObject;
  108. public event TransferObjectHandler OnTransferObject;
  109. public event TakeObjectHandler OnTakeObject;
  110. public event TakeCopyObjectHandler OnTakeCopyObject;
  111. public event DuplicateObjectHandler OnDuplicateObject;
  112. public event EditObjectHandler OnEditObject;
  113. public event EditObjectInventoryHandler OnEditObjectInventory;
  114. public event MoveObjectHandler OnMoveObject;
  115. public event ObjectEntryHandler OnObjectEntry;
  116. public event ReturnObjectsHandler OnReturnObjects;
  117. public event InstantMessageHandler OnInstantMessage;
  118. public event InventoryTransferHandler OnInventoryTransfer;
  119. public event ViewScriptHandler OnViewScript;
  120. public event ViewNotecardHandler OnViewNotecard;
  121. public event EditScriptHandler OnEditScript;
  122. public event EditNotecardHandler OnEditNotecard;
  123. public event RunScriptHandler OnRunScript;
  124. public event CompileScriptHandler OnCompileScript;
  125. public event StartScriptHandler OnStartScript;
  126. public event StopScriptHandler OnStopScript;
  127. public event ResetScriptHandler OnResetScript;
  128. public event TerraformLandHandler OnTerraformLand;
  129. public event RunConsoleCommandHandler OnRunConsoleCommand;
  130. public event IssueEstateCommandHandler OnIssueEstateCommand;
  131. public event IsGodHandler OnIsGod;
  132. public event IsGridGodHandler OnIsGridGod;
  133. public event IsAdministratorHandler OnIsAdministrator;
  134. // public event EditParcelHandler OnEditParcel;
  135. public event EditParcelPropertiesHandler OnEditParcelProperties;
  136. public event SellParcelHandler OnSellParcel;
  137. public event AbandonParcelHandler OnAbandonParcel;
  138. public event ReclaimParcelHandler OnReclaimParcel;
  139. public event DeedParcelHandler OnDeedParcel;
  140. public event DeedObjectHandler OnDeedObject;
  141. public event BuyLandHandler OnBuyLand;
  142. public event LinkObjectHandler OnLinkObject;
  143. public event DelinkObjectHandler OnDelinkObject;
  144. public event CreateObjectInventoryHandler OnCreateObjectInventory;
  145. public event CopyObjectInventoryHandler OnCopyObjectInventory;
  146. public event DeleteObjectInventoryHandler OnDeleteObjectInventory;
  147. public event TransferObjectInventoryHandler OnTransferObjectInventory;
  148. public event CreateUserInventoryHandler OnCreateUserInventory;
  149. public event EditUserInventoryHandler OnEditUserInventory;
  150. public event CopyUserInventoryHandler OnCopyUserInventory;
  151. public event DeleteUserInventoryHandler OnDeleteUserInventory;
  152. public event TransferUserInventoryHandler OnTransferUserInventory;
  153. public event TeleportHandler OnTeleport;
  154. public event ControlPrimMediaHandler OnControlPrimMedia;
  155. public event InteractWithPrimMediaHandler OnInteractWithPrimMedia;
  156. #endregion
  157. #region Object Permission Checks
  158. public uint GenerateClientFlags(UUID userID, UUID objectID)
  159. {
  160. // libomv will moan about PrimFlags.ObjectYouOfficer being
  161. // obsolete...
  162. #pragma warning disable 0612
  163. const PrimFlags DEFAULT_FLAGS =
  164. PrimFlags.ObjectModify |
  165. PrimFlags.ObjectCopy |
  166. PrimFlags.ObjectMove |
  167. PrimFlags.ObjectTransfer |
  168. PrimFlags.ObjectYouOwner |
  169. PrimFlags.ObjectAnyOwner |
  170. PrimFlags.ObjectOwnerModify |
  171. PrimFlags.ObjectYouOfficer;
  172. #pragma warning restore 0612
  173. SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
  174. if (part == null)
  175. return 0;
  176. uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS;
  177. GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags;
  178. if (handlerGenerateClientFlags != null)
  179. {
  180. Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
  181. foreach (GenerateClientFlagsHandler check in list)
  182. {
  183. perms &= check(userID, objectID);
  184. }
  185. }
  186. return perms;
  187. }
  188. public void SetBypassPermissions(bool value)
  189. {
  190. SetBypassPermissionsHandler handler = OnSetBypassPermissions;
  191. if (handler != null)
  192. handler(value);
  193. }
  194. public bool BypassPermissions()
  195. {
  196. BypassPermissionsHandler handler = OnBypassPermissions;
  197. if (handler != null)
  198. {
  199. Delegate[] list = handler.GetInvocationList();
  200. foreach (BypassPermissionsHandler h in list)
  201. {
  202. if (h() == false)
  203. return false;
  204. }
  205. }
  206. return true;
  207. }
  208. public bool PropagatePermissions()
  209. {
  210. PropagatePermissionsHandler handler = OnPropagatePermissions;
  211. if (handler != null)
  212. {
  213. Delegate[] list = handler.GetInvocationList();
  214. foreach (PropagatePermissionsHandler h in list)
  215. {
  216. if (h() == false)
  217. return false;
  218. }
  219. }
  220. return true;
  221. }
  222. #region REZ OBJECT
  223. public bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition)
  224. {
  225. RezObjectHandler handler = OnRezObject;
  226. if (handler != null)
  227. {
  228. Delegate[] list = handler.GetInvocationList();
  229. foreach (RezObjectHandler h in list)
  230. {
  231. if (h(objectCount, owner,objectPosition, m_scene) == false)
  232. return false;
  233. }
  234. }
  235. return true;
  236. }
  237. #endregion
  238. #region DELETE OBJECT
  239. public bool CanDeleteObject(UUID objectID, UUID deleter)
  240. {
  241. bool result = true;
  242. DeleteObjectHandler handler = OnDeleteObject;
  243. if (handler != null)
  244. {
  245. Delegate[] list = handler.GetInvocationList();
  246. foreach (DeleteObjectHandler h in list)
  247. {
  248. if (h(objectID, deleter, m_scene) == false)
  249. {
  250. result = false;
  251. break;
  252. }
  253. }
  254. }
  255. return result;
  256. }
  257. public bool CanTransferObject(UUID objectID, UUID recipient)
  258. {
  259. bool result = true;
  260. TransferObjectHandler handler = OnTransferObject;
  261. if (handler != null)
  262. {
  263. Delegate[] list = handler.GetInvocationList();
  264. foreach (TransferObjectHandler h in list)
  265. {
  266. if (h(objectID, recipient, m_scene) == false)
  267. {
  268. result = false;
  269. break;
  270. }
  271. }
  272. }
  273. return result;
  274. }
  275. #endregion
  276. #region TAKE OBJECT
  277. public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID)
  278. {
  279. bool result = true;
  280. TakeObjectHandler handler = OnTakeObject;
  281. if (handler != null)
  282. {
  283. Delegate[] list = handler.GetInvocationList();
  284. foreach (TakeObjectHandler h in list)
  285. {
  286. if (h(objectID, AvatarTakingUUID, m_scene) == false)
  287. {
  288. result = false;
  289. break;
  290. }
  291. }
  292. }
  293. // m_log.DebugFormat(
  294. // "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}",
  295. // objectID, AvatarTakingUUID, result);
  296. return result;
  297. }
  298. #endregion
  299. #region TAKE COPY OBJECT
  300. public bool CanTakeCopyObject(UUID objectID, UUID userID)
  301. {
  302. bool result = true;
  303. TakeCopyObjectHandler handler = OnTakeCopyObject;
  304. if (handler != null)
  305. {
  306. Delegate[] list = handler.GetInvocationList();
  307. foreach (TakeCopyObjectHandler h in list)
  308. {
  309. if (h(objectID, userID, m_scene) == false)
  310. {
  311. result = false;
  312. break;
  313. }
  314. }
  315. }
  316. // m_log.DebugFormat(
  317. // "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}",
  318. // objectID, userID, result);
  319. return result;
  320. }
  321. #endregion
  322. #region DUPLICATE OBJECT
  323. public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition)
  324. {
  325. DuplicateObjectHandler handler = OnDuplicateObject;
  326. if (handler != null)
  327. {
  328. Delegate[] list = handler.GetInvocationList();
  329. foreach (DuplicateObjectHandler h in list)
  330. {
  331. if (h(objectCount, objectID, owner, m_scene, objectPosition) == false)
  332. return false;
  333. }
  334. }
  335. return true;
  336. }
  337. #endregion
  338. #region EDIT OBJECT
  339. public bool CanEditObject(UUID objectID, UUID editorID)
  340. {
  341. EditObjectHandler handler = OnEditObject;
  342. if (handler != null)
  343. {
  344. Delegate[] list = handler.GetInvocationList();
  345. foreach (EditObjectHandler h in list)
  346. {
  347. if (h(objectID, editorID, m_scene) == false)
  348. return false;
  349. }
  350. }
  351. return true;
  352. }
  353. public bool CanEditObjectInventory(UUID objectID, UUID editorID)
  354. {
  355. EditObjectInventoryHandler handler = OnEditObjectInventory;
  356. if (handler != null)
  357. {
  358. Delegate[] list = handler.GetInvocationList();
  359. foreach (EditObjectInventoryHandler h in list)
  360. {
  361. if (h(objectID, editorID, m_scene) == false)
  362. return false;
  363. }
  364. }
  365. return true;
  366. }
  367. #endregion
  368. #region MOVE OBJECT
  369. public bool CanMoveObject(UUID objectID, UUID moverID)
  370. {
  371. MoveObjectHandler handler = OnMoveObject;
  372. if (handler != null)
  373. {
  374. Delegate[] list = handler.GetInvocationList();
  375. foreach (MoveObjectHandler h in list)
  376. {
  377. if (h(objectID, moverID, m_scene) == false)
  378. return false;
  379. }
  380. }
  381. return true;
  382. }
  383. #endregion
  384. #region OBJECT ENTRY
  385. public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint)
  386. {
  387. ObjectEntryHandler handler = OnObjectEntry;
  388. if (handler != null)
  389. {
  390. Delegate[] list = handler.GetInvocationList();
  391. foreach (ObjectEntryHandler h in list)
  392. {
  393. if (h(objectID, enteringRegion, newPoint, m_scene) == false)
  394. return false;
  395. }
  396. }
  397. return true;
  398. }
  399. #endregion
  400. #region RETURN OBJECT
  401. public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects)
  402. {
  403. bool result = true;
  404. ReturnObjectsHandler handler = OnReturnObjects;
  405. if (handler != null)
  406. {
  407. Delegate[] list = handler.GetInvocationList();
  408. foreach (ReturnObjectsHandler h in list)
  409. {
  410. if (h(land, user, objects, m_scene) == false)
  411. {
  412. result = false;
  413. break;
  414. }
  415. }
  416. }
  417. // m_log.DebugFormat(
  418. // "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}",
  419. // user, objects.Count, land.LandData.Name, result);
  420. return result;
  421. }
  422. #endregion
  423. #region INSTANT MESSAGE
  424. public bool CanInstantMessage(UUID user, UUID target)
  425. {
  426. InstantMessageHandler handler = OnInstantMessage;
  427. if (handler != null)
  428. {
  429. Delegate[] list = handler.GetInvocationList();
  430. foreach (InstantMessageHandler h in list)
  431. {
  432. if (h(user, target, m_scene) == false)
  433. return false;
  434. }
  435. }
  436. return true;
  437. }
  438. #endregion
  439. #region INVENTORY TRANSFER
  440. public bool CanInventoryTransfer(UUID user, UUID target)
  441. {
  442. InventoryTransferHandler handler = OnInventoryTransfer;
  443. if (handler != null)
  444. {
  445. Delegate[] list = handler.GetInvocationList();
  446. foreach (InventoryTransferHandler h in list)
  447. {
  448. if (h(user, target, m_scene) == false)
  449. return false;
  450. }
  451. }
  452. return true;
  453. }
  454. #endregion
  455. #region VIEW SCRIPT
  456. public bool CanViewScript(UUID script, UUID objectID, UUID user)
  457. {
  458. ViewScriptHandler handler = OnViewScript;
  459. if (handler != null)
  460. {
  461. Delegate[] list = handler.GetInvocationList();
  462. foreach (ViewScriptHandler h in list)
  463. {
  464. if (h(script, objectID, user, m_scene) == false)
  465. return false;
  466. }
  467. }
  468. return true;
  469. }
  470. public bool CanViewNotecard(UUID script, UUID objectID, UUID user)
  471. {
  472. ViewNotecardHandler handler = OnViewNotecard;
  473. if (handler != null)
  474. {
  475. Delegate[] list = handler.GetInvocationList();
  476. foreach (ViewNotecardHandler h in list)
  477. {
  478. if (h(script, objectID, user, m_scene) == false)
  479. return false;
  480. }
  481. }
  482. return true;
  483. }
  484. #endregion
  485. #region EDIT SCRIPT
  486. public bool CanEditScript(UUID script, UUID objectID, UUID user)
  487. {
  488. EditScriptHandler handler = OnEditScript;
  489. if (handler != null)
  490. {
  491. Delegate[] list = handler.GetInvocationList();
  492. foreach (EditScriptHandler h in list)
  493. {
  494. if (h(script, objectID, user, m_scene) == false)
  495. return false;
  496. }
  497. }
  498. return true;
  499. }
  500. public bool CanEditNotecard(UUID script, UUID objectID, UUID user)
  501. {
  502. EditNotecardHandler handler = OnEditNotecard;
  503. if (handler != null)
  504. {
  505. Delegate[] list = handler.GetInvocationList();
  506. foreach (EditNotecardHandler h in list)
  507. {
  508. if (h(script, objectID, user, m_scene) == false)
  509. return false;
  510. }
  511. }
  512. return true;
  513. }
  514. #endregion
  515. #region RUN SCRIPT (When Script Placed in Object)
  516. public bool CanRunScript(UUID script, UUID objectID, UUID user)
  517. {
  518. RunScriptHandler handler = OnRunScript;
  519. if (handler != null)
  520. {
  521. Delegate[] list = handler.GetInvocationList();
  522. foreach (RunScriptHandler h in list)
  523. {
  524. if (h(script, objectID, user, m_scene) == false)
  525. return false;
  526. }
  527. }
  528. return true;
  529. }
  530. #endregion
  531. #region COMPILE SCRIPT (When Script needs to get (re)compiled)
  532. public bool CanCompileScript(UUID ownerUUID, int scriptType)
  533. {
  534. CompileScriptHandler handler = OnCompileScript;
  535. if (handler != null)
  536. {
  537. Delegate[] list = handler.GetInvocationList();
  538. foreach (CompileScriptHandler h in list)
  539. {
  540. if (h(ownerUUID, scriptType, m_scene) == false)
  541. return false;
  542. }
  543. }
  544. return true;
  545. }
  546. #endregion
  547. #region START SCRIPT (When Script run box is Checked after placed in object)
  548. public bool CanStartScript(UUID script, UUID user)
  549. {
  550. StartScriptHandler handler = OnStartScript;
  551. if (handler != null)
  552. {
  553. Delegate[] list = handler.GetInvocationList();
  554. foreach (StartScriptHandler h in list)
  555. {
  556. if (h(script, user, m_scene) == false)
  557. return false;
  558. }
  559. }
  560. return true;
  561. }
  562. #endregion
  563. #region STOP SCRIPT (When Script run box is unchecked after placed in object)
  564. public bool CanStopScript(UUID script, UUID user)
  565. {
  566. StopScriptHandler handler = OnStopScript;
  567. if (handler != null)
  568. {
  569. Delegate[] list = handler.GetInvocationList();
  570. foreach (StopScriptHandler h in list)
  571. {
  572. if (h(script, user, m_scene) == false)
  573. return false;
  574. }
  575. }
  576. return true;
  577. }
  578. #endregion
  579. #region RESET SCRIPT
  580. public bool CanResetScript(UUID prim, UUID script, UUID user)
  581. {
  582. ResetScriptHandler handler = OnResetScript;
  583. if (handler != null)
  584. {
  585. Delegate[] list = handler.GetInvocationList();
  586. foreach (ResetScriptHandler h in list)
  587. {
  588. if (h(prim, script, user, m_scene) == false)
  589. return false;
  590. }
  591. }
  592. return true;
  593. }
  594. #endregion
  595. #region TERRAFORM LAND
  596. public bool CanTerraformLand(UUID user, Vector3 pos)
  597. {
  598. TerraformLandHandler handler = OnTerraformLand;
  599. if (handler != null)
  600. {
  601. Delegate[] list = handler.GetInvocationList();
  602. foreach (TerraformLandHandler h in list)
  603. {
  604. if (h(user, pos, m_scene) == false)
  605. return false;
  606. }
  607. }
  608. return true;
  609. }
  610. #endregion
  611. #region RUN CONSOLE COMMAND
  612. public bool CanRunConsoleCommand(UUID user)
  613. {
  614. RunConsoleCommandHandler handler = OnRunConsoleCommand;
  615. if (handler != null)
  616. {
  617. Delegate[] list = handler.GetInvocationList();
  618. foreach (RunConsoleCommandHandler h in list)
  619. {
  620. if (h(user, m_scene) == false)
  621. return false;
  622. }
  623. }
  624. return true;
  625. }
  626. #endregion
  627. #region CAN ISSUE ESTATE COMMAND
  628. public bool CanIssueEstateCommand(UUID user, bool ownerCommand)
  629. {
  630. IssueEstateCommandHandler handler = OnIssueEstateCommand;
  631. if (handler != null)
  632. {
  633. Delegate[] list = handler.GetInvocationList();
  634. foreach (IssueEstateCommandHandler h in list)
  635. {
  636. if (h(user, m_scene, ownerCommand) == false)
  637. return false;
  638. }
  639. }
  640. return true;
  641. }
  642. #endregion
  643. #region CAN BE GODLIKE
  644. public bool IsGod(UUID user)
  645. {
  646. IsGodHandler handler = OnIsGod;
  647. if (handler != null)
  648. {
  649. Delegate[] list = handler.GetInvocationList();
  650. foreach (IsGodHandler h in list)
  651. {
  652. if (h(user, m_scene) == false)
  653. return false;
  654. }
  655. }
  656. return true;
  657. }
  658. public bool IsGridGod(UUID user)
  659. {
  660. IsGridGodHandler handler = OnIsGridGod;
  661. if (handler != null)
  662. {
  663. Delegate[] list = handler.GetInvocationList();
  664. foreach (IsGridGodHandler h in list)
  665. {
  666. if (h(user, m_scene) == false)
  667. return false;
  668. }
  669. }
  670. return true;
  671. }
  672. public bool IsAdministrator(UUID user)
  673. {
  674. IsAdministratorHandler handler = OnIsAdministrator;
  675. if (handler != null)
  676. {
  677. Delegate[] list = handler.GetInvocationList();
  678. foreach (IsAdministratorHandler h in list)
  679. {
  680. if (h(user) == false)
  681. return false;
  682. }
  683. }
  684. return true;
  685. }
  686. #endregion
  687. #region EDIT PARCEL
  688. public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p)
  689. {
  690. EditParcelPropertiesHandler handler = OnEditParcelProperties;
  691. if (handler != null)
  692. {
  693. Delegate[] list = handler.GetInvocationList();
  694. foreach (EditParcelPropertiesHandler h in list)
  695. {
  696. if (h(user, parcel, p, m_scene) == false)
  697. return false;
  698. }
  699. }
  700. return true;
  701. }
  702. #endregion
  703. #region SELL PARCEL
  704. public bool CanSellParcel(UUID user, ILandObject parcel)
  705. {
  706. SellParcelHandler handler = OnSellParcel;
  707. if (handler != null)
  708. {
  709. Delegate[] list = handler.GetInvocationList();
  710. foreach (SellParcelHandler h in list)
  711. {
  712. if (h(user, parcel, m_scene) == false)
  713. return false;
  714. }
  715. }
  716. return true;
  717. }
  718. #endregion
  719. #region ABANDON PARCEL
  720. public bool CanAbandonParcel(UUID user, ILandObject parcel)
  721. {
  722. AbandonParcelHandler handler = OnAbandonParcel;
  723. if (handler != null)
  724. {
  725. Delegate[] list = handler.GetInvocationList();
  726. foreach (AbandonParcelHandler h in list)
  727. {
  728. if (h(user, parcel, m_scene) == false)
  729. return false;
  730. }
  731. }
  732. return true;
  733. }
  734. #endregion
  735. public bool CanReclaimParcel(UUID user, ILandObject parcel)
  736. {
  737. ReclaimParcelHandler handler = OnReclaimParcel;
  738. if (handler != null)
  739. {
  740. Delegate[] list = handler.GetInvocationList();
  741. foreach (ReclaimParcelHandler h in list)
  742. {
  743. if (h(user, parcel, m_scene) == false)
  744. return false;
  745. }
  746. }
  747. return true;
  748. }
  749. public bool CanDeedParcel(UUID user, ILandObject parcel)
  750. {
  751. DeedParcelHandler handler = OnDeedParcel;
  752. if (handler != null)
  753. {
  754. Delegate[] list = handler.GetInvocationList();
  755. foreach (DeedParcelHandler h in list)
  756. {
  757. if (h(user, parcel, m_scene) == false)
  758. return false;
  759. }
  760. }
  761. return true;
  762. }
  763. public bool CanDeedObject(UUID user, UUID group)
  764. {
  765. DeedObjectHandler handler = OnDeedObject;
  766. if (handler != null)
  767. {
  768. Delegate[] list = handler.GetInvocationList();
  769. foreach (DeedObjectHandler h in list)
  770. {
  771. if (h(user, group, m_scene) == false)
  772. return false;
  773. }
  774. }
  775. return true;
  776. }
  777. public bool CanBuyLand(UUID user, ILandObject parcel)
  778. {
  779. BuyLandHandler handler = OnBuyLand;
  780. if (handler != null)
  781. {
  782. Delegate[] list = handler.GetInvocationList();
  783. foreach (BuyLandHandler h in list)
  784. {
  785. if (h(user, parcel, m_scene) == false)
  786. return false;
  787. }
  788. }
  789. return true;
  790. }
  791. public bool CanLinkObject(UUID user, UUID objectID)
  792. {
  793. LinkObjectHandler handler = OnLinkObject;
  794. if (handler != null)
  795. {
  796. Delegate[] list = handler.GetInvocationList();
  797. foreach (LinkObjectHandler h in list)
  798. {
  799. if (h(user, objectID) == false)
  800. return false;
  801. }
  802. }
  803. return true;
  804. }
  805. public bool CanDelinkObject(UUID user, UUID objectID)
  806. {
  807. DelinkObjectHandler handler = OnDelinkObject;
  808. if (handler != null)
  809. {
  810. Delegate[] list = handler.GetInvocationList();
  811. foreach (DelinkObjectHandler h in list)
  812. {
  813. if (h(user, objectID) == false)
  814. return false;
  815. }
  816. }
  817. return true;
  818. }
  819. #endregion
  820. /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
  821. /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
  822. /// </summary>
  823. /// <param name="invType"></param>
  824. /// <param name="objectID"></param>
  825. /// <param name="userID"></param>
  826. /// <returns></returns>
  827. public bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
  828. {
  829. CreateObjectInventoryHandler handler = OnCreateObjectInventory;
  830. if (handler != null)
  831. {
  832. Delegate[] list = handler.GetInvocationList();
  833. foreach (CreateObjectInventoryHandler h in list)
  834. {
  835. if (h(invType, objectID, userID) == false)
  836. return false;
  837. }
  838. }
  839. return true;
  840. }
  841. public bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
  842. {
  843. CopyObjectInventoryHandler handler = OnCopyObjectInventory;
  844. if (handler != null)
  845. {
  846. Delegate[] list = handler.GetInvocationList();
  847. foreach (CopyObjectInventoryHandler h in list)
  848. {
  849. if (h(itemID, objectID, userID) == false)
  850. return false;
  851. }
  852. }
  853. return true;
  854. }
  855. public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
  856. {
  857. DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;
  858. if (handler != null)
  859. {
  860. Delegate[] list = handler.GetInvocationList();
  861. foreach (DeleteObjectInventoryHandler h in list)
  862. {
  863. if (h(itemID, objectID, userID) == false)
  864. return false;
  865. }
  866. }
  867. return true;
  868. }
  869. public bool CanTransferObjectInventory(UUID itemID, UUID objectID, UUID userID)
  870. {
  871. TransferObjectInventoryHandler handler = OnTransferObjectInventory;
  872. if (handler != null)
  873. {
  874. Delegate[] list = handler.GetInvocationList();
  875. foreach (TransferObjectInventoryHandler h in list)
  876. {
  877. if (h(itemID, objectID, userID) == false)
  878. return false;
  879. }
  880. }
  881. return true;
  882. }
  883. /// <summary>
  884. /// Check whether the specified user is allowed to create the given inventory type in their inventory.
  885. /// </summary>
  886. /// <param name="invType"></param>
  887. /// <param name="userID"></param>
  888. /// <returns></returns>
  889. public bool CanCreateUserInventory(int invType, UUID userID)
  890. {
  891. CreateUserInventoryHandler handler = OnCreateUserInventory;
  892. if (handler != null)
  893. {
  894. Delegate[] list = handler.GetInvocationList();
  895. foreach (CreateUserInventoryHandler h in list)
  896. {
  897. if (h(invType, userID) == false)
  898. return false;
  899. }
  900. }
  901. return true;
  902. }
  903. /// <summary>
  904. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  905. /// </summary>
  906. /// <param name="itemID"></param>
  907. /// <param name="userID"></param>
  908. /// <returns></returns>
  909. public bool CanEditUserInventory(UUID itemID, UUID userID)
  910. {
  911. EditUserInventoryHandler handler = OnEditUserInventory;
  912. if (handler != null)
  913. {
  914. Delegate[] list = handler.GetInvocationList();
  915. foreach (EditUserInventoryHandler h in list)
  916. {
  917. if (h(itemID, userID) == false)
  918. return false;
  919. }
  920. }
  921. return true;
  922. }
  923. /// <summary>
  924. /// Check whether the specified user is allowed to copy the given inventory item from their own inventory.
  925. /// </summary>
  926. /// <param name="itemID"></param>
  927. /// <param name="userID"></param>
  928. /// <returns></returns>
  929. public bool CanCopyUserInventory(UUID itemID, UUID userID)
  930. {
  931. CopyUserInventoryHandler handler = OnCopyUserInventory;
  932. if (handler != null)
  933. {
  934. Delegate[] list = handler.GetInvocationList();
  935. foreach (CopyUserInventoryHandler h in list)
  936. {
  937. if (h(itemID, userID) == false)
  938. return false;
  939. }
  940. }
  941. return true;
  942. }
  943. /// <summary>
  944. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  945. /// </summary>
  946. /// <param name="itemID"></param>
  947. /// <param name="userID"></param>
  948. /// <returns></returns>
  949. public bool CanDeleteUserInventory(UUID itemID, UUID userID)
  950. {
  951. DeleteUserInventoryHandler handler = OnDeleteUserInventory;
  952. if (handler != null)
  953. {
  954. Delegate[] list = handler.GetInvocationList();
  955. foreach (DeleteUserInventoryHandler h in list)
  956. {
  957. if (h(itemID, userID) == false)
  958. return false;
  959. }
  960. }
  961. return true;
  962. }
  963. public bool CanTransferUserInventory(UUID itemID, UUID userID, UUID recipientID)
  964. {
  965. TransferUserInventoryHandler handler = OnTransferUserInventory;
  966. if (handler != null)
  967. {
  968. Delegate[] list = handler.GetInvocationList();
  969. foreach (TransferUserInventoryHandler h in list)
  970. {
  971. if (h(itemID, userID, recipientID) == false)
  972. return false;
  973. }
  974. }
  975. return true;
  976. }
  977. public bool CanTeleport(UUID userID)
  978. {
  979. TeleportHandler handler = OnTeleport;
  980. if (handler != null)
  981. {
  982. Delegate[] list = handler.GetInvocationList();
  983. foreach (TeleportHandler h in list)
  984. {
  985. if (h(userID, m_scene) == false)
  986. return false;
  987. }
  988. }
  989. return true;
  990. }
  991. public bool CanControlPrimMedia(UUID userID, UUID primID, int face)
  992. {
  993. ControlPrimMediaHandler handler = OnControlPrimMedia;
  994. if (handler != null)
  995. {
  996. Delegate[] list = handler.GetInvocationList();
  997. foreach (ControlPrimMediaHandler h in list)
  998. {
  999. if (h(userID, primID, face) == false)
  1000. return false;
  1001. }
  1002. }
  1003. return true;
  1004. }
  1005. public bool CanInteractWithPrimMedia(UUID userID, UUID primID, int face)
  1006. {
  1007. InteractWithPrimMediaHandler handler = OnInteractWithPrimMedia;
  1008. if (handler != null)
  1009. {
  1010. Delegate[] list = handler.GetInvocationList();
  1011. foreach (InteractWithPrimMediaHandler h in list)
  1012. {
  1013. if (h(userID, primID, face) == false)
  1014. return false;
  1015. }
  1016. }
  1017. return true;
  1018. }
  1019. }
  1020. }