You are here

function tmgmt_job_access in Translation Management Tool 7

Access callback for the job entity.

Parameters

$op: The operation being performed.

$item: (Optional) A TMGMTJob 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.

Related topics

7 calls to tmgmt_job_access()
tmgmt_file_file_download in translators/file/tmgmt_file.module
Implements hook_file_download().
tmgmt_job_item_access in ./tmgmt.module
Access callback for the job item entity.
tmgmt_message_access in ./tmgmt.module
Access callback for the job message entity.
tmgmt_rules_job_accept_translation_access in ./tmgmt.rules.inc
Checks access to rules accept translation action.
tmgmt_rules_job_delete in ./tmgmt.rules.inc
Rules action to delete a translation job.

... See full list

2 string references to 'tmgmt_job_access'
TMGMTDefaultSourceUIController::hook_menu in plugin/tmgmt.ui.source.inc
tmgmt_entity_info in ./tmgmt.module
Implements hook_entity_info().

File

./tmgmt.module, line 515
Main module file for the Translation Management module.

Code

function tmgmt_job_access($op, $job = NULL, $account = NULL) {
  if (user_access('administer tmgmt', $account)) {

    // Administrators can do everything.
    return TRUE;
  }
  switch ($op) {
    case 'create':
      return user_access('create translation jobs', $account);
      break;
    case 'view':
    case 'update':
      return user_access('create translation jobs', $account) || user_access('submit translation jobs', $account) || user_access('accept translation jobs', $account);
      break;
    case 'delete':

      // Only administrators can delete jobs.
      return FALSE;
      break;

    // Custom operations.
    case 'submit':
      return user_access('submit translation jobs');
      break;
    case 'abort':
    case 'resubmit':
      return user_access('submit translation jobs');
      break;
    case 'accept':
      return user_access('accept translation jobs');
      break;
  }
}