skinr.install 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * @file
  4. * Contains install, update, and uninstall functions for Skinr.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function skinr_schema() {
  10. $schema['skinr_skins'] = array(
  11. 'description' => 'Stores skinr data.',
  12. 'fields' => array(
  13. 'sid' => array(
  14. 'description' => 'The primary identifier for a skin configuration.',
  15. 'type' => 'serial',
  16. 'unsigned' => TRUE,
  17. 'not null' => TRUE,
  18. ),
  19. 'theme' => array(
  20. 'description' => 'The theme this configuration applies to.',
  21. 'type' => 'varchar',
  22. 'length' => 64,
  23. 'not null' => TRUE,
  24. 'default' => '',
  25. ),
  26. 'module' => array(
  27. 'description' => 'The module this configuration applies to.',
  28. 'type' => 'varchar',
  29. 'length' => 64,
  30. 'not null' => TRUE,
  31. 'default' => '',
  32. ),
  33. 'element' => array(
  34. 'description' => 'The element this configutation applies to.',
  35. 'type' => 'varchar',
  36. 'length' => 128,
  37. 'not null' => TRUE,
  38. 'default' => '',
  39. ),
  40. 'skin' => array(
  41. 'description' => 'The skin that has been applied.',
  42. 'type' => 'varchar',
  43. 'length' => 64,
  44. 'not null' => TRUE,
  45. 'default' => '',
  46. ),
  47. 'options' => array(
  48. 'description' => 'A serialized array containing the skin options that have been applied.',
  49. 'type' => 'text',
  50. 'size' => 'big',
  51. 'not null' => TRUE,
  52. 'serialize' => TRUE,
  53. ),
  54. 'status' => array(
  55. 'description' => 'Boolean indicating whether or not this item is enabled.',
  56. 'type' => 'int',
  57. 'not null' => TRUE,
  58. 'default' => 0,
  59. 'size' => 'tiny',
  60. ),
  61. ),
  62. 'primary key' => array('sid'),
  63. 'unique keys' => array(
  64. 'theme_module_element_skin' => array('theme', 'module', 'element', 'skin'),
  65. ),
  66. 'indexes' => array(
  67. 'theme' => array('theme'),
  68. 'module' => array('theme', 'module'),
  69. 'element' => array('theme', 'module', 'element'),
  70. 'skin' => array('skin'),
  71. ),
  72. );
  73. $schema['skinr_rules'] = array(
  74. 'description' => 'Stores skinr rule data.',
  75. 'fields' => array(
  76. 'rid' => array(
  77. 'type' => 'serial',
  78. 'not null' => TRUE,
  79. 'description' => 'Primary Key: Unique skinr rule ID.',
  80. ),
  81. 'title' => array(
  82. 'description' => 'The administrative title for this rule.',
  83. 'type' => 'varchar',
  84. 'length' => 128,
  85. 'not null' => TRUE,
  86. 'default' => '',
  87. ),
  88. 'rule_type' => array(
  89. 'description' => 'The content type of this rule.',
  90. 'type' => 'varchar',
  91. 'length' => 128,
  92. 'not null' => TRUE,
  93. 'default' => '',
  94. ),
  95. 'node_types' => array(
  96. 'type' => 'text',
  97. 'size' => 'normal',
  98. 'not null' => FALSE,
  99. 'serialize' => TRUE,
  100. 'description' => 'A serialized array of node types for this record.',
  101. ),
  102. 'roles' => array(
  103. 'type' => 'text',
  104. 'size' => 'normal',
  105. 'not null' => FALSE,
  106. 'serialize' => TRUE,
  107. 'description' => 'A serialized array of roles for this record.',
  108. ),
  109. 'visibility' => array(
  110. 'type' => 'int',
  111. 'not null' => TRUE,
  112. 'default' => 0,
  113. 'size' => 'tiny',
  114. 'description' => 'Flag to indicate how to show rules on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)',
  115. ),
  116. 'pages' => array(
  117. 'type' => 'text',
  118. 'not null' => TRUE,
  119. 'description' => 'Contains either a list of paths on which to include/exclude the rule or PHP code, depending on "visibility" setting.',
  120. ),
  121. ),
  122. 'primary key' => array('rid'),
  123. );
  124. return $schema;
  125. }
  126. /**
  127. * Implements hook_uninstall().
  128. */
  129. function skinr_uninstall() {
  130. // Remove all skinr variables.
  131. db_delete('variable')
  132. ->condition('name', 'skinr_%', 'LIKE')
  133. ->execute();
  134. }
  135. /**
  136. * Implements hook_update_last_removed().
  137. *
  138. * Make sure any previous updates aren't skipped.
  139. */
  140. function skinr_update_last_removed() {
  141. // @todo We probably shouldn't expect people to have ever installed
  142. // Skinr version 6.x-2.x, where updates 6000 through 6003 are from.
  143. return 6004;
  144. }
  145. /**
  146. * Install new skinr tables and convert old variables to the new db system.
  147. *
  148. * @todo Shoud we remove this? It was ported from skinr_update_6000(), but
  149. * shouldn't have been.
  150. *
  151. * Contents removed because the table added here is no longer required.
  152. */
  153. function skinr_update_7001() {
  154. }
  155. /**
  156. * Install a new field in {skinr_rules} table.
  157. *
  158. * @todo Should we remove this? It was ported from skinr_update_6001(), but
  159. * shouldn't have been.
  160. */
  161. function skinr_update_7002() {
  162. // @todo skinr_update_6001() contains additional field manipulations.
  163. if (!db_field_exists('skinr_rules', 'rule_type')) {
  164. db_add_field('skinr_rules', 'rule_type', array(
  165. 'description' => 'The content type of this rule.',
  166. 'type' => 'varchar',
  167. 'length' => 128,
  168. 'not null' => TRUE,
  169. 'default' => '',
  170. ));
  171. db_update('skinr_rules')
  172. ->fields(array('rule_type' => 'page'))
  173. ->execute();
  174. db_update('skinr')
  175. ->fields(array('module' => 'rules'))
  176. ->condition('module', 'page')
  177. ->execute();
  178. }
  179. }
  180. /**
  181. * Install the new {skinr_skinsets} and {skinr_skins} tables.
  182. *
  183. * @todo Should we remove this? It was ported from skinr_update_6002() and
  184. * skinr_update_6003(), but should not have been.
  185. *
  186. * Contents removed because the tables added here are no longer required.
  187. */
  188. function skinr_update_7003() {
  189. }