You are here

function flag_flag::user_access in Flag 6.2

Same name and namespace in other branches
  1. 5 flag.inc \flag_flag::user_access()
  2. 6 flag.inc \flag_flag::user_access()
  3. 7.3 includes/flag/flag_flag.inc \flag_flag::user_access()
  4. 7.2 flag.inc \flag_flag::user_access()

Determines whether the user has access to use this flag.

Parameters

$action: Optional. The action to test, either "flag" or "unflag". If none given, "flag" will be tested, which is the minimum permission to use a flag.

$account: Optional. The user object. If none given, the current user will be used.

Return value

Boolean TRUE if the user is allowed to flag/unflag. FALSE otherwise.

2 calls to flag_flag::user_access()
flag_flag::access in ./flag.inc
Determines whether the user may flag, or unflag, the given content.
flag_flag::access_multiple in ./flag.inc
Determine access to multiple objects.

File

./flag.inc, line 435
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function user_access($action = 'flag', $account = NULL) {
  if (!isset($account)) {
    $account = $GLOBALS['user'];
  }

  // Anonymous user can't use this system unless Session API is installed.
  if ($account->uid == 0 && !module_exists('session_api')) {
    return FALSE;
  }
  $matched_roles = array_intersect($this->roles[$action], array_keys($account->roles));
  return !empty($matched_roles) || $account->uid == 1;
}