group_overview.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 = array('group', 'admin');
  20. //require_once '../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. $courseId = api_get_course_int_id();
  27. $courseInfo = api_get_course_info();
  28. /* Libraries */
  29. include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  30. include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  31. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
  32. if (isset($_GET['action'])) {
  33. switch ($_GET['action']) {
  34. case 'export_all':
  35. $data = GroupManager::exportCategoriesAndGroupsToArray();
  36. Export::export_table_csv($data);
  37. exit;
  38. break;
  39. case 'export_pdf':
  40. $content = GroupManager::getOverview($courseId, $keyword);
  41. $pdf = new PDF();
  42. $extra = '<div style="text-align:center"><h2>'.get_lang('GroupList').'</h2></div>';
  43. $extra .= '<strong>'.get_lang('Course').': </strong>'.$courseInfo['title'].' ('.$courseInfo['code'].')';
  44. $content = $extra.$content;
  45. $pdf->content_to_pdf($content, null, null, api_get_course_id());
  46. break;
  47. case 'export':
  48. $groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
  49. $groups = GroupManager::get_group_list();
  50. $data = array();
  51. foreach ($groups as $index => $group) {
  52. if (!empty($groupId)) {
  53. if ($group['id'] != $groupId) {
  54. continue;
  55. }
  56. }
  57. $users = GroupManager::get_users($group['id']);
  58. foreach ($users as $index => $user) {
  59. $row = array();
  60. $user = api_get_user_info($user);
  61. $row[] = $group['name'];
  62. $row[] = $user['official_code'];
  63. $row[] = $user['lastName'];
  64. $row[] = $user['firstName'];
  65. $data[] = $row;
  66. }
  67. }
  68. switch ($_GET['type']) {
  69. case 'csv':
  70. Export::export_table_csv($data);
  71. exit;
  72. break;
  73. case 'xls':
  74. if (!empty($data)) {
  75. Export::export_table_xls($data);
  76. exit;
  77. }
  78. break;
  79. }
  80. break;
  81. }
  82. }
  83. /* Header */
  84. $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
  85. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  86. // So we are not in learnpath tool
  87. if (!$is_allowed_in_course) {
  88. api_not_allowed(true);
  89. }
  90. if (!api_is_allowed_to_edit(false, true)) {
  91. api_not_allowed(true);
  92. } else {
  93. Display::display_header($nameTools, 'Group');
  94. // Tool introduction
  95. Display::display_introduction_section(TOOL_GROUP);
  96. }
  97. } else {
  98. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>default.css" /> <?php
  99. }
  100. // Action links
  101. echo '<div class="actions">';
  102. echo '<a href="group_creation.php?'.api_get_cidreq().'">'.
  103. Display::return_icon('new_group.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
  104. if (api_get_setting('allow_group_categories') == 'true') {
  105. echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
  106. Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
  107. } else {
  108. echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.
  109. Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>';
  110. }
  111. echo '<a href="import.php?'.api_get_cidreq().'&action=import">'.
  112. Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>';
  113. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
  114. Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  115. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
  116. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
  117. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
  118. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
  119. echo '<a href="group.php?'.api_get_cidreq().'">'.
  120. Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
  121. echo '<a href="../user/user.php?'.api_get_cidreq().'">'.
  122. Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
  123. echo GroupManager::getSearchForm();
  124. echo '</div>';
  125. echo GroupManager::getOverview($courseId, $keyword);
  126. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  127. Display::display_footer();
  128. }