[svn r16248] improve group tool handling with sessions FS#2743

skala
Eric Marguin 16 years ago
parent 03c9a59505
commit 1b7d05da08
  1. 4
      main/announcements/announcements.inc.php
  2. 15
      main/calendar/agenda.inc.php
  3. 22
      main/group/group.php
  4. 4
      main/group/group_category.php
  5. 2
      main/group/group_creation.php
  6. 2
      main/group/group_edit.php
  7. 8
      main/group/group_space.php
  8. 2
      main/inc/lib/add_course.lib.inc.php
  9. 5
      main/inc/lib/course.lib.php
  10. 22
      main/inc/lib/groupmanager.lib.php
  11. 2
      main/install/migrate-db-1.8.5-1.8.6-pre.sql

@ -1,4 +1,4 @@
<?php //$Id: announcements.inc.php 16224 2008-09-02 14:16:13Z elixir_inter $
<?php //$Id: announcements.inc.php 16248 2008-09-05 13:30:55Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -286,7 +286,7 @@ function get_course_users()
*/
function get_course_groups()
{
$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id());
$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($_SESSION['id_session']));
return $new_group_list;
}

@ -1,4 +1,4 @@
<?php //$Id: agenda.inc.php 16247 2008-09-05 10:10:13Z elixir_inter $
<?php //$Id: agenda.inc.php 16248 2008-09-05 13:30:55Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -486,20 +486,9 @@ return $users;
*/
function get_course_groups()
{
global $tbl_group;
global $tbl_groupUser;
$group_list = array();
$sql = "SELECT g.id, g.name, COUNT(gu.id) userNb
FROM ".$tbl_group." AS g LEFT JOIN ".$tbl_groupUser." gu
ON g.id = gu.group_id
GROUP BY g.id";
$result = api_sql_query($sql,__FILE__,__LINE__) or die(Database::error());
while ($group_data = Database::fetch_array($result))
{
$group_list [$group_data['id']] = $group_data;
}
$group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($_SESSION['id_session']));
return $group_list;
}

@ -123,7 +123,7 @@ if (isset ($_GET['action']))
/*
* Group-admin functions
*/
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(false,true))
{
// Post-actions
@ -230,7 +230,7 @@ foreach ($group_cats as $index => $category)
}
$group_list = GroupManager :: get_group_list($category['id']);
echo ' ('.count($group_list).' '.get_lang('ExistingGroups').')';
if (api_is_allowed_to_edit())
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(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a> ';
@ -266,13 +266,13 @@ foreach ($group_cats as $index => $category)
// create a new table-row
$row = array ();
// checkbox
if (api_is_allowed_to_edit() && count($group_list) > 1)
if (api_is_allowed_to_edit(false,true) && count($group_list) > 1)
{
$row[] = $this_group['id'];
}
// group name
if (api_is_allowed_to_edit() ||
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_DOCUMENTS) ||
@ -290,6 +290,10 @@ foreach ($group_cats as $index => $category)
{
$group_name .= ' ('.get_lang('MyGroup').')';
}
if(api_is_allowed_to_edit() && !empty($this_group['session_name']))
{
$group_name .= ' ('.$this_group['session_name'].')';
}
$row[] = $group_name.'<br/>'.stripslashes(trim($this_group['description']));
}
else
@ -297,7 +301,7 @@ foreach ($group_cats as $index => $category)
$row[] = $this_group['name'].'<br/>'.stripslashes(trim($this_group['description']));
}
// self-registration / unregistration
if (!api_is_allowed_to_edit())
if (!api_is_allowed_to_edit(false,true))
{
if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id']))
{
@ -329,7 +333,7 @@ foreach ($group_cats as $index => $category)
$tutor_info = substr($tutor_info,0,strlen($tutor_info)-2);
$row[] = $tutor_info;
// edit-links
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(false,true))
{
$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(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a>&nbsp;';
@ -351,19 +355,19 @@ foreach ($group_cats as $index => $category)
$table = new SortableTableFromArray($group_data, 1);
$table->set_additional_parameters(array('category'=>$_GET['category']));
$column = 0;
if (api_is_allowed_to_edit() and count($group_list) > 1)
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()) // If self-registration allowed
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('Max'));
$table->set_header($column++,get_lang('GroupTutor'));
if (api_is_allowed_to_edit()) // only for course administrator
if (api_is_allowed_to_edit(false,true)) // only for course administrator
{
$table->set_header($column++,get_lang('Modify'), false);
$form_actions = array();

@ -1,5 +1,5 @@
<?php
// $Id: group_category.php 16179 2008-08-31 20:20:23Z herodoto $
// $Id: group_category.php 16248 2008-09-05 13:30:55Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -40,7 +40,7 @@ $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() || !(isset ($_GET['id']) || isset ($_POST['id']) || isset ($_GET['action']) || isset ($_POST['action'])))
if (!api_is_allowed_to_edit(false,true) || !(isset ($_GET['id']) || isset ($_POST['id']) || isset ($_GET['action']) || isset ($_POST['action'])))
{
api_not_allowed();
}

@ -107,7 +107,7 @@ $nameTools = get_lang('GroupCreation');
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('GroupManagement'));
Display :: display_header($nameTools, "Group");
api_display_tool_title($nameTools);
if (!is_allowed_to_edit())
if (!api_is_allowed_to_edit(false,true))
{
api_not_allowed();
}

@ -65,7 +65,7 @@ $current_group = GroupManager :: get_group_properties($_SESSION['_gid']);
$nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('GroupManagement'));
if (!api_is_allowed_to_edit())
if (!api_is_allowed_to_edit(false,true))
{
api_not_allowed(true);
}

@ -1,4 +1,4 @@
<?php //$Id: group_space.php 16179 2008-08-31 20:20:23Z herodoto $
<?php //$Id: group_space.php 16248 2008-09-05 13:30:55Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -95,7 +95,7 @@ if ($_GET['selfUnReg'] && GroupManager :: is_self_unregistration_allowed($_SESSI
/*
* Edit the group
*/
if (api_is_allowed_to_edit() or GroupManager :: is_tutor($_user['user_id']))
if (api_is_allowed_to_edit(false,true) or GroupManager :: is_tutor($_user['user_id']))
{
echo "<a href=\"group_edit.php?origin=$origin\">".get_lang("EditGroup")."</a><br/><br/>";
}
@ -153,7 +153,7 @@ if (!empty($current_group['description']))
* 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() 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 = '';
$forums_of_groups = get_forums_of_group($current_group['id']);
@ -161,7 +161,7 @@ if (api_is_allowed_to_edit() OR GroupManager :: is_user_in_group($_SESSION['_use
{
foreach ($forums_of_groups as $key => $value)
{
if($value['forum_group_public_private'] == 'public' || ($user_subscribe_to_current_group && $value['forum_group_public_private'] == 'private') || $user_is_tutor || api_is_allowed_to_edit())
if($value['forum_group_public_private'] == 'public' || ($user_subscribe_to_current_group && $value['forum_group_public_private'] == 'private') || $user_is_tutor || api_is_allowed_to_edit(false,true))
{
$tools.= Display::return_icon('forum.gif') . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
}

@ -881,8 +881,10 @@ function update_Db_course($courseDbName)
secret_directory varchar(255) default NULL,
self_registration_allowed tinyint unsigned NOT NULL default '0',
self_unregistration_allowed tinyint unsigned NOT NULL default '0',
session_id smallint unsigned NOT NULL default 0,
PRIMARY KEY (id)
)", __FILE__, __LINE__);
api_sql_query("ALTER TABLE `".$TABLEGROUPS . "` ADD INDEX ( session_id )", __FILE__,__LINE__);
api_sql_query("CREATE TABLE `".$TABLEGROUPCATEGORIES . "` (
id int unsigned NOT NULL auto_increment,

@ -1331,16 +1331,19 @@ class CourseManager
==============================================================================
*/
function get_group_list_of_course($course_code)
function get_group_list_of_course($course_code, $session_id=0)
{
$course_info = Database :: get_course_info($course_code);
$database_name = $course_info['db_name'];
$group_table = Database :: get_course_table(TABLE_GROUP, $database_name);
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER, $database_name);
$session_condition = $session_id==0 ? '' : ' WHERE g.session_id IN(0,'.intval($session_id).')';
$sql = "SELECT g.id, g.name, COUNT(gu.id) userNb
FROM $group_table AS g LEFT JOIN $group_user_table gu
ON g.id = gu.group_id
$session_condition
GROUP BY g.id
ORDER BY g.name";

@ -109,6 +109,9 @@ class GroupManager
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER, $course_db);
$session_condition = intval($_SESSION['id_session'])==0 ? '' : ' g.session_id IN (0,'.intval($_SESSION['id_session']).') ';
$sql = "SELECT g.id ,
g.name ,
g.description ,
@ -117,6 +120,7 @@ class GroupManager
g.secret_directory,
g.self_registration_allowed,
g.self_unregistration_allowed,
g.session_id,
ug.user_id is_member,
COUNT(ug2.id) number_of_members
FROM ".$table_group." `g`
@ -124,8 +128,14 @@ class GroupManager
ON `ug`.`group_id` = `g`.`id` AND `ug`.`user_id` = '".$_user['user_id']."'
LEFT JOIN ".$table_group_user." `ug2`
ON `ug2`.`group_id` = `g`.`id`";
if ($category != null)
if ($category != null){
$sql .= " WHERE `g`.`category_id` = '".$category."' ";
$sql .= 'AND '.$session_condition;
}
else if(!empty($session_condition))
$sql .= 'WHERE '.$session_condition;
$sql .= " GROUP BY `g`.`id` ORDER BY UPPER(g.name)";
$groupList = api_sql_query($sql,__FILE__,__LINE__);
$groups = array ();
@ -137,6 +147,12 @@ class GroupManager
$obj = mysql_fetch_object(api_sql_query($sql,__FILE__,__LINE__));
$thisGroup['name'] = $obj->title;
}
if($thisGroup['session_id']!=0)
{
$sql_session = 'SELECT name FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$thisGroup['session_id'];
$rs_session = api_sql_query($sql_session,__FILE__,__LINE__);
$thisGroup['session_name'] = Database::result($rs_session,0,0);
}
$groups[] = $thisGroup;
}
return $groups;
@ -160,7 +176,7 @@ class GroupManager
{
$places = $category['max_student'];
}
$sql = "INSERT INTO ".$table_group." SET category_id='".$category_id."', max_student = '".$places."', doc_state = '".$category['doc_state']."', calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."'";
$sql = "INSERT INTO ".$table_group." SET category_id='".$category_id."', max_student = '".$places."', doc_state = '".$category['doc_state']."', calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id=".intval($_SESSION['id_session']);
api_sql_query($sql,__FILE__,__LINE__);
$lastId = mysql_insert_id();
/*$secret_directory = uniqid("")."_team_".$lastId;
@ -1358,7 +1374,7 @@ class GroupManager
{
return true;
}
elseif (api_is_allowed_to_edit())
elseif (api_is_allowed_to_edit(false,true))
{
return true;
}

@ -62,3 +62,5 @@ ALTER TABLE student_publication ADD session_id SMALLINT UNSIGNED NOT NULL defaul
ALTER TABLE student_publication ADD INDEX ( session_id ) ;
ALTER TABLE calendar_event ADD session_id SMALLINT UNSIGNED NOT NULL default 0 ;
ALTER TABLE calendar_event ADD INDEX ( session_id ) ;
ALTER TABLE group_info ADD session_id SMALLINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE group_info ADD INDEX ( session_id ) ;

Loading…
Cancel
Save