-
Notifications
You must be signed in to change notification settings - Fork 28
/
CanastaUtils.php
57 lines (51 loc) · 1.82 KB
/
CanastaUtils.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
<?php
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
/**
* @param $extName
*/
function cfLoadExtension( $extName ) {
echo "Error: As of Canasta 1.3.0, the cfLoadExtension function has been removed. Use wfLoadExtension instead.\r\n";
echo "The following extension was loaded with cfLoadExtension, but needs to be loaded with wfLoadExtension instead: $extName";
die();
}
/**
* @param $skinName
*/
function cfLoadSkin( $skinName ) {
echo "Error: As of Canasta 1.3.0, the cfLoadSkin function has been removed. Use wfLoadSkin instead.\r\n";
echo "The following skin was loaded with cfLoadSkin, but needs to be loaded with wfLoadSkin instead: $skinName";
die();
}
/**
* Not exactly a utility function, but - show a warning to users if $wgSMTP is not set.
*/
$wgHooks['SiteNoticeAfter'][] = function ( &$siteNotice, Skin $skin ) {
global $wgSMTP, $wgEnableEmail, $wgEnableUserEmail;
if ( !$wgEnableEmail || $wgSMTP ) {
return;
}
$title = $skin->getTitle();
if ( !$title->isSpecialPage() ) {
return;
}
$specialPage = MediaWiki\MediaWikiServices::getInstance()
->getSpecialPageFactory()
->getPage( $title->getText() );
if ( $specialPage == null ) {
return;
}
$canonicalName = $specialPage->getName();
// Only display this warning for pages that could result in an email getting sent.
$specialPagesWithEmail = [ 'Preferences', 'CreateAccount' ];
if ( $wgEnableUserEmail ) {
$specialPagesWithEmail[] = 'Emailuser';
}
if ( !in_array( $canonicalName, $specialPagesWithEmail ) ) {
return;
}
$warningText = 'Please note that mailing does not currently work on this wiki, because Canasta requires <a href="https://www.mediawiki.org/wiki/Manual:$wgSMTP">$wgSMTP</a> to be set in order to send emails.';
$siteNotice .= Html::warningBox( '<span style="font-size: larger;">' . $warningText . '</span>' );
};