General Actions:
Log-in
Wiki:
CreativeIT
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
UserMap
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
UserMap
Wiki source code of
UserMap
Last modified by
Hal Eden
on 2010/07/15 08:22
Content
·
Comments
(0)
·
Attachments
(7)
·
History
·
Information
Show line numbers
#includeMacros("XWiki.GraphMacro") $xwiki.jsx.use("XWiki.UserMap") #graphgearmap("groupmap.xml" "CreativeIT") <% import java.io.StringReader import java.util.HashMap import com.xpn.xwiki.doc.XWikiAttachment import groovy.xml.MarkupBuilder if (xwiki.hasAdminRights()) { println "[Update the Group Map>" + doc.fullName + "?updategm=1]" if (request.get("updategm") != null) { print "Start mindmap generation... " def sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'" def writer = new StringWriter() def xmlBuilder = new MarkupBuilder(writer) def nodes = [] xmlBuilder.graph (title: "User Map", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725") { xmlBuilder.node (id: "root", text:"Groups", color:"ffffff") for (item in xwiki.searchDocuments(sql)) { def groupdoc = xwiki.getDocument(item) xmlBuilder.node(id: groupdoc.getName(), text:groupdoc.getName(), color:"cccccc") xmlBuilder.edge(sourceNode: "root", targetNode: groupdoc.getName(), label:"") def users = groupdoc.getObjects("XWiki.XWikiGroups") for (user in users) { def hgapcount = 0 def totalCount = users.size() def userName = xwiki.getUserName(user.getProperty("member").value) userName = user.getProperty("member").value def userdoc = xwiki.getDocument(userName) if (userdoc != null) { def attachCount = userdoc.attachmentList.size() def attachIndex = attachCount - 1 def nodeURL = userdoc.getURL() def nodeHtml = xwiki.getUserName(userName, false) def userN = nodeHtml def obj = userdoc.getObject("XWiki.XWikiUsers") def attachURL = "" if (obj != null) { def lastname = obj.get("last_name") def firstname = obj.get('first_name') nodeHtml = firstname + ' ' + lastname } if (attachCount >0){ def attach = userdoc.attachmentList.get(0) attachURL = userdoc.getAttachmentURL(attach.filename,"download") + "?width=90" } if (! nodes.contains(userName)) { nodes.add(userName) xmlBuilder.node(id: userN, text: nodeHtml, color:"aaaaaa", image: attachURL, link: nodeURL) } xmlBuilder.edge(sourceNode: groupdoc.getName(), targetNode: userN, label:"") } } } } def attachmentName = "groupmap.xml" def attachment = doc.getDocument().getAttachment(attachmentName) if (!attachment){ attachment = new XWikiAttachment(doc.getDocument(), attachmentName) doc.getDocument().getAttachmentList().add(attachment) } attachment.setContent(writer.toString().getBytes()) doc.getDocument().saveAttachmentContent(attachment, context.getContext()) doc.save() println "done" response.sendRedirect(xwiki.getURL(doc.getName(),"view")) } } %>
Quick Links
Home
Index
What's New
Blog
Calendar
Photo Albums
Sandbox
Tags
Bulletin Board
My Recent Modifications
PamelaJennings
|
rwakkary
|
HaledenSands
|
ByronLahey