twitter.install 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the twitter module.
  5. *
  6. */
  7. /**
  8. * Implements hook_schema().
  9. */
  10. function twitter_schema() {
  11. $schema['twitter'] = array(
  12. 'description' => "Stores individual Twitter posts.",
  13. 'fields' => array(
  14. 'twitter_id' => array(
  15. 'description' => "Unique identifier for each {twitter} post.",
  16. 'type' => 'numeric',
  17. 'unsigned' => TRUE,
  18. 'precision' => 20,
  19. 'scale' => 0,
  20. 'not null' => TRUE,
  21. 'default' => 0,
  22. ),
  23. 'screen_name' => array(
  24. 'description' => "Screen Name of the {twitter_account} user.",
  25. 'type' => 'varchar',
  26. 'length' => 255,
  27. 'not null' => TRUE,
  28. 'default' => '',
  29. ),
  30. 'created_at' => array(
  31. 'description' => "Date and time the {twitter} post was created.",
  32. 'type' => 'varchar',
  33. 'length' => 64,
  34. 'not null' => TRUE,
  35. 'default' => '',
  36. ),
  37. 'created_time' => array(
  38. 'description' => "A duplicate of {twitter}.created_at in UNIX timestamp format.",
  39. 'type' => 'int',
  40. 'not null' => TRUE,
  41. ),
  42. 'text' => array(
  43. 'description' => "The text of the {twitter} post.",
  44. 'type' => 'varchar',
  45. 'length' => 255,
  46. 'not null' => FALSE,
  47. ),
  48. 'source' => array(
  49. 'description' => "The application that created the {twitter} post.",
  50. 'type' => 'varchar',
  51. 'length' => 255,
  52. 'not null' => FALSE,
  53. ),
  54. 'in_reply_to_status_id' => array(
  55. 'description' => "Unique identifier of a status this {twitter} post was replying to.",
  56. 'type' => 'numeric',
  57. 'unsigned' => TRUE,
  58. 'precision' => 20,
  59. 'scale' => 0,
  60. 'not null' => FALSE,
  61. ),
  62. 'in_reply_to_user_id' => array(
  63. 'description' => "Unique identifier for the {twitter_account} this post was replying to.",
  64. 'type' => 'numeric',
  65. 'unsigned' => TRUE,
  66. 'precision' => 20,
  67. 'scale' => 0,
  68. 'not null' => FALSE,
  69. ),
  70. 'in_reply_to_screen_name' => array(
  71. 'description' => "Screen name of the {twitter} user this post was replying to.",
  72. 'type' => 'varchar',
  73. 'length' => 255,
  74. 'not null' => FALSE,
  75. ),
  76. 'truncated' => array(
  77. 'description' => "Boolean flag indicating whether the {twitter} status was cut off to fit in the 140 character limit.",
  78. 'type' => 'int',
  79. 'unsigned' => TRUE,
  80. 'not null' => TRUE,
  81. 'default' => 0,
  82. ),
  83. ),
  84. 'indexes' => array('screen_name' => array('screen_name')),
  85. 'primary key' => array('twitter_id'),
  86. );
  87. $schema['twitter_account'] = array(
  88. 'description' => "Stores information on specific Twitter user accounts.",
  89. 'fields' => array(
  90. 'twitter_uid' => array(
  91. 'description' => "The unique identifier of the {twitter_account}.",
  92. 'type' => 'numeric',
  93. 'unsigned' => TRUE,
  94. 'precision' => 20,
  95. 'scale' => 0,
  96. 'not null' => TRUE,
  97. 'default' => 0,
  98. ),
  99. 'uid' => array(
  100. 'description' => "The {users}.uid of the owner of this account",
  101. 'type' => 'int',
  102. 'unsigned' => TRUE,
  103. 'size' => 'big',
  104. 'not null' => TRUE,
  105. ),
  106. 'host' => array(
  107. 'description' => 'The host for this account can be a laconi.ca instance',
  108. 'type' => 'varchar',
  109. 'length' => 255,
  110. ),
  111. 'screen_name' => array(
  112. 'description' => "The unique login name of the {twitter_account} user.",
  113. 'type' => 'varchar',
  114. 'length' => 255,
  115. ),
  116. 'password' => array(
  117. 'description' => "The password for the Twitter account.",
  118. 'type' => 'varchar',
  119. 'length' => 64,
  120. ),
  121. 'oauth_token' => array(
  122. 'description' => 'The token_key for oauth-based access.',
  123. 'type' => 'varchar',
  124. 'length' => 64,
  125. ),
  126. 'oauth_token_secret' => array(
  127. 'description' => 'The token_secret for oauth-based access.',
  128. 'type' => 'varchar',
  129. 'length' => 64,
  130. ),
  131. 'name' => array(
  132. 'description' => "The full name of the {twitter_account} user.",
  133. 'type' => 'varchar',
  134. 'length' => 64,
  135. 'not null' => TRUE,
  136. 'default' => '',
  137. ),
  138. 'description' => array(
  139. 'description' => "The description/biography associated with the {twitter_account}.",
  140. 'type' => 'varchar',
  141. 'length' => 255,
  142. ),
  143. 'location' => array(
  144. 'description' => "The location of the {twitter_account}'s owner.",
  145. 'type' => 'varchar',
  146. 'length' => 255,
  147. ),
  148. 'followers_count' => array(
  149. 'description' => "The number of users following this {twitter_account}.",
  150. 'type' => 'int',
  151. 'not null' => TRUE,
  152. 'default' => 0,
  153. ),
  154. 'friends_count' => array(
  155. 'description' => "The number of users this {twitter_account} is following.",
  156. 'type' => 'int',
  157. 'not null' => TRUE,
  158. 'default' => 0,
  159. ),
  160. 'statuses_count' => array(
  161. 'description' => "The total number of status updates performed by a user, excluding direct messages sent.",
  162. 'type' => 'int',
  163. 'not null' => TRUE,
  164. 'default' => 0,
  165. ),
  166. 'favourites_count' => array(
  167. 'description' => "The number of statuses a user has marked as favorite.",
  168. 'type' => 'int',
  169. 'not null' => TRUE,
  170. 'default' => 0,
  171. ),
  172. 'url' => array(
  173. 'description' => "The url of the {twitter_account}'s home page.",
  174. 'type' => 'varchar',
  175. 'length' => 255,
  176. ),
  177. 'profile_image_url' => array(
  178. 'description' => "The url of the {twitter_account}'s profile image.",
  179. 'type' => 'varchar',
  180. 'length' => 255,
  181. ),
  182. 'protected' => array(
  183. 'description' => "Boolean flag indicating whether the {twitter_account}'s posts are publicly accessible.",
  184. 'type' => 'int',
  185. 'unsigned' => TRUE,
  186. 'not null' => TRUE,
  187. 'default' => 0,
  188. ),
  189. 'profile_background_color' => array(
  190. 'description' => "hex RGB value for a user's background color",
  191. 'type' => 'varchar',
  192. 'length' => 6,
  193. 'not null' => TRUE,
  194. 'default' => '',
  195. ),
  196. 'profile_text_color' => array(
  197. 'description' => "hex RGB value for a user's text color",
  198. 'type' => 'varchar',
  199. 'length' => 6,
  200. 'not null' => TRUE,
  201. 'default' => '',
  202. ),
  203. 'profile_link_color' => array(
  204. 'description' => "hex RGB value for a user's link color",
  205. 'type' => 'varchar',
  206. 'length' => 6,
  207. 'not null' => TRUE,
  208. 'default' => '',
  209. ),
  210. 'profile_sidebar_fill_color' => array(
  211. 'description' => "hex RGB value for a user's sidebar color",
  212. 'type' => 'varchar',
  213. 'length' => 6,
  214. 'not null' => TRUE,
  215. 'default' => '',
  216. ),
  217. 'profile_sidebar_border_color' => array(
  218. 'description' => "hex RGB value for a user's border color",
  219. 'type' => 'varchar',
  220. 'length' => 6,
  221. 'not null' => TRUE,
  222. 'default' => '',
  223. ),
  224. 'profile_background_image_url' => array(
  225. 'description' => "The url of the {twitter_account}'s profile image.",
  226. 'type' => 'varchar',
  227. 'length' => 255,
  228. ),
  229. 'profile_background_tile' => array(
  230. 'description' => "Boolean indicating if a user's background is tiled.",
  231. 'type' => 'int',
  232. 'unsigned' => TRUE,
  233. 'not null' => TRUE,
  234. 'default' => 1,
  235. ),
  236. 'verified' => array(
  237. 'description' => "Indicates if a user is verified.",
  238. 'type' => 'int',
  239. 'unsigned' => TRUE,
  240. 'not null' => TRUE,
  241. 'default' => 1,
  242. ),
  243. 'created_at' => array(
  244. 'description' => "Date and time the {twitter_account} was created.",
  245. 'type' => 'varchar',
  246. 'length' => 64,
  247. 'not null' => TRUE,
  248. 'default' => '',
  249. ),
  250. 'created_time' => array(
  251. 'description' => "A duplicate of {twitter_account}.created_at in UNIX timestamp format.",
  252. 'type' => 'int',
  253. 'not null' => TRUE,
  254. ),
  255. 'utc_offset' => array(
  256. 'description' => "A duplicate of {twitter_account}.created_at in UNIX timestamp format.",
  257. 'type' => 'int',
  258. 'not null' => TRUE,
  259. ),
  260. 'import' => array(
  261. 'description' => "Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site.",
  262. 'type' => 'int',
  263. 'unsigned' => TRUE,
  264. 'not null' => TRUE,
  265. 'default' => 1,
  266. ),
  267. 'last_refresh' => array(
  268. 'description' => "A UNIX timestamp marking the date Twitter statuses were last fetched on.",
  269. 'type' => 'int',
  270. 'not null' => TRUE,
  271. 'default' => 0,
  272. ),
  273. 'is_global' => array(
  274. 'description' => "Boolean flag indicating if this account is available for global use",
  275. 'type' => 'int',
  276. 'unsigned' => TRUE,
  277. 'not null' => TRUE,
  278. 'default' => 0,
  279. ),
  280. ),
  281. 'indexes' => array('screen_name' => array('screen_name')),
  282. 'primary key' => array('twitter_uid'),
  283. );
  284. return $schema;
  285. }
  286. /**
  287. * Implements hook_install().
  288. */
  289. function twitter_install() {
  290. // Set the weight to 3, making it heavier than Pathauto.
  291. db_update('system')
  292. ->fields(array(
  293. 'weight' => 3,
  294. ))
  295. ->condition('type', 'module')
  296. ->condition('name', 'twitter')
  297. ->execute();
  298. }
  299. /**
  300. * Implements hook_uninstall().
  301. */
  302. function twitter_uninstall() {
  303. // Remove variables
  304. variable_del('twitter_import');
  305. variable_del('twitter_expire');
  306. variable_del('twitter_consumer_key');
  307. variable_del('twitter_consumer_secret');
  308. variable_del('twitter_post_types');
  309. variable_del('twitter_host');
  310. variable_del('twitter_post_default_format');
  311. variable_del('twitter_signin_button');
  312. variable_del('twitter_signin_register');
  313. }
  314. /**
  315. * Implements hook_update_last_removed().
  316. */
  317. function twitter_update_last_removed() {
  318. return 6005;
  319. }