group_overview.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /*
  3. ===============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
  9. Copyright (c) Bart Mollet
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ===============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * Main page for the group module.
  23. * This script displays the general group settings,
  24. * and a list of groups with buttons to view, edit...
  25. *
  26. * @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
  27. * @author Bert Vanderkimpen, improved self-unsubscribe for cvs
  28. * @author Patrick Cool, show group comment under the group name
  29. * @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
  30. * @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
  31. * @package dokeos.group
  32. ==============================================================================
  33. */
  34. /*
  35. ==============================================================================
  36. INIT SECTION
  37. ==============================================================================
  38. */
  39. // name of the language file that needs to be included
  40. $language_file = "group";
  41. include ('../inc/global.inc.php');
  42. $this_section=SECTION_COURSES;
  43. $nameTools = get_lang("GroupOverview");
  44. /*
  45. -----------------------------------------------------------
  46. Libraries
  47. -----------------------------------------------------------
  48. */
  49. include_once (api_get_path(LIBRARY_PATH).'course.lib.php'); //necessary
  50. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  51. include_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  52. include_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php'); //necessary for statistics
  53. if( isset($_GET['action']))
  54. {
  55. switch($_GET['action'])
  56. {
  57. case 'export':
  58. $groups = GroupManager::get_group_list();
  59. $data = array();
  60. foreach($groups as $index => $group)
  61. {
  62. $users = GroupManager::get_users($group['id']);
  63. foreach($users as $index => $user)
  64. {
  65. $row = array();
  66. $user = api_get_user_info($user);
  67. $row[] = $group['name'];
  68. $row[] = $user['official_code'];
  69. $row[] = $user['lastName'];
  70. $row[] = $user['firstName'];
  71. $data[] = $row;
  72. }
  73. }
  74. switch($_GET['type'])
  75. {
  76. case 'csv':
  77. Export::export_table_csv($data);
  78. case 'xls':
  79. Export::export_table_xls($data);
  80. }
  81. break;
  82. }
  83. }
  84. /*
  85. -----------------------------------------------------------
  86. Header
  87. -----------------------------------------------------------
  88. */
  89. $interbreadcrumb[]=array("url" => "group.php","name" => get_lang('GroupManagement'));
  90. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
  91. { //so we are not in learnpath tool
  92. if (! $is_allowed_in_course) api_not_allowed(true);
  93. else Display::display_header($nameTools,"Group");
  94. }
  95. else
  96. {
  97. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css" /> <?php
  98. }
  99. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.get_lang('ExportAsCSV').'</a>';
  100. echo ' | <a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.get_lang('ExportAsXLS').'</a>';
  101. $categories = GroupManager::get_categories();
  102. foreach($categories as $index => $category)
  103. {
  104. if( api_get_setting('allow_group_categories') == 'true')
  105. {
  106. echo '<h3>'.$category['title'].'</h3>';
  107. }
  108. $groups = GroupManager::get_group_list($category['id']);
  109. echo '<ul>';
  110. foreach($groups as $index => $group)
  111. {
  112. echo '<li>';
  113. echo stripslashes($group['name']);
  114. echo '<ul>';
  115. $users = GroupManager::get_users($group['id']);
  116. foreach($users as $index => $user)
  117. {
  118. $user_info = api_get_user_info($user);
  119. echo '<li>'.$user_info['firstName'].' '.$user_info['lastName'].'</li>';
  120. }
  121. echo '</ul>';
  122. echo '</li>';
  123. }
  124. echo '</ul>';
  125. }
  126. /*
  127. ==============================================================================
  128. FOOTER
  129. ==============================================================================
  130. */
  131. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
  132. {
  133. Display::display_footer();
  134. }
  135. ?>