user_information.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. // $Id: user_information.php 13900 2007-12-04 04:10:41Z yannoo $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) Olivier Brouckaert
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. @author Bart Mollet
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. /*
  27. ==============================================================================
  28. INIT SECTION
  29. ==============================================================================
  30. */
  31. // name of the language file that needs to be included
  32. $language_file = 'admin';
  33. $cidReset = true;
  34. require ('../inc/global.inc.php');
  35. $this_section=SECTION_PLATFORM_ADMIN;
  36. api_protect_admin_script();
  37. require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  38. $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
  39. $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList'));
  40. if( ! isset($_GET['user_id']))
  41. {
  42. api_not_allowed();
  43. }
  44. $user = api_get_user_info($_GET['user_id']);
  45. $tool_name = $user['firstName'].' '.$user['lastName'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
  46. Display::display_header($tool_name);
  47. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  48. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  49. if( isset($_GET['action']) )
  50. {
  51. switch($_GET['action'])
  52. {
  53. case 'unsubscribe':
  54. if( CourseManager::get_user_in_course_status($_GET['user_id'],$_GET['course_code']) == STUDENT)
  55. {
  56. CourseManager::unsubscribe_user($_GET['user_id'],$_GET['course_code']);
  57. Display::display_normal_message(get_lang('UserUnsubscribed'));
  58. }
  59. else
  60. {
  61. Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse'));
  62. }
  63. break;
  64. }
  65. }
  66. api_display_tool_title($tool_name);
  67. echo '<div align="right" style="margin-right:4em;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$_GET['user_id'].'" title="'.get_lang('Reporting').'"><img src="'.api_get_path(WEB_CODE_PATH).'img/statistics.gif" /></a></div>'."\n";
  68. if ($user['picture_uri'] != '')
  69. {
  70. echo '<p><img src="'.api_get_path(WEB_CODE_PATH).'upload/users/'.$user['picture_uri'].'" style="width:150px;"/></p>';
  71. }
  72. echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
  73. echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
  74. /**
  75. * Show the sessions and the courses in wich this user is subscribed
  76. */
  77. echo '<p><b>'.get_lang('SessionList').'</b></p>';
  78. echo '<blockquote>';
  79. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  80. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  81. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  82. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  83. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  84. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  85. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  86. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  87. $user_id = $user['user_id'];
  88. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end
  89. FROM session_rel_user, session
  90. WHERE id_session=id AND id_user=$user_id
  91. AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
  92. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  93. $sessions=api_store_result($result);
  94. // get the list of sessions where the user is subscribed as coach in a course
  95. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end
  96. FROM $tbl_session as session
  97. INNER JOIN $tbl_session_course as session_rel_course
  98. ON session_rel_course.id_coach = $user_id
  99. AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
  100. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  101. $session_is_coach = api_store_result($result);
  102. $personal_course_list = array();
  103. if(count($sessions)>0){
  104. $header[] = array (get_lang('Code'), true);
  105. $header[] = array (get_lang('Title'), true);
  106. $header[] = array (get_lang('Status'), true);
  107. $header[] = array ('', false);
  108. foreach($sessions as $enreg){
  109. $data = array ();
  110. $personal_course_list = array();
  111. $id_session = $enreg['id'];
  112. $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, 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.id_coach = ".$user_id.",'2', '5')
  113. FROM $tbl_session_course as session_course
  114. INNER JOIN $tbl_course AS course
  115. ON course.code = session_course.course_code
  116. LEFT JOIN $tbl_user as user
  117. ON user.user_id = session_course.id_coach
  118. INNER JOIN $tbl_session_course_user
  119. ON $tbl_session_course_user.id_session = $id_session
  120. AND $tbl_session_course_user.id_user = $user_id
  121. INNER JOIN $tbl_session as session
  122. ON session_course.id_session = session.id
  123. WHERE session_course.id_session = $id_session
  124. ORDER BY i";
  125. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  126. while ($result_row = mysql_fetch_array($course_list_sql_result)){
  127. $key = $result_row['id_session'].' - '.$result_row['k'];
  128. $result_row['s'] = $result_row['14'];
  129. if(!isset($personal_course_list[$key])){
  130. $personal_course_list[$key] = $result_row;
  131. }
  132. }
  133. foreach ($personal_course_list as $my_course){
  134. $row = array ();
  135. $row[] = $my_course['k'];
  136. $row[] = $my_course['i'];
  137. $row[] = $my_course['s'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
  138. $tools = '<a href="course_information.php?code='.$my_course['k'].'"><img src="../img/synthese_view.gif" border="0" style="vertical-align: middle" /></a>'.
  139. '<a href="'.api_get_path(WEB_COURSE_PATH).$my_course['d'].'?id_session='.$id_session.'"><img src="../img/course_home.gif" border="0" style="vertical-align: middle" /></a>' .
  140. '<a href="course_edit.php?course_code='.$my_course['k'].'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>';
  141. if( $my_course->status == STUDENT ){
  142. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$my_course['k'].'&user_id='.$user['user_id'].'"><img src="../img/delete.gif"/></a>';
  143. }
  144. $row[] = $tools;
  145. $data[] = $row;
  146. }
  147. echo $enreg['name'];
  148. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  149. echo '<br><br><br>';
  150. }
  151. }
  152. else{
  153. echo '<p>'.get_lang('NoSessionsForThisUser').'</p>';
  154. }
  155. echo '</blockquote>';
  156. /**
  157. * Show the courses in which this user is subscribed
  158. */
  159. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code';
  160. $res = api_sql_query($sql,__FILE__,__LINE__);
  161. if (mysql_num_rows($res) > 0)
  162. {
  163. $header=array();
  164. $header[] = array (get_lang('Code'), true);
  165. $header[] = array (get_lang('Title'), true);
  166. $header[] = array (get_lang('Status'), true);
  167. $header[] = array ('', false);
  168. $data = array ();
  169. while ($course = mysql_fetch_object($res))
  170. {
  171. $row = array ();
  172. $row[] = $course->code;
  173. $row[] = $course->title;
  174. $row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  175. $tools = '<a href="course_information.php?code='.$course->code.'"><img src="../img/synthese_view.gif" border="0" style="vertical-align: middle" /></a>'.
  176. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'"><img src="../img/course_home.gif" border="0" style="vertical-align: middle" /></a>' .
  177. '<a href="course_edit.php?course_code='.$course->code.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>';
  178. if( $course->status == STUDENT )
  179. {
  180. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'"><img src="../img/delete.gif"/></a>';
  181. }
  182. $row[] = $tools;
  183. $data[] = $row;
  184. }
  185. echo '<p><b>'.get_lang('Courses').'</b></p>';
  186. echo '<blockquote>';
  187. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  188. echo '</blockquote>';
  189. }
  190. else
  191. {
  192. echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
  193. }
  194. /**
  195. * Show the classes in which this user is subscribed
  196. */
  197. $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  198. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  199. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  200. $res = api_sql_query($sql,__FILE__,__LINE__);
  201. if (mysql_num_rows($res) > 0)
  202. {
  203. $header = array();
  204. $header[] = array (get_lang('ClassName'), true);
  205. $header[] = array ('', false);
  206. $data = array ();
  207. while ($class = mysql_fetch_object($res))
  208. {
  209. $row = array();
  210. $row[] = $class->name;
  211. $row[] = '<a href="class_information.php?id='.$class->id.'"><img src="../img/synthese_view.gif" border="0" style="vertical-align: middle" /></a>';
  212. $data[] = $row;
  213. }
  214. echo '<p><b>'.get_lang('Classes').'</b></p>';
  215. echo '<blockquote>';
  216. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  217. echo '</blockquote>';
  218. }
  219. else
  220. {
  221. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  222. }
  223. /*
  224. ==============================================================================
  225. FOOTER
  226. ==============================================================================
  227. */
  228. Display::display_footer();
  229. ?>