user_information.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. // $Id: user_information.php 9246 2006-09-25 13:24:53Z bmol $
  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. $langFile = 'admin';
  32. $cidReset = true;
  33. require ('../inc/global.inc.php');
  34. $this_section=SECTION_PLATFORM_ADMIN;
  35. api_protect_admin_script();
  36. require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  37. //$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('PlatformAdmin'));
  38. $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList'));
  39. if( ! isset($_GET['user_id']))
  40. {
  41. api_not_allowed();
  42. }
  43. $user = api_get_user_info($_GET['user_id']);
  44. $tool_name = $user['firstName'].' '.$user['lastName'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
  45. Display::display_header($tool_name);
  46. $table_course_user = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
  47. $table_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  48. if( isset($_GET['action']) )
  49. {
  50. switch($_GET['action'])
  51. {
  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('UserUnsubscribed');
  57. }
  58. else
  59. {
  60. Display::display_error_message('CannotUnsubscribeUserFromCourse');
  61. }
  62. break;
  63. }
  64. }
  65. api_display_tool_title($tool_name);
  66. if ($user['picture_uri'] != '')
  67. {
  68. echo '<p><img src="'.api_get_path(WEB_CODE_PATH).'upload/users/'.$user['picture_uri'].'" style="width:150px;"/></p>';
  69. }
  70. echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
  71. echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
  72. /**
  73. * Show the courses in which this user is subscribed
  74. */
  75. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code';
  76. $res = api_sql_query($sql,__FILE__,__LINE__);
  77. if (mysql_num_rows($res) > 0)
  78. {
  79. $header[] = array (get_lang('Code'), true);
  80. $header[] = array (get_lang('Title'), true);
  81. $header[] = array (get_lang('Status'), true);
  82. $header[] = array ('', false);
  83. $data = array ();
  84. while ($course = mysql_fetch_object($res))
  85. {
  86. $row = array ();
  87. $row[] = $course->code;
  88. $row[] = $course->title;
  89. $row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  90. $tools = '<a href="course_information.php?code='.$course->code.'"><img src="../img/info_small.gif" border="0" style="vertical-align: middle" /></a>'.
  91. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'"><img src="../img/home_small.gif" border="0" style="vertical-align: middle" /></a>' .
  92. '<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>';
  93. if( $course->status == STUDENT )
  94. {
  95. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'"><img src="../img/delete.gif"/></a>';
  96. }
  97. $row[] = $tools;
  98. $data[] = $row;
  99. }
  100. echo '<p><b>'.get_lang('Courses').'</b></p>';
  101. echo '<blockquote>';
  102. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  103. echo '</blockquote>';
  104. }
  105. else
  106. {
  107. echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
  108. }
  109. /**
  110. * Show the classes in which this user is subscribed
  111. */
  112. $table_class_user = Database :: get_main_table(MAIN_CLASS_USER_TABLE);
  113. $table_class = Database :: get_main_table(MAIN_CLASS_TABLE);
  114. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  115. $res = api_sql_query($sql,__FILE__,__LINE__);
  116. if (mysql_num_rows($res) > 0)
  117. {
  118. $header = array();
  119. $header[] = array (get_lang('ClassName'), true);
  120. $header[] = array ('', false);
  121. $data = array ();
  122. while ($class = mysql_fetch_object($res))
  123. {
  124. $row = array();
  125. $row[] = $class->name;
  126. $row[] = '<a href="class_information.php?id='.$class->id.'"><img src="../img/info_small.gif" border="0" style="vertical-align: middle" /></a>';
  127. $data[] = $row;
  128. }
  129. echo '<p><b>'.get_lang('Classes').'</b></p>';
  130. echo '<blockquote>';
  131. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => $_GET['user_id']));
  132. echo '</blockquote>';
  133. }
  134. else
  135. {
  136. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  137. }
  138. /*
  139. ==============================================================================
  140. FOOTER
  141. ==============================================================================
  142. */
  143. Display::display_footer();
  144. ?>