user_information.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Bart Mollet
  5. * @package chamilo.admin
  6. */
  7. /* INIT SECTION */
  8. // name of the language file that needs to be included
  9. $language_file = 'admin';
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. $this_section=SECTION_PLATFORM_ADMIN;
  13. api_protect_admin_script();
  14. $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
  15. $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList'));
  16. if (!isset($_GET['user_id'])) {
  17. api_not_allowed();
  18. }
  19. $user = api_get_user_info($_GET['user_id']);
  20. $tool_name = $user['complete_name'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
  21. Display::display_header($tool_name);
  22. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  23. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  24. if ( isset($_GET['action']) ) {
  25. switch($_GET['action']) {
  26. case 'unsubscribe':
  27. if ( CourseManager::get_user_in_course_status($_GET['user_id'],$_GET['course_code']) == STUDENT) {
  28. CourseManager::unsubscribe_user($_GET['user_id'],$_GET['course_code']);
  29. Display::display_normal_message(get_lang('UserUnsubscribed'));
  30. } else {
  31. Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse'));
  32. }
  33. break;
  34. }
  35. }
  36. //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
  37. $statusname = api_get_status_langvars();
  38. $login_as_icon = '';
  39. if (api_is_platform_admin() || (api_is_session_admin() && $row['6'] == $statusname[STUDENT])) {
  40. $login_as_icon = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user['user_id'].'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>';
  41. }
  42. echo '<div class="actions"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.intval($_GET['user_id']).'" title="'.get_lang('Reporting').'">'.Display::return_icon('statistics.png',get_lang('Reporting'),'', ICON_SIZE_MEDIUM).'</a>'.$login_as_icon.'</div>';
  43. echo Display::page_header($tool_name);
  44. //getting the user image
  45. $sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'system',false,true);
  46. $sysdir = $sysdir_array['dir'];
  47. $webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'web',false,true);
  48. $webdir = $webdir_array['dir'];
  49. $fullurl=$webdir.$webdir_array['file'];
  50. $system_image_path=$sysdir.$webdir_array['file'];
  51. list($width, $height, $type, $attr) = @getimagesize($system_image_path);
  52. $resizing = (($height > 200) ? 'height="200"' : '');
  53. $height += 30;
  54. $width += 30;
  55. $window_name = 'window'.uniqid('');
  56. $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;";
  57. echo '<a href="javascript: void(0);" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
  58. echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
  59. echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
  60. /**
  61. * Show the sessions and the courses in wich this user is subscribed
  62. */
  63. echo Display::page_subheader(get_lang('SessionList'));
  64. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  65. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  66. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  67. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  68. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  69. $user_id = $user['user_id'];
  70. $sessions = SessionManager::get_sessions_by_user($user_id);
  71. $personal_course_list = array();
  72. if (count($sessions) > 0) {
  73. $header[] = array (get_lang('Code'), true);
  74. $header[] = array (get_lang('Title'), true);
  75. $header[] = array (get_lang('Status'), true);
  76. $header[] = array ('', false);
  77. foreach ($sessions as $session_item) {
  78. $data = array ();
  79. $personal_course_list = array();
  80. $id_session = $session_item['session_id'];
  81. foreach ($session_item['courses'] as $my_course) {
  82. $course_info = api_get_course_info($my_course['code']);
  83. $row = array ();
  84. $row[] = $my_course['code'];
  85. $row[] = $course_info['title'];
  86. $row[] = $my_course['status'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
  87. $tools = '<a href="course_information.php?code='.$course_info['code'].'&id_session='.$id_session.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  88. '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>';
  89. if ($my_course['status'] == STUDENT) {
  90. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course_info['code'].'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
  91. }
  92. $row[] = $tools;
  93. $data[] = $row;
  94. }
  95. echo Display::page_subheader($session_item['session_name']);
  96. Display :: display_sortable_table($header, $data, array (), array(), array ('user_id' => intval($_GET['user_id'])));
  97. }
  98. } else {
  99. echo '<p>'.get_lang('NoSessionsForThisUser').'</p>';
  100. }
  101. /**
  102. * Show the courses in which this user is subscribed
  103. */
  104. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c'.
  105. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code '.
  106. ' AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
  107. $res = Database::query($sql);
  108. if (Database::num_rows($res) > 0) {
  109. $header=array();
  110. $header[] = array (get_lang('Code'), true);
  111. $header[] = array (get_lang('Title'), true);
  112. $header[] = array (get_lang('Status'), true);
  113. $header[] = array ('', false);
  114. $data = array ();
  115. while ($course = Database::fetch_object($res)) {
  116. $row = array ();
  117. $row[] = $course->code;
  118. $row[] = $course->title;
  119. $row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  120. $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  121. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  122. '<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  123. if ( $course->status == STUDENT ) {
  124. $tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
  125. }
  126. $row[] = $tools;
  127. $data[] = $row;
  128. }
  129. echo Display::page_subheader(get_lang('Courses'));
  130. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  131. } else {
  132. echo '<p>'.get_lang('NoCoursesForThisUser').'</p>';
  133. }
  134. /**
  135. * Show the classes in which this user is subscribed
  136. */
  137. $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  138. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  139. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c '.
  140. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  141. $res = Database::query($sql);
  142. if (Database::num_rows($res) > 0) {
  143. $header = array();
  144. $header[] = array (get_lang('ClassName'), true);
  145. $header[] = array ('', false);
  146. $data = array ();
  147. while ($class = Database::fetch_object($res)) {
  148. $row = array();
  149. $row[] = $class->name;
  150. $row[] = '<a href="class_information.php?id='.$class->id.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>';
  151. $data[] = $row;
  152. }
  153. echo '<p><b>'.get_lang('Classes').'</b></p>';
  154. echo '<blockquote>';
  155. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  156. echo '</blockquote>';
  157. } else {
  158. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  159. }
  160. /**
  161. * Show the URL in which this user is subscribed
  162. */
  163. global $_configuration;
  164. if ($_configuration['multiple_access_urls']) {
  165. $url_list= UrlManager::get_access_url_from_user($user['user_id']);
  166. if (count($url_list) > 0) {
  167. $header = array();
  168. $header[] = array ('URL', true);
  169. $data = array ();
  170. foreach ($url_list as $url) {
  171. $row = array();
  172. $row[] = Display::url($url['url'], $url['url']);
  173. $data[] = $row;
  174. }
  175. echo '<p><b>'.get_lang('URLList').'</b></p>';
  176. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  177. } else {
  178. echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
  179. }
  180. }
  181. /* FOOTER */
  182. Display::display_footer();