jenkins-bot has submitted this change and it was merged. Change subject: Add Specialpage to manage googlelogin connections for sysop ......................................................................
Add Specialpage to manage googlelogin connections for sysop Bug: T86684 Change-Id: If016f83bd6bb2b4ce6f2cb3893e1f84a7b5df541 --- M GoogleLogin.alias.php M GoogleLogin.php M i18n/en.json M i18n/qqq.json A includes/api/ApiGoogleLoginInfo.php A includes/specials/SpecialManageGoogleLogin.php A javascripts/specialpages/ext.GoogleLogin.specialManage.js M style/ext.GoogleLogin.css A style/ext.GoogleLogin.specialManage.css 9 files changed, 551 insertions(+), 5 deletions(-) Approvals: Florianschmidtwelzow: Looks good to me, approved jenkins-bot: Verified diff --git a/GoogleLogin.alias.php b/GoogleLogin.alias.php index fa483f9..213a707 100644 --- a/GoogleLogin.alias.php +++ b/GoogleLogin.alias.php @@ -10,6 +10,7 @@ /** English (English) */ $specialPageAliases['en'] = array( 'GoogleLogin' => array( 'GoogleLogin', 'Login with Google' ), + 'ManageGoogleLogin' => array( 'ManageGoogleLogin', 'Manage GoogleLogin connections' ), ); /** Arabic (العربية) */ diff --git a/GoogleLogin.php b/GoogleLogin.php index 657826e..5e62d12 100644 --- a/GoogleLogin.php +++ b/GoogleLogin.php @@ -50,9 +50,11 @@ // 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[ 'GoogleLoginDB' ] = $dir . '/includes/GoogleLoginDB.php'; $wgAutoloadClasses[ 'GoogleLoginAuth' ] = $dir . '/includes/GoogleLoginAuth.php'; + $wgAutoloadClasses[ 'ApiGoogleLoginInfo' ] = $dir . '/includes/api/ApiGoogleLoginInfo.php'; $wgExtensionFunctions[] = 'efGoogleLoginSetup'; @@ -69,9 +71,18 @@ $wgExtensionMessagesFiles[ 'GoogleLoginAlias' ] = $dir . '/GoogleLogin.alias.php'; $wgMessagesDirs['GoogleLogin'] = $dir . '/i18n'; + // new user rights for this extension + $wgGroupPermissions['sysop']['managegooglelogin'] = true; + $wgAvailableRights[] = 'managegooglelogin'; + // Special Page $wgSpecialPageGroups[ 'GoogleLogin' ] = 'login'; $wgSpecialPages[ 'GoogleLogin' ] = 'SpecialGoogleLogin'; + $wgSpecialPageGroups[ 'ManageGoogleLogin' ] = 'users'; + $wgSpecialPages[ 'ManageGoogleLogin' ] = 'SpecialManageGoogleLogin'; + + // API Modules + $wgAPIModules['googleplusprofileinfo'] = 'ApiGoogleLoginInfo'; // Hooks $wgHooks['UserLogoutComplete'][] = 'GoogleLoginHooks::onUserLogoutComplete'; @@ -86,12 +97,43 @@ $wgHooks['ChangeTagsListActive'][] = 'GoogleLoginHooks::onListDefinedAndActiveTags'; // ResourceLoader modules - $wgResourceModules['ext.GoogleLogin.style'] = array( + // path template + $wgGLResourcePath = array( + 'localBasePath' => __DIR__, + 'remoteExtPath' => 'GoogleLogin' + ); + + $wgResourceModules['ext.GoogleLogin.style'] = $wgGLResourcePath + array( 'styles' => 'style/ext.GoogleLogin.css', 'position' => 'top', 'targets' => array( 'desktop', 'mobile' ), - 'localBasePath' => __DIR__, - 'remoteExtPath' => 'GoogleLogin' + ); + + $wgResourceModules['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', + ), ); // Create own instance of Config @@ -152,3 +194,8 @@ * 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 = ''; diff --git a/i18n/en.json b/i18n/en.json index 9e57384..9ec00cc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5,6 +5,32 @@ ] }, "googlelogin": "Login with Google", + "managegooglelogin": "Manage GoogleLogin connections", + "googlelogin-managelegend": "Find User to manage", + "googlelogin-manage-usersubmit": "Manage User", + "googlelogin-manage-notexist": "There is no User with name <strong>$1</strong>.", + "googlelogin-manage-user": "You manage the user <strong>$1</strong>.", + "googlelogin-manage-linked": "The account is linked with a Google account with the ID ", + "googlelogin-manage-notlinked": "The account is actually not linked with a Google account.", + "googlelogin-manage-changelegend": "Change Google ID", + "googlelogin-manage-noplus": "<strong>Notice:</strong> The User with the Google ID you entered seems to have no Google+ profile. Maybe a typing error?", + "googlelogin-manage-changedsuccess": "The User is now linked with the Google account.", + "googlelogin-manage-terminatesuccess": "The User isn't linked with a Google account anymore.", + "googlelogin-manage-changederror": "<strong>An error occured while create/terminate the link between the wiki user and the Google account.</strong>", + "googlelogin-manage-terminatebutton": "Remove connection", + "googlelogin-manage-invalidid": "The new Google ID you entered is invalid. The ID needs to be numeric.", + "googlelogin-manage-isplusser": "Registered on Google Plus", + "googlelogin-manage-orgname": "Organization name", + "googlelogin-manage-orgtitle": "Job position", + "googlelogin-manage-orgsince": "Since", + "googlelogin-manage-yes": "yes", + "googlelogin-manage-no": "no", + "googlelogin-manage-dismiss": "Dismiss", + "googlelogin-manage-openpluslink": "Open Google+ profile", + "googlelogin-manage-unknownerror": "There was an unknown error while loading your data. Maybe the user doesn't exist on Google Plus or the profile Id is false?", + "googlelogin-manage-plusinfo-title": "Profile information", + "googlelogin-manage-errorloading": "Loading error", + "googlelogin-username": "Username", "googlelogin-create": "Create with Google", "googlelogin-desc": "Provides a [[Special:GoogleLogin|Special page]] to allow users to login with their Google accounts", "googlelogin-parerror": "The requested page doesn't exist. Please go back and try the action again.", @@ -40,5 +66,6 @@ "googlelogin-success-unlink": "Congratulations! Your wiki account isn't linked to your Google account anymore.", "googlelogin-prefs-status": "GoogleLogin status:", "tag-googlelogin": "[[Special:GoogleLogin|GoogleLogin]]", - "tag-googlelogin-description": "Registrations with this tag were made with [[Special:GoogleLogin|GoogleLogin]]" + "tag-googlelogin-description": "Registrations with this tag were made with [[Special:GoogleLogin|GoogleLogin]]", + "action-managegooglelogin": "Manage GoogleLogin connections" } diff --git a/i18n/qqq.json b/i18n/qqq.json index 2aa0188..8e2bd4a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -7,6 +7,32 @@ ] }, "googlelogin": "{{doc-special|GoogleLogin}}\nAlso used as label for the button shown in [[Special:Login]].", + "managegooglelogin": "Title of Special:ManageGoogleLogin", + "googlelogin-managelegend": "Text used in legend on Special:ManageGoogleLogin.", + "googlelogin-manage-usersubmit": "Submit text for find user form on Special:ManageGoogleLogin.", + "googlelogin-manage-notexist": "Indicates, that the user to manage does not exist.\n* $1 - The username entered", + "googlelogin-username": "Used to indicate a username input field.", + "googlelogin-manage-user": "Used on Special:ManageGoogleLogin to show, which user is managed.\n* $1 - The name of the managed user", + "googlelogin-manage-linked": "Message, that indicates, that the Wiki user is linked with a Google account.\n* $1 - Google ID of the linked Google account", + "googlelogin-manage-notlinked": "Message that indicates, that the Wiki user isn't linked with a Google account.", + "googlelogin-manage-changelegend": "Legendmessage for the \"Change Google ID\" form on Special:ManageGoogleLogin.", + "googlelogin-manage-noplus": "Notice message, that the passed Google ID doesn't have a Plus profile, including a hint to check a typing error.", + "googlelogin-manage-changedsuccess": "Indicates, that the manages user is linked with the Google account now.", + "googlelogin-manage-terminatesuccess": "Successmessage when the connection between the User and Google account was removed.", + "googlelogin-manage-changederror": "Indicates an error while trying to link the Wiki user and Google account.", + "googlelogin-manage-terminatebutton": "Buttonlabel to terminate the connection between Google account and Wiki user.", + "googlelogin-manage-invalidid": "Notice, that the given Google ID is invalid and needs to be numeric.", + "googlelogin-manage-isplusser": "Label for a field that indicates, if the User is registered in Google Plus.", + "googlelogin-manage-orgname": "Label for field that shows the actual organization the User works in.", + "googlelogin-manage-orgtitle": "Name of the job position of the User.", + "googlelogin-manage-orgsince": "Since when the User works in the organization.\n* {{msg-mw|Googlelogin-manage-orgname}}", + "googlelogin-manage-yes": "Used to indicate if a user is registered on Google Plus.", + "googlelogin-manage-no": "Used to indicate if a user isn't registered on Google Plus.", + "googlelogin-manage-dismiss": "Buttonlabel for a dismiss function.", + "googlelogin-manage-errorloading": "Title of an error dialog with a generic \"There was an error\" message.", + "googlelogin-manage-openpluslink": "Label for link to open the Google Plus profile of the user.", + "googlelogin-manage-unknownerror": "Error message, when the Google Plus profile data could not be loaded.", + "googlelogin-manage-plusinfo-title": "Title of the information dialog on [[Special:ManageGoogleLogin]].", "googlelogin-create": "Used as label for the button shown in [[Special:CreateAccount]].", "googlelogin-desc": "{{desc|name=Google Login|url=https://www.mediawiki.org/wiki/Extension:GoogleLogin}}", "googlelogin-parerror": "Error message when a Subpage of Special:GoogleLogin is requested, which does not exist.", @@ -42,5 +68,6 @@ "googlelogin-success-unlink": "Successful message, that the wiki account isn't linked anymore with the Google account.", "googlelogin-prefs-status": "Name of the Line in Special:Preferences identifying GoogleLoign status (linked or not linked).", "tag-googlelogin": "Tag in [[Special:RecentChanges]] for user account creations made with GoogleLogin.\n\nSee also:\n* {{msg-mw|Tag-googlelogin-description}}", - "tag-googlelogin-description": "Short description, that account creations with this tag are made with GoogleLogin." + "tag-googlelogin-description": "Short description, that account creations with this tag are made with GoogleLogin.", + "action-managegooglelogin": "Message key for user right \"managegooglelogin\"" } diff --git a/includes/api/ApiGoogleLoginInfo.php b/includes/api/ApiGoogleLoginInfo.php new file mode 100644 index 0000000..91c4c99 --- /dev/null +++ b/includes/api/ApiGoogleLoginInfo.php @@ -0,0 +1,71 @@ +<?php +class ApiGoogleLoginInfo extends ApiBase { + public function execute() { + $apiResult = $this->getResult(); + $params = $this->extractRequestParams(); + $glConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'googlelogin' ); + $user = $this->getUser(); + + if ( !isset( $params['googleid'] ) ) { + $this->dieUsage( 'Invalid Google ID', 'googleidinvalid' ); + } + + // only user with the managegooglelogin right can use this Api + if ( !$user->isAllowed( 'managegooglelogin' ) ) { + $this->dieUsage( + 'Insufficient permissions. You need the managegooglelogin permission to use this API module', + 'insufficientpermissions' + ); + } + + // check, if the api is protected and if the key is correct + $plusCheck = Http::get( + 'https://www.googleapis.com/plus/v1/people/' . + $params['googleid'] . + '?key=' . + $glConfig->get( 'GLAPIKey' ) + ); + + if ( !$plusCheck ) { + $this->dieUsage( 'Google user not found or false api key.', 'unknownuser' ); + } + $plusCheck = json_decode( $plusCheck, true ); + $result = array(); + if ( $plusCheck['displayName'] ) { + $result[$this->msg( 'googlelogin-googleuser' )->text()] = $plusCheck['displayName']; + } + if ( $plusCheck['image'] ) { + $result['profileimage'] = $plusCheck['image']['url']; + } + if ( $plusCheck['isPlusUser'] ) { + $result[$this->msg( 'googlelogin-manage-isplusser' )->text()] = $plusCheck['isPlusUser']; + } + if ( is_array( $plusCheck['organizations'] ) ) { + $org = $plusCheck['organizations'][0]; + if ( $org['primary'] ) { + $result[$this->msg( 'googlelogin-manage-orgname' )->text()] = $org['name']; + } + if ( $org['title'] ) { + $result[$this->msg( 'googlelogin-manage-orgtitle' )->text()] = $org['title']; + } + if ( $org['startDate'] ) { + $result[$this->msg( 'googlelogin-manage-orgsince' )->text()] = $org['startDate']; + } + } + // build result array + $r = array( + 'success' => true, + 'result' => $result + ); + // add result to API output + $apiResult->addValue( null, $this->getModuleName(), $r ); + } + + public function getAllowedParams() { + return array( + 'googleid' => array( + ApiBase::PARAM_TYPE => 'string', + ), + ); + } +} diff --git a/includes/specials/SpecialManageGoogleLogin.php b/includes/specials/SpecialManageGoogleLogin.php new file mode 100644 index 0000000..bc24e56 --- /dev/null +++ b/includes/specials/SpecialManageGoogleLogin.php @@ -0,0 +1,197 @@ +<?php + class SpecialManageGoogleLogin extends SpecialPage { + /** @var $mGoogleLogin saves an instance of GoogleLogin class */ + private $mGoogleLogin; + + /** @var User $manageableUser User object of the user to manage */ + private static $manageableUser = null; + + function __construct() { + parent::__construct( 'ManageGoogleLogin', 'managegooglelogin' ); + $this->listed = true; + } + + /** + * Special page executer + * @param SubPage $par Subpage + */ + function execute( $par ) { + $user = $this->getUser(); + $out = $this->getOutput(); + $request = $this->getRequest(); + if ( !$this->userCanExecute( $user ) ) { + $this->displayRestrictionError(); + return; + } + $this->setHeaders(); + if ( !$request->getVal( 'glManageableUser' ) ) { + $out->addModules( 'mediawiki.userSuggest' ); + $formFields = array( + 'username' => array( + 'type' => 'text', + 'name' => 'username', + 'label-message' => 'googlelogin-username', + 'id' => 'mw-gl-username', + 'cssclass' => 'mw-autocomplete-user', + 'autofocus' => true, + ) + ); + $htmlForm = new HTMLForm( $formFields, $this->getContext(), 'googlelogin-manage' ); + $htmlForm->setWrapperLegendMsg( $this->msg( 'googlelogin-managelegend' ) ); + $htmlForm->setSubmitText( $this->msg( 'googlelogin-manage-usersubmit' )->text() ); + $htmlForm->setSubmitProgressive(); + $htmlForm->setSubmitCallback( array( $this, 'submitUserName' ) ); + $htmlForm->show(); + } else { + $this->submitUserName( + array( + 'username' => $request->getVal( 'glManageableUser' ) + ) + ); + } + + if ( self::$manageableUser ) { + $this->manageUser( self::$manageableUser ); + } else { + + } + } + + /** + * Checks, if a user with the entered username exists. + * + * @param array $data Formdata + * @return boolean + */ + public function submitUserName( $data ) { + if ( !isset( $data['username'] ) ) { + return false; + } + $checkUser = User::newFromName( $data['username'] ); + if ( $checkUser->isAnon() ) { + return wfMessage( 'googlelogin-manage-notexist', $data['username'] ); + } + self::$manageableUser = $checkUser; + return true; + } + + /** + * Renders a form to manage this user and handles all actions. + * + * @param User $user + */ + private function manageUser( User $user ) { + $request = $this->getRequest(); + $out = $this->getOutput(); + + $out->addModules( + array( + 'ext.GoogleLogin.specialManage.scripts', + 'ext.GoogleLogin.style', + ) + ); + $out->addBackLinkSubtitle( $this->getPageTitle() ); + $db = new GoogleLoginDB; + $id = $db->userIdExists( $user->getId() ); + $googleId = $request->getVal( 'googleid' ); + $terminateLink = $request->getVal( 'terminate-link' ); + if ( isset( $terminateLink ) && $id ) { + // terminate the connection + if ( $db->terminateConnection( $id['id'] ) ) { + $out->addWikiMsg( 'googlelogin-manage-terminatesuccess' ); + $id = false; + } else { + $out->addWikiMsg( 'googlelogin-manage-changederror' ); + } + } elseif ( $googleId ) { + if ( !is_numeric( $googleId ) ) { + $out->wrapWikiMsg( '<div class="error">$1</div>', 'googlelogin-manage-invalidid' ); + } else { + // check, if the google id has a google plus profile + $glConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'googlelogin' ); + $plusCheck = Http::get( + 'https://www.googleapis.com/plus/v1/people/' . + $googleId . + '?key=' . + $glConfig->get( 'GLAPIKey' ) + ); + if ( !$plusCheck ) { + // it seems, that the google id doesn't have a plus profile (or another error occur). Add a notice message for it. + $out->addWikiMsg( 'googlelogin-manage-noplus' ); + } + // FIXME: Really need to terminate and then create a new connection, how about an update routine? + if ( !empty( $id ) ) { + $db->terminateConnection( $id['id'] ); + } + if ( $db->createConnection( $googleId, $user->getId() ) ) { + $out->addWikiMsg( 'googlelogin-manage-changedsuccess' ); + $id = $db->userIdExists( $user->getId() ); + } else { + $out->addWikiMsg( 'googlelogin-manage-changederror' ); + } + } + } + $out->addWikiMsg( 'googlelogin-manage-user', $user->getName() ); + if ( $id ) { + $out->addHtml( + Html::openElement( 'div' ) . + $this->msg( 'googlelogin-manage-linked' )->escaped() . + Html::openElement( 'strong' ) . + Html::element( 'span', + array( + 'class' => 'googlelogin-googleid', + ), + $id['id'] + ) . + Html::element( 'a', + array( + 'href' => 'javascript:void(0)', + 'class' => 'googlelogin-googleid hidden', + 'data-googleid' => $id['id'], + ), + $id['id'] + ) . + Html::closeElement( 'strong' ) . + Html::closeElement( 'div' ) + ); + $formId = $id['id']; + } else { + $out->addWikiMsg( 'googlelogin-manage-notlinked' ); + $formId = ''; + } + $formFields = array( + 'googleid' => array( + 'type' => 'text', + 'name' => 'googleid', + 'label-raw' => 'Google-ID:', + 'default' => $formId, + 'id' => 'mw-gl-username', + ) + ); + $htmlForm = new HTMLForm( $formFields, $this->getContext(), 'googlelogin-change' ); + $htmlForm->addHiddenField( 'glManageableUser', $user->getName() ); + $htmlForm->setWrapperLegendMsg( $this->msg( 'googlelogin-manage-changelegend' ) ); + $htmlForm->setSubmitCallback( array( 'SpecialManageGoogleLogin', 'submitGoogleId' ) ); + if ( $id ) { + $htmlForm->addButton( + 'terminate-link', + $this->msg( 'googlelogin-manage-terminatebutton' )->escaped(), + null, + array( + 'class' => 'mw-ui-destructive', + ) + ); + } + $htmlForm->show(); + } + + /** + * Submithandler for new google id + * + * @param array $data Formdata + * @return boolean + */ + public static function submitGoogleId( $data ) { + return false; + } + } diff --git a/javascripts/specialpages/ext.GoogleLogin.specialManage.js b/javascripts/specialpages/ext.GoogleLogin.specialManage.js new file mode 100644 index 0000000..8589eca --- /dev/null +++ b/javascripts/specialpages/ext.GoogleLogin.specialManage.js @@ -0,0 +1,170 @@ +$( function ( mw ) { + var api = new mw.Api(), + windowManager = new OO.ui.WindowManager(); + + // GoogleLogin javascript module + mw.GoogleLogin = { + /** + * Creates a new ProcessDialog as a Google Plus Info dialog with some information about + * the user connected with the provided Google Plus ID. The data will be loaded from Api + * and if there is an error, an error dialog will be shown. The user has always a button + * to open the Google Plus profile directly on Google Plus. + * + * @param {Integer} plusid The Google Plus ID to load the data from + */ + showInfoDialog: function ( plusid ) { + // Create an information overlay to show basics about a google plus id + function InfoDialog( config ) { + InfoDialog.super.call( this, config ); + } + // inherit ProcessDialog instead of MessageDialog or similar to use the top buttons + OO.inheritClass( InfoDialog, OO.ui.ProcessDialog ); + + InfoDialog.static.size = 'medium'; + InfoDialog.static.title = mw.msg( 'googlelogin-manage-plusinfo-title' ); + // one button to close the dialog and one to open a new tab + // to redirect the user to the official and full google plus profile + InfoDialog.static.actions = [ + { action: 'close', label: 'Close', flags: 'safe' }, + { + action: 'openplus', + label: mw.msg( 'googlelogin-manage-openpluslink' ), + flags: [ 'primary', 'safe' ], + href: 'http://plus.google.com/' + plusid, + target: '_blank' + } + ]; + + InfoDialog.prototype.getBodyHeight = function () { + return 400; + }; + + // Make an api request to get the data and show the dialog. + InfoDialog.prototype.initialize = function () { + var self = this; + + InfoDialog.super.prototype.initialize.apply( this, arguments ); + this.content = new OO.ui.PanelLayout( { + $: this.$, + padded: true, + scrollable: true + } ); + // show, that we're loading the data + this.pushPending(); + api.get( { + action: 'googleplusprofileinfo', + googleid: plusid + } ).done( function ( data ) { + if ( data && data.googleplusprofileinfo && data.googleplusprofileinfo.result ) { + $.each( data.googleplusprofileinfo.result, function ( index, value ) { + var element; + + if ( index !== 'profileimage' ) { + // add a new information fieldset + element = new OO.ui.FieldsetLayout( { + $: self.$, + label: index + } ); + // determine if it is a boolean value and use yes/no + if ( value === true || value === false ) { + value = ( + value === true ? + mw.msg( 'googlelogin-manage-yes' ) : + mw.msg( 'googlelogin-manage-no' ) + ); + } + element.addItems( [ + new OO.ui.LabelWidget( { + $: self.$, label: value + } ) + ] ); + self.content.$element.append( element.$element ); + } else { + // add the profile image if there exists one + element = new OO.ui.LabelWidget( { + $: self.$, + label: $( '<img src="' + value + '">' ), + classes: [ 'googlelogin-profilepicture' ] + } ); + self.content.$element.prepend( element.$element ); + } + } ); + } else { + var fieldset; + fieldset = new OO.ui.FieldsetLayout( { + $: self.$, label: 'Data could not be loaded', icon: 'alert' + } ); + fieldset.addItems( [ + new OO.ui.LabelWidget( { + $: self.$, label: 'Sorry, but there was an error.' + } ) + ] ); + self.content.$element.append( fieldset.$element ); + } + self.$body.append( self.content.$element ); + + // finished loading, hide loading + self.popPending(); + } ).fail( function ( code, error ) { + var msg; + + if ( error.info ) { + msg = error.info; + } else { + msg = mw.msg( 'googlelogin-manage-unknownerror' ); + } + self.close(); + var messageDialog = new OO.ui.MessageDialog(); + + // Add the dialog to the window manager. + windowManager.addWindows( [ messageDialog ] ); + + // Configure the message dialog when it is opened with the window manager's openWindow() method. + windowManager.openWindow( messageDialog, { + title: mw.msg( 'googlelogin-manage-errorloading' ), + message: msg, + actions: [ + // the user should have the chance to easily open the google plus profile, here is the link + { + action: 'pluslink', + label: mw.msg( 'googlelogin-manage-openpluslink' ), + flags: 'primary', + href: 'http://plus.google.com/' + plusid, + target: '_blank' + }, + // just close the dialog + { action: 'reject', label: mw.msg( 'googlelogin-manage-dismiss' ), flags: 'safe' } + ] + }); + } ); + }; + + InfoDialog.prototype.getActionProcess = function ( action ) { + return InfoDialog.super.prototype.getActionProcess.call( this, action ) + .next( + function () { + if ( action === 'close' ) { + this.close(); + } + return InfoDialog.super.prototype.getActionProcess.call( this, action ); + }, + this + ); + }; + + // Create a new instance of InfoDialog + var infoDialog = new InfoDialog(); + + // and add it to the window manager + windowManager.addWindows( [ infoDialog ] ); + windowManager.openWindow( infoDialog ); + } + }; + + // Append the window manager. + $( 'body' ).append( windowManager.$element ); + + $( '.googlelogin-googleid' ).toggleClass( 'hidden' ).on( 'click', function ( ev ) { + mw.GoogleLogin.showInfoDialog( $( this ).data( 'googleid' ) ); + } ); +}( mediaWiki ) ); \ No newline at end of file diff --git a/style/ext.GoogleLogin.css b/style/ext.GoogleLogin.css index 84678b4..9346b11 100644 --- a/style/ext.GoogleLogin.css +++ b/style/ext.GoogleLogin.css @@ -20,3 +20,6 @@ padding-top: 0px; padding-bottom: 0px; } +.hidden { + display: none; +} diff --git a/style/ext.GoogleLogin.specialManage.css b/style/ext.GoogleLogin.specialManage.css new file mode 100644 index 0000000..7cac3e5 --- /dev/null +++ b/style/ext.GoogleLogin.specialManage.css @@ -0,0 +1,3 @@ +.googlelogin-profilepicture { + float: right; +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/187999 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If016f83bd6bb2b4ce6f2cb3893e1f84a7b5df541 Gerrit-PatchSet: 10 Gerrit-Project: mediawiki/extensions/GoogleLogin Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits