user.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <?php // $Id: user.php 22291 2009-07-22 17:39:20Z herodoto $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
  15. ==============================================================================
  16. */
  17. /**
  18. ==============================================================================
  19. * This script displays a list of the users of the current course.
  20. * Course admins can change user perimssions, subscribe and unsubscribe users...
  21. *
  22. * EXPERIMENTAL: support for virtual courses
  23. * - show users registered in virtual and real courses;
  24. * - only show the users of a virtual course if the current user;
  25. * is registered in that virtual course.
  26. *
  27. * Exceptions: platform admin and the course admin will see all virtual courses.
  28. * This is a new feature, there may be bugs.
  29. *
  30. * @todo possibility to edit user-course rights and view statistics for users in virtual courses
  31. * @todo convert normal table display to display function (refactor virtual course display function)
  32. * @todo display table functions need support for align and valign (e.g. to center text in cells) (this is now possible)
  33. * @author Roan Embrechts, refactoring + virtual courses support
  34. * @author Julio Montoya Armas Several fixes
  35. * @package dokeos.user
  36. ==============================================================================
  37. */
  38. /*
  39. ==============================================================================
  40. INIT SECTION
  41. ==============================================================================
  42. */
  43. // name of the language file that needs to be included
  44. $language_file = array('registration','admin','userInfo');
  45. $use_anonymous = true;
  46. require_once ("../inc/global.inc.php");
  47. $this_section = SECTION_COURSES;
  48. // notice for unauthorized people.
  49. api_protect_course_script(true);
  50. /*
  51. -----------------------------------------------------------
  52. Libraries
  53. -----------------------------------------------------------
  54. */
  55. require_once (api_get_path(LIBRARY_PATH)."debug.lib.inc.php");
  56. require_once (api_get_path(LIBRARY_PATH)."export.lib.inc.php");
  57. require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
  58. require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
  59. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  60. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  61. require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  62. //CHECK KEYS
  63. if( !isset ($_cid)) {
  64. header("location: ".$_configuration['root_web']);
  65. }
  66. /*
  67. -----------------------------------------------------------
  68. Constants and variables
  69. -----------------------------------------------------------
  70. */
  71. $currentCourseID = $_course['sysCode'];
  72. /*--------------------------------------
  73. Unregistering a user section
  74. --------------------------------------
  75. */
  76. if (api_is_allowed_to_edit()) {
  77. if (isset($_POST['action'])) {
  78. switch ($_POST['action']) {
  79. case 'unsubscribe' :
  80. // Make sure we don't unsubscribe current user from the course
  81. if (is_array($_POST['user'])) {
  82. $user_ids = array_diff($_POST['user'],array($_user['user_id']));
  83. if (count($user_ids) > 0) {
  84. CourseManager::unsubscribe_user($user_ids, $_SESSION['_course']['sysCode']);
  85. $message = get_lang('UsersUnsubscribed');
  86. }
  87. }
  88. }
  89. }
  90. }
  91. if (api_is_allowed_to_edit()) {
  92. if ( isset ($_GET['action'])) {
  93. switch ($_GET['action']) {
  94. case 'export' :
  95. $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  96. $session_id=0;
  97. $table_users = Database :: get_main_table(TABLE_MAIN_USER);
  98. $data=array();
  99. $a_users=array();
  100. // users subscribed to the course through a session
  101. if (api_get_setting('use_session_mode')=='true') {
  102. $session_id = intval($_SESSION['id_session']);
  103. $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  104. $sql_query = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code
  105. FROM $table_session_course_user as session_course_user, $table_users as user
  106. WHERE `course_code` = '$currentCourseID' AND session_course_user.id_user = user.user_id ";
  107. if ($session_id!=0) {
  108. $sql_query .= ' AND id_session = '.$session_id;
  109. }
  110. $sql_query.=' ORDER BY user.lastname';
  111. $rs = api_sql_query($sql_query, __FILE__, __LINE__);
  112. while ($user = Database:: fetch_array($rs,'ASSOC')) {
  113. $data[]=$user;
  114. //$user_infos = Database :: get_user_info_from_id($user['user_id']);
  115. $a_users[$user['user_id']] = $user;
  116. }
  117. }
  118. if ($session_id == 0) {
  119. // users directly subscribed to the course
  120. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  121. $sql_query = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code
  122. FROM $table_course_user as course_user, $table_users as user WHERE `course_code` = '$currentCourseID' AND course_user.user_id = user.user_id ORDER BY user.lastname";
  123. $rs = api_sql_query($sql_query, __FILE__, __LINE__);
  124. while ($user = Database::fetch_array($rs,'ASSOC')) {
  125. $data[]=$user;
  126. $a_users[$user['user_id']] = $user;
  127. }
  128. }
  129. switch ($_GET['type']) {
  130. case 'csv' :
  131. Export::export_table_csv($a_users);
  132. case 'xls' :
  133. Export::export_table_xls($a_users);
  134. }
  135. }
  136. }
  137. } // end if allowed to edit
  138. if (api_is_allowed_to_edit()) {
  139. // Unregister user from course
  140. if ($_REQUEST['unregister']) {
  141. if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $_GET['user_id'] != $_user['user_id']) {
  142. $user_id = Database::escape_string($_GET['user_id']);
  143. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  144. $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  145. $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  146. $sql = 'SELECT '.$tbl_user.'.user_id
  147. FROM '.$tbl_user.' user
  148. INNER JOIN '.$tbl_session_rel_user.' reluser
  149. ON user.user_id = reluser.id_user
  150. INNER JOIN '.$tbl_session_rel_course.' rel_course
  151. ON rel_course.id_session = reluser.id_session
  152. WHERE user.user_id = "'.$user_id.'"
  153. AND rel_course.course_code = "'.$currentCourseID.'"
  154. ORDER BY lastname, firstname';
  155. $result=api_sql_query($sql,__FILE__,__LINE__);
  156. $row=Database::fetch_array($result,'ASSOC');
  157. if ($row['user_id']==$user_id || $row['user_id']=="") {
  158. CourseManager::unsubscribe_user($_GET['user_id'],$_SESSION['_course']['sysCode']);
  159. $message = get_lang('UserUnsubscribed');
  160. } else {
  161. $message = get_lang('ThisStudentIsSubscribeThroughASession');
  162. }
  163. }
  164. }
  165. } // end if allowed to edit
  166. /*
  167. ==============================================================================
  168. FUNCTIONS
  169. ==============================================================================
  170. */
  171. function display_user_search_form() {
  172. echo '<form method="get" action="user.php">';
  173. echo get_lang("SearchForUser") . "&nbsp;&nbsp;";
  174. echo '<input type="text" name="keyword" value="'.$_GET['keyword'].'"/>';
  175. echo '<input type="submit" value="'.get_lang('SearchButton').'"/>';
  176. echo '</form>';
  177. }
  178. /**
  179. * This function displays a list if users for each virtual course linked to the current
  180. * real course.
  181. *
  182. * defines globals
  183. *
  184. * @version 1.0
  185. * @author Roan Embrechts
  186. * @todo users from virtual courses always show "-" for the group related output. Edit and statistics columns are disabled * for these users, for now.
  187. */
  188. function show_users_in_virtual_courses() {
  189. global $_course, $_user, $origin;
  190. $real_course_code = $_course['sysCode'];
  191. $real_course_info = Database::get_course_info($real_course_code);
  192. $user_subscribed_virtual_course_list = CourseManager::get_list_of_virtual_courses_for_specific_user_and_real_course($_user['user_id'], $real_course_code);
  193. $number_of_virtual_courses = count($user_subscribed_virtual_course_list);
  194. $row = 0;
  195. $column_header[$row ++] = "ID";
  196. $column_header[$row ++] = get_lang("FullUserName");
  197. $column_header[$row ++] = get_lang("Role");
  198. $column_header[$row ++] = get_lang("Group");
  199. if ( api_is_allowed_to_edit()) {
  200. $column_header[$row ++] = get_lang("Tutor");
  201. }
  202. if ( api_is_allowed_to_edit()) {
  203. $column_header[$row ++] = get_lang("CourseManager");
  204. }
  205. if ( !is_array($user_subscribed_virtual_course_list)) {
  206. return;
  207. }
  208. foreach ($user_subscribed_virtual_course_list as $virtual_course) {
  209. $virtual_course_code = $virtual_course["code"];
  210. $virtual_course_user_list = CourseManager::get_user_list_from_course_code($virtual_course_code);
  211. $message = get_lang("RegisteredInVirtualCourse")." ".$virtual_course["title"]."&nbsp;&nbsp;(".$virtual_course["code"].")";
  212. echo "<br/>";
  213. echo "<h4>".$message."</h4>";
  214. $properties["width"] = "100%";
  215. $properties["cellspacing"] = "1";
  216. Display::display_complex_table_header($properties, $column_header);
  217. foreach ($virtual_course_user_list as $this_user) {
  218. $user_id = $this_user["user_id"];
  219. $loginname = $this_user["username"];
  220. $lastname = $this_user["lastname"];
  221. $firstname = $this_user["firstname"];
  222. $status = $this_user["status"];
  223. $role = $this_user["role"];
  224. if ( $status == "1") {
  225. $status = get_lang("CourseManager");
  226. } else {
  227. $status = " - ";
  228. }
  229. $full_name = $lastname.", ".$firstname;
  230. if ( $lastname == "" || $firstname == '') {
  231. $full_name = $loginname;
  232. }
  233. $user_info_hyperlink = "<a href=\"userInfo.php?".api_get_cidreq()."&origin=".$origin."&uInfo=".$user_id."&virtual_course=".$virtual_course["code"]."\">".$full_name."</a>";
  234. $row = 0;
  235. $table_row[$row ++] = $user_id;
  236. $table_row[$row ++] = $user_info_hyperlink; //Full name
  237. $table_row[$row ++] = $role; //Description
  238. $table_row[$row ++] = " - "; //Group, for the moment groups don't work for students in virtual courses
  239. if ( api_is_allowed_to_edit()) {
  240. $table_row[$row ++] = " - "; //Tutor column
  241. $table_row[$row ++] = $status; //Course Manager column
  242. }
  243. Display::display_table_row(null, $table_row, true);
  244. }
  245. Display::display_table_footer();
  246. }
  247. }
  248. if (!$is_allowed_in_course) {
  249. api_not_allowed(true);
  250. }
  251. /*
  252. -----------------------------------------------------------
  253. Header
  254. -----------------------------------------------------------
  255. */
  256. if ( $origin != 'learnpath') {
  257. if (isset($_GET['keyword'])) {
  258. $interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
  259. $tool_name = get_lang('SearchResults');
  260. } else {
  261. $tool_name = get_lang('Users');
  262. }
  263. Display::display_header($tool_name, "User");
  264. } else {
  265. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css" /> <?php
  266. }
  267. if ( isset($message)) {
  268. Display::display_normal_message($message);
  269. }
  270. /*
  271. ==============================================================================
  272. MAIN CODE
  273. ==============================================================================
  274. */
  275. //statistics
  276. event_access_tool(TOOL_USER);
  277. /*
  278. --------------------------------------
  279. Setting the permissions for this page
  280. --------------------------------------
  281. */
  282. $is_allowed_to_track = ($is_courseAdmin || $is_courseTutor) && $_configuration['tracking_enabled'];
  283. // Tool introduction
  284. Display::display_introduction_section(TOOL_USER, 'left');
  285. if ( api_is_allowed_to_edit()) {
  286. echo "<div class=\"actions\">";
  287. // the action links
  288. $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.Display::return_icon('csv.gif', get_lang('ExportAsCSV')).'&nbsp;'.get_lang('ExportAsCSV').'</a> ';
  289. $actions .= '<a href="subscribe_user.php?'.api_get_cidreq().'">'.Display::return_icon('add_user_big.gif',get_lang("SubscribeUserToCourse")).'&nbsp;'.get_lang("SubscribeUserToCourse").'</a> ';
  290. $actions .= "<a href=\"subscribe_user.php?".api_get_cidreq()."&type=teacher\">".Display::return_icon('add_teacher_big.gif', get_lang("SubscribeUserToCourseAsTeacher"))."&nbsp;".get_lang("SubscribeUserToCourseAsTeacher")."</a> ";
  291. $actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".Display::return_icon('group.gif', get_lang("GroupUserManagement"))."&nbsp;".get_lang("GroupUserManagement")."</a>";
  292. if (api_get_setting('use_session_mode')=='false') {
  293. $actions .= ' <a href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
  294. }
  295. // Build search-form
  296. $form = new FormValidator('search_user', 'get','','',null,false);
  297. $renderer = & $form->defaultRenderer();
  298. $renderer->setElementTemplate('<span>{element}</span> ');
  299. $form->add_textfield('keyword', '', false);
  300. $form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
  301. $form->addElement('static','additionalactions',null,$actions);
  302. $form->display();
  303. echo '</div>';
  304. }
  305. /*
  306. if (1) // platform setting api_get_setting('subscribe_user_by_coach')
  307. {
  308. if (!api_is_allowed_to_edit() && $is_courseTutor)
  309. {
  310. echo "<div align=\"right\">";
  311. echo '<a href="subscribe_user.php?'.api_get_cidreq().'">'.Display::return_icon('add_user_big.gif',get_lang("SubscribeUserToCourse")).'&nbsp;'.get_lang("SubscribeUserToCourse").'</a>';
  312. echo "</div>";
  313. }
  314. }*/
  315. /*
  316. --------------------------------------
  317. DISPLAY USERS LIST
  318. --------------------------------------
  319. Also shows a "next page" button if there are
  320. more than 50 users.
  321. There's a bug in here somewhere - some users count as more than one if they are in more than one group
  322. --> code for > 50 users should take this into account
  323. (Roan, Feb 2004)
  324. */
  325. if ( CourseManager::has_virtual_courses_from_code($course_id, $user_id)) {
  326. $real_course_code = $_course['sysCode'];
  327. $real_course_info = Database::get_course_info($real_course_code);
  328. $message = get_lang("RegisteredInRealCourse")." ".$real_course_info["title"]."&nbsp;&nbsp;(".$real_course_info["official_code"].")";
  329. echo "<h4>".$message."</h4>";
  330. }
  331. /*
  332. ==============================================================================
  333. DISPLAY LIST OF USERS
  334. ==============================================================================
  335. */
  336. /**
  337. * * Get the users to display on the current page.
  338. */
  339. function get_number_of_users() {
  340. $counter=0;
  341. if (!empty($_SESSION["id_session"])) {
  342. $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session']);
  343. } else {
  344. $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true);
  345. }
  346. foreach ($a_course_users as $user_id=>$o_course_user) {
  347. if ( (isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'],$o_course_user['lastname'],$o_course_user['username'],$o_course_user['official_code'],$_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
  348. $counter++;
  349. }
  350. }
  351. return $counter;
  352. }
  353. function search_keyword($firstname,$lastname,$username,$official_code,$keyword) {
  354. if (strripos($firstname,$keyword)!==false || strripos($lastname,$keyword)!==false || strripos($username,$keyword)!==false || strripos($official_code,$keyword)!==false) {
  355. return true;
  356. } else {
  357. return false;
  358. }
  359. }
  360. /**
  361. * Get the users to display on the current page.
  362. */
  363. function get_user_data($from, $number_of_items, $column, $direction) {
  364. global $origin;
  365. $a_users=array();
  366. // limit
  367. if (!isset($_GET['keyword']) || empty($_GET['keyword']))
  368. $limit = 'LIMIT '.intval($from).','.intval($number_of_items);
  369. // order by
  370. switch ($column) {
  371. case 1 : $order_by = 'ORDER BY user.firstname';break;
  372. case 2 : $order_by = 'ORDER BY user.lastname';break;
  373. case 5 : $order_by = 'ORDER BY user.official_code';break;
  374. default: $order_by = 'ORDER BY user.lastname';break;
  375. }
  376. if(!in_array($direction, array('ASC','DESC'))){
  377. $direction = 'ASC';
  378. }
  379. $order_by .= ' '.$direction;
  380. if (!empty($_SESSION["id_session"])) {
  381. $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session'], $limit, $order_by);
  382. } else {
  383. $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], false, 0, $limit, $order_by);
  384. }
  385. foreach ($a_course_users as $user_id=>$o_course_user) {
  386. if ( (isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'],$o_course_user['lastname'],$o_course_user['username'],$o_course_user['official_code'],$_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
  387. $groups_name=GroupManager :: get_user_group_name($user_id);
  388. if (api_is_allowed_to_edit()) {
  389. $temp=array();
  390. $temp[] = $user_id;
  391. $image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
  392. $user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, 'small_', ' width="22" height="22" ');
  393. if (!api_is_anonymous()) {
  394. $photo= '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" title="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" /></a></center>';
  395. } else {
  396. $photo= '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" title="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" /></center>';
  397. }
  398. $temp[] = $photo;
  399. $temp[] = $o_course_user['firstname'];
  400. $temp[] = $o_course_user['lastname'];
  401. $temp[] = $o_course_user['role'];
  402. $temp[] = implode(', ',$groups_name); //Group
  403. $temp[] = $o_course_user['official_code'];
  404. // deprecated feature
  405. if (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id']==1) {
  406. $temp[] = get_lang('Tutor');
  407. } else {
  408. $temp[] = '-';
  409. }
  410. if (isset($o_course_user['status']) && $o_course_user['status']==1) {
  411. $temp[] = get_lang('CourseManager');
  412. } else {
  413. $temp[] = '-';
  414. }
  415. $temp[] = $o_course_user['active'];
  416. $temp[] = $user_id;
  417. } else {
  418. $temp=array();
  419. $image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
  420. $image_repository = $image_path['dir'];
  421. $existing_image = $image_path['file'];
  422. if (!api_is_anonymous()) {
  423. $photo= '<center><a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$image_repository.$existing_image.'" alt="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" width="22" height="22" title="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" /></a></center>';
  424. }
  425. else
  426. {
  427. $photo= '<center><img src="'.$image_repository.$existing_image.'" alt="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" width="22" height="22" title="'.$o_course_user['firstname'].' '.$o_course_user['lastname'].'" /></center>';
  428. }
  429. $temp[] = $photo;
  430. $temp[] = $o_course_user['firstname'];
  431. $temp[] = $o_course_user['lastname'];
  432. $temp[] = $o_course_user['role'];
  433. $temp[] = implode(', ',$groups_name);//Group
  434. $temp[] = $o_course_user['official_code'];
  435. $temp[] = $user_id;
  436. }
  437. $a_users[$user_id] = $temp;
  438. }
  439. }
  440. return $a_users;
  441. }
  442. /**
  443. * Build the active-column of the table to lock or unlock a certain user
  444. * lock = the user can no longer use this account
  445. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  446. * @param int $active the current state of the account
  447. * @param int $user_id The user id
  448. * @param string $url_params
  449. * @return string Some HTML-code with the lock/unlock button
  450. */
  451. function active_filter($active, $url_params, $row) {
  452. global $_user;
  453. if ($active=='1') {
  454. $action='AccountActive';
  455. $image='right';
  456. }
  457. if ($active=='0') {
  458. $action='AccountInactive';
  459. $image='wrong';
  460. }
  461. if ($row['0']<>$_user['user_id']) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
  462. $result = '<center><img src="../img/'.$image.'.gif" border="0" style="vertical-align: middle;" alt="'.get_lang(ucfirst($action)).'" title="'.get_lang(ucfirst($action)).'"/></center>';
  463. }
  464. return $result;
  465. }
  466. /**
  467. * Build the modify-column of the table
  468. * @param int $user_id The user id
  469. * @return string Some HTML-code
  470. */
  471. function modify_filter($user_id) {
  472. global $origin,$_user, $_course, $is_allowed_to_track,$charset;
  473. $result="<div style='text-align: center'>";
  474. if ($is_allowed_to_track) {
  475. $result .= '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&student='.$user_id.'&amp;details=true&amp;course='.$_course['id'].'&amp;origin=user_course&amp;id_session='.$_SESSION["id_session"].'" title="'.get_lang('Tracking').'" ><img border="0" alt="'.get_lang('Tracking').'" src="../img/statistics.gif" /></a>&nbsp;';
  476. }
  477. if (api_is_allowed_to_edit()) {
  478. // edit
  479. $result .= '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;editMainUserInfo='.$user_id.'" title="'.get_lang('Edit').'" ><img border="0" alt="'.get_lang('Edit').'" src="../img/edit.gif" /></a>&nbsp;';
  480. // unregister
  481. if ( $user_id != $_user['user_id']) {
  482. $result .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&unregister=yes&amp;user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;"><img border="0" alt="'.get_lang("Unreg").'" src="../img/delete.gif"/></a>';
  483. } else {
  484. $result .= '<img border="0" alt="'.get_lang("Unreg").'" src="../img/delete_na.gif"/>';
  485. }
  486. }
  487. $result.="</div>";
  488. return $result;
  489. }
  490. $default_column = api_is_allowed_to_edit() ? 2 : 1;
  491. $table = new SortableTable('users', 'get_number_of_users', 'get_user_data',$default_column);
  492. $parameters['keyword'] = $_GET['keyword'];
  493. $table->set_additional_parameters($parameters);
  494. $header_nr = 0;
  495. if ( api_is_allowed_to_edit()) {
  496. $table->set_header($header_nr++, '', false);
  497. }
  498. $table->set_header($header_nr++, get_lang('Photo'),false);
  499. $table->set_header($header_nr++, get_lang('FirstName'));
  500. $table->set_header($header_nr++, get_lang('LastName'));
  501. $table->set_header($header_nr++, get_lang('Description'),false);
  502. $table->set_header($header_nr++, get_lang('GroupSingle'),false);
  503. $table->set_header($header_nr++, get_lang('OfficialCode'));
  504. if ( api_is_allowed_to_edit()) {
  505. // deprecated feature
  506. $table->set_header($header_nr++, get_lang('Tutor'),false);
  507. $table->set_header($header_nr++, get_lang('CourseManager'),false);
  508. $table->set_header($header_nr++, get_lang('Active'),false);
  509. $table->set_column_filter(9,'active_filter');
  510. }
  511. //actions column
  512. $table->set_header($header_nr++, get_lang('Modify'), false);
  513. $table->set_column_filter($header_nr-1,'modify_filter');
  514. if ( api_is_allowed_to_edit()) {
  515. $table->set_form_actions(array ('unsubscribe' => get_lang('Unreg')), 'user');
  516. }
  517. $table->display();
  518. if ( !empty($_GET['keyword']) && !empty($_GET['submit']) ) {
  519. $keyword_name=Security::remove_XSS($_GET['keyword']);
  520. echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
  521. }
  522. if ( get_setting('allow_user_headings') == 'true' && $is_courseAdmin && api_is_allowed_to_edit() && $origin != 'learnpath') { // only course administrators see this line
  523. echo "<div align=\"right\">", "<form method=\"post\" action=\"userInfo.php\">", get_lang("CourseAdministratorOnly"), " : ", "<input type=\"submit\" name=\"viewDefList\" value=\"".get_lang("DefineHeadings")."\" />", "</form>", "</div>\n";
  524. }
  525. //User list of the virtual courses linked to this course.
  526. //show_users_in_virtual_courses($is_allowed_to_track);
  527. /*
  528. ==============================================================================
  529. FOOTER
  530. ==============================================================================
  531. */
  532. if ( $origin != 'learnpath') {
  533. Display::display_footer();
  534. }