source: main/trunk/ibisph-view/src/main/webapp/xslt/_ibis-user.xslt @ 22751

Last change on this file since 22751 was 17416, checked in by Garth Braithwaite, 3 years ago

java, view, admin - Cleaned out old, unused SVG map js code. More work on view xml static model maps. Misc community and user access_denied.jsp ui updates. Refactored ibis.xslt into sub xslt files to manage better. Refactored interactive, kendo, leaflet, graphic xslt code into XML, JSON, and graphic.xslt.

File size: 3.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet version="3.0" 
4        xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" 
5        xmlns:xs  ="http://www.w3.org/2001/XMLSchema"
6        xmlns:ibis="http://www.ibisph.org"
7
8        exclude-result-prefixes="ibis xs xsl"
9>
10
11        <ibis:doc>
12                <name>ibis.user</name>
13                <summary>Library of generic/common user related functions</summary>
14        </ibis:doc>
15
16
17        <!-- ========================= P A R A M E T E R S   and   V A R I A B L E S
18                The java servlet controller code adds ALL URL query request parameters
19                to the XSLT transformation's parameters.  Other special parameters are
20                added as well. 
21
22                Many of the global type parameters are defined within this XSLT file. 
23                The parameters are passed in via the Java XSLT transformation parameter
24                map (and thus are nameed according to the Java model map key value). 
25                For ease of XSLT code maintenance these global XSLT parameters are
26                wrapped within an "ibis." prefix so that it is shown which XSLT file
27                contains the definition.
28        -->
29
30        <xsl:param name="UserProfile"
31                ibis:doc="User's XML Profile document.  Must provide a default node type
32                        value so that $UserProfile//AUTHORITIES will work when no user profile
33                        doc is injected.  Otherwise the following type of check is needed:
34                        xsl:with-param name='userAuthorities' select='if(boolean($UserProfile))then $UserProfile//AUTHORITIES else ''
35                "
36        />
37        <xsl:variable name="ibis.userProfile" 
38                ibis:doc="User Profile XML variable that all pages should use.  Has the
39                        'ibis.' prefix to know what XSLT the variable/param is defined in.
40                "
41        >
42                <xsl:choose>
43                        <xsl:when test="not($UserProfile)">
44                                <FULL_NAME>Not Authenticated</FULL_NAME>
45                        </xsl:when>
46                        <xsl:when test="exists($UserProfile/USER)">
47                                <xsl:copy-of select="$UserProfile/USER/*"/>
48                        </xsl:when>
49                        <xsl:when test="exists($UserProfile)">
50                                <xsl:copy-of select="$UserProfile"/>
51                        </xsl:when>
52                        <xsl:otherwise>
53                                <FULL_NAME>Not Authenticated</FULL_NAME>
54                        </xsl:otherwise>
55                </xsl:choose>
56        </xsl:variable>
57        <xsl:param name="ibis.userAuthorities" select="$ibis.userProfile/AUTHORITIES"
58                ibis:doc="Variable used by the ibis:hasAuthority function or can be used directly."
59        />
60
61
62        <!-- ===================================================== G E N E R A L -->
63        <xsl:function name="ibis:isAuthenticated" as="xs:boolean"
64                ibis:doc="localizes checking the UserProfile param exists as a node. 
65                        Note the not not is needed to handle string vs node xslt problem. 
66                        Exists returns true for any/all defined variables/params.  not
67                        handles a null or zero len string as false and also handles an
68                        empty node set as false.
69                "
70        >
71                <xsl:value-of select="not(not($UserProfile))"/>
72        </xsl:function>
73
74        <xsl:function name="ibis:hasAuthorities" as="xs:boolean"
75                ibis:doc="localizes checking if the user is authenticated and if so if
76                        they have an authority (secure type user).
77                "
78        >
79                <xsl:value-of select="if(ibis:isAuthenticated()) then exists($ibis.userAuthorities/AUTHORITY) else false()"/>
80        </xsl:function>
81
82        <xsl:function name="ibis:hasAuthority" as="xs:boolean"
83                ibis:doc="localizes checking the user authorities against the passed in
84                        AUTHORITY.  If an AUTHORITY's text() matches one of the user's
85                        AUTHORITY values then true is returned.  Else false is returned. 
86                        This function is dependent on the global UserAuthorities param
87                        which needs to be injected via the java controller/transformer code.
88                "
89        >
90                <xsl:param name="authority" ibis:doc="AUTHORITY value to be tested for."/>
91                <xsl:value-of select="not(exists($authority)) or exists($ibis.userAuthorities[AUTHORITY = $authority])"/>
92        </xsl:function>
93
94</xsl:stylesheet>
95
96<!-- ============================= End of File ============================= -->
97
Note: See TracBrowser for help on using the repository browser.