user_list.php 3.0 KB

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