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 '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':
$idChecked = $_GET['idChecked'];
if(is_array($idChecked)) {
$my_temp = array();
foreach ($idChecked as $id){
$courseInfo = api_get_course_info($id);
$my_temp[]= $courseInfo['real_id'];// forcing the escape_string
}
$idChecked = $my_temp;
$idChecked = "'".implode("','", $idChecked)."'";
$result = Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id='$id_session' AND c_id IN($idChecked)");
$nbr_affected_rows=Database::affected_rows($result);
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id='$id_session' AND c_id IN($idChecked)");
Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
}
if (!empty($_GET['class'])){
$result = Database::query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' 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='$id_session'");
}
if (!empty($_GET['user'])) {
$result = Database::query("DELETE FROM $tbl_session_rel_user WHERE relation_type<>".SESSION_RELATION_TYPE_RRHH." AND session_id ='$id_session' AND user_id=".intval($_GET['user']));
$nbr_affected_rows = Database::affected_rows($result);
Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'");
$result = Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id ='$id_session' AND user_id=".intval($_GET['user']));
$nbr_affected_rows=Database::affected_rows($result);
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE session_id ='$id_session'");
}
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']);
echo Display::page_subheader(get_lang('GeneralProperties').$url);
?>
: |
|
|
|
: |
|
:
|
|
:
|
|
:
|
|
';
echo 'URL';
echo ' | ';
echo '';
$url_list = UrlManager::get_access_url_from_session($id_session);
foreach($url_list as $url_data) {
echo $url_data['url'].' ';
}
echo ' | ';
}
?>
|
|
|
'.get_lang('NoCoursesForThisSession').' |
';
} else {
// select the courses
$sql = "SELECT c.id, code,title,visual_code, nbr_users
FROM $tbl_course c,$tbl_session_rel_course sc
WHERE c.id = sc.c_id
AND session_id='$id_session'
ORDER BY title";
$result=Database::query($sql);
$courses=Database::store_result($result);
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 = '".Database::escape_string($course['id'])."'AND
sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND
srcru.session_id = '".intval($id_session)."'";
$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($id_session)."' AND
session_rcru.c_id ='".Database::escape_string($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');
}
$orig_param = '&origin=resume_session';
//hide_course_breadcrumb the parameter has been added to hide the
// name of the course, that appeared in the default $interbreadcrumb
echo '
'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session),' |
'.$coach.' |
'.$course['nbr_users'].' |
';
}
}
?>
|
|
'.get_lang('NoUsersForThisSession').' |
';
} else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if ($multiple_url_is_on) {
$sql = "SELECT u.user_id, lastname, firstname, username, access_url_id
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON u.user_id = su.user_id AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH."
LEFT OUTER JOIN $table_access_url_user uu ON (uu.user_id = u.user_id)
WHERE su.session_id = $id_session AND (access_url_id = $url_id OR access_url_id is null )
$order_clause";
} else {
$sql = "SELECT u.user_id, lastname, firstname, username
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON u.user_id = su.user_id AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND su.session_id = ".$id_session.$order_clause;
}
$result = Database::query($sql);
$users = Database::store_result($result);
// change breadcrumb in destination page
$orig_param = '&origin=resume_session&id_session='.$id_session;
foreach ($users as $user) {
$user_link = '';
if (!empty($user['user_id'])) {
$user_link = ''.
api_htmlentities(api_get_person_name($user['firstname'], $user['lastname']),ENT_QUOTES,$charset).' ('.$user['username'].')';
}
$link_to_add_user_in_url = '';
if ($multiple_url_is_on) {
if ($user['access_url_id'] != $url_id) {
$user_link .= ' '.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);
$link_to_add_user_in_url = ''.$add.'';
}
}
echo '
'.$user_link.'
|
'.Display::return_icon('statistics.gif', get_lang('Reporting')).'
'.Display::return_icon('course.gif', get_lang('BlockCoursesForThisUser')).'
'.Display::return_icon('delete.png', get_lang('Delete')).'
'.$link_to_add_user_in_url.'
|
';
}
}
?>