group_overview.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 chamilo.group
  14. */
  15. /**
  16. * INIT SECTION
  17. */
  18. // Name of the language file that needs to be included
  19. $language_file = 'group';
  20. require '../inc/global.inc.php';
  21. $this_section = SECTION_COURSES;
  22. $nameTools = get_lang('GroupOverview');
  23. /* Libraries */
  24. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  25. include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  26. include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  27. if (isset($_GET['action'])) {
  28. switch ($_GET['action']) {
  29. case 'export':
  30. $groups = GroupManager::get_group_list();
  31. $data = array();
  32. foreach ($groups as $index => $group) {
  33. $users = GroupManager::get_users($group['id']);
  34. foreach ($users as $index => $user) {
  35. $row = array();
  36. $user = api_get_user_info($user);
  37. $row[] = $group['name'];
  38. $row[] = $user['official_code'];
  39. $row[] = $user['lastName'];
  40. $row[] = $user['firstName'];
  41. $data[] = $row;
  42. }
  43. }
  44. switch ($_GET['type']) {
  45. case 'csv':
  46. Export::export_table_csv($data);
  47. exit;
  48. case 'xls':
  49. Export::export_table_xls($data);
  50. exit;
  51. }
  52. break;
  53. }
  54. }
  55. /* Header */
  56. $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
  57. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  58. // So we are not in learnpath tool
  59. if (!$is_allowed_in_course) {
  60. api_not_allowed(true);
  61. }
  62. if (!api_is_allowed_to_edit(false, true)) {
  63. api_not_allowed(true);
  64. } else {
  65. Display::display_header($nameTools, 'Group');
  66. }
  67. } else {
  68. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>default.css" /> <?php
  69. }
  70. // Action links
  71. echo '<div class="actions">';
  72. echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'',ICON_SIZE_MEDIUM).'</a>';
  73. echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
  74. if (api_get_setting('allow_group_categories') == 'true') {
  75. echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.Display::return_icon('new_folder.png', get_lang('AddCategory'),'',ICON_SIZE_MEDIUM).'</a>';
  76. } else {
  77. //echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
  78. echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'',ICON_SIZE_MEDIUM).'</a>';
  79. }
  80. //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> ';
  81. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
  82. echo '</div>';
  83. $categories = GroupManager::get_categories();
  84. foreach ($categories as $index => $category) {
  85. if (api_get_setting('allow_group_categories') == 'true') {
  86. echo '<h2>'.$category['title'].'</h2>';
  87. }
  88. $groups = GroupManager::get_group_list($category['id']);
  89. echo '<ul>';
  90. if (!empty($groups)) {
  91. foreach ($groups as $index => $group) {
  92. echo '<li>';
  93. echo Display::tag('h3', Security::remove_XSS($group['name']));
  94. echo '<ul>';
  95. $users = GroupManager::get_users($group['id']);
  96. if (!empty($users)) {
  97. foreach ($users as $index => $user) {
  98. $user_info = api_get_user_info($user);
  99. $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
  100. echo '<li title="'.$username.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
  101. }
  102. } else {
  103. //echo Display::tag('li', get_lang('NoStudents'));
  104. }
  105. echo '</ul>';
  106. echo '</li>';
  107. }
  108. } else {
  109. //echo Display::tag('li', get_lang('NoData'));
  110. }
  111. echo '</ul>';
  112. }
  113. /* FOOTER */
  114. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  115. Display::display_footer();
  116. }