function user_has_permission

6.x user_has_permission($permission = "", $account = NULL)
4.x user_has_permission($permission)
5.x user_has_permission($permission, $account = NULL)

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


String $permission:

69 calls to user_has_permission()
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/
This form lets the user edit details about a course.
admin_edit_course_form_submit in modules/admin/
admin_edit_degree_form in modules/admin/
Meant to replace the old-fashioned display_edit_degree function...
admin_edit_degree_form_submit in modules/admin/

... See full list


includes/, line 2799
This file contains misc functions for FlightPath


function user_has_permission($permission = "", $account = NULL) {
  global $user;

  if ($account == NULL) {
    $account = $user;
  //fpm("checking permission $permission");

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

  if (!isset($account->permissions) || !is_array($account->permissions)) {
    return FALSE; // not set up yet; anonymous user most likely.

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

  return FALSE;