1 | <accessor debug="false"> |
---|
2 | <name>ISOcat.access.data.user.update</name> |
---|
3 | <descr>Update a users profile.</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>user</name> |
---|
6 | <descr>the user login</descr> |
---|
7 | <type canonical="true">string</type> |
---|
8 | </param> |
---|
9 | <param mandatory="true"> |
---|
10 | <name>profile</name> |
---|
11 | <descr>the users updated profile</descr> |
---|
12 | </param> |
---|
13 | <idoc> |
---|
14 | <!-- validate the new users profile --> |
---|
15 | <instr> |
---|
16 | <type>validateRNG</type> |
---|
17 | <operand>var:profile</operand> |
---|
18 | <operator>active:ISOcat.access.data.user.profile.schema</operator> |
---|
19 | <target>var:valid</target> |
---|
20 | </instr> |
---|
21 | <if> |
---|
22 | <cond> |
---|
23 | <instr> |
---|
24 | <type>copy</type> |
---|
25 | <operand>var:valid</operand> |
---|
26 | <target>this:cond</target> |
---|
27 | </instr> |
---|
28 | </cond> |
---|
29 | <then> |
---|
30 | <instr> |
---|
31 | <type>xslt2</type> |
---|
32 | <operand>var:profile</operand> |
---|
33 | <operator> |
---|
34 | <xsl:stylesheet |
---|
35 | version="2.0" |
---|
36 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
37 | xmlns:isocat="urn:ISOcat" |
---|
38 | > |
---|
39 | <xsl:variable name="NL" select="system-property('line.separator')"/> |
---|
40 | <xsl:template match="/user"> |
---|
41 | <sql> |
---|
42 | <xsl:text>UPDATE core_user SET</xsl:text><xsl:value-of select="$NL"/> |
---|
43 | <xsl:for-each select="* except (id,login,access_count,first_access,last_access,type,name,sync)"> |
---|
44 | <xsl:value-of select="name()"/> |
---|
45 | <xsl:text> = '</xsl:text> |
---|
46 | <xsl:value-of select="replace(.,"'","''")"/> |
---|
47 | <xsl:text>',</xsl:text> |
---|
48 | <xsl:value-of select="$NL"/> |
---|
49 | </xsl:for-each> |
---|
50 | <xsl:text>sync = true </xsl:text> |
---|
51 | <xsl:text>WHERE login = '</xsl:text> |
---|
52 | <xsl:value-of select="login"/> |
---|
53 | <xsl:text>';</xsl:text> |
---|
54 | </sql> |
---|
55 | </xsl:template> |
---|
56 | </xsl:stylesheet> |
---|
57 | </operator> |
---|
58 | <target>var:sql</target> |
---|
59 | </instr> |
---|
60 | <accessor-debug> |
---|
61 | <instr> |
---|
62 | <type>copy</type> |
---|
63 | <operand>var:sql</operand> |
---|
64 | <target>ffcpl:/trace/user_update.sql.xml</target> |
---|
65 | </instr> |
---|
66 | </accessor-debug> |
---|
67 | <instr> |
---|
68 | <type>sqlUpdate</type> |
---|
69 | <operand>var:sql</operand> |
---|
70 | <target>var:result</target> |
---|
71 | </instr> |
---|
72 | <!-- get the uid --> |
---|
73 | <instr> |
---|
74 | <type>ISOcat.access.data.user.id</type> |
---|
75 | <user>var:user</user> |
---|
76 | <target>var:uid</target> |
---|
77 | </instr> |
---|
78 | <!-- touch the updated user --> |
---|
79 | <instr> |
---|
80 | <type>ISOcat.access.data.user.touch</type> |
---|
81 | <user>var:uid</user> |
---|
82 | <target>var:void</target> |
---|
83 | </instr> |
---|
84 | <!-- hug the context of the updated user --> |
---|
85 | <instr> |
---|
86 | <type>ISOcat.access.data.user.hug</type> |
---|
87 | <user>var:uid</user> |
---|
88 | <target>var:void</target> |
---|
89 | </instr> |
---|
90 | <!-- get the updated profile --> |
---|
91 | <instr> |
---|
92 | <type>ISOcat.access.data.user</type> |
---|
93 | <user>var:user</user> |
---|
94 | <target>this:response</target> |
---|
95 | </instr> |
---|
96 | </then> |
---|
97 | <else> |
---|
98 | <instr> |
---|
99 | <type>copy</type> |
---|
100 | <operand>var:profile</operand> |
---|
101 | <target>ffcpl:/trace/user_update.profile.xml</target> |
---|
102 | </instr> |
---|
103 | <instr> |
---|
104 | <type>copy</type> |
---|
105 | <operand>var:valid</operand> |
---|
106 | <target>ffcpl:/trace/user_update.profile.invalid.xml</target> |
---|
107 | </instr> |
---|
108 | <instr> |
---|
109 | <type>throw</type> |
---|
110 | <operand> |
---|
111 | <ex> |
---|
112 | <id>ISOcat[BAD REQUEST]</id> |
---|
113 | <message>The new users profile is invalid.</message> |
---|
114 | </ex> |
---|
115 | </operand> |
---|
116 | </instr> |
---|
117 | </else> |
---|
118 | </if> |
---|
119 | </idoc> |
---|
120 | <exception> |
---|
121 | <debug/> |
---|
122 | <trace>ffcpl:/trace/user_update.exception.xml</trace> |
---|
123 | <throw/> |
---|
124 | </exception> |
---|
125 | <response> |
---|
126 | <mime>application/xml</mime> |
---|
127 | <expire>now</expire> |
---|
128 | </response> |
---|
129 | </accessor> |
---|