|
|
@ -11,6 +11,16 @@ if (!api_is_allowed_to_edit(false, true)) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(); |
|
|
|
$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(); |
|
|
|
|
|
|
|
$allowGroupCategories = 'true' === api_get_setting('allow_group_categories'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$categories = []; |
|
|
|
|
|
|
|
$numberOfGroups = GroupManager::get_number_of_groups() + 1; |
|
|
|
|
|
|
|
if ($allowGroupCategories) { |
|
|
|
|
|
|
|
$groupCategories = GroupManager::get_categories(); |
|
|
|
|
|
|
|
foreach ($groupCategories as $category) { |
|
|
|
|
|
|
|
$categories[$category['iid']] = $category['title']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Create the groups */ |
|
|
|
/* Create the groups */ |
|
|
|
if (isset($_POST['action'])) { |
|
|
|
if (isset($_POST['action'])) { |
|
|
@ -131,12 +141,6 @@ if (isset($_POST['number_of_groups'])) { |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
} |
|
|
|
} |
|
|
|
$group_categories = GroupManager::get_categories(); |
|
|
|
|
|
|
|
$group_id = GroupManager::get_number_of_groups() + 1; |
|
|
|
|
|
|
|
$cat_options = []; |
|
|
|
|
|
|
|
foreach ($group_categories as $index => $category) { |
|
|
|
|
|
|
|
$cat_options[$category['iid']] = $category['title']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq()); |
|
|
|
$form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq()); |
|
|
|
|
|
|
|
|
|
|
|
// Modify the default templates |
|
|
|
// Modify the default templates |
|
|
@ -165,7 +169,7 @@ EOT; |
|
|
|
$group_el = []; |
|
|
|
$group_el = []; |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group name').'</b>'); |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group name').'</b>'); |
|
|
|
|
|
|
|
|
|
|
|
if ('true' === api_get_setting('allow_group_categories')) { |
|
|
|
if ($allowGroupCategories) { |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group category').'</b>'); |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group category').'</b>'); |
|
|
|
} |
|
|
|
} |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('seats (optional)').'</b>'); |
|
|
|
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('seats (optional)').'</b>'); |
|
|
@ -174,7 +178,7 @@ EOT; |
|
|
|
if ($_POST['number_of_groups'] > 1) { |
|
|
|
if ($_POST['number_of_groups'] > 1) { |
|
|
|
$group_el = []; |
|
|
|
$group_el = []; |
|
|
|
$group_el[] = $form->createElement('static', null, null, ' '); |
|
|
|
$group_el[] = $form->createElement('static', null, null, ' '); |
|
|
|
if ('true' === api_get_setting('allow_group_categories')) { |
|
|
|
if ($allowGroupCategories) { |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
'checkbox', |
|
|
|
'checkbox', |
|
|
|
'same_category', |
|
|
|
'same_category', |
|
|
@ -196,17 +200,18 @@ EOT; |
|
|
|
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number++) { |
|
|
|
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number++) { |
|
|
|
$group_el = []; |
|
|
|
$group_el = []; |
|
|
|
$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
|
|
$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
|
|
if ('true' === api_get_setting('allow_group_categories')) { |
|
|
|
if ($allowGroupCategories) { |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
'select', |
|
|
|
'select', |
|
|
|
'group_'.$group_number.'_category', |
|
|
|
'group_'.$group_number.'_category', |
|
|
|
null, |
|
|
|
null, |
|
|
|
$cat_options, |
|
|
|
$categories, |
|
|
|
['id' => 'category_'.$group_number] |
|
|
|
['id' => 'category_'.$group_number] |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$group_el[] = $form->createElement('hidden', 'group_'.$group_number.'_category', 0); |
|
|
|
$group_el[] = $form->createElement('hidden', 'group_'.$group_number.'_category', 0); |
|
|
|
$defaults['group_'.$group_number.'_category'] = array_keys($cat_options)[0]; |
|
|
|
|
|
|
|
|
|
|
|
$defaults['group_'.$group_number.'_category'] = null; |
|
|
|
} |
|
|
|
} |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
$group_el[] = $form->createElement( |
|
|
|
'text', |
|
|
|
'text', |
|
|
@ -216,18 +221,18 @@ EOT; |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($_POST['number_of_groups'] < 10000) { |
|
|
|
if ($_POST['number_of_groups'] < 10000) { |
|
|
|
if ($group_id < 10) { |
|
|
|
if ($numberOfGroups < 10) { |
|
|
|
$prev = '000'; |
|
|
|
$prev = '000'; |
|
|
|
} elseif ($group_id < 100) { |
|
|
|
} elseif ($numberOfGroups < 100) { |
|
|
|
$prev = '00'; |
|
|
|
$prev = '00'; |
|
|
|
} elseif ($group_id < 1000) { |
|
|
|
} elseif ($numberOfGroups < 1000) { |
|
|
|
$prev = '0'; |
|
|
|
$prev = '0'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$prev = ''; |
|
|
|
$prev = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$defaults['group_'.$group_number.'_name'] = get_lang('Group').' '.$prev.$group_id++; |
|
|
|
$defaults['group_'.$group_number.'_name'] = get_lang('Group').' '.$prev.$numberOfGroups++; |
|
|
|
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
|
|
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
|
|
} |
|
|
|
} |
|
|
|
$defaults['action'] = 'create_groups'; |
|
|
|
$defaults['action'] = 'create_groups'; |
|
|
@ -252,7 +257,7 @@ EOT; |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Show form to generate subgroups |
|
|
|
* Show form to generate subgroups |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if ('true' === api_get_setting('allow_group_categories')) { |
|
|
|
if ($allowGroupCategories) { |
|
|
|
$groups = GroupManager::get_group_list(); |
|
|
|
$groups = GroupManager::get_group_list(); |
|
|
|
if (!empty($groups)) { |
|
|
|
if (!empty($groups)) { |
|
|
|
$base_group_options = []; |
|
|
|
$base_group_options = []; |
|
|
@ -260,8 +265,7 @@ EOT; |
|
|
|
$groupId = $group['iid']; |
|
|
|
$groupId = $group['iid']; |
|
|
|
$number_of_students = GroupManager::number_of_students($groupId); |
|
|
|
$number_of_students = GroupManager::number_of_students($groupId); |
|
|
|
if ($number_of_students > 0) { |
|
|
|
if ($number_of_students > 0) { |
|
|
|
$base_group_options[$groupId] = |
|
|
|
$base_group_options[$groupId] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
|
|
$group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/*if (count($base_group_options) > 0) { |
|
|
|
/*if (count($base_group_options) > 0) { |
|
|
@ -320,13 +324,8 @@ EOT; |
|
|
|
|
|
|
|
|
|
|
|
$classForm->addHtml($description); |
|
|
|
$classForm->addHtml($description); |
|
|
|
$classForm->addElement('hidden', 'action'); |
|
|
|
$classForm->addElement('hidden', 'action'); |
|
|
|
if ('true' === api_get_setting('allow_group_categories')) { |
|
|
|
if ($allowGroupCategories) { |
|
|
|
$group_categories = GroupManager :: get_categories(); |
|
|
|
$classForm->addElement('select', 'group_category', null, $categories); |
|
|
|
$cat_options = []; |
|
|
|
|
|
|
|
foreach ($group_categories as $index => $category) { |
|
|
|
|
|
|
|
$cat_options[$category['id']] = $category['title']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$classForm->addElement('select', 'group_category', null, $cat_options); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$classForm->addElement('hidden', 'group_category'); |
|
|
|
$classForm->addElement('hidden', 'group_category'); |
|
|
|
} |
|
|
|
} |
|
|
|