1313
1414class SettingsCurrentFixtures extends Fixture implements FixtureGroupInterface
1515{
16+ /**
17+ * Settings candidates that must be locked at URL-level (access_url_locked = 1),
18+ * based on the task list.
19+ */
20+ private const ACCESS_URL_LOCKED_YES = [
21+ 'permissions_for_new_directories ' ,
22+ 'permissions_for_new_files ' ,
23+ 'course_creation_form_set_extra_fields_mandatory ' ,
24+ 'access_url_specific_files ' ,
25+ 'cron_remind_course_finished_activate ' ,
26+ 'cron_remind_course_expiration_frequency ' ,
27+ 'cron_remind_course_expiration_activate ' ,
28+ 'donotlistcampus ' ,
29+ 'server_type ' ,
30+ 'chamilo_database_version ' ,
31+ 'unoconv_binaries ' ,
32+ 'session_admin_access_to_all_users_on_all_urls ' ,
33+ 'split_users_upload_directory ' ,
34+ 'multiple_url_hide_disabled_settings ' ,
35+ 'login_is_email ' ,
36+ 'proxy_settings ' ,
37+ 'login_max_attempt_before_blocking_account ' ,
38+ 'permanently_remove_deleted_files ' ,
39+ 'allow_use_sub_language ' ,
40+ ];
41+
42+ /**
43+ * Settings candidates explicitly mentioned as "no" in the task list.
44+ * We set them to access_url_locked = 0, but only for this candidate list.
45+ */
46+ private const ACCESS_URL_LOCKED_NO = [
47+ 'drh_allow_access_to_all_students ' ,
48+ 'ticket_allow_category_edition ' ,
49+ 'max_anonymous_users ' ,
50+ 'enable_x_sendfile_headers ' ,
51+ 'mailer_dsn ' ,
52+ 'allow_send_message_to_all_platform_users ' ,
53+ 'message_max_upload_filesize ' ,
54+ 'use_custom_pages ' ,
55+ 'security_strict_transport ' ,
56+ 'security_content_policy ' ,
57+ 'security_content_policy_report_only ' ,
58+ 'security_public_key_pins ' ,
59+ 'security_public_key_pins_report_only ' ,
60+ 'security_x_frame_options ' ,
61+ 'security_xss_protection ' ,
62+ 'security_x_content_type_options ' ,
63+ 'security_referrer_policy ' ,
64+ 'security_session_cookie_samesite_none ' ,
65+ 'allow_session_admins_to_manage_all_sessions ' ,
66+ 'prevent_session_admins_to_manage_all_users ' ,
67+ 'session_admins_edit_courses_content ' ,
68+ 'assignment_base_course_teacher_access_to_all_session ' ,
69+ ];
70+
1671 public static function getGroups (): array
1772 {
1873 return ['settings-update ' ];
1974 }
2075
2176 public function load (ObjectManager $ manager ): void
2277 {
78+ $ repo = $ manager ->getRepository (SettingsCurrent::class);
79+
2380 $ existingSettings = $ this ->flattenConfigurationSettings (self ::getExistingSettings ());
2481 $ newConfigurationSettings = $ this ->flattenConfigurationSettings (self ::getNewConfigurationSettings ());
2582
2683 $ allConfigurations = array_merge ($ existingSettings , $ newConfigurationSettings );
2784
85+ // Keep current behavior: update title/comment from configuration arrays.
2886 foreach ($ allConfigurations as $ settingData ) {
29- $ setting = $ manager -> getRepository (SettingsCurrent::class) ->findOneBy (['variable ' => $ settingData ['name ' ]]);
87+ $ setting = $ repo ->findOneBy (['variable ' => $ settingData ['name ' ]]);
3088
3189 if (!$ setting ) {
3290 continue ;
@@ -38,6 +96,34 @@ public function load(ObjectManager $manager): void
3896 $ manager ->persist ($ setting );
3997 }
4098
99+ // Reset all task candidates to access_url_locked = 0 (deterministic baseline).
100+ $ candidates = array_values (array_unique (array_merge (
101+ self ::ACCESS_URL_LOCKED_YES ,
102+ self ::ACCESS_URL_LOCKED_NO
103+ )));
104+
105+ /** @var SettingsCurrent[] $candidateSettings */
106+ $ candidateSettings = $ repo ->findBy (['variable ' => $ candidates ]);
107+
108+ // Index by variable to avoid extra queries.
109+ $ byVariable = [];
110+ foreach ($ candidateSettings as $ setting ) {
111+ $ byVariable [$ setting ->getVariable ()] = $ setting ;
112+
113+ $ setting ->setAccessUrlLocked (0 );
114+ $ manager ->persist ($ setting );
115+ }
116+
117+ // Apply access_url_locked = 1 for the explicit YES list.
118+ foreach (self ::ACCESS_URL_LOCKED_YES as $ variable ) {
119+ if (!isset ($ byVariable [$ variable ])) {
120+ continue ;
121+ }
122+
123+ $ byVariable [$ variable ]->setAccessUrlLocked (1 );
124+ $ manager ->persist ($ byVariable [$ variable ]);
125+ }
126+
41127 $ manager ->flush ();
42128 }
43129
0 commit comments