function crm_core_relationship_access_permissions in CRM Core 8.2
Same name and namespace in other branches
- 8.3 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_access_permissions()
- 8 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_access_permissions()
- 7 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_access_permissions()
Access callback for all relationship permissions
Return value
array $permissions
2 string references to 'crm_core_relationship_access_permissions'
- crm_core_relationship_entity_info_alter in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.module - Implements hook_entity_info_alter().
- crm_core_relationship_ui_menu in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.module - Implements hook_menu().
File
- modules/
crm_core_relationship/ crm_core_relationship.module, line 80 - CRM Core Relationship, handles relationship logic and API.
Code
function crm_core_relationship_access_permissions($relation_type, $op = 'create') {
// $administer_relation_types = user_access('administer relation types');
$administer_relationship_types = user_access('administer contact relationship types');
if (is_object($relation_type)) {
$bundle = $relation_type->relation_type;
}
else {
$bundle = $relation_type;
}
switch ($op) {
case 'admin':
return $administer_relationship_types;
break;
// We are just viewing the list of relationships a contact has here
case 'view_list':
$view_any_relationship = user_access('view relation entities of any contact relationship');
return $administer_relationship_types || $view_any_relationship;
break;
case 'view':
// view a single relationship
$view_any_relationship = user_access('view relation entities of any contact relationship');
$view_type_relationship = user_access('view relation entities of bundle ' . $bundle);
return $administer_relationship_types || $view_any_relationship || $view_type_relationship;
break;
case 'create_view':
// we just need any of the create permissions
$create_any_relationship = user_access('create relation entities of any contact relationship');
$relationships = crm_core_relationship_get_relationships();
$relationship_types = array_keys($relationships);
foreach ($relationship_types as $type) {
$create_type_relationship[] = user_access('create relation entities of bundle ' . $type);
}
// they just need any type of contact type create permission
$create_type_relationship_flag = in_array(TRUE, $create_type_relationship);
return $administer_relationship_types || $create_any_relationship || $create_type_relationship_flag;
break;
case 'create':
default:
$create_any_relationship = user_access('create relation entities of any contact relationship');
$create_type_relationship = user_access('create relation entities of bundle ' . $bundle);
return $administer_relationship_types || $create_any_relationship || $create_type_relationship;
break;
}
return FALSE;
}