session_import_drh.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. $cidReset = true;
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. $this_section = SECTION_PLATFORM_ADMIN;
  9. api_protect_admin_script(true);
  10. api_protect_limit_for_session_admin();
  11. $form_sent = 0;
  12. $tool_name = get_lang('ImportSessionDrhList');
  13. //$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  14. $interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList'));
  15. set_time_limit(0);
  16. $inserted_in_course = array();
  17. // Display the header.
  18. Display::display_header($tool_name);
  19. echo '<div class="actions">';
  20. echo '<a href="../session/session_list.php">'.
  21. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).'</a>';
  22. echo '</div>';
  23. if (!empty($error_message)) {
  24. echo Display::return_message($error_message, 'normal', false);
  25. }
  26. $form = new FormValidator('import_sessions', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
  27. $form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
  28. $form->addElement('checkbox', 'remove_old_relationships', null, get_lang('RemoveOldRelationships'));
  29. //$form->addElement('checkbox', 'send_email', null, get_lang('SendMailToUsers'));
  30. $form->addButtonImport(get_lang('ImportSession'));
  31. if ($form->validate()) {
  32. if (isset($_FILES['import_file']['tmp_name']) && !empty($_FILES['import_file']['tmp_name'])) {
  33. $values = $form->exportValues();
  34. $sendMail = isset($values['send_email']) ? true : false;
  35. $removeOldRelationships = isset($values['remove_old_relationships']) ? true : false;
  36. $result = SessionManager::importSessionDrhCSV(
  37. $_FILES['import_file']['tmp_name'],
  38. $sendMail,
  39. $removeOldRelationships
  40. );
  41. echo Display::return_message($result, 'info', false);
  42. } else {
  43. $error_message = get_lang('NoInputFile');
  44. }
  45. }
  46. $form->display();
  47. ?>
  48. <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  49. <blockquote>
  50. <pre>
  51. Username;SessionName;
  52. drh1;Session 1;
  53. drh2;Session 2;
  54. </pre>
  55. </blockquote>
  56. <?php
  57. /* FOOTER */
  58. Display::display_footer();