You are here

function tmgmt_local_task_access in Translation Management Tool 7

Access callback for the local task entity.

Parameters

$op: The operation being performed.

$item: (Optional) A TMGMTLocalTask entity to check access for. If no entity is given, it will be determined whether access is allowed for all entities.

$account: (Optional) The user to check for. Leave it to NULL to check for the global user.

Return value

boolean TRUE if access is allowed, FALSE otherwise.

1 string reference to 'tmgmt_local_task_access'
tmgmt_local_entity_info in translators/tmgmt_local/tmgmt_local.module
Implements hook_entity_info().

File

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

Code

function tmgmt_local_task_access($op, $task = NULL, $account = NULL) {
  if (user_access('administer tmgmt', $account) || user_access('administer translation tasks', $account)) {

    // Administrators can do everything.
    return TRUE;
  }
  if (!$account) {
    global $user;
    $account = $user;
  }

  // @todo - probably need refinement when we introduce more module permissions.
  switch ($op) {
    case 'view':
    case 'update':
      return user_access('provide translation services', $account);
      break;
    case 'unassign':
      return !empty($task->tuid) && $task->tuid == $account->uid && user_access('provide translation services', $account);
  }
}