pull/6055/merge
Estéban Ristich 7 months ago committed by GitHub
commit c6db42062a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      public/main/group/group.php
  2. 8
      public/main/group/group_category.php
  3. 14
      public/main/inc/lib/groupmanager.lib.php

@ -234,12 +234,13 @@ echo UserManager::getUserSubscriptionTab(3);
/* List all categories */
if ('true' === api_get_setting('allow_group_categories')) {
$defaultCategory = [
'iid' => null,
'description' => '',
'title' => get_lang('Default groups'),
];
$categories = array_merge([$defaultCategory], $categories);
if (empty($categories)) {
$defaultCategoryId = GroupManager::create_category(
get_lang('Default groups')
);
$defaultCategory = GroupManager::get_category($defaultCategoryId);
$categories = [$defaultCategory];
}
$course = api_get_course_entity();
foreach ($categories as $index => $category) {
$categoryId = $category['iid'];
@ -264,13 +265,15 @@ if ('true' === api_get_setting('allow_group_categories')) {
// Edit
$actions .= '<a
href="group_category.php?'.api_get_cidreq().'&id='.$categoryId.'" title="'.get_lang('Edit').'">'.
Display::getMdiIcon('edit', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit this category')).'</a>';
Display::getMdiIcon('pencil', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit this category')).'</a>';
// Delete
$actions .= Display::url(
Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete')),
Display::getMdiIcon(ActionIcon::DELETE, count($categories) == 1 ? 'ch-tool-icon-disabled' : 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete')),
'group.php?'.api_get_cidreq().'&action=delete_category&category_id='.$categoryId,
[
count($categories) == 1 ? [
'onclick' => 'javascript:alert('."'".addslashes(api_htmlentities(get_lang('You cannot delete the last category'), ENT_QUOTES))."'".'); return false;',
] : [
'onclick' => 'javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;',
]
);

@ -103,7 +103,11 @@ if (isset($_GET['id'])) {
} else {
// Create a new category
$action = 'add_category';
$form = new FormValidator('group_category');
$form = new FormValidator(
'group_category',
'post',
api_get_self().'?'.api_get_cidreq()
);
}
$form->addElement('header', $nameTools);
@ -436,7 +440,7 @@ if ($form->validate()) {
// Else display the form
Display::display_header($nameTools, 'Group');
$actions = '<a href="group.php">'.
$actions = '<a href="group.php?'.api_get_cidreq().'">'.
Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back to Groups list')).'</a>';
echo Display::toolbarAction('toolbar', [$actions]);

@ -889,13 +889,13 @@ class GroupManager
*/
public static function create_category(
$title,
$description,
$docState,
$workState,
$calendarState,
$anonuncementState,
$forumState,
$wikiState,
$description = '',
$docState = 1,
$workState = 1,
$calendarState = 1,
$anonuncementState = 1,
$forumState = 1,
$wikiState = 1,
$chatState = 1,
$selfRegistrationAllowed = 0,
$selfUnRegistrationAllowed = 0,

Loading…
Cancel
Save