On user profiles the maildisplay property always using straight integers. For example
if ($user->maildisplay == 2 && is_enrolled($context, $user))
This makes the code unnecessarily hard to read. Constants should be used.
The values are:
0 hide my email address
1 allow everyone to see my email address
2 only allow other users in a course with me to see my email address