Scene.Permissions.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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.Text;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Region.Framework.Interfaces;
  33. namespace OpenSim.Region.Framework.Scenes
  34. {
  35. #region Delegates
  36. public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID);
  37. public delegate void SetBypassPermissionsHandler(bool value);
  38. public delegate bool BypassPermissionsHandler();
  39. public delegate bool PropagatePermissionsHandler();
  40. public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
  41. public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene);
  42. public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene);
  43. public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene);
  44. public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
  45. public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene);
  46. public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
  47. public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
  48. public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
  49. public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene);
  50. public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
  51. public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene);
  52. public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  53. public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene);
  54. public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  55. public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene);
  56. public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  57. public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene);
  58. public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene);
  59. public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene);
  60. public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene);
  61. public delegate bool TerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene);
  62. public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
  63. public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
  64. public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
  65. public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
  66. public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene);
  67. public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
  68. public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene);
  69. public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene);
  70. public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene);
  71. public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene);
  72. public delegate bool LinkObjectHandler(UUID user, UUID objectID);
  73. public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
  74. public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
  75. public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  76. public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  77. public delegate bool CreateUserInventoryHandler(int invType, UUID userID);
  78. public delegate bool EditUserInventoryHandler(UUID itemID, UUID userID);
  79. public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID);
  80. public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
  81. public delegate bool TeleportHandler(UUID userID, Scene scene);
  82. public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene);
  83. #endregion
  84. public class ScenePermissions
  85. {
  86. private Scene m_scene;
  87. public ScenePermissions(Scene scene)
  88. {
  89. m_scene = scene;
  90. }
  91. #region Events
  92. public event GenerateClientFlagsHandler OnGenerateClientFlags;
  93. public event SetBypassPermissionsHandler OnSetBypassPermissions;
  94. public event BypassPermissionsHandler OnBypassPermissions;
  95. public event PropagatePermissionsHandler OnPropagatePermissions;
  96. public event RezObjectHandler OnRezObject;
  97. public event DeleteObjectHandler OnDeleteObject;
  98. public event TakeObjectHandler OnTakeObject;
  99. public event TakeCopyObjectHandler OnTakeCopyObject;
  100. public event DuplicateObjectHandler OnDuplicateObject;
  101. public event EditObjectHandler OnEditObject;
  102. public event EditObjectInventoryHandler OnEditObjectInventory;
  103. public event MoveObjectHandler OnMoveObject;
  104. public event ObjectEntryHandler OnObjectEntry;
  105. public event ReturnObjectHandler OnReturnObject;
  106. public event InstantMessageHandler OnInstantMessage;
  107. public event InventoryTransferHandler OnInventoryTransfer;
  108. public event ViewScriptHandler OnViewScript;
  109. public event ViewNotecardHandler OnViewNotecard;
  110. public event EditScriptHandler OnEditScript;
  111. public event EditNotecardHandler OnEditNotecard;
  112. public event RunScriptHandler OnRunScript;
  113. public event CompileScriptHandler OnCompileScript;
  114. public event StartScriptHandler OnStartScript;
  115. public event StopScriptHandler OnStopScript;
  116. public event ResetScriptHandler OnResetScript;
  117. public event TerraformLandHandler OnTerraformLand;
  118. public event RunConsoleCommandHandler OnRunConsoleCommand;
  119. public event IssueEstateCommandHandler OnIssueEstateCommand;
  120. public event IsGodHandler OnIsGod;
  121. public event EditParcelHandler OnEditParcel;
  122. public event SellParcelHandler OnSellParcel;
  123. public event AbandonParcelHandler OnAbandonParcel;
  124. public event ReclaimParcelHandler OnReclaimParcel;
  125. public event DeedParcelHandler OnDeedParcel;
  126. public event DeedObjectHandler OnDeedObject;
  127. public event BuyLandHandler OnBuyLand;
  128. public event LinkObjectHandler OnLinkObject;
  129. public event DelinkObjectHandler OnDelinkObject;
  130. public event CreateObjectInventoryHandler OnCreateObjectInventory;
  131. public event CopyObjectInventoryHandler OnCopyObjectInventory;
  132. public event DeleteObjectInventoryHandler OnDeleteObjectInventory;
  133. public event CreateUserInventoryHandler OnCreateUserInventory;
  134. public event EditUserInventoryHandler OnEditUserInventory;
  135. public event CopyUserInventoryHandler OnCopyUserInventory;
  136. public event DeleteUserInventoryHandler OnDeleteUserInventory;
  137. public event TeleportHandler OnTeleport;
  138. public event UseObjectReturnHandler OnUseObjectReturn;
  139. #endregion
  140. #region Object Permission Checks
  141. public uint GenerateClientFlags(UUID userID, UUID objectID)
  142. {
  143. SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);
  144. if (part == null)
  145. return 0;
  146. // libomv will moan about PrimFlags.ObjectYouOfficer being
  147. // obsolete...
  148. #pragma warning disable 0612
  149. uint perms=part.GetEffectiveObjectFlags() |
  150. (uint)PrimFlags.ObjectModify |
  151. (uint)PrimFlags.ObjectCopy |
  152. (uint)PrimFlags.ObjectMove |
  153. (uint)PrimFlags.ObjectTransfer |
  154. (uint)PrimFlags.ObjectYouOwner |
  155. (uint)PrimFlags.ObjectAnyOwner |
  156. (uint)PrimFlags.ObjectOwnerModify |
  157. (uint)PrimFlags.ObjectYouOfficer;
  158. #pragma warning restore 0612
  159. GenerateClientFlagsHandler handlerGenerateClientFlags =
  160. OnGenerateClientFlags;
  161. if (handlerGenerateClientFlags != null)
  162. {
  163. Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
  164. foreach (GenerateClientFlagsHandler check in list)
  165. {
  166. perms &= check(userID, objectID);
  167. }
  168. }
  169. return perms;
  170. }
  171. public void SetBypassPermissions(bool value)
  172. {
  173. SetBypassPermissionsHandler handler = OnSetBypassPermissions;
  174. if (handler != null)
  175. handler(value);
  176. }
  177. public bool BypassPermissions()
  178. {
  179. BypassPermissionsHandler handler = OnBypassPermissions;
  180. if (handler != null)
  181. {
  182. Delegate[] list = handler.GetInvocationList();
  183. foreach (BypassPermissionsHandler h in list)
  184. {
  185. if (h() == false)
  186. return false;
  187. }
  188. }
  189. return true;
  190. }
  191. public bool PropagatePermissions()
  192. {
  193. PropagatePermissionsHandler handler = OnPropagatePermissions;
  194. if (handler != null)
  195. {
  196. Delegate[] list = handler.GetInvocationList();
  197. foreach (PropagatePermissionsHandler h in list)
  198. {
  199. if (h() == false)
  200. return false;
  201. }
  202. }
  203. return true;
  204. }
  205. #region REZ OBJECT
  206. public bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition)
  207. {
  208. RezObjectHandler handler = OnRezObject;
  209. if (handler != null)
  210. {
  211. Delegate[] list = handler.GetInvocationList();
  212. foreach (RezObjectHandler h in list)
  213. {
  214. if (h(objectCount, owner,objectPosition, m_scene) == false)
  215. return false;
  216. }
  217. }
  218. return true;
  219. }
  220. #endregion
  221. #region DELETE OBJECT
  222. public bool CanDeleteObject(UUID objectID, UUID deleter)
  223. {
  224. DeleteObjectHandler handler = OnDeleteObject;
  225. if (handler != null)
  226. {
  227. Delegate[] list = handler.GetInvocationList();
  228. foreach (DeleteObjectHandler h in list)
  229. {
  230. if (h(objectID, deleter, m_scene) == false)
  231. return false;
  232. }
  233. }
  234. return true;
  235. }
  236. #endregion
  237. #region TAKE OBJECT
  238. public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID)
  239. {
  240. TakeObjectHandler handler = OnTakeObject;
  241. if (handler != null)
  242. {
  243. Delegate[] list = handler.GetInvocationList();
  244. foreach (TakeObjectHandler h in list)
  245. {
  246. if (h(objectID, AvatarTakingUUID, m_scene) == false)
  247. return false;
  248. }
  249. }
  250. return true;
  251. }
  252. #endregion
  253. #region TAKE COPY OBJECT
  254. public bool CanTakeCopyObject(UUID objectID, UUID userID)
  255. {
  256. TakeCopyObjectHandler handler = OnTakeCopyObject;
  257. if (handler != null)
  258. {
  259. Delegate[] list = handler.GetInvocationList();
  260. foreach (TakeCopyObjectHandler h in list)
  261. {
  262. if (h(objectID, userID, m_scene) == false)
  263. return false;
  264. }
  265. }
  266. return true;
  267. }
  268. #endregion
  269. #region DUPLICATE OBJECT
  270. public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition)
  271. {
  272. DuplicateObjectHandler handler = OnDuplicateObject;
  273. if (handler != null)
  274. {
  275. Delegate[] list = handler.GetInvocationList();
  276. foreach (DuplicateObjectHandler h in list)
  277. {
  278. if (h(objectCount, objectID, owner, m_scene, objectPosition) == false)
  279. return false;
  280. }
  281. }
  282. return true;
  283. }
  284. #endregion
  285. #region EDIT OBJECT
  286. public bool CanEditObject(UUID objectID, UUID editorID)
  287. {
  288. EditObjectHandler handler = OnEditObject;
  289. if (handler != null)
  290. {
  291. Delegate[] list = handler.GetInvocationList();
  292. foreach (EditObjectHandler h in list)
  293. {
  294. if (h(objectID, editorID, m_scene) == false)
  295. return false;
  296. }
  297. }
  298. return true;
  299. }
  300. public bool CanEditObjectInventory(UUID objectID, UUID editorID)
  301. {
  302. EditObjectInventoryHandler handler = OnEditObjectInventory;
  303. if (handler != null)
  304. {
  305. Delegate[] list = handler.GetInvocationList();
  306. foreach (EditObjectInventoryHandler h in list)
  307. {
  308. if (h(objectID, editorID, m_scene) == false)
  309. return false;
  310. }
  311. }
  312. return true;
  313. }
  314. #endregion
  315. #region MOVE OBJECT
  316. public bool CanMoveObject(UUID objectID, UUID moverID)
  317. {
  318. MoveObjectHandler handler = OnMoveObject;
  319. if (handler != null)
  320. {
  321. Delegate[] list = handler.GetInvocationList();
  322. foreach (MoveObjectHandler h in list)
  323. {
  324. if (h(objectID, moverID, m_scene) == false)
  325. return false;
  326. }
  327. }
  328. return true;
  329. }
  330. #endregion
  331. #region OBJECT ENTRY
  332. public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint)
  333. {
  334. ObjectEntryHandler handler = OnObjectEntry;
  335. if (handler != null)
  336. {
  337. Delegate[] list = handler.GetInvocationList();
  338. foreach (ObjectEntryHandler h in list)
  339. {
  340. if (h(objectID, enteringRegion, newPoint, m_scene) == false)
  341. return false;
  342. }
  343. }
  344. return true;
  345. }
  346. #endregion
  347. #region RETURN OBJECT
  348. public bool CanReturnObject(UUID objectID, UUID returnerID)
  349. {
  350. ReturnObjectHandler handler = OnReturnObject;
  351. if (handler != null)
  352. {
  353. Delegate[] list = handler.GetInvocationList();
  354. foreach (ReturnObjectHandler h in list)
  355. {
  356. if (h(objectID, returnerID, m_scene) == false)
  357. return false;
  358. }
  359. }
  360. return true;
  361. }
  362. #endregion
  363. #region INSTANT MESSAGE
  364. public bool CanInstantMessage(UUID user, UUID target)
  365. {
  366. InstantMessageHandler handler = OnInstantMessage;
  367. if (handler != null)
  368. {
  369. Delegate[] list = handler.GetInvocationList();
  370. foreach (InstantMessageHandler h in list)
  371. {
  372. if (h(user, target, m_scene) == false)
  373. return false;
  374. }
  375. }
  376. return true;
  377. }
  378. #endregion
  379. #region INVENTORY TRANSFER
  380. public bool CanInventoryTransfer(UUID user, UUID target)
  381. {
  382. InventoryTransferHandler handler = OnInventoryTransfer;
  383. if (handler != null)
  384. {
  385. Delegate[] list = handler.GetInvocationList();
  386. foreach (InventoryTransferHandler h in list)
  387. {
  388. if (h(user, target, m_scene) == false)
  389. return false;
  390. }
  391. }
  392. return true;
  393. }
  394. #endregion
  395. #region VIEW SCRIPT
  396. public bool CanViewScript(UUID script, UUID objectID, UUID user)
  397. {
  398. ViewScriptHandler handler = OnViewScript;
  399. if (handler != null)
  400. {
  401. Delegate[] list = handler.GetInvocationList();
  402. foreach (ViewScriptHandler h in list)
  403. {
  404. if (h(script, objectID, user, m_scene) == false)
  405. return false;
  406. }
  407. }
  408. return true;
  409. }
  410. public bool CanViewNotecard(UUID script, UUID objectID, UUID user)
  411. {
  412. ViewNotecardHandler handler = OnViewNotecard;
  413. if (handler != null)
  414. {
  415. Delegate[] list = handler.GetInvocationList();
  416. foreach (ViewNotecardHandler h in list)
  417. {
  418. if (h(script, objectID, user, m_scene) == false)
  419. return false;
  420. }
  421. }
  422. return true;
  423. }
  424. #endregion
  425. #region EDIT SCRIPT
  426. public bool CanEditScript(UUID script, UUID objectID, UUID user)
  427. {
  428. EditScriptHandler handler = OnEditScript;
  429. if (handler != null)
  430. {
  431. Delegate[] list = handler.GetInvocationList();
  432. foreach (EditScriptHandler h in list)
  433. {
  434. if (h(script, objectID, user, m_scene) == false)
  435. return false;
  436. }
  437. }
  438. return true;
  439. }
  440. public bool CanEditNotecard(UUID script, UUID objectID, UUID user)
  441. {
  442. EditNotecardHandler handler = OnEditNotecard;
  443. if (handler != null)
  444. {
  445. Delegate[] list = handler.GetInvocationList();
  446. foreach (EditNotecardHandler h in list)
  447. {
  448. if (h(script, objectID, user, m_scene) == false)
  449. return false;
  450. }
  451. }
  452. return true;
  453. }
  454. #endregion
  455. #region RUN SCRIPT (When Script Placed in Object)
  456. public bool CanRunScript(UUID script, UUID objectID, UUID user)
  457. {
  458. RunScriptHandler handler = OnRunScript;
  459. if (handler != null)
  460. {
  461. Delegate[] list = handler.GetInvocationList();
  462. foreach (RunScriptHandler h in list)
  463. {
  464. if (h(script, objectID, user, m_scene) == false)
  465. return false;
  466. }
  467. }
  468. return true;
  469. }
  470. #endregion
  471. #region COMPILE SCRIPT (When Script needs to get (re)compiled)
  472. public bool CanCompileScript(UUID ownerUUID, int scriptType)
  473. {
  474. CompileScriptHandler handler = OnCompileScript;
  475. if (handler != null)
  476. {
  477. Delegate[] list = handler.GetInvocationList();
  478. foreach (CompileScriptHandler h in list)
  479. {
  480. if (h(ownerUUID, scriptType, m_scene) == false)
  481. return false;
  482. }
  483. }
  484. return true;
  485. }
  486. #endregion
  487. #region START SCRIPT (When Script run box is Checked after placed in object)
  488. public bool CanStartScript(UUID script, UUID user)
  489. {
  490. StartScriptHandler handler = OnStartScript;
  491. if (handler != null)
  492. {
  493. Delegate[] list = handler.GetInvocationList();
  494. foreach (StartScriptHandler h in list)
  495. {
  496. if (h(script, user, m_scene) == false)
  497. return false;
  498. }
  499. }
  500. return true;
  501. }
  502. #endregion
  503. #region STOP SCRIPT (When Script run box is unchecked after placed in object)
  504. public bool CanStopScript(UUID script, UUID user)
  505. {
  506. StopScriptHandler handler = OnStopScript;
  507. if (handler != null)
  508. {
  509. Delegate[] list = handler.GetInvocationList();
  510. foreach (StopScriptHandler h in list)
  511. {
  512. if (h(script, user, m_scene) == false)
  513. return false;
  514. }
  515. }
  516. return true;
  517. }
  518. #endregion
  519. #region RESET SCRIPT
  520. public bool CanResetScript(UUID prim, UUID script, UUID user)
  521. {
  522. ResetScriptHandler handler = OnResetScript;
  523. if (handler != null)
  524. {
  525. Delegate[] list = handler.GetInvocationList();
  526. foreach (ResetScriptHandler h in list)
  527. {
  528. if (h(prim, script, user, m_scene) == false)
  529. return false;
  530. }
  531. }
  532. return true;
  533. }
  534. #endregion
  535. #region TERRAFORM LAND
  536. public bool CanTerraformLand(UUID user, Vector3 pos)
  537. {
  538. TerraformLandHandler handler = OnTerraformLand;
  539. if (handler != null)
  540. {
  541. Delegate[] list = handler.GetInvocationList();
  542. foreach (TerraformLandHandler h in list)
  543. {
  544. if (h(user, pos, m_scene) == false)
  545. return false;
  546. }
  547. }
  548. return true;
  549. }
  550. #endregion
  551. #region RUN CONSOLE COMMAND
  552. public bool CanRunConsoleCommand(UUID user)
  553. {
  554. RunConsoleCommandHandler handler = OnRunConsoleCommand;
  555. if (handler != null)
  556. {
  557. Delegate[] list = handler.GetInvocationList();
  558. foreach (RunConsoleCommandHandler h in list)
  559. {
  560. if (h(user, m_scene) == false)
  561. return false;
  562. }
  563. }
  564. return true;
  565. }
  566. #endregion
  567. #region CAN ISSUE ESTATE COMMAND
  568. public bool CanIssueEstateCommand(UUID user, bool ownerCommand)
  569. {
  570. IssueEstateCommandHandler handler = OnIssueEstateCommand;
  571. if (handler != null)
  572. {
  573. Delegate[] list = handler.GetInvocationList();
  574. foreach (IssueEstateCommandHandler h in list)
  575. {
  576. if (h(user, m_scene, ownerCommand) == false)
  577. return false;
  578. }
  579. }
  580. return true;
  581. }
  582. #endregion
  583. #region CAN BE GODLIKE
  584. public bool IsGod(UUID user)
  585. {
  586. IsGodHandler handler = OnIsGod;
  587. if (handler != null)
  588. {
  589. Delegate[] list = handler.GetInvocationList();
  590. foreach (IsGodHandler h in list)
  591. {
  592. if (h(user, m_scene) == false)
  593. return false;
  594. }
  595. }
  596. return true;
  597. }
  598. #endregion
  599. #region EDIT PARCEL
  600. public bool CanEditParcel(UUID user, ILandObject parcel)
  601. {
  602. EditParcelHandler handler = OnEditParcel;
  603. if (handler != null)
  604. {
  605. Delegate[] list = handler.GetInvocationList();
  606. foreach (EditParcelHandler h in list)
  607. {
  608. if (h(user, parcel, m_scene) == false)
  609. return false;
  610. }
  611. }
  612. return true;
  613. }
  614. #endregion
  615. #region SELL PARCEL
  616. public bool CanSellParcel(UUID user, ILandObject parcel)
  617. {
  618. SellParcelHandler handler = OnSellParcel;
  619. if (handler != null)
  620. {
  621. Delegate[] list = handler.GetInvocationList();
  622. foreach (SellParcelHandler h in list)
  623. {
  624. if (h(user, parcel, m_scene) == false)
  625. return false;
  626. }
  627. }
  628. return true;
  629. }
  630. #endregion
  631. #region ABANDON PARCEL
  632. public bool CanAbandonParcel(UUID user, ILandObject parcel)
  633. {
  634. AbandonParcelHandler handler = OnAbandonParcel;
  635. if (handler != null)
  636. {
  637. Delegate[] list = handler.GetInvocationList();
  638. foreach (AbandonParcelHandler h in list)
  639. {
  640. if (h(user, parcel, m_scene) == false)
  641. return false;
  642. }
  643. }
  644. return true;
  645. }
  646. #endregion
  647. public bool CanReclaimParcel(UUID user, ILandObject parcel)
  648. {
  649. ReclaimParcelHandler handler = OnReclaimParcel;
  650. if (handler != null)
  651. {
  652. Delegate[] list = handler.GetInvocationList();
  653. foreach (ReclaimParcelHandler h in list)
  654. {
  655. if (h(user, parcel, m_scene) == false)
  656. return false;
  657. }
  658. }
  659. return true;
  660. }
  661. public bool CanDeedParcel(UUID user, ILandObject parcel)
  662. {
  663. DeedParcelHandler handler = OnDeedParcel;
  664. if (handler != null)
  665. {
  666. Delegate[] list = handler.GetInvocationList();
  667. foreach (DeedParcelHandler h in list)
  668. {
  669. if (h(user, parcel, m_scene) == false)
  670. return false;
  671. }
  672. }
  673. return true;
  674. }
  675. public bool CanDeedObject(UUID user, UUID group)
  676. {
  677. DeedObjectHandler handler = OnDeedObject;
  678. if (handler != null)
  679. {
  680. Delegate[] list = handler.GetInvocationList();
  681. foreach (DeedObjectHandler h in list)
  682. {
  683. if (h(user, group, m_scene) == false)
  684. return false;
  685. }
  686. }
  687. return true;
  688. }
  689. public bool CanBuyLand(UUID user, ILandObject parcel)
  690. {
  691. BuyLandHandler handler = OnBuyLand;
  692. if (handler != null)
  693. {
  694. Delegate[] list = handler.GetInvocationList();
  695. foreach (BuyLandHandler h in list)
  696. {
  697. if (h(user, parcel, m_scene) == false)
  698. return false;
  699. }
  700. }
  701. return true;
  702. }
  703. public bool CanLinkObject(UUID user, UUID objectID)
  704. {
  705. LinkObjectHandler handler = OnLinkObject;
  706. if (handler != null)
  707. {
  708. Delegate[] list = handler.GetInvocationList();
  709. foreach (LinkObjectHandler h in list)
  710. {
  711. if (h(user, objectID) == false)
  712. return false;
  713. }
  714. }
  715. return true;
  716. }
  717. public bool CanDelinkObject(UUID user, UUID objectID)
  718. {
  719. DelinkObjectHandler handler = OnDelinkObject;
  720. if (handler != null)
  721. {
  722. Delegate[] list = handler.GetInvocationList();
  723. foreach (DelinkObjectHandler h in list)
  724. {
  725. if (h(user, objectID) == false)
  726. return false;
  727. }
  728. }
  729. return true;
  730. }
  731. #endregion
  732. /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
  733. /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
  734. /// </summary>
  735. /// <param name="invType"></param>
  736. /// <param name="objectID"></param>
  737. /// <param name="userID"></param>
  738. /// <returns></returns>
  739. public bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
  740. {
  741. CreateObjectInventoryHandler handler = OnCreateObjectInventory;
  742. if (handler != null)
  743. {
  744. Delegate[] list = handler.GetInvocationList();
  745. foreach (CreateObjectInventoryHandler h in list)
  746. {
  747. if (h(invType, objectID, userID) == false)
  748. return false;
  749. }
  750. }
  751. return true;
  752. }
  753. public bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
  754. {
  755. CopyObjectInventoryHandler handler = OnCopyObjectInventory;
  756. if (handler != null)
  757. {
  758. Delegate[] list = handler.GetInvocationList();
  759. foreach (CopyObjectInventoryHandler h in list)
  760. {
  761. if (h(itemID, objectID, userID) == false)
  762. return false;
  763. }
  764. }
  765. return true;
  766. }
  767. public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
  768. {
  769. DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;
  770. if (handler != null)
  771. {
  772. Delegate[] list = handler.GetInvocationList();
  773. foreach (DeleteObjectInventoryHandler h in list)
  774. {
  775. if (h(itemID, objectID, userID) == false)
  776. return false;
  777. }
  778. }
  779. return true;
  780. }
  781. /// <summary>
  782. /// Check whether the specified user is allowed to create the given inventory type in their inventory.
  783. /// </summary>
  784. /// <param name="invType"></param>
  785. /// <param name="userID"></param>
  786. /// <returns></returns>
  787. public bool CanCreateUserInventory(int invType, UUID userID)
  788. {
  789. CreateUserInventoryHandler handler = OnCreateUserInventory;
  790. if (handler != null)
  791. {
  792. Delegate[] list = handler.GetInvocationList();
  793. foreach (CreateUserInventoryHandler h in list)
  794. {
  795. if (h(invType, userID) == false)
  796. return false;
  797. }
  798. }
  799. return true;
  800. }
  801. /// <summary>
  802. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  803. /// </summary>
  804. /// <param name="itemID"></param>
  805. /// <param name="userID"></param>
  806. /// <returns></returns>
  807. public bool CanEditUserInventory(UUID itemID, UUID userID)
  808. {
  809. EditUserInventoryHandler handler = OnEditUserInventory;
  810. if (handler != null)
  811. {
  812. Delegate[] list = handler.GetInvocationList();
  813. foreach (EditUserInventoryHandler h in list)
  814. {
  815. if (h(itemID, userID) == false)
  816. return false;
  817. }
  818. }
  819. return true;
  820. }
  821. /// <summary>
  822. /// Check whether the specified user is allowed to copy the given inventory item from their own inventory.
  823. /// </summary>
  824. /// <param name="itemID"></param>
  825. /// <param name="userID"></param>
  826. /// <returns></returns>
  827. public bool CanCopyUserInventory(UUID itemID, UUID userID)
  828. {
  829. CopyUserInventoryHandler handler = OnCopyUserInventory;
  830. if (handler != null)
  831. {
  832. Delegate[] list = handler.GetInvocationList();
  833. foreach (CopyUserInventoryHandler h in list)
  834. {
  835. if (h(itemID, userID) == false)
  836. return false;
  837. }
  838. }
  839. return true;
  840. }
  841. /// <summary>
  842. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  843. /// </summary>
  844. /// <param name="itemID"></param>
  845. /// <param name="userID"></param>
  846. /// <returns></returns>
  847. public bool CanDeleteUserInventory(UUID itemID, UUID userID)
  848. {
  849. DeleteUserInventoryHandler handler = OnDeleteUserInventory;
  850. if (handler != null)
  851. {
  852. Delegate[] list = handler.GetInvocationList();
  853. foreach (DeleteUserInventoryHandler h in list)
  854. {
  855. if (h(itemID, userID) == false)
  856. return false;
  857. }
  858. }
  859. return true;
  860. }
  861. public bool CanTeleport(UUID userID)
  862. {
  863. TeleportHandler handler = OnTeleport;
  864. if (handler != null)
  865. {
  866. Delegate[] list = handler.GetInvocationList();
  867. foreach (TeleportHandler h in list)
  868. {
  869. if (h(userID, m_scene) == false)
  870. return false;
  871. }
  872. }
  873. return true;
  874. }
  875. public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List<SceneObjectGroup> retlist)
  876. {
  877. UseObjectReturnHandler handler = OnUseObjectReturn;
  878. if (handler != null)
  879. {
  880. Delegate[] list = handler.GetInvocationList();
  881. foreach (UseObjectReturnHandler h in list)
  882. {
  883. if (h(landData, type, client, retlist, m_scene) == false)
  884. return false;
  885. }
  886. }
  887. return true;
  888. }
  889. }
  890. }