checklistapi.admin.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * Admin page callback file for the Checklist API module.
  5. */
  6. /**
  7. * Page callback: Form constructor for the report form.
  8. *
  9. * @see checklistapi_menu()
  10. *
  11. * @ingroup forms
  12. */
  13. function checklistapi_report_form() {
  14. $header = array(
  15. t('Checklist'),
  16. t('Progress'),
  17. t('Last updated'),
  18. t('Last updated by'),
  19. t('Operations'),
  20. );
  21. $definitions = checklistapi_get_checklist_info();
  22. if (count($definitions)) {
  23. $rows = array();
  24. foreach ($definitions as $id => $definition) {
  25. $checklist = checklistapi_checklist_load($id);
  26. $row = array();
  27. $row[] = array(
  28. 'data' => ($checklist->userHasAccess()) ? l($checklist->title, $checklist->path) : drupal_placeholder($checklist->title),
  29. 'title' => (!empty($checklist->description)) ? $checklist->description : '',
  30. );
  31. $row[] = t('@completed of @total (@percent%)', array(
  32. '@completed' => $checklist->getNumberCompleted(),
  33. '@total' => $checklist->getNumberOfItems(),
  34. '@percent' => round($checklist->getPercentComplete()),
  35. ));
  36. $row[] = $checklist->getLastUpdatedDate();
  37. $row[] = $checklist->getLastUpdatedUser();
  38. $row[] = ($checklist->userHasAccess('edit') && $checklist->hasSavedProgress()) ? l(t('clear saved progress'), $checklist->path . '/clear', array(
  39. 'query' => array('destination' => 'admin/reports/checklistapi'),
  40. )) : '';
  41. $rows[] = $row;
  42. }
  43. }
  44. else {
  45. $rows[][] = array('data' => t('No checklists available.'), 'colspan' => 5);
  46. }
  47. return theme('table', array('header' => $header, 'rows' => $rows));
  48. }