user_information.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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='.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_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. $roles = api_detect_user_roles($user['user_id'], $my_course['code'], $id_session);
  88. $row[] = api_get_roles_to_string($roles);
  89. $tools = '<a href="course_information.php?code='.$course_info['code'].'&id_session='.$id_session.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  90. '<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>';
  91. /*if (isset($my_course['status']) && $my_course['status'] == STUDENT) {
  92. $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>';
  93. }*/
  94. $row[] = $tools;
  95. $data[] = $row;
  96. }
  97. echo Display::page_subheader($session_item['session_name']);
  98. Display :: display_sortable_table($header, $data, array (), array(), array ('user_id' => intval($_GET['user_id'])));
  99. }
  100. } else {
  101. Display::display_warning_message(get_lang('NoSessionsForThisUser'));
  102. }
  103. /**
  104. * Show the courses in which this user is subscribed
  105. */
  106. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c'.
  107. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.course_code = c.code '.
  108. ' AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
  109. $res = Database::query($sql);
  110. if (Database::num_rows($res) > 0) {
  111. $header=array();
  112. $header[] = array (get_lang('Code'), true);
  113. $header[] = array (get_lang('Title'), true);
  114. $header[] = array (get_lang('Status'), true);
  115. $header[] = array ('', false);
  116. $data = array();
  117. while ($course = Database::fetch_object($res)) {
  118. $row = array ();
  119. $row[] = $course->code;
  120. $row[] = $course->title;
  121. //$row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  122. $roles = api_detect_user_roles($user['user_id'], $course->code);
  123. $row[] = api_get_roles_to_string($roles);
  124. $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  125. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  126. '<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  127. if ( $course->status == STUDENT ) {
  128. $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>';
  129. }
  130. $row[] = $tools;
  131. $data[] = $row;
  132. }
  133. echo Display::page_subheader(get_lang('Courses'));
  134. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  135. } else {
  136. Display::display_warning_message(get_lang('NoCoursesForThisUser'));
  137. }
  138. /**
  139. * Show the classes in which this user is subscribed
  140. */
  141. /*
  142. $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  143. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  144. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c '.
  145. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  146. $res = Database::query($sql);
  147. if (Database::num_rows($res) > 0) {
  148. $header = array();
  149. $header[] = array (get_lang('ClassName'), true);
  150. $header[] = array ('', false);
  151. $data = array ();
  152. while ($class = Database::fetch_object($res)) {
  153. $row = array();
  154. $row[] = $class->name;
  155. $row[] = '<a href="class_information.php?id='.$class->id.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>';
  156. $data[] = $row;
  157. }
  158. echo '<p><b>'.get_lang('Classes').'</b></p>';
  159. echo '<blockquote>';
  160. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  161. echo '</blockquote>';
  162. } else {
  163. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  164. }*/
  165. /**
  166. * Show the URL in which this user is subscribed
  167. */
  168. if (api_is_multiple_url_enabled()) {
  169. $url_list= UrlManager::get_access_url_from_user($user['user_id']);
  170. if (count($url_list) > 0) {
  171. $header = array();
  172. $header[] = array ('URL', true);
  173. $data = array ();
  174. foreach ($url_list as $url) {
  175. $row = array();
  176. $row[] = Display::url($url['url'], $url['url']);
  177. $data[] = $row;
  178. }
  179. echo '<p><b>'.get_lang('URLList').'</b></p>';
  180. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  181. } else {
  182. echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
  183. }
  184. }
  185. /* FOOTER */
  186. Display::display_footer();