Toggle navigation
Go
Log-in
Home
Go to Wiki
platform.wiki.menu.wikiindex
Document Index
User Index
Main
Go to Space
Document Index
UserDirectory
Main.WebHome
User Directory
Wiki source code of
User Directory
More actions
Content
Comments
Attachments
History
Information
Show line numbers
{{velocity}} #set ($xwikiUsersClassReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'XWikiUsers')) #set ($xwikiUsersClassName = $services.model.serialize($xwikiUsersClassReference)) #set ($xwikiUsersClass = $xwiki.getClass($xwikiUsersClassName)) #set ($directoryPreferencesClassReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryPreferencesClass')) #set ($directoryPreferencesClassName = $services.model.serialize($directoryPreferencesClassReference)) ## ## Fake user used in some cases to properly display class properties #set ($fakeUser = false) ## ## Set the fixed columns that we want the user directory to always show. #set ($columns = ['_avatar', 'doc.name']) ## ## The columns that the user directory will default to when no user preferences exist or when the user resets to default. #set ($defaultColumns = ['first_name', 'last_name']) #set ($defaultColumnsString = $stringtool.join($defaultColumns, ' ')) #set ($isCustomized = false) ## ## Guests and superadmin don't have an user profile and, therefore, no preferences. Offer default. #if ($isGuest || $isSuperAdmin) #if ($isGuest) {{info}}$services.localization.render('xe.userdirectory.canCustomizeInfoGuest', ["path:$doc.getURL('login')"]){{/info}} #end ## Use the default columns for guests or superadmin. #set ($discard = $columns.addAll($defaultColumns)) ## Fake a user (in-memory) object inside a fake user profile page in order to be able to nicely display translated property pretty names of the XWikiUsers class. #set ($userPreferences = $doc) #set ($fakeUser = $doc.newObject($xwikiUsersClassName)) #else ## User is logged in. #set ($userPreferences = $xwiki.getDocument($xcontext.userReference)) #set ($userPreference = $userPreferences.getObject($directoryPreferencesClassName)) #if (!$userPreference) ## Fake a user directory preference (in-memory) object just to be able to display the default values nicely. #set ($userPreference = $userPreferences.newObject($directoryPreferencesClassName)) #set ($discard = $userPreference.set('columns', $defaultColumnsString)) #end ## ## Read the user's preferences and build the list of columns to display. #set ($userColumnsString = $!{userPreference.getProperty('columns').value.trim()}) #foreach ($column in $userColumnsString.split('\s+')) ## Skip invalid or duplicate columns. Duplicate columns break the livetable filtering query. #if ($column.trim() != '' && $xwikiUsersClass.get($column) && !$columns.contains($column)) #set ($discard = $columns.add($column)) #end #end ## ## Check if they are the default preferences. #if ($userColumnsString != $defaultColumnsString) ## Mark it as a customized user directory. #set ($isCustomized = true) #end ## #set ($xredirect = $doc.getURL($xcontext.action, ${request.queryString})) ## ## Ability to customize the view. ## #if ($request.customize == 'true') #if ("$!request.action" != '') #if ($request.action == 'add') #set ($columnToAdd = $request.value.trim()) #if (!$columns.contains($columnToAdd)) #set ($userColumnsString = "$!userColumnsString $columnToAdd") #set ($userColumnsString = $userColumnsString.trim()) #set ($discard = $userPreference.set('columns', $userColumnsString)) #set ($discard = $userPreferences.save('Updated user directory preferences.')) #end #elseif ($request.action == 'reset') #set ($discard = $userPreferences.removeObject($userPreference)) #set ($discard = $userPreferences.save('Reset user directory preferences.')) #elseif ($request.action == 'save') #set ($discard = $userPreferences.updateObjectFromRequest($directoryPreferencesClassName)) #set ($discard = $userPreferences.save('Updated user directory preferences.')) #end ## Redirect using xredirect so that the page can be safely refreshed after an action. $response.sendRedirect($request.xredirect) #stop() #end ## ## Customize form. Note: Using 2 forms to be able to do everything without JavaScript. ## == {{translation key="xe.userdirectory.customizeColumnsTitle"/}} == {{html clean='false' wiki='true'}} <form class='xform half' action="$doc.getURL($xcontext.action, $request.queryString)" method='post'> <dl> <dt> <label>{{translation key="xe.userdirectory.customizeAvailableColumnsLabel"/}}</label> <span class='xHint'>{{translation key="xe.userdirectory.customizeAvailableColumnsHint"/}}</span> </dt> <dd> <select name='value'> #foreach ($property in $xwikiUsersClass.properties) ## Display translated class property pretty names. <option value="$property.name">$userPreferences.displayPrettyName($property.name)</option> #end </select> </dd> <dt> <input type='hidden' name='xredirect' value="$xredirect" /> <input type='hidden' name='action' value='add' /> <span class='buttonwrapper'> <input type="submit" class="button" name="submit" value="$services.localization.render('xe.userdirectory.customizeAddColumnButtonLabel')" /> </span> </dt> </dl> </form> <form class='xform half' action="$doc.getURL($xcontext.action, $request.queryString)" method='post'> <dl> <dt> <label>{{translation key="xe.userdirectory.customizeSelectedColumnsLabel"/}}</label> <span class='xHint'>{{translation key="xe.userdirectory.customizeSelectedColumnsHint"/}}</span> </dt> <dd>$userPreferences.display('columns', 'edit', $userPreference)</dd> <dt> <input type='hidden' name='xredirect' value="$xredirect" /> <input type='hidden' name='action' value='save' /> <span class='buttonwrapper'> <input class='button' type='submit' name='submit' value="$services.localization.render('xe.userdirectory.customizeSaveButtonLabel')"/> </span> <span class="buttonwrapper"> <a href="$doc.getURL($xcontext.action, "$request.queryString&action=reset&xredirect=$escapetool.url($xredirect)")" class='button secondary'>{{translation key="xe.userdirectory.customizeResetButtonLabel"/}}</a> </span> </dt> </dl> </form> ## == {{translation key="xe.userdirectory.customizePreviewTitle"/}} == {{/html}} #elseif ($isCustomized) {{warning}}$services.localization.render('xe.userdirectory.isCustomizedWarning', ["$doc.fullName", "customize=true&action=reset&xredirect=$escapetool.url($xredirect)", "$doc.fullName", 'customize=true']){{/warning}} #else {{info}}$services.localization.render('xe.userdirectory.canCustomizeInfo', ["$doc.fullName", 'customize=true']){{/info}} #end #end ## ## Build and display the resulting livetable. ## #set($columnsProperties = {}) ## #foreach ($column in $columns) #set ($filterable = true) #set ($sortable = true) #set ($type = 'text') #set ($link = '') #set ($html = false) #set ($displayName = $userPreferences.displayPrettyName($column)) #set ($classPropertyType = $xwikiUsersClass.get($column).type) #if ($column == '_avatar') #set ($type = 'none') #set ($html = true) #set ($sortable = false) #set ($link = 'view') #elseif ($column == 'doc.name') #set ($link = 'view') #elseif ($classPropertyType.endsWith('ListClass')) #set($type = 'list') #elseif ($classPropertyType.endsWith('NumberClass')) #set($type = 'number') #elseif ($classPropertyType.endsWith('PasswordClass')) #set($sortable = false) #elseif ($classPropertyType.endsWith('TextAreaClass') || $classPropertyType.endsWith('EmailClass')) #set($html = true) #end #set ($columnValue = { 'type' : $type, 'link' : $link, 'html' : $html, 'sortable' : $sortable, 'displayName' : $displayName }) #set ($discard = $columnsProperties.put($column, $columnValue)) #end ## ## Allow other applications to provide a different data source for the user directory livetable. For example, some application might define a different membership relation. #set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResultsOverride')) #if (!$xwiki.exists($userDirectoryLivetableResultsReference)) ## If no override is present, use the default data source. #set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResults')) #end ## Note that we specify the class name even though we use a custom results page (which hard-codes it) because the class ## name is needed by the live table filters, to have a proper drop down list for Static List fields for instance ## (see XWIKI-9660). #set ($options = { 'className': $services.model.serialize($xwikiUsersClassReference, 'local'), 'resultPage' : "$services.model.serialize($userDirectoryLivetableResultsReference)", 'translationPrefix' : 'xe.userdirectory.', 'tagCloud' : true, 'rowCount': 10 }) ## Add a filter for subwikis #if ($xcontext.database != $xcontext.mainWikiName && "$!services.wiki" != '' && "$!services.wiki.user" != '') #set($userScope = $services.wiki.user.getUserScope($services.wiki.currentWikiId)) #if ($userScope == 'GLOBAL_ONLY') #set($discard = $options.put('extraParams', 'userScope=global')) #else #set($discard = $options.put('extraParams', 'userScope=local')) #end #if ($userScope == 'LOCAL_AND_GLOBAL') #set($discard = $xwiki.jsx.use('Main.UserDirectory')) {{html}} <form class="xform third" action=""> <dl> <dt> <label for="userScopeFilter">$services.localization.render('userdirectory.userScopeFilter')</label> <span class="xHint">$services.localization.render('userdirectory.userScopeFilter.hint')</span> </dt> <dd> <select name="userScope" id="userScopeFilter"> <option value="local">$services.localization.render('userdirectory.userScopeFilter.local')</option> <option value="global">$services.localization.render('userdirectory.userScopeFilter.global')</option> </select> </dd> </dl> </form> {{/html}} #end #end #livetable('userdirectory' $columns $columnsProperties $options) ## ## Clean up any existing fake user from the current in-memory document to avoid side-effects #if ($fakeUser) #set ($discard = $doc.removeObject($fakeUser)) #end {{/velocity}}
Applications
Dashboard
User Index
Quick Links
Sandbox
My Recent Modifications
Teleconnections (Interactions and teleconnections between midlatitudes and tropics)
S2S Phase-II Ensembles Sub-project
Monsoon Sub-Project
S2S sub-project on verification and products