group_overview.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. if (!api_is_allowed_to_edit(false, true)) {
  58. api_not_allowed(true);
  59. } else {
  60. Display::display_header($nameTools, 'Group');
  61. }
  62. } else {
  63. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>default.css" /> <?php
  64. }
  65. // Action links
  66. echo '<div class="actions">';
  67. echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'',ICON_SIZE_MEDIUM).'</a>';
  68. echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
  69. if (api_get_setting('allow_group_categories') == 'true') {
  70. 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>';
  71. } else {
  72. //echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
  73. echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'',ICON_SIZE_MEDIUM).'</a>';
  74. }
  75. //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> ';
  76. 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>';
  77. echo '</div>';
  78. $categories = GroupManager::get_categories();
  79. foreach ($categories as $index => $category) {
  80. if (api_get_setting('allow_group_categories') == 'true') {
  81. echo '<h2>'.$category['title'].'</h2>';
  82. }
  83. $groups = GroupManager::get_group_list($category['id']);
  84. echo '<ul>';
  85. if (!empty($groups)) {
  86. foreach ($groups as $index => $group) {
  87. echo '<li>';
  88. echo Display::tag('h3', Security::remove_XSS($group['name']));
  89. echo '<ul>';
  90. $users = GroupManager::get_users($group['id']);
  91. if (!empty($users)) {
  92. foreach ($users as $index => $user) {
  93. $user_info = api_get_user_info($user);
  94. $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
  95. echo '<li title="'.$username.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
  96. }
  97. } else {
  98. //echo Display::tag('li', get_lang('NoStudents'));
  99. }
  100. echo '</ul>';
  101. echo '</li>';
  102. }
  103. } else {
  104. //echo Display::tag('li', get_lang('NoData'));
  105. }
  106. echo '</ul>';
  107. }
  108. /* FOOTER */
  109. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  110. Display::display_footer();
  111. }