The macro defined below works as intended in it's source page (such as footer) but when the footer is rendered in a page which includes the footer it fails. It appears the script cannot detect the context. Any ideas why this doesn't work.
Source Page:

Target Page

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 28/04/2012
## Installed by: <your name>
## Macro to list all users and groups with the permission to administer the current space.
## @noparams
<h3>Space Adminstrators</h3>
<p>The following users and groups have permission to administer the <strong>$space.getName()</strong> Space.</p>
<h4>Users</h4>
<ul>
#foreach ($permission in $space.getPermissions())
#if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
<li> #usernameLink($permission.getUserName())</li>
#end
</ul>
#end
</table>
<h4>Groups</h4>
#foreach ($permission in $space.getPermissions())
#if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ( $groupString = $permission.getGroup() )
#set ( $groupObject = $userAccessor.getGroup($groupString) )
#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
<h5>$groupString</h5>
<ul>
#foreach ($member in $memberList)
<li>#usernameLink($member)</li>
#end
</ul>
#end
#end