[svn r13984]

skala
Olivier Sourie 18 years ago
parent 91b1996ed2
commit ab4e388a40
  1. 46
      main/group/group.php
  2. 39
      main/inc/lib/groupmanager.lib.php

@ -66,8 +66,7 @@ if( api_get_setting('allow_group_categories') == 'false')
$num = mysql_num_rows($res); $num = mysql_num_rows($res);
if($num == 0) if($num == 0)
{ {
api_sql_query("INSERT INTO ".$cat_table." ( id , title , description , forum_state , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) VALUES ('2', '".lang2db($DefaultGroupCategory)."', '', '1', '8', '0', '0', '0', '0');"); api_sql_query("INSERT INTO ".$cat_table." ( id , title , description , forum_state , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) VALUES ('2', '".lang2db($DefaultGroupCategory)."', '', '1', '8', '0', '0', '0', '0');");
} }
} }
@ -179,25 +178,32 @@ if (api_is_allowed_to_edit())
} }
} }
// Show admin-panel // Show admin-panel
echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('group_add_big.gif').'&nbsp;'.get_lang("NewGroupCreate").'</a>&nbsp;'; echo "<div id=\"actions\">\n";
echo "<ul id=\"groupItems\">";
if (get_setting('allow_group_categories') == 'true') if (get_setting('allow_group_categories') == 'true')
{ {
echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.get_lang("AddCategory").'</a>&nbsp;'; echo '<li><a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.get_lang("AddCategory").'</a>&nbsp;</li>';
} }
else else
{ {
echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;'; //echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('edit_group.gif').'&nbsp;'.get_lang('PropModify').'</a>&nbsp;';
echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.get_lang('PropModify').'</a>&nbsp;';
} }
/*if( Database::count_rows(Database::get_course_table(TABLE_GROUP)) > 0) //echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('group_add_big.gif').'&nbsp;'.get_lang("NewGroupCreate").'</a>&nbsp;';
echo '<li><a href="group_creation.php?'.api_get_cidreq().'">'.get_lang("NewGroupCreate").'</a>&nbsp;</li>';
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 '<a href="group_overview.php?'.api_get_cidreq().'">'.Display::return_icon('group_view.gif').'&nbsp;'.get_lang('GroupOverview').'</a>&nbsp;';
}*/ echo '<li><a href="group_overview.php?'.api_get_cidreq().'">'.get_lang('GroupOverview').'</a>&nbsp;</li>';
}
} }
$group_cats = GroupManager :: get_categories(); $group_cats = GroupManager :: get_categories();
if (get_setting('allow_group_categories') == 'true' && count($group_cats) > 1) if (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 '<p><a href="?'.api_get_cidreq().'&show_all=1">'.get_lang('ShowAll').'</a></p>';
echo '<li><a href="?'.api_get_cidreq().'&show_all=1">'.get_lang('ShowAll').'</a></li>';
} }
echo "</ul>";
/* /*
* List all categories * List all categories
*/ */
@ -223,7 +229,7 @@ foreach ($group_cats as $index => $category)
if (api_is_allowed_to_edit()) if (api_is_allowed_to_edit())
{ {
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_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"),ENT_QUOTES,$charset))."'".')) return false;" title="'.get_lang('Delete').'"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></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> ';
if ($index != 0) 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>'; 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>';
@ -233,7 +239,7 @@ foreach ($group_cats as $index => $category)
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 ' <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>'; echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>';
} }
else else
{ {
@ -262,7 +268,13 @@ foreach ($group_cats as $index => $category)
} }
// group name // group name
if (api_is_allowed_to_edit() || in_array($_user['user_id'],$tutorsids_of_group) || $this_group['is_member']) if (api_is_allowed_to_edit() ||
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) ||
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))
{ {
$group_name = '<a href="group_space.php?'.api_get_cidreq().'&amp;origin='.$origin.'&amp;gidReq='.$this_group['id'].'">'.stripslashes($this_group['name']).'</a>'; $group_name = '<a href="group_space.php?'.api_get_cidreq().'&amp;origin='.$origin.'&amp;gidReq='.$this_group['id'].'">'.stripslashes($this_group['name']).'</a>';
if ($_SESSION['_user']['user_id'] && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) if ($_SESSION['_user']['user_id'] && $_SESSION['_user']['user_id'] == $this_group['id_tutor'])
@ -284,11 +296,11 @@ foreach ($group_cats as $index => $category)
{ {
if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) 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(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang("GroupSelfRegInf").'</a>'; $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(htmlentities(get_lang("ConfirmYourChoice")))."'".')) 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(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang("GroupSelfUnRegInf").'</a>'; $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(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;">'.get_lang("GroupSelfUnRegInf").'</a>';
} }
else else
{ {
@ -315,9 +327,9 @@ foreach ($group_cats as $index => $category)
if (api_is_allowed_to_edit()) if (api_is_allowed_to_edit())
{ {
$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="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"),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=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;';
$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(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;" title="'.get_lang('EmptyGroup').'"><img src="../img/group_delete.gif" alt="'.get_lang("EmptyGroup").'"/></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(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;" title="'.get_lang('EmptyGroup').'"><img src="../img/group_delete.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(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;" title="'.get_lang('FillGroup').'"><img src="../img/add_user.gif" alt="'.get_lang("FillGroup").'"/></a>'; $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(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;" title="'.get_lang('FillGroup').'"><img src="../img/add_user.gif" alt="'.get_lang("FillGroup").'"/></a>';
$row[] = $edit_actions; $row[] = $edit_actions;
} }
$totalRegistered = $totalRegistered + $this_group[nbMember]; $totalRegistered = $totalRegistered + $this_group[nbMember];

@ -63,6 +63,10 @@ define("TOOL_PRIVATE", "2");
*/ */
//define("GROUP_TOOL_FORUM", "0"); //define("GROUP_TOOL_FORUM", "0");
define("GROUP_TOOL_DOCUMENTS", "1"); define("GROUP_TOOL_DOCUMENTS", "1");
define("GROUP_TOOL_CALENDAR","2");
define("GROUP_TOOL_ANNOUNCEMENT","3");
define("GROUP_TOOL_WORK","4");
/** /**
* Fixed id's for group categories * Fixed id's for group categories
* - VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the * - VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the
@ -151,6 +155,10 @@ class GroupManager
$table_forum = Database :: get_course_table(TABLE_FORUM); $table_forum = Database :: get_course_table(TABLE_FORUM);
$category = GroupManager :: get_category($category_id); $category = GroupManager :: get_category($category_id);
if (intval($places) == 0) //if the amount of users per group is not filled in, use the setting from the category
{
$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']."', 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']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."'";
api_sql_query($sql,__FILE__,__LINE__); api_sql_query($sql,__FILE__,__LINE__);
$lastId = mysql_insert_id(); $lastId = mysql_insert_id();
@ -368,7 +376,7 @@ class GroupManager
work_state = '".$work_state."', work_state = '".$work_state."',
calendar_state = '".$calendar_state."', calendar_state = '".$calendar_state."',
announcements_state = '".$announcements_state."', announcements_state = '".$announcements_state."',
description='".Database::escape_string(trim($description))."', description='".trim($description)."',
max_student=".$maximum_number_of_students.", max_student=".$maximum_number_of_students.",
self_registration_allowed='".$self_registration_allowed."', self_registration_allowed='".$self_registration_allowed."',
self_unregistration_allowed='".$self_unregistration_allowed."' self_unregistration_allowed='".$self_unregistration_allowed."'
@ -495,7 +503,7 @@ class GroupManager
* @param int $max_number_of_students * @param int $max_number_of_students
* @param int $groups_per_user * @param int $groups_per_user
*/ */
function create_category($title, $description, $doc_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) function create_category($title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user)
{ {
$table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); $table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$sql = "SELECT MAX(display_order)+1 as new_order FROM $table_group_category "; $sql = "SELECT MAX(display_order)+1 as new_order FROM $table_group_category ";
@ -507,8 +515,12 @@ class GroupManager
} }
$sql = "INSERT INTO ".$table_group_category." $sql = "INSERT INTO ".$table_group_category."
SET title='".mysql_real_escape_string($title)."', SET title='".mysql_real_escape_string($title)."',
display_order = $obj->new_order,description='".mysql_real_escape_string($description)."', display_order = $obj->new_order,
description='".mysql_real_escape_string($description)."',
doc_state = '".$doc_state."', doc_state = '".$doc_state."',
work_state = '".$work_state."',
calendar_state = '".$calendar_state."',
announcements_state = '".$announcements_state."',
groups_per_user = ".$groups_per_user.", groups_per_user = ".$groups_per_user.",
self_reg_allowed = '".$self_registration_allowed."', self_reg_allowed = '".$self_registration_allowed."',
self_unreg_allowed = '".$self_unregistration_allowed."', self_unreg_allowed = '".$self_unregistration_allowed."',
@ -523,6 +535,7 @@ class GroupManager
} }
return $id; return $id;
} }
/** /**
* Update group category * Update group category
* @param int $id The id of the category * @param int $id The id of the category
@ -533,13 +546,16 @@ class GroupManager
* @param int $max_number_of_students * @param int $max_number_of_students
* @param int $groups_per_user * @param int $groups_per_user
*/ */
function update_category($id, $title, $description, $doc_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) function update_category($id, $title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user)
{ {
$table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); $table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$sql = "UPDATE ".$table_group_category." $sql = "UPDATE ".$table_group_category."
SET title='".mysql_real_escape_string($title)."', SET title='".mysql_real_escape_string($title)."',
description='".mysql_real_escape_string($description)."', description='".mysql_real_escape_string($description)."',
doc_state = '".$doc_state."', doc_state = '".$doc_state."',
work_state = '".$work_state."',
calendar_state = '".$calendar_state."',
announcements_state = '".$announcements_state."',
groups_per_user = ".$groups_per_user.", groups_per_user = ".$groups_per_user.",
self_reg_allowed = '".$self_registration_allowed."', self_reg_allowed = '".$self_registration_allowed."',
self_unreg_allowed = '".$self_unregistration_allowed."', self_unreg_allowed = '".$self_unregistration_allowed."',
@ -547,6 +563,8 @@ class GroupManager
WHERE id=$id"; WHERE id=$id";
api_sql_query($sql,__FILE__,__LINE__); api_sql_query($sql,__FILE__,__LINE__);
} }
/** /**
* Returns the number of groups of the user with the greatest number of * Returns the number of groups of the user with the greatest number of
* subscribtions in the given category * subscribtions in the given category
@ -1265,13 +1283,18 @@ class GroupManager
{ {
switch ($tool) switch ($tool)
{ {
/*case GROUP_TOOL_FORUM :
$state_key = 'forum_state';
break;
*/
case GROUP_TOOL_DOCUMENTS : case GROUP_TOOL_DOCUMENTS :
$state_key = 'doc_state'; $state_key = 'doc_state';
break; break;
case GROUP_TOOL_CALENDAR :
$state_key = 'calendar_state';
break;
case GROUP_TOOL_ANNOUNCEMENT :
$state_key = 'announcements_state';
break;
case GROUP_TOOL_WORK :
$state_key = 'work_state';
break;
default: default:
return false; return false;
} }

Loading…
Cancel
Save