Dokeos PHP Cross Reference Learning Management Systems

Source: /main/group/group_overview.php - 175 lines - 4809 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /* For licensing terms, see /dokeos_license.txt */
   4  
   5  /**
   6  ==============================================================================
   7  *    @package dokeos.group
   8  ==============================================================================
   9  */
  10  
  11  // settings (temporarily added here)
  12  $_setting['group_overview'] = 'true';
  13  $_setting['group_export_csv'] = 'true';
  14  $_setting['group_export_xls'] = 'true';
  15  // setting to remove: allow_group_categories
  16  
  17  // name of the language file that needs to be included
  18  $language_file = "group";
  19  
  20  // including the global Dokeos file
  21  require_once  ('../inc/global.inc.php');
  22  
  23  // including additional libraries
  24  include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  25  include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  26  include_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  27  
  28  // the section (for the tabs)
  29  $this_section = SECTION_COURSES;
  30  
  31  // access control
  32  api_protect_course_script(true);
  33  if (!api_is_allowed_to_edit(false,true))
  34  {
  35      api_not_allowed();
  36  }
  37  
  38  // tracking
  39  event_access_tool(TOOL_GROUP);
  40  
  41  $nameTools = get_lang('GroupOverview');
  42  
  43  // header actions
  44  header_actions();
  45  
  46  // breadcrumbs
  47  $interbreadcrumb[]=array('url' => "group.php","name" => get_lang('Groups'));
  48  
  49  // display the header
  50  Display::display_header(get_lang('Groups'));
  51  
  52  // Tool introduction
  53  Display::display_introduction_section(TOOL_GROUP);
  54  
  55  // display the tool title
  56  //api_display_tool_title(get_lang('Groups'));
  57  
  58  // primary actions
  59  display_actions();
  60  
  61  //start the content div
  62  echo '<div id="content">';
  63  
  64  // all the categories
  65  $categories     = GroupManager::get_categories();
  66  $categories[]     = array('id'=>0);
  67  
  68  // all the groups
  69  $groups        = GroupManager::get_all_groups();
  70  
  71  // all the users
  72  $usersandgroups    = GroupManager::get_all_groups_and_users('group',array('user.firstname','user.lastname','user.email'));
  73  
  74  // looping through all the group categories (scenarios)
  75  foreach($categories as $index => $category)
  76  {
  77      // displaying the category (scenario) type
  78      if ($category['id'] <> 0){
  79          echo '<h3>'.$category['title'].'</h3>';
  80      } else {
  81          echo '<h3>'.get_lang('NoCategory').'</h3>';
  82      }
  83  
  84      // displaying all the groups in this category (scenario)
  85      echo '<ul class="groupsoverviewgroup">';
  86      foreach($groups as $index => $group)
  87      {
  88          if ($group['category_id'] == $category['id']) {
  89              echo '<li>'.$group['name'];
  90              echo '<ul class="groupsoverviewusers">';
  91              // displaying all the users in this group
  92              foreach($usersandgroups[$group['id']] as $index => $user)
  93              {
  94                  echo '<li>'.$user['firstname'].' '.$user['lastname'].'</li>';
  95              }
  96              echo '</ul>';
  97              echo '</li>';
  98          }
  99      }
 100      echo '</ul>';
 101  }
 102  
 103  // close the content div
 104  echo '</div>';
 105  
 106  // secondary action links
 107  display_secondary_actions();
 108  
 109  // Display the footer
 110  Display::display_footer();
 111  
 112  
 113  
 114  function display_actions(){
 115      echo '<div class="actions">';
 116      echo '<a href="group.php?'.api_get_cidreq().'">'.Display::return_icon('group.png', get_lang('Groups')).get_lang('Groups').'</a>';
 117      if (api_is_allowed_to_edit(false,true))
 118      {
 119          echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('groupadd.png', get_lang('NewGroupCreate')).' '.get_lang('NewGroupCreate').'</a>';
 120          echo '<a href="group_category.php?'.api_get_cidreq().'">'.Display::return_icon('dokeos_scenario.png', get_lang('Scenario')).' '.get_lang('Scenario').'</a>';
 121      }
 122      echo '</div>';
 123  }
 124  
 125  function header_actions(){
 126      if( isset($_GET['action']))
 127      {
 128          switch($_GET['action'])
 129          {
 130              case 'export':
 131                  $groups = GroupManager::get_group_list();
 132                  $data = array();
 133                  foreach($groups as $index => $group)
 134                  {
 135                      $users = GroupManager::get_users($group['id'],api_get_setting('user_order_by'));
 136                      foreach($users as $index => $user)
 137                      {
 138                          $row = array();
 139                          $user = api_get_user_info($user);
 140                          $row[] = $group['name'];
 141                          $row[] = $user['official_code'];
 142                          $row[] = $user['lastName'];
 143                          $row[] = $user['firstName'];
 144                          $data[] = $row;
 145                      }
 146                  }
 147                  switch($_GET['type'])
 148                  {
 149                      case 'csv':
 150                          Export::export_table_csv($data);
 151                      case 'xls':
 152                          Export::export_table_xls($data);
 153                  }
 154                  break;
 155          }
 156      }
 157  }
 158  
 159  function display_secondary_actions(){
 160      echo '<div class="actions">';
 161      if (api_is_allowed_to_edit(false,true)){
 162          // export
 163          if (api_is_allowed_to_edit(false,true)){
 164              if (api_get_setting('group_export_csv') == 'true') {
 165                  echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.Display::return_icon('csv.gif', get_lang('ExportAsCSV')).' '.get_lang('ExportAsCSV').'</a> ';
 166                  }
 167              if (api_get_setting('group_export_xls') == 'true') {
 168                  echo ' <a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' '.get_lang('ExportAsXLS').'</a>';
 169              }
 170          }
 171          echo '</div>';
 172      }
 173      echo '</div>';
 174  }
 175  ?>

title

Description

title

Description

title

Description

title

title

Body