bound export functionality to addAttachment permission (verifying the right when rendering now). Some cleanups