session_import_drh.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. $language_file = array('admin', 'registration');
  7. $cidReset = true;
  8. //require_once '../inc/global.inc.php';
  9. $this_section = SECTION_PLATFORM_ADMIN;
  10. api_protect_admin_script(true);
  11. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  12. $form_sent = 0;
  13. $tool_name = get_lang('ImportSessionDrhList');
  14. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  15. $interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('SessionList'));
  16. set_time_limit(0);
  17. $inserted_in_course = array();
  18. // Display the header.
  19. Display::display_header($tool_name);
  20. echo '<div class="actions">';
  21. echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  22. echo '</div>';
  23. if (!empty($error_message)) {
  24. Display::display_normal_message($error_message, 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->addElement('button', 'submit', 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();