Changes for page User Directory

Last modified by Thomas Mortagne on 2019/11/04 10:44

From version 3.1
edited by Thomas Mortagne
on 2013/11/06 09:15
Change comment: Import
To version 4.1
edited by Thomas Mortagne
on 2014/04/24 08:43
Change comment: Install extensoin [org.xwiki.platform:xwiki-platform-user-directory-ui-5.4.4]

Summary

Details

Page properties
Content
... ... @@ -169,12 +169,46 @@
169 169   ## If no override is present, use the default data source.
170 170   #set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResults'))
171 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).
172 172  #set ($options = {
176 + 'className': $services.model.serialize($xwikiUsersClassReference, 'local'),
173 173   'resultPage' : "$services.model.serialize($userDirectoryLivetableResultsReference)",
174 174   'translationPrefix' : 'xe.userdirectory.',
175 175   'tagCloud' : true,
176 176   'rowCount': 10
177 177  })
182 +## Add a filter for subwikis
183 +#if ($xcontext.database != $xcontext.mainWikiName && "$!services.wiki" != '' && "$!services.wiki.user" != '')
184 + #set($userScope = $services.wiki.user.getUserScope($services.wiki.currentWikiId))
185 + #if ($userScope == 'GLOBAL_ONLY')
186 + #set($discard = $options.put('extraParams', 'userScope=global'))
187 + #else
188 + #set($discard = $options.put('extraParams', 'userScope=local'))
189 + #end
190 + #if ($userScope == 'LOCAL_AND_GLOBAL')
191 + #set($discard = $xwiki.jsx.use('Main.UserDirectory'))
192 +
193 + {{html}}
194 + <form class="xform third" action="">
195 + <dl>
196 + <dt>
197 + <label for="userScopeFilter">$services.localization.render('userdirectory.userScopeFilter')</label>
198 + <span class="xHint">$services.localization.render('userdirectory.userScopeFilter.hint')</span>
199 + </dt>
200 + <dd>
201 + <select name="userScope" id="userScopeFilter">
202 + <option value="local">$services.localization.render('userdirectory.userScopeFilter.local')</option>
203 + <option value="global">$services.localization.render('userdirectory.userScopeFilter.global')</option>
204 + </select>
205 + </dd>
206 + </dl>
207 + </form>
208 + {{/html}}
209 +
210 + #end
211 +#end
178 178  #livetable('userdirectory' $columns $columnsProperties $options)
179 179  ##
180 180  ## Clean up any existing fake user from the current in-memory document to avoid side-effects
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