diff --git a/jquery_update.install b/jquery_update.install index b5a9204..a944585 100644 --- a/jquery_update.install +++ b/jquery_update.install @@ -20,6 +20,19 @@ function jquery_update_requirements($phase) { 'severity' => REQUIREMENT_OK, 'value' => t('jQuery %jquery (configure) and jQuery UI %ui', array('%jquery' => $jquery['version'], '%ui' => $ui['version'], '@link' => url('admin/config/development/jquery_update'))), ); + + if (!jquery_update_meets_min_requirement()) { + $requirements['jquery_update_min_version'] = array( + 'severity' => REQUIREMENT_ERROR, + 'title' => $t('jQuery Update minimum version'), + 'value' => variable_get('jquery_update_jquery_version'), + 'description' => $t('The minimum required version of jQuery for the current set of modules is !minimum, current version is set to !current.', array( + '!minimum' => jquery_update_min_requirement(), + '!current' => variable_get('jquery_update_jquery_version'), + ) + ), + ); + } } return $requirements; diff --git a/jquery_update.module b/jquery_update.module index 68bb8c2..51a123c 100644 --- a/jquery_update.module +++ b/jquery_update.module @@ -635,3 +635,45 @@ function jquery_update_jqueryui_local(&$javascript, $path, $min, $names) { $javascript[$name]['version'] = '1.10.2'; } } + +/** + * Determine the current environment's minimal jQuery version requirement. + * + * @return string + * The minimum required jQuery version. + */ +function jquery_update_min_requirement() { + $jquery_min = &drupal_static(__FUNCTION__); + + if (!isset($jquery_min)) { + $infos = db_select('system', 's') + ->fields('s', array('info')) + ->execute() + ->fetchCol(); + + // Determine highest minimum. + $jquery_min = array_reduce($infos, function($carry, $item) { + $info = unserialize($item); + if (isset($info['jquery']) && version_compare($info['jquery'], $carry) == 1) { + return $info['jquery']; + } + return $carry; + }); + } + + return $jquery_min; +} + +/** + * Determine if the current jQuery version meets the minimum requirement. + * + * @return bool + * Whether the current version of jQuery meets the minimum requirement. + */ +function jquery_update_meets_min_requirement() { + if (version_compare(variable_get('jquery_update_jquery_version'), jquery_update_min_requirement()) == -1) { + return false; + } + + return true; +}