There is no RationalWiki without you. We are a small non-profit with no staff—we are hundreds of volunteers who document pseudoscience and crankery around the world every day. We will never allow ads because we must remain independent. We cannot rely on big donors with corresponding big agendas. We are not the largest website around, but we believe we play an important role in defending truth and objectivity. |
Fighting pseudoscience isn't free. We are 100% user-supported! Help and donate $5, $10, $20 or whatever you can today with ![]() ![]() |
User:Nx/Extensions/Intercom/Intercom.php
< User:Nx | Extensions
Jump to navigation
Jump to search
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
# change varbinary to varchar depending on wiki settings
# create table /*$wgDBprefix*/intercom_message (id int NOT NULL auto_increment, summary tinyblob, message mediumblob, author int unsigned NOT NULL, list varbinary(255) NOT NULL, timestamp varbinary(14), expires varbinary(14), parsed boolean NOT NULL default true, PRIMARY KEY id (id)) /*$wgDBTableOptions*/;
# create table /*$wgDBprefix*/intercom_list (userid int unsigned NOT NULL, list varbinary(255) NOT NULL, PRIMARY KEY (userid,list)) /*$wgDBTableOptions*/;
# create table /*$wgDBprefix*/intercom_read (userid int unsigned NOT NULL, messageid int unsigned NOT NULL, PRIMARY KEY (userid,messageid)) /*$wgDBTableOptions*/;
# give crats the right to send urgent messages
$wgGroupPermissions['bureaucrat']['intercom-sendurgent'] = true;
# give autoconfirmed users the right to send urgent messages
$wgGroupPermissions['autoconfirmed']['intercom-sendmessage'] = true;
$wgExtensionCredits['other'][] = array(
'name' => 'RationalWiki Intercom',
'author' => '[http://rationalwiki.com/wiki/User:Tmtoulouse Trent Toulouse]',
'url' => 'http://rationalwiki.com/',
'description' => 'Creates a sitewide message to all users'
);
$wgHooks['SiteNoticeAfter'][] = 'Intercom::DisplayMessages';
$wgSpecialPages['Intercom'] = 'SpecialIntercom';
global $wgUseAjax;
if ($wgUseAjax)
{
$wgAjaxExportList[] = 'Intercom::getNextMessage';
$wgAjaxExportList[] = 'Intercom::getPrevMessage';
$wgAjaxExportList[] = 'Intercom::markRead';
}
$wgHooks['AjaxAddScript'][] = 'Intercomaddjs';
function Intercomaddjs($out) {
global $wgJsMimeType, $wgScriptPath;
$out->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/Intercom/js/Intercom.js\"></script>");
return true;
}
## include path
$wgIntercomIP = dirname( __FILE__ );
$wgExtensionMessagesFiles['Intercom'] = "$wgIntercomIP/Intercom.i18n.php";
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'intercominit';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'intercominit';
}
function intercominit() {
wfLoadExtensionMessages('Intercom');
return true;
}
## Load classes
$wgAutoloadClasses['Intercom'] = "$wgIntercomIP/Intercom.body.php";
$wgAutoloadClasses['SpecialIntercom'] = "$wgIntercomIP/Intercom.body.php";