user_information.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. // $Id: user_information.php 20076 2009-04-24 15:13:03Z cfasanando $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos SPRL
  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, rue du Corbeau, 108, B-1030 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. require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  39. $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
  40. $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList'));
  41. if( ! isset($_GET['user_id']))
  42. {
  43. api_not_allowed();
  44. }
  45. $user = api_get_user_info($_GET['user_id']);
  46. $tool_name = api_get_person_name($user['firstName'], $user['lastName']).(empty($user['official_code'])?'':' ('.$user['official_code'].')');
  47. Display::display_header($tool_name);
  48. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  49. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  50. if( isset($_GET['action']) ) {
  51. switch($_GET['action']) {
  52. case 'unsubscribe':
  53. if( CourseManager::get_user_in_course_status($_GET['user_id'],$_GET['course_code']) == STUDENT)
  54. {
  55. CourseManager::unsubscribe_user($_GET['user_id'],$_GET['course_code']);
  56. Display::display_normal_message(get_lang('UserUnsubscribed'));
  57. }
  58. else
  59. {
  60. Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse'));
  61. }
  62. break;
  63. }
  64. }
  65. api_display_tool_title($tool_name);
  66. 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').'">'.Display::return_icon('statistics.gif',get_lang('Reporting')).'</a></div>'."\n";
  67. //getting the user image
  68. $sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'system',false,true);
  69. $sysdir = $sysdir_array['dir'];
  70. $webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'web',false,true);
  71. $webdir = $webdir_array['dir'];
  72. $fullurl=$webdir.$webdir_array['file'];
  73. $system_image_path=$sysdir.$webdir_array['file'];
  74. list($width, $height, $type, $attr) = @getimagesize($system_image_path);
  75. $resizing = (($height > 200) ? 'height="200"' : '');
  76. $height += 30;
  77. $width += 30;
  78. $window_name = 'window'.uniqid('');
  79. $onclick = $window_name."=window.open('".$fullurl."','".$window_name."','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=".$width.",height=".$height.",left=200,top=20'); return false;";
  80. echo '<a href="javascript: void(0);" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
  81. echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
  82. echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
  83. /**
  84. * Show the sessions and the courses in wich this user is subscribed
  85. */
  86. echo '<p><b>'.get_lang('SessionList').'</b></p>';
  87. echo '<blockquote>';
  88. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  89. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  90. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  91. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  92. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  93. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  94. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  95. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  96. $user_id = $user['user_id'];
  97. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end
  98. FROM session_rel_user, session
  99. WHERE id_session=id AND id_user=$user_id
  100. AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
  101. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  102. $sessions=api_store_result($result);
  103. // get the list of sessions where the user is subscribed as coach in a course
  104. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end
  105. FROM $tbl_session as session
  106. INNER JOIN $tbl_session_course as session_rel_course
  107. ON session_rel_course.id_coach = $user_id
  108. AND (date_start <= NOW() AND date_end >= NOW() OR date_start='0000-00-00')
  109. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  110. $session_is_coach = api_store_result($result);
  111. $personal_course_list = array();
  112. if(count($sessions)>0){
  113. $header[] = array (get_lang('Code'), true);
  114. $header[] = array (get_lang('Title'), true);
  115. $header[] = array (get_lang('Status'), true);
  116. $header[] = array ('', false);
  117. foreach($sessions as $enreg){
  118. $data = array ();
  119. $personal_course_list = array();
  120. $id_session = $enreg['id'];
  121. $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.id_coach = ".$user_id.",'2', '5')
  122. FROM $tbl_session_course as session_course
  123. INNER JOIN $tbl_course AS course
  124. ON course.code = session_course.course_code
  125. LEFT JOIN $tbl_user as user
  126. ON user.user_id = session_course.id_coach
  127. INNER JOIN $tbl_session_course_user
  128. ON $tbl_session_course_user.id_session = $id_session
  129. AND $tbl_session_course_user.id_user = $user_id
  130. INNER JOIN $tbl_session as session
  131. ON session_course.id_session = session.id
  132. WHERE session_course.id_session = $id_session
  133. ORDER BY i";
  134. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  135. while ($result_row = Database::fetch_array($course_list_sql_result)){
  136. $key = $result_row['id_session'].' - '.$result_row['k'];
  137. $result_row['s'] = $result_row['14'];
  138. if(!isset($personal_course_list[$key])){
  139. $personal_course_list[$key] = $result_row;
  140. }
  141. }
  142. foreach ($personal_course_list as $my_course){
  143. $row = array ();
  144. $row[] = $my_course['k'];
  145. $row[] = $my_course['i'];
  146. $row[] = $my_course['s'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
  147. $tools = '<a href="course_information.php?code='.$my_course['k'].'">'.Display::return_icon('synthese_view.gif').'</a>'.
  148. '<a href="'.api_get_path(WEB_COURSE_PATH).$my_course['d'].'?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  149. '<a href="course_edit.php?course_code='.$my_course['k'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  150. if( $my_course->status == STUDENT ){
  151. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$my_course['k'].'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
  152. }
  153. $row[] = $tools;
  154. $data[] = $row;
  155. }
  156. echo $enreg['name'];
  157. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  158. echo '<br><br><br>';
  159. }
  160. }
  161. else{
  162. echo '<p>'.get_lang('NoSessionsForThisUser').'</p>';
  163. }
  164. echo '</blockquote>';
  165. /**
  166. * Show the courses in which this user is subscribed
  167. */
  168. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code';
  169. $res = api_sql_query($sql,__FILE__,__LINE__);
  170. if (Database::num_rows($res) > 0)
  171. {
  172. $header=array();
  173. $header[] = array (get_lang('Code'), true);
  174. $header[] = array (get_lang('Title'), true);
  175. $header[] = array (get_lang('Status'), true);
  176. $header[] = array ('', false);
  177. $data = array ();
  178. while ($course = mysql_fetch_object($res))
  179. {
  180. $row = array ();
  181. $row[] = $course->code;
  182. $row[] = $course->title;
  183. $row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  184. $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('SynthesisView')).'</a>'.
  185. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  186. '<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  187. if( $course->status == STUDENT )
  188. {
  189. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
  190. }
  191. $row[] = $tools;
  192. $data[] = $row;
  193. }
  194. echo '<p><b>'.get_lang('Courses').'</b></p>';
  195. echo '<blockquote>';
  196. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  197. echo '</blockquote>';
  198. }
  199. else
  200. {
  201. echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
  202. }
  203. /**
  204. * Show the classes in which this user is subscribed
  205. */
  206. $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  207. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  208. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  209. $res = api_sql_query($sql,__FILE__,__LINE__);
  210. if (Database::num_rows($res) > 0)
  211. {
  212. $header = array();
  213. $header[] = array (get_lang('ClassName'), true);
  214. $header[] = array ('', false);
  215. $data = array ();
  216. while ($class = mysql_fetch_object($res))
  217. {
  218. $row = array();
  219. $row[] = $class->name;
  220. $row[] = '<a href="class_information.php?id='.$class->id.'">'.Display::return_icon('synthese_view.gif').'</a>';
  221. $data[] = $row;
  222. }
  223. echo '<p><b>'.get_lang('Classes').'</b></p>';
  224. echo '<blockquote>';
  225. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  226. echo '</blockquote>';
  227. }
  228. else
  229. {
  230. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  231. }
  232. /**
  233. * Show the URL in which this user is subscribed
  234. */
  235. global $_configuration;
  236. if ($_configuration['multiple_access_urls']==true) {
  237. require_once(api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
  238. $url_list= UrlManager::get_access_url_from_user($user['user_id']);
  239. if (count($url_list) > 0) {
  240. $header = array();
  241. $header[] = array (get_lang('URL'), true);
  242. $data = array ();
  243. foreach ($url_list as $url) {
  244. $row = array();
  245. $row[] = $url['url'];
  246. $data[] = $row;
  247. }
  248. echo '<p><b>'.get_lang('URLList').'</b></p>';
  249. echo '<blockquote>';
  250. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  251. echo '</blockquote>';
  252. } else {
  253. echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
  254. }
  255. }
  256. /*
  257. ==============================================================================
  258. FOOTER
  259. ==============================================================================
  260. */
  261. Display::display_footer();
  262. ?>