session_import.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php // $Id: user_import.php,v 1.17 2005/06/22 08:00:31 bmol Exp $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * @package dokeos.admin
  22. ==============================================================================
  23. */
  24. $language_file = array('admin','registration');
  25. $cidReset=true;
  26. include('../inc/global.inc.php');
  27. if(empty($charset))
  28. {
  29. $charset = 'ISO-8859-15';
  30. }
  31. api_protect_admin_script();
  32. include(api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  33. include (api_get_path(LIBRARY_PATH)."/add_course.conf.php");
  34. include_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  35. $formSent=0;
  36. $errorMsg='';
  37. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  38. $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
  39. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  40. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  41. $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  42. $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  43. $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  44. $tool_name=get_lang('ImportSessionListXMLCSV');
  45. $interbreadcrumb[]=array("url" => "index.php","name" => get_lang('AdministrationTools'));
  46. set_time_limit(0);
  47. if($_POST['formSent'])
  48. {
  49. if(isset($_FILES['import_file']['tmp_name']))
  50. {
  51. $formSent=$_POST['formSent'];
  52. $file_type=$_POST['file_type'];
  53. $sendMail=$_POST['sendMail']?1:0;
  54. $sessions=array();
  55. ///////////////////////
  56. //XML/////////////////
  57. /////////////////////
  58. if($file_type == 'xml')
  59. {
  60. $racine = simplexml_load_file($_FILES['import_file']['tmp_name']);
  61. if(is_object($racine))
  62. {
  63. foreach($racine->Users->User as $userNode)
  64. {
  65. $username = mb_convert_encoding($userNode->Username,$charset,'utf-8');
  66. $isCut = 0; // if the username given is too long
  67. if(strlen($username)>20)
  68. {
  69. $user_name_dist = $username;
  70. $username = substr($username,0,20);
  71. $isCut = 1;
  72. }
  73. $sql = "SELECT 1 FROM $tbl_user WHERE username='".addslashes($username)."'";
  74. $rs = api_sql_query($sql, __FILE__, __LINE__);
  75. if(mysql_affected_rows()==0)
  76. {
  77. if($isCut)
  78. {
  79. $errorMsg .= get_lang('UsernameTooLongWasCut').' '.get_lang('From').' '.$user_name_dist.' '.get_lang('To').' '.$username.' <br />';
  80. }
  81. $lastname = mb_convert_encoding($userNode->Lastname,$charset,'utf-8');
  82. $firstname = mb_convert_encoding($userNode->Firstname,$charset,'utf-8');
  83. $password = mb_convert_encoding($userNode->Password,$charset,'utf-8');
  84. if(empty($password))
  85. $password = base64_encode(rand(1000,10000));
  86. $email = mb_convert_encoding($userNode->Email,$charset,'utf-8');
  87. $official_code = mb_convert_encoding($userNode->OfficialCode,$charset,'utf-8');
  88. $phone = mb_convert_encoding($userNode->Phone,$charset,'utf-8');
  89. $status = mb_convert_encoding($userNode->Status,$charset,'utf-8');
  90. switch($status)
  91. {
  92. case 'student' : $status = 5; break;
  93. case 'teacher' : $status = 1; break;
  94. default : $status = 5; $errorMsg = get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
  95. }
  96. $sql = "INSERT INTO $tbl_user SET
  97. username = '".Database::escape_string($username)."',
  98. lastname = '".Database::escape_string($lastname)."',
  99. firstname = '".Database::escape_string($firstname)."',
  100. password = '".($userPasswordCrypted==true ? md5($password) : $password)."',
  101. email = '".Database::escape_string($email)."',
  102. official_code = '".Database::escape_string($official_code)."',
  103. phone = '".Database::escape_string($phone)."',
  104. status = '".Database::escape_string($status)."'";
  105. api_sql_query($sql, __FILE__, __LINE__);
  106. if(mysql_affected_rows()>0 && $sendMail)
  107. {
  108. $emailto='"'.$firstname.' '.$lastname.'" <'.$email.'>';
  109. $emailsubject='['.get_setting('siteName').'] '.get_lang('YourReg').' '.get_setting('siteName');
  110. $emailbody="[NOTE:] ".get_lang('ThisIsAutomaticEmailNoReply').".\n\n".get_lang('langDear')." $firstname $lastname,\n\n".get_lang('langYouAreReg')." ". get_setting('siteName') ." ".get_lang('langSettings')." $username\n". get_lang('langPass')." : $password\n\n".get_lang('langAddress') ." ". get_lang('langIs') ." ". $serverAddress ."\n\n".get_lang('YouWillSoonReceiveMailFromCoach')."\n\n". get_lang('langProblem'). "\n\n". get_lang('langFormula');
  111. //#287 modifiée par Stéphane DEBIEVE - FOREM
  112. $emailheaders='From: '.get_setting('administratorName').' '.get_setting('administratorSurname').' <'.get_setting('emailAdministrator').">\n";
  113. $emailheaders.='Reply-To: '.get_setting('emailAdministrator');
  114. @api_send_mail($emailto,$emailsubject,$emailbody,$emailheaders);
  115. }
  116. }
  117. }
  118. foreach($racine->Courses->Course as $courseNode)
  119. {
  120. $course_code = mb_convert_encoding($courseNode->CourseCode,$charset,'utf-8');
  121. $title = mb_convert_encoding($courseNode->CourseTitle,$charset,'utf-8');
  122. $description = mb_convert_encoding($courseNode->CourseDescription,$charset,'utf-8');
  123. $language = mb_convert_encoding($courseNode->CourseLanguage,$charset,'utf-8');
  124. $username = mb_convert_encoding($courseNode->CourseTeacher,$charset,'utf-8');
  125. $sql = "SELECT user_id, lastname, firstname FROM $tbl_user WHERE username='$username'";
  126. $rs = api_sql_query($sql, __FILE__, __LINE__);
  127. list($user_id, $lastname, $firstname) = mysql_fetch_array($rs);
  128. $keys = define_course_keys($course_code, "", $dbNamePrefix);
  129. if (sizeof($keys))
  130. {
  131. $currentCourseCode = $keys['visual_code'];
  132. $currentCourseId = $keys["currentCourseId"];
  133. if(empty($currentCourseCode))
  134. $currentCourseCode = $currentCourseId;
  135. $currentCourseDbName = $keys["currentCourseDbName"];
  136. $currentCourseRepository = $keys["currentCourseRepository"];
  137. if($currentCourseId == strtoupper($course_code))
  138. {
  139. if (empty ($title))
  140. {
  141. $title = $keys["currentCourseCode"];
  142. }
  143. prepare_course_repository($currentCourseRepository, $currentCourseId);
  144. update_Db_course($currentCourseDbName);
  145. fill_course_repository($currentCourseRepository);
  146. fill_Db_course($currentCourseDbName, $currentCourseRepository, 'french');
  147. //register_course($currentCourseId, $currentCourseCode, $currentCourseRepository, $currentCourseDbName, "$lastname $firstname", $course['unit_code'], addslashes($course['FR']['title']), $language, $user_id);
  148. $sql = "INSERT INTO ".$tbl_course." SET
  149. code = '".$currentCourseId."',
  150. db_name = '".$currentCourseDbName."',
  151. directory = '".$currentCourseRepository."',
  152. course_language = '".$language."',
  153. title = '".$title."',
  154. description = '".lang2db($description)."',
  155. category_code = '',
  156. visibility = '".$defaultVisibilityForANewCourse."',
  157. show_score = '',
  158. disk_quota = NULL,
  159. creation_date = now(),
  160. expiration_date = NULL,
  161. last_edit = now(),
  162. last_visit = NULL,
  163. tutor_name = '".$lastname." ".$firstname."',
  164. visual_code = '".$currentCourseCode."'";
  165. api_sql_query($sql, __FILE__, __LINE__);
  166. $sql = "INSERT INTO ".$tbl_course_user." SET
  167. course_code = '".$currentCourseId."',
  168. user_id = '".$user_id."',
  169. status = '1',
  170. role = '".lang2db('Professor')."',
  171. tutor_id='1',
  172. sort='". ($sort +1)."',
  173. user_course_cat='0'";
  174. api_sql_query($sql, __FILE__, __LINE__);
  175. }
  176. }
  177. }
  178. foreach ($racine->Session as $sessionNode){ // foreach session
  179. $countCourses = 0;
  180. $countUsers = 0;
  181. $SessionName = mb_convert_encoding($sessionNode->SessionName,$charset,'utf-8');
  182. $Coach = mb_convert_encoding($sessionNode->Coach,$charset,'utf-8');
  183. if(!empty($Coach)){
  184. $sqlCoach = "SELECT user_id FROM $tbl_user WHERE username='$Coach'";
  185. $rsCoach = api_sql_query($sqlCoach);
  186. list($CoachId) = (mysql_fetch_array($rsCoach));
  187. if(empty($CoachId))
  188. {
  189. $errorMsg .= get_lang('UserDoesNotExist').' : '.$Coach.'<br />';
  190. }
  191. }
  192. $DateStart = $sessionNode->DateStart;
  193. if(!empty($DateStart))
  194. {
  195. list($YearStart,$MonthStart, $DayStart) = explode('-',$DateStart);
  196. if(empty($YearStart) || empty($MonthStart) || empty($DayStart))
  197. {
  198. $errorMsg .= get_lang('WrongDate').' : '.$DateStart.'<br />';
  199. break;
  200. }
  201. else
  202. {
  203. $timeStart = mktime(0,0,0,$MonthStart,$DayStart,$YearStart);
  204. }
  205. $DateEnd = $sessionNode->DateEnd;
  206. if(!empty($DateStart))
  207. {
  208. list($YearEnd,$MonthEnd, $DayEnd) = explode('-',$DateEnd);
  209. if(empty($YearEnd) || empty($MonthEnd) || empty($DayEnd))
  210. {
  211. $errorMsg .= get_lang('WrongDate').' : '.$DateEnd.'<br />';
  212. break;
  213. }
  214. else
  215. {
  216. $timeEnd = mktime(0,0,0,$MonthEnd,$DayEnd,$YearEnd);
  217. }
  218. }
  219. if($timeEnd - $timeStart < 0)
  220. {
  221. $errorMsg .= get_lang('StartDateShouldBeBeforeEndDate').' : '.$DateEnd.'<br />';
  222. }
  223. }
  224. // verify that session doesn't exist
  225. while(!$uniqueName)
  226. {
  227. if($i>1)
  228. $suffix = ' - '.$i;
  229. $sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($SessionName.$suffix).'"';
  230. $rs = api_sql_query($sql, __FILE__, __LINE__);
  231. if(mysql_result($rs,0,0))
  232. {
  233. $i++;
  234. }
  235. else
  236. {
  237. $uniqueName = true;
  238. $SessionName .= $suffix;
  239. }
  240. }
  241. $sqlSession = "INSERT IGNORE INTO $tbl_session SET
  242. name = '".Database::escape_string($SessionName)."',
  243. id_coach = '$CoachId',
  244. date_start = '$DateStart',
  245. date_end = '$DateEnd'";
  246. $rsSession = api_sql_query($sqlSession, __FILE__, __LINE__);
  247. $session_id = mysql_insert_id();
  248. foreach ($sessionNode->User as $userNode){
  249. $username = mb_convert_encoding(substr($userNode->nodeValue(),0,20),$charset,'utf-8');
  250. $sqlUser = "SELECT user_id FROM $tbl_user WHERE username='".Database::escape_string($username)."'";
  251. $rsUser = api_sql_query($sqlUser);
  252. list($user_id) = (mysql_fetch_array($rsUser));
  253. if(!empty($user_id)){
  254. $sql = "INSERT INTO $tbl_session_user SET
  255. id_user='$user_id',
  256. id_session = '$session_id'";
  257. $rsUser = api_sql_query($sql,__FILE__,__LINE__);
  258. if(mysql_affected_rows()){
  259. $countUsers++;
  260. }
  261. }
  262. }
  263. foreach($sessionNode->Course as $courseNode){
  264. $CourseCode = $courseNode->CourseCode;
  265. // verify that the course pointed by the course code node exists
  266. $sql = 'SELECT 1 FROM '.$tbl_course.' WHERE code="'.mysql_escape_string($CourseCode).'"';
  267. $rs = api_sql_query($sql, __FILE__, __LINE__);
  268. if(mysql_num_rows($rs)>0)
  269. { // if the course exists we continue
  270. $Coach = substr($courseNode->Coach,0,20);
  271. if(!empty($Coach)){
  272. $sqlCoach = "SELECT user_id FROM $tbl_user WHERE username='$Coach'";
  273. $rsCoach = api_sql_query($sqlCoach,__FILE__,__LINE__);
  274. list($CoachId) = (mysql_fetch_array($rsCoach));
  275. if(empty($CoachId))
  276. {
  277. $errorMsg .= get_lang('UserDoesNotExist').' : '.$Coach.'<br />';
  278. }
  279. }
  280. else {
  281. $Coach = '';
  282. }
  283. $sqlCourse = "INSERT INTO $tbl_session_course SET
  284. course_code = '$CourseCode',
  285. id_coach='$CoachId',
  286. id_session='$session_id'";
  287. $rsCourse = api_sql_query($sqlCourse,__FILE__,__LINE__);
  288. if(mysql_affected_rows()){
  289. $countCourses++;
  290. $countUsersCourses = 0;
  291. foreach ($courseNode->User as $userNode){
  292. $username = substr($userNode,0,20);
  293. $sqlUser = "SELECT user_id FROM $tbl_user WHERE username='".$username."'";
  294. $rsUser = api_sql_query($sqlUser);
  295. list($user_id) = (mysql_fetch_array($rsUser));
  296. if(!empty($user_id))
  297. {
  298. $sql = "INSERT IGNORE INTO $tbl_session_user SET
  299. id_user='$user_id',
  300. id_session = '$session_id'";
  301. if(mysql_affected_rows())
  302. $countUsers++;
  303. $rsUser = api_sql_query($sql,__FILE__,__LINE__);
  304. $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
  305. id_user='$user_id',
  306. course_code='$CourseCode',
  307. id_session = '$session_id'";
  308. $rsUsers = api_sql_query($sql,__FILE__,__LINE__);
  309. if(mysql_affected_rows())
  310. $countUsersCourses++;
  311. }
  312. else
  313. {
  314. $errorMsg .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
  315. }
  316. }
  317. api_sql_query("UPDATE $tbl_session_course SET nbr_users='$countUsersCourses' WHERE course_code='$CourseCode'",__FILE__,__LINE__);
  318. }
  319. }
  320. else
  321. { // if the course does not exists
  322. $errorMsg .= get_lang('CourseDoesNotExist').' : '.$CourseCode.'<br />';
  323. }
  324. }
  325. api_sql_query("UPDATE $tbl_session SET nbr_users='$countUsers', nbr_courses='$countCourses' WHERE id='$session_id'",__FILE__,__LINE__);
  326. }
  327. }
  328. else
  329. {
  330. $errorMsg .= get_lang('XMLNotValid');
  331. }
  332. }
  333. /////////////////////
  334. // CSV /////////////
  335. ///////////////////
  336. else
  337. {
  338. $content=file($_FILES['import_file']['tmp_name']);
  339. if(!strstr($content[0],';'))
  340. {
  341. $errorMsg=get_lang('NotCSV');
  342. }
  343. else
  344. {
  345. $tag_names=array();
  346. foreach($content as $key=>$enreg)
  347. {
  348. $enreg=explode(';',trim($enreg));
  349. if($key)
  350. {
  351. foreach($tag_names as $tag_key=>$tag_name)
  352. {
  353. $sessions[$key-1][$tag_name]=$enreg[$tag_key];
  354. }
  355. }
  356. else
  357. {
  358. foreach($enreg as $tag_name)
  359. {
  360. $tag_names[]=eregi_replace('[^a-z0-9_-]','',$tag_name);
  361. }
  362. if(!in_array('SessionName',$tag_names) || !in_array('DateStart',$tag_names) || !in_array('DateEnd',$tag_names))
  363. {
  364. $errorMsg=get_lang('NoNeededData');
  365. break;
  366. }
  367. }
  368. }
  369. foreach($sessions as $enreg) {
  370. $SessionName = $enreg['SessionName'];
  371. $DateStart = $enreg['DateStart'];
  372. $DateEnd = $enreg['DateEnd'];
  373. if(!empty($enreg['Coach'])){
  374. $sqlCoach = "SELECT user_id FROM $tbl_user WHERE username='".$enreg['Coach']."'";
  375. $rsCoach = api_sql_query($sqlCoach);
  376. list($Coach) = (mysql_fetch_array($rsCoach));
  377. }
  378. else {
  379. $Coach = '';
  380. }
  381. $sqlSession = "INSERT IGNORE INTO $tbl_session SET
  382. name = '$SessionName',
  383. id_coach = '$Coach',
  384. date_start = '$DateStart',
  385. date_end = '$DateEnd'";
  386. $rsSession = api_sql_query($sqlSession, __FILE__, __LINE__);
  387. $update = false;
  388. if(!mysql_affected_rows($rsSession)){
  389. $update = true;
  390. $sqlSession = "UPDATE $tbl_session SET
  391. id_coach = '$Coach',
  392. date_start = '$DateStart',
  393. date_end = '$DateEnd'
  394. WHERE name = '$SessionName'";
  395. $rsSession = api_sql_query($sqlSession, __FILE__, __LINE__);
  396. $session_id = api_sql_query("SELECT id FROM $tbl_session WHERE name='$SessionName'",__FILE__,__LINE__);
  397. list($session_id) = mysql_fetch_array($session_id);
  398. api_sql_query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'",__FILE__,__LINE__);
  399. api_sql_query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'",__FILE__,__LINE__);
  400. api_sql_query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'",__FILE__,__LINE__);
  401. }
  402. else {
  403. $session_id = mysql_insert_id($rsSession);
  404. }
  405. $users = explode('|',$enreg['Users']);
  406. foreach ($users as $user){
  407. $sqlUser = "SELECT user_id FROM $tbl_user WHERE username='".$user."'";
  408. $rsUser = api_sql_query($sqlUser);
  409. list($user_id) = (mysql_fetch_array($rsUser));
  410. $sql = "INSERT INTO $tbl_session_user SET
  411. id_user='$user_id',
  412. id_session = '$session_id'";
  413. $rsUser = api_sql_query($sql,__FILE__,__LINE__);
  414. if(mysql_affected_rows()){
  415. $countUsers++;
  416. }
  417. }
  418. $courses = explode('|',$enreg['Courses']);
  419. foreach($courses as $course){
  420. $CourseCode = substr($course,0,strpos($course,'['));
  421. $Coach = strstr($course,'[');
  422. $Coach = substr($Coach,1,strpos($Coach,']')-1);
  423. if(!empty($Coach)){
  424. $sqlCoach = "SELECT user_id FROM $tbl_user WHERE username='$Coach'";
  425. $rsCoach = api_sql_query($sqlCoach,__FILE__,__LINE__);
  426. list($Coach) = (mysql_fetch_array($rsCoach));
  427. }
  428. else {
  429. $Coach = '';
  430. }
  431. $sqlCourse = "INSERT INTO $tbl_session_course SET
  432. course_code = '$CourseCode',
  433. id_coach='$Coach',
  434. id_session='$session_id'";
  435. $rsCourse = api_sql_query($sqlCourse,__FILE__,__LINE__);
  436. if(mysql_affected_rows()){
  437. $countCourses++;
  438. $users = substr($course , strpos($course,'[',1)+1 , strpos($course,']',1));
  439. $users = explode('|',$enreg['Users']);
  440. $countUsersCourses = 0;
  441. foreach ($users as $user){
  442. $sqlUser = "SELECT user_id FROM $tbl_user WHERE username='".$user."'";
  443. $rsUser = api_sql_query($sqlUser);
  444. list($user_id) = (mysql_fetch_array($rsUser));
  445. $sql = "INSERT INTO $tbl_session_course_user SET
  446. id_user='$user_id',
  447. course_code='$CourseCode',
  448. id_session = '$session_id'";
  449. $rsUsers = api_sql_query($sql,__FILE__,__LINE__);
  450. if(mysql_affected_rows())
  451. $countUsersCourses++;
  452. }
  453. api_sql_query("UPDATE $tbl_session_course SET nbr_users='$countUsersCourses' WHERE course_code='$CourseCode'",__FILE__,__LINE__);
  454. }
  455. }
  456. api_sql_query("UPDATE $tbl_session SET nbr_users='$countUsers', nbr_courses='$countCourses' WHERE id='$session_id'",__FILE__,__LINE__);
  457. }
  458. }
  459. }
  460. if(!empty($errorMsg))
  461. {
  462. $errorMsg = get_lang('ButProblemsOccured').' :<br />'.$errorMsg;
  463. }
  464. header('Location: session_list.php?action=show_message&message='.urlencode(get_lang('FileImported').' '.$errorMsg));
  465. }
  466. else
  467. {
  468. $errorMsg = get_lang('NoInputFile');
  469. }
  470. }
  471. Display::display_header($tool_name);
  472. api_display_tool_title($tool_name);
  473. ?>
  474. <form method="post" action="<?php echo api_get_self(); ?>" enctype="multipart/form-data" style="margin:0px;">
  475. <input type="hidden" name="formSent" value="1">
  476. <table border="0" cellpadding="5" cellspacing="0">
  477. <?php
  478. if(!empty($errorMsg))
  479. {
  480. ?>
  481. <tr>
  482. <td colspan="2">
  483. <?php
  484. Display::display_normal_message($errorMsg,false); //main API
  485. ?>
  486. </td>
  487. </tr>
  488. <?php
  489. }
  490. ?>
  491. <tr>
  492. <td nowrap="nowrap"><?php echo get_lang('ImportFileLocation'); ?> :</td>
  493. <td><input type="file" name="import_file" size="30"></td>
  494. </tr>
  495. <tr>
  496. <td nowrap="nowrap" valign="top"><?php echo get_lang('FileType'); ?> :</td>
  497. <td>
  498. <input class="checkbox" type="radio" name="file_type" id="file_type_xml" value="xml" checked="checked" /> <label for="file_type_xml">XML</label> (<a href="exemple.xml" target="_blank"><?php echo get_lang('ExampleXMLFile'); ?></a>)<br>
  499. <input class="checkbox" type="radio" name="file_type" id="file_type_csv" value="csv" <?php if($formSent && $file_type == 'csv') echo 'checked="checked"'; ?>> <label for="file_type_csv">CSV</label> (<a href="exempleSession.csv" target="_blank"><?php echo get_lang('ExampleCSVFile'); ?></a>)<br>
  500. </td>
  501. </tr>
  502. <tr>
  503. <td nowrap="nowrap" valign="top"><?php echo get_lang('SendMailToUsers'); ?> :</td>
  504. <td>
  505. <input class="checkbox" type="checkbox" name="sendMail" id="sendMail" value="true" />
  506. </td>
  507. </tr>
  508. <tr>
  509. <td>&nbsp;</td>
  510. <td><input type="submit" value="<?php echo get_lang('Ok'); ?>"></td>
  511. </tr>
  512. </table>
  513. </form>
  514. <font color="gray">
  515. <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  516. <blockquote>
  517. <pre>
  518. <b>SessionName</b>;Coach;<b>DateStart</b>;<b>DateEnd</b>;Users;Courses
  519. <b>xxx</b>;xxx;<b>xxx;xxx</b>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
  520. </pre>
  521. </blockquote>
  522. <p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  523. <blockquote>
  524. <pre>
  525. &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
  526. &lt;Sessions&gt;
  527. &lt;Users&gt;
  528. &lt;User&gt;
  529. &lt;Username&gt;<b>username1</b>&lt;/Username&gt;
  530. &lt;Lastname&gt;xxx&lt;/Lastname&gt;
  531. &lt;Firstname&gt;xxx&lt;/Firstname&gt;
  532. &lt;Password&gt;xxx&lt;/Password&gt;
  533. &lt;Email&gt;xxx@xx.xx&lt;/Email&gt;
  534. &lt;OfficialCode&gt;xxx&lt;/OfficialCode&gt;
  535. &lt;Phone&gt;xxx&lt;/Phone&gt;
  536. &lt;Status&gt;student|teacher&lt;/Status&gt;
  537. &lt;/User&gt;
  538. &lt;/Users&gt;
  539. &lt;Courses&gt;
  540. &lt;Course&gt;
  541. &lt;CourseCode&gt;<b>xxx</b>&lt;/CourseCode&gt;
  542. &lt;CourseTeacher&gt;xxx&lt;/CourseTeacher&gt;
  543. &lt;CourseLanguage&gt;xxx&lt;/CourseLanguage&gt;
  544. &lt;CourseTitle&gt;xxx&lt;/CourseTitle&gt;
  545. &lt;CourseDescription&gt;xxx&lt;/CourseDescription&gt;
  546. &lt;/Course&gt;
  547. &lt;/Courses&gt;
  548. &lt;Session&gt;
  549. <b>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</b>
  550. &lt;Coach&gt;xxx&lt;/Coach&gt;
  551. <b>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</b>
  552. <b>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</b>
  553. &lt;User&gt;xxx&lt;/User&gt;
  554. &lt;User&gt;xxx&lt;/User&gt;
  555. &lt;Course&gt;
  556. &lt;CourseCode&gt;coursecode1&lt;/CourseCode&gt;
  557. &lt;Coach&gt;coach1&lt;/Coach&gt;
  558. &lt;User&gt;username1&lt;/User&gt;
  559. &lt;User&gt;username2&lt;/User&gt;
  560. &lt;/Course&gt;
  561. &lt;/Session&gt;
  562. &lt;/Sessions&gt;
  563. </pre>
  564. </blockquote>
  565. </font>
  566. <?php
  567. /*
  568. ==============================================================================
  569. FOOTER
  570. ==============================================================================
  571. */
  572. Display::display_footer();
  573. ?>