webform_localization.install 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * @file
  4. * Webform Localization module install/schema hooks.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function webform_localization_install() {
  10. /**
  11. * NOTE:
  12. * We add a field to record the language of the submission since when using
  13. * "Localization by String Translation" you can get single webform been
  14. * submitted by several nodes in different languages.
  15. */
  16. db_add_field('webform_submissions', 'language', array(
  17. 'description' => 'The {languages}.language source of this submission.',
  18. 'type' => 'varchar',
  19. 'length' => 12,
  20. 'not null' => TRUE,
  21. 'default' => '',
  22. ));
  23. variable_set('webform_localization_using_uuid', module_exists('uuid'));
  24. }
  25. /**
  26. * Implements hook_uninstall().
  27. */
  28. function webform_localization_uninstall() {
  29. db_drop_field('webform_submissions', 'language');
  30. variable_del('webform_localization_using_uuid');
  31. }
  32. /**
  33. * Implements hook_schema().
  34. */
  35. function webform_localization_schema() {
  36. $schema = array();
  37. $schema['webform_localization'] = array(
  38. 'description' => 'Table for storing additional properties for webform localization.',
  39. 'fields' => array(
  40. 'nid' => array(
  41. 'description' => 'The node identifier of a webform.',
  42. 'type' => 'int',
  43. 'unsigned' => TRUE,
  44. 'not null' => TRUE,
  45. ),
  46. 'expose_strings' => array(
  47. 'description' => 'Boolean value of a webform for expose component strings for translation or not.',
  48. 'type' => 'int',
  49. 'size' => 'tiny',
  50. 'not null' => TRUE,
  51. 'default' => 0,
  52. ),
  53. 'single_webform' => array(
  54. 'description' => 'A Tanslation set Id for keep one single webform across a translation set.',
  55. 'type' => 'int',
  56. 'not null' => TRUE,
  57. 'default' => 0,
  58. ),
  59. 'webform_properties' => array(
  60. 'description' => 'Webform properties to be sync.',
  61. 'type' => 'text',
  62. 'not null' => TRUE,
  63. ),
  64. 'sync_components' => array(
  65. 'description' => 'Boolean value for whether the webform components must be sync across translated nodes.',
  66. 'type' => 'int',
  67. 'size' => 'tiny',
  68. 'not null' => TRUE,
  69. 'default' => 0,
  70. ),
  71. 'sync_roles' => array(
  72. 'description' => 'Boolean value for whether the webform submission access roles must be sync across translated nodes.',
  73. 'type' => 'int',
  74. 'size' => 'tiny',
  75. 'not null' => TRUE,
  76. 'default' => 0,
  77. ),
  78. 'sync_emails' => array(
  79. 'description' => 'Boolean value for whether the webform emails must be sync across translated nodes.',
  80. 'type' => 'int',
  81. 'size' => 'tiny',
  82. 'not null' => TRUE,
  83. 'default' => 0,
  84. ),
  85. ),
  86. 'primary key' => array('nid'),
  87. );
  88. $schema['webform_component_localization'] = array(
  89. 'description' => 'Stores information about components properties sync for webform localization.',
  90. 'fields' => array(
  91. 'nid' => array(
  92. 'description' => 'The node identifier of a webform.',
  93. 'type' => 'int',
  94. 'unsigned' => TRUE,
  95. 'not null' => TRUE,
  96. 'default' => 0,
  97. ),
  98. 'cid' => array(
  99. 'description' => 'The identifier for this component within this node, starts at 0 for each node.',
  100. 'type' => 'int',
  101. 'size' => 'small',
  102. 'unsigned' => TRUE,
  103. 'not null' => TRUE,
  104. 'default' => 0,
  105. ),
  106. 'standar_properties' => array(
  107. 'description' => 'Standar properties of this component to be sync.',
  108. 'type' => 'text',
  109. 'not null' => TRUE,
  110. ),
  111. 'extra_properties' => array(
  112. 'description' => 'Additional properties of this component to be sync.',
  113. 'type' => 'text',
  114. 'not null' => TRUE,
  115. ),
  116. ),
  117. );
  118. return $schema;
  119. }
  120. /**
  121. * Implements hook_schema_alter().
  122. *
  123. * Add webform_submissions table language field
  124. */
  125. function webform_localization_schema_alter(&$schema) {
  126. $schema['webform_submissions']['fields']['language'] = array(
  127. 'description' => 'The {languages}.language source of this submission.',
  128. 'type' => 'varchar',
  129. 'length' => 12,
  130. 'not null' => TRUE,
  131. 'default' => '',
  132. );
  133. }