|
|
|
@ -154,21 +154,21 @@ class GroupManager |
|
|
|
|
/** |
|
|
|
|
* Create a group |
|
|
|
|
* @param string $name The name for this group |
|
|
|
|
* @param int $category_id |
|
|
|
|
* @param int $tutor The user-id of the group's tutor |
|
|
|
|
* @param int $places How many people can subscribe to the new group |
|
|
|
|
*/ |
|
|
|
|
public static function create_group($name, $category_id, $tutor, $places) |
|
|
|
|
{ |
|
|
|
|
$_course = api_get_course_info(); |
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
|
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$currentCourseRepository = $_course['path']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$currentCourseRepository = $_course['path']; |
|
|
|
|
$category = self :: get_category($category_id); |
|
|
|
|
$places = intval($places); |
|
|
|
|
|
|
|
|
|
$places = intval($places); |
|
|
|
|
if ($places == 0) { |
|
|
|
|
//if the amount of users per group is not filled in, use the setting from the category |
|
|
|
|
$places = $category['max_student']; |
|
|
|
@ -178,6 +178,7 @@ class GroupManager |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$sql = "INSERT INTO ".$table_group." SET |
|
|
|
|
c_id = $course_id , |
|
|
|
|
category_id='".Database::escape_string($category_id)."', |
|
|
|
@ -192,16 +193,30 @@ class GroupManager |
|
|
|
|
self_registration_allowed = '".$category['self_reg_allowed']."', |
|
|
|
|
self_unregistration_allowed = '".$category['self_unreg_allowed']."', |
|
|
|
|
session_id='".Database::escape_string($session_id)."'"; |
|
|
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
|
$lastId = Database::insert_id(); |
|
|
|
|
|
|
|
|
|
if ($lastId) { |
|
|
|
|
$desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs'; |
|
|
|
|
$my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document'; |
|
|
|
|
$unique_name = create_unexisting_directory($_course, api_get_user_id(), $session_id, $lastId, null, $my_path, $desired_dir_name, null, 1); |
|
|
|
|
$my_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository . '/document'; |
|
|
|
|
|
|
|
|
|
$unique_name = create_unexisting_directory( |
|
|
|
|
$_course, |
|
|
|
|
api_get_user_id(), |
|
|
|
|
$session_id, |
|
|
|
|
$lastId, |
|
|
|
|
null, |
|
|
|
|
$my_path, |
|
|
|
|
$desired_dir_name, |
|
|
|
|
null, |
|
|
|
|
1 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
/* Stores the directory path into the group table */ |
|
|
|
|
$sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$unique_name."' |
|
|
|
|
$sql = "UPDATE ".$table_group." SET |
|
|
|
|
name = '".Database::escape_string($name)."', |
|
|
|
|
secret_directory = '".$unique_name."' |
|
|
|
|
WHERE c_id = $course_id AND id ='".$lastId."'"; |
|
|
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
@ -234,7 +249,7 @@ class GroupManager |
|
|
|
|
$values['approval_direct_group']['approval_direct'] = 0; |
|
|
|
|
$values['allow_attachments_group']['allow_attachments'] = 1; |
|
|
|
|
$values['allow_new_threads_group']['allow_new_threads'] = 1; |
|
|
|
|
$values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view'); |
|
|
|
|
$values['default_view_type_group']['default_view_type'] = api_get_setting('default_forum_view'); |
|
|
|
|
$values['group_forum'] = $lastId; |
|
|
|
|
if ($category['forum_state'] == '1') { |
|
|
|
|
$values['public_private_group_forum_group']['public_private_group_forum']='public'; |
|
|
|
@ -347,7 +362,12 @@ class GroupManager |
|
|
|
|
$group_ids = array(); |
|
|
|
|
foreach ($classes as $class) { |
|
|
|
|
$users_ids = $obj->get_users_by_usergroup($class['id']); |
|
|
|
|
$group_id = self::create_group($class['name'],$category_id,0,count($users_ids)); |
|
|
|
|
$group_id = self::create_group( |
|
|
|
|
$class['name'], |
|
|
|
|
$category_id, |
|
|
|
|
0, |
|
|
|
|
count($users_ids) |
|
|
|
|
); |
|
|
|
|
self::subscribe_users($users_ids,$group_id); |
|
|
|
|
$group_ids[] = $group_id; |
|
|
|
|
} |
|
|
|
@ -418,10 +438,12 @@ class GroupManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// delete the groups |
|
|
|
|
$sql = "DELETE FROM ".$group_table." WHERE c_id = $course_id AND id IN ('".implode("' , '", $group_ids)."')"; |
|
|
|
|
$sql = "DELETE FROM ".$group_table." |
|
|
|
|
WHERE c_id = $course_id AND id IN ('".implode("' , '", $group_ids)."')"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
$sql = "DELETE FROM ".$forum_table." WHERE c_id = $course_id AND forum_of_group IN ('".implode("' , '", $group_ids)."')"; |
|
|
|
|
$sql = "DELETE FROM ".$forum_table." |
|
|
|
|
WHERE c_id = $course_id AND forum_of_group IN ('".implode("' , '", $group_ids)."')"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return Database::affected_rows(); |
|
|
|
@ -442,7 +464,8 @@ class GroupManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$sql = "SELECT * FROM $table_group WHERE c_id = $course_id AND id = ".intval($group_id); |
|
|
|
|
$sql = "SELECT * FROM $table_group |
|
|
|
|
WHERE c_id = $course_id AND id = ".intval($group_id); |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
$db_object = Database::fetch_object($db_result); |
|
|
|
|
|
|
|
|
@ -614,7 +637,9 @@ class GroupManager |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$sql = "SELECT COUNT(id) AS number_of_groups FROM $table_group WHERE c_id = $course_id "; |
|
|
|
|
$sql = "SELECT COUNT(id) AS number_of_groups |
|
|
|
|
FROM $table_group |
|
|
|
|
WHERE c_id = $course_id "; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$obj = Database::fetch_object($res); |
|
|
|
|
return $obj->number_of_groups; |
|
|
|
@ -630,7 +655,8 @@ class GroupManager |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $table_group_cat WHERE c_id = $course_id ORDER BY display_order"; |
|
|
|
|
$sql = "SELECT * FROM $table_group_cat |
|
|
|
|
WHERE c_id = $course_id ORDER BY display_order"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$cats = array (); |
|
|
|
|
while ($cat = Database::fetch_array($res)) { |
|
|
|
@ -654,7 +680,8 @@ class GroupManager |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$id = Database::escape_string($id); |
|
|
|
|
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $table_group_cat WHERE c_id = $course_id AND id = $id LIMIT 1"; |
|
|
|
|
$sql = "SELECT * FROM $table_group_cat |
|
|
|
|
WHERE c_id = $course_id AND id = $id LIMIT 1"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
return Database::fetch_array($res); |
|
|
|
|
} |
|
|
|
@ -696,8 +723,8 @@ class GroupManager |
|
|
|
|
*/ |
|
|
|
|
public static function get_category_from_group($group_id, $course_code = null) |
|
|
|
|
{ |
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$table_group = Database:: get_course_table(TABLE_GROUP); |
|
|
|
|
$table_group_cat = Database:: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
|
|
|
|
|
if (empty($group_id)) { |
|
|
|
|
return array(); |
|
|
|
@ -708,9 +735,11 @@ class GroupManager |
|
|
|
|
|
|
|
|
|
$group_id = Database::escape_string($group_id); |
|
|
|
|
$sql = "SELECT gc.* FROM $table_group_cat gc, $table_group g |
|
|
|
|
WHERE gc.c_id = $course_id AND |
|
|
|
|
g.c_id = $course_id AND |
|
|
|
|
gc.id = g.category_id AND g.id= $group_id LIMIT 1"; |
|
|
|
|
WHERE |
|
|
|
|
gc.c_id = $course_id AND |
|
|
|
|
g.c_id = $course_id AND |
|
|
|
|
gc.id = g.category_id AND g.id= $group_id |
|
|
|
|
LIMIT 1"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$cat = array(); |
|
|
|
|
if (Database::num_rows($res)) { |
|
|
|
@ -730,10 +759,11 @@ class GroupManager |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
|
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$cat_id = Database::escape_string($cat_id); |
|
|
|
|
$sql = "SELECT id FROM $table_group WHERE c_id = $course_id AND category_id='".$cat_id."'"; |
|
|
|
|
$table_group = Database:: get_course_table(TABLE_GROUP); |
|
|
|
|
$table_group_cat = Database:: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$cat_id = Database::escape_string($cat_id); |
|
|
|
|
$sql = "SELECT id FROM $table_group |
|
|
|
|
WHERE c_id = $course_id AND category_id='".$cat_id."'"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
if (Database::num_rows($res) > 0) { |
|
|
|
|
$groups_to_delete = array (); |
|
|
|
@ -776,7 +806,9 @@ class GroupManager |
|
|
|
|
$table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT MAX(display_order)+1 as new_order FROM $table_group_category WHERE c_id = $course_id "; |
|
|
|
|
$sql = "SELECT MAX(display_order)+1 as new_order |
|
|
|
|
FROM $table_group_category |
|
|
|
|
WHERE c_id = $course_id "; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$obj = Database::fetch_object($res); |
|
|
|
|
if (!isset ($obj->new_order)) { |
|
|
|
@ -801,7 +833,8 @@ class GroupManager |
|
|
|
|
Database::query($sql); |
|
|
|
|
$categoryId = Database::insert_id(); |
|
|
|
|
if ($categoryId == self::VIRTUAL_COURSE_CATEGORY) { |
|
|
|
|
$sql = "UPDATE ".$table_group_category." SET id = ". ($categoryId +1)." WHERE c_id = $course_id AND id = $categoryId"; |
|
|
|
|
$sql = "UPDATE ".$table_group_category." SET id = ". ($categoryId +1)." |
|
|
|
|
WHERE c_id = $course_id AND id = $categoryId"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
return $categoryId +1; |
|
|
|
|
} |
|
|
|
@ -899,7 +932,8 @@ class GroupManager |
|
|
|
|
$course_info = api_get_course_info ($course_code); |
|
|
|
|
$group_table = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER); |
|
|
|
|
$sql = 'SELECT COUNT(gu.group_id) AS current_max FROM '.$group_user_table.' gu, '.$group_table.' g |
|
|
|
|
$sql = 'SELECT COUNT(gu.group_id) AS current_max |
|
|
|
|
FROM '.$group_user_table.' gu, '.$group_table.' g |
|
|
|
|
WHERE g.c_id = '.$course_info['real_id'].' |
|
|
|
|
AND gu.c_id = g.c_id |
|
|
|
|
AND gu.group_id = g.id '; |
|
|
|
@ -923,17 +957,18 @@ class GroupManager |
|
|
|
|
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$id1 = Database::escape_string($id1); |
|
|
|
|
$id2 = Database::escape_string($id2); |
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT id,display_order FROM $table_group_cat WHERE id IN ($id1,$id2) AND c_id = $course_id "; |
|
|
|
|
$sql = "SELECT id,display_order FROM $table_group_cat |
|
|
|
|
WHERE id IN ($id1,$id2) AND c_id = $course_id "; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$cat1 = Database::fetch_object($res); |
|
|
|
|
$cat2 = Database::fetch_object($res); |
|
|
|
|
$sql = "UPDATE $table_group_cat SET display_order=$cat2->display_order WHERE id = $cat1->id AND c_id = $course_id "; |
|
|
|
|
$sql = "UPDATE $table_group_cat SET display_order=$cat2->display_order |
|
|
|
|
WHERE id = $cat1->id AND c_id = $course_id "; |
|
|
|
|
Database::query($sql); |
|
|
|
|
$sql = "UPDATE $table_group_cat SET display_order=$cat1->display_order WHERE id = $cat2->id AND c_id = $course_id "; |
|
|
|
|
$sql = "UPDATE $table_group_cat SET display_order=$cat1->display_order |
|
|
|
|
WHERE id = $cat2->id AND c_id = $course_id "; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1015,7 +1050,8 @@ class GroupManager |
|
|
|
|
$tutor_user_table = Database :: get_course_table(TABLE_GROUP_TUTOR); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$group_id = intval($group_id); |
|
|
|
|
$sql = "SELECT user_id FROM $group_user_table WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$sql = "SELECT user_id FROM $group_user_table |
|
|
|
|
WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$users = array(); |
|
|
|
|
|
|
|
|
@ -1023,7 +1059,8 @@ class GroupManager |
|
|
|
|
$users[] = api_get_user_info($obj->user_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT user_id FROM $tutor_user_table WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$sql = "SELECT user_id FROM $tutor_user_table |
|
|
|
|
WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($res)) { |
|
|
|
|
$users[] = api_get_user_info($obj->user_id); |
|
|
|
@ -1042,7 +1079,8 @@ class GroupManager |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$group_id = intval($group_id); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT user_id FROM $tutor_user_table WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$sql = "SELECT user_id FROM $tutor_user_table |
|
|
|
|
WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($res)) { |
|
|
|
|
$users[] = api_get_user_info($obj->user_id); |
|
|
|
@ -1060,7 +1098,8 @@ class GroupManager |
|
|
|
|
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$group_id = intval($group_id); |
|
|
|
|
$sql = "SELECT user_id FROM $group_user_table WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$sql = "SELECT user_id FROM $group_user_table |
|
|
|
|
WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$users = array(); |
|
|
|
|
|
|
|
|
@ -1098,19 +1137,19 @@ class GroupManager |
|
|
|
|
/** |
|
|
|
|
* Fill the groups with students. |
|
|
|
|
* The algorithm takes care to first fill the groups with the least # of users. |
|
|
|
|
* Analysis |
|
|
|
|
* There was a problem with the "ALL" setting. |
|
|
|
|
* When max # of groups is set to all, the value is sometimes NULL and sometimes ALL |
|
|
|
|
* and in both cased the query does not work as expected. |
|
|
|
|
* Stupid solution (currently implemented: set ALL to a big number (INFINITE) and things are solved :) |
|
|
|
|
* Better solution: that's up to you. |
|
|
|
|
* Analysis |
|
|
|
|
* There was a problem with the "ALL" setting. |
|
|
|
|
* When max # of groups is set to all, the value is sometimes NULL and sometimes ALL |
|
|
|
|
* and in both cased the query does not work as expected. |
|
|
|
|
* Stupid solution (currently implemented: set ALL to a big number (INFINITE) and things are solved :) |
|
|
|
|
* Better solution: that's up to you. |
|
|
|
|
* |
|
|
|
|
* Note |
|
|
|
|
* Throughout Dokeos there is some confusion about "course id" and "course code" |
|
|
|
|
* The code is e.g. TEST101, but sometimes a variable that is called courseID also contains a course code string. |
|
|
|
|
* However, there is also a integer course_id that uniquely identifies the course. |
|
|
|
|
* ywarnier:> Now the course_id has been removed (25/1/2005) |
|
|
|
|
* The databases are als very inconsistent in this. |
|
|
|
|
* Note |
|
|
|
|
* Throughout Dokeos there is some confusion about "course id" and "course code" |
|
|
|
|
* The code is e.g. TEST101, but sometimes a variable that is called courseID also contains a course code string. |
|
|
|
|
* However, there is also a integer course_id that uniquely identifies the course. |
|
|
|
|
* ywarnier:> Now the course_id has been removed (25/1/2005) |
|
|
|
|
* The databases are als very inconsistent in this. |
|
|
|
|
* |
|
|
|
|
* @author Chrisptophe Gesche <christophe.geshe@claroline.net>, |
|
|
|
|
* Hugues Peeters <hugues.peeters@claroline.net> - original version |
|
|
|
@ -1137,12 +1176,11 @@ class GroupManager |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$category = self::get_category_from_group($group_ids[0]); |
|
|
|
|
|
|
|
|
|
$groups_per_user = $category['groups_per_user']; |
|
|
|
|
$group_table = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
$category = self::get_category_from_group($group_ids[0]); |
|
|
|
|
$groups_per_user = $category['groups_per_user']; |
|
|
|
|
$group_table = Database:: get_course_table(TABLE_GROUP); |
|
|
|
|
$group_user_table = Database:: get_course_table(TABLE_GROUP_USER); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
$complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); |
|
|
|
|
$number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); |
|
|
|
@ -1232,7 +1270,8 @@ class GroupManager |
|
|
|
|
} else { |
|
|
|
|
$course_id = intval($course_id); |
|
|
|
|
} |
|
|
|
|
$sql = "SELECT COUNT(*) AS number_of_students FROM $table_group_user WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$sql = "SELECT COUNT(*) AS number_of_students FROM $table_group_user |
|
|
|
|
WHERE c_id = $course_id AND group_id = $group_id"; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
$db_object = Database::fetch_object($db_result); |
|
|
|
|
return $db_object->number_of_students; |
|
|
|
@ -1274,11 +1313,13 @@ class GroupManager |
|
|
|
|
$cat_condition = " AND g.category_id = $cat_id "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT COUNT(*) AS number_of_groups FROM $table_group_user gu, $table_group g |
|
|
|
|
WHERE gu.c_id = $course_id AND |
|
|
|
|
g.c_id = $course_id AND |
|
|
|
|
gu.user_id = $user_id AND |
|
|
|
|
g.id = gu.group_id $cat_condition"; |
|
|
|
|
$sql = "SELECT COUNT(*) AS number_of_groups |
|
|
|
|
FROM $table_group_user gu, $table_group g |
|
|
|
|
WHERE |
|
|
|
|
gu.c_id = $course_id AND |
|
|
|
|
g.c_id = $course_id AND |
|
|
|
|
gu.user_id = $user_id AND |
|
|
|
|
g.id = gu.group_id $cat_condition"; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
$db_object = Database::fetch_object($db_result); |
|
|
|
|
return $db_object->number_of_groups; |
|
|
|
@ -1299,7 +1340,9 @@ class GroupManager |
|
|
|
|
$table_group = Database :: get_course_table(TABLE_GROUP); |
|
|
|
|
$group_id = intval($group_id); |
|
|
|
|
if (isset($group_id)) { |
|
|
|
|
$sql = "SELECT self_registration_allowed FROM $table_group WHERE c_id = $course_id AND id = $group_id"; |
|
|
|
|
$sql = "SELECT self_registration_allowed |
|
|
|
|
FROM $table_group |
|
|
|
|
WHERE c_id = $course_id AND id = $group_id"; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
$db_object = Database::fetch_object($db_result); |
|
|
|
|
return $db_object->self_registration_allowed == 1 && self :: can_user_subscribe($user_id, $group_id); |
|
|
|
@ -1323,7 +1366,9 @@ class GroupManager |
|
|
|
|
$group_id = Database::escape_string($group_id); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$db_result = Database::query( |
|
|
|
|
'SELECT self_unregistration_allowed FROM '.$table_group.' WHERE c_id = '.$course_id.' AND id = '.$group_id |
|
|
|
|
'SELECT self_unregistration_allowed |
|
|
|
|
FROM '.$table_group.' |
|
|
|
|
WHERE c_id = '.$course_id.' AND id = '.$group_id |
|
|
|
|
); |
|
|
|
|
$db_object = Database::fetch_object($db_result); |
|
|
|
|
|
|
|
|
@ -1588,7 +1633,8 @@ class GroupManager |
|
|
|
|
$group_ids = is_array($group_ids) ? $group_ids : array($group_ids); |
|
|
|
|
if (count($group_ids) > 0) { |
|
|
|
|
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR); |
|
|
|
|
$sql = 'DELETE FROM '.$table_group_tutor.' WHERE group_id IN ('.implode(',', $group_ids).') AND c_id = '.$course_id; |
|
|
|
|
$sql = 'DELETE FROM '.$table_group_tutor.' |
|
|
|
|
WHERE group_id IN ('.implode(',', $group_ids).') AND c_id = '.$course_id; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
@ -1610,7 +1656,8 @@ class GroupManager |
|
|
|
|
$group_id = Database::escape_string($group_id); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM ".$table_group_tutor." WHERE c_id = $course_id AND user_id='".$user_id."' AND group_id='".$group_id."'"; |
|
|
|
|
$sql = "SELECT * FROM ".$table_group_tutor." |
|
|
|
|
WHERE c_id = $course_id AND user_id='".$user_id."' AND group_id='".$group_id."'"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if (Database::num_rows($result) > 0) { |
|
|
|
|
return true; |
|
|
|
@ -1621,8 +1668,11 @@ class GroupManager |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Is the user part of this group? This can be a tutor or a normal member |
|
|
|
|
* you should use this function if the access to a tool or functionality is restricted to the people who are actually in the group |
|
|
|
|
* before you had to check if the user was 1. a member of the group OR 2. a tutor of the group. This function combines both |
|
|
|
|
* you should use this function if the access to a tool or functionality is |
|
|
|
|
* restricted to the people who are actually in the group |
|
|
|
|
* before you had to check if the user was |
|
|
|
|
* 1. a member of the group OR |
|
|
|
|
* 2. a tutor of the group. This function combines both |
|
|
|
|
* @param int $user_id the id of the user |
|
|
|
|
* @param int $group_id the id of the group |
|
|
|
|
* @return boolean true/false |
|
|
|
@ -1722,10 +1772,6 @@ class GroupManager |
|
|
|
|
return $groups; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
Group functions - these take virtual/linked courses into account when necessary |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a combined list of all users of the real course $course_code |
|
|
|
|
* and all users in virtual courses linked to this course $course_code |
|
|
|
|