tmgmt_handler_field_tmgmt_job_operations.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Field handler which shows the operations for a job.
  4. *
  5. * @todo Remove this once http://drupal.org/node/1435662 is through.
  6. *
  7. * @ingroup views_field_handlers
  8. */
  9. class tmgmt_handler_field_tmgmt_job_operations extends views_handler_field_entity {
  10. function render($values) {
  11. $job = $this->get_value($values);
  12. $element = array();
  13. $element['#theme'] = 'links';
  14. $element['#attributes'] = array('class' => array('inline'));
  15. $uri = $job->uri();
  16. if ($job->isSubmittable() && entity_access('submit', 'tmgmt_job', $job)) {
  17. $element['#links']['submit'] = array(
  18. 'href' => $uri['path'],
  19. 'query' => array('destination' => current_path()),
  20. 'title' => t('submit'),
  21. );
  22. }
  23. else {
  24. $element['#links']['manage'] = array(
  25. 'href' => $uri['path'],
  26. 'title' => t('manage'),
  27. );
  28. }
  29. if ($job->isAbortable() && entity_access('submit', 'tmgmt_job', $job)) {
  30. $element['#links']['cancel'] = array(
  31. 'href' => 'admin/tmgmt/jobs/' . $job->tjid . '/abort',
  32. 'query' => array('destination' => current_path()),
  33. 'title' => t('abort'),
  34. );
  35. }
  36. if ($job->isDeletable() && user_access('administer tmgmt')) {
  37. $element['#links']['delete'] = array(
  38. 'href' => 'admin/tmgmt/jobs/' . $job->tjid . '/delete',
  39. 'query' => array('destination' => current_path()),
  40. 'title' => t('delete'),
  41. );
  42. }
  43. return drupal_render($element);
  44. }
  45. }