Changes for page User Directory
Last modified by Ludovic Dubost on 2019/11/21 10:10
To version 5.1
edited by Ludovic Dubost
on 2015/09/01 11:47
on 2015/09/01 11:47
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-user-directory-ui-7.1]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (0 modified, 1 added, 1 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,188 +1,6 @@ 1 +{{include reference='XWiki.UserDirectoryMacros'/}} 2 + 1 1 {{velocity}} 2 -#set ($xwikiUsersClassReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'XWikiUsers')) 3 -#set ($xwikiUsersClassName = $services.model.serialize($xwikiUsersClassReference)) 4 -#set ($xwikiUsersClass = $xwiki.getClass($xwikiUsersClassName)) 5 -#set ($directoryPreferencesClassReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryPreferencesClass')) 6 -#set ($directoryPreferencesClassName = $services.model.serialize($directoryPreferencesClassReference)) 7 -## 8 -## Fake user used in some cases to properly display class properties 9 -#set ($fakeUser = false) 10 -## 11 -## Set the fixed columns that we want the user directory to always show. 12 -#set ($columns = ['_avatar', 'doc.fullName']) 13 -## 14 -## The columns that the user directory will default to when no user preferences exist or when the user resets to default. 15 -#set ($defaultColumns = ['first_name', 'last_name']) 16 -#set ($defaultColumnsString = $stringtool.join($defaultColumns, ' ')) 17 -#set ($isCustomized = false) 18 -## 19 -## Guests and superadmin don't have an user profile and, therefore, no preferences. Offer default. 20 -#if ($isGuest || $isSuperAdmin) 21 - #if ($isGuest) 22 - {{info}}$services.localization.render('xe.userdirectory.canCustomizeInfoGuest', ["path:$doc.getURL('login')"]){{/info}} 23 - #end 24 - ## Use the default columns for guests or superadmin. 25 - #set ($discard = $columns.addAll($defaultColumns)) 26 - ## 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. 27 - #set ($userPreferences = $doc) 28 - #set ($fakeUser = $doc.newObject($xwikiUsersClassName)) 29 -#else 30 - ## User is logged in. 31 - #set ($userPreferences = $xwiki.getDocument($xcontext.userReference)) 32 - #set ($userPreference = $userPreferences.getObject($directoryPreferencesClassName)) 33 - #if (!$userPreference) 34 - ## Fake a user directory preference (in-memory) object just to be able to display the default values nicely. 35 - #set ($userPreference = $userPreferences.newObject($directoryPreferencesClassName)) 36 - #set ($discard = $userPreference.set('columns', $defaultColumnsString)) 37 - #end 38 - ## 39 - ## Read the user's preferences and build the list of columns to display. 40 - #set ($userColumnsString = $!{userPreference.getProperty('columns').value.trim()}) 41 - #foreach ($column in $userColumnsString.split('\s+')) 42 - ## Skip invalid or duplicate columns. Duplicate columns break the livetable filtering query. 43 - #if ($column.trim() != '' && $xwikiUsersClass.get($column) && !$columns.contains($column)) 44 - #set ($discard = $columns.add($column)) 45 - #end 46 - #end 47 - ## 48 - ## Check if they are the default preferences. 49 - #if ($userColumnsString != $defaultColumnsString) 50 - ## Mark it as a customized user directory. 51 - #set ($isCustomized = true) 52 - #end 53 - ## 54 - #set ($xredirect = $doc.getURL($xcontext.action, ${request.queryString})) 55 - ## 56 - ## Ability to customize the view. 57 - ## 58 - #if ($request.customize == 'true') 59 - #if ("$!request.action" != '') 60 - #if ($request.action == 'add') 61 - #set ($columnToAdd = $request.value.trim()) 62 - #if (!$columns.contains($columnToAdd)) 63 - #set ($userColumnsString = "$!userColumnsString $columnToAdd") 64 - #set ($userColumnsString = $userColumnsString.trim()) 65 - #set ($discard = $userPreference.set('columns', $userColumnsString)) 66 - #set ($discard = $userPreferences.save('Updated user directory preferences.')) 67 - #end 68 - #elseif ($request.action == 'reset') 69 - #set ($discard = $userPreferences.removeObject($userPreference)) 70 - #set ($discard = $userPreferences.save('Reset user directory preferences.')) 71 - #elseif ($request.action == 'save') 72 - #set ($discard = $userPreferences.updateObjectFromRequest($directoryPreferencesClassName)) 73 - #set ($discard = $userPreferences.save('Updated user directory preferences.')) 74 - #end 75 - ## Redirect using xredirect so that the page can be safely refreshed after an action. 76 - $response.sendRedirect($request.xredirect) 77 - #stop() 78 - #end 79 - ## 80 - ## Customize form. Note: Using 2 forms to be able to do everything without JavaScript. 81 - ## 82 - == {{translation key="xe.userdirectory.customizeColumnsTitle"/}} == 83 - {{html clean='false' wiki='true'}} 84 - <form class='xform half' action="$doc.getURL($xcontext.action, $request.queryString)" method='post'> 85 - <dl> 86 - <dt class='label'> 87 - <label>{{translation key="xe.userdirectory.customizeAvailableColumnsLabel"/}}</label> 88 - <span class='xHint'>{{translation key="xe.userdirectory.customizeAvailableColumnsHint"/}}</span> 89 - </dt> 90 - <dd> 91 - <select name='value'> 92 - #foreach ($property in $xwikiUsersClass.properties) 93 - ## Display translated class property pretty names. 94 - <option value="$property.name">$userPreferences.displayPrettyName($property.name)</option> 95 - #end 96 - </select> 97 - </dd> 98 - <dt> 99 - <input type='hidden' name='xredirect' value="$xredirect" /> 100 - <input type='hidden' name='action' value='add' /> 101 - <span class='buttonwrapper'> 102 - <input type="submit" class="button" name="submit" value="$services.localization.render('xe.userdirectory.customizeAddColumnButtonLabel')" /> 103 - </span> 104 - </dt> 105 - </dl> 106 - </form> 107 - <form class='xform half' action="$doc.getURL($xcontext.action, $request.queryString)" method='post'> 108 - <dl> 109 - <dt> 110 - <label>{{translation key="xe.userdirectory.customizeSelectedColumnsLabel"/}}</label> 111 - <span class='xHint'>{{translation key="xe.userdirectory.customizeSelectedColumnsHint"/}}</span> 112 - </dt> 113 - <dd>$userPreferences.display('columns', 'edit', $userPreference)</dd> 114 - <dt> 115 - <input type='hidden' name='xredirect' value="$xredirect" /> 116 - <input type='hidden' name='action' value='save' /> 117 - <span class='buttonwrapper'> 118 - <input class='button' type='submit' name='submit' value="$services.localization.render('xe.userdirectory.customizeSaveButtonLabel')"/> 119 - </span> 120 - <span class="buttonwrapper"> 121 - <a href="$doc.getURL($xcontext.action, "$request.queryString&action=reset&xredirect=$escapetool.url($xredirect)")" class='button secondary'>{{translation key="xe.userdirectory.customizeResetButtonLabel"/}}</a> 122 - </span> 123 - </dt> 124 - </dl> 125 - </form> 126 - ## 127 - == {{translation key="xe.userdirectory.customizePreviewTitle"/}} == 128 - {{/html}} 129 - #elseif ($isCustomized) 130 - {{warning}}$services.localization.render('xe.userdirectory.isCustomizedWarning', ["$doc.fullName", "customize=true&action=reset&xredirect=$escapetool.url($xredirect)", "$doc.fullName", 'customize=true']){{/warning}} 131 - #else 132 - {{info}}$services.localization.render('xe.userdirectory.canCustomizeInfo', ["$doc.fullName", 'customize=true']){{/info}} 133 - #end 134 -#end 135 -## 136 -## Build and display the resulting livetable. 137 -## 138 -#set($columnsProperties = {}) 139 -## 140 -#foreach ($column in $columns) 141 - #set ($filterable = true) 142 - #set ($sortable = true) 143 - #set ($type = 'text') 144 - #set ($link = '') 145 - #set ($html = false) 146 - #set ($displayName = $userPreferences.displayPrettyName($column)) 147 - #set ($classPropertyType = $xwikiUsersClass.get($column).type) 148 - #if ($column == '_avatar') 149 - #set ($type = 'none') 150 - #set ($html = true) 151 - #set ($sortable = false) 152 - #set ($link = 'view') 153 - #elseif ($column == 'doc.fullName') 154 - #set ($link = 'view') 155 - #elseif ($classPropertyType.endsWith('ListClass')) 156 - #set($type = 'list') 157 - #elseif ($classPropertyType.endsWith('NumberClass')) 158 - #set($type = 'number') 159 - #elseif ($classPropertyType.endsWith('PasswordClass')) 160 - #set($sortable = false) 161 - #end 162 - #set ($columnValue = { 'type' : $type, 'link' : $link, 'html' : $html, 'sortable' : $sortable, 'displayName' : $displayName }) 163 - #set ($discard = $columnsProperties.put($column, $columnValue)) 164 -#end 165 -## 166 -## Allow other applications to provide a different data source for the user directory livetable. For example, some application might define a different membership relation. 167 -#set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResultsOverride')) 168 -#if (!$xwiki.exists($userDirectoryLivetableResultsReference)) 169 - ## If no override is present, use the default data source. 170 - #set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResults')) 171 -#end 172 -## Note that we specify the class name even though we use a custom results page (which hard-codes it) because the class 173 -## name is needed by the live table filters, to have a proper drop down list for Static List fields for instance 174 -## (see XWIKI-9660). 175 -#set ($options = { 176 - 'className': $services.model.serialize($xwikiUsersClassReference, 'local'), 177 - 'resultPage' : "$services.model.serialize($userDirectoryLivetableResultsReference)", 178 - 'translationPrefix' : 'xe.userdirectory.', 179 - 'tagCloud' : true, 180 - 'rowCount': 10 181 -}) 182 -#livetable('userdirectory' $columns $columnsProperties $options) 183 -## 184 -## Clean up any existing fake user from the current in-memory document to avoid side-effects 185 -#if ($fakeUser) 186 - #set ($discard = $doc.removeObject($fakeUser)) 187 -#end 4 +#displayUserDirectory(true) 5 +#set($docextras=[]) 188 188 {{/velocity}}
- XWiki.UIExtensionClass[0]
-
- Extension Point ID
-
... ... @@ -1,1 +1,0 @@ 1 -org.xwiki.platform.panels.Applications - Extension ID
-
... ... @@ -1,1 +1,0 @@ 1 -platform.panels.userDirectoryApplication - Extension Parameters
-
... ... @@ -1,3 +1,0 @@ 1 -label=$services.localization.render('xe.panels.quicklinks.userdirectory') 2 -target=Main.UserDirectory 3 -icon=icon:group - Extension Scope
-
... ... @@ -1,1 +1,0 @@ 1 -wiki
- XWiki.JavaScriptExtension[0]
-
- Caching policy
-
... ... @@ -1,0 +1,1 @@ 1 +long - Code
-
... ... @@ -1,0 +1,41 @@ 1 +(function(){ 2 + 3 + /** 4 + * Init 5 + */ 6 + function init() { 7 + var userScope = $('userScopeFilter'); 8 + if (userScope === null) { 9 + // Nothing to do 10 + return; 11 + } 12 + userScope.observe('change', onUserScopeChange); 13 + } 14 + 15 + function onUserScopeChange(event) { 16 + var value = $('userScopeFilter').value; 17 + var livetable = window["livetable_userdirectory"]; 18 + var url = livetable.getUrl; 19 + if (url.search("userScope=") >= 0) { 20 + // Replace the old value 21 + if (value == 'local') { 22 + url = url.replace("userScope=global", "userScope=local"); 23 + } else { 24 + url = url.replace("userScope=local", "userScope=global"); 25 + } 26 + } else { 27 + url = url + "&userScope=" + value; 28 + } 29 + livetable.getUrl = url; 30 + // Reload the livetable 31 + livetable.clearCache(); 32 + livetable.showRows(1, livetable.limit); 33 + } 34 + 35 + /** 36 + * Call Init 37 + */ 38 + (XWiki && XWiki.domIsLoaded && init()) || document.observe("xwiki:dom:loaded", init); 39 + 40 +})(); 41 + - Name
-
... ... @@ -1,0 +1,1 @@ 1 +Dynamic filter for user scope - Parse content
-
... ... @@ -1,0 +1,1 @@ 1 +No - Use this extension
-
... ... @@ -1,0 +1,1 @@ 1 +onDemand