user.php 23 KB

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