Somewhat related to this question... Know space administrators
I'd like to embed this list of Space Admins on the pages that come up most commonly when people try to email a link to someone that's not permitted to view it.
From poking around, I've noticed that the templates in question are primarily these three:
confluence/notpermitted.vm <- Space permissions
confluence/pages/pagenotpermitted.vm <- Page restrictions
confluence/404.vm <- Space and page restrictions (and 404)
Am I allowed to embed my own velocity code in there or does that void my warranty? Is there a less brutal option?
This is what I've got so far. A new template I've added to the confluence directory...
confluence/spaceadmins.vm
#set($querystring=$req.getQueryString()) ##<p>$querystring</p> <!--uncomment for debugging--> #if($querystring) ## Try pulling a spacekey out of the query string #if($querystring.toLowerCase().contains("key=")) #set($pos1=$querystring.toLowerCase().indexOf("key=")+4) #set($pos2=$querystring.indexOf("&",$pos1)) #if($pos2==-1) #set($pos2=$querystring.length()) #end #set($spacekey = $querystring.substring($pos1,$pos2)) #elseif($querystring.contains("pageId=")) #set($pos1=$querystring.indexOf("pageId=")+7) #set($pos2=$querystring.indexOf("&",$pos1)) #set($Integer = 0) #if($pos2==-1) #set($pos2=$querystring.length()) #end #set($pageid = $querystring.substring($pos1,$pos2)) #set($spacekey=$pageManager.getPage($Integer.parseInt($pageid)).getSpaceKey()) #end ## Validate any spacekey we might have gotten #if($spacekey) #set($space=$spaceManager.getSpace($spacekey)) #end #if($space) If you believe this is an error, please contact any of the <a href="$req.contextPath/display/$space.getKey()">$space.getKey()</a> Space Administrators below: <ul> #set($admincount=0) ## List groups... #foreach ($permission in $space.getPermissions()) #if($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS") #set($admincount=$admincount+1) <li> #set ( $groupString = $permission.getGroup() ) #set ( $groupObject = $userAccessor.getGroup($groupString) ) #set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) ) (group) $groupString <a href="javascript:void(0);" onclick="AJS.$('.hidgroup_$admincount').show();AJS.$(this).hide();">[ expand ]</a> <ul class="hidgroup_$admincount" style="display:none"> #foreach ($member in $memberList) #if(!$userAccessor.isDeactivated($member)) <li>#usernameLink($member)</li> #end #end </ul> </li> #end #end ## List users... #foreach ($permission in $space.getPermissions()) #if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS") #if(!$userAccessor.isDeactivated($permission.getUserName())) #set($admincount=$admincount+1) <li>#usernameLink($permission.getUserName())</li> #end #end #end </ul> #if ($admincount==0) <p> No space administrators found, this space may have been deleted or abandoned. You may report this issue to the <a href="$req.contextPath/contactadministrators.action">Site Administrators</a>. </p> #end #end #end
Then I add this to the templates where ever it seems like a good place to list space admins:
#parse ( "/spaceadmins.vm" )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.