aggregator.install 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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' => 'text',
  128. 'not null' => TRUE,
  129. 'description' => 'URL to the feed.',
  130. ),
  131. 'refresh' => array(
  132. 'type' => 'int',
  133. 'not null' => TRUE,
  134. 'default' => 0,
  135. 'description' => 'How often to check for new feed items, in seconds.',
  136. ),
  137. 'checked' => array(
  138. 'type' => 'int',
  139. 'not null' => TRUE,
  140. 'default' => 0,
  141. 'description' => 'Last time feed was checked for new items, as Unix timestamp.',
  142. ),
  143. 'queued' => array(
  144. 'type' => 'int',
  145. 'not null' => TRUE,
  146. 'default' => 0,
  147. 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
  148. ),
  149. 'link' => array(
  150. 'type' => 'text',
  151. 'not null' => TRUE,
  152. 'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
  153. ),
  154. 'description' => array(
  155. 'type' => 'text',
  156. 'not null' => TRUE,
  157. 'size' => 'big',
  158. 'description' => "The parent website's description; comes from the <description> element in the feed.",
  159. ),
  160. 'image' => array(
  161. 'type' => 'text',
  162. 'not null' => TRUE,
  163. 'size' => 'big',
  164. 'description' => 'An image representing the feed.',
  165. ),
  166. 'hash' => array(
  167. 'type' => 'varchar',
  168. 'length' => 64,
  169. 'not null' => TRUE,
  170. 'default' => '',
  171. 'description' => 'Calculated hash of the feed data, used for validating cache.',
  172. ),
  173. 'etag' => array(
  174. 'type' => 'varchar',
  175. 'length' => 255,
  176. 'not null' => TRUE,
  177. 'default' => '',
  178. 'description' => 'Entity tag HTTP response header, used for validating cache.',
  179. ),
  180. 'modified' => array(
  181. 'type' => 'int',
  182. 'not null' => TRUE,
  183. 'default' => 0,
  184. 'description' => 'When the feed was last modified, as a Unix timestamp.',
  185. ),
  186. 'block' => array(
  187. 'type' => 'int',
  188. 'not null' => TRUE,
  189. 'default' => 0,
  190. 'size' => 'tiny',
  191. 'description' => "Number of items to display in the feed's block.",
  192. )
  193. ),
  194. 'primary key' => array('fid'),
  195. 'indexes' => array(
  196. 'url' => array(array('url', 255)),
  197. 'queued' => array('queued'),
  198. ),
  199. 'unique keys' => array(
  200. 'title' => array('title'),
  201. ),
  202. );
  203. $schema['aggregator_item'] = array(
  204. 'description' => 'Stores the individual items imported from feeds.',
  205. 'fields' => array(
  206. 'iid' => array(
  207. 'type' => 'serial',
  208. 'not null' => TRUE,
  209. 'description' => 'Primary Key: Unique ID for feed item.',
  210. ),
  211. 'fid' => array(
  212. 'type' => 'int',
  213. 'not null' => TRUE,
  214. 'default' => 0,
  215. 'description' => 'The {aggregator_feed}.fid to which this item belongs.',
  216. ),
  217. 'title' => array(
  218. 'type' => 'varchar',
  219. 'length' => 255,
  220. 'not null' => TRUE,
  221. 'default' => '',
  222. 'description' => 'Title of the feed item.',
  223. ),
  224. 'link' => array(
  225. 'type' => 'text',
  226. 'not null' => TRUE,
  227. 'description' => 'Link to the feed item.',
  228. ),
  229. 'author' => array(
  230. 'type' => 'varchar',
  231. 'length' => 255,
  232. 'not null' => TRUE,
  233. 'default' => '',
  234. 'description' => 'Author of the feed item.',
  235. ),
  236. 'description' => array(
  237. 'type' => 'text',
  238. 'not null' => TRUE,
  239. 'size' => 'big',
  240. 'description' => 'Body of the feed item.',
  241. ),
  242. 'timestamp' => array(
  243. 'type' => 'int',
  244. 'not null' => FALSE,
  245. 'description' => 'Posted date of the feed item, as a Unix timestamp.',
  246. ),
  247. 'guid' => array(
  248. 'type' => 'text',
  249. 'not null' => TRUE,
  250. 'description' => 'Unique identifier for the feed item.',
  251. )
  252. ),
  253. 'primary key' => array('iid'),
  254. 'indexes' => array(
  255. 'fid' => array('fid'),
  256. 'timestamp' => array('timestamp'),
  257. ),
  258. 'foreign keys' => array(
  259. 'aggregator_feed' => array(
  260. 'table' => 'aggregator_feed',
  261. 'columns' => array('fid' => 'fid'),
  262. ),
  263. ),
  264. );
  265. return $schema;
  266. }
  267. /**
  268. * @addtogroup updates-6.x-to-7.x
  269. * @{
  270. */
  271. /**
  272. * Add hash column to aggregator_feed table.
  273. */
  274. function aggregator_update_7000() {
  275. db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
  276. }
  277. /**
  278. * Add aggregator teaser length to settings from old global default teaser length
  279. */
  280. function aggregator_update_7001() {
  281. variable_set('aggregator_teaser_length', variable_get('teaser_length'));
  282. }
  283. /**
  284. * Add queued timestamp.
  285. */
  286. function aggregator_update_7002() {
  287. db_add_field('aggregator_feed', 'queued', array(
  288. 'type' => 'int',
  289. 'not null' => TRUE,
  290. 'default' => 0,
  291. 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
  292. ));
  293. db_add_index('aggregator_feed', 'queued', array('queued'));
  294. }
  295. /**
  296. * @} End of "addtogroup updates-6.x-to-7.x"
  297. */
  298. /**
  299. * @addtogroup updates-7.x-extra
  300. * @{
  301. */
  302. /**
  303. * Increase the length of {aggregator_feed}.url.
  304. */
  305. function aggregator_update_7003() {
  306. db_drop_unique_key('aggregator_feed', 'url');
  307. db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.'));
  308. db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.'));
  309. db_change_field('aggregator_item', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'Link to the feed item.'));
  310. db_change_field('aggregator_item', 'guid', 'guid', array('type' => 'text', 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.'));
  311. db_add_index('aggregator_feed', 'url', array(array('url', 255)));
  312. }
  313. /**
  314. * Add index on timestamp.
  315. */
  316. function aggregator_update_7004() {
  317. if (!db_index_exists('aggregator_item', 'timestamp')) {
  318. db_add_index('aggregator_item', 'timestamp', array('timestamp'));
  319. }
  320. }
  321. /**
  322. * @} End of "addtogroup updates-7.x-extra"
  323. */