3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/modules/farm/farm_access
2017-08-29 15:47:44 -04:00
..
farm_access.api.php Move to modules/farm/farm_access in preparation for #2876992. 2017-05-26 09:42:42 -04:00
farm_access.farm_access.inc Implement hook_hook_info() in farm_access module. Move implementations to farm_access.farm_access.inc. 2017-06-28 11:35:36 -04:00
farm_access.info Move to modules/farm/farm_access in preparation for #2876992. 2017-05-26 09:42:42 -04:00
farm_access.install Move to modules/farm/farm_access in preparation for #2876992. 2017-05-26 09:42:42 -04:00
farm_access.module Create a function for loading farm roles. 2017-08-29 15:47:44 -04:00
README.md Delete readme files from all the merged modules and farm_theme (except for some of farm_access/README.md, which is useful to keep). 2017-05-26 10:53:02 -04:00

FARM ACCESS

Provides mechanisms for managing farmOS user access permissions.

Three hooks are provided (see example usage in farm_access.api.php):

  • hook_farm_access_roles() - for defining farm roles
  • hook_farm_access_perms() - for defining farm permissions
  • hook_farm_access_perms_alter() - for altering role permissions defined by other modules

Three roles are provided via hook_farm_access_roles():

  • Farm Manager
  • Farm Worker
  • Farm Viewer

Most farmOS modules implement hook_farm_access_perms() to add their necessary permissions to each of the three roles above. But you can also write a custom module that implements this hook to do the same thing... if you want to craft your own permissions. Or, you can use hook_farm_access_perms_alter() to alter the list of permissions defined by others.

The nice thing about this approach is we can include it in the farmOS distribution (http://drupal.org/project/farm), but if other people want to use a farm_* module individually, and want to define their own permissions, they can do that without a dependency on farm_access. So it's the best of all worlds, I think.

The only catch (right now), is that the permissions are very strictly enforced. If you try to disable certain permissions in the Drupal UI, they will be immediately reset to those defined by modules that implement hook_farm_access_perms(). This is because the module is not super complicated ... it just tries to determine which permissions the role DOES have, and compares it to a list of permissions it SHOULD have... then it adds/removes permissions to sync them up. If this is a problem for someone, they have two choices: don't use the Farm Access module, and do it yourself... or implement hook_farm_access_perms_alter() to make changes to the permissions available to each role.

DEPENDENCIES

Requires Drupal core patch!

Note that this module depends on a patch to Drupal core that ensures vocabulary names are used in the naming of permissions, rather than vocabulary IDs (which can vary from site to site).

Here is the patch: http://www.drupal.org/files/issues/995156-5_portable_taxonomy_permissions_0.patch

And the related issue thread: http://drupal.org/node/995156

This patch is already included in the farmOS distribution.