Merge "Updates for core temp user autocreation feature"
This commit is contained in:
commit
3d36fac0ef
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
|
||||
.vector-user-menu-legacy #pt-anonuserpage,
|
||||
.vector-user-menu-legacy #pt-tmpuserpage,
|
||||
.vector-user-menu-legacy #pt-userpage a {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAx0lEQVQ4jdXSzQmEQAwFYEuYUixhSwgkA8mQgKXYgS3YgXZgCZagHWgHuxf14t8osssGcv145CVJvjk+hBRFK2TrkK1D0cqHkN7CUBRI7L21KAqXMIDModiwD9oAkLlH0i3L+ooGiTWPAPPfJQTIHLGOB9h46YZnKS+3PI8PISW2GkV7FO2Jrb79h4+ODyElsYJYm437NSRWRCWdylgj++U0u+UAZI5E22hsWW03UWQtr2NT66zlCjz8uzNQbFiDN7F5/xB8aj57Ynp2FKI0bAAAAABJRU5ErkJggg==") !important;
|
||||
}
|
||||
|
|
|
@ -238,16 +238,20 @@ class Hooks implements
|
|||
private static function updateUserLinksDropdownItems( $sk, &$content_navigation ) {
|
||||
// For logged-in users in modern Vector, rearrange some links in the personal toolbar.
|
||||
$user = $sk->getUser();
|
||||
if ( $user->isRegistered() ) {
|
||||
// Remove user page from personal menu dropdown for logged in use
|
||||
// Note we need to check for userpage, as a registered user in
|
||||
// future may be an anonymous user who has been assigned a temporary
|
||||
// account.
|
||||
if ( isset( $content_navigation['user-menu']['userpage'] ) ) {
|
||||
self::makeMenuItemCollapsible(
|
||||
$content_navigation['user-menu']['userpage']
|
||||
);
|
||||
$isTemp = $user->isTemp();
|
||||
$isRegistered = $user->isRegistered();
|
||||
if ( $isTemp ) {
|
||||
if ( isset( $content_navigation['user-page']['tmpuserpage'] ) ) {
|
||||
self::makeMenuItemCollapsible( $content_navigation['user-page']['tmpuserpage'] );
|
||||
}
|
||||
if ( isset( $content_navigation['user-menu']['tmpuserpage'] ) ) {
|
||||
self::makeMenuItemCollapsible( $content_navigation['user-menu']['tmpuserpage'] );
|
||||
}
|
||||
} elseif ( $isRegistered ) {
|
||||
// Remove user page from personal menu dropdown for logged in use
|
||||
self::makeMenuItemCollapsible(
|
||||
$content_navigation['user-menu']['userpage']
|
||||
);
|
||||
// watchlist may be disabled if $wgGroupPermissions['*']['viewmywatchlist'] = false;
|
||||
// See [[phab:T299671]]
|
||||
if ( isset( $content_navigation['user-menu']['watchlist'] ) ) {
|
||||
|
@ -257,6 +261,8 @@ class Hooks implements
|
|||
}
|
||||
// Remove logout link from user-menu and recreate it in SkinVector,
|
||||
unset( $content_navigation['user-menu']['logout'] );
|
||||
}
|
||||
if ( $isRegistered ) {
|
||||
// Don't show icons for anon menu items (besides login and create account).
|
||||
// Prefix user link items with associated icon.
|
||||
$user_menu = $content_navigation['user-menu'];
|
||||
|
@ -268,6 +274,8 @@ class Hooks implements
|
|||
} else {
|
||||
// Remove "Not logged in" from personal menu dropdown for anon users.
|
||||
unset( $content_navigation['user-menu']['anonuserpage'] );
|
||||
}
|
||||
if ( !$isRegistered || $isTemp ) {
|
||||
// "Create account" link is handled manually by Vector
|
||||
unset( $content_navigation['user-menu']['createaccount'] );
|
||||
// "Login" link is handled manually by Vector
|
||||
|
|
|
@ -33,6 +33,7 @@ use SkinMustache;
|
|||
use SkinTemplate;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* Skin subclass for Vector that may be the new or old version of Vector.
|
||||
|
@ -262,9 +263,10 @@ abstract class SkinVector extends SkinMustache {
|
|||
* Returns HTML for the create account button, login button and learn more link inside the anon user menu
|
||||
* @param string[] $returnto array of query strings used to build the login link
|
||||
* @param bool $useCombinedLoginLink if a combined login/signup link will be used
|
||||
* @param bool $isTempUser
|
||||
* @return string
|
||||
*/
|
||||
private function getAnonMenuBeforePortletHTML( $returnto, $useCombinedLoginLink ) {
|
||||
private function getAnonMenuBeforePortletHTML( $returnto, $useCombinedLoginLink, $isTempUser ) {
|
||||
$loginData = $this->buildLoginData( $returnto, $useCombinedLoginLink );
|
||||
$loginData['class'] = [
|
||||
'vector-menu-content-item',
|
||||
|
@ -274,23 +276,30 @@ abstract class SkinVector extends SkinMustache {
|
|||
];
|
||||
unset( $loginData['icon'] );
|
||||
|
||||
$learnMoreLinkData = [
|
||||
'text' => $this->msg( 'vector-anon-user-menu-pages-learn' )->text(),
|
||||
'href' => Title::newFromText( $this->msg( 'vector-intro-page' )->text() )->getLocalURL(),
|
||||
'aria-label' => $this->msg( 'vector-anon-user-menu-pages-label' )->text(),
|
||||
];
|
||||
$learnMoreLink = $this->makeLink( '', $learnMoreLinkData );
|
||||
|
||||
$templateParser = $this->getTemplateParser();
|
||||
return $templateParser->processTemplate( 'UserLinks__login', [
|
||||
$templateData = [
|
||||
'htmlCreateAccount' => $this->getCreateAccountHTML( $returnto, [
|
||||
'user-links-collapsible-item',
|
||||
'vector-menu-content-item',
|
||||
], true ),
|
||||
'htmlLogin' => $this->makeLink( 'login', $loginData ),
|
||||
'msgLearnMore' => $this->msg( 'vector-anon-user-menu-pages' ),
|
||||
'htmlLearnMoreLink' => $learnMoreLink
|
||||
] );
|
||||
];
|
||||
|
||||
$templateParser = $this->getTemplateParser();
|
||||
|
||||
if ( $isTempUser ) {
|
||||
$templateName = 'UserLinks__templogin';
|
||||
} else {
|
||||
$templateName = 'UserLinks__login';
|
||||
$learnMoreLinkData = [
|
||||
'text' => $this->msg( 'vector-anon-user-menu-pages-learn' )->text(),
|
||||
'href' => Title::newFromText( $this->msg( 'vector-intro-page' )->text() )->getLocalURL(),
|
||||
'aria-label' => $this->msg( 'vector-anon-user-menu-pages-label' )->text(),
|
||||
];
|
||||
$templateData['htmlLearnMoreLink'] = $this->makeLink( '', $learnMoreLinkData );
|
||||
$templateData['msgLearnMore'] = $this->msg( 'vector-anon-user-menu-pages' );
|
||||
}
|
||||
|
||||
return $templateParser->processTemplate( $templateName, $templateData );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,11 +326,12 @@ abstract class SkinVector extends SkinMustache {
|
|||
/**
|
||||
* Returns template data for UserLinks.mustache
|
||||
* @param array $menuData existing menu template data to be transformed and copied for UserLinks
|
||||
* @param bool $isAnon if the user is logged out, used to conditionally provide data
|
||||
* @param array $searchBoxData representing search box.
|
||||
* @param User $user the context user
|
||||
* @return array
|
||||
*/
|
||||
private function getUserLinksTemplateData( $menuData, $isAnon, $searchBoxData ): array {
|
||||
private function getUserLinksTemplateData( $menuData, $user ): array {
|
||||
$isAnon = !$user->isRegistered();
|
||||
$isTempUser = $user->isTemp();
|
||||
$returnto = $this->getReturnToParam();
|
||||
$useCombinedLoginLink = $this->useCombinedLoginLink();
|
||||
$htmlCreateAccount = $this->getCreateAccountHTML( $returnto, [
|
||||
|
@ -336,7 +346,8 @@ abstract class SkinVector extends SkinMustache {
|
|||
// Supporting removing items via hook involves unnecessary additional complexity we'd rather avoid at this time.
|
||||
// (see https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/713505/3)
|
||||
// Account creation can be disabled by setting `$wgGroupPermissions['*']['createaccount'] = false;`
|
||||
$isCreateAccountAllowed = $isAnon && $this->getAuthority()->isAllowed( 'createaccount' );
|
||||
$isCreateAccountAllowed = ( $isAnon || $isTempUser )
|
||||
&& $this->getAuthority()->isAllowed( 'createaccount' );
|
||||
$userMoreHtmlItems = $templateParser->processTemplate( 'UserLinks__more', [
|
||||
'is-anon' => $isAnon,
|
||||
'is-create-account-allowed' => $isCreateAccountAllowed,
|
||||
|
@ -355,10 +366,11 @@ abstract class SkinVector extends SkinMustache {
|
|||
];
|
||||
|
||||
$userMenuData = $menuData[ 'data-user-menu' ];
|
||||
if ( $isAnon ) {
|
||||
if ( $isAnon || $isTempUser ) {
|
||||
$userMenuData[ 'html-before-portal' ] .= $this->getAnonMenuBeforePortletHTML(
|
||||
$returnto,
|
||||
$useCombinedLoginLink
|
||||
$useCombinedLoginLink,
|
||||
$isTempUser
|
||||
);
|
||||
} else {
|
||||
// Appending as to not override data potentially set by the onSkinAfterPortlet hook.
|
||||
|
@ -529,7 +541,8 @@ abstract class SkinVector extends SkinMustache {
|
|||
)
|
||||
] );
|
||||
|
||||
if ( $skin->getUser()->isRegistered() ) {
|
||||
$user = $skin->getUser();
|
||||
if ( $user->isRegistered() ) {
|
||||
// Note: This data is also passed to legacy template where it is unused.
|
||||
$optOutUrl = [
|
||||
'text' => $this->msg( 'vector-opt-out' )->text(),
|
||||
|
@ -553,8 +566,7 @@ abstract class SkinVector extends SkinMustache {
|
|||
if ( !$this->isLegacy() ) {
|
||||
$commonSkinData['data-vector-user-links'] = $this->getUserLinksTemplateData(
|
||||
$commonSkinData['data-portlets'],
|
||||
$commonSkinData['is-anon'],
|
||||
$commonSkinData['data-search-box']
|
||||
$user
|
||||
);
|
||||
|
||||
// T295555 Add language switch alert message temporarily (to be removed).
|
||||
|
@ -781,9 +793,14 @@ abstract class SkinVector extends SkinMustache {
|
|||
' vector-user-menu-logged-out';
|
||||
$portletData['heading-class'] .= ' ' . self::CLASS_QUIET_BUTTON . ' ' .
|
||||
self::CLASS_ICON_BUTTON . ' ';
|
||||
$portletData['heading-class'] .= $this->loggedin ?
|
||||
$this->iconClass( 'userAvatar' ) :
|
||||
$this->iconClass( 'ellipsis' );
|
||||
if ( $this->getUser()->isTemp() ) {
|
||||
$icon = 'userAnonymous';
|
||||
} elseif ( $this->loggedin ) {
|
||||
$icon = 'userAvatar';
|
||||
} else {
|
||||
$icon = 'ellipsis';
|
||||
}
|
||||
$portletData['heading-class'] .= $this->iconClass( $icon );
|
||||
}
|
||||
}
|
||||
switch ( $portletData['id'] ) {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<div class="vector-user-menu-create-account">{{{htmlCreateAccount}}}</div>
|
||||
<div class="vector-user-menu-login">{{{htmlLogin}}}</div>
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
/* Icon for registered user names & anonymous message */
|
||||
#pt-anonuserpage,
|
||||
#pt-tmpuserpage,
|
||||
#pt-userpage a {
|
||||
background-position: @background-position-nav-personal-icon;
|
||||
background-image: url( images/user-avatar.svg );
|
||||
|
@ -26,7 +27,8 @@
|
|||
}
|
||||
|
||||
/* Show anonymous "Not logged in" text in gray */
|
||||
#pt-anonuserpage {
|
||||
#pt-anonuserpage,
|
||||
#pt-tmpuserpage {
|
||||
color: #54595d;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,12 @@
|
|||
.vector-menu-content-item-logout {
|
||||
border-top: 1px solid @border-color-base;
|
||||
}
|
||||
|
||||
#pt-tmpuserpage {
|
||||
padding: 4px @padding-horizontal-user-links;
|
||||
color: @colorGray5;
|
||||
font-size: @font-size-user-links;
|
||||
}
|
||||
}
|
||||
|
||||
.vector-user-menu-logged-out .vector-menu-heading {
|
||||
|
|
Loading…
Reference in New Issue