From 128ca5b7a0a10c3d04dc06f60ef92626f9b71f05 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 20 May 2015 16:00:03 +0200 Subject: [PATCH] Move session CRUD files inside main/session, instead main/admin See BT#4296 --- main/admin/index.php | 10 +- .../add_courses_to_session.php | 0 .../add_users_to_session.php | 0 main/{admin => session}/resume_session.php | 988 +++++++++--------- main/{admin => session}/session_add.php | 0 .../session_course_edit.php | 344 +++--- .../session_course_user.php | 0 .../session_course_user_list.php | 0 main/{admin => session}/session_edit.php | 0 main/{admin => session}/session_export.php | 0 main/{admin => session}/session_import.php | 0 main/{admin => session}/session_list.php | 0 12 files changed, 672 insertions(+), 670 deletions(-) rename main/{admin => session}/add_courses_to_session.php (100%) mode change 100755 => 100644 rename main/{admin => session}/add_users_to_session.php (100%) mode change 100755 => 100644 rename main/{admin => session}/resume_session.php (97%) mode change 100755 => 100644 rename main/{admin => session}/session_add.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_course_edit.php (97%) mode change 100755 => 100644 rename main/{admin => session}/session_course_user.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_course_user_list.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_edit.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_export.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_import.php (100%) mode change 100755 => 100644 rename main/{admin => session}/session_list.php (100%) mode change 100755 => 100644 diff --git a/main/admin/index.php b/main/admin/index.php index 81dfadeda3..9958d809d7 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -290,11 +290,13 @@ $search_form = '
0) { - $rows_session_category = Database::store_result($rs); - $rows_session_category = $rows_session_category[0]; - $session_category = $rows_session_category['name']; -} - -$action = isset($_GET['action']) ? $_GET['action'] : null; - -$url_id = api_get_current_access_url_id(); - -switch ($action) { - case 'move_up': - SessionManager::moveUp($sessionId, $_GET['course_id']); - header('Location: resume_session.php?id_session='.$sessionId); - exit; - break; - case 'move_down': - SessionManager::moveDown($sessionId, $_GET['course_id']); - header('Location: resume_session.php?id_session='.$sessionId); - exit; - break; - case 'add_user_to_url': - $user_id = $_REQUEST['user_id']; - $result = UrlManager::add_user_to_url($user_id, $url_id); - $user_info = api_get_user_info($user_id); - if ($result) { - $message = Display::return_message( - get_lang('UserAdded').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']), - 'confirm' - ); - } - break; - case 'delete': - // Delete course from session. - $idChecked = isset($_GET['idChecked']) ? $_GET['idChecked'] : null; - if (is_array($idChecked)) { - $usersToDelete = array(); - foreach ($idChecked as $courseCode) { - // forcing the escape_string - $courseInfo = api_get_course_info($courseCode); - SessionManager::unsubscribe_course_from_session( - $sessionId, - $courseInfo['real_id'] - ); - } - } - - if (!empty($_GET['class'])) { - $result = Database::query("DELETE FROM $tbl_session_rel_class - WHERE session_id='$sessionId' AND class_id=".intval($_GET['class'])); - $nbr_affected_rows = Database::affected_rows($result); - Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$sessionId'"); - } - - if (!empty($_GET['user'])) { - SessionManager::unsubscribe_user_from_session( - $sessionId, - $_GET['user'] - ); - } - break; -} -Display::display_header($tool_name); - -if (!empty($_GET['warn'])) { - Display::display_warning_message(urldecode($_GET['warn'])); -} - -if (!empty($message)) { - echo $message; -} - -echo Display::page_header( - Display::return_icon('session.png', get_lang('Session')).' '.$session['name'] -); - -$url = Display::url( - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), - "session_edit.php?page=resume_session.php&id=$sessionId" -); -echo Display::page_subheader(get_lang('GeneralProperties').$url); - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -getDataAndFormattedValues($sessionId); - -foreach ($extraFieldData as $displayExtraField) { -?> - - - - -'; - echo ''; -} - -$sessionInfo = api_get_session_info($sessionId); -echo ''; -echo ''; - -?> - - - - - - - - -
:
: - -
- : - - -
- : - - -
- : - - -
'; - echo 'URL'; - echo ''; - $url_list = UrlManager::get_access_url_from_session($sessionId); - foreach ($url_list as $url_data) { - echo $url_data['url'].'
'; - } - echo '
'; -echo get_lang('Duration'); -echo ''; -echo $sessionInfo['duration'].' '; -echo get_lang('Days'); -echo '
-
- - - - - - - - - - - - - - '; -} else { - // select the courses - - $orderBy = "ORDER BY position"; - $sql = "SELECT c.id, code, title, visual_code, nbr_users - FROM $tbl_course c INNER JOIN $tbl_session_rel_course sc - ON (c.id = sc.c_id) - WHERE - sc.c_id = c.id AND - session_id='$sessionId' - $orderBy"; - - $result = Database::query($sql); - $courses = Database::store_result($result); - $count = 0; - - foreach ($courses as $course) { - //select the number of users - $sql = "SELECT count(*) - FROM $tbl_session_rel_user sru, - $tbl_session_rel_course_rel_user srcru - WHERE - srcru.user_id = sru.user_id AND - srcru.session_id = sru.session_id AND - srcru.c_id = '".intval($course['id'])."' AND - sru.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND - srcru.session_id = '".intval($sessionId)."'"; - - $rs = Database::query($sql); - $course['nbr_users'] = Database::result($rs, 0, 0); - - // Get coachs of the courses in session - - $sql = "SELECT user.lastname, user.firstname, user.username - FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user - WHERE - session_rcru.user_id = user.user_id AND - session_rcru.session_id = '".intval($sessionId)."' AND - session_rcru.c_id ='".intval($course['id'])."' AND - session_rcru.status=2"; - $rs = Database::query($sql); - - $coachs = array(); - if (Database::num_rows($rs) > 0) { - while($info_coach = Database::fetch_array($rs)) { - $coachs[] = api_get_person_name($info_coach['firstname'], $info_coach['lastname']).' ('.$info_coach['username'].')'; - } - } else { - $coach = get_lang('None'); - } - - if (count($coachs) > 0) { - $coach = implode('
',$coachs); - } else { - $coach = get_lang('None'); - } - - $orderButtons = null; - - $upIcon = 'up.png'; - $urlUp = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_up'; - - if ($count == 0) { - $upIcon = 'up_na.png'; - $urlUp = '#'; - } - - $orderButtons = Display::url( - Display::return_icon($upIcon, get_lang('MoveUp')), - $urlUp - ); - - $downIcon = 'down.png'; - $downUrl = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_down'; - - if ($count +1 == count($courses)) { - $downIcon = 'down_na.png'; - $downUrl = '#'; - } - - $orderButtons .= Display::url( - Display::return_icon($downIcon, get_lang('MoveDown')), - $downUrl - ); - - //hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb - echo ' - - - - - - '; - $count++; - } -} -?> -
'.get_lang('NoCoursesForThisSession').'
'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$sessionId),''.$coach.''.$course['nbr_users'].' - '.Display::return_icon('course_home.gif', get_lang('Course')).' - '.$orderButtons.' - '.Display::return_icon('user.png', get_lang('Edit'), '', ICON_SIZE_SMALL).' - '.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), null, ICON_SIZE_SMALL).' - '.Display::return_icon('statistics.gif', get_lang('Tracking')).'  - '.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).' - '.Display::return_icon('delete.png', get_lang('Delete')).' -
-
- - 'data_table')); - - $table->setHeaderContents(0, 0, get_lang('User')); - $table->setHeaderContents(0, 1, get_lang('Status')); - $table->setHeaderContents(0, 2, get_lang('Actions')); - - $row = 1; - foreach ($userList as $user) { - $userId = $user['user_id']; - $userInfo = api_get_user_info($userId); - - $userLink = ''. - api_htmlentities($userInfo['complete_name_with_username']).''; - - $reportingLink = Display::url( - Display::return_icon('statistics.gif', get_lang('Reporting')), - api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$user['user_id'].''.$orig_param - ); - - $courseUserLink = Display::url( - Display::return_icon('course.gif', get_lang('BlockCoursesForThisUser')), - api_get_path(WEB_CODE_PATH).'admin/session_course_user.php?id_user='.$user['user_id'].'&id_session='.$sessionId - ); - - $removeLink = Display::url( - Display::return_icon('delete.png', get_lang('Delete')), - api_get_self().'?id_session='.$sessionId.'&action=delete&user='.$user['user_id'], - array('onclick' => "javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;") - ); - - $addUserToUrlLink= ''; - if ($multiple_url_is_on) { - if ($user['access_url_id'] != $url_id) { - $userLink .= ' '.Display::return_icon( - 'warning.png', - get_lang('UserNotAddedInURL'), - array(), - ICON_SIZE_SMALL - ); - $add = Display::return_icon( - 'add.png', - get_lang('AddUsersToURL'), - array(), - ICON_SIZE_SMALL - ); - $addUserToUrlLink = ''.$add.''; - } - } - - $editUrl = null; - if (isset($sessionInfo['duration']) && !empty($sessionInfo['duration'])) { - $editUrl = api_get_path(WEB_CODE_PATH) . 'admin/session_user_edit.php?session_id=' . $sessionId . '&user_id=' . $userId; - $editUrl = Display::url( - Display::return_icon('agenda.png', get_lang('SessionDurationEdit')), - $editUrl - ); - } - - $table->setCellContents($row, 0, $userLink); - $link = $reportingLink.$courseUserLink.$removeLink.$addUserToUrlLink.$editUrl; - switch ($user['relation_type']) { - case 1: - $status = get_lang('Drh'); - $link = Display::url( - Display::return_icon('edit.png', get_lang('Edit')), - api_get_path(WEB_CODE_PATH).'admin/dashboard_add_sessions_to_user.php?user='.$userId - ); - break; - default: - $status = get_lang('Student'); - } - - $table->setCellContents($row, 1, $status); - $table->setCellContents($row, 2, $link); - $row++; - } - $table->display(); -} - -Display :: display_footer(); + 'index.php','name' => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); + +$orig_param = '&origin=resume_session'; + +// Database Table Definitions +$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); +$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); +$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); +$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); +$tbl_user = Database::get_main_table(TABLE_MAIN_USER); +$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); +$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); +$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); +$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); + +$sql = 'SELECT + name, + nbr_courses, + nbr_users, + nbr_classes, + DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, + DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, + lastname, + firstname, + username, + session_admin_id, + nb_days_access_before_beginning, + nb_days_access_after_end, + session_category_id, + visibility, + show_description, description + FROM '.$tbl_session.' + LEFT JOIN '.$tbl_user.' + ON id_coach = user_id + WHERE '.$tbl_session.'.id='.$sessionId; + +$rs = Database::query($sql); +$session = Database::store_result($rs); +$session = $session[0]; + +$sql = 'SELECT name FROM '.$tbl_session_category.' + WHERE id = "'.intval($session['session_category_id']).'"'; +$rs = Database::query($sql); +$session_category = ''; + +if (Database::num_rows($rs)>0) { + $rows_session_category = Database::store_result($rs); + $rows_session_category = $rows_session_category[0]; + $session_category = $rows_session_category['name']; +} + +$action = isset($_GET['action']) ? $_GET['action'] : null; + +$url_id = api_get_current_access_url_id(); + +switch ($action) { + case 'move_up': + SessionManager::moveUp($sessionId, $_GET['course_id']); + header('Location: resume_session.php?id_session='.$sessionId); + exit; + break; + case 'move_down': + SessionManager::moveDown($sessionId, $_GET['course_id']); + header('Location: resume_session.php?id_session='.$sessionId); + exit; + break; + case 'add_user_to_url': + $user_id = $_REQUEST['user_id']; + $result = UrlManager::add_user_to_url($user_id, $url_id); + $user_info = api_get_user_info($user_id); + if ($result) { + $message = Display::return_message( + get_lang('UserAdded').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']), + 'confirm' + ); + } + break; + case 'delete': + // Delete course from session. + $idChecked = isset($_GET['idChecked']) ? $_GET['idChecked'] : null; + if (is_array($idChecked)) { + $usersToDelete = array(); + foreach ($idChecked as $courseCode) { + // forcing the escape_string + $courseInfo = api_get_course_info($courseCode); + SessionManager::unsubscribe_course_from_session( + $sessionId, + $courseInfo['real_id'] + ); + } + } + + if (!empty($_GET['class'])) { + $result = Database::query("DELETE FROM $tbl_session_rel_class + WHERE session_id='$sessionId' AND class_id=".intval($_GET['class'])); + $nbr_affected_rows = Database::affected_rows($result); + Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$sessionId'"); + } + + if (!empty($_GET['user'])) { + SessionManager::unsubscribe_user_from_session( + $sessionId, + $_GET['user'] + ); + } + break; +} +Display::display_header($tool_name); + +if (!empty($_GET['warn'])) { + Display::display_warning_message(urldecode($_GET['warn'])); +} + +if (!empty($message)) { + echo $message; +} + +echo Display::page_header( + Display::return_icon('session.png', get_lang('Session')).' '.$session['name'] +); + +$url = Display::url( + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), + "session_edit.php?page=resume_session.php&id=$sessionId" +); +echo Display::page_subheader(get_lang('GeneralProperties').$url); + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +getDataAndFormattedValues($sessionId); + +foreach ($extraFieldData as $displayExtraField) { +?> + + + + +'; + echo ''; +} + +$sessionInfo = api_get_session_info($sessionId); +echo ''; +echo ''; + +?> + + + + + + + + +
:
: + +
+ : + + +
+ : + + +
+ : + + +
'; + echo 'URL'; + echo ''; + $url_list = UrlManager::get_access_url_from_session($sessionId); + foreach ($url_list as $url_data) { + echo $url_data['url'].'
'; + } + echo '
'; +echo get_lang('Duration'); +echo ''; +echo $sessionInfo['duration'].' '; +echo get_lang('Days'); +echo '
+
+ + + + + + + + + + + + + + '; +} else { + // select the courses + + $orderBy = "ORDER BY position"; + $sql = "SELECT c.id, code, title, visual_code, nbr_users + FROM $tbl_course c INNER JOIN $tbl_session_rel_course sc + ON (c.id = sc.c_id) + WHERE + sc.c_id = c.id AND + session_id='$sessionId' + $orderBy"; + + $result = Database::query($sql); + $courses = Database::store_result($result); + $count = 0; + + foreach ($courses as $course) { + //select the number of users + $sql = "SELECT count(*) + FROM $tbl_session_rel_user sru, + $tbl_session_rel_course_rel_user srcru + WHERE + srcru.user_id = sru.user_id AND + srcru.session_id = sru.session_id AND + srcru.c_id = '".intval($course['id'])."' AND + sru.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND + srcru.session_id = '".intval($sessionId)."'"; + + $rs = Database::query($sql); + $course['nbr_users'] = Database::result($rs, 0, 0); + + // Get coachs of the courses in session + + $sql = "SELECT user.lastname, user.firstname, user.username + FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user + WHERE + session_rcru.user_id = user.user_id AND + session_rcru.session_id = '".intval($sessionId)."' AND + session_rcru.c_id ='".intval($course['id'])."' AND + session_rcru.status=2"; + $rs = Database::query($sql); + + $coachs = array(); + if (Database::num_rows($rs) > 0) { + while($info_coach = Database::fetch_array($rs)) { + $coachs[] = api_get_person_name($info_coach['firstname'], $info_coach['lastname']).' ('.$info_coach['username'].')'; + } + } else { + $coach = get_lang('None'); + } + + if (count($coachs) > 0) { + $coach = implode('
',$coachs); + } else { + $coach = get_lang('None'); + } + + $orderButtons = null; + + $upIcon = 'up.png'; + $urlUp = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_up'; + + if ($count == 0) { + $upIcon = 'up_na.png'; + $urlUp = '#'; + } + + $orderButtons = Display::url( + Display::return_icon($upIcon, get_lang('MoveUp')), + $urlUp + ); + + $downIcon = 'down.png'; + $downUrl = api_get_self().'?id_session='.$sessionId.'&course_id='.$course['id'].'&action=move_down'; + + if ($count +1 == count($courses)) { + $downIcon = 'down_na.png'; + $downUrl = '#'; + } + + $orderButtons .= Display::url( + Display::return_icon($downIcon, get_lang('MoveDown')), + $downUrl + ); + + //hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb + echo ' + + + + + + '; + $count++; + } +} +?> +
'.get_lang('NoCoursesForThisSession').'
'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$sessionId),''.$coach.''.$course['nbr_users'].' + '.Display::return_icon('course_home.gif', get_lang('Course')).' + '.$orderButtons.' + '.Display::return_icon('user.png', get_lang('Edit'), '', ICON_SIZE_SMALL).' + '.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), null, ICON_SIZE_SMALL).' + '.Display::return_icon('statistics.gif', get_lang('Tracking')).'  + '.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).' + '.Display::return_icon('delete.png', get_lang('Delete')).' +
+
+ + 'data_table')); + + $table->setHeaderContents(0, 0, get_lang('User')); + $table->setHeaderContents(0, 1, get_lang('Status')); + $table->setHeaderContents(0, 2, get_lang('Actions')); + + $row = 1; + foreach ($userList as $user) { + $userId = $user['user_id']; + $userInfo = api_get_user_info($userId); + + $userLink = ''. + api_htmlentities($userInfo['complete_name_with_username']).''; + + $reportingLink = Display::url( + Display::return_icon('statistics.gif', get_lang('Reporting')), + api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$user['user_id'].''.$orig_param + ); + + $courseUserLink = Display::url( + Display::return_icon('course.gif', get_lang('BlockCoursesForThisUser')), + api_get_path(WEB_CODE_PATH).'admin/session_course_user.php?id_user='.$user['user_id'].'&id_session='.$sessionId + ); + + $removeLink = Display::url( + Display::return_icon('delete.png', get_lang('Delete')), + api_get_self().'?id_session='.$sessionId.'&action=delete&user='.$user['user_id'], + array('onclick' => "javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;") + ); + + $addUserToUrlLink= ''; + if ($multiple_url_is_on) { + if ($user['access_url_id'] != $url_id) { + $userLink .= ' '.Display::return_icon( + 'warning.png', + get_lang('UserNotAddedInURL'), + array(), + ICON_SIZE_SMALL + ); + $add = Display::return_icon( + 'add.png', + get_lang('AddUsersToURL'), + array(), + ICON_SIZE_SMALL + ); + $addUserToUrlLink = ''.$add.''; + } + } + + $editUrl = null; + if (isset($sessionInfo['duration']) && !empty($sessionInfo['duration'])) { + $editUrl = api_get_path(WEB_CODE_PATH) . 'admin/session_user_edit.php?session_id=' . $sessionId . '&user_id=' . $userId; + $editUrl = Display::url( + Display::return_icon('agenda.png', get_lang('SessionDurationEdit')), + $editUrl + ); + } + + $table->setCellContents($row, 0, $userLink); + $link = $reportingLink.$courseUserLink.$removeLink.$addUserToUrlLink.$editUrl; + switch ($user['relation_type']) { + case 1: + $status = get_lang('Drh'); + $link = Display::url( + Display::return_icon('edit.png', get_lang('Edit')), + api_get_path(WEB_CODE_PATH).'admin/dashboard_add_sessions_to_user.php?user='.$userId + ); + break; + default: + $status = get_lang('Student'); + } + + $table->setCellContents($row, 1, $status); + $table->setCellContents($row, 2, $link); + $row++; + } + $table->display(); +} + +Display :: display_footer(); diff --git a/main/admin/session_add.php b/main/session/session_add.php old mode 100755 new mode 100644 similarity index 100% rename from main/admin/session_add.php rename to main/session/session_add.php diff --git a/main/admin/session_course_edit.php b/main/session/session_course_edit.php old mode 100755 new mode 100644 similarity index 97% rename from main/admin/session_course_edit.php rename to main/session/session_course_edit.php index f067d62953..a9dd90bb20 --- a/main/admin/session_course_edit.php +++ b/main/session/session_course_edit.php @@ -1,172 +1,172 @@ - 'index.php',"name" => get_lang('PlatformAdmin')); -$interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang("SessionList")); -$interbreadcrumb[]=array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview')); -$interbreadcrumb[]=array('url' => "session_course_list.php?id_session=$id_session","name" =>api_htmlentities($session_name,ENT_QUOTES,$charset)); - -$arr_infos = array(); -if (isset($_POST['formSent']) && $_POST['formSent']) { - $formSent = 1; - - // get all tutor by course_code in the session - $sql = "SELECT user_id - FROM $tbl_session_rel_course_rel_user - WHERE session_id = '$id_session' AND c_id = '".$courseId."' AND status = 2"; - $rs_coachs = Database::query($sql); - - $coachs_course_session = array(); - if (Database::num_rows($rs_coachs) > 0){ - while ($row_coachs = Database::fetch_row($rs_coachs)) { - $coachs_course_session[] = $row_coachs[0]; - } - } - - $id_coachs= $_POST['id_coach']; - - if (is_array($id_coachs) && count($id_coachs) > 0) { - - foreach ($id_coachs as $id_coach) { - $id_coach = intval($id_coach); - $rs1 = SessionManager::set_coach_to_course_session($id_coach, $id_session, $courseId); - } - - // set status to 0 other tutors from multiple list - $array_intersect = array_diff($coachs_course_session,$id_coachs); - - foreach ($array_intersect as $nocoach_user_id) { - $rs2 = SessionManager::set_coach_to_course_session( - $nocoach_user_id, - $id_session, - $courseId, - true - ); - } - - header('Location: '.Security::remove_XSS($_GET['page']).'?id_session='.$id_session); - exit(); - } -} else { - $sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user - WHERE session_id = '$id_session' AND c_id = '".$courseId."' AND status = 2 "; - $rs = Database::query($sql); - - if (Database::num_rows($rs) > 0) { - while ($infos = Database::fetch_array($rs)) { - $arr_infos[] = $infos['user_id']; - } - } -} - -$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; - -if (api_is_multiple_url_enabled()) { - $tbl_access_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $access_url_id = api_get_current_access_url_id(); - $sql="SELECT u.user_id,lastname,firstname,username - FROM $tbl_user u LEFT JOIN $tbl_access_rel_user a ON(u.user_id= a.user_id) - WHERE status='1' AND active = 1 AND access_url_id = $access_url_id ".$order_clause; -} else { - $sql="SELECT user_id,lastname,firstname,username - FROM $tbl_user - WHERE status='1' AND active = 1 ".$order_clause; -} - -$result = Database::query($sql); -$coaches = Database::store_result($result); -Display::display_header($tool_name); - -$tool_name = get_lang('ModifySessionCourse'); -api_display_tool_title($tool_name); -?> -
- - - - -
-
-
- -
-
-
-
- -
-
- - -
- -
-
-
-
- -
- 'index.php',"name" => get_lang('PlatformAdmin')); +$interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang("SessionList")); +$interbreadcrumb[]=array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview')); +$interbreadcrumb[]=array('url' => "session_course_list.php?id_session=$id_session","name" =>api_htmlentities($session_name,ENT_QUOTES,$charset)); + +$arr_infos = array(); +if (isset($_POST['formSent']) && $_POST['formSent']) { + $formSent = 1; + + // get all tutor by course_code in the session + $sql = "SELECT user_id + FROM $tbl_session_rel_course_rel_user + WHERE session_id = '$id_session' AND c_id = '".$courseId."' AND status = 2"; + $rs_coachs = Database::query($sql); + + $coachs_course_session = array(); + if (Database::num_rows($rs_coachs) > 0){ + while ($row_coachs = Database::fetch_row($rs_coachs)) { + $coachs_course_session[] = $row_coachs[0]; + } + } + + $id_coachs= $_POST['id_coach']; + + if (is_array($id_coachs) && count($id_coachs) > 0) { + + foreach ($id_coachs as $id_coach) { + $id_coach = intval($id_coach); + $rs1 = SessionManager::set_coach_to_course_session($id_coach, $id_session, $courseId); + } + + // set status to 0 other tutors from multiple list + $array_intersect = array_diff($coachs_course_session,$id_coachs); + + foreach ($array_intersect as $nocoach_user_id) { + $rs2 = SessionManager::set_coach_to_course_session( + $nocoach_user_id, + $id_session, + $courseId, + true + ); + } + + header('Location: '.Security::remove_XSS($_GET['page']).'?id_session='.$id_session); + exit(); + } +} else { + $sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user + WHERE session_id = '$id_session' AND c_id = '".$courseId."' AND status = 2 "; + $rs = Database::query($sql); + + if (Database::num_rows($rs) > 0) { + while ($infos = Database::fetch_array($rs)) { + $arr_infos[] = $infos['user_id']; + } + } +} + +$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; + +if (api_is_multiple_url_enabled()) { + $tbl_access_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); + $access_url_id = api_get_current_access_url_id(); + $sql="SELECT u.user_id,lastname,firstname,username + FROM $tbl_user u LEFT JOIN $tbl_access_rel_user a ON(u.user_id= a.user_id) + WHERE status='1' AND active = 1 AND access_url_id = $access_url_id ".$order_clause; +} else { + $sql="SELECT user_id,lastname,firstname,username + FROM $tbl_user + WHERE status='1' AND active = 1 ".$order_clause; +} + +$result = Database::query($sql); +$coaches = Database::store_result($result); +Display::display_header($tool_name); + +$tool_name = get_lang('ModifySessionCourse'); +api_display_tool_title($tool_name); +?> +
+ +
+ + +
+
+
+ +
+
+
+
+ +
+
+ + +
+ +
+
+
+
+
+
+