course_log_resources.php 5.9 KB

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