Completed
Push — 1.10.x ( 2635b5...f0080b )
by Yannick
165:55 queued 120:08
created

Version20150522222222   B

Complexity

Total Complexity 49

Size/Duplication

Total Lines 809
Duplicated Lines 1.73 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 14
loc 809
rs 8
c 0
b 0
f 0
wmc 49
lcom 1
cbo 3

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Version20150522222222 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Version20150522222222, and based on these observations, apply Extract Interface, too.

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Application\Migrations\Schema\V110;
5
6
use Application\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
9
/**
10
 * Class Version20150522222222
11
 * @package Application\Migrations\Schema\V11010
12
 */
13
class Version20150522222222 extends AbstractMigrationChamilo
14
{
15
    /**
16
     * @param Schema $schema
17
     */
18
    public function up(Schema $schema)
19
    {
20
        // The first ALTER queries here requires a check because the field might already exist
21
        $connection = $this->connection;
22
        $fieldExists = false;
23
        $sql = "SELECT *
24
                FROM user
25
                LIMIT 1";
26
        $result = $connection->executeQuery($sql);
27
        $dataList = $result->fetchAll();
28
        if (!empty($dataList)) {
29
            foreach ($dataList as $data) {
30
                if (isset($data['last_login'])) {
31
                    $fieldExists = true;
32
                }
33
            }
34
        }
35
        if (!$fieldExists) {
36
            $this->addSql('ALTER TABLE user ADD COLUMN last_login datetime DEFAULT NULL');
37
        }
38
        // calendar events comments
39
        $fieldExists = false;
40
        $sql = "SELECT *
41
                FROM c_calendar_event
42
                LIMIT 1";
43
        $result = $connection->executeQuery($sql);
44
        $dataList = $result->fetchAll();
45
        if (!empty($dataList)) {
46
            foreach ($dataList as $data) {
47
                if (isset($data['comment'])) {
48
                    $fieldExists = true;
49
                }
50
            }
51
        }
52
        if (!$fieldExists) {
53
            $this->addSql("ALTER TABLE c_calendar_event ADD COLUMN comment TEXT");
54
        }
55
56
        // Move some settings from configuration.php to the database
57
        // Current settings categories are:
58
        // Platform, Course, Session, Languages, User, Tools, Editor, Security,
59
        // Tuning, Gradebook, Timezones, Tracking, Search, stylesheets (lowercase),
60
        // LDAP, CAS, Shibboleth, Facebook
61
62
        // Allow select the return link in the LP view
63
        $value = $this->getConfigurationValue('allow_lp_return_link');
64
        $this->addSettingCurrent(
65
            'allow_lp_return_link',
66
            '',
67
            'radio',
68
            'Course',
69
            ($value?$value:'true'),
70
            'AllowLearningPathReturnLinkTitle',
71
            'AllowLearningPathReturnLinkComment',
72
            null,
73
            '',
74
            1,
75
            true,
76
            false,
77
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
78
        );
79
80
        // If true the export link is blocked.
81
        $value = $this->getConfigurationValue('hide_scorm_export_link');
82
        $this->addSettingCurrent(
83
            'hide_scorm_export_link',
84
            '',
85
            'radio',
86
            'Course',
87
            ($value?$value:'false'),
88
            'HideScormExportLinkTitle',
89
            'HideScormExportLinkComment',
90
            null,
91
            '',
92
            1,
93
            true,
94
            false,
95
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
96
        );
97
98
        // If true the copy link is blocked.
99
        //$_configuration['hide_scorm_copy_link'] = false;
100
        $value = $this->getConfigurationValue('hide_scorm_copy_link');
101
        $this->addSettingCurrent(
102
            'hide_scorm_copy_link',
103
            '',
104
            'radio',
105
            'Course',
106
            ($value?$value:'false'),
107
            'HideScormCopyLinkTitle',
108
            'HideScormCopyLinkComment',
109
            null,
110
            '',
111
            1,
112
            true,
113
            false,
114
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
115
        );
116
117
        // If true the pdf export link is blocked.
118
        //$_configuration['hide_scorm_pdf_link'] = false;
119
        $value = $this->getConfigurationValue('hide_scorm_pdf_link');
120
        $this->addSettingCurrent(
121
            'hide_scorm_pdf_link',
122
            '',
123
            'radio',
124
            'Course',
125
            ($value?$value:'false'),
126
            'HideScormPdfLinkTitle',
127
            'HideScormPdfLinkComment',
128
            null,
129
            '',
130
            1,
131
            true,
132
            false,
133
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
134
        );
135
136
        // Default session days before coach access
137
        //$_configuration['session_days_before_coach_access'] = 0;
138
        $value = $this->getConfigurationValue('session_days_before_coach_access');
139
        $this->addSettingCurrent(
140
            'session_days_before_coach_access',
141
            '',
142
            'textfield',
143
            'Session',
144
            ($value?$value:'0'),
145
            'SessionDaysBeforeCoachAccessTitle',
146
            'SessionDaysBeforeCoachAccessComment',
147
            null,
148
            '',
149
            1,
150
            true,
151
            false
152
        );
153
154
155
        // Default session days after coach access
156
        //$_configuration['session_days_after_coach_access'] = 0;
157
        $value = $this->getConfigurationValue('session_days_after_coach_access');
158
        $this->addSettingCurrent(
159
            'session_days_after_coach_access',
160
            '',
161
            'textfield',
162
            'Session',
163
            ($value?$value:'0'),
164
            'SessionDaysAfterCoachAccessTitle',
165
            'SessionDaysAfterCoachAccessComment',
166
            null,
167
            '',
168
            1,
169
            true,
170
            false
171
        );
172
173
        // PDF Logo header in app/Resources/public/css/themes/xxx/images/pdf_logo_header.png
174
        //$_configuration['pdf_logo_header'] = false;
175
        $value = $this->getConfigurationValue('pdf_logo_header');
176
        $this->addSettingCurrent(
177
            'pdf_logo_header',
178
            '',
179
            'radio',
180
            'Course',
181
            ($value?$value:'false'),
182
            'PdfLogoHeaderTitle',
183
            'PdfLogoHeaderComment',
184
            null,
185
            '',
186
            1,
187
            true,
188
            false,
189
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
190
        );
191
192
        // Order inscription user list by official_code
193
        //$_configuration['order_user_list_by_official_code'] = false;
194
        $value = $this->getConfigurationValue('order_user_list_by_official_code');
195
        $this->addSettingCurrent(
196
            'order_user_list_by_official_code',
197
            '',
198
            'radio',
199
            'Platform',
200
            ($value?$value:'false'),
201
            'OrderUserListByOfficialCodeTitle',
202
            'OrderUserListByOfficialCodeComment',
203
            null,
204
            '',
205
            1,
206
            true,
207
            false,
208
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
209
        );
210
211
        // Default course setting "email_alert_manager_on_new_quiz"
212
        //$_configuration['email_alert_manager_on_new_quiz'] = 1;
213
        $value = $this->getConfigurationValue('email_alert_manager_on_new_quiz');
214
        $this->addSettingCurrent(
215
            'email_alert_manager_on_new_quiz',
216
            '',
217
            'radio',
218
            'Course',
219
            ($value?$value:'true'),
220
            'AlertManagerOnNewQuizTitle',
221
            'AlertManagerOnNewQuizComment',
222
            null,
223
            '',
224
            1,
225
            true,
226
            false,
227
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
228
        );
229
230
        // Show official code in exercise report list.
231
        //$_configuration['show_official_code_exercise_result_list'] = false;
232
        $value = $this->getConfigurationValue('show_official_code_exercise_result_list');
233
        $this->addSettingCurrent(
234
            'show_official_code_exercise_result_list',
235
            '',
236
            'radio',
237
            'Tools',
238
            ($value?$value:'false'),
239
            'ShowOfficialCodeInExerciseResultListTitle',
240
            'ShowOfficialCodeInExerciseResultListComment',
241
            null,
242
            '',
243
            1,
244
            true,
245
            false,
246
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
247
        );
248
249
250
        // Hide private courses from course catalog
251
        //$_configuration['course_catalog_hide_private'] = false;
252
        $value = $this->getConfigurationValue('course_catalog_hide_private');
253
        $this->addSettingCurrent(
254
            'course_catalog_hide_private',
255
            '',
256
            'radio',
257
            'Platform',
258
            ($value?$value:'false'),
259
            'HidePrivateCoursesFromCourseCatalogTitle',
260
            'HidePrivateCoursesFromCourseCatalogComment',
261
            null,
262
            '',
263
            1,
264
            true,
265
            false,
266
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
267
        );
268
269
        // Display sessions catalog
270
        // 0 = show only courses; 1 = show only sessions; 2 = show courses and sessions
271
        //$_configuration['catalog_show_courses_sessions'] = 0;
272
        $value = $this->getConfigurationValue('catalog_show_courses_sessions');
273
        $this->addSettingCurrent(
274
            'catalog_show_courses_sessions',
275
            '',
276
            'radio',
277
            'Platform',
278
            ($value?$value:'0'),
279
            'CoursesCatalogueShowSessionsTitle',
280
            'CoursesCatalogueShowSessionsComment',
281
            null,
282
            '',
283
            1,
284
            true,
285
            false,
286
            [0 => ['value' => '0', 'text' => 'CatalogueShowOnlyCourses'], 1 => ['value' => '1', 'text' => 'CatalogueShowOnlySessions'], 2 => ['value' => '2', 'text' => 'CatalogueShowCoursesAndSessions']]
287
        );
288
289
        // Auto detect language custom pages.
290
        // $_configuration['auto_detect_language_custom_pages'] = true;
291
        $value = $this->getConfigurationValue('auto_detect_language_custom_pages');
292
        $this->addSettingCurrent(
293
            'auto_detect_language_custom_pages',
294
            '',
295
            'radio',
296
            'Platform',
297
            ($value?$value:'true'),
298
            'AutoDetectLanguageCustomPagesTitle',
299
            'AutoDetectLanguageCustomPagesComment',
300
            null,
301
            '',
302
            1,
303
            true,
304
            false,
305
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
306
        );
307
308
        // Show reduce LP report
309
        //$_configuration['lp_show_reduced_report'] = false;
310
        $value = $this->getConfigurationValue('lp_show_reduced_report');
311
        $this->addSettingCurrent(
312
            'lp_show_reduced_report',
313
            '',
314
            'radio',
315
            'Tools',
316
            ($value?$value:'false'),
317
            'LearningPathShowReducedReportTitle',
318
            'LearningPathShowReducedReportComment',
319
            null,
320
            '',
321
            1,
322
            true,
323
            false,
324
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
325
        );
326
327
        //Allow session-to-session copy
328
        //$_configuration['allow_session_course_copy_for_teachers'] = true;
329
        $value = $this->getConfigurationValue('allow_session_course_copy_for_teachers');
330
        $this->addSettingCurrent(
331
            'allow_session_course_copy_for_teachers',
332
            '',
333
            'radio',
334
            'Session',
335
            ($value?$value:'false'),
336
            'AllowSessionCourseCopyForTeachersTitle',
337
            'AllowSessionCourseCopyForTeachersComment',
338
            null,
339
            '',
340
            1,
341
            true,
342
            false,
343
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
344
        );
345
346
        // Hide the logout button
347
        //$_configuration['hide_logout_button'] = true;
348
        $value = $this->getConfigurationValue('hide_logout_button');
349
        $this->addSettingCurrent(
350
            'hide_logout_button',
351
            '',
352
            'radio',
353
            'Security',
354
            ($value?$value:'false'),
355
            'HideLogoutButtonTitle',
356
            'HideLogoutButtonComment',
357
            null,
358
            '',
359
            1,
360
            true,
361
            false,
362
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
363
        );
364
365
        // Prevent redirecting admin to admin page
366
        //$_configuration['redirect_admin_to_courses_list'] = true;
367
        $value = $this->getConfigurationValue('redirect_admin_to_courses_list');
368
        $this->addSettingCurrent(
369
            'redirect_admin_to_courses_list',
370
            '',
371
            'radio',
372
            'Platform',
373
            ($value?$value:'false'),
374
            'RedirectAdminToCoursesListTitle',
375
            'RedirectAdminToCoursesListComment',
376
            null,
377
            '',
378
            1,
379
            true,
380
            false,
381
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
382
        );
383
384
        // Shows the custom course icon instead of the classic green board icon
385
        //$_configuration['course_images_in_courses_list'] = false;
386
        $value = $this->getConfigurationValue('course_images_in_courses_list');
387
        $this->addSettingCurrent(
388
            'course_images_in_courses_list',
389
            '',
390
            'radio',
391
            'Course',
392
            ($value?$value:'false'),
393
            'CourseImagesInCoursesListTitle',
394
            'CourseImagesInCoursesListComment',
395
            null,
396
            '',
397
            1,
398
            true,
399
            false,
400
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
401
        );
402
403
        // Which student publication will be taken when connected to the gradebook: first|last
404
        //$_configuration['student_publication_to_take_in_gradebook'] = 'first';
405
        $value = $this->getConfigurationValue('student_publication_to_take_in_gradebook');
406
        $this->addSettingCurrent(
407
            'student_publication_to_take_in_gradebook',
408
            '',
409
            'radio',
410
            'Gradebook',
411
            ($value?$value:'first'),
412
            'StudentPublicationSelectionForGradebookTitle',
413
            'StudentPublicationSelectionForGradebookComment',
414
            null,
415
            '',
416
            1,
417
            true,
418
            false,
419
            [0 => ['value' => 'first', 'text' => 'First'], 1 => ['value' => 'last', 'text' => 'Last']]
420
        );
421
422
        // Show a filter by official code
423
        //$_configuration['certificate_filter_by_official_code'] = false;
424
        $value = $this->getConfigurationValue('certificate_filter_by_official_code');
425
        $this->addSettingCurrent(
426
            'certificate_filter_by_official_code',
427
            '',
428
            'radio',
429
            'Gradebook',
430
            ($value?$value:'false'),
431
            'FilterCertificateByOfficialCodeTitle',
432
            'FilterCertificateByOfficialCodeComment',
433
            null,
434
            '',
435
            1,
436
            true,
437
            false,
438
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
439
        );
440
441
        // Max quantity of fkceditor allowed in the exercise result page otherwise
442
        // Textareas are used.
443
        //$_configuration['exercise_max_ckeditors_in_page'] = 0;
444
        $value = $this->getConfigurationValue('exercise_max_ckeditors_in_page');
445
        $this->addSettingCurrent(
446
            'exercise_max_ckeditors_in_page',
447
            '',
448
            'textfield',
449
            'Tools',
450
            ($value?$value:'0'),
451
            'MaxCKeditorsOnExerciseResultsPageTitle',
452
            'MaxCKeditorsOnExerciseResultsPageComment',
453
            null,
454
            '',
455
            1,
456
            true,
457
            false,
458
            array()
459
        );
460
461
        // Default upload option
462
        //$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite
463
        $value = $this->getConfigurationValue('document_if_file_exists_option');
464
        $this->addSettingCurrent(
465
            'document_if_file_exists_option',
466
            '',
467
            'radio',
468
            'Tools',
469
            ($value?$value:'rename'),
470
            'DocumentDefaultOptionIfFileExistsTitle',
471
            'DocumentDefaultOptionIfFileExistsComment',
472
            null,
473
            '',
474
            1,
475
            true,
476
            false,
477
            [0 => ['value' => 'rename', 'text' => 'Rename'], 1 => ['value' => 'overwrite', 'text' => 'Overwrite']]
478
        );
479
        // Enable add_gradebook_certificates.php cron task
480
        //$_configuration['add_gradebook_certificates_cron_task_enabled'] = true;
481
        $value = $this->getConfigurationValue('add_gradebook_certificates_cron_task_enabled');
482
        $this->addSettingCurrent(
483
            'add_gradebook_certificates_cron_task_enabled',
484
            '',
485
            'radio',
486
            'Tools',
487
            ($value?$value:'false'),
488
            'GradebookCronTaskGenerationTitle',
489
            'GradebookCronTaskGenerationComment',
490
            null,
491
            '',
492
            1,
493
            true,
494
            false,
495
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
496
        );
497
498
        // Which OpenBadges backpack send the badges
499
        //$_configuration['openbadges_backpack'] = 'https://backpack.openbadges.org/';
500
        $value = $this->getConfigurationValue('openbadges_backpack');
501
        $this->addSettingCurrent(
502
            'openbadges_backpack',
503
            '',
504
            'textfield',
505
            'Gradebook',
506
            ($value?$value:'https://backpack.openbadges.org/'),
507
            'OpenBadgesBackpackUrlTitle',
508
            'OpenBadgesBackpackUrlComment',
509
            null,
510
            '',
511
            1,
512
            true,
513
            false,
514
            []
515
        );
516
517
        // Shows a warning message explaining that the site uses cookies
518
        //$_configuration['cookie_warning'] = false;
519
        $value = $this->getConfigurationValue('cookie_warning');
520
        $this->addSettingCurrent(
521
            'cookie_warning',
522
            '',
523
            'radio',
524
            'Tools',
525
            ($value?$value:'false'),
526
            'CookieWarningTitle',
527
            'CookieWarningComment',
528
            null,
529
            '',
530
            1,
531
            true,
532
            false,
533
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
534
        );
535
536
        // If there are any tool available and the user is not registered hide the group
537
        //$_configuration['hide_course_group_if_no_tools_available'] = false;
538
        $value = $this->getConfigurationValue('hide_course_group_if_no_tools_available');
539
        $this->addSettingCurrent(
540
            'hide_course_group_if_no_tools_available',
541
            '',
542
            'radio',
543
            'Tools',
544
            ($value?$value:'false'),
545
            'HideCourseGroupIfNoToolAvailableTitle',
546
            'HideCourseGroupIfNoToolAvailableComment',
547
            null,
548
            '',
549
            1,
550
            true,
551
            false,
552
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
553
        );
554
555
        // Allow student to enroll into a session without an approval needing
556
        //$_configuration['catalog_allow_session_auto_subscription'] = false;
557
        $value = $this->getConfigurationValue('catalog_allow_session_auto_subscription');
558
        $this->addSettingCurrent(
559
            'catalog_allow_session_auto_subscription',
560
            '',
561
            'radio',
562
            'Session',
563
            ($value?$value:'false'),
564
            'CatalogueAllowSessionAutoSubscriptionTitle',
565
            'CatalogueAllowSessionAutoSubscriptionComment',
566
            null,
567
            '',
568
            1,
569
            true,
570
            false,
571
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
572
        );
573
574
        // Decode UTF-8 from Web Services (option passed to SOAP)
575
        //$_configuration['registration.soap.php.decode_utf8'] = false;
576
        $value = $this->getConfigurationValue('registration.soap.php.decode_utf8');
577
        $this->addSettingCurrent(
578
            'registration.soap.php.decode_utf8',
579
            '',
580
            'radio',
581
            'Platform',
582
            ($value?$value:'false'),
583
            'SoapRegistrationDecodeUtf8Title',
584
            'SoapRegistrationDecodeUtf8Comment',
585
            null,
586
            '',
587
            1,
588
            true,
589
            false,
590
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
591
        );
592
593
        // Show delete option in attendance
594
        //$_configuration['allow_delete_attendance'] = false;
595
        $value = $this->getConfigurationValue('allow_delete_attendance');
596
        $this->addSettingCurrent(
597
            'allow_delete_attendance',
598
            '',
599
            'radio',
600
            'Tools',
601
            ($value?$value:'false'),
602
            'AttendanceDeletionEnableTitle',
603
            'AttendanceDeletionEnableComment',
604
            null,
605
            '',
606
            1,
607
            true,
608
            false,
609
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
610
        );
611
612
        // Enable Gravatar profile image if no local image has been given
613
        //$_configuration['gravatar_enabled'] = true;
614
        $value = $this->getConfigurationValue('gravatar_enabled');
615
        $this->addSettingCurrent(
616
            'gravatar_enabled',
617
            '',
618
            'radio',
619
            'Platform',
620
            ($value?$value:'false'),
621
            'GravatarPicturesTitle',
622
            'GravatarPicturesComment',
623
            null,
624
            '',
625
            1,
626
            true,
627
            false,
628
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
629
        );
630
631
        // If Gravatar is enabled, tells which type of picture we want (default is "mm").
632
        // Options: mm | identicon | monsterid | wavatar
633
        //$_configuration['gravatar_type'] = 'mm';
634
        $value = $this->getConfigurationValue('gravatar_type');
635
        $this->addSettingCurrent(
636
            'gravatar_type',
637
            '',
638
            'radio',
639
            'Platform',
640
            ($value?$value:'mm'),
641
            'GravatarPicturesTypeTitle',
642
            'GravatarPicturesTypeComment',
643
            null,
644
            '',
645
            1,
646
            true,
647
            false,
648
            [
649
                0 => ['value' => 'mm', 'text' => 'mystery-man'],
650
                1 => ['value' => 'identicon', 'text' => 'identicon'],
651
                2 => ['value' => 'monsterid', 'text' => 'monsterid'],
652
                3 => ['value' => 'wavatar', 'text' => 'wavatar']
653
            ]
654
        );
655
656
        // Limit for the Session Admin role. The administration page show only
657
        // User block -> Add user
658
        // Course Sessions block -> Training session list
659
        //$_configuration['limit_session_admin_role'] = false;
660
        $value = $this->getConfigurationValue('limit_session_admin_role');
661
        $this->addSettingCurrent(
662
            'limit_session_admin_role',
663
            '',
664
            'radio',
665
            'Session',
666
            ($value?$value:'false'),
667
            'SessionAdminPermissionsLimitTitle',
668
            'SessionAdminPermissionsLimitComment',
669
            null,
670
            '',
671
            1,
672
            true,
673
            false,
674
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
675
        );
676
677
        // Show session description
678
        //$_configuration['show_session_description'] = false;
679
        $value = $this->getConfigurationValue('show_session_description');
680
        $this->addSettingCurrent(
681
            'show_session_description',
682
            '',
683
            'radio',
684
            'Session',
685
            ($value?$value:'false'),
686
            'ShowSessionDescriptionTitle',
687
            'ShowSessionDescriptionComment',
688
            null,
689
            '',
690
            1,
691
            true,
692
            false,
693
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
694
        );
695
696
        // Hide only for students the link to export certificates to PDF
697
        //$_configuration['hide_certificate_export_link_students'] = false;
698
        $value = $this->getConfigurationValue('hide_certificate_export_link_students');
699
        $this->addSettingCurrent(
700
            'hide_certificate_export_link_students',
701
            '',
702
            'radio',
703
            'Gradebook',
704
            ($value?$value:'false'),
705
            'CertificateHideExportLinkStudentTitle',
706
            'CertificateHideExportLinkStudentComment',
707
            null,
708
            '',
709
            1,
710
            true,
711
            false,
712
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
713
        );
714
715
        // Hide for all user roles the link to export certificates to PDF
716
        //$_configuration['hide_certificate_export_link'] = false;
717
        $value = $this->getConfigurationValue('hide_certificate_export_link');
718
        $this->addSettingCurrent(
719
            'hide_certificate_export_link',
720
            '',
721
            'radio',
722
            'Gradebook',
723
            ($value?$value:'false'),
724
            'CertificateHideExportLinkTitle',
725
            'CertificateHideExportLinkComment',
726
            null,
727
            '',
728
            1,
729
            true,
730
            false,
731
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
732
        );
733
734
        // Hide session course coach in dropbox sent to user list
735
        //$_configuration['dropbox_hide_course_coach'] = false;
736
        $value = $this->getConfigurationValue('dropbox_hide_course_coach');
737
        $this->addSettingCurrent(
738
            'dropbox_hide_course_coach',
739
            '',
740
            'radio',
741
            'Tools',
742
            ($value ? $value : 'false'),
743
            'DropboxHideCourseCoachTitle',
744
            'DropboxHideCourseCoachComment',
745
            null,
746
            '',
747
            1,
748
            true,
749
            false,
750
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
751
        );
752
753
        $value = $this->getConfigurationValue('dropbox_hide_general_coach');
754
        $this->addSettingCurrent(
755
            'dropbox_hide_general_coach',
756
            '',
757
            'radio',
758
            'Tools',
759
            ($value ? $value : 'false'),
760
            'DropboxHideGeneralCoachTitle',
761
            'DropboxHideGeneralCoachComment',
762
            null,
763
            '',
764
            1,
765
            true,
766
            false,
767
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
768
        );
769
770
        // If SSO is used, the redirection to the master server is forced.
771
        //$_configuration['force_sso_redirect'] = false;
772
        $value = $this->getConfigurationValue('force_sso_redirect');
773
        $this->addSettingCurrent(
774
            'sso_force_redirect',
775
            '',
776
            'radio',
777
            'Security',
778
            ($value?$value:'false'),
779
            'SSOForceRedirectTitle',
780
            'SSOForceRedirectComment',
781
            null,
782
            '',
783
            1,
784
            true,
785
            false,
786
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
787
        );
788
789
        // Session course ordering in the the session view.
790
        // false = alphabetic order (default)
791
        // true = based in the session course list
792
        //$_configuration['session_course_ordering'] = false;
793
        $value = $this->getConfigurationValue('session_course_ordering');
794
        $this->addSettingCurrent(
795
            'session_course_ordering',
796
            '',
797
            'radio',
798
            'Session',
799
            ($value?$value:'false'),
800
            'SessionCourseOrderingTitle',
801
            'SessionCourseOrderingComment',
802
            null,
803
            '',
804
            1,
805
            true,
806
            false,
807
            [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
808
        );
809
    }
810
811
    /**
812
     * @param Schema $schema
813
     */
814
    public function down(Schema $schema)
815
    {
816
        $this->addSql("DELETE FROM settings_options WHERE variable IN ('session_course_ordering', 'sso_force_redirect', 'dropbox_hide_course_coach', 'hide_certificate_export_link', 'hide_certificate_export_link_students', 'show_session_description', 'limit_session_admin_role', 'gravatar_type', 'gravatar_enabled', 'allow_delete_attendance', 'registration.soap.php.decode_utf8', 'catalog_allow_session_auto_subscription', 'hide_course_group_if_no_tools_available', 'cookie_warning', 'openbadges_backpack', 'add_gradebook_certificates_cron_task_enabled', 'document_if_file_exists_option', 'exercise_max_ckeditors_in_page', 'certificate_filter_by_official_code', 'student_publication_to_take_in_gradebook', 'course_images_in_courses_list', 'redirect_admin_to_courses_list', 'hide_logout_button', 'allow_session_course_copy_for_teachers', 'lp_show_reduced_report', 'auto_detect_language_custom_pages', 'catalog_show_courses_sessions', 'course_catalog_hide_private', 'show_official_code_exercise_result_list', 'allow_lp_return_link', 'hide_scorm_export_link', 'hide_scorm_copy_link', 'hide_scorm_pdf_link', 'session_days_before_coach_access', 'session_days_after_coach_access', 'pdf_logo_header', 'order_user_list_by_official_code', 'email_alert_manager_on_new_quiz')");
817
        $this->addSql("DELETE FROM settings_current WHERE variable IN ('session_course_ordering', 'sso_force_redirect', 'dropbox_hide_course_coach', 'hide_certificate_export_link', 'hide_certificate_export_link_students', 'show_session_description', 'limit_session_admin_role', 'gravatar_type', 'gravatar_enabled', 'allow_delete_attendance', 'registration.soap.php.decode_utf8', 'catalog_allow_session_auto_subscription', 'hide_course_group_if_no_tools_available', 'cookie_warning', 'openbadges_backpack', 'add_gradebook_certificates_cron_task_enabled', 'document_if_file_exists_option', 'exercise_max_ckeditors_in_page', 'certificate_filter_by_official_code', 'student_publication_to_take_in_gradebook', 'course_images_in_courses_list', 'redirect_admin_to_courses_list', 'hide_logout_button', 'allow_session_course_copy_for_teachers', 'lp_show_reduced_report', 'auto_detect_language_custom_pages', 'catalog_show_courses_sessions', 'course_catalog_hide_private', 'show_official_code_exercise_result_list', 'allow_lp_return_link', 'hide_scorm_export_link', 'hide_scorm_copy_link', 'hide_scorm_pdf_link', 'session_days_before_coach_access', 'session_days_after_coach_access', 'pdf_logo_header', 'order_user_list_by_official_code', 'email_alert_manager_on_new_quiz')");
818
819
        $this->addSql('ALTER TABLE user DROP COLUMN last_login');
820
    }
821
}
822