user_information.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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['courseId']) == STUDENT) {
  28. CourseManager::unsubscribe_user($_GET['user_id'], $_GET['courseId']);
  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='.Security::getCurrentToken().'">'.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.' /></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 = Database :: get_main_table(TABLE_MAIN_SESSION);
  65. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  66. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  67. $user_id = $user['user_id'];
  68. $sessions = SessionManager::get_sessions_by_user($user_id);
  69. $personal_course_list = array();
  70. if (count($sessions) > 0) {
  71. $header[] = array (get_lang('Code'), true);
  72. $header[] = array (get_lang('Title'), true);
  73. $header[] = array (get_lang('Status'), true);
  74. $header[] = array ('', false);
  75. foreach ($sessions as $session_item) {
  76. $data = array ();
  77. $personal_course_list = array();
  78. $id_session = $session_item['session_id'];
  79. foreach ($session_item['courses'] as $my_course) {
  80. $course_info = api_get_course_info($my_course['code']);
  81. $row = array();
  82. $row[] = $my_course['code'];
  83. $row[] = $course_info['title'];
  84. //$row[] = $my_course['status'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
  85. $roles = api_detect_user_roles($user['user_id'], $my_course['real_id'], $id_session);
  86. $row[] = api_get_roles_to_string($roles);
  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. $row[] = $tools;
  90. $data[] = $row;
  91. }
  92. echo Display::page_subheader($session_item['session_name']);
  93. Display :: display_sortable_table($header, $data, array (), array(), array ('user_id' => intval($_GET['user_id'])));
  94. }
  95. } else {
  96. Display::display_warning_message(get_lang('NoSessionsForThisUser'));
  97. }
  98. /**
  99. * Show the courses in which this user is subscribed
  100. */
  101. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c'.
  102. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.c_id = c.id '.
  103. ' AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
  104. $res = Database::query($sql);
  105. if (Database::num_rows($res) > 0) {
  106. $header=array();
  107. $header[] = array (get_lang('Code'), true);
  108. $header[] = array (get_lang('Title'), true);
  109. $header[] = array (get_lang('Status'), true);
  110. $header[] = array ('', false);
  111. $data = array();
  112. while ($course = Database::fetch_object($res)) {
  113. $row = array ();
  114. $row[] = $course->code;
  115. $row[] = $course->title;
  116. //$row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  117. $roles = api_detect_user_roles($user['user_id'], $course->id);
  118. $row[] = api_get_roles_to_string($roles);
  119. $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  120. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  121. '<a href="course_edit.php?courseId='.$course->c_id.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  122. if ( $course->status == STUDENT ) {
  123. $tools .= '<a href="user_information.php?action=unsubscribe&courseId='.$course->c_id.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
  124. }
  125. $row[] = $tools;
  126. $data[] = $row;
  127. }
  128. echo Display::page_subheader(get_lang('Courses'));
  129. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  130. } else {
  131. Display::display_warning_message(get_lang('NoCoursesForThisUser'));
  132. }
  133. /**
  134. * Show the classes in which this user is subscribed
  135. */
  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. if (api_is_multiple_url_enabled()) {
  164. $url_list= UrlManager::get_access_url_from_user($user['user_id']);
  165. if (count($url_list) > 0) {
  166. $header = array();
  167. $header[] = array ('URL', true);
  168. $data = array ();
  169. foreach ($url_list as $url) {
  170. $row = array();
  171. $row[] = Display::url($url['url'], $url['url']);
  172. $data[] = $row;
  173. }
  174. echo '<p><b>'.get_lang('URLList').'</b></p>';
  175. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  176. } else {
  177. echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
  178. }
  179. }
  180. /* FOOTER */
  181. Display::display_footer();