summaryrefslogtreecommitdiff
path: root/extensions/Renameuser/Renameuser.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /extensions/Renameuser/Renameuser.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'extensions/Renameuser/Renameuser.php')
-rw-r--r--extensions/Renameuser/Renameuser.php113
1 files changed, 113 insertions, 0 deletions
diff --git a/extensions/Renameuser/Renameuser.php b/extensions/Renameuser/Renameuser.php
new file mode 100644
index 00000000..ecfb4298
--- /dev/null
+++ b/extensions/Renameuser/Renameuser.php
@@ -0,0 +1,113 @@
+<?php
+if ( !defined( 'MEDIAWIKI' ) ) die();
+/**
+ * A Special Page extension to rename users, runnable by users with renameuser
+ * righs
+ *
+ * @file
+ * @ingroup Extensions
+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ */
+
+$wgAvailableRights[] = 'renameuser';
+$wgGroupPermissions['bureaucrat']['renameuser'] = true;
+
+$wgExtensionCredits['specialpage'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Renameuser',
+ 'author' => array( 'Ævar Arnfjörð Bjarmason', 'Aaron Schulz' ),
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Renameuser',
+ 'descriptionmsg' => 'renameuser-desc',
+);
+
+# Internationalisation file
+$dir = dirname( __FILE__ ) . '/';
+$wgExtensionMessagesFiles['Renameuser'] = $dir . 'Renameuser.i18n.php';
+$wgExtensionAliasesFiles['Renameuser'] = $dir . 'Renameuser.alias.php';
+
+/**
+ * Users with more than this number of edits will have their rename operation
+ * deferred via the job queue.
+ */
+define( 'RENAMEUSER_CONTRIBJOB', 5000 );
+
+# Add a new log type
+global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;
+$wgLogTypes[] = 'renameuser';
+$wgLogNames['renameuser'] = 'renameuserlogpage';
+$wgLogHeaders['renameuser'] = 'renameuserlogpagetext';
+# $wgLogActions['renameuser/renameuser'] = 'renameuserlogentry';
+$wgLogActionsHandlers['renameuser/renameuser'] = 'wfRenameUserLogActionText'; // deal with old breakage
+
+/**
+ * @param $type
+ * @param $action
+ * @param $title Title
+ * @param $skin Skin
+ * @param $params array
+ * @param $filterWikilinks bool
+ * @return String
+ */
+function wfRenameUserLogActionText( $type, $action, $title = null, $skin = null, $params = array(), $filterWikilinks = false ) {
+ if ( !$title || $title->getNamespace() !== NS_USER ) {
+ $rv = ''; // handled in comment, the old way
+ } else {
+ $titleLink = $skin ?
+ $skin->makeLinkObj( $title, htmlspecialchars( $title->getPrefixedText() ) ) : htmlspecialchars( $title->getText() );
+ # Add title to params
+ array_unshift( $params, $titleLink );
+ $rv = wfMsg( 'renameuserlogentry', $params );
+ }
+ return $rv;
+}
+
+$wgAutoloadClasses['SpecialRenameuser'] = dirname( __FILE__ ) . '/Renameuser_body.php';
+$wgAutoloadClasses['RenameUserJob'] = dirname( __FILE__ ) . '/RenameUserJob.php';
+$wgSpecialPages['Renameuser'] = 'SpecialRenameuser';
+$wgSpecialPageGroups['Renameuser'] = 'users';
+$wgJobClasses['renameUser'] = 'RenameUserJob';
+
+$wgHooks['ShowMissingArticle'][] = 'wfRenameUserShowLog';
+$wgHooks['ContributionsToolLinks'][] = 'wfRenameuserOnContribsLink';
+
+/**
+ * Show a log if the user has been renamed and point to the new username.
+ * Don't show the log if the $oldUserName exists as a user.
+ *
+ * @param $article Article
+ */
+function wfRenameUserShowLog( $article ) {
+ global $wgOut;
+ $title = $article->getTitle();
+ $oldUser = User::newFromName( $title->getBaseText() );
+ if ( ($title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) && ($oldUser && $oldUser->isAnon() )) {
+ // Get the title for the base userpage
+ $page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )->getPrefixedDBkey();
+ LogEventsList::showLogExtract( $wgOut, 'renameuser', $page, '', array( 'lim' => 10, 'showIfEmpty' => false,
+ 'msgKey' => array( 'renameuser-renamed-notice', $title->getBaseText() ) ) );
+ }
+ return true;
+}
+
+/**
+ * @param $id
+ * @param $nt Title
+ * @param $tools
+ * @return bool
+ */
+function wfRenameuserOnContribsLink( $id, $nt, &$tools ) {
+ global $wgUser;
+
+ if ( $wgUser->isAllowed( 'renameuser' ) && $id ) {
+ $sk = $wgUser->getSkin();
+ $tools[] = $sk->link(
+ SpecialPage::getTitleFor( 'Renameuser' ),
+ wfMsg( 'renameuser-linkoncontribs' ),
+ array( 'title' => wfMsgExt( 'renameuser-linkoncontribs-text', 'parseinline' ) ),
+ array( 'oldusername' => $nt->getText() )
+ );
+ }
+ return true;
+}