group_space.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script shows the group space for one specific group, possibly displaying
  5. * a list of users in the group, subscribe or unsubscribe option, tutors...
  6. *
  7. * @package chamilo.group
  8. * @todo Display error message if no group ID specified
  9. */
  10. /* INIT SECTION */
  11. // Name of the language file that needs to be included
  12. $language_file = 'group';
  13. require_once '../inc/global.inc.php';
  14. $current_course_tool = TOOL_GROUP;
  15. // Notice for unauthorized people.
  16. api_protect_course_script(true);
  17. /* Libraries & config files */
  18. require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
  19. require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
  20. /* MAIN CODE */
  21. $group_id = api_get_group_id();
  22. $user_id = api_get_user_id();
  23. $current_group = GroupManager :: get_group_properties($group_id);
  24. if (empty($current_group)) {
  25. api_not_allowed();
  26. }
  27. $this_section = SECTION_COURSES;
  28. $nameTools = get_lang('GroupSpace');
  29. $interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
  30. /* Ensure all private groups // Juan Carlos Raña Trabado */
  31. $forums_of_groups = get_forums_of_group($current_group['id']);
  32. $forum_state_public = 0;
  33. if (is_array($forums_of_groups)) {
  34. foreach ($forums_of_groups as $key => $value) {
  35. if ($value['forum_group_public_private'] == 'public') {
  36. $forum_state_public = 1;
  37. }
  38. }
  39. }
  40. if ($current_group['doc_state'] != 1 && $current_group['calendar_state'] != 1 && $current_group['work_state'] != 1 && $current_group['announcements_state'] != 1 && $current_group['wiki_state'] != 1 && $current_group['chat_state'] != 1 && $forum_state_public != 1) {
  41. if (!api_is_allowed_to_edit(null,true) && !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) {
  42. echo api_not_allowed($print_headers);
  43. }
  44. }
  45. /* Header */
  46. Display::display_header($nameTools.' '.Security::remove_XSS($current_group['name']), 'Group');
  47. /* Introduction section (editable by course admin) */
  48. Display::display_introduction_section(TOOL_GROUP);
  49. /* Actions and Action links */
  50. /*
  51. * User wants to register in this group
  52. */
  53. if (!empty($_GET['selfReg']) && GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])) {
  54. GroupManager :: subscribe_users($user_id, $current_group['id']);
  55. Display :: display_normal_message(get_lang('GroupNowMember'));
  56. }
  57. /*
  58. * User wants to unregister from this group
  59. */
  60. if (!empty($_GET['selfUnReg']) && GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) {
  61. GroupManager :: unsubscribe_users($user_id, $current_group['id']);
  62. Display::display_normal_message(get_lang('StudentDeletesHimself'));
  63. }
  64. echo '<div class="actions">';
  65. echo '<a href="group.php">'.Display::return_icon('back.png',get_lang('BackToGroupList'),'',ICON_SIZE_MEDIUM).'</a>';
  66. /*
  67. * Register to group
  68. */
  69. $subscribe_group = '';
  70. if (GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])) {
  71. $subscribe_group = '<a class="btn" href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.get_lang("RegIntoGroup").'</a>';
  72. }
  73. /*
  74. * Unregister from group
  75. */
  76. $unsubscribe_group = '';
  77. if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) {
  78. $unsubscribe_group = '<a class="btn" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.get_lang("StudentUnsubscribe").'</a>';
  79. }
  80. echo '&nbsp;</div>';
  81. if (isset($_GET['action'])) {
  82. switch ($_GET['action']) {
  83. case 'show_msg':
  84. Display::display_normal_message(Security::remove_XSS($_GET['msg']));
  85. break;
  86. }
  87. }
  88. /* Main Display Area */
  89. $course_code = $_course['sysCode'];
  90. $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course(api_get_user_id(), $course_code);
  91. /*
  92. * Edit the group
  93. */
  94. $edit_url = '';
  95. if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())) {
  96. $my_origin = isset($origin) ? $origin : '';
  97. $edit_url = '<a href="group_edit.php?origin='.$my_origin.'&gidReq='.api_get_group_id().'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
  98. }
  99. echo Display::tag('h2', Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group);
  100. if (!empty($current_group['description'])) {
  101. echo '<p>'.Security::remove_XSS($current_group['description']).'</p>';
  102. }
  103. /*
  104. * Group Tools
  105. */
  106. // If the user is subscribed to the group or the user is a tutor of the group then
  107. if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) {
  108. echo '<ul>';
  109. $tools = '';
  110. // Link to the forum of this group
  111. $forums_of_groups = get_forums_of_group($current_group['id']);
  112. if (is_array($forums_of_groups)) {
  113. if ($current_group['forum_state'] != TOOL_NOT_AVAILABLE ) {
  114. foreach ($forums_of_groups as $key => $value) {
  115. if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false, true)) {
  116. $tools .= '<li style="display:inline; margin:5px;"><a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group">'.Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32).'</a></li>';
  117. }
  118. }
  119. }
  120. }
  121. if ($current_group['doc_state'] != TOOL_NOT_AVAILABLE ) {
  122. // Link to the documents area of this group
  123. $tools .= '<li style="display:inline; margin:5px;" ><a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'">'.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'</a></li>';
  124. }
  125. if ($current_group['calendar_state'] != TOOL_NOT_AVAILABLE) {
  126. // Link to a group-specific part of agenda
  127. $tools .= '<li style="display:inline; margin:5px;"><a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'&amp;acces=0">'.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'</a></li>';
  128. }
  129. if ($current_group['work_state'] != TOOL_NOT_AVAILABLE) {
  130. // Link to the works area of this group
  131. $tools .= '<li style="display:inline; margin:5px;" ><a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'</a></li>';
  132. }
  133. if ($current_group['announcements_state'] != TOOL_NOT_AVAILABLE) {
  134. // Link to a group-specific part of announcements
  135. $tools .= '<li style="display:inline; margin:5px;"><a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'</a></li>';
  136. }
  137. if ($current_group['wiki_state'] != TOOL_NOT_AVAILABLE) {
  138. // Link to the wiki area of this group
  139. $tools .= '<li style="display:inline; margin:5px;"><a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'].'">'.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'</a></li>';
  140. }
  141. if ($current_group['chat_state'] != TOOL_NOT_AVAILABLE) {
  142. // Link to the chat area of this group
  143. if (api_get_course_setting('allow_open_chat_window')) {
  144. $tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.png', get_lang('Chat'),'',ICON_SIZE_MEDIUM)."</a></li>";
  145. } else {
  146. $tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.png', get_lang('Chat'), array(), 32)."</a></li>";
  147. }
  148. }
  149. echo '</ul>';
  150. echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang('Tools').'</b></div>';
  151. if (!empty($tools)) {
  152. echo '<div style="margin-left:5px; margin-bottom:4px; margin-top:4px;">'.$tools.'</div>';
  153. }
  154. } else {
  155. echo '<ul>';
  156. $tools = '';
  157. // Link to the forum of this group
  158. $forums_of_groups = get_forums_of_group($current_group['id']);
  159. if (is_array($forums_of_groups)) {
  160. if ( $current_group['forum_state'] == TOOL_PUBLIC ) {
  161. foreach ($forums_of_groups as $key => $value) {
  162. if ($value['forum_group_public_private'] == 'public' ) {
  163. $tools.= '<li style="display:inline; margin:5px;"><a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group">'.Display::return_icon('forum.png', get_lang('GroupForum'), array(), 32).'</a></li>';
  164. }
  165. }
  166. }
  167. }
  168. if ($current_group['doc_state'] == TOOL_PUBLIC) {
  169. // Link to the documents area of this group
  170. $tools .= '<li style="display:inline; margin:5px;"><a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'&amp;origin='.$origin.'">'.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'</a></li>';
  171. }
  172. if ($current_group['calendar_state'] == TOOL_PUBLIC) {
  173. // Link to a group-specific part of agenda
  174. $tools .= '<li style="display:inline; margin:5px;"><a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'</a></li>';
  175. }
  176. if ($current_group['work_state'] == TOOL_PUBLIC) {
  177. // Link to the works area of this group
  178. $tools .= '<li style="display:inline; margin:5px;"><a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'</a></li>';
  179. }
  180. if ($current_group['announcements_state'] == TOOL_PUBLIC) {
  181. // Link to a group-specific part of announcements
  182. $tools .= '<li style="display:inline; margin:5px;"><a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'</a></li>';
  183. }
  184. if ($current_group['wiki_state'] == TOOL_PUBLIC) {
  185. // Link to the wiki area of this group
  186. $tools .= '<li style="display:inline; margin:5px;"><a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'].'">'.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'</a></li>';
  187. }
  188. if ($current_group['chat_state'] == TOOL_PUBLIC ) {
  189. // Link to the chat area of this group
  190. if (api_get_course_setting('allow_open_chat_window')) {
  191. $tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."</a></li>";
  192. } else {
  193. $tools .= "<li style=\"display:inline; margin:5px;\"><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."</a></li>";
  194. }
  195. }
  196. echo '</ul>';
  197. echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang('Tools').'</b></div>';
  198. if (!empty($tools)) {
  199. echo '<div style="margin-left:5px; margin-bottom:4px; margin-top:4px;">'.$tools.'</div>';
  200. }
  201. }
  202. /*
  203. * List all the tutors of the current group
  204. */
  205. $tutors = GroupManager::get_subscribed_tutors($current_group['id']);
  206. $tutor_info = '';
  207. if (count($tutors) == 0) {
  208. $tutor_info = get_lang('GroupNoneMasc');
  209. } else {
  210. isset($origin)?$my_origin = $origin:$my_origin='';
  211. foreach($tutors as $index => $tutor) {
  212. $tab_user_info = Database::get_user_info_from_id($tutor['user_id']);
  213. $username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
  214. $image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
  215. $image_repository = $image_path['dir'];
  216. $existing_image = $image_path['file'];
  217. $photo= '<img src="'.$image_repository.$existing_image.'" align="absbottom" alt="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" width="32" height="32" title="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" />';
  218. $tutor_info .= '<div style="margin-bottom: 5px;"><a href="../user/userInfo.php?origin='.$my_origin.'&amp;uInfo='.$tutor['user_id'].'">'.$photo.'&nbsp;'.Display::tag('span', api_get_person_name($tutor['firstname'], $tutor['lastname']), array('title'=>$username)).'</a></div>';
  219. }
  220. }
  221. echo '<div class="actions-message" style="margin-bottom:4px;style="margin:4px;"><b>'.get_lang('GroupTutors').'</b></div>';
  222. if (!empty($tutor_info)) {
  223. echo '<div style="margin-left:5px;">'.$tutor_info.'</div>';
  224. }
  225. echo '<br />';
  226. /*
  227. * List all the members of the current group
  228. */
  229. echo '<b>'.get_lang("GroupMembers").'</b>';
  230. $table = new SortableTable('group_users', 'get_number_of_group_users', 'get_group_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
  231. $my_cidreq = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : '';
  232. $my_origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
  233. $my_gidreq = isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : '';
  234. $parameters = array('cidReq' => $my_cidreq, 'origin'=> $my_origin, 'gidReq' => $my_gidreq);
  235. $table->set_additional_parameters($parameters);
  236. $table->set_header(0, '');
  237. if (api_is_western_name_order()) {
  238. $table->set_header(1, get_lang('FirstName'));
  239. $table->set_header(2, get_lang('LastName'));
  240. } else {
  241. $table->set_header(1, get_lang('LastName'));
  242. $table->set_header(2, get_lang('FirstName'));
  243. }
  244. if (api_get_setting('show_email_addresses') == 'true') {
  245. $table->set_header(3, get_lang('Email'));
  246. $table->set_column_filter(3, 'email_filter');
  247. } else {
  248. if (api_is_allowed_to_edit() == 'true') {
  249. $table->set_header(3, get_lang('Email'));
  250. $table->set_column_filter(3, 'email_filter');
  251. }
  252. }
  253. //the order of these calls is important
  254. $table->set_column_filter(1, 'user_name_filter');
  255. $table->set_column_filter(2, 'user_name_filter');
  256. $table->set_column_filter(0, 'user_icon_filter');
  257. $table->display();
  258. /**
  259. * Get the number of subscribed users to the group
  260. *
  261. * @return integer
  262. *
  263. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  264. * @version April 2008
  265. */
  266. function get_number_of_group_users() {
  267. global $current_group;
  268. $course_id = api_get_course_int_id();
  269. // Database table definition
  270. $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
  271. // Query
  272. $sql = "SELECT count(id) AS number_of_users FROM ".$table_group_user."
  273. WHERE c_id = $course_id AND group_id='".Database::escape_string($current_group['id'])."'";
  274. $result = Database::query($sql);
  275. $return = Database::fetch_array($result,'ASSOC');
  276. return $return['number_of_users'];
  277. }
  278. /**
  279. * Get the details of the users in a group
  280. *
  281. * @param integer $from starting row
  282. * @param integer $number_of_items number of items to be displayed
  283. * @param integer $column sorting colum
  284. * @param integer $direction sorting direction
  285. * @return array
  286. *
  287. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  288. * @version April 2008
  289. */
  290. function get_group_user_data($from, $number_of_items, $column, $direction) {
  291. global $current_group;
  292. // Database table definition
  293. $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
  294. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  295. $course_id = api_get_course_int_id();
  296. // Query
  297. if (api_get_setting('show_email_addresses') == 'true') {
  298. $sql = "SELECT user.user_id AS col0,
  299. ".(api_is_western_name_order() ?
  300. "user.firstname AS col1,
  301. user.lastname AS col2,"
  302. :
  303. "user.lastname AS col1,
  304. user.firstname AS col2,"
  305. )."
  306. user.email AS col3
  307. FROM ".$table_user." user, ".$table_group_user." group_rel_user
  308. WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id
  309. AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
  310. $sql .= " ORDER BY col$column $direction ";
  311. $sql .= " LIMIT $from,$number_of_items";
  312. } else {
  313. if (api_is_allowed_to_edit()) {
  314. $sql = "SELECT DISTINCT
  315. u.user_id AS col0,
  316. ".(api_is_western_name_order() ?
  317. "u.firstname AS col1,
  318. u.lastname AS col2,"
  319. :
  320. "u.lastname AS col1,
  321. u.firstname AS col2,"
  322. )."
  323. u.email AS col3
  324. FROM ".$table_user." u INNER JOIN ".$table_group_user." gu ON (gu.user_id = u.user_id) AND gu.c_id = $course_id
  325. WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'";
  326. $sql .= " ORDER BY col$column $direction ";
  327. $sql .= " LIMIT $from,$number_of_items";
  328. } else {
  329. $sql = "SELECT DISTINCT
  330. user.user_id AS col0,
  331. ". (api_is_western_name_order() ?
  332. "user.firstname AS col1,
  333. user.lastname AS col2 "
  334. :
  335. "user.lastname AS col1,
  336. user.firstname AS col2 "
  337. )."
  338. FROM ".$table_user." user, ".$table_group_user." group_rel_user
  339. WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id
  340. AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
  341. $sql .= " ORDER BY col$column $direction ";
  342. $sql .= " LIMIT $from,$number_of_items";
  343. }
  344. }
  345. $return = array();
  346. $result = Database::query($sql);
  347. while ($row = Database::fetch_row($result)) {
  348. $return[] = $row;
  349. }
  350. return $return;
  351. }
  352. /**
  353. * Returns a mailto-link
  354. * @param string $email An email-address
  355. * @return string HTML-code with a mailto-link
  356. */
  357. function email_filter($email) {
  358. return Display :: encrypted_mailto_link($email, $email);
  359. }
  360. /**
  361. * Display a user icon that links to the user page
  362. *
  363. * @param integer $user_id the id of the user
  364. * @return html code
  365. *
  366. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  367. * @version April 2008
  368. */
  369. function user_icon_filter($user_id) {
  370. global $origin;
  371. $userinfo = Database::get_user_info_from_id($user_id);
  372. $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
  373. $image_repository = $image_path['dir'];
  374. $existing_image = $image_path['file'];
  375. $photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" width="22" height="22" title="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" /></center>';
  376. return '<a href="../user/userInfo.php?origin='.$origin.'&amp;uInfo='.$user_id.'">'.$photo;
  377. }
  378. /**
  379. * Return user profile link around the given user name.
  380. *
  381. * The parameters use a trick of the sorteable table, where the first param is
  382. * the original value of the column
  383. * @param string User name (value of the column at the time of calling)
  384. * @param string URL parameters
  385. * @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there
  386. * @return string HTML link
  387. */
  388. function user_name_filter($name, $url_params, $row) {
  389. global $origin;
  390. $tab_user_info = Database::get_user_info_from_id($row[0]);
  391. $username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
  392. return '<a href="../user/userInfo.php?uInfo='.$row[0].'&amp;'.$url_params.'" title="'.$username.'">'.$name.'</a>';
  393. }
  394. // Footer
  395. $orig = isset($origin) ? $origin : '';
  396. if ($orig != 'learnpath') {
  397. Display::display_footer();
  398. }