Introduces grant_bp_moderate() to testcase

In some cases, we have to test on the fly whether a given user has the
bp_moderate cap. This utility method makes it easy to do so in the unit
tests. Note that this implementation depends on using bp_current_user_can(),
rather than the WP equivalent.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@7364 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
Fix hidden xprofile fields for admins

XProfile field visibility was not being calculated correctly for admins,
due to incorrect logic in bp_xprofile_get_hidden_fields_for_user(). This
changeset clears up the logic, by moving the bp_moderate check earlier
in the flow.

To make the changes easier to implement and to test, this changeset also
breaks the calculation of visibility levels for a user-user pair into
a separate function, bp_xprofile_get_hidden_field_types_for_user().

Also introduces unit tests for the latter function.

Fixes #4984

Props imath

git-svn-id: https://buddypress.svn.wordpress.org/trunk@7365 cdf35c40-ae34-48e0-9cc9-0c9da1808c22