You are here

function farm_access_compare_perms in farmOS 7

Compares available permissions to actual permissions.

Parameters

string $role: A farm role machine name to get current permissions for.

Return value

array Returns an array with two sub-arrays: 'add': a list of permission strings that should be added 'remove': a list of permission strings that should be removed

1 call to farm_access_compare_perms()
farm_access_sync_perms in modules/farm/farm_access/farm_access.module
Synchronize all available farm permissions farm roles.

File

modules/farm/farm_access/farm_access.module, line 379
Farm Access module.

Code

function farm_access_compare_perms($role) {

  // Get the available perms.
  $available_perms = farm_access_available_perms($role);

  // Get the currently applied perms.
  $current_perms = farm_access_current_perms($role);

  // Determine which perms should be added.
  $compare['add'] = array_diff($available_perms, $current_perms);

  // Determine which perms should be removed.
  $compare['remove'] = array_diff($current_perms, $available_perms);

  // Return the comparison.
  return $compare;
}