LukBukkit has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/404169 )
Change subject: Using the extension registration (extension.json) ...................................................................... Using the extension registration (extension.json) Change-Id: I53831f06577ba8024a93e3a77e9fd8fa7a73c3cc --- M NetworkAuth.php A NetworkAuthHooks.php A extension.json 3 files changed, 79 insertions(+), 54 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NetworkAuth refs/changes/69/404169/1 diff --git a/NetworkAuth.php b/NetworkAuth.php index f51651d..c7cc86e 100644 --- a/NetworkAuth.php +++ b/NetworkAuth.php @@ -1,55 +1,14 @@ <?php -/* -Copyright (C) 2012,2013 Olaf Lenz <http://www.mediawiki.org/wiki/User:Olenz> -Copyright (C) 2007,2008,2009,2010,2011 Tim Laqua - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -http://www.gnu.org/copyleft/gpl.html -*/ - -if ( !defined( 'MEDIAWIKI' ) ) { - die(); -} - -$wgExtensionCredits['other'][] = array( - 'path' => __FILE__, - 'name' => 'NetworkAuth', - 'version' => '2.1.2', - 'author' => array( 'Tim Laqua', 'Olaf Lenz' ), - 'descriptionmsg' => 'networkauth-desc', - 'url' => 'https://www.mediawiki.org/wiki/Extension:NetworkAuth', - 'license-name' => 'GPL-2.0+', -); - -$wgAutoloadClasses['NetworkAuth'] = __DIR__ . '/NetworkAuth.class.php'; -$wgMessagesDirs['NetworkAuth'] = __DIR__ . '/i18n'; -// defaults -if ( !isset( $wgNetworkAuthUsers ) ) - $wgNetworkAuthUsers = array(); -if ( !isset( $wgNetworkAuthSpecialUsers ) ) - $wgNetworkAuthSpecialUsers = array(); - -$wgExtensionFunctions[] = function() { - global $wgHooks, $wgNetworkAuth, $wgNetworkAuthUsers, $wgNetworkAuthSpecialUsers; - - $wgNetworkAuth = new NetworkAuth( $wgNetworkAuthUsers, $wgNetworkAuthSpecialUsers ); - - $wgHooks['UserLoadAfterLoadFromSession'][] = - array( $wgNetworkAuth, 'onUserLoadAfterLoadFromSession' ); - $wgHooks['PersonalUrls'][] = - array( $wgNetworkAuth, 'onPersonalUrls' ); - - return true; -}; +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'NetworkAuth' ); + // Keep i18n globals so mergeMessageFileList.php doesn't break + $wgMessagesDirs['NetworkAuth'] = __DIR__ . '/i18n'; + wfWarn( + 'Deprecated PHP entry point used for the NetworkAuth extension. ' . + 'Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + ); + return; +} else { + die( 'This version of the NetworkAuth extension requires MediaWiki 1.25+' ); +} \ No newline at end of file diff --git a/NetworkAuthHooks.php b/NetworkAuthHooks.php new file mode 100644 index 0000000..14e8d39 --- /dev/null +++ b/NetworkAuthHooks.php @@ -0,0 +1,32 @@ +<?php + +/** + * A wrapper class for the hooks of this extension. + */ +class NetworkAuthHooks { + + private static $wgNetworkAuth; + + public static function onUserLoadAfterLoadFromSession( $user ) { + self::getNetworkAuth()->onUserLoadAfterLoadFromSession( $user ); + } + + public static function onPersonalUrls( &$personal_urls, &$title ) { + self::getNetworkAuth()->onPersonalUrls( $personal_urls, $title ); + } + + /** + * Creates, if necessary, a instance of the NetworkAuth and returns it. + * + * @return NetworkAuth + */ + private static function getNetworkAuth() { + global $wgNetworkAuthUsers, $wgNetworkAuthSpecialUsers; + + if ( isset( $wgNetworkAuth ) ) return NetworkAuthHooks::$wgNetworkAuth; + + NetworkAuthHooks::$wgNetworkAuth = new NetworkAuth( $wgNetworkAuthUsers, $wgNetworkAuthSpecialUsers ); + return NetworkAuthHooks::$wgNetworkAuth; + } + +} \ No newline at end of file diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..71b04ab --- /dev/null +++ b/extension.json @@ -0,0 +1,34 @@ +{ + "name": "NetworkAuth", + "version": "2.1.2", + "author": [ + "Tim Laqua", + "Olaf Lenz" + ], + "url": "https://www.mediawiki.org/wiki/Extension:NetworkAuth", + "descriptionmsg": "networkauth-desc", + "license-name": "GPL-2.0-or-later", + "type": "other", + "MessagesDirs": { + "NetworkAuth": [ + "i18n" + ] + }, + "AutoloadClasses": { + "NetworkAuth": "NetworkAuth.class.php", + "NetworkAuthHooks": "NetworkAuthHooks.php" + }, + "Hooks": { + "UserLoadAfterLoadFromSession": "NetworkAuthHooks::onUserLoadAfterLoadFromSession", + "PersonalUrls": "NetworkAuthHooks::onPersonalUrls" + }, + "config": { + "NetworkAuthUsers": { + "value": [] + }, + "NetworkAuthSpecialUsers": { + "value": [] + } + }, + "manifest_version": 2 +} -- To view, visit https://gerrit.wikimedia.org/r/404169 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I53831f06577ba8024a93e3a77e9fd8fa7a73c3cc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/NetworkAuth Gerrit-Branch: master Gerrit-Owner: LukBukkit <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
