user_has_permission

5.x misc.inc user_has_permission($permission)
4.x misc.inc user_has_permission($permission)

Returns TRUE or FALSE if the logged in user has access based on the permission supplied.

Parameters

String $permission:

46 calls to user_has_permission()
admin_display_edit_degree in modules/admin/admin.degrees.inc
This screen displays the form which allows the user to actually edit a degree.
admin_display_main in modules/admin/admin.module
This is the "main" page for the admin module. It's what the user first sees when the click to go to the Admin page.
admin_edit_course_form in modules/admin/admin.courses.inc
This form lets the user edit details about a course.
admin_edit_course_form_submit in modules/admin/admin.courses.inc
admin_edit_degree_form in modules/admin/admin.degrees.inc
Meant to replace the old-fashioned display_edit_degree function...

... See full list

File

includes/misc.inc, line 1986
This file contains misc functions for FlightPath

Code

function user_has_permission($permission) {
  global $user;

  //fpm("checking permission $permission");

  // If the user is admin (id == 1) then they always have access.
  if ($user->id == 1) {
    return TRUE;
  }


  // Otherwise, simply check their permissions array.
  if (in_array($permission, $user->permissions)) {
    return TRUE;
  }


  return FALSE;

}