| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- /**
- * @file
- * Handles installing, uninstalling and the requirements for Splashify.
- */
- /**
- * Implements hook_requirements().
- *
- * Make sure the jStorage library is installed on the site.
- */
- function splashify_requirements($phase) {
- $requirements = array();
- $t = get_t();
- // Make sure we we can access the necessary libraries.
- if ($phase == 'runtime') {
- // jStorage
- $jstorage = libraries_detect('jstorage');
- $installed = ($jstorage && !empty($jstorage['installed']));
- if ($installed) {
- // Check PHPMailer file integrity.
- $path = DRUPAL_ROOT . '/' . $jstorage['library path'] . '/';
- $file_integrity = file_exists($path . 'jstorage.min.js');
- if (!$file_integrity) {
- $requirements['splashify_jstorage_integrity'] = array(
- 'title' => $t('Splashify library file integrity'),
- 'description' => $t('Cannot find the file "jstorage.min.js".'),
- 'value' => '',
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- else {
- $requirements['splashify_jstorage'] = array(
- 'title' => $t('Splashify'),
- 'description' => $t('The jStorage library could not be found. See the README.txt file for more information.'),
- 'value' => '',
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- // Mobile Detect
- $is_mobile_enabled = variable_get('splashify_when_mobile', 0);
- if ($is_mobile_enabled) {
- // Verify the Mobile Detect library is installed.
- $mobile_detect = libraries_load('Mobile_Detect');
- if (!$mobile_detect['installed']) {
- $requirements['splashify_Mobile_Detect'] = array(
- 'title' => $t('Splashify'),
- 'description' => $t('Mobile splash is enabled, but could not find the Mobile Detect library. See the readme.'),
- 'value' => '',
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- }
- return $requirements;
- }
- /**
- * Implements hook_uninstall().
- *
- * Deletes all of the variables this module creates via variable_set().
- */
- function splashify_uninstall() {
- variable_del('splashify_when_anonymous');
- variable_del('disable_referrer_check');
- // Desktop variables.
- variable_del('splashify_when_desktop_frequency');
- variable_del('splashify_where_desktop_page');
- variable_del('splashify_where_desktop_listpages');
- variable_del('splashify_where_desktop_opposite');
- variable_del('splashify_what_desktop_mode');
- variable_del('splashify_what_desktop_content');
- variable_del('splashify_what_desktop_pagetitle');
- variable_del('splashify_how_desktop_mode');
- variable_del('splashify_how_desktop_size');
- variable_del('splashify_when_roles');
- variable_del('splashify_when_roles_options');
- // Mobile variables.
- variable_del('splashify_when_mobile');;
- variable_del('splashify_when_mobile_test');
- variable_del('splashify_when_mobile_frequency');
- variable_del('splashify_where_mobile_page');
- variable_del('splashify_where_mobile_listpages');
- variable_del('splashify_where_mobile_opposite');
- variable_del('splashify_what_mobile_mode');
- variable_del('splashify_what_mobile_content');
- variable_del('splashify_what_mobile_pagetitle');
- variable_del('splashify_how_mobile_mode');
- }
|