module.itop-change-mgmt.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. // Module installation handler
  42. //
  43. class ChangeManagementInstaller extends ModuleInstallerAPI
  44. {
  45. public static function BeforeWritingConfig(Config $oConfiguration)
  46. {
  47. // If you want to override/force some configuration values, do it here
  48. return $oConfiguration;
  49. }
  50. /**
  51. * Handler called before creating or upgrading the database schema
  52. * @param $oConfiguration Config The new configuration of the application
  53. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  54. * @param $sCurrentVersion string Current version number of the module
  55. */
  56. public static function BeforeDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  57. {
  58. // If you want to migrate data from one format to another, do it here
  59. }
  60. /**
  61. * Handler called after the creation/update of the database schema
  62. * @param $oConfiguration Config The new configuration of the application
  63. * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  64. * @param $sCurrentVersion string Current version number of the module
  65. */
  66. public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
  67. {
  68. // Bug #464 - start_date was both in Ticket and Change tables
  69. //
  70. $sSourceTable = 'change';
  71. $sSourceKeyField = 'id';
  72. $sTargetTable = 'ticket';
  73. $sTargetKeyField = 'id';
  74. $sField = 'start_date';
  75. if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField))
  76. {
  77. SetupPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
  78. $sRepair = "UPDATE `$sTargetTable`, `$sSourceTable` SET `$sTargetTable`.`$sField` = `$sSourceTable`.`$sField` WHERE `$sTargetTable`.`$sField` IS NULL AND`$sTargetTable`.`$sTargetKeyField` = `$sSourceTable`.`$sSourceKeyField`";
  79. CMDBSource::Query($sRepair);
  80. }
  81. }
  82. }
  83. ?>