MediaWiki扩展:编辑前确认Email
天下维客,你可以修改的网络知识库
本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^
This describes my hack that requires email authentication before editing for Wiki 1.5. - Tbsmith
This hack is for 1.5.
If you are using 1.6, just add '$wgEmailConfirmToEdit = true;' to the end of your LocalSettings.php file.
For those with 1.5, first add this code to includes/EditPage.php (~line 158):
....
if (!$wgUser->isAllowed('edit') ){
if ( $wgUser->isAnon() ) {
$this->userNotLoggedInPage();
return;
} else {
$wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
return;
}
}
## Add this for email authentication before editing#
if (!$wgUser->getEmailAuthenticationTimestamp() ) {
$this->userHasNotAuthenticatedEmailPage();
return;
}
#################################################
if ( wfReadOnly() ) {
....
Put this code in the same file above the userNotLoggedInPage function on about line 858:
#### Add this function for Email Authentication before editing ###
function userHasNotAuthenticatedEmailPage() {
global $wgOut;
$wgOut->setPageTitle( wfMsg( 'noemailauthtitle' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiText( wfMsg( 'noemailauthtext' ) );
$wgOut->returnToMain( false );
}
###################################################################
function userNotLoggedInPage() {
....
Add this to languages/Language.php line 692: (for 1.6 seems like context is in languages/Messages.php (-- added edit)
'whitelistedittitle' => 'Login required to edit', 'whitelistedittext' => 'You have to [[Special:Userlogin|login]] to edit pages.', ###### Add for email auth before editing ############### 'noemailauthtitle' => 'Email Authentication Required', 'noemailauthtext' => 'You have to [[Special:Confirmemail|confirm]] your email address to edit pages.', ########################################################


