Skip to content

Commit 0684999

Browse files
authored
MIR-1336 Display realname of creator/modifier in mir-admin-box (#1031)
* MIR-1341 Shorten texts for createdby and modifiedby in mir-admindata-box.xsl * MIR-1336 Display realname of creator in mir-admin-box * MIR-1336 Added template print-user-info to mir-admindata-box.xsl * MIR-1336 Minor layout fix * MIR-1336 Display real name of user as headline rather than username (which might be an uuid, when user is authenticated by shibboleth) * MIR-1336 Added blank after colon * MIR-1336 Fixed MIRUserController * MIR-1336 Fixed mir-module/pom.xml * MIR-1336 Check for administrate-users privilege
1 parent 6d192e4 commit 0684999

File tree

5 files changed

+72
-11
lines changed

5 files changed

+72
-11
lines changed

mir-it/src/test/java/org/mycore/mir/it/controller/MIRUserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected void assertEqualsIgnoreCase(String message, String expected, String ac
128128
}
129129

130130
public void assertUserCreated(String user) {
131-
driver.waitFor(ExpectedConditions.titleContains("Nutzerdaten anzeigen:" + user));
131+
driver.waitFor(ExpectedConditions.titleContains("Nutzerdaten anzeigen: " + user));
132132
}
133133

134134
public void assertValidationErrorVisible() {

mir-module/src/main/resources/xsl/metadata/mir-admindata-box.xsl

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33
xmlns:xlink="http://www.w3.org/1999/xlink"
44
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation" xmlns:mods="http://www.loc.gov/mods/v3"
5+
xmlns:mcracl="xalan://org.mycore.access.MCRAccessManager"
56
xmlns:mcrxsl="xalan://org.mycore.common.xml.MCRXMLFunctions"
6-
exclude-result-prefixes="i18n mods xlink mcrxsl">
7+
exclude-result-prefixes="i18n mcracl mods xlink mcrxsl">
78
<xsl:import href="xslImport:modsmeta:metadata/mir-admindata-box.xsl"/>
9+
<xsl:param name="WebApplicationBaseURL"/>
810

911
<xsl:template match="/">
1012
<xsl:variable name="ID" select="/mycoreobject/@ID"/>
@@ -30,9 +32,10 @@
3032
<xsl:with-param select="mycoreobject/service/servdates/servdate[@type='createdate']" name="nodes"/>
3133
<xsl:with-param select="i18n:translate('metaData.createdAt')" name="label"/>
3234
</xsl:call-template>
33-
<xsl:call-template name="printMetaDate">
34-
<xsl:with-param select="mycoreobject/service/servflags/servflag[@type='createdby']" name="nodes"/>
35-
<xsl:with-param select="i18n:translate('mir.metaData.detailBox.by')" name="label"/>
35+
36+
<xsl:call-template name="print-user-info">
37+
<xsl:with-param name="user" select="document(concat('notnull:user:', mycoreobject/service/servflags/servflag[@type='createdby']))"/>
38+
<xsl:with-param name="label" select="i18n:translate('mir.metaData.detailBox.by')"/>
3639
</xsl:call-template>
3740
<xsl:for-each select="mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:note">
3841
<xsl:variable name="noteType">
@@ -65,9 +68,9 @@
6568
<xsl:with-param select="mycoreobject/service/servdates/servdate[@type='modifydate']" name="nodes"/>
6669
<xsl:with-param select="i18n:translate('metaData.lastChanged')" name="label"/>
6770
</xsl:call-template>
68-
<xsl:call-template name="printMetaDate">
69-
<xsl:with-param select="mycoreobject/service/servflags/servflag[@type='modifiedby']" name="nodes"/>
70-
<xsl:with-param select="i18n:translate('mir.metaData.detailBox.by')" name="label"/>
71+
<xsl:call-template name="print-user-info">
72+
<xsl:with-param name="user" select="document(concat('notnull:user:', mycoreobject/service/servflags/servflag[@type='modifiedby']))"/>
73+
<xsl:with-param name="label" select="i18n:translate('mir.metaData.detailBox.by')"/>
7174
</xsl:call-template>
7275
<!--*** MyCoRe-ID and intern ID *************************** -->
7376
<tr>
@@ -126,4 +129,44 @@
126129
<xsl:apply-imports/>
127130
</xsl:template>
128131

132+
<xsl:template name="print-user-info">
133+
<xsl:param name="user"/>
134+
<xsl:param name="label"/>
135+
136+
<xsl:variable name="display-name">
137+
<xsl:choose>
138+
<xsl:when test="$user/user/realName">
139+
<xsl:value-of select="$user/user/realName"/>
140+
</xsl:when>
141+
<xsl:otherwise>
142+
<xsl:value-of select="$user/user/@name"/>
143+
</xsl:otherwise>
144+
</xsl:choose>
145+
</xsl:variable>
146+
147+
<tr>
148+
<td class="metaname">
149+
<xsl:value-of select="concat($label, ':')"/>
150+
</td>
151+
152+
<td class="metavalue">
153+
<xsl:if test="$user/user/realName">
154+
<xsl:attribute name="title">
155+
<xsl:value-of select="concat($user/user/@name, '@', $user/user/@realm)"/>
156+
</xsl:attribute>
157+
</xsl:if>
158+
159+
<xsl:choose>
160+
<xsl:when test="mcracl:checkPermission('POOLPRIVILEGE', 'administrate-users')">
161+
<a href="{$WebApplicationBaseURL}servlets/MCRUserServlet?action=show&amp;id={$user/user/@name}">
162+
<xsl:value-of select="$display-name"/>
163+
</a>
164+
</xsl:when>
165+
<xsl:otherwise>
166+
<xsl:value-of select="$display-name"/>
167+
</xsl:otherwise>
168+
</xsl:choose>
169+
</td>
170+
</tr>
171+
</xsl:template>
129172
</xsl:stylesheet>

mir-module/src/main/resources/xsl/modsdetails-external.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@
485485
</li -->
486486
</xsl:when>
487487
<xsl:otherwise>
488-
<li>
488+
<li class="dropdown-item">
489489
<xsl:value-of select="i18n:translate('object.locked')" />
490490
</li>
491491
</xsl:otherwise>

mir-module/src/main/resources/xsl/user.xsl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
<xsl:variable name="PageID" select="'show-user'" />
1313

14-
<xsl:variable name="PageTitle" select="concat(i18n:translate('component.user2.admin.userDisplay'),/user/@name)" />
14+
<xsl:variable name="PageTitle">
15+
<xsl:call-template name="user-display-name"/>
16+
</xsl:variable>
1517

1618
<xsl:param name="step" />
1719
<xsl:param name="MCR.ORCID.LinkURL" />
@@ -79,7 +81,7 @@
7981
</div>
8082
<div class="clearfix" />
8183
<h2>
82-
<xsl:value-of select="concat(i18n:translate('component.user2.admin.userDisplay'),@name)" />
84+
<xsl:call-template name="user-display-name"/>
8385
</h2>
8486
<xsl:if test="$step = 'confirmDelete'">
8587
<div class="section alert alert-danger">
@@ -429,4 +431,15 @@
429431
</xsl:if>
430432
</xsl:template>
431433

434+
<xsl:template name="user-display-name">
435+
<xsl:choose>
436+
<xsl:when test="/user/realName">
437+
<xsl:value-of select="concat(i18n:translate('component.user2.admin.userDisplay'), ' ', /user/realName)"/>
438+
</xsl:when>
439+
<xsl:otherwise>
440+
<xsl:value-of select="concat(i18n:translate('component.user2.admin.userDisplay'), ' ', /user/@name)"/>
441+
</xsl:otherwise>
442+
</xsl:choose>
443+
</xsl:template>
444+
432445
</xsl:stylesheet>

mir-module/src/main/resources/xslt/metadata/mods-metadata-page.xsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@
280280
</xsl:template>
281281
<xsl:template match="td[@class='metavalue']" mode="newMetadata" priority="2">
282282
<dd>
283+
<xsl:if test="@title">
284+
<xsl:attribute name="title">
285+
<xsl:value-of select="@title"/>
286+
</xsl:attribute>
287+
</xsl:if>
283288
<xsl:copy-of select="node()|*"/>
284289
</dd>
285290
</xsl:template>

0 commit comments

Comments
 (0)