2015-10-03 20:13:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file
|
2017-06-28 17:35:09 +02:00
|
|
|
* Farm access hooks implemented by farm access module.
|
2015-10-03 20:13:30 +02:00
|
|
|
*/
|
|
|
|
|
2017-06-22 23:03:00 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
2018-12-20 18:58:22 +01:00
|
|
|
*
|
|
|
|
* Set up default CRUD permissions for all farm asset entity types.
|
2017-06-22 23:03:00 +02:00
|
|
|
*/
|
|
|
|
function farm_asset_farm_access_perms($role) {
|
2018-12-20 18:58:22 +01:00
|
|
|
|
2018-12-20 19:48:59 +01:00
|
|
|
// Use the helper function to generate a list of entity type bundles
|
|
|
|
// permissions for the given role.
|
|
|
|
$perms = farm_access_entity_bundles_role_perms('farm_asset', $role);
|
2017-06-22 23:03:00 +02:00
|
|
|
|
|
|
|
// Grant access to view farm assets.
|
|
|
|
$perms[] = 'view farm assets';
|
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
2017-09-15 15:18:45 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
|
|
|
function farm_plan_farm_access_perms($role) {
|
|
|
|
|
2018-12-20 19:48:59 +01:00
|
|
|
// Use the helper function to generate a list of entity type bundles
|
|
|
|
// permissions for the given role.
|
|
|
|
$perms = farm_access_entity_bundles_role_perms('farm_plan', $role);
|
2017-09-15 15:18:45 +02:00
|
|
|
|
|
|
|
// Grant access to view farm plans.
|
|
|
|
$perms[] = 'view farm plans';
|
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
2015-10-03 20:13:30 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
2015-10-04 05:31:07 +02:00
|
|
|
function log_farm_access_perms($role) {
|
2015-10-03 20:13:30 +02:00
|
|
|
|
2018-12-20 19:48:59 +01:00
|
|
|
// Use the helper function to generate a list of entity type bundles
|
|
|
|
// permissions for the given role.
|
|
|
|
$perms = farm_access_entity_bundles_role_perms('log', $role);
|
2017-06-22 23:03:00 +02:00
|
|
|
|
2016-10-24 21:19:59 +02:00
|
|
|
// View all logs.
|
|
|
|
$perms[] = 'view all logs';
|
|
|
|
|
2015-10-03 20:13:30 +02:00
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
2015-10-04 05:31:07 +02:00
|
|
|
function node_farm_access_perms($role) {
|
2015-10-03 20:13:30 +02:00
|
|
|
$perms = array();
|
|
|
|
|
|
|
|
// This is needed to view nodes and taxonomy terms.
|
|
|
|
$perms[] = 'access content';
|
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
2015-10-04 05:31:07 +02:00
|
|
|
function system_farm_access_perms($role) {
|
2015-10-03 20:13:30 +02:00
|
|
|
$perms = array();
|
|
|
|
|
|
|
|
// Grant access to admin pages.
|
|
|
|
$perms[] = 'access administration pages';
|
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
2015-10-04 05:31:07 +02:00
|
|
|
function taxonomy_farm_access_perms($role) {
|
2017-06-22 23:03:00 +02:00
|
|
|
|
2018-12-20 22:36:54 +01:00
|
|
|
// Use the helper function to generate a list of entity type bundles
|
|
|
|
// permissions for the given role.
|
|
|
|
$perms = farm_access_entity_bundles_role_perms('taxonomy_term', $role);
|
2017-06-22 23:03:00 +02:00
|
|
|
|
2018-12-20 22:36:54 +01:00
|
|
|
// Load the list of farm roles.
|
|
|
|
$roles = farm_access_roles();
|
2017-06-22 23:03:00 +02:00
|
|
|
|
2018-12-20 22:36:54 +01:00
|
|
|
// If the role has high-level 'edit' access of taxonomy terms, give them the
|
|
|
|
// 'administer taxonomy' permission so that they can add terms.
|
|
|
|
if (!empty($roles[$role]['access']['edit'])) {
|
2015-10-04 05:31:07 +02:00
|
|
|
$perms[] = 'administer taxonomy';
|
|
|
|
}
|
2015-10-03 20:13:30 +02:00
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
2017-06-22 23:15:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
|
|
|
function user_farm_access_perms($role) {
|
|
|
|
$perms = array();
|
|
|
|
|
2018-12-20 20:05:25 +01:00
|
|
|
// Allow all roles to view user profiles.
|
|
|
|
$perms[] = 'access user profiles';
|
|
|
|
|
2017-06-22 23:15:15 +02:00
|
|
|
return $perms;
|
|
|
|
}
|