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
Hide line numbers
1: #includeMacros("XWiki.GraphMacro") 2: $xwiki.jsx.use("XWiki.UserMap") 3: 4: #graphgearmap("groupmap.xml" "CreativeIT") 5: <% 6: import java.io.StringReader 7: import java.util.HashMap 8: import com.xpn.xwiki.doc.XWikiAttachment 9: import groovy.xml.MarkupBuilder 10: 11: if (xwiki.hasAdminRights()) 12: { 13: println "[Update the Group Map>" + doc.fullName + "?updategm=1]" 14: if (request.get("updategm") != null) 15: { 16: print "Start mindmap generation... " 17: 18: def sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'" 19: def writer = new StringWriter() 20: def xmlBuilder = new MarkupBuilder(writer) 21: def nodes = [] 22: 23: xmlBuilder.graph (title: "User Map", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725") { 24: xmlBuilder.node (id: "root", text:"Groups", color:"ffffff") 25: for (item in xwiki.searchDocuments(sql)) { 26: def groupdoc = xwiki.getDocument(item) 27: xmlBuilder.node(id: groupdoc.getName(), text:groupdoc.getName(), color:"cccccc") 28: xmlBuilder.edge(sourceNode: "root", targetNode: groupdoc.getName(), label:"") 29: def users = groupdoc.getObjects("XWiki.XWikiGroups") 30: for (user in users) { 31: def hgapcount = 0 32: def totalCount = users.size() 33: def userName = xwiki.getUserName(user.getProperty("member").value) 34: userName = user.getProperty("member").value 35: def userdoc = xwiki.getDocument(userName) 36: if (userdoc != null) { 37: def attachCount = userdoc.attachmentList.size() 38: def attachIndex = attachCount - 1 39: def nodeURL = userdoc.getURL() 40: def nodeHtml = xwiki.getUserName(userName, false) 41: def userN = nodeHtml 42: def obj = userdoc.getObject("XWiki.XWikiUsers") 43: def attachURL = "" 44: if (obj != null) { 45: def lastname = obj.get("last_name") 46: def firstname = obj.get('first_name') 47: nodeHtml = firstname + ' ' + lastname 48: } 49: 50: if (attachCount >0){ 51: def attach = userdoc.attachmentList.get(0) 52: attachURL = userdoc.getAttachmentURL(attach.filename,"download") + "?width=90" 53: } 54: if (! nodes.contains(userName)) { 55: nodes.add(userName) 56: xmlBuilder.node(id: userN, text: nodeHtml, color:"aaaaaa", image: attachURL, link: nodeURL) 57: } 58: xmlBuilder.edge(sourceNode: groupdoc.getName(), targetNode: userN, label:"") 59: } 60: } 61: } 62: } 63: def attachmentName = "groupmap.xml" 64: def attachment = doc.getDocument().getAttachment(attachmentName) 65: if (!attachment){ 66: attachment = new XWikiAttachment(doc.getDocument(), attachmentName) 67: doc.getDocument().getAttachmentList().add(attachment) 68: } 69: 70: attachment.setContent(writer.toString().getBytes()) 71: doc.getDocument().saveAttachmentContent(attachment, context.getContext()) 72: doc.save() 73: 74: println "done" 75: response.sendRedirect(xwiki.getURL(doc.getName(),"view")) 76: } 77: } 78: 79: %> 80: 81:
Quick Links
Home
Index
What's New
Blog
Calendar
Photo Albums
Sandbox
Tags
Bulletin Board
My Recent Modifications
PamelaJennings
|
rwakkary
|
HaledenSands
|
ByronLahey