Groups: Fix group/category creation

pull/3741/head
Julio Montoya 4 years ago
parent e766a28794
commit 311e81c2bd
  1. 6
      assets/css/app.css
  2. 62
      public/main/group/group.php
  3. 2
      public/main/group/group_creation.php
  4. 2
      public/main/group/settings.php
  5. 11
      public/main/inc/lib/display.lib.php
  6. 283
      public/main/inc/lib/groupmanager.lib.php
  7. 2
      public/main/lp/lp_subscribe_users_to_category.php

@ -1,3 +1,9 @@
body {
background-color: lightgray;
}
.actions li a {
border: 1px solid transparent;
border-top-left-radius: .25rem;
border-top-right-radius: .25rem;
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session;
/**
@ -32,7 +33,9 @@ $htmlHeadXtra[] = '<script>
$(function() {
var i;
for (i=0; i<$(".actions").length; i++) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" ||
$(".actions:eq("+i+")").html()==null
) {
$(".actions:eq("+i+")").hide();
}
}
@ -43,11 +46,16 @@ $nameTools = get_lang('Groups management');
/*
* Self-registration and un-registration
*/
$my_group_id = isset($_GET['group_id']) ? (int) $_GET['group_id'] : null;
$my_group = isset($_REQUEST['group']) ? Security::remove_XSS($_REQUEST['group']) : null;
$my_group_id = $_GET['group_id'] ?? null;
$categoryId = $_GET['category_id'] ?? null;
$my_get_id1 = isset($_GET['id1']) ? Security::remove_XSS($_GET['id1']) : null;
$my_get_id2 = isset($_GET['id2']) ? Security::remove_XSS($_GET['id2']) : null;
$my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null;
$groupRepo = Container::getGroupRepository();
$groupEntity = null;
if (!empty($my_group_id)) {
$groupEntity = $groupRepo->find($my_group_id);
}
$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq();
$groupInfo = GroupManager::get_group_properties($my_group_id);
@ -55,8 +63,8 @@ $groupInfo = GroupManager::get_group_properties($my_group_id);
if (isset($_GET['action']) && $is_allowed_in_course) {
switch ($_GET['action']) {
case 'set_visible':
if (api_is_allowed_to_edit()) {
GroupManager::setVisible($my_get_id);
if ($groupEntity && api_is_allowed_to_edit()) {
GroupManager::setVisible($groupEntity);
Display::addFlash(Display::return_message(get_lang('Item updated')));
header("Location: $currentUrl");
exit;
@ -64,8 +72,8 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
break;
case 'set_invisible':
if (api_is_allowed_to_edit()) {
GroupManager::setInvisible($my_get_id);
if ($groupEntity && api_is_allowed_to_edit()) {
GroupManager::setInvisible($groupEntity);
Display::addFlash(Display::return_message(get_lang('Item updated')));
header("Location: $currentUrl");
exit;
@ -107,8 +115,8 @@ if (api_is_allowed_to_edit(false, true)) {
case 'delete_selected':
if (is_array($_POST['group'])) {
foreach ($_POST['group'] as $myGroupId) {
$groupInfo = GroupManager::get_group_properties($myGroupId);
GroupManager::deleteGroup($groupInfo);
$group = $groupRepo->find($myGroupId);
GroupManager::deleteGroup($group);
}
Display::addFlash(Display::return_message(get_lang('All selected groups have been deleted')));
@ -120,8 +128,7 @@ if (api_is_allowed_to_edit(false, true)) {
case 'empty_selected':
if (is_array($_POST['group'])) {
foreach ($_POST['group'] as $myGroupId) {
$groupInfo = GroupManager::get_group_properties($myGroupId);
GroupManager::unsubscribe_all_users($groupInfo);
GroupManager::unsubscribe_all_users($myGroupId);
}
Display::addFlash(Display::return_message(get_lang('All selected groups are now empty')));
@ -133,8 +140,8 @@ if (api_is_allowed_to_edit(false, true)) {
case 'fill_selected':
if (is_array($_POST['group'])) {
foreach ($_POST['group'] as $myGroupId) {
$groupInfo = GroupManager::get_group_properties($myGroupId);
GroupManager::fillGroupWithUsers($groupInfo);
$group = $groupRepo->find($myGroupId);
GroupManager::fillGroupWithUsers($group);
}
Display::addFlash(Display::return_message(get_lang('All selected groups have been filled')));
header("Location: $currentUrl");
@ -156,24 +163,26 @@ if (api_is_allowed_to_edit(false, true)) {
break;
case 'delete_one':
$groupInfo = GroupManager::get_group_properties($my_get_id);
GroupManager::deleteGroup($groupInfo);
GroupManager::deleteGroup($groupEntity);
Display::addFlash(Display::return_message(get_lang('Group deleted')));
header("Location: $currentUrl");
exit;
break;
case 'fill_one':
$groupInfo = GroupManager::get_group_properties($my_get_id);
GroupManager::fillGroupWithUsers($groupInfo);
Display::addFlash(Display::return_message(get_lang('Groups have been filled (or completed) by users present in the \'Users\' list.')));
GroupManager::fillGroupWithUsers($groupEntity);
Display::addFlash(
Display::return_message(
get_lang('Groups have been filled (or completed) by users present in the \'Users\' list.')
)
);
header("Location: $currentUrl");
exit;
break;
case 'delete_category':
if (empty($sessionId)) {
GroupManager::delete_category($my_get_id);
GroupManager::delete_category($categoryId);
Display::addFlash(
Display::return_message(get_lang('The category has been deleted.'))
);
@ -186,14 +195,10 @@ if (api_is_allowed_to_edit(false, true)) {
}
}
/* Header */
Display::display_header(get_lang('Groups'));
// Tool introduction
Display::display_introduction_section(TOOL_GROUP);
$actionsLeft = '';
if (api_is_allowed_to_edit(false, true)) {
$actionsLeft .= '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add-groups.png', get_lang('Create new group(s)'), '', ICON_SIZE_MEDIUM).'</a>';
@ -251,13 +256,14 @@ if ('true' === api_get_setting('allow_group_categories')) {
$actions = null;
if (api_is_allowed_to_edit(false, true) && !empty($categoryId) && empty($sessionId)) {
// Edit
$actions .= '<a href="group_category.php?'.api_get_cidreq().'&id='.$categoryId.'" title="'.get_lang('Edit').'">'.
$actions .= '<a
href="group_category.php?'.api_get_cidreq().'&id='.$categoryId.'" title="'.get_lang('Edit').'">'.
Display::return_icon('edit.png', get_lang('Edit this category'), '', ICON_SIZE_SMALL).'</a>';
// Delete
$actions .= Display::url(
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL),
'group.php?'.api_get_cidreq().'&action=delete_category&id='.$categoryId,
'group.php?'.api_get_cidreq().'&action=delete_category&category_id='.$categoryId,
[
'onclick' => 'javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;',
]
@ -265,12 +271,12 @@ if ('true' === api_get_setting('allow_group_categories')) {
// Move
if (0 != $index) {
$actions .= ' <a
href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$categoryId.'&id2='.$categories[$index - 1]['iid'].'">'.
href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$categoryId.'&id2='.$categories[$index - 1]['iid'].'">'.
Display::return_icon('up.png', '&nbsp;', '', ICON_SIZE_SMALL).'</a>';
}
if ($index != count($categories) - 1) {
$actions .= ' <a
href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$categoryId.'&id2='.$categories[$index + 1]['iid'].'">'.
href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$categoryId.'&id2='.$categories[$index + 1]['iid'].'">'.
Display::return_icon('down.png', '&nbsp;', '', ICON_SIZE_SMALL).'</a>';
}
}

@ -116,7 +116,7 @@ if (isset($_POST['number_of_groups'])) {
disabled = element.disabled;
$(id).prop('disabled', disabled);
$(id).prop('value', ref.value);
$(id).selectpicker('refresh');
//$(id).selectpicker('refresh');
}
if (disabled) {
ref.addEventListener("change", copy, false);

@ -43,7 +43,7 @@ $form->addElement('html', '<div class="col-md-6">');
// Group name
$form->addElement('text', 'name', get_lang('Group name'));
if ('true' == api_get_setting('allow_group_categories')) {
if ('true' === api_get_setting('allow_group_categories')) {
$groupCategories = GroupManager::get_categories();
$categoryList = [];
foreach ($groupCategories as $category) {

@ -2555,9 +2555,8 @@ class Display
});
}
$html = '<div id="'.$id.'" class="actions">';
$html .= '<div class="row">';
$html = '<ul id="'.$id.'" class="nav nav-tabs actions">';
//$html .= '<div class="row">';
for ($i = 0; $i < $col; $i++) {
$class = 'col-sm-'.$colsWidth[$i];
@ -2569,11 +2568,11 @@ class Display
}
}
$html .= '<div class="'.$class.'">'.$content[$i].'</div>';
$html .= '<li class="nav-item '.$class.'">'.$content[$i].'</li>';
}
$html .= '</div>';
$html .= '</div>';
//$html .= '</div>';
$html .= '</ul>';
return $html;
}

@ -123,8 +123,8 @@ class GroupManager
$repo = Container::getGroupRepository();
$course = api_get_course_entity($course_id);
$session = api_get_session_entity($sessionId);
$group = api_get_group_entity(api_get_group_id());
//$group = api_get_group_entity(api_get_group_id());
$group = null;
$qb = $repo->getResourcesByCourse($course, $session, $group);
if (null === $categoryId) {
@ -464,14 +464,13 @@ class GroupManager
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @author Bart Mollet
*
* @param array $groupInfo iid
* @param string $course_code Default is current course
*
* @return int - number of groups deleted
*/
public static function deleteGroup($groupInfo, $course_code = null)
public static function deleteGroup(CGroup $group, $course_code = null)
{
if (empty($groupInfo['iid'])) {
if (empty($group)) {
return false;
}
$course_info = api_get_course_info($course_code);
@ -481,66 +480,63 @@ class GroupManager
$course_id = $course_info['real_id'];
$em = Database::getManager();
$groupInfo = self::get_group_properties($groupInfo['iid'], true);
if ($groupInfo) {
$groupIid = $groupInfo['iid'];
// Unsubscribe all users
self::unsubscribe_all_users($groupInfo);
self::unsubscribe_all_tutors($groupInfo);
if (!empty($groupInfo['secret_directory'])) {
/*
$directory = $groupInfo['secret_directory'];
// move group-documents to garbage
$source_directory = api_get_path(SYS_COURSE_PATH).$course_info['path']."/document".$directory;
// File to renamed
$destination_dir = api_get_path(SYS_COURSE_PATH).$course_info['path']."/document".$directory.'_DELETED_'.$groupInfo['id'];
//Deleting from document tool
DocumentManager::delete_document(
$course_info,
$directory,
$source_directory
);
if (file_exists($source_directory)) {
if ('true' === api_get_setting('permanently_remove_deleted_files')) {
// Delete
my_delete($source_directory);
} else {
// Rename
rename($source_directory, $destination_dir);
}
}*/
}
$groupIid = $group->getIid();
// Unsubscribe all users
self::unsubscribe_all_users($groupInfo);
self::unsubscribe_all_tutors($groupInfo);
if (!empty($groupInfo['secret_directory'])) {
/*
$directory = $groupInfo['secret_directory'];
// move group-documents to garbage
$source_directory = api_get_path(SYS_COURSE_PATH).$course_info['path']."/document".$directory;
// File to renamed
$destination_dir = api_get_path(SYS_COURSE_PATH).$course_info['path']."/document".$directory.'_DELETED_'.$groupInfo['id'];
//Deleting from document tool
DocumentManager::delete_document(
$course_info,
$directory,
$source_directory
);
$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CForumForum f WHERE f.forumOfGroup = :group'
)
->execute(['group' => $groupIid]);
// Delete item properties of this group.
// to_group_id is related to c_group_info.iid
/*$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CItemProperty ci WHERE ci.course = :course AND ci.group = :group'
)
->execute(['course' => $course_id, 'group' => $groupId]);
*/
// delete the groups
$repo = Container::getGroupRepository();
$group = $repo->find($groupIid);
if ($group) {
$em->remove($group);
$em->flush();
}
/*$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CGroup g WHERE g.course = :course AND g.iid = :id'
)
->execute(['course' => $course_id, 'id' => $groupIid]);*/
if (file_exists($source_directory)) {
if ('true' === api_get_setting('permanently_remove_deleted_files')) {
// Delete
my_delete($source_directory);
} else {
// Rename
rename($source_directory, $destination_dir);
}
}*/
}
$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CForumForum f WHERE f.forumOfGroup = :group'
)
->execute(['group' => $groupIid]);
// Delete item properties of this group.
// to_group_id is related to c_group_info.iid
/*$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CItemProperty ci WHERE ci.course = :course AND ci.group = :group'
)
->execute(['course' => $course_id, 'group' => $groupId]);
*/
// delete the groups
$repo = Container::getGroupRepository();
$em->remove($group);
$em->flush();
/*$em
->createQuery(
'DELETE FROM ChamiloCourseBundle:CGroup g WHERE g.course = :course AND g.iid = :id'
)
->execute(['course' => $course_id, 'id' => $groupIid]);*/
return true;
}
@ -808,7 +804,8 @@ class GroupManager
}
$session = api_get_session_entity(api_get_session_id());
$group = api_get_group_entity(api_get_group_id());
//$group = api_get_group_entity(api_get_group_id());
$group = null;
$qb = $repo->getResourcesByCourse($course, $session, $group);
@ -1354,7 +1351,6 @@ class GroupManager
public static function getStudents($groupId, $filterOnlyActive = false)
{
$groupId = (int) $groupId;
$activeCondition = $filterOnlyActive ? 'AND u.active = 1' : '';
$em = Database::getManager();
@ -1381,6 +1377,28 @@ class GroupManager
return $users;
}
public static function getStudentsCount($groupId, $filterOnlyActive = false)
{
$groupId = (int) $groupId;
$activeCondition = $filterOnlyActive ? 'AND u.active = 1' : '';
$em = Database::getManager();
return $em
->createQuery("
SELECT COUNT(u.id) FROM ChamiloCoreBundle:User u
INNER JOIN ChamiloCourseBundle:CGroupRelUser gu
WITH u.id = gu.user
INNER JOIN ChamiloCourseBundle:CGroup g
WITH gu.group = g.iid
WHERE g.iid = :group
$activeCondition
")
->setParameters([
'group' => $groupId,
])
->getSingleScalarResult();
}
/**
* Returns users belonging to any of the group.
*
@ -1425,8 +1443,6 @@ class GroupManager
* ywarnier:> Now the course_id has been removed (25/1/2005)
* The databases are als very inconsistent in this.
*
* @param array $groupInfo
*
* @author Chrisptophe Gesche <christophe.geshe@claroline.net>,
* Hugues Peeters <hugues.peeters@claroline.net> - original version
* @author Roan Embrechts - virtual course support, code cleaning
@ -1434,10 +1450,10 @@ class GroupManager
*
* @return bool
*/
public static function fillGroupWithUsers($groupInfo)
public static function fillGroupWithUsers(CGroup $group)
{
$_course = api_get_course_info();
if (empty($_course) || empty($groupInfo)) {
if (empty($_course) || empty($group)) {
return false;
}
$session_id = api_get_session_id();
@ -1445,7 +1461,7 @@ class GroupManager
$_course['code'],
$session_id
);
$groupIid = $groupInfo['iid'];
$groupIid = $group->getIid();
$category = self::get_category_from_group($groupIid);
// Getting max numbers of user from group
@ -1907,20 +1923,19 @@ class GroupManager
/**
* Unsubscribe all users from one or more groups.
*
* @param array $groupInfo
* @param int $groupId
*
* @return bool TRUE if successful
*/
public static function unsubscribe_all_users($groupInfo)
public static function unsubscribe_all_users($groupId)
{
$course_id = api_get_course_int_id();
$groupId = (int) $groupInfo['iid'];
if (empty($course_id) || empty($groupId)) {
$groupId = (int) $groupId;
if (empty($groupId)) {
return false;
}
$table_group_user = Database::get_course_table(TABLE_GROUP_USER);
$sql = "DELETE FROM $table_group_user
$table = Database::get_course_table(TABLE_GROUP_USER);
$sql = "DELETE FROM $table
WHERE
group_id = $groupId ";
@ -2344,8 +2359,9 @@ class GroupManager
$group_name2 = '';
if (api_get_configuration_value('extra')) {
$group_name2 = '<a href="group_space_tracking.php?cid='.api_get_course_int_id().'&gid='
.$groupId.'">'.get_lang('suivi_de').''.stripslashes($this_group['name']).'</a>';
$group_name2 = '<a
href="group_space_tracking.php?cid='.api_get_course_int_id().'&gid='.$groupId.'">'.
get_lang('suivi_de').''.stripslashes($this_group['name']).'</a>';
}
if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
@ -2414,16 +2430,22 @@ class GroupManager
// Max number of members in group
$max_members = self::MEMBER_PER_GROUP_NO_LIMIT == $this_group['maxStudent'] ? ' ' : ' / '.$this_group['maxStudent'];
$registeredUsers = self::getStudentsCount($groupId);
// Number of members in group
$row[] = $this_group['maxStudent'].$max_members;
$row[] = $registeredUsers.$max_members;
$confirmMessage = addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES, $charset));
// Self-registration / unregistration
if (!api_is_allowed_to_edit(false, true)) {
if (self::is_self_registration_allowed($user_id, $this_group)) {
$row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_reg&group_id='.$groupId.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('register').'</a>';
$row[] = '<a
class = "btn btn-default"
href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_reg&group_id='.$groupId.'"
onclick="javascript:if(!confirm('."'".$confirmMessage."'".')) return false;">'.get_lang('register').'</a>';
} elseif (self::is_self_unregistration_allowed($user_id, $this_group)) {
$row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_unreg&group_id='.$groupId.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('unregister').'</a>';
$row[] = '<a
class = "btn btn-default"
href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_unreg&group_id='.$groupId.'"
onclick="javascript:if(!confirm('."'".$confirmMessage."'".')) return false;">'.get_lang('unregister').'</a>';
} else {
$row[] = '-';
}
@ -2433,35 +2455,48 @@ class GroupManager
if (api_is_allowed_to_edit(false, true) &&
!(api_is_session_general_coach() && intval($this_group['session_id']) != $session_id)
) {
$edit_actions = '<a href="'.$url.'settings.php?'.api_get_cidreq(true, false).'&gid='.$groupId.'" title="'.get_lang('Edit').'">'.
Display::return_icon('edit.png', get_lang('Edit this group'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
$edit_actions = '<a
href="'.$url.'settings.php?'.api_get_cidreq(true, false).'&gid='.$groupId.'"
title="'.get_lang('Edit').'">'.
Display::return_icon('edit.png', get_lang('Edit this group'), '', ICON_SIZE_SMALL).
'</a>&nbsp;';
if (1 == $this_group['status']) {
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_invisible&id='.$groupId.'" title="'.get_lang('Hide').'">'.
$edit_actions .= '<a
href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_invisible&group_id='.$groupId.'"
title="'.get_lang('Hide').'">'.
Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
} else {
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_visible&id='.$groupId.'" title="'.get_lang('Show').'">'.
$edit_actions .= '<a
href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_visible&group_id='.$groupId.'"
title="'.get_lang('Show').'">'.
Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
}
$edit_actions .= '<a href="'.$url.'member_settings.php?'.api_get_cidreq(true, false).'&gid='.$groupId.'" title="'.get_lang('Group members').'">'.
$edit_actions .= '<a
href="'.$url.'member_settings.php?'.api_get_cidreq(true, false).'&gid='.$groupId.'"
title="'.get_lang('Group members').'">'.
Display::return_icon('user.png', get_lang('Group members'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
$edit_actions .= '<a href="'.$url.'group_overview.php?action=export&type=xls&'.api_get_cidreq(true, false).'&id='.$groupId.'" title="'.get_lang('Export users list').'">'.
$edit_actions .= '<a
href="'.$url.'group_overview.php?action=export&type=xls&'.api_get_cidreq(true, false).'&id='.$groupId.'"
title="'.get_lang('Export users list').'">'.
Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
if ($surveyGroupExists) {
$edit_actions .= Display::url(
Display::return_icon('survey.png', get_lang('ExportSurveyResults'), '', ICON_SIZE_SMALL),
$url.'group_overview.php?action=export_surveys&'.api_get_cidreq(true, false).'&id='.$groupId
).'&nbsp;';
Display::return_icon('survey.png', get_lang('ExportSurveyResults'), '', ICON_SIZE_SMALL),
$url.'group_overview.php?action=export_surveys&'.api_get_cidreq(true, false).'&id='.$groupId
).'&nbsp;';
}
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&id='.$groupId.'"
onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
$edit_actions .= '<a
href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&group_id='.$groupId.'"
onclick="javascript: if(!confirm('."'".$confirmMessage."'".')) return false;" title="'.get_lang('FillGroup').'">'.
Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&id='.$groupId.'"
onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
$edit_actions .= '<a
href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&group_id='.$groupId.'"
onclick="javascript: if(!confirm('."'".$confirmMessage."'".')) return false;" title="'.get_lang('Delete').'">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
$row[] = $edit_actions;
@ -2470,7 +2505,7 @@ class GroupManager
$totalRegistered = $totalRegistered + $this_group['nbMember'];
}
$group_data[] = $row;
} // end loop
}
// If no groups then don't show the table (only for students)
if (!api_is_allowed_to_edit(true, false)) {
@ -2898,7 +2933,7 @@ class GroupManager
case 'settings':
$activeSettings = 'active';
break;
case'tutor':
case 'tutor':
$activeTutor = 'active';
break;
case 'member':
@ -2909,18 +2944,18 @@ class GroupManager
$url = api_get_path(WEB_CODE_PATH).'group/%s?'.api_get_cidreq();
echo '
<ul class="toolbar-groups nav nav-tabs">
<li class="'.$activeSettings.'">
<a id="group_settings_tab" href="'.sprintf($url, 'settings.php').'">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link '.$activeSettings.'" id="group_settings_tab" href="'.sprintf($url, 'settings.php').'">
'.Display::return_icon('settings.png').' '.get_lang('Settings').'
</a>
</li>
<li class="'.$activeMember.'">
<a id="group_members_tab" href="'.sprintf($url, 'member_settings.php').'">
<li class="nav-item">
<a class="nav-link '.$activeMember.'" id="group_members_tab" href="'.sprintf($url, 'member_settings.php').'">
'.Display::return_icon('user.png').' '.get_lang('Group members').'</a>
</li>
<li class="'.$activeTutor.'">
<a id="group_tutors_tab" href="'.sprintf($url, 'tutor_settings.php').'">
<li class="nav-item">
<a class="nav-link '.$activeTutor.'" id="group_tutors_tab" href="'.sprintf($url, 'tutor_settings.php').'">
'.Display::return_icon('teacher.png').' '.get_lang('Group tutors').'
</a>
</li>
@ -3036,42 +3071,22 @@ class GroupManager
return $form->toHtml();
}
/**
* @param int $groupId
* @param int $status
*/
public static function setStatus($groupId, $status)
public static function setStatus(CGroup $group, $status)
{
$groupInfo = self::get_group_properties($groupId);
$courseId = api_get_course_int_id();
if (!empty($groupInfo)) {
$table = Database::get_course_table(TABLE_GROUP);
$params = [
'status' => intval($status),
];
Database::update(
$table,
$params,
['c_id = ? AND id = ?' => [$courseId, $groupId]]
);
}
$group->setStatus($status);
$em = Database::getManager();
$em->persist($group);
$em->flush();
}
/**
* @param int $groupId
*/
public static function setVisible($groupId)
public static function setVisible(CGroup $group)
{
self::setStatus($groupId, 1);
self::setStatus($group, true);
}
/**
* @param int $groupId
*/
public static function setInvisible($groupId)
public static function setInvisible(CGroup $group)
{
self::setStatus($groupId, 0);
self::setStatus($group, false);
}
/**

@ -78,7 +78,7 @@ $links = $category->getResourceNode()->getResourceLinks();
$selectedGroupChoices = [];
foreach ($links as $link) {
if (null !== $link->getGroup()) {
$selectedGroupChoices[] = $link->getGroup()->getId();
$selectedGroupChoices[] = $link->getGroup()->getIid();
}
}

Loading…
Cancel
Save