datamodel.itop-attachments.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <classes><class name="Attachment" category="addon,bizmodel" parent="DBObject" abstract="false" key_type="autoincrement" db_table="attachment" db_key_field="id" db_final_class_field=""><properties><comment><![CDATA[/**
  3. * Module attachments
  4. *
  5. * A quick and easy way to upload and attach files to *any* (see Configuration below) object in the CMBD in one click
  6. *
  7. * Configuration: the list of classes for which the "Attachments" tab is visible is defined via the module's 'allowed_classes'
  8. * configuration parameter. By default the tab is active for all kind of Tickets.
  9. *
  10. * @author Erwan Taloc <erwan.taloc@combodo.com>
  11. * @author Romain Quetiez <romain.quetiez@combodo.com>
  12. * @author Denis Flaven <denis.flaven@combodo.com>
  13. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  14. */]]></comment><naming format="%1$s %2$s"><attributes><attribute name="item_class"/><attribute name="temp_id"/></attributes></naming><display_template></display_template><icon></icon><reconciliation><attributes/></reconciliation></properties><fields><field name="expire" type="DateTime" sql="expire" default_value="" is_null_allowed="false"/><field name="temp_id" type="String" sql="temp_id" default_value="" is_null_allowed="true"/><field name="item_class" type="String" sql="item_class" default_value="" is_null_allowed="false"/><field name="item_id" type="String" sql="item_id" default_value="" is_null_allowed="true"/><field name="item_org_id" type="Integer" sql="item_org_id" default_value="0" is_null_allowed="true"/><field name="contents" type="Blob"/></fields><methods><method name="MapContextParam" static="true" access="public" type="Overload-ExNihilo"><comment><![CDATA[/**
  15. * Maps the given context parameter name to the appropriate filter/search code for this class
  16. * @param string $sContextParam Name of the context parameter, e.g. 'org_id'
  17. * @return string Filter code, e.g. 'customer_id'
  18. */]]></comment><![CDATA[ public static function MapContextParam($sContextParam)
  19. {
  20. if ($sContextParam == 'org_id')
  21. {
  22. return 'item_org_id';
  23. }
  24. else
  25. {
  26. return null;
  27. }
  28. }]]></method><method name="SetItem" static="false" access="public" type="Overload-ExNihilo"><comment><![CDATA[/**
  29. * Set/Update all of the '_item' fields
  30. * @param object $oItem Container item
  31. * @return void
  32. */]]></comment><![CDATA[ public function SetItem($oItem, $bUpdateOnChange = false)
  33. {
  34. $sClass = get_class($oItem);
  35. $iItemId = $oItem->GetKey();
  36. $this->Set('item_class', $sClass);
  37. $this->Set('item_id', $iItemId);
  38. $aCallSpec = array($sClass, 'MapContextParam');
  39. if (is_callable($aCallSpec))
  40. {
  41. $sAttCode = call_user_func($aCallSpec, 'org_id'); // Returns null when there is no mapping for this parameter
  42. if (MetaModel::IsValidAttCode($sClass, $sAttCode))
  43. {
  44. $iOrgId = $oItem->Get($sAttCode);
  45. if ($iOrgId > 0)
  46. {
  47. if ($iOrgId != $this->Get('item_org_id'))
  48. {
  49. $this->Set('item_org_id', $iOrgId);
  50. if ($bUpdateOnChange)
  51. {
  52. $this->DBUpdate();
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }]]></method><method name="SetDefaultOrgId" static="false" access="public" type="Overload-ExNihilo"><comment><![CDATA[/**
  59. * Give a default value for item_org_id (if relevant...)
  60. * @return void
  61. */]]></comment><![CDATA[ public function SetDefaultOrgId()
  62. {
  63. // First check that the organization CAN be fetched from the target class
  64. //
  65. $sClass = $this->Get('item_class');
  66. $aCallSpec = array($sClass, 'MapContextParam');
  67. if (is_callable($aCallSpec))
  68. {
  69. $sAttCode = call_user_func($aCallSpec, 'org_id'); // Returns null when there is no mapping for this parameter
  70. if (MetaModel::IsValidAttCode($sClass, $sAttCode))
  71. {
  72. // Second: check that the organization CAN be fetched from the current user
  73. //
  74. if (MetaModel::IsValidClass('Person'))
  75. {
  76. $aCallSpec = array($sClass, 'MapContextParam');
  77. if (is_callable($aCallSpec))
  78. {
  79. $sAttCode = call_user_func($aCallSpec, 'org_id'); // Returns null when there is no mapping for this parameter
  80. if (MetaModel::IsValidAttCode($sClass, $sAttCode))
  81. {
  82. // OK - try it
  83. //
  84. $oCurrentPerson = MetaModel::GetObject('Person', UserRights::GetContactId(), false);
  85. if ($oCurrentPerson)
  86. {
  87. $this->Set('item_org_id', $oCurrentPerson->Get($sAttCode));
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }]]></method></methods><presentation><details><items><item>temp_id</item><item>item_class</item><item>item_id</item><item>item_org_id</item></items></details><search><items><item>temp_id</item><item>item_class</item><item>item_id</item></items></search><list><items><item>temp_id</item><item>item_class</item><item>item_id</item></items></list></presentation></class></classes>