|
|
|
@ -193,6 +193,18 @@ class GroupManager |
|
|
|
|
$category = self::get_category($category_id); |
|
|
|
|
$places = intval($places); |
|
|
|
|
|
|
|
|
|
// Default values |
|
|
|
|
$docState = self::TOOL_PRIVATE; |
|
|
|
|
$calendarState = self::TOOL_PRIVATE; |
|
|
|
|
$workState = self::TOOL_PRIVATE; |
|
|
|
|
$anonuncementState = self::TOOL_PRIVATE; |
|
|
|
|
$forumState = self::TOOL_PRIVATE; |
|
|
|
|
$wikiState = self::TOOL_PRIVATE; |
|
|
|
|
$chatState = self::TOOL_PRIVATE; |
|
|
|
|
$selfRegAllowed = 0; |
|
|
|
|
$selfUnregAllwoed = 0; |
|
|
|
|
$documentAccess = 0; |
|
|
|
|
|
|
|
|
|
if ($category) { |
|
|
|
|
if ($places == 0) { |
|
|
|
|
//if the amount of users per group is not filled in, use the setting from the category |
|
|
|
@ -211,16 +223,14 @@ class GroupManager |
|
|
|
|
$chatState = $category['chat_state']; |
|
|
|
|
$selfRegAllowed = $category['self_reg_allowed']; |
|
|
|
|
$selfUnregAllwoed = $category['self_unreg_allowed']; |
|
|
|
|
} else { |
|
|
|
|
$docState = self::TOOL_PRIVATE; |
|
|
|
|
$calendarState = self::TOOL_PRIVATE; |
|
|
|
|
$workState = self::TOOL_PRIVATE; |
|
|
|
|
$anonuncementState = self::TOOL_PRIVATE; |
|
|
|
|
$forumState = self::TOOL_PRIVATE; |
|
|
|
|
$wikiState = self::TOOL_PRIVATE; |
|
|
|
|
$chatState = self::TOOL_PRIVATE; |
|
|
|
|
$selfRegAllowed = 0; |
|
|
|
|
$selfUnregAllwoed = 0; |
|
|
|
|
$documentAccess = isset($category['document_access']) ? $category['document_access'] : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$allowDocumentAccess = api_get_configuration_value('group_document_access'); |
|
|
|
|
$documentCondition = ''; |
|
|
|
|
if ($allowDocumentAccess) { |
|
|
|
|
$documentAccess = (int) $documentAccess; |
|
|
|
|
$documentCondition = " document_access = $documentAccess, "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table_group = Database::get_course_table(TABLE_GROUP); |
|
|
|
@ -238,6 +248,7 @@ class GroupManager |
|
|
|
|
chat_state = '".$chatState."', |
|
|
|
|
self_registration_allowed = '".$selfRegAllowed."', |
|
|
|
|
self_unregistration_allowed = '".$selfUnregAllwoed."', |
|
|
|
|
$documentCondition |
|
|
|
|
session_id='".intval($session_id)."'"; |
|
|
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
@ -283,7 +294,6 @@ class GroupManager |
|
|
|
|
'forum_category_title' => get_lang('GroupForums'), |
|
|
|
|
]; |
|
|
|
|
store_forumcategory($categoryParam); |
|
|
|
|
|
|
|
|
|
$forum_categories = get_forum_categories(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -335,7 +345,7 @@ class GroupManager |
|
|
|
|
*/ |
|
|
|
|
public static function create_subgroups($group_id, $number_of_groups) |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
$table_group = Database::get_course_table(TABLE_GROUP); |
|
|
|
|
$category_id = self::create_category( |
|
|
|
|
get_lang('Subgroups'), |
|
|
|
@ -372,7 +382,7 @@ class GroupManager |
|
|
|
|
|
|
|
|
|
foreach ($members as $group_id => $places) { |
|
|
|
|
$sql = "UPDATE $table_group SET max_student = $places |
|
|
|
|
WHERE c_id = $course_id AND id = $group_id"; |
|
|
|
|
WHERE c_id = $courseId AND id = $group_id"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -650,7 +660,7 @@ class GroupManager |
|
|
|
|
$table_forum = Database::get_course_table(TABLE_FORUM); |
|
|
|
|
$categoryId = intval($categoryId); |
|
|
|
|
$group_id = intval($group_id); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
$allowDocumentAccess = api_get_configuration_value('group_document_access'); |
|
|
|
|
$documentCondition = ''; |
|
|
|
@ -674,7 +684,7 @@ class GroupManager |
|
|
|
|
self_unregistration_allowed = '".Database::escape_string($self_unregistration_allowed)."', |
|
|
|
|
$documentCondition |
|
|
|
|
category_id = ".intval($categoryId)." |
|
|
|
|
WHERE c_id = $course_id AND id=".$group_id; |
|
|
|
|
WHERE c_id = $courseId AND id=".$group_id; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
/* Here we are updating a field in the table forum_forum that perhaps |
|
|
|
@ -688,7 +698,7 @@ class GroupManager |
|
|
|
|
} elseif ($forum_state === 0) { |
|
|
|
|
$sql2 .= " forum_group_public_private='unavailable' "; |
|
|
|
|
} |
|
|
|
|
$sql2 .= " WHERE c_id = $course_id AND forum_of_group=".$group_id; |
|
|
|
|
$sql2 .= " WHERE c_id = $courseId AND forum_of_group=".$group_id; |
|
|
|
|
Database::query($sql2); |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -701,11 +711,11 @@ class GroupManager |
|
|
|
|
*/ |
|
|
|
|
public static function get_number_of_groups() |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
$table = Database::get_course_table(TABLE_GROUP); |
|
|
|
|
$sql = "SELECT COUNT(id) AS number_of_groups |
|
|
|
|
FROM $table |
|
|
|
|
WHERE c_id = $course_id "; |
|
|
|
|
WHERE c_id = $courseId "; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$obj = Database::fetch_object($res); |
|
|
|
|
|
|
|
|
@ -722,10 +732,10 @@ class GroupManager |
|
|
|
|
public static function get_categories($course_code = null) |
|
|
|
|
{ |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$courseId = $course_info['real_id']; |
|
|
|
|
$table = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE c_id = $course_id |
|
|
|
|
WHERE c_id = $courseId |
|
|
|
|
ORDER BY display_order"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$cats = []; |
|
|
|
@ -750,12 +760,12 @@ class GroupManager |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$courseInfo = api_get_course_info($course_code); |
|
|
|
|
$courseId = $courseInfo['real_id']; |
|
|
|
|
$id = intval($id); |
|
|
|
|
$table = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE c_id = $course_id AND id = $id |
|
|
|
|
WHERE c_id = $courseId AND id = $id |
|
|
|
|
LIMIT 1"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
|
|
|
|
@ -779,11 +789,11 @@ class GroupManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$courseId = $course_info['real_id']; |
|
|
|
|
$title = Database::escape_string($title); |
|
|
|
|
$table = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE c_id = $course_id AND title = '$title' |
|
|
|
|
WHERE c_id = $courseId AND title = '$title' |
|
|
|
|
LIMIT 1"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$category = []; |
|
|
|
@ -820,11 +830,11 @@ class GroupManager |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
$courseId = $course_info['real_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.c_id = $courseId AND |
|
|
|
|
g.c_id = $courseId AND |
|
|
|
|
gc.id = g.category_id AND |
|
|
|
|
g.iid = $group_id |
|
|
|
|
LIMIT 1"; |
|
|
|
@ -881,8 +891,8 @@ class GroupManager |
|
|
|
|
/** |
|
|
|
|
* Create group category. |
|
|
|
|
* |
|
|
|
|
* @param string $title The title of the new category |
|
|
|
|
* @param string $description The description of the new category |
|
|
|
|
* @param string $title The title of the new category |
|
|
|
|
* @param string $description The description of the new category |
|
|
|
|
* @param int $doc_state |
|
|
|
|
* @param int $work_state |
|
|
|
|
* @param int $calendar_state |
|
|
|
@ -894,6 +904,7 @@ class GroupManager |
|
|
|
|
* @param int $self_unregistration_allowed |
|
|
|
|
* @param int $maximum_number_of_students |
|
|
|
|
* @param int $groups_per_user |
|
|
|
|
* @param int $documentAccess |
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
@ -910,7 +921,8 @@ class GroupManager |
|
|
|
|
$self_registration_allowed = 0, |
|
|
|
|
$self_unregistration_allowed = 0, |
|
|
|
|
$maximum_number_of_students = 8, |
|
|
|
|
$groups_per_user = 0 |
|
|
|
|
$groups_per_user = 0, |
|
|
|
|
$documentAccess = 0 |
|
|
|
|
) { |
|
|
|
|
if (empty($title)) { |
|
|
|
|
return false; |
|
|
|
@ -945,6 +957,11 @@ class GroupManager |
|
|
|
|
'max_student' => $maximum_number_of_students, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$allowDocumentAccess = api_get_configuration_value('group_category_document_access'); |
|
|
|
|
if ($allowDocumentAccess) { |
|
|
|
|
$params['document_access'] = $documentAccess; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$categoryId = Database::insert($table, $params); |
|
|
|
|
if ($categoryId) { |
|
|
|
|
$sql = "UPDATE $table SET id = iid |
|
|
|
@ -974,6 +991,7 @@ class GroupManager |
|
|
|
|
* @param $self_unregistration_allowed |
|
|
|
|
* @param $maximum_number_of_students |
|
|
|
|
* @param $groups_per_user |
|
|
|
|
* @param $documentAccess |
|
|
|
|
*/ |
|
|
|
|
public static function update_category( |
|
|
|
|
$id, |
|
|
|
@ -989,12 +1007,20 @@ class GroupManager |
|
|
|
|
$self_registration_allowed, |
|
|
|
|
$self_unregistration_allowed, |
|
|
|
|
$maximum_number_of_students, |
|
|
|
|
$groups_per_user |
|
|
|
|
$groups_per_user, |
|
|
|
|
$documentAccess |
|
|
|
|
) { |
|
|
|
|
$table = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$id = intval($id); |
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
$allowDocumentAccess = api_get_configuration_value('group_category_document_access'); |
|
|
|
|
$documentCondition = ''; |
|
|
|
|
if ($allowDocumentAccess) { |
|
|
|
|
$documentAccess = (int) $documentAccess; |
|
|
|
|
$documentCondition = " document_access = $documentAccess, "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "UPDATE ".$table." SET |
|
|
|
|
title='".Database::escape_string($title)."', |
|
|
|
@ -1009,8 +1035,9 @@ class GroupManager |
|
|
|
|
groups_per_user = '".Database::escape_string($groups_per_user)."', |
|
|
|
|
self_reg_allowed = '".Database::escape_string($self_registration_allowed)."', |
|
|
|
|
self_unreg_allowed = '".Database::escape_string($self_unregistration_allowed)."', |
|
|
|
|
$documentCondition |
|
|
|
|
max_student = ".intval($maximum_number_of_students)." |
|
|
|
|
WHERE c_id = $course_id AND id = $id"; |
|
|
|
|
WHERE c_id = $courseId AND id = $id"; |
|
|
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
@ -1033,7 +1060,8 @@ class GroupManager |
|
|
|
|
$chat_state, |
|
|
|
|
$self_registration_allowed, |
|
|
|
|
$self_unregistration_allowed, |
|
|
|
|
$id |
|
|
|
|
$id, |
|
|
|
|
$documentAccess |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -3018,6 +3046,17 @@ class GroupManager |
|
|
|
|
|
|
|
|
|
// Default behaviour |
|
|
|
|
$documentAccess = self::DOCUMENT_MODE_SHARE; |
|
|
|
|
|
|
|
|
|
// Check category document access |
|
|
|
|
/*$allowCategoryGroupDocumentAccess = api_get_configuration_value('group_category_document_access'); |
|
|
|
|
if ($allowCategoryGroupDocumentAccess) { |
|
|
|
|
$category = GroupManager::get_category_from_group($groupInfo['iid']); |
|
|
|
|
if (!empty($category) && isset($category['document_access'])) { |
|
|
|
|
$documentAccess = (int) $category['document_access']; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
// Check group document access |
|
|
|
|
$allow = api_get_configuration_value('group_document_access'); |
|
|
|
|
if ($allow) { |
|
|
|
|
if (isset($groupInfo['document_access'])) { |
|
|
|
|