user_information.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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
  37. // (not teachers nor other admins), and only if all options confirm it
  38. // $_configuration['login_as_forbidden_globally'], defined in configuration.php,
  39. // is the master key to these conditions
  40. $statusname = api_get_status_langvars();
  41. $login_as_icon = '';
  42. if (empty($_configuration['login_as_forbidden_globally']) &&
  43. (api_is_global_platform_admin() ||
  44. (api_get_setting('login_as_allowed') === 'true' &&
  45. (api_is_platform_admin() ||
  46. (api_is_session_admin() &&
  47. (api_is_session_admin() && $row['6'] == $statusname[STUDENT])
  48. )
  49. )
  50. )
  51. )
  52. ) {
  53. $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>';
  54. }
  55. 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>';
  56. echo Display::page_header($tool_name);
  57. //getting the user image
  58. $sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'system',false,true);
  59. $sysdir = $sysdir_array['dir'];
  60. $webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'],'web',false,true);
  61. $webdir = $webdir_array['dir'];
  62. $fullurl=$webdir.$webdir_array['file'];
  63. $system_image_path=$sysdir.$webdir_array['file'];
  64. list($width, $height, $type, $attr) = @getimagesize($system_image_path);
  65. $resizing = (($height > 200) ? 'height="200"' : '');
  66. $height += 30;
  67. $width += 30;
  68. $window_name = 'window'.uniqid('');
  69. $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;";
  70. echo '<a href="javascript: void(0);" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' /></a><br />';
  71. echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
  72. echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
  73. /**
  74. * Show the sessions and the courses in wich this user is subscribed
  75. */
  76. echo Display::page_subheader(get_lang('SessionList'));
  77. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  78. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  79. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  80. $user_id = $user['user_id'];
  81. $sessions = SessionManager::get_sessions_by_user($user_id, true);
  82. $personal_course_list = array();
  83. if (count($sessions) > 0) {
  84. $header[] = array (get_lang('Code'), true);
  85. $header[] = array (get_lang('Title'), true);
  86. $header[] = array (get_lang('Status'), true);
  87. $header[] = array ('', false);
  88. foreach ($sessions as $session_item) {
  89. $data = array ();
  90. $personal_course_list = array();
  91. $id_session = $session_item['session_id'];
  92. foreach ($session_item['courses'] as $my_course) {
  93. $courseInfo = api_get_course_info_by_id($my_course['id']);
  94. $row = array();
  95. $row[] = $courseInfo['code'];
  96. $row[] = $courseInfo['title'];
  97. //$row[] = $my_course['status'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
  98. $roles = api_detect_user_roles($user['user_id'], $courseInfo['real_id'], $id_session);
  99. $row[] = api_get_roles_to_string($roles);
  100. $tools = '<a href="course_information.php?code='.$courseInfo['code'].'&id_session='.$id_session.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  101. '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>';
  102. $row[] = $tools;
  103. $data[] = $row;
  104. }
  105. $dates = SessionManager::parse_session_dates($session_item);
  106. echo Display::page_subheader($session_item['session_name'], ' '.$dates);
  107. Display :: display_sortable_table($header, $data, array (), array(), array ('user_id' => intval($_GET['user_id'])));
  108. }
  109. } else {
  110. Display::display_warning_message(get_lang('NoSessionsForThisUser'));
  111. }
  112. /**
  113. * Show the courses in which this user is subscribed
  114. */
  115. $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c'.
  116. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.c_id = c.id '.
  117. ' AND cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
  118. $res = Database::query($sql);
  119. if (Database::num_rows($res) > 0) {
  120. $header=array();
  121. $header[] = array (get_lang('Code'), true);
  122. $header[] = array (get_lang('Title'), true);
  123. $header[] = array (get_lang('Status'), true);
  124. $header[] = array ('', false);
  125. $data = array();
  126. while ($course = Database::fetch_object($res)) {
  127. $row = array ();
  128. $row[] = $course->code;
  129. $row[] = $course->title;
  130. //$row[] = $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher');
  131. $roles = api_detect_user_roles($user['user_id'], $course->id);
  132. $row[] = api_get_roles_to_string($roles);
  133. $tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
  134. '<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
  135. '<a href="course_edit.php?courseId='.$course->c_id.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  136. if ( $course->status == STUDENT ) {
  137. $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>';
  138. }
  139. $row[] = $tools;
  140. $data[] = $row;
  141. }
  142. echo Display::page_subheader(get_lang('Courses'));
  143. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  144. } else {
  145. Display::display_warning_message(get_lang('NoCoursesForThisUser'));
  146. }
  147. /**
  148. * Show the classes in which this user is subscribed
  149. */
  150. /*
  151. $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  152. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  153. $sql = 'SELECT * FROM '.$table_class_user.' cu, '.$table_class.' c '.
  154. ' WHERE cu.user_id = '.$user['user_id'].' AND cu.class_id = c.id';
  155. $res = Database::query($sql);
  156. if (Database::num_rows($res) > 0) {
  157. $header = array();
  158. $header[] = array (get_lang('ClassName'), true);
  159. $header[] = array ('', false);
  160. $data = array ();
  161. while ($class = Database::fetch_object($res)) {
  162. $row = array();
  163. $row[] = $class->name;
  164. $row[] = '<a href="class_information.php?id='.$class->id.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>';
  165. $data[] = $row;
  166. }
  167. echo '<p><b>'.get_lang('Classes').'</b></p>';
  168. echo '<blockquote>';
  169. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  170. echo '</blockquote>';
  171. } else {
  172. echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
  173. }*/
  174. /**
  175. * Show the URL in which this user is subscribed
  176. */
  177. if (api_is_multiple_url_enabled()) {
  178. $url_list= UrlManager::get_access_url_from_user($user['user_id']);
  179. if (count($url_list) > 0) {
  180. $header = array();
  181. $header[] = array ('URL', true);
  182. $data = array ();
  183. foreach ($url_list as $url) {
  184. $row = array();
  185. $row[] = Display::url($url['url'], $url['url']);
  186. $data[] = $row;
  187. }
  188. echo '<p><b>'.get_lang('URLList').'</b></p>';
  189. Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
  190. } else {
  191. echo '<p>'.get_lang('NoUrlForThisUser').'</p>';
  192. }
  193. }
  194. /* FOOTER */
  195. Display::display_footer();