Skip to content

Commit 2aa0c9e

Browse files
committed
Merge branch 'master' of github.com:chamilo/chamilo-lms
2 parents 9c235f2 + 16a0e6e commit 2aa0c9e

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

public/main/auth/courses.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
api_block_anonymous_users();
2323
}
2424

25-
$allowExtraFields = !empty(api_get_setting('catalog.course_catalog_settings'));
25+
$catalogSettings = api_get_setting('catalog.course_catalog_settings');
26+
$allowExtraFields = !empty($catalogSettings['extra_fields_in_search_form']);
2627

2728
// For students
2829
$userCanViewPage = true;

src/CoreBundle/Controller/CatalogueController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function listSessions(): JsonResponse
179179
#[Route('/course-extra-fields', name: 'chamilo_core_catalogue_course_extra_fields', methods: ['GET'])]
180180
public function getCourseExtraFields(SettingsManager $settingsManager): JsonResponse
181181
{
182-
if (empty($settingsManager->getSetting('catalog.course_catalog_settings'))) {
182+
if (empty($settingsManager->getSetting('catalog.course_catalog_settings')['extra_fields_in_search_form'])) {
183183
return $this->json([]);
184184
}
185185

src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,8 @@ public static function getNewConfigurationSettings(): array
15431543
],
15441544
[
15451545
'name' => 'only_show_course_from_selected_category',
1546-
'title' => 'Only Selected Category',
1547-
'comment' => 'Show only courses from a specific selected category.',
1546+
'title' => 'Only show matching categories in courses catalogue',
1547+
'comment' => 'When not empty, only the courses from the given categories will appear in the courses catalogue.',
15481548
],
15491549
[
15501550
'name' => 'allow_students_to_browse_courses',

src/CoreBundle/DataFixtures/SettingsValueTemplateFixtures.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public static function getTemplatesGrouped(): array
2929
{
3030
return [
3131
'catalog' => [
32+
[
33+
'variable' => 'only_show_course_from_selected_category',
34+
'json_example' => ['Cat1', 'Cat2'],
35+
],
3236
[
3337
'variable' => 'course_catalog_settings',
3438
'json_example' => [

src/CoreBundle/Migrations/Schema/V200/Version20250724180700.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function up(Schema $schema): void
7272
],
7373
[
7474
'variable' => 'only_show_course_from_selected_category',
75-
'selected_value' => 'false',
76-
'title' => 'Only Selected Category',
77-
'comment' => 'Show only courses from a specific selected category.',
75+
'selected_value' => '',
76+
'title' => 'Only show matching categories in courses catalogue',
77+
'comment' => 'When not empty, only the courses from the given categories will appear in the courses catalogue.',
7878
'category' => 'catalog',
7979
],
8080
[

src/CoreBundle/Settings/CatalogSettingsSchema.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Chamilo\CoreBundle\Settings;
88

99
use Chamilo\CoreBundle\Form\Type\YesNoType;
10+
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
1011
use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder;
1112
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
1213
use Symfony\Component\Form\FormBuilderInterface;
@@ -20,13 +21,13 @@ public function buildSettings(AbstractSettingsBuilder $builder): void
2021
'session_catalog_settings' => '',
2122
'show_courses_descriptions_in_catalog' => 'false',
2223
'course_catalog_published' => 'false',
23-
'course_catalog_display_in_home' => 'true',
24+
'course_catalog_display_in_home' => 'false',
2425
'hide_public_link' => 'false',
2526
'only_show_selected_courses' => 'false',
26-
'only_show_course_from_selected_category' => 'false',
27+
'only_show_course_from_selected_category' => '',
2728
'allow_students_to_browse_courses' => 'true',
2829
'course_catalog_hide_private' => 'true',
29-
'show_courses_sessions' => 'true',
30+
'show_courses_sessions' => '0',
3031
'allow_session_auto_subscription' => 'false',
3132
'course_subscription_in_user_s_session' => 'false',
3233
]);
@@ -52,10 +53,23 @@ public function buildForm(FormBuilderInterface $builder): void
5253
->add('course_catalog_display_in_home', YesNoType::class)
5354
->add('hide_public_link', YesNoType::class)
5455
->add('only_show_selected_courses', YesNoType::class)
55-
->add('only_show_course_from_selected_category', YesNoType::class)
56+
->add('only_show_course_from_selected_category', TextareaType::class, [
57+
'attr' => ['rows' => 3, 'style' => 'font-family: monospace;'],
58+
])
5659
->add('allow_students_to_browse_courses', YesNoType::class)
5760
->add('course_catalog_hide_private', YesNoType::class)
58-
->add('show_courses_sessions', YesNoType::class)
61+
->add(
62+
'show_courses_sessions',
63+
ChoiceType::class,
64+
[
65+
'choices' => [
66+
'Hide catalogue' => '-1',
67+
'Show only courses' => '0',
68+
'Show only sessions' => '1',
69+
'Show courses & sessions' => '2',
70+
],
71+
],
72+
)
5973
->add('allow_session_auto_subscription', YesNoType::class)
6074
->add('course_subscription_in_user_s_session', YesNoType::class);
6175

src/CoreBundle/State/PublicCatalogueCourseStateProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
4545
}
4646

4747
$onlyShowMatching = 'true' === $this->settingsManager->getSetting('catalog.only_show_selected_courses', true);
48-
$onlyShowCoursesWithCategory = 'true' === $this->settingsManager->getSetting('catalog.only_show_course_from_selected_category', true);
48+
$onlyShowCoursesWithCategory = $this->settingsManager->getSetting('catalog.only_show_course_from_selected_category', true);
4949

5050
$request = $this->requestStack->getCurrentRequest();
5151
if (!$request) {

0 commit comments

Comments
 (0)