content.install

  1. 6.x modules/content/content.install
  2. 4.x modules/content/content.install
  3. 5.x modules/content/content.install

File

modules/content/content.install
View source
  1. <?php
  2. /**
  3. * This file should contain only hooks relating to installing, enabling, disabling, and uninstalling this module.
  4. *
  5. */
  6. function content_update($old_schema, $new_schema) {
  7. if (intval($old_schema) < 2) {
  8. // Adding user_id to the content_versions table, so we know which user edited what version.
  9. db_query("ALTER TABLE content_versions ADD COLUMN `user_id` int NOT NULL DEFAULT '0' ");
  10. db_query("ALTER TABLE content_versions ADD INDEX (`user_id`) ");
  11. }
  12. // Skipped 3 intentionally, decided to undo it.
  13. if (intval($old_schema) < 4) {
  14. db_query("ALTER TABLE content ADD COLUMN `log` longtext DEFAULT NULL ");
  15. }
  16. if (intval($old_schema) < 5) {
  17. if (!file_exists(fp_get_files_path() . '/content_uploads/')) {
  18. mkdir(fp_get_files_path() . '/content_uploads/');
  19. }
  20. }
  21. if (intval($old_schema) < 6) {
  22. db_query("ALTER TABLE content_files ADD COLUMN `is_encrypted` tinyint(4) DEFAULT 0 ");
  23. db_query("ALTER TABLE content_files ADD INDEX (`is_encrypted`) ");
  24. }
  25. if (intval($old_schema) < 7) {
  26. db_query("ALTER TABLE content_files ADD COLUMN `cid` int(10) unsigned DEFAULT 0 ");
  27. db_query("ALTER TABLE content_files ADD INDEX (`cid`) ");
  28. }
  29. if (intval($old_schema) < 8) {
  30. db_query("ALTER TABLE content_files ADD COLUMN `attributes` tinyint(4) unsigned DEFAULT 0 ");
  31. db_query("ALTER TABLE content_files ADD INDEX (`attributes`) ");
  32. if (!file_exists(fp_get_files_path() . '/content_uploads/public_uploads/')) {
  33. mkdir(fp_get_files_path() . '/content_uploads/public_uploads/');
  34. }
  35. }
  36. }
  37. /**
  38. * Hook install. Called when the module is installed on the admin modules page.
  39. */
  40. function content_install() {
  41. // Create our tables
  42. $query = "
  43. CREATE TABLE `content` (
  44. `cid` int unsigned NOT NULL AUTO_INCREMENT,
  45. `vid` int unsigned NOT NULL DEFAULT '0',
  46. `user_id` int NOT NULL DEFAULT '0',
  47. `type` varchar(255) NOT NULL DEFAULT '',
  48. `title` varchar(1000) NOT NULL DEFAULT '',
  49. `posted` int unsigned NOT NULL DEFAULT '0',
  50. `updated` int unsigned NOT NULL DEFAULT '0',
  51. `published` tinyint DEFAULT NULL,
  52. `delete_flag` tinyint DEFAULT '0',
  53. `log` longtext DEFAULT NULL,
  54. PRIMARY KEY (`cid`),
  55. KEY `posted` (`posted`),
  56. KEY `updated` (`updated`),
  57. KEY `user_id` (`user_id`),
  58. KEY `type` (`type`),
  59. KEY `vid` (`vid`),
  60. KEY `delete_flag` (`delete_flag`)
  61. );";
  62. db_query($query);
  63. $query = "
  64. CREATE TABLE `content_versions` (
  65. `vid` int unsigned NOT NULL AUTO_INCREMENT,
  66. `cid` int unsigned NOT NULL,
  67. `user_id` int NOT NULL DEFAULT '0',
  68. PRIMARY KEY (`vid`) ,
  69. KEY `cid` (`cid`),
  70. KEY `user_id` (`user_id`)
  71. );";
  72. db_query($query);
  73. $query = "
  74. CREATE TABLE `content_last_access` (
  75. `cid` int unsigned NOT NULL,
  76. `user_id` int NOT NULL,
  77. `last_access` int unsigned DEFAULT NULL,
  78. PRIMARY KEY (`cid`,`user_id`)
  79. );";
  80. db_query($query);
  81. $query = "
  82. CREATE TABLE `content_files` (
  83. `fid` int unsigned NOT NULL AUTO_INCREMENT,
  84. `cid` int unsigned DEFAULT 0,
  85. `original_filename` varchar(255) DEFAULT NULL,
  86. `filename` varchar(255) DEFAULT NULL,
  87. `mimetype` varchar(255) DEFAULT NULL,
  88. `is_encrypted` tinyint(4) DEFAULT 0,
  89. `posted` int unsigned DEFAULT NULL,
  90. `attributes` tinyint(4) unsigned DEFAULT 0,
  91. PRIMARY KEY (`fid`),
  92. KEY `original_filename` (`original_filename`),
  93. KEY `filename` (`filename`),
  94. KEY `cid` (`cid`),
  95. KEY `mimetype` (`mimetype`),
  96. KEY `is_encrypted` (`is_encrypted`),
  97. KEY `attributes` (`attributes`),
  98. KEY `posted` (`posted`)
  99. );";
  100. db_query($query);
  101. $query = "
  102. CREATE TABLE `content__page` (
  103. `cid` int(10) unsigned NOT NULL,
  104. `vid` int(10) unsigned NOT NULL,
  105. `field__body` text DEFAULT NULL,
  106. PRIMARY KEY (`vid`),
  107. KEY `cid` (`cid`),
  108. KEY `field__body` (`field__body`(768))
  109. );
  110. ";
  111. db_query($query);
  112. if (!file_exists(fp_get_files_path() . '/content_uploads/')) {
  113. mkdir(fp_get_files_path() . '/content_uploads/');
  114. }
  115. if (!file_exists(fp_get_files_path() . '/content_uploads/public_uploads/')) {
  116. mkdir(fp_get_files_path() . '/content_uploads/public_uploads/');
  117. }
  118. }

Functions

Namesort descending Description
content_install Hook install. Called when the module is installed on the admin modules page.
content_update