1 | <accessor debug="false"> |
---|
2 | <name>ISOcat.access.data.broadcast</name> |
---|
3 | <descr>Broadcast a message to all logged in users</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>from</name> |
---|
6 | <descr>the login from the sysadmin broadcasting the message</descr> |
---|
7 | <type canonical="true">string</type> |
---|
8 | </param> |
---|
9 | <param> |
---|
10 | <name>subject</name> |
---|
11 | <descr>the message subject</descr> |
---|
12 | <type canonical="true">string</type> |
---|
13 | <source> |
---|
14 | <param/> |
---|
15 | <default> |
---|
16 | <string>ISOcat broadcast</string> |
---|
17 | </default> |
---|
18 | </source> |
---|
19 | </param> |
---|
20 | <param mandatory="true"> |
---|
21 | <name>message</name> |
---|
22 | <descr>the actual message</descr> |
---|
23 | <type canonical="true">string</type> |
---|
24 | </param> |
---|
25 | <idoc> |
---|
26 | <!-- check if the user exists and is an administrator --> |
---|
27 | <instr> |
---|
28 | <type>ISOcat.access.data.user.type</type> |
---|
29 | <user>var:from</user> |
---|
30 | <target>var:type</target> |
---|
31 | </instr> |
---|
32 | <exception> |
---|
33 | <!-- probably the user doesn't exist --> |
---|
34 | <instr> |
---|
35 | <type>copy</type> |
---|
36 | <operand> |
---|
37 | <string>none</string> |
---|
38 | </operand> |
---|
39 | <target>var:type</target> |
---|
40 | </instr> |
---|
41 | </exception> |
---|
42 | <if> |
---|
43 | <cond> |
---|
44 | <instr> |
---|
45 | <type>sloot.xpath2eval</type> |
---|
46 | <operand>var:type</operand> |
---|
47 | <operator> |
---|
48 | <xpath>.='admin'</xpath> |
---|
49 | </operator> |
---|
50 | <target>this:cond</target> |
---|
51 | </instr> |
---|
52 | </cond> |
---|
53 | <then> |
---|
54 | <instr> |
---|
55 | <type>sloot.xquery</type> |
---|
56 | <operator> |
---|
57 | <xquery> |
---|
58 | declare variable $from as node() external; |
---|
59 | declare variable $subject as node() external; |
---|
60 | declare variable $message as node() external; |
---|
61 | <sql> |
---|
62 | INSERT INTO core_message |
---|
63 | ( |
---|
64 | "from", |
---|
65 | "subject", |
---|
66 | "message", |
---|
67 | "type" |
---|
68 | ) |
---|
69 | VALUES |
---|
70 | ( |
---|
71 | (SELECT id FROM core_user WHERE login = '{replace(string($from),"'","''")}'), |
---|
72 | '{replace(string($subject),"'","''")}', |
---|
73 | '{replace(string($message),"'","''")}', |
---|
74 | 'broadcast' |
---|
75 | ) |
---|
76 | ; |
---|
77 | </sql> |
---|
78 | </xquery> |
---|
79 | </operator> |
---|
80 | <from>var:from</from> |
---|
81 | <subject>var:subject</subject> |
---|
82 | <message>var:message</message> |
---|
83 | <target>var:sql</target> |
---|
84 | </instr> |
---|
85 | <accessor-debug> |
---|
86 | <instr> |
---|
87 | <type>copy</type> |
---|
88 | <operand>var:sql</operand> |
---|
89 | <target>ffcpl:/trace/broadcast.sql.xml</target> |
---|
90 | </instr> |
---|
91 | </accessor-debug> |
---|
92 | <instr> |
---|
93 | <type>isocat.sqlUpdate</type> |
---|
94 | <operand>var:sql</operand> |
---|
95 | <target>var:result</target> |
---|
96 | </instr> |
---|
97 | <accessor-debug> |
---|
98 | <instr> |
---|
99 | <type>copy</type> |
---|
100 | <operand>var:result</operand> |
---|
101 | <target>ffcpl:/trace/broadcast.result.xml</target> |
---|
102 | </instr> |
---|
103 | </accessor-debug> |
---|
104 | <instr> |
---|
105 | <type>sloot.xquery</type> |
---|
106 | <operator> |
---|
107 | <xquery> |
---|
108 | declare variable $from as node() external; |
---|
109 | declare variable $subject as node() external; |
---|
110 | declare variable $message as node() external; |
---|
111 | <msg>INF: {current-dateTime()}:ISOcat.access.data.broadcast: [{string($from)}][{string($subject)}]{string($message)}</msg> |
---|
112 | </xquery> |
---|
113 | </operator> |
---|
114 | <from>var:from</from> |
---|
115 | <subject>var:subject</subject> |
---|
116 | <message>var:message</message> |
---|
117 | <target>var:msg</target> |
---|
118 | </instr> |
---|
119 | <instr> |
---|
120 | <type>sloot.log</type> |
---|
121 | <operand>var:msg</operand> |
---|
122 | </instr> |
---|
123 | <instr> |
---|
124 | <type>copy</type> |
---|
125 | <operand>var:msg</operand> |
---|
126 | <target>this:response</target> |
---|
127 | </instr> |
---|
128 | </then> |
---|
129 | <else> |
---|
130 | <instr> |
---|
131 | <type>throw</type> |
---|
132 | <operand> |
---|
133 | <ex> |
---|
134 | <id>ISOcat[FORBIDDEN]</id> |
---|
135 | <message>This user isn't allowed to carry out this action.</message> |
---|
136 | </ex> |
---|
137 | </operand> |
---|
138 | </instr> |
---|
139 | </else> |
---|
140 | </if> |
---|
141 | </idoc> |
---|
142 | <exception> |
---|
143 | <debug/> |
---|
144 | <trace>ffcpl:/trace/broadcast.exception.xml</trace> |
---|
145 | <throw/> |
---|
146 | </exception> |
---|
147 | <response> |
---|
148 | <debug>ffcpl:/trace/broadcast.response.xml</debug> |
---|
149 | <mime>application/xml</mime> |
---|
150 | </response> |
---|
151 | </accessor> |
---|