tmgmt_handler_field_tmgmt_job_item_operations.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Field handler which shows the operations for a job item.
  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_item_operations extends views_handler_field_entity {
  10. function render($values) {
  11. $item = $this->get_value($values);
  12. $element = array();
  13. $element['#theme'] = 'links';
  14. $element['#attributes'] = array('class' => array('inline'));
  15. $uri = $item->uri();
  16. if ($item->getCountTranslated() > 0 && entity_access('accept', 'tmgmt_job_item', $item)) {
  17. $element['#links']['review'] = array(
  18. 'href' => $uri['path'],
  19. 'query' => array('destination' => current_path()),
  20. 'title' => t('review'),
  21. );
  22. }
  23. // Do not display view on unprocessed jobs.
  24. elseif (!$item->getJob()->isUnprocessed()) {
  25. $element['#links']['view'] = array(
  26. 'href' => $uri['path'],
  27. 'query' => array('destination' => current_path()),
  28. 'title' => t('view'),
  29. );
  30. }
  31. if (user_access('administer tmgmt') && !$item->isAccepted()) {
  32. $element['#links']['delete'] = array(
  33. 'href' => 'admin/tmgmt/items/' . $item->tjiid . '/delete',
  34. 'query' => array('destination' => current_path()),
  35. 'title' => t('delete'),
  36. );
  37. }
  38. return drupal_render($element);
  39. }
  40. }