Scene.Permissions.cs 34 KB

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