Cambios para el documento Directorio de Usuarios
Última modificación por Administrator el 2024/06/06 11:36
Desde la versión 3.1
editado por Administrator
el 2024/06/06 11:36
el 2024/06/06 11:36
Cambiar el comentario:
Install extension [org.xwiki.platform:xwiki-platform-user-directory-ui/15.10.10]
Hasta la versión 2.1
editado por Administrator
el 2024/06/05 19:09
el 2024/06/05 19:09
Cambiar el comentario:
Migrated property [async_enabled] from class [XWiki.UIExtensionClass]
Resumen
-
Propiedades de página (1 modificado, 0 añadido, 0 eliminado)
-
Objetos (0 modificado, 2 añadido, 0 eliminado)
Detalles
- Propiedades de página
-
- Contenido
-
... ... @@ -1,7 +3,220 @@ 1 -{{include reference='XWiki.UserDirectoryMacros'/}} 2 - 3 3 {{velocity}} 4 -#set ($customize = $request.customize == 'true') 5 -#displayUserDirectory($customize) 6 -#set ($docextras = []) 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.name']) 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> 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.name') 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 + #elseif ($classPropertyType.endsWith('TextAreaClass') || $classPropertyType.endsWith('EmailClass')) 162 + #set($html = true) 163 + #end 164 + #set ($columnValue = { 'type' : $type, 'link' : $link, 'html' : $html, 'sortable' : $sortable, 'displayName' : $displayName }) 165 + #set ($discard = $columnsProperties.put($column, $columnValue)) 166 +#end 167 +## 168 +## Allow other applications to provide a different data source for the user directory livetable. For example, some application might define a different membership relation. 169 +#set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResultsOverride')) 170 +#if (!$xwiki.exists($userDirectoryLivetableResultsReference)) 171 + ## If no override is present, use the default data source. 172 + #set ($userDirectoryLivetableResultsReference = $services.model.createDocumentReference($xcontext.database, 'XWiki', 'UserDirectoryLivetableResults')) 173 +#end 174 +## Note that we specify the class name even though we use a custom results page (which hard-codes it) because the class 175 +## name is needed by the live table filters, to have a proper drop down list for Static List fields for instance 176 +## (see XWIKI-9660). 177 +#set ($options = { 178 + 'className': $services.model.serialize($xwikiUsersClassReference, 'local'), 179 + 'resultPage' : "$services.model.serialize($userDirectoryLivetableResultsReference)", 180 + 'translationPrefix' : 'xe.userdirectory.', 181 + 'tagCloud' : true, 182 + 'rowCount': 10 183 +}) 184 +## Add a filter for subwikis 185 +#if ($xcontext.database != $xcontext.mainWikiName && "$!services.wiki" != '' && "$!services.wiki.user" != '') 186 + #set($userScope = $services.wiki.user.getUserScope($services.wiki.currentWikiId)) 187 + #if ($userScope == 'GLOBAL_ONLY') 188 + #set($discard = $options.put('extraParams', 'userScope=global')) 189 + #else 190 + #set($discard = $options.put('extraParams', 'userScope=local')) 191 + #end 192 + #if ($userScope == 'LOCAL_AND_GLOBAL') 193 + #set($discard = $xwiki.jsx.use('Main.UserDirectory')) 194 + 195 + {{html}} 196 + <form class="xform third" action=""> 197 + <dl> 198 + <dt> 199 + <label for="userScopeFilter">$services.localization.render('userdirectory.userScopeFilter')</label> 200 + <span class="xHint">$services.localization.render('userdirectory.userScopeFilter.hint')</span> 201 + </dt> 202 + <dd> 203 + <select name="userScope" id="userScopeFilter"> 204 + <option value="local">$services.localization.render('userdirectory.userScopeFilter.local')</option> 205 + <option value="global">$services.localization.render('userdirectory.userScopeFilter.global')</option> 206 + </select> 207 + </dd> 208 + </dl> 209 + </form> 210 + {{/html}} 211 + 212 + #end 213 +#end 214 +#livetable('userdirectory' $columns $columnsProperties $options) 215 +## 216 +## Clean up any existing fake user from the current in-memory document to avoid side-effects 217 +#if ($fakeUser) 218 + #set ($discard = $doc.removeObject($fakeUser)) 219 +#end 7 7 {{/velocity}}
- XWiki.JavaScriptExtension[0]
-
- Política de cacheado
-
... ... @@ -1,0 +1,1 @@ 1 +long - Código
-
... ... @@ -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 + - Nombre
-
... ... @@ -1,0 +1,1 @@ 1 +Dynamic filter for user scope - Parsear contenido
-
... ... @@ -1,0 +1,1 @@ 1 +No - Utilizar esta extensión
-
... ... @@ -1,0 +1,1 @@ 1 +onDemand
- XWiki.UIExtensionClass[0]
-
- Extension Point ID
-
... ... @@ -1,0 +1,1 @@ 1 +org.xwiki.platform.panels.Applications - Extension ID
-
... ... @@ -1,0 +1,1 @@ 1 +platform.panels.userDirectoryApplication - Extension Parameters
-
... ... @@ -1,0 +1,3 @@ 1 +label=$services.localization.render('xe.panels.quicklinks.userdirectory') 2 +target=Main.UserDirectory 3 +icon=icon:group - Extension Scope
-
... ... @@ -1,0 +1,1 @@ 1 +wiki