/mods/_standard/directory/directory.php

https://github.com/harriswong/ATutor · PHP · 109 lines · 78 code · 17 blank · 14 comment · 30 complexity · ce793f9ddaad1a50635ad4f5d1c05bb2 MD5 · raw file

  1. <?php
  2. /****************************************************************/
  3. /* ATutor */
  4. /****************************************************************/
  5. /* Copyright (c) 2002-2010 */
  6. /* Inclusive Design Institute */
  7. /* http://atutor.ca */
  8. /* */
  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. */
  12. /****************************************************************/
  13. // $Id$
  14. define('AT_INCLUDE_PATH', '../../../include/');
  15. require(AT_INCLUDE_PATH.'vitals.inc.php');
  16. /* should only be in here if you are enrolled in the course!!!!!! */
  17. if ($_SESSION['enroll'] == '') {
  18. require(AT_INCLUDE_PATH.'header.inc.php');
  19. $msg->addInfo('NOT_ENROLLED');
  20. $msg->printAll();
  21. require(AT_INCLUDE_PATH.'footer.inc.php');
  22. exit;
  23. }
  24. if ($_GET['reset_filter']) {
  25. unset($_GET);
  26. }
  27. if (isset($_GET['online_status']) && ($_GET['online_status'] != '')) {
  28. if ($_GET['online_status'] == 1) {
  29. $on = 'checked="checked"';
  30. } else if ($_GET['online_status'] == 2) {
  31. $all = 'checked="checked"';
  32. } else if ($_GET['online_status'] == 0) {
  33. $off = 'checked="checked"';
  34. }
  35. } else {
  36. $all = 'checked="checked"';
  37. }
  38. $group = abs($_GET['group']);
  39. $sql_groups = implode(',', $_SESSION['groups']);
  40. $sql = "SELECT G.title, G.group_id, T.title AS type_title FROM ".TABLE_PREFIX."groups G INNER JOIN ".TABLE_PREFIX."groups_types T USING (type_id) WHERE T.course_id=$_SESSION[course_id] AND G.group_id IN ($sql_groups) ORDER BY T.title";
  41. $result_groups = mysql_query($sql, $db);
  42. if ($_GET['order'] == 'asc') {
  43. $order = 'desc';
  44. } else {
  45. $order = 'asc';
  46. }
  47. $group_members = '';
  48. if ($group) {
  49. $group_members = array();
  50. $sql = "SELECT member_id FROM ".TABLE_PREFIX."groups_members WHERE group_id=$group";
  51. $result = mysql_query($sql, $db);
  52. while ($row = mysql_fetch_assoc($result)) {
  53. $group_members[] = $row['member_id'];
  54. }
  55. $group_members = ' AND C.member_id IN (' . implode(',', $group_members) . ')';
  56. }
  57. /* look through enrolled students list */
  58. $sql_members = "SELECT C.member_id, C.approved, C.privileges, M.login, M.first_name, M.second_name, M.last_name FROM ".TABLE_PREFIX."course_enrollment C, ".TABLE_PREFIX."members M WHERE C.course_id=$_SESSION[course_id] AND C.member_id=M.member_id AND (C.approved='y' OR C.approved='a') $group_members ORDER BY M.login $order";
  59. $result_members = mysql_query($sql_members, $db);
  60. while ($row_members = mysql_fetch_assoc($result_members)) {
  61. $all_[$row_members['member_id']] = $row_members;
  62. $all_[$row_members['member_id']]['online'] = FALSE;
  63. }
  64. $sql_online = "SELECT member_id FROM ".TABLE_PREFIX."users_online WHERE course_id = $_SESSION[course_id] AND expiry>".time();
  65. $result_online = mysql_query($sql_online, $db);
  66. while ($row_online = mysql_fetch_assoc($result_online)) {
  67. if ($all_[$row_online['member_id']] != '') {
  68. $all_[$row_online['member_id']]['online'] = TRUE;
  69. $online[$row_online['member_id']] = $all_[$row_online['member_id']];
  70. }
  71. }
  72. if ($all) {
  73. $final = $all_;
  74. } else if ($on) {
  75. $final = $online;
  76. } else {
  77. foreach ($all_ as $id=>$attrs) {
  78. if ($attrs['online'] == FALSE) {
  79. $final[$id] = $attrs;
  80. }
  81. }
  82. }
  83. require(AT_INCLUDE_PATH.'header.inc.php');
  84. $savant->assign('result_groups', $result_groups);
  85. $savant->assign('final', $final);
  86. $savant->assign('base_href', $_base_href);
  87. $savant->assign('on', $on);
  88. $savant->assign('off', $off);
  89. $savant->assign('all', $all);
  90. $savant->display('directory.tmpl.php');
  91. require(AT_INCLUDE_PATH.'footer.inc.php');
  92. ?>