[svn r18800] change call tu function see FS#3749

skala
Carlos Vargas 16 years ago
parent a3abf3f360
commit ac91794fc0
  1. 38
      main/admin/session_add.php
  2. 33
      main/admin/session_edit.php
  3. 61
      main/inc/lib/sessionmanager.lib.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,25 +111,24 @@ 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');
$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;
@ -138,6 +136,14 @@ $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);
}
?>
<form method="post" name="form" action="<?php echo api_get_self(); ?>" style="margin:0px;">
<input type="hidden" name="formSent" value="1">

@ -60,21 +60,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);
$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);
}
?>
<form method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo $_GET['page'] ?>&id=<?php echo $id; ?>" style="margin:0px;">
@ -110,7 +115,7 @@ api_display_tool_title($tool_name);
<tr>
<td width="30%"><?php echo get_lang('CoachName') ?>&nbsp;&nbsp;</td>
<td width="70%"><select name="id_coach" style="width:250px;">
<option value="0">----- <?php echo get_lang('Choose') ?> -----</option>
<option value="">----- <?php echo get_lang('Choose') ?> -----</option>
<?php
foreach($Coaches as $enreg) {

@ -37,7 +37,17 @@ class SessionManager{
* @author Carlos Vargas <carlos.vargas@dokeos.com>,
* @param array name, year_start,month_start, day_start,year_end,month_end,day_end,nb_days_acess_before,nb_days_acess_after
**/
function 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) {
function CreateSession($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end,$sday_end,$snb_days_acess_before,$snb_days_acess_after,$nolimit,$coach_username) {
$name= trim($sname);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($sday_end);
$nb_days_acess_before = intval($snb_days_acess_before);
$nb_days_acess_after = intval($snb_days_acess_after);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
global $_user;
@ -54,19 +64,25 @@ class SessionManager{
$date_end="000-00-00";
}
if(empty($name)) {
Display::display_normal_message(get_lang('SessionNameIsRequired'));
$msg=get_lang('SessionNameIsRequired');
return $msg;
} elseif (empty($coach_username)) {
Display::display_normal_message(get_lang('CoachIsRequired'));
$msg=get_lang('CoachIsRequired');
return $msg;
} elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start,$day_start,$year_start))) {
Display::display_normal_message(get_lang('InvalidStartDate'));
$msg=get_lang('InvalidStartDate');
return $msg;
} elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end))) {
Display::display_normal_message(get_lang('InvalidEndDate'));
$msg=get_lang('InvalidEndDate');
return $msg;
} elseif(empty($nolimit) && $date_start >= $date_end) {
Display::display_normal_message(get_lang('StartDateShouldBeBeforeEndDate'));
$msg=get_lang('StartDateShouldBeBeforeEndDate');
return $msg;
} else {
$rs = api_sql_query("SELECT 1 FROM $tbl_session WHERE name='".addslashes($name)."'");
if(Database::num_rows($rs)) {
Display::display_normal_message(get_lang('SessionNameSoonExists'));
$msg=get_lang('SessionNameSoonExists');
return $msg;
} else {
api_sql_query("INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end) VALUES('".addslashes($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.")",__FILE__,__LINE__);
$id_session=Database::get_last_insert_id();
@ -79,7 +95,18 @@ class SessionManager{
* @param array name, year_start,month_start, day_start,year_end,month_end,day_end,nb_days_acess_before,nb_days_acess_after,id
* The parameter id is a primary key
**/
function 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) {
function EditSession($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end,$sday_end,$snb_days_acess_before,$snb_days_acess_after,$snolimit,$sid_coach,$id) {
$name=trim(stripslashes($sname));
$year_start=intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($$sday_end);
$id_coach= intval($sid_coach);
$nb_days_acess_before=intval($snb_days_acess_before);
$nb_days_acess_after = intval($snb_days_acess_after);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -94,13 +121,20 @@ class SessionManager{
$date_end="000-00-00";
}
if(empty($name)){
Display::display_normal_message(get_lang('SessionNameIsRequired'));
$msg=get_lang('SessionNameIsRequired');
return $msg;
} elseif (empty($id_coach)) {
$msg=get_lang('CoachIsRequired');
return $msg;
} elseif(!empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start,$day_start,$year_start))) {
Display::display_normal_message(get_lang('InvalidStartDate'));
$msg=get_lang('InvalidStartDate');
return $msg;
} elseif(!empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end))) {
Display::display_normal_message(get_lang('InvalidEndDate'));
$msg=get_lang('InvalidEndDate');
return $msg;
} elseif(!empty($nolimit) && $date_start >= $date_end) {
Display::display_normal_message(get_lang('StartDateShouldBeBeforeEndDate'));
$msg=get_lang('StartDateShouldBeBeforeEndDate');
return $msg;
} else {
$rs = api_sql_query("SELECT id FROM $tbl_session WHERE name='".addslashes($name)."'");
$exists = false;
@ -109,7 +143,8 @@ class SessionManager{
$exists = true;
}
if ($exists) {
Display::display_normal_message(get_lang('SessionNameSoonExists'));
$msg=get_lang('SessionNameSoonExists');
return $msg;
} else {
$sql="UPDATE $tbl_session " .
"SET name='".addslashes($name)."',

Loading…
Cancel
Save