You are here

function tmgmt_local_field_access in Translation Management Tool 7

Same name and namespace in other branches
  1. 8 translators/tmgmt_local/tmgmt_local.module \tmgmt_local_field_access()

Implements hook_field_access().

File

translators/tmgmt_local/tmgmt_local.module, line 649
Main module file for the local translation module.

Code

function tmgmt_local_field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) {
  if ($field['field_name'] == 'tmgmt_translation_skills' && $entity_type == 'user') {
    $account = !empty($account) ? $account : $GLOBALS['user'];

    // If the field is just being viewed, grant access.
    if ($op == 'view') {
      return TRUE;
    }

    // User can provide transl. services and is dealing with own account.
    if (!empty($entity) && $entity->uid == $account->uid) {
      return user_access('provide translation services', $entity);
    }

    // Administrators are allowed to deal with others only.
    if (user_access('administer tmgmt', $account)) {
      return TRUE;
    }
    return FALSE;
  }
}