course_log_resources.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.tracking
  5. */
  6. require_once __DIR__.'/../inc/global.inc.php';
  7. $current_course_tool = TOOL_TRACKING;
  8. $from_myspace = false;
  9. $from = isset($_GET['from']) ? $_GET['from'] : null;
  10. // Starting the output buffering when we are exporting the information.
  11. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  12. $exportXls = isset($_GET['export']) && $_GET['export'] == 'xls' ? true : false;
  13. $session_id = intval($_REQUEST['id_session']);
  14. $this_section = SECTION_COURSES;
  15. if ($from == 'myspace') {
  16. $from_myspace = true;
  17. $this_section = 'session_my_space';
  18. }
  19. // Access restrictions.
  20. $is_allowedToTrack = Tracking::isAllowToTrack($session_id);
  21. if (!$is_allowedToTrack) {
  22. api_not_allowed(true);
  23. }
  24. if ($export_csv || $exportXls) {
  25. $csvData = TrackingCourseLog::get_item_resources_data(0, 0, '', '');
  26. array_walk(
  27. $csvData,
  28. function (&$item) {
  29. $item[0] = strip_tags($item[0]);
  30. $item[2] = strip_tags(preg_replace('/\<br(\s*)?\/?\>/i', PHP_EOL, $item[2]));
  31. $item[3] = strip_tags($item[3]);
  32. $item[4] = strip_tags($item[4]);
  33. unset(
  34. $item['col0'],
  35. $item['col1'],
  36. $item['ref'],
  37. $item['col3'],
  38. $item['col6'],
  39. $item['user_id'],
  40. $item['col7']
  41. );
  42. }
  43. );
  44. array_unshift(
  45. $csvData,
  46. [
  47. get_lang('Tool'),
  48. get_lang('EventType'),
  49. get_lang('Session'),
  50. get_lang('UserName'),
  51. get_lang('IPAddress'),
  52. get_lang('Document'),
  53. get_lang('Date'),
  54. ]
  55. );
  56. if ($export_csv) {
  57. Export::arrayToCsv($csvData);
  58. }
  59. if ($exportXls) {
  60. Export::arrayToXls($csvData);
  61. }
  62. die;
  63. }
  64. if (empty($session_id)) {
  65. $session_id = api_get_session_id();
  66. }
  67. // Breadcrumbs.
  68. if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  69. $interbreadcrumb[] = [
  70. 'url' => api_get_path(WEB_CODE_PATH).'admin/index.php',
  71. 'name' => get_lang('PlatformAdmin'),
  72. ];
  73. $interbreadcrumb[] = [
  74. 'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php',
  75. 'name' => get_lang('SessionList'),
  76. ];
  77. $interbreadcrumb[] = [
  78. 'url' => api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.api_get_session_id(),
  79. 'name' => get_lang('SessionOverview'),
  80. ];
  81. }
  82. $nameTools = get_lang('Tracking');
  83. Display::display_header($nameTools, 'Tracking');
  84. echo '<div class="actions">';
  85. echo TrackingCourseLog::actionsLeft('resources', api_get_session_id());
  86. echo '<span style="float:right; padding-top:0px;">';
  87. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
  88. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).
  89. '</a>';
  90. $addional_param = '';
  91. if (isset($_GET['additional_profile_field'])) {
  92. $addional_param = 'additional_profile_field='.intval($_GET['additional_profile_field']);
  93. }
  94. $users_tracking_per_page = '';
  95. if (isset($_GET['users_tracking_per_page'])) {
  96. $users_tracking_per_page = '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
  97. }
  98. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.$users_tracking_per_page.'">
  99. '.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
  100. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=xls&'.$addional_param.$users_tracking_per_page.'">
  101. '.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
  102. echo '</span>';
  103. echo '</div>';
  104. // Create a search-box.
  105. $form = new FormValidator(
  106. 'search_simple',
  107. 'GET',
  108. api_get_path(WEB_CODE_PATH).'tracking/course_log_resources.php?'.api_get_cidreq().'&id_session'.$session_id,
  109. '',
  110. ['class' => 'form-search'],
  111. false
  112. );
  113. $renderer = $form->defaultRenderer();
  114. $renderer->setCustomElementTemplate('<span>{element}</span>');
  115. $form->addElement('text', 'keyword', get_lang('Keyword'));
  116. $form->addElement('hidden', 'cidReq', api_get_course_id());
  117. $form->addElement('hidden', 'id_session', $session_id);
  118. $form->addButtonSearch(get_lang('SearchUsers'), 'submit');
  119. echo '<div class="actions">';
  120. $form->display();
  121. echo '</div>';
  122. $table = new SortableTable(
  123. 'resources',
  124. ['TrackingCourseLog', 'count_item_resources'],
  125. ['TrackingCourseLog', 'get_item_resources_data'],
  126. 6,
  127. 20,
  128. 'DESC'
  129. );
  130. $parameters = [
  131. 'id_session' => $session_id,
  132. 'cidReq' => api_get_course_id(),
  133. ];
  134. $table->set_additional_parameters($parameters);
  135. $table->set_header(0, get_lang('Tool'));
  136. $table->set_header(1, get_lang('EventType'));
  137. $table->set_header(2, get_lang('Session'), false);
  138. $table->set_header(3, get_lang('UserName'), true, 'width=65px');
  139. $table->set_header(4, get_lang('IPAddress'), true, 'width=100px');
  140. $table->set_header(5, get_lang('Document'), false);
  141. $table->set_header(6, get_lang('Date'), true, 'width=190px');
  142. $table->display();
  143. Display::display_footer();