/
yanel-user-profile.xsl
352 lines (328 loc) · 11 KB
/
yanel-user-profile.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:l10n="http://www.wyona.org/yanel/l10n/1.0"
xmlns:xalan="http://xml.apache.org/xalan">
<xsl:output method="xhtml" encoding="UTF-8"/>
<xsl:param name="userId" select="''"/>
<xsl:param name="userName" select="''"/>
<!-- DEPRECATED
<xsl:param name="email" select="''"/>
-->
<xsl:param name="user-profile-language" select="'IS_NULL'"/>
<xsl:param name="expiration-date" select="'IS_NULL'"/>
<xsl:param name="description" select="'TODO'"/>
<xsl:param name="userGroupsString" select="'IS_NULL'"/>
<xsl:param name="allGroupsString" select="'IS_NULL'"/>
<xsl:param name="success" select="''"/>
<xsl:param name="error" select="''"/>
<xsl:param name="deletion" select="'false'"/>
<xsl:param name="yanel.back2realm" select="'BACK2REALM_IS_NULL'"/>
<xsl:param name="yanel.reservedPrefix" select="'RESERVEDPREFIX_IS_NULL'"/>
<xsl:param name="yanel.pre-authentication-enabled" select="'IS_PRE_AUTH_ENABLED_IS_NULL'"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:choose>
<xsl:when test="contains('true',$deletion)">
<head>
<link type="text/css" href="{$yanel.back2realm}{$yanel.reservedPrefix}/yanel-css/global.css" rel="stylesheet"></link>
</head>
<body>
<xsl:call-template name="show-message"/>
</body>
</xsl:when>
<xsl:otherwise>
<head>
<title>Edit user profile: <xsl:value-of select="/user/name"/></title>
<link type="text/css" href="{$yanel.back2realm}{$yanel.reservedPrefix}/yanel-css/global.css" rel="stylesheet"></link>
</head>
<body>
<table id="bodytable" cellpadding="0" cellspacing="0"><tr><td id="title">
Edit user profile of <xsl:value-of select="/user/name"/>
</td><td id="logo"><img src="{$yanel.back2realm}{$yanel.reservedPrefix}/yanel-img/yanel_header.png"/></td></tr><tr><td colspan="2" valign="top" width="100%"><div id="content">
<h1>
User Profile of '<xsl:value-of select="/user/name"/>' (ID: <xsl:value-of select="/user/@id"/>)
</h1>
<xsl:call-template name="show-message"/>
<!--
<xsl:apply-templates select="form"/>
-->
<xsl:apply-templates select="user"/>
</div></td></tr></table>
</body>
</xsl:otherwise>
</xsl:choose>
</html>
</xsl:template>
<xsl:template match="user">
<!--
<xsl:template match="form">
-->
<xsl:if test="$yanel.pre-authentication-enabled != 'true'">
<h2>Change Password</h2>
<form name="user-password-form" method="post" action="#">
<p>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Current password:</td>
<td>
<input type="password" name="oldPassword"/>
</td>
</tr>
<tr>
<td>New password:</td>
<td>
<input type="password" name="newPassword"/>
</td>
</tr>
<tr>
<td>Confirm new password:</td>
<td>
<input type="password" name="newPasswordConfirmation"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submitPassword" value="Apply"/>
</td>
</tr>
</table>
</p>
</form>
</xsl:if>
<h2>Change Identity</h2>
<form name="user-profile-form" method="post" action="#">
<p>
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="userName" value="{name}"/>
</td>
</tr>
<tr>
<td>E-Mail:</td>
<td>
<input type="text" name="email" value="{@email}"/>
</td>
</tr>
<tr>
<td>Language:</td>
<td><!-- TODO: Display languages only which are supported by this realm! What about identity managers used by more than one realm with different languages?! -->
<select name="user-profile-language">
<xsl:for-each select="/user/realm/languages/language">
<option value="{.}"><xsl:if test="/user/@language = ."><xsl:attribute name="selected">selected</xsl:attribute></xsl:if><xsl:value-of select="."/></option>
</xsl:for-each>
</select>
</td>
<!--
<td>
<input type="text" name="user-profile-language" value="{$user-profile-language}"/>
</td>
-->
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submitProfile" value="Apply"/>
</td>
</tr>
</table>
</p>
</form>
<h2>Additional Account info</h2>
<p>
<table>
<!--
<tr>
<td>Language:</td>
<td><xsl:value-of select="$user-profile-language"/></td>
</tr>
-->
<tr>
<td>Expiration Date:</td>
<td><xsl:value-of select="expiration-date"/></td>
</tr>
<tr>
<td>Description:</td>
<td><xsl:value-of select="description"/></td>
</tr>
</table>
</p>
<h2>Groups</h2>
Groups which this user belongs to:<!-- <xsl:value-of select="$userGroupsString"/> -->
<xsl:for-each select="groups/group">
<xsl:value-of select="@id"/><xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
<!--
<br/>
All groups of this realm: <xsl:value-of select="$allGroupsString"/>
-->
<!-- TODO: Is this actually working? -->
<!--
<h2>Change Groups</h2>
<h4>Remove from group</h4>
<p>
<table>
<xsl:call-template name="process-user-groups"/>
</table>
</p>
<xsl:call-template name="process-all-groups"/>
-->
<h2>Aliases</h2>
<xsl:choose>
<xsl:when test="aliases">
<ul>
<xsl:for-each select="aliases/alias">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:otherwise>
<p>No aliases yet.</p>
</xsl:otherwise>
</xsl:choose>
<!-- TBD <xsl:if test="$yanel.pre-authentication-enabled != 'true'"> -->
<h2>History</h2>
<table>
<tr>
<th>Usecase</th><th>Description</th><th>Date</th>
</tr>
<xsl:for-each select="history/event">
<tr>
<td><xsl:value-of select="@usecase"/></td><td><xsl:value-of select="@description"/></td><td><xsl:value-of select="@date"/></td>
</tr>
</xsl:for-each>
</table>
<!-- TBD: One shouldn't be able to delete oneself! -->
<!--
<h2>Delete User</h2>
<form name="user-deletion-form" method="post" action="#">
<p>
<table>
<tr>
<td colspan="2">
<input type="submit" name="submitDelete" value="Delete"/>
</td>
</tr>
</table>
</p>
</form>
-->
</xsl:template>
<xsl:template name="show-message">
<xsl:choose>
<xsl:when test="$success != ''">
<h4>
<xsl:value-of select="$success"/>
</h4>
</xsl:when>
<xsl:when test="$error != ''">
<h4>
An error occurred: <xsl:value-of select="$error"/>
</h4>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="tokenize">
<xsl:param name="inputString"/>
<xsl:param name="separator" select="' '"/>
<xsl:param name="resultElement" select="'item'"/>
<xsl:variable
name="token"
select="substring-before($inputString, $separator)" />
<xsl:variable
name="nextToken"
select="substring-after($inputString, $separator)" />
<xsl:if test="$token">
<xsl:element name="{$resultElement}">
<xsl:value-of select="$token"/>
</xsl:element>
</xsl:if>
<xsl:if test="$nextToken">
<xsl:call-template name="tokenize">
<xsl:with-param name="inputString" select="$nextToken"/>
<xsl:with-param name="separator" select="$separator"/>
<xsl:with-param name="resultElement" select="$resultElement"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="process-all-groups">
<xsl:variable name="groups">
<xsl:call-template name="tokenize">
<xsl:with-param name="inputString" select="$allGroupsString"/>
<xsl:with-param name="separator" select="';'"/>
<xsl:with-param name="resultElement" select="'group'"/>
</xsl:call-template>
</xsl:variable>
<h4> Add to group </h4>
<xsl:choose>
<xsl:when test="xalan:nodeset($groups)/node()">
<p>
<table>
<tr>
<td/>
<td>
<form name="add-user-to-group" method="post" action="#">
<select name="Group">
<xsl:for-each select="xalan:nodeset($groups)/node()">
<option>
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</option>
</xsl:for-each>
</select>
<input type="submit" value="Add">
<xsl:attribute name="name">
<xsl:text>submitAddToGroup</xsl:text>
</xsl:attribute>
</input>
</form>
</td>
</tr>
</table>
</p>
</xsl:when>
<xsl:otherwise>
<p>User already belongs to all existing groups</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-user-groups">
<xsl:variable name="groups">
<xsl:call-template name="tokenize">
<xsl:with-param name="inputString" select="$userGroupsString"/>
<xsl:with-param name="separator" select="';'"/>
<xsl:with-param name="resultElement" select="'group'"/>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="xalan:nodeset($groups)/node()">
<xsl:variable name="uniqueID">
<xsl:text>Group_</xsl:text>
<xsl:value-of select="."/>
</xsl:variable>
<tr>
<td/>
<td>
<form method="post" action="#">
<xsl:attribute name="name">
<xsl:value-of select="$uniqueID"/>
</xsl:attribute>
<h4>
<xsl:value-of select="."/>
</h4>
<input type="submit" value="Unsubscribe">
<xsl:attribute name="name">
<xsl:text>submitDeleteFrom</xsl:text>
<xsl:value-of select="$uniqueID"/>
</xsl:attribute>
</input>
</form>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>