From ac91794fc0be84f9fc4fc2322e9eb720c814ff36 Mon Sep 17 00:00:00 2001 From: Carlos Vargas Date: Thu, 5 Mar 2009 00:04:55 +0100 Subject: [PATCH] [svn r18800] change call tu function see FS#3749 --- main/admin/session_add.php | 40 ++++++++++-------- main/admin/session_edit.php | 37 +++++++++-------- main/inc/lib/sessionmanager.lib.php | 63 ++++++++++++++++++++++------- 3 files changed, 93 insertions(+), 47 deletions(-) diff --git a/main/admin/session_add.php b/main/admin/session_add.php index 4ffca2400c..52f070601d 100644 --- a/main/admin/session_add.php +++ b/main/admin/session_add.php @@ -39,7 +39,6 @@ api_protect_admin_script(true); $formSent=0; $errorMsg=''; -$tool_name = get_lang('AddSession'); $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin')); $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang('SessionList')); @@ -112,32 +111,39 @@ function fill_coach_field (username) { if ($_POST['formSent']) { $formSent=1; - $name= trim($_POST['name']); - $year_start= intval($_POST['year_start']); - $month_start=intval($_POST['month_start']); - $day_start=intval($_POST['day_start']); - $year_end=intval($_POST['year_end']); - $month_end=intval($_POST['month_end']); - $day_end=intval($_POST['day_end']); - $nb_days_acess_before = intval($_POST['nb_days_acess_before']); - $nb_days_acess_after = intval($_POST['nb_days_acess_after']); + $name= $_POST['name']; + $year_start= $_POST['year_start']; + $month_start=$_POST['month_start']; + $day_start=$_POST['day_start']; + $year_end=$_POST['year_end']; + $month_end=$_POST['month_end']; + $day_end=$_POST['day_end']; + $nb_days_acess_before = $_POST['nb_days_acess_before']; + $nb_days_acess_after = $_POST['nb_days_acess_after']; $nolimit=$_POST['nolimit']; $coach_username=$_POST['coach_username']; - - $id_session=SessionManager::AddSession($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$coach_username); - header('Location: add_courses_to_session.php?id_session='.$id_session.'&add=true'); - exit(); + $return = SessionManager::CreateSession($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$coach_username); + if ($return == strval(intval($return))) { + // integer => no error on session creation + header('Location: add_courses_to_session.php?id_session='.$return.'&add=true&msg='); + exit(); + } } -Display::display_header($tool_name); -api_display_tool_title($tool_name); - $nb_days_acess_before = 0; $nb_days_acess_after = 0; $thisYear=date('Y'); $thisMonth=date('m'); $thisDay=date('d'); + + +$tool_name = get_lang('AddSession'); +Display::display_header($tool_name); +api_display_tool_title($tool_name); +if (!empty($return)) { + Display::display_error_message($return,false); +} ?>
diff --git a/main/admin/session_edit.php b/main/admin/session_edit.php index 482ecb9cf9..657ac933fd 100644 --- a/main/admin/session_edit.php +++ b/main/admin/session_edit.php @@ -59,21 +59,23 @@ if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id']) { } if ($_POST['formSent']) { - $formSent=1; - $name=trim(stripslashes($_POST['name'])); - $year_start=intval($_POST['year_start']); - $month_start=intval($_POST['month_start']); - $day_start=intval($_POST['day_start']); - $year_end=intval($_POST['year_end']); - $month_end=intval($_POST['month_end']); - $day_end=intval($_POST['day_end']); - $id_coach=intval($_POST['id_coach']); - $nb_days_acess_before = intval($_POST['nb_days_access_before']); - $nb_days_acess_after = intval($_POST['nb_days_access_after']); - - SessionManager::EditSession($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$id_coach,$id); - header('Location: resume_session.php?id_session='.$id); - exit(); + $formSent=1; + $name= $_POST['name']; + $year_start= $_POST['year_start']; + $month_start=$_POST['month_start']; + $day_start=$_POST['day_start']; + $year_end=$_POST['year_end']; + $month_end=$_POST['month_end']; + $day_end=$_POST['day_end']; + $nb_days_acess_before = $_POST['nb_days_acess_before']; + $nb_days_acess_after = $_POST['nb_days_acess_after']; + $nolimit=$_POST['nolimit']; + $id_coach=$_POST['id_coach']; + $return = SessionManager::EditSession($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$id_coach,$id); + if ($return == strval(intval($return))) { + header('Location: resume_session.php?id_session='.$return); + exit(); + } } $sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1' ORDER BY lastname,firstname,username"; @@ -96,6 +98,9 @@ $thisYear=date('Y'); Display::display_header($tool_name); api_display_tool_title($tool_name); +if (!empty($return)) { + Display::display_error_message($return,false); +} ?> @@ -110,7 +115,7 @@ api_display_tool_title($tool_name);