<?php

# See includes/MainConfigSchema.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.

# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
	exit;
}

# wgconf
$wgLocalDatabases = [
    'enwickedgov',
    'metawiki',
    'ensterling',
    'loginwiki',
    'entechwiki',
    'commonswiki',
    'testwiki'
];

$wgConf->wikis = $wgLocalDatabases;
$wgConf->suffixes = [ 'wickedgov', 'metawiki', 'sterling', 'loginwiki', 'techwiki', 'commonswiki', 'testwiki' ];

$wgConf->settings = [

'wgServer' => [
    'enwickedgov' => 'https://www.wickedgov.org',
    'metawiki' => 'https://meta.wickedgov.org',
    'ensterling' => 'https://sterling.wickedgov.org',
    'loginwiki' => 'https://login.wickedgov.org',
    'entechwiki' => 'https://tech.wickedgov.org',
    'commonswiki' => 'https://commons.wickedgov.org',
    'testwiki' => 'https://test.wickedgov.org',
],

'wgCanonicalServer' => [
    'enwickedgov' => 'https://www.wickedgov.org',
    'metawiki' => 'https://meta.wickedgov.org',
    'ensterling' => 'https://sterling.wickedgov.org',
    'loginwiki' => 'https://login.wickedgov.org',
    'entechwiki' => 'https://tech.wickedgov.org',
    'commonswiki' => 'https://commons.wickedgov.org',
    'testwiki' => 'https://test.wickedgov.org',
],

'wgScriptPath' => [
    'default' => '/w',
],

'wgArticlePath' => [
    'default' => '/wiki/$1',
],

'wgSitename' => [
    'enwickedgov' => 'WickedGov',
    'ensterling' => 'LambWiki',
    'metawiki' => 'WickedGov Meta-Wiki',
    'loginwiki' => 'WickedGov Login Wiki',
    'entechwiki' => 'WickedTech',
    'commonswiki' => 'WickedGov Commons',
    'testwiki' => 'Test Wiki',
],

'wgMetaNamespace' => [
	'default' => false,
	'metawiki' => 'Meta',
	'loginwiki' => 'LoginWiki',
	'commonswiki' => 'Commons',
],

'+wgGroupPermissions' => [

'default' => [
        'user' => [
                'changetags' => false,
                'oathauth-enable' => true,
#		'reupload-own' => true,
                'spamblacklistlog' => false,
                'viewmywatchlist' => true,
                'torunblocked' => false,
		'movefile' => false,
        ],
        'accountcreator' => [
                'noratelimit' => true,
		'centralauth-createlocal' => true,
        ],
        'autoconfirmed' => [
                'editsemiprotected' => true,
                'autoconfirmed' => true,
                'skipcaptcha' => true,
        ],
        'autopatrolled' => [
                'autopatrol' => true,
                'patrolmarks' => true,
        ],
        'bot' => [
                'bot' => true,
                'abusefilter-bypass-blocked-external-domains' => true,
                'sboverride' => true,
                'editsemiprotected' => true,
                'autopatrol' => true,
                'autoconfirmed' => true,
                'suppressredirect' => true,
                'nominornewtalk' => true,
                'apihighlimits' => true,
                'changetags' => true,
                'ipblock-exempt' => true,
		'globalblock-exempt' => true,
                'skipcaptcha' => true,
        ],
        'bureaucrat' => [
		'noratelimit' => true,
		'oathauth-verify-user' => true,
#		'oathauth-view-log' => true,
        ],
        'checkuser' => [
                'checkuser' => true,
                'checkuser-temporary-account-no-preference' => false,
                'abusefilter-privatedetails' => true,
                'abusefilter-privatedetails-log' => true,
                'checkuser-log' => true,
                'checkuser-temporary-account-log' => false,
        ],/*
        'temp-account-viewer' => [
                'checkuser-temporary-account' => true,
        ],*/
        'confirmed' => [
                'editsemiprotected' => true,
                'autoconfirmed' => true,
                'skipcaptcha' => true,
        ],
        'interface-admin' => [
                'editcontentmodel' => true,
                'editusercss' => true,
                'edituserjson' => true,
                'edituserjs' => true,
                'editsitecss' => true,
                'editsitejson' => true,
                'editsitejs' => true,
                'editinterface' => true,
        ],
        'ipb-exemption' => [
                'ipblock-exempt' => true,
                'torunblocked' => true,
                'autoconfirmed' => true,
		'globalblock-exempt' => true,
        ],
        'steward' => [
                'centralauth-lock' => false,
                'centralauth-suppress' => false,
                'centralauth-unmerge' => false,
                'userrights' => true,
        ],
        'suppress' => [
                'hideuser' => true,
                'deletelogentry' => true,
                'deleterevision' => true,
                'abusefilter-hide-log' => true,
                'abusefilter-hidden-log' => true,
                'viewsuppressed' => true,
                'suppressionlog' => true,
                'suppressrevision' => true,
		'deletedhistory' => true,
		'deletedtext' => true,
		'browsearchive' => true,
        ],
        'sysop' => [
                'blockemail' => true,
                'block' => true,
                'changetags' => true,
                'ipblock-exempt' => true,
                'torunblocked' => true,
		'globalblock-exempt' => true,
                'protect' => true,
                'managechangetags' => true,
                'createaccount' => false,
                'abusefilter-modify' => true,
                'abusefilter-modify-blocked-external-domains' => true,
                'abusefilter-bypass-blocked-external-domains' => true,
#                'deletechangetags' => true,
                'deletelogentry' => true,
                'deleterevision' => true,
                'delete' => true,
                'edituserjson' => true,
                'editprotected' => true,
                'editsemiprotected' => true,
                'editsitejson' => true,
                'editcontentmodel' => true,
                'editinterface' => true,
                'autopatrol' => true,
                'import' => true,
		'importupload' => false,
                'patrol' => true,
                'markbotedits' => true,
                'nuke' => true,
                'oathauth-view-log' => false,
                'oathauth-disable-for-user' => false,
                'oathauth-verify-user' => false,
                'mergehistory' => true,
                'abusefilter-modify-restricted' => true,
                'move-categorypages' => true,
                'movefile' => true,
                'move' => false,
                'move-subpages' => true,
                'move-rootuserpages' => false,
                'autoconfirmed' => true,
                'noratelimit' => true,
                'suppressredirect' => true,
                'nominornewtalk' => true,
                'tboverride' => true,
                'override-antispoof' => true,
                'reupload' => true,
                'rollback' => true,
                'abusefilter-revert' => true,
                'browsearchive' => true,
                'undelete' => true,
                'upload' => true,
                'upload_by_url' => true,
                'apihighlimits' => true,
                'unwatchedpages' => true,
                'abusefilter-view-private' => true,
                'deletedhistory' => true,
                'deletedtext' => true,
                'abusefilter-log-detail' => true,
                'abusefilter-log-private' => true,
                'titleblacklistlog' => false,
                'spamblacklistlog' => true,
                'abusefilter-access-protected-vars' => false,
                'abusefilter-protected-vars-log' => false,
                'skipcaptcha' => true,
        ],
	'transwiki' => [
		'import' => true,
	],
	'importupload' => [
		'import' => true,
		'importupload' => true,
		'mergehistory' => true,
	],
    ],
    '+enwickedgov' => [
        'uploader' => [
            'reupload' => true,
            'upload' => true,
            'upload_by_url' => true,
        ],
        'extendedconfirmed' => [
            'editextendedprotected' => true,
        ],
        'bot' => [
            'editextendedprotected' => true,
        ],
	'bureaucrat' => [
		'deletechangetags' => true,
	],
        'sysop' => [
		'deletechangetags' => false,
		'editextendedprotected' => true,
        ],
	'user' => [
		'edituserpages' => true,
	],
    ],
    '+metawiki' => [
	'autoconfirmed' => [
		'mwoauthproposeconsumer' => true,
	],
	'confirmed' => [
		'mwoauthproposeconsumer' => true,
	],
	'user' => [
		'mwoauthupdateownconsumer' => true,
		'mwoauthmanagemygrants' => true,
	],
        'steward' => [
            'userrights' => true,
            'userrights-interwiki' => true,
            'centralauth-lock' => true,
            'centralauth-suppress' => true,
            'centralauth-rename' => true,
	    'globalblock' => true,
	    'block' => true,
	    'blockemail' => true,
            'globalgrouppermissions' => true,
            'globalgroupmembership' => true,
	    'abusefilter-modify' => true,
            'abusefilter-modify-global' => true,
            'interwiki' => true,
	    'oathauth-verify-user' => true,
	    'mwoauthsuppress' => true,
	    'mwoauthviewsuppressed' => true,
	    'mwoauthmanageconsumer' => true,
       ],
        'sysadmin' => [
            'userrights' => true,
            'userrights-interwiki' => true,
            'centralauth-lock' => true,
            'centralauth-suppress' => true,
            'centralauth-rename' => true,
            'centralauth-unmerge' => true,
	    'globalblock' => true,
	    'block' => true,
	    'blockemail' => true,
            'globalgrouppermissions' => true,
            'globalgroupmembership' => true,
            'abusefilter-modify' => true,
            'abusefilter-modify-global' => true,
            'oathauth-verify-user' => true,
            'oathauth-disable-for-user' => true,
	    'mwoauthmanageconsumer' => true,
	    'mwoauthviewsuppressed' => true,
	    'mwoauthsuppress' => true,
       ],
	'translationadmin' => [
	    'pagelang' => true,
	    'editcontentmodel' => true,
	    'translate-import' => true,
	    'translate-manage' => true,
	    'pagetranslation' => true,
	],
	'sysop' => [
	    'pagelang' => true,
	    'abusefilter-modify-global' => true,
	],
	'trustandsafety' => [
		'userrights' => true,
		'userrights-interwiki' => true,
		'centralauth-lock'=> true,
		'globalblock' => true,
		'centralauth-suppress' => true,
		'centralauth-unmerge' => true,
		'oathauth-verify-user' => true,
		'oathauth-disable-for-user' => true,
		'centralauth-rename' => true,
		'globalgrouppermissions' => true,
		'globalgroupmembership' => true,
	],
	'centralnoticeadmin' => [
		'centralnotice-admin' => true,
		'protect' => true,
		'editinterface' => true,
	],
	// T7
	'tempaccountviewer' => [
		'checkuser-temporary-account' => true,
	],
    ],
    '+commonswiki' => [
	'filemover' => [
	    'movefile' => true,
	],
	'translationadmin' => [
	    'pagelang' => true,
	    'editcontentmodel' => true,
	    'translate-import' => true,
	    'translate-manage' => true,
	    'pagetranslation' => true,
	],
	'sysop' => [
	    'pagelang' => true,
	],
	'patroller' => [
	    'rollback' => true,
	    'patrol' => true,
	],
    ],
    '+testwiki' => [
        'translationadmin' => [
            'pagelang' => true,
            'editcontentmodel' => true,
            'translate-import' => true,
            'translate-manage' => true,
            'pagetranslation' => true,
        ],
        'sysop' => [
            'pagelang' => true,
        ],
        'centralnoticeadmin' => [
                'centralnotice-admin' => true,
                'protect' => true,
                'editinterface' => true,
        ],
	'tempaccountviewer' => [
		'checkuser-temporary-account' => true,
	],
	'checkuser' => [
		'checkuser-temporary-account-no-preference' => true,
	],
	'suppress' => [
		'checkuser-temporary-account-no-preference' => true,
	],
    ],
],

'wgAddGroups' => [
        'default' => [
                'accountcreator' => [
                        'confirmed'
                ],
                'bureaucrat' => [
                        'accountcreator',
                        'bot',
                        'bureaucrat',
			'interface-admin',
                        'sysop',
			'transwiki',
                ],
                'sysop' => [
                        'autopatrolled',
                        'confirmed',
                        'ipb-exemption',
                ],
        ],
        '+enwickedgov' => [
                'sysop' => [
                        'extendedconfirmed',
			'uploader',
                ],
        ],
	'+metawiki' => [
		'bureaucrat' => [
			'translationadmin'
		],
	],
	'+commonswiki' => [
		'bureaucrat' => [
			'translationadmin'
		],
		'sysop' => [
			'filemover',
			'patroller'
		],
	],
	'+testwiki' => [
		'bureaucrat' => [
			'importupload',
			'centralnoticeadmin',
			'translationadmin'
		],
	],
],

'wgRemoveGroups' => [
        'default' => [
                'bureaucrat' => [
                        'accountcreator',
                        'bot',
			'interface-admin',
			'transwiki'
                ],
                'sysop' => [
                        'autopatrolled',
                        'confirmed',
                        'ipb-exemption'
                ],
        ],
        '+enwickedgov' => [
                'bureaucrat' => [
                        'sysop'
                ],
                'sysop' => [
                        'extendedconfirmed',
			'uploader',
                ],
        ],
        '+metawiki' => [
                'bureaucrat' => [
                        'translationadmin'
                ],
        ],
	'+commonswiki' => [
		'bureaucrat' => [
			'translationadmin'
		],
		'sysop' => [
			'filemover',
			'patroller'
		],
	],
	'+testwiki' => [
		'bureaucrat' => [
			'sysop',
			'importupload',
			'translationadmin',
			'centralnoticeadmin'
		],
	],
],
'wgGroupsAddToSelf' => [
	'metawiki' => [
		'sysop' => [
			'translationadmin'
		],
	],
	'commonswiki' => [
		'sysop' => [
			'translationadmin'
		],
	],
],
'wgGroupsRemoveFromSelf' => [
	'default' => [
		'autoconfirmed' => [
			'confirmed'
		],
	],
        '+metawiki' => [
                'sysop' => [
                        'translationadmin'
                ],
        ],
	'+commonswiki' => [
		'sysop' => [
			'translationadmin'
		],
	],
],

'wgUseInstantCommons' => [
	'default' => false,
],

'wgLogos' => [
'default' => [
        'icon' => "https://uploads.wickedgov.org/enwickedgov/static/logo/logo.svg",
        '1x' => "https://uploads.wickedgov.org/enwickedgov/static/logo/135px.png",
        'wordmark' => [
                '1x' => 'https://uploads.wickedgov.org/enwickedgov/static/wordmark/135px.png',
                'src' => 'https://uploads.wickedgov.org/enwickedgov/static/wordmark/wordmark.svg',
                'width' => 135,
                'height' => 19,
        ],
],
'metawiki' => [
	'icon' => "https://uploads.wickedgov.org/enwickedgov/static/logo/meta.svg",
	'1x' => "https://uploads.wickedgov.org/enwickedgov/static/logo/135px-meta.png",
	'wordmark' => [
		'1x' => 'https://uploads.wickedgov.org/enwickedgov/static/wordmark/135px-meta.png',
		'src' => 'https://uploads.wickedgov.org/enwickedgov/static/wordmark/meta.svg',
		'width' => 107,
		'height' => 32,
	],
],
'+entechwiki' => [
	'1x' => 'https://uploads.wickedgov.org/enwickedgov/static/logo/WickedTech-135px.png'
],

],

'wgNoticeProject' => [
	'enwickedgov' => 'wickedgov',
	'ensterling' => 'sterling',
	'entechwiki' => 'techwiki',
	'commonswiki' => 'commonswiki',
	'metawiki' => 'metawiki',
	'testwiki' => 'test',
],

];
$wgGroupPermissions['user']['editcontentmodel'] = false;
$wgGroupPermissions['user']['reupload'] = false;
$wgGroupPermissions['user']['reupload-shared'] = false;
$wgGroupPermissions['user']['move-categorypages'] = false;
$wgGroupPermissions['user']['movefile'] = false;
$wgGroupPermissions['user']['move-subpages'] = false;
$wgGroupPermissions['bureaucrat']['userrights'] = false;
$wgGroupPermissions['bureaucrat']['override-antispoof'] = false;
$wgGroupPermissions['steward']['userrights'] = true;
$wgGroupPermissions['steward']['centralauth-createlocal'] = false;
$wgGroupPermissions['sysop']['unblockself'] = false;
$wgGroupPermissions['sysop']['bigdelete'] = false;
$wgGroupPermissions['bureaucrat']['renameuser'] = false;
$wgGroupPermissions['sysop']['importupload'] = false;
$wgGroupPermissions['user']['changetags'] = false;
if ($wgDBname === 'enwickedgov') {
	$wgGroupPermissions['sysop']['deletechangetags'] = false;
};

# Loginwiki should be fishbowl
if ($wgDBname === 'loginwiki') {
	$wgGroupPermissions['*'] = [
		'read' => true,
		'autocreateaccount' => true,
		'editmyoptions' => true,
		'editmyprivateinfo' => true,
		'viewmyprivateinfo' => true,
		'centralauth-merge' => true,
		'torunblocked' => true,
	];
	$wgGroupPermissions['user'] = [
		'read' => true,
	];
	$wgGroupPermissions['autoconfirmed'] = [
		'read' => true,
	];
	$wgGroupPermissions['steward']['edit'] = true;
	$wgGroupPermissions['*']['ipblock-exempt'] = true;
};

# Load additional userright
$wgAvailableRights[] = 'editextendedprotected';

# On metawiki, allow subpages in mainspace
if ($wgDBname === 'metawiki') {
$wgNamespacesWithSubpages[NS_MAIN] = true;
};

# Template subpages, all wikis
$wgNamespacesWithSubpages[NS_TEMPLATE] = true;

# All non-redirects in mainspace are articles
$wgArticleCountMethod = 'any';

## Specify the canonical URI for all pages
$wgEnableCanonicalServerLink = true;

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL paths to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
/*$wgLogos = [
	'icon' => "https://uploads.wickedgov.org/static/logo/logo.svg",
	'1x' => "https://uploads.wickedgov.org/static/logo/135px.png",
	'wordmark' => [
		'1x' => 'https://uploads.wickedgov.org/static/wordmark/135px.png',
		'src' => 'https://uploads.wickedgov.org/static/wordmark/wordmark.svg',
		'width' => 135,
		'height' => 19,
	],
];*/
$wgFavicon = 'https://uploads.wickedgov.org/enwickedgov/static/favicon.png';

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "info@wickedgov.org";
$wgPasswordSender = "noreply@wickedgov.org";

$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBuser = "wguser";
require('/var/www/PrivateSettings.php');

# MySQL specific settings
$wgDBprefix = "";
$wgDBssl = false;

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];

## Upload configuration
if ($wgDBname === 'enwickedgov' or $wgDBname === 'commonswiki') {
	$wgEnableUploads = true;
};
if ($wgDBname !== 'commonswiki') {
	$wgGroupPermissions['user']['upload'] = false;
	$wgGroupPermissions['user']['reupload-own'] = false;
	$wgUploadNavigationUrl = "https://commons.wickedgov.org/wiki/Special:Upload";
	$wgUploadMissingFileUrl= "https://commons.wickedgov.org/wiki/Special:Upload";
	$wgUseSharedUploads = true;
	$wgSharedUploadPath = 'https://uploads.wickedgov.org/commonswiki';
	$wgSharedUploadDirectory = '/var/www/wguploads/commonswiki/';
	$wgHashedSharedUploadDirectory = true;
	$wgFetchCommonsDescriptions = true;
	$wgSharedUploadDBname = 'commonswiki';  # DB-Name of commons
	$wgRepositoryBaseUrl = "https://commons.wickedgov.org/wiki/Image:";
};
$wgUploadDirectory = "/var/www/wguploads/{$wgDBname}";
$wgUploadPath = "https://uploads.wickedgov.org/$wgDBname";
$wgUseImageMagick = false;
$wgAllowCopyUploads = true;
$wgCopyUploadsFromSpecialUpload = true;


# SVG configuration
$wgFileExtensions[] = 'svg';
$wgSVGConverters = [ 'rsvg' => '/usr/bin/rsvg-convert -w $width -h $height -o $output $input' ];
$wgSVGConverter = 'rsvg' ;


# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;

# Site language code, should be one of the list in ./includes/languages/data/Names.php
$wgLanguageCode = "en";

# Time zone
$wgLocaltimezone = "UTC";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publicly accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
#$wgUpgradeKey = "2a8df03a1cf51f4f";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = "Policy:Copyrights"; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "https://creativecommons.org/licenses/by-sa/4.0/";
$wgRightsText = "Creative Commons Attribution-ShareAlike";

# Terms of Use footer link
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['termsofuse'] = Html::rawElement( 'a', [
			'href' => Title::newFromText(
				$skin->msg( 'termsofuse-page' )->inContentLanguage()->text()
			)->getFullURL()
		], $skin->msg( 'termsofuse-desc' )->escaped() );
    };
};

# Disable raw HTML copyright messages
$wgAllowRawHtmlCopyrightMessages = false;

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

## Default skin: you can change the default skin. Use the internal symbolic
## names, e.g. 'vector' or 'monobook':
$wgDefaultSkin = "vector";

# Enable the Vector skin
wfLoadSkin( 'Vector' );

# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtension( 'ExtensionName' );
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
wfLoadExtension( 'AbuseFilter' );
$wgAbuseFilterEnableBlockedExternalDomain = true;
wfLoadExtension( 'CategoryTree' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'CodeMirror' );
wfLoadExtension( 'DiscussionTools' );
wfLoadExtension( 'Echo' );
$wgEchoSharedTrackingDB = 'metawiki';
$wgDefaultUserOptions['echo-cross-wiki-notifications'] = true;
$wgMainStash = CACHE_ACCEL;
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'Linter' );
wfLoadExtension( 'LoginNotify' );
wfLoadExtension( 'Math' );
wfLoadExtension( 'MultimediaViewer' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'OAuth' );
$wgMWOAuthCentralWiki = 'metawiki';
wfLoadExtension( 'OATHAuth' );
$wgOATHRequiredForGroups = [
	'bureaucrat',
	'checkuser',
	'interface-admin',
	'steward',
	'suppress'
];
$wgOATHExclusiveRights = [
	'editsitecss',
	'editsitejs',
	'editusercss',
	'edituserjs'
];
$wgOATHAuthAccountPrefix = 'WickedGov';
$wgVirtualDomainsMapping['virtual-oathauth'] = [ 'db' => 'metawiki' ];
wfLoadExtension( 'PageImages' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'Poem' );
wfLoadExtension( 'SecureLinkFixer' );
wfLoadExtension( 'SpamBlacklist' );
$wgLogSpamBlacklistHits = true;
$wgBlacklistSettings = [
	'spam' => [
		'files' => [
			'DB: metawiki Spam_blacklist',
		],
	],
        'email' => [
                'files' => [
                        'DB: metawiki Spam_blacklist',
                ],
        ],
];
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'TemplateData' );
wfLoadExtension( 'TextExtracts' );
wfLoadExtension( 'Thanks' );
wfLoadExtension( 'TitleBlacklist' );
$wgTitleBlacklistLogHits = false;
$wgTitleBlacklistBlockAutoAccountCreation = false;
$wgTitleBlacklistSources = [
    [
         'type' => 'localpage',
         'src'  => 'MediaWiki:Titleblacklist'
    ],
    [
         'type' => 'url',
         'src'  => 'https://meta.wickedgov.org/w/index.php?title=Title_blacklist&action=raw'
    ],
];
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'WikiEditor' );

# Additional extensions
wfLoadExtension( 'AntiSpoof' );
wfLoadExtension( 'CheckUser' );
wfLoadExtension( 'CommonsMetadata' );
wfLoadExtension( 'Disambiguator' );
wfLoadExtension( 'DismissableSiteNotice' );
$wgDismissableSiteNoticeForAnons = true;
wfLoadExtension( 'TemplateStyles' );
wfLoadExtension( 'TorBlock' );
$wgApplyIpBlocksToXff = true;
wfLoadExtension( 'WikimediaMessages' );

# CENTRALAUTH
wfLoadExtension( 'CentralAuth' );
$wgVirtualDomainsMapping['virtual-centralauth'] = [ 'db' => 'centralauth' ];

# GlobalUserPage
wfLoadExtension( 'GlobalUserPage' );
$wgGlobalUserPageAPIUrl = 'https://meta.wickedgov.org/w/api.php';
$wgGlobalUserPageFooterKey = 'globaluserpage-footer';
$wgGlobalUserPageDBname = 'metawiki';

# GlobalCssJs
wfLoadExtension( 'GlobalCssJs' );
$wgUseGlobalSiteCssJs = true;
$wgResourceLoaderSources['metawiki'] = array(
     'apiScript' => 'https://meta.wickedgov.org/w/api.php',
     'loadScript' => 'https://meta.wickedgov.org/w/load.php',
);
$wgGlobalCssJsConfig = [
	'wiki' => 'metawiki',
	'source' => 'metawiki',
];

# GlobalPreferences
wfLoadExtension( 'GlobalPreferences' );
$wgGlobalPreferencesDB = 'metawiki';

# GlobalBlocking
wfLoadExtension( 'GlobalBlocking' );
$wgVirtualDomainsMapping['virtual-globalblocking'] = ['db' => 'globalblocking'];
if (($wgDBname === 'metawiki') || ($wgDBname === 'loginwiki')) {
        $wgApplyGlobalBlocks = false;
} else {
        $wgApplyGlobalBlocks = true;
};
$wgGlobalBlockingCentralWiki = 'metawiki';

# ContactPage on metawiki
if ($wgDBname === 'metawiki') {

wfLoadExtension( 'ContactPage' );

$wgContactConfig['stewards'] = [
       'RecipientEmail' => 'stewards@wickedgov.org',
       'SenderEmail' => 'noreply@wickedgov.org',
       'SenderName' => 'User Email',
       'RequireDetails' => true,
       'IncludeIP' => true,
       'MustBeLoggedIn' => false,
       'NameReadonly' => false,
       'EmailReadonly' => false,
       'SubjectReadonly' => false,
       'MustHaveEmail' => false,
       'AdditionalFields' => [
	 'Text' => [
		'label-message' => 'emailmessage',
		'type' => 'textarea',
		'required' => true
	  ],
	],
       'FieldsMergeStrategy' => null,
       'RLModules' => [],
       'RLStyleModules' => [],
];


};
wfLoadExtension( 'ConfirmEdit' );
$wgCaptchaClass = false;
$wgCaptchaTriggers['edit'] = false;
$wgCaptchaTriggers['create'] = false;
$wgCaptchaTriggersOnNamespace[NS_MAIN]['create'] = true;
$wgCaptchaTriggersOnNamespace[NS_USER]['create'] = true;
$wgCaptchaTriggers['sendemail'] = true;
$wgCaptchaTriggers['contactpage'] = true;
$wgCaptchaTriggers['addurl'] = true;
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin'] = true;
$wgCaptchaTriggers['badloginperuser'] = true;
$wgCaptchaBadLoginAttempts = 3;
$wgCaptchaBadLoginExpiration = 300;
$wgCaptchaBadLoginPerUserAttempts = 5;
$wgCaptchaBadLoginPerUserExpiration = 600;
# wgconf
function efGetSiteParams( $conf, $wiki ) {
    $site = null;
    $lang = null;
    foreach( $conf->suffixes as $suffix ) {
        if ( substr( $wiki, -strlen( $suffix ) ) === $suffix ) {
            $site = $suffix;
            $lang = substr( $wiki, 0, -strlen( $suffix ) );
            break;
        }
    }
    return [
        'suffix' => $site,
        'lang' => $lang,
        'params' => [
            'lang' => $lang,
            'site' => $site,
            'wiki' => $wiki,
        ],
        'tags' => [],
    ];
}

$wgConf->siteParamsCallback = 'efGetSiteParams';
$wgConf->extractAllGlobals( $wgDBname );


# Disambiguator configuration
$wgDisambiguatorIndicateLinks = true;
$wgDisambiguatorNotifications = true;

# MobileFrontend configuration
wfLoadExtension( 'MobileFrontend' );
wfLoadSkin( 'MinervaNeue' );
$wgDefaultMobileSkin = 'minerva';
$wgMFAutodetectMobileView = true;

# Popups/Previews configuration
if ($wgDBname !== 'metawiki') {
wfLoadExtension( 'Popups' );
};
$wgPopupsReferencePreviewsBetaFeature = false;

# Scribunto configuration
wfLoadExtension( 'Scribunto' );
$wgScribuntoDefaultEngine = 'luastandalone';

# MLES
$wgBabelCategoryNames = [
	'0' => 'User %code%-0',
	'1' => 'User %code%-1',
	'2' => 'User %code%-2',
	'3' => 'User %code%-3',
	'4' => 'User %code%-4',
	'5' => 'User %code%-5',
	'N' => 'User %code%-N',
];
$wgBabelMainCategory = false;
wfLoadExtension( 'Babel' );
if ($wgDBname === 'metawiki' or $wgDBname === 'commonswiki' or $wgDBname === 'testwiki') {
$wgPageLanguageUseDB = true;

wfLoadExtension( 'cldr' );

wfLoadExtension( 'CleanChanges' );
$wgCCTrailerFilter = true;
$wgCCUserFilter = false;
$wgDefaultUserOptions['usenewrc'] = 1;

wfLoadExtension( 'Translate' );
$wgGroupPermissions['*']['translate'] = true;
$wgGroupPermissions['user']['translate-messagereview'] = true;
$wgTranslateDocumentationLanguageCode = 'qqq';
$wgExtraLanguageNames['qqq'] = 'Message documentation'; # No linguistic content. Used for documenting messages
$wgTranslateFuzzyBotName = 'TranslationBot';
$wgEnablePageTranslation = true;

wfLoadExtension( 'UniversalLanguageSelector' );


};

# Dependency for CentralNotice.
# Do not remove unless you know what you're doing.
wfLoadExtension( 'EventLogging' );
$wgEventLoggingBaseUri = '/beacon/event';
$wgEventLoggingServiceUri = '/beacon/intake-analytics';
$wgEventLoggingStreamNames = false;

# CENTRALNOTICE
wfLoadExtension( 'CentralNotice' );
$wgNoticeProjects = array(
        'wickedgov',
        'sterling',
        'techwiki',
        'commonswiki',
	'metawiki',
	'test',
);
if ($wgDBname === 'metawiki' | $wgDBname === 'testwiki') {
	$wgNoticeInfrastructure = true;
	$wgGroupPermissions['sysop']['centralnotice-admin'] = false;
} else {
	$wgNoticeInfrastructure = false;
	$wgCentralHost = 'https://meta.wickedgov.org';
	$wgCentralSelectedBannerDispatcher = 'https://meta.wickedgov.org/w/index.php/Special:BannerLoader';
	$wgCentralDBname = 'metawiki';
	$wgCentralBannerRecorder = 'https://meta.wickedgov.org/w/index.php/Special:RecordImpression';
};

# Enable user CSS/JS
$wgAllowUserJs = true;
$wgAllowUserCss = true;

if ($wgDBname === 'enwickedgov') {
# Policy: namespace
define("NS_POLICY", 3000); // This MUST be even.
define("NS_POLICY_TALK", 3001); // This MUST be the following odd integer.
$wgExtraNamespaces[NS_POLICY] = "Policy";
$wgExtraNamespaces[NS_POLICY_TALK] = "Policy_talk";
$wgNamespaceProtection[NS_POLICY] = ['editpolicyns'];
};

# Protection levels
if ($wgDBname === 'enwickedgov') {
$wgRestrictionLevels = [ '', 'autoconfirmed', 'editextendedprotected', 'sysop', 'editofficeprotected'];
$wgSemiprotectedRestrictionLevels = ['autoconfirmed', 'editextendedprotected'];
};

$wgAutoConfirmAge = 86400*3;
$wgAutoConfirmCount = 5;
$wgTorAutoConfirmAge = $wgAutoConfirmAge;
$wgTorAutoConfirmCount = $wgAutoConfirmCount;


if ($wgDBname === 'enwickedgov') {
$wgAutopromoteOnce = [
  "onView" => [
    "extendedconfirmed" => [
        "&",
        [
            APCOND_EDITCOUNT,
            100
        ],
        [
            APCOND_AGE_FROM_EDIT,
            1209600
        ],
        [
            "!",
            [
                APCOND_INGROUPS,
                "sysop"
            ]
        ],
        [
            "!",
            [
                APCOND_INGROUPS,
                "bot"
            ]
        ],
	[
	    "!",
	    [
		APCOND_INGROUPS,
		"officestaff"
	    ]
	]
    ]
  ]
];
};

# Disable unused groups/rights from extensions
$wgHooks['MediaWikiServices'][] = static function () {
	global $wgGroupPermissions, $wgDBname;
	unset( $wgGroupPermissions['push-subscription-manager'] );
	unset( $wgGroupPermissions['checkuser-temporary-account-viewer'] );
	unset( $wgGroupPermissions['sysop']['centralnotice-admin'] );
	if ($wgDBname !== 'metawiki') {
		unset ( $wgGroupPermissions['steward']['globalblock'] );
	};
};

# Disallow certain characters in usernames
$wgInvalidUsernameCharacters =  '@:>=.';

# CU config
// Do NOT change these settings without
// office legal approval; thanks.
$wgAbuseFilterLogPrivateDetailsAccess = true;
$wgAbuseFilterPrivateDetailsForceReason = true;
$wgCheckUserForceSummary = true;
$wgCheckUserCAMultiLock = [
    'centralDB' => 'metawiki',
    'groups' => [ 'steward' ]
];
$wgCheckUserCAtoollink = 'metawiki';
$wgCheckUserGBtoollink = $wgCheckUserCAMultiLock;
$wgCheckUserLogLogins = true;
$wgCheckUserLogSuccessfulBotLogins = false;
$wgVirtualDomainsMapping['virtual-checkuser-global'] = ['db' => 'metawiki'];
$wgCUDMaxAge = 86400 * 90;
# end CU config

# Protection of the User: namespace
/*
if ($wgDBname === 'enwickedgov') {
$wgNamespaceProtection[NS_USER] = ['edituserpages'];
};
*/

# CommonsMetadata configuration
$wgCommonsMetadataSetTrackingCategories = true;
$wgCommonsMetadataPublicDomainPageUrl = "https://en.wikipedia.org/wiki/Public_domain";


# Namespace alias for metaspace and metatalkspace
if ($wgDBname === 'enwickedgov') {
    $wgNamespaceAliases['WG'] = NS_PROJECT;
    $wgNamespaceAliases['WT'] = NS_PROJECT_TALK;
};
switch ($wgDBname) {
	case 'enwickedgov':
		$wgNamespaceAliases['WG'] = NS_PROJECT;
		$wgNamespaceAliases['WT'] = NS_PROJECT_TALK;
		break;
	case 'ensterling':
		$wgNamespaceAliases['LW'] = NS_PROJECT;
		$wgNamespaceAliases['LT'] = NS_PROJECT_TALK;
		break;
};

# Prevent Main Page shenanigans on enwickedgov
if ($wgDBname === 'enwickedgov') {
	$wgHooks['getUserPermissionsErrorsExpensive'][] = static function ( &$title, &$user, $action, &$result ) {
	  if ( $action !== 'protect' && $action !== 'unprotect' && $action !== 'delete' && $action !== 'move') {
	    return true;
	  }
	  $main = Title::newMainPage();
	  $mainText = $main->getPrefixedDBkey();
	  if ( $mainText === $title->getPrefixedDBkey() ) {
	    $result = [ 'cant-delete-main-page' ];
	    return false;
	  }
	};
};

# NEW protection indicators
if ($wgDBname === 'enwickedgov') {
	$wgEnableProtectionIndicators = true;
};

# Turn on Realtime Preview in WikiEditor
$wgWikiEditorRealtimePreview = true;

# Restrict deletion of pages with very large histories
$wgDeleteRevisionsLimit = 5000;

# Configure transwiki import sources
$wgImportSources = [
	'wikipedia',
	'mediawikiwiki',
	'metawikimedia',
	'metawiki',
	'enwickedgov',
	'mirahezedev',
];

// Don't allow import from the current wiki
if (($key = array_search($wgDBname, $wgImportSources)) !== false) {
    unset($wgImportSources[$key]);
}

# Set group permissions
$wgExtensionFunctions[] = function() use ( &$wgGroupPermissions )
 {
    unset( $wgGroupPermissions['push-subscription-manager']);
    unset( $wgGroupPermissions['upwizcampeditors']);
};

# BEGIN GRANT CONFIG

$wgGrantPermissions = [
	'basic' => [
		'abusefilter-log' => true,
		'abusefilter-log-detail' => false,
		'abusefilter-view' => true,
		'autocreateaccount' => false,
                'autoconfirmed' => true,
                'autopatrol' => true,
                'editsemiprotected' => true,
		'editextendedprotected' => true,
                'ipblock-exempt' => true,
                'nominornewtalk' => true,
                'patrolmarks' => true,
                'read' => true,
		'skipcaptcha' => true,
		'torunblocked' => true,
                'unwatchedpages' => true,
            ],
            'highvolume' => [
                'bot' => true,
                'apihighlimits' => true,
                'noratelimit' => true,
                'markbotedits' => true,
            ],
            'import' => [
                'import' => true,
                'importupload' => true,
            ],
            'editpage' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
            ],
            'editprotected' => [
		'abusefilter-bypass-blocked-external-domains' => true,
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'editprotected' => true,
		'editofficeprotected' => true,
		'sboverride' => true,
		'tboverride' => true,
            ],
            'editmycssjs' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'editmyusercss' => true,
                'editmyuserjson' => true,
                'editmyuserjs' => true,
            ],
            'editmyoptions' => [
                'editmyoptions' => true,
                'editmyuserjson' => true,
            ],
            'editinterface' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'editinterface' => true,
                'edituserjson' => true,
                'editsitejson' => true,
            ],
            'editsiteconfig' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'editinterface' => true,
                'edituserjson' => true,
                'editsitejson' => true,
                'editusercss' => true,
                'edituserjs' => true,
                'editsitecss' => true,
                'editsitejs' => true,
            ],
            'createeditmovepage' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'createpage' => true,
                'createtalk' => true,
                'delete-redirect' => true,
                'move' => true,
                'move-rootuserpages' => true,
                'move-subpages' => true,
                'move-categorypages' => true,
                'suppressredirect' => true,
            ],
            'uploadfile' => [
                'upload' => true,
                'reupload-own' => true,
            ],
            'uploadeditmovefile' => [
                'upload' => true,
                'reupload-own' => true,
                'reupload' => true,
                'upload_by_url' => true,
                'movefile' => true,
                'suppressredirect' => true,
            ],
            'patrol' => [
                'patrol' => true,
            ],
            'rollback' => [
                'rollback' => true,
            ],
            'blockusers' => [
                'block' => true,
                'blockemail' => true,
            ],
            'viewdeleted' => [
                'browsearchive' => true,
                'deletedhistory' => true,
                'deletedtext' => true,
            ],
            'viewrestrictedlogs' => [
		'abusefilter-hidden-log' => true,
		'abusefilter-log-private' => true,
		'abusefilter-view-private' => true,
		'spamblacklistlog' => true,
                'suppressionlog' => true,
		'titleblacklistlog' => true,
            ],
            'delete' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'browsearchive' => true,
                'deletedhistory' => true,
                'deletedtext' => true,
                'delete' => true,
                'bigdelete' => true,
                'deletelogentry' => true,
                'deleterevision' => true,
                'undelete' => true,
		'nuke' => true,
            ],
            'oversight' => [
		'abusefilter-hide-log' => true,
                'suppressrevision' => true,
                'viewsuppressed' => true,
            ],
            'protect' => [
                'edit' => true,
                'minoredit' => true,
                'applychangetags' => true,
                'changetags' => true,
                'editcontentmodel' => true,
                'editprotected' => true,
		'editofficeprotected' => true,
                'protect' => true,
            ],
            'viewmywatchlist' => [
                'viewmywatchlist' => true,
            ],
            'editmywatchlist' => [
                'editmywatchlist' => true,
            ],
            'sendemail' => [
                'sendemail' => true,
            ],
            'createaccount' => [
                'createaccount' => true,
		'tboverride-account' => true,
		'override-antispoof' => true,
            ],
            'privateinfo' => [
                'viewmyprivateinfo' => true,
            ],
            'mergehistory' => [
                'mergehistory' => true,
            ],
	'oath' => [
		'oathauth-api-all' => true,
		'oathauth-verify-user' => true,
	],
	'checkuser' => [
		'checkuser' => true,
		'checkuser-log' => true,
	],
	'checkuser-temporary-account' => [
		'checkuser-temporary-account' => true,
		'checkuser-temporary-account-no-preference' => true,
		'checkuser-temporary-account-log' => true,
	],
];
# END GRANT CONFIG

# Rate limit stuff
$wgRateLimits = [
	'move' => [
		'newbie' => [ 2, 120 ],
		# To limit high-rate move page attacks on smaller wikis
		# Newbie limit was trivially avoided by a patient vandal
		'user' => [ 8, 60 ],
	],
		'edit' => [
			// 8 ed./min per each non-autoconfirmed, or group thereof from same IP
			'ip' => [ 8, 60 ],
			'newbie' => [ 8, 60 ],
			'user' => [ 90, 60 ],
		],
		'badcaptcha' => [ // Bug T92376
			// Mainly for account creation by unregistered spambots.
			// A human probably gives up after a handful attempts to
			// register, but ip/newbie editing needs to be considered too.
			'ip' => [ 15, 60 ],
			'newbie' => [ 15, 60 ],
			// Mainly to catch linkspam bot edits. Account creations by users?
			// Some wikis request tons of captchas to users under 50 edits:
			// the limit needs to be higher than any human can conceivably do.
			'user' => [ 30, 60 ],
		],
		'mailpassword' => [
			// 5 password reminders per hour per IP
			'ip' => [ 5, 3600 ],
		],
		'sendemail' => [
			'ip' => [ 5, 86400 ], // 5 per day per ip (logged-out and new users)
			'newbie' => [ 5, 86400 ], // 5 per day for non-autoconfirmed
			'user-global' => [ 20, 86400 ], // 20 per day for users
		],
		'changeemail' => [
			'ip-all' => [ 10, 3600 ],
			'user' => [ 4, 86400 ]
		],
		// For expanded rollback permissions...
		'rollback' => [
			'user' => [ 100, 60 ], // T228708
			'newbie' => [ 5, 120 ],
		],
		'purge' => [
			// 30 page purges per minute
			'ip' => [ 30, 60 ],
			'user' => [ 30, 60 ],
		],
		'linkpurge' => [
			// 30 backlink purges per minute
			'ip' => [ 30, 60 ],
			'user' => [ 30, 60 ],
		],
		'renderfile' => [
			// 1400 new thumbnails per minute
			'ip' => [ 700, 30 ],
			'user' => [ 700, 30 ],
		],
		'renderfile-nonstandard' => [
			// 140 new thumbnails per minute
			'ip' => [ 70, 30 ],
			'user' => [ 70, 30 ],
		],
		'cxsave' => [
			// 10 saves per 30 seconds
			'ip' => [ 10, 30 ],
			'user' => [ 10, 30 ],
		],
		'badoath' => [
			'&can-bypass' => false,
			'user' => [ 10, 60 ],
			'user-global' => [ 10, 60 ],
		],
		'upload' => [
			'user' => [ 10, 120 ],
			'newbie' => [ 3, 120 ],
		],

];

#Number of account creations per IP per day
$wgAccountCreationThrottle = [ [
        'count' => 10,
        'seconds' => 86400,
] ];


# Password policies
$wgPasswordPolicy['policies'] = [
		'bureaucrat' => [
			'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
			'MinimumPasswordLengthToLogin' => 1,
		],
		'sysop' => [
			'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
			'MinimumPasswordLengthToLogin' => 1,
		],
		'interface-admin' => [
			'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
			'MinimumPasswordLengthToLogin' => 1,
		],
		'bot' => [
			'MinimalPasswordLength' => 8,
			'MinimumPasswordLengthToLogin' => 1,
		],
		'checkuser' => [
                        'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
                        'MinimumPasswordLengthToLogin' => 1,
		],
		'suppress' => [
			'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
                        'MinimumPasswordLengthToLogin' => 1,
		],
		'importupload' => [
                        'MinimalPasswordLength' => ['value' => 10, 'forceChange' => true],
                        'MinimumPasswordLengthToLogin' => 1,
		],
		'steward' => [
			'MinimalPasswordLength' => [ 'value' => 12, 'forceChange' => true ],
			'MinimumPasswordLengthToLogin' => 1,
		],
		'default' => [
			'MinimalPasswordLength' => [ 'value' => 8, 'suggestChangeOnLogin' => true ],
			'PasswordCannotBeSubstringInUsername' => [
				'value' => true,
				'suggestChangeOnLogin' => true
			],
			'PasswordCannotMatchDefaults' => [ 'value' => true, 'suggestChangeOnLogin' => true ],
			'MaximalPasswordLength' => [ 'value' => 4096, 'suggestChangeOnLogin' => true ],
			'PasswordNotInCommonList' => [ 'value' => true, 'suggestChangeOnLogin' => true ],
		],
];
$wgCentralAuthGlobalPasswordPolicies['policies'] = [
	'steward' => [
        	'MinimalPasswordLength' => [ 'value' => 12, 'forceChange' => true ],
                'MinimumPasswordLengthToLogin' => 1,
	],
	'global-sysop' => [
		'MinimalPasswordLength' => [ 'value' => 10, 'forceChange' => true ],
                'MinimumPasswordLengthToLogin' => 1,
	],
        'sysadmin' => [
                'MinimalPasswordLength' => [ 'value' => 12, 'forceChange' => true ],
                'MinimumPasswordLengthToLogin' => 1,
        ],
	'staff' => [
                'MinimalPasswordLength' => [ 'value' => 12, 'forceChange' => true ],
                'MinimumPasswordLengthToLogin' => 1,
        ],
	'default' => [
		'MinimalPasswordLength' => [ 'value' => 8, 'suggestChangeOnLogin' => true ],
                'PasswordCannotBeSubstringInUsername' => [
                	'value' => true,
                	'suggestChangeOnLogin' => true
                ],
                'PasswordCannotMatchDefaults' => [ 'value' => true, 'suggestChangeOnLogin' => true ],
                'MaximalPasswordLength' => [ 'value' => 4096, 'suggestChangeOnLogin' => true ],
                'PasswordNotInCommonList' => [ 'value' => true, 'suggestChangeOnLogin' => true ],
	],
];


# Stewards outside metawiki
if ($wgDBname !== 'metawiki') {
  $wgExtensionFunctions[] = function() use ( &$wgGroupPermissions ) {
    unset( $wgGroupPermissions['steward'] );
    $wgGroupPermissions['steward']['userrights'] = true;
    $wgGroupPermissions['steward']['edit'] = true;
  };
};

$wgScriptPath = "/w";
$wgResourceBasePath = $wgScriptPath;
$wgRightsIcon = "$wgScriptPath/resources/assets/licenses/cc-by-sa.png";

$wgEnableMultiBlocks = true;
$wgEnablePartialActionBlocks = true;

$wgExtensionFunctions[] = function() use ( &$wgGroupPermissions ) {
    unset( $wgGroupPermissions['push-subscription-manager'] );
};

$wgCookieSameSite = "None";
$wgUseSameSiteLegacyCookies = true;
$wgCentralAuthCookies = true;
$wgCentralAuthCookieDomain = '.wickedgov.org';
$wgCentralAuthAutoMigrate = true;
$wgCentralAuthLoginWiki = 'loginwiki';
$wgCentralAuthAutoMigrateNonGlobalAccounts = true;
$wgCentralAuthStrict = true;
$wgCentralAuthAutoCreateWikis = ['loginwiki', 'metawiki'];
$wgCentralAuthAutoLoginWikis = [
    # Mapping from domain name to wiki id for other wikis to automatically login into
    'login.wickedgov.org' => 'loginwiki',
];
if ($wgDBname === 'metawiki') {
	$wgCentralAuthEnableGlobalRenameRequest	= true;
};
$wgCentralAuthAutomaticVanishPerformer = 'GlobalVanishRequests';

$wgAbuseFilterCentralDB	= 'metawiki';
if ($wgDBname === 'metawiki') {
	$wgAbuseFilterIsCentral	= true;
};

if ($wgDBname === 'testwiki' or $wgDBname === 'loginwiki') {
$wgAutoCreateTempUser = [
        'known' => true,
        'enabled' => true,
        'actions' => [
                'edit',
        ],
        'genPattern' => '~$1',
        'matchPattern' => null,
        'reservedPattern' => '~$1',
        'serialProvider' => [
                'type' => 'centralauth',
                'useYear' => true,
        ],
        'serialMapping' => [
                'type' => 'plain-numeric',
        ],
        'expireAfterDays' => 90,
        'notifyBeforeExpirationDays' => 10,
];
} else {
$wgAutoCreateTempUser = [
	'known' => false,
	'enabled' => false,
	'actions' => [
		'edit',
	],
	'genPattern' => '~$1',
	'matchPattern' => null,
	'reservedPattern' => '~$1',
	'serialProvider' => [
		'type' => 'centralauth',
		'useYear' => true,
	],
	'serialMapping' => [
		'type' => 'plain-numeric',
	],
	'expireAfterDays' => 90,
	'notifyBeforeExpirationDays' => 10,
];
};
$wgInterwikiCentralDB = 'metawiki';

