cmdbchangeop.class.inc.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * Various atomic change operations, to be tracked
  4. *
  5. * @package iTopORM
  6. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  7. * @author Denis Flaven <denisflave@free.fr>
  8. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  9. * @link www.itop.com
  10. * @since 1.0
  11. * @version 1.1.1.1 $
  12. */
  13. class CMDBChangeOp extends DBObject
  14. {
  15. public static function Init()
  16. {
  17. $aParams = array
  18. (
  19. "category" => "core/cmdb",
  20. "name" => "change operation",
  21. "description" => "Change operations tracking",
  22. "key_type" => "autoincrement",
  23. "key_label" => "",
  24. "name_attcode" => "change",
  25. "state_attcode" => "",
  26. "reconc_keys" => array(),
  27. "db_table" => "priv_changeop",
  28. "db_key_field" => "id",
  29. "db_finalclass_field" => "optype",
  30. );
  31. MetaModel::Init_Params($aParams);
  32. //MetaModel::Init_InheritAttributes();
  33. MetaModel::Init_AddAttribute(new AttributeExternalKey("change", array("label"=>"change", "description"=>"change", "allowed_values"=>null, "sql"=>"changeid", "targetclass"=>"CMDBChange", "is_null_allowed"=>false, "depends_on"=>array())));
  34. MetaModel::Init_AddAttribute(new AttributeExternalField("date", array("label"=>"date", "description"=>"date and time of the change", "allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"date")));
  35. MetaModel::Init_AddAttribute(new AttributeExternalField("userinfo", array("label"=>"user", "description"=>"who made this change", "allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"userinfo")));
  36. MetaModel::Init_AddAttribute(new AttributeString("objclass", array("label"=>"object class", "description"=>"object class", "allowed_values"=>null, "sql"=>"objclass", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  37. MetaModel::Init_AddAttribute(new AttributeString("objkey", array("label"=>"object id", "description"=>"object id", "allowed_values"=>null, "sql"=>"objkey", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  38. MetaModel::Init_AddFilterFromAttribute("objclass");
  39. MetaModel::Init_AddFilterFromAttribute("objkey");
  40. MetaModel::Init_AddFilterFromAttribute("date");
  41. MetaModel::Init_AddFilterFromAttribute("userinfo");
  42. }
  43. }
  44. /**
  45. * Record the creation of an object
  46. *
  47. * @package iTopORM
  48. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  49. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  50. * @link www.itop.com
  51. * @since 1.0
  52. * @version $itopversion$
  53. */
  54. class CMDBChangeOpCreate extends CMDBChangeOp
  55. {
  56. public static function Init()
  57. {
  58. $aParams = array
  59. (
  60. "category" => "core/cmdb",
  61. "name" => "object creation",
  62. "description" => "Object creation tracking",
  63. "key_type" => "",
  64. "key_label" => "",
  65. "name_attcode" => "change",
  66. "state_attcode" => "",
  67. "reconc_keys" => array(),
  68. "db_table" => "priv_changeop_create",
  69. "db_key_field" => "id",
  70. "db_finalclass_field" => "",
  71. );
  72. MetaModel::Init_Params($aParams);
  73. MetaModel::Init_InheritAttributes();
  74. MetaModel::Init_InheritFilters();
  75. }
  76. }
  77. /**
  78. * Record the deletion of an object
  79. *
  80. * @package iTopORM
  81. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  82. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  83. * @link www.itop.com
  84. * @since 1.0
  85. * @version $itopversion$
  86. */
  87. class CMDBChangeOpDelete extends CMDBChangeOp
  88. {
  89. public static function Init()
  90. {
  91. $aParams = array
  92. (
  93. "category" => "core/cmdb",
  94. "name" => "object deletion",
  95. "description" => "Object deletion tracking",
  96. "key_type" => "",
  97. "key_label" => "",
  98. "name_attcode" => "change",
  99. "state_attcode" => "",
  100. "reconc_keys" => array(),
  101. "db_table" => "priv_changeop_delete",
  102. "db_key_field" => "id",
  103. "db_finalclass_field" => "",
  104. );
  105. MetaModel::Init_Params($aParams);
  106. MetaModel::Init_InheritAttributes();
  107. MetaModel::Init_InheritFilters();
  108. }
  109. }
  110. /**
  111. * Record the modification of an attribute
  112. *
  113. * @package iTopORM
  114. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  115. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  116. * @link www.itop.com
  117. * @since 1.0
  118. * @version $itopversion$
  119. */
  120. class CMDBChangeOpSetAttribute extends CMDBChangeOp
  121. {
  122. public static function Init()
  123. {
  124. $aParams = array
  125. (
  126. "category" => "core/cmdb",
  127. "name" => "object change",
  128. "description" => "Object properties change tracking",
  129. "key_type" => "",
  130. "key_label" => "",
  131. "name_attcode" => "change",
  132. "state_attcode" => "",
  133. "reconc_keys" => array(),
  134. "db_table" => "priv_changeop_setatt",
  135. "db_key_field" => "id",
  136. "db_finalclass_field" => "",
  137. );
  138. MetaModel::Init_Params($aParams);
  139. MetaModel::Init_InheritAttributes();
  140. MetaModel::Init_AddAttribute(new AttributeString("attcode", array("label"=>"Attribute", "description"=>"code of the modified property", "allowed_values"=>null, "sql"=>"attcode", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  141. MetaModel::Init_AddAttribute(new AttributeString("oldvalue", array("label"=>"Previous value", "description"=>"previous value of the attribute", "allowed_values"=>null, "sql"=>"oldvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  142. MetaModel::Init_AddAttribute(new AttributeString("newvalue", array("label"=>"New value", "description"=>"new value of the attribute", "allowed_values"=>null, "sql"=>"newvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  143. MetaModel::Init_InheritFilters();
  144. MetaModel::Init_AddFilterFromAttribute("attcode");
  145. MetaModel::Init_AddFilterFromAttribute("oldvalue");
  146. MetaModel::Init_AddFilterFromAttribute("newvalue");
  147. // Display lists
  148. MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode', 'oldvalue', 'newvalue')); // Attributes to be displayed for the complete details
  149. MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'attcode', 'oldvalue', 'newvalue')); // Attributes to be displayed for a list
  150. }
  151. }
  152. ?>