blogapi.install

File

drupal-6.x/modules/blogapi/blogapi.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function blogapi_install() {
  6. // Create tables.
  7. drupal_install_schema('blogapi');
  8. }
  9. /**
  10. * Implementation of hook_uninstall().
  11. */
  12. function blogapi_uninstall() {
  13. // Remove tables.
  14. drupal_uninstall_schema('blogapi');
  15. }
  16. /**
  17. * Implementation of hook_schema().
  18. */
  19. function blogapi_schema() {
  20. //This table was introduced in Drupal 6.4
  21. $schema['blogapi_files'] = array(
  22. 'description' => 'Stores information for files uploaded via the blogapi.',
  23. 'fields' => array(
  24. 'fid' => array(
  25. 'description' => 'Primary Key: Unique file ID.',
  26. 'type' => 'serial',
  27. ),
  28. 'uid' => array(
  29. 'description' => 'The {users}.uid of the user who is associated with the file.',
  30. 'type' => 'int',
  31. 'unsigned' => TRUE,
  32. 'not null' => TRUE,
  33. 'default' => 0),
  34. 'filepath' => array(
  35. 'description' => 'Path of the file relative to Drupal root.',
  36. 'type' => 'varchar',
  37. 'length' => 255,
  38. 'not null' => TRUE,
  39. 'default' => ''),
  40. 'filesize' => array(
  41. 'description' => 'The size of the file in bytes.',
  42. 'type' => 'int',
  43. 'unsigned' => TRUE,
  44. 'not null' => TRUE,
  45. 'default' => 0),
  46. ),
  47. 'primary key' => array('fid'),
  48. 'indexes' => array(
  49. 'uid' => array('uid'),
  50. ),
  51. );
  52. return $schema;
  53. }
  54. /**
  55. * @addtogroup updates-5.x-to-6.x
  56. * @{
  57. */
  58. /**
  59. * Inform users about the new permission.
  60. */
  61. function blogapi_update_6000() {
  62. drupal_set_message("Blog API module does not depend on blog module's permissions anymore, but provides its own 'administer content with blog api' permission instead. Until <a href=\"". url('admin/user/permissions', array('fragment' => 'module-blogapi')) .'">this permission is assigned</a> to at least one user role, only the site administrator will be able to use Blog API features.');
  63. return array();
  64. }
  65. /**
  66. * Add blogapi_files table to enable size restriction for BlogAPI file uploads.
  67. *
  68. * This table was introduced in Drupal 6.4.
  69. */
  70. function blogapi_update_6001() {
  71. $schema['blogapi_files'] = array(
  72. 'description' => 'Stores information for files uploaded via the blogapi.',
  73. 'fields' => array(
  74. 'fid' => array(
  75. 'description' => 'Primary Key: Unique file ID.',
  76. 'type' => 'serial',
  77. ),
  78. 'uid' => array(
  79. 'description' => 'The {users}.uid of the user who is associated with the file.',
  80. 'type' => 'int',
  81. 'unsigned' => TRUE,
  82. 'not null' => TRUE,
  83. 'default' => 0),
  84. 'filepath' => array(
  85. 'description' => 'Path of the file relative to Drupal root.',
  86. 'type' => 'varchar',
  87. 'length' => 255,
  88. 'not null' => TRUE,
  89. 'default' => ''),
  90. 'filesize' => array(
  91. 'description' => 'The size of the file in bytes.',
  92. 'type' => 'int',
  93. 'unsigned' => TRUE,
  94. 'not null' => TRUE,
  95. 'default' => 0),
  96. ),
  97. 'primary key' => array('fid'),
  98. 'indexes' => array(
  99. 'uid' => array('uid'),
  100. ),
  101. );
  102. $ret = array();
  103. if (!db_table_exists('blogapi_files')) {
  104. db_create_table($ret, 'blogapi_files', $schema['blogapi_files']);
  105. }
  106. return $ret;
  107. }
  108. /**
  109. * @} End of "addtogroup updates-5.x-to-6.x".
  110. * The next series of updates should start at 7000.
  111. */