Allgemeine Aktionen:
Anmelden
Erstellen
▼
:
Kommentar erstellen
Wiki
▼
:
Dokumentenindex
»
Space:
XWiki
▼
:
Dokumentenverzeichnis
»
Seite:
ConfigurableClass
Suche
Aktionen:
Exportieren
▼
:
Als PDF exportieren
Als RTF exportieren
Als HTML exportieren
Weitere Aktionen
▼
:
Druckvorschau
Zeige den Quellcode
Willkommen in den metamagix Wikis!
»
XWiki Space
»
XWiki.ConfigurableClass
Wiki-Quellcode von
XWiki.ConfigurableClass
Zuletzt geändert von
Administrator
am 2010/04/30 11:44
Inhalt
·
Kommentare
(0)
·
Anmerkungen
(0)
·
Anhänge
(1)
·
Historie
·
Information
Zeilennummern verstecken
Maximieren »
1: {{velocity}} 2: #* 3: * This part takes the configuration from any documents containing XWiki.ConfigurableClass objects and creates a form 4: * for each. To includeForm this document, you may specify: 5: * 6: * $section - String - The section which we are administrating eg: "Registration", "Users", or "Import". 7: * If none is specified then it checks for a request parameter called "section" and uses that, 8: * if no parameter, then this code assumes that it is part of the admin icons sheet and adds icons 9: * for any section which is not in $sections, in that event, this code assumes it is being run 10: * inside of a <ul> block. 11: * 12: * $sections - List<String> - If section is not specified, any sections on this list will not have icons made for them 13: * the assumption being that the icons are already there. If section is specified then this 14: * is not taken into account and may safely be undefined. 15: * 16: * $currentDoc - String (document.fullName) - The administration document, users who don't have permission to edit 17: * it will not be able to include applications (possibly injecting 18: * arbitrary code.) if none specified then $doc.getFullName() is used. 19: * 20: * $globaladmin - boolean - If set true then we will assume we are administrationg the entire wiki. 21: * If not set then we look for a request parameter called "editor" if that exists and equals 22: * "globaladmin" then $globaladmin is true, if it doesn't exist then we check to see if 23: * $currentDoc.getFullName() equals "XWiki.XWikiPreferences". 24: * 25: * $doNotUnlockConfigurableDocuments - boolean - If true then this code will not make any attempt to unlock configurable 26: * documents. By default it does because it locks any document in the 27: * section which is being configured which would lead to a lot of stray 28: * locks if they weren't all cancelled. Only recommended if this page is 29: * being included twice in the same page. 30: *### 31: ## Constants: 32: #set($redirectParameter = 'xredirect') 33: #set($nameOfThisDocument = 'XWiki.ConfigurableClass') 34: ## 35: ## Form submission depends on this. 36: $xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true) 37: ## 38: #if(!$section) 39: #set($section = $request.getParameter('section')) 40: #end 41: #if(!$currentDoc) 42: #set($currentDoc = $doc.getFullName()) 43: #end 44: ## Get value of $globaladmin if not specified. 45: #if("$!globaladmin" == '') 46: #if($editor != 'globaladmin' 47: && $request.getParameter('editor') != 'globaladmin' 48: && $currentDoc != "XWiki.XWikiPreferences") 49: ## 50: #set($globaladmin = false) 51: #else 52: #set($globaladmin = true) 53: #end 54: #end 55: #set($currentSpace = $xwiki.getDocument("$currentDoc").getSpace()) 56: ## 57: ## This application should not run with programming rights because it evaluates code which may not be trustworthy. 58: ## Removing the next line will open a security hole. 59: #sandboxDocument() 60: ## 61: ## This application locks every document in a section while that section is being edited so we should 62: ## check for locks held by the current user on any of the applications configured here and remove them. 63: #if(!$doNotUnlockConfigurableDocuments) 64: #set($outputList = []) 65: #findNamesOfAppsToConfigure("", $globaladmin, $currentSpace, $outputList)## 66: ## We don't want to generate javascript which unlocks the current document just after we got finished locking it. 67: #set($discard = $outputList.remove($currentDoc)) 68: #unlockDocuments($outputList) 69: #end 70: ## 71: ##------------------------------------------------------------------------------------------------------------ 72: ## If $section exists then we are viewing the admin page for a perticular section. 73: ## eg: 'Registration', 'Presentation', 'Import' etc. 74: ##------------------------------------------------------------------------------------------------------------ 75: ## 76: #if($section && $section != '') 77: ## 78: ## This is for keeping track of whether we have shown the heading yet or not. 79: ## If the heading doesn't need to be shown, but an error occurs in processing, then we show the heading 80: ## so that the user knows what the error relates to. 81: #set($headingShowing = false) 82: ## 83: ## Searches the database for names of apps to be configured 84: #set($outputList = []) 85: #findNamesOfAppsToConfigure($section, $globaladmin, $xwiki.getDocument("$currentDoc").getSpace(), $outputList) 86: ## 87: #foreach($appName in $outputList) 88: ## 89: ## Make sure the current user has permission to edit the configurable application. 90: #set($userHasAccessToDocument = $xcontext.hasAccessLevel('edit', $appName)) 91: ## 92: ## If the document was not last saved by a user with edit privilage on this page 93: ## then we can't safely display the page but we should warn the viewer. 94: #if($userHasAccessToDocument) 95: ## Get the configurable application 96: #set($app = $xwiki.getDocument($appName)) 97: ## 98: #set($documentSavedByAuthorizedUser = false) 99: #checkDocumentSavedByAuthorizedUser($app, $currentDoc, $documentSavedByAuthorizedUser) 100: #end 101: ## 102: ## There is no need to display a heading unless: 103: ## 1. There was already a section before this document. 104: ## 2. This is not the first document in this section. 105: ## 106: ## If we are displaying the heading and there is an error to be shown Javascript will not strip the heading. 107: #if(!$appName.equals($outputList.get(0)) || $sections.contains($section)) 108: ## Create a document heading. 109: #showHeading($appName, $headingShowing) 110: #end 111: ## 112: #if(!$userHasAccessToDocument) 113: #showHeading($appName, $headingShowing) 114: 115: {{error}}$msg.get('xe.admin.configurable.noPermissionThisApplication'){{/error}} 116: 117: #else 118: ## 119: #if(!$documentSavedByAuthorizedUser) 120: #showHeading($appName, $headingShowing) 121: 122: {{error}}$msg.get('xe.admin.configurable.applicationAuthorNoAdmin', [$app.Author]){{/error}} 123: 124: #else 125: ## 126: ## Locking document 127: ##------------------------------------------------------------------------------------------------------------ 128: #if($app.getLocked()) 129: #set($locked = true) 130: #end 131: ## If the document is locked and not by the current user and forceEdit is not set true, 132: #if($locked && $app.getLockingUser() != $xcontext.getUser() && !$request.getParameter('forceEdit')) 133: #set($requestURL = "$request.getRequestURL()") 134: #if($requestURL.indexOf("?") == -1) 135: #set($requestURL = "${requestURL}?") 136: #end 137: #showHeading($appName, $headingShowing) 138: 139: {{error}}$msg.get("doclockedby") $app.getLockingUser() [[$msg.get("forcelock")>>${requestURL}&forceEdit=1]]{{/error}} 140: 141: #else 142: ## If the document is not already locked, attempt to aquire the lock. 143: #if(!$locked) 144: ## Try to use an ajax call to lock the document. 145: 146: 147: {{html clean=false wiki=true}} 148: <noscript> 149: 150: {{warning}}$msg.get('xe.admin.configurable.cannotLockNoJavascript'){{/warning}} 151: 152: </noscript> 153: <script type="text/javascript"> 154: document.observe("dom:loaded", function() { 155: new Ajax.Request("$xwiki.getURL($app.getFullName(), 'lock', 'ajax=1')"); 156: }); 157: </script> 158: {{/html}} 159: 160: #set($discard = $lockedDocumentNames.add($app.getFullName())) 161: #end 162: ##------------------------------------------------------------------------------------------------------------ 163: ## Done Locking. 164: ## 165: ## Get all objects of the "ConfigurableClass" from this document. 166: #set($allConfigurableObjs = $app.getObjects($nameOfThisDocument)) 167: ## Seperate out the objects which are for this section. 168: #set($configurableObjs = []) 169: #foreach($configurableObj in $allConfigurableObjs) 170: #if($app.getValue('displayInSection', $configurableObj) == $section) 171: ## If this is space admin, then don't display global, if global don't display space. 172: #if($globaladmin == ($app.getValue('configureGlobally', $configurableObj) == 1)) 173: #set($discard = $configurableObjs.add($configurableObj)) 174: #end 175: #end 176: #end 177: #if($configurableObjs.size() == 0) 178: ## Internal error, not translated. 179: #showHeading($appName, $headingShowing) 180: 181: {{error}}Internal error: All objects were filtered out for application: $appName.{{/error}} 182: 183: #else 184: #set($formAction = "$xwiki.getURL($app.getFullName(), 'save')") 185: #set($formId = "$section.toLowerCase()_$app.getFullName()") 186: #set($escapedAppName = $escapetool.html($app.getFullName())) 187: #foreach($configurableObj in $configurableObjs) 188: ## Display the header if one exists. 189: #set($heading = $app.getValue('heading', $configurableObj)) 190: #if($heading && $heading != '') 191: == #evaluate($heading) == 192: #end 193: ## 194: #set($codeToExecute = "$!app.getValue('codeToExecute', $configurableObj)") 195: #if($codeToExecute != '') 196: #evaluate($codeToExecute) 197: #end 198: ## 199: ## If propertiesToShow is set, then we will only show the properties contained therein. 200: #set($propertiesToShow = $app.getValue('propertiesToShow', $configurableObj)) 201: #if(!$propertiesToShow || $propertiesToShow.getClass().getName().indexOf('List') == -1) 202: #set($propertiesToShow = []) 203: #end 204: ## 205: ## If linkPrefix is set, then we will make each property label a link which starts with that prefix. 206: #set($linkPrefix = "$!app.getValue('linkPrefix', $configurableObj)") 207: ## 208: ## If the Configurable object specifies a configuration class, use it, 209: ## otherwise assume custom forms are used instead. 210: #set($configClassName = "$!app.getValue('configurationClass', $configurableObj)") 211: #if($configClassName != '') 212: #set($objClass = $xwiki.getDocument("$configClassName").getxWikiClass()) 213: #if(!$objClass || $objClass.getClass().getName().indexOf('.Class') == -1) 214: #showHeading($appName, $headingShowing) 215: 216: {{error}}$msg.get('xe.admin.configurable.configurationClassNonexistant'){{/error}} 217: 218: #else 219: ## Use the first object from the document which is of the configuration class. 220: #set($obj = $app.getObject($objClass.getName())) 221: ## 222: #if(!$obj || $obj.getClass().getName().indexOf('.Object') == -1) 223: #showHeading($appName, $headingShowing) 224: 225: {{error}} 226: $msg.get('xe.admin.configurable.noObjectOfConfigurationClassFound', 227: [$objClass.getName(), $app.getFullName()]) 228: {{/error}} 229: 230: #else 231: ## 232: ## Merge save buttons, remove headings from subsections, and make information links into popups. 233: ## This is not done if there is only a custom defined form. 234: $xwiki.jsx.use($nameOfThisDocument) 235: ## 236: #define($formHtml) 237: ## We don't begin the form until we have content for it so that a configurable can specify a 238: ## custom form in codeToExecute and if that configurable object is the first of it's kind in that 239: ## document, the custom form will not be put inside of our form. 240: #if(!$insideForm) 241: <form id="$formId" method="post" action="$formAction"> 242: <fieldset> 243: #set($insideForm = true) 244: #end 245: #foreach($propName in $objClass.getPropertyNames()) 246: #if($propertiesToShow.size() > 0 && !$propertiesToShow.contains($propName)) 247: ## Silently skip over this property. 248: #else 249: <p> 250: #set($prettyName = "#evaluate($app.displayPrettyName($propName, $obj))") 251: ## App Name is prepended to for= to make label work with id which is modified to prevent collisions. 252: <label for="${escapedAppName}_$objClass.getName()_$obj.getNumber()_$propName"> 253: #if($linkPrefix != '') 254: #set($linkScript = "$linkPrefix$propName") 255: <a href="$escapetool.html("#evaluate($linkScript)")">$escapetool.html($prettyName)</a> 256: #else 257: $escapetool.html($prettyName) 258: #end 259: </label> 260: ## Step 1: Strip pre tags which $obj.display inserts, this won't affect content because it's escaped. 261: #set($out = $obj.display($propName, "edit").replaceAll('<[/]?pre>', '')) 262: ## Step 2: Select only content between first < and last > because $obj.display inserts html macros. 263: ## Careful not to remove html macros from the content because they are not escaped! 264: ## Step 3: Prepend app name to all ID tags to prevent id collision with multiple apps on one page. 265: $out.substring($out.indexOf('<'), $mathtool.add(1, $out.lastIndexOf('>'))).replaceAll( 266: " id='$objClass.getName()_$obj.getNumber()_$propName", 267: " id='${escapedAppName}_$objClass.getName()_$obj.getNumber()_$propName") 268: </p> 269: #end## If property is in propertiesToShow 270: #end## Foreach property in this class 271: #end## define $formHtml 272: 273: 274: {{html clean="false" wiki="false"}} 275: $formHtml.toString() 276: {{/html}} 277: 278: #end## If object exists 279: #end## If class exists 280: #end## If class name is specified. 281: #end## Foreach configurable object found in this document 282: ## If a form was started then we end it. 283: #if($insideForm) 284: 285: {{html clean="false" wiki="false"}} 286: ## We add in a redirect field to prevent the user from being carried away when they save 287: ## if they don't have javascript. 288: #set($thisURL = $request.getRequestURL()) 289: #if($request.getQueryString() && $request.getQueryString().length() > 0) 290: #set($thisURL = "${thisURL}?$request.getQueryString()") 291: #end 292: <input type="hidden" id="${escapedAppName}_redirect" name="$redirectParameter" value="$escapetool.html($thisURL)" /> 293: </fieldset> 294: <div class="bottombuttons"> 295: <p class="admin-buttons"> 296: <span class="buttonwrapper"> 297: ## Text to display on the button. If there is a heading then this button should be labeled 298: ## that it is for saving this section. Otherwise it should be a generic "save" button. 299: #if($headingShowing) 300: #set($buttonText = "$msg.get('admin.save') $escapedAppName") 301: #else 302: #set($buttonText = "$msg.get('admin.save')") 303: #end 304: <input class="button" type="submit" name="action_saveandcontinue" value="$buttonText" /> 305: </span> 306: </p> 307: </div> ## bottombuttons 308: </form> 309: #set($insideForm = false) 310: {{/html}} 311: 312: #end 313: #end## If there are configurable objects 314: #end## If document is not locked or forceEdit is enabled 315: #end## If app author has permission to edit admin page 316: #end## If the current user has permission to edit the configurable application. 317: #end## Foreach document name in names to configure 318: {{html clean=false wiki=false}} 319: <script type="text/javascript"> 320: /* <![CDATA[ */ 321: ## Alt+Shift+S presses the first saveAndContinue button it finds, not what we want so we will disable edit shortcuts. 322: document.observe('xwiki:dom:loaded', function() { 323: XWiki.actionButtons.EditActions = Object.extend(XWiki.actionButtons.EditActions, {addShortcuts : function() { }}); 324: }); 325: //]]> 326: </script> 327: {{/html}}## 328: ## 329: #else 330: ## 331: ##------------------------------------------------------------------------------------------------------------ 332: ## If section is not set then we are viewing the main administration page. 333: ##------------------------------------------------------------------------------------------------------------ 334: ## 335: ## If there is no list called sections then we set sections to an empty list. 336: #if(!$sections || $sections.getClass().getName().indexOf("List") == -1) 337: #set($sections = []) 338: #end 339: ## 340: ## We have to create a list of documents which the current user doesn't have permission to view. 341: ## So we can add an error messsage to the bottom of the page if there are any. 342: #set($appsUserCannotView = []) 343: ## 344: ## A list of sections (to be added) which the user is not allowed to edit, icons will be displayed with a message 345: #set($sectionsUserCannotEdit = []) 346: ## List of sections to be added, in order by creationDate of oldest contained application. 347: #set($sectionsToAdd = []) 348: ## Map of URL of icon to use by the name of the section to use that icon on. 349: #set($iconBySection = {}) 350: ## 351: #set($outputList = []) 352: #findNamesOfAppsToConfigure("", $globaladmin, $currentSpace, $outputList) 353: ## 354: #foreach($appName in $outputList) 355: ## 356: ## Get the configurable application 357: #set($app = $xwiki.getDocument($appName)) 358: ## 359: ## If getDocument returns null, then warn the user that they don't have view access to that application. 360: #if(!$app) 361: #set($discard = $appsUserCannotView.add($appName)) 362: #end 363: ## 364: #set($configurableObjects = $app.getObjects($nameOfThisDocument)) 365: #foreach($configurableObject in $configurableObjects) 366: #set($displayInSection = $app.getValue('displayInSection', $configurableObject)) 367: ## 368: ## If there is no section for this configurable or if the section cannot be edited, then check if the 369: ## application can be edited by the current user, if so then we display the icon from the current app and 370: ## don't display any message to tell the user they can't edit that section. 371: #if(!$sections.contains($displayInSection) || $sectionsUserCannotEdit.contains($displayInSection)) 372: ## 373: ## If there is no section for this configurable, then we will have to add one. 374: #if(!$sections.contains($displayInSection) && !$sectionsToAdd.contains($displayInSection)) 375: #set($discard = $sectionsToAdd.add($displayInSection)) 376: #end 377: ## 378: ## If an attachment by the filename iconAttachment exists and is an image 379: #set($attachment = $app.getAttachment("$app.getValue('iconAttachment', $configurableObject)")) 380: #if($attachment && $attachment.isImage()) 381: ## Set the icon for this section as the attachment URL. 382: #set($discard = $iconBySection.put($displayInSection, $app.getAttachmentURL($attachment.getFilename()))) 383: #end 384: ## 385: ## If the user doesn't have edit access to the application, we want to should show a message on the icon 386: #if(!$xcontext.hasAccessLevel("edit", $app.getFullName())) 387: #if(!$sectionsUserCannotEdit.contains($displayInSection)) 388: #set($discard = $sectionsUserCannotEdit.add($displayInSection)) 389: #end 390: #elseif($sectionsUserCannotEdit.contains($displayInSection)) 391: ## If the user didn't have access to the section before but does have access to _this_ app which is 392: ## configured in the section, then the section becomes accessable. 393: #set($discard = $sectionsUserCannotEdit.remove($displayInSection)) 394: #end 395: #end## If section doesn't exist or user doesn't have access. 396: #end## Foreach configurable object in this app. 397: #end## Foreach application which is configurable. 398: ## 399: ## Now we go through sectionsToAdd and generate icons for them 400: #set($defaultIcon = $xwiki.getAttachmentURL($nameOfThisDocument, 'DefaultAdminSectionIcon.png')) 401: #if($globaladmin) 402: #set($queryString = "editor=globaladmin&section=") 403: #else 404: #set($queryString = "space=${currentSpace}&section=") 405: #if($request.getParameter('editor')) 406: #set($queryString = "editor=$escapetool.url($request.getParameter('editor'))&$queryString") 407: #end 408: #end 409: 410: {{html clean=false wiki=false}} 411: #foreach($sectionToAdd in $sectionsToAdd) 412: #set($icon = $iconBySection.get($sectionToAdd)) 413: #if(!$icon) 414: #set($icon = $defaultIcon) 415: #end 416: <li class="$escapetool.html($sectionToAdd).replaceAll(' ', '_')"> 417: #set($hasAccess = !$sectionsUserCannotEdit.contains($sectionToAdd)) 418: #if($hasAccess) 419: <a href="$xwiki.getURL($currentDoc, $xcontext.getAction(), "$queryString$escapetool.url($sectionToAdd)")"> 420: #else 421: <a title="$msg.get('xe.admin.configurable.sectionIconNoAccessTooltip')"> 422: #end 423: <img src="$icon" alt="$escapetool.html($sectionToAdd) icon"/> 424: $escapetool.html($sectionToAdd) 425: #if(!$hasAccess) 426: <br/><span class="errormessage">$msg.get('xe.admin.configurable.sectionIconNoAccess')</span> 427: #end 428: </a> 429: </li> 430: #end 431: {{/html}} 432: 433: ## Finally we display an error message if there are any applications which we were unable to view. 434: #if($appsUserCannotView.size() > 0) 435: 436: {{error}}$msg.get('xe.admin.configurable.noViewAccessSomeApplications', [$appsUserCannotView]){{/error}} 437: 438: #end 439: #end## If we should be looking at the main administration page. 440: ## 441: ##------------------------------------------------------------------------------------------------------------ 442: ## The Macros, nothing below this point is run directly. 443: ##------------------------------------------------------------------------------------------------------------ 444: ## 445: #* 446: * 447: * Any documents which are on the provided list ($documentNames) which are locked by the current user will be unlocked. 448: * If this macro has programming rights, then they are unlocked programmatically, otherwise a javascript tag is 449: * generated with ajax calls to cancel for all of the documents. If there are documents on this list which are not 450: * locked by the current user, then they are ignored. 451: * 452: * @param $documentNames - List<String> - fullNames of documents which should be unlocked if they are locked by the 453: * current user. 454: *### 455: #macro(unlockDocuments $documentNames) 456: #if($documentNames.size() > 0) 457: #set($sql = "doc.fullName=") 458: #foreach($documentName in $documentNames) 459: #set($sql = "${sql}'$documentName' or doc.fullName=") 460: #end 461: ## Trim the dangling ' or doc.fullName=?' 462: #set($sql = $sql.substring(0, $sql.lastIndexOf(' or doc.fullName='))) 463: #set($sql = ", XWikiLock lock where lock.docId=doc.id and lock.userName='$xcontext.getUser()' and (${sql})") 464: #set($namesOfdocumentsToUnlock = $xwiki.searchDocuments($sql)) 465: ## Use ajax and hope the user runs javascript. 466: {{html clean=false wiki=false}} 467: <script type="text/javascript"> 468: document.observe("dom:loaded", function() { 469: #foreach($nameOflockedDocument in $namesOfdocumentsToUnlock) 470: new Ajax.Request("$xwiki.getURL($nameOflockedDocument, 'cancel', 'ajax=1')"); 471: #end 472: }); 473: </script> 474: {{/html}}## 475: #end## If output list size > 0 476: #end## Macro 477: ## 478: #* 479: * Find names of documents which contain objects of the class 'XWiki.ConfigurableClass' 480: * 481: * @param $section - String - Look for apps which specify that they should be configured in this section, 482: * if null or "" then returns them for all sections. 483: * 484: * @param $globaladmin - boolean - If true then we will look for applications which should be configured globally. 485: * 486: * @param $space - String - If not looking for apps which are configured globally, then this is the space where we 487: * will look for apps in. If null or "" or if $globaladmin is true, then all spaces will be 488: * searched. 489: * 490: * @param $outputList - List - The returns from this macro will be put in this list, passing the list as a parameter 491: * a safety measure because macros can't return values. 492: *### 493: #macro(findNamesOfAppsToConfigure, $section, $globaladmin, $space, $outputList) 494: ## Use a parameterized sql query to prevent injection. 495: #set($params = []) 496: #if($section && $section != '') 497: #set($discard = $params.add("$section")) 498: #set($sqlA = ' StringProperty as section,') 499: #set($sqlB = " and section.id=obj.id and section.name='displayInSection' and section.value=?") 500: #else 501: ## Make sure they are "" in case they were set prior to calling the macro. 502: #set($sqlA = '') 503: #set($sqlB = '') 504: #end 505: ## Set up query based on value of $globaladmin 506: #if($globaladmin == true) 507: #set($sqlC = '1') 508: #else 509: #if($space && $space != '') 510: #set($sqlC = '0 and doc.space = ?') 511: #set($discard = $params.add($space)) 512: #else 513: #set($sqlC = '0') 514: #end 515: #end 516: #set($sql = ", BaseObject as obj,$sqlA IntegerProperty as global where " 517: + "doc.fullName=obj.name and obj.className='" + $nameOfThisDocument + "'$sqlB " 518: + "and global.id=obj.id and global.name='configureGlobally' and global.value=$sqlC " 519: + "order by doc.creationDate") 520: ## 521: ## Run the search 522: #set($outputList = $xwiki.searchDocuments($sql, 0, 0, $params)) 523: ## 524: #end 525: ## 526: #* 527: * If this document is saved with programming access or is includeForm'd into a document with programming, we have to 528: * drop programming rights in order for it to run safely because it evaluates potentially untrustworthy code. 529: *### 530: #macro(sandboxDocument) 531: #if($xcontext.hasProgrammingRights()) 532: $xcontext.getContext().getDoc().setContentAuthor('XWiki.XWikiGuest')## 533: #end 534: #end 535: ## 536: #* 537: * Try to determine whether a document was edited by a user who has edit right on this page. This is trickey because 538: * documents are imported with the name XWiki.XWikiGuest who has no access to anything after import. 539: * 540: * @param theDoc - Document who's editor should be checked for edit access on this document. 541: *### 542: #macro(checkDocumentSavedByAuthorizedUser, $docToCheck, $currentDoc, $hasAccess) 543: ## The system is started and the only user is XWikiGuest who has admin right but gives it up when he imports the default 544: ## documents, we are checking to see if this looks like the guest imported the document with the first import. 545: #if($docToCheck.getWiki() == $xcontext.getMainWikiName() 546: && $docToCheck.getVersion() == '1.1' 547: && $docToCheck.getCreator() != $docToCheck.getContentAuthor() 548: && $docToCheck.getContentAuthor() == 'XWiki.XWikiGuest') 549: ## 550: #set($userToCheck = $docToCheck.getCreator()) 551: #else 552: #set($userToCheck = $docToCheck.getAuthor()) 553: #end 554: #set($hasAccess = $xwiki.hasAccessLevel("edit", $userToCheck, $currentDoc)) 555: #end 556: ## 557: #* 558: * Show the heading for configuration for a given application. 559: * 560: * $appName (String) Name of the application to show configuration heading for. 561: * 562: * $headingAlreadyShowing (boolean) If true then we don't make another heading. Otherwise it is set to true. 563: *### 564: #macro(showHeading, $appName, $headingAlreadyShowing) 565: #if(!$headingAlreadyShowing) 566: #set($headingAlreadyShowing = true) 567: 568: = $msg.get("admin.customize") __[[$appName>>$appName]]__: = 569: #end 570: #end 571: {{/velocity}}