aggregator.install 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the aggregator module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function aggregator_uninstall() {
  10. variable_del('aggregator_allowed_html_tags');
  11. variable_del('aggregator_summary_items');
  12. variable_del('aggregator_clear');
  13. variable_del('aggregator_category_selector');
  14. variable_del('aggregator_fetcher');
  15. variable_del('aggregator_parser');
  16. variable_del('aggregator_processors');
  17. variable_del('aggregator_teaser_length');
  18. }
  19. /**
  20. * Implements hook_schema().
  21. */
  22. function aggregator_schema() {
  23. $schema['aggregator_category'] = array(
  24. 'description' => 'Stores categories for aggregator feeds and feed items.',
  25. 'fields' => array(
  26. 'cid' => array(
  27. 'type' => 'serial',
  28. 'not null' => TRUE,
  29. 'description' => 'Primary Key: Unique aggregator category ID.',
  30. ),
  31. 'title' => array(
  32. 'type' => 'varchar',
  33. 'length' => 255,
  34. 'not null' => TRUE,
  35. 'default' => '',
  36. 'description' => 'Title of the category.',
  37. ),
  38. 'description' => array(
  39. 'type' => 'text',
  40. 'not null' => TRUE,
  41. 'size' => 'big',
  42. 'description' => 'Description of the category',
  43. ),
  44. 'block' => array(
  45. 'type' => 'int',
  46. 'not null' => TRUE,
  47. 'default' => 0,
  48. 'size' => 'tiny',
  49. 'description' => 'The number of recent items to show within the category block.',
  50. )
  51. ),
  52. 'primary key' => array('cid'),
  53. 'unique keys' => array(
  54. 'title' => array('title'),
  55. ),
  56. );
  57. $schema['aggregator_category_feed'] = array(
  58. 'description' => 'Bridge table; maps feeds to categories.',
  59. 'fields' => array(
  60. 'fid' => array(
  61. 'type' => 'int',
  62. 'not null' => TRUE,
  63. 'default' => 0,
  64. 'description' => "The feed's {aggregator_feed}.fid.",
  65. ),
  66. 'cid' => array(
  67. 'type' => 'int',
  68. 'not null' => TRUE,
  69. 'default' => 0,
  70. 'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
  71. )
  72. ),
  73. 'primary key' => array('cid', 'fid'),
  74. 'indexes' => array(
  75. 'fid' => array('fid'),
  76. ),
  77. 'foreign keys' => array(
  78. 'aggregator_category' => array(
  79. 'table' => 'aggregator_category',
  80. 'columns' => array('cid' => 'cid'),
  81. ),
  82. ),
  83. );
  84. $schema['aggregator_category_item'] = array(
  85. 'description' => 'Bridge table; maps feed items to categories.',
  86. 'fields' => array(
  87. 'iid' => array(
  88. 'type' => 'int',
  89. 'not null' => TRUE,
  90. 'default' => 0,
  91. 'description' => "The feed item's {aggregator_item}.iid.",
  92. ),
  93. 'cid' => array(
  94. 'type' => 'int',
  95. 'not null' => TRUE,
  96. 'default' => 0,
  97. 'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
  98. )
  99. ),
  100. 'primary key' => array('cid', 'iid'),
  101. 'indexes' => array(
  102. 'iid' => array('iid'),
  103. ),
  104. 'foreign keys' => array(
  105. 'aggregator_category' => array(
  106. 'table' => 'aggregator_category',
  107. 'columns' => array('cid' => 'cid'),
  108. ),
  109. ),
  110. );
  111. $schema['aggregator_feed'] = array(
  112. 'description' => 'Stores feeds to be parsed by the aggregator.',
  113. 'fields' => array(
  114. 'fid' => array(
  115. 'type' => 'serial',
  116. 'not null' => TRUE,
  117. 'description' => 'Primary Key: Unique feed ID.',
  118. ),
  119. 'title' => array(
  120. 'type' => 'varchar',
  121. 'length' => 255,
  122. 'not null' => TRUE,
  123. 'default' => '',
  124. 'description' => 'Title of the feed.',
  125. ),
  126. 'url' => array(
  127. 'type' => 'varchar',
  128. 'length' => 255,
  129. 'not null' => TRUE,
  130. 'default' => '',
  131. 'description' => 'URL to the feed.',
  132. ),
  133. 'refresh' => array(
  134. 'type' => 'int',
  135. 'not null' => TRUE,
  136. 'default' => 0,
  137. 'description' => 'How often to check for new feed items, in seconds.',
  138. ),
  139. 'checked' => array(
  140. 'type' => 'int',
  141. 'not null' => TRUE,
  142. 'default' => 0,
  143. 'description' => 'Last time feed was checked for new items, as Unix timestamp.',
  144. ),
  145. 'queued' => array(
  146. 'type' => 'int',
  147. 'not null' => TRUE,
  148. 'default' => 0,
  149. 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
  150. ),
  151. 'link' => array(
  152. 'type' => 'varchar',
  153. 'length' => 255,
  154. 'not null' => TRUE,
  155. 'default' => '',
  156. 'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
  157. ),
  158. 'description' => array(
  159. 'type' => 'text',
  160. 'not null' => TRUE,
  161. 'size' => 'big',
  162. 'description' => "The parent website's description; comes from the <description> element in the feed.",
  163. ),
  164. 'image' => array(
  165. 'type' => 'text',
  166. 'not null' => TRUE,
  167. 'size' => 'big',
  168. 'description' => 'An image representing the feed.',
  169. ),
  170. 'hash' => array(
  171. 'type' => 'varchar',
  172. 'length' => 64,
  173. 'not null' => TRUE,
  174. 'default' => '',
  175. 'description' => 'Calculated hash of the feed data, used for validating cache.',
  176. ),
  177. 'etag' => array(
  178. 'type' => 'varchar',
  179. 'length' => 255,
  180. 'not null' => TRUE,
  181. 'default' => '',
  182. 'description' => 'Entity tag HTTP response header, used for validating cache.',
  183. ),
  184. 'modified' => array(
  185. 'type' => 'int',
  186. 'not null' => TRUE,
  187. 'default' => 0,
  188. 'description' => 'When the feed was last modified, as a Unix timestamp.',
  189. ),
  190. 'block' => array(
  191. 'type' => 'int',
  192. 'not null' => TRUE,
  193. 'default' => 0,
  194. 'size' => 'tiny',
  195. 'description' => "Number of items to display in the feed's block.",
  196. )
  197. ),
  198. 'primary key' => array('fid'),
  199. 'unique keys' => array(
  200. 'url' => array('url'),
  201. 'title' => array('title'),
  202. ),
  203. 'indexes' => array(
  204. 'queued' => array('queued'),
  205. ),
  206. );
  207. $schema['aggregator_item'] = array(
  208. 'description' => 'Stores the individual items imported from feeds.',
  209. 'fields' => array(
  210. 'iid' => array(
  211. 'type' => 'serial',
  212. 'not null' => TRUE,
  213. 'description' => 'Primary Key: Unique ID for feed item.',
  214. ),
  215. 'fid' => array(
  216. 'type' => 'int',
  217. 'not null' => TRUE,
  218. 'default' => 0,
  219. 'description' => 'The {aggregator_feed}.fid to which this item belongs.',
  220. ),
  221. 'title' => array(
  222. 'type' => 'varchar',
  223. 'length' => 255,
  224. 'not null' => TRUE,
  225. 'default' => '',
  226. 'description' => 'Title of the feed item.',
  227. ),
  228. 'link' => array(
  229. 'type' => 'varchar',
  230. 'length' => 255,
  231. 'not null' => TRUE,
  232. 'default' => '',
  233. 'description' => 'Link to the feed item.',
  234. ),
  235. 'author' => array(
  236. 'type' => 'varchar',
  237. 'length' => 255,
  238. 'not null' => TRUE,
  239. 'default' => '',
  240. 'description' => 'Author of the feed item.',
  241. ),
  242. 'description' => array(
  243. 'type' => 'text',
  244. 'not null' => TRUE,
  245. 'size' => 'big',
  246. 'description' => 'Body of the feed item.',
  247. ),
  248. 'timestamp' => array(
  249. 'type' => 'int',
  250. 'not null' => FALSE,
  251. 'description' => 'Posted date of the feed item, as a Unix timestamp.',
  252. ),
  253. 'guid' => array(
  254. 'type' => 'varchar',
  255. 'length' => 255,
  256. 'not null' => FALSE,
  257. 'description' => 'Unique identifier for the feed item.',
  258. )
  259. ),
  260. 'primary key' => array('iid'),
  261. 'indexes' => array(
  262. 'fid' => array('fid'),
  263. ),
  264. 'foreign keys' => array(
  265. 'aggregator_feed' => array(
  266. 'table' => 'aggregator_feed',
  267. 'columns' => array('fid' => 'fid'),
  268. ),
  269. ),
  270. );
  271. return $schema;
  272. }
  273. /**
  274. * Add hash column to aggregator_feed table.
  275. */
  276. function aggregator_update_7000() {
  277. db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
  278. }
  279. /**
  280. * Add aggregator teaser length to settings from old global default teaser length
  281. */
  282. function aggregator_update_7001() {
  283. variable_set('aggregator_teaser_length', variable_get('teaser_length'));
  284. }
  285. /**
  286. * Add queued timestamp.
  287. */
  288. function aggregator_update_7002() {
  289. db_add_field('aggregator_feed', 'queued', array(
  290. 'type' => 'int',
  291. 'not null' => TRUE,
  292. 'default' => 0,
  293. 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
  294. ));
  295. db_add_index('aggregator_feed', 'queued', array('queued'));
  296. }