drupal-6.forum.database.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. /**
  3. * Database additions for forum tests.
  4. */
  5. db_create_table('forum', array(
  6. 'fields' => array(
  7. 'nid' => array(
  8. 'type' => 'int',
  9. 'unsigned' => TRUE,
  10. 'not null' => TRUE,
  11. 'default' => 0,
  12. ),
  13. 'vid' => array(
  14. 'type' => 'int',
  15. 'unsigned' => TRUE,
  16. 'not null' => TRUE,
  17. 'default' => 0,
  18. ),
  19. 'tid' => array(
  20. 'type' => 'int',
  21. 'unsigned' => TRUE,
  22. 'not null' => TRUE,
  23. 'default' => 0,
  24. ),
  25. ),
  26. 'indexes' => array(
  27. 'nid' => array(
  28. 'nid',
  29. ),
  30. 'tid' => array(
  31. 'tid',
  32. ),
  33. ),
  34. 'primary key' => array(
  35. 'vid',
  36. ),
  37. 'module' => 'forum',
  38. 'name' => 'forum',
  39. ));
  40. db_insert('forum')->fields(array(
  41. 'nid',
  42. 'vid',
  43. 'tid',
  44. ))
  45. ->values(array(
  46. 'nid' => '51',
  47. 'vid' => '61',
  48. 'tid' => '81',
  49. ))
  50. ->execute();
  51. db_insert('node')->fields(array(
  52. 'nid',
  53. 'vid',
  54. 'type',
  55. 'language',
  56. 'title',
  57. 'uid',
  58. 'status',
  59. 'created',
  60. 'changed',
  61. 'comment',
  62. 'promote',
  63. 'moderate',
  64. 'sticky',
  65. 'tnid',
  66. 'translate',
  67. ))
  68. ->values(array(
  69. 'nid' => '51',
  70. 'vid' => '61',
  71. 'type' => 'forum',
  72. 'language' => '',
  73. 'title' => 'Apples',
  74. 'uid' => '1',
  75. 'status' => '1',
  76. 'created' => '1298363952',
  77. 'changed' => '1298363952',
  78. 'comment' => '2',
  79. 'promote' => '0',
  80. 'moderate' => '0',
  81. 'sticky' => '0',
  82. 'tnid' => '0',
  83. 'translate' => '0',
  84. ))
  85. ->execute();
  86. db_insert('node_revisions')->fields(array(
  87. 'nid',
  88. 'vid',
  89. 'uid',
  90. 'title',
  91. 'body',
  92. 'teaser',
  93. 'log',
  94. 'timestamp',
  95. 'format',
  96. ))
  97. ->values(array(
  98. 'nid' => '51',
  99. 'vid' => '61',
  100. 'uid' => '1',
  101. 'title' => 'Apples',
  102. 'body' => 'A fruit.',
  103. 'teaser' => 'A fruit.',
  104. 'log' => '',
  105. 'timestamp' => '1298363952',
  106. 'format' => '1',
  107. ))
  108. ->execute();
  109. db_insert('node_comment_statistics')->fields(array(
  110. 'nid',
  111. 'last_comment_timestamp',
  112. 'last_comment_name',
  113. 'last_comment_uid',
  114. 'comment_count',
  115. ))
  116. ->values(array(
  117. 'nid' => '51',
  118. 'last_comment_timestamp' => '1298363952',
  119. 'last_comment_name' => NULL,
  120. 'last_comment_uid' => '1',
  121. 'comment_count' => '0',
  122. ))
  123. ->execute();
  124. db_insert('node_type')->fields(array(
  125. 'type',
  126. 'name',
  127. 'module',
  128. 'description',
  129. 'help',
  130. 'has_title',
  131. 'title_label',
  132. 'has_body',
  133. 'body_label',
  134. 'min_word_count',
  135. 'custom',
  136. 'modified',
  137. 'locked',
  138. 'orig_type',
  139. ))
  140. ->values(array(
  141. 'type' => 'forum',
  142. 'name' => 'Forum topic',
  143. 'module' => 'forum',
  144. 'description' => 'A <em>forum topic</em> is the initial post to a new discussion thread within a forum.',
  145. 'help' => '',
  146. 'has_title' => '1',
  147. 'title_label' => 'Subject',
  148. 'has_body' => '1',
  149. 'body_label' => 'Body',
  150. 'min_word_count' => '0',
  151. 'custom' => '0',
  152. 'modified' => '0',
  153. 'locked' => '1',
  154. 'orig_type' => 'forum',
  155. ))
  156. ->execute();
  157. db_update('system')->fields(array(
  158. 'schema_version' => '6000',
  159. 'status' => '1',
  160. ))
  161. ->condition('filename', 'modules/forum/forum.module')
  162. ->execute();
  163. db_insert('term_data')->fields(array(
  164. 'tid',
  165. 'vid',
  166. 'name',
  167. 'description',
  168. 'weight',
  169. ))
  170. ->values(array(
  171. 'tid' => '81',
  172. 'vid' => '101',
  173. 'name' => 'Fruits',
  174. 'description' => 'Fruits.',
  175. 'weight' => '0',
  176. ))
  177. ->execute();
  178. db_insert('term_hierarchy')->fields(array(
  179. 'tid',
  180. 'parent',
  181. ))
  182. ->values(array(
  183. 'tid' => '81',
  184. 'parent' => '0',
  185. ))
  186. ->execute();
  187. db_insert('term_node')->fields(array(
  188. 'nid',
  189. 'vid',
  190. 'tid',
  191. ))
  192. ->values(array(
  193. 'nid' => '51',
  194. 'vid' => '61',
  195. 'tid' => '81',
  196. ))
  197. ->execute();
  198. db_insert('variable')->fields(array(
  199. 'name',
  200. 'value',
  201. ))
  202. ->values(array(
  203. 'name' => 'forum_nav_vocabulary',
  204. 'value' => 's:3:"101";',
  205. ))
  206. ->values(array(
  207. 'name' => 'forum_containers',
  208. 'value' => 'a:1:{i:0;s:3:"101";}',
  209. ))
  210. ->execute();
  211. db_insert('vocabulary')->fields(array(
  212. 'vid',
  213. 'name',
  214. 'description',
  215. 'help',
  216. 'relations',
  217. 'hierarchy',
  218. 'multiple',
  219. 'required',
  220. 'tags',
  221. 'module',
  222. 'weight',
  223. ))
  224. ->values(array(
  225. 'vid' => '101',
  226. 'name' => 'Upgrade test for forums',
  227. 'description' => 'Vocabulary used for Forums. The name is changed from the default "Forums" so that the upgrade path may be tested.',
  228. 'help' => '',
  229. 'relations' => '1',
  230. 'hierarchy' => '1',
  231. 'multiple' => '0',
  232. 'required' => '0',
  233. 'tags' => '0',
  234. 'module' => 'forum',
  235. 'weight' => '-10',
  236. ))
  237. ->execute();
  238. db_insert('vocabulary_node_types')->fields(array(
  239. 'vid',
  240. 'type',
  241. ))
  242. ->values(array(
  243. 'vid' => '101',
  244. 'type' => 'forum',
  245. ))
  246. ->execute();
  247. // Provide all users with the ability to create forum topics.
  248. $results = db_select('permission', 'p')
  249. ->fields('p')
  250. ->execute();
  251. foreach ($results as $result) {
  252. $permissions = $result->perm . ', create forum topics';
  253. db_update('permission')
  254. ->fields(array(
  255. 'perm' => $permissions,
  256. ))
  257. ->condition('rid', $result->rid)
  258. ->execute();
  259. }