You are here

function xmlsitemap_check_status in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_check_status()
  2. 6.2 xmlsitemap.inc \xmlsitemap_check_status()
  3. 2.x xmlsitemap.module \xmlsitemap_check_status()

Check the status of all hook_requirements() from any xmlsitemap modules.

1 call to xmlsitemap_check_status()
xmlsitemap_help in ./xmlsitemap.module
Implements hook_help().

File

./xmlsitemap.inc, line 52
Miscellaneous functions for the xmlsitemap module.

Code

function xmlsitemap_check_status() {
  $messages =& drupal_static(__FUNCTION__);
  if (!isset($messages)) {

    // Cache the list of modules that are checked.
    if ($cache = cache_get('xmlsitemap:registry:requirements')) {
      $modules = $cache->data;
    }
    else {
      $modules = array();
      module_load_all_includes('install');
      foreach (module_implements('requirements') as $module) {
        if (strpos($module, 'xmlsitemap') !== FALSE) {
          $modules[] = $module;
        }
      }
      cache_set('xmlsitemap:registry:requirements', $modules);
    }
    $messages = array();
    foreach ($modules as $module) {
      module_load_install($module);
      $requirements = module_invoke($module, 'requirements', 'runtime');
      foreach ($requirements as $requirement) {
        if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
          $messages[] = $requirement['description'];
        }
      }
    }
    if ($messages) {
      $message = t('One or more problems were detected with your XML sitemap configuration: !messages', array(
        '!messages' => theme('item_list', array(
          'items' => $messages,
        )),
      ));
      if (user_access('access site reports')) {
        $message .= t('Check the <a href="@status-report">status report</a> for more information.', array(
          '@status-report' => url('admin/reports/status'),
        ));
      }
      drupal_set_message($message, 'warning', FALSE);
    }
  }
  return !empty($messages);
}