'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList')); if ( ! isset($_GET['user_id'])) { api_not_allowed(); } $user = api_get_user_info($_GET['user_id']); $tool_name = api_get_person_name($user['firstName'], $user['lastName']).(empty($user['official_code'])?'':' ('.$user['official_code'].')'); Display::display_header($tool_name); $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); if ( isset($_GET['action']) ) { switch($_GET['action']) { case 'unsubscribe': if ( CourseManager::get_user_in_course_status($_GET['user_id'],$_GET['course_code']) == STUDENT) { CourseManager::unsubscribe_user($_GET['user_id'],$_GET['course_code']); Display::display_normal_message(get_lang('UserUnsubscribed')); } else { Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse')); } break; } } api_display_tool_title($tool_name); //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) $statusname = api_get_status_langvars(); $login_as_icon = ''; if (api_is_platform_admin() || (api_is_session_admin() && $row['6'] == $statusname[STUDENT])) { $login_as_icon = ''.Display::return_icon('login_as.gif', get_lang('LoginAs')).''; } echo '
'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'
'; echo ''.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'
'; /** * Show the sessions and the courses in wich this user is subscribed */ echo ''.get_lang('SessionList').'
'; echo ''; $main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); $user_id = $user['user_id']; $result = Database::query("SELECT DISTINCT id, name, date_start, date_end ". " FROM session_rel_user, session ". " WHERE id_session=id AND id_user=$user_id ". " AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00') ". " ORDER BY date_start, date_end, name"); $sessions = Database::store_result($result); /* // Get the list of sessions where the user is subscribed as coach in a course $sql = "SELECT DISTINCT id, name, date_start, date_end FROM $tbl_session as session ". " INNER JOIN $tbl_session_course_user as session_rel_course_rel_user ". " ON session_rel_course_rel_user.id_user = $user_id AND status = 2 ". " AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00') ". " ORDER BY date_start, date_end, name"; $result = Database::query($sql); $session_is_coach = Database::store_result($result); */ $personal_course_list = array(); if (count($sessions)>0) { $header[] = array (get_lang('Code'), true); $header[] = array (get_lang('Title'), true); $header[] = array (get_lang('Status'), true); $header[] = array ('', false); foreach ($sessions as $enreg) { $data = array (); $personal_course_list = array(); $id_session = $enreg['id']; $personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." t, email, " . "course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF((session_course_user.id_user = 3 AND session_course_user.status=2),'2', '5') ". " FROM $tbl_session_course_user as session_course_user INNER JOIN $tbl_course AS course ". " ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session ". " INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id ". " INNER JOIN $tbl_session_course as session_course ". " LEFT JOIN $tbl_user as user ON user.user_id = session_course_user.id_user AND session_course_user.status = 2 ". " WHERE session_course_user.id_user = $user_id ORDER BY i"; $course_list_sql_result = Database::query($personal_course_list_sql); while ($result_row = Database::fetch_array($course_list_sql_result)) { $key = $result_row['id_session'].' - '.$result_row['k']; $result_row['s'] = $result_row['14']; if (!isset($personal_course_list[$key])) { $personal_course_list[$key] = $result_row; } } foreach ($personal_course_list as $my_course) { $row = array (); $row[] = $my_course['k']; $row[] = $my_course['i']; $row[] = $my_course['s'] == STUDENT ? get_lang('Student') : get_lang('Teacher'); $tools = ''.Display::return_icon('synthese_view.gif', get_lang('Overview')).''. ''.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'' . ''.Display::return_icon('edit.gif', get_lang('Edit')).''; if( $my_course->status == STUDENT ){ $tools .= ''.Display::return_icon('delete.gif', get_lang('Delete')).''; } $row[] = $tools; $data[] = $row; } echo $enreg['name']; Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id']))); echo ''; /** * Show the courses in which this user is subscribed */ $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c'. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code '. ' AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' '; $res = Database::query($sql); if (Database::num_rows($res) > 0) { $header=array(); $header[] = array (get_lang('Code'), true); $header[] = array (get_lang('Title'), true); $header[] = array (get_lang('Status'), true); $header[] = array ('', false); $data = array (); while ($course = Database::fetch_object($res)) { $row = array (); $row[] = $course->code; $row[] = $course->title; $row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher'); $tools = ''.Display::return_icon('synthese_view.gif', get_lang('Overview')).''. ''.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'' . ''.Display::return_icon('edit.gif', get_lang('Edit')).''; if ( $course->status == STUDENT ) { $tools .= ''.Display::return_icon('delete.gif', get_lang('Delete')).''; } $row[] = $tools; $data[] = $row; } echo '
'; } } else { echo ''.get_lang('NoSessionsForThisUser').'
'; } echo '
'.get_lang('Courses').'
'; echo ''; Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id']))); echo ''; } else { echo '
'.get_lang('NoCoursesForThisUser').'
'; } /** * Show the classes in which this user is subscribed */ $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER); $table_class = Database :: get_main_table(TABLE_MAIN_CLASS); $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c '. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id'; $res = Database::query($sql); if (Database::num_rows($res) > 0) { $header = array(); $header[] = array (get_lang('ClassName'), true); $header[] = array ('', false); $data = array (); while ($class = Database::fetch_object($res)) { $row = array(); $row[] = $class->name; $row[] = ''.Display::return_icon('synthese_view.gif', get_lang('Overview')).''; $data[] = $row; } echo ''.get_lang('Classes').'
'; echo ''; Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id']))); echo ''; } else { echo '
'.get_lang('NoClassesForThisUser').'
'; } /** * Show the URL in which this user is subscribed */ global $_configuration; if ($_configuration['multiple_access_urls']) { require_once(api_get_path(LIBRARY_PATH).'urlmanager.lib.php'); $url_list= UrlManager::get_access_url_from_user($user['user_id']); if (count($url_list) > 0) { $header = array(); $header[] = array (get_lang('URL'), true); $data = array (); foreach ($url_list as $url) { $row = array(); $row[] = $url['url']; $data[] = $row; } echo ''.get_lang('URLList').'
'; echo ''; Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id']))); echo ''; } else { echo '
'.get_lang('NoUrlForThisUser').'
'; } } /* FOOTER */ Display::display_footer();