admin.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Special reporting page for admins.
  5. *
  6. * @package chamilo.reporting
  7. */
  8. ob_start();
  9. $cidReset = true;
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. $this_section = SECTION_TRACKING;
  12. $nameTools = get_lang('Administrators');
  13. api_block_anonymous_users();
  14. $interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
  15. Display :: display_header($nameTools);
  16. api_display_tool_title($nameTools);
  17. // Database Table Definitions
  18. $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
  19. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  20. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  21. $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  22. $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  23. $tbl_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
  24. if (isset($_POST['export'])) {
  25. $order_clause = api_is_western_name_order(PERSON_NAME_DATA_EXPORT) ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
  26. } else {
  27. $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
  28. }
  29. $sql = "SELECT user.user_id,lastname,firstname,email
  30. FROM $tbl_user as user, $tbl_admin as admin
  31. WHERE admin.user_id=user.user_id".$order_clause;
  32. $result_admins = Database::query($sql);
  33. if (api_is_western_name_order()) {
  34. echo '<table class="data_table"><tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('Email').'</th></tr>';
  35. } else {
  36. echo '<table class="data_table"><tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('Email').'</th></tr>';
  37. }
  38. if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
  39. $header[] = get_lang('FirstName', '');
  40. $header[] = get_lang('LastName', '');
  41. } else {
  42. $header[] = get_lang('LastName', '');
  43. $header[] = get_lang('FirstName', '');
  44. }
  45. $header[] = get_lang('Email', '');
  46. if (Database::num_rows($result_admins) > 0) {
  47. while ($admins = Database::fetch_array($result_admins)) {
  48. $user_id = $admins["user_id"];
  49. $lastname = $admins["lastname"];
  50. $firstname = $admins["firstname"];
  51. $email = $admins["email"];
  52. if ($i % 2 == 0) {
  53. $css_class = "row_odd";
  54. if ($i % 20 == 0 && $i != 0) {
  55. if (api_is_western_name_order()) {
  56. echo '<tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('Email').'</th></tr>';
  57. } else {
  58. echo '<tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('Email').'</th></tr>';
  59. }
  60. }
  61. } else {
  62. $css_class = "row_even";
  63. }
  64. $i++;
  65. if (api_is_western_name_order()) {
  66. echo "<tr class=".$css_class."><td>$firstname</td><td>$lastname</td><td><a href='mailto:".$email."'>$email</a></td></tr>";
  67. } else {
  68. echo "<tr class=".$css_class."><td>$lastname</td><td>$firstname</td><td><a href='mailto:".$email."'>$email</a></td></tr>";
  69. }
  70. if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
  71. $data[$user_id]["firstname"] = $firstname;
  72. $data[$user_id]["lastname"] = $lastname;
  73. } else {
  74. $data[$user_id]["lastname"] = $lastname;
  75. $data[$user_id]["firstname"] = $firstname;
  76. }
  77. $data[$user_id]["email"] = $email;
  78. }
  79. } else {
  80. // No results
  81. echo '<tr><td colspan="3">'.get_lang('NoResults').'</td></tr>';
  82. }
  83. echo '</table>';
  84. if (isset($_POST['export'])) {
  85. export_csv($header, $data, 'administrators.csv');
  86. }
  87. echo "
  88. <br /><br />
  89. <form method='post' action='admin.php'>
  90. <button type='submit' class='save' name='export' value='".get_lang('ExportExcel')."'>
  91. ".get_lang('ExportExcel')."
  92. </button>
  93. <form>
  94. ";
  95. Display::display_footer();