PHP code to find out the roles of logged in user.

is there any build in PHP function in Moodle 2.5.2, which can be used to find out what roles posses the logged in user? I need to have this functionality already on the mainpage and not in course, therefore such function such aus has_capability() does not help me in this case.

I want to find out, whether the logged in person have only the student rights.

However, you are almost certainly approaching this the wrong way. You do not want to think it terms of what roles a user has, you should be thinking in terms of what capabilities a user has in a given context.

If you ask "is teacher()" then what happens if you copy the teacher role?