diff -Naur ../htmlpurifier/htmlpurifier.module htmlpurifier/htmlpurifier.module --- ../htmlpurifier/htmlpurifier.module 2010-04-27 14:55:13.000000000 -0500 +++ htmlpurifier/htmlpurifier.module 2010-04-27 15:08:31.000000000 -0500 @@ -34,35 +34,43 @@ $version = trim($result->data); variable_set('htmlpurifier_version_current', $version); } - /** - * Implementation of hook_init(). + * Implementation of hook_requirements(). * @note * Displays any need to update the HTML Purifier library. */ -function htmlpurifier_init() { - if (user_access('access administration pages')) { - $current = variable_get('htmlpurifier_version_current', FALSE); - if (!$current) { - htmlpurifier_cron(); +function htmlpurifier_requirements($phase) { + $requirements = array(); + switch ($phase) { + // Check at runtime + case 'runtime': $current = variable_get('htmlpurifier_version_current', FALSE); - } - $ours = variable_get('htmlpurifier_version_ours', FALSE); - if (!$ours || version_compare($current, $ours, '>')) { - // Update our version number if it can't be found, or there's a mismatch. - _htmlpurifier_load(); + if (!$current) { + htmlpurifier_cron(); + $current = variable_get('htmlpurifier_version_current', FALSE); + } $ours = variable_get('htmlpurifier_version_ours', FALSE); - } - if ($current && $ours && version_compare($current, $ours, '>')) { - drupal_set_message( - t('Your version of HTML Purifier is currently out of date; '. - 'the most recent version is %version. You can download the latest '. - 'version at htmlpurifier.org. '. - 'To update, place the contents of HTML Purifier\'s library/ folder in '. - 'modules/htmlpurifier/library/.', - array('%version' => $current)), 'warning', FALSE); - } + if (!$ours || version_compare($current, $ours, '>')) { + // Update our version number if it can't be found, or there's a mismatch. + _htmlpurifier_load(); + $ours = variable_get('htmlpurifier_version_ours', FALSE); + } + if ($current && $ours && version_compare($current, $ours, '>')) { + $requirements['htmlpurifier_library'] = array( + 'title' => t('HTML Purifier Library'), + 'value' => t('The library is out of date'), + 'description' => t('Your version of HTML Purifier is currently out of date; '. + 'the most recent version is %version. You can download the latest '. + 'version at htmlpurifier.org. '. + 'To update, place the contents of HTML Purifier\'s library/ folder in '. + 'modules/htmlpurifier/library/.', + array('%version' => $current)), + 'severity' => REQUIREMENT_WARNING, + ); + } + break; } + return $requirements; } /**