group_overview.php 4.8 KB

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