group_overview.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Main page for the group module.
  5. * This script displays the general group settings,
  6. * and a list of groups with buttons to view, edit...
  7. *
  8. * @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
  9. * @author Bert Vanderkimpen, improved self-unsubscribe for cvs
  10. * @author Patrick Cool, show group comment under the group name
  11. * @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
  12. * @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
  13. * @package dokeos.group
  14. */
  15. /* INIT SECTION */
  16. // Name of the language file that needs to be included
  17. $language_file = 'group';
  18. require '../inc/global.inc.php';
  19. $this_section = SECTION_COURSES;
  20. $nameTools = get_lang('GroupOverview');
  21. /* Libraries */
  22. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  23. include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  24. include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  25. if (isset($_GET['action'])) {
  26. switch ($_GET['action']) {
  27. case 'export':
  28. $groups = GroupManager::get_group_list();
  29. $data = array();
  30. foreach ($groups as $index => $group) {
  31. $users = GroupManager::get_users($group['id']);
  32. foreach ($users as $index => $user) {
  33. $row = array();
  34. $user = api_get_user_info($user);
  35. $row[] = $group['name'];
  36. $row[] = $user['official_code'];
  37. $row[] = $user['lastName'];
  38. $row[] = $user['firstName'];
  39. $data[] = $row;
  40. }
  41. }
  42. switch ($_GET['type']) {
  43. case 'csv':
  44. Export::export_table_csv($data);
  45. exit;
  46. case 'xls':
  47. Export::export_table_xls($data);
  48. exit;
  49. }
  50. break;
  51. }
  52. }
  53. /* Header */
  54. $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
  55. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  56. // So we are not in learnpath tool
  57. if (!$is_allowed_in_course) {
  58. api_not_allowed(true);
  59. }
  60. if (!api_is_allowed_to_edit(false, true)) {
  61. api_not_allowed(true);
  62. } else {
  63. Display::display_header($nameTools, 'Group');
  64. }
  65. } else {
  66. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>default.css" /> <?php
  67. }
  68. // Action links
  69. echo '<div class="actions">';
  70. echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'','32').'</a>';
  71. echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups'),'','32').'</a>';
  72. if (api_get_setting('allow_group_categories') == 'true') {
  73. echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.Display::return_icon('new_folder.png', get_lang('AddCategory'),'','32').'</a>';
  74. } else {
  75. //echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
  76. echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'','32').'</a>';
  77. }
  78. //echo Display::return_icon('csv.gif', get_lang('ExportAsCSV')).'<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.get_lang('ExportAsCSV').'</a> ';
  79. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32').'</a>';
  80. echo '</div>';
  81. $categories = GroupManager::get_categories();
  82. foreach ($categories as $index => $category) {
  83. if (api_get_setting('allow_group_categories') == 'true') {
  84. echo '<h3>'.$category['title'].'</h3>';
  85. }
  86. $groups = GroupManager::get_group_list($category['id']);
  87. echo '<ul>';
  88. foreach ($groups as $index => $group) {
  89. echo '<li>';
  90. echo stripslashes($group['name']);
  91. echo '<ul>';
  92. $users = GroupManager::get_users($group['id']);
  93. foreach ($users as $index => $user) {
  94. $user_info = api_get_user_info($user);
  95. echo '<li>'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
  96. }
  97. echo '</ul>';
  98. echo '</li>';
  99. }
  100. echo '</ul>';
  101. }
  102. /* FOOTER */
  103. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  104. Display::display_footer();
  105. }