group_overview.php 5.0 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. //require_once '../inc/global.inc.php';
  16. $this_section = SECTION_COURSES;
  17. $current_course_tool = TOOL_GROUP;
  18. // Notice for unauthorized people.
  19. api_protect_course_script(true);
  20. $nameTools = get_lang('GroupOverview');
  21. $courseId = api_get_course_int_id();
  22. $courseInfo = api_get_course_info();
  23. $is_allowed_in_course = api_is_allowed_in_course();
  24. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
  25. if (isset($_GET['action'])) {
  26. switch ($_GET['action']) {
  27. case 'export_all':
  28. $data = GroupManager::exportCategoriesAndGroupsToArray(null, true);
  29. Export::arrayToCsv($data);
  30. exit;
  31. break;
  32. case 'export_pdf':
  33. $content = GroupManager::getOverview($courseId, $keyword);
  34. $pdf = new PDF();
  35. $extra = '<div style="text-align:center"><h2>'.get_lang('GroupList').'</h2></div>';
  36. $extra .= '<strong>'.get_lang('Course').': </strong>'.$courseInfo['title'].' ('.$courseInfo['code'].')';
  37. $content = $extra.$content;
  38. $pdf->content_to_pdf($content, null, null, api_get_course_id());
  39. break;
  40. case 'export':
  41. $groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
  42. $data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true);
  43. switch ($_GET['type']) {
  44. case 'csv':
  45. Export::arrayToCsv($data);
  46. exit;
  47. break;
  48. case 'xls':
  49. if (!empty($data)) {
  50. Export::arrayToXls($data);
  51. exit;
  52. }
  53. break;
  54. }
  55. break;
  56. }
  57. }
  58. /* Header */
  59. $interbreadcrumb[] = array('url' => 'group.php?'.api_get_cidReq(), 'name' => get_lang('Groups'));
  60. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  61. // So we are not in learnpath tool
  62. if (!$is_allowed_in_course) {
  63. api_not_allowed(true);
  64. }
  65. if (!api_is_allowed_to_edit(false, true)) {
  66. api_not_allowed(true);
  67. } else {
  68. Display::display_header($nameTools, 'Group');
  69. // Tool introduction
  70. Display::display_introduction_section(TOOL_GROUP);
  71. }
  72. } else {
  73. Display::display_reduced_header();
  74. }
  75. $actions = '<a href="group_creation.php?'.api_get_cidreq().'">'.
  76. Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
  77. if (api_get_setting('group.allow_group_categories') == 'true') {
  78. $actions.= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
  79. Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
  80. } else {
  81. $actions.= '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.
  82. Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>';
  83. }
  84. $actions.= '<a href="import.php?'.api_get_cidreq().'&action=import">'.
  85. Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>';
  86. $actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
  87. Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  88. $actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
  89. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
  90. $actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
  91. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
  92. $actions.= '<a href="group.php?'.api_get_cidreq().'">'.
  93. Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
  94. $actions.= '<a href="../user/user.php?'.api_get_cidreq().'">'.
  95. Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
  96. // Action links
  97. echo '<div class="actions">';
  98. echo '<div class="row">';
  99. echo '<div class="col-md-6">';
  100. echo $actions;
  101. echo '</div>';
  102. echo '<div class="col-md-6">';
  103. echo '<div class="pull-right">';
  104. echo GroupManager::getSearchForm();
  105. echo '</div>';
  106. echo '</div>';
  107. echo '</div>';
  108. echo '</div>';
  109. echo GroupManager::getOverview($courseId, $keyword);
  110. if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
  111. Display::display_footer();
  112. }