Mhutti1 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/257698
Change subject: Converted GoogleLogin to new extension registration system
......................................................................
Converted GoogleLogin to new extension registration system
Moved most of GoogleLogin.php to the new extension.json and added method for
backward compatable implementation of the extension if still called though the
php file.
Bug: T120644
Change-Id: I523ab79687debcaecd9c20b5b310b29ef258fc2b
---
M GoogleLogin.php
A extension.json
2 files changed, 168 insertions(+), 191 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleLogin
refs/changes/98/257698/1
diff --git a/GoogleLogin.php b/GoogleLogin.php
index 1f58798..d6f4099 100644
--- a/GoogleLogin.php
+++ b/GoogleLogin.php
@@ -25,195 +25,16 @@
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This is an extension for Mediawiki and can not run standalone.' );
}
-
-// master and v2.x requires MediaWiki 1.26
-if ( version_compare( $wgVersion, '1.26c', '<' ) ) {
- echo "This version of GoogleLogin requires MediaWiki 1.26, you have
$wgVersion.<br>
- You can <a href='https://www.mediawiki.org/wiki/Upgrade'>upgrade your
MediaWiki Installation</a>
- or <a
href='https://www.mediawiki.org/wiki/Special:ExtensionDistributor/GoogleLogin'>download
a
- version of GoogleLogin</a> which supports your MediaWiki version.";
- die( -1 );
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'GoogleLogin' );
+ // Keep i18n globals so mergeMessageFileList.php doesn't break
+ $wgMessagesDirs['GoogleLogin'] = __DIR__ . '/i18n';
+ $wgExtensionMessagesFiles['GoogleLogin'] = __DIR__ .
'/GoogleLogin.alias.php';
+ wfWarn(
+ 'Deprecated PHP entry point used for GoogleLogin extension.
Please use wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
+ );
+ return;
+} else {
+ die( 'This version of the Google Login extension requires MediaWiki
1.25+' );
}
-
-$wgExtensionCredits['specialpage'][] = array(
- 'path' => __FILE__,
- 'name' => 'GoogleLogin',
- 'author' => 'Florian Schmidt',
- 'url' => 'https://www.mediawiki.org/wiki/Extension:GoogleLogin',
- 'descriptionmsg' => 'googlelogin-desc',
- 'version' => '0.3.1-git',
- 'license-name' => "MIT",
-);
-
-// Autoload Classes
-$wgAutoloadClasses[ 'GoogleLogin' ] = __DIR__ .
'/includes/GoogleLogin.body.php';
-$wgAutoloadClasses[ 'SpecialGoogleLogin' ] = __DIR__ .
'/includes/specials/SpecialGoogleLogin.php';
-$wgAutoloadClasses[ 'SpecialManageGoogleLogin' ] =
- __DIR__ . '/includes/specials/SpecialManageGoogleLogin.php';
-$wgAutoloadClasses[ 'GoogleLoginHooks' ] = __DIR__ .
'/includes/GoogleLogin.hooks.php';
-$wgAutoloadClasses[ 'GoogleLogin\\GoogleUser' ] = __DIR__ .
'/includes/GoogleUser.php';
-$wgAutoloadClasses[ 'ApiGoogleLoginInfo' ] = __DIR__ .
'/includes/api/ApiGoogleLoginInfo.php';
-
-// i18n directory and aliases
-$wgExtensionMessagesFiles[ 'GoogleLoginAlias' ] = __DIR__ .
'/GoogleLogin.alias.php';
-$wgMessagesDirs['GoogleLogin'] = __DIR__ . '/i18n';
-
-// new user rights for this extension
-$wgGroupPermissions['sysop']['managegooglelogin'] = true;
-$wgAvailableRights[] = 'managegooglelogin';
-
-// Special Page
-$wgSpecialPages[ 'GoogleLogin' ] = 'SpecialGoogleLogin';
-$wgSpecialPages[ 'ManageGoogleLogin' ] = 'SpecialManageGoogleLogin';
-
-// API Modules
-$wgAPIModules['googleplusprofileinfo'] = 'ApiGoogleLoginInfo';
-
-// Hooks
-$wgHooks['UserLogoutComplete'][] = 'GoogleLoginHooks::onUserLogoutComplete';
-$wgHooks['LoadExtensionSchemaUpdates'][] =
'GoogleLoginHooks::onLoadExtensionSchemaUpdates';
-$wgHooks['UserLoginForm'][] = 'GoogleLoginHooks::onUserLoginForm';
-$wgHooks['UserCreateForm'][] = 'GoogleLoginHooks::onUserCreateForm';
-$wgHooks['PersonalUrls'][] = 'GoogleLoginHooks::onPersonalUrls';
-$wgHooks['SpecialPage_initList'][] =
'GoogleLoginHooks::onSpecialPage_initList';
-$wgHooks['GetPreferences'][] = 'GoogleLoginHooks::onGetPreferences';
-$wgHooks['RecentChange_save'][] = 'GoogleLoginHooks::onRecentChange_save';
-$wgHooks['ListDefinedTags'][] = 'GoogleLoginHooks::onListDefinedAndActiveTags';
-$wgHooks['ChangeTagsListActive'][] =
'GoogleLoginHooks::onListDefinedAndActiveTags';
-$wgHooks['LoginFormValidErrorMessages'][] =
'GoogleLoginHooks::onLoginFormValidErrorMessages';
-$wgHooks['UnitTestsList'][] = 'GoogleLoginHooks::onUnitTestsList';
-
-// ResourceLoader modules
-// path template
-$wgGLResourcePath = array(
- 'localBasePath' => __DIR__,
- 'remoteExtPath' => 'GoogleLogin'
-);
-
-$wgResourceModules += array(
- 'ext.GoogleLogin.style' => $wgGLResourcePath + array(
- 'styles' => 'style/ext.GoogleLogin.css',
- 'position' => 'top',
- 'targets' => array( 'desktop', 'mobile' ),
- ),
- 'ext.GoogleLogin.right.style' => $wgGLResourcePath + array(
- 'styles' => 'style/ext.GoogleLogin.right.css',
- 'position' => 'top',
- ),
-);
-
-$wgResourceModules += array(
- 'ext.GoogleLogin.specialManage.scripts' => $wgGLResourcePath + array(
- 'dependencies' => array(
- 'mediawiki.api',
- 'oojs-ui'
- ),
- 'scripts' => array(
-
'javascripts/specialpages/ext.GoogleLogin.specialManage.js'
- ),
- 'styles' => array(
- 'style/ext.GoogleLogin.specialManage.css'
- ),
- 'messages' => array(
- 'googlelogin-googleuser',
- 'googlelogin-manage-isplusser',
- 'googlelogin-manage-orgname',
- 'googlelogin-manage-orgtitle',
- 'googlelogin-manage-orgsince',
- 'googlelogin-manage-yes',
- 'googlelogin-manage-no',
- 'googlelogin-manage-errorloading',
- 'googlelogin-manage-dismiss',
- 'googlelogin-manage-openpluslink',
- 'googlelogin-manage-unknownerror',
- 'googlelogin-manage-plusinfo-title',
- ),
- ),
- 'ext.GoogleLogin.specialGoogleLogin.chooseown' => $wgGLResourcePath +
array(
- 'dependencies' => array(
- 'oojs-ui',
- ),
- 'scripts' => array(
-
'javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js',
- ),
- 'targets' => array( 'desktop', 'mobile' ),
- ),
-);
-
-// Create own instance of Config
-$wgConfigRegistry['googlelogin'] = 'GlobalVarConfig::newInstance';
-
-// Configuration settings defaults
-
-/**
- * The Secret key of Google developer console
- */
-$wgGLSecret = '';
-
-/**
- * The App ID of the web application to use for GoogleLogin
- */
-$wgGLAppId = '';
-
-/**
- * Which domains are allowed to login (or create/merge an account) with
GoogleLogin
- * default: empty string -> all domains allowed
- * to allow special domains, create an array with all allowed domains, example:
- * array( 'example.com' );
- */
-$wgGLAllowedDomains = '';
-
-/**
- * If $wgGoogleAllowedDomains restrict to specified domains, use strict mode?
Means:
- * Only the exact specified domains are allowed, e.g. if test.example.com is
allowed and strict
- * mode is enabled, example.com isn't allowed (if strict mode is of, it is
allowed)
- */
-$wgGLAllowedDomainsStrict = false;
-
-/**
- * If the user creates an account via GoogleLogin, show this as a reason in
log?
- */
-$wgGLShowCreateReason = false;
-
-/**
- * Variable to control if there is an "Keep login" checkbox for GoogleLogin
right above the
- * "Login with Google" button on the user login form.
- */
-$wgGLShowKeepLogin = true;
-
-/**
- * Control, if "Keep login" is always enabled (even if
- * the user doesn't checked the keep login box!).
- */
-$wgGLForceKeepLogin = false;
-
-/**
- * If the creation of wiki accounts is allowed with GoogleLogin or not, is
handled by this
- * variable. Default is the value of $wgGroupPermissions['*']['createaccount']
(user right
- * to create a wiki account).
- */
-$wgGLAllowAccountCreation = $wgGroupPermissions['*']['createaccount'];
-
-/**
- * If true, GoogleLogin replaces the MediaWiki Login function (personal links
and
- * Special:UserLogin) and replace it with GoogleLogin values.
- */
-$wgGLReplaceMWLogin = false;
-
-/**
- * Key for public API access. Used only for admin actions to check,
- * if the user has a plus profile or not.
- */
-$wgGLAPIKey = '';
-
-/**
- * If set to true, the Google Login button will be added to
- * the right side of the login form, instead above the normal login form.
- */
-$wgGLShowRight = false;
-
-/**
- * Whether the user needs to confirm the google mail adress after registration
- * of a new local MediaWiki account, or not.
- */
-$wgGLNeedsConfirmEmail = true;
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..e358fc0
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,156 @@
+{
+ "name": "GoogleLogin",
+ "version": "0.3.1-git",
+ "author": "Florian Schmidt",
+ "url": "https://www.mediawiki.org/wiki/Extension:GoogleLogin",
+ "descriptionmsg": "googlelogin-desc",
+ "license-name": "MIT",
+ "type": "specialpage",
+ "GroupPermissions": {
+ "sysop": {
+ "managegooglelogin": true
+ }
+ },
+ "AvailableRights": [
+ "managegooglelogin"
+ ],
+ "ConfigRegistry": {
+ "googlelogin": "GlobalVarConfig::newInstance"
+ },
+ "SpecialPages": {
+ "GoogleLogin": "SpecialGoogleLogin",
+ "ManageGoogleLogin": "SpecialManageGoogleLogin"
+ },
+ "APIModules": {
+ "googleplusprofileinfo": "ApiGoogleLoginInfo"
+ },
+ "MessagesDirs": {
+ "GoogleLogin": [
+ "i18n"
+ ]
+ },
+ "ExtensionMessagesFiles": {
+ "GoogleLoginAlias": "GoogleLogin.alias.php"
+ },
+ "AutoloadClasses": {
+ "GoogleLogin": "includes/GoogleLogin.body.php",
+ "SpecialGoogleLogin":
"includes/specials/SpecialGoogleLogin.php",
+ "SpecialManageGoogleLogin":
"includes/specials/SpecialManageGoogleLogin.php",
+ "GoogleLoginHooks": "includes/GoogleLogin.hooks.php",
+ "GoogleLogin\\GoogleUser": "includes/GoogleUser.php",
+ "ApiGoogleLoginInfo": "includes/api/ApiGoogleLoginInfo.php"
+ },
+ "ResourceModules": {
+ "ext.GoogleLogin.style": {
+ "styles": "style/ext.GoogleLogin.css",
+ "position": "top",
+ "targets": [
+ "desktop",
+ "mobile"
+ ]
+ },
+ "ext.GoogleLogin.right.style": {
+ "styles": "style/ext.GoogleLogin.right.css",
+ "position": "top"
+ },
+ "ext.GoogleLogin.specialManage.scripts": {
+ "dependencies": [
+ "mediawiki.api",
+ "oojs-ui"
+ ],
+ "scripts": [
+
"javascripts/specialpages/ext.GoogleLogin.specialManage.js"
+ ],
+ "styles": [
+ "style/ext.GoogleLogin.specialManage.css"
+ ],
+ "messages": [
+ "googlelogin-googleuser",
+ "googlelogin-manage-isplusser",
+ "googlelogin-manage-orgname",
+ "googlelogin-manage-orgtitle",
+ "googlelogin-manage-orgsince",
+ "googlelogin-manage-yes",
+ "googlelogin-manage-no",
+ "googlelogin-manage-errorloading",
+ "googlelogin-manage-dismiss",
+ "googlelogin-manage-openpluslink",
+ "googlelogin-manage-unknownerror",
+ "googlelogin-manage-plusinfo-title"
+ ]
+ },
+ "ext.GoogleLogin.specialGoogleLogin.chooseown": {
+ "dependencies": [
+ "oojs-ui"
+ ],
+ "scripts": [
+
"javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js"
+ ],
+ "targets": [
+ "desktop",
+ "mobile"
+ ]
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "",
+ "remoteExtPath": "GoogleLogin"
+ },
+ "Hooks": {
+ "UserLogoutComplete": [
+ "GoogleLoginHooks::onUserLogoutComplete"
+ ],
+ "LoadExtensionSchemaUpdates": [
+ "GoogleLoginHooks::onLoadExtensionSchemaUpdates"
+ ],
+ "UserLoginForm": [
+ "GoogleLoginHooks::onUserLoginForm"
+ ],
+ "UserCreateForm": [
+ "GoogleLoginHooks::onUserCreateForm"
+ ],
+ "PersonalUrls": [
+ "GoogleLoginHooks::onPersonalUrls"
+ ],
+ "SpecialPage_initList": [
+ "GoogleLoginHooks::onSpecialPage_initList"
+ ],
+ "GetPreferences": [
+ "GoogleLoginHooks::onGetPreferences"
+ ],
+ "RecentChange_save": [
+ "GoogleLoginHooks::onRecentChange_save"
+ ],
+ "ListDefinedTags": [
+ "GoogleLoginHooks::onListDefinedAndActiveTags"
+ ],
+ "ChangeTagsListActive": [
+ "GoogleLoginHooks::onListDefinedAndActiveTags"
+ ],
+ "LoginFormValidErrorMessages": [
+ "GoogleLoginHooks::onLoginFormValidErrorMessages"
+ ],
+ "UnitTestsList": [
+ "GoogleLoginHooks::onUnitTestsList"
+ ]
+ },
+ "config": {
+ "GLResourcePath": {
+ "localBasePath":
"/var/www/html/media/extensions/GoogleLogin",
+ "remoteExtPath": "GoogleLogin"
+ },
+ "GLSecret": "",
+ "GLAppId": "",
+ "GLAllowedDomains": "",
+ "GLAllowedDomainsStrict": false,
+ "GLShowCreateReason": false,
+ "GLShowKeepLogin": true,
+ "GLForceKeepLogin": false,
+ "GLAllowAccountCreation": null,
+ "GLReplaceMWLogin": false,
+ "GLAPIKey": "",
+ "GLShowRight": false,
+ "GLNeedsConfirmEmail": true
+ },
+ "manifest_version": 1
+}
--
To view, visit https://gerrit.wikimedia.org/r/257698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I523ab79687debcaecd9c20b5b310b29ef258fc2b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GoogleLogin
Gerrit-Branch: master
Gerrit-Owner: Mhutti1 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits