Skip to content

Instantly share code, notes, and snippets.

@danpoltawski
Created August 3, 2011 20:46
Show Gist options
  • Save danpoltawski/1123720 to your computer and use it in GitHub Desktop.
Save danpoltawski/1123720 to your computer and use it in GitHub Desktop.
Moodle config.php files
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
date_default_timezone_set('Australia/Perth');
/**************************************************
* Work out a branch prefix based on ugly branch retrieval
* Thanks Iñaki:
* http://moodle.org/mod/forum/discuss.php?d=139693
**************************************************/
$gitpath = '/usr/local/bin/git';
$pwd = dirname(__FILE__);
preg_match ('/^\*\s*(.*)\s*$/m', `cd $pwd; $gitpath branch`, $matches);
$branch = $matches[1];
// default defix in case the above fails..
$branchprefix = 'other';
if ($branch == 'master') {
// easy to remember prefix
$branchprefix = 'mdl';
}elseif (preg_match('/MOODLE_(\d+)_STABLE/', $branch, $matches)) {
// MOODLE_21_STABLE becomes m21_
$branchprefix = 'm'.$matches[1];
}elseif (!empty($branch)) {
// make a prefix as shortnered verson of branchname
$branchprefix = substr(preg_replace('/\W*/', '', $branch), 0, 7);
}
/**************************************************
* I'm in dans home directory
**************************************************/
$CFG->wwwroot = 'http://dan.moodle.local/integration';
$CFG->dirroot = '/Users/danp/git/integration';
/**************************************************
* Switch between DB's..
**************************************************/
$CFG->dbtype = 'pgsql';
$CFG->dbhost = '127.0.0.1';
#$CFG->dbtype = 'mysqli';
#$CFG->dbhost = 'win7';
#$CFG->dbtype = 'mssql';
// Setup DB prefix..
$CFG->prefix = $branchprefix.'_';
// setup cookie..
$CFG->sessioncookie = $branchprefix.'integr'.$CFG->dbtype;
// Setup data directory
$CFG->dataroot = '/Users/danp/moodledata/integration/'.$branchprefix;
$CFG->phpunit_dataroot = '/Users/danp/phpunitdata';
$CFG->phpunit_prefix = 'phpu_';
// make data subdirector if it doesn't exist..
if (!is_dir($CFG->dataroot)) {
mkdir($CFG->dataroot);
}
// debugging settings...
define('MDL_PERF', true);
define('MDL_PERFDB', true);
define('MDL_PERFTOFOOT', true);
#define('MDL_PERFTOLOG', true);
// Only use E_STRICT in >23
if (in_array($branch, array('MOODLE_22_STABLE', 'MOODLE_21_STABLE',
'MOODLE_20_STABLE', 'MOODLE_19_STABLE'))) {
$CFG->debug = 38911;
} else {
$CFG->debug = E_ALL | E_STRICT; // DEBUG_DEVELOPER
}
$CFG->debugdisplay = 1; // I notice notices better
$CFG->loginhttps = 0; // for testing https sites dbs on my machine
$CFG->passwordpolicy = 0; // because making complex test passwords is hard!
// database settings
$CFG->dblibrary = 'native';
$CFG->dbname = 'integration';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'm00dl3';
$CFG->unittestprefix = 'tsx_';
$CFG->dboptions = array (
'dbpersist' => 0,
//'logall' => true,
'dbsocket' => 0,
);
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
$CFG->enablebackupconverters = true;
// email settings
$CFG->smtphosts = 'smtp.highway1.com.au';
$CFG->divertallemailsto = '[email protected]';
$CFG->noemailever = 1;
require_once($CFG->dirroot.'/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment