group_overview.php 4.6 KB

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