You are here

function block_access_features_revert in Block Access 7

Implements hook_features_revert().

2 calls to block_access_features_revert()
block_access_features_enable_feature in ./block_access.module
Implements hook_features_enable_feature().
block_access_features_rebuild in ./block_access.module
Implements hook_features_revert().

File

./block_access.module, line 749

Code

function block_access_features_revert($module) {
  if ($defaults = features_get_default('block_access', $module)) {

    // Revert.
    foreach ($defaults as $source_module => $perms) {
      module_load_include('inc', 'block_access', 'block_access.db');
      $dbperms = block_access_get_module($source_module);
      $roles = array_flip(user_roles());
      foreach (array_keys($perms) as $role) {
        $perms[$roles[$role]] = $perms[$role];
        unset($perms[$role]);
      }
      if ($dbperms != $perms) {

        // Delete existing config.
        foreach ($perms as $rid => $role_perms) {
          foreach ($role_perms as $perm) {
            block_access_delete_roles($source_module, $perm);
          }
        }

        // Add default config.
        foreach ($perms as $rid => $role_perms) {
          foreach ($role_perms as $perm) {
            block_access_add_role($rid, $source_module, $perm);
          }
        }
      }
    }
  }
}