session_import_drh.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. api_protect_limit_for_session_admin();
  12. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  13. $form_sent = 0;
  14. $tool_name = get_lang('ImportSessionDrhList');
  15. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  16. $interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('SessionList'));
  17. set_time_limit(0);
  18. $inserted_in_course = array();
  19. // Display the header.
  20. Display::display_header($tool_name);
  21. echo '<div class="actions">';
  22. echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  23. echo '</div>';
  24. if (!empty($error_message)) {
  25. Display::display_normal_message($error_message, false);
  26. }
  27. $form = new FormValidator('import_sessions', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
  28. $form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
  29. $form->addElement('checkbox', 'remove_old_relationships', null, get_lang('RemoveOldRelationships'));
  30. //$form->addElement('checkbox', 'send_email', null, get_lang('SendMailToUsers'));
  31. $form->addElement('button', 'submit', get_lang('ImportSession'));
  32. if ($form->validate()) {
  33. if (isset($_FILES['import_file']['tmp_name']) && !empty($_FILES['import_file']['tmp_name'])) {
  34. $values = $form->exportValues();
  35. $sendMail = isset($values['send_email']) ? true : false;
  36. $removeOldRelationships = isset($values['remove_old_relationships']) ? true : false;
  37. $result = SessionManager::importSessionDrhCSV(
  38. $_FILES['import_file']['tmp_name'],
  39. $sendMail,
  40. $removeOldRelationships
  41. );
  42. echo Display::return_message($result, 'info', false);
  43. } else {
  44. $error_message = get_lang('NoInputFile');
  45. }
  46. }
  47. $form->display();
  48. ?>
  49. <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  50. <blockquote>
  51. <pre>
  52. Username;SessionName;
  53. drh1;Session 1;
  54. drh2;Session 2;
  55. </pre>
  56. </blockquote>
  57. <?php
  58. /* FOOTER */
  59. Display::display_footer();