module.itop-change-mgmt.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/1.0.0',
  5. array(
  6. // Identification
  7. //
  8. 'label' => 'Change Management',
  9. 'category' => 'business',
  10. // Setup
  11. //
  12. 'dependencies' => array(
  13. 'itop-config-mgmt/1.0.0',
  14. 'itop-tickets/1.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. 'main.itop-change-mgmt.php',
  24. ),
  25. 'data.struct' => array(
  26. //'data.struct.itop-change-mgmt.xml',
  27. ),
  28. 'data.sample' => array(
  29. //'data.sample.itop-change-mgmt.xml',
  30. ),
  31. // Documentation
  32. //
  33. 'doc.manual_setup' => '',
  34. 'doc.more_information' => '/doc/itop-documentation.htm#ChangeMgmt',
  35. // Default settings
  36. //
  37. 'settings' => array(
  38. ),
  39. )
  40. );
  41. if (!class_exists('ChangeManagementInstaller'))
  42. {
  43. // Module installation handler
  44. //
  45. class ChangeManagementInstaller extends ModuleInstallerAPI
  46. {
  47. public static function BeforeWritingConfig(Config $oConfiguration)
  48. {
  49. // If you want to override/force some configuration values, do it here
  50. return $oConfiguration;
  51. }
  52. /**
  53. * Handler called before creating or upgrading the database schema
  54. * @param $oConfiguration Config The new configuration of the application
  55. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  56. * @param $sCurrentVersion string Current version number of the module
  57. */
  58. public static function BeforeDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  59. {
  60. // If you want to migrate data from one format to another, do it here
  61. }
  62. /**
  63. * Handler called after the creation/update of the database schema
  64. * @param $oConfiguration Config The new configuration of the application
  65. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  66. * @param $sCurrentVersion string Current version number of the module
  67. */
  68. public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  69. {
  70. // Bug #464 - start_date was both in Ticket and Change tables
  71. //
  72. $sSourceTable = 'change';
  73. $sSourceKeyField = 'id';
  74. $sTargetTable = 'ticket';
  75. $sTargetKeyField = 'id';
  76. $sField = 'start_date';
  77. if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField))
  78. {
  79. SetupPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
  80. $sRepair = "UPDATE `$sTargetTable`, `$sSourceTable` SET `$sTargetTable`.`$sField` = `$sSourceTable`.`$sField` WHERE `$sTargetTable`.`$sField` IS NULL AND`$sTargetTable`.`$sTargetKeyField` = `$sSourceTable`.`$sSourceKeyField`";
  81. CMDBSource::Query($sRepair);
  82. }
  83. }
  84. }
  85. }
  86. ?>