browscap.install 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Browscap module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function browscap_schema() {
  10. $schema['browscap'] = array(
  11. 'fields' => array(
  12. 'useragent' => array(
  13. 'type' => 'varchar',
  14. 'length' => 255,
  15. 'not null' => TRUE,
  16. 'default' => '',
  17. ),
  18. 'data' => array(
  19. 'type' => 'blob',
  20. 'size' => 'big',
  21. ),
  22. ),
  23. 'primary key' => array('useragent'),
  24. );
  25. $schema['cache_browscap'] = drupal_get_schema_unprocessed('system', 'cache');
  26. return $schema;
  27. }
  28. /**
  29. * Implements hook_requirements().
  30. */
  31. function browscap_requirements($phase) {
  32. $requirements = array();
  33. $t = get_t();
  34. if ($phase == 'runtime' && user_access('administer browscap')) {
  35. $requirement = array(
  36. 'value' => variable_get('browscap_version', 0) === 0 ? $t('Not installed') : l(variable_get('browscap_version', 0), 'admin/config/system/browscap'),
  37. 'title' => $t('Browscap version'),
  38. );
  39. if (variable_get('browscap_version', 0) === 0) {
  40. $requirement += array(
  41. 'severity' => REQUIREMENT_ERROR,
  42. 'description' => $t('Browscap data is not imported! See <a href="!settings_url">Browscap settings</a> to import manually.', array(
  43. '!settings_url' => url('admin/config/system/browscap'),
  44. )),
  45. );
  46. }
  47. else {
  48. $requirement += array(
  49. 'severity' => REQUIREMENT_OK,
  50. );
  51. }
  52. $requirements['browscap_version'] = $requirement;
  53. }
  54. return $requirements;
  55. }
  56. /**
  57. * Implements hook_uninstall().
  58. */
  59. function browscap_uninstall() {
  60. variable_del('browscap_imported');
  61. variable_del('browscap_version');
  62. variable_del('browscap_enable_automatic_updates');
  63. variable_del('browscap_automatic_updates_timer');
  64. }
  65. /**
  66. * Drop the unused Browscap 1.x statistics table.
  67. */
  68. function browscap_update_7200() {
  69. db_drop_table('browscap_statistics');
  70. }