thanks Paul Holden but all the three are not working to check whether the admin is logged in or not in moodle2.0 ,as i want to display the category names which are assigned to that user only in index page but admin should display all categories so in that i need to use this code so,i need help in this regard.
The traditional admin check is:
has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))
You can also use require_capability (when processing requests which should give an error if users don't have this permission).
--sam
PS There might be some specific cases where you need to know if a user is the primary admin, but actually I can't think of any except some already handled in core code...
There are plenty of capabilities that a teacher will have but a student won't, e.g. the ability to edit the course page, or the ability to enter grades. Following Sam's instructions will show you which particular capabilities to look for programatically.
If you're trying to establish the role of a user whereever they are (i.e. not just within a partiuclar course) you'll need to assign them a role in the system context and check for a capaibility given to that role.