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 */ /* List all categories */
if ('true' === api_get_setting('allow_group_categories')) { if ('true' === api_get_setting('allow_group_categories')) {
$defaultCategory = [ if (empty($categories)) {
'iid' => null, $defaultCategoryId = GroupManager::create_category(
'description' => '', get_lang('Default groups')
'title' => get_lang('Default groups'), );
]; $defaultCategory = GroupManager::get_category($defaultCategoryId);
$categories = array_merge([$defaultCategory], $categories); $categories = [$defaultCategory];
}
$course = api_get_course_entity(); $course = api_get_course_entity();
foreach ($categories as $index => $category) { foreach ($categories as $index => $category) {
$categoryId = $category['iid']; $categoryId = $category['iid'];
@ -264,13 +265,15 @@ if ('true' === api_get_setting('allow_group_categories')) {
// Edit // Edit
$actions .= '<a $actions .= '<a
href="group_category.php?'.api_get_cidreq().'&id='.$categoryId.'" title="'.get_lang('Edit').'">'. 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 // Delete
$actions .= Display::url( $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, '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;', '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 { } else {
// Create a new category // Create a new category
$action = 'add_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); $form->addElement('header', $nameTools);
@ -436,7 +440,7 @@ if ($form->validate()) {
// Else display the form // Else display the form
Display::display_header($nameTools, 'Group'); 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>'; Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back to Groups list')).'</a>';
echo Display::toolbarAction('toolbar', [$actions]); echo Display::toolbarAction('toolbar', [$actions]);

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

Loading…
Cancel
Save