Feature #272 - "Groups" tool: Minor corrections and code cleaning.

skala
Ivan Tcholakov 15 years ago
parent fe9c92f9e9
commit 189bf37d05
  1. 370
      main/group/group.php
  2. 179
      main/group/group_category.php
  3. 379
      main/group/group_creation.php
  4. 160
      main/group/group_edit.php
  5. 147
      main/group/group_overview.php
  6. 365
      main/group/group_space.php

@ -1,56 +1,31 @@
<?php // $Id: group.php 22201 2009-07-17 19:57:03Z cfasanando $
<?php
/* For licensing terms, see /license.txt */
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
/**
* Main page for the group module.
* This script displays the general group settings,
* and a list of groups with buttons to view, edit...
*
* @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
* @author Bert Vanderkimpen, improved self-unsubscribe for cvs
* @author Patrick Cool, show group comment under the group name
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @author Isaac Flores, code cleaning and improvements
* @package chamilo.group
*/
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* INIT SECTION */
/**
==============================================================================
* Main page for the group module.
* This script displays the general group settings,
* and a list of groups with buttons to view, edit...
*
* @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
* @author Bert Vanderkimpen, improved self-unsubscribe for cvs
* @author Patrick Cool, show group comment under the group name
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @author Isaac Flores, code cleaning and improvements
* @package dokeos.group
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
// Name of the language file that needs to be included
$language_file = 'group';
require_once '../inc/global.inc.php';
$this_section=SECTION_COURSES;
$this_section = SECTION_COURSES;
// notice for unauthorized people.
// Notice for unauthorized people.
api_protect_course_script(true);
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
@ -63,36 +38,30 @@ $(document).ready( function() {
</script>';
$nameTools = get_lang('GroupManagement');
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
/* Libraries */
//Create default category if it doesn't exist when group categories aren't allowed
if( api_get_setting('allow_group_categories') == 'false')
{
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
// Create default category if it doesn't exist when group categories aren't allowed
if (api_get_setting('allow_group_categories') == 'false') {
$cat_table = Database::get_course_table(TABLE_GROUP_CATEGORY);
$sql = "SELECT * FROM $cat_table WHERE id = '".DEFAULT_GROUP_CATEGORY."'";
$res = Database::query($sql);
$num = Database::num_rows($res);
if($num == 0)
{
if ($num == 0) {
Database::query("INSERT INTO ".$cat_table." ( id , title , description , forum_state , wiki_state, max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) VALUES ('2', '".lang2db($DefaultGroupCategory)."', '', '1', '1', '8', '0', '0', '0', '0');");
}
}
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
{ //so we are not in learnpath tool
/* Header */
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
// So we are not in learnpath tool
event_access_tool(TOOL_GROUP);
if (! $is_allowed_in_course) api_not_allowed(true);
if (!$is_allowed_in_course) {
api_not_allowed(true);
}
}
Display::display_header(get_lang('Groups'));
@ -109,21 +78,17 @@ Display::display_introduction_section(TOOL_GROUP);
$my_get_id2 = Security::remove_XSS($_GET['id2']);
$my_get_id = Security::remove_XSS($_GET['id']);
if (isset ($_GET['action']))
{
switch ($_GET['action'])
{
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'self_reg' :
if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $my_group_id))
{
GroupManager :: subscribe_users($_SESSION['_user']['user_id'],$my_group_id);
if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $my_group_id)) {
GroupManager :: subscribe_users($_SESSION['_user']['user_id'], $my_group_id);
Display :: display_confirmation_message(get_lang('GroupNowMember'));
}
break;
case 'self_unreg' :
if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $my_group_id))
{
GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'],$my_group_id);
if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $my_group_id)) {
GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'], $my_group_id);
Display :: display_confirmation_message(get_lang('StudentDeletesHimself'));
}
break;
@ -132,62 +97,56 @@ if (isset ($_GET['action']))
break;
}
}
/*
* Group-admin functions
*/
if (api_is_allowed_to_edit(false,true))
{
if (api_is_allowed_to_edit(false, true)) {
// Post-actions
if (isset ($_POST['action']))
{
switch ($_POST['action'])
{
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'delete_selected' :
if( is_array($_POST['group']))
{
if (is_array($_POST['group'])) {
GroupManager :: delete_groups($my_group);
Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted'));
}
break;
case 'empty_selected' :
if( is_array($_POST['group']))
{
if (is_array($_POST['group'])) {
GroupManager :: unsubscribe_all_users($my_group);
Display :: display_confirmation_message(get_lang('SelectedGroupsEmptied'));
}
break;
case 'fill_selected' :
if( is_array($_POST['group']))
{
if (is_array($_POST['group'])) {
GroupManager :: fill_groups($my_group);
Display :: display_confirmation_message(get_lang('SelectedGroupsFilled'));
}
break;
}
}
// Get-actions
if (isset ($_GET['action']))
{
switch ($_GET['action'])
{
case 'swap_cat_order' :
GroupManager :: swap_category_order($my_get_id1,$my_get_id2);
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'swap_cat_order':
GroupManager :: swap_category_order($my_get_id1, $my_get_id2);
Display :: display_confirmation_message(get_lang('CategoryOrderChanged'));
break;
case 'delete_one' :
case 'delete_one':
GroupManager :: delete_groups($my_get_id);
Display :: display_confirmation_message(get_lang('GroupDel'));
break;
case 'empty_one' :
case 'empty_one':
GroupManager :: unsubscribe_all_users($my_get_id);
Display :: display_confirmation_message(get_lang('GroupEmptied'));
break;
case 'fill_one' :
case 'fill_one':
GroupManager :: fill_groups($my_get_id);
Display :: display_confirmation_message(get_lang('GroupFilledGroups'));
break;
case 'delete_category' :
case 'delete_category':
GroupManager :: delete_category($my_get_id);
Display :: display_confirmation_message(get_lang('CategoryDeleted'));
break;
@ -196,10 +155,9 @@ if (api_is_allowed_to_edit(false,true))
}
echo '<div class="actions">';
if (api_is_allowed_to_edit(false,true))
{
if (api_is_allowed_to_edit(false, true)) {
echo Display::return_icon('groupadd.gif', get_lang('NewGroupCreate')) . '<a href="group_creation.php?'.api_get_cidreq().'">'.get_lang('NewGroupCreate').'</a>&nbsp;';
if( Database::count_rows(Database::get_course_table(TABLE_GROUP)) > 0) {
if (Database::count_rows(Database::get_course_table(TABLE_GROUP)) > 0) {
//echo '<a href="group_overview.php?'.api_get_cidreq().'">'.Display::return_icon('group_view.gif').'&nbsp;'.get_lang('GroupOverview').'</a>&nbsp;';
echo Display::return_icon('group.gif', get_lang('GroupOverview')) .'<a href="group_overview.php?'.api_get_cidreq().'">'.get_lang('GroupOverview').'</a>&nbsp;';
}
@ -214,165 +172,133 @@ if (api_is_allowed_to_edit(false,true))
echo Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' <a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.get_lang('ExportAsXLS').'</a>';
//echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('group_add_big.gif').'&nbsp;'.get_lang('NewGroupCreate').'</a>&nbsp;';
}
$group_cats = GroupManager :: get_categories();
if (api_get_setting('allow_group_categories') == 'true' && count($group_cats) > 1)
{
if (api_get_setting('allow_group_categories') == 'true' && count($group_cats) > 1) {
//echo '<p><a href="?'.api_get_cidreq().'&show_all=1">'.get_lang('ShowAll').'</a></p>';
echo Display::return_icon('group.gif').' <a href="?'.api_get_cidreq().'&show_all=1">'.get_lang('ShowAll').'</a>';
}
echo '</div>';
/*
* List all categories
*/
foreach ($group_cats as $index => $category)
{
global $charset;
foreach ($group_cats as $index => $category) {
$group_list = array ();
$in_category = false;
if (api_get_setting('allow_group_categories') == 'true')
{
if (isset ($_GET['show_all']) || (isset ($_GET['category']) && $_GET['category'] == $category['id']))
{
if (api_get_setting('allow_group_categories') == 'true') {
if (isset ($_GET['show_all']) || (isset ($_GET['category']) && $_GET['category'] == $category['id'])) {
echo '<img src="../img/shared_folder.gif" alt=""/>';
echo ' <a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'">'.$category['title'].'</a>';
echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'">'.$category['title'].'</a>';
$in_category = true;
}
else
{
} else {
echo '<img src="../img/folder_document.gif" alt=""/>';
echo ' <a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&amp;category='.$category['id'].'">'.$category['title'].'</a>';
echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&amp;category='.$category['id'].'">'.$category['title'].'</a>';
}
$group_list = GroupManager :: get_group_list($category['id']);
echo ' ('.count($group_list).' '.get_lang('ExistingGroups').')';
if (api_is_allowed_to_edit(false,true))
{
if (api_is_allowed_to_edit(false, true)) {
echo '<a href="group_category.php?'.api_get_cidreq().'&id='.$category['id'].'" title="'.get_lang('Edit').'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'"/></a> ';
echo '<a href="group.php?'.api_get_cidreq().'&action=delete_category&amp;id='.$category['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a> ';
if ($index != 0)
{
echo '<a href="group.php?'.api_get_cidreq().'&action=delete_category&amp;id='.$category['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a> ';
if ($index != 0) {
echo ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index -1]['id'].'"><img src="../img/up.gif" alt=""/></a>';
}
if ($index != count($group_cats) - 1)
{
if ($index != count($group_cats) - 1) {
echo ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index +1]['id'].'"><img src="../img/down.gif" alt=""/></a>';
}
}
echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>';
} else {
$group_list = GroupManager :: get_group_list();
$in_category = true;
}
else {
$group_list = GroupManager :: get_group_list();
$in_category = true;
}
//if (count($group_list) > 0 && $in_category)
if ($in_category)
{
if ($in_category) {
$totalRegistered = 0;
// Determine wether current user is tutor for this course
$user_is_tutor = GroupManager :: is_tutor($_user['user_id']);
$group_data = array ();
$group_data = array();
foreach ($group_list as $index => $this_group) {
//validacion when belongs to a session
// Validacion when belongs to a session
$session_img = api_get_session_image($this_group['session_id'], $_user['status']);
// all the tutors of this group
$tutorsids_of_group=GroupManager::get_subscribed_tutors($this_group['id'],true);
// All the tutors of this group
$tutorsids_of_group=GroupManager::get_subscribed_tutors($this_group['id'], true);
// create a new table-row
// Create a new table-row
$row = array ();
// checkbox
if (api_is_allowed_to_edit(false,true) && count($group_list) > 1)
{
// Checkbox
if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) {
$row[] = $this_group['id'];
}
// group name
if ((api_is_allowed_to_edit(false,true) ||
in_array($_user['user_id'],$tutorsids_of_group) ||
// Group name
if ((api_is_allowed_to_edit(false, true) ||
in_array($_user['user_id'], $tutorsids_of_group) ||
$this_group['is_member'] ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_FORUM) ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_DOCUMENTS) ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_CALENDAR) ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_ANNOUNCEMENT) ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_WORK) ||
GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_WIKI))
&& !(api_is_course_coach() && intval($this_group['session_id'])!=intval($_SESSION['id_session'])))
{
isset($origin)?$orig=$origin:$orig=null;
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_FORUM) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_DOCUMENTS) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_CALENDAR) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_ANNOUNCEMENT) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WORK) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WIKI))
&& !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
$orig = isset($origin) ? $origin : null;
$group_name = '<a href="group_space.php?'.api_get_cidreq().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.stripslashes($this_group['name']).'</a>';
if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor'])
{
if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) {
$group_name .= ' ('.get_lang('OneMyGroups').')';
}
elseif ($this_group['is_member'])
{
} elseif ($this_group['is_member']) {
$group_name .= ' ('.get_lang('MyGroup').')';
}
if(api_is_allowed_to_edit() && !empty($this_group['session_name']))
{
if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) {
$group_name .= ' ('.$this_group['session_name'].')';
}
$group_name .= $session_img;
$row[] = $group_name.'<br/>'.stripslashes(trim($this_group['description']));
}
else
{
$row[] = $this_group['name'].'<br/>'.stripslashes(trim($this_group['description']));
$row[] = $group_name.'<br />'.stripslashes(trim($this_group['description']));
} else {
$row[] = $this_group['name'].'<br />'.stripslashes(trim($this_group['description']));
}
// self-registration / unregistration
if (!api_is_allowed_to_edit(false,true))
{
if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id']))
{
// Self-registration / unregistration
if (!api_is_allowed_to_edit(false, true)) {
if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) {
$row[] = '<a href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
}
elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id']))
{
} elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id'])) {
$row[] = '<a href="group.php?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
}
else
{
} else {
$row[] = '-';
}
}
// number of members in group
// Number of members in group
$row[] = $this_group['number_of_members'];
// max number of members in group
// Max number of members in group
$row[] = ($this_group['maximum_number_of_members'] == MEMBER_PER_GROUP_NO_LIMIT ? '-' : $this_group['maximum_number_of_members']);
// tutor name
// Tutor name
$tutor_info = '';
if(count($tutorsids_of_group)>0)
{
foreach($tutorsids_of_group as $tutor_id){
if (count($tutorsids_of_group) > 0) {
foreach ($tutorsids_of_group as $tutor_id) {
$tutor = api_get_user_info($tutor_id);
if (api_get_setting("show_email_addresses") == "true")
{
if (api_get_setting('show_email_addresses') == 'true') {
$tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
}
else
{
if (api_is_allowed_to_edit()=='true')
{
} else {
if (api_is_allowed_to_edit()) {
$tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', ';
}
else
{
} else {
$tutor_info .= api_get_person_name($tutor['firstName'], $tutor['lastName']).', ';
}
}
}
}
$tutor_info = api_substr($tutor_info,0,api_strlen($tutor_info)-2);
$tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
$row[] = $tutor_info;
// edit-links
if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && intval($this_group['session_id'])!=intval($_SESSION['id_session'])))
{
// Edit-links
if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
$edit_actions = '<a href="group_edit.php?'.api_get_cidreq().'&gidReq='.$this_group['id'].'" title="'.get_lang('Edit').'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'"/></a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=delete_one&amp;id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;" title="'.get_lang('EmptyGroup').'"><img src="../img/clean_group.gif" alt="'.get_lang('EmptyGroup').'"/></a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=fill_one&amp;id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;" title="'.get_lang('FillGroup').'"><img src="../img/fill_group.gif" alt="'.get_lang('FillGroup').'"/></a>';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=delete_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'"><img src="../img/clean_group.gif" alt="'.get_lang('EmptyGroup').'"/></a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&category='.$category['id'].'&amp;action=fill_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'"><img src="../img/fill_group.gif" alt="'.get_lang('FillGroup').'"/></a>';
$row[] = $edit_actions;
}
if (!empty($this_group['nbMember'])) {
@ -381,58 +307,46 @@ foreach ($group_cats as $index => $category)
$group_data[] = $row;
} // while loop
if (isset ($_GET['show_all']))
{
$paging_options = array ('per_page' => count($group_data));
}
else
{
if (isset ($_GET['show_all'])) {
$paging_options = array('per_page' => count($group_data));
} else {
$paging_options = array ();
}
$table = new SortableTableFromArrayConfig($group_data, 1);
isset($_GET['category'])?$my_cat = Security::remove_XSS($_GET['category']): $my_cat = null;
$table->set_additional_parameters(array('category'=>$my_cat));
$my_cat = isset($_GET['category']) ? Security::remove_XSS($_GET['category']) : null;
$table->set_additional_parameters(array('category' => $my_cat));
$column = 0;
if (api_is_allowed_to_edit(false,true) and count($group_list) > 1)
{
$table->set_header($column++,'', false);
if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) {
$table->set_header($column++, '', false);
}
$table->set_header($column++,get_lang('ExistingGroups'));
if (!api_is_allowed_to_edit(false,true)) // If self-registration allowed
{
$table->set_header($column++,get_lang('GroupSelfRegistration'));
$table->set_header($column++, get_lang('ExistingGroups'));
if (!api_is_allowed_to_edit(false, true)) { // If self-registration allowed
$table->set_header($column++, get_lang('GroupSelfRegistration'));
}
$table->set_header($column++,get_lang('Registered'));
$table->set_header($column++,get_lang('MaximumOfParticipants'));
$table->set_header($column++,get_lang('GroupTutor'));
if (api_is_allowed_to_edit(false,true)) // only for course administrator
{
$table->set_header($column++,get_lang('Modify'), false);
$table->set_header($column++, get_lang('Registered'));
$table->set_header($column++, get_lang('MaximumOfParticipants'));
$table->set_header($column++, get_lang('GroupTutor'));
if (api_is_allowed_to_edit(false, true)) { // Only for course administrator
$table->set_header($column++, get_lang('Modify'), false);
$form_actions = array();
$form_actions['delete_selected'] = get_lang('Delete');
$form_actions['fill_selected'] = get_lang('FillGroup');
$form_actions['empty_selected'] = get_lang('EmptyGroup');
if (count($group_list) > 1)
{
$table->set_form_actions($form_actions,'group');
if (count($group_list) > 1) {
$table->set_form_actions($form_actions, 'group');
}
}
$table->display();
}
/*
elseif ($in_category)
{
elseif ($in_category) {
echo get_lang('NoGroupsAvailable');
}
*/
}
/*
==============================================================================
FOOTER
==============================================================================
*/
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
{
/* FOOTER */
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
Display::display_footer();
}
?>

@ -1,160 +1,121 @@
<?php
// $Id: group_category.php 21074 2009-05-29 15:48:32Z cvargas1 $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
==============================================================================
* @package dokeos.group
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = "group";
require_once ('../inc/global.inc.php');
* @package chamilo.group
*/
// Name of the language file that needs to be included
$language_file = 'group';
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
if (!api_is_allowed_to_edit(false,true) || !(isset ($_GET['id']) || isset ($_POST['id']) || isset ($_GET['action']) || isset ($_POST['action'])))
{
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
if (!api_is_allowed_to_edit(false,true) || !(isset ($_GET['id']) || isset ($_POST['id']) || isset ($_GET['action']) || isset ($_POST['action']))) {
api_not_allowed();
}
/**
* Function to check the given max number of members per group
*/
function check_max_number_of_members($value)
{
function check_max_number_of_members($value) {
$max_member_no_limit = $value['max_member_no_limit'];
if( $max_member_no_limit == MEMBER_PER_GROUP_NO_LIMIT)
{
if ($max_member_no_limit == MEMBER_PER_GROUP_NO_LIMIT) {
return true;
}
$max_member = $value['max_member'];
return is_numeric($max_member);
}
/**
* Function to check the number of groups per user
*/
function check_groups_per_user($value)
{
function check_groups_per_user($value) {
$groups_per_user = $value['groups_per_user'];
if(isset ($_POST['id']) && intval($groups_per_user) != GROUP_PER_MEMBER_NO_LIMIT && GroupManager :: get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user))
{
if (isset ($_POST['id']) && intval($groups_per_user) != GROUP_PER_MEMBER_NO_LIMIT && GroupManager :: get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user)) {
return false;
}
return true;
}
if (api_get_setting('allow_group_categories') == 'true')
{
if (isset ($_GET['id']))
{
if (api_get_setting('allow_group_categories') == 'true') {
if (isset ($_GET['id'])) {
$category = GroupManager :: get_category($_GET['id']);
$nameTools = get_lang('EditGroupCategory').': '.$category['title'];
}
else
{
} else {
$nameTools = get_lang('AddCategory');
// default values for new category
// Default values for new category
$category = array ('groups_per_user' => 1, 'doc_state' => TOOL_PRIVATE, 'work_state' => TOOL_PRIVATE, 'wiki_state' => TOOL_PRIVATE , 'chat_state' => TOOL_PRIVATE, 'calendar_state' => TOOL_PRIVATE, 'announcements_state'=> TOOL_PRIVATE, 'forum_state' => TOOL_PRIVATE, 'max_student' => 0);
}
}
else
{
} else {
$category = GroupManager :: get_category($_GET['id']);
$nameTools = get_lang('PropModify');
}
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
// Build the form
if (isset ($_GET['id']))
{
if (isset ($_GET['id'])) {
// Update settings of existing category
$action = 'update_settings';
$form = new FormValidator('group_category', 'post', '?id='.$category['id']);
$form->addElement('header','',$nameTools);
$form->addElement('hidden', 'id');
}
else
{
//Checks if the field was created in the table Category. It creates it if is neccesary
} else {
// Checks if the field was created in the table Category. It creates it if is neccesary
$table_category = Database :: get_course_table(TABLE_GROUP_CATEGORY);
if (Database::query("SELECT wiki_state FROM $table_category") == FALSE) {
if (!Database::query("SELECT wiki_state FROM $table_category")) {
Database::query("ALTER TABLE $table_category ADD `wiki_state` tinyint(3) UNSIGNED NOT NULL default '1';");
}
// Create a new category
$action = 'add_category';
$form = new FormValidator('group_category');
}
$form->addElement('html', '<div class="sectiontitle" >'.$nameTools);
$form->addElement('html', '</div>');
$form->addElement('html', '<div class="sectiontitle" >'.$nameTools);
$form->addElement('html', '</div>');
// If categories allowed, show title & description field
if (api_get_setting('allow_group_categories') == 'true')
{
if (api_get_setting('allow_group_categories') == 'true') {
$form->add_textfield('title', get_lang('Title'));
$form->addElement('textarea', 'description', get_lang('Description'),array('cols'=>50,'rows'=>6));
}
else
{
$form->addElement('hidden','title');
$form->addElement('hidden','description');
$form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 50, 'rows' => 6));
} else {
$form->addElement('hidden', 'title');
$form->addElement('hidden', 'description');
}
// Action
$form->addElement('hidden', 'action');
// Groups per user
$group = array ();
$group[] = & $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartBeforeNumber'));
$possible_values = array ();
for ($i = 1; $i <= 10; $i ++)
{
for ($i = 1; $i <= 10; $i ++) {
$possible_values[$i] = $i;
}
$possible_values[GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
$group[] = & $form->createElement('select', 'groups_per_user', null, $possible_values);
$group[] = & $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber'));
$form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false);
$form->addRule('limit_group',get_lang('MaxGroupsPerUserInvalid'),'callback','check_groups_per_user');
$form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user');
// Default settings for new groups
//$form->addElement('static', null, '<b>'.get_lang('DefaultSettingsForNewGroups').'</b>');
$form->addElement('html', '<br/><br/><div class="sectiontitle" >'.get_lang('DefaultSettingsForNewGroups'));
$form->addElement('html', '<br /><br /><div class="sectiontitle" >'.get_lang('DefaultSettingsForNewGroups'));
$form->addElement('html', '</div>');
// Members per group
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'),MEMBER_PER_GROUP_NO_LIMIT);
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), MEMBER_PER_GROUP_NO_LIMIT);
$group = array ();
$group[] = & $form->createElement('radio', 'max_member_no_limit',null,get_lang('MaximumOfParticipants'),1);
$group[] = & $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1);
$group[] = & $form->createElement('text', 'max_member', null, array ('size' => 2));
$group[] = & $form->createElement('static', null, null, get_lang('GroupPlacesThis'));
$form->addGroup($group, 'max_member_group', null, '',false);
$form->addRule('max_member_group',get_lang('InvalidMaxNumberOfMembers'),'callback','check_max_number_of_members');
$form->addGroup($group, 'max_member_group', null, '', false);
$form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members');
// Self registration
$form->addElement('checkbox', 'self_reg_allowed', get_lang('GroupSelfRegistration'), get_lang('GroupAllowStudentRegistration'), 1);
$form->addElement('checkbox', 'self_unreg_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1);
@ -179,7 +140,7 @@ $form->addElement('radio', 'announcements_state', get_lang('GroupAnnouncements')
$form->addElement('radio', 'announcements_state', null, get_lang('Public'), TOOL_PUBLIC);
$form->addElement('radio', 'announcements_state', null, get_lang('Private'), TOOL_PRIVATE);
//Forum settings
// Forum settings
$form->addElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE);
$form->addElement('radio', 'forum_state', null, get_lang('Public'), TOOL_PUBLIC);
$form->addElement('radio', 'forum_state', null, get_lang('Private'), TOOL_PRIVATE);
@ -196,54 +157,48 @@ $form->addElement('radio', 'chat_state', null, get_lang('Private'), TOOL_PRIVATE
// Submit
$form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'class="save"');
// If form validates -> save data
if ($form->validate())
{
if ($form->validate()) {
$values = $form->exportValues();
if ($values['max_member_no_limit'] == MEMBER_PER_GROUP_NO_LIMIT)
{
if ($values['max_member_no_limit'] == MEMBER_PER_GROUP_NO_LIMIT) {
$max_member = MEMBER_PER_GROUP_NO_LIMIT;
}
else
{
} else {
$max_member = $values['max_member'];
}
$self_reg_allowed = isset ($values['self_reg_allowed']) ? $values['self_reg_allowed'] : 0;
$self_unreg_allowed = isset ($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
switch ($values['action'])
{
case 'update_settings' :
$self_reg_allowed = isset($values['self_reg_allowed']) ? $values['self_reg_allowed'] : 0;
$self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
switch ($values['action']) {
case 'update_settings':
GroupManager :: update_category($values['id'], $values['title'], $values['description'], $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_reg_allowed, $self_unreg_allowed, $max_member, $values['groups_per_user']);
$msg = urlencode(get_lang("GroupPropertiesModified"));
$msg = urlencode(get_lang('GroupPropertiesModified'));
header('Location: group.php?action=show_msg&msg='.$msg.'&category='.$values['id']);
break;
case 'add_category' :
case 'add_category':
GroupManager :: create_category($values['title'], $values['description'], $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_reg_allowed, $self_unreg_allowed, $max_member, $values['groups_per_user']);
$msg = urlencode(get_lang("CategoryCreated"));
$msg = urlencode(get_lang('CategoryCreated'));
header('Location: group.php?action=show_msg&msg='.$msg);
break;
}
}
// Else display the form
Display :: display_header($nameTools, "Group");
Display :: display_header($nameTools, 'Group');
// actions bar
echo '<div class="actions">';
echo '<a href="group.php">'.Display::return_icon('back.png',get_lang('BackTo').' '.api_strtolower(get_lang('GroupOverview'))).' '.get_lang('BackTo').' '.api_strtolower(get_lang('GroupOverview')).'</a>';
echo '<a href="group.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.api_strtolower(get_lang('GroupOverview'))).' '.get_lang('BackTo').' '.api_strtolower(get_lang('GroupOverview')).'</a>';
echo '</div>';
$defaults = $category;
$defaults['action'] = $action;
if( $defaults['max_student'] == MEMBER_PER_GROUP_NO_LIMIT)
{
if ($defaults['max_student'] == MEMBER_PER_GROUP_NO_LIMIT) {
$defaults['max_member_no_limit'] = MEMBER_PER_GROUP_NO_LIMIT;
}
else
{
} else {
$defaults['max_member_no_limit'] = 1;
$defaults['max_member'] = $defaults['max_student'];
}
$form->setDefaults($defaults);
$form->display();
Display :: display_footer();
?>

@ -1,140 +1,91 @@
<?php
/*
===============================================================================
Dokeos - elearning and course management software
/* For licensing terms, see /license.txt */
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Hugues Peeters
Copyright (c) Thomas Depraetere
Copyright (c) Christophe Gesche
Copyright (c) Roan Embrechts
Copyright (c) Bart Mollet
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
/**
* @package chamilo.group
*/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
/* INIT SETTINGS */
See the GNU General Public License for more details.
// Name of the language file that needs to be included
$language_file = 'group';
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
===============================================================================
*/
/**
==============================================================================
* @package dokeos.group
==============================================================================
*/
/*
===============================================================================
DOKEOS INIT SETTINGS
===============================================================================
*/
// name of the language file that needs to be included
$language_file = "group";
require_once ('../inc/global.inc.php');
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'classmanager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
/*
--------------------------------------
Create the groups
--------------------------------------
*/
if (isset ($_POST['action']))
{
switch ($_POST['action'])
{
case 'create_groups' :
$groups = array ();
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
/* Create the groups */
for ($i = 0; $i < $_POST['number_of_groups']; $i ++)
{
$group1['name'] = api_strlen($_POST['group_'.$i.'_name']) == 0 ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name'] ;
$group1['category'] = isset($_POST['group_'.$i.'_category'])?$_POST['group_'.$i.'_category']:null;
$group1['tutor'] = isset($_POST['group_'.$i.'_tutor'])?$_POST['group_'.$i.'_tutor']:null;
$group1['places'] = isset($_POST['group_'.$i.'_places'])?$_POST['group_'.$i.'_places']:null;
if (isset ($_POST['action'])) {
switch ($_POST['action']) {
case 'create_groups':
$groups = array();
for ($i = 0; $i < $_POST['number_of_groups']; $i ++) {
$group1['name'] = empty($_POST['group_'.$i.'_name']) ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name'];
$group1['category'] = isset($_POST['group_'.$i.'_category']) ? $_POST['group_'.$i.'_category'] : null;
$group1['tutor'] = isset($_POST['group_'.$i.'_tutor']) ? $_POST['group_'.$i.'_tutor'] : null;
$group1['places'] = isset($_POST['group_'.$i.'_places']) ? $_POST['group_'.$i.'_places'] : null;
$groups[] = $group1;
}
foreach ($groups as $index => $group)
{
if (!empty($_POST['same_tutor']))
{
foreach ($groups as $index => $group) {
if (!empty($_POST['same_tutor'])) {
$group['tutor'] = $_POST['group_0_tutor'];
}
if (!empty($_POST['same_places']))
{
if (!empty($_POST['same_places'])) {
$group['places'] = $_POST['group_0_places'];
}
if (api_get_setting('allow_group_categories') == 'false')
{
if (api_get_setting('allow_group_categories') == 'false') {
$group['category'] = DEFAULT_GROUP_CATEGORY;
}
elseif ($_POST['same_category'])
{
} elseif ($_POST['same_category']) {
$group['category'] = $_POST['group_0_category'];
}
GroupManager :: create_group(strip_tags($group['name']),$group['category'],$group['tutor'] , $group['places']);
GroupManager :: create_group(strip_tags($group['name']), $group['category'], $group['tutor'], $group['places']);
}
$msg = urlencode(count($groups).' '.get_lang('GroupsAdded'));
header('Location: group.php?action=show_msg&msg='.$msg);
break;
case 'create_virtual_groups' :
case 'create_virtual_groups':
$ids = GroupManager :: create_groups_from_virtual_courses();
$msg = urlencode(count($ids).' '.get_lang('GroupsAdded'));
header('Location: group.php?action=show_msg&msg='.$msg);
break;
case 'create_subgroups' :
case 'create_subgroups':
GroupManager :: create_subgroups($_POST['base_group'], $_POST['number_of_groups']);
$msg = urlencode($_POST['number_of_groups'].' '.get_lang('GroupsAdded'));
header('Location: group.php?action=show_msg&msg='.$msg);
break;
case 'create_class_groups' :
case 'create_class_groups':
$ids = GroupManager :: create_class_groups($_POST['group_category']);
$msg = urlencode(count($ids).' '.get_lang('GroupsAdded'));
header('Location: group.php?action=show_msg&msg='.$msg);
break;
}
}
$nameTools = get_lang('GroupCreation');
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('Groups'));
Display :: display_header($nameTools, "Group");
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
Display :: display_header($nameTools, 'Group');
if (!api_is_allowed_to_edit(false,true))
{
if (!api_is_allowed_to_edit(false, true)) {
api_not_allowed();
}
/*
===============================================================================
MAIN TOOL CODE
===============================================================================
*/
/*
--------------------------------------
Show group-settings-form
--------------------------------------
*/
elseif (isset ($_POST['number_of_groups']))
{
if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1)
{
Display :: display_error_message(get_lang('PleaseEnterValidNumber').'<br/><br/><a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>',false);
}
else
{
$number_of_groups = intval($_POST['number_of_groups']);
if ($number_of_groups > 1)
{
/* MAIN TOOL CODE */
/* Show group-settings-form */
elseif (isset($_POST['number_of_groups'])) {
if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) {
Display :: display_error_message(get_lang('PleaseEnterValidNumber').'<br /><br /><a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>', false);
} else {
$number_of_groups = intval($_POST['number_of_groups']);
if ($number_of_groups > 1) {
?>
<script type="text/javascript">
<!--
@ -176,35 +127,30 @@ elseif (isset ($_POST['number_of_groups']))
}
-->
</script>
<?php
}
$group_categories = GroupManager :: get_categories();
$group_id = GroupManager :: get_number_of_groups() + 1;
/*$tutors = GroupManager :: get_all_tutors();
$tutor_options[0] = get_lang('GroupNoTutor');
foreach ($tutors as $index => $tutor)
{
$tutor_options[$tutor['user_id']] = api_get_person_name($tutor['firstname'], $tutor['lastname']);
}
$cat_options = array ();
*/
foreach ($group_categories as $index => $category)
{
// Don't allow new groups in the virtual course category!
if ($category['id'] != VIRTUAL_COURSE_CATEGORY)
{
$cat_options[$category['id']] = $category['title'];
<?php
}
}
$form = new FormValidator('create_groups_step2');
$group_categories = GroupManager :: get_categories();
$group_id = GroupManager :: get_number_of_groups() + 1;
/*$tutors = GroupManager :: get_all_tutors();
$tutor_options[0] = get_lang('GroupNoTutor');
foreach ($tutors as $index => $tutor) {
$tutor_options[$tutor['user_id']] = api_get_person_name($tutor['firstname'], $tutor['lastname']);
}
$cat_options = array ();
*/
foreach ($group_categories as $index => $category) {
// Don't allow new groups in the virtual course category!
if ($category['id'] != VIRTUAL_COURSE_CATEGORY) {
$cat_options[$category['id']] = $category['title'];
}
}
$form = new FormValidator('create_groups_step2');
// Modify the default templates
$renderer = & $form->defaultRenderer();
$form_template = "<form {attributes}>\n<div>\n<table>\n{content}\n</table>\n</div>\n</form>";
$renderer->setFormTemplate($form_template);
$element_template = <<<EOT
// Modify the default templates
$renderer = & $form->defaultRenderer();
$form_template = "<form {attributes}>\n<div>\n<table>\n{content}\n</table>\n</div>\n</form>";
$renderer->setFormTemplate($form_template);
$element_template = <<<EOT
<tr>
<td>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
@ -215,170 +161,147 @@ elseif (isset ($_POST['number_of_groups']))
</tr>
EOT;
$renderer->setElementTemplate($element_template);
$form->addElement('header', '', $nameTools);
$renderer->setElementTemplate($element_template);
$form->addElement('header', '', $nameTools);
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'number_of_groups');
$defaults = array ();
// Table heading
$group_el = array ();
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
if (api_get_setting('allow_group_categories') == 'true')
{
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
}
//$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupTutor').'</b>');
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
$form->addGroup($group_el, 'groups', null, "\n</td>\n<td>\n", false);
// Checkboxes
if ($_POST['number_of_groups'] > 1)
{
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'number_of_groups');
$defaults = array ();
// Table heading
$group_el = array ();
$group_el[] = & $form->createElement('static', null, null, ' ');
if (api_get_setting('allow_group_categories') == 'true')
{
$group_el[] = & $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('category')"));
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
if (api_get_setting('allow_group_categories') == 'true') {
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
}
//$group_el[] = & $form->createElement('checkbox', 'same_tutor', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('tutor')"));
$group_el[] = & $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('places')"));
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
}
// Properties for all groups
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++)
{
$group_el = array ();
$group_el[] = & $form->createElement('text', 'group_'.$group_number.'_name');
if (api_get_setting('allow_group_categories') == 'true')
{
$group_el[] = & $form->createElement('select', 'group_'.$group_number.'_category', null, $cat_options, array ('id' => 'category_'.$group_number));
}
//$group_el[] = & $form->createElement('select', 'group_'.$group_number.'_tutor', null, $tutor_options, array ('id' => 'tutor_'.$group_number));
$group_el[] = & $form->createElement('text', 'group_'.$group_number.'_places', null, array ('size' => 3, 'id' => 'places_'.$group_number));
if($_POST['number_of_groups']<10000)
{
if ($group_id<10)
{
$prev='000';
}
elseif ($group_id<100)
{
$prev='00';
//$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupTutor').'</b>');
$group_el[] = & $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
$form->addGroup($group_el, 'groups', null, "\n</td>\n<td>\n", false);
// Checkboxes
if ($_POST['number_of_groups'] > 1) {
$group_el = array ();
$group_el[] = & $form->createElement('static', null, null, ' ');
if (api_get_setting('allow_group_categories') == 'true') {
$group_el[] = & $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
}
elseif ($group_id<1000)
{
$prev='0';
//$group_el[] = & $form->createElement('checkbox', 'same_tutor', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('tutor');"));
$group_el[] = & $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
}
// Properties for all groups
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
$group_el = array ();
$group_el[] = & $form->createElement('text', 'group_'.$group_number.'_name');
if (api_get_setting('allow_group_categories') == 'true') {
$group_el[] = & $form->createElement('select', 'group_'.$group_number.'_category', null, $cat_options, array('id' => 'category_'.$group_number));
}
else
{
$prev='';
//$group_el[] = & $form->createElement('select', 'group_'.$group_number.'_tutor', null, $tutor_options, array('id' => 'tutor_'.$group_number));
$group_el[] = & $form->createElement('text', 'group_'.$group_number.'_places', null, array('size' => 3, 'id' => 'places_'.$group_number));
if ($_POST['number_of_groups'] < 10000) {
if ($group_id < 10) {
$prev = '000';
} elseif ($group_id < 100) {
$prev = '00';
} elseif ($group_id<1000) {
$prev = '0';
} else {
$prev = '';
}
}
}
$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
}
$defaults['action'] = 'create_groups';
$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
$form->setDefaults($defaults);
$form->addElement('style_submit_button', 'submit', get_lang('CreateGroup'), 'class="save"');
$form->display();
$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
}
$defaults['action'] = 'create_groups';
$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
$form->setDefaults($defaults);
$form->addElement('style_submit_button', 'submit', get_lang('CreateGroup'), 'class="save"');
$form->display();
}
}
else
{
} else {
/*
* Show form to generate new groups
*/
$categories = GroupManager :: get_categories();
//echo '<blockquote>';
if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != VIRTUAL_COURSE_CATEGORY)
{
if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != VIRTUAL_COURSE_CATEGORY) {
$create_groups_form = new FormValidator('create_groups');
$create_groups_form->addElement('header', '', $nameTools);
$group_el = array ();
$group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('Create'));
$group_el[] = & $create_groups_form->createElement('text', 'number_of_groups', null, array ('size' => 3));
$group_el[] = & $create_groups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
$group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('NewGroups'));
$group_el[] = & $create_groups_form->createElement('style_submit_button', 'submit', get_lang('ProceedToCreateGroup'), 'class="save"');
$create_groups_form->addGroup($group_el, 'create_groups', null, ' ', false);
$defaults = array ();
$defaults = array();
$defaults['number_of_groups'] = 1;
$create_groups_form->setDefaults($defaults);
$create_groups_form->display();
}
else
{
} else {
echo get_lang('NoCategoriesDefined');
}
//echo '</blockquote>';
/*
* Show form to generate groups from virtual courses
*/
$virtual_courses = CourseManager :: get_virtual_courses_linked_to_real_course($_course['sysCode']);
if (count($virtual_courses) > 0)
{
if (count($virtual_courses) > 0) {
echo '<b>'.get_lang('CreateGroupsFromVirtualCourses').'</b>';
echo '<blockquote>';
echo get_lang('CreateGroupsFromVirtualCoursesInfo');
$create_virtual_groups_form = new FormValidator('create_virtual_groups');
$create_virtual_groups_form->addElement('hidden', 'action');
$create_virtual_groups_form->addElement('submit', 'submit', get_lang('Ok'));
$create_virtual_groups_form->setDefaults(array ('action' => 'create_virtual_groups'));
$create_virtual_groups_form->setDefaults(array('action' => 'create_virtual_groups'));
$create_virtual_groups_form->display();
echo '</blockquote>';
}
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0)
{
if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
$base_group_options = array ();
$groups = GroupManager :: get_group_list();
foreach ($groups as $index => $group)
{
foreach ($groups as $index => $group) {
$number_of_students = GroupManager :: number_of_students($group['id']);
if ($number_of_students > 0)
{
if ($number_of_students > 0) {
$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
}
}
if (count($base_group_options) > 0)
{
if (count($base_group_options) > 0) {
echo '<b>'.get_lang('CreateSubgroups').'</b>';
echo '<blockquote>';
echo '<p>'.get_lang('CreateSubgroupsInfo').'</p>';
$create_subgroups_form = new FormValidator('create_subgroups');
$create_subgroups_form->addElement('hidden', 'action');
$group_el = array ();
$group_el = array();
$group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
$group_el[] = & $create_subgroups_form->createElement('text', 'number_of_groups', null, array ('size' => 3));
$group_el[] = & $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
$group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = & $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = & $create_subgroups_form->createElement('submit', 'submit', get_lang('Ok'));
$create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
$defaults = array ();
$defaults = array();
$defaults['action'] = 'create_subgroups';
$create_subgroups_form->setDefaults($defaults);
$create_subgroups_form->display();
echo '</blockquote>';
}
}
/*
* Show form to generate groups from classes subscribed to the course
*/
$classes = ClassManager :: get_classes_in_course($_course['sysCode']);
if (count($classes) > 0)
{
if (count($classes) > 0) {
echo '<b>'.get_lang('GroupsFromClasses').'</b>';
echo '<blockquote>';
echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
echo '<ul>';
foreach ($classes as $index => $class)
{
foreach ($classes as $index => $class) {
$number_of_users = count(ClassManager :: get_users($class['id']));
echo '<li>';
echo $class['name'];
@ -389,22 +312,17 @@ else
$create_class_groups_form = new FormValidator('create_class_groups_form');
$create_class_groups_form->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') == 'true')
{
if (api_get_setting('allow_group_categories') == 'true') {
$group_categories = GroupManager :: get_categories();
$cat_options = array ();
foreach ($group_categories as $index => $category)
{
foreach ($group_categories as $index => $category) {
// Don't allow new groups in the virtual course category!
if ($category['id'] != VIRTUAL_COURSE_CATEGORY)
{
if ($category['id'] != VIRTUAL_COURSE_CATEGORY) {
$cat_options[$category['id']] = $category['title'];
}
}
$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
}
else
{
} else {
$create_class_groups_form->addElement('hidden', 'group_category');
}
$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
@ -415,10 +333,7 @@ else
echo '</blockquote>';
}
}
/*
===============================================================================
DOKEOS FOOTER
===============================================================================
*/
/* FOOTER */
Display :: display_footer();
?>

@ -1,83 +1,48 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
/* For licensing terms, see /license.txt */
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
/**
* This script displays an area where teachers can edit the group properties and member list.
* Groups are also often called "teams" in the Dokeos code.
*
* @author various contributors
* @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
* @package chamilo.group
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
/* INIT SECTION */
See the GNU General Public License for more details.
// Name of the language file that needs to be included
$language_file = 'group';
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This script displays an area where teachers can edit the group properties and member list.
* Groups are also often called "teams" in the Dokeos code.
*
* @author various contributors
* @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
@package dokeos.group
* @todo course admin functionality to create groups based on who is in which course (or class).
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = "group";
include ('../inc/global.inc.php');
require '../inc/global.inc.php';
$this_section = SECTION_COURSES;
/*
-----------------------------------------------------------
Libraries & settings
-----------------------------------------------------------
*/
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
/*
-----------------------------------------------------------
Constants & variables
-----------------------------------------------------------
*/
/* Libraries & settings */
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
/* Constants & variables */
$current_group = GroupManager :: get_group_properties($_SESSION['_gid']);
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
/* Header */
$nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
if (!api_is_allowed_to_edit(false,true)) {
api_not_allowed(true);
}
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
/* FUNCTIONS */
/**
* function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort()
*/
function sort_users($user_a, $user_b) {
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
@ -117,6 +82,7 @@ function check_max_number_of_members($value) {
$max_member = $value['max_member'];
return is_numeric($max_member);
}
/**
* Function to check if the number of selected group members is valid
*/
@ -129,17 +95,15 @@ function check_group_members($value) {
}
return true;
}
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/* MAIN CODE */
// Build form
$form = new FormValidator('group_edit');
$form->addElement('header', '', $nameTools);
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'referer');
// Group name
$form->add_textfield('name', get_lang('GroupName'));
@ -160,9 +124,9 @@ $form->addElement('textarea', 'description', get_lang('Description'), array ('co
// Members per group
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), MEMBER_PER_GROUP_NO_LIMIT);
$group = array ();
$group = array();
$group[] = & $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1);
$group[] = & $form->createElement('text', 'max_member', null, array ('size' => 2));
$group[] = & $form->createElement('text', 'max_member', null, array('size' => 2));
$group[] = & $form->createElement('static', null, null, get_lang('GroupPlacesThis'));
$form->addGroup($group, 'max_member_group', null, '', false);
$form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members');
@ -206,27 +170,25 @@ $form->addElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailabl
$form->addElement('radio', 'chat_state', null, get_lang('Public'), TOOL_PUBLIC);
$form->addElement('radio', 'chat_state', null, get_lang('Private'), TOOL_PRIVATE);
// getting all the users
// Getting all the users
if (isset($_SESSION['id_session'])) {
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'],true,$_SESSION['id_session']);
$complete_user_list2 = CourseManager :: get_coach_list_from_course_code($_course['id'],$_SESSION['id_session']);
$complete_user_list = array_merge($complete_user_list,$complete_user_list2);
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], true, $_SESSION['id_session']);
$complete_user_list2 = CourseManager :: get_coach_list_from_course_code($_course['id'], $_SESSION['id_session']);
$complete_user_list = array_merge($complete_user_list, $complete_user_list2);
} else {
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id']);
}
usort($complete_user_list, 'sort_users');
$possible_users = array ();
$possible_users = array();
foreach ($complete_user_list as $index => $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
}
//print_r($complete_user_list2);
// Group tutors
$group_tutor_list = GroupManager :: get_subscribed_tutors($current_group['id']);
$selected_users = array ();
$selected_users = array();
$selected_tutors = array();
foreach ($group_tutor_list as $index => $user) {
//$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], .$user['lastname']);
@ -247,8 +209,8 @@ $group_tutors_element->setElementTemplate('
</table>
');
$group_tutors_element->setButtonAttributes('add',array('class'=>'arrowr'));
$group_tutors_element->setButtonAttributes('remove',array('class'=>'arrowl'));
$group_tutors_element->setButtonAttributes('add', array('class' => 'arrowr'));
$group_tutors_element->setButtonAttributes('remove', array('class' => 'arrowl'));
// Group members
$group_member_list = GroupManager :: get_subscribed_users($current_group['id']);
@ -272,8 +234,8 @@ $group_members_element->setElementTemplate('
</table>
');
$group_members_element->setButtonAttributes('add',array('class'=>'arrowr'));
$group_members_element->setButtonAttributes('remove',array('class'=>'arrowl'));
$group_members_element->setButtonAttributes('add', array('class' => 'arrowr'));
$group_members_element->setButtonAttributes('remove', array('class' => 'arrowl'));
$form->addFormRule('check_group_members');
// submit button
@ -286,31 +248,31 @@ if ($form->validate()) {
} else {
$max_member = $values['max_member'];
}
$self_registration_allowed = isset ($values['self_registration_allowed']) ? 1 : 0;
$self_unregistration_allowed = isset ($values['self_unregistration_allowed']) ? 1 : 0;
GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'],$values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed);
$self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
$self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed);
// storing the tutors (we first remove all the tutors and then add only those who were selected)
// Storing the tutors (we first remove all the tutors and then add only those who were selected)
GroupManager :: unsubscribe_all_tutors($current_group['id']);
if (isset ($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) {
GroupManager :: subscribe_tutors($values['group_tutors'], $current_group['id']);
}
// storing the users (we first remove all users and then add only those who were selected)
// Storing the users (we first remove all users and then add only those who were selected)
GroupManager :: unsubscribe_all_users($current_group['id']);
if (isset ($_POST['group_members']) && count($_POST['group_members']) > 0) {
GroupManager :: subscribe_users($values['group_members'], $current_group['id']);
}
// returning to the group area (note: this is inconsistent with the rest of dokeos)
// Returning to the group area (note: this is inconsistent with the rest of chamilo)
$cat = GroupManager :: get_category_from_group($current_group['id']);
header('Location: '.$values['referer'].'?action=show_msg&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']);
}
$defaults = $current_group;
$defaults['group_members'] = $selected_users;
$defaults['group_tutors'] = $selected_tutors;
isset($_GET['action'])?$action=$_GET['action']:$action='';
$action = isset($_GET['action']) ? $_GET['action'] : '';
$defaults['action'] = $action;
if ($defaults['maximum_number_of_students'] == MEMBER_PER_GROUP_NO_LIMIT) {
$defaults['max_member_no_limit'] = MEMBER_PER_GROUP_NO_LIMIT;
@ -324,17 +286,18 @@ if ($referer != 'group_space.php' && $referer != 'group.php') {
$referer = 'group.php';
}
if (isset($_POST['group_members'])) {
if (count($_POST['group_members'])<=$defaults['max_member']) {
if (count($_POST['group_members']) <= $defaults['max_member']) {
//
} else {
header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers'));
header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers'));
}
}
Display :: display_header($nameTools, "Group");
Display :: display_header($nameTools, 'Group');
?>
<div class="actions">
<a href="group_space.php"><?php echo Display::return_icon('back.png',get_lang('ReturnTo').' '.get_lang('GroupSpace')).get_lang('ReturnTo').' '.get_lang('GroupSpace') ?></a>
<a href="group_space.php"><?php echo Display::return_icon('back.png', get_lang('ReturnTo').' '.get_lang('GroupSpace')).get_lang('ReturnTo').' '.get_lang('GroupSpace') ?></a>
</div>
<?php
@ -345,10 +308,7 @@ if (isset($_GET['show_message'])) {
$defaults['referer'] = $referer;
$form->setDefaults($defaults);
$form->display();
/*
==============================================================================
FOOTER
==============================================================================
*/
/* FOOTER */
Display :: display_footer();
?>

@ -1,76 +1,43 @@
<?php // $Id: group_overview.php 22201 2009-07-17 19:57:03Z cfasanando $
<?php
/* For licensing terms, see /license.txt */
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
/**
* Main page for the group module.
* This script displays the general group settings,
* and a list of groups with buttons to view, edit...
*
* @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
* @author Bert Vanderkimpen, improved self-unsubscribe for cvs
* @author Patrick Cool, show group comment under the group name
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @package dokeos.group
*/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
/* INIT SECTION */
See the GNU General Public License for more details.
// Name of the language file that needs to be included
$language_file = 'group';
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
require '../inc/global.inc.php';
$this_section = SECTION_COURSES;
/**
==============================================================================
* Main page for the group module.
* This script displays the general group settings,
* and a list of groups with buttons to view, edit...
*
* @author Thomas Depraetere, Hugues Peeters, Christophe Gesche: initial versions
* @author Bert Vanderkimpen, improved self-unsubscribe for cvs
* @author Patrick Cool, show group comment under the group name
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @package dokeos.group
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = "group";
include ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
$nameTools = get_lang('GroupOverview');
$nameTools = get_lang("GroupOverview");
/* Libraries */
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
include_once (api_get_path(LIBRARY_PATH).'course.lib.php'); //necessary
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
include_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
include_once api_get_path(LIBRARY_PATH).'course.lib.php';
include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
if( isset($_GET['action']))
{
switch($_GET['action'])
{
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'export':
$groups = GroupManager::get_group_list();
$data = array();
foreach($groups as $index => $group)
{
foreach ($groups as $index => $group) {
$users = GroupManager::get_users($group['id']);
foreach($users as $index => $user)
{
foreach ($users as $index => $user) {
$row = array();
$user = api_get_user_info($user);
$row[] = $group['name'];
@ -80,7 +47,7 @@ if( isset($_GET['action']))
$data[] = $row;
}
}
switch($_GET['type']) {
switch ($_GET['type']) {
case 'csv':
Export::export_table_csv($data);
exit;
@ -92,24 +59,24 @@ if( isset($_GET['action']))
}
}
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "group.php","name" => get_lang('Groups'));
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
{ //so we are not in learnpath tool
if (! $is_allowed_in_course) api_not_allowed(true);
if (!api_is_allowed_to_edit(false,true)) api_not_allowed(true);
else Display::display_header($nameTools,"Group");
}
else
{
?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css" /> <?php
/* Header */
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
// So we are not in learnpath tool
if (!$is_allowed_in_course) {
api_not_allowed(true);
}
if (!api_is_allowed_to_edit(false, true)) {
api_not_allowed(true);
} else {
Display::display_header($nameTools, 'Group');
}
} else {
?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>default.css" /> <?php
}
// action links
// Action links
echo '<div class="actions">';
echo Display::return_icon('groupadd.gif', get_lang('NewGroupCreate')) . '<a href="group_creation.php?'.api_get_cidreq().'">'.get_lang('NewGroupCreate').'</a>';
echo Display::return_icon('group.gif', get_lang('Groups')) .'<a href="group.php?'.api_get_cidreq().'">'.get_lang('Groups').'</a>';
@ -124,22 +91,18 @@ echo Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' <a href="group
echo '</div>';
$categories = GroupManager::get_categories();
foreach($categories as $index => $category)
{
if( api_get_setting('allow_group_categories') == 'true')
{
foreach ($categories as $index => $category) {
if (api_get_setting('allow_group_categories') == 'true') {
echo '<h3>'.$category['title'].'</h3>';
}
$groups = GroupManager::get_group_list($category['id']);
echo '<ul>';
foreach($groups as $index => $group)
{
foreach ($groups as $index => $group) {
echo '<li>';
echo stripslashes($group['name']);
echo '<ul>';
$users = GroupManager::get_users($group['id']);
foreach($users as $index => $user)
{
foreach ($users as $index => $user) {
$user_info = api_get_user_info($user);
echo '<li>'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</li>';
}
@ -148,13 +111,9 @@ foreach($categories as $index => $category)
}
echo '</ul>';
}
/*
==============================================================================
FOOTER
==============================================================================
*/
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath')
{
/* FOOTER */
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
Display::display_footer();
}
?>

@ -1,109 +1,68 @@
<?php //$Id: group_space.php 21933 2009-07-09 06:08:22Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
Copyright (c) Bart Mollet
<?php
/* For licensing terms, see /license.txt */
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
/**
* This script shows the group space for one specific group, possibly displaying
* a list of users in the group, subscribe or unsubscribe option, tutors...
*
* @package chamilo.group
* @todo Display error message if no group ID specified
*/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
/* INIT SECTION */
See the GNU General Public License for more details.
// Name of the language file that needs to be included
$language_file = 'group';
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This script shows the group space for one specific group, possibly displaying
* a list of users in the group, subscribe or unsubscribe option, tutors...
*
* @package dokeos.group
* @todo Display error message if no group ID specified
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = "group";
require_once '../inc/global.inc.php';
/*
-----------------------------------------------------------
Libraries & config files
-----------------------------------------------------------
*/
/* Libraries & config files */
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/* MAIN CODE */
$current_group = GroupManager :: get_group_properties($_SESSION['_gid']);
if (!is_array($current_group) ) {
//display some error message
//display some error message
}
$this_section=SECTION_COURSES;
$nameTools = get_lang("GroupSpace");
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang("Groups"));
$this_section = SECTION_COURSES;
$nameTools = get_lang('GroupSpace');
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
/*
-----------------------------------------------------------
Ensure all private groups // Juan Carlos Ra<EFBFBD>a Trabado
-----------------------------------------------------------
*/
/* Ensure all private groups // Juan Carlos Raña Trabado */
$forums_of_groups = get_forums_of_group($current_group['id']);
$forum_state_public=0;
$forum_state_public = 0;
if (is_array($forums_of_groups)) {
foreach ($forums_of_groups as $key => $value) {
if($value['forum_group_public_private'] == 'public') {
$forum_state_public=1;
$forum_state_public = 1;
}
}
}
if ($current_group['doc_state']!=1 and $current_group['calendar_state']!=1 and $current_group['work_state']!=1 and $current_group['announcements_state']!=1 and $current_group['wiki_state']!=1 and $current_group['chat_state']!=1 and $forum_state_public!=1) {
if (!api_is_allowed_to_edit(null,true) and !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) {
if ($current_group['doc_state'] != 1 && $current_group['calendar_state'] != 1 && $current_group['work_state'] != 1 && $current_group['announcements_state'] != 1 && $current_group['wiki_state'] != 1 && $current_group['chat_state'] != 1 && $forum_state_public != 1) {
if (!api_is_allowed_to_edit(null,true) && !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) {
echo api_not_allowed($print_headers);
}
}
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
Display::display_header($nameTools.' '.stripslashes($current_group['name']),"Group");
/*
-----------------------------------------------------------
Introduction section
(editable by course admin)
-----------------------------------------------------------
*/
/* Header */
Display::display_header($nameTools.' '.stripslashes($current_group['name']), 'Group');
/* Introduction section (editable by course admin) */
Display::display_introduction_section(group_space_.$_SESSION['_gid']);
/*
-----------------------------------------------------------
Actions and Action links
-----------------------------------------------------------
*/
/* Actions and Action links */
/*
* User wants to register in this group
*/
@ -124,38 +83,36 @@ echo '<a href="group.php">'.Display::return_icon('back.png',get_lang('BackToGrou
/*
* Edit the group
*/
if (api_is_allowed_to_edit(false,true) or GroupManager :: is_tutor($_user['user_id'])) {
isset($origin)?$my_origin = $origin:$my_origin='';
echo Display::return_icon('edit.gif', get_lang("EditGroup"))."<a href=\"group_edit.php?origin=$my_origin\">".get_lang("EditGroup")."</a>";
if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor($_user['user_id'])) {
$my_origin = isset($origin) ? $origin : '';
echo Display::return_icon('edit.gif', get_lang('EditGroup')).'<a href="group_edit.php?origin=$my_origin">'.get_lang('EditGroup').'</a>';
}
/*
* Register to group
*/
if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) {
echo '<a href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('groupadd.gif').get_lang("RegIntoGroup").'</a>';
echo '<a href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.Display::return_icon('groupadd.gif').get_lang("RegIntoGroup").'</a>';
}
/*
* Unregister from group
*/
if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) {
echo '<a href="'.api_get_self().'?selfUnReg=1" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('group_delete.gif').get_lang("StudentUnsubscribe").'</a>';
echo '<a href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.Display::return_icon('group_delete.gif').get_lang("StudentUnsubscribe").'</a>';
}
echo '&nbsp;</div>';
if( isset($_GET['action'])) {
switch( $_GET['action']) {
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'show_msg':
Display::display_normal_message(Security::remove_XSS($_GET['msg']));
break;
}
}
/*
-----------------------------------------------------------
Main Display Area
-----------------------------------------------------------
*/
/* Main Display Area */
$course_code = $_course['sysCode'];
$is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course($_SESSION['_user']['user_id'], $course_code);
@ -167,174 +124,143 @@ $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course
if (!empty($current_group['description'])) {
echo '<blockquote>'.stripslashes($current_group['description']).'</blockquote>';
}
/*
* Group Tools
*/
// If the user is subscribed to the group or the user is a tutor of the group then
if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id'])) {
if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id'])) {
$tools = '';
// link to the forum of this group
// Link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups)) {
if ( $current_group['forum_state'] != TOOL_NOT_AVAILABLE ) {
if ($current_group['forum_state'] != TOOL_NOT_AVAILABLE ) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false,true)) {
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'">'.get_lang("Forum").': '.$value['forum_title'].'</a><br />';
//$tools.= Display::return_icon('forum.gif', get_lang("Forum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.get_lang("Forum").': '.$value['forum_title'].'</a><br />';
}
if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false, true)) {
$tools .= Display::return_icon('forum.gif', get_lang('GroupForum')) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'">'.get_lang('Forum').': '.$value['forum_title'].'</a><br />';
//$tools .= Display::return_icon('forum.gif', get_lang('Forum')) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.get_lang('Forum').': '.$value['forum_title'].'</a><br />';
}
}
}
}
if( $current_group['doc_state'] != TOOL_NOT_AVAILABLE )
{
// link to the documents area of this group
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../document/document.php?".api_get_cidreq()."&amp;gidReq=".$current_group['id']."\">".Display::return_icon('folder_document.gif', get_lang("GroupDocument"))."&nbsp;".get_lang("GroupDocument")."</a></div>";
if ($current_group['doc_state'] != TOOL_NOT_AVAILABLE ) {
// Link to the documents area of this group
$tools .= '<div style="margin-bottom: 5px;"><a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'">'.Display::return_icon('folder_document.gif', get_lang('GroupDocument')).'&nbsp;'.get_lang('GroupDocument').'</a></div>';
}
if ( $current_group['calendar_state'] != TOOL_NOT_AVAILABLE)
{
//link to a group-specific part of agenda
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../calendar/agenda.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."&amp;acces=0\">".Display::return_icon('agenda.gif', get_lang("GroupCalendar"))."&nbsp;".get_lang("GroupCalendar")."</a></div>";
if ($current_group['calendar_state'] != TOOL_NOT_AVAILABLE) {
// Link to a group-specific part of agenda
$tools .= '<div style="margin-bottom: 5px;"><a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'&amp;acces=0">'.Display::return_icon('agenda.gif', get_lang('GroupCalendar')).'&nbsp;'.get_lang('GroupCalendar').'</a></div>';
}
if ( $current_group['work_state'] != TOOL_NOT_AVAILABLE)
{
//link to the works area of this group
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../work/work.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('works.gif', get_lang("GroupWork"))."&nbsp;".get_lang("GroupWork")."</a></div>";
if ($current_group['work_state'] != TOOL_NOT_AVAILABLE) {
// Link to the works area of this group
$tools .= '<div style="margin-bottom: 5px;"><a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('works.gif', get_lang('GroupWork')).'&nbsp;'.get_lang('GroupWork').'</a></div>';
}
if ( $current_group['announcements_state'] != TOOL_NOT_AVAILABLE)
{
//link to a group-specific part of announcements
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../announcements/announcements.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('valves.gif', get_lang("GroupAnnouncements"))."&nbsp;".get_lang("GroupAnnouncements")."</a></div>";
if ($current_group['announcements_state'] != TOOL_NOT_AVAILABLE) {
// Link to a group-specific part of announcements
$tools .= '<div style="margin-bottom: 5px;"><a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('valves.gif', get_lang('GroupAnnouncements')).'&nbsp;'.get_lang('GroupAnnouncements').'</a></div>';
}
if ( $current_group['wiki_state'] != TOOL_NOT_AVAILABLE)
{
//link to the wiki area of this group
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../wiki/index.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('wiki.gif', get_lang("GroupWiki"))."&nbsp;".get_lang("GroupWiki")."</a></div>";
if ($current_group['wiki_state'] != TOOL_NOT_AVAILABLE) {
// Link to the wiki area of this group
$tools .= '<div style="margin-bottom: 5px;"><a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('wiki.gif', get_lang('GroupWiki')).'&nbsp;'.get_lang('GroupWiki').'</a></div>';
}
if ( $current_group['chat_state'] != TOOL_NOT_AVAILABLE)
{
//link to the chat area of this group
if(api_get_course_setting('allow_open_chat_window')==true)
{
$tools .= "<div style='margin-bottom: 5px;'><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.gif', get_lang("Chat"))."&nbsp;".get_lang("Chat")."</a></div>";
}
else
{
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.gif', get_lang("Chat"))."&nbsp;".get_lang("Chat")."</a></div>";
if ($current_group['chat_state'] != TOOL_NOT_AVAILABLE) {
// Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) {
$tools .= "<div style='margin-bottom: 5px;'><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.gif', get_lang('Chat'))."&nbsp;".get_lang('Chat')."</a></div>";
} else {
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.gif', get_lang('Chat'))."&nbsp;".get_lang('Chat')."</a></div>";
}
}
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang("Tools").':</b></div>';
if (!empty($tools))
{
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang('Tools').':</b></div>';
if (!empty($tools)) {
echo '<div style="margin-left:5px;">'.$tools.'</div>';
}
} else {
$tools = '';
// link to the forum of this group
// Link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups)) {
if ( $current_group['forum_state'] == TOOL_PUBLIC ) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' ) {
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'">'.$value['forum_title'].'</a><br />';
//$tools.= Display::return_icon('forum.gif', get_lang("Forum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.get_lang("Forum").': '.$value['forum_title'].'</a><br />';
$tools.= Display::return_icon('forum.gif', get_lang('GroupForum')) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'">'.$value['forum_title'].'</a><br />';
//$tools.= Display::return_icon('forum.gif', get_lang('Forum')) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.get_lang("Forum").': '.$value['forum_title'].'</a><br />';
}
}
}
}
if( $current_group['doc_state'] == TOOL_PUBLIC )
{
// link to the documents area of this group
$tools .= "<a href=\"../document/document.php?".api_get_cidreq()."&amp;gidReq=".$current_group['id']."&amp;origin=$origin\">".Display::return_icon('folder_document.gif', get_lang("GroupDocument"))."&nbsp;".get_lang("GroupDocument")."</a><br/>";
if ($current_group['doc_state'] == TOOL_PUBLIC) {
// Link to the documents area of this group
$tools .= '<a href="../document/document.php?'.api_get_cidreq().'&amp;gidReq='.$current_group['id'].'&amp;origin='.$origin.'">'.Display::return_icon('folder_document.gif', get_lang('GroupDocument')).'&nbsp;'.get_lang('GroupDocument').'</a><br />';
}
if ( $current_group['calendar_state'] == TOOL_PUBLIC )
{
//link to a group-specific part of agenda
$tools .= "<a href=\"../calendar/agenda.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."\">".Display::return_icon('agenda.gif', get_lang("GroupCalendar"))."&nbsp;".get_lang("GroupCalendar")."</a><br/>";
if ($current_group['calendar_state'] == TOOL_PUBLIC) {
// Link to a group-specific part of agenda
$tools .= '<a href="../calendar/agenda.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('agenda.gif', get_lang('GroupCalendar')).'&nbsp;'.get_lang('GroupCalendar').'</a><br />';
}
if ( $current_group['work_state'] == TOOL_PUBLIC )
{
//link to the works area of this group
$tools .= "<a href=\"../work/work.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('works.gif', get_lang("GroupWork"))."&nbsp;".get_lang("GroupWork")."</a><br/>";
if ($current_group['work_state'] == TOOL_PUBLIC) {
// Link to the works area of this group
$tools .= '<a href="../work/work.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('works.gif', get_lang('GroupWork')).'&nbsp;'.get_lang('GroupWork').'</a><br />';
}
if ( $current_group['announcements_state'] == TOOL_PUBLIC)
{
//link to a group-specific part of announcements
$tools .= "<a href=\"../announcements/announcements.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."\">".Display::return_icon('valves.gif', get_lang("GroupAnnouncements"))."&nbsp;".get_lang("GroupAnnouncements")."</a><br/>";
if ($current_group['announcements_state'] == TOOL_PUBLIC) {
// Link to a group-specific part of announcements
$tools .= '<a href="../announcements/announcements.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'&amp;group='.$current_group['id'].'">'.Display::return_icon('valves.gif', get_lang('GroupAnnouncements')).'&nbsp;'.get_lang('GroupAnnouncements').'</a><br />';
}
if ( $current_group['wiki_state'] == TOOL_PUBLIC )
{
//link to the wiki area of this group
$tools .= "<a href=\"../wiki/index.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('wiki.gif', get_lang('GroupWiki'))."&nbsp;".get_lang('GroupWiki')."</a><br/>";
if ($current_group['wiki_state'] == TOOL_PUBLIC) {
// Link to the wiki area of this group
$tools .= '<a href="../wiki/index.php?'.api_get_cidreq().'&amp;toolgroup='.$current_group['id'].'">'.Display::return_icon('wiki.gif', get_lang('GroupWiki')).'&nbsp;'.get_lang('GroupWiki').'</a><br />';
}
if ( $current_group['chat_state'] == TOOL_PUBLIC )
{
//link to the chat area of this group
if(api_get_course_setting('allow_open_chat_window')==true)
{
if ($current_group['chat_state'] == TOOL_PUBLIC ) {
// Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) {
$tools .= "<div style='margin-bottom: 5px;'><a href=\"javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \" >".Display::return_icon('chat.gif', get_lang("Chat"))."&nbsp;".get_lang("Chat")."</a></div>";
}
else
{
} else {
$tools .= "<div style='margin-bottom: 5px;'><a href=\"../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('chat.gif', get_lang("Chat"))."&nbsp;".get_lang("Chat")."</a></div>";
}
}
echo '<br/>';
echo '<br />';
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang("Tools").':</b></div>';
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang('Tools').':</b></div>';
if (!empty($tools)) {
echo '<div style="margin-left:5px;">'.$tools.'</div>';
}
}
/*
* list all the tutors of the current group
* List all the tutors of the current group
*/
$tutors = GroupManager::get_subscribed_tutors($current_group['id']);
$tutor_info = '';
if (count($tutors) == 0)
{
$tutor_info = get_lang("GroupNoneMasc");
}
else
{
if (count($tutors) == 0) {
$tutor_info = get_lang('GroupNoneMasc');
} else {
isset($origin)?$my_origin = $origin:$my_origin='';
foreach($tutors as $index => $tutor)
{
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'],'web',false, true);
foreach($tutors as $index => $tutor) {
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$photo= '<img src="'.$image_repository.$existing_image.'" align="absbottom" alt="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" width="32" height="32" title="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" />';
$tutor_info .= "<div style='margin-bottom: 5px;'><a href='../user/userInfo.php?origin=".$my_origin."&amp;uInfo=".$tutor['user_id']."'>".$photo."&nbsp;".api_get_person_name($tutor['firstname'], $tutor['lastname'])."</a></div>";
$photo= '<img src="'.$image_repository.$existing_image.'" align="absbottom" alt="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" width="32" height="32" title="'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'" />';
$tutor_info .= '<div style="margin-bottom: 5px;"><a href="../user/userInfo.php?origin='.$my_origin.'&amp;uInfo='.$tutor['user_id'].'">'.$photo.'&nbsp;'.api_get_person_name($tutor['firstname'], $tutor['lastname']).'</a></div>';
}
}
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang("GroupTutors").':</b></div>';
echo '<div class="actions-message" style="margin-bottom:4px;"><b>'.get_lang('GroupTutors').':</b></div>';
if (!empty($tutor_info)) {
echo '<div style="margin-left:5px;">'.$tutor_info.'</div>';
}
echo '<br/>';
echo '<br />';
/*
* list all the members of the current group
* List all the members of the current group
*/
echo '<b>'.get_lang("GroupMembers").':</b>';
$table = new SortableTable('group_users', 'get_number_of_group_users', 'get_group_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
$my_cidreq=isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : '';
$my_origin=isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
$my_gidreq=isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : '';
$my_cidreq = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : '';
$my_origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
$my_gidreq = isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : '';
$parameters = array('cidReq' => $my_cidreq, 'origin'=> $my_origin, 'gidReq' => $my_gidreq);
$table->set_additional_parameters($parameters);
$table->set_header(0, '');
@ -346,15 +272,11 @@ if (api_is_western_name_order()) {
$table->set_header(2, get_lang('FirstName'));
}
if (api_get_setting("show_email_addresses") == "true")
{
if (api_get_setting('show_email_addresses') == 'true') {
$table->set_header(3, get_lang('Email'));
$table->set_column_filter(3, 'email_filter');
}
else
{
if (api_is_allowed_to_edit()=="true")
{
} else {
if (api_is_allowed_to_edit() == 'true') {
$table->set_header(3, get_lang('Email'));
$table->set_column_filter(3, 'email_filter');
}
@ -370,14 +292,13 @@ $table->display();
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008
*/
function get_number_of_group_users()
{
function get_number_of_group_users() {
global $current_group;
// Database table definition
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
// query
// Query
$sql = "SELECT count(id) AS number_of_users
FROM ".$table_group_user."
WHERE group_id='".Database::escape_string($current_group['id'])."'";
@ -398,18 +319,15 @@ function get_number_of_group_users()
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008
*/
function get_group_user_data($from, $number_of_items, $column, $direction)
{
function get_group_user_data($from, $number_of_items, $column, $direction) {
global $current_group;
// Database table definition
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// query
if (api_get_setting("show_email_addresses") == "true") {
// Query
if (api_get_setting('show_email_addresses') == 'true') {
$sql = "SELECT
user.user_id AS col0,
".(api_is_western_name_order() ?
@ -425,11 +343,8 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
}
else
{
if (api_is_allowed_to_edit()=="true")
{
} else {
if (api_is_allowed_to_edit()) {
$sql = "SELECT
user.user_id AS col0,
".(api_is_western_name_order() ?
@ -445,9 +360,7 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
}
else
{
} else {
$sql = "SELECT
user.user_id AS col0,
". (api_is_western_name_order() ?
@ -465,10 +378,9 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
}
}
$return = array ();
$return = array();
$result = Database::query($sql);
while ($row = Database::fetch_row($result))
{
while ($row = Database::fetch_row($result)) {
$return[] = $row;
}
return $return;
@ -479,8 +391,7 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
* @param string $email An email-address
* @return string HTML-code with a mailto-link
*/
function email_filter($email)
{
function email_filter($email) {
return Display :: encrypted_mailto_link($email, $email);
}
@ -493,22 +404,18 @@ function email_filter($email)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008
*/
function user_icon_filter($user_id)
{
function user_icon_filter($user_id) {
global $origin;
$userinfo=Database::get_user_info_from_id($user_id);
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
$userinfo = Database::get_user_info_from_id($user_id);
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$photo= '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" width="22" height="22" title="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" /></center>';
return "<a href='../user/userInfo.php?origin=".$origin."&amp;uInfo=".$user_id."'>".$photo;
$photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" width="22" height="22" title="'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'" /></center>';
return '<a href="../user/userInfo.php?origin='.$origin.'&amp;uInfo='.$user_id.'">'.$photo;
}
// footer
isset($origin)?$orig=$origin:$orig='';
if ($orig != 'learnpath')
{
// Footer
$orig = isset($origin) ? $origin : '';
if ($orig != 'learnpath') {
Display::display_footer();
}
?>

Loading…
Cancel
Save