From version < 9.1 >
edited by Vincent Massol
on 2012/11/28 16:02
To version < 10.1 >
edited by Thomas Mortagne
on 2016/09/08 12:36
< >
Change comment: Install extension [org.xwiki.platform:xwiki-platform-user-directory-ui-8.2.1]

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -$msg.get("xe.userdirectory.title")
1 +$services.localization.render('xe.userdirectory.title')
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.VincentMassol
1 +xwiki:XWiki.ThomasMortagne
Content
... ... @@ -1,184 +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}}$msg.get('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 - == $msg.get('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>$msg.get('xe.userdirectory.customizeAvailableColumnsLabel')</label>
88 - <span class='xHint'>$msg.get('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='$msg.get('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>$msg.get('xe.userdirectory.customizeSelectedColumnsLabel')</label>
111 - <span class='xHint'>$msg.get('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="$msg.get('xe.userdirectory.customizeSaveButtonLabel')"/>
119 - </span>
120 - <span class="buttonwrapper">
121 - <a href="$doc.getURL($xcontext.action, "$request.queryString&amp;action=reset&amp;xredirect=$escapetool.url($xredirect)")" class='button secondary'>$msg.get('xe.userdirectory.customizeResetButtonLabel')</a>
122 - </span>
123 - </dt>
124 - </dl>
125 - </form>
126 - ##
127 - <h2>$msg.get('xe.userdirectory.customizePreviewTitle')</h2>
128 - {{/html}}
129 - #elseif ($isCustomized)
130 - {{warning}}$msg.get('xe.userdirectory.isCustomizedWarning', ["$doc.fullName", "customize=true&action=reset&xredirect=$escapetool.url($xredirect)", "$doc.fullName", 'customize=true']){{/warning}}
131 - #else
132 - {{info}}$msg.get('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 -#set ($options = {
173 - 'resultPage' : "$services.model.serialize($userDirectoryLivetableResultsReference)",
174 - 'translationPrefix' : 'xe.userdirectory.',
175 - 'tagCloud' : true,
176 - 'rowCount': 10
177 -})
178 -#livetable('userdirectory' $columns $columnsProperties $options)
179 -##
180 -## Clean up any existing fake user from the current in-memory document to avoid side-effects
181 -#if ($fakeUser)
182 - #set ($discard = $doc.removeObject($fakeUser))
183 -#end
4 +#displayUserDirectory(true)
5 +#set($docextras=[])
184 184  {{/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=$msg.get('xe.panels.quicklinks.userdirectory')
2 -target=Main.UserDirectory
3 -icon=icon:group
XWiki.JavaScriptExtension[0]
Caching policy
... ... @@ -1,0 +1,1 @@
1 +long
Code
... ... @@ -1,0 +1,40 @@
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 +})();
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

The user directory can be customized to display the columns you wish to see, but you need to log in first.

You are not allowed to customize this User Directory.

Preview

per page of Page
The environment prevents the table from loading data.
 
Page
per page of Page
Picture
The environment prevents the table from loading data.
 
Page

Get Connected