filler.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Index of the admin tools.
  5. *
  6. * @package chamilo.admin
  7. */
  8. // resetting the course id
  9. $cidReset = true;
  10. // including some necessary chamilo files
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. // setting the section (for the tabs)
  13. $this_section = SECTION_PLATFORM_ADMIN;
  14. // Access restrictions
  15. api_protect_admin_script(true);
  16. $nameTools = get_lang('Administration');
  17. // setting breadcrumbs
  18. $interbreadcrumb[] = ['url' => 'index.php', 'name' => $nameTools];
  19. // setting the name of the tool
  20. $nameTools = get_lang('Data filler');
  21. $output = [];
  22. if (!empty($_GET['fill'])) {
  23. switch ($_GET['fill']) {
  24. case 'users':
  25. require api_get_path(SYS_TEST_PATH).'datafiller/fill_users.php';
  26. $output = fill_users();
  27. break;
  28. case 'courses':
  29. require api_get_path(SYS_TEST_PATH).'datafiller/fill_courses.php';
  30. $output = fill_courses();
  31. break;
  32. default:
  33. break;
  34. }
  35. }
  36. // Displaying the header
  37. Display::display_header($nameTools);
  38. $result = '';
  39. if (count($output) > 0) {
  40. $result = '<div class="filler-report">'."\n";
  41. $result .= '<h3>'.$output[0]['title'].'</h3>'."\n";
  42. $result .= '<table>';
  43. foreach ($output as $line) {
  44. $result .= '<tr>';
  45. $result .= '<td class="filler-report-data-init">'.$line['line-init'].' </td>
  46. <td class="filler-report-data">'.$line['line-info'].'</td>';
  47. $result .= '</tr>';
  48. }
  49. $result .= '</table>';
  50. $result .= '</div>';
  51. echo Display::return_message($result, 'normal', false);
  52. }
  53. ?>
  54. <div id="datafiller" class="card">
  55. <div class="card-body">
  56. <h4><?php
  57. echo Display::return_icon('bug.png', get_lang('Data filler'), null, ICON_SIZE_MEDIUM).' '.get_lang('Data filler');
  58. ?>
  59. </h4>
  60. <div class="description"><?php echo get_lang('This section is only visible on installations from source code, not in packaged versions of the platform. It will allow you to quickly populate your platform with test data. Use with care (data is really inserted) and only on development or testing installations.'); ?></div>
  61. <ul class="fillers">
  62. <li>
  63. <a href="filler.php?fill=users">
  64. <?php
  65. echo Display::return_icon('user.png', get_lang('Fill users'), null, ICON_SIZE_SMALL).
  66. ' '.get_lang('Fill users');
  67. ?>
  68. </a></li>
  69. <li>
  70. <a href="filler.php?fill=courses">
  71. <?php
  72. echo Display::return_icon('new-course.png', get_lang('Fill courses'), null, ICON_SIZE_SMALL).
  73. ' '.get_lang('Fill courses');
  74. ?>
  75. </a>
  76. </li>
  77. </ul>
  78. </div>
  79. </div>
  80. <?php
  81. /* FOOTER */
  82. Display::display_footer();