You are here

function flag_features_revert in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag.features.inc \flag_features_revert()
  2. 7.2 includes/flag.features.inc \flag_features_revert()

Implements hook_features_revert().

Parameters

$module: The name of module for which to revert content.

File

includes/flag.features.inc, line 59
Features integration for Flag module.

Code

function flag_features_revert($module = NULL) {

  // Get default flags from features.
  if (module_hook($module, 'flag_default_flags')) {
    module_load_include('inc', 'flag', '/includes/flag.admin');
    $default_flags = module_invoke($module, 'flag_default_flags');

    // Revert flags that are defined in code.
    foreach ($default_flags as $flag_name => $flag_info) {
      if (is_numeric($flag_name)) {

        // Backward compatibility.
        $flag_name = $flag_info['name'];
      }
      $flag = flag_load($flag_name, TRUE);
      if ($flag && $flag
        ->revert() === FALSE) {
        drupal_set_message(t('Could not revert flag %flag-name to the state described in your code: Your flag was created by a different version of the Flag module than is now being used.', array(
          '%flag-name' => $flag->name,
        )), 'error');
      }
    }
    _flag_clear_cache();
  }
}