Skip to content

Commit

Permalink
Merge pull request #30 from wolfgangmm/bugfix/deprecated-funcs
Browse files Browse the repository at this point in the history
Fix use of deprecated functions for compatibility with 5.0
  • Loading branch information
adamretter authored May 8, 2019
2 parents dfb1522 + 33ddca2 commit c0355d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/xar-resources/controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ else if ($exist:resource eq "login") then
util:declare-option("exist:serialize", "method=json"),
<status>
<user>{request:get-attribute("org.exist.login.user")}</user>
<isAdmin json:literal="true">{ xmldb:is-admin-user(request:get-attribute("org.exist.login.user")) }</isAdmin>
<isAdmin json:literal="true">{ sm:is-dba(request:get-attribute("org.exist.login.user")) }</isAdmin>
</status>
} catch * {
response:set-status-code(401),
Expand Down
12 changes: 6 additions & 6 deletions src/main/xar-resources/modules/app.xql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare variable $app:MD_CONFIG := map {
};

declare function app:check-dba-user($node as node(), $model as map(*)) {
let $user := xmldb:get-current-user()
let $user := sm:id()/sm:id/(sm:effective|sm:real)[1]/sm:username
return
if (sm:is-dba($user)) then
$node
Expand All @@ -38,7 +38,7 @@ declare function app:check-dba-user($node as node(), $model as map(*)) {

declare function app:check-dba-user-and-not-data($node as node(), $model as map(*)) {
let $data := collection($config:app-data)/xqdoc:xqdoc
let $user := xmldb:get-current-user()
let $user := sm:id()/sm:id/(sm:effective|sm:real)[1]/sm:username
return
if (sm:is-dba($user) and not($data)) then
element { node-name($node) } {
Expand All @@ -50,7 +50,7 @@ declare function app:check-dba-user-and-not-data($node as node(), $model as map(

declare function app:check-dba-user-and-data($node as node(), $model as map(*)) {
let $data := collection($config:app-data)/xqdoc:xqdoc
let $user := xmldb:get-current-user()
let $user := sm:id()/sm:id/(sm:effective|sm:real)[1]/sm:username
return
if (sm:is-dba($user) and ($data)) then
element { node-name($node) } {
Expand All @@ -71,7 +71,7 @@ declare function app:check-not-data($node as node(), $model as map(*)) {

declare function app:check-not-dba-user-and-not-data($node as node(), $model as map(*)) {
let $data := collection($config:app-data)/xqdoc:xqdoc
let $user := xmldb:get-current-user()
let $user := sm:id()/sm:id/(sm:effective|sm:real)[1]/sm:username
return
if (not(sm:is-dba($user)) and not($data)) then
$node
Expand Down Expand Up @@ -136,7 +136,7 @@ declare %private function app:print-module($module as element(xqdoc:xqdoc), $fun
let $uri := $module/xqdoc:module/xqdoc:uri/text()
let $extDocs := app:get-extended-module-doc($module)[1]
let $description := $module/xqdoc:module/xqdoc:comment/xqdoc:description/node()
let $parsed := if (contains($description, '&lt;') or contains($description, '&amp;')) then $description else util:parse("<div>" || replace($description, "\n{2,}", "<br/>") || "</div>")/*/node()
let $parsed := if (contains($description, '&lt;') or contains($description, '&amp;')) then $description else parse-xml("<div>" || replace($description, "\n{2,}", "<br/>") || "</div>")/*/node()
return
<div class="module" data-xqdoc="{document-uri(root($module))}">
<div class="module-head">
Expand Down Expand Up @@ -220,7 +220,7 @@ declare %private function app:print-function($function as element(xqdoc:function
then (substring-after($function-name, ":") || $arity)
else ($function-name || $arity)
let $description := $comment/xqdoc:description/node()
let $parsed := if (contains($description, '&lt;') or contains($description, '&amp;')) then $description else util:parse("<div>" || replace($description, "\n{2,}", "<br/>") || "</div>")/*/node()
let $parsed := if (contains($description, '&lt;') or contains($description, '&amp;')) then $description else parse-xml("<div>" || replace($description, "\n{2,}", "<br/>") || "</div>")/*/node()
let $extDocs := app:get-extended-doc($function)[1]
return
<div class="function" id="{$function-identifier}">
Expand Down
2 changes: 1 addition & 1 deletion src/main/xar-resources/modules/reindex.xql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import module namespace config="http://exist-db.org/xquery/apps/config" at "conf

declare option exist:serialize "method=json media-type=application/javascript";

let $isDba := xmldb:is-admin-user(xmldb:get-current-user())
let $isDba := sm:is-dba(xsm:id()/sm:id/(sm:effective|sm:real)[1]/sm:username)
return
if ($isDba) then
<response status="ok">
Expand Down

0 comments on commit c0355d5

Please sign in to comment.