mediawiki-extensions-TitleB.../TitleBlacklist.hooks.php
Victor Vasiliev d6a7b33f91 TitleBlacklist:
* Add TitleBlacklistEntry class
* Add entry attributes
* Temporary remove error message for userCan. Needs better hook
* Changed configuration structure
2007-12-10 19:02:38 +00:00

49 lines
1.4 KiB
PHP

<?php
/**
* Hooks for Title Blacklist
*
* @package MediaWiki
* @subpackage Extensions
* @author VasilievVV
* @copyright © 2007 VasilievVV
* @licence GNU General Public Licence 2.0 or later
*/
class TitleBlacklistHooks {
public static function userCan( $title, $user, $action, &$result )
{
global $wgTitleBlacklist;
if ( $action != 'create' && $action != 'edit' ) {
$result = true;
return $result;
}
$blacklisted = $wgTitleBlacklist->isBlacklisted( $title, $action );
if( is_string( $blacklisted ) ) {
//return wfMsgWikiHtml( "titleblacklist-forbidden-edit", htmlspecialchars( $blacklisted ), $title->getFullText() );
return $result = false;
}
return $result = true;
}
public static function abortMove( $old, $nt, $user, &$err ) {
global $wgTitleBlacklist;
$blacklisted = $wgTitleBlacklist->isBlacklisted( $nt, 'move' );
if( is_string( $blacklisted ) ) {
$err = wfMsgWikiHtml( "titleblacklist-forbidden-move", htmlspecialchars( $blacklisted ), $nt->getFullText(), $old->getFullText() );
return false;
}
return true;
}
public static function verifyUpload( $fname, $fpath, &$err ) {
global $wgTitleBlacklist, $wgUser;
$blacklisted = $wgTitleBlacklist->isBlacklisted( $fname, 'upload' );
if( is_string( $blacklisted ) ) {
$err = wfMsgWikiHtml( "titleblacklist-forbidden-upload", htmlspecialchars( $blacklisted ), $fname );
return false;
}
return true;
}
}