splashify.install 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * @file
  4. * Handles installing, uninstalling and the requirements for Splashify.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. *
  9. * Make sure the jStorage library is installed on the site.
  10. */
  11. function splashify_requirements($phase) {
  12. $requirements = array();
  13. $t = get_t();
  14. // Make sure we we can access the necessary libraries.
  15. if ($phase == 'runtime') {
  16. // jStorage
  17. $jstorage = libraries_detect('jstorage');
  18. $installed = ($jstorage && !empty($jstorage['installed']));
  19. if ($installed) {
  20. // Check PHPMailer file integrity.
  21. $path = DRUPAL_ROOT . '/' . $jstorage['library path'] . '/';
  22. $file_integrity = file_exists($path . 'jstorage.min.js');
  23. if (!$file_integrity) {
  24. $requirements['splashify_jstorage_integrity'] = array(
  25. 'title' => $t('Splashify library file integrity'),
  26. 'description' => $t('Cannot find the file "jstorage.min.js".'),
  27. 'value' => '',
  28. 'severity' => REQUIREMENT_ERROR,
  29. );
  30. }
  31. }
  32. else {
  33. $requirements['splashify_jstorage'] = array(
  34. 'title' => $t('Splashify'),
  35. 'description' => $t('The jStorage library could not be found. See the README.txt file for more information.'),
  36. 'value' => '',
  37. 'severity' => REQUIREMENT_ERROR,
  38. );
  39. }
  40. // Mobile Detect
  41. $is_mobile_enabled = variable_get('splashify_when_mobile', 0);
  42. if ($is_mobile_enabled) {
  43. // Verify the Mobile Detect library is installed.
  44. $mobile_detect = libraries_load('Mobile_Detect');
  45. if (!$mobile_detect['installed']) {
  46. $requirements['splashify_Mobile_Detect'] = array(
  47. 'title' => $t('Splashify'),
  48. 'description' => $t('Mobile splash is enabled, but could not find the Mobile Detect library. See the readme.'),
  49. 'value' => '',
  50. 'severity' => REQUIREMENT_ERROR,
  51. );
  52. }
  53. }
  54. }
  55. return $requirements;
  56. }
  57. /**
  58. * Implements hook_uninstall().
  59. *
  60. * Deletes all of the variables this module creates via variable_set().
  61. */
  62. function splashify_uninstall() {
  63. variable_del('splashify_when_anonymous');
  64. variable_del('disable_referrer_check');
  65. // Desktop variables.
  66. variable_del('splashify_when_desktop_frequency');
  67. variable_del('splashify_where_desktop_page');
  68. variable_del('splashify_where_desktop_listpages');
  69. variable_del('splashify_where_desktop_opposite');
  70. variable_del('splashify_what_desktop_mode');
  71. variable_del('splashify_what_desktop_content');
  72. variable_del('splashify_what_desktop_pagetitle');
  73. variable_del('splashify_how_desktop_mode');
  74. variable_del('splashify_how_desktop_size');
  75. variable_del('splashify_when_roles');
  76. variable_del('splashify_when_roles_options');
  77. // Mobile variables.
  78. variable_del('splashify_when_mobile');;
  79. variable_del('splashify_when_mobile_test');
  80. variable_del('splashify_when_mobile_frequency');
  81. variable_del('splashify_where_mobile_page');
  82. variable_del('splashify_where_mobile_listpages');
  83. variable_del('splashify_where_mobile_opposite');
  84. variable_del('splashify_what_mobile_mode');
  85. variable_del('splashify_what_mobile_content');
  86. variable_del('splashify_what_mobile_pagetitle');
  87. variable_del('splashify_how_mobile_mode');
  88. }