profile.install

  1. 7.x drupal-7.x/modules/profile/profile.install
  2. 6.x drupal-6.x/modules/profile/profile.install

Install, update and uninstall functions for the profile module.

File

drupal-7.x/modules/profile/profile.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the profile module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function profile_uninstall() {
  10. variable_del('profile_block_author_fields');
  11. }
  12. /**
  13. * Implements hook_schema().
  14. */
  15. function profile_schema() {
  16. $schema['profile_field'] = array(
  17. 'description' => 'Stores profile field information.',
  18. 'fields' => array(
  19. 'fid' => array(
  20. 'type' => 'serial',
  21. 'not null' => TRUE,
  22. 'description' => 'Primary Key: Unique profile field ID.',
  23. ),
  24. 'title' => array(
  25. 'type' => 'varchar',
  26. 'length' => 255,
  27. 'not null' => FALSE,
  28. 'description' => 'Title of the field shown to the end user.',
  29. ),
  30. 'name' => array(
  31. 'type' => 'varchar',
  32. 'length' => 128,
  33. 'not null' => TRUE,
  34. 'default' => '',
  35. 'description' => 'Internal name of the field used in the form HTML and URLs.',
  36. ),
  37. 'explanation' => array(
  38. 'type' => 'text',
  39. 'not null' => FALSE,
  40. 'description' => 'Explanation of the field to end users.',
  41. ),
  42. 'category' => array(
  43. 'type' => 'varchar',
  44. 'length' => 255,
  45. 'not null' => FALSE,
  46. 'description' => 'Profile category that the field will be grouped under.',
  47. ),
  48. 'page' => array(
  49. 'type' => 'varchar',
  50. 'length' => 255,
  51. 'not null' => FALSE,
  52. 'description' => "Title of page used for browsing by the field's value",
  53. ),
  54. 'type' => array(
  55. 'type' => 'varchar',
  56. 'length' => 128,
  57. 'not null' => FALSE,
  58. 'description' => 'Type of form field.',
  59. ),
  60. 'weight' => array(
  61. 'type' => 'int',
  62. 'not null' => TRUE,
  63. 'default' => 0,
  64. 'description' => 'Weight of field in relation to other profile fields.',
  65. ),
  66. 'required' => array(
  67. 'type' => 'int',
  68. 'not null' => TRUE,
  69. 'default' => 0,
  70. 'size' => 'tiny',
  71. 'description' => 'Whether the user is required to enter a value. (0 = no, 1 = yes)',
  72. ),
  73. 'register' => array(
  74. 'type' => 'int',
  75. 'not null' => TRUE,
  76. 'default' => 0,
  77. 'size' => 'tiny',
  78. 'description' => 'Whether the field is visible in the user registration form. (1 = yes, 0 = no)',
  79. ),
  80. 'visibility' => array(
  81. 'type' => 'int',
  82. 'not null' => TRUE,
  83. 'default' => 0,
  84. 'size' => 'tiny',
  85. 'description' => 'The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)',
  86. ),
  87. 'autocomplete' => array(
  88. 'type' => 'int',
  89. 'not null' => TRUE,
  90. 'default' => 0,
  91. 'size' => 'tiny',
  92. 'description' => 'Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)',
  93. ),
  94. 'options' => array(
  95. 'type' => 'text',
  96. 'not null' => FALSE,
  97. 'description' => 'List of options to be used in a list selection field.',
  98. ),
  99. ),
  100. 'indexes' => array(
  101. 'category' => array('category'),
  102. ),
  103. 'unique keys' => array(
  104. 'name' => array('name'),
  105. ),
  106. 'primary key' => array('fid'),
  107. );
  108. $schema['profile_value'] = array(
  109. 'description' => 'Stores values for profile fields.',
  110. 'fields' => array(
  111. 'fid' => array(
  112. 'type' => 'int',
  113. 'unsigned' => TRUE,
  114. 'not null' => TRUE,
  115. 'default' => 0,
  116. 'description' => 'The {profile_field}.fid of the field.',
  117. ),
  118. 'uid' => array(
  119. 'type' => 'int',
  120. 'unsigned' => TRUE,
  121. 'not null' => TRUE,
  122. 'default' => 0,
  123. 'description' => 'The {users}.uid of the profile user.',
  124. ),
  125. 'value' => array(
  126. 'type' => 'text',
  127. 'not null' => FALSE,
  128. 'description' => 'The value for the field.',
  129. ),
  130. ),
  131. 'primary key' => array('uid', 'fid'),
  132. 'indexes' => array(
  133. 'fid' => array('fid'),
  134. ),
  135. 'foreign keys' => array(
  136. 'profile_field' => array(
  137. 'table' => 'profile_field',
  138. 'columns' => array('fid' => 'fid'),
  139. ),
  140. 'profile_user' => array(
  141. 'table' => 'users',
  142. 'columns' => array('uid' => 'uid'),
  143. ),
  144. ),
  145. );
  146. return $schema;
  147. }
  148. /**
  149. * Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}.
  150. */
  151. function profile_update_7001() {
  152. db_rename_table('profile_fields', 'profile_field');
  153. db_rename_table('profile_values', 'profile_value');
  154. }
  155. /**
  156. * Change the weight column to normal int.
  157. */
  158. function profile_update_7002() {
  159. db_change_field('profile_field', 'weight', 'weight', array(
  160. 'type' => 'int',
  161. 'not null' => TRUE,
  162. 'default' => 0,
  163. 'description' => 'Weight of field in relation to other profile fields.',
  164. ));
  165. }