follow.install 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @file
  4. * Follow module's install and uninstall code.
  5. */
  6. /**
  7. * Implementation of hook_install().
  8. */
  9. function follow_install() {
  10. // Add a default link to this site's node RSS feed.
  11. db_insert('follow_links')
  12. ->fields(array(
  13. 'name' => 'this-site',
  14. 'path' => 'rss.xml',
  15. 'options' => 'a:0:{}',
  16. 'uid' => 0,
  17. 'weight' => 0,
  18. ))
  19. ->execute();
  20. }
  21. /**
  22. * Implementation of hook_schema().
  23. */
  24. function follow_schema() {
  25. $schema['follow_links'] = array(
  26. 'description' => 'Stores sitewide and user follow links.',
  27. 'fields' => array(
  28. 'lid' => array(
  29. 'type' => 'serial',
  30. 'unsigned' => TRUE,
  31. 'not null' => TRUE,
  32. 'description' => 'Unique identifier for the {follow_links}.',
  33. ),
  34. 'name' => array(
  35. 'type' => 'varchar',
  36. 'length' => 255,
  37. 'not null' => TRUE,
  38. 'default' => '',
  39. 'description' => "The machine name of the {follow_links}.",
  40. ),
  41. 'uid' => array(
  42. 'type' => 'int',
  43. 'not null' => TRUE,
  44. 'default' => 0,
  45. 'description' => "User's {users} uid. Sitewide {follow_links} use uid 0",
  46. ),
  47. 'path' => array(
  48. 'type' => 'varchar',
  49. 'length' => 255,
  50. 'not null' => TRUE,
  51. 'default' => '',
  52. 'description' => 'The Drupal path or extenal URL the {follow_links} should point to.',
  53. ),
  54. 'options' => array(
  55. 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
  56. 'type' => 'text',
  57. 'translatable' => TRUE,
  58. 'serialize' => TRUE,
  59. ),
  60. 'title' => array(
  61. 'type' => 'varchar',
  62. 'length' => 255,
  63. 'not null' => TRUE,
  64. 'default' => '',
  65. 'description' => 'The human readable name for the link.',
  66. ),
  67. 'weight' => array(
  68. 'type' => 'int',
  69. 'not null' => TRUE,
  70. 'default' => 0,
  71. 'size' => 'tiny',
  72. 'description' => 'The weight of this {follow_links}.',
  73. ),
  74. ),
  75. 'primary key' => array('lid'),
  76. 'unique keys' => array(
  77. 'uid_name' => array('uid', 'name'),
  78. ),
  79. );
  80. return $schema;
  81. }
  82. /**
  83. * Implementation of hook_uninstall().
  84. */
  85. function follow_uninstall() {
  86. variable_del('follow_user_block_title');
  87. variable_del('follow_site_block_title');
  88. variable_del('follow_site_block_user');
  89. }
  90. /**
  91. * Implementation of hook_update_last_removed().
  92. */
  93. function follow_update_last_removed() {
  94. // We need to ensure that all D6 users have upgraded to the latest version of
  95. // Follow before upgrading to D7.
  96. return 6003;
  97. }
  98. /**
  99. * Placeholder to ensure the correct schema version.
  100. */
  101. function follow_update_7003() {
  102. }