@espenmn relying on the roles is an error prone way of doing this. Because it depends if someone has been explicitly given that role or not. For example someone might only have authenticated and member roles but not the reader role. However every other user might also have authenticated and member so it doesn't work to differentiate them.
Checking actual permissions a user has is the only full proof way but there isn't a body tag for that. The body tag for permission that is shown is the permission required by the object to view this particular view.
The best replacement I'd suggest is looking inside the html of the toolbar itself and seeing if the contents menu item is there and only showing the toolbar if it is. Not great but I can't think of a better hack for <5.1. ie diazo if you have the toolbar but without .contentview-folderContents then drop the toolbar?