module.itop-tickets.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. SetupWebPage::AddModule(
  3. __FILE__,
  4. 'itop-tickets/2.2.0',
  5. array(
  6. // Identification
  7. //
  8. 'label' => 'Tickets Management',
  9. 'category' => 'business',
  10. // Setup
  11. //
  12. 'dependencies' => array(
  13. 'itop-config-mgmt/2.0.0',
  14. ),
  15. 'mandatory' => true,
  16. 'visible' => false,
  17. 'installer' => 'TicketsInstaller',
  18. // Components
  19. //
  20. 'datamodel' => array(
  21. 'main.itop-tickets.php',
  22. 'model.itop-tickets.php',
  23. ),
  24. 'data.struct' => array(
  25. // 'data.struct.ta-actions.xml',
  26. ),
  27. 'data.sample' => array(
  28. ),
  29. // Documentation
  30. //
  31. 'doc.manual_setup' => '/documentation/itop-tickets.htm',
  32. 'doc.more_information' => '',
  33. // Default settings
  34. //
  35. 'settings' => array(
  36. ),
  37. )
  38. );
  39. // Module installation handler
  40. //
  41. class TicketsInstaller extends ModuleInstallerAPI
  42. {
  43. public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  44. {
  45. // Delete all Triggers corresponding to a no more valid class
  46. $oSearch = new DBObjectSearch('TriggerOnObject');
  47. $oSet = new DBObjectSet($oSearch);
  48. $oChange = null;
  49. while($oTrigger = $oSet->Fetch())
  50. {
  51. if (!MetaModel::IsValidClass($oTrigger->Get('target_class')))
  52. {
  53. if ($oChange == null)
  54. {
  55. // Create the change for its first use
  56. $oChange = new CMDBChange;
  57. $oChange->Set("date", time());
  58. $oChange->Set("userinfo", "Uninstallation");
  59. $oChange->DBInsert();
  60. }
  61. $oTrigger->DBDeleteTracked($oChange);
  62. }
  63. }
  64. }
  65. }
  66. ?>