-
Notifications
You must be signed in to change notification settings - Fork 31
/
config.php
544 lines (460 loc) · 21.6 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<?php
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////////////////////////////////// \//////////////////////////////////
///////////////////////////////// \/////////////////////////////////
//////////////////////////////// \////////////////////////////////
///////////////////////////////\ /////////////////////////////////
////////////////////////////////\ //////////////////////////////////
////////////////////\ \///\ ///// /////////////////////
/////////////////////\ \////// //////////////////////
//////////////////////\ \//// ///////////////////////
/////////////////////////\ \// //////////////////////////
///////////////////////////////////// //////////////////////////////////
///////////////////////////////////// ////////////////////////////////////
///////////////////////////////////// ////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///////////////////////// Totara Docker Dev //////////////////////////
///////////// https://github.com/totara/totara-docker-dev //////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//<editor-fold desc="Docker-dev specific variable setup" defaultstate="collapsed">
// phpcs:ignoreFile
// Docker-dev specific variable setup
$DOCKER_DEV = new stdClass();
$DOCKER_DEV->has_server_dir = file_exists(__DIR__ . '/server/config.php');
$DOCKER_DEV->is_multi_site = __DIR__ !== '/var/www/totara/src';
$DOCKER_DEV->site_name = $DOCKER_DEV->is_multi_site ? basename(__DIR__) : 'totara';
// Required for older versions (T12 and below) and moodle
if (!$DOCKER_DEV->has_server_dir || !isset($CFG)) {
unset($CFG);
global $CFG;
$CFG = new stdClass();
}
// Get what version of Totara/Moodle is running via regex from the version.php file
// We can't include the version.php file directly as it may contain undefined constants, which results in a fatal errors in PHP 8+
$version_file = @file_get_contents(__DIR__ . '/server/version.php') ?: file_get_contents(__DIR__ . '/version.php');
$totara_version_matches = $moodle_version_matches = array();
preg_match("/TOTARA->version[\s]*=[\s]*'([^']+)'/", $version_file, $totara_version_matches);
preg_match("/release[\s]*=[\s]*'([\S]+)[^']+'/", $version_file, $moodle_version_matches);
$DOCKER_DEV->version = end($totara_version_matches) ?: end($moodle_version_matches);
$DOCKER_DEV->major_version = preg_replace("/^(\d{2}|[1-8]\.\d|9).+$/", '$1', $DOCKER_DEV->version);
unset($version_file, $totara_version_matches, $moodle_version_matches);
//</editor-fold>
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// Main Site Database & Dataroot Configuration //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/** PostgresSQL */
$CFG->dbhost = 'pgsql13'; // See https://github.com/totara/totara-docker-dev/wiki/Database%20Credentials for other versions
$CFG->dbtype = 'pgsql';
$CFG->dbuser = 'postgres';
$CFG->dbpass = '';
/** MySQL */
//$CFG->dbhost = 'mysql8'; // See https://github.com/totara/totara-docker-dev/wiki/Database%20Credentials for other versions
//$CFG->dbtype = 'mysqli';
//$CFG->dbuser = 'root';
//$CFG->dbpass = 'root';
/** MariaDB */
//$CFG->dbhost = 'mariadb'; // See https://github.com/totara/totara-docker-dev/wiki/Database%20Credentials for other versions
//$CFG->dbtype = 'mariadb';
//$CFG->dbuser = 'root';
//$CFG->dbpass = 'root';
/** Microsoft SQL Server */
//$CFG->dbhost = 'mssql2019'; // See https://github.com/totara/totara-docker-dev/wiki/Database%20Credentials for other versions
//$CFG->dbtype = PHP_MAJOR_VERSION >= 7 ? 'sqlsrv' : 'mssql'; // In PHP 7+ it is called 'sqlsrv' instead of 'mssql'.
//$CFG->dbuser = 'SA';
//$CFG->dbpass = 'Totara.Mssql1';
/**
* By default, the site database name is simply the name of the subdirectory you have your site in,
* or just 'totara' if you only have a single site. It can be accessed by using the `tdb` command.
*
* If you want to use a specific database for your site, set it here.
*/
$CFG->dbname = $DOCKER_DEV->site_name;
//$CFG->dbname = 'my_totara_db';
/**
* Every table in the site database will be prefixed with this.
* 'ttr_' and 'mdl_' are the most commonly used prefixes.
*
* Pro Tip: You can set the prefix to be the same as what is used for behat for extra debugging power while a scenario is paused.
*/
$CFG->prefix = 'ttr_';
//$CFG->prefix = 'mdl_';
//$CFG->prefix = 'bht_';
$CFG->directorypermissions = 02777;
/**
* Dataroot: For storing uploaded files, temporary and cache files, and other miscellaneous files created by Totara.
*/
$CFG->dataroot = "/var/www/totara/data/{$DOCKER_DEV->site_name}.{$CFG->dbhost}";
//$CFG->dataroot = '/var/www/totara/data/totara13.pgsql13';
//$CFG->dataroot = '/var/www/totara/data/mobile.mysql';
//$CFG->dataroot = '/var/www/totara/data/engage.mssql';
if (!is_dir($CFG->dataroot)) {
@mkdir($CFG->dataroot, $CFG->directorypermissions) && @chgrp($CFG->dataroot, 'www-data') && @chown($CFG->dataroot, 'www-data');
}
/**
* You shouldn't really need to change these.
*/
$CFG->dblibrary = 'native';
$CFG->dboptions = array('dbpersist' => false, 'dbsocket' => false, 'dbport' => '');
//<editor-fold desc="wwwroot Configuration">
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// wwwroot Configuration //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/**
* Here we generate a dynamic wwwroot, so the site can be simultaneously accessed via different PHP versions, and externally via ngrok.
* You shouldn't need to change this section - but if you find this needs modification to get it working,
* then please contribute what you did back to the docker-dev repository :)
*/
// Ngrok uses a few different URLs, add if a new one is used
$ngrok_urls = array('ngrok-free.app', 'ngrok.app');
// Depending on the Ngrok version its hostname is stored in different server vars
$ngrok_server_vars = array(
$_SERVER['HTTP_X_FORWARDED_HOST'] ?: '',
$_SERVER['HTTP_X_ORIGINAL_HOST'] ?: '',
);
$ngrok_hostname = '';
foreach ($ngrok_server_vars as $server_var) {
if (!empty($server_var) && empty($ngrok_hostname)) {
foreach ($ngrok_urls as $ngrok_url) {
if (strpos($server_var, $ngrok_url) !== false) {
$ngrok_hostname = $server_var;
break;
}
}
}
}
// Turns out request came via Ngrok
if (!empty($ngrok_hostname)) {
$_SERVER['HTTP_HOST'] = $ngrok_hostname;
$CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST'];
} else if (!empty($_SERVER['HTTP_HOST']) && !empty($_SERVER['REQUEST_SCHEME'])) {
// accessing it locally via the web
$CFG->wwwroot = $_SERVER['REQUEST_SCHEME'] . '://';
$hostname = $_SERVER['HTTP_HOST'];
$hostname_parts = explode('.', $hostname);
if (end($hostname_parts) === 'behat') {
// redirect if using the behat URL
$hostname = str_replace('.behat', '', $hostname);
}
$CFG->wwwroot .= $hostname;
if ($DOCKER_DEV->is_multi_site && strpos($hostname, $DOCKER_DEV->site_name) === false) {
$CFG->wwwroot .= '/' . $DOCKER_DEV->site_name;
if ($DOCKER_DEV->has_server_dir) {
$CFG->wwwroot .= '/server';
}
}
} else {
// accessing it via CLI
$CFG->wwwroot = 'http://totara' . PHP_MAJOR_VERSION . PHP_MINOR_VERSION;
if ($DOCKER_DEV->is_multi_site) {
$CFG->wwwroot .= '/' . $DOCKER_DEV->site_name;
}
if ($DOCKER_DEV->has_server_dir) {
$CFG->wwwroot .= '/server';
}
}
//</editor-fold>
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// PHPUnit Configuration //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/**
* Can either use the same database as the main site for PHPUnit,
* or a different database can be used (generally makes tests more stable)
*/
$CFG->phpunit_dbname = $CFG->dbname;
//$CFG->phpunit_dbname = 'unt_' . $CFG->dbname;
//$CFG->phpunit_dbname = 'totaraphpunit';
/**
* You shouldn't really need to change this.
*/
$CFG->phpunit_prefix = 'phpu_';
/**
* We use a different PHPUnit dataroot for each different version, otherwise there are warnings about the dataroot not being empty.
*/
$CFG->phpunit_dataroot = "/var/www/totara/data/{$DOCKER_DEV->site_name}.{$CFG->dbhost}.{$DOCKER_DEV->major_version}.phpunit";
if (!is_dir($CFG->phpunit_dataroot)) {
@mkdir($CFG->phpunit_dataroot, $CFG->directorypermissions) && @chgrp($CFG->phpunit_dataroot, 'www-data') && @chown($CFG->phpunit_dataroot, 'www-data');
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// Behat Configuration //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/**
* If false, then a behat config will be generated using selenium-chrome-debug, meaning you can view the pages being tested via VNC.
* If true, then multiple behat profiles will be generated, using selenium-hub,
* so you can run behat scenarios in parallel (faster. although you lose the ability to view it running)
*
* See https://github.com/totara/totara-docker-dev/wiki/Behat for more info on running behat in parallel/viewing it with VNC.
*/
$DOCKER_DEV->behat_parallel = false;
/**
* How many behat processes to run simultaneously if behat_parallel is set to true.
*/
//$DOCKER_DEV->behat_parallel_count = 2;
$DOCKER_DEV->behat_parallel_count = 4;
//$DOCKER_DEV->behat_parallel_count = 8;
/**
* By default, the behat database name is simply the name of the subdirectory you have your site in,
* or just 'totara' if you only have a single site. It can be accessed by using the `tdb` command.
*
* If you want to use a specific database for behat, set it here.
*/
$CFG->behat_dbname = $CFG->dbname;
/**
* You shouldn't really need to change this.
*/
$CFG->behat_prefix = 'bht_';
/**
* Saves screenshots of what exactly failed on the last behat run.
* You can add this directory to the .git/info/exclude file in your Totara site, so it doesn't get committed accidentally.
*/
//$CFG->behat_faildump_path = __DIR__ . '/screenshots';
/**
* We use a different behat dataroot for each different version, otherwise as the behat.yml will need to be regenerated everytime.
* If the same behat.yml is used across versions, then the tests won't run correctly.
*/
$CFG->behat_dataroot = "/var/www/totara/data/{$DOCKER_DEV->site_name}.{$CFG->dbhost}.{$DOCKER_DEV->major_version}.behat";
if (!is_dir($CFG->behat_dataroot)) {
@mkdir($CFG->behat_dataroot, $CFG->directorypermissions) && @chgrp($CFG->behat_dataroot, 'www-data') && @chown($CFG->behat_dataroot, 'www-data');
}
//<editor-fold desc="Advanced behat setup" defaultstate="collapsed">
/**
* The wwwroot for behat is the same as the host, but with '.behat' added as a suffix (so 'totara73' becomes 'totara73.behat')
* You shouldn't really need to change this.
*/
$CFG->behat_wwwroot = 'http://totara' . PHP_MAJOR_VERSION . PHP_MINOR_VERSION . '.behat';
if ($DOCKER_DEV->is_multi_site) {
$CFG->behat_wwwroot .= '/' . $DOCKER_DEV->site_name;
}
if ($DOCKER_DEV->has_server_dir) {
$CFG->behat_wwwroot .= '/server';
}
/**
* This is where the behat setup get a bit complicated - here we generate the behat config that supports multiple different Totara versions.
* You shouldn't need to change this section - but if you find this needs modification to get it working,
* then please contribute what you did back to the docker-dev repository :)
*/
// Disable running behat in parallel if the Totara version is too old, or if there isn't enough CPU threads available.
$DOCKER_DEV->behat_parallel &= $DOCKER_DEV->major_version >= 2.9;
$DOCKER_DEV->behat_host = $DOCKER_DEV->behat_parallel ? 'selenium-hub' : 'selenium-chrome-debug';
if ($DOCKER_DEV->behat_parallel) {
for ($i = 1; $i <= $DOCKER_DEV->behat_parallel_count; $i++) {
$CFG->behat_parallel_run[] = array(
'dbname' => $CFG->behat_dbname,
'behat_prefix' => "bh{$i}_",
'wd_host' => 'http://selenium-hub:4444/wd/hub'
);
}
}
if ($DOCKER_DEV->major_version > 18) {
// Behat config for Totara 19 and higher
$CFG->behat_profiles['default'] = array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'extra_capabilities' => array(
'goog:chromeOptions' => array(
'args' => array(
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows'
),
'excludeSwitches' => array(
'enable-automation'
),
'prefs' => array(
'credentials_enable_service' => false,
),
)
)
)
);
} else if ($DOCKER_DEV->major_version >= 10) {
// Behat config for Totara 10+
$CFG->behat_profiles['default'] = array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'extra_capabilities' => array(
'chromeOptions' => array(
'args' => array(
'--disable-infobars',
'--disable-background-throttling'
),
'prefs' => array(
'credentials_enable_service' => false,
),
'w3c' => false,
),
'goog:chromeOptions' => array(
'args' => array(
'--disable-infobars',
'--disable-background-throttling',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows'
),
'prefs' => array(
'credentials_enable_service' => false,
),
'w3c' => false,
'excludeSwitches' => array(
'enable-automation'
)
)
)
)
);
} else {
// Behat config for Totara 9 and earlier
$CFG->behat_config = array(
'default' => array(
'extensions' => array(
'Behat\MinkExtension\Extension' => array(
'browser_name' => 'chrome',
'default_session' => 'selenium2',
'selenium2' => array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'version' => '',
'platform' => 'LINUX',
)
)
)
)
)
);
if ($DOCKER_DEV->behat_parallel) {
$CFG->behat_profiles = array(
'default' => array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'browser' => 'chrome',
'browserVersion' => 'ANY',
'version' => '',
'chrome' => array(
'switches' => array(
'--disable-infobars',
'--disable-background-throttling'
),
'w3c' => false
)
)
)
);
}
}
//</editor-fold>
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// Development Mode Settings //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
$development_mode = true;
if ($development_mode) {
$CFG->sitetype = 'development';
@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT & ~E_DEPRECATED);
$CFG->debugdisplay = 1;
$CFG->perfdebug = 15;
define('GRAPHQL_DEVELOPMENT_MODE', true);
// $CFG->legacyadminsettingsmenu = true;
$CFG->debugallowscheduledtaskoverride = true;
$CFG->preventexecpath = false;
$CFG->mobile_device_emulator = true;
// Useful when changing or creating language string lookups, so
// that your changes are reflecting in the UI
$CFG->langstringcache = false;
// Helps to identify potentially missing or incorrectly named
// language strings in the UI
$CFG->debugstringids = false;
// Allow URL query parameter to change the current system Theme for
// the current session, handy for qualifying if changes or issues
// exist across different Themes
$CFG->allowthemechangeonurl = true;
// Theme designer mode useful for individual *legacy only* Theme file
// debugging by breaking out many Theme dependency files into separate
// <head /> entries. This creates many requests, and significantly
// degrades page load and readiness performance. Don't use this for
// Tui-only development
$CFG->themedesignermode = false;
// Un-cache legacy-only front end dependencies
$CFG->cachejs = false;
$CFG->cachetemplates = false;
// When working with YUI, you may need to disable PHP combo loading
// of dependency files for easier debugging
$CFG->yuicomboloading = false;
$CFG->yuiloglevel = 'debug';
// When you expect fresh data from GraphQL, disable the cache,
// otherwise expect an increase to page load and readiness times
//
// Disabling caching of the GraphQL schema has a serious performance impact
// thus we keep it enabled by default.
// Either purge caches if needed or uncomment the following line if needed.
// $CFG->cache_graphql_schema = false;
// Tui-specific settings to turn off performance optimisations
// during development. They do similar things to the legacy-only
// settings, and can be turned off when not changing Tui code
$CFG->forced_plugin_settings['totara_tui'] = array(
'cache_js' => false,
'cache_scss' => false,
'development_mode' => true
);
// // Xhprof Profiling settings
// $CFG->profilingenabled = true;
// $CFG->profilingincluded = '*';
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
////// //////
////// Extras / Miscellaneous //////
////// //////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Redirects any emails sent by the server
$CFG->smtphosts = 'mailcatcher:25';
$CFG->passwordpolicy = false;
$CFG->tool_generator_users_password = '12345';
$CFG->upgradekey = '';
$CFG->country = 'NZ';
$CFG->defaultcity = 'Wellington'; // very windy!
//<editor-fold desc="Paths for additional binary packages" defaultstate="collapsed">
$CFG->py3path = '/usr/bin/python3';
$CFG->pathtogs = '/usr/bin/gs';
$CFG->pathtodu = '/usr/bin/du';
$CFG->aspellpath = '/usr/bin/aspell';
$CFG->pathtodot = '/usr/bin/dot';
//</editor-fold>
if ($DOCKER_DEV->major_version >= 13) {
// $CFG->forceflavour = 'learn';
// $CFG->forceflavour = 'learn_professional';
// $CFG->forceflavour = 'engage';
// $CFG->forceflavour = 'learn_engage';
// $CFG->forceflavour = 'learn_perform';
// $CFG->forceflavour = 'perform_engage';
$CFG->forceflavour = 'learn_perform_engage';
} else {
// For Totara versions earlier than 13, the enterprise flavour must be set
$CFG->forceflavour = 'enterprise';
}
// This must be the last thing in the config.
file_exists(__DIR__ . '/lib/setup.php') && require_once __DIR__ . '/lib/setup.php';