You are here

function _cdn_admin_check_requirements in CDN 7.2

Same name and namespace in other branches
  1. 6.2 cdn.admin.inc \_cdn_admin_check_requirements()

Helper function to check if the requirements of the CDN module have been met. If any requirement errors exist, they are aggregated into a single error message and are subsequently displayed.

Return value

The number of requirement errors.

1 call to _cdn_admin_check_requirements()
_cdn_settings_form_prepare in ./cdn.admin.inc

File

./cdn.admin.inc, line 547
Settings administration UI.

Code

function _cdn_admin_check_requirements() {

  // Check run-time requirements of the CDN integration module.
  module_load_install('cdn');
  $requirements = cdn_requirements('runtime');
  $problematic_statuses = array(
    REQUIREMENT_WARNING,
    REQUIREMENT_ERROR,
  );

  // Filter out the requirement errors and display these, with links back to
  // the admin/reports/status page.
  $errors = array();
  foreach ($requirements as $requirement => $details) {
    if (in_array($details['severity'], $problematic_statuses)) {
      $errors[] = $details['description'];
    }
  }
  if (!empty($errors)) {
    drupal_set_message(t('The CDN module has detected the following <em>potential</em>
          problems in its configuration:<br />
          !error-list
          You can also see them on the !status-report.', array(
      '!status-report' => l(t('status report'), 'admin/reports/status'),
      '!error-list' => theme('item_list', array(
        'items' => $errors,
      )),
    )), 'error');
  }
  return count($errors);
}