user_list.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /* For license terms, see /license.txt */
  3. $language_file = array('document', 'gradebook');
  4. require_once dirname(__FILE__) . '/config.php';
  5. // Course legal
  6. $enabled = api_get_plugin_setting('courselegal', 'tool_enable');
  7. if ($enabled != 'true') {
  8. api_not_allowed(true);
  9. }
  10. if (!api_is_allowed_to_edit()) {
  11. api_not_allowed(true);
  12. }
  13. $legal = CourseLegalPlugin::create();
  14. $courseId = api_get_course_int_id();
  15. $sessionId = api_get_session_id();
  16. $url = api_get_self().'?'.api_get_cidreq();
  17. $action = isset($_GET['action']) ? $_GET['action'] : null;
  18. switch($action) {
  19. case 'resend':
  20. if (isset($_GET['user_id'])) {
  21. $legal->updateMailAgreementLink($_GET['user_id'], $courseId, $sessionId);
  22. header('Location: '.$url);
  23. exit;
  24. }
  25. break;
  26. case 'delete':
  27. if (isset($_GET['user_id'])) {
  28. $legal->deleteUserAgreement($_GET['user_id'], $courseId, $sessionId);
  29. header('Location: '.$url);
  30. exit;
  31. }
  32. break;
  33. }
  34. $order = " ORDER BY firstname, lastname";
  35. $userList = $legal->getUserAgreementList($courseId, $sessionId, $order);
  36. $table = new HTML_Table(array('class' => 'data_table'));
  37. $table->setHeaderContents(0, 0, get_lang('User'));
  38. $table->setHeaderContents(0, 1, $legal->get_lang('WebAgreement'));
  39. $table->setHeaderContents(0, 2, $legal->get_lang('MailAgreement'));
  40. $table->setHeaderContents(0, 3, $legal->get_lang('Actions'));
  41. $row = 1;
  42. $pluginPath = api_get_path(WEB_PLUGIN_PATH).'courselegal/';
  43. if (!empty($userList)) {
  44. foreach ($userList as $user) {
  45. $userName = api_get_person_name($user['firstname'], $user['lastname']);
  46. $webDate = !empty($user['web_agreement_date']) ? api_get_local_time($user['web_agreement_date']) : '-';
  47. $mailDate = !empty($user['mail_agreement_date']) ? api_get_local_time($user['mail_agreement_date']) : '-';
  48. $url = $pluginPath.'user_list.php?action=resend&user_id='.$user['user_id'].'&'.api_get_cidreq();
  49. $link = Display::url(
  50. Display::return_icon('inbox.png', $legal->get_lang('ReSendMailAgreementLink')),
  51. $url
  52. );
  53. $deleteLink = Display::url(
  54. Display::return_icon('delete.png', $legal->get_lang('Delete')),
  55. $pluginPath.'user_list.php?action=delete&user_id='.$user['user_id'].'&'.api_get_cidreq()
  56. );
  57. $table->setCellContents($row, 0, $userName);
  58. $table->setCellContents($row, 1, $webDate);
  59. $table->setCellContents($row, 2, $mailDate);
  60. $table->setCellContents($row, 3, $link.' '.$deleteLink);
  61. $row++;
  62. /*
  63. 'web_agreement' => string '1' (length=1)
  64. 'web_agreement_date' => string '2014-09-30 14:36:30' (length=19)
  65. 'mail_agreement' => string '1' (length=1)
  66. 'mail_agreement_date' => string '2014-09-30 14:43:16' (length=19)
  67. 'mail_agreement_link' => s*/
  68. }
  69. }
  70. $url = $pluginPath.'start.php?'.api_get_cidreq();
  71. $interbreadcrumb[] = array("url" => $url, "name" => $legal->get_lang('CourseLegal'));
  72. Display::display_header($legal->get_lang('UserList'));
  73. $table->display();
  74. Display::display_footer();