From 988e72c528942b6e030ee2a5218bfd00b6c87346 Mon Sep 17 00:00:00 2001 From: Julian Prud'homme Date: Mon, 10 Sep 2007 09:46:17 +0200 Subject: [PATCH] [svn r12976] If there is only one session imported, we redirect on the session resume page : http://projects.dokeos.com/?do=details&id=1867 --- main/admin/session_import.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/main/admin/session_import.php b/main/admin/session_import.php index b560e5850d..bb802c31f3 100644 --- a/main/admin/session_import.php +++ b/main/admin/session_import.php @@ -74,7 +74,9 @@ if($_POST['formSent']) /////////////////////// //XML///////////////// ///////////////////// - + + $countSessions = 0; + if($file_type == 'xml') { @@ -215,8 +217,9 @@ if($_POST['formSent']) } } + foreach ($racine->Session as $sessionNode){ // foreach session - + $countCourses = 0; $countUsers = 0; @@ -294,6 +297,8 @@ if($_POST['formSent']) date_end = '$DateEnd'"; $rsSession = api_sql_query($sqlSession, __FILE__, __LINE__); $session_id = mysql_insert_id(); + + $countSessions++; foreach ($sessionNode->User as $userNode){ $username = mb_convert_encoding(substr($userNode->nodeValue,0,20),$charset,'utf-8'); @@ -438,8 +443,9 @@ if($_POST['formSent']) } } } - + foreach($sessions as $enreg) { + $SessionName = $enreg['SessionName']; $DateStart = $enreg['DateStart']; $DateEnd = $enreg['DateEnd']; @@ -478,7 +484,9 @@ if($_POST['formSent']) else { $session_id = mysql_insert_id($rsSession); } - + + $countSessions++; + $users = explode('|',$enreg['Users']); foreach ($users as $user){ $sqlUser = "SELECT user_id FROM $tbl_user WHERE username='".$user."'"; @@ -546,7 +554,15 @@ if($_POST['formSent']) { $errorMsg = get_lang('ButProblemsOccured').' :
'.$errorMsg; } - header('Location: session_list.php?action=show_message&message='.urlencode(get_lang('FileImported').' '.$errorMsg)); + + if($countSessions == 1){ + header('Location: resume_session.php?id_session='.$session_id); + exit; + } + else{ + header('Location: session_list.php?action=show_message&message='.urlencode(get_lang('FileImported').' '.$errorMsg)); + exit; + } } else {