module.itop-change-mgmt.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. SetupWebPage::AddModule(
  3. __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
  4. 'itop-change-mgmt/2.3.0',
  5. array(
  6. // Identification
  7. //
  8. 'label' => 'Change Management',
  9. 'category' => 'business',
  10. // Setup
  11. //
  12. 'dependencies' => array(
  13. 'itop-config-mgmt/2.2.0',
  14. 'itop-tickets/2.0.0',
  15. ),
  16. 'mandatory' => false,
  17. 'visible' => true,
  18. 'installer' => 'ChangeManagementInstaller',
  19. // Components
  20. //
  21. 'datamodel' => array(
  22. 'model.itop-change-mgmt.php',
  23. ),
  24. 'data.struct' => array(
  25. //'data.struct.itop-change-mgmt.xml',
  26. ),
  27. 'data.sample' => array(
  28. //'data.sample.itop-change-mgmt.xml',
  29. ),
  30. // Documentation
  31. //
  32. 'doc.manual_setup' => '',
  33. 'doc.more_information' => '',
  34. // Default settings
  35. //
  36. 'settings' => array(
  37. ),
  38. )
  39. );
  40. // Module installation handler
  41. //
  42. class ChangeManagementInstaller extends ModuleInstallerAPI
  43. {
  44. public static function BeforeWritingConfig(Config $oConfiguration)
  45. {
  46. // If you want to override/force some configuration values, do it here
  47. return $oConfiguration;
  48. }
  49. /**
  50. * Handler called before creating or upgrading the database schema
  51. * @param $oConfiguration Config The new configuration of the application
  52. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  53. * @param $sCurrentVersion string Current version number of the module
  54. */
  55. public static function BeforeDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  56. {
  57. // If you want to migrate data from one format to another, do it here
  58. }
  59. /**
  60. * Handler called after the creation/update of the database schema
  61. * @param $oConfiguration Config The new configuration of the application
  62. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  63. * @param $sCurrentVersion string Current version number of the module
  64. */
  65. public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  66. {
  67. // Bug #464 - start_date was both in Ticket and Change tables
  68. //
  69. $sSourceTable = 'change';
  70. $sSourceKeyField = 'id';
  71. $sTargetTable = 'ticket';
  72. $sTargetKeyField = 'id';
  73. $sField = 'start_date';
  74. if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField))
  75. {
  76. SetupWebPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
  77. $sRepair = "UPDATE `$sTargetTable`, `$sSourceTable` SET `$sTargetTable`.`$sField` = `$sSourceTable`.`$sField` WHERE `$sTargetTable`.`$sField` IS NULL AND`$sTargetTable`.`$sTargetKeyField` = `$sSourceTable`.`$sSourceKeyField`";
  78. CMDBSource::Query($sRepair);
  79. }
  80. }
  81. }
  82. ?>