Hi Julie,
Based on the same logic as before here is a possible solution – albeit a quick & dirty one…
SELECT
documents.prefix AS 'Document Prefix',
documents.revision AS 'Revision',
roles.name AS 'Role Name',
templates.name AS 'Instantiated Template',
CASE WHEN permission & 1 > 0 THEN 'Yes' ELSE 'No' END AS 'View',
CASE WHEN permission & 2 > 0 THEN 'Yes' ELSE 'No' END AS 'Modify',
CASE WHEN permission & 16 > 0 THEN 'Yes' ELSE 'No' END AS 'Delete',
CASE WHEN permission & 4 > 0 THEN 'Yes' ELSE 'No' END AS 'Approve'
FROM
perm_gb_roles
INNER JOIN roles ON perm_gb_roles.role_id = roles.role_id
INNER JOIN documents ON perm_gb_roles.object_id = documents.document_id
LEFT OUTER JOIN instantiated_templates ON perm_gb_roles.object_id = instantiated_templates.object_id
AND instantiated_templates.object_type = '3'
LEFT OUTER JOIN templates ON instantiated_templates.template_id = templates.template_id
WHERE
perm_gb_roles.object_type = '3'
As before no guarantees it works, but again might give you some pointers to help you get started.
(It gets strange results when the ‘Everyone’ group is used)
Cheers,
Andy.