module.itop-tickets.php 1.5 KB

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